Skip to content

Commit d8966fc

Browse files
Dasaratharaman Chandramoulidledford
authored andcommitted
IB/core: Use rdma_ah_attr accessor functions
Modify core and driver components to use accessor functions introduced to access individual fields of rdma_ah_attr Reviewed-by: Ira Weiny <[email protected]> Reviewed-by: Don Hiatt <[email protected]> Reviewed-by: Sean Hefty <[email protected]> Reviewed-by: Niranjana Vishwanathapura <[email protected]> Signed-off-by: Dasaratharaman Chandramouli <[email protected]> Signed-off-by: Doug Ledford <[email protected]>
1 parent 2224c47 commit d8966fc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1040
-881
lines changed

drivers/infiniband/core/cm.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,6 +1722,7 @@ static int cm_req_handler(struct cm_work *work)
17221722
struct cm_req_msg *req_msg;
17231723
union ib_gid gid;
17241724
struct ib_gid_attr gid_attr;
1725+
const struct ib_global_route *grh;
17251726
int ret;
17261727

17271728
req_msg = (struct cm_req_msg *)work->mad_recv_wc->recv_buf.mad;
@@ -1761,10 +1762,11 @@ static int cm_req_handler(struct cm_work *work)
17611762
cm_format_paths_from_req(req_msg, &work->path[0], &work->path[1]);
17621763

