summaryrefslogtreecommitdiffstats
path: root/include/rdma
diff options
context:
space:
mode:
authorDasaratharaman Chandramouli <dasaratharaman.chandramouli@intel.com>2017-04-29 14:41:29 -0400
committerDoug Ledford <dledford@redhat.com>2017-05-01 14:32:43 -0400
commit44c58487d51a0dc43d96f1dc864f0461ec6a346a (patch)
treeedab4f4f87a0347b8abf9169cd3f030ffc6439bd /include/rdma
parentd8966fcd4c25708c3a76ea7619644218373df639 (diff)
downloadlinux-44c58487d51a0dc43d96f1dc864f0461ec6a346a.tar.gz
linux-44c58487d51a0dc43d96f1dc864f0461ec6a346a.tar.bz2
linux-44c58487d51a0dc43d96f1dc864f0461ec6a346a.zip
IB/core: Define 'ib' and 'roce' rdma_ah_attr types
rdma_ah_attr can now be either ib or roce allowing core components to use one type or the other and also to define attributes unique to a specific type. struct ib_ah is also initialized with the type when its first created. This ensures that calls such as modify_ah dont modify the type of the address handle attribute. Reviewed-by: Ira Weiny <ira.weiny@intel.com> Reviewed-by: Don Hiatt <don.hiatt@intel.com> Reviewed-by: Sean Hefty <sean.hefty@intel.com> Reviewed-by: Niranjana Vishwanathapura <niranjana.vishwanathapura@intel.com> Signed-off-by: Dasaratharaman Chandramouli <dasaratharaman.chandramouli@intel.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
Diffstat (limited to 'include/rdma')
-rw-r--r--include/rdma/ib_verbs.h58
1 files changed, 47 insertions, 11 deletions
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 46a5be62c052..803927b31742 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -840,15 +840,31 @@ struct ib_mr_status {
*/
__attribute_const__ enum ib_rate mult_to_ib_rate(int mult);
+enum rdma_ah_attr_type {
+ RDMA_AH_ATTR_TYPE_IB,
+ RDMA_AH_ATTR_TYPE_ROCE,
+};
+
+struct ib_ah_attr {
+ u16 dlid;
+ u8 src_path_bits;
+};
+
+struct roce_ah_attr {
+ u8 dmac[ETH_ALEN];
+};
+
struct rdma_ah_attr {
struct ib_global_route grh;
- u16 dlid;
u8 sl;
- u8 src_path_bits;
u8 static_rate;
- u8 ah_flags;
u8 port_num;
- u8 dmac[ETH_ALEN];
+ u8 ah_flags;
+ enum rdma_ah_attr_type type;
+ union {
+ struct ib_ah_attr ib;
+ struct roce_ah_attr roce;
+ };
};
enum ib_wc_status {
@@ -1467,6 +1483,7 @@ struct ib_ah {
struct ib_device *device;
struct ib_pd *pd;
struct ib_uobject *uobject;
+ enum rdma_ah_attr_type type;
};
typedef void (*ib_comp_handler)(struct ib_cq *cq, void *cq_context);
@@ -3468,17 +3485,22 @@ int ib_resolve_eth_dmac(struct ib_device *device,
static inline u8 *rdma_ah_retrieve_dmac(struct rdma_ah_attr *attr)
{
- return attr->dmac;
+ if (attr->type == RDMA_AH_ATTR_TYPE_ROCE)
+ return attr->roce.dmac;
+ return NULL;
}
-static inline void rdma_ah_set_dlid(struct rdma_ah_attr *attr, u32 dlid)
+static inline void rdma_ah_set_dlid(struct rdma_ah_attr *attr, u16 dlid)
{
- attr->dlid = (u16)dlid;
+ if (attr->type == RDMA_AH_ATTR_TYPE_IB)
+ attr->ib.dlid = dlid;
}
-static inline u32 rdma_ah_get_dlid(const struct rdma_ah_attr *attr)
+static inline u16 rdma_ah_get_dlid(const struct rdma_ah_attr *attr)
{
- return attr->dlid;
+ if (attr->type == RDMA_AH_ATTR_TYPE_IB)
+ return attr->ib.dlid;
+ return 0;
}
static inline void rdma_ah_set_sl(struct rdma_ah_attr *attr, u8 sl)
@@ -3494,12 +3516,15 @@ static inline u8 rdma_ah_get_sl(const struct rdma_ah_attr *attr)
static inline void rdma_ah_set_path_bits(struct rdma_ah_attr *attr,
u8 src_path_bits)
{
- attr->src_path_bits = src_path_bits;
+ if (attr->type == RDMA_AH_ATTR_TYPE_IB)
+ attr->ib.src_path_bits = src_path_bits;
}
static inline u8 rdma_ah_get_path_bits(const struct rdma_ah_attr *attr)
{
- return attr->src_path_bits;
+ if (attr->type == RDMA_AH_ATTR_TYPE_IB)
+ return attr->ib.src_path_bits;
+ return 0;
}
static inline void rdma_ah_set_port_num(struct rdma_ah_attr *attr, u8 port_num)
@@ -3586,4 +3611,15 @@ static inline void rdma_ah_set_grh(struct rdma_ah_attr *attr,
grh->hop_limit = hop_limit;
grh->traffic_class = traffic_class;
}
+
+/*Get AH type */
+static inline enum rdma_ah_attr_type rdma_ah_find_type(struct ib_device *dev,
+ u32 port_num)
+{
+ if ((rdma_protocol_roce(dev, port_num)) ||
+ (rdma_protocol_iwarp(dev, port_num)))
+ return RDMA_AH_ATTR_TYPE_ROCE;
+ else
+ return RDMA_AH_ATTR_TYPE_IB;
+}
#endif /* IB_VERBS_H */