net/mlx5e: Re-order fields of struct mlx5e_xdpsq
authorTariq Toukan <tariqt@mellanox.com>
Tue, 22 May 2018 13:43:54 +0000 (16:43 +0300)
committerSaeed Mahameed <saeedm@mellanox.com>
Thu, 26 Jul 2018 22:23:56 +0000 (15:23 -0700)
In the downstream patch that adds support to XDP_REDIRECT-out,
the XDP xmit frame function doesn't share the same run context as
the NAPI that polls the XDP-SQ completion queue.

Hence, need to re-order the XDP-SQ fields to avoid cacheline
false-sharing.

Take redirect_flush and doorbell out of DB, into separated
cachelines.

Add a cacheline breaker within the stats struct.

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_rx.c
drivers/net/ethernet/mellanox/mlx5/core/en_stats.h

index d9e24fbe6a28cf865e6586ff37e0b47436a5fb68..16e219a8f240707ec72c0223269d238dfd1ca029 100644 (file)
@@ -409,22 +409,22 @@ struct mlx5e_xdp_info {
 struct mlx5e_xdpsq {
        /* data path */
 
-       /* dirtied @rx completion */
+       /* dirtied @completion */
        u16                        cc;
-       u16                        pc;
+       bool                       redirect_flush;
 
-       struct mlx5e_cq            cq;
+       /* dirtied @xmit */
+       u16                        pc ____cacheline_aligned_in_smp;
+       bool                       doorbell;
 
-       /* write@xmit, read@completion */
-       struct {
-               struct mlx5e_xdp_info     *xdpi;
-               bool                       doorbell;
-               bool                       redirect_flush;
-       } db;
+       struct mlx5e_cq            cq;
 
        /* read only */
        struct mlx5_wq_cyc         wq;
        struct mlx5e_xdpsq_stats  *stats;
+       struct {
+               struct mlx5e_xdp_info     *xdpi;
+       } db;
        void __iomem              *uar_map;
        u32                        sqn;
        struct device             *pdev;
index 26e24823504be811e7a51dc82aee1165c05cf080..eabd5537927d7de103bd1c38d90bb09bd62310f4 100644 (file)
@@ -85,7 +85,7 @@ bool mlx5e_xdp_handle(struct mlx5e_rq *rq, struct mlx5e_dma_info *di,
                if (unlikely(err))
                        goto xdp_abort;
                __set_bit(MLX5E_RQ_FLAG_XDP_XMIT, rq->flags);
-               rq->xdpsq.db.redirect_flush = true;
+               rq->xdpsq.redirect_flush = true;
                mlx5e_page_dma_unmap(rq, di);
                rq->stats->xdp_redirect++;
                return true;
@@ -124,10 +124,10 @@ bool mlx5e_xmit_xdp_frame(struct mlx5e_xdpsq *sq, struct mlx5e_xdp_info *xdpi)
        }
 
        if (unlikely(!mlx5e_wqc_has_room_for(wq, sq->cc, sq->pc, 1))) {
-               if (sq->db.doorbell) {
+               if (sq->doorbell) {
                        /* SQ is full, ring doorbell */
                        mlx5e_xmit_xdp_doorbell(sq);
-                       sq->db.doorbell = false;
+                       sq->doorbell = false;
                }
                stats->full++;
                return false;
@@ -156,7 +156,7 @@ bool mlx5e_xmit_xdp_frame(struct mlx5e_xdpsq *sq, struct mlx5e_xdp_info *xdpi)
        sq->db.xdpi[pi] = *xdpi;
        sq->pc++;
 
-       sq->db.doorbell = true;
+       sq->doorbell = true;
 
        stats->xmit++;
        return true;
index 70b984c4e8a44fe1e8a37d3a41ea53ad2e62b74a..e33ca03b21009c00d2f07f37abdfb9d4cbf8702d 100644 (file)
@@ -1201,14 +1201,14 @@ int mlx5e_poll_rx_cq(struct mlx5e_cq *cq, int budget)
                rq->handle_rx_cqe(rq, cqe);
        } while ((++work_done < budget) && (cqe = mlx5_cqwq_get_cqe(&cq->wq)));
 
-       if (xdpsq->db.doorbell) {
+       if (xdpsq->doorbell) {
                mlx5e_xmit_xdp_doorbell(xdpsq);
-               xdpsq->db.doorbell = false;
+               xdpsq->doorbell = false;
        }
 
-       if (xdpsq->db.redirect_flush) {
+       if (xdpsq->redirect_flush) {
                xdp_do_flush_map();
-               xdpsq->db.redirect_flush = false;
+               xdpsq->redirect_flush = false;
        }
 
        mlx5_cqwq_update_db_record(&cq->wq);
index 95e1f32c67d9f4b8d8658ef7f3815764b2fb158a..7aa8ff389cdd610f1c58f3effdeee8a32f3c2d71 100644 (file)
@@ -230,7 +230,8 @@ struct mlx5e_xdpsq_stats {
        u64 xmit;
        u64 full;
        u64 err;
-       u64 cqes;
+       /* dirtied @completion */
+       u64 cqes ____cacheline_aligned_in_smp;
 };
 
 struct mlx5e_ch_stats {