Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions providers/ionic/ionic_fw_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ union ionic_v1_pld {
struct ionic_v1_cqe {
union {
struct {
__u64 wqe_id;
__le64 wqe_idx;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO, all that is needed is to change "__u64 wqe_id;" to be
"__u8 rsvd[3];
__u8 wqe_idx;"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks that would have simplified. However we want to enforce the endianness on wqe_idx.
With the suggested change, we would again need to introduce endian conversions around the field.

__le16 wqe_idx;
__u8 rsvd[6];

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks that would have simplified. However we want to enforce the endianness on wqe_idx. With the suggested change, we would again need to introduce endian conversions around the field.

__le16 wqe_idx;
__u8 rsvd[6];

Sure, it was just an idea.

__be32 src_qpn_op;
__u8 src_mac[6];
__be16 vlan_tag;
Expand All @@ -84,13 +84,18 @@ struct ionic_v1_cqe {
__u8 rsvd[4];
__be32 msg_msn;
__u8 rsvd2[8];
__u64 npg_wqe_id;
__le64 npg_wqe_idx;
} send;
};
__be32 status_length;
__be32 qid_type_flags;
};

/* bits for cqe wqe_idx */
enum ionic_v1_cqe_wqe_idx_bits {
IONIC_V1_CQE_WQE_IDX_MASK = 0xffff,
};

/* bits for cqe recv */
enum ionic_v1_cqe_src_qpn_bits {
IONIC_V1_CQE_RECV_QPN_MASK = 0xffffff,
Expand Down Expand Up @@ -125,7 +130,7 @@ enum ionic_v1_cqe_qtf_bits {

/* v1 base wqe header */
struct ionic_v1_base_hdr {
__u64 wqe_id;
__le64 wqe_idx;
__u8 op;
__u8 num_sge_key;
__be16 flags;
Expand Down
47 changes: 24 additions & 23 deletions providers/ionic/ionic_verbs.c
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,7 @@ static int ionic_flush_recv(struct ionic_qp *qp, struct ibv_wc *wc)
struct ionic_rq_meta *meta;
struct ionic_v1_wqe *wqe;
struct ionic_ctx *ctx;
uint64_t wqe_idx;

if (!qp->rq.flush)
return 0;
Expand All @@ -711,20 +712,19 @@ static int ionic_flush_recv(struct ionic_qp *qp, struct ibv_wc *wc)
return 0;

wqe = ionic_queue_at_cons(&qp->rq.queue);
wqe_idx = le64toh(wqe->base.wqe_idx);
ctx = to_ionic_ctx(qp->vqp.qp.context);

/* wqe_id must be a valid queue index */
if (unlikely(wqe->base.wqe_id >> qp->rq.queue.depth_log2)) {
verbs_err(&ctx->vctx, "invalid id %#lx",
(unsigned long)wqe->base.wqe_id);
/* wqe_idx must be a valid queue index */
if (unlikely(wqe_idx >> qp->rq.queue.depth_log2)) {
verbs_err(&ctx->vctx, "invalid id %#lx", (unsigned long)wqe_idx);
return -EIO;
}

/* wqe_id must indicate a request that is outstanding */
meta = &qp->rq.meta[wqe->base.wqe_id];
/* wqe_idx must indicate a request that is outstanding */
meta = &qp->rq.meta[wqe_idx];
if (unlikely(meta->next != IONIC_META_POSTED)) {
verbs_err(&ctx->vctx, "wqe not posted %#lx",
(unsigned long)wqe->base.wqe_id);
verbs_err(&ctx->vctx, "wqe not posted %#lx", (unsigned long)wqe_idx);
return -EIO;
}

Expand Down Expand Up @@ -803,8 +803,8 @@ static int ionic_poll_recv(struct ionic_ctx *ctx, struct ionic_cq *cq,
{
struct ionic_qp *qp = NULL;
struct ionic_rq_meta *meta;
uint16_t vlan_tag, wqe_idx;
uint32_t src_qpn, st_len;
uint16_t vlan_tag;
uint8_t op;

if (cqe_qp->rq.flush)
Expand All @@ -814,7 +814,7 @@ static int ionic_poll_recv(struct ionic_ctx *ctx, struct ionic_cq *cq,

st_len = be32toh(cqe->status_length);

/* ignore wqe_id in case of flush error */
/* ignore wqe_idx in case of flush error */
if (ionic_v1_cqe_error(cqe) && st_len == IONIC_STS_WQE_FLUSHED_ERR) {
cqe_qp->rq.flush = true;
cq->flush = true;
Expand All @@ -831,19 +831,20 @@ static int ionic_poll_recv(struct ionic_ctx *ctx, struct ionic_cq *cq,
return -EIO;
}

/* wqe_id must be a valid queue index */
if (unlikely(cqe->recv.wqe_id >> qp->rq.queue.depth_log2)) {
verbs_err(&ctx->vctx, "invalid id %#lx",
(unsigned long)cqe->recv.wqe_id);
wqe_idx = le64toh(cqe->recv.wqe_idx) & IONIC_V1_CQE_WQE_IDX_MASK;

/* wqe_idx must be a valid queue index */
if (unlikely(wqe_idx >> qp->rq.queue.depth_log2)) {
verbs_err(&ctx->vctx, "invalid id %#lx", (unsigned long)wqe_idx);
return -EIO;
}

/* wqe_id must indicate a request that is outstanding */
meta = &qp->rq.meta[qp->rq.meta_idx[cqe->recv.wqe_id]];
/* wqe_idx must indicate a request that is outstanding */
meta = &qp->rq.meta[qp->rq.meta_idx[wqe_idx]];
if (unlikely(meta->next != IONIC_META_POSTED)) {
verbs_err(&ctx->vctx, "wqe is not posted for idx %lu meta_idx %u qpid %u rq.prod %u rq.cons %u cqid %u",
(unsigned long)cqe->recv.wqe_id,
qp->rq.meta_idx[cqe->recv.wqe_id],
(unsigned long)wqe_idx,
qp->rq.meta_idx[wqe_idx],
qp->qpid, qp->rq.queue.prod,
qp->rq.queue.cons, cq->cqid);
return -EIO;
Expand Down Expand Up @@ -1086,7 +1087,7 @@ static int ionic_comp_npg(struct ionic_ctx *ctx,
struct ionic_v1_cqe *cqe)
{
struct ionic_sq_meta *meta;
uint16_t cqe_idx;
uint16_t wqe_idx;
uint32_t st_len;

if (qp->sq.flush)
Expand All @@ -1107,8 +1108,8 @@ static int ionic_comp_npg(struct ionic_ctx *ctx,
return 0;
}

cqe_idx = cqe->send.npg_wqe_id & qp->sq.queue.mask;
meta = &qp->sq.meta[cqe_idx];
wqe_idx = le64toh(cqe->send.npg_wqe_idx) & qp->sq.queue.mask;
meta = &qp->sq.meta[wqe_idx];
meta->local_comp = true;

if (ionic_v1_cqe_error(cqe)) {
Expand Down Expand Up @@ -2100,7 +2101,7 @@ static void ionic_v1_prep_base(struct ionic_qp *qp,
meta->signal = false;
meta->local_comp = false;

wqe->base.wqe_id = qp->sq.queue.prod;
wqe->base.wqe_idx = htole64(qp->sq.queue.prod);
if (qp->sq.color)
wqe->base.flags |= htobe16(IONIC_V1_FLAG_COLOR);

Expand Down Expand Up @@ -2708,7 +2709,7 @@ static int ionic_v1_prep_recv(struct ionic_qp *qp,

meta->wrid = wr->wr_id;

wqe->base.wqe_id = qp->rq.queue.prod;
wqe->base.wqe_idx = htole64(qp->rq.queue.prod);
wqe->base.num_sge_key = wr->num_sge;

qp->rq.meta_idx[qp->rq.queue.prod] = meta - qp->rq.meta;
Expand Down