net/mlx5e: XDP, Change the XDP SQ redirect indication

Do not maintain an SQ state bit to indicate whether an
XDP SQ serves redirect operations.

Instead, rely on the fact that such an XDP SQ doesn't reside
in an RQ instance, while the others do.
This info is not known to the XDP SQ functions themselves,
and they rely on their callers to distinguish between the cases.

Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
This commit is contained in:
Tariq Toukan 2018-11-21 14:04:45 +02:00 committed by Saeed Mahameed
parent 4fb2f51618
commit feb2ff9d74
5 changed files with 18 additions and 26 deletions

View File

@ -344,7 +344,6 @@ enum {
MLX5E_SQ_STATE_IPSEC, MLX5E_SQ_STATE_IPSEC,
MLX5E_SQ_STATE_AM, MLX5E_SQ_STATE_AM,
MLX5E_SQ_STATE_TLS, MLX5E_SQ_STATE_TLS,
MLX5E_SQ_STATE_REDIRECT,
}; };
struct mlx5e_sq_wqe_info { struct mlx5e_sq_wqe_info {

View File

@ -164,11 +164,10 @@ bool mlx5e_xmit_xdp_frame(struct mlx5e_xdpsq *sq, struct mlx5e_xdp_info *xdpi)
return true; return true;
} }
bool mlx5e_poll_xdpsq_cq(struct mlx5e_cq *cq) bool mlx5e_poll_xdpsq_cq(struct mlx5e_cq *cq, struct mlx5e_rq *rq)
{ {
struct mlx5e_xdpsq *sq; struct mlx5e_xdpsq *sq;
struct mlx5_cqe64 *cqe; struct mlx5_cqe64 *cqe;
struct mlx5e_rq *rq;
bool is_redirect; bool is_redirect;
u16 sqcc; u16 sqcc;
int i; int i;
@ -182,8 +181,7 @@ bool mlx5e_poll_xdpsq_cq(struct mlx5e_cq *cq)
if (!cqe) if (!cqe)
return false; return false;
is_redirect = test_bit(MLX5E_SQ_STATE_REDIRECT, &sq->state); is_redirect = !rq;
rq = container_of(sq, struct mlx5e_rq, xdpsq);
/* sq->cc must be updated only after mlx5_cqwq_update_db_record(), /* sq->cc must be updated only after mlx5_cqwq_update_db_record(),
* otherwise a cq overrun may occur * otherwise a cq overrun may occur
@ -228,13 +226,9 @@ bool mlx5e_poll_xdpsq_cq(struct mlx5e_cq *cq)
return (i == MLX5E_TX_CQ_POLL_BUDGET); return (i == MLX5E_TX_CQ_POLL_BUDGET);
} }
void mlx5e_free_xdpsq_descs(struct mlx5e_xdpsq *sq) void mlx5e_free_xdpsq_descs(struct mlx5e_xdpsq *sq, struct mlx5e_rq *rq)
{ {
struct mlx5e_rq *rq; bool is_redirect = !rq;
bool is_redirect;
is_redirect = test_bit(MLX5E_SQ_STATE_REDIRECT, &sq->state);
rq = is_redirect ? NULL : container_of(sq, struct mlx5e_rq, xdpsq);
while (sq->cc != sq->pc) { while (sq->cc != sq->pc) {
u16 ci = mlx5_wq_cyc_ctr2ix(&sq->wq, sq->cc); u16 ci = mlx5_wq_cyc_ctr2ix(&sq->wq, sq->cc);

View File

@ -42,8 +42,8 @@
bool mlx5e_xdp_handle(struct mlx5e_rq *rq, struct mlx5e_dma_info *di, bool mlx5e_xdp_handle(struct mlx5e_rq *rq, struct mlx5e_dma_info *di,
void *va, u16 *rx_headroom, u32 *len); void *va, u16 *rx_headroom, u32 *len);
bool mlx5e_poll_xdpsq_cq(struct mlx5e_cq *cq); bool mlx5e_poll_xdpsq_cq(struct mlx5e_cq *cq, struct mlx5e_rq *rq);
void mlx5e_free_xdpsq_descs(struct mlx5e_xdpsq *sq); void mlx5e_free_xdpsq_descs(struct mlx5e_xdpsq *sq, struct mlx5e_rq *rq);
void mlx5e_xdp_rx_poll_complete(struct mlx5e_rq *rq); void mlx5e_xdp_rx_poll_complete(struct mlx5e_rq *rq);
bool mlx5e_xmit_xdp_frame(struct mlx5e_xdpsq *sq, struct mlx5e_xdp_info *xdpi); bool mlx5e_xmit_xdp_frame(struct mlx5e_xdpsq *sq, struct mlx5e_xdp_info *xdpi);
int mlx5e_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **frames, int mlx5e_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **frames,

View File

@ -1577,8 +1577,6 @@ static int mlx5e_open_xdpsq(struct mlx5e_channel *c,
csp.cqn = sq->cq.mcq.cqn; csp.cqn = sq->cq.mcq.cqn;
csp.wq_ctrl = &sq->wq_ctrl; csp.wq_ctrl = &sq->wq_ctrl;
csp.min_inline_mode = sq->min_inline_mode; csp.min_inline_mode = sq->min_inline_mode;
if (is_redirect)
set_bit(MLX5E_SQ_STATE_REDIRECT, &sq->state);
set_bit(MLX5E_SQ_STATE_ENABLED, &sq->state); set_bit(MLX5E_SQ_STATE_ENABLED, &sq->state);
err = mlx5e_create_sq_rdy(c->mdev, param, &csp, &sq->sqn); err = mlx5e_create_sq_rdy(c->mdev, param, &csp, &sq->sqn);
if (err) if (err)
@ -1612,7 +1610,7 @@ static int mlx5e_open_xdpsq(struct mlx5e_channel *c,
return err; return err;
} }
static void mlx5e_close_xdpsq(struct mlx5e_xdpsq *sq) static void mlx5e_close_xdpsq(struct mlx5e_xdpsq *sq, struct mlx5e_rq *rq)
{ {
struct mlx5e_channel *c = sq->channel; struct mlx5e_channel *c = sq->channel;
@ -1620,7 +1618,7 @@ static void mlx5e_close_xdpsq(struct mlx5e_xdpsq *sq)
napi_synchronize(&c->napi); napi_synchronize(&c->napi);
mlx5e_destroy_sq(c->mdev, sq->sqn); mlx5e_destroy_sq(c->mdev, sq->sqn);
mlx5e_free_xdpsq_descs(sq); mlx5e_free_xdpsq_descs(sq, rq);
mlx5e_free_xdpsq(sq); mlx5e_free_xdpsq(sq);
} }
@ -2008,7 +2006,7 @@ static int mlx5e_open_channel(struct mlx5e_priv *priv, int ix,
err_close_xdp_sq: err_close_xdp_sq:
if (c->xdp) if (c->xdp)
mlx5e_close_xdpsq(&c->rq.xdpsq); mlx5e_close_xdpsq(&c->rq.xdpsq, &c->rq);
err_close_sqs: err_close_sqs:
mlx5e_close_sqs(c); mlx5e_close_sqs(c);
@ -2061,10 +2059,10 @@ static void mlx5e_deactivate_channel(struct mlx5e_channel *c)
static void mlx5e_close_channel(struct mlx5e_channel *c) static void mlx5e_close_channel(struct mlx5e_channel *c)
{ {
mlx5e_close_xdpsq(&c->xdpsq); mlx5e_close_xdpsq(&c->xdpsq, NULL);
mlx5e_close_rq(&c->rq); mlx5e_close_rq(&c->rq);
if (c->xdp) if (c->xdp)
mlx5e_close_xdpsq(&c->rq.xdpsq); mlx5e_close_xdpsq(&c->rq.xdpsq, &c->rq);
mlx5e_close_sqs(c); mlx5e_close_sqs(c);
mlx5e_close_icosq(&c->icosq); mlx5e_close_icosq(&c->icosq);
napi_disable(&c->napi); napi_disable(&c->napi);

View File

@ -76,6 +76,7 @@ int mlx5e_napi_poll(struct napi_struct *napi, int budget)
struct mlx5e_channel *c = container_of(napi, struct mlx5e_channel, struct mlx5e_channel *c = container_of(napi, struct mlx5e_channel,
napi); napi);
struct mlx5e_ch_stats *ch_stats = c->stats; struct mlx5e_ch_stats *ch_stats = c->stats;
struct mlx5e_rq *rq = &c->rq;
bool busy = false; bool busy = false;
int work_done = 0; int work_done = 0;
int i; int i;
@ -85,17 +86,17 @@ int mlx5e_napi_poll(struct napi_struct *napi, int budget)
for (i = 0; i < c->num_tc; i++) for (i = 0; i < c->num_tc; i++)
busy |= mlx5e_poll_tx_cq(&c->sq[i].cq, budget); busy |= mlx5e_poll_tx_cq(&c->sq[i].cq, budget);
busy |= mlx5e_poll_xdpsq_cq(&c->xdpsq.cq); busy |= mlx5e_poll_xdpsq_cq(&c->xdpsq.cq, NULL);
if (c->xdp) if (c->xdp)
busy |= mlx5e_poll_xdpsq_cq(&c->rq.xdpsq.cq); busy |= mlx5e_poll_xdpsq_cq(&rq->xdpsq.cq, rq);
if (likely(budget)) { /* budget=0 means: don't poll rx rings */ if (likely(budget)) { /* budget=0 means: don't poll rx rings */
work_done = mlx5e_poll_rx_cq(&c->rq.cq, budget); work_done = mlx5e_poll_rx_cq(&rq->cq, budget);
busy |= work_done == budget; busy |= work_done == budget;
} }
busy |= c->rq.post_wqes(&c->rq); busy |= c->rq.post_wqes(rq);
if (busy) { if (busy) {
if (likely(mlx5e_channel_no_affinity_change(c))) if (likely(mlx5e_channel_no_affinity_change(c)))
@ -115,9 +116,9 @@ int mlx5e_napi_poll(struct napi_struct *napi, int budget)
mlx5e_cq_arm(&c->sq[i].cq); mlx5e_cq_arm(&c->sq[i].cq);
} }
mlx5e_handle_rx_dim(&c->rq); mlx5e_handle_rx_dim(rq);
mlx5e_cq_arm(&c->rq.cq); mlx5e_cq_arm(&rq->cq);
mlx5e_cq_arm(&c->icosq.cq); mlx5e_cq_arm(&c->icosq.cq);
mlx5e_cq_arm(&c->xdpsq.cq); mlx5e_cq_arm(&c->xdpsq.cq);