net/mlx5: Refactor imm_inval_pkey field in cqe struct
authorRaed Salem <raeds@mellanox.com>
Fri, 24 Apr 2020 19:45:05 +0000 (12:45 -0700)
committerSaeed Mahameed <saeedm@mellanox.com>
Tue, 28 Apr 2020 19:45:15 +0000 (12:45 -0700)
The imm_inval_pkey field can hold four different types of data,
depends on the usage, the data could be one of the below:
- Immediate field of the received message
- Invalidate rkey
- Pkey of the packet
- Flow table metadata

Current implementation doesn't reflect the intended usage of the
field at usage time.

Reflect the different types by replace this field with a union,
modify code where this field is used to reflect its intended
usage.

Signed-off-by: Raed Salem <raeds@mellanox.com>
Reviewed-by: Huy Nguyen <huyn@mellanox.com>
Reviewed-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
drivers/infiniband/hw/mlx5/cq.c
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
include/linux/mlx5/device.h

index 32c0573..0c18cb6 100644 (file)
@@ -202,7 +202,7 @@ static void handle_responder(struct ib_wc *wc, struct mlx5_cqe64 *cqe,
        case MLX5_CQE_RESP_WR_IMM:
                wc->opcode      = IB_WC_RECV_RDMA_WITH_IMM;
                wc->wc_flags    = IB_WC_WITH_IMM;
-               wc->ex.imm_data = cqe->imm_inval_pkey;
+               wc->ex.imm_data = cqe->immediate;
                break;
        case MLX5_CQE_RESP_SEND:
                wc->opcode   = IB_WC_RECV;
@@ -214,12 +214,12 @@ static void handle_responder(struct ib_wc *wc, struct mlx5_cqe64 *cqe,
        case MLX5_CQE_RESP_SEND_IMM:
                wc->opcode      = IB_WC_RECV;
                wc->wc_flags    = IB_WC_WITH_IMM;
-               wc->ex.imm_data = cqe->imm_inval_pkey;
+               wc->ex.imm_data = cqe->immediate;
                break;
        case MLX5_CQE_RESP_SEND_INV:
                wc->opcode      = IB_WC_RECV;
                wc->wc_flags    = IB_WC_WITH_INVALIDATE;
-               wc->ex.invalidate_rkey = be32_to_cpu(cqe->imm_inval_pkey);
+               wc->ex.invalidate_rkey = be32_to_cpu(cqe->inval_rkey);
                break;
        }
        wc->src_qp         = be32_to_cpu(cqe->flags_rqpn) & 0xffffff;
@@ -227,7 +227,7 @@ static void handle_responder(struct ib_wc *wc, struct mlx5_cqe64 *cqe,
        g = (be32_to_cpu(cqe->flags_rqpn) >> 28) & 3;
        wc->wc_flags |= g ? IB_WC_GRH : 0;
        if (unlikely(is_qp1(qp->ibqp.qp_type))) {
-               u16 pkey = be32_to_cpu(cqe->imm_inval_pkey) & 0xffff;
+               u16 pkey = be32_to_cpu(cqe->pkey) & 0xffff;
 
                ib_find_cached_pkey(&dev->ib_dev, qp->port, pkey,
                                    &wc->pkey_index);
index 12c5ca5..5b63243 100644 (file)
@@ -4891,7 +4891,7 @@ bool mlx5e_tc_rep_update_skb(struct mlx5_cqe64 *cqe,
        reg_c0 = (be32_to_cpu(cqe->sop_drop_qpn) & MLX5E_TC_FLOW_ID_MASK);
        if (reg_c0 == MLX5_FS_DEFAULT_FLOW_TAG)
                reg_c0 = 0;
-       reg_c1 = be32_to_cpu(cqe->imm_inval_pkey);
+       reg_c1 = be32_to_cpu(cqe->ft_metadata);
 
        if (!reg_c0)
                return true;
index 7b57877..746e174 100644 (file)
@@ -767,7 +767,12 @@ struct mlx5_cqe64 {
        u8              l4_l3_hdr_type;
        __be16          vlan_info;
        __be32          srqn; /* [31:24]: lro_num_seg, [23:0]: srqn */
-       __be32          imm_inval_pkey;
+       union {
+               __be32 immediate;
+               __be32 inval_rkey;
+               __be32 pkey;
+               __be32 ft_metadata;
+       };
        u8              rsvd40[4];
        __be32          byte_cnt;
        __be32          timestamp_h;