net/mlx5e: Use struct assignment for WQE info updates
authorTariq Toukan <tariqt@mellanox.com>
Thu, 19 Mar 2020 14:50:14 +0000 (16:50 +0200)
committerSaeed Mahameed <saeedm@mellanox.com>
Sat, 9 May 2020 08:05:41 +0000 (01:05 -0700)
Struct assignment looks more clean, and implies resetting
the not assigned fields to zero, instead of holding values
from older ring cycles.

Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
Reviewed-by: Maxim Mikityanskiy <maximmi@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c
drivers/net/ethernet/mellanox/mlx5/core/en_main.c
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
drivers/net/ethernet/mellanox/mlx5/core/en_txrx.c

index 1c9d0174676df7d57f0fdd699d455845ff19edfe..3cd78d9503c1228151b47ae67da5a15b1827ce2c 100644 (file)
@@ -108,10 +108,11 @@ static void tx_fill_wi(struct mlx5e_txqsq *sq,
 {
        struct mlx5e_tx_wqe_info *wi = &sq->db.wqe_info[pi];
 
-       memset(wi, 0, sizeof(*wi));
-       wi->num_wqebbs = num_wqebbs;
-       wi->num_bytes  = num_bytes;
-       wi->resync_dump_frag_page = page;
+       *wi = (struct mlx5e_tx_wqe_info) {
+               .num_wqebbs = num_wqebbs,
+               .num_bytes  = num_bytes,
+               .resync_dump_frag_page = page,
+       };
 }
 
 void mlx5e_ktls_tx_offload_set_pending(struct mlx5e_ktls_offload_context_tx *priv_tx)
index 048a4f8601a8af4df9dea973434c10c676da5df6..0a9dfc31de3e62189ec4cab6558367066df146d4 100644 (file)
@@ -1364,13 +1364,12 @@ static void mlx5e_deactivate_txqsq(struct mlx5e_txqsq *sq)
        /* last doorbell out, godspeed .. */
        if (mlx5e_wqc_has_room_for(wq, sq->cc, sq->pc, 1)) {
                u16 pi = mlx5_wq_cyc_ctr2ix(wq, sq->pc);
-               struct mlx5e_tx_wqe_info *wi;
                struct mlx5e_tx_wqe *nop;
 
-               wi = &sq->db.wqe_info[pi];
+               sq->db.wqe_info[pi] = (struct mlx5e_tx_wqe_info) {
+                       .num_wqebbs = 1,
+               };
 
-               memset(wi, 0, sizeof(*wi));
-               wi->num_wqebbs = 1;
                nop = mlx5e_post_nop(wq, sq->sqn, &sq->pc);
                mlx5e_notify_hw(wq, sq->pc, sq->uar_map, &nop->ctrl);
        }
@@ -1482,20 +1481,21 @@ int mlx5e_open_xdpsq(struct mlx5e_channel *c, struct mlx5e_params *params,
 
                /* Pre initialize fixed WQE fields */
                for (i = 0; i < mlx5_wq_cyc_get_size(&sq->wq); i++) {
-                       struct mlx5e_xdp_wqe_info *wi  = &sq->db.wqe_info[i];
                        struct mlx5e_tx_wqe      *wqe  = mlx5_wq_cyc_get_wqe(&sq->wq, i);
                        struct mlx5_wqe_ctrl_seg *cseg = &wqe->ctrl;
                        struct mlx5_wqe_eth_seg  *eseg = &wqe->eth;
                        struct mlx5_wqe_data_seg *dseg;
 
+                       sq->db.wqe_info[i] = (struct mlx5e_xdp_wqe_info) {
+                               .num_wqebbs = 1,
+                               .num_pkts   = 1,
+                       };
+
                        cseg->qpn_ds = cpu_to_be32((sq->sqn << 8) | ds_cnt);
                        eseg->inline_hdr.sz = cpu_to_be16(inline_hdr_sz);
 
                        dseg = (struct mlx5_wqe_data_seg *)cseg + (ds_cnt - 1);
                        dseg->lkey = sq->mkey_be;
-
-                       wi->num_wqebbs = 1;
-                       wi->num_pkts   = 1;
                }
        }
 
index d9a5a669b84da7b43d94ef3f49602ee50382b70a..8142b6e70857a556a1b4513034ce00ca03d9d3b3 100644 (file)
@@ -505,9 +505,12 @@ static int mlx5e_alloc_rx_mpwqe(struct mlx5e_rq *rq, u16 ix)
                            MLX5_OPCODE_UMR);
        umr_wqe->uctrl.xlt_offset = cpu_to_be16(xlt_offset);
 
-       sq->db.wqe_info[pi].opcode = MLX5_OPCODE_UMR;
-       sq->db.wqe_info[pi].num_wqebbs = MLX5E_UMR_WQEBBS;
-       sq->db.wqe_info[pi].umr.rq = rq;
+       sq->db.wqe_info[pi] = (struct mlx5e_icosq_wqe_info) {
+               .opcode     = MLX5_OPCODE_UMR,
+               .num_wqebbs = MLX5E_UMR_WQEBBS,
+               .umr.rq     = rq,
+       };
+
        sq->pc += MLX5E_UMR_WQEBBS;
 
        sq->doorbell_cseg = &umr_wqe->ctrl;
index 869fd58a67755e763c370d1ad9522563d289b7fb..73293f9c3f635652655dbb02f6af844aa76c5a72 100644 (file)
@@ -78,8 +78,11 @@ void mlx5e_trigger_irq(struct mlx5e_icosq *sq)
        struct mlx5e_tx_wqe *nopwqe;
        u16 pi = mlx5_wq_cyc_ctr2ix(wq, sq->pc);
 
-       sq->db.wqe_info[pi].opcode = MLX5_OPCODE_NOP;
-       sq->db.wqe_info[pi].num_wqebbs = 1;
+       sq->db.wqe_info[pi] = (struct mlx5e_icosq_wqe_info) {
+               .opcode     = MLX5_OPCODE_NOP,
+               .num_wqebbs = 1,
+       };
+
        nopwqe = mlx5e_post_nop(wq, sq->sqn, &sq->pc);
        mlx5e_notify_hw(wq, sq->pc, sq->uar_map, &nopwqe->ctrl);
 }