[openib-general] RE: static rate encoding changes

Hoang-Nam Nguyen HNGUYEN at de.ibm.com
Tue Apr 11 01:30:50 PDT 2006


Hi Roland!
For libehca (ehca user verbs) I realized that I also need conversion
functions ibv_rate_to_mult() and mult_to_ibv_rate() similar to the ones for
kernel space. I guess they might be used by others as well and did create a
patch for that, see below. Coud you review it? Thanks!
Regards
Hoang-Nam Nguyen


Index: src/userspace/libibverbs/include/infiniband/verbs.h
===================================================================
--- src/userspace/libibverbs/include/infiniband/verbs.h     (revision 6377)
+++ src/userspace/libibverbs/include/infiniband/verbs.h     (working copy)
@@ -306,6 +306,21 @@
      IBV_RATE_120_GBPS = 10
 };

+/**
+ * ibv_rate_to_mult - Convert the IB rate enum to a multiple of the
+ * base rate of 2.5 Gbit/sec.  For example, IBV_RATE_5_GBPS will be
+ * converted to 2, since 5 Gbit/sec is 2 * 2.5 Gbit/sec.
+ * @rate: rate to convert.
+ */
+int ibv_rate_to_mult(enum ibv_rate rate);
+
+/**
+ * mult_to_ibv_rate - Convert a multiple of 2.5 Gbit/sec to an IB rate
+ * enum.
+ * @mult: multiple to convert.
+ */
+enum ibv_rate mult_to_ibv_rate(int mult);
+
 struct ibv_ah_attr {
      struct ibv_global_route grh;
      uint16_t          dlid;
Index: src/userspace/libibverbs/src/libibverbs.map
===================================================================
--- src/userspace/libibverbs/src/libibverbs.map (revision 6377)
+++ src/userspace/libibverbs/src/libibverbs.map (working copy)
@@ -67,5 +67,7 @@
            ib_copy_qp_attr_from_kern;
            ib_copy_path_rec_from_kern;
            ib_copy_path_rec_to_kern;
+           ibv_rate_to_mult;
+           mult_to_ibv_rate;
      local: *;
 };
Index: src/userspace/libibverbs/src/verbs.c
===================================================================
--- src/userspace/libibverbs/src/verbs.c  (revision 6377)
+++ src/userspace/libibverbs/src/verbs.c  (working copy)
@@ -366,6 +366,38 @@
      return qp->context->ops.destroy_qp(qp);
 }

+int ibv_rate_to_mult(enum ibv_rate rate)
+{
+     switch (rate) {
+     case IBV_RATE_2_5_GBPS: return  1;
+     case IBV_RATE_5_GBPS:   return  2;
+     case IBV_RATE_10_GBPS:  return  4;
+     case IBV_RATE_20_GBPS:  return  8;
+     case IBV_RATE_30_GBPS:  return 12;
+     case IBV_RATE_40_GBPS:  return 16;
+     case IBV_RATE_60_GBPS:  return 24;
+     case IBV_RATE_80_GBPS:  return 32;
+     case IBV_RATE_120_GBPS: return 48;
+     default:           return -1;
+     }
+}
+
+enum ibv_rate mult_to_ibv_rate(int mult)
+{
+     switch (mult) {
+     case 1:  return IBV_RATE_2_5_GBPS;
+     case 2:  return IBV_RATE_5_GBPS;
+     case 4:  return IBV_RATE_10_GBPS;
+     case 8:  return IBV_RATE_20_GBPS;
+     case 12: return IBV_RATE_30_GBPS;
+     case 16: return IBV_RATE_40_GBPS;
+     case 24: return IBV_RATE_60_GBPS;
+     case 32: return IBV_RATE_80_GBPS;
+     case 48: return IBV_RATE_120_GBPS;
+     default: return IBV_RATE_MAX;
+     }
+}
+
 struct ibv_ah *ibv_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr)
 {
      struct ibv_ah *ah = pd->context->ops.create_ah(pd, attr);


(See attached file: myipd.diff)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: myipd.diff
Type: application/octet-stream
Size: 2547 bytes
Desc: not available
URL: <http://lists.openfabrics.org/pipermail/general/attachments/20060411/fc7d38f7/attachment.obj>


More information about the general mailing list