Commit 082a9edf authored by Maxim Mikityanskiy's avatar Maxim Mikityanskiy Committed by Jakub Kicinski

net/mlx5e: xsk: Flush RQ on XSK activation to save memory

The regular RQ remains open after opening an XSK socket, in order to
guarantee that closing the XSK socket never fails due to an error when
reopening the regular RQ.

To save memory, the regular RQ can be deactivated and flushed, releasing
all pages, when an XSK socket is open.
Signed-off-by: default avatarMaxim Mikityanskiy <maximmi@nvidia.com>
Reviewed-by: default avatarTariq Toukan <tariqt@nvidia.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent a4388da5
...@@ -1036,6 +1036,7 @@ struct mlx5e_rq_param; ...@@ -1036,6 +1036,7 @@ struct mlx5e_rq_param;
int mlx5e_open_rq(struct mlx5e_params *params, struct mlx5e_rq_param *param, int mlx5e_open_rq(struct mlx5e_params *params, struct mlx5e_rq_param *param,
struct mlx5e_xsk_param *xsk, int node, struct mlx5e_xsk_param *xsk, int node,
struct mlx5e_rq *rq); struct mlx5e_rq *rq);
#define MLX5E_RQ_WQES_TIMEOUT 20000 /* msecs */
int mlx5e_wait_for_min_rx_wqes(struct mlx5e_rq *rq, int wait_time); int mlx5e_wait_for_min_rx_wqes(struct mlx5e_rq *rq, int wait_time);
void mlx5e_close_rq(struct mlx5e_rq *rq); void mlx5e_close_rq(struct mlx5e_rq *rq);
int mlx5e_create_rq(struct mlx5e_rq *rq, struct mlx5e_rq_param *param); int mlx5e_create_rq(struct mlx5e_rq *rq, struct mlx5e_rq_param *param);
......
...@@ -126,6 +126,9 @@ static int mlx5e_xsk_enable_locked(struct mlx5e_priv *priv, ...@@ -126,6 +126,9 @@ static int mlx5e_xsk_enable_locked(struct mlx5e_priv *priv,
mlx5e_rx_res_xsk_update(priv->rx_res, &priv->channels, ix, true); mlx5e_rx_res_xsk_update(priv->rx_res, &priv->channels, ix, true);
mlx5e_deactivate_rq(&c->rq);
mlx5e_flush_rq(&c->rq, MLX5_RQC_STATE_RDY);
return 0; return 0;
err_remove_pool: err_remove_pool:
...@@ -165,7 +168,13 @@ static int mlx5e_xsk_disable_locked(struct mlx5e_priv *priv, u16 ix) ...@@ -165,7 +168,13 @@ static int mlx5e_xsk_disable_locked(struct mlx5e_priv *priv, u16 ix)
goto remove_pool; goto remove_pool;
c = priv->channels.c[ix]; c = priv->channels.c[ix];
mlx5e_activate_rq(&c->rq);
mlx5e_trigger_napi_icosq(c);
mlx5e_wait_for_min_rx_wqes(&c->rq, MLX5E_RQ_WQES_TIMEOUT);
mlx5e_rx_res_xsk_update(priv->rx_res, &priv->channels, ix, false); mlx5e_rx_res_xsk_update(priv->rx_res, &priv->channels, ix, false);
mlx5e_deactivate_xsk(c); mlx5e_deactivate_xsk(c);
mlx5e_close_xsk(c); mlx5e_close_xsk(c);
......
...@@ -2408,10 +2408,11 @@ static void mlx5e_activate_channel(struct mlx5e_channel *c) ...@@ -2408,10 +2408,11 @@ static void mlx5e_activate_channel(struct mlx5e_channel *c)
mlx5e_activate_txqsq(&c->sq[tc]); mlx5e_activate_txqsq(&c->sq[tc]);
mlx5e_activate_icosq(&c->icosq); mlx5e_activate_icosq(&c->icosq);
mlx5e_activate_icosq(&c->async_icosq); mlx5e_activate_icosq(&c->async_icosq);
mlx5e_activate_rq(&c->rq);
if (test_bit(MLX5E_CHANNEL_STATE_XSK, c->state)) if (test_bit(MLX5E_CHANNEL_STATE_XSK, c->state))
mlx5e_activate_xsk(c); mlx5e_activate_xsk(c);
else
mlx5e_activate_rq(&c->rq);
mlx5e_trigger_napi_icosq(c); mlx5e_trigger_napi_icosq(c);
} }
...@@ -2422,8 +2423,9 @@ static void mlx5e_deactivate_channel(struct mlx5e_channel *c) ...@@ -2422,8 +2423,9 @@ static void mlx5e_deactivate_channel(struct mlx5e_channel *c)
if (test_bit(MLX5E_CHANNEL_STATE_XSK, c->state)) if (test_bit(MLX5E_CHANNEL_STATE_XSK, c->state))
mlx5e_deactivate_xsk(c); mlx5e_deactivate_xsk(c);
else
mlx5e_deactivate_rq(&c->rq); mlx5e_deactivate_rq(&c->rq);
mlx5e_deactivate_icosq(&c->async_icosq); mlx5e_deactivate_icosq(&c->async_icosq);
mlx5e_deactivate_icosq(&c->icosq); mlx5e_deactivate_icosq(&c->icosq);
for (tc = 0; tc < c->num_tc; tc++) for (tc = 0; tc < c->num_tc; tc++)
...@@ -2515,8 +2517,6 @@ static void mlx5e_activate_channels(struct mlx5e_channels *chs) ...@@ -2515,8 +2517,6 @@ static void mlx5e_activate_channels(struct mlx5e_channels *chs)
mlx5e_ptp_activate_channel(chs->ptp); mlx5e_ptp_activate_channel(chs->ptp);
} }
#define MLX5E_RQ_WQES_TIMEOUT 20000 /* msecs */
static int mlx5e_wait_channels_min_rx_wqes(struct mlx5e_channels *chs) static int mlx5e_wait_channels_min_rx_wqes(struct mlx5e_channels *chs)
{ {
int err = 0; int err = 0;
...@@ -2524,8 +2524,12 @@ static int mlx5e_wait_channels_min_rx_wqes(struct mlx5e_channels *chs) ...@@ -2524,8 +2524,12 @@ static int mlx5e_wait_channels_min_rx_wqes(struct mlx5e_channels *chs)
for (i = 0; i < chs->num; i++) { for (i = 0; i < chs->num; i++) {
int timeout = err ? 0 : MLX5E_RQ_WQES_TIMEOUT; int timeout = err ? 0 : MLX5E_RQ_WQES_TIMEOUT;
struct mlx5e_channel *c = chs->c[i];
if (test_bit(MLX5E_CHANNEL_STATE_XSK, c->state))
continue;
err |= mlx5e_wait_for_min_rx_wqes(&chs->c[i]->rq, timeout); err |= mlx5e_wait_for_min_rx_wqes(&c->rq, timeout);
/* Don't wait on the XSK RQ, because the newer xdpsock sample /* Don't wait on the XSK RQ, because the newer xdpsock sample
* doesn't provide any Fill Ring entries at the setup stage. * doesn't provide any Fill Ring entries at the setup stage.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment