Commit de19ec77 authored by Cheng Xu's avatar Cheng Xu Committed by Leon Romanovsky

RDMA/erdma: Unify byte ordering APIs usage

Replace __be32_to_cpu/__cpu_to_be16 with be32_to_cpu/cpu_to_be16.
And use be32_to_cpu_array to copy and swap byte order to hide the
loop.
Signed-off-by: default avatarCheng Xu <chengyou@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230322093319.84045-2-chengyou@linux.alibaba.comSigned-off-by: default avatarLeon Romanovsky <leon@kernel.org>
parent 697d5cf0
...@@ -33,11 +33,11 @@ struct mpa_rr_params { ...@@ -33,11 +33,11 @@ struct mpa_rr_params {
* MPA request/response Hdr bits & fields * MPA request/response Hdr bits & fields
*/ */
enum { enum {
MPA_RR_FLAG_MARKERS = __cpu_to_be16(0x8000), MPA_RR_FLAG_MARKERS = cpu_to_be16(0x8000),
MPA_RR_FLAG_CRC = __cpu_to_be16(0x4000), MPA_RR_FLAG_CRC = cpu_to_be16(0x4000),
MPA_RR_FLAG_REJECT = __cpu_to_be16(0x2000), MPA_RR_FLAG_REJECT = cpu_to_be16(0x2000),
MPA_RR_RESERVED = __cpu_to_be16(0x1f00), MPA_RR_RESERVED = cpu_to_be16(0x1f00),
MPA_RR_MASK_REVISION = __cpu_to_be16(0x00ff) MPA_RR_MASK_REVISION = cpu_to_be16(0x00ff)
}; };
/* /*
......
...@@ -283,7 +283,7 @@ static void *get_next_valid_cmdq_cqe(struct erdma_cmdq *cmdq) ...@@ -283,7 +283,7 @@ static void *get_next_valid_cmdq_cqe(struct erdma_cmdq *cmdq)
__be32 *cqe = get_queue_entry(cmdq->cq.qbuf, cmdq->cq.ci, __be32 *cqe = get_queue_entry(cmdq->cq.qbuf, cmdq->cq.ci,
cmdq->cq.depth, CQE_SHIFT); cmdq->cq.depth, CQE_SHIFT);
u32 owner = FIELD_GET(ERDMA_CQE_HDR_OWNER_MASK, u32 owner = FIELD_GET(ERDMA_CQE_HDR_OWNER_MASK,
__be32_to_cpu(READ_ONCE(*cqe))); be32_to_cpu(READ_ONCE(*cqe)));
return owner ^ !!(cmdq->cq.ci & cmdq->cq.depth) ? cqe : NULL; return owner ^ !!(cmdq->cq.ci & cmdq->cq.depth) ? cqe : NULL;
} }
...@@ -319,7 +319,6 @@ static int erdma_poll_single_cmd_completion(struct erdma_cmdq *cmdq) ...@@ -319,7 +319,6 @@ static int erdma_poll_single_cmd_completion(struct erdma_cmdq *cmdq)
__be32 *cqe; __be32 *cqe;
u16 ctx_id; u16 ctx_id;
u64 *sqe; u64 *sqe;
int i;
cqe = get_next_valid_cmdq_cqe(cmdq); cqe = get_next_valid_cmdq_cqe(cmdq);
if (!cqe) if (!cqe)
...@@ -328,8 +327,8 @@ static int erdma_poll_single_cmd_completion(struct erdma_cmdq *cmdq) ...@@ -328,8 +327,8 @@ static int erdma_poll_single_cmd_completion(struct erdma_cmdq *cmdq)
cmdq->cq.ci++; cmdq->cq.ci++;
dma_rmb(); dma_rmb();
hdr0 = __be32_to_cpu(*cqe); hdr0 = be32_to_cpu(*cqe);
sqe_idx = __be32_to_cpu(*(cqe + 1)); sqe_idx = be32_to_cpu(*(cqe + 1));
sqe = get_queue_entry(cmdq->sq.qbuf, sqe_idx, cmdq->sq.depth, sqe = get_queue_entry(cmdq->sq.qbuf, sqe_idx, cmdq->sq.depth,
SQEBB_SHIFT); SQEBB_SHIFT);
...@@ -341,9 +340,8 @@ static int erdma_poll_single_cmd_completion(struct erdma_cmdq *cmdq) ...@@ -341,9 +340,8 @@ static int erdma_poll_single_cmd_completion(struct erdma_cmdq *cmdq)
comp_wait->cmd_status = ERDMA_CMD_STATUS_FINISHED; comp_wait->cmd_status = ERDMA_CMD_STATUS_FINISHED;
comp_wait->comp_status = FIELD_GET(ERDMA_CQE_HDR_SYNDROME_MASK, hdr0); comp_wait->comp_status = FIELD_GET(ERDMA_CQE_HDR_SYNDROME_MASK, hdr0);
cmdq->sq.ci += cmdq->sq.wqebb_cnt; cmdq->sq.ci += cmdq->sq.wqebb_cnt;
/* Copy 16B comp data after cqe hdr to outer */
for (i = 0; i < 4; i++) be32_to_cpu_array(comp_wait->comp_data, cqe + 2, 4);
comp_wait->comp_data[i] = __be32_to_cpu(*(cqe + 2 + i));
if (cmdq->use_event) if (cmdq->use_event)
complete(&comp_wait->wait_event); complete(&comp_wait->wait_event);
......
...@@ -11,7 +11,7 @@ static void *get_next_valid_cqe(struct erdma_cq *cq) ...@@ -11,7 +11,7 @@ static void *get_next_valid_cqe(struct erdma_cq *cq)
__be32 *cqe = get_queue_entry(cq->kern_cq.qbuf, cq->kern_cq.ci, __be32 *cqe = get_queue_entry(cq->kern_cq.qbuf, cq->kern_cq.ci,
cq->depth, CQE_SHIFT); cq->depth, CQE_SHIFT);
u32 owner = FIELD_GET(ERDMA_CQE_HDR_OWNER_MASK, u32 owner = FIELD_GET(ERDMA_CQE_HDR_OWNER_MASK,
__be32_to_cpu(READ_ONCE(*cqe))); be32_to_cpu(READ_ONCE(*cqe)));
return owner ^ !!(cq->kern_cq.ci & cq->depth) ? cqe : NULL; return owner ^ !!(cq->kern_cq.ci & cq->depth) ? cqe : NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment