net/mlx5e: XDP, Change the XDP SQ redirect indication
authorTariq Toukan <tariqt@mellanox.com>
Wed, 21 Nov 2018 12:04:45 +0000 (14:04 +0200)
committerSaeed Mahameed <saeedm@mellanox.com>
Fri, 21 Dec 2018 06:54:18 +0000 (22:54 -0800)
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>
drivers/net/ethernet/mellanox/mlx5/core/en.h
drivers/net/ethernet/mellanox/mlx5/core/en/xdp.c
drivers/net/ethernet/mellanox/mlx5/core/en/xdp.h
drivers/net/ethernet/mellanox/mlx5/core/en_main.c
drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c

index 72cc204f9a34f33d612fd6e75a99648b8677bda1..15cbf0c6e309d48c3191c34a235b660eebb18aa9 100644 (file)
@@ -344,7 +344,6 @@ enum {
        MLX5E_SQ_STATE_IPSEC,
        MLX5E_SQ_STATE_AM,
        MLX5E_SQ_STATE_TLS,
-       MLX5E_SQ_STATE_REDIRECT,
 };
 
 struct mlx5e_sq_wqe_info {
index cf22ea529c53c34a563f75f9f77ecb7ab2768a72..4961b8fea111ada911de839fcc8eb798a7ed0a02 100644 (file)
@@ -164,11 +164,10 @@ bool mlx5e_xmit_xdp_frame(struct mlx5e_xdpsq *sq, struct mlx5e_xdp_info *xdpi)
        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 mlx5_cqe64 *cqe;
-       struct mlx5e_rq *rq;
        bool is_redirect;
        u16 sqcc;
        int i;
@@ -182,8 +181,7 @@ bool mlx5e_poll_xdpsq_cq(struct mlx5e_cq *cq)
        if (!cqe)
                return false;
 
-       is_redirect = test_bit(MLX5E_SQ_STATE_REDIRECT, &sq->state);
-       rq = container_of(sq, struct mlx5e_rq, xdpsq);
+       is_redirect = !rq;
 
        /* sq->cc must be updated only after mlx5_cqwq_update_db_record(),
         * 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);
 }
 
-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;
-
-       is_redirect = test_bit(MLX5E_SQ_STATE_REDIRECT, &sq->state);
-       rq = is_redirect ? NULL : container_of(sq, struct mlx5e_rq, xdpsq);
+       bool is_redirect = !rq;
 
        while (sq->cc != sq->pc) {
                u16 ci = mlx5_wq_cyc_ctr2ix(&sq->wq, sq->cc);
index eecc0392fcffea6dd33e4a2f0050712f78888c4b..37fcb17e7f271d0187556f09ea71650b2f6751a0 100644 (file)
@@ -42,8 +42,8 @@
 
 bool mlx5e_xdp_handle(struct mlx5e_rq *rq, struct mlx5e_dma_info *di,
                      void *va, u16 *rx_headroom, u32 *len);
-bool mlx5e_poll_xdpsq_cq(struct mlx5e_cq *cq);
-void mlx5e_free_xdpsq_descs(struct mlx5e_xdpsq *sq);
+bool mlx5e_poll_xdpsq_cq(struct mlx5e_cq *cq, struct mlx5e_rq *rq);
+void mlx5e_free_xdpsq_descs(struct mlx5e_xdpsq *sq, 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);
 int mlx5e_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **frames,
index bc791404f2e7f761f203af471f24c401808777e4..8a19f451fb7a87cd675a0e1d49fc4e2a7f4f86c5 100644 (file)
@@ -1577,8 +1577,6 @@ static int mlx5e_open_xdpsq(struct mlx5e_channel *c,
        csp.cqn             = sq->cq.mcq.cqn;
        csp.wq_ctrl         = &sq->wq_ctrl;
        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);
        err = mlx5e_create_sq_rdy(c->mdev, param, &csp, &sq->sqn);
        if (err)
@@ -1612,7 +1610,7 @@ err_free_xdpsq:
        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;
 
@@ -1620,7 +1618,7 @@ static void mlx5e_close_xdpsq(struct mlx5e_xdpsq *sq)
        napi_synchronize(&c->napi);
 
        mlx5e_destroy_sq(c->mdev, sq->sqn);
-       mlx5e_free_xdpsq_descs(sq);
+       mlx5e_free_xdpsq_descs(sq, rq);
        mlx5e_free_xdpsq(sq);
 }
 
@@ -2008,7 +2006,7 @@ err_close_rq:
 
 err_close_xdp_sq:
        if (c->xdp)
-               mlx5e_close_xdpsq(&c->rq.xdpsq);
+               mlx5e_close_xdpsq(&c->rq.xdpsq, &c->rq);
 
 err_close_sqs:
        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)
 {
-       mlx5e_close_xdpsq(&c->xdpsq);
+       mlx5e_close_xdpsq(&c->xdpsq, NULL);
        mlx5e_close_rq(&c->rq);
        if (c->xdp)
-               mlx5e_close_xdpsq(&c->rq.xdpsq);
+               mlx5e_close_xdpsq(&c->rq.xdpsq, &c->rq);
        mlx5e_close_sqs(c);
        mlx5e_close_icosq(&c->icosq);
        napi_disable(&c->napi);
index 85d51736015729267573436b35630acc4f0897b0..b4af5e19f6acd63fb9b08375a533ec1fc9085820 100644 (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,
                                               napi);
        struct mlx5e_ch_stats *ch_stats = c->stats;
+       struct mlx5e_rq *rq = &c->rq;
        bool busy = false;
        int work_done = 0;
        int i;
@@ -85,17 +86,17 @@ int mlx5e_napi_poll(struct napi_struct *napi, int budget)
        for (i = 0; i < c->num_tc; i++)
                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)
-               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 */
-               work_done = mlx5e_poll_rx_cq(&c->rq.cq, budget);
+               work_done = mlx5e_poll_rx_cq(&rq->cq, budget);
                busy |= work_done == budget;
        }
 
-       busy |= c->rq.post_wqes(&c->rq);
+       busy |= c->rq.post_wqes(rq);
 
        if (busy) {
                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_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->xdpsq.cq);