summaryrefslogtreecommitdiff
path: root/drivers/net/mlx5/mlx5_mr.c
diff options
context:
space:
mode:
authorYongseok Koh <yskoh@mellanox.com>2018-05-09 04:04:50 -0700
committerFerruh Yigit <ferruh.yigit@intel.com>2018-05-14 22:31:51 +0100
commitdf428ceef4fdbceacda8d50341c25ddd46a76a39 (patch)
tree22f0275c40b0130593b4b1c6f20ebb633af0e577 /drivers/net/mlx5/mlx5_mr.c
parentce07b1514d5961baf59ead7d030b522eb06ea527 (diff)
downloaddpdk-next-eventdev-df428ceef4fdbceacda8d50341c25ddd46a76a39.zip
dpdk-next-eventdev-df428ceef4fdbceacda8d50341c25ddd46a76a39.tar.gz
dpdk-next-eventdev-df428ceef4fdbceacda8d50341c25ddd46a76a39.tar.xz
net/mlx5: change device reference for secondary process
rte_eth_devices[] is not shared between primary and secondary process, but a static array to each process. The reverse pointer of device (priv->dev) is invalid. Instead, priv has the pointer to shared data of the device, struct rte_eth_dev_data *dev_data; Two macros are added, #define PORT_ID(priv) ((priv)->dev_data->port_id) #define ETH_DEV(priv) (&rte_eth_devices[PORT_ID(priv)]) Signed-off-by: Yongseok Koh <yskoh@mellanox.com>
Diffstat (limited to 'drivers/net/mlx5/mlx5_mr.c')
-rw-r--r--drivers/net/mlx5/mlx5_mr.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/drivers/net/mlx5/mlx5_mr.c b/drivers/net/mlx5/mlx5_mr.c
index 1b4c7ec..48ac84b 100644
--- a/drivers/net/mlx5/mlx5_mr.c
+++ b/drivers/net/mlx5/mlx5_mr.c
@@ -105,8 +105,8 @@ mlx5_txq_mp2mr_reg(struct mlx5_txq_data *txq, struct rte_mempool *mp,
rte_spinlock_lock(&txq_ctrl->priv->mr_lock);
/* Add a new entry, register MR first. */
DRV_LOG(DEBUG, "port %u discovered new memory pool \"%s\" (%p)",
- txq_ctrl->priv->dev->data->port_id, mp->name, (void *)mp);
- dev = txq_ctrl->priv->dev;
+ PORT_ID(txq_ctrl->priv), mp->name, (void *)mp);
+ dev = ETH_DEV(txq_ctrl->priv);
mr = mlx5_mr_get(dev, mp);
if (mr == NULL) {
if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
@@ -114,8 +114,7 @@ mlx5_txq_mp2mr_reg(struct mlx5_txq_data *txq, struct rte_mempool *mp,
"port %u using unregistered mempool 0x%p(%s)"
" in secondary process, please create mempool"
" before rte_eth_dev_start()",
- txq_ctrl->priv->dev->data->port_id,
- (void *)mp, mp->name);
+ PORT_ID(txq_ctrl->priv), (void *)mp, mp->name);
rte_spinlock_unlock(&txq_ctrl->priv->mr_lock);
rte_errno = ENOTSUP;
return NULL;
@@ -126,7 +125,7 @@ mlx5_txq_mp2mr_reg(struct mlx5_txq_data *txq, struct rte_mempool *mp,
DRV_LOG(DEBUG,
"port %u unable to configure memory region,"
" ibv_reg_mr() failed.",
- txq_ctrl->priv->dev->data->port_id);
+ PORT_ID(txq_ctrl->priv));
rte_spinlock_unlock(&txq_ctrl->priv->mr_lock);
return NULL;
}
@@ -135,7 +134,7 @@ mlx5_txq_mp2mr_reg(struct mlx5_txq_data *txq, struct rte_mempool *mp,
DRV_LOG(DEBUG,
"port %u memory region <-> memory pool table full, "
" dropping oldest entry",
- txq_ctrl->priv->dev->data->port_id);
+ PORT_ID(txq_ctrl->priv));
--idx;
mlx5_mr_release(txq->mp2mr[0]);
memmove(&txq->mp2mr[0], &txq->mp2mr[1],
@@ -146,7 +145,7 @@ mlx5_txq_mp2mr_reg(struct mlx5_txq_data *txq, struct rte_mempool *mp,
DRV_LOG(DEBUG,
"port %u new memory region lkey for MP \"%s\" (%p): 0x%08"
PRIu32,
- txq_ctrl->priv->dev->data->port_id, mp->name, (void *)mp,
+ PORT_ID(txq_ctrl->priv), mp->name, (void *)mp,
txq_ctrl->txq.mp2mr[idx]->lkey);
rte_spinlock_unlock(&txq_ctrl->priv->mr_lock);
return mr;
@@ -207,15 +206,15 @@ mlx5_mp2mr_iter(struct rte_mempool *mp, void *arg)
if (rte_mempool_obj_iter(mp, txq_mp2mr_mbuf_check, &data) == 0 ||
data.ret == -1)
return;
- mr = mlx5_mr_get(priv->dev, mp);
+ mr = mlx5_mr_get(ETH_DEV(priv), mp);
if (mr) {
mlx5_mr_release(mr);
return;
}
- mr = mlx5_mr_new(priv->dev, mp);
+ mr = mlx5_mr_new(ETH_DEV(priv), mp);
if (!mr)
DRV_LOG(ERR, "port %u cannot create memory region: %s",
- priv->dev->data->port_id, strerror(rte_errno));
+ PORT_ID(priv), strerror(rte_errno));
}
/**