@@ -375,8 +375,7 @@ static int cma_acquire_dev(struct rdma_id_private
*id_priv,
listen_id_priv->id.port_num) == dev_ll) {
cma_dev = listen_id_priv->cma_dev;
port = listen_id_priv->id.port_num;
- if (rdma_node_get_transport(cma_dev->device->node_type) ==
RDMA_TRANSPORT_IB &&
- rdma_port_get_link_layer(cma_dev->device, port) ==
IB_LINK_LAYER_ETHERNET)
+ if (rdma_mgmt_cap_iboe(cma_dev->device, port))
ret = ib_find_cached_gid(cma_dev->device, &iboe_gid,
&found_port, NULL);
else
@@ -395,8 +394,7 @@ static int cma_acquire_dev(struct rdma_id_private
*id_priv,
listen_id_priv->id.port_num == port)
continue;
if (rdma_port_get_link_layer(cma_dev->device, port) ==
dev_ll) {
- if (rdma_node_get_transport(cma_dev->device->node_type)
== RDMA_TRANSPORT_IB &&
- rdma_port_get_link_layer(cma_dev->device, port) ==
IB_LINK_LAYER_ETHERNET)
+ if (rdma_mgmt_cap_iboe(cma_dev->device, port))
ret = ib_find_cached_gid(cma_dev->device,
&iboe_gid, &found_port, NULL);
else
ret = ib_find_cached_gid(cma_dev->device, &gid,
&found_port, NULL);
@@ -2938,7 +2938,7 @@ static int ib_mad_port_open(struct ib_device *device,
init_mad_qp(port_priv, &port_priv->qp_info[1]);
cq_size = mad_sendq_size + mad_recvq_size;
- has_smi = rdma_port_get_link_layer(device, port_num) ==
IB_LINK_LAYER_INFINIBAND;
+ has_smi = rdma_mgmt_cap_smi(device, port_num);
if (has_smi)
cq_size *= 2;
@@ -3057,7 +3057,7 @@ static void ib_mad_init_device(struct ib_device
*device)
{
int start, end, i;
- if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
+ if (!rdma_mgmt_cap_ib(device))
return;
if (device->node_type == RDMA_NODE_IB_SWITCH) {
b/drivers/infiniband/core/verbs.c
@@ -146,6 +146,26 @@ enum rdma_link_layer
rdma_port_get_link_layer(struct ib_device *device, u8 port_
}
EXPORT_SYMBOL(rdma_port_get_link_layer);
+int rdma_port_default_mgmt_flags(struct ib_device *device, u8 port_num)
+{
+ int mgmt_flags = 0;
+ enum rdma_transport_type tp =
+ rdma_node_get_transport(device->node_type);
+ enum rdma_link_layer ll =
+ rdma_port_get_link_layer(device, port_num);
+
+ if (tp == RDMA_TRANSPORT_IB) {
+ mgmt_flags |= IB_MGMT_PROTO_IB;
+ if (ll == IB_LINK_LAYER_INFINIBAND) {
+ mgmt_flags |= IB_MGMT_PROTO_SMI;
+ mgmt_flags |= IB_MGMT_PROTO_IBOE;
+ }
+ }
+
+ return mgmt_flags;
+}
+EXPORT_SYMBOL(rdma_port_default_mgmt_flags);
+
/* Protection domains */
struct ib_pd *ib_alloc_pd(struct ib_device *device)
b/drivers/infiniband/hw/amso1100/c2_provider.c
@@ -96,6 +96,9 @@ static int c2_query_port(struct ib_device *ibdev,
props->active_width = 1;
props->active_speed = IB_SPEED_SDR;
+ /* Makeup flags here, by default or on your own */
+ props->mgmt_flags = rdma_port_default_mgmt_flags(ibdev, port);
+
return 0;
}
@@ -90,6 +90,13 @@ enum rdma_link_layer {
IB_LINK_LAYER_ETHERNET,
};
+enum rdma_mgmt_flag {
+ IB_MGMT_PROTO_IB,
+ IB_MGMT_PROTO_SMI,
+ IB_MGMT_PROTO_IBOE,
+ /* More Here*/
+};
+
enum ib_device_cap_flags {
IB_DEVICE_RESIZE_MAX_WR = 1,
IB_DEVICE_BAD_PKEY_CNTR = (1<<1),
@@ -352,6 +359,7 @@ struct ib_port_attr {
enum ib_mtu active_mtu;
int gid_tbl_len;
u32 port_cap_flags;
+ u32 mgmt_flags;
u32 max_msg_sz;
u32 bad_pkey_cntr;
u32 qkey_viol_cntr;
@@ -1743,6 +1751,32 @@ int ib_query_port(struct ib_device *device,
enum rdma_link_layer rdma_port_get_link_layer(struct ib_device *device,
u8 port_num);
+int rdma_port_default_mgmt_flags(struct ib_device *device, u8 port_num);
+
+static inline int rdma_mgmt_cap(struct ib_device *device, u8 port_num)
+{
+ struct ib_port_attr port_attr;
+ memset(&port_attr, 0, sizeof port_attr);
+ ib_query_port(device, port_num, &port_attr);
+ return port_attr.mgmt_flags;
+}
+
+static inline int rdma_mgmt_cap_ib(struct ib_device *device)
+{
+ u8 port_num = device->node_type == RDMA_NODE_IB_SWITCH ? 0 : 1;
+ return rdma_mgmt_cap(device, port_num) & IB_MGMT_PROTO_IB;
+}
+
+static inline int rdma_mgmt_cap_smi(struct ib_device *device, u8 port_num)
+{
+ return rdma_mgmt_cap(device, port_num) & IB_MGMT_PROTO_SMI;
+}
+
+static inline int rdma_mgmt_cap_iboe(struct ib_device *device, u8 port_num)
+{
+ return rdma_mgmt_cap(device, port_num) & IB_MGMT_PROTO_IBOE;
+}
+
int ib_query_gid(struct ib_device *device,
u8 port_num, int index, union ib_gid *gid);