Skip to content

Commit 513789e

Browse files
Hal RosenstockLinus Torvalds
authored andcommitted
[PATCH] IB: Add ib_create_ah_from_wc to IB verbs
Added new call: ib_create_ah_from_wc. Call will allocate an address handle given work completion information, including any received GRH. Signed-off-by: Sean Hefty <[email protected]> Signed-off-by: Hal Rosenstock <[email protected]> Cc: Roland Dreier <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent cabe3cb commit 513789e

File tree

3 files changed

+59
-9
lines changed

3 files changed

+59
-9
lines changed

drivers/infiniband/core/verbs.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include <linux/err.h>
4242

4343
#include <ib_verbs.h>
44+
#include <ib_cache.h>
4445

4546
/* Protection domains */
4647

@@ -88,6 +89,40 @@ struct ib_ah *ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr)
8889
}
8990
EXPORT_SYMBOL(ib_create_ah);
9091

92+
struct ib_ah *ib_create_ah_from_wc(struct ib_pd *pd, struct ib_wc *wc,
93+
struct ib_grh *grh, u8 port_num)
94+
{
95+
struct ib_ah_attr ah_attr;
96+
u32 flow_class;
97+
u16 gid_index;
98+
int ret;
99+
100+
memset(&ah_attr, 0, sizeof ah_attr);
101+
ah_attr.dlid = wc->slid;
102+
ah_attr.sl = wc->sl;
103+
ah_attr.src_path_bits = wc->dlid_path_bits;
104+
ah_attr.port_num = port_num;
105+
106+
if (wc->wc_flags & IB_WC_GRH) {
107+
ah_attr.ah_flags = IB_AH_GRH;
108+
ah_attr.grh.dgid = grh->dgid;
109+
110+
ret = ib_find_cached_gid(pd->device, &grh->sgid, &port_num,
111+
&gid_index);
112+
if (ret)
113+
return ERR_PTR(ret);
114+
115+
ah_attr.grh.sgid_index = (u8) gid_index;
116+
flow_class = be32_to_cpu(&grh->version_tclass_flow);
117+
ah_attr.grh.flow_label = flow_class & 0xFFFFF;
118+
ah_attr.grh.traffic_class = (flow_class >> 20) & 0xFF;
119+
ah_attr.grh.hop_limit = grh->hop_limit;
120+
}
121+
122+
return ib_create_ah(pd, &ah_attr);
123+
}
124+
EXPORT_SYMBOL(ib_create_ah_from_wc);
125+
91126
int ib_modify_ah(struct ib_ah *ah, struct ib_ah_attr *ah_attr)
92127
{
93128
return ah->device->modify_ah ?

drivers/infiniband/include/ib_mad.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,6 @@
7777
#define IB_QP1_QKEY 0x80010000
7878
#define IB_QP_SET_QKEY 0x80000000
7979

80-
struct ib_grh {
81-
u32 version_tclass_flow;
82-
u16 paylen;
83-
u8 next_hdr;
84-
u8 hop_limit;
85-
union ib_gid sgid;
86-
union ib_gid dgid;
87-
} __attribute__ ((packed));
88-
8980
struct ib_mad_hdr {
9081
u8 base_version;
9182
u8 mgmt_class;

drivers/infiniband/include/ib_verbs.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,15 @@ struct ib_global_route {
289289
u8 traffic_class;
290290
};
291291

292+
struct ib_grh {
293+
u32 version_tclass_flow;
294+
u16 paylen;
295+
u8 next_hdr;
296+
u8 hop_limit;
297+
union ib_gid sgid;
298+
union ib_gid dgid;
299+
};
300+
292301
enum {
293302
IB_MULTICAST_QPN = 0xffffff
294303
};
@@ -990,6 +999,21 @@ int ib_dealloc_pd(struct ib_pd *pd);
990999
*/
9911000
struct ib_ah *ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr);
9921001

1002+
/**
1003+
* ib_create_ah_from_wc - Creates an address handle associated with the
1004+
* sender of the specified work completion.
1005+
* @pd: The protection domain associated with the address handle.
1006+
* @wc: Work completion information associated with a received message.
1007+
* @grh: References the received global route header. This parameter is
1008+
* ignored unless the work completion indicates that the GRH is valid.
1009+
* @port_num: The outbound port number to associate with the address.
1010+
*
1011+
* The address handle is used to reference a local or global destination
1012+
* in all UD QP post sends.
1013+
*/
1014+
struct ib_ah *ib_create_ah_from_wc(struct ib_pd *pd, struct ib_wc *wc,
1015+
struct ib_grh *grh, u8 port_num);
1016+
9931017
/**
9941018
* ib_modify_ah - Modifies the address vector associated with an address
9951019
* handle.

0 commit comments

Comments
 (0)