[ofa-general] ***SPAM*** [PATCHv3] Add pkey table support to osm_get_all_port_attr
Hal Rosenstock
hnrose at comcast.net
Fri Mar 6 04:30:38 PST 2009
Only supported in osm_vendor_ibumad.c (separate patch for other
vendor layers)
Also, update applications using this (osmtest, opensm)
Signed-off-by: Hal Rosenstock <hal.rosenstock at gmail.com>
---
Changes from v2:
Added pkey bound check in osm_vendor_get_all_port_attr
as pointed out by Sasha
Readded initialization in opensm/main.c
Changes from v1:
Only copy number of pkeys indicated
Also, don't indicate insufficient memory error if insufficient pkey space
supplied and always return number of pkeys that the port supports
Note: initialization prior to get_all_port_attrs call not changed
since it is faster this way
Other patch for other vendor layers still appropriate following this
ibutils patch sent separately
diff --git a/opensm/libvendor/osm_vendor_ibumad.c b/opensm/libvendor/osm_vendor_ibumad.c
index d7089f0..89b3c43 100644
--- a/opensm/libvendor/osm_vendor_ibumad.c
+++ b/opensm/libvendor/osm_vendor_ibumad.c
@@ -2,6 +2,7 @@
* Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
* Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
* Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
*
* This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU
@@ -556,12 +557,13 @@ osm_vendor_get_all_port_attr(IN osm_vendor_t * const p_vend,
umad_ca_t ca;
ib_port_attr_t *attr = p_attr_array;
unsigned done = 0;
- int r, i, j;
+ int r, i, j, k;
OSM_LOG_ENTER(p_vend->p_log);
CL_ASSERT(p_vend && p_num_ports);
+ r = 0;
if (!*p_num_ports) {
r = IB_INVALID_PARAMETER;
OSM_LOG(p_vend->p_log, OSM_LOG_ERROR, "ERR 5418: "
@@ -576,9 +578,7 @@ osm_vendor_get_all_port_attr(IN osm_vendor_t * const p_vend,
}
for (i = 0; i < p_vend->ca_count && !done; i++) {
- /*
- * For each CA, retrieve the port guids
- */
+ /* For each CA, retrieve the port attributes */
if (umad_get_ca(p_vend->ca_names[i], &ca) == 0) {
if (ca.node_type < 1 || ca.node_type > 3)
continue;
@@ -590,6 +590,14 @@ osm_vendor_get_all_port_attr(IN osm_vendor_t * const p_vend,
attr->port_num = ca.ports[j]->portnum;
attr->sm_lid = ca.ports[j]->sm_lid;
attr->link_state = ca.ports[j]->state;
+ if (attr->num_pkeys && attr->p_pkey_table) {
+ if (attr->num_pkeys > ca.ports[j]->pkeys_size)
+ attr->num_pkeys = ca.ports[j]->pkeys_size;
+ for (k = 0; k < attr->num_pkeys; k++)
+ attr->p_pkey_table[k] =
+ cl_hton16(ca.ports[j]->pkeys[k]);
+ }
+ attr->num_pkeys = ca.ports[j]->pkeys_size;
attr++;
if (attr - p_attr_array > *p_num_ports) {
done = 1;
@@ -601,7 +609,6 @@ osm_vendor_get_all_port_attr(IN osm_vendor_t * const p_vend,
}
*p_num_ports = attr - p_attr_array;
- r = 0;
Exit:
OSM_LOG_EXIT(p_vend->p_log);
diff --git a/opensm/opensm/main.c b/opensm/opensm/main.c
index 4d80120..296d5d5 100644
--- a/opensm/opensm/main.c
+++ b/opensm/opensm/main.c
@@ -2,6 +2,7 @@
* Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
* Copyright (c) 2002-2008 Mellanox Technologies LTD. All rights reserved.
* Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
*
* This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU
@@ -64,7 +65,7 @@ volatile unsigned int osm_exit_flag = 0;
static volatile unsigned int osm_hup_flag = 0;
static volatile unsigned int osm_usr1_flag = 0;
-#define GUID_ARRAY_SIZE 64
+#define MAX_LOCAL_IBPORTS 64
#define INVALID_GUID (0xFFFFFFFFFFFFFFFFULL)
static void mark_exit_flag(int signum)
@@ -369,15 +370,17 @@ static void show_usage(void)
**********************************************************************/
static ib_net64_t get_port_guid(IN osm_opensm_t * p_osm, uint64_t port_guid)
{
- ib_port_attr_t attr_array[GUID_ARRAY_SIZE];
- uint32_t num_ports = GUID_ARRAY_SIZE;
+ ib_port_attr_t attr_array[MAX_LOCAL_IBPORTS];
+ uint32_t num_ports = MAX_LOCAL_IBPORTS;
uint32_t i, choice = 0;
ib_api_status_t status;
- /*
- Call the transport layer for a list of local port
- GUID values.
- */
+ for (i = 0; i < num_ports; i++) {
+ attr_array[i].num_pkeys = 0;
+ attr_array[i].p_pkey_table = NULL;
+ }
+
+ /* Call the transport layer for a list of local port GUID values */
status = osm_vendor_get_all_port_attr(p_osm->p_vendor, attr_array,
&num_ports);
if (status != IB_SUCCESS) {
diff --git a/opensm/osmtest/main.c b/opensm/osmtest/main.c
index 4ca99f3..83c1e13 100644
--- a/opensm/osmtest/main.c
+++ b/opensm/osmtest/main.c
@@ -1,6 +1,7 @@
/*
* Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
* Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
*
* This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU
@@ -54,7 +55,7 @@
Future versions could support multiple subents by
instantiating more than one osmtest object.
*/
-#define GUID_ARRAY_SIZE 64
+#define MAX_LOCAL_IBPORTS 64
#define OSMT_DEFAULT_RETRY_COUNT 3
#define OSMT_DEFAULT_TRANS_TIMEOUT_MILLISEC 1000
#define OSMT_DEFAULT_TRAP_WAIT_TIMEOUT_SEC 10
@@ -73,6 +74,8 @@ boolean_t osmt_is_debug(void)
/**********************************************************************
**********************************************************************/
+void show_usage(void);
+
void show_usage()
{
printf
@@ -207,13 +210,19 @@ void show_usage()
/**********************************************************************
**********************************************************************/
+static void print_all_guids(IN osmtest_t * p_osmt);
static void print_all_guids(IN osmtest_t * p_osmt)
{
ib_api_status_t status;
- uint32_t num_ports = GUID_ARRAY_SIZE;
- ib_port_attr_t attr_array[GUID_ARRAY_SIZE];
+ uint32_t num_ports = MAX_LOCAL_IBPORTS;
+ ib_port_attr_t attr_array[MAX_LOCAL_IBPORTS];
int i;
+ for (i = 0; i < num_ports; i++) {
+ attr_array[i].num_pkeys = 0;
+ attr_array[i].p_pkey_table = NULL;
+ }
+
/*
Call the transport layer for a list of local port
GUID values.
@@ -238,10 +247,15 @@ static void print_all_guids(IN osmtest_t * p_osmt)
ib_net64_t get_port_guid(IN osmtest_t * p_osmt, uint64_t port_guid)
{
ib_api_status_t status;
- uint32_t num_ports = GUID_ARRAY_SIZE;
- ib_port_attr_t attr_array[GUID_ARRAY_SIZE];
+ uint32_t num_ports = MAX_LOCAL_IBPORTS;
+ ib_port_attr_t attr_array[MAX_LOCAL_IBPORTS];
int i;
+ for (i = 0; i < num_ports; i++) {
+ attr_array[i].num_pkeys = 0;
+ attr_array[i].p_pkey_table = NULL;
+ }
+
/*
Call the transport layer for a list of local port
GUID values.
diff --git a/opensm/osmtest/osmtest.c b/opensm/osmtest/osmtest.c
index 32cfa01..986a8d2 100644
--- a/opensm/osmtest/osmtest.c
+++ b/opensm/osmtest/osmtest.c
@@ -2,6 +2,7 @@
* Copyright (c) 2006-2008 Voltaire, Inc. All rights reserved.
* Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
* Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
+ * Copyright (c) 2009 HNR Consulting. All rights reserved.
*
* This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU
@@ -63,7 +64,7 @@
#endif
#define POOL_MIN_ITEMS 64
-#define GUID_ARRAY_SIZE 64
+#define MAX_LOCAL_IBPORTS 64
typedef struct _osmtest_sm_info_rec {
ib_net64_t sm_guid;
@@ -7094,11 +7095,17 @@ osmtest_bind(IN osmtest_t * p_osmt,
{
uint32_t port_index;
ib_api_status_t status;
- uint32_t num_ports = GUID_ARRAY_SIZE;
- ib_port_attr_t attr_array[GUID_ARRAY_SIZE];
+ uint32_t num_ports = MAX_LOCAL_IBPORTS;
+ ib_port_attr_t attr_array[MAX_LOCAL_IBPORTS];
+ int i;
OSM_LOG_ENTER(&p_osmt->log);
+ for (i = 0; i < num_ports; i++) {
+ attr_array[i].num_pkeys = 0;
+ attr_array[i].p_pkey_table = NULL;
+ }
+
/*
* Call the transport layer for a list of local port
* GUID values.
More information about the general
mailing list