Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider. Critical: 0 · High: 1 · Medium: 0 · Low: 1 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [High] net/mlx5e: mlx5i_pkey_dev_init() breaks default RTNL IPoIB child creation - [Low] The commit message describes the bug only as a startup race: the child QPN is attached by mlx5_fs_add_rx_underlay_qpn() in… -- net/mlx5e: preallocate child PKEY channel_stats at init This commit preallocates the child PKEY interface's channel_stats[] entries in mlx5i_pkey_dev_init(), sized to the parent's channel count, before the child's QPN is added to the hash table. It also replaces the num_rx_queues check with a check that the child's max_nch is not lower than the parent's params.num_channels.
> mlx5i_complete_rx_cqe() uses the parent's rq->ix to index the child PKEY > priv's channel_stats[]. The child's entries are allocated lazily in > mlx5e_open_channels(), called from mlx5i_pkey_open(). Once the QPN is > attached by mlx5_fs_add_rx_underlay_qpn(), the parent's NAPI can receive > packets for the child before its channel_stats entries exist, and > dereferences a NULL pointer.
[Severity: Low] This isn't a bug, but does the commit message describe only part of what the patch fixes? It explains a startup race. There also seems to be a second case that is deterministic. In drivers/net/ethernet/mellanox/mlx5/core/en_main.c, mlx5e_build_nic_params() sets the child's channel count once: params->num_channels = min_t(unsigned int, MLX5E_MAX_NUM_CHANNELS / 2, priv->max_nch); mlx5i_pkey_ethtool_ops has no .set_channels, so the child never goes above 128 channels. The parent can still be raised above 128 with ethtool -L, through mlx5i_set_channels()->mlx5e_ethtool_set_channels(). This is allowed while it has no sub-interfaces, on hosts with more than 128 completion vectors. A child created after that only allocates channel_stats[0..127], through mlx5e_open_channel()->mlx5e_channel_stats_alloc(). The child QPN is steered through the parent's RSS, so mlx5i_complete_rx_cqe() in en_rx.c would run: stats = &priv->channel_stats[rq->ix]->rq; For any parent rq->ix >= 128 that entry is NULL. The dereference happens on every such packet, not only during startup. The old check, dev->num_rx_queues < parent_dev->real_num_rx_queues, did not catch this. The child's num_rx_queues is the device maximum from mlx5e_get_max_num_channels(), not its real channel count. The new mlx5e_channel_stats_prealloc(priv, nch) call in mlx5i_pkey_dev_init() uses the parent's params.num_channels, so it fixes this case too. Could the commit message also describe this case, so that it can be matched against crash reports and assessed for stable backports? [ ... ]
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib_vlan.c b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib_vlan.c > --- a/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib_vlan.c > +++ b/drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib_vlan.c > @@ -172,15 +174,22 @@ static int mlx5i_pkey_dev_init(struct net_device *dev) > return -EINVAL; > } > > - if (dev->num_rx_queues < parent_dev->real_num_rx_queues) { > + parent_priv = mlx5i_epriv(parent_dev); > + nch = parent_priv->channels.params.num_channels; > + if (priv->max_nch < nch) { > mlx5_core_warn(priv->mdev, > - "failed to create child device with rx queues [%d] less than parent's [%d]\n", > - dev->num_rx_queues, > - parent_dev->real_num_rx_queues); > + "failed to create child device with max channel count [%d] less than parent's [%d]\n", > + priv->max_nch, nch); > mlx5i_parent_put(dev); > return -EINVAL; > } > > + err = mlx5e_channel_stats_prealloc(priv, nch); > + if (err) { > + mlx5i_parent_put(dev); > + return err; > + } > + > /* Get QPN to netdevice hash table from parent */ > parent_ipriv = netdev_priv(parent_dev); > ipriv->qpn_htbl = parent_ipriv->qpn_htbl;
[Severity: High] Does this new check reject child creation through the default netlink path on common ConnectX parts? For ip link add ... type ipoib pkey ..., rtnl_create_link() sizes the child through ipoib_link_ops. ipoib_get_max_num_queues() returns min(num_possible_cpus(), 128) for both num_tx_queues and num_rx_queues, so the child gets no extra tx queue headroom. The parent is allocated through mlx5_rdma_rn_get_params() with txqs = nch * MLX5_MAX_NUM_TC, so its tx queue count does not trim its max_nch. mlx5e_build_nic_params() then gives it num_channels = min(128, max_nch). When the host has at least as many completion vectors as CPUs, that equals the child's queue count. For the child, mlx5e_calc_max_nch() starts from netdev->num_tx_queues. It subtracts mlx5e_qos_max_leaf_nodes() when mlx5_qos_is_supported() is true, and profile->max_tc when ts_cqe_to_dest_cqn is set. Unlike mlx5e_get_max_num_txqs(), it does not check mlx5e_profile_feature_cap(profile, QOS_HTB) or PTP_TX. mlx5i_pkey_nic_profile sets no features at all. On an HCA that advertises ts_cqe_to_dest_cqn, the child's priv->max_nch therefore ends up at least one below the parent's params.num_channels. The old num_rx_queues < real_num_rx_queues comparison passed in that configuration. With the new priv->max_nch < nch test, mlx5i_pkey_dev_init() returns -EINVAL and the child cannot be created. channel_stats[] really is sized by max_nch, so the check itself looks right. The miscount seems to be in mlx5e_calc_max_nch(). Should that function gate the QoS and PTP subtractions on the profile features, as mlx5e_get_max_num_txqs() does, as part of this fix? It may also want a guard against the unsigned tmp underflowing when the leaf node count exceeds num_tx_queues. Was this tested with ip link add, using default queue counts, on a ConnectX-5 or later?
-- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/axEq…%40eaujamesFR0130