From c6393cefa339549efbc12a2624434f38da2dd0a7 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 3 Jan 2018 20:48:56 +0000 Subject: [PATCH 1/4] ib_srpt: Make it easier to use SR-IOV virtual functions Management datagrams (MADs) are not supported for SR-IOV VFs. That is why srpt_refresh_port() fails for SR-IOV VFs. Make it easier to use SR-IOV VFs by only logging an error message if MAD handler registration fails. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7315 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- srpt/src/ib_srpt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index f2b3e2b3e..6f03dcb2b 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -4359,9 +4359,8 @@ static void srpt_add_one(struct ib_device *device) INIT_WORK(&sport->work, srpt_refresh_port_work); #endif if (srpt_refresh_port(sport)) { - pr_err("MAD registration failed for %s-%d.\n", + pr_err("MAD registration failed for %s-%d. Note: this is expected for SR-IOV virtual functions.\n", sdev->device->name, i); - goto err_ring; } } From c3b1c10abf9614a2b0cec61d682c9bf83951027e Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 3 Jan 2018 23:29:49 +0000 Subject: [PATCH 2/4] ib_srpt: Revert r7315 because it did not enable SR-IOV support git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7316 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- srpt/src/ib_srpt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index 6f03dcb2b..f2b3e2b3e 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -4359,8 +4359,9 @@ static void srpt_add_one(struct ib_device *device) INIT_WORK(&sport->work, srpt_refresh_port_work); #endif if (srpt_refresh_port(sport)) { - pr_err("MAD registration failed for %s-%d. Note: this is expected for SR-IOV virtual functions.\n", + pr_err("MAD registration failed for %s-%d.\n", sdev->device->name, i); + goto err_ring; } } From 58f7ca66f1c017a8e64673d4b7c3065e1e675606 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 3 Jan 2018 23:54:44 +0000 Subject: [PATCH 3/4] ib_srpt: Make it easier to use SR-IOV virtual functions Management datagrams (MADs) are not supported for SR-IOV VFs. That is why srpt_refresh_port() fails for SR-IOV VFs. Make it easier to use SR-IOV VFs by only logging an error message if MAD handler registration fails. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7317 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- srpt/src/ib_srpt.c | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index f2b3e2b3e..d42b4ba4b 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -686,17 +686,9 @@ static int srpt_refresh_port(struct srpt_port *sport) int ret; char tgt_name[40]; - memset(&port_modify, 0, sizeof(port_modify)); - port_modify.set_port_cap_mask = IB_PORT_DEVICE_MGMT_SUP; - port_modify.clr_port_cap_mask = 0; - - ret = ib_modify_port(sport->sdev->device, sport->port, 0, &port_modify); - if (ret) - goto err_mod_port; - ret = ib_query_port(sport->sdev->device, sport->port, &port_attr); if (ret) - goto err_query_port; + return ret; sport->sm_lid = port_attr.sm_lid; sport->lid = port_attr.lid; @@ -707,7 +699,18 @@ static int srpt_refresh_port(struct srpt_port *sport) #endif ); if (ret) - goto err_query_port; + return ret; + + memset(&port_modify, 0, sizeof(port_modify)); + port_modify.set_port_cap_mask = IB_PORT_DEVICE_MGMT_SUP; + port_modify.clr_port_cap_mask = 0; + + ret = ib_modify_port(sport->sdev->device, sport->port, 0, &port_modify); + if (ret) { + pr_warn("%s-%d: enabling device management failed (%d). Note: this is expected for SR-IOV virtual functions.\n", + sport->sdev->device->name, sport->port, ret); + goto register_tgt; + } if (!sport->mad_agent) { memset(®_req, 0, sizeof(reg_req)); @@ -728,12 +731,14 @@ static int srpt_refresh_port(struct srpt_port *sport) #endif ); if (IS_ERR(sport->mad_agent)) { - ret = PTR_ERR(sport->mad_agent); + pr_err("%s-%d: MAD agent registration failed (%ld). Note: this is expected for SR-IOV virtual functions.\n", + sport->sdev->device->name, sport->port, + PTR_ERR(sport->mad_agent)); sport->mad_agent = NULL; - goto err_query_port; } } +register_tgt: if (!sport->scst_tgt) { snprintf(tgt_name, sizeof(tgt_name), "%pI6", &sport->gid); sport->scst_tgt = scst_register_target(&srpt_template, @@ -745,14 +750,6 @@ static int srpt_refresh_port(struct srpt_port *sport) } return 0; - -err_query_port: - port_modify.set_port_cap_mask = 0; - port_modify.clr_port_cap_mask = IB_PORT_DEVICE_MGMT_SUP; - ib_modify_port(sport->sdev->device, sport->port, 0, &port_modify); - -err_mod_port: - return ret; } /* From a51cd226149704e504aedcf26d02b2002fad3134 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Thu, 4 Jan 2018 00:30:22 +0000 Subject: [PATCH 4/4] ib_srpt: Refine two log messages git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7318 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- srpt/src/ib_srpt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/srpt/src/ib_srpt.c b/srpt/src/ib_srpt.c index d42b4ba4b..1b575f283 100644 --- a/srpt/src/ib_srpt.c +++ b/srpt/src/ib_srpt.c @@ -707,7 +707,7 @@ static int srpt_refresh_port(struct srpt_port *sport) ret = ib_modify_port(sport->sdev->device, sport->port, 0, &port_modify); if (ret) { - pr_warn("%s-%d: enabling device management failed (%d). Note: this is expected for SR-IOV virtual functions.\n", + pr_warn("%s-%d: enabling device management failed (%d). Note: this is expected if SR-IOV is enabled.\n", sport->sdev->device->name, sport->port, ret); goto register_tgt; } @@ -731,7 +731,7 @@ static int srpt_refresh_port(struct srpt_port *sport) #endif ); if (IS_ERR(sport->mad_agent)) { - pr_err("%s-%d: MAD agent registration failed (%ld). Note: this is expected for SR-IOV virtual functions.\n", + pr_err("%s-%d: MAD agent registration failed (%ld). Note: this is expected if SR-IOV is enabled.\n", sport->sdev->device->name, sport->port, PTR_ERR(sport->mad_agent)); sport->mad_agent = NULL;