From: Michael Wang <yun.wang@profitbricks.com>
To: Roland Dreier <roland@kernel.org>,
Sean Hefty <sean.hefty@intel.com>,
linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-nfs@vger.kernel.org, netdev@vger.kernel.org
Cc: Hal Rosenstock <hal.rosenstock@gmail.com>,
Tom Tucker <tom@opengridcomputing.com>,
Steve Wise <swise@opengridcomputing.com>,
Hoang-Nam Nguyen <hnguyen@de.ibm.com>,
Christoph Raisch <raisch@de.ibm.com>,
Mike Marciniszyn <infinipath@intel.com>,
Eli Cohen <eli@mellanox.com>,
Faisal Latif <faisal.latif@intel.com>,
Upinder Malhi <umalhi@cisco.com>,
Trond Myklebust <trond.myklebust@primarydata.com>,
"J. Bruce Fields" <bfields@fieldses.org>,
"David S. Miller" <davem@davemloft.net>,
Ira Weiny <ira.weiny@intel.com>,
PJ Waskiewicz <pj.waskiewicz@solidfire.com>,
Tatyana Nikolova <Tatyana.E.Nikolova@intel.com>,
Or Gerlitz <ogerlitz@mellanox.com>,
Jack Morgenstein <jackm@dev.mellanox.co.il>,
Haggai Eran <haggaie@mellanox.com>,
Ilya Nelkenbaum <ilyan@mellanox.com>,
Yann Droneaud <ydroneaud@opteya.com>,
Bart Van Assche <bvanassche@acm.org>,
Shachar Raindel <raindel@mellanox.com>,
Sagi Grimberg <sagig@mellanox.com>,
Devesh Sharma <devesh.sharma@emulex.com>,
Matan Barak <matanb@mellanox.com>,
Moni Shoua <monis@mellanox.com>, Jiri Kosina <jkosina@suse.cz>,
Selvin Xavier <selvin.xavier@emulex.com>,
Mitesh Ahuja <mitesh.ahuja@emulex.com>,
Li RongQing <roy.qing.li@gmail.com>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Alex Estrin <alex.estrin@intel.com>,
Doug Ledford <dledford@redhat.com>,
Eric Dumazet <edumazet@google.com>,
Erez Shitrit <erezsh@mellanox.com>, Tom Gundersen <teg@jklm.no>,
Chuck Lever <chuck.lever@oracle.com>,
Michael Wang <yun.wang@profitbricks.com>
Subject: [PATCH v2 03/17] IB/Verbs: Use management helper cap_ib_mad() for mad-check
Date: Tue, 07 Apr 2015 14:30:22 +0200 [thread overview]
Message-ID: <5523CDDE.4050209@profitbricks.com> (raw)
In-Reply-To: <5523CCD5.6030401@profitbricks.com>
Introduce helper cap_ib_mad() to help us check if the port of an
IB device support Infiniband Management Datagrams.
Reform ib_umad_add_one() to fit per-port-check method better.
Cc: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Cc: Doug Ledford <dledford@redhat.com>
Cc: Ira Weiny <ira.weiny@intel.com>
Cc: Sean Hefty <sean.hefty@intel.com>
Signed-off-by: Michael Wang <yun.wang@profitbricks.com>
---
drivers/infiniband/core/mad.c | 18 +++++++++---------
drivers/infiniband/core/user_mad.c | 26 ++++++++++++++++++++------
include/rdma/ib_verbs.h | 15 +++++++++++++++
3 files changed, 44 insertions(+), 15 deletions(-)
diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c
index 74c30f4..ef0c0c5 100644
--- a/drivers/infiniband/core/mad.c
+++ b/drivers/infiniband/core/mad.c
@@ -3057,9 +3057,6 @@ 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)
- return;
-
if (device->node_type == RDMA_NODE_IB_SWITCH) {
start = 0;
end = 0;
@@ -3069,6 +3066,9 @@ static void ib_mad_init_device(struct ib_device *device)
}
for (i = start; i <= end; i++) {
+ if (!cap_ib_mad(device, i))
+ continue;
+
if (ib_mad_port_open(device, i)) {
dev_err(&device->dev, "Couldn't open port %d\n", i);
goto error;
@@ -3086,15 +3086,15 @@ error_agent:
dev_err(&device->dev, "Couldn't close port %d\n", i);
error:
- i--;
+ while (--i >= start) {
+ if (!cap_ib_mad(device, i))
+ continue;
- while (i >= start) {
if (ib_agent_port_close(device, i))
dev_err(&device->dev,
"Couldn't close port %d for agents\n", i);
if (ib_mad_port_close(device, i))
dev_err(&device->dev, "Couldn't close port %d\n", i);
- i--;
}
}
@@ -3102,9 +3102,6 @@ static void ib_mad_remove_device(struct ib_device *device)
{
int i, num_ports, cur_port;
- if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
- return;
-
if (device->node_type == RDMA_NODE_IB_SWITCH) {
num_ports = 1;
cur_port = 0;
@@ -3113,6 +3110,9 @@ static void ib_mad_remove_device(struct ib_device *device)
cur_port = 1;
}
for (i = 0; i < num_ports; i++, cur_port++) {
+ if (!cap_ib_mad(device, i))
+ continue;
+
if (ib_agent_port_close(device, cur_port))
dev_err(&device->dev,
"Couldn't close port %d for agents\n",
diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c
index 928cdd2..b52884b 100644
--- a/drivers/infiniband/core/user_mad.c
+++ b/drivers/infiniband/core/user_mad.c
@@ -1273,9 +1273,7 @@ static void ib_umad_add_one(struct ib_device *device)
{
struct ib_umad_device *umad_dev;
int s, e, i;
-
- if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
- return;
+ int count = 0;
if (device->node_type == RDMA_NODE_IB_SWITCH)
s = e = 0;
@@ -1296,11 +1294,21 @@ static void ib_umad_add_one(struct ib_device *device)
umad_dev->end_port = e;
for (i = s; i <= e; ++i) {
+ if (!cap_ib_mad(device, i))
+ continue;
+
umad_dev->port[i - s].umad_dev = umad_dev;
if (ib_umad_init_port(device, i, umad_dev,
&umad_dev->port[i - s]))
goto err;
+
+ count++;
+ }
+
+ if (!count) {
+ kobject_put(&umad_dev->kobj);
+ return;
}
ib_set_client_data(device, &umad_client, umad_dev);
@@ -1308,8 +1316,12 @@ static void ib_umad_add_one(struct ib_device *device)
return;
err:
- while (--i >= s)
+ while (--i >= s) {
+ if (!cap_ib_mad(device, i))
+ continue;
+
ib_umad_kill_port(&umad_dev->port[i - s]);
+ }
kobject_put(&umad_dev->kobj);
}
@@ -1322,8 +1334,10 @@ static void ib_umad_remove_one(struct ib_device *device)
if (!umad_dev)
return;
- for (i = 0; i <= umad_dev->end_port - umad_dev->start_port; ++i)
- ib_umad_kill_port(&umad_dev->port[i]);
+ for (i = 0; i <= umad_dev->end_port - umad_dev->start_port; ++i) {
+ if (cap_ib_mad(device, i))
+ ib_umad_kill_port(&umad_dev->port[i]);
+ }
kobject_put(&umad_dev->kobj);
}
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 780b3b7..4013933 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1773,6 +1773,21 @@ static inline int rdma_ib_mgmt(struct ib_device *device, u8 port_num)
return (tp == RDMA_TRANSPORT_IB || tp == RDMA_TRANSPORT_IBOE);
}
+/**
+ * cap_ib_mad - Check if the port of device has the capability Infiniband
+ * Management Datagrams.
+ *
+ * @device: Device to be checked
+ * @port_num: Port number of the device
+ *
+ * Return 0 when port of the device don't support Infiniband
+ * Management Datagrams.
+ */
+static inline int cap_ib_mad(struct ib_device *device, u8 port_num)
+{
+ return rdma_ib_mgmt(device, port_num);
+}
+
int ib_query_gid(struct ib_device *device,
u8 port_num, int index, union ib_gid *gid);
--
2.1.0
WARNING: multiple messages have this Message-ID (diff)
From: Michael Wang <yun.wang-EIkl63zCoXaH+58JC4qpiA@public.gmane.org>
To: Roland Dreier <roland-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: Hal Rosenstock
<hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Tom Tucker
<tom-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.org>,
Steve Wise
<swise-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.org>,
Hoang-Nam Nguyen
<hnguyen-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>,
Christoph Raisch <raisch-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>,
Mike Marciniszyn
<infinipath-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
Eli Cohen <eli-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
Faisal Latif
<faisal.latif-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
Upinder Malhi <umalhi-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org>,
Trond Myklebust
<trond.myklebust-7I+n7zu2hftEKMMhf/gKZA@public.gmane.org>,
"J. Bruce Fields"
<bfields-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>,
"David S. Miller" <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>,
Ira Weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
PJ Waskiewicz
<pj.waskiewicz-PrFOU5CTvK1l57MIdRCFDg@public.gmane.org>,
Tatyana Nikolova
<Tatyana.E.Nikolova-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
Or Gerlitz <ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
Jack Morgenstein
<jackm-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>,
Haggai Eran <haggaie-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
Ilya Nelkenbaum <ilyan-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
Yann Droneaud <ydroneaud-RlY5vtjFyJ3QT0dZR+AlfA@public.gmane.org>,
Bart Van Assche <bvanassche-HInyCGIudOg@public.gmane.org>,
Shachar Raindel <raindel-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Subject: [PATCH v2 03/17] IB/Verbs: Use management helper cap_ib_mad() for mad-check
Date: Tue, 07 Apr 2015 14:30:22 +0200 [thread overview]
Message-ID: <5523CDDE.4050209@profitbricks.com> (raw)
In-Reply-To: <5523CCD5.6030401-EIkl63zCoXaH+58JC4qpiA@public.gmane.org>
Introduce helper cap_ib_mad() to help us check if the port of an
IB device support Infiniband Management Datagrams.
Reform ib_umad_add_one() to fit per-port-check method better.
Cc: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
Cc: Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: Ira Weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Signed-off-by: Michael Wang <yun.wang-EIkl63zCoXaH+58JC4qpiA@public.gmane.org>
---
drivers/infiniband/core/mad.c | 18 +++++++++---------
drivers/infiniband/core/user_mad.c | 26 ++++++++++++++++++++------
include/rdma/ib_verbs.h | 15 +++++++++++++++
3 files changed, 44 insertions(+), 15 deletions(-)
diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c
index 74c30f4..ef0c0c5 100644
--- a/drivers/infiniband/core/mad.c
+++ b/drivers/infiniband/core/mad.c
@@ -3057,9 +3057,6 @@ 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)
- return;
-
if (device->node_type == RDMA_NODE_IB_SWITCH) {
start = 0;
end = 0;
@@ -3069,6 +3066,9 @@ static void ib_mad_init_device(struct ib_device *device)
}
for (i = start; i <= end; i++) {
+ if (!cap_ib_mad(device, i))
+ continue;
+
if (ib_mad_port_open(device, i)) {
dev_err(&device->dev, "Couldn't open port %d\n", i);
goto error;
@@ -3086,15 +3086,15 @@ error_agent:
dev_err(&device->dev, "Couldn't close port %d\n", i);
error:
- i--;
+ while (--i >= start) {
+ if (!cap_ib_mad(device, i))
+ continue;
- while (i >= start) {
if (ib_agent_port_close(device, i))
dev_err(&device->dev,
"Couldn't close port %d for agents\n", i);
if (ib_mad_port_close(device, i))
dev_err(&device->dev, "Couldn't close port %d\n", i);
- i--;
}
}
@@ -3102,9 +3102,6 @@ static void ib_mad_remove_device(struct ib_device *device)
{
int i, num_ports, cur_port;
- if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
- return;
-
if (device->node_type == RDMA_NODE_IB_SWITCH) {
num_ports = 1;
cur_port = 0;
@@ -3113,6 +3110,9 @@ static void ib_mad_remove_device(struct ib_device *device)
cur_port = 1;
}
for (i = 0; i < num_ports; i++, cur_port++) {
+ if (!cap_ib_mad(device, i))
+ continue;
+
if (ib_agent_port_close(device, cur_port))
dev_err(&device->dev,
"Couldn't close port %d for agents\n",
diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c
index 928cdd2..b52884b 100644
--- a/drivers/infiniband/core/user_mad.c
+++ b/drivers/infiniband/core/user_mad.c
@@ -1273,9 +1273,7 @@ static void ib_umad_add_one(struct ib_device *device)
{
struct ib_umad_device *umad_dev;
int s, e, i;
-
- if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
- return;
+ int count = 0;
if (device->node_type == RDMA_NODE_IB_SWITCH)
s = e = 0;
@@ -1296,11 +1294,21 @@ static void ib_umad_add_one(struct ib_device *device)
umad_dev->end_port = e;
for (i = s; i <= e; ++i) {
+ if (!cap_ib_mad(device, i))
+ continue;
+
umad_dev->port[i - s].umad_dev = umad_dev;
if (ib_umad_init_port(device, i, umad_dev,
&umad_dev->port[i - s]))
goto err;
+
+ count++;
+ }
+
+ if (!count) {
+ kobject_put(&umad_dev->kobj);
+ return;
}
ib_set_client_data(device, &umad_client, umad_dev);
@@ -1308,8 +1316,12 @@ static void ib_umad_add_one(struct ib_device *device)
return;
err:
- while (--i >= s)
+ while (--i >= s) {
+ if (!cap_ib_mad(device, i))
+ continue;
+
ib_umad_kill_port(&umad_dev->port[i - s]);
+ }
kobject_put(&umad_dev->kobj);
}
@@ -1322,8 +1334,10 @@ static void ib_umad_remove_one(struct ib_device *device)
if (!umad_dev)
return;
- for (i = 0; i <= umad_dev->end_port - umad_dev->start_port; ++i)
- ib_umad_kill_port(&umad_dev->port[i]);
+ for (i = 0; i <= umad_dev->end_port - umad_dev->start_port; ++i) {
+ if (cap_ib_mad(device, i))
+ ib_umad_kill_port(&umad_dev->port[i]);
+ }
kobject_put(&umad_dev->kobj);
}
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 780b3b7..4013933 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1773,6 +1773,21 @@ static inline int rdma_ib_mgmt(struct ib_device *device, u8 port_num)
return (tp == RDMA_TRANSPORT_IB || tp == RDMA_TRANSPORT_IBOE);
}
+/**
+ * cap_ib_mad - Check if the port of device has the capability Infiniband
+ * Management Datagrams.
+ *
+ * @device: Device to be checked
+ * @port_num: Port number of the device
+ *
+ * Return 0 when port of the device don't support Infiniband
+ * Management Datagrams.
+ */
+static inline int cap_ib_mad(struct ib_device *device, u8 port_num)
+{
+ return rdma_ib_mgmt(device, port_num);
+}
+
int ib_query_gid(struct ib_device *device,
u8 port_num, int index, union ib_gid *gid);
--
2.1.0
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
WARNING: multiple messages have this Message-ID (diff)
From: Michael Wang <yun.wang-EIkl63zCoXaH+58JC4qpiA@public.gmane.org>
To: Roland Dreier <roland-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: Hal Rosenstock
<hal.rosenstock-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Tom Tucker
<tom-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.org>,
Steve Wise
<swise-7bPotxP6k4+P2YhJcF5u+vpXobYPEAuW@public.gmane.org>,
Hoang-Nam Nguyen
<hnguyen-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>,
Christoph Raisch <raisch-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>,
Mike Marciniszyn
<infinipath-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
Eli Cohen <eli-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
Faisal Latif
<faisal.latif-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
Upinder Malhi <umalhi-FYB4Gu1CFyUAvxtiuMwx3w@public.gmane.org>,
Trond Myklebust
<trond.myklebust-7I+n7zu2hftEKMMhf/gKZA@public.gmane.org>,
"J. Bruce Fields"
<bfields-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>,
"David S. Miller" <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>,
Ira Weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
PJ Waskiewicz
<pj.waskiewicz-PrFOU5CTvK1l57MIdRCFDg@public.gmane.org>,
Tatyana Nikolova
<Tatyana.E.Nikolova-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
Or Gerlitz <ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
Jack Morgenstein
<jackm-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>,
Haggai Eran <haggaie-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
Ilya Nelkenbaum <ilyan-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
Yann Droneaud <ydroneaud-RlY5vtjFyJ3QT0dZR+AlfA@public.gmane.org>,
Bart Van Assche <bvanassche-HInyCGIudOg@public.gmane.org>,
Shachar Raindel <raindel-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org
Subject: [PATCH v2 03/17] IB/Verbs: Use management helper cap_ib_mad() for mad-check
Date: Tue, 07 Apr 2015 14:30:22 +0200 [thread overview]
Message-ID: <5523CDDE.4050209@profitbricks.com> (raw)
In-Reply-To: <5523CCD5.6030401-EIkl63zCoXaH+58JC4qpiA@public.gmane.org>
Introduce helper cap_ib_mad() to help us check if the port of an
IB device support Infiniband Management Datagrams.
Reform ib_umad_add_one() to fit per-port-check method better.
Cc: Jason Gunthorpe <jgunthorpe-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
Cc: Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: Ira Weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: Sean Hefty <sean.hefty-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Signed-off-by: Michael Wang <yun.wang-EIkl63zCoXaH+58JC4qpiA@public.gmane.org>
---
drivers/infiniband/core/mad.c | 18 +++++++++---------
drivers/infiniband/core/user_mad.c | 26 ++++++++++++++++++++------
include/rdma/ib_verbs.h | 15 +++++++++++++++
3 files changed, 44 insertions(+), 15 deletions(-)
diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c
index 74c30f4..ef0c0c5 100644
--- a/drivers/infiniband/core/mad.c
+++ b/drivers/infiniband/core/mad.c
@@ -3057,9 +3057,6 @@ 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)
- return;
-
if (device->node_type == RDMA_NODE_IB_SWITCH) {
start = 0;
end = 0;
@@ -3069,6 +3066,9 @@ static void ib_mad_init_device(struct ib_device *device)
}
for (i = start; i <= end; i++) {
+ if (!cap_ib_mad(device, i))
+ continue;
+
if (ib_mad_port_open(device, i)) {
dev_err(&device->dev, "Couldn't open port %d\n", i);
goto error;
@@ -3086,15 +3086,15 @@ error_agent:
dev_err(&device->dev, "Couldn't close port %d\n", i);
error:
- i--;
+ while (--i >= start) {
+ if (!cap_ib_mad(device, i))
+ continue;
- while (i >= start) {
if (ib_agent_port_close(device, i))
dev_err(&device->dev,
"Couldn't close port %d for agents\n", i);
if (ib_mad_port_close(device, i))
dev_err(&device->dev, "Couldn't close port %d\n", i);
- i--;
}
}
@@ -3102,9 +3102,6 @@ static void ib_mad_remove_device(struct ib_device *device)
{
int i, num_ports, cur_port;
- if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
- return;
-
if (device->node_type == RDMA_NODE_IB_SWITCH) {
num_ports = 1;
cur_port = 0;
@@ -3113,6 +3110,9 @@ static void ib_mad_remove_device(struct ib_device *device)
cur_port = 1;
}
for (i = 0; i < num_ports; i++, cur_port++) {
+ if (!cap_ib_mad(device, i))
+ continue;
+
if (ib_agent_port_close(device, cur_port))
dev_err(&device->dev,
"Couldn't close port %d for agents\n",
diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c
index 928cdd2..b52884b 100644
--- a/drivers/infiniband/core/user_mad.c
+++ b/drivers/infiniband/core/user_mad.c
@@ -1273,9 +1273,7 @@ static void ib_umad_add_one(struct ib_device *device)
{
struct ib_umad_device *umad_dev;
int s, e, i;
-
- if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
- return;
+ int count = 0;
if (device->node_type == RDMA_NODE_IB_SWITCH)
s = e = 0;
@@ -1296,11 +1294,21 @@ static void ib_umad_add_one(struct ib_device *device)
umad_dev->end_port = e;
for (i = s; i <= e; ++i) {
+ if (!cap_ib_mad(device, i))
+ continue;
+
umad_dev->port[i - s].umad_dev = umad_dev;
if (ib_umad_init_port(device, i, umad_dev,
&umad_dev->port[i - s]))
goto err;
+
+ count++;
+ }
+
+ if (!count) {
+ kobject_put(&umad_dev->kobj);
+ return;
}
ib_set_client_data(device, &umad_client, umad_dev);
@@ -1308,8 +1316,12 @@ static void ib_umad_add_one(struct ib_device *device)
return;
err:
- while (--i >= s)
+ while (--i >= s) {
+ if (!cap_ib_mad(device, i))
+ continue;
+
ib_umad_kill_port(&umad_dev->port[i - s]);
+ }
kobject_put(&umad_dev->kobj);
}
@@ -1322,8 +1334,10 @@ static void ib_umad_remove_one(struct ib_device *device)
if (!umad_dev)
return;
- for (i = 0; i <= umad_dev->end_port - umad_dev->start_port; ++i)
- ib_umad_kill_port(&umad_dev->port[i]);
+ for (i = 0; i <= umad_dev->end_port - umad_dev->start_port; ++i) {
+ if (cap_ib_mad(device, i))
+ ib_umad_kill_port(&umad_dev->port[i]);
+ }
kobject_put(&umad_dev->kobj);
}
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 780b3b7..4013933 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1773,6 +1773,21 @@ static inline int rdma_ib_mgmt(struct ib_device *device, u8 port_num)
return (tp == RDMA_TRANSPORT_IB || tp == RDMA_TRANSPORT_IBOE);
}
+/**
+ * cap_ib_mad - Check if the port of device has the capability Infiniband
+ * Management Datagrams.
+ *
+ * @device: Device to be checked
+ * @port_num: Port number of the device
+ *
+ * Return 0 when port of the device don't support Infiniband
+ * Management Datagrams.
+ */
+static inline int cap_ib_mad(struct ib_device *device, u8 port_num)
+{
+ return rdma_ib_mgmt(device, port_num);
+}
+
int ib_query_gid(struct ib_device *device,
u8 port_num, int index, union ib_gid *gid);
--
2.1.0
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2015-04-07 12:30 UTC|newest]
Thread overview: 247+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-07 12:25 [PATCH v2 00/17] IB/Verbs: IB Management Helpers Michael Wang
2015-04-07 12:25 ` Michael Wang
2015-04-07 12:25 ` Michael Wang
2015-04-07 12:28 ` [PATCH 01/17] IB/Verbs: Implement new callback query_transport() for each HW Michael Wang
2015-04-07 12:28 ` Michael Wang
2015-04-07 12:28 ` Michael Wang
2015-04-07 12:44 ` Michael Wang
2015-04-07 12:44 ` Michael Wang
2015-04-07 12:44 ` Michael Wang
2015-04-07 12:29 ` [PATCH v2 02/17] IB/Verbs: Implement raw management helpers Michael Wang
2015-04-07 12:29 ` Michael Wang
2015-04-07 12:29 ` Michael Wang
2015-04-07 21:25 ` Hefty, Sean
2015-04-07 21:25 ` Hefty, Sean
2015-04-07 21:25 ` Hefty, Sean
2015-04-07 21:25 ` Hefty, Sean
2015-04-08 8:41 ` Michael Wang
2015-04-08 8:41 ` Michael Wang
2015-04-08 8:41 ` Michael Wang
2015-04-07 12:30 ` Michael Wang [this message]
2015-04-07 12:30 ` [PATCH v2 03/17] IB/Verbs: Use management helper cap_ib_mad() for mad-check Michael Wang
2015-04-07 12:30 ` Michael Wang
2015-04-07 17:26 ` Jason Gunthorpe
2015-04-07 17:26 ` Jason Gunthorpe
2015-04-07 17:26 ` Jason Gunthorpe
2015-04-08 8:13 ` Michael Wang
2015-04-08 8:13 ` Michael Wang
2015-04-08 8:13 ` Michael Wang
2015-04-07 12:31 ` [PATCH v2 04/17] IB/Verbs: Use management helper cap_ib_smi() for smi-check Michael Wang
2015-04-07 12:31 ` Michael Wang
2015-04-07 12:31 ` Michael Wang
2015-04-07 12:32 ` [PATCH v2 05/17] IB/Verbs: Use management helper cap_ib_cm() for cm-check Michael Wang
2015-04-07 12:32 ` Michael Wang
2015-04-07 12:32 ` Michael Wang
2015-04-07 12:32 ` [PATCH v2 06/17] IB/Verbs: Use management helper cap_ib_sa() for sa-check Michael Wang
2015-04-07 12:32 ` Michael Wang
2015-04-07 12:32 ` Michael Wang
2015-04-07 12:33 ` [PATCH v2 07/17] IB/Verbs: Use management helper cap_ib_mcast() for mcast-check Michael Wang
2015-04-07 12:33 ` Michael Wang
2015-04-07 12:33 ` Michael Wang
2015-04-07 12:34 ` [PATCH v2 08/17] IB/Verbs: Use management helper cap_ipoib() for ipoib-check Michael Wang
2015-04-07 12:34 ` Michael Wang
2015-04-07 12:34 ` Michael Wang
2015-04-07 12:34 ` [PATCH v2 09/17] IB/Verbs: Use helper cap_read_multi_sge() and reform svc_rdma_accept() Michael Wang
2015-04-07 12:34 ` Michael Wang
2015-04-07 12:34 ` Michael Wang
2015-04-07 15:46 ` Tom Talpey
2015-04-07 15:46 ` Tom Talpey
2015-04-07 15:46 ` Tom Talpey
2015-04-07 16:05 ` Michael Wang
2015-04-07 16:05 ` Michael Wang
2015-04-07 16:05 ` Michael Wang
2015-04-07 17:42 ` Jason Gunthorpe
2015-04-07 17:42 ` Jason Gunthorpe
2015-04-07 17:42 ` Jason Gunthorpe
2015-04-08 8:51 ` Michael Wang
2015-04-08 8:51 ` Michael Wang
2015-04-07 12:35 ` [PATCH v2 10/17] IB/Verbs: Adopt management helpers for IB helpers Michael Wang
2015-04-07 12:35 ` Michael Wang
2015-04-07 12:35 ` Michael Wang
2015-04-07 18:40 ` Hefty, Sean
2015-04-07 18:40 ` Hefty, Sean
2015-04-07 18:40 ` Hefty, Sean
2015-04-07 18:40 ` Hefty, Sean
2015-04-08 8:24 ` Michael Wang
2015-04-08 8:24 ` Michael Wang
2015-04-08 8:24 ` Michael Wang
2015-04-07 20:12 ` Jason Gunthorpe
2015-04-07 20:12 ` Jason Gunthorpe
2015-04-07 20:12 ` Jason Gunthorpe
2015-04-07 20:16 ` Steve Wise
2015-04-07 20:16 ` Steve Wise
2015-04-07 20:16 ` Steve Wise
2015-04-08 8:28 ` Michael Wang
2015-04-08 8:28 ` Michael Wang
2015-04-08 8:28 ` Michael Wang
2015-04-09 5:36 ` ira.weiny
2015-04-09 5:36 ` ira.weiny
2015-04-07 20:18 ` Hefty, Sean
2015-04-07 20:18 ` Hefty, Sean
2015-04-07 20:18 ` Hefty, Sean
2015-04-07 12:36 ` [PATCH v2 11/17] IB/Verbs: Reform link_layer_show() and ib_uverbs_query_port() Michael Wang
2015-04-07 12:36 ` Michael Wang
2015-04-07 12:36 ` Michael Wang
2015-04-07 18:49 ` Hefty, Sean
2015-04-07 18:49 ` Hefty, Sean
2015-04-07 18:49 ` Hefty, Sean
2015-04-07 18:49 ` Hefty, Sean
2015-04-07 18:56 ` Steve Wise
2015-04-07 18:56 ` Steve Wise
2015-04-07 18:56 ` Steve Wise
2015-04-08 8:29 ` Michael Wang
2015-04-08 8:29 ` Michael Wang
2015-04-08 8:29 ` Michael Wang
2015-04-07 12:36 ` [PATCH v2 12/17] IB/Verbs: Use management helper cap_ib_cm_dev() for cm-device-check Michael Wang
2015-04-07 12:36 ` Michael Wang
2015-04-07 12:36 ` Michael Wang
2015-04-07 12:37 ` [PATCH v2 13/17] IB/Verbs: Reform cma/ucma with management helpers Michael Wang
2015-04-07 12:37 ` Michael Wang
2015-04-07 12:37 ` Michael Wang
2015-04-07 21:11 ` Steve Wise
2015-04-07 21:11 ` Steve Wise
2015-04-07 21:11 ` Steve Wise
2015-04-08 8:39 ` Michael Wang
2015-04-08 8:39 ` Michael Wang
2015-04-07 21:36 ` Hefty, Sean
2015-04-07 21:36 ` Hefty, Sean
2015-04-07 21:36 ` Hefty, Sean
2015-04-07 21:36 ` Hefty, Sean
2015-04-08 9:37 ` Michael Wang
2015-04-08 9:37 ` Michael Wang
2015-04-08 9:37 ` Michael Wang
2015-04-08 17:02 ` Hefty, Sean
2015-04-08 17:02 ` Hefty, Sean
2015-04-08 17:02 ` Hefty, Sean
2015-04-08 17:02 ` Hefty, Sean
2015-04-09 8:05 ` Michael Wang
2015-04-09 8:05 ` Michael Wang
2015-04-07 12:38 ` [PATCH v2 14/17] IB/Verbs: Reserve legacy transport type for 'struct rdma_dev_addr' Michael Wang
2015-04-07 12:38 ` Michael Wang
2015-04-07 12:38 ` Michael Wang
2015-04-07 12:38 ` [PATCH v2 15/17] IB/Verbs: Reform cma_acquire_dev() with management helpers Michael Wang
2015-04-07 12:38 ` Michael Wang
2015-04-07 12:38 ` Michael Wang
2015-04-07 12:39 ` [PATCH v2 16/17] IB/Verbs: Cleanup rdma_node_get_transport() Michael Wang
2015-04-07 12:39 ` Michael Wang
2015-04-07 12:39 ` Michael Wang
2015-04-07 12:39 ` [PATCH v2 17/17] IB/Verbs: Move rdma_port_get_link_layer() to mlx4 head file Michael Wang
2015-04-07 12:39 ` Michael Wang
2015-04-07 12:39 ` Michael Wang
2015-04-07 12:42 ` [PATCH v2 01/17] IB/Verbs: Implement new callback query_transport() for each HW Michael Wang
2015-04-07 12:42 ` Michael Wang
2015-04-07 12:42 ` Michael Wang
2015-04-08 18:29 ` Doug Ledford
2015-04-08 18:29 ` Doug Ledford
2015-04-08 18:29 ` Doug Ledford
2015-04-08 18:41 ` Hefty, Sean
2015-04-08 18:41 ` Hefty, Sean
2015-04-08 18:41 ` Hefty, Sean
2015-04-08 18:41 ` Hefty, Sean
2015-04-08 19:35 ` Jason Gunthorpe
2015-04-08 19:35 ` Jason Gunthorpe
2015-04-08 19:35 ` Jason Gunthorpe
2015-04-08 20:10 ` Jason Gunthorpe
2015-04-08 20:10 ` Jason Gunthorpe
2015-04-08 20:10 ` Jason Gunthorpe
2015-04-08 20:55 ` Tom Talpey
2015-04-08 20:55 ` Tom Talpey
2015-04-08 20:55 ` Tom Talpey
2015-04-09 9:45 ` Michael Wang
2015-04-09 9:45 ` Michael Wang
2015-04-09 9:45 ` Michael Wang
2015-04-09 12:42 ` Michael Wang
2015-04-09 12:42 ` Michael Wang
2015-04-09 12:42 ` Michael Wang
2015-04-09 16:00 ` Jason Gunthorpe
2015-04-09 16:00 ` Jason Gunthorpe
2015-04-09 16:00 ` Jason Gunthorpe
2015-04-10 8:19 ` Michael Wang
2015-04-10 8:19 ` Michael Wang
2015-04-10 8:19 ` Michael Wang
2015-04-09 14:34 ` Doug Ledford
2015-04-09 14:34 ` Doug Ledford
2015-04-09 14:34 ` Doug Ledford
2015-04-09 16:01 ` Jason Gunthorpe
2015-04-09 16:01 ` Jason Gunthorpe
2015-04-09 16:01 ` Jason Gunthorpe
2015-04-09 21:19 ` Doug Ledford
2015-04-09 21:19 ` Doug Ledford
2015-04-09 21:19 ` Doug Ledford
2015-04-09 21:36 ` Jason Gunthorpe
2015-04-09 21:36 ` Jason Gunthorpe
2015-04-09 21:36 ` Jason Gunthorpe
2015-04-10 7:46 ` Michael Wang
2015-04-10 7:46 ` Michael Wang
2015-04-10 7:46 ` Michael Wang
2015-04-10 16:48 ` Doug Ledford
2015-04-10 16:48 ` Doug Ledford
2015-04-10 6:16 ` ira.weiny
2015-04-10 6:16 ` ira.weiny
2015-04-10 6:16 ` ira.weiny
2015-04-10 8:25 ` Michael Wang
2015-04-10 8:25 ` Michael Wang
2015-04-10 14:56 ` ira.weiny
2015-04-10 14:56 ` ira.weiny
2015-04-10 14:56 ` ira.weiny
2015-04-10 16:15 ` Jason Gunthorpe
2015-04-10 16:15 ` Jason Gunthorpe
2015-04-10 16:15 ` Jason Gunthorpe
2015-04-10 17:38 ` ira.weiny
2015-04-10 17:38 ` ira.weiny
2015-04-10 17:38 ` ira.weiny
2015-04-10 17:49 ` Doug Ledford
2015-04-10 17:49 ` Doug Ledford
2015-04-10 17:49 ` Doug Ledford
2015-04-10 18:11 ` ira.weiny
2015-04-10 18:11 ` ira.weiny
2015-04-10 18:11 ` ira.weiny
2015-04-10 18:04 ` Jason Gunthorpe
2015-04-10 18:04 ` Jason Gunthorpe
2015-04-10 18:04 ` Jason Gunthorpe
2015-04-10 18:24 ` Doug Ledford
2015-04-10 18:24 ` Doug Ledford
2015-04-10 18:24 ` Doug Ledford
2015-04-10 19:17 ` Jason Gunthorpe
2015-04-10 19:17 ` Jason Gunthorpe
2015-04-10 19:17 ` Jason Gunthorpe
2015-04-10 21:06 ` ira.weiny
2015-04-10 21:06 ` ira.weiny
2015-04-10 21:06 ` ira.weiny
2015-04-11 0:01 ` Tom Talpey
2015-04-11 0:01 ` Tom Talpey
2015-04-11 0:01 ` Tom Talpey
2015-04-10 20:38 ` ira.weiny
2015-04-10 20:38 ` ira.weiny
2015-04-10 20:38 ` ira.weiny
[not found] ` <1428517786.2980.180.camel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-04-09 9:34 ` Michael Wang
2015-04-09 9:34 ` Michael Wang
2015-04-10 7:48 ` ira.weiny
2015-04-10 7:48 ` ira.weiny
2015-04-10 7:48 ` ira.weiny
2015-04-10 17:10 ` Doug Ledford
2015-04-10 17:10 ` Doug Ledford
2015-04-10 17:10 ` Doug Ledford
2015-04-10 17:36 ` Jason Gunthorpe
2015-04-10 17:36 ` Jason Gunthorpe
2015-04-10 17:36 ` Jason Gunthorpe
2015-04-13 7:40 ` Michael Wang
2015-04-13 7:40 ` Michael Wang
2015-04-10 17:50 ` Tom Talpey
2015-04-10 17:50 ` Tom Talpey
2015-04-10 17:50 ` Tom Talpey
2015-04-10 18:17 ` Doug Ledford
2015-04-10 18:17 ` Doug Ledford
2015-04-10 18:17 ` Doug Ledford
2015-04-08 11:38 ` [PATCH v2 00/17] IB/Verbs: IB Management Helpers Tom Talpey
2015-04-08 11:38 ` Tom Talpey
2015-04-08 11:38 ` Tom Talpey
2015-04-08 12:41 ` Michael Wang
2015-04-08 12:41 ` Michael Wang
2015-04-08 12:41 ` Michael Wang
2015-04-08 15:51 ` Jason Gunthorpe
2015-04-08 15:51 ` Jason Gunthorpe
2015-04-08 15:51 ` Jason Gunthorpe
2015-04-08 16:05 ` Michael Wang
2015-04-08 16:05 ` Michael Wang
2015-04-08 16:05 ` Michael Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5523CDDE.4050209@profitbricks.com \
--to=yun.wang@profitbricks.com \
--cc=Tatyana.E.Nikolova@intel.com \
--cc=alex.estrin@intel.com \
--cc=bfields@fieldses.org \
--cc=bvanassche@acm.org \
--cc=chuck.lever@oracle.com \
--cc=davem@davemloft.net \
--cc=devesh.sharma@emulex.com \
--cc=dledford@redhat.com \
--cc=edumazet@google.com \
--cc=eli@mellanox.com \
--cc=erezsh@mellanox.com \
--cc=faisal.latif@intel.com \
--cc=haggaie@mellanox.com \
--cc=hal.rosenstock@gmail.com \
--cc=hnguyen@de.ibm.com \
--cc=ilyan@mellanox.com \
--cc=infinipath@intel.com \
--cc=ira.weiny@intel.com \
--cc=jackm@dev.mellanox.co.il \
--cc=jkosina@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=matanb@mellanox.com \
--cc=mitesh.ahuja@emulex.com \
--cc=monis@mellanox.com \
--cc=netdev@vger.kernel.org \
--cc=ogerlitz@mellanox.com \
--cc=pj.waskiewicz@solidfire.com \
--cc=raindel@mellanox.com \
--cc=raisch@de.ibm.com \
--cc=roland@kernel.org \
--cc=roy.qing.li@gmail.com \
--cc=sagig@mellanox.com \
--cc=sean.hefty@intel.com \
--cc=selvin.xavier@emulex.com \
--cc=swise@opengridcomputing.com \
--cc=teg@jklm.no \
--cc=tom@opengridcomputing.com \
--cc=trond.myklebust@primarydata.com \
--cc=umalhi@cisco.com \
--cc=ydroneaud@opteya.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.