[PATCH 16/27] Add ib_create_ah_from_wc to IB verbs

2005-07-11 Thread Hal Rosenstock
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]>

This patch depends on patch 15/27.

-- 
 core/verbs.c   |   35 +++
 include/ib_mad.h   |9 --
 include/ib_verbs.h |   24 
 3 files changed, 59 insertions(+), 9 deletions(-)
diff -uprN linux-2.6.13-rc2-mm1/drivers/infiniband15/core/verbs.c 
linux-2.6.13-rc2-mm1/drivers/infiniband16/core/verbs.c
-- linux-2.6.13-rc2-mm1/drivers/infiniband15/core/verbs.c   2005-07-10 
11:09:37.0 -0400
+++ linux-2.6.13-rc2-mm1/drivers/infiniband16/core/verbs.c  2005-07-10 
11:43:44.0 -0400
@@ -41,6 +41,7 @@
 #include 
 
 #include 
+#include 
 
 /* Protection domains */
 
@@ -88,6 +89,40 @@ struct ib_ah *ib_create_ah(struct ib_pd 
 }
 EXPORT_SYMBOL(ib_create_ah);
 
+struct ib_ah *ib_create_ah_from_wc(struct ib_pd *pd, struct ib_wc *wc,
+  struct ib_grh *grh, u8 port_num)
+{
+   struct ib_ah_attr ah_attr;
+   u32 flow_class;
+   u16 gid_index;
+   int ret;
+
+   memset(_attr, 0, sizeof ah_attr);
+   ah_attr.dlid = wc->slid;
+   ah_attr.sl = wc->sl;
+   ah_attr.src_path_bits = wc->dlid_path_bits;
+   ah_attr.port_num = port_num;
+   
+   if (wc->wc_flags & IB_WC_GRH) {
+   ah_attr.ah_flags = IB_AH_GRH;
+   ah_attr.grh.dgid = grh->dgid;
+
+   ret = ib_find_cached_gid(pd->device, >sgid, _num,
+_index);
+   if (ret)
+   return ERR_PTR(ret);
+
+   ah_attr.grh.sgid_index = (u8) gid_index;
+   flow_class = be32_to_cpu(>version_tclass_flow);
+   ah_attr.grh.flow_label = flow_class & 0xF;
+   ah_attr.grh.traffic_class = (flow_class >> 20) & 0xFF;
+   ah_attr.grh.hop_limit = grh->hop_limit;
+   }
+
+   return ib_create_ah(pd, _attr);
+}
+EXPORT_SYMBOL(ib_create_ah_from_wc);
+
 int ib_modify_ah(struct ib_ah *ah, struct ib_ah_attr *ah_attr)
 {
return ah->device->modify_ah ?
diff -uprN linux-2.6.13-rc2-mm1/drivers/infiniband15/include/ib_mad.h 
linux-2.6.13-rc2-mm1/drivers/infiniband16/include/ib_mad.h
-- linux-2.6.13-rc2-mm1/drivers/infiniband15/include/ib_mad.h   2005-07-09 
17:57:11.0 -0400
+++ linux-2.6.13-rc2-mm1/drivers/infiniband16/include/ib_mad.h  2005-07-10 
11:43:45.0 -0400
@@ -77,15 +77,6 @@
 #define IB_QP1_QKEY0x8001
 #define IB_QP_SET_QKEY 0x8000
 
-struct ib_grh {
-   u32 version_tclass_flow;
-   u16 paylen;
-   u8  next_hdr;
-   u8  hop_limit;
-   union ib_gidsgid;
-   union ib_giddgid;
-} __attribute__ ((packed));
-
 struct ib_mad_hdr {
u8  base_version;
u8  mgmt_class;
diff -uprN linux-2.6.13-rc2-mm1/drivers/infiniband15/include/ib_verbs.h 
linux-2.6.13-rc2-mm1/drivers/infiniband16/include/ib_verbs.h
-- linux-2.6.13-rc2-mm1/drivers/infiniband15/include/ib_verbs.h 2005-07-10 
10:55:59.0 -0400
+++ linux-2.6.13-rc2-mm1/drivers/infiniband16/include/ib_verbs.h
2005-07-10 11:43:45.0 -0400
@@ -289,6 +289,15 @@ struct ib_global_route {
u8  traffic_class;
 };
 
+struct ib_grh {
+   u32 version_tclass_flow;
+   u16 paylen;
+   u8  next_hdr;
+   u8  hop_limit;
+   union ib_gidsgid;
+   union ib_giddgid;
+};
+
 enum {
IB_MULTICAST_QPN = 0xff
 };
@@ -991,6 +1000,21 @@ int ib_dealloc_pd(struct ib_pd *pd);
 struct ib_ah *ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr);
 
 /**
+ * ib_create_ah_from_wc - Creates an address handle associated with the
+ *   sender of the specified work completion.
+ * @pd: The protection domain associated with the address handle.
+ * @wc: Work completion information associated with a received message.
+ * @grh: References the received global route header.  This parameter is
+ *   ignored unless the work completion indicates that the GRH is valid.
+ * @port_num: The outbound port number to associate with the address.
+ *
+ * The address handle is used to reference a local or global destination
+ * in all UD QP post sends.
+ */
+struct ib_ah *ib_create_ah_from_wc(struct ib_pd *pd, struct ib_wc *wc,
+  struct ib_grh *grh, u8 port_num);
+
+/**
  * ib_modify_ah - Modifies the address vector associated with an address
  *   handle.
  * @ah: The address handle to modify.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 16/27] Add ib_create_ah_from_wc to IB verbs

2005-07-11 Thread Hal Rosenstock
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]

This patch depends on patch 15/27.

-- 
 core/verbs.c   |   35 +++
 include/ib_mad.h   |9 --
 include/ib_verbs.h |   24 
 3 files changed, 59 insertions(+), 9 deletions(-)
diff -uprN linux-2.6.13-rc2-mm1/drivers/infiniband15/core/verbs.c 
linux-2.6.13-rc2-mm1/drivers/infiniband16/core/verbs.c
-- linux-2.6.13-rc2-mm1/drivers/infiniband15/core/verbs.c   2005-07-10 
11:09:37.0 -0400
+++ linux-2.6.13-rc2-mm1/drivers/infiniband16/core/verbs.c  2005-07-10 
11:43:44.0 -0400
@@ -41,6 +41,7 @@
 #include linux/err.h
 
 #include ib_verbs.h
+#include ib_cache.h
 
 /* Protection domains */
 
@@ -88,6 +89,40 @@ struct ib_ah *ib_create_ah(struct ib_pd 
 }
 EXPORT_SYMBOL(ib_create_ah);
 
+struct ib_ah *ib_create_ah_from_wc(struct ib_pd *pd, struct ib_wc *wc,
+  struct ib_grh *grh, u8 port_num)
+{
+   struct ib_ah_attr ah_attr;
+   u32 flow_class;
+   u16 gid_index;
+   int ret;
+
+   memset(ah_attr, 0, sizeof ah_attr);
+   ah_attr.dlid = wc-slid;
+   ah_attr.sl = wc-sl;
+   ah_attr.src_path_bits = wc-dlid_path_bits;
+   ah_attr.port_num = port_num;
+   
+   if (wc-wc_flags  IB_WC_GRH) {
+   ah_attr.ah_flags = IB_AH_GRH;
+   ah_attr.grh.dgid = grh-dgid;
+
+   ret = ib_find_cached_gid(pd-device, grh-sgid, port_num,
+gid_index);
+   if (ret)
+   return ERR_PTR(ret);
+
+   ah_attr.grh.sgid_index = (u8) gid_index;
+   flow_class = be32_to_cpu(grh-version_tclass_flow);
+   ah_attr.grh.flow_label = flow_class  0xF;
+   ah_attr.grh.traffic_class = (flow_class  20)  0xFF;
+   ah_attr.grh.hop_limit = grh-hop_limit;
+   }
+
+   return ib_create_ah(pd, ah_attr);
+}
+EXPORT_SYMBOL(ib_create_ah_from_wc);
+
 int ib_modify_ah(struct ib_ah *ah, struct ib_ah_attr *ah_attr)
 {
return ah-device-modify_ah ?
diff -uprN linux-2.6.13-rc2-mm1/drivers/infiniband15/include/ib_mad.h 
linux-2.6.13-rc2-mm1/drivers/infiniband16/include/ib_mad.h
-- linux-2.6.13-rc2-mm1/drivers/infiniband15/include/ib_mad.h   2005-07-09 
17:57:11.0 -0400
+++ linux-2.6.13-rc2-mm1/drivers/infiniband16/include/ib_mad.h  2005-07-10 
11:43:45.0 -0400
@@ -77,15 +77,6 @@
 #define IB_QP1_QKEY0x8001
 #define IB_QP_SET_QKEY 0x8000
 
-struct ib_grh {
-   u32 version_tclass_flow;
-   u16 paylen;
-   u8  next_hdr;
-   u8  hop_limit;
-   union ib_gidsgid;
-   union ib_giddgid;
-} __attribute__ ((packed));
-
 struct ib_mad_hdr {
u8  base_version;
u8  mgmt_class;
diff -uprN linux-2.6.13-rc2-mm1/drivers/infiniband15/include/ib_verbs.h 
linux-2.6.13-rc2-mm1/drivers/infiniband16/include/ib_verbs.h
-- linux-2.6.13-rc2-mm1/drivers/infiniband15/include/ib_verbs.h 2005-07-10 
10:55:59.0 -0400
+++ linux-2.6.13-rc2-mm1/drivers/infiniband16/include/ib_verbs.h
2005-07-10 11:43:45.0 -0400
@@ -289,6 +289,15 @@ struct ib_global_route {
u8  traffic_class;
 };
 
+struct ib_grh {
+   u32 version_tclass_flow;
+   u16 paylen;
+   u8  next_hdr;
+   u8  hop_limit;
+   union ib_gidsgid;
+   union ib_giddgid;
+};
+
 enum {
IB_MULTICAST_QPN = 0xff
 };
@@ -991,6 +1000,21 @@ int ib_dealloc_pd(struct ib_pd *pd);
 struct ib_ah *ib_create_ah(struct ib_pd *pd, struct ib_ah_attr *ah_attr);
 
 /**
+ * ib_create_ah_from_wc - Creates an address handle associated with the
+ *   sender of the specified work completion.
+ * @pd: The protection domain associated with the address handle.
+ * @wc: Work completion information associated with a received message.
+ * @grh: References the received global route header.  This parameter is
+ *   ignored unless the work completion indicates that the GRH is valid.
+ * @port_num: The outbound port number to associate with the address.
+ *
+ * The address handle is used to reference a local or global destination
+ * in all UD QP post sends.
+ */
+struct ib_ah *ib_create_ah_from_wc(struct ib_pd *pd, struct ib_wc *wc,
+  struct ib_grh *grh, u8 port_num);
+
+/**
  * ib_modify_ah - Modifies the address vector associated with an address
  *   handle.
  * @ah: The address handle to modify.


-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/