Skip to content

Commit

Permalink
net/mlx5: fix port attach in secondary process
Browse files Browse the repository at this point in the history
[ upstream commit 2b36c30 ]

Currently, the secondary process port UAR register mapping used by Tx
queue is done during port initializing.

Unluckily, in port hot-plug case, the secondary process was requested
to initialize the port when primary process did not complete the
device configuration and the port Tx queue number is not configured
yet. Hence, the secondary process gets the zero Tx queue number during
probing, causing the UAR registers not be mapped in the correct
fashion.

This commit checks the configured number of Tx queues in secondary
process when the port start is requested. In case the Tx queue
number mismatch found the UAR mapping is reinitialized accordingly.

Fixes: 2aac5b5 ("net/mlx5: sync stop/start with secondary process")

Signed-off-by: Suanming Mou <suanmingm@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
  • Loading branch information
smou-mlnx authored and bluca committed Feb 4, 2021
1 parent 293737e commit 432de5a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
19 changes: 19 additions & 0 deletions drivers/net/mlx5/linux/mlx5_mp_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ struct rte_mp_msg mp_res;
const struct mlx5_mp_param *param =
(const struct mlx5_mp_param *)mp_msg->param;
struct rte_eth_dev *dev;
struct mlx5_proc_priv *ppriv;
struct mlx5_priv *priv;
int ret;

Expand All @@ -132,6 +133,20 @@ struct rte_mp_msg mp_res;
rte_mb();
dev->rx_pkt_burst = mlx5_select_rx_function(dev);
dev->tx_pkt_burst = mlx5_select_tx_function(dev);
ppriv = (struct mlx5_proc_priv *)dev->process_private;
/* If Tx queue number changes, re-initialize UAR. */
if (ppriv->uar_table_sz != priv->txqs_n) {
mlx5_tx_uar_uninit_secondary(dev);
mlx5_proc_priv_uninit(dev);
ret = mlx5_proc_priv_init(dev);
if (ret)
return -rte_errno;
ret = mlx5_tx_uar_init_secondary(dev, mp_msg->fds[0]);
if (ret) {
mlx5_proc_priv_uninit(dev);
return -rte_errno;
}
}
mp_init_msg(&priv->mp_id, &mp_res, param->type);
res->result = 0;
ret = rte_mp_reply(&mp_res, peer);
Expand Down Expand Up @@ -183,6 +198,10 @@ mp_req_on_rxtx(struct rte_eth_dev *dev, enum mlx5_mp_req_type type)
return;
}
mp_init_msg(&priv->mp_id, &mp_req, type);
if (type == MLX5_MP_REQ_START_RXTX) {
mp_req.num_fds = 1;
mp_req.fds[0] = ((struct ibv_context *)priv->sh->ctx)->cmd_fd;
}
ret = rte_mp_request_sync(&mp_req, &mp_rep, &ts);
if (ret) {
if (rte_errno != ENOTSUP)
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/mlx5/mlx5.c
Original file line number Diff line number Diff line change
Expand Up @@ -1264,7 +1264,7 @@ mlx5_proc_priv_init(struct rte_eth_dev *dev)
* @param dev
* Pointer to Ethernet device structure.
*/
static void
void
mlx5_proc_priv_uninit(struct rte_eth_dev *dev)
{
if (!dev->process_private)
Expand Down
6 changes: 5 additions & 1 deletion drivers/net/mlx5/mlx5.h
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,10 @@ struct mlx5_dev_ctx_shared {
struct mlx5_dev_shared_port port[]; /* per device port data array. */
};

/* Per-process private structure. */
/*
* Per-process private structure.
* Caution, secondary process may rebuild the struct during port start.
*/
struct mlx5_proc_priv {
size_t uar_table_sz;
/* Size of UAR register table. */
Expand Down Expand Up @@ -1004,6 +1007,7 @@ struct rte_hairpin_peer_info {

int mlx5_getenv_int(const char *);
int mlx5_proc_priv_init(struct rte_eth_dev *dev);
void mlx5_proc_priv_uninit(struct rte_eth_dev *dev);
int mlx5_udp_tunnel_port_add(struct rte_eth_dev *dev,
struct rte_eth_udp_tunnel *udp_tunnel);
uint16_t mlx5_eth_find_next(uint16_t port_id, struct rte_pci_device *pci_dev);
Expand Down

0 comments on commit 432de5a

Please sign in to comment.