mlx5 still refuses queue restarts with an XDP program, and its page
pools take no provider next to XDP.
Let striding RQs with a program take XDP-only providers, and accept
queue restarts with one, as other providers refuse XDP. Binds on the
cyclic RQ fail, as it would spin on a short FILL ring.
While a queue has such a provider, refuse with -EBUSY:
- a switch to the cyclic RQ;
- PTP RX, TX port timestamps and HTB offload, as queue restarts clone
no channel under them, so unbind would fail and binds fail with
-EOPNOTSUPP;
- growing the RQs of a device that is down, which would fail the next
open.
A devlink eswitch mode change bypasses these checks, leaving the queue
on system pages that the socket drops.
At MTU 1500, the linear RQ puts one packet per 4 KiB chunk. The
nonlinear RQ puts every byte in fragments, so its head reaches the
socket only with metadata. A bind or unbind pauses all channels
briefly.
Signed-off-by: Björn Töpel <bjo…@kernel.org>
---
Notes (v2changes):
Changes in v2:
- Move the skip of the wait for posted WQEs to patch 10, and use the
net/mlx5e prefix.
- Let only striding RQs take XDP-only providers. The cyclic RQ posts
whole bulks only, and would spin on a short FILL ring (Sashiko).
- Refuse a switch from the striding RQ to the cyclic one, PTP RX, TX
port timestamps and HTB offload while a queue has such a provider,
and growing the RQs while the device is down (Sashiko).
- The message covers the nonlinear RQ and its empty heads (Sashiko),
and says what users see.
.../net/ethernet/mellanox/mlx5/core/en_main.c | 62 ++++++++++++++++++-
.../net/ethernet/mellanox/mlx5/core/en_rx.c | 10 +--
2 files changed, 64 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index a76ba297c9a9..74a2ae37a587 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -1012,6 +1012,13 @@ static int mlx5e_alloc_rq(struct mlx5e_params *params,
pp_params.order = pool_order;
pp_params.flags = PP_FLAG_DMA_MAP | PP_FLAG_DMA_SYNC_DEV;
+ /* Trap and PTP RQs use queue 0 too, without a program. A
+ * cyclic RQ posts whole bulks only, and would spin in NAPI
+ * on a short FILL ring.
+ */
+ if (params->xdp_prog &&
+ rq->wq_type == MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ)
+ pp_params.flags |= PP_FLAG_ALLOW_XDP_ONLY_NETMEM;
pp_params.pool_size = pool_size;
pp_params.nid = node;
pp_params.dev = rq->pdev;
@@ -3609,6 +3616,46 @@ int mlx5e_safe_switch_params(struct mlx5e_priv *priv,
bool old_first;
int err;
+ /* An XDP-only memory provider takes a striding RQ, and the socket
+ * that installed it would lose its queue without a word, also when
+ * the device opens later
+ */
+ if (priv->channels.params.rq_wq_type ==
+ MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ &&
+ params->rq_wq_type != MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ &&
+ mlx5e_has_xdp_only_mp(priv, priv->netdev->real_num_rx_queues)) {
+ netdev_warn(priv->netdev,
+ "Cannot leave the striding RQ while a queue has an XDP-only memory provider\n");
+ return -EBUSY;
+ }
+
+ /* mlx5e_queue_mem_alloc() clones no channel while PTP is on, so the
+ * provider of any queue could not go: its unbind restarts the queue
+ */
+ if (((params->ptp_rx && !priv->channels.params.ptp_rx) ||
+ (MLX5E_GET_PFLAG(params, MLX5E_PFLAG_TX_PORT_TS) &&
+ !MLX5E_GET_PFLAG(&priv->channels.params,
+ MLX5E_PFLAG_TX_PORT_TS))) &&
+ mlx5e_has_xdp_only_mp(priv, priv->netdev->real_num_rx_queues)) {
+ netdev_warn(priv->netdev,
+ "Cannot turn on PTP while a queue has an XDP-only memory provider\n");
+ return -EBUSY;
+ }
+
+ /* Closed channels open no RQ that would let the provider check a
+ * larger page pool, so the device would fail to open later
+ */
+ if (!test_bit(MLX5E_STATE_OPENED, &priv->state) &&
+ params->rq_wq_type == MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ &&
+ mlx5e_mpwqe_get_log_rq_size(priv->mdev, params, NULL) >
+ mlx5e_mpwqe_get_log_rq_size(priv->mdev, &priv->channels.params,
+ NULL) &&
+ mlx5e_has_xdp_only_mp(priv, priv->netdev->real_num_rx_queues)) {
+ netdev_warn(priv->netdev,
+ "Cannot grow the RQs while the device is down and a queue has an XDP-only memory provider\n");
+ return -EBUSY;
+ }
+
reset &= test_bit(MLX5E_STATE_OPENED, &priv->state);
if (!reset)
return mlx5e_switch_priv_params(priv, params, preactivate, context);
@@ -4166,11 +4213,21 @@ static int mlx5e_setup_tc(struct net_device *dev, enum tc_setup_type type,
err = mlx5e_setup_tc_mqprio(priv, type_data);
mutex_unlock(&priv->state_lock);
return err;
- case TC_SETUP_QDISC_HTB:
+ case TC_SETUP_QDISC_HTB: {
+ struct tc_htb_qopt_offload *htb_qopt = type_data;
+
+ /* As for PTP, see mlx5e_safe_switch_params() */
+ if (htb_qopt->command == TC_HTB_CREATE &&
+ mlx5e_has_xdp_only_mp(priv, dev->real_num_rx_queues)) {
+ NL_SET_ERR_MSG_MOD(htb_qopt->extack,
+ "Cannot offload HTB while a queue has an XDP-only memory provider");
+ return -EBUSY;
+ }
mutex_lock(&priv->state_lock);
err = mlx5e_htb_setup_tc(priv, type_data);
mutex_unlock(&priv->state_lock);
return err;
+ }
default:
return -EOPNOTSUPP;
}
@@ -5872,10 +5929,9 @@ static int mlx5e_queue_mem_alloc(struct net_device *dev,
if (MLX5E_GET_PFLAG(&chs->params, MLX5E_PFLAG_TX_PORT_TS) ||
chs->params.ptp_rx ||
- chs->params.xdp_prog ||
priv->htb) {
netdev_err(priv->netdev,
- "Cloning channels with Port/rx PTP, XDP or HTB is not supported\n");
+ "Cloning channels with Port/rx PTP or HTB is not supported\n");
err = -EOPNOTSUPP;
goto unlock;
}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
index 1586cb2404c0..43a382fcd3ad 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
@@ -327,7 +327,7 @@ static void *mlx5e_mpwqe_get_linear_page_frag(struct mlx5e_rq *rq)
frag_offset = li->frag_page.frags << MLX5E_XDP_LOG_MAX_LINEAR_SZ;
WARN_ON(frag_offset >= BIT(rq->mpwqe.page_shift));
- return netmem_address(li->frag_page.netmem) + frag_offset;
+ return xdp_netmem_address(li->frag_page.netmem) + frag_offset;
}
static inline int mlx5e_get_rx_frag(struct mlx5e_rq *rq,
@@ -1585,7 +1585,7 @@ mlx5e_skb_from_cqe_linear(struct mlx5e_rq *rq, struct mlx5e_wqe_frag_info *wi,
dma_addr_t addr;
u32 frag_size;
- va = netmem_address(frag_page->netmem) + wi->offset;
+ va = xdp_netmem_address(frag_page->netmem) + wi->offset;
data = va + rx_headroom;
frag_size = MLX5_SKB_FRAG_SZ(rx_headroom + cqe_bcnt);
@@ -1640,7 +1640,7 @@ mlx5e_skb_from_cqe_nonlinear(struct mlx5e_rq *rq, struct mlx5e_wqe_frag_info *wi
frag_page = wi->frag_page;
- va = netmem_address(frag_page->netmem) + wi->offset;
+ va = xdp_netmem_address(frag_page->netmem) + wi->offset;
frag_consumed_bytes = min_t(u32, frag_info->frag_size, cqe_bcnt);
addr = page_pool_get_dma_addr_netmem(frag_page->netmem);
@@ -1940,7 +1940,7 @@ mlx5e_skb_from_cqe_mpwrq_nonlinear(struct mlx5e_rq *rq, struct mlx5e_mpw_info *w
prog = rcu_dereference(rq->xdp_prog);
- head_addr = netmem_address(head_page->netmem) + head_offset;
+ head_addr = xdp_netmem_address(head_page->netmem) + head_offset;
if (prog) {
/* area for bpf_xdp_[store|load]_bytes */
@@ -2114,7 +2114,7 @@ mlx5e_skb_from_cqe_mpwrq_linear(struct mlx5e_rq *rq, struct mlx5e_mpw_info *wi,
return NULL;
}
- va = netmem_address(frag_page->netmem) + head_offset;
+ va = xdp_netmem_address(frag_page->netmem) + head_offset;
data = va + rx_headroom;
frag_size = MLX5_SKB_FRAG_SZ(rx_headroom + cqe_bcnt);
--
2.56.1