net/mlx5: Use helper to get CQE opcode
authorTariq Toukan <tariqt@mellanox.com>
Wed, 5 Dec 2018 02:03:01 +0000 (18:03 -0800)
committerSaeed Mahameed <saeedm@mellanox.com>
Mon, 10 Dec 2018 02:16:16 +0000 (18:16 -0800)
Introduce and use a helper that extracts the opcode
from a CQE (completion queue entry) structure.

Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
drivers/net/ethernet/mellanox/mlx5/core/en_tx.c
drivers/net/ethernet/mellanox/mlx5/core/fpga/conn.c
include/linux/mlx5/device.h

index 79638dcbae78395fb723c9bf3fa877e7a42d91cd..31956ddd394ee71433b09981877498a39eaaf7d2 100644 (file)
@@ -554,9 +554,9 @@ static inline void mlx5e_poll_ico_single_cqe(struct mlx5e_cq *cq,
 
        mlx5_cqwq_pop(&cq->wq);
 
-       if (unlikely((cqe->op_own >> 4) != MLX5_CQE_REQ)) {
+       if (unlikely(get_cqe_opcode(cqe) != MLX5_CQE_REQ)) {
                netdev_WARN_ONCE(cq->channel->netdev,
-                                "Bad OP in ICOSQ CQE: 0x%x\n", cqe->op_own);
+                                "Bad OP in ICOSQ CQE: 0x%x\n", get_cqe_opcode(cqe));
                return;
        }
 
@@ -898,7 +898,7 @@ mlx5e_skb_from_cqe_linear(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe,
        prefetchw(va); /* xdp_frame data area */
        prefetch(data);
 
-       if (unlikely((cqe->op_own >> 4) != MLX5_CQE_RESP_SEND)) {
+       if (unlikely(get_cqe_opcode(cqe) != MLX5_CQE_RESP_SEND)) {
                rq->stats->wqe_err++;
                return NULL;
        }
@@ -930,7 +930,7 @@ mlx5e_skb_from_cqe_nonlinear(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe,
        u16 byte_cnt     = cqe_bcnt - headlen;
        struct sk_buff *skb;
 
-       if (unlikely((cqe->op_own >> 4) != MLX5_CQE_RESP_SEND)) {
+       if (unlikely(get_cqe_opcode(cqe) != MLX5_CQE_RESP_SEND)) {
                rq->stats->wqe_err++;
                return NULL;
        }
@@ -1148,7 +1148,7 @@ void mlx5e_handle_rx_cqe_mpwrq(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe)
 
        wi->consumed_strides += cstrides;
 
-       if (unlikely((cqe->op_own >> 4) != MLX5_CQE_RESP_SEND)) {
+       if (unlikely(get_cqe_opcode(cqe) != MLX5_CQE_RESP_SEND)) {
                rq->stats->wqe_err++;
                goto mpwrq_cqe_out;
        }
index 6dacaeba2fbff85e5091a1151f7ee731e70cf0cd..46b5a6914d7174c162681313884394065ad86678 100644 (file)
@@ -507,7 +507,7 @@ bool mlx5e_poll_tx_cq(struct mlx5e_cq *cq, int napi_budget)
 
                wqe_counter = be16_to_cpu(cqe->wqe_counter);
 
-               if (unlikely(cqe->op_own >> 4 == MLX5_CQE_REQ_ERR)) {
+               if (unlikely(get_cqe_opcode(cqe) == MLX5_CQE_REQ_ERR)) {
                        if (!test_and_set_bit(MLX5E_SQ_STATE_RECOVERING,
                                              &sq->state)) {
                                mlx5e_dump_error_cqe(sq,
index 8ca1d1949d930d46d0cf7c386383e060640ff792..873541ef4c1b754b15209f7516bcee07378f6763 100644 (file)
@@ -334,7 +334,7 @@ static void mlx5_fpga_conn_handle_cqe(struct mlx5_fpga_conn *conn,
 {
        u8 opcode, status = 0;
 
-       opcode = cqe->op_own >> 4;
+       opcode = get_cqe_opcode(cqe);
 
        switch (opcode) {
        case MLX5_CQE_REQ_ERR:
index f7c8bebfe472943b6ae4c703661debb1010192c4..c66867c8fc2ff9cebb14b8ca43031eb70d443055 100644 (file)
@@ -781,6 +781,11 @@ static inline u8 mlx5_get_cqe_format(struct mlx5_cqe64 *cqe)
        return (cqe->op_own >> 2) & 0x3;
 }
 
+static inline u8 get_cqe_opcode(struct mlx5_cqe64 *cqe)
+{
+       return cqe->op_own >> 4;
+}
+
 static inline u8 get_cqe_lro_tcppsh(struct mlx5_cqe64 *cqe)
 {
        return (cqe->lro_tcppsh_abort_dupack >> 6) & 1;