17631764
memcpy(work->path[0].dmac, cm_id_priv->av.ah_attr.dmac, ETH_ALEN);
1764-
work->path[0].hop_limit = cm_id_priv->av.ah_attr.grh.hop_limit;
1765+
grh = rdma_ah_read_grh(&cm_id_priv->av.ah_attr);
1766+
work->path[0].hop_limit = grh->hop_limit;
17651767
ret = ib_get_cached_gid(work->port->cm_dev->ib_device,
17661768
work->port->port_num,
1767-
cm_id_priv->av.ah_attr.grh.sgid_index,
1769+
grh->sgid_index,
17681770
&gid, &gid_attr);
17691771
if (!ret) {
17701772
if (gid_attr.ndev) {
@@ -3800,7 +3802,7 @@ static int cm_init_qp_rtr_attr(struct cm_id_private *cm_id_priv,
38003802
cm_id_priv->responder_resources;
38013803
qp_attr->min_rnr_timer = 0;
38023804
}
3803-
if (cm_id_priv->alt_av.ah_attr.dlid) {
3805+
if (rdma_ah_get_dlid(&cm_id_priv->alt_av.ah_attr)) {
38043806
*qp_attr_mask |= IB_QP_ALT_PATH;
38053807
qp_attr->alt_port_num = cm_id_priv->alt_av.port->port_num;
38063808
qp_attr->alt_pkey_index = cm_id_priv->alt_av.pkey_index;
@@ -3854,7 +3856,7 @@ static int cm_init_qp_rts_attr(struct cm_id_private *cm_id_priv,
38543856
default:
38553857
break;
38563858
}
3857-
if (cm_id_priv->alt_av.ah_attr.dlid) {
3859+
if (rdma_ah_get_dlid(&cm_id_priv->alt_av.ah_attr)) {
38583860
*qp_attr_mask |= IB_QP_PATH_MIG_STATE;
38593861
qp_attr->path_mig_state = IB_MIG_REARM;
38603862
}

drivers/infiniband/core/cma.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,8 @@ static int cma_modify_qp_rtr(struct rdma_id_private *id_priv,
929929
goto out;
930930

931931
ret = ib_query_gid(id_priv->id.device, id_priv->id.port_num,
932-
qp_attr.ah_attr.grh.sgid_index, &sgid, NULL);
932+
rdma_ah_read_grh(&qp_attr.ah_attr)->sgid_index,
933+
&sgid, NULL);
933934
if (ret)
934935
goto out;
935936

drivers/infiniband/core/mad.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1839,6 +1839,7 @@ static inline int rcv_has_same_gid(const struct ib_mad_agent_private *mad_agent_
18391839
struct ib_device *device = mad_agent_priv->agent.device;
18401840
u8 port_num = mad_agent_priv->agent.port_num;
18411841
u8 lmc;
1842+
bool has_grh;
18421843

18431844
send_resp = ib_response_mad((struct ib_mad_hdr *)wr->send_buf.mad);
18441845
rcv_resp = ib_response_mad(&rwc->recv_buf.mad->mad_hdr);
@@ -1851,32 +1852,36 @@ static inline int rcv_has_same_gid(const struct ib_mad_agent_private *mad_agent_
18511852
/* Assume not equal, to avoid false positives. */
18521853
return 0;
18531854

1854-
if (!!(attr.ah_flags & IB_AH_GRH) !=
1855-
!!(rwc->wc->wc_flags & IB_WC_GRH))
1855+
has_grh = !!(rdma_ah_get_ah_flags(&attr) & IB_AH_GRH);
1856+
if (has_grh != !!(rwc->wc->wc_flags & IB_WC_GRH))
18561857
/* one has GID, other does not. Assume different */
18571858
return 0;
18581859

18591860
if (!send_resp && rcv_resp) {
18601861
/* is request/response. */
1861-
if (!(attr.ah_flags & IB_AH_GRH)) {
1862+
if (!has_grh) {
18621863
if (ib_get_cached_lmc(device, port_num, &lmc))
18631864
return 0;
1864-
return (!lmc || !((attr.src_path_bits ^
1865+
return (!lmc || !((rdma_ah_get_path_bits(&attr) ^
18651866
rwc->wc->dlid_path_bits) &
18661867
((1 << lmc) - 1)));
18671868
} else {
1869+
const struct ib_global_route *grh =
1870+
rdma_ah_read_grh(&attr);
1871+
18681872
if (ib_get_cached_gid(device, port_num,
1869-
attr.grh.sgid_index, &sgid, NULL))
1873+
grh->sgid_index, &sgid, NULL))
18701874
return 0;
18711875
return !memcmp(sgid.raw, rwc->recv_buf.grh->dgid.raw,
18721876
16);
18731877
}
18741878
}
18751879

1876-
if (!(attr.ah_flags & IB_AH_GRH))
1877-
return attr.dlid == rwc->wc->slid;
1880+
if (!has_grh)
1881+
return rdma_ah_get_dlid(&attr) == rwc->wc->slid;
18781882
else
1879-
return !memcmp(attr.grh.dgid.raw, rwc->recv_buf.grh->sgid.raw,
1883+
return !memcmp(rdma_ah_read_grh(&attr)->dgid.raw,
1884+
rwc->recv_buf.grh->sgid.raw,
18801885
16);
18811886
}
18821887

drivers/infiniband/core/mad_rmpp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ static int init_newwin(struct ib_mad_send_wr_private *mad_send_wr)
870870
if (rdma_query_ah(mad_send_wr->send_buf.ah, &ah_attr))
871871
continue;
872872

873-
if (rmpp_recv->slid == ah_attr.dlid) {
873+
if (rmpp_recv->slid == rdma_ah_get_dlid(&ah_attr)) {
874874
newwin = rmpp_recv->repwin;
875875
break;
876876
}

drivers/infiniband/core/multicast.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -743,19 +743,17 @@ int ib_init_ah_from_mcmember(struct ib_device *device, u8 port_num,
743743
return ret;
744744

745745
memset(ah_attr, 0, sizeof *ah_attr);
746-
ah_attr->dlid = be16_to_cpu(rec->mlid);
747-
ah_attr->sl = rec->sl;
748-
ah_attr->port_num = port_num;
749-
ah_attr->static_rate = rec->rate;
750746

751-
ah_attr->ah_flags = IB_AH_GRH;
752-
ah_attr->grh.dgid = rec->mgid;
753-
754-
ah_attr->grh.sgid_index = (u8) gid_index;
755-
ah_attr->grh.flow_label = be32_to_cpu(rec->flow_label);
756-
ah_attr->grh.hop_limit = rec->hop_limit;
757-
ah_attr->grh.traffic_class = rec->traffic_class;
747+
rdma_ah_set_dlid(ah_attr, be16_to_cpu(rec->mlid));
748+
rdma_ah_set_sl(ah_attr, rec->sl);
749+
rdma_ah_set_port_num(ah_attr, port_num);
750+
rdma_ah_set_static_rate(ah_attr, rec->rate);
758751

752+
rdma_ah_set_grh(ah_attr, &rec->mgid,
753+
be32_to_cpu(rec->flow_label),
754+
(u8)gid_index,
755+
rec->hop_limit,
756+
rec->traffic_class);
759757
return 0;
760758
}
761759
EXPORT_SYMBOL(ib_init_ah_from_mcmember);

drivers/infiniband/core/sa_query.c

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,13 +1108,13 @@ int ib_init_ah_from_path(struct ib_device *device, u8 port_num,
11081108
struct net_device *ndev = NULL;
11091109

11101110
memset(ah_attr, 0, sizeof *ah_attr);
1111-
ah_attr->dlid = be16_to_cpu(rec->dlid);
1112-
ah_attr->sl = rec->sl;
1113-
ah_attr->src_path_bits = be16_to_cpu(rec->slid) &
1114-
get_src_path_mask(device, port_num);
1115-
ah_attr->port_num = port_num;
1116-
ah_attr->static_rate = rec->rate;
11171111

1112+
rdma_ah_set_dlid(ah_attr, be16_to_cpu(rec->dlid));
1113+
rdma_ah_set_sl(ah_attr, rec->sl);
1114+
rdma_ah_set_path_bits(ah_attr, be16_to_cpu(rec->slid) &
1115+
get_src_path_mask(device, port_num));
1116+
rdma_ah_set_port_num(ah_attr, port_num);
1117+
rdma_ah_set_static_rate(ah_attr, rec->rate);
11181118
use_roce = rdma_cap_eth_ah(device, port_num);
11191119

11201120
if (use_roce) {
@@ -1174,9 +1174,6 @@ int ib_init_ah_from_path(struct ib_device *device, u8 port_num,
11741174
}
11751175

11761176
if (rec->hop_limit > 0 || use_roce) {
1177-
ah_attr->ah_flags = IB_AH_GRH;
1178-
ah_attr->grh.dgid = rec->dgid;
1179-
11801177
ret = ib_find_cached_gid_by_port(device, &rec->sgid,
11811178
rec->gid_type, port_num, ndev,
11821179
&gid_index);
@@ -1186,10 +1183,10 @@ int ib_init_ah_from_path(struct ib_device *device, u8 port_num,
11861183
return ret;
11871184
}
11881185

1189-
ah_attr->grh.sgid_index = gid_index;
1190-
ah_attr->grh.flow_label = be32_to_cpu(rec->flow_label);
1191-
ah_attr->grh.hop_limit = rec->hop_limit;
1192-
ah_attr->grh.traffic_class = rec->traffic_class;
1186+
rdma_ah_set_grh(ah_attr, &rec->dgid,
1187+
be32_to_cpu(rec->flow_label),
1188+
gid_index, rec->hop_limit,
1189+
rec->traffic_class);
11931190
if (ndev)
11941191
dev_put(ndev);
11951192
}
@@ -2032,15 +2029,16 @@ static void update_sm_ah(struct work_struct *work)
20322029
pr_err("Couldn't find index for default PKey\n");
20332030

20342031
memset(&ah_attr, 0, sizeof(ah_attr));
2035-
ah_attr.dlid = port_attr.sm_lid;
2036-
ah_attr.sl = port_attr.sm_sl;
2037-
ah_attr.port_num = port->port_num;
2032+
rdma_ah_set_dlid(&ah_attr, port_attr.sm_lid);
2033+
rdma_ah_set_sl(&ah_attr, port_attr.sm_sl);
2034+
rdma_ah_set_port_num(&ah_attr, port->port_num);
20382035
if (port_attr.grh_required) {
2039-
ah_attr.ah_flags = IB_AH_GRH;
2040-
ah_attr.grh.dgid.global.subnet_prefix =
2041-
cpu_to_be64(port_attr.subnet_prefix);
2042-
ah_attr.grh.dgid.global.interface_id =
2043-
cpu_to_be64(IB_SA_WELL_KNOWN_GUID);
2036+
rdma_ah_set_ah_flags(&ah_attr, IB_AH_GRH);
2037+
2038+
rdma_ah_set_subnet_prefix(&ah_attr,
2039+
cpu_to_be64(port_attr.subnet_prefix));
2040+
rdma_ah_set_interface_id(&ah_attr,
2041+
cpu_to_be64(IB_SA_WELL_KNOWN_GUID));
20442042
}
20452043

20462044
new_ah->ah = rdma_create_ah(port->agent->qp->pd, &ah_attr);

drivers/infiniband/core/user_mad.c

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -236,16 +236,18 @@ static void recv_handler(struct ib_mad_agent *agent,
236236
packet->mad.hdr.grh_present = !!(mad_recv_wc->wc->wc_flags & IB_WC_GRH);
237237
if (packet->mad.hdr.grh_present) {
238238
struct rdma_ah_attr ah_attr;
239+
const struct ib_global_route *grh;
239240

240241
ib_init_ah_from_wc(agent->device, agent->port_num,
241242
mad_recv_wc->wc, mad_recv_wc->recv_buf.grh,
242243
&ah_attr);
243244

244-
packet->mad.hdr.gid_index = ah_attr.grh.sgid_index;
245-
packet->mad.hdr.hop_limit = ah_attr.grh.hop_limit;
246-
packet->mad.hdr.traffic_class = ah_attr.grh.traffic_class;
247-
memcpy(packet->mad.hdr.gid, &ah_attr.grh.dgid, 16);
248-
packet->mad.hdr.flow_label = cpu_to_be32(ah_attr.grh.flow_label);
245+
grh = rdma_ah_read_grh(&ah_attr);
246+
packet->mad.hdr.gid_index = grh->sgid_index;
247+
packet->mad.hdr.hop_limit = grh->hop_limit;
248+
packet->mad.hdr.traffic_class = grh->traffic_class;
249+
memcpy(packet->mad.hdr.gid, &grh->dgid, 16);
250+
packet->mad.hdr.flow_label = cpu_to_be32(grh->flow_label);
249251
}
250252

251253
if (queue_packet(file, agent, packet))
@@ -489,17 +491,17 @@ static ssize_t ib_umad_write(struct file *filp, const char __user *buf,
489491
}
490492

491493
memset(&ah_attr, 0, sizeof ah_attr);
492-
ah_attr.dlid = be16_to_cpu(packet->mad.hdr.lid);
493-
ah_attr.sl = packet->mad.hdr.sl;
494-
ah_attr.src_path_bits = packet->mad.hdr.path_bits;
495-
ah_attr.port_num = file->port->port_num;
494+
rdma_ah_set_dlid(&ah_attr, be16_to_cpu(packet->mad.hdr.lid));
495+
rdma_ah_set_sl(&ah_attr, packet->mad.hdr.sl);
496+
rdma_ah_set_path_bits(&ah_attr, packet->mad.hdr.path_bits);
497+
rdma_ah_set_port_num(&ah_attr, file->port->port_num);
496498
if (packet->mad.hdr.grh_present) {
497-
ah_attr.ah_flags = IB_AH_GRH;
498-
memcpy(ah_attr.grh.dgid.raw, packet->mad.hdr.gid, 16);
499-
ah_attr.grh.sgid_index = packet->mad.hdr.gid_index;
500-
ah_attr.grh.flow_label = be32_to_cpu(packet->mad.hdr.flow_label);
501-
ah_attr.grh.hop_limit = packet->mad.hdr.hop_limit;
502-
ah_attr.grh.traffic_class = packet->mad.hdr.traffic_class;
499+
rdma_ah_set_grh(&ah_attr, NULL,
500+
be32_to_cpu(packet->mad.hdr.flow_label),
501+
packet->mad.hdr.gid_index,
502+
packet->mad.hdr.hop_limit,
503+
packet->mad.hdr.traffic_class);
504+
rdma_ah_set_dgid_raw(&ah_attr, packet->mad.hdr.gid);
503505
}
504506

505507
ah = rdma_create_ah(agent->qp->pd, &ah_attr);

0 commit comments

Comments
 (0)