[openib-general][PATCH][kdapl]: check port status in dat_ia_open
Guy German
guyg at voltaire.com
Thu Jul 28 04:22:17 PDT 2005
[kdapl]: this patch makes sure that the consumer has opened an
Interface Adaptor's with active hca port. In this approach, the
consumer should try opening mthca0a and if failed - mthca0b.
There are also some spacing corrections at end.. :)
Signed-off-by: Guy German <guyg at voltaire.com>
Index: infiniband/ulp/kdapl/ib/dapl_ia.c
===================================================================
--- infiniband/ulp/kdapl/ib/dapl_ia.c (revision 2914)
+++ infiniband/ulp/kdapl/ib/dapl_ia.c (working copy)
@@ -580,6 +580,7 @@ int dapl_ia_open(const char *name, int a
struct dapl_hca *hca = NULL;
struct dapl_ia *ia = NULL;
struct dapl_evd *evd;
+ struct ib_port_attr port_attr;
dapl_dbg_log(DAPL_DBG_TYPE_API,
"dapl_ia_open (%s, %d, %p, %p)\n",
@@ -587,7 +588,7 @@ int dapl_ia_open(const char *name, int a
status = dapl_provider_list_search(name, &provider);
if (0 != status) {
- status = -EINVAL;
+ status = -ENODEV;
goto bail;
}
@@ -595,12 +596,24 @@ int dapl_ia_open(const char *name, int a
*ia_ptr = NULL;
hca = (struct dapl_hca *)provider->extension;
+ status = ib_query_port(hca->ib_hca_handle, hca->port_num, &port_attr);
+ if (status)
+ goto bail;
+ if (port_attr.state != IB_PORT_ACTIVE) {
+ dapl_dbg_log(DAPL_DBG_TYPE_WARN,
+ "%s: Port %d is not in ACTIVE state\n",
+ __FUNCTION__, hca->port_num);
+
+ status = -EBUSY;
+ goto bail;
+ }
+
atomic_inc(&hca->handle_ref_count);
/* Allocate and initialize ia structure */
ia = dapl_ia_alloc(provider, hca);
if (!ia) {
- atomic_dec(&hca->handle_ref_count);
+ atomic_dec(&hca->handle_ref_count);
status = -EINVAL;
goto bail;
}
@@ -637,18 +650,19 @@ int dapl_ia_open(const char *name, int a
goto bail;
atomic_inc(&evd->evd_ref_count);
- /* Register the handlers associated with the async EVD. */
- status = dapl_ia_setup_callbacks(ia, evd);
- /* Assign the EVD so it gets cleaned up */
+ /* Register the handlers associated with the async EVD. */
+ status = dapl_ia_setup_callbacks(ia, evd);
+ /* Assign the EVD so it gets cleaned up */
ia->cleanup_async_error_evd = TRUE;
ia->async_error_evd = evd;
- if (status != 0)
- goto bail;
+ if (status != 0)
+ goto bail;
}
status = 0;
*ia_ptr = (struct dat_ia *)ia;
*async_evd = (struct dat_evd *)evd;
More information about the general
mailing list