Commit 2b0ad2da authored by Michael J. Ruhl's avatar Michael J. Ruhl Committed by Jason Gunthorpe

IB/{rdmavt, hfi1, qib}: Add helpers to hide SWQE WR details

Add some helper functions to hide struct rvt_swqe details.
Reviewed-by: default avatarMike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: default avatarMichael J. Ruhl <michael.j.ruhl@intel.com>
Signed-off-by: default avatarDennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent d310c4bf
...@@ -348,7 +348,7 @@ int hfi1_setup_wqe(struct rvt_qp *qp, struct rvt_swqe *wqe, bool *call_send) ...@@ -348,7 +348,7 @@ int hfi1_setup_wqe(struct rvt_qp *qp, struct rvt_swqe *wqe, bool *call_send)
break; break;
case IB_QPT_GSI: case IB_QPT_GSI:
case IB_QPT_UD: case IB_QPT_UD:
ah = ibah_to_rvtah(wqe->ud_wr.wr.ah); ah = rvt_get_swqe_ah(wqe);
if (wqe->length > (1 << ah->log_pmtu)) if (wqe->length > (1 << ah->log_pmtu))
return -EINVAL; return -EINVAL;
if (ibp->sl_to_sc[rdma_ah_get_sl(&ah->attr)] == 0xf) if (ibp->sl_to_sc[rdma_ah_get_sl(&ah->attr)] == 0xf)
......
...@@ -87,7 +87,7 @@ static void ud_loopback(struct rvt_qp *sqp, struct rvt_swqe *swqe) ...@@ -87,7 +87,7 @@ static void ud_loopback(struct rvt_qp *sqp, struct rvt_swqe *swqe)
rcu_read_lock(); rcu_read_lock();
qp = rvt_lookup_qpn(ib_to_rvt(sqp->ibqp.device), &ibp->rvp, qp = rvt_lookup_qpn(ib_to_rvt(sqp->ibqp.device), &ibp->rvp,
swqe->ud_wr.wr.remote_qpn); rvt_get_swqe_remote_qpn(swqe));
if (!qp) { if (!qp) {
ibp->rvp.n_pkt_drops++; ibp->rvp.n_pkt_drops++;
rcu_read_unlock(); rcu_read_unlock();
...@@ -105,7 +105,7 @@ static void ud_loopback(struct rvt_qp *sqp, struct rvt_swqe *swqe) ...@@ -105,7 +105,7 @@ static void ud_loopback(struct rvt_qp *sqp, struct rvt_swqe *swqe)
goto drop; goto drop;
} }
ah_attr = swqe->ud_wr.attr; ah_attr = rvt_get_swqe_ah_attr(swqe);
ppd = ppd_from_ibp(ibp); ppd = ppd_from_ibp(ibp);
if (qp->ibqp.qp_num > 1) { if (qp->ibqp.qp_num > 1) {
...@@ -135,8 +135,8 @@ static void ud_loopback(struct rvt_qp *sqp, struct rvt_swqe *swqe) ...@@ -135,8 +135,8 @@ static void ud_loopback(struct rvt_qp *sqp, struct rvt_swqe *swqe)
if (qp->ibqp.qp_num) { if (qp->ibqp.qp_num) {
u32 qkey; u32 qkey;
qkey = (int)swqe->ud_wr.wr.remote_qkey < 0 ? qkey = (int)rvt_get_swqe_remote_qkey(swqe) < 0 ?
sqp->qkey : swqe->ud_wr.wr.remote_qkey; sqp->qkey : rvt_get_swqe_remote_qkey(swqe);
if (unlikely(qkey != qp->qkey)) if (unlikely(qkey != qp->qkey))
goto drop; /* silently drop per IBTA spec */ goto drop; /* silently drop per IBTA spec */
} }
...@@ -240,7 +240,7 @@ static void ud_loopback(struct rvt_qp *sqp, struct rvt_swqe *swqe) ...@@ -240,7 +240,7 @@ static void ud_loopback(struct rvt_qp *sqp, struct rvt_swqe *swqe)
if (qp->ibqp.qp_type == IB_QPT_GSI || qp->ibqp.qp_type == IB_QPT_SMI) { if (qp->ibqp.qp_type == IB_QPT_GSI || qp->ibqp.qp_type == IB_QPT_SMI) {
if (sqp->ibqp.qp_type == IB_QPT_GSI || if (sqp->ibqp.qp_type == IB_QPT_GSI ||
sqp->ibqp.qp_type == IB_QPT_SMI) sqp->ibqp.qp_type == IB_QPT_SMI)
wc.pkey_index = swqe->ud_wr.wr.pkey_index; wc.pkey_index = rvt_get_swqe_pkey_index(swqe);
else else
wc.pkey_index = sqp->s_pkey_index; wc.pkey_index = sqp->s_pkey_index;
} else { } else {
...@@ -282,20 +282,21 @@ static void hfi1_make_bth_deth(struct rvt_qp *qp, struct rvt_swqe *wqe, ...@@ -282,20 +282,21 @@ static void hfi1_make_bth_deth(struct rvt_qp *qp, struct rvt_swqe *wqe,
bth0 |= IB_BTH_SOLICITED; bth0 |= IB_BTH_SOLICITED;
bth0 |= extra_bytes << 20; bth0 |= extra_bytes << 20;
if (qp->ibqp.qp_type == IB_QPT_GSI || qp->ibqp.qp_type == IB_QPT_SMI) if (qp->ibqp.qp_type == IB_QPT_GSI || qp->ibqp.qp_type == IB_QPT_SMI)
*pkey = hfi1_get_pkey(ibp, wqe->ud_wr.wr.pkey_index); *pkey = hfi1_get_pkey(ibp, rvt_get_swqe_pkey_index(wqe));
else else
*pkey = hfi1_get_pkey(ibp, qp->s_pkey_index); *pkey = hfi1_get_pkey(ibp, qp->s_pkey_index);
if (!bypass) if (!bypass)
bth0 |= *pkey; bth0 |= *pkey;
ohdr->bth[0] = cpu_to_be32(bth0); ohdr->bth[0] = cpu_to_be32(bth0);
ohdr->bth[1] = cpu_to_be32(wqe->ud_wr.wr.remote_qpn); ohdr->bth[1] = cpu_to_be32(rvt_get_swqe_remote_qpn(wqe));
ohdr->bth[2] = cpu_to_be32(mask_psn(wqe->psn)); ohdr->bth[2] = cpu_to_be32(mask_psn(wqe->psn));
/* /*
* Qkeys with the high order bit set mean use the * Qkeys with the high order bit set mean use the
* qkey from the QP context instead of the WR (see 10.2.5). * qkey from the QP context instead of the WR (see 10.2.5).
*/ */
ohdr->u.ud.deth[0] = cpu_to_be32((int)wqe->ud_wr.wr.remote_qkey < 0 ? ohdr->u.ud.deth[0] =
qp->qkey : wqe->ud_wr.wr.remote_qkey); cpu_to_be32((int)rvt_get_swqe_remote_qkey(wqe) < 0 ? qp->qkey :
rvt_get_swqe_remote_qkey(wqe));
ohdr->u.ud.deth[1] = cpu_to_be32(qp->ibqp.qp_num); ohdr->u.ud.deth[1] = cpu_to_be32(qp->ibqp.qp_num);
} }
...@@ -315,7 +316,7 @@ void hfi1_make_ud_req_9B(struct rvt_qp *qp, struct hfi1_pkt_state *ps, ...@@ -315,7 +316,7 @@ void hfi1_make_ud_req_9B(struct rvt_qp *qp, struct hfi1_pkt_state *ps,
ibp = to_iport(qp->ibqp.device, qp->port_num); ibp = to_iport(qp->ibqp.device, qp->port_num);
ppd = ppd_from_ibp(ibp); ppd = ppd_from_ibp(ibp);
ah_attr = wqe->ud_wr.attr; ah_attr = rvt_get_swqe_ah_attr(wqe);
extra_bytes = -wqe->length & 3; extra_bytes = -wqe->length & 3;
nwords = ((wqe->length + extra_bytes) >> 2) + SIZE_OF_CRC; nwords = ((wqe->length + extra_bytes) >> 2) + SIZE_OF_CRC;
...@@ -379,7 +380,7 @@ void hfi1_make_ud_req_16B(struct rvt_qp *qp, struct hfi1_pkt_state *ps, ...@@ -379,7 +380,7 @@ void hfi1_make_ud_req_16B(struct rvt_qp *qp, struct hfi1_pkt_state *ps,
struct hfi1_pportdata *ppd; struct hfi1_pportdata *ppd;
struct hfi1_ibport *ibp; struct hfi1_ibport *ibp;
u32 dlid, slid, nwords, extra_bytes; u32 dlid, slid, nwords, extra_bytes;
u32 dest_qp = wqe->ud_wr.wr.remote_qpn; u32 dest_qp = rvt_get_swqe_remote_qpn(wqe);
u32 src_qp = qp->ibqp.qp_num; u32 src_qp = qp->ibqp.qp_num;
u16 len, pkey; u16 len, pkey;
u8 l4, sc5; u8 l4, sc5;
...@@ -387,7 +388,7 @@ void hfi1_make_ud_req_16B(struct rvt_qp *qp, struct hfi1_pkt_state *ps, ...@@ -387,7 +388,7 @@ void hfi1_make_ud_req_16B(struct rvt_qp *qp, struct hfi1_pkt_state *ps,
ibp = to_iport(qp->ibqp.device, qp->port_num); ibp = to_iport(qp->ibqp.device, qp->port_num);
ppd = ppd_from_ibp(ibp); ppd = ppd_from_ibp(ibp);
ah_attr = wqe->ud_wr.attr; ah_attr = rvt_get_swqe_ah_attr(wqe);
/* /*
* Build 16B Management Packet if either the destination * Build 16B Management Packet if either the destination
...@@ -449,7 +450,7 @@ void hfi1_make_ud_req_16B(struct rvt_qp *qp, struct hfi1_pkt_state *ps, ...@@ -449,7 +450,7 @@ void hfi1_make_ud_req_16B(struct rvt_qp *qp, struct hfi1_pkt_state *ps,
if (is_mgmt) { if (is_mgmt) {
l4 = OPA_16B_L4_FM; l4 = OPA_16B_L4_FM;
pkey = hfi1_get_pkey(ibp, wqe->ud_wr.wr.pkey_index); pkey = hfi1_get_pkey(ibp, rvt_get_swqe_pkey_index(wqe));
hfi1_16B_set_qpn(&ps->s_txreq->phdr.hdr.opah.u.mgmt, hfi1_16B_set_qpn(&ps->s_txreq->phdr.hdr.opah.u.mgmt,
dest_qp, src_qp); dest_qp, src_qp);
} else { } else {
...@@ -514,7 +515,7 @@ int hfi1_make_ud_req(struct rvt_qp *qp, struct hfi1_pkt_state *ps) ...@@ -514,7 +515,7 @@ int hfi1_make_ud_req(struct rvt_qp *qp, struct hfi1_pkt_state *ps)
/* Construct the header. */ /* Construct the header. */
ibp = to_iport(qp->ibqp.device, qp->port_num); ibp = to_iport(qp->ibqp.device, qp->port_num);
ppd = ppd_from_ibp(ibp); ppd = ppd_from_ibp(ibp);
ah_attr = wqe->ud_wr.attr; ah_attr = rvt_get_swqe_ah_attr(wqe);
priv->hdr_type = hfi1_get_hdr_type(ppd->lid, ah_attr); priv->hdr_type = hfi1_get_hdr_type(ppd->lid, ah_attr);
if ((!hfi1_check_mcast(rdma_ah_get_dlid(ah_attr))) || if ((!hfi1_check_mcast(rdma_ah_get_dlid(ah_attr))) ||
(rdma_ah_get_dlid(ah_attr) == be32_to_cpu(OPA_LID_PERMISSIVE))) { (rdma_ah_get_dlid(ah_attr) == be32_to_cpu(OPA_LID_PERMISSIVE))) {
......
...@@ -398,7 +398,7 @@ int qib_check_send_wqe(struct rvt_qp *qp, ...@@ -398,7 +398,7 @@ int qib_check_send_wqe(struct rvt_qp *qp,
case IB_QPT_SMI: case IB_QPT_SMI:
case IB_QPT_GSI: case IB_QPT_GSI:
case IB_QPT_UD: case IB_QPT_UD:
ah = ibah_to_rvtah(wqe->ud_wr.wr.ah); ah = rvt_get_swqe_ah(wqe);
if (wqe->length > (1 << ah->log_pmtu)) if (wqe->length > (1 << ah->log_pmtu))
return -EINVAL; return -EINVAL;
/* progress hint */ /* progress hint */
......
...@@ -64,7 +64,7 @@ static void qib_ud_loopback(struct rvt_qp *sqp, struct rvt_swqe *swqe) ...@@ -64,7 +64,7 @@ static void qib_ud_loopback(struct rvt_qp *sqp, struct rvt_swqe *swqe)
enum ib_qp_type sqptype, dqptype; enum ib_qp_type sqptype, dqptype;
rcu_read_lock(); rcu_read_lock();
qp = rvt_lookup_qpn(rdi, &ibp->rvp, swqe->ud_wr.wr.remote_qpn); qp = rvt_lookup_qpn(rdi, &ibp->rvp, rvt_get_swqe_remote_qpn(swqe));
if (!qp) { if (!qp) {
ibp->rvp.n_pkt_drops++; ibp->rvp.n_pkt_drops++;
goto drop; goto drop;
...@@ -81,7 +81,7 @@ static void qib_ud_loopback(struct rvt_qp *sqp, struct rvt_swqe *swqe) ...@@ -81,7 +81,7 @@ static void qib_ud_loopback(struct rvt_qp *sqp, struct rvt_swqe *swqe)
goto drop; goto drop;
} }
ah_attr = swqe->ud_wr.attr; ah_attr = rvt_get_swqe_ah_attr(swqe);
ppd = ppd_from_ibp(ibp); ppd = ppd_from_ibp(ibp);
if (qp->ibqp.qp_num > 1) { if (qp->ibqp.qp_num > 1) {
...@@ -111,8 +111,8 @@ static void qib_ud_loopback(struct rvt_qp *sqp, struct rvt_swqe *swqe) ...@@ -111,8 +111,8 @@ static void qib_ud_loopback(struct rvt_qp *sqp, struct rvt_swqe *swqe)
if (qp->ibqp.qp_num) { if (qp->ibqp.qp_num) {
u32 qkey; u32 qkey;
qkey = (int)swqe->ud_wr.wr.remote_qkey < 0 ? qkey = (int)rvt_get_swqe_remote_qkey(swqe) < 0 ?
sqp->qkey : swqe->ud_wr.wr.remote_qkey; sqp->qkey : rvt_get_swqe_remote_qkey(swqe);
if (unlikely(qkey != qp->qkey)) if (unlikely(qkey != qp->qkey))
goto drop; goto drop;
} }
...@@ -204,7 +204,7 @@ static void qib_ud_loopback(struct rvt_qp *sqp, struct rvt_swqe *swqe) ...@@ -204,7 +204,7 @@ static void qib_ud_loopback(struct rvt_qp *sqp, struct rvt_swqe *swqe)
wc.qp = &qp->ibqp; wc.qp = &qp->ibqp;
wc.src_qp = sqp->ibqp.qp_num; wc.src_qp = sqp->ibqp.qp_num;
wc.pkey_index = qp->ibqp.qp_type == IB_QPT_GSI ? wc.pkey_index = qp->ibqp.qp_type == IB_QPT_GSI ?
swqe->ud_wr.wr.pkey_index : 0; rvt_get_swqe_pkey_index(swqe) : 0;
wc.slid = ppd->lid | (rdma_ah_get_path_bits(ah_attr) & wc.slid = ppd->lid | (rdma_ah_get_path_bits(ah_attr) &
((1 << ppd->lmc) - 1)); ((1 << ppd->lmc) - 1));
wc.sl = rdma_ah_get_sl(ah_attr); wc.sl = rdma_ah_get_sl(ah_attr);
...@@ -271,7 +271,7 @@ int qib_make_ud_req(struct rvt_qp *qp, unsigned long *flags) ...@@ -271,7 +271,7 @@ int qib_make_ud_req(struct rvt_qp *qp, unsigned long *flags)
/* Construct the header. */ /* Construct the header. */
ibp = to_iport(qp->ibqp.device, qp->port_num); ibp = to_iport(qp->ibqp.device, qp->port_num);
ppd = ppd_from_ibp(ibp); ppd = ppd_from_ibp(ibp);
ah_attr = wqe->ud_wr.attr; ah_attr = rvt_get_swqe_ah_attr(wqe);
if (rdma_ah_get_dlid(ah_attr) >= be16_to_cpu(IB_MULTICAST_LID_BASE)) { if (rdma_ah_get_dlid(ah_attr) >= be16_to_cpu(IB_MULTICAST_LID_BASE)) {
if (rdma_ah_get_dlid(ah_attr) != if (rdma_ah_get_dlid(ah_attr) !=
be16_to_cpu(IB_LID_PERMISSIVE)) be16_to_cpu(IB_LID_PERMISSIVE))
...@@ -363,7 +363,7 @@ int qib_make_ud_req(struct rvt_qp *qp, unsigned long *flags) ...@@ -363,7 +363,7 @@ int qib_make_ud_req(struct rvt_qp *qp, unsigned long *flags)
bth0 |= extra_bytes << 20; bth0 |= extra_bytes << 20;
bth0 |= qp->ibqp.qp_type == IB_QPT_SMI ? QIB_DEFAULT_P_KEY : bth0 |= qp->ibqp.qp_type == IB_QPT_SMI ? QIB_DEFAULT_P_KEY :
qib_get_pkey(ibp, qp->ibqp.qp_type == IB_QPT_GSI ? qib_get_pkey(ibp, qp->ibqp.qp_type == IB_QPT_GSI ?
wqe->ud_wr.wr.pkey_index : qp->s_pkey_index); rvt_get_swqe_pkey_index(wqe) : qp->s_pkey_index);
ohdr->bth[0] = cpu_to_be32(bth0); ohdr->bth[0] = cpu_to_be32(bth0);
/* /*
* Use the multicast QP if the destination LID is a multicast LID. * Use the multicast QP if the destination LID is a multicast LID.
...@@ -372,14 +372,15 @@ int qib_make_ud_req(struct rvt_qp *qp, unsigned long *flags) ...@@ -372,14 +372,15 @@ int qib_make_ud_req(struct rvt_qp *qp, unsigned long *flags)
be16_to_cpu(IB_MULTICAST_LID_BASE) && be16_to_cpu(IB_MULTICAST_LID_BASE) &&
rdma_ah_get_dlid(ah_attr) != be16_to_cpu(IB_LID_PERMISSIVE) ? rdma_ah_get_dlid(ah_attr) != be16_to_cpu(IB_LID_PERMISSIVE) ?
cpu_to_be32(QIB_MULTICAST_QPN) : cpu_to_be32(QIB_MULTICAST_QPN) :
cpu_to_be32(wqe->ud_wr.wr.remote_qpn); cpu_to_be32(rvt_get_swqe_remote_qpn(wqe));
ohdr->bth[2] = cpu_to_be32(wqe->psn & QIB_PSN_MASK); ohdr->bth[2] = cpu_to_be32(wqe->psn & QIB_PSN_MASK);
/* /*
* Qkeys with the high order bit set mean use the * Qkeys with the high order bit set mean use the
* qkey from the QP context instead of the WR (see 10.2.5). * qkey from the QP context instead of the WR (see 10.2.5).
*/ */
ohdr->u.ud.deth[0] = cpu_to_be32((int)wqe->ud_wr.wr.remote_qkey < 0 ? ohdr->u.ud.deth[0] =
qp->qkey : wqe->ud_wr.wr.remote_qkey); cpu_to_be32((int)rvt_get_swqe_remote_qkey(wqe) < 0 ? qp->qkey :
rvt_get_swqe_remote_qkey(wqe));
ohdr->u.ud.deth[1] = cpu_to_be32(qp->ibqp.qp_num); ohdr->u.ud.deth[1] = cpu_to_be32(qp->ibqp.qp_num);
done: done:
......
...@@ -2089,7 +2089,7 @@ static int rvt_post_one_wr(struct rvt_qp *qp, ...@@ -2089,7 +2089,7 @@ static int rvt_post_one_wr(struct rvt_qp *qp,
*/ */
log_pmtu = qp->log_pmtu; log_pmtu = qp->log_pmtu;
if (qp->allowed_ops == IB_OPCODE_UD) { if (qp->allowed_ops == IB_OPCODE_UD) {
struct rvt_ah *ah = ibah_to_rvtah(wqe->ud_wr.wr.ah); struct rvt_ah *ah = rvt_get_swqe_ah(wqe);
log_pmtu = ah->log_pmtu; log_pmtu = ah->log_pmtu;
rdma_copy_ah_attr(wqe->ud_wr.attr, &ah->attr); rdma_copy_ah_attr(wqe->ud_wr.attr, &ah->attr);
......
...@@ -219,6 +219,56 @@ struct rvt_krwq { ...@@ -219,6 +219,56 @@ struct rvt_krwq {
struct rvt_rwqe wq[]; struct rvt_rwqe wq[];
}; };
/*
* rvt_get_swqe_ah - Return the pointer to the struct rvt_ah
* @swqe: valid Send WQE
*
*/
static inline struct rvt_ah *rvt_get_swqe_ah(struct rvt_swqe *swqe)
{
return ibah_to_rvtah(swqe->ud_wr.wr.ah);
}
/**
* rvt_get_swqe_ah_attr - Return the cached ah attribute information
* @swqe: valid Send WQE
*
*/
static inline struct rdma_ah_attr *rvt_get_swqe_ah_attr(struct rvt_swqe *swqe)
{
return swqe->ud_wr.attr;
}
/**
* rvt_get_swqe_remote_qpn - Access the remote QPN value
* @swqe: valid Send WQE
*
*/
static inline u32 rvt_get_swqe_remote_qpn(struct rvt_swqe *swqe)
{
return swqe->ud_wr.wr.remote_qpn;
}
/**
* rvt_get_swqe_remote_qkey - Acces the remote qkey value
* @swqe: valid Send WQE
*
*/
static inline u32 rvt_get_swqe_remote_qkey(struct rvt_swqe *swqe)
{
return swqe->ud_wr.wr.remote_qkey;
}
/**
* rvt_get_swqe_pkey_index - Access the pkey index
* @swqe: valid Send WQE
*
*/
static inline u16 rvt_get_swqe_pkey_index(struct rvt_swqe *swqe)
{
return swqe->ud_wr.wr.pkey_index;
}
struct rvt_rq { struct rvt_rq {
struct rvt_rwq *wq; struct rvt_rwq *wq;
struct rvt_krwq *kwq; struct rvt_krwq *kwq;
......
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