[ofa-general] [PATCH] opensm/libvendor: indentation changes
Sasha Khapyorsky
sashak at voltaire.com
Wed Aug 15 14:55:42 PDT 2007
Formatted with opensm/osm_indent
(indent -npro -kr -i8 -ts8 -sob -l80 -ss -ncs)
Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
---
opensm/libvendor/osm_pkt_randomizer.c | 474 +++---
opensm/libvendor/osm_vendor_al.c | 2185 ++++++++++-----------
opensm/libvendor/osm_vendor_ibumad.c | 542 +++---
opensm/libvendor/osm_vendor_ibumad_sa.c | 1411 +++++++-------
opensm/libvendor/osm_vendor_mlx.c | 1192 ++++++------
opensm/libvendor/osm_vendor_mlx_anafa.c | 517 +++---
opensm/libvendor/osm_vendor_mlx_dispatcher.c | 1115 +++++------
opensm/libvendor/osm_vendor_mlx_hca.c | 843 ++++-----
opensm/libvendor/osm_vendor_mlx_hca_anafa.c | 74 +-
opensm/libvendor/osm_vendor_mlx_hca_pfs.c | 1192 ++++++------
opensm/libvendor/osm_vendor_mlx_hca_sim.c | 1389 +++++++-------
opensm/libvendor/osm_vendor_mlx_ibmgt.c | 1358 +++++++-------
opensm/libvendor/osm_vendor_mlx_rmpp_ctx.c | 542 +++---
opensm/libvendor/osm_vendor_mlx_sa.c | 1352 ++++++-------
opensm/libvendor/osm_vendor_mlx_sar.c | 198 +-
opensm/libvendor/osm_vendor_mlx_sender.c | 538 +++---
opensm/libvendor/osm_vendor_mlx_sim.c | 659 +++----
opensm/libvendor/osm_vendor_mlx_ts.c | 791 ++++----
opensm/libvendor/osm_vendor_mlx_ts_anafa.c | 203 +-
opensm/libvendor/osm_vendor_mlx_txn.c | 1016 +++++-----
opensm/libvendor/osm_vendor_mtl.c | 1863 +++++++++---------
opensm/libvendor/osm_vendor_mtl_hca_guid.c | 995 +++++-----
opensm/libvendor/osm_vendor_mtl_transaction_mgr.c | 897 +++++-----
opensm/libvendor/osm_vendor_test.c | 303 ++--
opensm/libvendor/osm_vendor_ts.c | 1479 +++++++--------
opensm/libvendor/osm_vendor_umadt.c | 1877 +++++++++---------
26 files changed, 12076 insertions(+), 12929 deletions(-)
diff --git a/opensm/libvendor/osm_pkt_randomizer.c b/opensm/libvendor/osm_pkt_randomizer.c
index 33993b6..70962e7 100644
--- a/opensm/libvendor/osm_pkt_randomizer.c
+++ b/opensm/libvendor/osm_pkt_randomizer.c
@@ -33,7 +33,6 @@
*
*/
-
/*
* Abstract:
* Implementation of osm_pkt_randomizer_t.
@@ -46,7 +45,7 @@
#if HAVE_CONFIG_H
# include <config.h>
-#endif /* HAVE_CONFIG_H */
+#endif /* HAVE_CONFIG_H */
#include <vendor/osm_pkt_randomizer.h>
#include <stdlib.h>
@@ -67,46 +66,45 @@
* the given paths: 0,1 or 0,3,1,4 - the return value will be FALSE.
**********************************************************************/
boolean_t
-__osm_pkt_randomizer_is_path_in_fault_paths(
- IN osm_log_t *p_log,
- IN osm_dr_path_t *p_dr_path,
- IN osm_pkt_randomizer_t *p_pkt_rand )
+__osm_pkt_randomizer_is_path_in_fault_paths(IN osm_log_t * p_log,
+ IN osm_dr_path_t * p_dr_path,
+ IN osm_pkt_randomizer_t *
+ p_pkt_rand)
{
- boolean_t res = FALSE, found_path;
- osm_dr_path_t *p_found_dr_path;
- uint8_t ind1, ind2;
-
- OSM_LOG_ENTER( p_log, __osm_pkt_randomizer_is_path_in_fault_paths );
-
- for ( ind1 = 0 ; ind1 < p_pkt_rand->num_paths_initialized ; ind1++ )
- {
- found_path = TRUE;
- p_found_dr_path = &(p_pkt_rand->fault_dr_paths[ind1]);
- /* if the hop count of the found path is greater than the
- hop count of the input path - then it is not part of it.
- Check the next path. */
- if (p_found_dr_path->hop_count > p_dr_path->hop_count)
- continue;
-
- /* go over all the ports in the found path and see if they match
- the ports in the input path */
- for ( ind2 = 0 ; ind2 <= p_found_dr_path->hop_count ; ind2++ )
- if (p_found_dr_path->path[ind2] != p_dr_path->path[ind2])
- found_path = FALSE;
-
- /* If found_path is TRUE then there is a full match of the path */
- if ( found_path == TRUE )
- {
- osm_log( p_log, OSM_LOG_VERBOSE,
- "__osm_pkt_randomizer_is_path_in_fault_paths: "
- "Given path is in a fault path\n");
- res = TRUE;
- break;
- }
- }
-
- OSM_LOG_EXIT( p_log );
- return res;
+ boolean_t res = FALSE, found_path;
+ osm_dr_path_t *p_found_dr_path;
+ uint8_t ind1, ind2;
+
+ OSM_LOG_ENTER(p_log, __osm_pkt_randomizer_is_path_in_fault_paths);
+
+ for (ind1 = 0; ind1 < p_pkt_rand->num_paths_initialized; ind1++) {
+ found_path = TRUE;
+ p_found_dr_path = &(p_pkt_rand->fault_dr_paths[ind1]);
+ /* if the hop count of the found path is greater than the
+ hop count of the input path - then it is not part of it.
+ Check the next path. */
+ if (p_found_dr_path->hop_count > p_dr_path->hop_count)
+ continue;
+
+ /* go over all the ports in the found path and see if they match
+ the ports in the input path */
+ for (ind2 = 0; ind2 <= p_found_dr_path->hop_count; ind2++)
+ if (p_found_dr_path->path[ind2] !=
+ p_dr_path->path[ind2])
+ found_path = FALSE;
+
+ /* If found_path is TRUE then there is a full match of the path */
+ if (found_path == TRUE) {
+ osm_log(p_log, OSM_LOG_VERBOSE,
+ "__osm_pkt_randomizer_is_path_in_fault_paths: "
+ "Given path is in a fault path\n");
+ res = TRUE;
+ break;
+ }
+ }
+
+ OSM_LOG_EXIT(p_log);
+ return res;
}
/**********************************************************************
@@ -121,228 +119,224 @@ __osm_pkt_randomizer_is_path_in_fault_paths(
* if to drop it or not.
**********************************************************************/
boolean_t
-__osm_pkt_randomizer_process_path(
- IN osm_log_t *p_log,
- IN osm_pkt_randomizer_t *p_pkt_rand,
- IN osm_dr_path_t *p_dr_path )
+__osm_pkt_randomizer_process_path(IN osm_log_t * p_log,
+ IN osm_pkt_randomizer_t * p_pkt_rand,
+ IN osm_dr_path_t * p_dr_path)
{
- boolean_t res = FALSE;
- static boolean_t rand_value_init = FALSE;
- static int rand_value;
- boolean_t in_fault_paths;
- uint8_t i;
- char buf[BUF_SIZE];
- char line[BUF_SIZE];
-
- OSM_LOG_ENTER( p_log, __osm_pkt_randomizer_process_path );
-
- if (rand_value_init == FALSE)
- {
- int seed;
+ boolean_t res = FALSE;
+ static boolean_t rand_value_init = FALSE;
+ static int rand_value;
+ boolean_t in_fault_paths;
+ uint8_t i;
+ char buf[BUF_SIZE];
+ char line[BUF_SIZE];
+
+ OSM_LOG_ENTER(p_log, __osm_pkt_randomizer_process_path);
+
+ if (rand_value_init == FALSE) {
+ int seed;
#ifdef WIN32
- SYSTEMTIME st;
+ SYSTEMTIME st;
#else
- struct timeval tv;
- struct timezone tz;
-#endif /* WIN32 */
+ struct timeval tv;
+ struct timezone tz;
+#endif /* WIN32 */
- /* initiate the rand_value according to timeofday */
- rand_value_init = TRUE;
+ /* initiate the rand_value according to timeofday */
+ rand_value_init = TRUE;
#ifdef WIN32
- GetLocalTime(&st);
- seed = st.wMilliseconds;
+ GetLocalTime(&st);
+ seed = st.wMilliseconds;
#else
- gettimeofday( &tv, &tz );
- seed = tv.tv_usec;
-#endif /* WIN32 */
-
- srand(seed);
- }
-
- /* If the hop_count is 1 - then this is a mad down to our local port - don't drop it */
- if ( p_dr_path->hop_count <= 1 )
- goto Exit;
-
- rand_value = rand();
-
- sprintf( buf, "Path: " );
- /* update the dr_path into the buf */
- for (i = 0 ; i <= p_dr_path->hop_count; i++ )
- {
- sprintf( line, "[%X]", p_dr_path->path[i] );
- strcat( buf, line );
- }
-
- /* Check if the path given is in one of the fault paths */
- in_fault_paths = __osm_pkt_randomizer_is_path_in_fault_paths(
- p_log, p_dr_path, p_pkt_rand );
-
- /* Check if all paths are initialized */
- if ( p_pkt_rand->num_paths_initialized < p_pkt_rand->osm_pkt_num_unstable_links )
- {
- /* Not all packets are initialized. */
- if ( in_fault_paths == FALSE )
- {
- /* the path is not in the false paths. Check using the rand value
- if to update it there or not. */
- if ( rand_value%(p_pkt_rand->osm_pkt_unstable_link_rate) == 0 )
- {
- osm_log( p_log, OSM_LOG_VERBOSE,
- "__osm_pkt_randomizer_process_path: "
- "%s added to the fault_dr_paths list\n"
- "\t\t\t rand_value:%u, unstable_link_rate:%u \n",
- buf, rand_value, p_pkt_rand->osm_pkt_unstable_link_rate );
-
- /* update the path in the fault paths */
- memcpy( &(p_pkt_rand->fault_dr_paths[p_pkt_rand->num_paths_initialized]),
- p_dr_path, sizeof(osm_dr_path_t) );
- p_pkt_rand->num_paths_initialized++;
- in_fault_paths = TRUE;
- }
- }
- }
-
- if ( in_fault_paths == FALSE )
- {
- /* If in_fault_paths is FALSE - just ignore the path */
- osm_log( p_log, OSM_LOG_VERBOSE,
- "__osm_pkt_randomizer_process_path: "
- "%s not in fault paths\n", buf );
- goto Exit;
- }
-
- /* The path is in the fault paths. Need to choose (randomally if to drop it
- or not. */
- rand_value = rand();
-
- if ( rand_value%(p_pkt_rand->osm_pkt_drop_rate) == 0 )
- {
- /* drop the current packet */
- res = TRUE;
- osm_log( p_log, OSM_LOG_VERBOSE,
- "__osm_pkt_randomizer_process_path: "
- "Dropping path:%s\n", buf );
- }
-
- Exit:
- OSM_LOG_EXIT( p_log );
- return res;
+ gettimeofday(&tv, &tz);
+ seed = tv.tv_usec;
+#endif /* WIN32 */
+
+ srand(seed);
+ }
+
+ /* If the hop_count is 1 - then this is a mad down to our local port - don't drop it */
+ if (p_dr_path->hop_count <= 1)
+ goto Exit;
+
+ rand_value = rand();
+
+ sprintf(buf, "Path: ");
+ /* update the dr_path into the buf */
+ for (i = 0; i <= p_dr_path->hop_count; i++) {
+ sprintf(line, "[%X]", p_dr_path->path[i]);
+ strcat(buf, line);
+ }
+
+ /* Check if the path given is in one of the fault paths */
+ in_fault_paths =
+ __osm_pkt_randomizer_is_path_in_fault_paths(p_log, p_dr_path,
+ p_pkt_rand);
+
+ /* Check if all paths are initialized */
+ if (p_pkt_rand->num_paths_initialized <
+ p_pkt_rand->osm_pkt_num_unstable_links) {
+ /* Not all packets are initialized. */
+ if (in_fault_paths == FALSE) {
+ /* the path is not in the false paths. Check using the rand value
+ if to update it there or not. */
+ if (rand_value %
+ (p_pkt_rand->osm_pkt_unstable_link_rate) == 0) {
+ osm_log(p_log, OSM_LOG_VERBOSE,
+ "__osm_pkt_randomizer_process_path: "
+ "%s added to the fault_dr_paths list\n"
+ "\t\t\t rand_value:%u, unstable_link_rate:%u \n",
+ buf, rand_value,
+ p_pkt_rand->osm_pkt_unstable_link_rate);
+
+ /* update the path in the fault paths */
+ memcpy(&
+ (p_pkt_rand->
+ fault_dr_paths[p_pkt_rand->
+ num_paths_initialized]),
+ p_dr_path, sizeof(osm_dr_path_t));
+ p_pkt_rand->num_paths_initialized++;
+ in_fault_paths = TRUE;
+ }
+ }
+ }
+
+ if (in_fault_paths == FALSE) {
+ /* If in_fault_paths is FALSE - just ignore the path */
+ osm_log(p_log, OSM_LOG_VERBOSE,
+ "__osm_pkt_randomizer_process_path: "
+ "%s not in fault paths\n", buf);
+ goto Exit;
+ }
+
+ /* The path is in the fault paths. Need to choose (randomally if to drop it
+ or not. */
+ rand_value = rand();
+
+ if (rand_value % (p_pkt_rand->osm_pkt_drop_rate) == 0) {
+ /* drop the current packet */
+ res = TRUE;
+ osm_log(p_log, OSM_LOG_VERBOSE,
+ "__osm_pkt_randomizer_process_path: "
+ "Dropping path:%s\n", buf);
+ }
+
+ Exit:
+ OSM_LOG_EXIT(p_log);
+ return res;
}
/**********************************************************************
**********************************************************************/
boolean_t
-osm_pkt_randomizer_mad_drop(
- IN osm_log_t *p_log,
- IN osm_pkt_randomizer_t *p_pkt_randomizer,
- IN const ib_mad_t *p_mad )
+osm_pkt_randomizer_mad_drop(IN osm_log_t * p_log,
+ IN osm_pkt_randomizer_t * p_pkt_randomizer,
+ IN const ib_mad_t * p_mad)
{
- const ib_smp_t* p_smp;
- boolean_t res = FALSE;
- osm_dr_path_t dr_path;
-
- OSM_LOG_ENTER( p_log, osm_pkt_randomizer_mad_drop );
-
- p_smp = (ib_smp_t*)p_mad;
-
- if ( p_smp->mgmt_class != IB_MCLASS_SUBN_DIR )
- /* This is a lid route mad. Don't drop it */
- goto Exit;
-
- osm_dr_path_init( &dr_path,
- 0, /* The h_bind is not really important for us to save */
- p_smp->hop_count, p_smp->initial_path );
-
- if (__osm_pkt_randomizer_process_path( p_log, p_pkt_randomizer, &dr_path ) )
- {
- /* the mad should be dropped o*/
- osm_log ( p_log, OSM_LOG_VERBOSE,
- "osm_pkt_randomizer_mad_drop: "
- "mad TID: 0x%" PRIx64 " is being dropped\n",
- cl_ntoh64(p_smp->trans_id) );
- res = TRUE;
- }
-
- Exit:
- OSM_LOG_EXIT( p_log );
- return res;
+ const ib_smp_t *p_smp;
+ boolean_t res = FALSE;
+ osm_dr_path_t dr_path;
+
+ OSM_LOG_ENTER(p_log, osm_pkt_randomizer_mad_drop);
+
+ p_smp = (ib_smp_t *) p_mad;
+
+ if (p_smp->mgmt_class != IB_MCLASS_SUBN_DIR)
+ /* This is a lid route mad. Don't drop it */
+ goto Exit;
+
+ osm_dr_path_init(&dr_path, 0, /* The h_bind is not really important for us to save */
+ p_smp->hop_count, p_smp->initial_path);
+
+ if (__osm_pkt_randomizer_process_path
+ (p_log, p_pkt_randomizer, &dr_path)) {
+ /* the mad should be dropped o */
+ osm_log(p_log, OSM_LOG_VERBOSE,
+ "osm_pkt_randomizer_mad_drop: "
+ "mad TID: 0x%" PRIx64 " is being dropped\n",
+ cl_ntoh64(p_smp->trans_id));
+ res = TRUE;
+ }
+
+ Exit:
+ OSM_LOG_EXIT(p_log);
+ return res;
}
/**********************************************************************
**********************************************************************/
ib_api_status_t
-osm_pkt_randomizer_init(
- IN OUT osm_pkt_randomizer_t **pp_pkt_randomizer,
- IN osm_log_t *p_log )
+osm_pkt_randomizer_init(IN OUT osm_pkt_randomizer_t ** pp_pkt_randomizer,
+ IN osm_log_t * p_log)
{
- uint8_t tmp;
- ib_api_status_t res = IB_SUCCESS;
-
- OSM_LOG_ENTER( p_log, osm_pkt_randomizer_init );
-
- *pp_pkt_randomizer = malloc( sizeof( osm_pkt_randomizer_t ) );
- if ( *pp_pkt_randomizer == NULL )
- {
- res = IB_INSUFFICIENT_MEMORY;
- goto Exit;
- }
- memset( *pp_pkt_randomizer, 0, sizeof(osm_pkt_randomizer_t) );
- (*pp_pkt_randomizer)->num_paths_initialized = 0;
-
- tmp = atol( getenv("OSM_PKT_DROP_RATE") );
- (*pp_pkt_randomizer)->osm_pkt_drop_rate = tmp;
-
- if ( getenv("OSM_PKT_NUM_UNSTABLE_LINKS") != NULL && (tmp = atol( getenv("OSM_PKT_NUM_UNSTABLE_LINKS") )) > 0 )
- (*pp_pkt_randomizer)->osm_pkt_num_unstable_links = tmp;
- else
- (*pp_pkt_randomizer)->osm_pkt_num_unstable_links = 1;
-
- if ( getenv("OSM_PKT_UNSTABLE_LINK_RATE") != NULL && (tmp = atol( getenv("OSM_PKT_UNSTABLE_LINK_RATE") )) > 0 )
- (*pp_pkt_randomizer)->osm_pkt_unstable_link_rate = tmp;
- else
- (*pp_pkt_randomizer)->osm_pkt_unstable_link_rate = 20;
-
- osm_log( p_log, OSM_LOG_VERBOSE,
- "osm_pkt_randomizer_init: "
- "Using OSM_PKT_DROP_RATE=%u \n"
- "\t\t\t\t OSM_PKT_NUM_UNSTABLE_LINKS=%u \n"
- "\t\t\t\t OSM_PKT_UNSTABLE_LINK_RATE=%u \n",
- (*pp_pkt_randomizer)->osm_pkt_drop_rate,
- (*pp_pkt_randomizer)->osm_pkt_num_unstable_links,
- (*pp_pkt_randomizer)->osm_pkt_unstable_link_rate );
-
- /* allocate the fault_dr_paths variable */
- /* It is the number of the paths that will be saved as fault = osm_pkt_num_unstable_links */
- (*pp_pkt_randomizer)->fault_dr_paths = malloc( sizeof( osm_dr_path_t ) *
- (*pp_pkt_randomizer)->osm_pkt_num_unstable_links );
- if ( (*pp_pkt_randomizer)->fault_dr_paths == NULL )
- {
- res = IB_INSUFFICIENT_MEMORY;
- goto Exit;
- }
-
- memset( (*pp_pkt_randomizer)->fault_dr_paths, 0,
- sizeof( osm_dr_path_t ) * (*pp_pkt_randomizer)->osm_pkt_num_unstable_links );
-
- Exit:
- OSM_LOG_EXIT( p_log );
- return (res);
+ uint8_t tmp;
+ ib_api_status_t res = IB_SUCCESS;
+
+ OSM_LOG_ENTER(p_log, osm_pkt_randomizer_init);
+
+ *pp_pkt_randomizer = malloc(sizeof(osm_pkt_randomizer_t));
+ if (*pp_pkt_randomizer == NULL) {
+ res = IB_INSUFFICIENT_MEMORY;
+ goto Exit;
+ }
+ memset(*pp_pkt_randomizer, 0, sizeof(osm_pkt_randomizer_t));
+ (*pp_pkt_randomizer)->num_paths_initialized = 0;
+
+ tmp = atol(getenv("OSM_PKT_DROP_RATE"));
+ (*pp_pkt_randomizer)->osm_pkt_drop_rate = tmp;
+
+ if (getenv("OSM_PKT_NUM_UNSTABLE_LINKS") != NULL
+ && (tmp = atol(getenv("OSM_PKT_NUM_UNSTABLE_LINKS"))) > 0)
+ (*pp_pkt_randomizer)->osm_pkt_num_unstable_links = tmp;
+ else
+ (*pp_pkt_randomizer)->osm_pkt_num_unstable_links = 1;
+
+ if (getenv("OSM_PKT_UNSTABLE_LINK_RATE") != NULL
+ && (tmp = atol(getenv("OSM_PKT_UNSTABLE_LINK_RATE"))) > 0)
+ (*pp_pkt_randomizer)->osm_pkt_unstable_link_rate = tmp;
+ else
+ (*pp_pkt_randomizer)->osm_pkt_unstable_link_rate = 20;
+
+ osm_log(p_log, OSM_LOG_VERBOSE,
+ "osm_pkt_randomizer_init: "
+ "Using OSM_PKT_DROP_RATE=%u \n"
+ "\t\t\t\t OSM_PKT_NUM_UNSTABLE_LINKS=%u \n"
+ "\t\t\t\t OSM_PKT_UNSTABLE_LINK_RATE=%u \n",
+ (*pp_pkt_randomizer)->osm_pkt_drop_rate,
+ (*pp_pkt_randomizer)->osm_pkt_num_unstable_links,
+ (*pp_pkt_randomizer)->osm_pkt_unstable_link_rate);
+
+ /* allocate the fault_dr_paths variable */
+ /* It is the number of the paths that will be saved as fault = osm_pkt_num_unstable_links */
+ (*pp_pkt_randomizer)->fault_dr_paths = malloc(sizeof(osm_dr_path_t) *
+ (*pp_pkt_randomizer)->
+ osm_pkt_num_unstable_links);
+ if ((*pp_pkt_randomizer)->fault_dr_paths == NULL) {
+ res = IB_INSUFFICIENT_MEMORY;
+ goto Exit;
+ }
+
+ memset((*pp_pkt_randomizer)->fault_dr_paths, 0,
+ sizeof(osm_dr_path_t) *
+ (*pp_pkt_randomizer)->osm_pkt_num_unstable_links);
+
+ Exit:
+ OSM_LOG_EXIT(p_log);
+ return (res);
}
/**********************************************************************
**********************************************************************/
void
-osm_pkt_randomizer_destroy(
- IN OUT osm_pkt_randomizer_t **pp_pkt_randomizer,
- IN osm_log_t *p_log )
+osm_pkt_randomizer_destroy(IN OUT osm_pkt_randomizer_t ** pp_pkt_randomizer,
+ IN osm_log_t * p_log)
{
- OSM_LOG_ENTER( p_log, osm_pkt_randomizer_destroy );
-
- if ( *pp_pkt_randomizer != NULL )
- {
- free( (*pp_pkt_randomizer)->fault_dr_paths );
- free( *pp_pkt_randomizer );
- }
- OSM_LOG_EXIT( p_log );
+ OSM_LOG_ENTER(p_log, osm_pkt_randomizer_destroy);
+
+ if (*pp_pkt_randomizer != NULL) {
+ free((*pp_pkt_randomizer)->fault_dr_paths);
+ free(*pp_pkt_randomizer);
+ }
+ OSM_LOG_EXIT(p_log);
}
diff --git a/opensm/libvendor/osm_vendor_al.c b/opensm/libvendor/osm_vendor_al.c
index 1b748ae..7ad8547 100644
--- a/opensm/libvendor/osm_vendor_al.c
+++ b/opensm/libvendor/osm_vendor_al.c
@@ -33,7 +33,6 @@
*
*/
-
/*
* Abstract:
* Implementation of osm_req_t.
@@ -52,7 +51,7 @@
#if HAVE_CONFIG_H
# include <config.h>
-#endif /* HAVE_CONFIG_H */
+#endif /* HAVE_CONFIG_H */
#include <vendor/osm_vendor_select.h>
@@ -79,18 +78,17 @@
*
* SYNOPSIS
*/
-typedef struct _osm_al_bind_info
-{
- osm_vendor_t *p_vend;
- void *client_context;
- ib_qp_handle_t h_qp;
- ib_mad_svc_handle_t h_svc;
- uint8_t port_num;
- ib_pool_key_t pool_key;
- osm_vend_mad_recv_callback_t rcv_callback;
- osm_vend_mad_send_err_callback_t send_err_callback;
- osm_mad_pool_t *p_osm_pool;
- ib_av_handle_t h_dr_av;
+typedef struct _osm_al_bind_info {
+ osm_vendor_t *p_vend;
+ void *client_context;
+ ib_qp_handle_t h_qp;
+ ib_mad_svc_handle_t h_svc;
+ uint8_t port_num;
+ ib_pool_key_t pool_key;
+ osm_vend_mad_recv_callback_t rcv_callback;
+ osm_vend_mad_send_err_callback_t send_err_callback;
+ osm_mad_pool_t *p_osm_pool;
+ ib_av_handle_t h_dr_av;
} osm_al_bind_info_t;
/*
@@ -122,500 +120,453 @@ typedef struct _osm_al_bind_info
/**********************************************************************
**********************************************************************/
inline static ib_api_status_t
-__osm_al_convert_wcs(
- IN ib_wc_status_t const wc_status )
+__osm_al_convert_wcs(IN ib_wc_status_t const wc_status)
{
- switch( wc_status )
- {
- case IB_WCS_SUCCESS:
- return( IB_SUCCESS );
+ switch (wc_status) {
+ case IB_WCS_SUCCESS:
+ return (IB_SUCCESS);
- case IB_WCS_TIMEOUT_RETRY_ERR:
- return( IB_TIMEOUT );
+ case IB_WCS_TIMEOUT_RETRY_ERR:
+ return (IB_TIMEOUT);
- default:
- return( IB_ERROR );
- }
+ default:
+ return (IB_ERROR);
+ }
}
/**********************************************************************
**********************************************************************/
-static void
-__osm_al_ca_err_callback(
- IN ib_async_event_rec_t *p_async_rec )
+static void __osm_al_ca_err_callback(IN ib_async_event_rec_t * p_async_rec)
{
- osm_vendor_t *p_vend = (osm_vendor_t*)p_async_rec->context;
- OSM_LOG_ENTER( p_vend->p_log, __osm_al_ca_err_callback );
+ osm_vendor_t *p_vend = (osm_vendor_t *) p_async_rec->context;
+ OSM_LOG_ENTER(p_vend->p_log, __osm_al_ca_err_callback);
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__osm_al_ca_err_callback: ERR 3B01: "
- "Event on channel adapter (%s).\n",
- ib_get_async_event_str( p_async_rec->code ) );
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_al_ca_err_callback: ERR 3B01: "
+ "Event on channel adapter (%s).\n",
+ ib_get_async_event_str(p_async_rec->code));
- OSM_LOG_EXIT( p_vend->p_log );
+ OSM_LOG_EXIT(p_vend->p_log);
}
/**********************************************************************
**********************************************************************/
-static void
-__osm_al_ca_destroy_callback(
- IN void *context )
+static void __osm_al_ca_destroy_callback(IN void *context)
{
- osm_al_bind_info_t *p_bind = (osm_al_bind_info_t*)context;
- osm_vendor_t *p_vend = p_bind->p_vend;
- OSM_LOG_ENTER( p_vend->p_log, __osm_al_ca_destroy_callback );
+ osm_al_bind_info_t *p_bind = (osm_al_bind_info_t *) context;
+ osm_vendor_t *p_vend = p_bind->p_vend;
+ OSM_LOG_ENTER(p_vend->p_log, __osm_al_ca_destroy_callback);
- osm_log( p_vend->p_log, OSM_LOG_INFO,
- "__osm_al_ca_destroy_callback: "
- "Closing local channel adapter.\n" );
+ osm_log(p_vend->p_log, OSM_LOG_INFO,
+ "__osm_al_ca_destroy_callback: "
+ "Closing local channel adapter.\n");
- OSM_LOG_EXIT( p_vend->p_log );
+ OSM_LOG_EXIT(p_vend->p_log);
}
/**********************************************************************
**********************************************************************/
-static void
-__osm_al_err_callback(
- IN ib_async_event_rec_t *p_async_rec )
+static void __osm_al_err_callback(IN ib_async_event_rec_t * p_async_rec)
{
- osm_al_bind_info_t *p_bind = (osm_al_bind_info_t*)p_async_rec->context;
- osm_vendor_t *p_vend = p_bind->p_vend;
- OSM_LOG_ENTER( p_vend->p_log, __osm_al_err_callback );
+ osm_al_bind_info_t *p_bind =
+ (osm_al_bind_info_t *) p_async_rec->context;
+ osm_vendor_t *p_vend = p_bind->p_vend;
+ OSM_LOG_ENTER(p_vend->p_log, __osm_al_err_callback);
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__osm_al_err_callback: ERR 3B02: "
- "Error on QP (%s).\n",
- ib_get_async_event_str( p_async_rec->code ) );
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_al_err_callback: ERR 3B02: "
+ "Error on QP (%s).\n",
+ ib_get_async_event_str(p_async_rec->code));
- OSM_LOG_EXIT( p_vend->p_log );
+ OSM_LOG_EXIT(p_vend->p_log);
}
/**********************************************************************
**********************************************************************/
static void
-__osm_al_send_callback(
- IN void *mad_svc_context,
- IN ib_mad_element_t *p_elem )
+__osm_al_send_callback(IN void *mad_svc_context, IN ib_mad_element_t * p_elem)
{
- osm_al_bind_info_t* const p_bind = (osm_al_bind_info_t*)mad_svc_context;
- osm_vendor_t* const p_vend = p_bind->p_vend;
- osm_madw_t* const p_madw = (osm_madw_t*)p_elem->context1;
- osm_vend_wrap_t* const p_vw = osm_madw_get_vend_ptr( p_madw );
- ib_mad_t *p_mad;
-
- OSM_LOG_ENTER( p_vend->p_log, __osm_al_send_callback );
-
- CL_ASSERT( p_vw );
- CL_ASSERT( p_vw->h_av );
-
- /*
- Destroy the address vector as necessary.
- */
- if( p_vw->h_av != p_bind->h_dr_av )
- {
- if( osm_log_is_active( p_vend->p_log, OSM_LOG_DEBUG ) )
- {
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "__osm_al_send_callback: "
- "Destroying av handle %p.\n", p_vw->h_av );
- }
-
- ib_destroy_av( p_vw->h_av );
- }
-
- p_mad = ib_get_mad_buf( p_elem );
-
- if( p_elem->resp_expected )
- {
- /*
- If the send was unsuccessful, notify the user
- for MADs that were expecting a response.
- A NULL mad wrapper parameter is the user's clue
- that the transaction turned sour.
-
- Otherwise, do nothing for successful sends when a
- reponse is expected. The mad will be returned to the
- pool later.
- */
- p_madw->status = __osm_al_convert_wcs( p_elem->status );
- if( p_elem->status != IB_WCS_SUCCESS )
- {
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "__osm_al_send_callback: "
- "MAD completed with work queue error: %s.\n",
- ib_get_wc_status_str( p_elem->status ) );
- /*
- Return any wrappers to the pool that may have been
- pre-emptively allocated to handle a receive.
- */
- if( p_vw->p_resp_madw )
- {
- osm_mad_pool_put( p_bind->p_osm_pool, p_vw->p_resp_madw );
- p_vw->p_resp_madw = NULL;
- }
-
- p_bind->send_err_callback( p_bind->client_context, p_madw );
- }
- }
- else
- {
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "__osm_al_send_callback: "
- "Returning MAD to pool, TID = 0x%" PRIx64 ".\n",
- cl_ntoh64( p_mad->trans_id ) );
- osm_mad_pool_put( p_bind->p_osm_pool, p_madw );
- goto Exit;
- }
-
- Exit:
- OSM_LOG_EXIT( p_vend->p_log );
+ osm_al_bind_info_t *const p_bind =
+ (osm_al_bind_info_t *) mad_svc_context;
+ osm_vendor_t *const p_vend = p_bind->p_vend;
+ osm_madw_t *const p_madw = (osm_madw_t *) p_elem->context1;
+ osm_vend_wrap_t *const p_vw = osm_madw_get_vend_ptr(p_madw);
+ ib_mad_t *p_mad;
+
+ OSM_LOG_ENTER(p_vend->p_log, __osm_al_send_callback);
+
+ CL_ASSERT(p_vw);
+ CL_ASSERT(p_vw->h_av);
+
+ /*
+ Destroy the address vector as necessary.
+ */
+ if (p_vw->h_av != p_bind->h_dr_av) {
+ if (osm_log_is_active(p_vend->p_log, OSM_LOG_DEBUG)) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__osm_al_send_callback: "
+ "Destroying av handle %p.\n", p_vw->h_av);
+ }
+
+ ib_destroy_av(p_vw->h_av);
+ }
+
+ p_mad = ib_get_mad_buf(p_elem);
+
+ if (p_elem->resp_expected) {
+ /*
+ If the send was unsuccessful, notify the user
+ for MADs that were expecting a response.
+ A NULL mad wrapper parameter is the user's clue
+ that the transaction turned sour.
+
+ Otherwise, do nothing for successful sends when a
+ reponse is expected. The mad will be returned to the
+ pool later.
+ */
+ p_madw->status = __osm_al_convert_wcs(p_elem->status);
+ if (p_elem->status != IB_WCS_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__osm_al_send_callback: "
+ "MAD completed with work queue error: %s.\n",
+ ib_get_wc_status_str(p_elem->status));
+ /*
+ Return any wrappers to the pool that may have been
+ pre-emptively allocated to handle a receive.
+ */
+ if (p_vw->p_resp_madw) {
+ osm_mad_pool_put(p_bind->p_osm_pool,
+ p_vw->p_resp_madw);
+ p_vw->p_resp_madw = NULL;
+ }
+
+ p_bind->send_err_callback(p_bind->client_context,
+ p_madw);
+ }
+ } else {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__osm_al_send_callback: "
+ "Returning MAD to pool, TID = 0x%" PRIx64 ".\n",
+ cl_ntoh64(p_mad->trans_id));
+ osm_mad_pool_put(p_bind->p_osm_pool, p_madw);
+ goto Exit;
+ }
+
+ Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
}
/**********************************************************************
**********************************************************************/
static void
-__osm_al_rcv_callback(
- IN void *mad_svc_context,
- IN ib_mad_element_t *p_elem )
+__osm_al_rcv_callback(IN void *mad_svc_context, IN ib_mad_element_t * p_elem)
{
- osm_al_bind_info_t* const p_bind = (osm_al_bind_info_t*)mad_svc_context;
- osm_vendor_t* const p_vend = p_bind->p_vend;
- osm_madw_t *p_old_madw;
- osm_madw_t *p_new_madw;
- osm_vend_wrap_t* p_old_vw;
- osm_vend_wrap_t* p_new_vw;
- ib_mad_t *p_new_mad;
- osm_mad_addr_t mad_addr;
-
- OSM_LOG_ENTER( p_vend->p_log, __osm_al_rcv_callback );
-
- CL_ASSERT( p_elem->context1 == NULL );
- CL_ASSERT( p_elem->context2 == NULL );
-
- p_new_mad = ib_get_mad_buf( p_elem );
-
- /*
- In preperation for initializing the new mad wrapper,
- Initialize the mad_addr structure for the received wire MAD.
- */
- mad_addr.dest_lid = p_elem->remote_lid;
- mad_addr.path_bits = p_elem->path_bits;
-
- /* TO DO - figure out which #define to use for the 2.5 Gb rate... */
- mad_addr.static_rate = 0;
-
- if( p_new_mad->mgmt_class == IB_MCLASS_SUBN_LID ||
- p_new_mad->mgmt_class == IB_MCLASS_SUBN_DIR )
- {
- mad_addr.addr_type.smi.source_lid = p_elem->remote_lid;
- }
- else
- {
- mad_addr.addr_type.gsi.remote_qp = p_elem->remote_qp;
- mad_addr.addr_type.gsi.remote_qkey = p_elem->remote_qkey;
- mad_addr.addr_type.gsi.pkey = p_elem->pkey_index;
- mad_addr.addr_type.gsi.service_level = p_elem->remote_sl;
- mad_addr.addr_type.gsi.global_route = FALSE;
- }
-
- /*
- If this MAD is a response to a previous request,
- then grab our pre-allocated MAD wrapper.
- Otherwise, allocate a new MAD wrapper.
- */
- if( ib_mad_is_response( p_new_mad ) )
- {
- CL_ASSERT( p_elem->send_context1 != NULL );
- CL_ASSERT( p_elem->send_context2 == NULL );
-
- p_old_madw = (osm_madw_t*)p_elem->send_context1;
- p_old_vw = osm_madw_get_vend_ptr( p_old_madw );
- p_new_madw = p_old_vw->p_resp_madw;
-
- CL_ASSERT( p_new_madw );
-
- osm_madw_init( p_new_madw, p_bind, p_elem->size,
- &mad_addr );
- osm_madw_set_mad( p_new_madw, p_new_mad );
- }
- else
- {
- CL_ASSERT( p_elem->send_context1 == NULL );
- CL_ASSERT( p_elem->send_context2 == NULL );
-
- p_new_madw = osm_mad_pool_get_wrapper( p_bind->p_osm_pool,
- p_bind, p_elem->size, p_new_mad, &mad_addr );
- }
-
- CL_ASSERT(p_new_madw);
- p_new_vw = osm_madw_get_vend_ptr( p_new_madw );
-
-
- p_new_vw->h_bind = p_bind;
- p_new_vw->size = p_elem->size;
- p_new_vw->p_elem = p_elem;
- p_new_vw->h_av = 0;
- p_new_vw->p_resp_madw = NULL;
-
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "__osm_al_rcv_callback: "
- "Calling receive callback function %p.\n",
- p_bind->rcv_callback );
-
- p_bind->rcv_callback( p_new_madw, p_bind->client_context,
- p_elem->send_context1 );
-
- OSM_LOG_EXIT( p_vend->p_log );
+ osm_al_bind_info_t *const p_bind =
+ (osm_al_bind_info_t *) mad_svc_context;
+ osm_vendor_t *const p_vend = p_bind->p_vend;
+ osm_madw_t *p_old_madw;
+ osm_madw_t *p_new_madw;
+ osm_vend_wrap_t *p_old_vw;
+ osm_vend_wrap_t *p_new_vw;
+ ib_mad_t *p_new_mad;
+ osm_mad_addr_t mad_addr;
+
+ OSM_LOG_ENTER(p_vend->p_log, __osm_al_rcv_callback);
+
+ CL_ASSERT(p_elem->context1 == NULL);
+ CL_ASSERT(p_elem->context2 == NULL);
+
+ p_new_mad = ib_get_mad_buf(p_elem);
+
+ /*
+ In preperation for initializing the new mad wrapper,
+ Initialize the mad_addr structure for the received wire MAD.
+ */
+ mad_addr.dest_lid = p_elem->remote_lid;
+ mad_addr.path_bits = p_elem->path_bits;
+
+ /* TO DO - figure out which #define to use for the 2.5 Gb rate... */
+ mad_addr.static_rate = 0;
+
+ if (p_new_mad->mgmt_class == IB_MCLASS_SUBN_LID ||
+ p_new_mad->mgmt_class == IB_MCLASS_SUBN_DIR) {
+ mad_addr.addr_type.smi.source_lid = p_elem->remote_lid;
+ } else {
+ mad_addr.addr_type.gsi.remote_qp = p_elem->remote_qp;
+ mad_addr.addr_type.gsi.remote_qkey = p_elem->remote_qkey;
+ mad_addr.addr_type.gsi.pkey = p_elem->pkey_index;
+ mad_addr.addr_type.gsi.service_level = p_elem->remote_sl;
+ mad_addr.addr_type.gsi.global_route = FALSE;
+ }
+
+ /*
+ If this MAD is a response to a previous request,
+ then grab our pre-allocated MAD wrapper.
+ Otherwise, allocate a new MAD wrapper.
+ */
+ if (ib_mad_is_response(p_new_mad)) {
+ CL_ASSERT(p_elem->send_context1 != NULL);
+ CL_ASSERT(p_elem->send_context2 == NULL);
+
+ p_old_madw = (osm_madw_t *) p_elem->send_context1;
+ p_old_vw = osm_madw_get_vend_ptr(p_old_madw);
+ p_new_madw = p_old_vw->p_resp_madw;
+
+ CL_ASSERT(p_new_madw);
+
+ osm_madw_init(p_new_madw, p_bind, p_elem->size, &mad_addr);
+ osm_madw_set_mad(p_new_madw, p_new_mad);
+ } else {
+ CL_ASSERT(p_elem->send_context1 == NULL);
+ CL_ASSERT(p_elem->send_context2 == NULL);
+
+ p_new_madw = osm_mad_pool_get_wrapper(p_bind->p_osm_pool,
+ p_bind, p_elem->size,
+ p_new_mad, &mad_addr);
+ }
+
+ CL_ASSERT(p_new_madw);
+ p_new_vw = osm_madw_get_vend_ptr(p_new_madw);
+
+ p_new_vw->h_bind = p_bind;
+ p_new_vw->size = p_elem->size;
+ p_new_vw->p_elem = p_elem;
+ p_new_vw->h_av = 0;
+ p_new_vw->p_resp_madw = NULL;
+
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__osm_al_rcv_callback: "
+ "Calling receive callback function %p.\n",
+ p_bind->rcv_callback);
+
+ p_bind->rcv_callback(p_new_madw, p_bind->client_context,
+ p_elem->send_context1);
+
+ OSM_LOG_EXIT(p_vend->p_log);
}
/**********************************************************************
**********************************************************************/
ib_api_status_t
-osm_vendor_init(
- IN osm_vendor_t* const p_vend,
- IN osm_log_t* const p_log,
- IN const uint32_t timeout )
+osm_vendor_init(IN osm_vendor_t * const p_vend,
+ IN osm_log_t * const p_log, IN const uint32_t timeout)
{
- ib_api_status_t status;
- OSM_LOG_ENTER( p_log, osm_vendor_init );
-
- p_vend->p_log = p_log;
-
- /*
- Open our instance of AL.
- */
- status = ib_open_al( &p_vend->h_al );
- if( status != IB_SUCCESS )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_init: ERR 3B03: "
- "Error opening AL (%s).\n",
- ib_get_err_str( status ) );
-
- goto Exit;
- }
-
- p_vend->timeout = timeout;
-
- Exit:
- OSM_LOG_EXIT( p_log );
- return( status );
+ ib_api_status_t status;
+ OSM_LOG_ENTER(p_log, osm_vendor_init);
+
+ p_vend->p_log = p_log;
+
+ /*
+ Open our instance of AL.
+ */
+ status = ib_open_al(&p_vend->h_al);
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_init: ERR 3B03: "
+ "Error opening AL (%s).\n", ib_get_err_str(status));
+
+ goto Exit;
+ }
+
+ p_vend->timeout = timeout;
+
+ Exit:
+ OSM_LOG_EXIT(p_log);
+ return (status);
}
/**********************************************************************
**********************************************************************/
-osm_vendor_t*
-osm_vendor_new(
- IN osm_log_t* const p_log,
- IN const uint32_t timeout )
+osm_vendor_t *osm_vendor_new(IN osm_log_t * const p_log,
+ IN const uint32_t timeout)
{
- ib_api_status_t status;
- osm_vendor_t *p_vend;
-
- OSM_LOG_ENTER( p_log, osm_vendor_new );
-
- p_vend = malloc( sizeof(*p_vend) );
- if( p_vend == NULL )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_new: ERR 3B04: "
- "Unable to allocate vendor object.\n" );
- goto Exit;
- }
-
- memset( p_vend, 0, sizeof(*p_vend) );
-
- status = osm_vendor_init( p_vend, p_log, timeout );
- if( status != IB_SUCCESS )
- {
- free( p_vend );
- p_vend = NULL;
- }
-
- Exit:
- OSM_LOG_EXIT( p_log );
- return( p_vend );
+ ib_api_status_t status;
+ osm_vendor_t *p_vend;
+
+ OSM_LOG_ENTER(p_log, osm_vendor_new);
+
+ p_vend = malloc(sizeof(*p_vend));
+ if (p_vend == NULL) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_new: ERR 3B04: "
+ "Unable to allocate vendor object.\n");
+ goto Exit;
+ }
+
+ memset(p_vend, 0, sizeof(*p_vend));
+
+ status = osm_vendor_init(p_vend, p_log, timeout);
+ if (status != IB_SUCCESS) {
+ free(p_vend);
+ p_vend = NULL;
+ }
+
+ Exit:
+ OSM_LOG_EXIT(p_log);
+ return (p_vend);
}
/**********************************************************************
**********************************************************************/
-void
-osm_vendor_delete(
- IN osm_vendor_t** const pp_vend )
+void osm_vendor_delete(IN osm_vendor_t ** const pp_vend)
{
- /* TO DO - fill this in */
- ib_close_al( (*pp_vend)->h_al );
- free( *pp_vend );
- *pp_vend = NULL;
+ /* TO DO - fill this in */
+ ib_close_al((*pp_vend)->h_al);
+ free(*pp_vend);
+ *pp_vend = NULL;
}
/**********************************************************************
**********************************************************************/
static ib_api_status_t
-__osm_ca_info_init(
- IN osm_vendor_t* const p_vend,
- IN osm_ca_info_t* const p_ca_info,
- IN const ib_net64_t ca_guid )
+__osm_ca_info_init(IN osm_vendor_t * const p_vend,
+ IN osm_ca_info_t * const p_ca_info,
+ IN const ib_net64_t ca_guid)
{
- ib_api_status_t status;
-
- OSM_LOG_ENTER( p_vend->p_log, __osm_ca_info_init );
-
- p_ca_info->guid = ca_guid;
-
- if( osm_log_is_active( p_vend->p_log, OSM_LOG_VERBOSE ) )
- {
- osm_log( p_vend->p_log, OSM_LOG_VERBOSE,
- "__osm_ca_info_init: "
- "Querying CA 0x%" PRIx64 ".\n",
- cl_ntoh64( ca_guid ) );
- }
-
- status = ib_query_ca_by_guid( p_vend->h_al, ca_guid, NULL,
- &p_ca_info->attr_size );
- if( (status != IB_INSUFFICIENT_MEMORY ) && (status != IB_SUCCESS ) )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__osm_ca_info_init: ERR 3B05: "
- "Unexpected status getting CA attributes (%s).\n",
- ib_get_err_str( status ) );
- goto Exit;
- }
-
- CL_ASSERT( p_ca_info->attr_size );
-
- p_ca_info->p_attr = malloc( p_ca_info->attr_size );
- if( p_ca_info->p_attr == NULL )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__osm_ca_info_init: ERR 3B06: "
- "Unable to allocate attribute storage.\n" );
- goto Exit;
- }
-
- status = ib_query_ca_by_guid( p_vend->h_al, ca_guid, p_ca_info->p_attr,
- &p_ca_info->attr_size );
- if( status != IB_SUCCESS )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__osm_ca_info_init: ERR 3B07: "
- "Unexpected status getting CA attributes (%s).\n",
- ib_get_err_str( status ) );
- goto Exit;
- }
-
- Exit:
- OSM_LOG_EXIT( p_vend->p_log );
- return( status );
+ ib_api_status_t status;
+
+ OSM_LOG_ENTER(p_vend->p_log, __osm_ca_info_init);
+
+ p_ca_info->guid = ca_guid;
+
+ if (osm_log_is_active(p_vend->p_log, OSM_LOG_VERBOSE)) {
+ osm_log(p_vend->p_log, OSM_LOG_VERBOSE,
+ "__osm_ca_info_init: "
+ "Querying CA 0x%" PRIx64 ".\n", cl_ntoh64(ca_guid));
+ }
+
+ status = ib_query_ca_by_guid(p_vend->h_al, ca_guid, NULL,
+ &p_ca_info->attr_size);
+ if ((status != IB_INSUFFICIENT_MEMORY) && (status != IB_SUCCESS)) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_ca_info_init: ERR 3B05: "
+ "Unexpected status getting CA attributes (%s).\n",
+ ib_get_err_str(status));
+ goto Exit;
+ }
+
+ CL_ASSERT(p_ca_info->attr_size);
+
+ p_ca_info->p_attr = malloc(p_ca_info->attr_size);
+ if (p_ca_info->p_attr == NULL) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_ca_info_init: ERR 3B06: "
+ "Unable to allocate attribute storage.\n");
+ goto Exit;
+ }
+
+ status = ib_query_ca_by_guid(p_vend->h_al, ca_guid, p_ca_info->p_attr,
+ &p_ca_info->attr_size);
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_ca_info_init: ERR 3B07: "
+ "Unexpected status getting CA attributes (%s).\n",
+ ib_get_err_str(status));
+ goto Exit;
+ }
+
+ Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
}
-
/**********************************************************************
**********************************************************************/
void
-osm_ca_info_destroy(
- IN osm_vendor_t* const p_vend,
- IN osm_ca_info_t* const p_ca_info )
+osm_ca_info_destroy(IN osm_vendor_t * const p_vend,
+ IN osm_ca_info_t * const p_ca_info)
{
- OSM_LOG_ENTER( p_vend->p_log, osm_ca_info_destroy );
+ OSM_LOG_ENTER(p_vend->p_log, osm_ca_info_destroy);
- if( p_ca_info->p_attr )
- free( p_ca_info->p_attr );
+ if (p_ca_info->p_attr)
+ free(p_ca_info->p_attr);
- free( p_ca_info );
+ free(p_ca_info);
- OSM_LOG_EXIT( p_vend->p_log );
+ OSM_LOG_EXIT(p_vend->p_log);
}
/**********************************************************************
**********************************************************************/
-osm_ca_info_t*
-osm_ca_info_new(
- IN osm_vendor_t* const p_vend,
- IN const ib_net64_t ca_guid )
+osm_ca_info_t *osm_ca_info_new(IN osm_vendor_t * const p_vend,
+ IN const ib_net64_t ca_guid)
{
- ib_api_status_t status;
- osm_ca_info_t *p_ca_info;
+ ib_api_status_t status;
+ osm_ca_info_t *p_ca_info;
- OSM_LOG_ENTER( p_vend->p_log, osm_ca_info_new );
+ OSM_LOG_ENTER(p_vend->p_log, osm_ca_info_new);
- CL_ASSERT( ca_guid );
+ CL_ASSERT(ca_guid);
- p_ca_info = malloc( sizeof(*p_ca_info) );
- if( p_ca_info == NULL )
- goto Exit;
+ p_ca_info = malloc(sizeof(*p_ca_info));
+ if (p_ca_info == NULL)
+ goto Exit;
- memset( p_ca_info, 0, sizeof(*p_ca_info) );
+ memset(p_ca_info, 0, sizeof(*p_ca_info));
- status = __osm_ca_info_init( p_vend, p_ca_info, ca_guid );
- if( status != IB_SUCCESS )
- {
- osm_ca_info_destroy( p_vend, p_ca_info );
- p_ca_info = NULL;
- goto Exit;
- }
+ status = __osm_ca_info_init(p_vend, p_ca_info, ca_guid);
+ if (status != IB_SUCCESS) {
+ osm_ca_info_destroy(p_vend, p_ca_info);
+ p_ca_info = NULL;
+ goto Exit;
+ }
- Exit:
- OSM_LOG_EXIT( p_vend->p_log );
- return( p_ca_info );
+ Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (p_ca_info);
}
/**********************************************************************
**********************************************************************/
static ib_api_status_t
-__osm_vendor_get_ca_guids(
- IN osm_vendor_t* const p_vend,
- IN ib_net64_t** const p_guids,
- IN uintn_t* const p_num_guids )
+__osm_vendor_get_ca_guids(IN osm_vendor_t * const p_vend,
+ IN ib_net64_t ** const p_guids,
+ IN uintn_t * const p_num_guids)
{
- ib_api_status_t status;
-
- OSM_LOG_ENTER( p_vend->p_log, __osm_vendor_get_ca_guids );
-
- CL_ASSERT( p_guids );
- CL_ASSERT( p_num_guids );
-
- status = ib_get_ca_guids( p_vend->h_al, NULL, p_num_guids );
- if( (status != IB_INSUFFICIENT_MEMORY ) && (status != IB_SUCCESS ) )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__osm_vendor_get_ca_guids: ERR 3B08: "
- "Unexpected status getting CA GUID array (%s).\n",
- ib_get_err_str( status ) );
- goto Exit;
- }
-
- if( *p_num_guids == 0 )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__osm_vendor_get_ca_guids: ERR 3B09: "
- "No available channel adapters.\n" );
- status = IB_INSUFFICIENT_RESOURCES;
- goto Exit;
- }
-
- *p_guids = malloc( *p_num_guids * sizeof(**p_guids) );
- if( *p_guids == NULL )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__osm_vendor_get_ca_guids: ERR 3B10: "
- "Unable to allocate CA GUID array.\n" );
- goto Exit;
- }
-
- status = ib_get_ca_guids( p_vend->h_al, *p_guids, p_num_guids );
- CL_ASSERT( *p_num_guids );
-
- if( osm_log_is_active( p_vend->p_log, OSM_LOG_VERBOSE ) )
- {
- osm_log( p_vend->p_log, OSM_LOG_VERBOSE,
- "__osm_vendor_get_ca_guids: "
- "Detected %u local channel adapters.\n", *p_num_guids );
- }
-
- Exit:
- OSM_LOG_EXIT( p_vend->p_log );
- return( status );
+ ib_api_status_t status;
+
+ OSM_LOG_ENTER(p_vend->p_log, __osm_vendor_get_ca_guids);
+
+ CL_ASSERT(p_guids);
+ CL_ASSERT(p_num_guids);
+
+ status = ib_get_ca_guids(p_vend->h_al, NULL, p_num_guids);
+ if ((status != IB_INSUFFICIENT_MEMORY) && (status != IB_SUCCESS)) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_vendor_get_ca_guids: ERR 3B08: "
+ "Unexpected status getting CA GUID array (%s).\n",
+ ib_get_err_str(status));
+ goto Exit;
+ }
+
+ if (*p_num_guids == 0) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_vendor_get_ca_guids: ERR 3B09: "
+ "No available channel adapters.\n");
+ status = IB_INSUFFICIENT_RESOURCES;
+ goto Exit;
+ }
+
+ *p_guids = malloc(*p_num_guids * sizeof(**p_guids));
+ if (*p_guids == NULL) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_vendor_get_ca_guids: ERR 3B10: "
+ "Unable to allocate CA GUID array.\n");
+ goto Exit;
+ }
+
+ status = ib_get_ca_guids(p_vend->h_al, *p_guids, p_num_guids);
+ CL_ASSERT(*p_num_guids);
+
+ if (osm_log_is_active(p_vend->p_log, OSM_LOG_VERBOSE)) {
+ osm_log(p_vend->p_log, OSM_LOG_VERBOSE,
+ "__osm_vendor_get_ca_guids: "
+ "Detected %u local channel adapters.\n", *p_num_guids);
+ }
+
+ Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
}
/****f* OpenSM: CA Info/osm_ca_info_get_pi_ptr
@@ -628,13 +579,13 @@ __osm_vendor_get_ca_guids(
*
* SYNOPSIS
*/
-static ib_port_attr_t*
-__osm_ca_info_get_port_attr_ptr(
- IN const osm_ca_info_t* const p_ca_info,
- IN const uint8_t index )
+static ib_port_attr_t *__osm_ca_info_get_port_attr_ptr(IN const osm_ca_info_t *
+ const p_ca_info,
+ IN const uint8_t index)
{
- return( &p_ca_info->p_attr->p_port_attr[index] );
+ return (&p_ca_info->p_attr->p_port_attr[index]);
}
+
/*
* PARAMETERS
* p_ca_info
@@ -657,807 +608,719 @@ __osm_ca_info_get_port_attr_ptr(
/**********************************************************************
**********************************************************************/
ib_api_status_t
-osm_vendor_get_all_port_attr(
- IN osm_vendor_t* const p_vend,
- IN ib_port_attr_t* const p_attr_array,
- IN uint32_t* const p_num_ports )
+osm_vendor_get_all_port_attr(IN osm_vendor_t * const p_vend,
+ IN ib_port_attr_t * const p_attr_array,
+ IN uint32_t * const p_num_ports)
{
- ib_api_status_t status;
-
- uint32_t ca;
- uintn_t ca_count;
- uint32_t port_count = 0;
- uint8_t port_num;
- uint32_t total_ports = 0;
- ib_net64_t *p_ca_guid = NULL;
- osm_ca_info_t *p_ca_info;
-
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_get_all_port_attr );
-
- CL_ASSERT( p_vend );
- CL_ASSERT( p_vend->p_ca_info == NULL );
-
- /*
- 1) Determine the number of CA's
- 2) Allocate an array big enough to hold the ca info objects.
- 3) Call again to retrieve the guids.
- */
- status = __osm_vendor_get_ca_guids( p_vend, &p_ca_guid, &ca_count );
-
- p_vend->p_ca_info = malloc( ca_count * sizeof(*p_vend->p_ca_info) );
- if( p_vend->p_ca_info == NULL )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_all_port_attr: ERR 3B11: "
- "Unable to allocate CA information array.\n" );
- goto Exit;
- }
-
- memset( p_vend->p_ca_info, 0, ca_count * sizeof(*p_vend->p_ca_info) );
- p_vend->ca_count = ca_count;
-
- /*
- For each CA, retrieve the port info attributes
- */
- for( ca = 0; ca < ca_count; ca++ )
- {
- p_ca_info = &p_vend->p_ca_info[ca];
-
- status = __osm_ca_info_init(
- p_vend,
- p_ca_info,
- p_ca_guid[ca] );
-
- if( status != IB_SUCCESS )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_all_port_attr: ERR 3B12: "
- "Unable to initialize CA Info object (%s).\n",
- ib_get_err_str( status ) );
- }
-
- total_ports += osm_ca_info_get_num_ports( p_ca_info );
- }
-
- /*
- If the user supplied enough storage, return the port guids,
- otherwise, return the appropriate error.
- */
- if( *p_num_ports >= total_ports )
- {
- for( ca = 0; ca < ca_count; ca++ )
- {
- uint32_t num_ports;
-
- p_ca_info = &p_vend->p_ca_info[ca];
-
- num_ports = osm_ca_info_get_num_ports( p_ca_info );
-
- for( port_num = 0; port_num < num_ports; port_num++ )
- {
- p_attr_array[port_count] = *__osm_ca_info_get_port_attr_ptr(
- p_ca_info, port_num );
- port_count++;
- }
- }
- }
- else
- {
- status = IB_INSUFFICIENT_MEMORY;
- }
-
-
- *p_num_ports = total_ports;
-
-
- Exit:
- if( p_ca_guid )
- free( p_ca_guid );
-
- OSM_LOG_EXIT( p_vend->p_log );
- return( status );
+ ib_api_status_t status;
+
+ uint32_t ca;
+ uintn_t ca_count;
+ uint32_t port_count = 0;
+ uint8_t port_num;
+ uint32_t total_ports = 0;
+ ib_net64_t *p_ca_guid = NULL;
+ osm_ca_info_t *p_ca_info;
+
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_get_all_port_attr);
+
+ CL_ASSERT(p_vend);
+ CL_ASSERT(p_vend->p_ca_info == NULL);
+
+ /*
+ 1) Determine the number of CA's
+ 2) Allocate an array big enough to hold the ca info objects.
+ 3) Call again to retrieve the guids.
+ */
+ status = __osm_vendor_get_ca_guids(p_vend, &p_ca_guid, &ca_count);
+
+ p_vend->p_ca_info = malloc(ca_count * sizeof(*p_vend->p_ca_info));
+ if (p_vend->p_ca_info == NULL) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_all_port_attr: ERR 3B11: "
+ "Unable to allocate CA information array.\n");
+ goto Exit;
+ }
+
+ memset(p_vend->p_ca_info, 0, ca_count * sizeof(*p_vend->p_ca_info));
+ p_vend->ca_count = ca_count;
+
+ /*
+ For each CA, retrieve the port info attributes
+ */
+ for (ca = 0; ca < ca_count; ca++) {
+ p_ca_info = &p_vend->p_ca_info[ca];
+
+ status = __osm_ca_info_init(p_vend, p_ca_info, p_ca_guid[ca]);
+
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_all_port_attr: ERR 3B12: "
+ "Unable to initialize CA Info object (%s).\n",
+ ib_get_err_str(status));
+ }
+
+ total_ports += osm_ca_info_get_num_ports(p_ca_info);
+ }
+
+ /*
+ If the user supplied enough storage, return the port guids,
+ otherwise, return the appropriate error.
+ */
+ if (*p_num_ports >= total_ports) {
+ for (ca = 0; ca < ca_count; ca++) {
+ uint32_t num_ports;
+
+ p_ca_info = &p_vend->p_ca_info[ca];
+
+ num_ports = osm_ca_info_get_num_ports(p_ca_info);
+
+ for (port_num = 0; port_num < num_ports; port_num++) {
+ p_attr_array[port_count] =
+ *__osm_ca_info_get_port_attr_ptr(p_ca_info,
+ port_num);
+ port_count++;
+ }
+ }
+ } else {
+ status = IB_INSUFFICIENT_MEMORY;
+ }
+
+ *p_num_ports = total_ports;
+
+ Exit:
+ if (p_ca_guid)
+ free(p_ca_guid);
+
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
}
/**********************************************************************
**********************************************************************/
ib_net64_t
-osm_vendor_get_ca_guid(
- IN osm_vendor_t* const p_vend,
- IN const ib_net64_t port_guid )
+osm_vendor_get_ca_guid(IN osm_vendor_t * const p_vend,
+ IN const ib_net64_t port_guid)
{
- uint8_t index;
- uint8_t num_ports;
- uint32_t num_guids = 0;
- osm_ca_info_t *p_ca_info;
- uint32_t ca;
-
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_get_ca_guid );
-
- CL_ASSERT( port_guid );
- /*
- First, locate the HCA that owns this port.
- */
- if( p_vend->p_ca_info == NULL )
- {
- /*
- Initialize the osm_ca_info_t array which allows
- us to match port GUID to CA.
- */
- osm_vendor_get_all_port_attr( p_vend, NULL, &num_guids );
- }
-
- CL_ASSERT( p_vend->p_ca_info );
- CL_ASSERT( p_vend->ca_count );
-
- for( ca = 0; ca < p_vend->ca_count; ca++ )
- {
- p_ca_info = &p_vend->p_ca_info[ca];
-
- num_ports = osm_ca_info_get_num_ports( p_ca_info );
- CL_ASSERT( num_ports );
-
- for( index = 0; index < num_ports; index++ )
- {
- if( port_guid ==
- osm_ca_info_get_port_guid( p_ca_info, index ) )
- {
- OSM_LOG_EXIT( p_vend->p_log );
- return( osm_ca_info_get_ca_guid( p_ca_info ) );
- }
- }
- }
-
- /*
- No local CA owns this guid!
- */
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_ca_guid: ERR 3B13: "
- "Unable to determine CA guid.\n" );
-
- OSM_LOG_EXIT( p_vend->p_log );
- return( 0 );
+ uint8_t index;
+ uint8_t num_ports;
+ uint32_t num_guids = 0;
+ osm_ca_info_t *p_ca_info;
+ uint32_t ca;
+
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_get_ca_guid);
+
+ CL_ASSERT(port_guid);
+ /*
+ First, locate the HCA that owns this port.
+ */
+ if (p_vend->p_ca_info == NULL) {
+ /*
+ Initialize the osm_ca_info_t array which allows
+ us to match port GUID to CA.
+ */
+ osm_vendor_get_all_port_attr(p_vend, NULL, &num_guids);
+ }
+
+ CL_ASSERT(p_vend->p_ca_info);
+ CL_ASSERT(p_vend->ca_count);
+
+ for (ca = 0; ca < p_vend->ca_count; ca++) {
+ p_ca_info = &p_vend->p_ca_info[ca];
+
+ num_ports = osm_ca_info_get_num_ports(p_ca_info);
+ CL_ASSERT(num_ports);
+
+ for (index = 0; index < num_ports; index++) {
+ if (port_guid ==
+ osm_ca_info_get_port_guid(p_ca_info, index)) {
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (osm_ca_info_get_ca_guid(p_ca_info));
+ }
+ }
+ }
+
+ /*
+ No local CA owns this guid!
+ */
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_ca_guid: ERR 3B13: "
+ "Unable to determine CA guid.\n");
+
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (0);
}
/**********************************************************************
**********************************************************************/
uint8_t
-osm_vendor_get_port_num(
- IN osm_vendor_t* const p_vend,
- IN const ib_net64_t port_guid )
+osm_vendor_get_port_num(IN osm_vendor_t * const p_vend,
+ IN const ib_net64_t port_guid)
{
- uint8_t index;
- uint8_t num_ports;
- uint32_t num_guids = 0;
- osm_ca_info_t *p_ca_info;
- uint32_t ca;
-
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_get_port_num );
-
- CL_ASSERT( port_guid );
- /*
- First, locate the HCA that owns this port.
- */
- if( p_vend->p_ca_info == NULL )
- {
- /*
- Initialize the osm_ca_info_t array which allows
- us to match port GUID to CA.
- */
- osm_vendor_get_all_port_attr( p_vend, NULL, &num_guids );
- }
-
- CL_ASSERT( p_vend->p_ca_info );
- CL_ASSERT( p_vend->ca_count );
-
- for( ca = 0; ca < p_vend->ca_count; ca++ )
- {
- p_ca_info = &p_vend->p_ca_info[ca];
-
- num_ports = osm_ca_info_get_num_ports( p_ca_info );
- CL_ASSERT( num_ports );
-
- for( index = 0; index < num_ports; index++ )
- {
- if( port_guid ==
- osm_ca_info_get_port_guid( p_ca_info, index ) )
- {
- OSM_LOG_EXIT( p_vend->p_log );
- return( osm_ca_info_get_port_num( p_ca_info, index ) );
- }
- }
- }
-
- /*
- No local CA owns this guid!
- */
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_port_num: ERR 3B30: "
- "Unable to determine CA guid.\n" );
-
- OSM_LOG_EXIT( p_vend->p_log );
- return( 0 );
+ uint8_t index;
+ uint8_t num_ports;
+ uint32_t num_guids = 0;
+ osm_ca_info_t *p_ca_info;
+ uint32_t ca;
+
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_get_port_num);
+
+ CL_ASSERT(port_guid);
+ /*
+ First, locate the HCA that owns this port.
+ */
+ if (p_vend->p_ca_info == NULL) {
+ /*
+ Initialize the osm_ca_info_t array which allows
+ us to match port GUID to CA.
+ */
+ osm_vendor_get_all_port_attr(p_vend, NULL, &num_guids);
+ }
+
+ CL_ASSERT(p_vend->p_ca_info);
+ CL_ASSERT(p_vend->ca_count);
+
+ for (ca = 0; ca < p_vend->ca_count; ca++) {
+ p_ca_info = &p_vend->p_ca_info[ca];
+
+ num_ports = osm_ca_info_get_num_ports(p_ca_info);
+ CL_ASSERT(num_ports);
+
+ for (index = 0; index < num_ports; index++) {
+ if (port_guid ==
+ osm_ca_info_get_port_guid(p_ca_info, index)) {
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (osm_ca_info_get_port_num
+ (p_ca_info, index));
+ }
+ }
+ }
+
+ /*
+ No local CA owns this guid!
+ */
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_port_num: ERR 3B30: "
+ "Unable to determine CA guid.\n");
+
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (0);
}
-
/**********************************************************************
**********************************************************************/
static ib_api_status_t
-__osm_vendor_open_ca(
- IN osm_vendor_t* const p_vend,
- IN const ib_net64_t port_guid )
+__osm_vendor_open_ca(IN osm_vendor_t * const p_vend,
+ IN const ib_net64_t port_guid)
{
- ib_net64_t ca_guid;
- ib_api_status_t status;
-
- OSM_LOG_ENTER( p_vend->p_log, __osm_vendor_open_ca );
-
- ca_guid = osm_vendor_get_ca_guid( p_vend, port_guid );
- if( ca_guid == 0 )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__osm_vendor_open_ca: ERR 3B31: "
- "Bad port GUID value 0x%" PRIx64 ".\n",
- cl_ntoh64( port_guid ) );
- status = IB_ERROR;
- goto Exit;
- }
-
- osm_log( p_vend->p_log, OSM_LOG_VERBOSE,
- "__osm_vendor_open_ca: "
- "Opening HCA 0x%" PRIx64 ".\n", cl_ntoh64( ca_guid ) );
-
- status = ib_open_ca( p_vend->h_al,
- ca_guid,
- __osm_al_ca_err_callback,
- p_vend,
- &p_vend->h_ca );
-
- if( status != IB_SUCCESS )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__osm_vendor_open_ca: ERR 3B15: "
- "Unable to open CA (%s).\n",
- ib_get_err_str( status ) );
- goto Exit;
- }
-
- CL_ASSERT( p_vend->h_ca );
-
- status = ib_alloc_pd(
- p_vend->h_ca,
- IB_PDT_ALIAS,
- p_vend,
- &p_vend->h_pd );
-
- if( status != IB_SUCCESS )
- {
- ib_close_ca( p_vend->h_ca, __osm_al_ca_destroy_callback );
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__osm_vendor_open_ca: ERR 3B16: "
- "Unable to allocate protection domain (%s).\n",
- ib_get_err_str( status ) );
- goto Exit;
- }
-
- CL_ASSERT( p_vend->h_pd );
-
- Exit:
- OSM_LOG_EXIT( p_vend->p_log );
- return( status );
+ ib_net64_t ca_guid;
+ ib_api_status_t status;
+
+ OSM_LOG_ENTER(p_vend->p_log, __osm_vendor_open_ca);
+
+ ca_guid = osm_vendor_get_ca_guid(p_vend, port_guid);
+ if (ca_guid == 0) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_vendor_open_ca: ERR 3B31: "
+ "Bad port GUID value 0x%" PRIx64 ".\n",
+ cl_ntoh64(port_guid));
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+ osm_log(p_vend->p_log, OSM_LOG_VERBOSE,
+ "__osm_vendor_open_ca: "
+ "Opening HCA 0x%" PRIx64 ".\n", cl_ntoh64(ca_guid));
+
+ status = ib_open_ca(p_vend->h_al,
+ ca_guid,
+ __osm_al_ca_err_callback, p_vend, &p_vend->h_ca);
+
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_vendor_open_ca: ERR 3B15: "
+ "Unable to open CA (%s).\n", ib_get_err_str(status));
+ goto Exit;
+ }
+
+ CL_ASSERT(p_vend->h_ca);
+
+ status = ib_alloc_pd(p_vend->h_ca, IB_PDT_ALIAS, p_vend, &p_vend->h_pd);
+
+ if (status != IB_SUCCESS) {
+ ib_close_ca(p_vend->h_ca, __osm_al_ca_destroy_callback);
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_vendor_open_ca: ERR 3B16: "
+ "Unable to allocate protection domain (%s).\n",
+ ib_get_err_str(status));
+ goto Exit;
+ }
+
+ CL_ASSERT(p_vend->h_pd);
+
+ Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
}
/**********************************************************************
**********************************************************************/
static void
-__osm_vendor_init_av(
- IN const osm_al_bind_info_t* p_bind,
- IN ib_av_attr_t* p_av )
+__osm_vendor_init_av(IN const osm_al_bind_info_t * p_bind,
+ IN ib_av_attr_t * p_av)
{
- memset( p_av, 0, sizeof(*p_av) );
- p_av->port_num = p_bind->port_num;
- p_av->dlid = IB_LID_PERMISSIVE;
+ memset(p_av, 0, sizeof(*p_av));
+ p_av->port_num = p_bind->port_num;
+ p_av->dlid = IB_LID_PERMISSIVE;
}
/**********************************************************************
**********************************************************************/
osm_bind_handle_t
-osm_vendor_bind(
- IN osm_vendor_t* const p_vend,
- IN osm_bind_info_t* const p_user_bind,
- IN osm_mad_pool_t* const p_mad_pool,
- IN osm_vend_mad_recv_callback_t mad_recv_callback,
- IN osm_vend_mad_send_err_callback_t send_err_callback,
- IN void* context )
+osm_vendor_bind(IN osm_vendor_t * const p_vend,
+ IN osm_bind_info_t * const p_user_bind,
+ IN osm_mad_pool_t * const p_mad_pool,
+ IN osm_vend_mad_recv_callback_t mad_recv_callback,
+ IN osm_vend_mad_send_err_callback_t send_err_callback,
+ IN void *context)
{
- ib_net64_t port_guid;
- osm_al_bind_info_t *p_bind = 0;
- ib_api_status_t status;
- ib_qp_create_t qp_create;
- ib_mad_svc_t mad_svc;
- ib_av_attr_t av;
-
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_bind );
-
- CL_ASSERT( p_user_bind );
- CL_ASSERT( p_mad_pool );
- CL_ASSERT( mad_recv_callback );
- CL_ASSERT( send_err_callback );
-
- port_guid = p_user_bind->port_guid;
-
- osm_log( p_vend->p_log, OSM_LOG_INFO,
- "osm_vendor_bind: "
- "Binding to port 0x%" PRIx64 ".\n",
- cl_ntoh64( port_guid ) );
-
- if( p_vend->h_ca == 0 )
- {
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_bind: "
- "Opening CA that owns port 0x%" PRIx64 ".\n", port_guid );
-
- status = __osm_vendor_open_ca( p_vend, port_guid );
- if( status != IB_SUCCESS )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 3B17: "
- "Unable to Open CA (%s).\n",
- ib_get_err_str( status ) );
- goto Exit;
- }
- }
-
- p_bind = malloc( sizeof(*p_bind) );
- if( p_bind == NULL )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 3B18: "
- "Unable to allocate internal bind object.\n" );
- goto Exit;
- }
-
- memset( p_bind, 0, sizeof(*p_bind) );
- p_bind->p_vend = p_vend;
- p_bind->client_context = context;
- p_bind->port_num = osm_vendor_get_port_num( p_vend, port_guid );
- p_bind->rcv_callback = mad_recv_callback;
- p_bind->send_err_callback = send_err_callback;
- p_bind->p_osm_pool = p_mad_pool;
-
- CL_ASSERT( p_bind->port_num );
-
- /*
- Get the proper QP.
- */
- memset( &qp_create, 0, sizeof(qp_create) );
-
- switch( p_user_bind->mad_class )
- {
- case IB_MCLASS_SUBN_LID:
- case IB_MCLASS_SUBN_DIR:
- qp_create.qp_type = IB_QPT_QP0_ALIAS;
- break;
-
- case IB_MCLASS_SUBN_ADM:
- default:
- qp_create.qp_type = IB_QPT_QP1_ALIAS;
- break;
- }
-
- qp_create.sq_depth = p_user_bind->send_q_size;
- qp_create.rq_depth = p_user_bind->recv_q_size;
- qp_create.sq_sge = OSM_AL_SQ_SGE;
- qp_create.rq_sge = OSM_AL_RQ_SGE;
-
- status = ib_get_spl_qp(
- p_vend->h_pd,
- port_guid,
- &qp_create,
- p_bind,
- __osm_al_err_callback,
- &p_bind->pool_key,
- &p_bind->h_qp );
-
- if( status != IB_SUCCESS )
- {
- free( p_bind );
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 3B19: "
- "Unable to get QP handle (%s).\n",
- ib_get_err_str( status ) );
- goto Exit;
- }
-
- CL_ASSERT( p_bind->h_qp );
- CL_ASSERT( p_bind->pool_key );
-
- memset( &mad_svc, 0, sizeof(mad_svc) );
-
- mad_svc.mad_svc_context = p_bind;
- mad_svc.pfn_mad_send_cb = __osm_al_send_callback;
- mad_svc.pfn_mad_recv_cb = __osm_al_rcv_callback;
- mad_svc.mgmt_class = p_user_bind->mad_class;
- mad_svc.mgmt_version = p_user_bind->class_version;
- mad_svc.support_unsol = p_user_bind->is_responder;
- mad_svc.method_array[IB_MAD_METHOD_GET] = TRUE;
- mad_svc.method_array[IB_MAD_METHOD_SET] = TRUE;
- mad_svc.method_array[IB_MAD_METHOD_DELETE] = TRUE;
- mad_svc.method_array[IB_MAD_METHOD_TRAP] = TRUE;
- mad_svc.method_array[IB_MAD_METHOD_GETTABLE] = TRUE;
-
-
- status = ib_reg_mad_svc(
- p_bind->h_qp,
- &mad_svc,
- &p_bind->h_svc );
-
- if( status != IB_SUCCESS )
- {
- free( p_bind );
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 3B21: "
- "Unable to register QP0 MAD service (%s).\n",
- ib_get_err_str( status ) );
- goto Exit;
- }
-
- __osm_vendor_init_av( p_bind, &av );
-
- status = ib_create_av( p_vend->h_pd, &av, &p_bind->h_dr_av );
- if( status != IB_SUCCESS )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 3B22: "
- "Unable to create address vector (%s).\n",
- ib_get_err_str( status ) );
-
- goto Exit;
- }
-
- if( osm_log_is_active( p_vend->p_log, OSM_LOG_DEBUG ) )
- {
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_bind: "
- "Allocating av handle %p.\n", p_bind->h_dr_av );
- }
-
- Exit:
- OSM_LOG_EXIT( p_vend->p_log );
- return( (osm_bind_handle_t)p_bind );
+ ib_net64_t port_guid;
+ osm_al_bind_info_t *p_bind = 0;
+ ib_api_status_t status;
+ ib_qp_create_t qp_create;
+ ib_mad_svc_t mad_svc;
+ ib_av_attr_t av;
+
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_bind);
+
+ CL_ASSERT(p_user_bind);
+ CL_ASSERT(p_mad_pool);
+ CL_ASSERT(mad_recv_callback);
+ CL_ASSERT(send_err_callback);
+
+ port_guid = p_user_bind->port_guid;
+
+ osm_log(p_vend->p_log, OSM_LOG_INFO,
+ "osm_vendor_bind: "
+ "Binding to port 0x%" PRIx64 ".\n", cl_ntoh64(port_guid));
+
+ if (p_vend->h_ca == 0) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_bind: "
+ "Opening CA that owns port 0x%" PRIx64 ".\n",
+ port_guid);
+
+ status = __osm_vendor_open_ca(p_vend, port_guid);
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 3B17: "
+ "Unable to Open CA (%s).\n",
+ ib_get_err_str(status));
+ goto Exit;
+ }
+ }
+
+ p_bind = malloc(sizeof(*p_bind));
+ if (p_bind == NULL) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 3B18: "
+ "Unable to allocate internal bind object.\n");
+ goto Exit;
+ }
+
+ memset(p_bind, 0, sizeof(*p_bind));
+ p_bind->p_vend = p_vend;
+ p_bind->client_context = context;
+ p_bind->port_num = osm_vendor_get_port_num(p_vend, port_guid);
+ p_bind->rcv_callback = mad_recv_callback;
+ p_bind->send_err_callback = send_err_callback;
+ p_bind->p_osm_pool = p_mad_pool;
+
+ CL_ASSERT(p_bind->port_num);
+
+ /*
+ Get the proper QP.
+ */
+ memset(&qp_create, 0, sizeof(qp_create));
+
+ switch (p_user_bind->mad_class) {
+ case IB_MCLASS_SUBN_LID:
+ case IB_MCLASS_SUBN_DIR:
+ qp_create.qp_type = IB_QPT_QP0_ALIAS;
+ break;
+
+ case IB_MCLASS_SUBN_ADM:
+ default:
+ qp_create.qp_type = IB_QPT_QP1_ALIAS;
+ break;
+ }
+
+ qp_create.sq_depth = p_user_bind->send_q_size;
+ qp_create.rq_depth = p_user_bind->recv_q_size;
+ qp_create.sq_sge = OSM_AL_SQ_SGE;
+ qp_create.rq_sge = OSM_AL_RQ_SGE;
+
+ status = ib_get_spl_qp(p_vend->h_pd,
+ port_guid,
+ &qp_create,
+ p_bind,
+ __osm_al_err_callback,
+ &p_bind->pool_key, &p_bind->h_qp);
+
+ if (status != IB_SUCCESS) {
+ free(p_bind);
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 3B19: "
+ "Unable to get QP handle (%s).\n",
+ ib_get_err_str(status));
+ goto Exit;
+ }
+
+ CL_ASSERT(p_bind->h_qp);
+ CL_ASSERT(p_bind->pool_key);
+
+ memset(&mad_svc, 0, sizeof(mad_svc));
+
+ mad_svc.mad_svc_context = p_bind;
+ mad_svc.pfn_mad_send_cb = __osm_al_send_callback;
+ mad_svc.pfn_mad_recv_cb = __osm_al_rcv_callback;
+ mad_svc.mgmt_class = p_user_bind->mad_class;
+ mad_svc.mgmt_version = p_user_bind->class_version;
+ mad_svc.support_unsol = p_user_bind->is_responder;
+ mad_svc.method_array[IB_MAD_METHOD_GET] = TRUE;
+ mad_svc.method_array[IB_MAD_METHOD_SET] = TRUE;
+ mad_svc.method_array[IB_MAD_METHOD_DELETE] = TRUE;
+ mad_svc.method_array[IB_MAD_METHOD_TRAP] = TRUE;
+ mad_svc.method_array[IB_MAD_METHOD_GETTABLE] = TRUE;
+
+ status = ib_reg_mad_svc(p_bind->h_qp, &mad_svc, &p_bind->h_svc);
+
+ if (status != IB_SUCCESS) {
+ free(p_bind);
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 3B21: "
+ "Unable to register QP0 MAD service (%s).\n",
+ ib_get_err_str(status));
+ goto Exit;
+ }
+
+ __osm_vendor_init_av(p_bind, &av);
+
+ status = ib_create_av(p_vend->h_pd, &av, &p_bind->h_dr_av);
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 3B22: "
+ "Unable to create address vector (%s).\n",
+ ib_get_err_str(status));
+
+ goto Exit;
+ }
+
+ if (osm_log_is_active(p_vend->p_log, OSM_LOG_DEBUG)) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_bind: "
+ "Allocating av handle %p.\n", p_bind->h_dr_av);
+ }
+
+ Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return ((osm_bind_handle_t) p_bind);
}
/**********************************************************************
**********************************************************************/
-ib_mad_t*
-osm_vendor_get(
- IN osm_bind_handle_t h_bind,
- IN const uint32_t mad_size,
- IN osm_vend_wrap_t* const p_vw )
+ib_mad_t *osm_vendor_get(IN osm_bind_handle_t h_bind,
+ IN const uint32_t mad_size,
+ IN osm_vend_wrap_t * const p_vw)
{
- ib_mad_t *p_mad;
- osm_al_bind_info_t *p_bind = (osm_al_bind_info_t *)h_bind;
- osm_vendor_t *p_vend = p_bind->p_vend;
- ib_api_status_t status;
-
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_get );
-
- CL_ASSERT( p_vw );
-
- p_vw->size = mad_size;
- p_vw->h_bind = h_bind;
-
- /*
- Retrieve a MAD element from the pool and give the user direct
- access to its buffer.
- */
- status = ib_get_mad( p_bind->pool_key, mad_size, &p_vw->p_elem );
- if( status != IB_SUCCESS )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get: ERR 3B25: "
- "Unable to acquire MAD (%s).\n",
- ib_get_err_str( status ) );
-
- p_mad = NULL;
- goto Exit;
- }
-
- CL_ASSERT( p_vw->p_elem );
- p_mad = ib_get_mad_buf( p_vw->p_elem );
-
- if( osm_log_get_level( p_vend->p_log ) >= OSM_LOG_DEBUG )
- {
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_get: "
- "Acquired MAD %p, size = %u.\n", p_mad, mad_size );
- }
-
- Exit:
- OSM_LOG_EXIT( p_vend->p_log );
- return( p_mad );
+ ib_mad_t *p_mad;
+ osm_al_bind_info_t *p_bind = (osm_al_bind_info_t *) h_bind;
+ osm_vendor_t *p_vend = p_bind->p_vend;
+ ib_api_status_t status;
+
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_get);
+
+ CL_ASSERT(p_vw);
+
+ p_vw->size = mad_size;
+ p_vw->h_bind = h_bind;
+
+ /*
+ Retrieve a MAD element from the pool and give the user direct
+ access to its buffer.
+ */
+ status = ib_get_mad(p_bind->pool_key, mad_size, &p_vw->p_elem);
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get: ERR 3B25: "
+ "Unable to acquire MAD (%s).\n",
+ ib_get_err_str(status));
+
+ p_mad = NULL;
+ goto Exit;
+ }
+
+ CL_ASSERT(p_vw->p_elem);
+ p_mad = ib_get_mad_buf(p_vw->p_elem);
+
+ if (osm_log_get_level(p_vend->p_log) >= OSM_LOG_DEBUG) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_get: "
+ "Acquired MAD %p, size = %u.\n", p_mad, mad_size);
+ }
+
+ Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (p_mad);
}
/**********************************************************************
**********************************************************************/
void
-osm_vendor_put(
- IN osm_bind_handle_t h_bind,
- IN osm_vend_wrap_t* const p_vw )
+osm_vendor_put(IN osm_bind_handle_t h_bind, IN osm_vend_wrap_t * const p_vw)
{
- osm_al_bind_info_t *p_bind = (osm_al_bind_info_t *)h_bind;
- osm_vendor_t *p_vend = p_bind->p_vend;
- ib_api_status_t status;
-
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_put );
-
- CL_ASSERT( p_vw );
- CL_ASSERT( p_vw->p_elem );
- CL_ASSERT( p_vw->h_bind == h_bind );
-
- if( osm_log_get_level( p_vend->p_log ) >= OSM_LOG_DEBUG )
- {
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_put: "
- "Retiring MAD %p.\n", ib_get_mad_buf( p_vw->p_elem ) );
- }
-
- status = ib_put_mad( p_vw->p_elem );
- if( status != IB_SUCCESS )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_put: ERR 3B26: "
- "Unable to retire MAD (%s).\n",
- ib_get_err_str( status ) );
- }
-
- OSM_LOG_EXIT( p_vend->p_log );
+ osm_al_bind_info_t *p_bind = (osm_al_bind_info_t *) h_bind;
+ osm_vendor_t *p_vend = p_bind->p_vend;
+ ib_api_status_t status;
+
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_put);
+
+ CL_ASSERT(p_vw);
+ CL_ASSERT(p_vw->p_elem);
+ CL_ASSERT(p_vw->h_bind == h_bind);
+
+ if (osm_log_get_level(p_vend->p_log) >= OSM_LOG_DEBUG) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_put: "
+ "Retiring MAD %p.\n", ib_get_mad_buf(p_vw->p_elem));
+ }
+
+ status = ib_put_mad(p_vw->p_elem);
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_put: ERR 3B26: "
+ "Unable to retire MAD (%s).\n", ib_get_err_str(status));
+ }
+
+ OSM_LOG_EXIT(p_vend->p_log);
}
/**********************************************************************
**********************************************************************/
ib_api_status_t
-osm_vendor_send(
- IN osm_bind_handle_t h_bind,
- IN osm_madw_t* const p_madw,
- IN boolean_t const resp_expected )
+osm_vendor_send(IN osm_bind_handle_t h_bind,
+ IN osm_madw_t * const p_madw, IN boolean_t const resp_expected)
{
- osm_al_bind_info_t* const p_bind = h_bind;
- osm_vendor_t* const p_vend = p_bind->p_vend;
- osm_vend_wrap_t* const p_vw = osm_madw_get_vend_ptr( p_madw );
- osm_mad_addr_t* const p_mad_addr = osm_madw_get_mad_addr_ptr( p_madw );
- ib_mad_t* const p_mad = osm_madw_get_mad_ptr( p_madw );
- ib_api_status_t status;
- ib_mad_element_t *p_elem;
- ib_av_attr_t av;
-
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_send );
-
- CL_ASSERT( p_vw->h_bind == h_bind );
- CL_ASSERT( p_vw->p_elem );
-
- p_elem = p_vw->p_elem;
-
- /*
- If a response is expected to this MAD, then preallocate
- a mad wrapper to contain the wire MAD received in the
- response. Allocating a wrapper here allows for easier
- failure paths than after we already received the wire mad.
- */
- if( resp_expected )
- {
- p_vw->p_resp_madw = osm_mad_pool_get_wrapper_raw(
- p_bind->p_osm_pool );
- if( p_vw->p_resp_madw == NULL )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_send: ERR 3B27: "
- "Unable to allocate MAD wrapper.\n" );
- status = IB_INSUFFICIENT_RESOURCES;
- goto Exit;
- }
- }
- else
- p_vw->p_resp_madw = NULL;
-
- /*
- For all sends other than directed route SM MADs,
- acquire an address vector for the destination.
- */
- if( p_mad->mgmt_class != IB_MCLASS_SUBN_DIR )
- {
- memset( &av, 0, sizeof(av) );
- av.port_num = p_bind->port_num;
- av.dlid = p_mad_addr->dest_lid;
- av.static_rate = p_mad_addr->static_rate;
- av.path_bits = p_mad_addr->path_bits;
-
- if( (p_mad->mgmt_class != IB_MCLASS_SUBN_LID) &&
- (p_mad->mgmt_class != IB_MCLASS_SUBN_DIR) ){
- av.sl = p_mad_addr->addr_type.gsi.service_level;
-
-
- if(p_mad_addr->addr_type.gsi.global_route)
- {
- av.grh_valid = TRUE;
- /* ANIL */
- /* av.grh = p_mad_addr->addr_type.gsi.grh_info; */
- }
- }
-
- if( osm_log_is_active( p_vend->p_log, OSM_LOG_DEBUG ) )
- {
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_send: "
- "av.port_num 0x%X, "
- "av.dlid 0x%X, "
- "av.static_rate %d, "
- "av.path_bits %d.\n",
- av.port_num, cl_ntoh16(av.dlid),
- av.static_rate, av.path_bits);
- }
-
- status = ib_create_av( p_vend->h_pd, &av, &p_vw->h_av );
- if( status != IB_SUCCESS )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_send: ERR 3B28: "
- "Unable to create address vector (%s).\n",
- ib_get_err_str( status ) );
-
- if( p_vw->p_resp_madw )
- osm_mad_pool_put( p_bind->p_osm_pool, p_vw->p_resp_madw );
- goto Exit;
- }
-
- if( osm_log_is_active( p_vend->p_log, OSM_LOG_DEBUG ) )
- {
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_send: "
- "Allocating av handle %p.\n", p_vw->h_av );
- }
- }
- else
- {
- p_vw->h_av = p_bind->h_dr_av;
- }
-
- p_elem->h_av = p_vw->h_av;
-
- p_elem->context1 = p_madw;
- p_elem->context2 = NULL;
-
- p_elem->immediate_data = 0;
- p_elem->p_grh = NULL;
- p_elem->resp_expected = resp_expected;
- p_elem->retry_cnt = OSM_DEFAULT_RETRY_COUNT;
-
- p_elem->send_opt = IB_SEND_OPT_SIGNALED;
- p_elem->timeout_ms = p_vend->timeout;
-
- /* Completion information. */
- p_elem->status = 0; /* Not trusting AL */
-
-
- if( (p_mad->mgmt_class == IB_MCLASS_SUBN_LID) ||
- (p_mad->mgmt_class == IB_MCLASS_SUBN_DIR) )
- {
- p_elem->remote_qp = 0;
- p_elem->remote_qkey = 0;
- }
- else
- {
- p_elem->remote_qp = p_mad_addr->addr_type.gsi.remote_qp;
- p_elem->remote_qkey = p_mad_addr->addr_type.gsi.remote_qkey;
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_send: "
- "remote qp = 0x%X, remote qkey = 0x%X.\n",
- cl_ntoh32(p_elem->remote_qp),
- cl_ntoh32(p_elem->remote_qkey) );
- }
-
- status = ib_send_mad( p_bind->h_svc, p_elem, NULL );
- if( status != IB_SUCCESS )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_send: ERR 3B29: "
- "Send failed (%s).\n",
- ib_get_err_str( status ) );
- if( p_vw->p_resp_madw )
- osm_mad_pool_put( p_bind->p_osm_pool, p_vw->p_resp_madw );
- goto Exit;
- }
-
- Exit:
- OSM_LOG_EXIT( p_vend->p_log );
- return( status );
+ osm_al_bind_info_t *const p_bind = h_bind;
+ osm_vendor_t *const p_vend = p_bind->p_vend;
+ osm_vend_wrap_t *const p_vw = osm_madw_get_vend_ptr(p_madw);
+ osm_mad_addr_t *const p_mad_addr = osm_madw_get_mad_addr_ptr(p_madw);
+ ib_mad_t *const p_mad = osm_madw_get_mad_ptr(p_madw);
+ ib_api_status_t status;
+ ib_mad_element_t *p_elem;
+ ib_av_attr_t av;
+
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_send);
+
+ CL_ASSERT(p_vw->h_bind == h_bind);
+ CL_ASSERT(p_vw->p_elem);
+
+ p_elem = p_vw->p_elem;
+
+ /*
+ If a response is expected to this MAD, then preallocate
+ a mad wrapper to contain the wire MAD received in the
+ response. Allocating a wrapper here allows for easier
+ failure paths than after we already received the wire mad.
+ */
+ if (resp_expected) {
+ p_vw->p_resp_madw =
+ osm_mad_pool_get_wrapper_raw(p_bind->p_osm_pool);
+ if (p_vw->p_resp_madw == NULL) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_send: ERR 3B27: "
+ "Unable to allocate MAD wrapper.\n");
+ status = IB_INSUFFICIENT_RESOURCES;
+ goto Exit;
+ }
+ } else
+ p_vw->p_resp_madw = NULL;
+
+ /*
+ For all sends other than directed route SM MADs,
+ acquire an address vector for the destination.
+ */
+ if (p_mad->mgmt_class != IB_MCLASS_SUBN_DIR) {
+ memset(&av, 0, sizeof(av));
+ av.port_num = p_bind->port_num;
+ av.dlid = p_mad_addr->dest_lid;
+ av.static_rate = p_mad_addr->static_rate;
+ av.path_bits = p_mad_addr->path_bits;
+
+ if ((p_mad->mgmt_class != IB_MCLASS_SUBN_LID) &&
+ (p_mad->mgmt_class != IB_MCLASS_SUBN_DIR)) {
+ av.sl = p_mad_addr->addr_type.gsi.service_level;
+
+ if (p_mad_addr->addr_type.gsi.global_route) {
+ av.grh_valid = TRUE;
+ /* ANIL */
+ /* av.grh = p_mad_addr->addr_type.gsi.grh_info; */
+ }
+ }
+
+ if (osm_log_is_active(p_vend->p_log, OSM_LOG_DEBUG)) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_send: "
+ "av.port_num 0x%X, "
+ "av.dlid 0x%X, "
+ "av.static_rate %d, "
+ "av.path_bits %d.\n",
+ av.port_num, cl_ntoh16(av.dlid),
+ av.static_rate, av.path_bits);
+ }
+
+ status = ib_create_av(p_vend->h_pd, &av, &p_vw->h_av);
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_send: ERR 3B28: "
+ "Unable to create address vector (%s).\n",
+ ib_get_err_str(status));
+
+ if (p_vw->p_resp_madw)
+ osm_mad_pool_put(p_bind->p_osm_pool,
+ p_vw->p_resp_madw);
+ goto Exit;
+ }
+
+ if (osm_log_is_active(p_vend->p_log, OSM_LOG_DEBUG)) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_send: "
+ "Allocating av handle %p.\n", p_vw->h_av);
+ }
+ } else {
+ p_vw->h_av = p_bind->h_dr_av;
+ }
+
+ p_elem->h_av = p_vw->h_av;
+
+ p_elem->context1 = p_madw;
+ p_elem->context2 = NULL;
+
+ p_elem->immediate_data = 0;
+ p_elem->p_grh = NULL;
+ p_elem->resp_expected = resp_expected;
+ p_elem->retry_cnt = OSM_DEFAULT_RETRY_COUNT;
+
+ p_elem->send_opt = IB_SEND_OPT_SIGNALED;
+ p_elem->timeout_ms = p_vend->timeout;
+
+ /* Completion information. */
+ p_elem->status = 0; /* Not trusting AL */
+
+ if ((p_mad->mgmt_class == IB_MCLASS_SUBN_LID) ||
+ (p_mad->mgmt_class == IB_MCLASS_SUBN_DIR)) {
+ p_elem->remote_qp = 0;
+ p_elem->remote_qkey = 0;
+ } else {
+ p_elem->remote_qp = p_mad_addr->addr_type.gsi.remote_qp;
+ p_elem->remote_qkey = p_mad_addr->addr_type.gsi.remote_qkey;
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_send: "
+ "remote qp = 0x%X, remote qkey = 0x%X.\n",
+ cl_ntoh32(p_elem->remote_qp),
+ cl_ntoh32(p_elem->remote_qkey));
+ }
+
+ status = ib_send_mad(p_bind->h_svc, p_elem, NULL);
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_send: ERR 3B29: "
+ "Send failed (%s).\n", ib_get_err_str(status));
+ if (p_vw->p_resp_madw)
+ osm_mad_pool_put(p_bind->p_osm_pool, p_vw->p_resp_madw);
+ goto Exit;
+ }
+
+ Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
}
/**********************************************************************
**********************************************************************/
-ib_api_status_t
-osm_vendor_local_lid_change(
- IN osm_bind_handle_t h_bind )
+ib_api_status_t osm_vendor_local_lid_change(IN osm_bind_handle_t h_bind)
{
- osm_al_bind_info_t *p_bind = (osm_al_bind_info_t *)h_bind;
- osm_vendor_t *p_vend = p_bind->p_vend;
- ib_av_attr_t av;
- ib_api_status_t status;
-
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_local_lid_change );
-
- /*
- The only thing we need to do is refresh the directed
- route address vector.
- */
- __osm_vendor_init_av( p_bind, &av );
-
- status = ib_destroy_av( p_bind->h_dr_av );
- if( status != IB_SUCCESS )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_local_lid_change: ERR 3B32: "
- "Unable to destroy address vector (%s).\n",
- ib_get_err_str( status ) );
-
- goto Exit;
- }
-
- status = ib_create_av( p_vend->h_pd, &av, &p_bind->h_dr_av );
- if( status != IB_SUCCESS )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_local_lid_change: ERR 3B33: "
- "Unable to create address vector (%s).\n",
- ib_get_err_str( status ) );
-
- goto Exit;
- }
-
- Exit:
- OSM_LOG_EXIT( p_vend->p_log );
- return( status );
+ osm_al_bind_info_t *p_bind = (osm_al_bind_info_t *) h_bind;
+ osm_vendor_t *p_vend = p_bind->p_vend;
+ ib_av_attr_t av;
+ ib_api_status_t status;
+
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_local_lid_change);
+
+ /*
+ The only thing we need to do is refresh the directed
+ route address vector.
+ */
+ __osm_vendor_init_av(p_bind, &av);
+
+ status = ib_destroy_av(p_bind->h_dr_av);
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_local_lid_change: ERR 3B32: "
+ "Unable to destroy address vector (%s).\n",
+ ib_get_err_str(status));
+
+ goto Exit;
+ }
+
+ status = ib_create_av(p_vend->h_pd, &av, &p_bind->h_dr_av);
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_local_lid_change: ERR 3B33: "
+ "Unable to create address vector (%s).\n",
+ ib_get_err_str(status));
+
+ goto Exit;
+ }
+
+ Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
}
/**********************************************************************
**********************************************************************/
-void
-osm_vendor_set_sm(
- IN osm_bind_handle_t h_bind,
- IN boolean_t is_sm_val )
+void osm_vendor_set_sm(IN osm_bind_handle_t h_bind, IN boolean_t is_sm_val)
{
- osm_al_bind_info_t *p_bind = (osm_al_bind_info_t *)h_bind;
- osm_vendor_t *p_vend = p_bind->p_vend;
- ib_api_status_t status;
- ib_port_attr_mod_t attr_mod;
+ osm_al_bind_info_t *p_bind = (osm_al_bind_info_t *) h_bind;
+ osm_vendor_t *p_vend = p_bind->p_vend;
+ ib_api_status_t status;
+ ib_port_attr_mod_t attr_mod;
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_set_sm );
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_set_sm);
- memset( &attr_mod, 0, sizeof(attr_mod) );
+ memset(&attr_mod, 0, sizeof(attr_mod));
- attr_mod.cap.sm = is_sm_val;
+ attr_mod.cap.sm = is_sm_val;
- status = ib_modify_ca( p_vend->h_ca, p_bind->port_num,
- IB_CA_MOD_IS_SM, &attr_mod );
+ status = ib_modify_ca(p_vend->h_ca, p_bind->port_num,
+ IB_CA_MOD_IS_SM, &attr_mod);
- if( status != IB_SUCCESS )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_set_sm: ERR 3B34: "
- "Unable set 'IS_SM' bit to:%u in port attributes (%s).\n",
- is_sm_val, ib_get_err_str( status ) );
- }
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_set_sm: ERR 3B34: "
+ "Unable set 'IS_SM' bit to:%u in port attributes (%s).\n",
+ is_sm_val, ib_get_err_str(status));
+ }
- OSM_LOG_EXIT( p_vend->p_log );
+ OSM_LOG_EXIT(p_vend->p_log);
}
/**********************************************************************
**********************************************************************/
-void
-osm_vendor_set_debug(
- IN osm_vendor_t* const p_vend,
- IN int32_t level )
+void osm_vendor_set_debug(IN osm_vendor_t * const p_vend, IN int32_t level)
{
}
-#endif /* OSM_VENDOR_INTF_AL */
+#endif /* OSM_VENDOR_INTF_AL */
diff --git a/opensm/libvendor/osm_vendor_ibumad.c b/opensm/libvendor/osm_vendor_ibumad.c
index 686da26..a5b2fce 100644
--- a/opensm/libvendor/osm_vendor_ibumad.c
+++ b/opensm/libvendor/osm_vendor_ibumad.c
@@ -46,7 +46,7 @@
#if HAVE_CONFIG_H
# include <config.h>
-#endif /* HAVE_CONFIG_H */
+#endif /* HAVE_CONFIG_H */
#include <vendor/osm_vendor_select.h>
@@ -76,8 +76,7 @@
*
* SYNOPSIS
*/
-typedef struct _osm_umad_bind_info
-{
+typedef struct _osm_umad_bind_info {
osm_vendor_t *p_vend;
void *client_context;
osm_mad_pool_t *p_mad_pool;
@@ -90,47 +89,44 @@ typedef struct _osm_umad_bind_info
int agent_id1; /* SMI requires two agents */
} osm_umad_bind_info_t;
-typedef struct _umad_receiver
-{
+typedef struct _umad_receiver {
pthread_t tid;
- osm_vendor_t *p_vend;
- osm_log_t *p_log;
+ osm_vendor_t *p_vend;
+ osm_log_t *p_log;
} umad_receiver_t;
-static void osm_vendor_close_port(osm_vendor_t* const p_vend);
+static void osm_vendor_close_port(osm_vendor_t * const p_vend);
-static void
-clear_madw(osm_vendor_t *p_vend)
+static void clear_madw(osm_vendor_t * p_vend)
{
umad_match_t *m, *e, *old_m;
ib_net64_t old_tid;
- OSM_LOG_ENTER( p_vend->p_log, clear_madw );
+ OSM_LOG_ENTER(p_vend->p_log, clear_madw);
pthread_mutex_lock(&p_vend->match_tbl_mutex);
for (m = p_vend->mtbl.tbl, e = m + p_vend->mtbl.max; m < e; m++) {
if (m->tid) {
old_m = m;
old_tid = m->tid;
m->tid = 0;
- osm_mad_pool_put(
- ((osm_umad_bind_info_t *)((osm_madw_t *)m->v)->h_bind)->p_mad_pool,
- m->v);
+ osm_mad_pool_put(((osm_umad_bind_info_t
+ *) ((osm_madw_t *) m->v)->h_bind)->
+ p_mad_pool, m->v);
pthread_mutex_unlock(&p_vend->match_tbl_mutex);
osm_log(p_vend->p_log, OSM_LOG_ERROR,
"clear_madw: ERR 5401: "
- "evicting entry %p (tid was 0x%"PRIx64")\n",
+ "evicting entry %p (tid was 0x%" PRIx64 ")\n",
old_m, old_tid);
goto Exit;
}
}
pthread_mutex_unlock(&p_vend->match_tbl_mutex);
-Exit:
- OSM_LOG_EXIT( p_vend->p_log );
+ Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
}
-static osm_madw_t *
-get_madw(osm_vendor_t *p_vend, ib_net64_t *tid)
+static osm_madw_t *get_madw(osm_vendor_t * p_vend, ib_net64_t * tid)
{
umad_match_t *m, *e;
ib_net64_t mtid = (*tid & cl_ntoh64(0x00000000ffffffffllu));
@@ -159,7 +155,7 @@ get_madw(osm_vendor_t *p_vend, ib_net64_t *tid)
}
static void
-put_madw(osm_vendor_t *p_vend, osm_madw_t *p_madw, ib_net64_t *tid)
+put_madw(osm_vendor_t * p_vend, osm_madw_t * p_madw, ib_net64_t * tid)
{
umad_match_t *m, *e, *old_lru, *lru = 0;
osm_madw_t *p_req_madw;
@@ -172,7 +168,9 @@ put_madw(osm_vendor_t *p_vend, osm_madw_t *p_madw, ib_net64_t *tid)
if (m->tid == 0) {
m->tid = *tid;
m->v = p_madw;
- m->version = cl_atomic_inc((atomic32_t *)&p_vend->mtbl.last_version);
+ m->version =
+ cl_atomic_inc((atomic32_t *) & p_vend->mtbl.
+ last_version);
pthread_mutex_unlock(&p_vend->match_tbl_mutex);
return;
}
@@ -188,19 +186,22 @@ put_madw(osm_vendor_t *p_vend, osm_madw_t *p_madw, ib_net64_t *tid)
p_bind = p_req_madw->h_bind;
p_req_madw->status = IB_CANCELED;
pthread_mutex_lock(&p_vend->cb_mutex);
- (*p_bind->send_err_callback)(p_bind->client_context, old_lru->v);
+ (*p_bind->send_err_callback) (p_bind->client_context, old_lru->v);
pthread_mutex_unlock(&p_vend->cb_mutex);
lru->tid = *tid;
lru->v = p_madw;
- lru->version = cl_atomic_inc((atomic32_t *)&p_vend->mtbl.last_version);
+ lru->version =
+ cl_atomic_inc((atomic32_t *) & p_vend->mtbl.last_version);
pthread_mutex_unlock(&p_vend->match_tbl_mutex);
osm_log(p_vend->p_log, OSM_LOG_ERROR,
"put_madw: ERR 5402: "
- "evicting entry %p (tid was 0x%"PRIx64")\n", old_lru, old_tid);
+ "evicting entry %p (tid was 0x%" PRIx64 ")\n", old_lru,
+ old_tid);
}
static void
-ib_mad_addr_conv(ib_mad_addr_t *ib_mad_addr, osm_mad_addr_t *osm_mad_addr, int is_smi)
+ib_mad_addr_conv(ib_mad_addr_t * ib_mad_addr, osm_mad_addr_t * osm_mad_addr,
+ int is_smi)
{
osm_mad_addr->dest_lid = ib_mad_addr->lid;
osm_mad_addr->path_bits = ib_mad_addr->path_bits;
@@ -216,13 +217,12 @@ ib_mad_addr_conv(ib_mad_addr_t *ib_mad_addr, osm_mad_addr_t *osm_mad_addr, int i
osm_mad_addr->addr_type.gsi.remote_qkey = ib_mad_addr->qkey;
osm_mad_addr->addr_type.gsi.pkey = IB_DEFAULT_PKEY; /* FIXME: support real pkey */
osm_mad_addr->addr_type.gsi.service_level = ib_mad_addr->sl;
- osm_mad_addr->addr_type.gsi.global_route = 0; /* FIXME: handle GRH */
+ osm_mad_addr->addr_type.gsi.global_route = 0; /* FIXME: handle GRH */
memset(&osm_mad_addr->addr_type.gsi.grh_info, 0,
- sizeof osm_mad_addr->addr_type.gsi.grh_info);
+ sizeof osm_mad_addr->addr_type.gsi.grh_info);
}
-static void *
-swap_mad_bufs(osm_madw_t *p_madw, void *umad)
+static void *swap_mad_bufs(osm_madw_t * p_madw, void *umad)
{
void *old;
@@ -238,10 +238,9 @@ static void unlock_mutex(void *arg)
pthread_mutex_unlock(arg);
}
-void *
-umad_receiver(void *p_ptr)
+void *umad_receiver(void *p_ptr)
{
- umad_receiver_t* const p_ur = (umad_receiver_t *)p_ptr;
+ umad_receiver_t *const p_ur = (umad_receiver_t *) p_ptr;
osm_vendor_t *p_vend = p_ur->p_vend;
osm_umad_bind_info_t *p_bind;
ib_mad_addr_t *ib_mad_addr;
@@ -251,12 +250,12 @@ umad_receiver(void *p_ptr)
void *umad = 0;
int mad_agent, length;
- OSM_LOG_ENTER( p_ur->p_log, umad_receiver );
+ OSM_LOG_ENTER(p_ur->p_log, umad_receiver);
for (;;) {
if (!umad &&
!(umad = umad_alloc(1, umad_size() + MAD_BLOCK_SIZE))) {
- osm_log(p_ur->p_log, OSM_LOG_ERROR,
+ osm_log(p_ur->p_log, OSM_LOG_ERROR,
"umad_receiver: ERR 5403: "
"can't alloc MAD sized umad\n");
break;
@@ -277,15 +276,18 @@ umad_receiver(void *p_ptr)
if (!umad) {
osm_log(p_ur->p_log, OSM_LOG_ERROR,
"umad_receiver: ERR 5405: "
- "can't alloc umad length %d\n", length);
+ "can't alloc umad length %d\n",
+ length);
continue;
}
if ((mad_agent = umad_recv(p_vend->umad_port_id,
- umad, &length, -1)) < 0) {
+ umad, &length,
+ -1)) < 0) {
osm_log(p_ur->p_log, OSM_LOG_ERROR,
"umad_receiver: ERR 5406: "
- "recv error on umad length %d (%m)\n", length);
+ "recv error on umad length %d (%m)\n",
+ length);
continue;
}
}
@@ -299,20 +301,20 @@ umad_receiver(void *p_ptr)
continue;
}
- mad = (ib_mad_t*)umad_get_mad(umad);
+ mad = (ib_mad_t *) umad_get_mad(umad);
ib_mad_addr = umad_get_mad_addr(umad);
ib_mad_addr_conv(ib_mad_addr, &osm_addr,
mad->mgmt_class == IB_MCLASS_SUBN_LID ||
mad->mgmt_class == IB_MCLASS_SUBN_DIR);
- if (!(p_madw = osm_mad_pool_get(p_bind->p_mad_pool,
- (osm_bind_handle_t)p_bind,
+ if (!(p_madw = osm_mad_pool_get(p_bind->p_mad_pool,
+ (osm_bind_handle_t) p_bind,
MAX(length, MAD_BLOCK_SIZE),
&osm_addr))) {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
"umad_receiver: ERR 5408: "
- "request for a new madw failed -- dropping packet\n" );
+ "request for a new madw failed -- dropping packet\n");
continue;
}
@@ -328,7 +330,7 @@ umad_receiver(void *p_ptr)
/* if status != 0 then we are handling recv timeout on send */
if (umad_status(p_madw->vend_wrap.umad)) {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
"umad_receiver: ERR 5409: "
"send completed with error"
" (method=0x%X attr=0x%X trans_id=0x%" PRIx64
@@ -337,7 +339,7 @@ umad_receiver(void *p_ptr)
cl_ntoh64(mad->trans_id));
if (mad->mgmt_class != IB_MCLASS_SUBN_DIR) {
/* LID routed */
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
"umad_receiver: ERR 5410: "
"class 0x%x LID 0x%x\n",
mad->mgmt_class,
@@ -346,14 +348,16 @@ umad_receiver(void *p_ptr)
ib_smp_t *smp;
/* Direct routed SMP */
- smp = (ib_smp_t *)mad;
+ smp = (ib_smp_t *) mad;
osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "umad_receiver: ERR 5411: DR SMP Hop Ptr: 0x%X\n", smp->hop_ptr);
- osm_dump_smp_dr_path(p_vend->p_log, smp, OSM_LOG_ERROR);
+ "umad_receiver: ERR 5411: DR SMP Hop Ptr: 0x%X\n",
+ smp->hop_ptr);
+ osm_dump_smp_dr_path(p_vend->p_log, smp,
+ OSM_LOG_ERROR);
}
if (!(p_req_madw = get_madw(p_vend, &mad->trans_id))) {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
"umad_receiver: ERR 5412: "
"Failed to obtain request madw for timed out MAD"
"(method=0x%X attr=0x%X) -- dropping\n",
@@ -362,8 +366,11 @@ umad_receiver(void *p_ptr)
p_req_madw->status = IB_TIMEOUT;
/* cb frees req_madw */
pthread_mutex_lock(&p_vend->cb_mutex);
- pthread_cleanup_push(unlock_mutex, &p_vend->cb_mutex);
- (*p_bind->send_err_callback)(p_bind->client_context, p_req_madw);
+ pthread_cleanup_push(unlock_mutex,
+ &p_vend->cb_mutex);
+ (*p_bind->send_err_callback) (p_bind->
+ client_context,
+ p_req_madw);
pthread_cleanup_pop(1);
}
@@ -374,7 +381,7 @@ umad_receiver(void *p_ptr)
p_req_madw = 0;
if (ib_mad_is_response(mad) &&
!(p_req_madw = get_madw(p_vend, &mad->trans_id))) {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
"umad_receiver: ERR 5413: "
"Failed to obtain request madw for received MAD"
"(method=0x%X attr=0x%X) -- dropping\n",
@@ -382,22 +389,21 @@ umad_receiver(void *p_ptr)
osm_mad_pool_put(p_bind->p_mad_pool, p_madw);
continue;
}
-
#ifndef VENDOR_RMPP_SUPPORT
if ((mad->mgmt_class != IB_MCLASS_SUBN_DIR) &&
(mad->mgmt_class != IB_MCLASS_SUBN_LID) &&
- (ib_rmpp_is_flag_set((ib_rmpp_mad_t *)mad,
- IB_RMPP_FLAG_ACTIVE))) {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
+ (ib_rmpp_is_flag_set((ib_rmpp_mad_t *) mad,
+ IB_RMPP_FLAG_ACTIVE))) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
"umad_receiver: ERR 5414: "
"class 0x%x method 0x%x"
" RMPP version %d type %d flags 0x%x"
" received -- dropping\n",
mad->mgmt_class,
mad->method,
- ((ib_rmpp_mad_t *)mad)->rmpp_version,
- ((ib_rmpp_mad_t *)mad)->rmpp_type,
- ((ib_rmpp_mad_t *)mad)->rmpp_flags);
+ ((ib_rmpp_mad_t *) mad)->rmpp_version,
+ ((ib_rmpp_mad_t *) mad)->rmpp_type,
+ ((ib_rmpp_mad_t *) mad)->rmpp_flags);
osm_mad_pool_put(p_bind->p_mad_pool, p_madw);
continue;
}
@@ -406,15 +412,16 @@ umad_receiver(void *p_ptr)
/* call the CB */
pthread_mutex_lock(&p_vend->cb_mutex);
pthread_cleanup_push(unlock_mutex, &p_vend->cb_mutex);
- (*p_bind->mad_recv_callback)(p_madw, p_bind->client_context, p_req_madw);
+ (*p_bind->mad_recv_callback) (p_madw, p_bind->client_context,
+ p_req_madw);
pthread_cleanup_pop(1);
}
- OSM_LOG_EXIT( p_vend->p_log );
+ OSM_LOG_EXIT(p_vend->p_log);
return NULL;
}
-static int umad_receiver_start(osm_vendor_t *p_vend)
+static int umad_receiver_start(osm_vendor_t * p_vend)
{
umad_receiver_t *p_ur = p_vend->receiver;
@@ -427,7 +434,7 @@ static int umad_receiver_start(osm_vendor_t *p_vend)
return 0;
}
-static void umad_receiver_stop(umad_receiver_t *p_ur)
+static void umad_receiver_stop(umad_receiver_t * p_ur)
{
pthread_cancel(p_ur->tid);
pthread_join(p_ur->tid, NULL);
@@ -435,17 +442,16 @@ static void umad_receiver_stop(umad_receiver_t *p_ur)
p_ur->p_vend = NULL;
p_ur->p_log = NULL;
}
+
/**********************************************************************
**********************************************************************/
ib_api_status_t
-osm_vendor_init(
- IN osm_vendor_t* const p_vend,
- IN osm_log_t* const p_log,
- IN const uint32_t timeout )
+osm_vendor_init(IN osm_vendor_t * const p_vend,
+ IN osm_log_t * const p_log, IN const uint32_t timeout)
{
int r, n_cas;
- OSM_LOG_ENTER( p_log, osm_vendor_init );
+ OSM_LOG_ENTER(p_log, osm_vendor_init);
p_vend->p_log = p_log;
p_vend->timeout = timeout;
@@ -459,13 +465,13 @@ osm_vendor_init(
* Open our instance of UMAD.
*/
if ((r = umad_init()) < 0) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_init: ERR 5415: Error opening UMAD\n");
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_init: ERR 5415: Error opening UMAD\n");
}
if ((n_cas = umad_get_cas_names(p_vend->ca_names,
OSM_UMAD_MAX_CAS)) < 0) {
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
"osm_vendor_init: ERR 5416: umad_get_cas_names failed\n");
r = n_cas;
goto Exit;
@@ -474,78 +480,71 @@ osm_vendor_init(
p_vend->ca_count = n_cas;
p_vend->mtbl.max = OSM_UMAD_MAX_PENDING;
-Exit:
- OSM_LOG_EXIT( p_log );
- return( r );
+ Exit:
+ OSM_LOG_EXIT(p_log);
+ return (r);
}
/**********************************************************************
**********************************************************************/
-osm_vendor_t*
-osm_vendor_new(
- IN osm_log_t* const p_log,
- IN const uint32_t timeout )
+osm_vendor_t *osm_vendor_new(IN osm_log_t * const p_log,
+ IN const uint32_t timeout)
{
- osm_vendor_t *p_vend = NULL;
+ osm_vendor_t *p_vend = NULL;
- OSM_LOG_ENTER( p_log, osm_vendor_new );
+ OSM_LOG_ENTER(p_log, osm_vendor_new);
- if ( !timeout )
- {
- osm_log( p_log, OSM_LOG_ERROR,
- "osm_vendor_new: ERR 5433: "
- "transaction timeout cannot be 0\n");
+ if (!timeout) {
+ osm_log(p_log, OSM_LOG_ERROR,
+ "osm_vendor_new: ERR 5433: "
+ "transaction timeout cannot be 0\n");
goto Exit;
}
- p_vend = malloc( sizeof(*p_vend) );
- if( p_vend == NULL )
- {
- osm_log( p_log, OSM_LOG_ERROR,
+ p_vend = malloc(sizeof(*p_vend));
+ if (p_vend == NULL) {
+ osm_log(p_log, OSM_LOG_ERROR,
"osm_vendor_new: ERR 5417: "
- "Unable to allocate vendor object\n" );
+ "Unable to allocate vendor object\n");
goto Exit;
}
- memset( p_vend, 0, sizeof(*p_vend) );
+ memset(p_vend, 0, sizeof(*p_vend));
- if (osm_vendor_init( p_vend, p_log, timeout ) < 0) {
- free( p_vend );
+ if (osm_vendor_init(p_vend, p_log, timeout) < 0) {
+ free(p_vend);
p_vend = NULL;
}
-Exit:
- OSM_LOG_EXIT( p_log );
- return( p_vend );
+ Exit:
+ OSM_LOG_EXIT(p_log);
+ return (p_vend);
}
/**********************************************************************
**********************************************************************/
-void
-osm_vendor_delete(
- IN osm_vendor_t** const pp_vend )
+void osm_vendor_delete(IN osm_vendor_t ** const pp_vend)
{
osm_vendor_close_port(*pp_vend);
- clear_madw( *pp_vend );
+ clear_madw(*pp_vend);
/* make sure all ports are closed */
umad_done();
pthread_mutex_destroy(&(*pp_vend)->cb_mutex);
pthread_mutex_destroy(&(*pp_vend)->match_tbl_mutex);
- free( *pp_vend );
+ free(*pp_vend);
*pp_vend = NULL;
}
/**********************************************************************
**********************************************************************/
ib_api_status_t
-osm_vendor_get_all_port_attr(
- IN osm_vendor_t* const p_vend,
- IN ib_port_attr_t* const p_attr_array,
- IN uint32_t* const p_num_ports )
+osm_vendor_get_all_port_attr(IN osm_vendor_t * const p_vend,
+ IN ib_port_attr_t * const p_attr_array,
+ IN uint32_t * const p_num_ports)
{
- ib_net64_t portguids[*p_num_ports];
+ ib_net64_t portguids[*p_num_ports];
ib_net64_t *p_guid = portguids, *e = portguids + *p_num_ports;
umad_ca_t ca;
int lids[*p_num_ports];
@@ -554,17 +553,17 @@ osm_vendor_get_all_port_attr(
int *p_lid = lids;
int *p_linkstates = linkstates;
int *p_portnum = portnums;
- umad_port_t def_port = {""};
+ umad_port_t def_port = { "" };
int r, i, j;
int sm_lid = 0;
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_get_all_port_attr );
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_get_all_port_attr);
- CL_ASSERT( p_vend && p_num_ports );
+ CL_ASSERT(p_vend && p_num_ports);
if (!*p_num_ports) {
r = IB_INVALID_PARAMETER;
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
"osm_vendor_get_all_port_attr: ERR 5418: "
"Ports in should be > 0\n");
goto Exit;
@@ -576,9 +575,9 @@ osm_vendor_get_all_port_attr(
*/
if ((r = umad_get_ca_portguids(p_vend->ca_names[i],
p_guid, e - p_guid)) < 0) {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_all_port_attr: ERR 5419: "
- "Unable to get CA %s port guids (%s)\n",
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_all_port_attr: ERR 5419: "
+ "Unable to get CA %s port guids (%s)\n",
p_vend->ca_names[i], strerror(r));
goto Exit;
}
@@ -615,11 +614,11 @@ osm_vendor_get_all_port_attr(
portnums[0] = def_port.portnum;
sm_lid = def_port.sm_lid;
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_get_all_port_attr: "
- "assign CA %s port %d guid (0x%"PRIx64") as the default port\n",
- def_port.ca_name, def_port.portnum,
- cl_hton64(def_port.port_guid));
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_get_all_port_attr: "
+ "assign CA %s port %d guid (0x%" PRIx64
+ ") as the default port\n", def_port.ca_name,
+ def_port.portnum, cl_hton64(def_port.port_guid));
umad_release_port(&def_port);
}
@@ -636,7 +635,8 @@ osm_vendor_get_all_port_attr(
if (j == 0)
p_attr_array[j].sm_lid = sm_lid;
else
- p_attr_array[j].sm_lid = p_vend->umad_port.sm_lid;
+ p_attr_array[j].sm_lid =
+ p_vend->umad_port.sm_lid;
p_attr_array[j].link_state = linkstates[i];
j++;
}
@@ -645,27 +645,26 @@ osm_vendor_get_all_port_attr(
} else
r = IB_INSUFFICIENT_MEMORY;
-Exit:
- OSM_LOG_EXIT( p_vend->p_log );
+ Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
return r;
}
/**********************************************************************
**********************************************************************/
static int
-osm_vendor_open_port(
- IN osm_vendor_t* const p_vend,
- IN const ib_net64_t port_guid )
+osm_vendor_open_port(IN osm_vendor_t * const p_vend,
+ IN const ib_net64_t port_guid)
{
- ib_net64_t portguids[OSM_UMAD_MAX_PORTS_PER_CA + 1];
+ ib_net64_t portguids[OSM_UMAD_MAX_PORTS_PER_CA + 1];
int i = 0, umad_port_id = -1, found = 0;
int ca, r;
- CL_ASSERT( p_vend );
+ CL_ASSERT(p_vend);
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_open_port );
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_open_port);
- CL_ASSERT( port_guid );
+ CL_ASSERT(port_guid);
if (p_vend->umad_port_id >= 0) {
umad_port_id = p_vend->umad_port_id;
@@ -676,9 +675,9 @@ osm_vendor_open_port(
if ((r = umad_get_ca_portguids(p_vend->ca_names[ca],
portguids,
OSM_UMAD_MAX_CAS)) < 0) {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_open_port: ERR 5421: "
- "Unable to get CA %s port guids (%s)\n",
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_open_port: ERR 5421: "
+ "Unable to get CA %s port guids (%s)\n",
p_vend->ca_names[ca], strerror(r));
goto Exit;
}
@@ -697,72 +696,71 @@ osm_vendor_open_port(
/*
* No local CA owns this guid!
*/
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
"osm_vendor_open_port: ERR 5422: "
- "Unable to find requested CA guid 0x%"PRIx64"\n",
- cl_ntoh64(port_guid) );
+ "Unable to find requested CA guid 0x%" PRIx64 "\n",
+ cl_ntoh64(port_guid));
goto Exit;
}
/* Port found, try to open it */
if (umad_get_ca(p_vend->ca_names[ca], &p_vend->umad_ca) < 0) {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_open_port: ERR 542A: "
- "umad_get_ca() failed\n" );
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_open_port: ERR 542A: "
+ "umad_get_ca() failed\n");
goto Exit;
}
/* Validate that node is an IB node type */
- if (p_vend->umad_ca.node_type < 1 ||
- p_vend->umad_ca.node_type > 3) {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_open_port: ERR 542D: "
- "Node type %d is not an IB node type\n",
- p_vend->umad_ca.node_type );
- fprintf( stderr, "Node type %d is not an IB node type\n",
- p_vend->umad_ca.node_type );
+ if (p_vend->umad_ca.node_type < 1 || p_vend->umad_ca.node_type > 3) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_open_port: ERR 542D: "
+ "Node type %d is not an IB node type\n",
+ p_vend->umad_ca.node_type);
+ fprintf(stderr, "Node type %d is not an IB node type\n",
+ p_vend->umad_ca.node_type);
goto Exit;
}
if (umad_get_port(p_vend->ca_names[ca], i, &p_vend->umad_port) < 0) {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_open_port: ERR 542B: "
- "umad_get_port() failed\n" );
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_open_port: ERR 542B: "
+ "umad_get_port() failed\n");
goto Exit;
}
if ((umad_port_id = umad_open_port(p_vend->ca_names[ca], i)) < 0) {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_open_port: ERR 542C: "
- "umad_open_port() failed\n" );
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_open_port: ERR 542C: "
+ "umad_open_port() failed\n");
goto Exit;
}
p_vend->umad_port_id = umad_port_id;
/* start receiver thread */
- if (!(p_vend->receiver = calloc(1, sizeof (umad_receiver_t)))) {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
+ if (!(p_vend->receiver = calloc(1, sizeof(umad_receiver_t)))) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
"osm_vendor_open_port: ERR 5423: "
- "Unable to alloc receiver struct\n" );
+ "Unable to alloc receiver struct\n");
umad_close_port(umad_port_id);
p_vend->umad_port_id = umad_port_id = -1;
goto Exit;
}
if (umad_receiver_start(p_vend) != 0) {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_open_port: ERR 5420: "
- "umad_receiver_init failed\n" );
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_open_port: ERR 5420: "
+ "umad_receiver_init failed\n");
umad_close_port(umad_port_id);
p_vend->umad_port_id = umad_port_id = -1;
}
-Exit:
- OSM_LOG_EXIT( p_vend->p_log );
+ Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
return umad_port_id;
}
-static void osm_vendor_close_port(osm_vendor_t* const p_vend)
+static void osm_vendor_close_port(osm_vendor_t * const p_vend)
{
umad_receiver_t *p_ur;
int i;
@@ -798,13 +796,12 @@ static int set_bit(int nr, void *method_mask)
/**********************************************************************
**********************************************************************/
osm_bind_handle_t
-osm_vendor_bind(
- IN osm_vendor_t* const p_vend,
- IN osm_bind_info_t* const p_user_bind,
- IN osm_mad_pool_t* const p_mad_pool,
- IN osm_vend_mad_recv_callback_t mad_recv_callback,
- IN osm_vend_mad_send_err_callback_t send_err_callback,
- IN void* context )
+osm_vendor_bind(IN osm_vendor_t * const p_vend,
+ IN osm_bind_info_t * const p_user_bind,
+ IN osm_mad_pool_t * const p_mad_pool,
+ IN osm_vend_mad_recv_callback_t mad_recv_callback,
+ IN osm_vend_mad_send_err_callback_t send_err_callback,
+ IN void *context)
{
ib_net64_t port_guid;
osm_umad_bind_info_t *p_bind = 0;
@@ -812,33 +809,34 @@ osm_vendor_bind(
int umad_port_id;
uint8_t rmpp_version;
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_bind );
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_bind);
- CL_ASSERT( p_user_bind );
- CL_ASSERT( p_mad_pool );
- CL_ASSERT( mad_recv_callback );
- CL_ASSERT( send_err_callback );
+ CL_ASSERT(p_user_bind);
+ CL_ASSERT(p_mad_pool);
+ CL_ASSERT(mad_recv_callback);
+ CL_ASSERT(send_err_callback);
port_guid = p_user_bind->port_guid;
- osm_log( p_vend->p_log, OSM_LOG_INFO, "osm_vendor_bind: "
- "Binding to port 0x%" PRIx64 "\n", cl_ntoh64( port_guid ) );
+ osm_log(p_vend->p_log, OSM_LOG_INFO, "osm_vendor_bind: "
+ "Binding to port 0x%" PRIx64 "\n", cl_ntoh64(port_guid));
- if ((umad_port_id = osm_vendor_open_port( p_vend, port_guid )) < 0) {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
+ if ((umad_port_id = osm_vendor_open_port(p_vend, port_guid)) < 0) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
"osm_vendor_bind: ERR 5424: "
- "Unable to open port 0x%" PRIx64 "\n", cl_ntoh64( port_guid ));
+ "Unable to open port 0x%" PRIx64 "\n",
+ cl_ntoh64(port_guid));
goto Exit;
}
- if (!(p_bind = malloc( sizeof(*p_bind) ))) {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
+ if (!(p_bind = malloc(sizeof(*p_bind)))) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
"osm_vendor_bind: ERR 5425: "
- "Unable to allocate internal bind object\n" );
+ "Unable to allocate internal bind object\n");
goto Exit;
}
- memset( p_bind, 0, sizeof(*p_bind) );
+ memset(p_bind, 0, sizeof(*p_bind));
p_bind->p_vend = p_vend;
p_bind->port_id = umad_port_id;
p_bind->client_context = context;
@@ -867,7 +865,6 @@ osm_vendor_bind(
set_bit(IB_MAD_METHOD_TRAP, &method_mask);
set_bit(IB_MAD_METHOD_TRAP_REPRESS, &method_mask);
}
-
#ifndef VENDOR_RMPP_SUPPORT
rmpp_version = 0;
#else
@@ -882,7 +879,7 @@ osm_vendor_bind(
p_user_bind->mad_class,
p_user_bind->class_version,
rmpp_version, method_mask)) < 0) {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
"osm_vendor_bind: ERR 5426: "
"Unable to register class %u version %u\n",
p_user_bind->mad_class, p_user_bind->class_version);
@@ -893,7 +890,7 @@ osm_vendor_bind(
if (p_bind->agent_id >= UMAD_CA_MAX_AGENTS ||
p_vend->agents[p_bind->agent_id]) {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
"osm_vendor_bind: ERR 5427: "
"bad agent id %u or duplicate agent for class %u vers %u\n",
p_bind->agent_id, p_user_bind->mad_class,
@@ -909,9 +906,10 @@ osm_vendor_bind(
if (p_user_bind->mad_class == IB_MCLASS_SUBN_DIR) {
if ((p_bind->agent_id1 = umad_register(p_vend->umad_port_id,
IB_MCLASS_SUBN_LID,
- p_user_bind->class_version,
- 0, method_mask)) < 0) {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
+ p_user_bind->
+ class_version, 0,
+ method_mask)) < 0) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
"osm_vendor_bind: ERR 5428: "
"Unable to register class 1 version %u\n",
p_user_bind->class_version);
@@ -922,7 +920,7 @@ osm_vendor_bind(
if (p_bind->agent_id1 >= UMAD_CA_MAX_AGENTS ||
p_vend->agents[p_bind->agent_id1]) {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
"osm_vendor_bind: ERR 5429: "
"bad agent id %u or duplicate agent for class 1 vers %u\n",
p_bind->agent_id1, p_user_bind->class_version);
@@ -934,101 +932,94 @@ osm_vendor_bind(
p_vend->agents[p_bind->agent_id1] = p_bind;
}
-Exit:
- OSM_LOG_EXIT( p_vend->p_log );
- return( (osm_bind_handle_t)p_bind );
+ Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return ((osm_bind_handle_t) p_bind);
}
/**********************************************************************
**********************************************************************/
void
-__osm_vendor_recv_dummy_cb(
- IN osm_madw_t *p_madw,
- IN void *bind_context,
- IN osm_madw_t *p_req_madw )
+__osm_vendor_recv_dummy_cb(IN osm_madw_t * p_madw,
+ IN void *bind_context, IN osm_madw_t * p_req_madw)
{
#ifdef _DEBUG_
- fprintf(stderr, "__osm_vendor_recv_dummy_cb: Ignoring received MAD after osm_vendor_unbind\n");
+ fprintf(stderr,
+ "__osm_vendor_recv_dummy_cb: Ignoring received MAD after osm_vendor_unbind\n");
#endif
}
/**********************************************************************
**********************************************************************/
void
-__osm_vendor_send_err_dummy_cb(
- IN void* bind_context,
- IN osm_madw_t *p_req_madw )
+__osm_vendor_send_err_dummy_cb(IN void *bind_context,
+ IN osm_madw_t * p_req_madw)
{
#ifdef _DEBUG_
- fprintf(stderr, "__osm_vendor_send_err_dummy_cb: Ignoring send error after osm_vendor_unbind\n");
+ fprintf(stderr,
+ "__osm_vendor_send_err_dummy_cb: Ignoring send error after osm_vendor_unbind\n");
#endif
}
/**********************************************************************
**********************************************************************/
-void
-osm_vendor_unbind(
- IN osm_bind_handle_t h_bind)
+void osm_vendor_unbind(IN osm_bind_handle_t h_bind)
{
- osm_umad_bind_info_t *p_bind = ( osm_umad_bind_info_t * ) h_bind;
+ osm_umad_bind_info_t *p_bind = (osm_umad_bind_info_t *) h_bind;
osm_vendor_t *p_vend = p_bind->p_vend;
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_unbind );
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_unbind);
pthread_mutex_lock(&p_vend->cb_mutex);
p_bind->mad_recv_callback = __osm_vendor_recv_dummy_cb;
p_bind->send_err_callback = __osm_vendor_send_err_dummy_cb;
pthread_mutex_unlock(&p_vend->cb_mutex);
- OSM_LOG_EXIT( p_vend->p_log);
+ OSM_LOG_EXIT(p_vend->p_log);
}
/**********************************************************************
**********************************************************************/
-ib_mad_t*
-osm_vendor_get(
- IN osm_bind_handle_t h_bind,
- IN const uint32_t mad_size,
- IN osm_vend_wrap_t* const p_vw )
+ib_mad_t *osm_vendor_get(IN osm_bind_handle_t h_bind,
+ IN const uint32_t mad_size,
+ IN osm_vend_wrap_t * const p_vw)
{
- osm_umad_bind_info_t *p_bind = ( osm_umad_bind_info_t * ) h_bind;
+ osm_umad_bind_info_t *p_bind = (osm_umad_bind_info_t *) h_bind;
osm_vendor_t *p_vend = p_bind->p_vend;
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_get );
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_get);
- osm_log( p_vend->p_log, OSM_LOG_DEBUG, "osm_vendor_get: "
- "Acquiring UMAD for p_madw = %p, size = %u\n", p_vw, mad_size );
- CL_ASSERT( p_vw );
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG, "osm_vendor_get: "
+ "Acquiring UMAD for p_madw = %p, size = %u\n", p_vw, mad_size);
+ CL_ASSERT(p_vw);
p_vw->size = mad_size;
p_vw->umad = umad_alloc(1, mad_size + umad_size());
/* track locally */
p_vw->h_bind = h_bind;
- osm_log( p_vend->p_log, OSM_LOG_DEBUG, "osm_vendor_get: "
- "Acquired UMAD %p, size = %u\n", p_vw->umad, p_vw->size );
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG, "osm_vendor_get: "
+ "Acquired UMAD %p, size = %u\n", p_vw->umad, p_vw->size);
- OSM_LOG_EXIT( p_vend->p_log );
+ OSM_LOG_EXIT(p_vend->p_log);
return umad_get_mad(p_vw->umad);
}
/**********************************************************************
**********************************************************************/
void
-osm_vendor_put(
- IN osm_bind_handle_t h_bind,
- IN osm_vend_wrap_t* const p_vw )
+osm_vendor_put(IN osm_bind_handle_t h_bind, IN osm_vend_wrap_t * const p_vw)
{
- osm_umad_bind_info_t *p_bind = ( osm_umad_bind_info_t * ) h_bind;
+ osm_umad_bind_info_t *p_bind = (osm_umad_bind_info_t *) h_bind;
osm_vendor_t *p_vend = p_bind->p_vend;
osm_madw_t *p_madw;
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_put );
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_put);
- CL_ASSERT( p_vw );
+ CL_ASSERT(p_vw);
- osm_log( p_vend->p_log, OSM_LOG_DEBUG, "osm_vendor_put: "
- "Retiring UMAD %p\n", p_vw->umad );
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG, "osm_vendor_put: "
+ "Retiring UMAD %p\n", p_vw->umad);
/*
* We moved the removal of the transaction to immediately after
@@ -1038,26 +1029,24 @@ osm_vendor_put(
/* free the mad but the wrapper is part of the madw object */
umad_free(p_vw->umad);
p_vw->umad = 0;
- p_madw = PARENT_STRUCT( p_vw, osm_madw_t, vend_wrap);
+ p_madw = PARENT_STRUCT(p_vw, osm_madw_t, vend_wrap);
p_madw->p_mad = NULL;
- OSM_LOG_EXIT( p_vend->p_log );
+ OSM_LOG_EXIT(p_vend->p_log);
}
/**********************************************************************
**********************************************************************/
ib_api_status_t
-osm_vendor_send(
- IN osm_bind_handle_t h_bind,
- IN osm_madw_t* const p_madw,
- IN boolean_t const resp_expected )
+osm_vendor_send(IN osm_bind_handle_t h_bind,
+ IN osm_madw_t * const p_madw, IN boolean_t const resp_expected)
{
- osm_umad_bind_info_t* const p_bind = h_bind;
- osm_vendor_t* const p_vend = p_bind->p_vend;
- osm_vend_wrap_t* const p_vw = osm_madw_get_vend_ptr( p_madw );
- osm_mad_addr_t* const p_mad_addr = osm_madw_get_mad_addr_ptr( p_madw );
- ib_mad_t* const p_mad = osm_madw_get_mad_ptr( p_madw );
- ib_sa_mad_t* const p_sa = (ib_sa_mad_t *)p_mad;
+ osm_umad_bind_info_t *const p_bind = h_bind;
+ osm_vendor_t *const p_vend = p_bind->p_vend;
+ osm_vend_wrap_t *const p_vw = osm_madw_get_vend_ptr(p_madw);
+ osm_mad_addr_t *const p_mad_addr = osm_madw_get_mad_addr_ptr(p_madw);
+ ib_mad_t *const p_mad = osm_madw_get_mad_ptr(p_madw);
+ ib_sa_mad_t *const p_sa = (ib_sa_mad_t *) p_mad;
int ret = -1;
int is_rmpp = 0;
uint32_t sent_mad_size;
@@ -1065,10 +1054,10 @@ osm_vendor_send(
uint32_t paylen = 0;
#endif
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_send );
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_send);
- CL_ASSERT( p_vw->h_bind == h_bind );
- CL_ASSERT( p_mad == umad_get_mad(p_vw->umad) );
+ CL_ASSERT(p_vw->h_bind == h_bind);
+ CL_ASSERT(p_mad == umad_get_mad(p_vw->umad));
if (p_mad->mgmt_class == IB_MCLASS_SUBN_DIR) {
umad_set_addr_net(p_vw->umad, 0xffff, 0, 0, 0);
@@ -1087,9 +1076,9 @@ osm_vendor_send(
IB_QP1_WELL_KNOWN_Q_KEY);
umad_set_grh(p_vw->umad, 0); /* FIXME: GRH support */
umad_set_pkey(p_vw->umad, 0);
- /* FIXME: p_mad_addr->addr_type.gsi.pkey to index */
- if (ib_class_is_rmpp(p_mad->mgmt_class)) { /* RMPP GSI classes FIXME: no GRH */
- if (!ib_rmpp_is_flag_set((ib_rmpp_mad_t *)p_sa,
+ /* FIXME: p_mad_addr->addr_type.gsi.pkey to index */
+ if (ib_class_is_rmpp(p_mad->mgmt_class)) { /* RMPP GSI classes FIXME: no GRH */
+ if (!ib_rmpp_is_flag_set((ib_rmpp_mad_t *) p_sa,
IB_RMPP_FLAG_ACTIVE)) {
/* Clear RMPP header when RMPP not ACTIVE */
p_sa->rmpp_version = 0;
@@ -1099,16 +1088,16 @@ osm_vendor_send(
#ifdef VENDOR_RMPP_SUPPORT
} else
is_rmpp = 1;
- osm_log( p_vend->p_log, OSM_LOG_VERBOSE,
+ osm_log(p_vend->p_log, OSM_LOG_VERBOSE,
"osm_vendor_send: RMPP %d length %d\n",
- ib_rmpp_is_flag_set((ib_rmpp_mad_t *)p_sa,
- IB_RMPP_FLAG_ACTIVE),
- p_madw->mad_size);
+ ib_rmpp_is_flag_set((ib_rmpp_mad_t *) p_sa,
+ IB_RMPP_FLAG_ACTIVE),
+ p_madw->mad_size);
#else
} else {
p_sa->rmpp_version = 1;
- p_sa->seg_num = cl_ntoh32(1); /* first DATA is seg 1 */
- p_sa->rmpp_flags |= (uint8_t)0x70; /* RRespTime of 14 (high 5 bits) */
+ p_sa->seg_num = cl_ntoh32(1); /* first DATA is seg 1 */
+ p_sa->rmpp_flags |= (uint8_t) 0x70; /* RRespTime of 14 (high 5 bits) */
p_sa->rmpp_status = 0;
paylen = p_madw->mad_size - IB_SA_MAD_HDR_SIZE;
paylen += (IB_SA_MAD_HDR_SIZE - MAD_RMPP_HDR_SIZE);
@@ -1117,7 +1106,7 @@ osm_vendor_send(
#endif
}
-Resp:
+ Resp:
if (resp_expected)
put_madw(p_vend, p_madw, &p_mad->trans_id);
@@ -1125,13 +1114,12 @@ Resp:
sent_mad_size = p_madw->mad_size;
#else
sent_mad_size = is_rmpp ? p_madw->mad_size - IB_SA_MAD_HDR_SIZE :
- p_madw->mad_size,
+ p_madw->mad_size,
#endif
-
- if ((ret = umad_send(p_bind->port_id, p_bind->agent_id, p_vw->umad,
- sent_mad_size,
- resp_expected ? p_vend->timeout : 0,
- p_vend->max_retries)) < 0) {
+ if ((ret = umad_send(p_bind->port_id, p_bind->agent_id, p_vw->umad,
+ sent_mad_size,
+ resp_expected ? p_vend->timeout : 0,
+ p_vend->max_retries)) < 0) {
if (resp_expected)
get_madw(p_vend, &p_mad->trans_id); /* remove from aging table */
osm_log(p_vend->p_log, OSM_LOG_ERROR,
@@ -1140,49 +1128,44 @@ Resp:
p_madw, sent_mad_size, ret);
p_madw->status = IB_ERROR;
pthread_mutex_lock(&p_vend->cb_mutex);
- (*p_bind->send_err_callback)(p_bind->client_context, p_madw); /* cb frees madw */
+ (*p_bind->send_err_callback) (p_bind->client_context, p_madw); /* cb frees madw */
pthread_mutex_unlock(&p_vend->cb_mutex);
goto Exit;
}
if (!resp_expected)
- osm_mad_pool_put(p_bind->p_mad_pool, p_madw);
+ osm_mad_pool_put(p_bind->p_mad_pool, p_madw);
osm_log(p_vend->p_log, OSM_LOG_DEBUG, "osm_vendor_send: "
"Completed sending %s p_madw = %p\n",
resp_expected ? "request" : "response or unsolicited", p_madw);
-Exit:
- OSM_LOG_EXIT( p_vend->p_log );
- return( ret );
+ Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (ret);
}
/**********************************************************************
**********************************************************************/
-ib_api_status_t
-osm_vendor_local_lid_change(
- IN osm_bind_handle_t h_bind )
+ib_api_status_t osm_vendor_local_lid_change(IN osm_bind_handle_t h_bind)
{
- osm_umad_bind_info_t *p_bind = (osm_umad_bind_info_t *)h_bind;
+ osm_umad_bind_info_t *p_bind = (osm_umad_bind_info_t *) h_bind;
osm_vendor_t *p_vend = p_bind->p_vend;
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_local_lid_change );
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_local_lid_change);
;
- OSM_LOG_EXIT( p_vend->p_log );
- return( 0 );
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (0);
}
/**********************************************************************
**********************************************************************/
-void
-osm_vendor_set_sm(
- IN osm_bind_handle_t h_bind,
- IN boolean_t is_sm_val )
+void osm_vendor_set_sm(IN osm_bind_handle_t h_bind, IN boolean_t is_sm_val)
{
- osm_umad_bind_info_t *p_bind = (osm_umad_bind_info_t *)h_bind;
+ osm_umad_bind_info_t *p_bind = (osm_umad_bind_info_t *) h_bind;
osm_vendor_t *p_vend = p_bind->p_vend;
char issmstring[24];
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_set_sm );
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_set_sm);
sprintf(issmstring, "/dev/infiniband/issm%d", p_vend->umad_port_id);
if (TRUE == is_sm_val) {
p_vend->issmfd = open(issmstring, O_NONBLOCK);
@@ -1203,15 +1186,12 @@ osm_vendor_set_sm(
}
p_vend->issmfd = -1;
}
- OSM_LOG_EXIT( p_vend->p_log );
+ OSM_LOG_EXIT(p_vend->p_log);
}
-void
-osm_vendor_set_debug(
- IN osm_vendor_t* const p_vend,
- IN int32_t level )
+void osm_vendor_set_debug(IN osm_vendor_t * const p_vend, IN int32_t level)
{
umad_debug(level);
}
-#endif /* OSM_VENDOR_INTF_OPENIB */
+#endif /* OSM_VENDOR_INTF_OPENIB */
diff --git a/opensm/libvendor/osm_vendor_ibumad_sa.c b/opensm/libvendor/osm_vendor_ibumad_sa.c
index 1abca91..42a6d3a 100644
--- a/opensm/libvendor/osm_vendor_ibumad_sa.c
+++ b/opensm/libvendor/osm_vendor_ibumad_sa.c
@@ -35,7 +35,7 @@
#if HAVE_CONFIG_H
# include <config.h>
-#endif /* HAVE_CONFIG_H */
+#endif /* HAVE_CONFIG_H */
#include <stdlib.h>
#include <string.h>
@@ -51,15 +51,15 @@
/* this struct is the internal rep of the bind handle */
typedef struct _osmv_sa_bind_info {
- osm_bind_handle_t h_bind;
- osm_log_t *p_log;
- osm_vendor_t *p_vendor;
- osm_mad_pool_t *p_mad_pool;
- uint64_t port_guid;
- cl_event_t sync_event;
- uint64_t last_lids_update_sec;
- uint16_t lid;
- uint16_t sm_lid;
+ osm_bind_handle_t h_bind;
+ osm_log_t *p_log;
+ osm_vendor_t *p_vendor;
+ osm_mad_pool_t *p_mad_pool;
+ uint64_t port_guid;
+ cl_event_t sync_event;
+ uint64_t last_lids_update_sec;
+ uint16_t lid;
+ uint16_t sm_lid;
} osmv_sa_bind_info_t;
/*****************************************************************************
@@ -75,117 +75,107 @@ typedef struct _osmv_sa_bind_info {
request structure) is attached as the p_madw->context.ni_context.node_guid
*/
void
-__osmv_sa_mad_rcv_cb(
- IN osm_madw_t *p_madw,
- IN void* bind_context,
- IN osm_madw_t *p_req_madw)
+__osmv_sa_mad_rcv_cb(IN osm_madw_t * p_madw,
+ IN void *bind_context, IN osm_madw_t * p_req_madw)
{
- osmv_sa_bind_info_t *p_bind = (osmv_sa_bind_info_t *)bind_context;
- osmv_query_req_t *p_query_req_copy = NULL;
- osmv_query_res_t query_res;
- ib_sa_mad_t *p_sa_mad;
- ib_net16_t mad_status;
-
- OSM_LOG_ENTER( p_bind->p_log, __osmv_sa_mad_rcv_cb );
-
- if (! p_req_madw)
- {
- osm_log( p_bind->p_log, OSM_LOG_DEBUG,
- "__osmv_sa_mad_rcv_cb: "
- "Ignoring a non-response mad\n");
- osm_mad_pool_put(p_bind->p_mad_pool, p_madw);
- goto Exit;
- }
-
- /* obtain the sent context since we store it during send in the ni_ctx */
- p_query_req_copy =
- (osmv_query_req_t *)(long*)(long)(p_req_madw->context.ni_context.node_guid);
-
- /* provide the context of the original request in the result */
- query_res.query_context = p_query_req_copy->query_context;
-
- /* provide the resulting madw */
- query_res.p_result_madw = p_madw;
-
- /* update the req fields */
- p_sa_mad = ( ib_sa_mad_t * ) p_madw->p_mad;
-
- /* if we got a remote error track it in the status */
- mad_status = ( ib_net16_t ) ( p_sa_mad->status & IB_SMP_STATUS_MASK );
- if (mad_status != IB_SUCCESS)
- {
- osm_log( p_bind->p_log, OSM_LOG_ERROR,
- "__osmv_sa_mad_rcv_cb: ERR 5501: "
- "Remote error:0x%04X\n", mad_status
- );
- query_res.status = IB_REMOTE_ERROR;
- }
- else
- {
- query_res.status = IB_SUCCESS;
- }
-
- /* what if we have got back an empty mad ? */
- if (! p_madw->mad_size)
- {
- osm_log( p_bind->p_log, OSM_LOG_ERROR,
- "__osmv_sa_mad_rcv_cb: ERR 5502: "
- "Got an empty mad\n"
- );
- query_res.status = IB_ERROR;
- }
-
- if (IB_SUCCESS == mad_status)
- {
-
- /* if we are in not in a method response of an rmpp nature we must get only 1 */
- /* HACK: in the future we might need to be smarter for other methods... */
- if (p_sa_mad->method != IB_MAD_METHOD_GETTABLE_RESP)
- {
- query_res.result_cnt = 1;
- }
- else
- {
+ osmv_sa_bind_info_t *p_bind = (osmv_sa_bind_info_t *) bind_context;
+ osmv_query_req_t *p_query_req_copy = NULL;
+ osmv_query_res_t query_res;
+ ib_sa_mad_t *p_sa_mad;
+ ib_net16_t mad_status;
+
+ OSM_LOG_ENTER(p_bind->p_log, __osmv_sa_mad_rcv_cb);
+
+ if (!p_req_madw) {
+ osm_log(p_bind->p_log, OSM_LOG_DEBUG,
+ "__osmv_sa_mad_rcv_cb: "
+ "Ignoring a non-response mad\n");
+ osm_mad_pool_put(p_bind->p_mad_pool, p_madw);
+ goto Exit;
+ }
+
+ /* obtain the sent context since we store it during send in the ni_ctx */
+ p_query_req_copy =
+ (osmv_query_req_t *) (long *)(long)(p_req_madw->context.ni_context.
+ node_guid);
+
+ /* provide the context of the original request in the result */
+ query_res.query_context = p_query_req_copy->query_context;
+
+ /* provide the resulting madw */
+ query_res.p_result_madw = p_madw;
+
+ /* update the req fields */
+ p_sa_mad = (ib_sa_mad_t *) p_madw->p_mad;
+
+ /* if we got a remote error track it in the status */
+ mad_status = (ib_net16_t) (p_sa_mad->status & IB_SMP_STATUS_MASK);
+ if (mad_status != IB_SUCCESS) {
+ osm_log(p_bind->p_log, OSM_LOG_ERROR,
+ "__osmv_sa_mad_rcv_cb: ERR 5501: "
+ "Remote error:0x%04X\n", mad_status);
+ query_res.status = IB_REMOTE_ERROR;
+ } else {
+ query_res.status = IB_SUCCESS;
+ }
+
+ /* what if we have got back an empty mad ? */
+ if (!p_madw->mad_size) {
+ osm_log(p_bind->p_log, OSM_LOG_ERROR,
+ "__osmv_sa_mad_rcv_cb: ERR 5502: "
+ "Got an empty mad\n");
+ query_res.status = IB_ERROR;
+ }
+
+ if (IB_SUCCESS == mad_status) {
+
+ /* if we are in not in a method response of an rmpp nature we must get only 1 */
+ /* HACK: in the future we might need to be smarter for other methods... */
+ if (p_sa_mad->method != IB_MAD_METHOD_GETTABLE_RESP) {
+ query_res.result_cnt = 1;
+ } else {
#ifndef VENDOR_RMPP_SUPPORT
- if (mad_status != IB_SUCCESS)
- query_res.result_cnt = 0;
- else
- query_res.result_cnt = 1;
+ if (mad_status != IB_SUCCESS)
+ query_res.result_cnt = 0;
+ else
+ query_res.result_cnt = 1;
#else
- /* we used the offset value to calculate the number of
- records in here */
- query_res.result_cnt =
- (uintn_t)
- ( ( p_madw->mad_size - IB_SA_MAD_HDR_SIZE ) /
- ib_get_attr_size( p_sa_mad->attr_offset ) );
- osm_log( p_bind->p_log, OSM_LOG_DEBUG,
- "__osmv_sa_mad_rcv_cb: Count = %u = %zu / %u (%zu)\n",
- query_res.result_cnt, p_madw->mad_size - IB_SA_MAD_HDR_SIZE,
- ib_get_attr_size( p_sa_mad->attr_offset ),
- ( p_madw->mad_size - IB_SA_MAD_HDR_SIZE ) %
- ib_get_attr_size( p_sa_mad->attr_offset )
- );
+ /* we used the offset value to calculate the number of
+ records in here */
+ query_res.result_cnt = (uintn_t)
+ ((p_madw->mad_size - IB_SA_MAD_HDR_SIZE) /
+ ib_get_attr_size(p_sa_mad->attr_offset));
+ osm_log(p_bind->p_log, OSM_LOG_DEBUG,
+ "__osmv_sa_mad_rcv_cb: Count = %u = %zu / %u (%zu)\n",
+ query_res.result_cnt,
+ p_madw->mad_size - IB_SA_MAD_HDR_SIZE,
+ ib_get_attr_size(p_sa_mad->attr_offset),
+ (p_madw->mad_size -
+ IB_SA_MAD_HDR_SIZE) %
+ ib_get_attr_size(p_sa_mad->attr_offset)
+ );
#endif
- }
- }
+ }
+ }
- query_res.query_type = p_query_req_copy->query_type;
+ query_res.query_type = p_query_req_copy->query_type;
- p_query_req_copy->pfn_query_cb( &query_res );
+ p_query_req_copy->pfn_query_cb(&query_res);
- if ((p_query_req_copy->flags & OSM_SA_FLAGS_SYNC) == OSM_SA_FLAGS_SYNC)
- cl_event_signal( &p_bind->sync_event );
+ if ((p_query_req_copy->flags & OSM_SA_FLAGS_SYNC) == OSM_SA_FLAGS_SYNC)
+ cl_event_signal(&p_bind->sync_event);
- Exit:
+ Exit:
- /* free the copied query request if found */
- if (p_query_req_copy) free(p_query_req_copy);
+ /* free the copied query request if found */
+ if (p_query_req_copy)
+ free(p_query_req_copy);
- /* put back the request madw */
- if (p_req_madw)
- osm_mad_pool_put(p_bind->p_mad_pool, p_req_madw);
+ /* put back the request madw */
+ if (p_req_madw)
+ osm_mad_pool_put(p_bind->p_mad_pool, p_req_madw);
- OSM_LOG_EXIT( p_bind->p_log );
+ OSM_LOG_EXIT(p_bind->p_log);
}
/*****************************************************************************
@@ -195,38 +185,37 @@ __osmv_sa_mad_rcv_cb(
Only report the error and get rid of the mad wrapper
*/
-void
-__osmv_sa_mad_err_cb(
- IN void* bind_context,
- IN osm_madw_t *p_madw)
+void __osmv_sa_mad_err_cb(IN void *bind_context, IN osm_madw_t * p_madw)
{
- osmv_sa_bind_info_t *p_bind = (osmv_sa_bind_info_t *)bind_context;
- osmv_query_req_t *p_query_req_copy = NULL;
- osmv_query_res_t query_res;
+ osmv_sa_bind_info_t *p_bind = (osmv_sa_bind_info_t *) bind_context;
+ osmv_query_req_t *p_query_req_copy = NULL;
+ osmv_query_res_t query_res;
- OSM_LOG_ENTER( p_bind->p_log, __osmv_sa_mad_err_cb );
+ OSM_LOG_ENTER(p_bind->p_log, __osmv_sa_mad_err_cb);
- /* Obtain the sent context etc */
- p_query_req_copy =
- (osmv_query_req_t *)(long*)(long)(p_madw->context.ni_context.node_guid);
+ /* Obtain the sent context etc */
+ p_query_req_copy =
+ (osmv_query_req_t *) (long *)(long)(p_madw->context.ni_context.
+ node_guid);
- /* provide the context of the original request in the result */
- query_res.query_context = p_query_req_copy->query_context;
+ /* provide the context of the original request in the result */
+ query_res.query_context = p_query_req_copy->query_context;
- query_res.p_result_madw = p_madw;
+ query_res.p_result_madw = p_madw;
- query_res.status = IB_TIMEOUT;
- query_res.result_cnt = 0;
+ query_res.status = IB_TIMEOUT;
+ query_res.result_cnt = 0;
- query_res.query_type = p_query_req_copy->query_type;
+ query_res.query_type = p_query_req_copy->query_type;
- p_query_req_copy->pfn_query_cb( &query_res );
+ p_query_req_copy->pfn_query_cb(&query_res);
- if ((p_query_req_copy->flags & OSM_SA_FLAGS_SYNC) == OSM_SA_FLAGS_SYNC)
- cl_event_signal( &p_bind->sync_event );
+ if ((p_query_req_copy->flags & OSM_SA_FLAGS_SYNC) == OSM_SA_FLAGS_SYNC)
+ cl_event_signal(&p_bind->sync_event);
- if (p_query_req_copy) free(p_query_req_copy);
- OSM_LOG_EXIT( p_bind->p_log );
+ if (p_query_req_copy)
+ free(p_query_req_copy);
+ OSM_LOG_EXIT(p_bind->p_log);
}
/*****************************************************************************
@@ -238,196 +227,175 @@ __osmv_sa_mad_err_cb(
we query for multiple guids.
*****************************************************************************/
ib_api_status_t
-__osmv_get_lid_and_sm_lid_by_port_guid(
- IN osm_vendor_t* const p_vend,
- IN ib_net64_t port_guid,
- IN OUT uint64_t* p_lids_update_time_sec,
- OUT uint16_t* lid,
- OUT uint16_t* sm_lid)
+__osmv_get_lid_and_sm_lid_by_port_guid(IN osm_vendor_t * const p_vend,
+ IN ib_net64_t port_guid,
+ IN OUT uint64_t * p_lids_update_time_sec,
+ OUT uint16_t * lid,
+ OUT uint16_t * sm_lid)
{
- ib_api_status_t status;
- ib_port_attr_t *p_attr_array;
- uint32_t num_ports = MAX_PORTS;
- uint32_t port_num;
-
- OSM_LOG_ENTER( p_vend->p_log, __osmv_get_lid_and_sm_lid_by_port_guid );
-
- /* use previous values if current time is close enough to previous query */
- if ((time(NULL) <= *p_lids_update_time_sec + 30) && *lid && *sm_lid)
- {
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "__osmv_get_lid_and_sm_lid_by_port_guid: "
- "Using previously stored lid:0x%04x sm_lid:0x%04x\n",
- *lid, *sm_lid
- );
- status = IB_SUCCESS;
- goto Exit;
- }
-
- /* obtain the number of available ports */
- num_ports = MAX_PORTS;
- status = osm_vendor_get_all_port_attr(p_vend, NULL, &num_ports);
- if (status != IB_INSUFFICIENT_MEMORY)
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__osmv_get_lid_and_sm_lid_by_port_guid: ERR 5503: "
- "expected to get IB_INSUFFICIENT_MEMORY but got: %s\n",
- ib_get_err_str(status)
- );
- status = IB_ERROR;
- goto Exit;
- }
-
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "__osmv_get_lid_and_sm_lid_by_port_guid: "
- "Found total of %u ports. Looking for guid:0x%016" PRIx64 "\n",
- num_ports, cl_ntoh64(port_guid)
- );
-
- /* allocate the attributes */
- p_attr_array =
- (ib_port_attr_t *)malloc(sizeof(ib_port_attr_t)*num_ports);
-
- /* obtain the attributes */
- status = osm_vendor_get_all_port_attr(p_vend, p_attr_array, &num_ports);
- if (status != IB_SUCCESS)
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__osmv_get_lid_and_sm_lid_by_port_guid: ERR 5504: "
- "Failed to get port attributes (error: %s)\n",
- ib_get_err_str(status)
- );
- free(p_attr_array);
- goto Exit;
- }
-
- status = IB_ERROR;
- /* find the port requested in the list */
- for (port_num = 0; (port_num<num_ports) && (status == IB_ERROR); port_num++)
- {
- if (p_attr_array[port_num].port_guid == port_guid)
- {
- *lid = p_attr_array[port_num].lid;
- *sm_lid = p_attr_array[port_num].sm_lid;
- *p_lids_update_time_sec = time(NULL);
- status = IB_SUCCESS;
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "__osmv_get_lid_and_sm_lid_by_port_guid: "
- "Found guid:0x%016" PRIx64 " with idx:%d\n",
- cl_ntoh64(port_guid), port_num);
- }
- }
-
- free(p_attr_array);
-
- Exit:
- OSM_LOG_EXIT( p_vend->p_log );
- return ( status );
+ ib_api_status_t status;
+ ib_port_attr_t *p_attr_array;
+ uint32_t num_ports = MAX_PORTS;
+ uint32_t port_num;
+
+ OSM_LOG_ENTER(p_vend->p_log, __osmv_get_lid_and_sm_lid_by_port_guid);
+
+ /* use previous values if current time is close enough to previous query */
+ if ((time(NULL) <= *p_lids_update_time_sec + 30) && *lid && *sm_lid) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__osmv_get_lid_and_sm_lid_by_port_guid: "
+ "Using previously stored lid:0x%04x sm_lid:0x%04x\n",
+ *lid, *sm_lid);
+ status = IB_SUCCESS;
+ goto Exit;
+ }
+
+ /* obtain the number of available ports */
+ num_ports = MAX_PORTS;
+ status = osm_vendor_get_all_port_attr(p_vend, NULL, &num_ports);
+ if (status != IB_INSUFFICIENT_MEMORY) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osmv_get_lid_and_sm_lid_by_port_guid: ERR 5503: "
+ "expected to get IB_INSUFFICIENT_MEMORY but got: %s\n",
+ ib_get_err_str(status)
+ );
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__osmv_get_lid_and_sm_lid_by_port_guid: "
+ "Found total of %u ports. Looking for guid:0x%016" PRIx64 "\n",
+ num_ports, cl_ntoh64(port_guid)
+ );
+
+ /* allocate the attributes */
+ p_attr_array =
+ (ib_port_attr_t *) malloc(sizeof(ib_port_attr_t) * num_ports);
+
+ /* obtain the attributes */
+ status = osm_vendor_get_all_port_attr(p_vend, p_attr_array, &num_ports);
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osmv_get_lid_and_sm_lid_by_port_guid: ERR 5504: "
+ "Failed to get port attributes (error: %s)\n",
+ ib_get_err_str(status)
+ );
+ free(p_attr_array);
+ goto Exit;
+ }
+
+ status = IB_ERROR;
+ /* find the port requested in the list */
+ for (port_num = 0; (port_num < num_ports) && (status == IB_ERROR);
+ port_num++) {
+ if (p_attr_array[port_num].port_guid == port_guid) {
+ *lid = p_attr_array[port_num].lid;
+ *sm_lid = p_attr_array[port_num].sm_lid;
+ *p_lids_update_time_sec = time(NULL);
+ status = IB_SUCCESS;
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__osmv_get_lid_and_sm_lid_by_port_guid: "
+ "Found guid:0x%016" PRIx64 " with idx:%d\n",
+ cl_ntoh64(port_guid), port_num);
+ }
+ }
+
+ free(p_attr_array);
+
+ Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
}
/*****************************************************************************
*****************************************************************************/
osm_bind_handle_t
-osmv_bind_sa(
- IN osm_vendor_t* const p_vend,
- IN osm_mad_pool_t* const p_mad_pool,
- IN ib_net64_t port_guid
- )
+osmv_bind_sa(IN osm_vendor_t * const p_vend,
+ IN osm_mad_pool_t * const p_mad_pool, IN ib_net64_t port_guid)
{
- osm_bind_info_t bind_info;
- osm_log_t *p_log = p_vend->p_log;
- ib_api_status_t status = IB_SUCCESS;
- osmv_sa_bind_info_t *p_sa_bind_info;
- cl_status_t cl_status;
-
- OSM_LOG_ENTER( p_log, osmv_bind_sa );
-
- osm_log( p_log, OSM_LOG_DEBUG,
- "osmv_bind_sa: "
- "Binding to port 0x%" PRIx64 "\n",
- cl_ntoh64( port_guid ) );
-
- bind_info.port_guid = port_guid;
- bind_info.mad_class = IB_MCLASS_SUBN_ADM;
- bind_info.class_version = 2;
- bind_info.is_responder = FALSE;
- bind_info.is_trap_processor = FALSE;
- bind_info.is_report_processor = FALSE;
- bind_info.send_q_size = OSM_SM_DEFAULT_QP1_RCV_SIZE;
- bind_info.recv_q_size = OSM_SM_DEFAULT_QP1_SEND_SIZE;
-
- /* allocate the new sa bind info */
- p_sa_bind_info =
- (osmv_sa_bind_info_t *)malloc(sizeof(osmv_sa_bind_info_t));
- if (! p_sa_bind_info)
- {
- osm_log( p_log, OSM_LOG_ERROR,
- "osmv_bind_sa: ERR 5505: "
- "Failed to allocate new bind structure\n" );
- p_sa_bind_info = OSM_BIND_INVALID_HANDLE;
- goto Exit;
- }
-
- /* store some important context */
- p_sa_bind_info->p_log = p_log;
- p_sa_bind_info->port_guid = port_guid;
- p_sa_bind_info->p_mad_pool = p_mad_pool;
- p_sa_bind_info->p_vendor = p_vend;
- p_sa_bind_info->last_lids_update_sec = 0;
-
- /* Bind to the lower level */
- p_sa_bind_info->h_bind =
- osm_vendor_bind( p_vend,
- &bind_info,
- p_mad_pool,
- __osmv_sa_mad_rcv_cb,
- __osmv_sa_mad_err_cb,
- p_sa_bind_info); /* context provided to CBs */
-
- if (p_sa_bind_info->h_bind == OSM_BIND_INVALID_HANDLE)
- {
- free(p_sa_bind_info);
- p_sa_bind_info = OSM_BIND_INVALID_HANDLE;
- osm_log( p_log, OSM_LOG_ERROR,
- "osmv_bind_sa: ERR 5506: "
- "Failed to bind to vendor GSI\n" );
- goto Exit;
- }
-
- /* obtain the sm_lid from the vendor */
- status =
- __osmv_get_lid_and_sm_lid_by_port_guid(
- p_vend, port_guid,
- &p_sa_bind_info->last_lids_update_sec,
- &p_sa_bind_info->lid,
- &p_sa_bind_info->sm_lid);
- if (status != IB_SUCCESS)
- {
- free(p_sa_bind_info);
- p_sa_bind_info = OSM_BIND_INVALID_HANDLE;
- osm_log( p_log, OSM_LOG_ERROR,
- "osmv_bind_sa: ERR 5507: "
- "Failed to obtain the SM lid\n" );
- goto Exit;
- }
-
- /* initialize the sync_event */
- cl_event_construct( &p_sa_bind_info->sync_event );
- cl_status = cl_event_init( &p_sa_bind_info->sync_event, TRUE );
- if( cl_status != CL_SUCCESS )
- {
- osm_log( p_log, OSM_LOG_ERROR,
- "osmv_bind_sa: ERR 5508: "
- "cl_init_event failed: %s\n",
- ib_get_err_str(cl_status)
- );
- free(p_sa_bind_info);
- p_sa_bind_info = OSM_BIND_INVALID_HANDLE;
- }
-
- Exit:
- OSM_LOG_EXIT( p_log );
- return ( p_sa_bind_info );
+ osm_bind_info_t bind_info;
+ osm_log_t *p_log = p_vend->p_log;
+ ib_api_status_t status = IB_SUCCESS;
+ osmv_sa_bind_info_t *p_sa_bind_info;
+ cl_status_t cl_status;
+
+ OSM_LOG_ENTER(p_log, osmv_bind_sa);
+
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "osmv_bind_sa: "
+ "Binding to port 0x%" PRIx64 "\n", cl_ntoh64(port_guid));
+
+ bind_info.port_guid = port_guid;
+ bind_info.mad_class = IB_MCLASS_SUBN_ADM;
+ bind_info.class_version = 2;
+ bind_info.is_responder = FALSE;
+ bind_info.is_trap_processor = FALSE;
+ bind_info.is_report_processor = FALSE;
+ bind_info.send_q_size = OSM_SM_DEFAULT_QP1_RCV_SIZE;
+ bind_info.recv_q_size = OSM_SM_DEFAULT_QP1_SEND_SIZE;
+
+ /* allocate the new sa bind info */
+ p_sa_bind_info =
+ (osmv_sa_bind_info_t *) malloc(sizeof(osmv_sa_bind_info_t));
+ if (!p_sa_bind_info) {
+ osm_log(p_log, OSM_LOG_ERROR,
+ "osmv_bind_sa: ERR 5505: "
+ "Failed to allocate new bind structure\n");
+ p_sa_bind_info = OSM_BIND_INVALID_HANDLE;
+ goto Exit;
+ }
+
+ /* store some important context */
+ p_sa_bind_info->p_log = p_log;
+ p_sa_bind_info->port_guid = port_guid;
+ p_sa_bind_info->p_mad_pool = p_mad_pool;
+ p_sa_bind_info->p_vendor = p_vend;
+ p_sa_bind_info->last_lids_update_sec = 0;
+
+ /* Bind to the lower level */
+ p_sa_bind_info->h_bind = osm_vendor_bind(p_vend, &bind_info, p_mad_pool, __osmv_sa_mad_rcv_cb, __osmv_sa_mad_err_cb, p_sa_bind_info); /* context provided to CBs */
+
+ if (p_sa_bind_info->h_bind == OSM_BIND_INVALID_HANDLE) {
+ free(p_sa_bind_info);
+ p_sa_bind_info = OSM_BIND_INVALID_HANDLE;
+ osm_log(p_log, OSM_LOG_ERROR,
+ "osmv_bind_sa: ERR 5506: "
+ "Failed to bind to vendor GSI\n");
+ goto Exit;
+ }
+
+ /* obtain the sm_lid from the vendor */
+ status =
+ __osmv_get_lid_and_sm_lid_by_port_guid(p_vend, port_guid,
+ &p_sa_bind_info->
+ last_lids_update_sec,
+ &p_sa_bind_info->lid,
+ &p_sa_bind_info->sm_lid);
+ if (status != IB_SUCCESS) {
+ free(p_sa_bind_info);
+ p_sa_bind_info = OSM_BIND_INVALID_HANDLE;
+ osm_log(p_log, OSM_LOG_ERROR,
+ "osmv_bind_sa: ERR 5507: "
+ "Failed to obtain the SM lid\n");
+ goto Exit;
+ }
+
+ /* initialize the sync_event */
+ cl_event_construct(&p_sa_bind_info->sync_event);
+ cl_status = cl_event_init(&p_sa_bind_info->sync_event, TRUE);
+ if (cl_status != CL_SUCCESS) {
+ osm_log(p_log, OSM_LOG_ERROR,
+ "osmv_bind_sa: ERR 5508: "
+ "cl_init_event failed: %s\n", ib_get_err_str(cl_status)
+ );
+ free(p_sa_bind_info);
+ p_sa_bind_info = OSM_BIND_INVALID_HANDLE;
+ }
+
+ Exit:
+ OSM_LOG_EXIT(p_log);
+ return (p_sa_bind_info);
}
/*****************************************************************************
@@ -443,15 +411,14 @@ osmv_bind_sa(
*
* SYNOPSIS
*/
-typedef struct _osmv_sa_mad_data
-{
- /* MAD data. */
- uint8_t method;
- ib_net16_t attr_id;
- ib_net16_t attr_offset;
- ib_net32_t attr_mod;
- ib_net64_t comp_mask;
- void *p_attr;
+typedef struct _osmv_sa_mad_data {
+ /* MAD data. */
+ uint8_t method;
+ ib_net16_t attr_id;
+ ib_net16_t attr_offset;
+ ib_net32_t attr_mod;
+ ib_net64_t comp_mask;
+ void *p_attr;
} osmv_sa_mad_data_t;
/*
* method
@@ -478,140 +445,128 @@ typedef struct _osmv_sa_mad_data
*****************************************************************************/
/* Send a MAD out on the GSI interface */
ib_api_status_t
-__osmv_send_sa_req(
- IN osmv_sa_bind_info_t* p_bind,
- IN const osmv_sa_mad_data_t * const p_sa_mad_data,
- IN const osmv_query_req_t * const p_query_req )
+__osmv_send_sa_req(IN osmv_sa_bind_info_t * p_bind,
+ IN const osmv_sa_mad_data_t * const p_sa_mad_data,
+ IN const osmv_query_req_t * const p_query_req)
{
- ib_api_status_t status;
- ib_mad_t *p_mad_hdr;
- ib_sa_mad_t *p_sa_mad;
- osm_madw_t *p_madw;
- osm_log_t *p_log = p_bind->p_log;
- static atomic32_t trans_id;
- boolean_t sync;
- osmv_query_req_t *p_query_req_copy;
-
- OSM_LOG_ENTER( p_log, __osmv_send_sa_req );
-
- /*
- since the sm_lid might change we obtain it every send
- (actually it is cached in the bind object and refreshed
- every 30sec by this proc )
- */
- status =
- __osmv_get_lid_and_sm_lid_by_port_guid(
- p_bind->p_vendor, p_bind->port_guid,
- &p_bind->last_lids_update_sec,
- &p_bind->lid,
- &p_bind->sm_lid );
- if (status != IB_SUCCESS)
- {
- osm_log( p_log, OSM_LOG_ERROR,
- "__osmv_send_sa_req: ERR 5509: "
- "Failed to obtain the SM lid\n" );
- goto Exit;
- }
-
- /* Get a MAD wrapper for the send */
- p_madw = osm_mad_pool_get(
- p_bind->p_mad_pool,
- p_bind->h_bind,
- MAD_BLOCK_SIZE,
- NULL );
-
- if( p_madw == NULL )
- {
- osm_log( p_log, OSM_LOG_ERROR,
- "__osmv_send_sa_req: ERR 5510: "
- "Unable to acquire MAD\n" );
- status = IB_INSUFFICIENT_RESOURCES;
- goto Exit;
- }
-
- /* Initialize the Sent MAD: */
-
- /* Initialize the MAD buffer for the send operation. */
- p_mad_hdr = osm_madw_get_mad_ptr( p_madw );
- p_sa_mad = osm_madw_get_sa_mad_ptr( p_madw );
-
- /* Get a new transaction Id */
- cl_atomic_inc( &trans_id );
-
- /* Cleanup the MAD from any residue */
- memset(p_sa_mad, 0, MAD_BLOCK_SIZE);
-
- /* Initialize the standard MAD header. */
- ib_mad_init_new(
- p_mad_hdr, /* mad pointer */
- IB_MCLASS_SUBN_ADM, /* class */
- ( uint8_t ) 2, /* version */
- p_sa_mad_data->method, /* method */
- cl_hton64( ( uint64_t ) trans_id ),/* tid */
- p_sa_mad_data->attr_id, /* attr id */
- p_sa_mad_data->attr_mod /* attr mod */
- );
-
- /* Set the query information. */
- p_sa_mad->sm_key = p_query_req->sm_key;
- p_sa_mad->attr_offset = 0;
- p_sa_mad->comp_mask = p_sa_mad_data->comp_mask;
+ ib_api_status_t status;
+ ib_mad_t *p_mad_hdr;
+ ib_sa_mad_t *p_sa_mad;
+ osm_madw_t *p_madw;
+ osm_log_t *p_log = p_bind->p_log;
+ static atomic32_t trans_id;
+ boolean_t sync;
+ osmv_query_req_t *p_query_req_copy;
+
+ OSM_LOG_ENTER(p_log, __osmv_send_sa_req);
+
+ /*
+ since the sm_lid might change we obtain it every send
+ (actually it is cached in the bind object and refreshed
+ every 30sec by this proc )
+ */
+ status =
+ __osmv_get_lid_and_sm_lid_by_port_guid(p_bind->p_vendor,
+ p_bind->port_guid,
+ &p_bind->
+ last_lids_update_sec,
+ &p_bind->lid,
+ &p_bind->sm_lid);
+ if (status != IB_SUCCESS) {
+ osm_log(p_log, OSM_LOG_ERROR,
+ "__osmv_send_sa_req: ERR 5509: "
+ "Failed to obtain the SM lid\n");
+ goto Exit;
+ }
+
+ /* Get a MAD wrapper for the send */
+ p_madw = osm_mad_pool_get(p_bind->p_mad_pool,
+ p_bind->h_bind, MAD_BLOCK_SIZE, NULL);
+
+ if (p_madw == NULL) {
+ osm_log(p_log, OSM_LOG_ERROR,
+ "__osmv_send_sa_req: ERR 5510: "
+ "Unable to acquire MAD\n");
+ status = IB_INSUFFICIENT_RESOURCES;
+ goto Exit;
+ }
+
+ /* Initialize the Sent MAD: */
+
+ /* Initialize the MAD buffer for the send operation. */
+ p_mad_hdr = osm_madw_get_mad_ptr(p_madw);
+ p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
+
+ /* Get a new transaction Id */
+ cl_atomic_inc(&trans_id);
+
+ /* Cleanup the MAD from any residue */
+ memset(p_sa_mad, 0, MAD_BLOCK_SIZE);
+
+ /* Initialize the standard MAD header. */
+ ib_mad_init_new(p_mad_hdr, /* mad pointer */
+ IB_MCLASS_SUBN_ADM, /* class */
+ (uint8_t) 2, /* version */
+ p_sa_mad_data->method, /* method */
+ cl_hton64((uint64_t) trans_id), /* tid */
+ p_sa_mad_data->attr_id, /* attr id */
+ p_sa_mad_data->attr_mod /* attr mod */
+ );
+
+ /* Set the query information. */
+ p_sa_mad->sm_key = p_query_req->sm_key;
+ p_sa_mad->attr_offset = 0;
+ p_sa_mad->comp_mask = p_sa_mad_data->comp_mask;
#ifdef DUAL_SIDED_RMPP
- if( p_sa_mad->method == IB_MAD_METHOD_GETMULTI )
- p_sa_mad->rmpp_flags = IB_RMPP_FLAG_ACTIVE;
+ if (p_sa_mad->method == IB_MAD_METHOD_GETMULTI)
+ p_sa_mad->rmpp_flags = IB_RMPP_FLAG_ACTIVE;
#endif
- if( p_sa_mad->comp_mask )
- {
- memcpy( p_sa_mad->data, p_sa_mad_data->p_attr,
- ib_get_attr_size(p_sa_mad_data->attr_offset));
- }
-
- /*
- Provide the address to send to
- */
- p_madw->mad_addr.dest_lid = cl_hton16(p_bind->sm_lid);
- p_madw->mad_addr.addr_type.smi.source_lid =
- cl_hton16(p_bind->lid);
- p_madw->mad_addr.addr_type.gsi.remote_qp = CL_HTON32(1);
- p_madw->resp_expected = TRUE;
- p_madw->fail_msg = CL_DISP_MSGID_NONE;
-
- /*
- Provide MAD context such that the call back will know what to do.
- We have to keep the entire request structure so we know the CB.
- Since we can not rely on the client to keep it around until
- the response - we duplicate it and will later dispose it (in CB).
- To store on the MADW we cast it into what opensm has:
- p_madw->context.ni_context.node_guid
- */
- p_query_req_copy = malloc(sizeof(*p_query_req_copy));
- *p_query_req_copy = *p_query_req;
- p_madw->context.ni_context.node_guid =
- (ib_net64_t)(long)p_query_req_copy;
-
- /* we can support async as well as sync calls */
- sync = ((p_query_req->flags & OSM_SA_FLAGS_SYNC) == OSM_SA_FLAGS_SYNC);
-
- /* send the mad asynchronously */
- status = osm_vendor_send(
- osm_madw_get_bind_handle( p_madw ),
- p_madw,
- p_madw->resp_expected );
-
- /* if synchronous - wait on the event */
- if (sync)
- {
- osm_log( p_log, OSM_LOG_DEBUG,
- "__osmv_send_sa_req: "
- "Waiting for async event\n" );
- cl_event_wait_on( &p_bind->sync_event, EVENT_NO_TIMEOUT, FALSE );
- cl_event_reset(&p_bind->sync_event);
- status = p_madw->status;
- }
-
- Exit:
- OSM_LOG_EXIT( p_log );
- return status;
+ if (p_sa_mad->comp_mask) {
+ memcpy(p_sa_mad->data, p_sa_mad_data->p_attr,
+ ib_get_attr_size(p_sa_mad_data->attr_offset));
+ }
+
+ /*
+ Provide the address to send to
+ */
+ p_madw->mad_addr.dest_lid = cl_hton16(p_bind->sm_lid);
+ p_madw->mad_addr.addr_type.smi.source_lid = cl_hton16(p_bind->lid);
+ p_madw->mad_addr.addr_type.gsi.remote_qp = CL_HTON32(1);
+ p_madw->resp_expected = TRUE;
+ p_madw->fail_msg = CL_DISP_MSGID_NONE;
+
+ /*
+ Provide MAD context such that the call back will know what to do.
+ We have to keep the entire request structure so we know the CB.
+ Since we can not rely on the client to keep it around until
+ the response - we duplicate it and will later dispose it (in CB).
+ To store on the MADW we cast it into what opensm has:
+ p_madw->context.ni_context.node_guid
+ */
+ p_query_req_copy = malloc(sizeof(*p_query_req_copy));
+ *p_query_req_copy = *p_query_req;
+ p_madw->context.ni_context.node_guid =
+ (ib_net64_t) (long)p_query_req_copy;
+
+ /* we can support async as well as sync calls */
+ sync = ((p_query_req->flags & OSM_SA_FLAGS_SYNC) == OSM_SA_FLAGS_SYNC);
+
+ /* send the mad asynchronously */
+ status = osm_vendor_send(osm_madw_get_bind_handle(p_madw),
+ p_madw, p_madw->resp_expected);
+
+ /* if synchronous - wait on the event */
+ if (sync) {
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "__osmv_send_sa_req: " "Waiting for async event\n");
+ cl_event_wait_on(&p_bind->sync_event, EVENT_NO_TIMEOUT, FALSE);
+ cl_event_reset(&p_bind->sync_event);
+ status = p_madw->status;
+ }
+
+ Exit:
+ OSM_LOG_EXIT(p_log);
+ return status;
}
/*****************************************************************************
@@ -620,280 +575,292 @@ __osmv_send_sa_req(
* Query the SA based on the user's request.
*/
ib_api_status_t
-osmv_query_sa(
- IN osm_bind_handle_t h_bind,
- IN const osmv_query_req_t * const p_query_req
- )
+osmv_query_sa(IN osm_bind_handle_t h_bind,
+ IN const osmv_query_req_t * const p_query_req)
{
- osmv_sa_bind_info_t *p_bind = (osmv_sa_bind_info_t *)h_bind;
- osmv_sa_mad_data_t sa_mad_data;
- osmv_user_query_t *p_user_query;
- ib_service_record_t svc_rec;
- ib_node_record_t node_rec;
- ib_portinfo_record_t port_info;
- ib_path_rec_t path_rec;
+ osmv_sa_bind_info_t *p_bind = (osmv_sa_bind_info_t *) h_bind;
+ osmv_sa_mad_data_t sa_mad_data;
+ osmv_user_query_t *p_user_query;
+ ib_service_record_t svc_rec;
+ ib_node_record_t node_rec;
+ ib_portinfo_record_t port_info;
+ ib_path_rec_t path_rec;
#ifdef DUAL_SIDED_RMPP
- ib_multipath_rec_t multipath_rec;
- osmv_multipath_req_t *p_mpr_req;
- int i, j;
+ ib_multipath_rec_t multipath_rec;
+ osmv_multipath_req_t *p_mpr_req;
+ int i, j;
#endif
- ib_class_port_info_t class_port_info;
- osm_log_t *p_log = p_bind->p_log;
- ib_api_status_t status;
-
- OSM_LOG_ENTER( p_log, osmv_query_sa );
-
- /* Set the request information. */
- sa_mad_data.method = IB_MAD_METHOD_GETTABLE;
- sa_mad_data.attr_mod = 0;
-
- /* Set the MAD attributes and component mask correctly. */
- switch ( p_query_req->query_type )
- {
-
- case OSMV_QUERY_USER_DEFINED:
- osm_log( p_log, OSM_LOG_DEBUG,
- "osmv_query_sa DBG:001 %s", "USER_DEFINED\n" );
- p_user_query = ( osmv_user_query_t * ) p_query_req->p_query_input;
- if (p_user_query->method)
- sa_mad_data.method = p_user_query->method;
- sa_mad_data.attr_offset = p_user_query->attr_offset;
- sa_mad_data.attr_id = p_user_query->attr_id;
- sa_mad_data.attr_mod = p_user_query->attr_mod;
- sa_mad_data.comp_mask = p_user_query->comp_mask;
- sa_mad_data.p_attr = p_user_query->p_attr;
- break;
-
- case OSMV_QUERY_ALL_SVC_RECS:
- osm_log( p_log, OSM_LOG_DEBUG,
- "osmv_query_sa DBG:001 %s", "SVC_REC_BY_NAME\n" );
- sa_mad_data.attr_id = IB_MAD_ATTR_SERVICE_RECORD;
- sa_mad_data.attr_offset =
- ib_get_attr_offset( sizeof( ib_service_record_t ) );
- sa_mad_data.comp_mask = 0;
- sa_mad_data.p_attr = &svc_rec;
- break;
-
- case OSMV_QUERY_SVC_REC_BY_NAME:
- osm_log( p_log, OSM_LOG_DEBUG,
- "osmv_query_sa DBG:001 %s", "SVC_REC_BY_NAME\n" );
- sa_mad_data.method = IB_MAD_METHOD_GET;
- sa_mad_data.attr_id = IB_MAD_ATTR_SERVICE_RECORD;
- sa_mad_data.comp_mask = IB_SR_COMPMASK_SNAME;
- sa_mad_data.attr_offset =
- ib_get_attr_offset( sizeof( ib_service_record_t ) );
- sa_mad_data.p_attr = &svc_rec;
- memcpy( svc_rec.service_name, p_query_req->p_query_input,
- sizeof( ib_svc_name_t ) );
- break;
-
- case OSMV_QUERY_SVC_REC_BY_ID:
- osm_log( p_log, OSM_LOG_DEBUG,
- "osmv_query_sa DBG:001 %s", "SVC_REC_BY_ID\n" );
- sa_mad_data.attr_id = IB_MAD_ATTR_SERVICE_RECORD;
- sa_mad_data.comp_mask = IB_SR_COMPMASK_SID;
- sa_mad_data.attr_offset =
- ib_get_attr_offset( sizeof( ib_service_record_t ) );
- sa_mad_data.p_attr = &svc_rec;
- svc_rec.service_id = *( ib_net64_t * ) ( p_query_req->p_query_input );
- break;
-
- case OSMV_QUERY_CLASS_PORT_INFO:
- osm_log( p_log, OSM_LOG_DEBUG,
- "osmv_query_sa DBG:001 %s","CLASS_PORT_INFO\n" );
- sa_mad_data.method = IB_MAD_METHOD_GET;
- sa_mad_data.attr_id = IB_MAD_ATTR_CLASS_PORT_INFO;
- sa_mad_data.attr_offset =
- ib_get_attr_offset( sizeof( ib_class_port_info_t ) );
- sa_mad_data.comp_mask = 0;
- sa_mad_data.p_attr = &class_port_info;
- break;
-
- case OSMV_QUERY_NODE_REC_BY_NODE_GUID:
- osm_log( p_log, OSM_LOG_DEBUG,
- "osmv_query_sa DBG:001 %s","NODE_REC_BY_NODE_GUID\n" );
- sa_mad_data.attr_id = IB_MAD_ATTR_NODE_RECORD;
- sa_mad_data.attr_offset =
- ib_get_attr_offset( sizeof( ib_node_record_t ) );
- sa_mad_data.comp_mask = IB_NR_COMPMASK_NODEGUID;
- sa_mad_data.p_attr = &node_rec;
- node_rec.node_info.node_guid =
- *( ib_net64_t * ) ( p_query_req->p_query_input );
- break;
-
- case OSMV_QUERY_PORT_REC_BY_LID:
- osm_log( p_log, OSM_LOG_DEBUG,
- "osmv_query_sa DBG:001 %s","PORT_REC_BY_LID\n" );
- sa_mad_data.attr_id = IB_MAD_ATTR_PORTINFO_RECORD;
- sa_mad_data.attr_offset =
- ib_get_attr_offset( sizeof( ib_portinfo_record_t ) );
- sa_mad_data.comp_mask = IB_PIR_COMPMASK_LID;
- sa_mad_data.p_attr = &port_info;
- port_info.lid = *( ib_net16_t * ) ( p_query_req->p_query_input );
- break;
-
- case OSMV_QUERY_PORT_REC_BY_LID_AND_NUM:
- sa_mad_data.method = IB_MAD_METHOD_GET;
- p_user_query = ( osmv_user_query_t * ) p_query_req->p_query_input;
- osm_log( p_log, OSM_LOG_DEBUG,
- "osmv_query_sa DBG:001 %s","PORT_REC_BY_LID_AND_NUM\n" );
- sa_mad_data.attr_id = IB_MAD_ATTR_PORTINFO_RECORD;
- sa_mad_data.attr_offset =
- ib_get_attr_offset( sizeof( ib_portinfo_record_t ) );
- sa_mad_data.comp_mask = IB_PIR_COMPMASK_LID | IB_PIR_COMPMASK_PORTNUM;
- sa_mad_data.p_attr = p_user_query->p_attr;
- break;
-
- case OSMV_QUERY_VLARB_BY_LID_PORT_BLOCK:
- sa_mad_data.method = IB_MAD_METHOD_GET;
- p_user_query = ( osmv_user_query_t * ) p_query_req->p_query_input;
- osm_log( p_log, OSM_LOG_DEBUG,
- "osmv_query_sa DBG:001 %s","OSMV_QUERY_VLARB_BY_LID_PORT_BLOCK\n" );
- sa_mad_data.attr_id = IB_MAD_ATTR_VLARB_RECORD;
- sa_mad_data.attr_offset =
- ib_get_attr_offset( sizeof( ib_vl_arb_table_record_t ) );
- sa_mad_data.comp_mask = IB_VLA_COMPMASK_LID | IB_VLA_COMPMASK_OUT_PORT | IB_VLA_COMPMASK_BLOCK;
- sa_mad_data.p_attr = p_user_query->p_attr;
- break;
-
- case OSMV_QUERY_SLVL_BY_LID_AND_PORTS:
- sa_mad_data.method = IB_MAD_METHOD_GET;
- p_user_query = ( osmv_user_query_t * ) p_query_req->p_query_input;
- osm_log( p_log, OSM_LOG_DEBUG,
- "osmv_query_sa DBG:001 %s","OSMV_QUERY_VLARB_BY_LID_PORT_BLOCK\n" );
- sa_mad_data.attr_id = IB_MAD_ATTR_SLVL_RECORD;
- sa_mad_data.attr_offset =
- ib_get_attr_offset( sizeof( ib_slvl_table_record_t ) );
- sa_mad_data.comp_mask = IB_SLVL_COMPMASK_LID | IB_SLVL_COMPMASK_OUT_PORT | IB_SLVL_COMPMASK_IN_PORT;
- sa_mad_data.p_attr = p_user_query->p_attr;
- break;
-
- case OSMV_QUERY_PATH_REC_BY_PORT_GUIDS:
- osm_log( p_log, OSM_LOG_DEBUG,
- "osmv_query_sa DBG:001 %s","PATH_REC_BY_PORT_GUIDS\n" );
- memset(&path_rec, 0, sizeof(ib_path_rec_t ));
- sa_mad_data.attr_id = IB_MAD_ATTR_PATH_RECORD;
- sa_mad_data.attr_offset =
- ib_get_attr_offset( sizeof( ib_path_rec_t ) );
- sa_mad_data.comp_mask = ( IB_PR_COMPMASK_DGID | IB_PR_COMPMASK_SGID );
- sa_mad_data.p_attr = &path_rec;
- ib_gid_set_default( &path_rec.dgid,
- ( ( osmv_guid_pair_t * ) ( p_query_req->
- p_query_input ) )->
- dest_guid );
- ib_gid_set_default( &path_rec.sgid,
- ( ( osmv_guid_pair_t * ) ( p_query_req->
- p_query_input ) )->
- src_guid );
- break;
-
- case OSMV_QUERY_PATH_REC_BY_GIDS:
- osm_log( p_log, OSM_LOG_DEBUG,
- "osmv_query_sa DBG:001 %s","PATH_REC_BY_GIDS\n" );
- memset(&path_rec, 0, sizeof(ib_path_rec_t ));
- sa_mad_data.attr_id = IB_MAD_ATTR_PATH_RECORD;
- sa_mad_data.attr_offset =
- ib_get_attr_offset( sizeof( ib_path_rec_t ) );
- sa_mad_data.comp_mask = ( IB_PR_COMPMASK_DGID | IB_PR_COMPMASK_SGID );
- sa_mad_data.p_attr = &path_rec;
- memcpy( &path_rec.dgid,
- &( ( osmv_gid_pair_t * ) ( p_query_req->p_query_input ) )->
- dest_gid, sizeof( ib_gid_t ) );
- memcpy( &path_rec.sgid,
- &( ( osmv_gid_pair_t * ) ( p_query_req->p_query_input ) )->
- src_gid, sizeof( ib_gid_t ) );
- break;
-
- case OSMV_QUERY_PATH_REC_BY_LIDS:
- osm_log( p_log, OSM_LOG_DEBUG,
- "osmv_query_sa DBG:001 %s","PATH_REC_BY_LIDS\n" );
- memset(&path_rec, 0, sizeof(ib_path_rec_t ));
- sa_mad_data.method = IB_MAD_METHOD_GET;
- sa_mad_data.attr_id = IB_MAD_ATTR_PATH_RECORD;
- sa_mad_data.attr_offset =
- ib_get_attr_offset( sizeof( ib_path_rec_t ) );
- sa_mad_data.comp_mask = ( IB_PR_COMPMASK_DLID | IB_PR_COMPMASK_SLID );
- sa_mad_data.p_attr = &path_rec;
- path_rec.dlid =
- ( ( osmv_lid_pair_t * ) ( p_query_req->p_query_input ) )->dest_lid;
- path_rec.slid =
- ( ( osmv_lid_pair_t * ) ( p_query_req->p_query_input ) )->src_lid;
- break;
-
- case OSMV_QUERY_UD_MULTICAST_SET:
- sa_mad_data.method = IB_MAD_METHOD_SET;
- p_user_query = ( osmv_user_query_t * ) p_query_req->p_query_input;
- osm_log( p_log, OSM_LOG_DEBUG,
- "osmv_query_sa DBG:001 %s","OSMV_QUERY_UD_MULTICAST_SET\n" );
- sa_mad_data.attr_id = IB_MAD_ATTR_MCMEMBER_RECORD;
- sa_mad_data.attr_offset =
- ib_get_attr_offset( sizeof( ib_member_rec_t ) );
- sa_mad_data.comp_mask = p_user_query->comp_mask;
- sa_mad_data.p_attr = p_user_query->p_attr;
- break;
-
- case OSMV_QUERY_UD_MULTICAST_DELETE:
- sa_mad_data.method = IB_MAD_METHOD_DELETE;
- p_user_query = ( osmv_user_query_t * ) p_query_req->p_query_input;
- osm_log( p_log, OSM_LOG_DEBUG,
- "osmv_query_sa DBG:001 %s","OSMV_QUERY_UD_MULTICAST_DELETE\n" );
- sa_mad_data.attr_id = IB_MAD_ATTR_MCMEMBER_RECORD;
- sa_mad_data.attr_offset =
- ib_get_attr_offset( sizeof( ib_member_rec_t ) );
- sa_mad_data.comp_mask = p_user_query->comp_mask;
- sa_mad_data.p_attr = p_user_query->p_attr;
- break;
+ ib_class_port_info_t class_port_info;
+ osm_log_t *p_log = p_bind->p_log;
+ ib_api_status_t status;
+
+ OSM_LOG_ENTER(p_log, osmv_query_sa);
+
+ /* Set the request information. */
+ sa_mad_data.method = IB_MAD_METHOD_GETTABLE;
+ sa_mad_data.attr_mod = 0;
+
+ /* Set the MAD attributes and component mask correctly. */
+ switch (p_query_req->query_type) {
+
+ case OSMV_QUERY_USER_DEFINED:
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "osmv_query_sa DBG:001 %s", "USER_DEFINED\n");
+ p_user_query = (osmv_user_query_t *) p_query_req->p_query_input;
+ if (p_user_query->method)
+ sa_mad_data.method = p_user_query->method;
+ sa_mad_data.attr_offset = p_user_query->attr_offset;
+ sa_mad_data.attr_id = p_user_query->attr_id;
+ sa_mad_data.attr_mod = p_user_query->attr_mod;
+ sa_mad_data.comp_mask = p_user_query->comp_mask;
+ sa_mad_data.p_attr = p_user_query->p_attr;
+ break;
+
+ case OSMV_QUERY_ALL_SVC_RECS:
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "osmv_query_sa DBG:001 %s", "SVC_REC_BY_NAME\n");
+ sa_mad_data.attr_id = IB_MAD_ATTR_SERVICE_RECORD;
+ sa_mad_data.attr_offset =
+ ib_get_attr_offset(sizeof(ib_service_record_t));
+ sa_mad_data.comp_mask = 0;
+ sa_mad_data.p_attr = &svc_rec;
+ break;
+
+ case OSMV_QUERY_SVC_REC_BY_NAME:
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "osmv_query_sa DBG:001 %s", "SVC_REC_BY_NAME\n");
+ sa_mad_data.method = IB_MAD_METHOD_GET;
+ sa_mad_data.attr_id = IB_MAD_ATTR_SERVICE_RECORD;
+ sa_mad_data.comp_mask = IB_SR_COMPMASK_SNAME;
+ sa_mad_data.attr_offset =
+ ib_get_attr_offset(sizeof(ib_service_record_t));
+ sa_mad_data.p_attr = &svc_rec;
+ memcpy(svc_rec.service_name, p_query_req->p_query_input,
+ sizeof(ib_svc_name_t));
+ break;
+
+ case OSMV_QUERY_SVC_REC_BY_ID:
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "osmv_query_sa DBG:001 %s", "SVC_REC_BY_ID\n");
+ sa_mad_data.attr_id = IB_MAD_ATTR_SERVICE_RECORD;
+ sa_mad_data.comp_mask = IB_SR_COMPMASK_SID;
+ sa_mad_data.attr_offset =
+ ib_get_attr_offset(sizeof(ib_service_record_t));
+ sa_mad_data.p_attr = &svc_rec;
+ svc_rec.service_id =
+ *(ib_net64_t *) (p_query_req->p_query_input);
+ break;
+
+ case OSMV_QUERY_CLASS_PORT_INFO:
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "osmv_query_sa DBG:001 %s", "CLASS_PORT_INFO\n");
+ sa_mad_data.method = IB_MAD_METHOD_GET;
+ sa_mad_data.attr_id = IB_MAD_ATTR_CLASS_PORT_INFO;
+ sa_mad_data.attr_offset =
+ ib_get_attr_offset(sizeof(ib_class_port_info_t));
+ sa_mad_data.comp_mask = 0;
+ sa_mad_data.p_attr = &class_port_info;
+ break;
+
+ case OSMV_QUERY_NODE_REC_BY_NODE_GUID:
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "osmv_query_sa DBG:001 %s", "NODE_REC_BY_NODE_GUID\n");
+ sa_mad_data.attr_id = IB_MAD_ATTR_NODE_RECORD;
+ sa_mad_data.attr_offset =
+ ib_get_attr_offset(sizeof(ib_node_record_t));
+ sa_mad_data.comp_mask = IB_NR_COMPMASK_NODEGUID;
+ sa_mad_data.p_attr = &node_rec;
+ node_rec.node_info.node_guid =
+ *(ib_net64_t *) (p_query_req->p_query_input);
+ break;
+
+ case OSMV_QUERY_PORT_REC_BY_LID:
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "osmv_query_sa DBG:001 %s", "PORT_REC_BY_LID\n");
+ sa_mad_data.attr_id = IB_MAD_ATTR_PORTINFO_RECORD;
+ sa_mad_data.attr_offset =
+ ib_get_attr_offset(sizeof(ib_portinfo_record_t));
+ sa_mad_data.comp_mask = IB_PIR_COMPMASK_LID;
+ sa_mad_data.p_attr = &port_info;
+ port_info.lid = *(ib_net16_t *) (p_query_req->p_query_input);
+ break;
+
+ case OSMV_QUERY_PORT_REC_BY_LID_AND_NUM:
+ sa_mad_data.method = IB_MAD_METHOD_GET;
+ p_user_query = (osmv_user_query_t *) p_query_req->p_query_input;
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "osmv_query_sa DBG:001 %s",
+ "PORT_REC_BY_LID_AND_NUM\n");
+ sa_mad_data.attr_id = IB_MAD_ATTR_PORTINFO_RECORD;
+ sa_mad_data.attr_offset =
+ ib_get_attr_offset(sizeof(ib_portinfo_record_t));
+ sa_mad_data.comp_mask =
+ IB_PIR_COMPMASK_LID | IB_PIR_COMPMASK_PORTNUM;
+ sa_mad_data.p_attr = p_user_query->p_attr;
+ break;
+
+ case OSMV_QUERY_VLARB_BY_LID_PORT_BLOCK:
+ sa_mad_data.method = IB_MAD_METHOD_GET;
+ p_user_query = (osmv_user_query_t *) p_query_req->p_query_input;
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "osmv_query_sa DBG:001 %s",
+ "OSMV_QUERY_VLARB_BY_LID_PORT_BLOCK\n");
+ sa_mad_data.attr_id = IB_MAD_ATTR_VLARB_RECORD;
+ sa_mad_data.attr_offset =
+ ib_get_attr_offset(sizeof(ib_vl_arb_table_record_t));
+ sa_mad_data.comp_mask =
+ IB_VLA_COMPMASK_LID | IB_VLA_COMPMASK_OUT_PORT |
+ IB_VLA_COMPMASK_BLOCK;
+ sa_mad_data.p_attr = p_user_query->p_attr;
+ break;
+
+ case OSMV_QUERY_SLVL_BY_LID_AND_PORTS:
+ sa_mad_data.method = IB_MAD_METHOD_GET;
+ p_user_query = (osmv_user_query_t *) p_query_req->p_query_input;
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "osmv_query_sa DBG:001 %s",
+ "OSMV_QUERY_VLARB_BY_LID_PORT_BLOCK\n");
+ sa_mad_data.attr_id = IB_MAD_ATTR_SLVL_RECORD;
+ sa_mad_data.attr_offset =
+ ib_get_attr_offset(sizeof(ib_slvl_table_record_t));
+ sa_mad_data.comp_mask =
+ IB_SLVL_COMPMASK_LID | IB_SLVL_COMPMASK_OUT_PORT |
+ IB_SLVL_COMPMASK_IN_PORT;
+ sa_mad_data.p_attr = p_user_query->p_attr;
+ break;
+
+ case OSMV_QUERY_PATH_REC_BY_PORT_GUIDS:
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "osmv_query_sa DBG:001 %s", "PATH_REC_BY_PORT_GUIDS\n");
+ memset(&path_rec, 0, sizeof(ib_path_rec_t));
+ sa_mad_data.attr_id = IB_MAD_ATTR_PATH_RECORD;
+ sa_mad_data.attr_offset =
+ ib_get_attr_offset(sizeof(ib_path_rec_t));
+ sa_mad_data.comp_mask =
+ (IB_PR_COMPMASK_DGID | IB_PR_COMPMASK_SGID);
+ sa_mad_data.p_attr = &path_rec;
+ ib_gid_set_default(&path_rec.dgid,
+ ((osmv_guid_pair_t *) (p_query_req->
+ p_query_input))->
+ dest_guid);
+ ib_gid_set_default(&path_rec.sgid,
+ ((osmv_guid_pair_t *) (p_query_req->
+ p_query_input))->
+ src_guid);
+ break;
+
+ case OSMV_QUERY_PATH_REC_BY_GIDS:
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "osmv_query_sa DBG:001 %s", "PATH_REC_BY_GIDS\n");
+ memset(&path_rec, 0, sizeof(ib_path_rec_t));
+ sa_mad_data.attr_id = IB_MAD_ATTR_PATH_RECORD;
+ sa_mad_data.attr_offset =
+ ib_get_attr_offset(sizeof(ib_path_rec_t));
+ sa_mad_data.comp_mask =
+ (IB_PR_COMPMASK_DGID | IB_PR_COMPMASK_SGID);
+ sa_mad_data.p_attr = &path_rec;
+ memcpy(&path_rec.dgid,
+ &((osmv_gid_pair_t *) (p_query_req->p_query_input))->
+ dest_gid, sizeof(ib_gid_t));
+ memcpy(&path_rec.sgid,
+ &((osmv_gid_pair_t *) (p_query_req->p_query_input))->
+ src_gid, sizeof(ib_gid_t));
+ break;
+
+ case OSMV_QUERY_PATH_REC_BY_LIDS:
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "osmv_query_sa DBG:001 %s", "PATH_REC_BY_LIDS\n");
+ memset(&path_rec, 0, sizeof(ib_path_rec_t));
+ sa_mad_data.method = IB_MAD_METHOD_GET;
+ sa_mad_data.attr_id = IB_MAD_ATTR_PATH_RECORD;
+ sa_mad_data.attr_offset =
+ ib_get_attr_offset(sizeof(ib_path_rec_t));
+ sa_mad_data.comp_mask =
+ (IB_PR_COMPMASK_DLID | IB_PR_COMPMASK_SLID);
+ sa_mad_data.p_attr = &path_rec;
+ path_rec.dlid =
+ ((osmv_lid_pair_t *) (p_query_req->p_query_input))->
+ dest_lid;
+ path_rec.slid =
+ ((osmv_lid_pair_t *) (p_query_req->p_query_input))->src_lid;
+ break;
+
+ case OSMV_QUERY_UD_MULTICAST_SET:
+ sa_mad_data.method = IB_MAD_METHOD_SET;
+ p_user_query = (osmv_user_query_t *) p_query_req->p_query_input;
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "osmv_query_sa DBG:001 %s",
+ "OSMV_QUERY_UD_MULTICAST_SET\n");
+ sa_mad_data.attr_id = IB_MAD_ATTR_MCMEMBER_RECORD;
+ sa_mad_data.attr_offset =
+ ib_get_attr_offset(sizeof(ib_member_rec_t));
+ sa_mad_data.comp_mask = p_user_query->comp_mask;
+ sa_mad_data.p_attr = p_user_query->p_attr;
+ break;
+
+ case OSMV_QUERY_UD_MULTICAST_DELETE:
+ sa_mad_data.method = IB_MAD_METHOD_DELETE;
+ p_user_query = (osmv_user_query_t *) p_query_req->p_query_input;
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "osmv_query_sa DBG:001 %s",
+ "OSMV_QUERY_UD_MULTICAST_DELETE\n");
+ sa_mad_data.attr_id = IB_MAD_ATTR_MCMEMBER_RECORD;
+ sa_mad_data.attr_offset =
+ ib_get_attr_offset(sizeof(ib_member_rec_t));
+ sa_mad_data.comp_mask = p_user_query->comp_mask;
+ sa_mad_data.p_attr = p_user_query->p_attr;
+ break;
#ifdef DUAL_SIDED_RMPP
- case OSMV_QUERY_MULTIPATH_REC:
- osm_log( p_log, OSM_LOG_DEBUG,
- "osmv_query_sa DBG:001 %s","MULTIPATH_REC\n" );
- /* Validate sgid/dgid counts against SA client limit */
- p_mpr_req = ( osmv_multipath_req_t * ) p_query_req->p_query_input;
- if ( p_mpr_req->sgid_count + p_mpr_req->dgid_count > IB_MULTIPATH_MAX_GIDS )
- {
- osm_log( p_log, OSM_LOG_ERROR,
- "osmv_query_sa DBG:001 MULTIPATH_REC "
- "SGID count %d DGID count %d max count %d\n",
- p_mpr_req->sgid_count, p_mpr_req->dgid_count,
- IB_MULTIPATH_MAX_GIDS );
- CL_ASSERT( 0 );
- return IB_ERROR;
- }
- memset(&multipath_rec, 0, sizeof(ib_multipath_rec_t ));
- sa_mad_data.method = IB_MAD_METHOD_GETMULTI;
- sa_mad_data.attr_id = IB_MAD_ATTR_MULTIPATH_RECORD;
- sa_mad_data.attr_offset =
- ib_get_attr_offset( sizeof( ib_multipath_rec_t ) );
- sa_mad_data.p_attr = &multipath_rec;
- sa_mad_data.comp_mask = p_mpr_req->comp_mask;
- multipath_rec.num_path = p_mpr_req->num_path;
- if ( p_mpr_req->reversible )
- multipath_rec.num_path |= 0x80;
- else
- multipath_rec.num_path &= ~0x80;
- multipath_rec.pkey = p_mpr_req->pkey;
- multipath_rec.sl = p_mpr_req->sl;
- multipath_rec.independence = p_mpr_req->independence;
- multipath_rec.sgid_count = p_mpr_req->sgid_count;
- multipath_rec.dgid_count = p_mpr_req->dgid_count;
- j = 0;
- for (i = 0; i < p_mpr_req->sgid_count; i++, j++)
- multipath_rec.gids[j] = p_mpr_req->gids[j];
- for (i = 0; i < p_mpr_req->dgid_count; i++, j++)
- multipath_rec.gids[j] = p_mpr_req->gids[j];
- break;
+ case OSMV_QUERY_MULTIPATH_REC:
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "osmv_query_sa DBG:001 %s", "MULTIPATH_REC\n");
+ /* Validate sgid/dgid counts against SA client limit */
+ p_mpr_req = (osmv_multipath_req_t *) p_query_req->p_query_input;
+ if (p_mpr_req->sgid_count + p_mpr_req->dgid_count >
+ IB_MULTIPATH_MAX_GIDS) {
+ osm_log(p_log, OSM_LOG_ERROR,
+ "osmv_query_sa DBG:001 MULTIPATH_REC "
+ "SGID count %d DGID count %d max count %d\n",
+ p_mpr_req->sgid_count, p_mpr_req->dgid_count,
+ IB_MULTIPATH_MAX_GIDS);
+ CL_ASSERT(0);
+ return IB_ERROR;
+ }
+ memset(&multipath_rec, 0, sizeof(ib_multipath_rec_t));
+ sa_mad_data.method = IB_MAD_METHOD_GETMULTI;
+ sa_mad_data.attr_id = IB_MAD_ATTR_MULTIPATH_RECORD;
+ sa_mad_data.attr_offset =
+ ib_get_attr_offset(sizeof(ib_multipath_rec_t));
+ sa_mad_data.p_attr = &multipath_rec;
+ sa_mad_data.comp_mask = p_mpr_req->comp_mask;
+ multipath_rec.num_path = p_mpr_req->num_path;
+ if (p_mpr_req->reversible)
+ multipath_rec.num_path |= 0x80;
+ else
+ multipath_rec.num_path &= ~0x80;
+ multipath_rec.pkey = p_mpr_req->pkey;
+ multipath_rec.sl = p_mpr_req->sl;
+ multipath_rec.independence = p_mpr_req->independence;
+ multipath_rec.sgid_count = p_mpr_req->sgid_count;
+ multipath_rec.dgid_count = p_mpr_req->dgid_count;
+ j = 0;
+ for (i = 0; i < p_mpr_req->sgid_count; i++, j++)
+ multipath_rec.gids[j] = p_mpr_req->gids[j];
+ for (i = 0; i < p_mpr_req->dgid_count; i++, j++)
+ multipath_rec.gids[j] = p_mpr_req->gids[j];
+ break;
#endif
- default:
- osm_log( p_log, OSM_LOG_ERROR,
- "osmv_query_sa DBG:001 %s", "UNKNOWN\n" );
- CL_ASSERT( 0 );
- return IB_ERROR;
- }
+ default:
+ osm_log(p_log, OSM_LOG_ERROR,
+ "osmv_query_sa DBG:001 %s", "UNKNOWN\n");
+ CL_ASSERT(0);
+ return IB_ERROR;
+ }
- status = __osmv_send_sa_req( h_bind, &sa_mad_data, p_query_req );
+ status = __osmv_send_sa_req(h_bind, &sa_mad_data, p_query_req);
- OSM_LOG_EXIT( p_log );
- return status;
+ OSM_LOG_EXIT(p_log);
+ return status;
}
diff --git a/opensm/libvendor/osm_vendor_mlx.c b/opensm/libvendor/osm_vendor_mlx.c
index ea2d9b3..e3eee2b 100644
--- a/opensm/libvendor/osm_vendor_mlx.c
+++ b/opensm/libvendor/osm_vendor_mlx.c
@@ -35,7 +35,7 @@
#if HAVE_CONFIG_H
# include <config.h>
-#endif /* HAVE_CONFIG_H */
+#endif /* HAVE_CONFIG_H */
#include <stdlib.h>
#include <string.h>
@@ -50,14 +50,12 @@
* FORWARD REFERENCES
*/
static ib_api_status_t
-__osmv_get_send_txn(IN osm_bind_handle_t h_bind,
- IN osm_madw_t* const p_madw,
- IN boolean_t is_rmpp,
- IN boolean_t resp_expected,
- OUT osmv_txn_ctx_t **pp_txn);
+__osmv_get_send_txn(IN osm_bind_handle_t h_bind,
+ IN osm_madw_t * const p_madw,
+ IN boolean_t is_rmpp,
+ IN boolean_t resp_expected, OUT osmv_txn_ctx_t ** pp_txn);
-static void
-__osm_vendor_internal_unbind(osm_bind_handle_t h_bind);
+static void __osm_vendor_internal_unbind(osm_bind_handle_t h_bind);
/*
* NAME osm_vendor_new
@@ -65,38 +63,32 @@ __osm_vendor_internal_unbind(osm_bind_handle_t h_bind);
* DESCRIPTION Create and Initialize the osm_vendor_t Object
*/
-osm_vendor_t*
-osm_vendor_new(
- IN osm_log_t* const p_log,
- IN const uint32_t timeout )
+osm_vendor_t *osm_vendor_new(IN osm_log_t * const p_log,
+ IN const uint32_t timeout)
{
- ib_api_status_t status;
- osm_vendor_t *p_vend;
-
- OSM_LOG_ENTER( p_log, osm_vendor_new );
-
- CL_ASSERT( p_log );
-
- p_vend = malloc( sizeof( *p_vend ) );
- if ( p_vend != NULL )
- {
- memset( p_vend, 0, sizeof( *p_vend ) );
-
- status = osm_vendor_init( p_vend, p_log, timeout );
- if ( status != IB_SUCCESS )
- {
- osm_vendor_delete( &p_vend );
- }
- }
- else
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_new: ERR 7301: "
- "Fail to allocate vendor object.\n" );
- }
-
- OSM_LOG_EXIT( p_log );
- return( p_vend );
+ ib_api_status_t status;
+ osm_vendor_t *p_vend;
+
+ OSM_LOG_ENTER(p_log, osm_vendor_new);
+
+ CL_ASSERT(p_log);
+
+ p_vend = malloc(sizeof(*p_vend));
+ if (p_vend != NULL) {
+ memset(p_vend, 0, sizeof(*p_vend));
+
+ status = osm_vendor_init(p_vend, p_log, timeout);
+ if (status != IB_SUCCESS) {
+ osm_vendor_delete(&p_vend);
+ }
+ } else {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_new: ERR 7301: "
+ "Fail to allocate vendor object.\n");
+ }
+
+ OSM_LOG_EXIT(p_log);
+ return (p_vend);
}
/*
@@ -105,47 +97,46 @@ osm_vendor_new(
* DESCRIPTION Delete all the binds behind the vendor + free the vendor object
*/
-void
-osm_vendor_delete( IN osm_vendor_t ** const pp_vend )
+void osm_vendor_delete(IN osm_vendor_t ** const pp_vend)
{
- cl_list_item_t *p_item;
- cl_list_obj_t* p_obj;
- osm_bind_handle_t bind_h;
- osm_log_t* p_log;
+ cl_list_item_t *p_item;
+ cl_list_obj_t *p_obj;
+ osm_bind_handle_t bind_h;
+ osm_log_t *p_log;
- OSM_LOG_ENTER( (*pp_vend)->p_log, osm_vendor_delete );
- p_log = (*pp_vend)->p_log;
+ OSM_LOG_ENTER((*pp_vend)->p_log, osm_vendor_delete);
+ p_log = (*pp_vend)->p_log;
- /* go over the bind handles , unbind them and remove from list */
- p_item = cl_qlist_remove_head(&((*pp_vend)->bind_handles));
- while ( p_item != cl_qlist_end(&((*pp_vend)->bind_handles))) {
+ /* go over the bind handles , unbind them and remove from list */
+ p_item = cl_qlist_remove_head(&((*pp_vend)->bind_handles));
+ while (p_item != cl_qlist_end(&((*pp_vend)->bind_handles))) {
- p_obj = PARENT_STRUCT(p_item,cl_list_obj_t,list_item);
- bind_h = (osm_bind_handle_t*)cl_qlist_obj(p_obj);
- osm_log(p_log,OSM_LOG_DEBUG,
- "osm_vendor_delete: unbinding bind_h:%p \n",bind_h);
+ p_obj = PARENT_STRUCT(p_item, cl_list_obj_t, list_item);
+ bind_h = (osm_bind_handle_t *) cl_qlist_obj(p_obj);
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "osm_vendor_delete: unbinding bind_h:%p \n", bind_h);
- __osm_vendor_internal_unbind(bind_h);
+ __osm_vendor_internal_unbind(bind_h);
- free(p_obj);
- /*removing from list */
- p_item = cl_qlist_remove_head(&((*pp_vend)->bind_handles));
- }
+ free(p_obj);
+ /*removing from list */
+ p_item = cl_qlist_remove_head(&((*pp_vend)->bind_handles));
+ }
- if (NULL != ((*pp_vend)->p_transport_info))
- {
- free((*pp_vend)->p_transport_info);
- (*pp_vend)->p_transport_info = NULL;
- }
+ if (NULL != ((*pp_vend)->p_transport_info)) {
+ free((*pp_vend)->p_transport_info);
+ (*pp_vend)->p_transport_info = NULL;
+ }
- /* remove the packet randomizer object */
- if ( (*pp_vend)->run_randomizer == TRUE )
- osm_pkt_randomizer_destroy( &((*pp_vend)->p_pkt_randomizer), p_log );
+ /* remove the packet randomizer object */
+ if ((*pp_vend)->run_randomizer == TRUE)
+ osm_pkt_randomizer_destroy(&((*pp_vend)->p_pkt_randomizer),
+ p_log);
- free( *pp_vend );
- *pp_vend = NULL;
+ free(*pp_vend);
+ *pp_vend = NULL;
- OSM_LOG_EXIT( p_log );
+ OSM_LOG_EXIT(p_log);
}
/*
@@ -155,40 +146,38 @@ osm_vendor_delete( IN osm_vendor_t ** const pp_vend )
*/
ib_api_status_t
-osm_vendor_init( IN osm_vendor_t * const p_vend,
- IN osm_log_t * const p_log,
- IN const uint32_t timeout )
+osm_vendor_init(IN osm_vendor_t * const p_vend,
+ IN osm_log_t * const p_log, IN const uint32_t timeout)
{
- ib_api_status_t status = IB_SUCCESS;
-
- OSM_LOG_ENTER( p_log, osm_vendor_init );
-
- p_vend->p_transport_info = NULL;
- p_vend->p_log = p_log;
- p_vend->resp_timeout = timeout;
- p_vend->ttime_timeout = timeout * OSMV_TXN_TIMEOUT_FACTOR;
-
- cl_qlist_init(&p_vend->bind_handles);
-
- /* update the run_randomizer flag */
- if ( getenv("OSM_PKT_DROP_RATE") != NULL && atol( getenv("OSM_PKT_DROP_RATE") ) != 0 )
- {
- /* if the OSM_PKT_DROP_RATE global variable is defined to a non-zero value -
- then the randomizer should be called.
- Need to create the packet randomizer object */
- p_vend->run_randomizer = TRUE;
- status = osm_pkt_randomizer_init( &(p_vend->p_pkt_randomizer), p_log );
- if ( status != IB_SUCCESS )
- return status;
- }
- else
- {
- p_vend->run_randomizer = FALSE;
- p_vend->p_pkt_randomizer = NULL;
- }
-
- OSM_LOG_EXIT( p_log );
- return( IB_SUCCESS );
+ ib_api_status_t status = IB_SUCCESS;
+
+ OSM_LOG_ENTER(p_log, osm_vendor_init);
+
+ p_vend->p_transport_info = NULL;
+ p_vend->p_log = p_log;
+ p_vend->resp_timeout = timeout;
+ p_vend->ttime_timeout = timeout * OSMV_TXN_TIMEOUT_FACTOR;
+
+ cl_qlist_init(&p_vend->bind_handles);
+
+ /* update the run_randomizer flag */
+ if (getenv("OSM_PKT_DROP_RATE") != NULL
+ && atol(getenv("OSM_PKT_DROP_RATE")) != 0) {
+ /* if the OSM_PKT_DROP_RATE global variable is defined to a non-zero value -
+ then the randomizer should be called.
+ Need to create the packet randomizer object */
+ p_vend->run_randomizer = TRUE;
+ status =
+ osm_pkt_randomizer_init(&(p_vend->p_pkt_randomizer), p_log);
+ if (status != IB_SUCCESS)
+ return status;
+ } else {
+ p_vend->run_randomizer = FALSE;
+ p_vend->p_pkt_randomizer = NULL;
+ }
+
+ OSM_LOG_EXIT(p_log);
+ return (IB_SUCCESS);
}
/*
@@ -198,134 +187,126 @@ osm_vendor_init( IN osm_vendor_t * const p_vend,
*/
osm_bind_handle_t
-osm_vendor_bind(
- IN osm_vendor_t* const p_vend,
- IN osm_bind_info_t* const p_bind_info,
- IN osm_mad_pool_t* const p_mad_pool,
- IN osm_vend_mad_recv_callback_t mad_recv_callback,
- IN osm_vend_mad_send_err_callback_t send_err_callback,
- IN void* context)
+osm_vendor_bind(IN osm_vendor_t * const p_vend,
+ IN osm_bind_info_t * const p_bind_info,
+ IN osm_mad_pool_t * const p_mad_pool,
+ IN osm_vend_mad_recv_callback_t mad_recv_callback,
+ IN osm_vend_mad_send_err_callback_t send_err_callback,
+ IN void *context)
{
- osmv_bind_obj_t *p_bo;
- ib_api_status_t status;
- char hca_id[32];
- cl_status_t cl_st;
- cl_list_obj_t* p_obj;
- uint8_t hca_index;
-
- if (NULL == p_vend || NULL == p_bind_info || NULL == p_mad_pool
- || NULL == mad_recv_callback || NULL == send_err_callback )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 7302: "
- "NULL parameter passed in: p_vend=%p p_bind_info=%p p_mad_pool=%p recv_cb=%p send_err_cb=%p\n",
- p_vend, p_bind_info, p_mad_pool, mad_recv_callback, send_err_callback);
-
- return OSM_BIND_INVALID_HANDLE;
- }
-
- p_bo = malloc(sizeof(osmv_bind_obj_t));
- if (NULL == p_bo)
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 7303: could not allocate the bind object\n");
- return OSM_BIND_INVALID_HANDLE;
- }
-
- memset(p_bo, 0, sizeof(osmv_bind_obj_t));
- p_bo->p_vendor = p_vend;
- p_bo->recv_cb = mad_recv_callback;
- p_bo->send_err_cb = send_err_callback;
- p_bo->cb_context = context;
- p_bo->p_osm_pool = p_mad_pool;
-
- /* obtain the hca name and port num from the guid */
- osm_log( p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "osm_vendor_bind: "
- "Finding CA and Port that owns port guid 0x%" PRIx64 ".\n",
- cl_ntoh64(p_bind_info->port_guid) );
-
- status = osm_vendor_get_guid_ca_and_port(
- p_bo->p_vendor,
- p_bind_info->port_guid,
- &(p_bo->hca_hndl),
- hca_id,
- &hca_index,
- &(p_bo->port_num));
- if (status != IB_SUCCESS)
- {
- osm_log( p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 7304: "
- "Fail to find port number of port guid:0x%016"PRIx64"\n",
- p_bind_info->port_guid
- );
- free(p_bo);
- return OSM_BIND_INVALID_HANDLE;
- }
-
- /* Initialize the magic_ptr to the pointer of the p_bo info.
- This will be used to signal when the object is being destroyed, so no
- real action will be done then. */
- p_bo->magic_ptr = p_bo;
-
- p_bo->is_closing = FALSE;
-
- cl_spinlock_construct(&(p_bo->lock));
- cl_st = cl_spinlock_init(&(p_bo->lock));
- if (cl_st != CL_SUCCESS)
- {
- osm_log(p_bo->p_vendor->p_log,OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 7305: "
- "could not initialize the spinlock ...\n");
- free(p_bo);
- return OSM_BIND_INVALID_HANDLE;
- }
-
- osm_log(p_bo->p_vendor->p_log,OSM_LOG_DEBUG,
- "osm_vendor_bind: osmv_txnmgr_init ... \n");
- if (osmv_txnmgr_init(&p_bo->txn_mgr, p_vend->p_log, &(p_bo->lock)) != IB_SUCCESS)
- {
- osm_log(p_bo->p_vendor->p_log,OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 7306: "
- "osmv_txnmgr_init failed \n");
- cl_spinlock_destroy(&p_bo->lock);
- free(p_bo);
- return OSM_BIND_INVALID_HANDLE;
- }
-
- /* Do the real job! (Transport-dependent) */
- if (IB_SUCCESS != osmv_transport_init(p_bind_info, hca_id, hca_index, p_bo))
- {
- osm_log(p_bo->p_vendor->p_log,OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 7307: "
- "osmv_transport_init failed \n");
- osmv_txnmgr_done((osm_bind_handle_t) p_bo);
- cl_spinlock_destroy(&p_bo->lock);
- free(p_bo);
- return OSM_BIND_INVALID_HANDLE;
- }
-
- /* insert bind handle into db */
- p_obj = malloc(sizeof(cl_list_obj_t));
- if (NULL == p_obj)
- {
-
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 7308: "
- "osm_vendor_bind: could not allocate the list object\n");
-
- osmv_transport_done(p_bo->p_transp_mgr);
- osmv_txnmgr_done((osm_bind_handle_t) p_bo);
- cl_spinlock_destroy(&p_bo->lock);
- free(p_bo);
- return OSM_BIND_INVALID_HANDLE;
- }
- memset(p_obj, 0, sizeof(cl_list_obj_t));
- cl_qlist_set_obj(p_obj, p_bo);
-
- cl_qlist_insert_head(&p_vend->bind_handles,&p_obj->list_item);
-
- return(osm_bind_handle_t)p_bo;
+ osmv_bind_obj_t *p_bo;
+ ib_api_status_t status;
+ char hca_id[32];
+ cl_status_t cl_st;
+ cl_list_obj_t *p_obj;
+ uint8_t hca_index;
+
+ if (NULL == p_vend || NULL == p_bind_info || NULL == p_mad_pool
+ || NULL == mad_recv_callback || NULL == send_err_callback) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 7302: "
+ "NULL parameter passed in: p_vend=%p p_bind_info=%p p_mad_pool=%p recv_cb=%p send_err_cb=%p\n",
+ p_vend, p_bind_info, p_mad_pool, mad_recv_callback,
+ send_err_callback);
+
+ return OSM_BIND_INVALID_HANDLE;
+ }
+
+ p_bo = malloc(sizeof(osmv_bind_obj_t));
+ if (NULL == p_bo) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 7303: could not allocate the bind object\n");
+ return OSM_BIND_INVALID_HANDLE;
+ }
+
+ memset(p_bo, 0, sizeof(osmv_bind_obj_t));
+ p_bo->p_vendor = p_vend;
+ p_bo->recv_cb = mad_recv_callback;
+ p_bo->send_err_cb = send_err_callback;
+ p_bo->cb_context = context;
+ p_bo->p_osm_pool = p_mad_pool;
+
+ /* obtain the hca name and port num from the guid */
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_bind: "
+ "Finding CA and Port that owns port guid 0x%" PRIx64 ".\n",
+ cl_ntoh64(p_bind_info->port_guid));
+
+ status = osm_vendor_get_guid_ca_and_port(p_bo->p_vendor,
+ p_bind_info->port_guid,
+ &(p_bo->hca_hndl),
+ hca_id,
+ &hca_index, &(p_bo->port_num));
+ if (status != IB_SUCCESS) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 7304: "
+ "Fail to find port number of port guid:0x%016" PRIx64
+ "\n", p_bind_info->port_guid);
+ free(p_bo);
+ return OSM_BIND_INVALID_HANDLE;
+ }
+
+ /* Initialize the magic_ptr to the pointer of the p_bo info.
+ This will be used to signal when the object is being destroyed, so no
+ real action will be done then. */
+ p_bo->magic_ptr = p_bo;
+
+ p_bo->is_closing = FALSE;
+
+ cl_spinlock_construct(&(p_bo->lock));
+ cl_st = cl_spinlock_init(&(p_bo->lock));
+ if (cl_st != CL_SUCCESS) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 7305: "
+ "could not initialize the spinlock ...\n");
+ free(p_bo);
+ return OSM_BIND_INVALID_HANDLE;
+ }
+
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_bind: osmv_txnmgr_init ... \n");
+ if (osmv_txnmgr_init(&p_bo->txn_mgr, p_vend->p_log, &(p_bo->lock)) !=
+ IB_SUCCESS) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 7306: "
+ "osmv_txnmgr_init failed \n");
+ cl_spinlock_destroy(&p_bo->lock);
+ free(p_bo);
+ return OSM_BIND_INVALID_HANDLE;
+ }
+
+ /* Do the real job! (Transport-dependent) */
+ if (IB_SUCCESS !=
+ osmv_transport_init(p_bind_info, hca_id, hca_index, p_bo)) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 7307: "
+ "osmv_transport_init failed \n");
+ osmv_txnmgr_done((osm_bind_handle_t) p_bo);
+ cl_spinlock_destroy(&p_bo->lock);
+ free(p_bo);
+ return OSM_BIND_INVALID_HANDLE;
+ }
+
+ /* insert bind handle into db */
+ p_obj = malloc(sizeof(cl_list_obj_t));
+ if (NULL == p_obj) {
+
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 7308: "
+ "osm_vendor_bind: could not allocate the list object\n");
+
+ osmv_transport_done(p_bo->p_transp_mgr);
+ osmv_txnmgr_done((osm_bind_handle_t) p_bo);
+ cl_spinlock_destroy(&p_bo->lock);
+ free(p_bo);
+ return OSM_BIND_INVALID_HANDLE;
+ }
+ memset(p_obj, 0, sizeof(cl_list_obj_t));
+ cl_qlist_set_obj(p_obj, p_bo);
+
+ cl_qlist_insert_head(&p_vend->bind_handles, &p_obj->list_item);
+
+ return (osm_bind_handle_t) p_bo;
}
/*
@@ -334,40 +315,39 @@ osm_vendor_bind(
* DESCRIPTION Destroy the bind object and remove it from the vendor's list
*/
-void
-osm_vendor_unbind(IN osm_bind_handle_t h_bind)
+void osm_vendor_unbind(IN osm_bind_handle_t h_bind)
{
- osmv_bind_obj_t* p_bo = (osmv_bind_obj_t*)h_bind;
- osm_log_t* p_log = p_bo->p_vendor->p_log;
- cl_list_obj_t* p_obj = NULL;
- cl_list_item_t* p_item,*p_item_tmp;
- cl_qlist_t *const p_bh_list = (cl_qlist_t *const)&p_bo->p_vendor->bind_handles;
-
- OSM_LOG_ENTER(p_log, osm_vendor_unbind );
-
- /* go over all the items in the list and remove the specific item */
- p_item = cl_qlist_head(p_bh_list);
- while (p_item != cl_qlist_end(p_bh_list)) {
- p_obj = PARENT_STRUCT(p_item,cl_list_obj_t,list_item);
- if (cl_qlist_obj(p_obj) == h_bind)
- {
- break;
- }
- p_item_tmp = cl_qlist_next(p_item);
- p_item = p_item_tmp;
- }
-
- CL_ASSERT(p_item != cl_qlist_end(p_bh_list));
-
- cl_qlist_remove_item(p_bh_list,p_item);
- if (p_obj) free(p_obj);
-
- if (h_bind != 0)
- {
- __osm_vendor_internal_unbind(h_bind);
- }
-
- OSM_LOG_EXIT(p_log);
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ osm_log_t *p_log = p_bo->p_vendor->p_log;
+ cl_list_obj_t *p_obj = NULL;
+ cl_list_item_t *p_item, *p_item_tmp;
+ cl_qlist_t *const p_bh_list =
+ (cl_qlist_t * const)&p_bo->p_vendor->bind_handles;
+
+ OSM_LOG_ENTER(p_log, osm_vendor_unbind);
+
+ /* go over all the items in the list and remove the specific item */
+ p_item = cl_qlist_head(p_bh_list);
+ while (p_item != cl_qlist_end(p_bh_list)) {
+ p_obj = PARENT_STRUCT(p_item, cl_list_obj_t, list_item);
+ if (cl_qlist_obj(p_obj) == h_bind) {
+ break;
+ }
+ p_item_tmp = cl_qlist_next(p_item);
+ p_item = p_item_tmp;
+ }
+
+ CL_ASSERT(p_item != cl_qlist_end(p_bh_list));
+
+ cl_qlist_remove_item(p_bh_list, p_item);
+ if (p_obj)
+ free(p_obj);
+
+ if (h_bind != 0) {
+ __osm_vendor_internal_unbind(h_bind);
+ }
+
+ OSM_LOG_EXIT(p_log);
}
/*
@@ -376,53 +356,47 @@ osm_vendor_unbind(IN osm_bind_handle_t h_bind)
* DESCRIPTION Allocate the space for a new MAD
*/
-ib_mad_t *
-osm_vendor_get( IN osm_bind_handle_t h_bind,
- IN const uint32_t mad_size,
- IN osm_vend_wrap_t * const p_vw )
+ib_mad_t *osm_vendor_get(IN osm_bind_handle_t h_bind,
+ IN const uint32_t mad_size,
+ IN osm_vend_wrap_t * const p_vw)
{
- ib_mad_t *p_mad;
- osmv_bind_obj_t *p_bo = ( osmv_bind_obj_t * ) h_bind;
- osm_vendor_t const *p_vend = p_bo->p_vendor;
- uint32_t act_mad_size;
-
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_get );
-
- CL_ASSERT( p_vw );
-
- if (mad_size < MAD_BLOCK_SIZE)
- {
- /* Stupid, but the applications want that! */
- act_mad_size = MAD_BLOCK_SIZE;
- }
- else
- {
- act_mad_size = mad_size;
- }
-
- /* allocate it */
- p_mad = ( ib_mad_t * ) malloc( act_mad_size );
- if ( p_mad == NULL )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get: ERR 7309: "
- "Error Obtaining MAD buffer.\n" );
- goto Exit;
- }
-
- memset( p_mad, 0, act_mad_size );
-
- if ( osm_log_get_level( p_vend->p_log ) >= OSM_LOG_DEBUG )
- {
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_get: "
- "Allocated MAD %p, size = %u.\n", p_mad, act_mad_size );
- }
- p_vw->p_mad = p_mad;
-
- Exit:
- OSM_LOG_EXIT( p_vend->p_log );
- return( p_mad );
+ ib_mad_t *p_mad;
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ osm_vendor_t const *p_vend = p_bo->p_vendor;
+ uint32_t act_mad_size;
+
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_get);
+
+ CL_ASSERT(p_vw);
+
+ if (mad_size < MAD_BLOCK_SIZE) {
+ /* Stupid, but the applications want that! */
+ act_mad_size = MAD_BLOCK_SIZE;
+ } else {
+ act_mad_size = mad_size;
+ }
+
+ /* allocate it */
+ p_mad = (ib_mad_t *) malloc(act_mad_size);
+ if (p_mad == NULL) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get: ERR 7309: "
+ "Error Obtaining MAD buffer.\n");
+ goto Exit;
+ }
+
+ memset(p_mad, 0, act_mad_size);
+
+ if (osm_log_get_level(p_vend->p_log) >= OSM_LOG_DEBUG) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_get: "
+ "Allocated MAD %p, size = %u.\n", p_mad, act_mad_size);
+ }
+ p_vw->p_mad = p_mad;
+
+ Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (p_mad);
}
/*
@@ -438,126 +412,112 @@ osm_vendor_get( IN osm_bind_handle_t h_bind,
*/
ib_api_status_t
-osm_vendor_send(
- IN osm_bind_handle_t h_bind,
- IN osm_madw_t* const p_madw,
- IN boolean_t const resp_expected)
+osm_vendor_send(IN osm_bind_handle_t h_bind,
+ IN osm_madw_t * const p_madw, IN boolean_t const resp_expected)
{
- ib_api_status_t ret = IB_SUCCESS;
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t*)h_bind;
- boolean_t is_rmpp=FALSE, is_rmpp_ds=FALSE;
- osmv_txn_ctx_t *p_txn = NULL;
- ib_mad_t *p_mad;
- osm_log_t *p_log = p_bo->p_vendor->p_log;
- osm_mad_pool_t *p_mad_pool = p_bo->p_osm_pool;
- OSM_LOG_ENTER(p_log, osm_vendor_send);
-
- if (NULL == h_bind || NULL == p_madw ||
- NULL == (p_mad = osm_madw_get_mad_ptr(p_madw)) ||
- NULL == osm_madw_get_mad_addr_ptr(p_madw)) {
-
- return IB_INVALID_PARAMETER;
- }
-
- is_rmpp = (p_madw->mad_size > MAD_BLOCK_SIZE || osmv_mad_is_rmpp(p_mad));
- /* is this rmpp double sided? This means we expect a response that can be
- an rmpp or not */
- is_rmpp_ds = (TRUE == is_rmpp && TRUE == resp_expected);
-
- /* Make our operations with the send context atomic */
- osmv_txn_lock(p_bo);
-
- if (TRUE == p_bo->is_closing)
- {
-
- osm_log(p_log, OSM_LOG_ERROR,
- "osm_vendor_send: ERR 7310: "
- "The handle %p is being unbound, cannot send.\n", h_bind);
- ret = IB_INTERRUPTED;
- /* When closing p_bo could be detroyed or is going to , thus could not refer to it */
- goto send_done;
- }
-
- if (TRUE == resp_expected || TRUE == is_rmpp)
- {
-
- /* We must run under a transaction framework.
- * Get the transaction object (old or new) */
- ret = __osmv_get_send_txn(h_bind, p_madw, is_rmpp,
- resp_expected, &p_txn);
- if (IB_SUCCESS != ret)
- {
- goto send_done;
- }
- }
-
- if (TRUE == is_rmpp)
- {
- /* Do the job - RMPP!
- * The call returns as all the packets are ACK'ed/upon error
- * The txn lock will be released each time the function sleeps
- * and re-acquired when it wakes up
- */
- ret = osmv_rmpp_send_madw(h_bind, p_madw, p_txn, is_rmpp_ds);
- }
- else {
-
- /* Do the job - single MAD!
- * The call returns as soon as the MAD is put on the wire
- */
- ret = osmv_simple_send_madw(h_bind, p_madw, p_txn, FALSE);
- }
-
- if (IB_SUCCESS == ret)
- {
-
- if ((TRUE == is_rmpp) && (FALSE == is_rmpp_ds))
- {
- /* For double-sided sends, the txn continues to live */
- osmv_txn_done(h_bind, osmv_txn_get_key(p_txn),
- FALSE /*not in callback*/);
- }
-
- if (FALSE == resp_expected)
- {
- osm_mad_pool_put(p_mad_pool, p_madw );
- }
- }
- else if (IB_INTERRUPTED != ret)
- {
- if (NULL != p_txn)
- {
- osmv_txn_done(h_bind, osmv_txn_get_key(p_txn),
- FALSE /*not in callback*/);
- }
-
- osm_log(p_log, OSM_LOG_ERROR,
- "osm_vendor_send: ERR 7311: failed to send MADW %p\n", p_madw);
-
- if (TRUE == resp_expected)
- {
- /* Change the status on the p_madw */
- p_madw->status = ret;
- /* Only the requester expects the error callback */
- p_bo->send_err_cb(p_bo->cb_context, p_madw);
- }
- else
- {
- /* put back the mad - it is useless ... */
- osm_mad_pool_put(p_mad_pool, p_madw );
- }
- }
- else /* the transaction was aborted due to p_bo exit */
- {
- osm_mad_pool_put(p_mad_pool, p_madw );
- goto aborted;
- }
- send_done:
-
- osmv_txn_unlock(p_bo);
- aborted:
- OSM_LOG_EXIT(p_log);
- return ret;
+ ib_api_status_t ret = IB_SUCCESS;
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ boolean_t is_rmpp = FALSE, is_rmpp_ds = FALSE;
+ osmv_txn_ctx_t *p_txn = NULL;
+ ib_mad_t *p_mad;
+ osm_log_t *p_log = p_bo->p_vendor->p_log;
+ osm_mad_pool_t *p_mad_pool = p_bo->p_osm_pool;
+ OSM_LOG_ENTER(p_log, osm_vendor_send);
+
+ if (NULL == h_bind || NULL == p_madw ||
+ NULL == (p_mad = osm_madw_get_mad_ptr(p_madw)) ||
+ NULL == osm_madw_get_mad_addr_ptr(p_madw)) {
+
+ return IB_INVALID_PARAMETER;
+ }
+
+ is_rmpp = (p_madw->mad_size > MAD_BLOCK_SIZE
+ || osmv_mad_is_rmpp(p_mad));
+ /* is this rmpp double sided? This means we expect a response that can be
+ an rmpp or not */
+ is_rmpp_ds = (TRUE == is_rmpp && TRUE == resp_expected);
+
+ /* Make our operations with the send context atomic */
+ osmv_txn_lock(p_bo);
+
+ if (TRUE == p_bo->is_closing) {
+
+ osm_log(p_log, OSM_LOG_ERROR,
+ "osm_vendor_send: ERR 7310: "
+ "The handle %p is being unbound, cannot send.\n",
+ h_bind);
+ ret = IB_INTERRUPTED;
+ /* When closing p_bo could be detroyed or is going to , thus could not refer to it */
+ goto send_done;
+ }
+
+ if (TRUE == resp_expected || TRUE == is_rmpp) {
+
+ /* We must run under a transaction framework.
+ * Get the transaction object (old or new) */
+ ret = __osmv_get_send_txn(h_bind, p_madw, is_rmpp,
+ resp_expected, &p_txn);
+ if (IB_SUCCESS != ret) {
+ goto send_done;
+ }
+ }
+
+ if (TRUE == is_rmpp) {
+ /* Do the job - RMPP!
+ * The call returns as all the packets are ACK'ed/upon error
+ * The txn lock will be released each time the function sleeps
+ * and re-acquired when it wakes up
+ */
+ ret = osmv_rmpp_send_madw(h_bind, p_madw, p_txn, is_rmpp_ds);
+ } else {
+
+ /* Do the job - single MAD!
+ * The call returns as soon as the MAD is put on the wire
+ */
+ ret = osmv_simple_send_madw(h_bind, p_madw, p_txn, FALSE);
+ }
+
+ if (IB_SUCCESS == ret) {
+
+ if ((TRUE == is_rmpp) && (FALSE == is_rmpp_ds)) {
+ /* For double-sided sends, the txn continues to live */
+ osmv_txn_done(h_bind, osmv_txn_get_key(p_txn),
+ FALSE /*not in callback */ );
+ }
+
+ if (FALSE == resp_expected) {
+ osm_mad_pool_put(p_mad_pool, p_madw);
+ }
+ } else if (IB_INTERRUPTED != ret) {
+ if (NULL != p_txn) {
+ osmv_txn_done(h_bind, osmv_txn_get_key(p_txn),
+ FALSE /*not in callback */ );
+ }
+
+ osm_log(p_log, OSM_LOG_ERROR,
+ "osm_vendor_send: ERR 7311: failed to send MADW %p\n",
+ p_madw);
+
+ if (TRUE == resp_expected) {
+ /* Change the status on the p_madw */
+ p_madw->status = ret;
+ /* Only the requester expects the error callback */
+ p_bo->send_err_cb(p_bo->cb_context, p_madw);
+ } else {
+ /* put back the mad - it is useless ... */
+ osm_mad_pool_put(p_mad_pool, p_madw);
+ }
+ } else { /* the transaction was aborted due to p_bo exit */
+
+ osm_mad_pool_put(p_mad_pool, p_madw);
+ goto aborted;
+ }
+ send_done:
+
+ osmv_txn_unlock(p_bo);
+ aborted:
+ OSM_LOG_EXIT(p_log);
+ return ret;
}
/*
@@ -567,32 +527,29 @@ osm_vendor_send(
*/
void
-osm_vendor_put(
- IN osm_bind_handle_t h_bind,
- IN osm_vend_wrap_t* const p_vw )
+osm_vendor_put(IN osm_bind_handle_t h_bind, IN osm_vend_wrap_t * const p_vw)
{
- osmv_bind_obj_t *p_bo = ( osmv_bind_obj_t * ) h_bind;
- osm_vendor_t const *p_vend = p_bo->p_vendor;
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ osm_vendor_t const *p_vend = p_bo->p_vendor;
- if (p_bo->is_closing != TRUE)
- {
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_put );
+ if (p_bo->is_closing != TRUE) {
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_put);
- CL_ASSERT( p_vw );
- CL_ASSERT( p_vw->p_mad);
+ CL_ASSERT(p_vw);
+ CL_ASSERT(p_vw->p_mad);
- if ( osm_log_get_level( p_vend->p_log ) >= OSM_LOG_DEBUG )
- {
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_put: " "Retiring MAD %p.\n", p_vw->p_mad );
- }
+ if (osm_log_get_level(p_vend->p_log) >= OSM_LOG_DEBUG) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_put: " "Retiring MAD %p.\n",
+ p_vw->p_mad);
+ }
- free( p_vw->p_mad );
- p_vw->p_mad = NULL;
+ free(p_vw->p_mad);
+ p_vw->p_mad = NULL;
- OSM_LOG_EXIT( p_vend->p_log );
- }
+ OSM_LOG_EXIT(p_vend->p_log);
+ }
}
/*
@@ -603,19 +560,17 @@ osm_vendor_put(
* housekeeping functions such as address vector updates.
*/
-ib_api_status_t
-osm_vendor_local_lid_change(
- IN osm_bind_handle_t h_bind )
+ib_api_status_t osm_vendor_local_lid_change(IN osm_bind_handle_t h_bind)
{
- osm_vendor_t const *p_vend = ( ( osmv_bind_obj_t * ) h_bind )->p_vendor;
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_local_lid_change );
+ osm_vendor_t const *p_vend = ((osmv_bind_obj_t *) h_bind)->p_vendor;
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_local_lid_change);
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_local_lid_change: " "Change of LID.\n" );
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_local_lid_change: " "Change of LID.\n");
- OSM_LOG_EXIT( p_vend->p_log );
+ OSM_LOG_EXIT(p_vend->p_log);
- return( IB_SUCCESS );
+ return (IB_SUCCESS);
}
@@ -626,37 +581,33 @@ osm_vendor_local_lid_change(
* according to the value given (TRUE or FALSE).
*/
#if !(defined(OSM_VENDOR_INTF_TS_NO_VAPI) || defined(OSM_VENDOR_INTF_SIM) || defined(OSM_VENDOR_INTF_TS))
-void
-osm_vendor_set_sm(
- IN osm_bind_handle_t h_bind,
- IN boolean_t is_sm_val )
+void osm_vendor_set_sm(IN osm_bind_handle_t h_bind, IN boolean_t is_sm_val)
{
- osmv_bind_obj_t *p_bo = ( osmv_bind_obj_t * ) h_bind;
- osm_vendor_t const *p_vend = p_bo->p_vendor;
- VAPI_ret_t status;
- VAPI_hca_attr_t attr_mod;
- VAPI_hca_attr_mask_t attr_mask;
-
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_set_sm );
-
- memset( &attr_mod, 0, sizeof( attr_mod ) );
- memset( &attr_mask, 0, sizeof( attr_mask ) );
-
- attr_mod.is_sm = is_sm_val;
- attr_mask = HCA_ATTR_IS_SM;
-
- status =
- VAPI_modify_hca_attr( p_bo->hca_hndl, p_bo->port_num, &attr_mod,
- &attr_mask );
- if ( status != VAPI_OK )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_set_sm: ERR 7312: "
- "Unable set 'IS_SM' bit to:%u in port attributes (%d).\n",
- is_sm_val, status );
- }
-
- OSM_LOG_EXIT( p_vend->p_log );
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ osm_vendor_t const *p_vend = p_bo->p_vendor;
+ VAPI_ret_t status;
+ VAPI_hca_attr_t attr_mod;
+ VAPI_hca_attr_mask_t attr_mask;
+
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_set_sm);
+
+ memset(&attr_mod, 0, sizeof(attr_mod));
+ memset(&attr_mask, 0, sizeof(attr_mask));
+
+ attr_mod.is_sm = is_sm_val;
+ attr_mask = HCA_ATTR_IS_SM;
+
+ status =
+ VAPI_modify_hca_attr(p_bo->hca_hndl, p_bo->port_num, &attr_mod,
+ &attr_mask);
+ if (status != VAPI_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_set_sm: ERR 7312: "
+ "Unable set 'IS_SM' bit to:%u in port attributes (%d).\n",
+ is_sm_val, status);
+ }
+
+ OSM_LOG_EXIT(p_vend->p_log);
}
#endif
@@ -669,54 +620,53 @@ osm_vendor_set_sm(
* (2) Destroy the associated data structures
*/
-static void
-__osm_vendor_internal_unbind(osm_bind_handle_t h_bind)
+static void __osm_vendor_internal_unbind(osm_bind_handle_t h_bind)
{
- osmv_bind_obj_t* p_bo = (osmv_bind_obj_t*)h_bind;
- osm_log_t* p_log = p_bo->p_vendor->p_log;
-
- OSM_LOG_ENTER(p_log,__osm_vendor_internal_unbind);
-
- /* "notifying" all that from now on no new sends can be done */
- p_bo->txn_mgr.p_event_wheel->closing = TRUE;
-
- osmv_txn_lock(p_bo);
-
- /*
- the is_closing is set under lock we we know we only need to
- check for it after obtaining the lock
- */
- p_bo->is_closing = TRUE;
-
- /* notifying all sleeping rmpp sends to exit */
- osmv_txn_abort_rmpp_txns(h_bind);
-
- /* unlock the bo to allow for any residual mads to be dispatched */
- osmv_txn_unlock(p_bo);
- osm_log(p_log,OSM_LOG_DEBUG,
- "__osm_vendor_internal_unbind: destroying transport mgr.. \n");
- /* wait for the receiver thread to exit */
- osmv_transport_done(h_bind);
-
- /* lock to avoid any collissions while we cleanup the structs */
- osmv_txn_lock(p_bo);
- osm_log(p_log,OSM_LOG_DEBUG,
- "__osm_vendor_internal_unbind: destroying txn mgr.. \n");
- osmv_txnmgr_done(h_bind);
- osm_log(p_log,OSM_LOG_DEBUG,
- "__osm_vendor_internal_unbind: destroying bind lock.. \n");
- osmv_txn_unlock(p_bo);
-
- /*
- we intentionally let the p_bo and its lock leak -
- as we did not implement a way to track active bind handles provided to
- the client - and the client might use them
-
- cl_spinlock_destroy(&p_bo->lock);
- free(p_bo);
- */
-
- OSM_LOG_EXIT(p_log);
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ osm_log_t *p_log = p_bo->p_vendor->p_log;
+
+ OSM_LOG_ENTER(p_log, __osm_vendor_internal_unbind);
+
+ /* "notifying" all that from now on no new sends can be done */
+ p_bo->txn_mgr.p_event_wheel->closing = TRUE;
+
+ osmv_txn_lock(p_bo);
+
+ /*
+ the is_closing is set under lock we we know we only need to
+ check for it after obtaining the lock
+ */
+ p_bo->is_closing = TRUE;
+
+ /* notifying all sleeping rmpp sends to exit */
+ osmv_txn_abort_rmpp_txns(h_bind);
+
+ /* unlock the bo to allow for any residual mads to be dispatched */
+ osmv_txn_unlock(p_bo);
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "__osm_vendor_internal_unbind: destroying transport mgr.. \n");
+ /* wait for the receiver thread to exit */
+ osmv_transport_done(h_bind);
+
+ /* lock to avoid any collissions while we cleanup the structs */
+ osmv_txn_lock(p_bo);
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "__osm_vendor_internal_unbind: destroying txn mgr.. \n");
+ osmv_txnmgr_done(h_bind);
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "__osm_vendor_internal_unbind: destroying bind lock.. \n");
+ osmv_txn_unlock(p_bo);
+
+ /*
+ we intentionally let the p_bo and its lock leak -
+ as we did not implement a way to track active bind handles provided to
+ the client - and the client might use them
+
+ cl_spinlock_destroy(&p_bo->lock);
+ free(p_bo);
+ */
+
+ OSM_LOG_EXIT(p_log);
}
/*
@@ -727,104 +677,94 @@ __osm_vendor_internal_unbind(osm_bind_handle_t h_bind)
*/
static ib_api_status_t
-__osmv_get_send_txn(IN osm_bind_handle_t h_bind,
- IN osm_madw_t* const p_madw,
- IN boolean_t is_rmpp,
- IN boolean_t resp_expected,
- OUT osmv_txn_ctx_t **pp_txn)
+__osmv_get_send_txn(IN osm_bind_handle_t h_bind,
+ IN osm_madw_t * const p_madw,
+ IN boolean_t is_rmpp,
+ IN boolean_t resp_expected, OUT osmv_txn_ctx_t ** pp_txn)
{
- ib_api_status_t ret;
- uint64_t tid, key;
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t*)h_bind;
- ib_mad_t *p_mad = osm_madw_get_mad_ptr(p_madw);
-
- OSM_LOG_ENTER(p_bo->p_vendor->p_log, __osmv_get_send_txn);
- CL_ASSERT(NULL != pp_txn);
-
- key = tid = cl_ntoh64(p_mad->trans_id);
- if (TRUE == resp_expected)
- {
- /* Create a unique identifier at the requester side */
- key = osmv_txn_uniq_key(tid);
- }
-
- /* We must run under a transaction framework */
- ret = osmv_txn_lookup(h_bind, key, pp_txn);
- if (IB_NOT_FOUND == ret)
- {
- /* Generally, we start a new transaction */
- ret = osmv_txn_init(h_bind, tid, key, pp_txn);
- if (IB_SUCCESS != ret)
- {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "__osmv_get_send_txn: ERR 7313: "
- "The transaction id=0x%llX failed to init.\n", tid);
- goto get_send_txn_done;
- }
- }
- else
- {
- CL_ASSERT(NULL != *pp_txn);
- /* The transaction context exists.
- * This is legal only if I am going to return an
- * (RMPP?) reply to an RMPP request sent by the other part
- * (double-sided RMPP transfer)
- */
- if (FALSE == is_rmpp || FALSE == osmv_txn_is_rmpp_init_by_peer(*pp_txn))
- {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "__osmv_get_send_txn: ERR 7314: "
- "The transaction id=0x%llX is not unique. Send failed.\n", tid);
-
- ret = IB_INVALID_SETTING;
- goto get_send_txn_done;
- }
-
- if (TRUE == resp_expected)
- {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "__osmv_get_send_txn: ERR 7315: "
- "The transaction id=%llX can't expect a response. Send failed.\n",
- tid);
-
- ret = IB_INVALID_PARAMETER;
- goto get_send_txn_done;
- }
- }
-
- if (TRUE == is_rmpp)
- {
- ret = osmv_txn_init_rmpp_sender(h_bind, *pp_txn, p_madw);
- if (IB_SUCCESS != ret)
- {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "__osmv_get_send_txn: ERR 7316: "
- "The transaction id=%llX failed to init the rmpp mad. Send failed.\n",
- tid);
- osmv_txn_done(h_bind, tid, FALSE);
- goto get_send_txn_done;
- }
- }
-
- /* Save a reference to the MAD in the txn context
- * We'll need to match it in two cases:
- * (1) When the response is returned, if I am the requester
- * (2) In RMPP retransmissions
- */
- osmv_txn_set_madw(*pp_txn, p_madw);
-
- get_send_txn_done:
- OSM_LOG_EXIT(p_bo->p_vendor->p_log);
-
- return ret;
+ ib_api_status_t ret;
+ uint64_t tid, key;
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ ib_mad_t *p_mad = osm_madw_get_mad_ptr(p_madw);
+
+ OSM_LOG_ENTER(p_bo->p_vendor->p_log, __osmv_get_send_txn);
+ CL_ASSERT(NULL != pp_txn);
+
+ key = tid = cl_ntoh64(p_mad->trans_id);
+ if (TRUE == resp_expected) {
+ /* Create a unique identifier at the requester side */
+ key = osmv_txn_uniq_key(tid);
+ }
+
+ /* We must run under a transaction framework */
+ ret = osmv_txn_lookup(h_bind, key, pp_txn);
+ if (IB_NOT_FOUND == ret) {
+ /* Generally, we start a new transaction */
+ ret = osmv_txn_init(h_bind, tid, key, pp_txn);
+ if (IB_SUCCESS != ret) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "__osmv_get_send_txn: ERR 7313: "
+ "The transaction id=0x%llX failed to init.\n",
+ tid);
+ goto get_send_txn_done;
+ }
+ } else {
+ CL_ASSERT(NULL != *pp_txn);
+ /* The transaction context exists.
+ * This is legal only if I am going to return an
+ * (RMPP?) reply to an RMPP request sent by the other part
+ * (double-sided RMPP transfer)
+ */
+ if (FALSE == is_rmpp
+ || FALSE == osmv_txn_is_rmpp_init_by_peer(*pp_txn)) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "__osmv_get_send_txn: ERR 7314: "
+ "The transaction id=0x%llX is not unique. Send failed.\n",
+ tid);
+
+ ret = IB_INVALID_SETTING;
+ goto get_send_txn_done;
+ }
+
+ if (TRUE == resp_expected) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "__osmv_get_send_txn: ERR 7315: "
+ "The transaction id=%llX can't expect a response. Send failed.\n",
+ tid);
+
+ ret = IB_INVALID_PARAMETER;
+ goto get_send_txn_done;
+ }
+ }
+
+ if (TRUE == is_rmpp) {
+ ret = osmv_txn_init_rmpp_sender(h_bind, *pp_txn, p_madw);
+ if (IB_SUCCESS != ret) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "__osmv_get_send_txn: ERR 7316: "
+ "The transaction id=%llX failed to init the rmpp mad. Send failed.\n",
+ tid);
+ osmv_txn_done(h_bind, tid, FALSE);
+ goto get_send_txn_done;
+ }
+ }
+
+ /* Save a reference to the MAD in the txn context
+ * We'll need to match it in two cases:
+ * (1) When the response is returned, if I am the requester
+ * (2) In RMPP retransmissions
+ */
+ osmv_txn_set_madw(*pp_txn, p_madw);
+
+ get_send_txn_done:
+ OSM_LOG_EXIT(p_bo->p_vendor->p_log);
+
+ return ret;
}
/**********************************************************************
**********************************************************************/
-void
-osm_vendor_set_debug(
- IN osm_vendor_t* const p_vend,
- IN int32_t level )
+void osm_vendor_set_debug(IN osm_vendor_t * const p_vend, IN int32_t level)
{
}
diff --git a/opensm/libvendor/osm_vendor_mlx_anafa.c b/opensm/libvendor/osm_vendor_mlx_anafa.c
index 722e446..bc79af8 100644
--- a/opensm/libvendor/osm_vendor_mlx_anafa.c
+++ b/opensm/libvendor/osm_vendor_mlx_anafa.c
@@ -33,10 +33,9 @@
*
*/
-
#if HAVE_CONFIG_H
# include <config.h>
-#endif /* HAVE_CONFIG_H */
+#endif /* HAVE_CONFIG_H */
#include <sys/ioctl.h>
#include <stdlib.h>
@@ -46,8 +45,6 @@
#include <fcntl.h>
#include <errno.h>
-
-
#include <vendor/osm_vendor_mlx.h>
#include <vendor/osm_vendor_mlx_transport.h>
#include <vendor/osm_vendor_mlx_transport_anafa.h>
@@ -61,14 +58,12 @@
* FORWARD REFERENCES
*/
static ib_api_status_t
-__osmv_get_send_txn (IN osm_bind_handle_t h_bind,
- IN osm_madw_t * const p_madw,
- IN boolean_t is_rmpp,
- IN boolean_t resp_expected,
- OUT osmv_txn_ctx_t ** pp_txn);
+__osmv_get_send_txn(IN osm_bind_handle_t h_bind,
+ IN osm_madw_t * const p_madw,
+ IN boolean_t is_rmpp,
+ IN boolean_t resp_expected, OUT osmv_txn_ctx_t ** pp_txn);
-static void
- __osm_vendor_internal_unbind (osm_bind_handle_t h_bind);
+static void __osm_vendor_internal_unbind(osm_bind_handle_t h_bind);
/*
* NAME osm_vendor_new
@@ -76,30 +71,30 @@ static void
* DESCRIPTION Create and Initialize the osm_vendor_t Object
*/
-osm_vendor_t *
-osm_vendor_new (IN osm_log_t * const p_log, IN const uint32_t timeout)
+osm_vendor_t *osm_vendor_new(IN osm_log_t * const p_log,
+ IN const uint32_t timeout)
{
ib_api_status_t status;
osm_vendor_t *p_vend;
- OSM_LOG_ENTER (p_log, osm_vendor_new);
+ OSM_LOG_ENTER(p_log, osm_vendor_new);
- CL_ASSERT (p_log);
+ CL_ASSERT(p_log);
- p_vend = malloc (sizeof (*p_vend));
+ p_vend = malloc(sizeof(*p_vend));
if (p_vend != NULL) {
- memset(p_vend, 0, sizeof (*p_vend));
- status = osm_vendor_init (p_vend, p_log, timeout);
+ memset(p_vend, 0, sizeof(*p_vend));
+ status = osm_vendor_init(p_vend, p_log, timeout);
if (status != IB_SUCCESS) {
- osm_vendor_delete (&p_vend);
+ osm_vendor_delete(&p_vend);
}
} else {
- osm_log (p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_new: ERR 7401: "
- "Fail to allocate vendor object.\n");
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_new: ERR 7401: "
+ "Fail to allocate vendor object.\n");
}
- OSM_LOG_EXIT (p_log);
+ OSM_LOG_EXIT(p_log);
return (p_vend);
}
@@ -109,52 +104,52 @@ osm_vendor_new (IN osm_log_t * const p_log, IN const uint32_t timeout)
* DESCRIPTION Delete all the binds behind the vendor + free the vendor object
*/
-void
-osm_vendor_delete (IN osm_vendor_t ** const pp_vend)
+void osm_vendor_delete(IN osm_vendor_t ** const pp_vend)
{
cl_list_item_t *p_item;
cl_list_obj_t *p_obj;
osm_bind_handle_t bind_h;
osm_log_t *p_log;
- OSM_LOG_ENTER ((*pp_vend)->p_log, osm_vendor_delete);
+ OSM_LOG_ENTER((*pp_vend)->p_log, osm_vendor_delete);
p_log = (*pp_vend)->p_log;
/* go over the bind handles , unbind them and remove from list */
/* Note that if we reached here due to problem in the init, then
- the bind_handles list is not initialized yet */
- if ((*pp_vend)->bind_handles.state == CL_INITIALIZED)
- {
- p_item = cl_qlist_remove_head (&((*pp_vend)->bind_handles));
- while (p_item != cl_qlist_end (&((*pp_vend)->bind_handles))) {
-
- p_obj = PARENT_STRUCT (p_item, cl_list_obj_t, list_item);
- bind_h = (osm_bind_handle_t *) cl_qlist_obj (p_obj);
- osm_log (p_log, OSM_LOG_DEBUG,
- "osm_vendor_delete: unbinding bind_h:%p \n", bind_h);
-
- __osm_vendor_internal_unbind (bind_h);
-
- free (p_obj);
- /* removing from list */
- p_item = cl_qlist_remove_head (&((*pp_vend)->bind_handles));
- }
- }
+ the bind_handles list is not initialized yet */
+ if ((*pp_vend)->bind_handles.state == CL_INITIALIZED) {
+ p_item = cl_qlist_remove_head(&((*pp_vend)->bind_handles));
+ while (p_item != cl_qlist_end(&((*pp_vend)->bind_handles))) {
+
+ p_obj = PARENT_STRUCT(p_item, cl_list_obj_t, list_item);
+ bind_h = (osm_bind_handle_t *) cl_qlist_obj(p_obj);
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "osm_vendor_delete: unbinding bind_h:%p \n",
+ bind_h);
+
+ __osm_vendor_internal_unbind(bind_h);
+
+ free(p_obj);
+ /* removing from list */
+ p_item =
+ cl_qlist_remove_head(&((*pp_vend)->bind_handles));
+ }
+ }
if (NULL != ((*pp_vend)->p_transport_info)) {
- free ((*pp_vend)->p_transport_info);
+ free((*pp_vend)->p_transport_info);
(*pp_vend)->p_transport_info = NULL;
}
/* remove the packet randomizer object */
if ((*pp_vend)->run_randomizer == TRUE)
- osm_pkt_randomizer_destroy (&((*pp_vend)->p_pkt_randomizer),
- p_log);
+ osm_pkt_randomizer_destroy(&((*pp_vend)->p_pkt_randomizer),
+ p_log);
- free (*pp_vend);
+ free(*pp_vend);
*pp_vend = NULL;
- OSM_LOG_EXIT (p_log);
+ OSM_LOG_EXIT(p_log);
}
/*
@@ -164,39 +159,38 @@ osm_vendor_delete (IN osm_vendor_t ** const pp_vend)
*/
ib_api_status_t
-osm_vendor_init (IN osm_vendor_t * const p_vend,
- IN osm_log_t * const p_log,
- IN const uint32_t timeout)
+osm_vendor_init(IN osm_vendor_t * const p_vend,
+ IN osm_log_t * const p_log, IN const uint32_t timeout)
{
ib_api_status_t status = IB_SUCCESS;
char device_file[16];
int device_fd;
- OSM_LOG_ENTER (p_log, osm_vendor_init);
+ OSM_LOG_ENTER(p_log, osm_vendor_init);
p_vend->p_log = p_log;
p_vend->resp_timeout = timeout;
p_vend->ttime_timeout = timeout * OSMV_TXN_TIMEOUT_FACTOR;
p_vend->p_transport_info = (osmv_TOPSPIN_ANAFA_transport_info_t *)
- malloc (sizeof (osmv_TOPSPIN_ANAFA_transport_info_t));
+ malloc(sizeof(osmv_TOPSPIN_ANAFA_transport_info_t));
if (!p_vend->p_transport_info) {
return IB_ERROR;
}
- memset(p_vend->p_transport_info, 0, sizeof (osmv_TOPSPIN_ANAFA_transport_info_t));
+ memset(p_vend->p_transport_info, 0,
+ sizeof(osmv_TOPSPIN_ANAFA_transport_info_t));
/* update the run_randomizer flag */
- if (getenv ("OSM_PKT_DROP_RATE") != NULL
- && atol (getenv ("OSM_PKT_DROP_RATE")) != 0) {
+ if (getenv("OSM_PKT_DROP_RATE") != NULL
+ && atol(getenv("OSM_PKT_DROP_RATE")) != 0) {
/* if the OSM_PKT_DROP_RATE global variable is defined
to a non-zero value -
then the randomizer should be called.
Need to create the packet randomizer object */
p_vend->run_randomizer = TRUE;
status =
- osm_pkt_randomizer_init (&(p_vend->p_pkt_randomizer),
- p_log);
+ osm_pkt_randomizer_init(&(p_vend->p_pkt_randomizer), p_log);
if (status != IB_SUCCESS)
return status;
} else {
@@ -205,22 +199,23 @@ osm_vendor_init (IN osm_vendor_t * const p_vend,
}
/* open TopSpin file device */
- sprintf (device_file, "/dev/ts_ua0");
- device_fd = open ("/dev/ts_ua0", O_RDWR);
+ sprintf(device_file, "/dev/ts_ua0");
+ device_fd = open("/dev/ts_ua0", O_RDWR);
if (device_fd < 0) {
- fprintf (stderr, "Fatal: Fail to open the file:%s(%d)\n",
- device_file, errno);
+ fprintf(stderr, "Fatal: Fail to open the file:%s(%d)\n",
+ device_file, errno);
return IB_ERROR;
}
((osmv_TOPSPIN_ANAFA_transport_info_t *) p_vend->p_transport_info)->
device_fd = device_fd;
- cl_qlist_init (&p_vend->bind_handles);
+ cl_qlist_init(&p_vend->bind_handles);
- OSM_LOG_EXIT (p_log);
+ OSM_LOG_EXIT(p_log);
return (IB_SUCCESS);
}
+
/*
* NAME osm_vendor_bind
*
@@ -228,106 +223,106 @@ osm_vendor_init (IN osm_vendor_t * const p_vend,
*/
osm_bind_handle_t
-osm_vendor_bind (IN osm_vendor_t * const p_vend,
- IN osm_bind_info_t * const p_bind_info,
- IN osm_mad_pool_t * const p_mad_pool,
- IN osm_vend_mad_recv_callback_t mad_recv_callback,
- IN osm_vend_mad_send_err_callback_t send_err_callback,
- IN void *context)
+osm_vendor_bind(IN osm_vendor_t * const p_vend,
+ IN osm_bind_info_t * const p_bind_info,
+ IN osm_mad_pool_t * const p_mad_pool,
+ IN osm_vend_mad_recv_callback_t mad_recv_callback,
+ IN osm_vend_mad_send_err_callback_t send_err_callback,
+ IN void *context)
{
osmv_bind_obj_t *p_bo;
cl_status_t cl_st;
cl_list_obj_t *p_obj;
- uint8_t hca_idx = 0;
+ uint8_t hca_idx = 0;
if (NULL == p_vend || NULL == p_bind_info || NULL == p_mad_pool
|| NULL == mad_recv_callback || NULL == send_err_callback) {
- osm_log (p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 7402: "
- "NULL parameter passed in: p_vend=%p p_bind_info=%p p_mad_pool=%p recv_cb=%p send_err_cb=%p\n",
- p_vend, p_bind_info, p_mad_pool, mad_recv_callback,
- send_err_callback);
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 7402: "
+ "NULL parameter passed in: p_vend=%p p_bind_info=%p p_mad_pool=%p recv_cb=%p send_err_cb=%p\n",
+ p_vend, p_bind_info, p_mad_pool, mad_recv_callback,
+ send_err_callback);
return OSM_BIND_INVALID_HANDLE;
}
- p_bo = malloc (sizeof (osmv_bind_obj_t));
+ p_bo = malloc(sizeof(osmv_bind_obj_t));
if (NULL == p_bo) {
- osm_log (p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 7403: "
- "could not allocate the bind object\n");
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 7403: "
+ "could not allocate the bind object\n");
return OSM_BIND_INVALID_HANDLE;
}
- memset (p_bo, 0, sizeof (osmv_bind_obj_t));
+ memset(p_bo, 0, sizeof(osmv_bind_obj_t));
p_bo->p_vendor = p_vend;
p_bo->recv_cb = mad_recv_callback;
p_bo->send_err_cb = send_err_callback;
p_bo->cb_context = context;
p_bo->p_osm_pool = p_mad_pool;
- p_bo->port_num = 1; /* anafa2 has one port */
- p_bo->hca_hndl = 0; /* only one ca on anafa system */
+ p_bo->port_num = 1; /* anafa2 has one port */
+ p_bo->hca_hndl = 0; /* only one ca on anafa system */
/* obtain the hca name and port num from the guid */
- osm_log (p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "osm_vendor_bind: "
- "Finding CA and Port that owns port guid 0x%" PRIx64 ".\n",
- cl_ntoh64 (p_bind_info->port_guid));
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_bind: "
+ "Finding CA and Port that owns port guid 0x%" PRIx64 ".\n",
+ cl_ntoh64(p_bind_info->port_guid));
p_bo->is_closing = FALSE;
- cl_spinlock_construct (&(p_bo->lock));
- cl_st = cl_spinlock_init (&(p_bo->lock));
+ cl_spinlock_construct(&(p_bo->lock));
+ cl_st = cl_spinlock_init(&(p_bo->lock));
if (cl_st != CL_SUCCESS) {
- osm_log (p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 7405: "
- "could not initialize the spinlock ...\n");
- free (p_bo);
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 7405: "
+ "could not initialize the spinlock ...\n");
+ free(p_bo);
return OSM_BIND_INVALID_HANDLE;
}
- osm_log (p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "osm_vendor_bind: osmv_txnmgr_init ... \n");
- if (osmv_txnmgr_init (&p_bo->txn_mgr, p_vend->p_log, &(p_bo->lock)) !=
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_bind: osmv_txnmgr_init ... \n");
+ if (osmv_txnmgr_init(&p_bo->txn_mgr, p_vend->p_log, &(p_bo->lock)) !=
IB_SUCCESS) {
- osm_log (p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 7406: "
- "osmv_txnmgr_init failed \n");
- cl_spinlock_destroy (&p_bo->lock);
- free (p_bo);
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 7406: "
+ "osmv_txnmgr_init failed \n");
+ cl_spinlock_destroy(&p_bo->lock);
+ free(p_bo);
return OSM_BIND_INVALID_HANDLE;
}
/* Do the real job! (Transport-dependent) */
if (IB_SUCCESS !=
- osmv_transport_init (p_bind_info, OSMV_ANAFA_ID, hca_idx, p_bo)) {
- osm_log (p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 7407: "
- "osmv_transport_init failed \n");
- osmv_txnmgr_done ((osm_bind_handle_t) p_bo);
- cl_spinlock_destroy (&p_bo->lock);
- free (p_bo);
+ osmv_transport_init(p_bind_info, OSMV_ANAFA_ID, hca_idx, p_bo)) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 7407: "
+ "osmv_transport_init failed \n");
+ osmv_txnmgr_done((osm_bind_handle_t) p_bo);
+ cl_spinlock_destroy(&p_bo->lock);
+ free(p_bo);
return OSM_BIND_INVALID_HANDLE;
}
/* insert bind handle into db */
- p_obj = malloc (sizeof (cl_list_obj_t));
+ p_obj = malloc(sizeof(cl_list_obj_t));
if (NULL == p_obj) {
- osm_log (p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 7408: "
- "osm_vendor_bind: could not allocate the list object\n");
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 7408: "
+ "osm_vendor_bind: could not allocate the list object\n");
- osmv_transport_done (p_bo->p_transp_mgr);
- osmv_txnmgr_done ((osm_bind_handle_t) p_bo);
- cl_spinlock_destroy (&p_bo->lock);
- free (p_bo);
+ osmv_transport_done(p_bo->p_transp_mgr);
+ osmv_txnmgr_done((osm_bind_handle_t) p_bo);
+ cl_spinlock_destroy(&p_bo->lock);
+ free(p_bo);
return OSM_BIND_INVALID_HANDLE;
}
if (p_obj)
- memset (p_obj, 0, sizeof (cl_list_obj_t));
- cl_qlist_set_obj (p_obj, p_bo);
+ memset(p_obj, 0, sizeof(cl_list_obj_t));
+ cl_qlist_set_obj(p_obj, p_bo);
- cl_qlist_insert_head (&p_vend->bind_handles, &p_obj->list_item);
+ cl_qlist_insert_head(&p_vend->bind_handles, &p_obj->list_item);
return (osm_bind_handle_t) p_bo;
}
@@ -338,8 +333,7 @@ osm_vendor_bind (IN osm_vendor_t * const p_vend,
* DESCRIPTION Destroy the bind object and remove it from the vendor's list
*/
-void
-osm_vendor_unbind (IN osm_bind_handle_t h_bind)
+void osm_vendor_unbind(IN osm_bind_handle_t h_bind)
{
osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
osm_log_t *p_log = p_bo->p_vendor->p_log;
@@ -348,27 +342,27 @@ osm_vendor_unbind (IN osm_bind_handle_t h_bind)
cl_qlist_t *const p_bh_list =
(cl_qlist_t * const)&p_bo->p_vendor->bind_handles;
- OSM_LOG_ENTER (p_log, osm_vendor_unbind);
+ OSM_LOG_ENTER(p_log, osm_vendor_unbind);
/* go over all the items in the list and remove the specific item */
- p_item = cl_qlist_head (&p_bo->p_vendor->bind_handles);
- while (p_item != cl_qlist_end (&p_bo->p_vendor->bind_handles)) {
- p_obj = PARENT_STRUCT (p_item, cl_list_obj_t, list_item);
- if (cl_qlist_obj (p_obj) == h_bind) {
+ p_item = cl_qlist_head(&p_bo->p_vendor->bind_handles);
+ while (p_item != cl_qlist_end(&p_bo->p_vendor->bind_handles)) {
+ p_obj = PARENT_STRUCT(p_item, cl_list_obj_t, list_item);
+ if (cl_qlist_obj(p_obj) == h_bind) {
break;
}
- p_item_tmp = cl_qlist_next (p_item);
+ p_item_tmp = cl_qlist_next(p_item);
p_item = p_item_tmp;
}
- CL_ASSERT (p_item != cl_qlist_end (p_bh_list));
+ CL_ASSERT(p_item != cl_qlist_end(p_bh_list));
- cl_qlist_remove_item (p_bh_list, p_item);
- free (p_obj);
+ cl_qlist_remove_item(p_bh_list, p_item);
+ free(p_obj);
- __osm_vendor_internal_unbind (h_bind);
+ __osm_vendor_internal_unbind(h_bind);
- OSM_LOG_EXIT (p_bo->p_vendor->p_log);
+ OSM_LOG_EXIT(p_bo->p_vendor->p_log);
}
/*
@@ -377,19 +371,18 @@ osm_vendor_unbind (IN osm_bind_handle_t h_bind)
* DESCRIPTION Allocate the space for a new MAD
*/
-ib_mad_t *
-osm_vendor_get (IN osm_bind_handle_t h_bind,
- IN const uint32_t mad_size,
- IN osm_vend_wrap_t * const p_vw)
+ib_mad_t *osm_vendor_get(IN osm_bind_handle_t h_bind,
+ IN const uint32_t mad_size,
+ IN osm_vend_wrap_t * const p_vw)
{
ib_mad_t *p_mad;
osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
osm_vendor_t const *p_vend = p_bo->p_vendor;
uint32_t act_mad_size;
- OSM_LOG_ENTER (p_vend->p_log, osm_vendor_get);
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_get);
- CL_ASSERT (p_vw);
+ CL_ASSERT(p_vw);
if (mad_size < MAD_BLOCK_SIZE) {
/* Stupid, but the applications want that! */
@@ -399,25 +392,25 @@ osm_vendor_get (IN osm_bind_handle_t h_bind,
}
/* allocate it */
- p_mad = (ib_mad_t *) malloc (act_mad_size);
+ p_mad = (ib_mad_t *) malloc(act_mad_size);
if (p_mad == NULL) {
- osm_log (p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get: ERR 7409: "
- "Error Obtaining MAD buffer.\n");
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get: ERR 7409: "
+ "Error Obtaining MAD buffer.\n");
goto Exit;
}
- memset (p_mad, 0, act_mad_size);
+ memset(p_mad, 0, act_mad_size);
- if (osm_log_get_level (p_vend->p_log) >= OSM_LOG_DEBUG) {
- osm_log (p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_get: "
- "Allocated MAD %p, size = %u.\n", p_mad, act_mad_size);
+ if (osm_log_get_level(p_vend->p_log) >= OSM_LOG_DEBUG) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_get: "
+ "Allocated MAD %p, size = %u.\n", p_mad, act_mad_size);
}
p_vw->p_mad = p_mad;
Exit:
- OSM_LOG_EXIT (p_vend->p_log);
+ OSM_LOG_EXIT(p_vend->p_log);
return (p_mad);
}
@@ -434,9 +427,8 @@ osm_vendor_get (IN osm_bind_handle_t h_bind,
*/
ib_api_status_t
-osm_vendor_send (IN osm_bind_handle_t h_bind,
- IN osm_madw_t * const p_madw,
- IN boolean_t const resp_expected)
+osm_vendor_send(IN osm_bind_handle_t h_bind,
+ IN osm_madw_t * const p_madw, IN boolean_t const resp_expected)
{
ib_api_status_t ret = IB_SUCCESS;
osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
@@ -444,37 +436,37 @@ osm_vendor_send (IN osm_bind_handle_t h_bind,
osmv_txn_ctx_t *p_txn = NULL;
ib_mad_t *p_mad;
- OSM_LOG_ENTER (p_bo->p_vendor->p_log, osm_vendor_send);
+ OSM_LOG_ENTER(p_bo->p_vendor->p_log, osm_vendor_send);
if (NULL == h_bind || NULL == p_madw ||
- NULL == (p_mad = osm_madw_get_mad_ptr (p_madw)) ||
- NULL == osm_madw_get_mad_addr_ptr (p_madw)) {
+ NULL == (p_mad = osm_madw_get_mad_ptr(p_madw)) ||
+ NULL == osm_madw_get_mad_addr_ptr(p_madw)) {
return IB_INVALID_PARAMETER;
}
is_rmpp = (p_madw->mad_size > MAD_BLOCK_SIZE
- || osmv_mad_is_rmpp (p_mad));
+ || osmv_mad_is_rmpp(p_mad));
is_rmpp_ds = (TRUE == is_rmpp && TRUE == resp_expected);
/* Make our operations with the send context atomic */
- osmv_txn_lock (p_bo);
+ osmv_txn_lock(p_bo);
if (TRUE == p_bo->is_closing) {
- osm_log (p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "osm_vendor_send: ERR 7410: "
- "The handle %p is being unbound, cannot send.\n",
- h_bind);
- ret = IB_INTERRUPTED;
- goto send_done;
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "osm_vendor_send: ERR 7410: "
+ "The handle %p is being unbound, cannot send.\n",
+ h_bind);
+ ret = IB_INTERRUPTED;
+ goto send_done;
}
if (TRUE == resp_expected || TRUE == is_rmpp) {
/* We must run under a transaction framework.
* Get the transaction object (old or new) */
- ret = __osmv_get_send_txn (h_bind, p_madw, is_rmpp,
- resp_expected, &p_txn);
+ ret = __osmv_get_send_txn(h_bind, p_madw, is_rmpp,
+ resp_expected, &p_txn);
if (IB_SUCCESS != ret) {
goto send_done;
}
@@ -486,52 +478,52 @@ osm_vendor_send (IN osm_bind_handle_t h_bind,
* The txn lock will be released each time the function sleeps
* and re-acquired when it wakes up
*/
- ret = osmv_rmpp_send_madw (h_bind, p_madw, p_txn, is_rmpp_ds);
+ ret = osmv_rmpp_send_madw(h_bind, p_madw, p_txn, is_rmpp_ds);
} else {
/* Do the job - single MAD!
* The call returns as soon as the MAD is put on the wire
*/
- ret = osmv_simple_send_madw (h_bind, p_madw, p_txn , FALSE); /* anafa2 */
+ ret = osmv_simple_send_madw(h_bind, p_madw, p_txn, FALSE); /* anafa2 */
}
if (IB_SUCCESS == ret) {
if ((TRUE == is_rmpp) && (FALSE == is_rmpp_ds)) {
/* For double-sided sends, the txn continues to live */
- osmv_txn_done (h_bind, osmv_txn_get_key (p_txn),
- FALSE /*not in callback */ );
+ osmv_txn_done(h_bind, osmv_txn_get_key(p_txn),
+ FALSE /*not in callback */ );
}
if (FALSE == resp_expected) {
- osm_mad_pool_put (p_bo->p_osm_pool, p_madw);
+ osm_mad_pool_put(p_bo->p_osm_pool, p_madw);
}
} else {
if (NULL != p_txn) {
- osmv_txn_done (h_bind, osmv_txn_get_key (p_txn),
- FALSE /*not in callback */ );
+ osmv_txn_done(h_bind, osmv_txn_get_key(p_txn),
+ FALSE /*not in callback */ );
}
- osm_log (p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "osm_vendor_send: ERR 7411: failed to send MADW %p\n",
- p_madw);
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "osm_vendor_send: ERR 7411: failed to send MADW %p\n",
+ p_madw);
if (TRUE == resp_expected) {
/* Change the status on the p_madw */
p_madw->status = ret;
/* Only the requester expects the error callback */
- p_bo->send_err_cb (p_bo->cb_context, p_madw);
+ p_bo->send_err_cb(p_bo->cb_context, p_madw);
} else {
/* put back the mad - it is useless ... */
- osm_mad_pool_put (p_bo->p_osm_pool, p_madw);
+ osm_mad_pool_put(p_bo->p_osm_pool, p_madw);
}
}
- send_done:
+ send_done:
- osmv_txn_unlock (p_bo);
+ osmv_txn_unlock(p_bo);
- OSM_LOG_EXIT (p_bo->p_vendor->p_log);
+ OSM_LOG_EXIT(p_bo->p_vendor->p_log);
return ret;
}
@@ -542,28 +534,28 @@ osm_vendor_send (IN osm_bind_handle_t h_bind,
*/
void
-osm_vendor_put (IN osm_bind_handle_t h_bind,
- IN osm_vend_wrap_t * const p_vw)
+osm_vendor_put(IN osm_bind_handle_t h_bind, IN osm_vend_wrap_t * const p_vw)
{
osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
osm_vendor_t const *p_vend = p_bo->p_vendor;
- OSM_LOG_ENTER (p_vend->p_log, osm_vendor_put);
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_put);
- CL_ASSERT (p_vw);
- CL_ASSERT (p_vw->p_mad);
+ CL_ASSERT(p_vw);
+ CL_ASSERT(p_vw->p_mad);
- if (osm_log_get_level (p_vend->p_log) >= OSM_LOG_DEBUG) {
- osm_log (p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_put: " "Retiring MAD %p.\n", p_vw->p_mad);
+ if (osm_log_get_level(p_vend->p_log) >= OSM_LOG_DEBUG) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_put: " "Retiring MAD %p.\n", p_vw->p_mad);
}
- free (p_vw->p_mad);
+ free(p_vw->p_mad);
p_vw->p_mad = NULL;
- OSM_LOG_EXIT (p_vend->p_log);
+ OSM_LOG_EXIT(p_vend->p_log);
}
+
/*
* NAME osm_vendor_local_lid_change
*
@@ -572,16 +564,15 @@ osm_vendor_put (IN osm_bind_handle_t h_bind,
* housekeeping functions such as address vector updates.
*/
-ib_api_status_t
-osm_vendor_local_lid_change (IN osm_bind_handle_t h_bind)
+ib_api_status_t osm_vendor_local_lid_change(IN osm_bind_handle_t h_bind)
{
osm_vendor_t const *p_vend = ((osmv_bind_obj_t *) h_bind)->p_vendor;
- OSM_LOG_ENTER (p_vend->p_log, osm_vendor_local_lid_change);
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_local_lid_change);
- osm_log (p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_local_lid_change: " "Change of LID.\n");
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_local_lid_change: " "Change of LID.\n");
- OSM_LOG_EXIT (p_vend->p_log);
+ OSM_LOG_EXIT(p_vend->p_log);
return (IB_SUCCESS);
@@ -593,10 +584,7 @@ osm_vendor_local_lid_change (IN osm_bind_handle_t h_bind)
* DESCRIPTION Modifies the port info for the bound port to set the "IS_SM" bit.
*/
-void
-osm_vendor_set_sm (
- IN osm_bind_handle_t h_bind,
- IN boolean_t is_sm_val )
+void osm_vendor_set_sm(IN osm_bind_handle_t h_bind, IN boolean_t is_sm_val)
{
osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
osm_vendor_t const *p_vend = p_bo->p_vendor;
@@ -604,23 +592,23 @@ osm_vendor_set_sm (
int ioctl_ret;
osm_ts_set_port_info_ioctl port_info;
- OSM_LOG_ENTER (p_vend->p_log, osm_vendor_set_sm);
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_set_sm);
- port_info.port = 0; /* anafa has only 1 port */
+ port_info.port = 0; /* anafa has only 1 port */
port_info.port_info.valid_fields = IB_PORT_IS_SM;
port_info.port_info.is_sm = is_sm_val;
p_mgr = (osmv_TOPSPIN_ANAFA_transport_mgr_t *) p_bo->p_transp_mgr;
- ioctl_ret = ioctl (p_mgr->device_fd, TS_IB_IOCSPORTINFO, &port_info);
+ ioctl_ret = ioctl(p_mgr->device_fd, TS_IB_IOCSPORTINFO, &port_info);
if (ioctl_ret < 0) {
- osm_log (p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_set_sm: ERR 7412: "
- "Unable set 'IS_SM' bit to:%u in port attributes (%d). errno=%d\n",
- is_sm_val, ioctl_ret, errno);
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_set_sm: ERR 7412: "
+ "Unable set 'IS_SM' bit to:%u in port attributes (%d). errno=%d\n",
+ is_sm_val, ioctl_ret, errno);
}
- OSM_LOG_EXIT (p_vend->p_log);
+ OSM_LOG_EXIT(p_vend->p_log);
}
/*
@@ -631,47 +619,46 @@ osm_vendor_set_sm (
* (2) Destroy the associated data structures
*/
-static void
-__osm_vendor_internal_unbind (osm_bind_handle_t h_bind)
+static void __osm_vendor_internal_unbind(osm_bind_handle_t h_bind)
{
osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
osm_log_t *p_log = p_bo->p_vendor->p_log;
- OSM_LOG_ENTER (p_log, __osm_vendor_internal_unbind);
+ OSM_LOG_ENTER(p_log, __osm_vendor_internal_unbind);
/* "notifying" all that from now on no new sends can be done */
- p_bo->txn_mgr.p_event_wheel->closing = TRUE;
+ p_bo->txn_mgr.p_event_wheel->closing = TRUE;
- osmv_txn_lock (p_bo);
+ osmv_txn_lock(p_bo);
p_bo->is_closing = TRUE;
/* notifying all sleeping rmpp sends to exit */
- osmv_txn_abort_rmpp_txns (h_bind);
+ osmv_txn_abort_rmpp_txns(h_bind);
/* frees all data in bind handle */
- osm_log (p_log, OSM_LOG_DEBUG,
- "__osm_vendor_internal_unbind: destroying transport mgr.. \n");
- osmv_txn_unlock(p_bo);
-
- osmv_transport_done (h_bind);
- osm_log (p_log, OSM_LOG_DEBUG,
- "__osm_vendor_internal_unbind: destroying txn mgr.. \n");
- osmv_txn_lock (p_bo);
- osmv_txnmgr_done (h_bind);
- osm_log (p_log, OSM_LOG_DEBUG,
- "__osm_vendor_internal_unbind: destroying bind lock.. \n");
-
- osmv_txn_unlock(p_bo);
- /*
- we intentionally let the p_bo and its lock leak -
- as we did not implement a way to track active bind handles provided to
- the client - and the client might use them
-
- cl_spinlock_destroy(&p_bo->lock);
- free(p_bo);
- */
-
- OSM_LOG_EXIT (p_log);
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "__osm_vendor_internal_unbind: destroying transport mgr.. \n");
+ osmv_txn_unlock(p_bo);
+
+ osmv_transport_done(h_bind);
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "__osm_vendor_internal_unbind: destroying txn mgr.. \n");
+ osmv_txn_lock(p_bo);
+ osmv_txnmgr_done(h_bind);
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "__osm_vendor_internal_unbind: destroying bind lock.. \n");
+
+ osmv_txn_unlock(p_bo);
+ /*
+ we intentionally let the p_bo and its lock leak -
+ as we did not implement a way to track active bind handles provided to
+ the client - and the client might use them
+
+ cl_spinlock_destroy(&p_bo->lock);
+ free(p_bo);
+ */
+
+ OSM_LOG_EXIT(p_log);
}
/*
@@ -682,57 +669,56 @@ __osm_vendor_internal_unbind (osm_bind_handle_t h_bind)
*/
static ib_api_status_t
-__osmv_get_send_txn (IN osm_bind_handle_t h_bind,
- IN osm_madw_t * const p_madw,
- IN boolean_t is_rmpp,
- IN boolean_t resp_expected,
- OUT osmv_txn_ctx_t ** pp_txn)
+__osmv_get_send_txn(IN osm_bind_handle_t h_bind,
+ IN osm_madw_t * const p_madw,
+ IN boolean_t is_rmpp,
+ IN boolean_t resp_expected, OUT osmv_txn_ctx_t ** pp_txn)
{
ib_api_status_t ret;
uint64_t tid, key;
osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
- ib_mad_t *p_mad = osm_madw_get_mad_ptr (p_madw);
+ ib_mad_t *p_mad = osm_madw_get_mad_ptr(p_madw);
- OSM_LOG_ENTER (p_bo->p_vendor->p_log, __osmv_get_send_txn);
- CL_ASSERT (NULL != pp_txn);
+ OSM_LOG_ENTER(p_bo->p_vendor->p_log, __osmv_get_send_txn);
+ CL_ASSERT(NULL != pp_txn);
- key = tid = cl_ntoh64 (p_mad->trans_id);
+ key = tid = cl_ntoh64(p_mad->trans_id);
if (TRUE == resp_expected) {
/* Create a unique identifier at the requester side */
- key = osmv_txn_uniq_key (tid);
+ key = osmv_txn_uniq_key(tid);
}
/* We must run under a transaction framework */
- ret = osmv_txn_lookup (h_bind, key, pp_txn);
+ ret = osmv_txn_lookup(h_bind, key, pp_txn);
if (IB_NOT_FOUND == ret) {
/* Generally, we start a new transaction */
- ret = osmv_txn_init (h_bind, tid, key, pp_txn);
+ ret = osmv_txn_init(h_bind, tid, key, pp_txn);
if (IB_SUCCESS != ret) {
goto get_send_txn_done;
}
} else {
- CL_ASSERT (NULL != *pp_txn);
+ CL_ASSERT(NULL != *pp_txn);
/* The transaction context exists.
* This is legal only if I am going to return an
* (RMPP?) reply to an RMPP request sent by the other part
* (double-sided RMPP transfer)
*/
if (FALSE == is_rmpp
- || FALSE == osmv_txn_is_rmpp_init_by_peer (*pp_txn)) {
- osm_log (p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "__osmv_get_send_txn: ERR 7413: "
- "The transaction id=0x%llX is not unique. Send failed.\n",
- tid);
+ || FALSE == osmv_txn_is_rmpp_init_by_peer(*pp_txn)) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "__osmv_get_send_txn: ERR 7413: "
+ "The transaction id=0x%llX is not unique. Send failed.\n",
+ tid);
ret = IB_INVALID_SETTING;
goto get_send_txn_done;
}
if (TRUE == resp_expected) {
- osm_log (p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "__osmv_get_send_txn: ERR 7414: "
- "The transaction id=%llX can\'t expect a response. Send failed.\n",
- tid);
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "__osmv_get_send_txn: ERR 7414: "
+ "The transaction id=%llX can\'t expect a response. Send failed.\n",
+ tid);
ret = IB_INVALID_PARAMETER;
goto get_send_txn_done;
@@ -740,9 +726,9 @@ __osmv_get_send_txn (IN osm_bind_handle_t h_bind,
}
if (TRUE == is_rmpp) {
- ret = osmv_txn_init_rmpp_sender (h_bind, *pp_txn, p_madw);
+ ret = osmv_txn_init_rmpp_sender(h_bind, *pp_txn, p_madw);
if (IB_SUCCESS != ret) {
- osmv_txn_done (h_bind, tid, FALSE);
+ osmv_txn_done(h_bind, tid, FALSE);
goto get_send_txn_done;
}
}
@@ -752,20 +738,17 @@ __osmv_get_send_txn (IN osm_bind_handle_t h_bind,
* (1) When the response is returned, if I am the requester
* (2) In RMPP retransmissions
*/
- osmv_txn_set_madw (*pp_txn, p_madw);
+ osmv_txn_set_madw(*pp_txn, p_madw);
get_send_txn_done:
- OSM_LOG_EXIT (p_bo->p_vendor->p_log);
+ OSM_LOG_EXIT(p_bo->p_vendor->p_log);
return ret;
}
/**********************************************************************
**********************************************************************/
-void
-osm_vendor_set_debug(
- IN osm_vendor_t* const p_vend,
- IN int32_t level )
+void osm_vendor_set_debug(IN osm_vendor_t * const p_vend, IN int32_t level)
{
}
diff --git a/opensm/libvendor/osm_vendor_mlx_dispatcher.c b/opensm/libvendor/osm_vendor_mlx_dispatcher.c
index 65309ef..968a914 100644
--- a/opensm/libvendor/osm_vendor_mlx_dispatcher.c
+++ b/opensm/libvendor/osm_vendor_mlx_dispatcher.c
@@ -35,7 +35,7 @@
#if HAVE_CONFIG_H
# include <config.h>
-#endif /* HAVE_CONFIG_H */
+#endif /* HAVE_CONFIG_H */
#include <string.h>
#include <vendor/osm_vendor_mlx.h>
@@ -47,9 +47,9 @@
typedef enum _osmv_disp_route {
- OSMV_ROUTE_DROP,
- OSMV_ROUTE_SIMPLE,
- OSMV_ROUTE_RMPP,
+ OSMV_ROUTE_DROP,
+ OSMV_ROUTE_SIMPLE,
+ OSMV_ROUTE_RMPP,
} osmv_disp_route_t;
@@ -58,43 +58,42 @@ typedef enum _osmv_disp_route {
*/
static osmv_disp_route_t
-__osmv_dispatch_route(IN osm_bind_handle_t h_bind,
- IN const ib_mad_t *p_mad,
- OUT osmv_txn_ctx_t **pp_txn);
+__osmv_dispatch_route(IN osm_bind_handle_t h_bind,
+ IN const ib_mad_t * p_mad, OUT osmv_txn_ctx_t ** pp_txn);
static void
-__osmv_dispatch_simple_mad(IN osm_bind_handle_t h_bind,
- IN const ib_mad_t *p_mad,
- IN osmv_txn_ctx_t *p_txn,
- IN const osm_mad_addr_t *p_mad_addr);
+__osmv_dispatch_simple_mad(IN osm_bind_handle_t h_bind,
+ IN const ib_mad_t * p_mad,
+ IN osmv_txn_ctx_t * p_txn,
+ IN const osm_mad_addr_t * p_mad_addr);
static void
-__osmv_dispatch_rmpp_mad(IN osm_bind_handle_t h_bind,
- IN const ib_mad_t *p_mad,
- IN osmv_txn_ctx_t *p_txn,
- IN const osm_mad_addr_t *p_mad_addr);
+__osmv_dispatch_rmpp_mad(IN osm_bind_handle_t h_bind,
+ IN const ib_mad_t * p_mad,
+ IN osmv_txn_ctx_t * p_txn,
+ IN const osm_mad_addr_t * p_mad_addr);
static void
-__osmv_dispatch_rmpp_snd(IN osm_bind_handle_t h_bind,
- IN const ib_mad_t *p_mad,
- IN osmv_txn_ctx_t *p_txn,
- IN const osm_mad_addr_t *p_mad_addr);
+__osmv_dispatch_rmpp_snd(IN osm_bind_handle_t h_bind,
+ IN const ib_mad_t * p_mad,
+ IN osmv_txn_ctx_t * p_txn,
+ IN const osm_mad_addr_t * p_mad_addr);
static ib_api_status_t
-__osmv_dispatch_rmpp_rcv(IN osm_bind_handle_t h_bind,
- IN const ib_mad_t *p_mad,
- IN osmv_txn_ctx_t *p_txn,
- IN const osm_mad_addr_t *p_mad_addr);
+__osmv_dispatch_rmpp_rcv(IN osm_bind_handle_t h_bind,
+ IN const ib_mad_t * p_mad,
+ IN osmv_txn_ctx_t * p_txn,
+ IN const osm_mad_addr_t * p_mad_addr);
static ib_api_status_t
-__osmv_dispatch_accept_seg(IN osm_bind_handle_t h_bind,
- IN osmv_txn_ctx_t *p_txn,
- IN const ib_mad_t *p_mad);
+__osmv_dispatch_accept_seg(IN osm_bind_handle_t h_bind,
+ IN osmv_txn_ctx_t * p_txn,
+ IN const ib_mad_t * p_mad);
static void
-__osmv_dispatch_send_ack(IN osm_bind_handle_t h_bind,
- IN const ib_mad_t *p_req_mad,
- IN osmv_txn_ctx_t *p_txn,
- IN const osm_mad_addr_t *p_mad_addr);
+__osmv_dispatch_send_ack(IN osm_bind_handle_t h_bind,
+ IN const ib_mad_t * p_req_mad,
+ IN osmv_txn_ctx_t * p_txn,
+ IN const osm_mad_addr_t * p_mad_addr);
/*
* NAME
@@ -114,73 +113,72 @@ __osmv_dispatch_send_ack(IN osm_bind_handle_t h_bind,
*/
ib_api_status_t
-osmv_dispatch_mad(IN osm_bind_handle_t h_bind,
- IN const void *p_mad_buf,
- IN const osm_mad_addr_t *p_mad_addr)
+osmv_dispatch_mad(IN osm_bind_handle_t h_bind,
+ IN const void *p_mad_buf,
+ IN const osm_mad_addr_t * p_mad_addr)
{
- ib_api_status_t ret = IB_SUCCESS;
- const ib_mad_t *p_mad = (ib_mad_t *)p_mad_buf;
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t*)h_bind;
- osmv_txn_ctx_t *p_txn = NULL;
- osm_log_t* p_log = p_bo->p_vendor->p_log;
-
- OSM_LOG_ENTER( p_bo->p_vendor->p_log, osmv_dispatch_mad);
-
- CL_ASSERT(NULL != h_bind && NULL != p_mad && NULL != p_mad_addr);
-
- osmv_txn_lock(p_bo);
-
- if (TRUE == p_bo->is_closing )
- {
-
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "The bind handle %p is being closed. "
- "The MAD will not be dispatched.\n", p_bo);
-
- ret = IB_INTERRUPTED;
- goto dispatch_mad_done;
- }
-
- /*
- Add call for packet drop randomizer.
- This is a testing feature. If run_randomizer flag is set to TRUE,
- the randomizer will be called, and randomally will drop
- a packet. This is used for simulating unstable fabric.
- */
- if ( p_bo->p_vendor->run_randomizer == TRUE )
- {
- /* Try the randomizer */
- if ( osm_pkt_randomizer_mad_drop( p_bo->p_vendor->p_log,
- p_bo->p_vendor->p_pkt_randomizer,
- p_mad ) == TRUE )
- {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "The MAD will not be dispatched.\n");
- goto dispatch_mad_done;
- }
- }
-
- switch (__osmv_dispatch_route(h_bind, p_mad, &p_txn)) {
-
- case OSMV_ROUTE_DROP:
- break; /* Do nothing */
-
- case OSMV_ROUTE_SIMPLE:
- __osmv_dispatch_simple_mad(h_bind, p_mad, p_txn, p_mad_addr);
- break;
-
- case OSMV_ROUTE_RMPP:
- __osmv_dispatch_rmpp_mad(h_bind, p_mad, p_txn, p_mad_addr);
- break;
-
- default: CL_ASSERT(FALSE);
- }
-
- dispatch_mad_done:
- osmv_txn_unlock(p_bo);
-
- OSM_LOG_EXIT( p_log );
- return ret;
+ ib_api_status_t ret = IB_SUCCESS;
+ const ib_mad_t *p_mad = (ib_mad_t *) p_mad_buf;
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ osmv_txn_ctx_t *p_txn = NULL;
+ osm_log_t *p_log = p_bo->p_vendor->p_log;
+
+ OSM_LOG_ENTER(p_bo->p_vendor->p_log, osmv_dispatch_mad);
+
+ CL_ASSERT(NULL != h_bind && NULL != p_mad && NULL != p_mad_addr);
+
+ osmv_txn_lock(p_bo);
+
+ if (TRUE == p_bo->is_closing) {
+
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "The bind handle %p is being closed. "
+ "The MAD will not be dispatched.\n", p_bo);
+
+ ret = IB_INTERRUPTED;
+ goto dispatch_mad_done;
+ }
+
+ /*
+ Add call for packet drop randomizer.
+ This is a testing feature. If run_randomizer flag is set to TRUE,
+ the randomizer will be called, and randomally will drop
+ a packet. This is used for simulating unstable fabric.
+ */
+ if (p_bo->p_vendor->run_randomizer == TRUE) {
+ /* Try the randomizer */
+ if (osm_pkt_randomizer_mad_drop(p_bo->p_vendor->p_log,
+ p_bo->p_vendor->
+ p_pkt_randomizer,
+ p_mad) == TRUE) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "The MAD will not be dispatched.\n");
+ goto dispatch_mad_done;
+ }
+ }
+
+ switch (__osmv_dispatch_route(h_bind, p_mad, &p_txn)) {
+
+ case OSMV_ROUTE_DROP:
+ break; /* Do nothing */
+
+ case OSMV_ROUTE_SIMPLE:
+ __osmv_dispatch_simple_mad(h_bind, p_mad, p_txn, p_mad_addr);
+ break;
+
+ case OSMV_ROUTE_RMPP:
+ __osmv_dispatch_rmpp_mad(h_bind, p_mad, p_txn, p_mad_addr);
+ break;
+
+ default:
+ CL_ASSERT(FALSE);
+ }
+
+ dispatch_mad_done:
+ osmv_txn_unlock(p_bo);
+
+ OSM_LOG_EXIT(p_log);
+ return ret;
}
/*
@@ -190,46 +188,42 @@ osmv_dispatch_mad(IN osm_bind_handle_t h_bind,
*/
static osmv_disp_route_t
-__osmv_dispatch_route(IN osm_bind_handle_t h_bind,
- IN const ib_mad_t *p_mad,
- OUT osmv_txn_ctx_t **pp_txn)
+__osmv_dispatch_route(IN osm_bind_handle_t h_bind,
+ IN const ib_mad_t * p_mad, OUT osmv_txn_ctx_t ** pp_txn)
{
- ib_api_status_t ret;
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t*)h_bind;
- boolean_t is_resp = osmv_mad_is_response(p_mad);
- boolean_t is_txn;
- uint64_t key = cl_ntoh64(p_mad->trans_id);
-
- CL_ASSERT(NULL != pp_txn);
-
- ret = osmv_txn_lookup(h_bind, key, pp_txn);
- is_txn = (IB_SUCCESS == ret);
-
- if (FALSE == is_txn && TRUE == is_resp)
- {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "Received a response to a non-started/aged-out transaction (tid=0x%llX). "
- "Dropping the MAD.\n", key);
- return OSMV_ROUTE_DROP;
- }
-
- if (TRUE == osmv_mad_is_rmpp(p_mad))
- {
- /* An RMPP transaction. The filtering is more delicate there */
- return OSMV_ROUTE_RMPP;
- }
-
- if (TRUE == is_txn && FALSE == is_resp)
- {
- /* Does this MAD try to start a transaction with duplicate tid? */
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "Duplicate TID 0x%llX received (not a response). "
- "Dropping the MAD.\n", key);
-
- return OSMV_ROUTE_DROP;
- }
-
- return OSMV_ROUTE_SIMPLE;
+ ib_api_status_t ret;
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ boolean_t is_resp = osmv_mad_is_response(p_mad);
+ boolean_t is_txn;
+ uint64_t key = cl_ntoh64(p_mad->trans_id);
+
+ CL_ASSERT(NULL != pp_txn);
+
+ ret = osmv_txn_lookup(h_bind, key, pp_txn);
+ is_txn = (IB_SUCCESS == ret);
+
+ if (FALSE == is_txn && TRUE == is_resp) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "Received a response to a non-started/aged-out transaction (tid=0x%llX). "
+ "Dropping the MAD.\n", key);
+ return OSMV_ROUTE_DROP;
+ }
+
+ if (TRUE == osmv_mad_is_rmpp(p_mad)) {
+ /* An RMPP transaction. The filtering is more delicate there */
+ return OSMV_ROUTE_RMPP;
+ }
+
+ if (TRUE == is_txn && FALSE == is_resp) {
+ /* Does this MAD try to start a transaction with duplicate tid? */
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "Duplicate TID 0x%llX received (not a response). "
+ "Dropping the MAD.\n", key);
+
+ return OSMV_ROUTE_DROP;
+ }
+
+ return OSMV_ROUTE_SIMPLE;
}
/*
@@ -239,62 +233,59 @@ __osmv_dispatch_route(IN osm_bind_handle_t h_bind,
*/
static void
-__osmv_dispatch_simple_mad(IN osm_bind_handle_t h_bind,
- IN const ib_mad_t *p_mad,
- IN osmv_txn_ctx_t *p_txn,
- IN const osm_mad_addr_t *p_mad_addr)
+__osmv_dispatch_simple_mad(IN osm_bind_handle_t h_bind,
+ IN const ib_mad_t * p_mad,
+ IN osmv_txn_ctx_t * p_txn,
+ IN const osm_mad_addr_t * p_mad_addr)
{
- osm_madw_t *p_madw;
- ib_mad_t *p_mad_buf;
- osm_madw_t *p_req_madw = NULL;
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t*)h_bind;
-
- OSM_LOG_ENTER( p_bo->p_vendor->p_log, __osmv_dispatch_simple_mad);
-
- /* Build the MAD wrapper to be returned to the user.
- * The actual storage for the MAD is allocated there.
- */
- p_madw =
- osm_mad_pool_get(p_bo->p_osm_pool, h_bind, MAD_BLOCK_SIZE, p_mad_addr);
-
- if (NULL == p_madw)
- {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "__osmv_dispatch_simple_mad: ERR 6501: "
- "Out Of Memory - could not allocate a buffer of size %d\n",
- MAD_BLOCK_SIZE);
-
- goto dispatch_simple_mad_done;
- }
-
- p_mad_buf = osm_madw_get_mad_ptr(p_madw);
- /* Copy the payload to the MAD buffer */
- memcpy((void*)p_mad_buf, (void*)p_mad, MAD_BLOCK_SIZE);
-
- if (NULL != p_txn)
- {
- /* This is a RESPONSE MAD. Pair it with the REQUEST MAD, pass upstream */
- p_req_madw = p_txn->p_madw;
- CL_ASSERT(NULL != p_req_madw);
-
- p_mad_buf->trans_id = cl_hton64(osmv_txn_get_tid(p_txn));
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "Restoring the original TID to 0x%llX\n",
- cl_ntoh64(p_mad_buf->trans_id));
-
- /* Reply matched, transaction complete */
- osmv_txn_done(h_bind, osmv_txn_get_key(p_txn), FALSE);
- }
- else
- {
- /* This is a REQUEST MAD. Don't create a context, pass upstream */
- }
-
- /* Do the job !*/
- p_bo->recv_cb(p_madw, p_bo->cb_context, p_req_madw);
-
- dispatch_simple_mad_done:
- OSM_LOG_EXIT( p_bo->p_vendor->p_log );
+ osm_madw_t *p_madw;
+ ib_mad_t *p_mad_buf;
+ osm_madw_t *p_req_madw = NULL;
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+
+ OSM_LOG_ENTER(p_bo->p_vendor->p_log, __osmv_dispatch_simple_mad);
+
+ /* Build the MAD wrapper to be returned to the user.
+ * The actual storage for the MAD is allocated there.
+ */
+ p_madw =
+ osm_mad_pool_get(p_bo->p_osm_pool, h_bind, MAD_BLOCK_SIZE,
+ p_mad_addr);
+
+ if (NULL == p_madw) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "__osmv_dispatch_simple_mad: ERR 6501: "
+ "Out Of Memory - could not allocate a buffer of size %d\n",
+ MAD_BLOCK_SIZE);
+
+ goto dispatch_simple_mad_done;
+ }
+
+ p_mad_buf = osm_madw_get_mad_ptr(p_madw);
+ /* Copy the payload to the MAD buffer */
+ memcpy((void *)p_mad_buf, (void *)p_mad, MAD_BLOCK_SIZE);
+
+ if (NULL != p_txn) {
+ /* This is a RESPONSE MAD. Pair it with the REQUEST MAD, pass upstream */
+ p_req_madw = p_txn->p_madw;
+ CL_ASSERT(NULL != p_req_madw);
+
+ p_mad_buf->trans_id = cl_hton64(osmv_txn_get_tid(p_txn));
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "Restoring the original TID to 0x%llX\n",
+ cl_ntoh64(p_mad_buf->trans_id));
+
+ /* Reply matched, transaction complete */
+ osmv_txn_done(h_bind, osmv_txn_get_key(p_txn), FALSE);
+ } else {
+ /* This is a REQUEST MAD. Don't create a context, pass upstream */
+ }
+
+ /* Do the job ! */
+ p_bo->recv_cb(p_madw, p_bo->cb_context, p_req_madw);
+
+ dispatch_simple_mad_done:
+ OSM_LOG_EXIT(p_bo->p_vendor->p_log);
}
/*
@@ -304,88 +295,86 @@ __osmv_dispatch_simple_mad(IN osm_bind_handle_t h_bind,
*/
static void
-__osmv_dispatch_rmpp_mad(IN osm_bind_handle_t h_bind,
- IN const ib_mad_t *p_mad,
- IN osmv_txn_ctx_t *p_txn,
- IN const osm_mad_addr_t *p_mad_addr)
+__osmv_dispatch_rmpp_mad(IN osm_bind_handle_t h_bind,
+ IN const ib_mad_t * p_mad,
+ IN osmv_txn_ctx_t * p_txn,
+ IN const osm_mad_addr_t * p_mad_addr)
{
- ib_api_status_t status = IB_SUCCESS;
- uint64_t key = cl_ntoh64(p_mad->trans_id);
- boolean_t is_init_by_peer = FALSE;
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t*)h_bind;
- osm_madw_t *p_madw;
-
- OSM_LOG_ENTER( p_bo->p_vendor->p_log, __osmv_dispatch_rmpp_mad);
-
- if (NULL == p_txn)
- {
- if (FALSE == osmv_rmpp_is_data(p_mad) || FALSE == osmv_rmpp_is_first(p_mad))
- {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "The MAD does not match any transaction "
- "and does not start a sender-initiated RMPP transfer.\n");
- goto dispatch_rmpp_mad_done;
- }
-
- /* IB Spec 13.6.2.2. This is a Sender Initiated Transfer.
- My peer is the requester and RMPP Sender. I am the RMPP Receiver.
- */
- status = osmv_txn_init(h_bind, /*tid==key*/key, key, &p_txn);
- if (IB_SUCCESS != status)
- {
- goto dispatch_rmpp_mad_done;
- }
-
- is_init_by_peer = TRUE;
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "A new sender-initiated transfer (TID=0x%llX) started\n", key);
- }
-
- if (OSMV_TXN_RMPP_NONE == osmv_txn_get_rmpp_state(p_txn))
- {
- /* Case 1: Fall through from above.
- * Case 2: When the transaction was initiated by me
- * (a single request MAD), there was an uncertainty
- * whether the reply will be RMPP. Now it's resolved,
- * since the reply is RMPP!
- */
- status = osmv_txn_init_rmpp_receiver(h_bind, p_txn, is_init_by_peer);
- if (IB_SUCCESS != status)
- {
- goto dispatch_rmpp_mad_done;
- }
- }
-
- switch (osmv_txn_get_rmpp_state(p_txn)) {
-
- case OSMV_TXN_RMPP_RECEIVER:
- status = __osmv_dispatch_rmpp_rcv(h_bind, p_mad, p_txn, p_mad_addr);
- if (IB_SUCCESS != status)
- {
- if (FALSE == osmv_txn_is_rmpp_init_by_peer(p_txn))
- {
- /* This is a requester, still waiting for the reply. Apply the callback */
- /* update the status of the p_madw */
- p_madw = osmv_txn_get_madw(p_txn);
- p_madw->status = status;
- p_bo->send_err_cb(p_bo->cb_context, p_madw);
- }
-
- /* ABORT/STOP/LOCAL ERROR */
- osmv_txn_done(h_bind, osmv_txn_get_key(p_txn), FALSE);
- }
- break;
-
- case OSMV_TXN_RMPP_SENDER:
- __osmv_dispatch_rmpp_snd(h_bind, p_mad, p_txn, p_mad_addr);
- /* If an error happens here, it's the sender thread to cleanup the txn */
- break;
-
- default: CL_ASSERT(FALSE);
- }
-
- dispatch_rmpp_mad_done:
- OSM_LOG_EXIT(p_bo->p_vendor->p_log);
+ ib_api_status_t status = IB_SUCCESS;
+ uint64_t key = cl_ntoh64(p_mad->trans_id);
+ boolean_t is_init_by_peer = FALSE;
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ osm_madw_t *p_madw;
+
+ OSM_LOG_ENTER(p_bo->p_vendor->p_log, __osmv_dispatch_rmpp_mad);
+
+ if (NULL == p_txn) {
+ if (FALSE == osmv_rmpp_is_data(p_mad)
+ || FALSE == osmv_rmpp_is_first(p_mad)) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "The MAD does not match any transaction "
+ "and does not start a sender-initiated RMPP transfer.\n");
+ goto dispatch_rmpp_mad_done;
+ }
+
+ /* IB Spec 13.6.2.2. This is a Sender Initiated Transfer.
+ My peer is the requester and RMPP Sender. I am the RMPP Receiver.
+ */
+ status = osmv_txn_init(h_bind, /*tid==key */ key, key, &p_txn);
+ if (IB_SUCCESS != status) {
+ goto dispatch_rmpp_mad_done;
+ }
+
+ is_init_by_peer = TRUE;
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "A new sender-initiated transfer (TID=0x%llX) started\n",
+ key);
+ }
+
+ if (OSMV_TXN_RMPP_NONE == osmv_txn_get_rmpp_state(p_txn)) {
+ /* Case 1: Fall through from above.
+ * Case 2: When the transaction was initiated by me
+ * (a single request MAD), there was an uncertainty
+ * whether the reply will be RMPP. Now it's resolved,
+ * since the reply is RMPP!
+ */
+ status =
+ osmv_txn_init_rmpp_receiver(h_bind, p_txn, is_init_by_peer);
+ if (IB_SUCCESS != status) {
+ goto dispatch_rmpp_mad_done;
+ }
+ }
+
+ switch (osmv_txn_get_rmpp_state(p_txn)) {
+
+ case OSMV_TXN_RMPP_RECEIVER:
+ status =
+ __osmv_dispatch_rmpp_rcv(h_bind, p_mad, p_txn, p_mad_addr);
+ if (IB_SUCCESS != status) {
+ if (FALSE == osmv_txn_is_rmpp_init_by_peer(p_txn)) {
+ /* This is a requester, still waiting for the reply. Apply the callback */
+ /* update the status of the p_madw */
+ p_madw = osmv_txn_get_madw(p_txn);
+ p_madw->status = status;
+ p_bo->send_err_cb(p_bo->cb_context, p_madw);
+ }
+
+ /* ABORT/STOP/LOCAL ERROR */
+ osmv_txn_done(h_bind, osmv_txn_get_key(p_txn), FALSE);
+ }
+ break;
+
+ case OSMV_TXN_RMPP_SENDER:
+ __osmv_dispatch_rmpp_snd(h_bind, p_mad, p_txn, p_mad_addr);
+ /* If an error happens here, it's the sender thread to cleanup the txn */
+ break;
+
+ default:
+ CL_ASSERT(FALSE);
+ }
+
+ dispatch_rmpp_mad_done:
+ OSM_LOG_EXIT(p_bo->p_vendor->p_log);
}
/*
@@ -395,100 +384,94 @@ __osmv_dispatch_rmpp_mad(IN osm_bind_handle_t h_bind,
*/
static void
-__osmv_dispatch_rmpp_snd(IN osm_bind_handle_t h_bind,
- IN const ib_mad_t *p_mad,
- IN osmv_txn_ctx_t *p_txn,
- IN const osm_mad_addr_t *p_mad_addr)
+__osmv_dispatch_rmpp_snd(IN osm_bind_handle_t h_bind,
+ IN const ib_mad_t * p_mad,
+ IN osmv_txn_ctx_t * p_txn,
+ IN const osm_mad_addr_t * p_mad_addr)
{
- osmv_rmpp_send_ctx_t *p_send_ctx = osmv_txn_get_rmpp_send_ctx(p_txn);
-
- uint32_t old_wl = p_send_ctx->window_last;
- uint32_t total_segs = osmv_rmpp_send_ctx_get_num_segs(p_send_ctx);
- uint32_t seg_num = cl_ntoh32(((ib_rmpp_mad_t*)p_mad)->seg_num);
- uint32_t new_wl = cl_ntoh32(((ib_rmpp_mad_t*)p_mad)->paylen_newwin);
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t*)h_bind;
-
- OSM_LOG_ENTER(p_bo->p_vendor->p_log, __osmv_dispatch_rmpp_snd);
-
- if (TRUE == osmv_rmpp_is_abort_stop(p_mad))
- {
-
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "__osmv_dispatch_rmpp_snd: ERR 6502: "
- "The remote side sent an ABORT/STOP indication.\n");
- osmv_rmpp_snd_error(p_send_ctx, IB_REMOTE_ERROR);
- goto dispatch_rmpp_snd_done;
- }
-
- if (FALSE == osmv_rmpp_is_ack(p_mad))
- {
-
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "Not supposed to receive DATA packets --> dropping the MAD\n");
- goto dispatch_rmpp_snd_done;
- }
-
- /* Continue processing the ACK */
- if (seg_num > old_wl)
- {
-
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "__osmv_dispatch_rmpp_snd: ERR 6503: "
- "ACK received for a non-sent segment %d\n", seg_num);
-
- osmv_rmpp_send_nak(h_bind, p_mad, p_mad_addr,
- IB_RMPP_TYPE_ABORT,
- IB_RMPP_STATUS_S2B);
-
- osmv_rmpp_snd_error(p_send_ctx, IB_REMOTE_ERROR);
- goto dispatch_rmpp_snd_done;
- }
-
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "__osmv_dispatch_rmpp_snd: "
- "New WL = %u Old WL = %u Total Segs = %u\n",
- new_wl, old_wl, total_segs);
-
- if (new_wl < old_wl)
- {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "__osmv_dispatch_rmpp_snd: ERR 6508: "
- "The receiver requests a smaller WL (%d) than before (%d)\n",
- new_wl, old_wl);
-
- osmv_rmpp_send_nak(h_bind, p_mad, p_mad_addr,
- IB_RMPP_TYPE_ABORT,
- IB_RMPP_STATUS_W2S);
-
- osmv_rmpp_snd_error(p_send_ctx, IB_REMOTE_ERROR);
- goto dispatch_rmpp_snd_done;
- }
-
- /* Update the sender's window, and optionally wake up the sender thread
- * Note! A single ACK can acknowledge a whole range of segments: [WF..SEG_NUM]
- */
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "ACK for seg_num #%d accepted.\n", seg_num);
-
- if (seg_num == old_wl)
- {
-
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "The send window [%d:%d] is totally acknowledged.\n",
- p_send_ctx->window_first, old_wl);
-
- p_send_ctx->window_first = seg_num+1;
- p_send_ctx->window_last = (new_wl < total_segs) ? new_wl : total_segs;
-
- /* Remove the response timeout event for the window */
- osmv_txn_remove_timeout_ev(h_bind, osmv_txn_get_key(p_txn));
-
- /* Wake up the sending thread */
- cl_event_signal(&p_send_ctx->event);
- }
-
- dispatch_rmpp_snd_done:
- OSM_LOG_EXIT(p_bo->p_vendor->p_log);
+ osmv_rmpp_send_ctx_t *p_send_ctx = osmv_txn_get_rmpp_send_ctx(p_txn);
+
+ uint32_t old_wl = p_send_ctx->window_last;
+ uint32_t total_segs = osmv_rmpp_send_ctx_get_num_segs(p_send_ctx);
+ uint32_t seg_num = cl_ntoh32(((ib_rmpp_mad_t *) p_mad)->seg_num);
+ uint32_t new_wl = cl_ntoh32(((ib_rmpp_mad_t *) p_mad)->paylen_newwin);
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+
+ OSM_LOG_ENTER(p_bo->p_vendor->p_log, __osmv_dispatch_rmpp_snd);
+
+ if (TRUE == osmv_rmpp_is_abort_stop(p_mad)) {
+
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "__osmv_dispatch_rmpp_snd: ERR 6502: "
+ "The remote side sent an ABORT/STOP indication.\n");
+ osmv_rmpp_snd_error(p_send_ctx, IB_REMOTE_ERROR);
+ goto dispatch_rmpp_snd_done;
+ }
+
+ if (FALSE == osmv_rmpp_is_ack(p_mad)) {
+
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "Not supposed to receive DATA packets --> dropping the MAD\n");
+ goto dispatch_rmpp_snd_done;
+ }
+
+ /* Continue processing the ACK */
+ if (seg_num > old_wl) {
+
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "__osmv_dispatch_rmpp_snd: ERR 6503: "
+ "ACK received for a non-sent segment %d\n", seg_num);
+
+ osmv_rmpp_send_nak(h_bind, p_mad, p_mad_addr,
+ IB_RMPP_TYPE_ABORT, IB_RMPP_STATUS_S2B);
+
+ osmv_rmpp_snd_error(p_send_ctx, IB_REMOTE_ERROR);
+ goto dispatch_rmpp_snd_done;
+ }
+
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "__osmv_dispatch_rmpp_snd: "
+ "New WL = %u Old WL = %u Total Segs = %u\n",
+ new_wl, old_wl, total_segs);
+
+ if (new_wl < old_wl) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "__osmv_dispatch_rmpp_snd: ERR 6508: "
+ "The receiver requests a smaller WL (%d) than before (%d)\n",
+ new_wl, old_wl);
+
+ osmv_rmpp_send_nak(h_bind, p_mad, p_mad_addr,
+ IB_RMPP_TYPE_ABORT, IB_RMPP_STATUS_W2S);
+
+ osmv_rmpp_snd_error(p_send_ctx, IB_REMOTE_ERROR);
+ goto dispatch_rmpp_snd_done;
+ }
+
+ /* Update the sender's window, and optionally wake up the sender thread
+ * Note! A single ACK can acknowledge a whole range of segments: [WF..SEG_NUM]
+ */
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "ACK for seg_num #%d accepted.\n", seg_num);
+
+ if (seg_num == old_wl) {
+
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "The send window [%d:%d] is totally acknowledged.\n",
+ p_send_ctx->window_first, old_wl);
+
+ p_send_ctx->window_first = seg_num + 1;
+ p_send_ctx->window_last =
+ (new_wl < total_segs) ? new_wl : total_segs;
+
+ /* Remove the response timeout event for the window */
+ osmv_txn_remove_timeout_ev(h_bind, osmv_txn_get_key(p_txn));
+
+ /* Wake up the sending thread */
+ cl_event_signal(&p_send_ctx->event);
+ }
+
+ dispatch_rmpp_snd_done:
+ OSM_LOG_EXIT(p_bo->p_vendor->p_log);
}
/*
@@ -498,165 +481,159 @@ __osmv_dispatch_rmpp_snd(IN osm_bind_handle_t h_bind,
*/
static ib_api_status_t
-__osmv_dispatch_rmpp_rcv(IN osm_bind_handle_t h_bind,
- IN const ib_mad_t *p_mad,
- IN osmv_txn_ctx_t *p_txn,
- IN const osm_mad_addr_t *p_mad_addr)
+__osmv_dispatch_rmpp_rcv(IN osm_bind_handle_t h_bind,
+ IN const ib_mad_t * p_mad,
+ IN osmv_txn_ctx_t * p_txn,
+ IN const osm_mad_addr_t * p_mad_addr)
{
- ib_api_status_t status = IB_SUCCESS;
- osmv_rmpp_recv_ctx_t *p_recv_ctx = osmv_txn_get_rmpp_recv_ctx(p_txn);
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t*)h_bind;
- boolean_t is_last1=FALSE, is_last2=FALSE;
- osm_madw_t *p_new_madw=NULL, *p_req_madw=NULL;
- ib_mad_t *p_mad_buf;
- uint32_t size = 0;
- uint64_t key = osmv_txn_get_key(p_txn);
- uint64_t tid = osmv_txn_get_tid(p_txn);
-
- OSM_LOG_ENTER(p_bo->p_vendor->p_log, __osmv_dispatch_rmpp_rcv);
-
- if (TRUE == osmv_rmpp_is_ack(p_mad))
- {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "Not supposed to receive ACK's --> dropping the MAD\n");
-
- goto dispatch_rmpp_rcv_done;
- }
-
- if (TRUE == osmv_rmpp_is_abort_stop(p_mad))
- {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "__osmv_dispatch_rmpp_rcv: ERR 6504: "
- "The Remote Side stopped sending\n");
-
- status = IB_REMOTE_ERROR;
- goto dispatch_rmpp_rcv_done;
- }
-
- status = __osmv_dispatch_accept_seg(h_bind, p_txn, p_mad);
- switch (status) {
-
- case IB_SUCCESS:
-
- /* Check wheter this is the legal last MAD */
- /* Criteria #1: the received MAD is marked last */
- is_last1 = osmv_rmpp_is_last(p_mad);
-
- /* Criteria #2: the total accumulated length hits the advertised one */
- is_last2 = is_last1;
-
- size = osmv_rmpp_recv_ctx_get_byte_num_from_first(p_recv_ctx);
- if (size > 0)
- {
- is_last2 = (osmv_rmpp_recv_ctx_get_cur_byte_num(p_recv_ctx) >= size);
- }
-
- if (is_last1 != is_last2)
- {
-
- osmv_rmpp_send_nak(h_bind, p_mad, p_mad_addr,
- IB_RMPP_TYPE_ABORT,
- IB_RMPP_STATUS_BAD_LEN);
-
- status = IB_ERROR;
- goto dispatch_rmpp_rcv_done;
- }
-
- /* TBD Consider an optimization - sending an ACK
- * only for the last segment in the window
- */
- __osmv_dispatch_send_ack(h_bind, p_mad, p_txn, p_mad_addr);
- break;
-
- case IB_INSUFFICIENT_RESOURCES:
- /* An out-of-order segment received. Send the ACK anyway */
- __osmv_dispatch_send_ack(h_bind, p_mad, p_txn, p_mad_addr);
- status = IB_SUCCESS;
- goto dispatch_rmpp_rcv_done;
-
- case IB_INSUFFICIENT_MEMORY:
- osmv_rmpp_send_nak(h_bind, p_mad, p_mad_addr,
- IB_RMPP_TYPE_STOP,
- IB_RMPP_STATUS_RESX);
- goto dispatch_rmpp_rcv_done;
-
- default:
- /* Illegal return code */
- CL_ASSERT(FALSE);
- }
-
- if (TRUE != is_last1)
- {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "RMPP MADW assembly continues, TID=0x%llX\n", tid);
- goto dispatch_rmpp_rcv_done;
- }
-
- /* This is the last packet. */
- if (0 == size)
- {
- /* The total size was not advertised in the first packet */
- size = osmv_rmpp_recv_ctx_get_byte_num_from_last(p_recv_ctx);
- }
-
- /*
- NOTE: the received mad might not be >= 256 bytes.
- some MADs might contain several SA records but still be
- less then a full MAD.
- We have to use RMPP to send them over since on a regular
- "simple" MAD there is no way to know how many records were sent
- */
-
- /* Build the MAD wrapper to be returned to the user.
- * The actual storage for the MAD is allocated there.
- */
- p_new_madw = osm_mad_pool_get(p_bo->p_osm_pool, h_bind, size, p_mad_addr);
- if (NULL == p_new_madw)
- {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "__osmv_dispatch_rmpp_rcv: ERR 6506: "
- "Out Of Memory - could not allocate %d bytes for the MADW\n",
- size);
-
- status = IB_INSUFFICIENT_MEMORY;
- goto dispatch_rmpp_rcv_done;
- }
-
- p_req_madw = osmv_txn_get_madw(p_txn);
- p_mad_buf = osm_madw_get_mad_ptr(p_new_madw);
- status = osmv_rmpp_recv_ctx_reassemble_arbt_mad(p_recv_ctx, size,
- (uint8_t*)p_mad_buf);
- if (IB_SUCCESS != status)
- {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "__osmv_dispatch_rmpp_rcv: ERR 6507: "
- "Internal error - could not reassemble the result MAD\n");
- goto dispatch_rmpp_rcv_done; /* What can happen here? */
- }
-
- /* The MAD is assembled, we are about to apply the callback.
- * Delete the transaction context, unless the transaction is double sided */
- if (FALSE == osmv_txn_is_rmpp_init_by_peer(p_txn)
- ||
- FALSE == osmv_mad_is_multi_resp(p_mad)) {
-
- osmv_txn_done(h_bind, key, FALSE);
- }
-
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "RMPP MADW %p assembly complete, TID=0x%llX\n", p_new_madw, tid);
-
- p_mad_buf->trans_id = cl_hton64(tid);
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "Restoring the original TID to 0x%llX\n",
- cl_ntoh64(p_mad_buf->trans_id));
-
- /* Finally, do the job! */
- p_bo->recv_cb(p_new_madw, p_bo->cb_context, p_req_madw);
-
- dispatch_rmpp_rcv_done:
- OSM_LOG_EXIT(p_bo->p_vendor->p_log);
- return status;
+ ib_api_status_t status = IB_SUCCESS;
+ osmv_rmpp_recv_ctx_t *p_recv_ctx = osmv_txn_get_rmpp_recv_ctx(p_txn);
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ boolean_t is_last1 = FALSE, is_last2 = FALSE;
+ osm_madw_t *p_new_madw = NULL, *p_req_madw = NULL;
+ ib_mad_t *p_mad_buf;
+ uint32_t size = 0;
+ uint64_t key = osmv_txn_get_key(p_txn);
+ uint64_t tid = osmv_txn_get_tid(p_txn);
+
+ OSM_LOG_ENTER(p_bo->p_vendor->p_log, __osmv_dispatch_rmpp_rcv);
+
+ if (TRUE == osmv_rmpp_is_ack(p_mad)) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "Not supposed to receive ACK's --> dropping the MAD\n");
+
+ goto dispatch_rmpp_rcv_done;
+ }
+
+ if (TRUE == osmv_rmpp_is_abort_stop(p_mad)) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "__osmv_dispatch_rmpp_rcv: ERR 6504: "
+ "The Remote Side stopped sending\n");
+
+ status = IB_REMOTE_ERROR;
+ goto dispatch_rmpp_rcv_done;
+ }
+
+ status = __osmv_dispatch_accept_seg(h_bind, p_txn, p_mad);
+ switch (status) {
+
+ case IB_SUCCESS:
+
+ /* Check wheter this is the legal last MAD */
+ /* Criteria #1: the received MAD is marked last */
+ is_last1 = osmv_rmpp_is_last(p_mad);
+
+ /* Criteria #2: the total accumulated length hits the advertised one */
+ is_last2 = is_last1;
+
+ size = osmv_rmpp_recv_ctx_get_byte_num_from_first(p_recv_ctx);
+ if (size > 0) {
+ is_last2 =
+ (osmv_rmpp_recv_ctx_get_cur_byte_num(p_recv_ctx) >=
+ size);
+ }
+
+ if (is_last1 != is_last2) {
+
+ osmv_rmpp_send_nak(h_bind, p_mad, p_mad_addr,
+ IB_RMPP_TYPE_ABORT,
+ IB_RMPP_STATUS_BAD_LEN);
+
+ status = IB_ERROR;
+ goto dispatch_rmpp_rcv_done;
+ }
+
+ /* TBD Consider an optimization - sending an ACK
+ * only for the last segment in the window
+ */
+ __osmv_dispatch_send_ack(h_bind, p_mad, p_txn, p_mad_addr);
+ break;
+
+ case IB_INSUFFICIENT_RESOURCES:
+ /* An out-of-order segment received. Send the ACK anyway */
+ __osmv_dispatch_send_ack(h_bind, p_mad, p_txn, p_mad_addr);
+ status = IB_SUCCESS;
+ goto dispatch_rmpp_rcv_done;
+
+ case IB_INSUFFICIENT_MEMORY:
+ osmv_rmpp_send_nak(h_bind, p_mad, p_mad_addr,
+ IB_RMPP_TYPE_STOP, IB_RMPP_STATUS_RESX);
+ goto dispatch_rmpp_rcv_done;
+
+ default:
+ /* Illegal return code */
+ CL_ASSERT(FALSE);
+ }
+
+ if (TRUE != is_last1) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "RMPP MADW assembly continues, TID=0x%llX\n", tid);
+ goto dispatch_rmpp_rcv_done;
+ }
+
+ /* This is the last packet. */
+ if (0 == size) {
+ /* The total size was not advertised in the first packet */
+ size = osmv_rmpp_recv_ctx_get_byte_num_from_last(p_recv_ctx);
+ }
+
+ /*
+ NOTE: the received mad might not be >= 256 bytes.
+ some MADs might contain several SA records but still be
+ less then a full MAD.
+ We have to use RMPP to send them over since on a regular
+ "simple" MAD there is no way to know how many records were sent
+ */
+
+ /* Build the MAD wrapper to be returned to the user.
+ * The actual storage for the MAD is allocated there.
+ */
+ p_new_madw =
+ osm_mad_pool_get(p_bo->p_osm_pool, h_bind, size, p_mad_addr);
+ if (NULL == p_new_madw) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "__osmv_dispatch_rmpp_rcv: ERR 6506: "
+ "Out Of Memory - could not allocate %d bytes for the MADW\n",
+ size);
+
+ status = IB_INSUFFICIENT_MEMORY;
+ goto dispatch_rmpp_rcv_done;
+ }
+
+ p_req_madw = osmv_txn_get_madw(p_txn);
+ p_mad_buf = osm_madw_get_mad_ptr(p_new_madw);
+ status = osmv_rmpp_recv_ctx_reassemble_arbt_mad(p_recv_ctx, size,
+ (uint8_t *) p_mad_buf);
+ if (IB_SUCCESS != status) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "__osmv_dispatch_rmpp_rcv: ERR 6507: "
+ "Internal error - could not reassemble the result MAD\n");
+ goto dispatch_rmpp_rcv_done; /* What can happen here? */
+ }
+
+ /* The MAD is assembled, we are about to apply the callback.
+ * Delete the transaction context, unless the transaction is double sided */
+ if (FALSE == osmv_txn_is_rmpp_init_by_peer(p_txn)
+ || FALSE == osmv_mad_is_multi_resp(p_mad)) {
+
+ osmv_txn_done(h_bind, key, FALSE);
+ }
+
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "RMPP MADW %p assembly complete, TID=0x%llX\n", p_new_madw,
+ tid);
+
+ p_mad_buf->trans_id = cl_hton64(tid);
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "Restoring the original TID to 0x%llX\n",
+ cl_ntoh64(p_mad_buf->trans_id));
+
+ /* Finally, do the job! */
+ p_bo->recv_cb(p_new_madw, p_bo->cb_context, p_req_madw);
+
+ dispatch_rmpp_rcv_done:
+ OSM_LOG_EXIT(p_bo->p_vendor->p_log);
+ return status;
}
/*
@@ -667,42 +644,38 @@ __osmv_dispatch_rmpp_rcv(IN osm_bind_handle_t h_bind,
*/
static ib_api_status_t
-__osmv_dispatch_accept_seg(IN osm_bind_handle_t h_bind,
- IN osmv_txn_ctx_t *p_txn,
- IN const ib_mad_t *p_mad)
+__osmv_dispatch_accept_seg(IN osm_bind_handle_t h_bind,
+ IN osmv_txn_ctx_t * p_txn, IN const ib_mad_t * p_mad)
{
- ib_api_status_t ret = IB_SUCCESS;
- uint32_t seg_num = cl_ntoh32(((ib_rmpp_mad_t*)p_mad)->seg_num);
- osmv_rmpp_recv_ctx_t *p_recv_ctx = osmv_txn_get_rmpp_recv_ctx(p_txn);
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t*)h_bind;
- uint64_t tid = osmv_txn_get_tid(p_txn);
-
- OSM_LOG_ENTER( p_bo->p_vendor->p_log, __osmv_dispatch_accept_seg);
-
- if (seg_num != p_recv_ctx->expected_seg)
- {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "TID 0x%llX: can't accept this segment (%d) - "
- "this is a Go-Back-N implementation\n",
- tid, seg_num);
- return IB_INSUFFICIENT_RESOURCES;
- }
-
- /* Store the packet's copy in the reassembly list.
- * Promote the expected segment counter.
- */
- ret = osmv_rmpp_recv_ctx_store_mad_seg(p_recv_ctx, (uint8_t*)p_mad);
- if (IB_SUCCESS != ret)
- {
- return ret;
- }
-
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "TID 0x%llX: segment %d accepted\n", tid, seg_num);
- p_recv_ctx->expected_seg = seg_num+1;
-
- OSM_LOG_EXIT( p_bo->p_vendor->p_log );
- return IB_SUCCESS;
+ ib_api_status_t ret = IB_SUCCESS;
+ uint32_t seg_num = cl_ntoh32(((ib_rmpp_mad_t *) p_mad)->seg_num);
+ osmv_rmpp_recv_ctx_t *p_recv_ctx = osmv_txn_get_rmpp_recv_ctx(p_txn);
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ uint64_t tid = osmv_txn_get_tid(p_txn);
+
+ OSM_LOG_ENTER(p_bo->p_vendor->p_log, __osmv_dispatch_accept_seg);
+
+ if (seg_num != p_recv_ctx->expected_seg) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "TID 0x%llX: can't accept this segment (%d) - "
+ "this is a Go-Back-N implementation\n", tid, seg_num);
+ return IB_INSUFFICIENT_RESOURCES;
+ }
+
+ /* Store the packet's copy in the reassembly list.
+ * Promote the expected segment counter.
+ */
+ ret = osmv_rmpp_recv_ctx_store_mad_seg(p_recv_ctx, (uint8_t *) p_mad);
+ if (IB_SUCCESS != ret) {
+ return ret;
+ }
+
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "TID 0x%llX: segment %d accepted\n", tid, seg_num);
+ p_recv_ctx->expected_seg = seg_num + 1;
+
+ OSM_LOG_EXIT(p_bo->p_vendor->p_log);
+ return IB_SUCCESS;
}
/*
@@ -716,22 +689,22 @@ __osmv_dispatch_accept_seg(IN osm_bind_handle_t h_bind,
*/
static void
-__osmv_dispatch_send_ack(IN osm_bind_handle_t h_bind,
- IN const ib_mad_t *p_req_mad,
- IN osmv_txn_ctx_t *p_txn,
- IN const osm_mad_addr_t *p_mad_addr)
+__osmv_dispatch_send_ack(IN osm_bind_handle_t h_bind,
+ IN const ib_mad_t * p_req_mad,
+ IN osmv_txn_ctx_t * p_txn,
+ IN const osm_mad_addr_t * p_mad_addr)
{
- osmv_rmpp_recv_ctx_t *p_recv_ctx = osmv_txn_get_rmpp_recv_ctx(p_txn);
+ osmv_rmpp_recv_ctx_t *p_recv_ctx = osmv_txn_get_rmpp_recv_ctx(p_txn);
- /* ACK the segment # that was accepted */
- uint32_t seg_num = cl_ntoh32(((ib_rmpp_mad_t*)p_req_mad)->seg_num);
+ /* ACK the segment # that was accepted */
+ uint32_t seg_num = cl_ntoh32(((ib_rmpp_mad_t *) p_req_mad)->seg_num);
- /* NOTE! The receiver can publish the New Window Last (NWL) value
- * that is greater than the total number of segments to be sent.
- * It's the sender's responsibility to compute the correct number
- * of segments to send in the next burst.
- */
- uint32_t nwl = p_recv_ctx->expected_seg + OSMV_RMPP_RECV_WIN - 1;
+ /* NOTE! The receiver can publish the New Window Last (NWL) value
+ * that is greater than the total number of segments to be sent.
+ * It's the sender's responsibility to compute the correct number
+ * of segments to send in the next burst.
+ */
+ uint32_t nwl = p_recv_ctx->expected_seg + OSMV_RMPP_RECV_WIN - 1;
- osmv_rmpp_send_ack(h_bind, p_req_mad, seg_num, nwl, p_mad_addr);
+ osmv_rmpp_send_ack(h_bind, p_req_mad, seg_num, nwl, p_mad_addr);
}
diff --git a/opensm/libvendor/osm_vendor_mlx_hca.c b/opensm/libvendor/osm_vendor_mlx_hca.c
index 3e011fb..2bbb995 100644
--- a/opensm/libvendor/osm_vendor_mlx_hca.c
+++ b/opensm/libvendor/osm_vendor_mlx_hca.c
@@ -33,10 +33,9 @@
*
*/
-
#if HAVE_CONFIG_H
# include <config.h>
-#endif /* HAVE_CONFIG_H */
+#endif /* HAVE_CONFIG_H */
#include <stdlib.h>
#include <string.h>
@@ -56,34 +55,31 @@
*
********************************************************************************/
-typedef struct _osm_ca_info
-{
- ib_net64_t guid;
- size_t attr_size;
- ib_ca_attr_t *p_attr;
-}
-osm_ca_info_t;
+typedef struct _osm_ca_info {
+ ib_net64_t guid;
+ size_t attr_size;
+ ib_ca_attr_t *p_attr;
+} osm_ca_info_t;
/**********************************************************************
* Convert the given GID to GUID by copy of it's upper 8 bytes
**********************************************************************/
ib_api_status_t
-__osm_vendor_gid_to_guid( IN u_int8_t * gid,
- OUT VAPI_gid_t * guid )
+__osm_vendor_gid_to_guid(IN u_int8_t * gid, OUT VAPI_gid_t * guid)
{
- memcpy( guid, gid + 8, 8 );
- return ( IB_SUCCESS );
+ memcpy(guid, gid + 8, 8);
+ return (IB_SUCCESS);
}
/**********************************************************************
* Returns a pointer to the port attribute of the specified port
* owned by this CA.
************************************************************************/
-static ib_port_attr_t *
-__osm_ca_info_get_port_attr_ptr( IN const osm_ca_info_t * const p_ca_info,
- IN const uint8_t index )
+static ib_port_attr_t *__osm_ca_info_get_port_attr_ptr(IN const osm_ca_info_t *
+ const p_ca_info,
+ IN const uint8_t index)
{
- return ( &p_ca_info->p_attr->p_port_attr[index] );
+ return (&p_ca_info->p_attr->p_port_attr[index]);
}
/********************************************************************************
@@ -91,223 +87,207 @@ __osm_ca_info_get_port_attr_ptr( IN const osm_ca_info_t * const p_ca_info,
* NOTE: user of this function needs to deallocate p_hca_ids after usage.
********************************************************************************/
static ib_api_status_t
-__osm_vendor_get_ca_ids( IN osm_vendor_t * const p_vend,
- IN VAPI_hca_id_t ** const p_hca_ids,
- IN uint32_t * const p_num_guids )
+__osm_vendor_get_ca_ids(IN osm_vendor_t * const p_vend,
+ IN VAPI_hca_id_t ** const p_hca_ids,
+ IN uint32_t * const p_num_guids)
{
- ib_api_status_t status;
- VAPI_ret_t vapi_res;
-
- OSM_LOG_ENTER( p_vend->p_log, __osm_vendor_get_ca_ids );
-
- CL_ASSERT( p_hca_ids );
- CL_ASSERT( p_num_guids );
-
- /* first call is just to get the number */
- vapi_res = EVAPI_list_hcas( 0, p_num_guids, NULL );
-
- /* fail ? */
- if( vapi_res == VAPI_EINVAL_PARAM )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__osm_vendor_get_ca_ids: ERR 3D08: : "
- "Bad parameter in calling: EVAPI_list_hcas. (%d)\n",
- vapi_res );
- status = IB_ERROR;
- goto Exit;
- }
-
- /* NO HCA ? */
- if( *p_num_guids == 0 )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__osm_vendor_get_ca_ids: ERR 3D09: "
- "No available channel adapters.\n" );
- status = IB_INSUFFICIENT_RESOURCES;
- goto Exit;
- }
-
- /* allocate and really call - user of this function needs to deallocate it */
- *p_hca_ids =
- ( VAPI_hca_id_t * ) malloc( *p_num_guids *
- sizeof( VAPI_hca_id_t ) );
-
- /* now call it really */
- vapi_res = EVAPI_list_hcas( *p_num_guids, p_num_guids, *p_hca_ids );
-
- /* too many ? */
- if( vapi_res == VAPI_EAGAIN )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__osm_vendor_get_ca_ids: ERR 3D10: "
- "More CA GUIDs than allocated array (%d).\n", *p_num_guids );
- status = IB_ERROR;
- goto Exit;
- }
-
- /* fail ? */
- if( vapi_res != VAPI_OK )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__osm_vendor_get_ca_ids: ERR 3D11: : "
- "Bad parameter in calling: EVAPI_list_hcas.\n" );
- status = IB_ERROR;
- goto Exit;
- }
-
- if( osm_log_is_active( p_vend->p_log, OSM_LOG_DEBUG ) )
- {
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "__osm_vendor_get_ca_ids: "
- "Detected %u local channel adapters.\n", *p_num_guids );
- }
-
- status = IB_SUCCESS;
-
- Exit:
- OSM_LOG_EXIT( p_vend->p_log );
- return ( status );
+ ib_api_status_t status;
+ VAPI_ret_t vapi_res;
+
+ OSM_LOG_ENTER(p_vend->p_log, __osm_vendor_get_ca_ids);
+
+ CL_ASSERT(p_hca_ids);
+ CL_ASSERT(p_num_guids);
+
+ /* first call is just to get the number */
+ vapi_res = EVAPI_list_hcas(0, p_num_guids, NULL);
+
+ /* fail ? */
+ if (vapi_res == VAPI_EINVAL_PARAM) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_vendor_get_ca_ids: ERR 3D08: : "
+ "Bad parameter in calling: EVAPI_list_hcas. (%d)\n",
+ vapi_res);
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+ /* NO HCA ? */
+ if (*p_num_guids == 0) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_vendor_get_ca_ids: ERR 3D09: "
+ "No available channel adapters.\n");
+ status = IB_INSUFFICIENT_RESOURCES;
+ goto Exit;
+ }
+
+ /* allocate and really call - user of this function needs to deallocate it */
+ *p_hca_ids =
+ (VAPI_hca_id_t *) malloc(*p_num_guids * sizeof(VAPI_hca_id_t));
+
+ /* now call it really */
+ vapi_res = EVAPI_list_hcas(*p_num_guids, p_num_guids, *p_hca_ids);
+
+ /* too many ? */
+ if (vapi_res == VAPI_EAGAIN) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_vendor_get_ca_ids: ERR 3D10: "
+ "More CA GUIDs than allocated array (%d).\n",
+ *p_num_guids);
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+ /* fail ? */
+ if (vapi_res != VAPI_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_vendor_get_ca_ids: ERR 3D11: : "
+ "Bad parameter in calling: EVAPI_list_hcas.\n");
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+ if (osm_log_is_active(p_vend->p_log, OSM_LOG_DEBUG)) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__osm_vendor_get_ca_ids: "
+ "Detected %u local channel adapters.\n", *p_num_guids);
+ }
+
+ status = IB_SUCCESS;
+
+ Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
}
-
/**********************************************************************
* Initialize an Info Struct for the Given HCA by its Id
**********************************************************************/
static ib_api_status_t
-__osm_ca_info_init( IN osm_vendor_t * const p_vend,
- IN VAPI_hca_id_t ca_id,
- OUT osm_ca_info_t * const p_ca_info )
+__osm_ca_info_init(IN osm_vendor_t * const p_vend,
+ IN VAPI_hca_id_t ca_id, OUT osm_ca_info_t * const p_ca_info)
{
- ib_api_status_t status = IB_ERROR;
- VAPI_ret_t vapi_res;
- VAPI_hca_hndl_t hca_hndl;
- VAPI_hca_vendor_t hca_vendor;
- VAPI_hca_cap_t hca_cap;
- VAPI_hca_port_t hca_port;
- uint8_t port_num;
- IB_gid_t *p_port_gid;
- uint16_t maxNumGids;
-
- OSM_LOG_ENTER( p_vend->p_log, __osm_ca_info_init );
-
- /* get the HCA handle */
- vapi_res = EVAPI_get_hca_hndl( ca_id, &hca_hndl );
- if( vapi_res != VAPI_OK )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__osm_ca_info_init: ERR 3D05: "
- "Fail to get HCA handle (%u).\n", vapi_res );
- goto Exit;
- }
-
- if( osm_log_is_active( p_vend->p_log, OSM_LOG_DEBUG ) )
- {
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "__osm_ca_info_init: " "Querying CA %s.\n", ca_id );
- }
-
- /* query and get the HCA capability */
- vapi_res = VAPI_query_hca_cap( hca_hndl, &hca_vendor, &hca_cap );
- if( vapi_res != VAPI_OK )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__osm_ca_info_init: ERR 3D06: "
- "Fail to get HCA Capabilities (%u).\n", vapi_res );
- goto Exit;
- }
-
- /* get the guid of the HCA */
- memcpy( &( p_ca_info->guid ), hca_cap.node_guid, 8 * sizeof( u_int8_t ) );
- p_ca_info->attr_size = 1;
- p_ca_info->p_attr =
- ( ib_ca_attr_t * ) malloc( sizeof( ib_ca_attr_t ) );
- memcpy( &( p_ca_info->p_attr->ca_guid ), hca_cap.node_guid,
- 8 * sizeof( u_int8_t ) );
-
- /* now obtain the attributes of the ports */
- p_ca_info->p_attr->num_ports = hca_cap.phys_port_num;
- p_ca_info->p_attr->p_port_attr =
- ( ib_port_attr_t * ) malloc( hca_cap.phys_port_num *
- sizeof( ib_port_attr_t ) );
-
- for( port_num = 0; port_num < p_ca_info->p_attr->num_ports; port_num++ )
- {
-
- /* query the port attributes */
- vapi_res =
- VAPI_query_hca_port_prop( hca_hndl, port_num + 1, &hca_port );
- if( vapi_res != VAPI_OK )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__osm_ca_info_init: ERR 3D07: "
- "Fail to get HCA Port Attributes (%d).\n", vapi_res );
- goto Exit;
- }
-
- /* first call to know the size of the gid table */
- vapi_res =
- VAPI_query_hca_gid_tbl( hca_hndl, port_num + 1, 0, &maxNumGids,
- NULL );
- p_port_gid =
- ( IB_gid_t * ) malloc( maxNumGids * sizeof( IB_gid_t ) );
-
- vapi_res =
- VAPI_query_hca_gid_tbl( hca_hndl, port_num + 1, maxNumGids,
- &maxNumGids, p_port_gid );
- if( vapi_res != VAPI_OK )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__osm_ca_info_init: ERR 3D12: "
- "Fail to get HCA Port GID (%d).\n", vapi_res );
- goto Exit;
- }
-
- __osm_vendor_gid_to_guid( p_port_gid[0],
- ( IB_gid_t * ) & p_ca_info->p_attr->
- p_port_attr[port_num].port_guid );
- p_ca_info->p_attr->p_port_attr[port_num].lid = hca_port.lid;
- p_ca_info->p_attr->p_port_attr[port_num].link_state = hca_port.state;
- p_ca_info->p_attr->p_port_attr[port_num].sm_lid = hca_port.sm_lid;
-
- free( p_port_gid );
- }
-
- status = IB_SUCCESS;
- Exit:
- OSM_LOG_EXIT( p_vend->p_log );
- return ( status );
+ ib_api_status_t status = IB_ERROR;
+ VAPI_ret_t vapi_res;
+ VAPI_hca_hndl_t hca_hndl;
+ VAPI_hca_vendor_t hca_vendor;
+ VAPI_hca_cap_t hca_cap;
+ VAPI_hca_port_t hca_port;
+ uint8_t port_num;
+ IB_gid_t *p_port_gid;
+ uint16_t maxNumGids;
+
+ OSM_LOG_ENTER(p_vend->p_log, __osm_ca_info_init);
+
+ /* get the HCA handle */
+ vapi_res = EVAPI_get_hca_hndl(ca_id, &hca_hndl);
+ if (vapi_res != VAPI_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_ca_info_init: ERR 3D05: "
+ "Fail to get HCA handle (%u).\n", vapi_res);
+ goto Exit;
+ }
+
+ if (osm_log_is_active(p_vend->p_log, OSM_LOG_DEBUG)) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__osm_ca_info_init: " "Querying CA %s.\n", ca_id);
+ }
+
+ /* query and get the HCA capability */
+ vapi_res = VAPI_query_hca_cap(hca_hndl, &hca_vendor, &hca_cap);
+ if (vapi_res != VAPI_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_ca_info_init: ERR 3D06: "
+ "Fail to get HCA Capabilities (%u).\n", vapi_res);
+ goto Exit;
+ }
+
+ /* get the guid of the HCA */
+ memcpy(&(p_ca_info->guid), hca_cap.node_guid, 8 * sizeof(u_int8_t));
+ p_ca_info->attr_size = 1;
+ p_ca_info->p_attr = (ib_ca_attr_t *) malloc(sizeof(ib_ca_attr_t));
+ memcpy(&(p_ca_info->p_attr->ca_guid), hca_cap.node_guid,
+ 8 * sizeof(u_int8_t));
+
+ /* now obtain the attributes of the ports */
+ p_ca_info->p_attr->num_ports = hca_cap.phys_port_num;
+ p_ca_info->p_attr->p_port_attr =
+ (ib_port_attr_t *) malloc(hca_cap.phys_port_num *
+ sizeof(ib_port_attr_t));
+
+ for (port_num = 0; port_num < p_ca_info->p_attr->num_ports; port_num++) {
+
+ /* query the port attributes */
+ vapi_res =
+ VAPI_query_hca_port_prop(hca_hndl, port_num + 1, &hca_port);
+ if (vapi_res != VAPI_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_ca_info_init: ERR 3D07: "
+ "Fail to get HCA Port Attributes (%d).\n",
+ vapi_res);
+ goto Exit;
+ }
+
+ /* first call to know the size of the gid table */
+ vapi_res =
+ VAPI_query_hca_gid_tbl(hca_hndl, port_num + 1, 0,
+ &maxNumGids, NULL);
+ p_port_gid = (IB_gid_t *) malloc(maxNumGids * sizeof(IB_gid_t));
+
+ vapi_res =
+ VAPI_query_hca_gid_tbl(hca_hndl, port_num + 1, maxNumGids,
+ &maxNumGids, p_port_gid);
+ if (vapi_res != VAPI_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_ca_info_init: ERR 3D12: "
+ "Fail to get HCA Port GID (%d).\n", vapi_res);
+ goto Exit;
+ }
+
+ __osm_vendor_gid_to_guid(p_port_gid[0],
+ (IB_gid_t *) & p_ca_info->p_attr->
+ p_port_attr[port_num].port_guid);
+ p_ca_info->p_attr->p_port_attr[port_num].lid = hca_port.lid;
+ p_ca_info->p_attr->p_port_attr[port_num].link_state =
+ hca_port.state;
+ p_ca_info->p_attr->p_port_attr[port_num].sm_lid =
+ hca_port.sm_lid;
+
+ free(p_port_gid);
+ }
+
+ status = IB_SUCCESS;
+ Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
}
/**********************************************************************
**********************************************************************/
void
-osm_ca_info_destroy( IN osm_vendor_t * const p_vend,
- IN osm_ca_info_t * const p_ca_info,
- IN uint8_t num_ca)
+osm_ca_info_destroy(IN osm_vendor_t * const p_vend,
+ IN osm_ca_info_t * const p_ca_info, IN uint8_t num_ca)
{
- osm_ca_info_t *p_ca;
- uint8_t i;
+ osm_ca_info_t *p_ca;
+ uint8_t i;
- OSM_LOG_ENTER( p_vend->p_log, osm_ca_info_destroy );
+ OSM_LOG_ENTER(p_vend->p_log, osm_ca_info_destroy);
- for (i=0; i < num_ca; i++)
- {
- p_ca = &p_ca_info[i];
+ for (i = 0; i < num_ca; i++) {
+ p_ca = &p_ca_info[i];
- if( NULL != p_ca->p_attr )
- {
- if(0 != p_ca->p_attr->num_ports)
- {
- free( p_ca->p_attr->p_port_attr );
- }
+ if (NULL != p_ca->p_attr) {
+ if (0 != p_ca->p_attr->num_ports) {
+ free(p_ca->p_attr->p_port_attr);
+ }
- free( p_ca->p_attr);
- }
- }
+ free(p_ca->p_attr);
+ }
+ }
- free( p_ca_info );
+ free(p_ca_info);
- OSM_LOG_EXIT( p_vend->p_log );
+ OSM_LOG_EXIT(p_vend->p_log);
}
/**********************************************************************
@@ -317,108 +297,100 @@ osm_ca_info_destroy( IN osm_vendor_t * const p_vend,
* Update the vendor object list of ca_info structs
**********************************************************************/
ib_api_status_t
-osm_vendor_get_all_port_attr( IN osm_vendor_t * const p_vend,
- IN ib_port_attr_t * const p_attr_array,
- IN uint32_t * const p_num_ports )
+osm_vendor_get_all_port_attr(IN osm_vendor_t * const p_vend,
+ IN ib_port_attr_t * const p_attr_array,
+ IN uint32_t * const p_num_ports)
{
- ib_api_status_t status;
-
- uint32_t ca;
- uint32_t ca_count = 0;
- uint32_t port_count = 0;
- uint8_t port_num;
- uint32_t total_ports = 0;
- VAPI_hca_id_t *p_ca_ids = NULL;
- osm_ca_info_t *p_ca_infos = NULL;
- uint32_t attr_array_sz = *p_num_ports;
-
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_get_all_port_attr );
-
- CL_ASSERT( p_vend );
-
-
- /* determine the number of CA's */
- status = __osm_vendor_get_ca_ids( p_vend, &p_ca_ids, &ca_count );
- if( status != IB_SUCCESS )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_all_port_attr: ERR 3D13: "
- "Fail to get CA Ids.\n" );
- goto Exit;
- }
-
- /* Allocate an array big enough to hold the ca info objects*/
- p_ca_infos = malloc( ca_count * sizeof( osm_ca_info_t ) );
- if( p_ca_infos == NULL )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_all_port_attr: ERR 3D14: "
- "Unable to allocate CA information array.\n" );
- goto Exit;
- }
-
- memset( p_ca_infos, 0, ca_count * sizeof( osm_ca_info_t ) );
-
- /*
- * For each CA, retrieve the CA info attributes
- */
- for( ca = 0; ca < ca_count; ca++ )
- {
- status = __osm_ca_info_init( p_vend, p_ca_ids[ca], &p_ca_infos[ca] );
- if( status != IB_SUCCESS )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_all_port_attr: ERR 3D15: "
- "Unable to initialize CA Info object (%s).\n",
- ib_get_err_str( status ) );
- goto Exit;
- }
- total_ports += p_ca_infos[ca].p_attr->num_ports;
- }
-
- *p_num_ports = total_ports;
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_get_all_port_attr: total ports:%u \n",total_ports);
-
- /*
- * If the user supplied enough storage, return the port guids,
- * otherwise, return the appropriate error.
- */
- if( attr_array_sz >= total_ports )
- {
- for( ca = 0; ca < ca_count; ca++ )
- {
- uint32_t num_ports;
-
- num_ports = p_ca_infos[ca].p_attr->num_ports;
-
- for( port_num = 0; port_num < num_ports; port_num++ )
- {
- p_attr_array[port_count] =
- *__osm_ca_info_get_port_attr_ptr( &p_ca_infos[ca], port_num );
- port_count++;
- }
- }
- }
- else
- {
- status = IB_INSUFFICIENT_MEMORY;
- goto Exit;
- }
-
- status = IB_SUCCESS;
-
- Exit:
- if( p_ca_ids )
- free( p_ca_ids );
-
- if ( p_ca_infos )
- {
- osm_ca_info_destroy(p_vend, p_ca_infos, ca_count);
- }
-
- OSM_LOG_EXIT( p_vend->p_log );
- return ( status );
+ ib_api_status_t status;
+
+ uint32_t ca;
+ uint32_t ca_count = 0;
+ uint32_t port_count = 0;
+ uint8_t port_num;
+ uint32_t total_ports = 0;
+ VAPI_hca_id_t *p_ca_ids = NULL;
+ osm_ca_info_t *p_ca_infos = NULL;
+ uint32_t attr_array_sz = *p_num_ports;
+
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_get_all_port_attr);
+
+ CL_ASSERT(p_vend);
+
+ /* determine the number of CA's */
+ status = __osm_vendor_get_ca_ids(p_vend, &p_ca_ids, &ca_count);
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_all_port_attr: ERR 3D13: "
+ "Fail to get CA Ids.\n");
+ goto Exit;
+ }
+
+ /* Allocate an array big enough to hold the ca info objects */
+ p_ca_infos = malloc(ca_count * sizeof(osm_ca_info_t));
+ if (p_ca_infos == NULL) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_all_port_attr: ERR 3D14: "
+ "Unable to allocate CA information array.\n");
+ goto Exit;
+ }
+
+ memset(p_ca_infos, 0, ca_count * sizeof(osm_ca_info_t));
+
+ /*
+ * For each CA, retrieve the CA info attributes
+ */
+ for (ca = 0; ca < ca_count; ca++) {
+ status =
+ __osm_ca_info_init(p_vend, p_ca_ids[ca], &p_ca_infos[ca]);
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_all_port_attr: ERR 3D15: "
+ "Unable to initialize CA Info object (%s).\n",
+ ib_get_err_str(status));
+ goto Exit;
+ }
+ total_ports += p_ca_infos[ca].p_attr->num_ports;
+ }
+
+ *p_num_ports = total_ports;
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_get_all_port_attr: total ports:%u \n", total_ports);
+
+ /*
+ * If the user supplied enough storage, return the port guids,
+ * otherwise, return the appropriate error.
+ */
+ if (attr_array_sz >= total_ports) {
+ for (ca = 0; ca < ca_count; ca++) {
+ uint32_t num_ports;
+
+ num_ports = p_ca_infos[ca].p_attr->num_ports;
+
+ for (port_num = 0; port_num < num_ports; port_num++) {
+ p_attr_array[port_count] =
+ *__osm_ca_info_get_port_attr_ptr(&p_ca_infos
+ [ca],
+ port_num);
+ port_count++;
+ }
+ }
+ } else {
+ status = IB_INSUFFICIENT_MEMORY;
+ goto Exit;
+ }
+
+ status = IB_SUCCESS;
+
+ Exit:
+ if (p_ca_ids)
+ free(p_ca_ids);
+
+ if (p_ca_infos) {
+ osm_ca_info_destroy(p_vend, p_ca_infos, ca_count);
+ }
+
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
}
/**********************************************************************
@@ -427,131 +399,126 @@ osm_vendor_get_all_port_attr( IN osm_vendor_t * const p_vend,
**********************************************************************/
ib_api_status_t
-osm_vendor_get_guid_ca_and_port(
- IN osm_vendor_t * const p_vend,
- IN ib_net64_t const guid,
- OUT VAPI_hca_hndl_t * p_hca_hndl,
- OUT VAPI_hca_id_t * p_hca_id,
- OUT uint8_t *p_hca_idx,
- OUT uint32_t * p_port_num )
+osm_vendor_get_guid_ca_and_port(IN osm_vendor_t * const p_vend,
+ IN ib_net64_t const guid,
+ OUT VAPI_hca_hndl_t * p_hca_hndl,
+ OUT VAPI_hca_id_t * p_hca_id,
+ OUT uint8_t * p_hca_idx,
+ OUT uint32_t * p_port_num)
{
- ib_api_status_t status;
- VAPI_hca_id_t *p_ca_ids = NULL;
- VAPI_ret_t vapi_res;
- VAPI_hca_hndl_t hca_hndl;
- VAPI_hca_vendor_t hca_vendor;
- VAPI_hca_cap_t hca_cap;
- IB_gid_t *p_port_gid = NULL;
- uint16_t maxNumGids;
- ib_net64_t port_guid;
- uint32_t ca, portIdx, ca_count;
-
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_get_guid_ca_and_port );
-
- CL_ASSERT( p_vend );
-
- /*
- * 1) Determine the number of CA's
- * 2) Allocate an array big enough to hold the ca info objects.
- * 3) Call again to retrieve the guids.
- */
- status = __osm_vendor_get_ca_ids( p_vend, &p_ca_ids, &ca_count );
- if( status != IB_SUCCESS )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_guid_ca_and_port: ERR 3D16: "
- "Fail to get CA Ids.\n" );
- goto Exit;
- }
-
- /*
- * For each CA, retrieve the CA info attributes
- */
- for( ca = 0; ca < ca_count; ca++ )
- {
- /* get the HCA handle */
- vapi_res = EVAPI_get_hca_hndl( p_ca_ids[ca], &hca_hndl );
- if( vapi_res != VAPI_OK )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_guid_ca_and_port: ERR 3D17: "
- "Fail to get HCA handle (%u).\n", vapi_res );
- goto Exit;
- }
-
- /* get the CA attributes - to know how many ports it has: */
- if( osm_log_is_active( p_vend->p_log, OSM_LOG_DEBUG) )
- {
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_get_guid_ca_and_port: "
- "Querying CA %s.\n", p_ca_ids[ca] );
- }
-
- /* query and get the HCA capability */
- vapi_res = VAPI_query_hca_cap( hca_hndl, &hca_vendor, &hca_cap );
- if( vapi_res != VAPI_OK )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_guid_ca_and_port: ERR 3D18: "
- "Fail to get HCA Capabilities (%u).\n", vapi_res );
- goto Exit;
- }
-
- /* go over all ports - to obtail their guids */
- for( portIdx = 0; portIdx < hca_cap.phys_port_num; portIdx++ )
- {
- vapi_res =
- VAPI_query_hca_gid_tbl( hca_hndl, portIdx + 1, 0, &maxNumGids,
- NULL );
- p_port_gid =
- ( IB_gid_t * ) malloc( maxNumGids * sizeof( IB_gid_t ) );
-
- /* get the port guid */
- vapi_res =
- VAPI_query_hca_gid_tbl( hca_hndl, portIdx + 1, maxNumGids,
- &maxNumGids, p_port_gid );
- if( vapi_res != VAPI_OK )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_guid_ca_and_port: ERR 3D19: "
- "Fail to get HCA Port GID (%d).\n", vapi_res );
- goto Exit;
- }
-
- /* convert to SF style */
- __osm_vendor_gid_to_guid( p_port_gid[0],
- ( VAPI_gid_t * ) & port_guid );
-
- /* finally did we find it ? */
- if( port_guid == guid )
- {
- *p_hca_hndl = hca_hndl;
- memcpy( p_hca_id, p_ca_ids[ca], sizeof ( VAPI_hca_id_t ) );
- *p_hca_idx = ca;
- *p_port_num = portIdx + 1;
- status = IB_SUCCESS;
- goto Exit;
- }
-
- free( p_port_gid );
- p_port_gid = NULL;
- } /* ALL PORTS */
- } /* all HCAs */
-
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_guid_ca_and_port: ERR 3D20: "
- "Fail to find HCA and Port for Port Guid 0x%" PRIx64 "\n",
- cl_ntoh64(guid) );
- status = IB_INVALID_GUID;
-
- Exit:
- if( p_ca_ids != NULL )
- free( p_ca_ids );
- if( p_port_gid != NULL )
- free( p_port_gid );
- OSM_LOG_EXIT( p_vend->p_log );
- return ( status );
+ ib_api_status_t status;
+ VAPI_hca_id_t *p_ca_ids = NULL;
+ VAPI_ret_t vapi_res;
+ VAPI_hca_hndl_t hca_hndl;
+ VAPI_hca_vendor_t hca_vendor;
+ VAPI_hca_cap_t hca_cap;
+ IB_gid_t *p_port_gid = NULL;
+ uint16_t maxNumGids;
+ ib_net64_t port_guid;
+ uint32_t ca, portIdx, ca_count;
+
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_get_guid_ca_and_port);
+
+ CL_ASSERT(p_vend);
+
+ /*
+ * 1) Determine the number of CA's
+ * 2) Allocate an array big enough to hold the ca info objects.
+ * 3) Call again to retrieve the guids.
+ */
+ status = __osm_vendor_get_ca_ids(p_vend, &p_ca_ids, &ca_count);
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_guid_ca_and_port: ERR 3D16: "
+ "Fail to get CA Ids.\n");
+ goto Exit;
+ }
+
+ /*
+ * For each CA, retrieve the CA info attributes
+ */
+ for (ca = 0; ca < ca_count; ca++) {
+ /* get the HCA handle */
+ vapi_res = EVAPI_get_hca_hndl(p_ca_ids[ca], &hca_hndl);
+ if (vapi_res != VAPI_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_guid_ca_and_port: ERR 3D17: "
+ "Fail to get HCA handle (%u).\n", vapi_res);
+ goto Exit;
+ }
+
+ /* get the CA attributes - to know how many ports it has: */
+ if (osm_log_is_active(p_vend->p_log, OSM_LOG_DEBUG)) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_get_guid_ca_and_port: "
+ "Querying CA %s.\n", p_ca_ids[ca]);
+ }
+
+ /* query and get the HCA capability */
+ vapi_res = VAPI_query_hca_cap(hca_hndl, &hca_vendor, &hca_cap);
+ if (vapi_res != VAPI_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_guid_ca_and_port: ERR 3D18: "
+ "Fail to get HCA Capabilities (%u).\n",
+ vapi_res);
+ goto Exit;
+ }
+
+ /* go over all ports - to obtail their guids */
+ for (portIdx = 0; portIdx < hca_cap.phys_port_num; portIdx++) {
+ vapi_res =
+ VAPI_query_hca_gid_tbl(hca_hndl, portIdx + 1, 0,
+ &maxNumGids, NULL);
+ p_port_gid =
+ (IB_gid_t *) malloc(maxNumGids * sizeof(IB_gid_t));
+
+ /* get the port guid */
+ vapi_res =
+ VAPI_query_hca_gid_tbl(hca_hndl, portIdx + 1,
+ maxNumGids, &maxNumGids,
+ p_port_gid);
+ if (vapi_res != VAPI_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_guid_ca_and_port: ERR 3D19: "
+ "Fail to get HCA Port GID (%d).\n",
+ vapi_res);
+ goto Exit;
+ }
+
+ /* convert to SF style */
+ __osm_vendor_gid_to_guid(p_port_gid[0],
+ (VAPI_gid_t *) & port_guid);
+
+ /* finally did we find it ? */
+ if (port_guid == guid) {
+ *p_hca_hndl = hca_hndl;
+ memcpy(p_hca_id, p_ca_ids[ca],
+ sizeof(VAPI_hca_id_t));
+ *p_hca_idx = ca;
+ *p_port_num = portIdx + 1;
+ status = IB_SUCCESS;
+ goto Exit;
+ }
+
+ free(p_port_gid);
+ p_port_gid = NULL;
+ } /* ALL PORTS */
+ } /* all HCAs */
+
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_guid_ca_and_port: ERR 3D20: "
+ "Fail to find HCA and Port for Port Guid 0x%" PRIx64 "\n",
+ cl_ntoh64(guid));
+ status = IB_INVALID_GUID;
+
+ Exit:
+ if (p_ca_ids != NULL)
+ free(p_ca_ids);
+ if (p_port_gid != NULL)
+ free(p_port_gid);
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
}
#endif
diff --git a/opensm/libvendor/osm_vendor_mlx_hca_anafa.c b/opensm/libvendor/osm_vendor_mlx_hca_anafa.c
index 64b9f64..ca3b4ea 100644
--- a/opensm/libvendor/osm_vendor_mlx_hca_anafa.c
+++ b/opensm/libvendor/osm_vendor_mlx_hca_anafa.c
@@ -33,10 +33,9 @@
*
*/
-
#if HAVE_CONFIG_H
# include <config.h>
-#endif /* HAVE_CONFIG_H */
+#endif /* HAVE_CONFIG_H */
#if defined(OSM_VENDOR_INTF_ANAFA)
#undef IN
@@ -69,9 +68,9 @@ typedef struct _osm_ca_info {
* Convert the given GID to GUID by copy of it's upper 8 bytes
**********************************************************************/
ib_api_status_t
-__osm_vendor_gid_to_guid (IN tTS_IB_GID gid, OUT ib_net64_t * p_guid)
+__osm_vendor_gid_to_guid(IN tTS_IB_GID gid, OUT ib_net64_t * p_guid)
{
- memcpy (p_guid, gid + 8, 8);
+ memcpy(p_guid, gid + 8, 8);
return (IB_SUCCESS);
}
@@ -79,8 +78,8 @@ __osm_vendor_gid_to_guid (IN tTS_IB_GID gid, OUT ib_net64_t * p_guid)
* Initialize an Info Struct for the Given HCA by its Id
**********************************************************************/
static ib_api_status_t
-__osm_ca_info_init (IN osm_vendor_t * const p_vend,
- OUT osm_ca_info_t * const p_ca_info)
+__osm_ca_info_init(IN osm_vendor_t * const p_vend,
+ OUT osm_ca_info_t * const p_ca_info)
{
ib_api_status_t status = IB_ERROR;
int ioctl_ret = 0;
@@ -90,50 +89,49 @@ __osm_ca_info_init (IN osm_vendor_t * const p_vend,
osm_ts_get_port_info_ioctl port_info;
struct ib_get_dev_info_ioctl dev_info;
- OSM_LOG_ENTER (p_vend->p_log, __osm_ca_info_init);
+ OSM_LOG_ENTER(p_vend->p_log, __osm_ca_info_init);
/* query HCA guid */
- ioctl_ret =
- ioctl (p_tpot_info->device_fd, TS_IB_IOCGDEVINFO, &dev_info);
+ ioctl_ret = ioctl(p_tpot_info->device_fd, TS_IB_IOCGDEVINFO, &dev_info);
if (ioctl_ret != 0) {
- osm_log (p_vend->p_log, OSM_LOG_ERROR,
- "__osm_ca_info_init: ERR 7001: "
- "Fail to get HCA Capabilities (%d).\n", ioctl_ret);
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_ca_info_init: ERR 7001: "
+ "Fail to get HCA Capabilities (%d).\n", ioctl_ret);
goto Exit;
}
- memcpy (&(p_ca_info->attr.ca_guid), dev_info.dev_info.node_guid,
- 8 * sizeof (uint8_t));
+ memcpy(&(p_ca_info->attr.ca_guid), dev_info.dev_info.node_guid,
+ 8 * sizeof(uint8_t));
/* now obtain the attributes of the ports - on our case port 1*/
p_ca_info->attr.num_ports = 1;
p_ca_info->attr.p_port_attr =
- (ib_port_attr_t *) malloc (1 * sizeof (ib_port_attr_t));
+ (ib_port_attr_t *) malloc(1 * sizeof(ib_port_attr_t));
port_info.port = 1;
ioctl_ret =
- ioctl (p_tpot_info->device_fd, TS_IB_IOCGPORTINFO, &port_info);
+ ioctl(p_tpot_info->device_fd, TS_IB_IOCGPORTINFO, &port_info);
if (ioctl_ret) {
- osm_log (p_vend->p_log, OSM_LOG_ERROR,
- "__osm_ca_info_init: ERR 7002: "
- "Fail to get HCA Port Attributes (%d).\n", ioctl_ret);
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_ca_info_init: ERR 7002: "
+ "Fail to get HCA Port Attributes (%d).\n", ioctl_ret);
goto Exit;
}
gid_ioctl.port = 1;
gid_ioctl.index = 0;
ioctl_ret =
- ioctl (p_tpot_info->device_fd, TS_IB_IOCGGIDENTRY, &gid_ioctl);
+ ioctl(p_tpot_info->device_fd, TS_IB_IOCGGIDENTRY, &gid_ioctl);
if (ioctl_ret) {
- osm_log (p_vend->p_log, OSM_LOG_ERROR,
- "__osm_ca_info_init: ERR 7003: "
- "Fail to get HCA Port GID (%d).\n", ioctl_ret);
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_ca_info_init: ERR 7003: "
+ "Fail to get HCA Port GID (%d).\n", ioctl_ret);
goto Exit;
}
- __osm_vendor_gid_to_guid (gid_ioctl.gid_entry,
- &(p_ca_info->attr.p_port_attr[0].port_guid));
+ __osm_vendor_gid_to_guid(gid_ioctl.gid_entry,
+ &(p_ca_info->attr.p_port_attr[0].port_guid));
p_ca_info->attr.p_port_attr[0].lid = port_info.port_info.lid;
p_ca_info->attr.p_port_attr[0].link_state =
port_info.port_info.port_state;
@@ -141,7 +139,7 @@ __osm_ca_info_init (IN osm_vendor_t * const p_vend,
status = IB_SUCCESS;
Exit:
- OSM_LOG_EXIT (p_vend->p_log);
+ OSM_LOG_EXIT(p_vend->p_log);
return (status);
}
@@ -153,16 +151,16 @@ __osm_ca_info_init (IN osm_vendor_t * const p_vend,
* Update the vendor object list of ca_info structs
**********************************************************************/
ib_api_status_t
-osm_vendor_get_all_port_attr (IN osm_vendor_t * const p_vend,
- IN ib_port_attr_t * const p_attr_array,
- IN uint32_t *const p_num_ports)
+osm_vendor_get_all_port_attr(IN osm_vendor_t * const p_vend,
+ IN ib_port_attr_t * const p_attr_array,
+ IN uint32_t * const p_num_ports)
{
ib_api_status_t status;
osm_ca_info_t ca_info;
uint32_t attr_array_sz = *p_num_ports;
- OSM_LOG_ENTER (p_vend->p_log, osm_vendor_get_all_port_attr);
- CL_ASSERT (p_vend);
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_get_all_port_attr);
+ CL_ASSERT(p_vend);
/* anafa has one port - the user didnt supply enough storage space */
if (attr_array_sz < 1) {
@@ -173,23 +171,23 @@ osm_vendor_get_all_port_attr (IN osm_vendor_t * const p_vend,
/*
* retrieve the CA info attributes
*/
- status = __osm_ca_info_init (p_vend, &ca_info);
+ status = __osm_ca_info_init(p_vend, &ca_info);
if (status != IB_SUCCESS) {
- osm_log (p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_all_port_attr: ERR 7004: "
- "Unable to initialize CA Info object (%s).\n",
- ib_get_err_str (status));
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_all_port_attr: ERR 7004: "
+ "Unable to initialize CA Info object (%s).\n",
+ ib_get_err_str(status));
goto Exit;
}
*p_num_ports = 1;
- p_attr_array[0] = ca_info.attr.p_port_attr[0]; /* anafa has only one port */
+ p_attr_array[0] = ca_info.attr.p_port_attr[0]; /* anafa has only one port */
status = IB_SUCCESS;
Exit:
- OSM_LOG_EXIT (p_vend->p_log);
+ OSM_LOG_EXIT(p_vend->p_log);
return (status);
}
diff --git a/opensm/libvendor/osm_vendor_mlx_hca_pfs.c b/opensm/libvendor/osm_vendor_mlx_hca_pfs.c
index af1cdb0..275bf92 100644
--- a/opensm/libvendor/osm_vendor_mlx_hca_pfs.c
+++ b/opensm/libvendor/osm_vendor_mlx_hca_pfs.c
@@ -33,10 +33,9 @@
*
*/
-
#if HAVE_CONFIG_H
# include <config.h>
-#endif /* HAVE_CONFIG_H */
+#endif /* HAVE_CONFIG_H */
#if defined(OSM_VENDOR_INTF_MTL) | defined(OSM_VENDOR_INTF_TS)
#undef IN
@@ -60,24 +59,22 @@
*
********************************************************************************/
-typedef struct _osm_ca_info
-{
- ib_net64_t guid;
- size_t attr_size;
- ib_ca_attr_t *p_attr;
+typedef struct _osm_ca_info {
+ ib_net64_t guid;
+ size_t attr_size;
+ ib_ca_attr_t *p_attr;
-}
-osm_ca_info_t;
+} osm_ca_info_t;
/**********************************************************************
* Returns a pointer to the port attribute of the specified port
* owned by this CA.
************************************************************************/
-static ib_port_attr_t *
-__osm_ca_info_get_port_attr_ptr( IN const osm_ca_info_t * const p_ca_info,
- IN const uint8_t index )
+static ib_port_attr_t *__osm_ca_info_get_port_attr_ptr(IN const osm_ca_info_t *
+ const p_ca_info,
+ IN const uint8_t index)
{
- return ( &p_ca_info->p_attr->p_port_attr[index] );
+ return (&p_ca_info->p_attr->p_port_attr[index]);
}
/**********************************************************************
@@ -85,24 +82,22 @@ __osm_ca_info_get_port_attr_ptr( IN const osm_ca_info_t * const p_ca_info,
**********************************************************************/
int __hca_pfs_get_num_cas()
{
- int num_cas = 0;
- DIR *dp;
- struct dirent *ep;
-
- dp = opendir ("/proc/infiniband/core");
- if (dp != NULL)
- {
- while ((ep = readdir (dp)))
- {
- /* CAs are directories with the format ca[1-9][0-9]* */
- if ((ep->d_type == DT_DIR) && !strncmp(ep->d_name, "ca", 2))
- {
- num_cas++;
- }
- }
- closedir(dp);
- }
- return num_cas;
+ int num_cas = 0;
+ DIR *dp;
+ struct dirent *ep;
+
+ dp = opendir("/proc/infiniband/core");
+ if (dp != NULL) {
+ while ((ep = readdir(dp))) {
+ /* CAs are directories with the format ca[1-9][0-9]* */
+ if ((ep->d_type == DT_DIR)
+ && !strncmp(ep->d_name, "ca", 2)) {
+ num_cas++;
+ }
+ }
+ closedir(dp);
+ }
+ return num_cas;
}
/*
@@ -116,126 +111,120 @@ int __hca_pfs_get_num_cas()
FW revision: 0x300020080
*/
typedef struct _pfs_ca_info {
- char name[32];
- char provider[32];
- uint64_t guid;
- uint8_t num_ports;
- uint32_t vend_id;
- uint16_t dev_id;
- uint16_t rev_id;
- uint64_t fw_rev;
+ char name[32];
+ char provider[32];
+ uint64_t guid;
+ uint8_t num_ports;
+ uint32_t vend_id;
+ uint16_t dev_id;
+ uint16_t rev_id;
+ uint64_t fw_rev;
} pfs_ca_info_t;
/**********************************************************************
* Parse the CA Info file available in /proc/infiniband/core/caN/info
**********************************************************************/
static ib_api_status_t
-__parse_ca_info_file(
- IN osm_vendor_t * const p_vend,
- IN uint32_t idx,
- OUT pfs_ca_info_t *pfs_ca_info)
+__parse_ca_info_file(IN osm_vendor_t * const p_vend,
+ IN uint32_t idx, OUT pfs_ca_info_t * pfs_ca_info)
{
- ib_api_status_t status = IB_ERROR;
- int info_file;
- char file_name[256];
- char file_buffer[3200];
- char *p_ch;
- int g1,g2,g3,g4;
- int num_ports;
- uint32_t len;
-
- OSM_LOG_ENTER( p_vend->p_log, __parse_ca_info_file );
-
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "__parse_ca_info_file: " "Querying CA %d.\n", idx );
-
- /* we use the proc file system so we must be able to open the info file .. */
- sprintf(file_name, "/proc/infiniband/core/ca%d/info", idx);
- info_file = open(file_name, O_RDONLY);
- if (! info_file)
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__parse_ca_info_file: ERR 5205: "
- "Fail to open HCA:%d info file:(%s).\n", idx, file_name);
- goto Exit;
- }
-
- /* read in the file */
- len = read(info_file, file_buffer, 3200);
- close(info_file);
- file_buffer[len] = '\0';
-
- /*
- parse the file ...
- name: InfiniHost0
- provider: tavor
- node GUID: 0002:c900:0120:3470
- ports: 2
- vendor ID: 0x2c9
- device ID: 0x5a44
- HW revision: 0xa1
- FW revision: 0x300020080
- */
- if (!(p_ch = strstr(file_buffer, "name:")))
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__parse_ca_info_file: ERR 5206: "
- "Fail to obtain HCA name. In info file:(%s).\n", file_buffer);
- goto Exit;
- }
- if (sscanf(p_ch,"name: %s", pfs_ca_info->name) != 1)
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__parse_ca_info_file: ERR 5207: "
- "Fail to parse name in info file:(%s).\n", p_ch);
- goto Exit;
- }
-
- /* get the guid of the HCA */
- if (!(p_ch = strstr(file_buffer, "node GUID:")))
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__parse_ca_info_file: ERR 5208: "
- "Fail to obtain GUID in info file:(%s).\n", file_buffer);
- goto Exit;
- }
- if (sscanf(p_ch, "node GUID: %x:%x:%x:%x", &g1,&g2,&g3,&g4) != 4)
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__parse_ca_info_file: ERR 5209: "
- "Fail to parse GUID in info file:(%s).\n", p_ch);
- goto Exit;
- }
- pfs_ca_info->guid = (uint64_t)g1 << 48 | (uint64_t)g1 << 32
- | (uint64_t)g1 << 16 | (uint64_t)g3 ;
-
- /* obtain number of ports */
- if (!(p_ch = strstr(file_buffer, "ports:")))
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__parse_ca_info_file: ERR 5210: "
- "Fail to obtain number of ports in info file:(%s).\n", file_buffer);
- goto Exit;
- }
- if (sscanf(p_ch, "ports: %d", &num_ports) != 1)
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__parse_ca_info_file: ERR 5211: "
- "Fail to parse num ports in info file:(%s).\n", p_ch);
- goto Exit;
- }
- pfs_ca_info->num_ports = num_ports;
-
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "__parse_ca_info_file: "
- "CA1 = name:%s guid:0x%016llx ports:%d\n",
- pfs_ca_info->name, pfs_ca_info->guid, pfs_ca_info->num_ports
- );
-
- status = IB_SUCCESS;
-Exit:
- OSM_LOG_EXIT( p_vend->p_log );
- return status;
+ ib_api_status_t status = IB_ERROR;
+ int info_file;
+ char file_name[256];
+ char file_buffer[3200];
+ char *p_ch;
+ int g1, g2, g3, g4;
+ int num_ports;
+ uint32_t len;
+
+ OSM_LOG_ENTER(p_vend->p_log, __parse_ca_info_file);
+
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__parse_ca_info_file: " "Querying CA %d.\n", idx);
+
+ /* we use the proc file system so we must be able to open the info file .. */
+ sprintf(file_name, "/proc/infiniband/core/ca%d/info", idx);
+ info_file = open(file_name, O_RDONLY);
+ if (!info_file) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_ca_info_file: ERR 5205: "
+ "Fail to open HCA:%d info file:(%s).\n", idx,
+ file_name);
+ goto Exit;
+ }
+
+ /* read in the file */
+ len = read(info_file, file_buffer, 3200);
+ close(info_file);
+ file_buffer[len] = '\0';
+
+ /*
+ parse the file ...
+ name: InfiniHost0
+ provider: tavor
+ node GUID: 0002:c900:0120:3470
+ ports: 2
+ vendor ID: 0x2c9
+ device ID: 0x5a44
+ HW revision: 0xa1
+ FW revision: 0x300020080
+ */
+ if (!(p_ch = strstr(file_buffer, "name:"))) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_ca_info_file: ERR 5206: "
+ "Fail to obtain HCA name. In info file:(%s).\n",
+ file_buffer);
+ goto Exit;
+ }
+ if (sscanf(p_ch, "name: %s", pfs_ca_info->name) != 1) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_ca_info_file: ERR 5207: "
+ "Fail to parse name in info file:(%s).\n", p_ch);
+ goto Exit;
+ }
+
+ /* get the guid of the HCA */
+ if (!(p_ch = strstr(file_buffer, "node GUID:"))) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_ca_info_file: ERR 5208: "
+ "Fail to obtain GUID in info file:(%s).\n",
+ file_buffer);
+ goto Exit;
+ }
+ if (sscanf(p_ch, "node GUID: %x:%x:%x:%x", &g1, &g2, &g3, &g4) != 4) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_ca_info_file: ERR 5209: "
+ "Fail to parse GUID in info file:(%s).\n", p_ch);
+ goto Exit;
+ }
+ pfs_ca_info->guid = (uint64_t) g1 << 48 | (uint64_t) g1 << 32
+ | (uint64_t) g1 << 16 | (uint64_t) g3;
+
+ /* obtain number of ports */
+ if (!(p_ch = strstr(file_buffer, "ports:"))) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_ca_info_file: ERR 5210: "
+ "Fail to obtain number of ports in info file:(%s).\n",
+ file_buffer);
+ goto Exit;
+ }
+ if (sscanf(p_ch, "ports: %d", &num_ports) != 1) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_ca_info_file: ERR 5211: "
+ "Fail to parse num ports in info file:(%s).\n", p_ch);
+ goto Exit;
+ }
+ pfs_ca_info->num_ports = num_ports;
+
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__parse_ca_info_file: "
+ "CA1 = name:%s guid:0x%016llx ports:%d\n",
+ pfs_ca_info->name, pfs_ca_info->guid, pfs_ca_info->num_ports);
+
+ status = IB_SUCCESS;
+ Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return status;
}
/*
@@ -254,11 +243,11 @@ Exit:
IsCapabilityMaskNoticeSupported
*/
typedef struct _pfs_port_info {
- uint8_t state;
- uint16_t lid;
- uint8_t lmc;
- uint16_t sm_lid;
- uint8_t sm_sl;
+ uint8_t state;
+ uint16_t lid;
+ uint8_t lmc;
+ uint16_t sm_lid;
+ uint8_t sm_sl;
} pfs_port_info_t;
/**********************************************************************
@@ -266,156 +255,150 @@ typedef struct _pfs_port_info {
* Port num is 1..N
**********************************************************************/
static ib_api_status_t
-__parse_port_info_file(
- IN osm_vendor_t * const p_vend,
- IN uint32_t hca_idx,
- IN uint8_t port_num,
- OUT pfs_port_info_t *pfs_port_info)
+__parse_port_info_file(IN osm_vendor_t * const p_vend,
+ IN uint32_t hca_idx,
+ IN uint8_t port_num, OUT pfs_port_info_t * pfs_port_info)
{
- ib_api_status_t status = IB_ERROR;
- int info_file;
- char file_name[256];
- char file_buffer[3200];
- char state[12];
- char *p_ch;
- int lid, sm_lid, lmc, sm_sl;
- uint32_t len;
-
- OSM_LOG_ENTER( p_vend->p_log, __parse_port_info_file );
-
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "__parse_port_info_file: "
- "Parsing Proc File System Port Info CA %d Port %d.\n", hca_idx, port_num );
-
- /* we use the proc file system so we must be able to open the info file .. */
- sprintf(file_name, "/proc/infiniband/core/ca%d/port%d/info", hca_idx, port_num);
- info_file = open(file_name, O_RDONLY);
- if (! info_file)
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__parse_port_info_file: ERR 5212: "
- "Fail to open HCA:%d Port:%d info file:(%s).\n", hca_idx, port_num,
- file_name);
- goto Exit;
- }
-
- /* read in the file */
- len = read(info_file, file_buffer, 3200);
- close(info_file);
- file_buffer[len] = '\0';
-
- /*
- parse the file ...
- state: ACTIVE
- LID: 0x0001
- LMC: 0x0000
- SM LID: 0x0001
- SM SL: 0x0000
- ...
- */
- if (!(p_ch = strstr(file_buffer, "state:")))
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__parse_port_info_file: ERR 5213: "
- "Fail to obtain port state. In info file:(%s).\n", file_buffer);
- goto Exit;
- }
- if (sscanf(p_ch,"state: %s", state) != 1)
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__parse_port_info_file: ERR 5214: "
- "Fail to parse state from info file:(%s).\n", p_ch);
- goto Exit;
- }
-
- if (!strcmp(state, "ACTIVE"))
- pfs_port_info->state = IB_LINK_ACTIVE;
- else if (!strcmp(state, "DOWN"))
- pfs_port_info->state = IB_LINK_DOWN;
- else if (!strcmp(state, "INIT"))
- pfs_port_info->state = IB_LINK_INIT;
- else if (!strcmp(state, "ARMED"))
- pfs_port_info->state = IB_LINK_ARMED;
- else
- pfs_port_info->state = 0;
-
- /* get lid */
- if (!(p_ch = strstr(file_buffer, "LID:")))
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__parse_port_info_file: ERR 5215: "
- "Fail to obtain port lid. In info file:(%s).\n", file_buffer);
- goto Exit;
- }
- if (sscanf(p_ch,"LID: %x", &lid) != 1)
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__parse_port_info_file: ERR 5216: "
- "Fail to parse lid from info file:(%s).\n", p_ch);
- goto Exit;
- }
- pfs_port_info->lid = lid;
- /* get LMC */
- if (!(p_ch = strstr(file_buffer, "LMC:")))
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__parse_port_info_file: ERR 5217: "
- "Fail to obtain port LMC. In info file:(%s).\n", file_buffer);
- goto Exit;
- }
- if (sscanf(p_ch,"LMC: %x", &lmc) != 1)
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__parse_port_info_file: ERR 5218: "
- "Fail to parse LMC from info file:(%s).\n", p_ch);
- goto Exit;
- }
- pfs_port_info->lmc = lmc;
-
- /* get SM LID */
- if (!(p_ch = strstr(file_buffer, "SM LID:")))
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__parse_port_info_file: ERR 5219: "
- "Fail to obtain port SM LID. In info file:(%s).\n", file_buffer);
- goto Exit;
- }
- if (sscanf(p_ch,"SM LID: %x", &sm_lid) != 1)
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__parse_port_info_file: ERR 5220: "
- "Fail to parse SM LID from info file:(%s).\n", p_ch);
- goto Exit;
- }
- pfs_port_info->sm_lid = sm_lid;
-
- /* get SM LID */
- if (!(p_ch = strstr(file_buffer, "SM SL:")))
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__parse_port_info_file: ERR 5221: "
- "Fail to obtain port SM SL. In info file:(%s).\n", file_buffer);
- goto Exit;
- }
- if (sscanf(p_ch,"SM SL: %x", &sm_sl) != 1)
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__parse_port_info_file: ERR 5222: "
- "Fail to parse SM SL from info file:(%s).\n", p_ch);
- goto Exit;
- }
- pfs_port_info->sm_sl = sm_sl;
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "__parse_port_info_file: "
- "Obtained Port:%d = state:%d, lid:0x%04X, lmc:%d, sm_lid:0x%04X, sm_sl:%d\n",
- port_num, pfs_port_info->state, pfs_port_info->lid,
- pfs_port_info->lmc, pfs_port_info->sm_lid, pfs_port_info->sm_sl
- );
-
- status = IB_SUCCESS;
- Exit:
- OSM_LOG_EXIT( p_vend->p_log );
- return status;
+ ib_api_status_t status = IB_ERROR;
+ int info_file;
+ char file_name[256];
+ char file_buffer[3200];
+ char state[12];
+ char *p_ch;
+ int lid, sm_lid, lmc, sm_sl;
+ uint32_t len;
+
+ OSM_LOG_ENTER(p_vend->p_log, __parse_port_info_file);
+
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__parse_port_info_file: "
+ "Parsing Proc File System Port Info CA %d Port %d.\n", hca_idx,
+ port_num);
+
+ /* we use the proc file system so we must be able to open the info file .. */
+ sprintf(file_name, "/proc/infiniband/core/ca%d/port%d/info", hca_idx,
+ port_num);
+ info_file = open(file_name, O_RDONLY);
+ if (!info_file) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_port_info_file: ERR 5212: "
+ "Fail to open HCA:%d Port:%d info file:(%s).\n",
+ hca_idx, port_num, file_name);
+ goto Exit;
+ }
+
+ /* read in the file */
+ len = read(info_file, file_buffer, 3200);
+ close(info_file);
+ file_buffer[len] = '\0';
+
+ /*
+ parse the file ...
+ state: ACTIVE
+ LID: 0x0001
+ LMC: 0x0000
+ SM LID: 0x0001
+ SM SL: 0x0000
+ ...
+ */
+ if (!(p_ch = strstr(file_buffer, "state:"))) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_port_info_file: ERR 5213: "
+ "Fail to obtain port state. In info file:(%s).\n",
+ file_buffer);
+ goto Exit;
+ }
+ if (sscanf(p_ch, "state: %s", state) != 1) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_port_info_file: ERR 5214: "
+ "Fail to parse state from info file:(%s).\n", p_ch);
+ goto Exit;
+ }
+
+ if (!strcmp(state, "ACTIVE"))
+ pfs_port_info->state = IB_LINK_ACTIVE;
+ else if (!strcmp(state, "DOWN"))
+ pfs_port_info->state = IB_LINK_DOWN;
+ else if (!strcmp(state, "INIT"))
+ pfs_port_info->state = IB_LINK_INIT;
+ else if (!strcmp(state, "ARMED"))
+ pfs_port_info->state = IB_LINK_ARMED;
+ else
+ pfs_port_info->state = 0;
+
+ /* get lid */
+ if (!(p_ch = strstr(file_buffer, "LID:"))) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_port_info_file: ERR 5215: "
+ "Fail to obtain port lid. In info file:(%s).\n",
+ file_buffer);
+ goto Exit;
+ }
+ if (sscanf(p_ch, "LID: %x", &lid) != 1) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_port_info_file: ERR 5216: "
+ "Fail to parse lid from info file:(%s).\n", p_ch);
+ goto Exit;
+ }
+ pfs_port_info->lid = lid;
+ /* get LMC */
+ if (!(p_ch = strstr(file_buffer, "LMC:"))) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_port_info_file: ERR 5217: "
+ "Fail to obtain port LMC. In info file:(%s).\n",
+ file_buffer);
+ goto Exit;
+ }
+ if (sscanf(p_ch, "LMC: %x", &lmc) != 1) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_port_info_file: ERR 5218: "
+ "Fail to parse LMC from info file:(%s).\n", p_ch);
+ goto Exit;
+ }
+ pfs_port_info->lmc = lmc;
+
+ /* get SM LID */
+ if (!(p_ch = strstr(file_buffer, "SM LID:"))) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_port_info_file: ERR 5219: "
+ "Fail to obtain port SM LID. In info file:(%s).\n",
+ file_buffer);
+ goto Exit;
+ }
+ if (sscanf(p_ch, "SM LID: %x", &sm_lid) != 1) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_port_info_file: ERR 5220: "
+ "Fail to parse SM LID from info file:(%s).\n", p_ch);
+ goto Exit;
+ }
+ pfs_port_info->sm_lid = sm_lid;
+
+ /* get SM LID */
+ if (!(p_ch = strstr(file_buffer, "SM SL:"))) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_port_info_file: ERR 5221: "
+ "Fail to obtain port SM SL. In info file:(%s).\n",
+ file_buffer);
+ goto Exit;
+ }
+ if (sscanf(p_ch, "SM SL: %x", &sm_sl) != 1) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_port_info_file: ERR 5222: "
+ "Fail to parse SM SL from info file:(%s).\n", p_ch);
+ goto Exit;
+ }
+ pfs_port_info->sm_sl = sm_sl;
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__parse_port_info_file: "
+ "Obtained Port:%d = state:%d, lid:0x%04X, lmc:%d, sm_lid:0x%04X, sm_sl:%d\n",
+ port_num, pfs_port_info->state, pfs_port_info->lid,
+ pfs_port_info->lmc, pfs_port_info->sm_lid,
+ pfs_port_info->sm_sl);
+
+ status = IB_SUCCESS;
+ Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return status;
}
/**********************************************************************
@@ -424,172 +407,172 @@ __parse_port_info_file(
* [ 0] fe80:0000:0000:0000:0002:c900:0120:3472
**********************************************************************/
static ib_api_status_t
-__get_port_guid_from_port_gid_tbl(
- IN osm_vendor_t * const p_vend,
- IN uint32_t hca_idx,
- IN uint8_t port_num,
- OUT uint64_t *port_guid)
+__get_port_guid_from_port_gid_tbl(IN osm_vendor_t * const p_vend,
+ IN uint32_t hca_idx,
+ IN uint8_t port_num, OUT uint64_t * port_guid)
{
- ib_api_status_t status = IB_ERROR;
- int info_file;
- char file_name[256];
- char file_buffer[3200];
- char *p_ch;
- int g[8];
- uint32_t len;
-
- OSM_LOG_ENTER( p_vend->p_log, __get_port_guid_from_port_gid_tbl );
-
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "__get_port_guid_from_port_gid_tbl: "
- "Parsing Proc File System Port Guid Table CA %d Port %d.\n",
- hca_idx, port_num );
-
- /* we use the proc file system so we must be able to open the info file .. */
- sprintf(file_name, "/proc/infiniband/core/ca%d/port%d/gid_table",
- hca_idx, port_num);
- info_file = open(file_name, O_RDONLY);
- if (! info_file)
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__get_port_guid_from_port_gid_tbl: ERR 5223: "
- "Fail to open HCA:%d Port:%d gid_table file:(%s).\n", hca_idx, port_num,
- file_name);
- goto Exit;
- }
-
- /* read in the file */
- len = read(info_file, file_buffer, 3200);
- close(info_file);
- file_buffer[len] = '\0';
-
- /*
- parse the file ...
- [ 0] fe80:0000:0000:0000:0002:c900:0120:3472
- ...
- */
- if (!(p_ch = strstr(file_buffer, "[ 0]")))
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__get_port_guid_from_port_gid_tbl: ERR 5224: "
- "Fail to obtain first gid index. In gid_table file:(%s).\n", file_buffer);
- goto Exit;
- }
- if (sscanf(p_ch+6,"%x:%x:%x:%x:%x:%x:%x:%x",
- &g[7],&g[6],&g[5],&g[4],&g[3],&g[2],&g[1],&g[0]) != 8)
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__get_port_guid_from_port_gid_tbl: ERR 5225: "
- "Fail to parse gid from gid_table file:(%s).\n", p_ch);
- goto Exit;
- }
-
- *port_guid = (uint64_t)g[3]<<48 | (uint64_t)g[2] << 32 | (uint64_t)g[1] << 16 | g[0];
- status = IB_SUCCESS;
-Exit:
- OSM_LOG_EXIT( p_vend->p_log );
- return status;
+ ib_api_status_t status = IB_ERROR;
+ int info_file;
+ char file_name[256];
+ char file_buffer[3200];
+ char *p_ch;
+ int g[8];
+ uint32_t len;
+
+ OSM_LOG_ENTER(p_vend->p_log, __get_port_guid_from_port_gid_tbl);
+
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__get_port_guid_from_port_gid_tbl: "
+ "Parsing Proc File System Port Guid Table CA %d Port %d.\n",
+ hca_idx, port_num);
+
+ /* we use the proc file system so we must be able to open the info file .. */
+ sprintf(file_name, "/proc/infiniband/core/ca%d/port%d/gid_table",
+ hca_idx, port_num);
+ info_file = open(file_name, O_RDONLY);
+ if (!info_file) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__get_port_guid_from_port_gid_tbl: ERR 5223: "
+ "Fail to open HCA:%d Port:%d gid_table file:(%s).\n",
+ hca_idx, port_num, file_name);
+ goto Exit;
+ }
+
+ /* read in the file */
+ len = read(info_file, file_buffer, 3200);
+ close(info_file);
+ file_buffer[len] = '\0';
+
+ /*
+ parse the file ...
+ [ 0] fe80:0000:0000:0000:0002:c900:0120:3472
+ ...
+ */
+ if (!(p_ch = strstr(file_buffer, "[ 0]"))) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__get_port_guid_from_port_gid_tbl: ERR 5224: "
+ "Fail to obtain first gid index. In gid_table file:(%s).\n",
+ file_buffer);
+ goto Exit;
+ }
+ if (sscanf(p_ch + 6, "%x:%x:%x:%x:%x:%x:%x:%x",
+ &g[7], &g[6], &g[5], &g[4], &g[3], &g[2], &g[1], &g[0]) != 8)
+ {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__get_port_guid_from_port_gid_tbl: ERR 5225: "
+ "Fail to parse gid from gid_table file:(%s).\n", p_ch);
+ goto Exit;
+ }
+
+ *port_guid =
+ (uint64_t) g[3] << 48 | (uint64_t) g[2] << 32 | (uint64_t) g[1] <<
+ 16 | g[0];
+ status = IB_SUCCESS;
+ Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return status;
}
/**********************************************************************
* Initialize an Info Struct for the Given HCA by its index 1..N
**********************************************************************/
static ib_api_status_t
-__osm_ca_info_init( IN osm_vendor_t * const p_vend,
- IN uint32_t const idx,
- OUT osm_ca_info_t * const p_ca_info )
+__osm_ca_info_init(IN osm_vendor_t * const p_vend,
+ IN uint32_t const idx, OUT osm_ca_info_t * const p_ca_info)
{
- ib_api_status_t status = IB_ERROR;
- uint8_t port_num;
- uint64_t port_guid;
-
- pfs_ca_info_t pfs_ca_info;
-
- OSM_LOG_ENTER( p_vend->p_log, __osm_ca_info_init );
-
- /* parse the CA info file */
- if (__parse_ca_info_file(p_vend, idx, &pfs_ca_info) != IB_SUCCESS)
- goto Exit;
-
- p_ca_info->guid = cl_hton64( pfs_ca_info.guid );
-
- /* set size of attributes and allocate them */
- p_ca_info->attr_size = 1;
- p_ca_info->p_attr = ( ib_ca_attr_t * ) malloc( sizeof( ib_ca_attr_t ) );
-
- p_ca_info->p_attr->ca_guid = p_ca_info->guid;
- p_ca_info->p_attr->num_ports = pfs_ca_info.num_ports;
-
- /* now obtain the attributes of the ports */
- p_ca_info->p_attr->p_port_attr =
- ( ib_port_attr_t * ) malloc( pfs_ca_info.num_ports * sizeof( ib_port_attr_t ) );
-
- /* get all the ports info */
- for( port_num = 1; port_num <= pfs_ca_info.num_ports; port_num++ )
- {
- pfs_port_info_t pfs_port_info;
- /* query the port attributes */
- if (__parse_port_info_file(p_vend, idx, port_num, &pfs_port_info))
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__osm_ca_info_init: ERR 5226: "
- "Fail to get HCA:%d Port:%d Attributes.\n", idx, port_num );
- goto Exit;
- }
-
- /* HACK: the lids should have been converted to network but the rest of the code
- is wrong and provdes them as is (host order) - so we stick with it. */
- p_ca_info->p_attr->p_port_attr[port_num-1].lid = pfs_port_info.lid;
- p_ca_info->p_attr->p_port_attr[port_num-1].link_state = pfs_port_info.state;
- p_ca_info->p_attr->p_port_attr[port_num-1].sm_lid = pfs_port_info.sm_lid;
-
- /* get the port guid */
- if (__get_port_guid_from_port_gid_tbl(p_vend, idx, port_num, &port_guid))
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__osm_ca_info_init: ERR 5227: "
- "Fail to get HCA:%d Port:%d Guid.\n", idx, port_num );
- goto Exit;
- }
- p_ca_info->p_attr->p_port_attr[port_num-1].port_guid =cl_hton64( port_guid );
- }
-
- status = IB_SUCCESS;
- Exit:
- OSM_LOG_EXIT( p_vend->p_log );
- return ( status );
+ ib_api_status_t status = IB_ERROR;
+ uint8_t port_num;
+ uint64_t port_guid;
+
+ pfs_ca_info_t pfs_ca_info;
+
+ OSM_LOG_ENTER(p_vend->p_log, __osm_ca_info_init);
+
+ /* parse the CA info file */
+ if (__parse_ca_info_file(p_vend, idx, &pfs_ca_info) != IB_SUCCESS)
+ goto Exit;
+
+ p_ca_info->guid = cl_hton64(pfs_ca_info.guid);
+
+ /* set size of attributes and allocate them */
+ p_ca_info->attr_size = 1;
+ p_ca_info->p_attr = (ib_ca_attr_t *) malloc(sizeof(ib_ca_attr_t));
+
+ p_ca_info->p_attr->ca_guid = p_ca_info->guid;
+ p_ca_info->p_attr->num_ports = pfs_ca_info.num_ports;
+
+ /* now obtain the attributes of the ports */
+ p_ca_info->p_attr->p_port_attr =
+ (ib_port_attr_t *) malloc(pfs_ca_info.num_ports *
+ sizeof(ib_port_attr_t));
+
+ /* get all the ports info */
+ for (port_num = 1; port_num <= pfs_ca_info.num_ports; port_num++) {
+ pfs_port_info_t pfs_port_info;
+ /* query the port attributes */
+ if (__parse_port_info_file
+ (p_vend, idx, port_num, &pfs_port_info)) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_ca_info_init: ERR 5226: "
+ "Fail to get HCA:%d Port:%d Attributes.\n", idx,
+ port_num);
+ goto Exit;
+ }
+
+ /* HACK: the lids should have been converted to network but the rest of the code
+ is wrong and provdes them as is (host order) - so we stick with it. */
+ p_ca_info->p_attr->p_port_attr[port_num - 1].lid =
+ pfs_port_info.lid;
+ p_ca_info->p_attr->p_port_attr[port_num - 1].link_state =
+ pfs_port_info.state;
+ p_ca_info->p_attr->p_port_attr[port_num - 1].sm_lid =
+ pfs_port_info.sm_lid;
+
+ /* get the port guid */
+ if (__get_port_guid_from_port_gid_tbl
+ (p_vend, idx, port_num, &port_guid)) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_ca_info_init: ERR 5227: "
+ "Fail to get HCA:%d Port:%d Guid.\n", idx,
+ port_num);
+ goto Exit;
+ }
+ p_ca_info->p_attr->p_port_attr[port_num - 1].port_guid =
+ cl_hton64(port_guid);
+ }
+
+ status = IB_SUCCESS;
+ Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
}
/**********************************************************************
**********************************************************************/
void
-osm_ca_info_destroy( IN osm_vendor_t * const p_vend,
- IN osm_ca_info_t * const p_ca_info,
- IN uint8_t num_ca)
+osm_ca_info_destroy(IN osm_vendor_t * const p_vend,
+ IN osm_ca_info_t * const p_ca_info, IN uint8_t num_ca)
{
- osm_ca_info_t *p_ca;
- uint8_t i;
+ osm_ca_info_t *p_ca;
+ uint8_t i;
- OSM_LOG_ENTER( p_vend->p_log, osm_ca_info_destroy );
+ OSM_LOG_ENTER(p_vend->p_log, osm_ca_info_destroy);
- for (i=0; i < num_ca; i++)
- {
- p_ca = &p_ca_info[i];
+ for (i = 0; i < num_ca; i++) {
+ p_ca = &p_ca_info[i];
- if( NULL != p_ca->p_attr )
- {
- if(0 != p_ca->p_attr->num_ports)
- {
- free( p_ca->p_attr->p_port_attr );
- }
+ if (NULL != p_ca->p_attr) {
+ if (0 != p_ca->p_attr->num_ports) {
+ free(p_ca->p_attr->p_port_attr);
+ }
- free( p_ca->p_attr);
- }
- }
+ free(p_ca->p_attr);
+ }
+ }
- free( p_ca_info );
+ free(p_ca_info);
- OSM_LOG_EXIT( p_vend->p_log );
+ OSM_LOG_EXIT(p_vend->p_log);
}
/**********************************************************************
@@ -597,105 +580,97 @@ osm_ca_info_destroy( IN osm_vendor_t * const p_vend,
* avilable CAs on this machine.
**********************************************************************/
ib_api_status_t
-osm_vendor_get_all_port_attr( IN osm_vendor_t * const p_vend,
- IN ib_port_attr_t * const p_attr_array,
- IN uint32_t * const p_num_ports )
+osm_vendor_get_all_port_attr(IN osm_vendor_t * const p_vend,
+ IN ib_port_attr_t * const p_attr_array,
+ IN uint32_t * const p_num_ports)
{
- ib_api_status_t status = IB_SUCCESS;
-
- uint32_t caIdx;
- uint32_t ca_count = 0;
- uint32_t port_count = 0;
- uint8_t port_num;
- uint32_t total_ports = 0;
- osm_ca_info_t *p_ca_infos = NULL;
- uint32_t attr_array_sz = *p_num_ports;
-
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_get_all_port_attr );
-
- CL_ASSERT( p_vend );
-
-
- /* determine the number of CA's */
- ca_count = __hca_pfs_get_num_cas();
- if (! ca_count)
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_all_port_attr: ERR 5228: "
- "Fail to get Any CA Ids.\n" );
- goto Exit;
- }
-
- /* Allocate an array big enough to hold the ca info objects*/
- p_ca_infos = malloc( ca_count * sizeof( osm_ca_info_t ) );
- if( p_ca_infos == NULL )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_all_port_attr: ERR 5229: "
- "Unable to allocate CA information array.\n" );
- goto Exit;
- }
-
- memset( p_ca_infos, 0, ca_count * sizeof( osm_ca_info_t ) );
-
- /*
- * For each CA, retrieve the CA info attributes
- */
- for( caIdx = 1; caIdx <= ca_count; caIdx++ )
- {
- status = __osm_ca_info_init( p_vend, caIdx, &p_ca_infos[caIdx-1] );
- if( status != IB_SUCCESS )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_all_port_attr: ERR 5230: "
- "Unable to initialize CA Info object (%s).\n",
- ib_get_err_str( status ) );
- goto Exit;
- }
- total_ports += p_ca_infos[caIdx-1].p_attr->num_ports;
- }
-
- *p_num_ports = total_ports;
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_get_all_port_attr: total ports:%u \n",
- total_ports);
-
- /*
- * If the user supplied enough storage, return the port guids,
- * otherwise, return the appropriate error.
- */
- if( attr_array_sz >= total_ports )
- {
- for( caIdx = 1; caIdx <= ca_count; caIdx++ )
- {
- uint32_t num_ports;
-
- num_ports = p_ca_infos[caIdx-1].p_attr->num_ports;
-
- for( port_num = 0; port_num < num_ports; port_num++ )
- {
- p_attr_array[port_count] =
- *__osm_ca_info_get_port_attr_ptr( &p_ca_infos[caIdx-1], port_num );
- port_count++;
- }
- }
- }
- else
- {
- status = IB_INSUFFICIENT_MEMORY;
- goto Exit;
- }
-
- status = IB_SUCCESS;
-
- Exit:
- if ( p_ca_infos )
- {
- osm_ca_info_destroy(p_vend, p_ca_infos, ca_count);
- }
-
- OSM_LOG_EXIT( p_vend->p_log );
- return ( status );
+ ib_api_status_t status = IB_SUCCESS;
+
+ uint32_t caIdx;
+ uint32_t ca_count = 0;
+ uint32_t port_count = 0;
+ uint8_t port_num;
+ uint32_t total_ports = 0;
+ osm_ca_info_t *p_ca_infos = NULL;
+ uint32_t attr_array_sz = *p_num_ports;
+
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_get_all_port_attr);
+
+ CL_ASSERT(p_vend);
+
+ /* determine the number of CA's */
+ ca_count = __hca_pfs_get_num_cas();
+ if (!ca_count) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_all_port_attr: ERR 5228: "
+ "Fail to get Any CA Ids.\n");
+ goto Exit;
+ }
+
+ /* Allocate an array big enough to hold the ca info objects */
+ p_ca_infos = malloc(ca_count * sizeof(osm_ca_info_t));
+ if (p_ca_infos == NULL) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_all_port_attr: ERR 5229: "
+ "Unable to allocate CA information array.\n");
+ goto Exit;
+ }
+
+ memset(p_ca_infos, 0, ca_count * sizeof(osm_ca_info_t));
+
+ /*
+ * For each CA, retrieve the CA info attributes
+ */
+ for (caIdx = 1; caIdx <= ca_count; caIdx++) {
+ status =
+ __osm_ca_info_init(p_vend, caIdx, &p_ca_infos[caIdx - 1]);
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_all_port_attr: ERR 5230: "
+ "Unable to initialize CA Info object (%s).\n",
+ ib_get_err_str(status));
+ goto Exit;
+ }
+ total_ports += p_ca_infos[caIdx - 1].p_attr->num_ports;
+ }
+
+ *p_num_ports = total_ports;
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_get_all_port_attr: total ports:%u \n", total_ports);
+
+ /*
+ * If the user supplied enough storage, return the port guids,
+ * otherwise, return the appropriate error.
+ */
+ if (attr_array_sz >= total_ports) {
+ for (caIdx = 1; caIdx <= ca_count; caIdx++) {
+ uint32_t num_ports;
+
+ num_ports = p_ca_infos[caIdx - 1].p_attr->num_ports;
+
+ for (port_num = 0; port_num < num_ports; port_num++) {
+ p_attr_array[port_count] =
+ *__osm_ca_info_get_port_attr_ptr(&p_ca_infos
+ [caIdx -
+ 1],
+ port_num);
+ port_count++;
+ }
+ }
+ } else {
+ status = IB_INSUFFICIENT_MEMORY;
+ goto Exit;
+ }
+
+ status = IB_SUCCESS;
+
+ Exit:
+ if (p_ca_infos) {
+ osm_ca_info_destroy(p_vend, p_ca_infos, ca_count);
+ }
+
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
}
/**********************************************************************
@@ -704,74 +679,73 @@ osm_vendor_get_all_port_attr( IN osm_vendor_t * const p_vend,
**********************************************************************/
ib_api_status_t
-osm_vendor_get_guid_ca_and_port(
- IN osm_vendor_t * const p_vend,
- IN ib_net64_t const guid,
- OUT uint32_t * p_hca_hndl,
- OUT char * p_hca_id,
- OUT uint8_t *p_hca_idx,
- OUT uint32_t * p_port_num )
+osm_vendor_get_guid_ca_and_port(IN osm_vendor_t * const p_vend,
+ IN ib_net64_t const guid,
+ OUT uint32_t * p_hca_hndl,
+ OUT char *p_hca_id,
+ OUT uint8_t * p_hca_idx,
+ OUT uint32_t * p_port_num)
{
- uint32_t caIdx;
- uint32_t ca_count = 0;
- uint8_t port_num;
- ib_api_status_t status = IB_ERROR;
-
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_get_guid_ca_and_port );
-
- CL_ASSERT( p_vend );
-
- /* determine the number of CA's */
- ca_count = __hca_pfs_get_num_cas();
- if (! ca_count)
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_guid_ca_and_port: ERR 5231: "
- "Fail to get Any CA Ids.\n" );
- goto Exit;
- }
-
- /*
- * For each CA, retrieve the CA info attributes
- */
- for( caIdx = 1; caIdx <= ca_count; caIdx++ )
- {
- pfs_ca_info_t pfs_ca_info;
- if (__parse_ca_info_file(p_vend, caIdx, &pfs_ca_info) == IB_SUCCESS)
- {
- /* get all the ports info */
- for( port_num = 1; port_num <= pfs_ca_info.num_ports; port_num++ )
- {
- uint64_t port_guid;
- if (! __get_port_guid_from_port_gid_tbl(p_vend, caIdx, port_num, &port_guid))
- {
- if (cl_hton64(port_guid) == guid)
- {
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_get_guid_ca_and_port: "
- "Found Matching guid on HCA:%d Port:%d.\n", caIdx, port_num );
- strcpy(p_hca_id, pfs_ca_info.name);
- *p_port_num = port_num;
- *p_hca_idx = caIdx - 1;
- *p_hca_hndl = 0;
- status = IB_SUCCESS;
- goto Exit;
- }
- }
- }
- }
- }
-
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_guid_ca_and_port: ERR 5232: "
- "Fail to find HCA and Port for Port Guid 0x%" PRIx64 "\n",
- cl_ntoh64(guid) );
- status = IB_INVALID_GUID;
-
- Exit:
-
- OSM_LOG_EXIT( p_vend->p_log );
- return ( status );
+ uint32_t caIdx;
+ uint32_t ca_count = 0;
+ uint8_t port_num;
+ ib_api_status_t status = IB_ERROR;
+
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_get_guid_ca_and_port);
+
+ CL_ASSERT(p_vend);
+
+ /* determine the number of CA's */
+ ca_count = __hca_pfs_get_num_cas();
+ if (!ca_count) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_guid_ca_and_port: ERR 5231: "
+ "Fail to get Any CA Ids.\n");
+ goto Exit;
+ }
+
+ /*
+ * For each CA, retrieve the CA info attributes
+ */
+ for (caIdx = 1; caIdx <= ca_count; caIdx++) {
+ pfs_ca_info_t pfs_ca_info;
+ if (__parse_ca_info_file(p_vend, caIdx, &pfs_ca_info) ==
+ IB_SUCCESS) {
+ /* get all the ports info */
+ for (port_num = 1; port_num <= pfs_ca_info.num_ports;
+ port_num++) {
+ uint64_t port_guid;
+ if (!__get_port_guid_from_port_gid_tbl
+ (p_vend, caIdx, port_num, &port_guid)) {
+ if (cl_hton64(port_guid) == guid) {
+ osm_log(p_vend->p_log,
+ OSM_LOG_DEBUG,
+ "osm_vendor_get_guid_ca_and_port: "
+ "Found Matching guid on HCA:%d Port:%d.\n",
+ caIdx, port_num);
+ strcpy(p_hca_id,
+ pfs_ca_info.name);
+ *p_port_num = port_num;
+ *p_hca_idx = caIdx - 1;
+ *p_hca_hndl = 0;
+ status = IB_SUCCESS;
+ goto Exit;
+ }
+ }
+ }
+ }
+ }
+
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_guid_ca_and_port: ERR 5232: "
+ "Fail to find HCA and Port for Port Guid 0x%" PRIx64 "\n",
+ cl_ntoh64(guid));
+ status = IB_INVALID_GUID;
+
+ Exit:
+
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
}
#endif
diff --git a/opensm/libvendor/osm_vendor_mlx_hca_sim.c b/opensm/libvendor/osm_vendor_mlx_hca_sim.c
index 1c68937..e4b1117 100644
--- a/opensm/libvendor/osm_vendor_mlx_hca_sim.c
+++ b/opensm/libvendor/osm_vendor_mlx_hca_sim.c
@@ -33,10 +33,9 @@
*
*/
-
#if HAVE_CONFIG_H
# include <config.h>
-#endif /* HAVE_CONFIG_H */
+#endif /* HAVE_CONFIG_H */
#if defined(OSM_VENDOR_INTF_SIM)
#undef IN
@@ -64,57 +63,56 @@
char *__get_simulator_dir(void)
{
- static char *ibmgtSimDir = NULL;
- static char *defaultIbmgtSimDir = "/tmp/ibmgtsim";
- static char *ibmgtSimNode = NULL;
- static char dirName[1024];
-
- /* we use the first pointer to know if we were here */
- if (ibmgtSimDir == NULL)
- {
- /* obtain the simulator directory */
- ibmgtSimDir = getenv("IBMGTSIM_DIR");
- if (ibmgtSimDir == NULL)
- {
- printf("-W- Environment variable: IBMGTSIM_DIR does not exist.\n");
- printf(" Please create one used by the simulator.\n");
- printf(" Using /tmp/ibmgtsim as default.\n");
- ibmgtSimDir = defaultIbmgtSimDir;
- }
-
- /* obtain the node name we simulate */
- ibmgtSimNode = getenv("IBMGTSIM_NODE");
- if (ibmgtSimNode == NULL)
- {
- printf("-W- Environment variable: IBMGTSIM_NODE does not exist.\n");
- printf(" This variable should be the name of the node you wish to simulate.\n");
- printf(" Using H-1 as default.\n");
- ibmgtSimNode = "H-1";
- }
- sprintf(dirName, "%s/%s", ibmgtSimDir, ibmgtSimNode);
- }
-
- return dirName;
+ static char *ibmgtSimDir = NULL;
+ static char *defaultIbmgtSimDir = "/tmp/ibmgtsim";
+ static char *ibmgtSimNode = NULL;
+ static char dirName[1024];
+
+ /* we use the first pointer to know if we were here */
+ if (ibmgtSimDir == NULL) {
+ /* obtain the simulator directory */
+ ibmgtSimDir = getenv("IBMGTSIM_DIR");
+ if (ibmgtSimDir == NULL) {
+ printf
+ ("-W- Environment variable: IBMGTSIM_DIR does not exist.\n");
+ printf
+ (" Please create one used by the simulator.\n");
+ printf(" Using /tmp/ibmgtsim as default.\n");
+ ibmgtSimDir = defaultIbmgtSimDir;
+ }
+
+ /* obtain the node name we simulate */
+ ibmgtSimNode = getenv("IBMGTSIM_NODE");
+ if (ibmgtSimNode == NULL) {
+ printf
+ ("-W- Environment variable: IBMGTSIM_NODE does not exist.\n");
+ printf
+ (" This variable should be the name of the node you wish to simulate.\n");
+ printf(" Using H-1 as default.\n");
+ ibmgtSimNode = "H-1";
+ }
+ sprintf(dirName, "%s/%s", ibmgtSimDir, ibmgtSimNode);
+ }
+
+ return dirName;
}
-typedef struct _osm_ca_info
-{
- ib_net64_t guid;
- size_t attr_size;
- ib_ca_attr_t *p_attr;
+typedef struct _osm_ca_info {
+ ib_net64_t guid;
+ size_t attr_size;
+ ib_ca_attr_t *p_attr;
-}
-osm_ca_info_t;
+} osm_ca_info_t;
/**********************************************************************
* Returns a pointer to the port attribute of the specified port
* owned by this CA.
************************************************************************/
-static ib_port_attr_t *
-__osm_ca_info_get_port_attr_ptr( IN const osm_ca_info_t * const p_ca_info,
- IN const uint8_t index )
+static ib_port_attr_t *__osm_ca_info_get_port_attr_ptr(IN const osm_ca_info_t *
+ const p_ca_info,
+ IN const uint8_t index)
{
- return ( &p_ca_info->p_attr->p_port_attr[index] );
+ return (&p_ca_info->p_attr->p_port_attr[index]);
}
/**********************************************************************
@@ -122,32 +120,30 @@ __osm_ca_info_get_port_attr_ptr( IN const osm_ca_info_t * const p_ca_info,
**********************************************************************/
int __hca_sim_get_num_cas(void)
{
- int num_cas = 0;
- DIR *dp;
- struct dirent *ep;
-
- dp = opendir(__get_simulator_dir());
-
- if (dp != NULL)
- {
- while ((ep = readdir (dp)))
- {
- /* CAs are directories with the format ca[1-9][0-9]* */
- /* if ((ep->d_type == DT_DIR) && !strncmp(ep->d_name, "ca", 2)) */
- if (!strncmp(ep->d_name, "ca", 2))
- {
- num_cas++;
- }
- }
- closedir(dp);
- } else {
- printf("__hca_sim_get_num_cas: ERROR : ail to open dir %s\n",
- __get_simulator_dir());
- exit(1);
- }
-
- if (!num_cas) exit(1);
- return num_cas;
+ int num_cas = 0;
+ DIR *dp;
+ struct dirent *ep;
+
+ dp = opendir(__get_simulator_dir());
+
+ if (dp != NULL) {
+ while ((ep = readdir(dp))) {
+ /* CAs are directories with the format ca[1-9][0-9]* */
+ /* if ((ep->d_type == DT_DIR) && !strncmp(ep->d_name, "ca", 2)) */
+ if (!strncmp(ep->d_name, "ca", 2)) {
+ num_cas++;
+ }
+ }
+ closedir(dp);
+ } else {
+ printf("__hca_sim_get_num_cas: ERROR : ail to open dir %s\n",
+ __get_simulator_dir());
+ exit(1);
+ }
+
+ if (!num_cas)
+ exit(1);
+ return num_cas;
}
/*
@@ -161,126 +157,120 @@ int __hca_sim_get_num_cas(void)
FW revision: 0x300020080
*/
typedef struct _sim_ca_info {
- char name[32];
- char provider[32];
- uint64_t guid;
- uint8_t num_ports;
- uint32_t vend_id;
- uint16_t dev_id;
- uint16_t rev_id;
- uint64_t fw_rev;
+ char name[32];
+ char provider[32];
+ uint64_t guid;
+ uint8_t num_ports;
+ uint32_t vend_id;
+ uint16_t dev_id;
+ uint16_t rev_id;
+ uint64_t fw_rev;
} sim_ca_info_t;
/**********************************************************************
* Parse the CA Info file available in ibmgtSimDir/caN/info
**********************************************************************/
static ib_api_status_t
-__parse_ca_info_file(
- IN osm_vendor_t * const p_vend,
- IN uint32_t idx,
- OUT sim_ca_info_t *sim_ca_info)
+__parse_ca_info_file(IN osm_vendor_t * const p_vend,
+ IN uint32_t idx, OUT sim_ca_info_t * sim_ca_info)
{
- ib_api_status_t status = IB_ERROR;
- int info_file;
- char file_name[256];
- char file_buffer[3200];
- char *p_ch;
- int g1,g2,g3,g4;
- int num_ports;
- uint32_t len;
-
- OSM_LOG_ENTER( p_vend->p_log, __parse_ca_info_file );
-
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "__parse_ca_info_file: " "Querying CA %d.\n", idx );
-
- /* we use the proc file system so we must be able to open the info file .. */
- sprintf(file_name, "%s/ca%d/info", __get_simulator_dir(), idx);
- info_file = open(file_name, O_RDONLY);
- if (! info_file)
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__parse_ca_info_file: ERR 5105: "
- "Fail to open HCA:%d info file:(%s).\n", idx, file_name);
- goto Exit;
- }
-
- /* read in the file */
- len = read(info_file, file_buffer, 3200);
- close(info_file);
- file_buffer[len] = '\0';
-
- /*
- parse the file ...
- name: InfiniHost0
- provider: tavor
- node GUID: 0002:c900:0120:3470
- ports: 2
- vendor ID: 0x2c9
- device ID: 0x5a44
- HW revision: 0xa1
- FW revision: 0x300020080
- */
- if (!(p_ch = strstr(file_buffer, "name:")))
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__parse_ca_info_file: ERR 5106: "
- "Fail to obtain HCA name. In info file:(%s).\n", file_buffer);
- goto Exit;
- }
- if (sscanf(p_ch,"name: %s", sim_ca_info->name) != 1)
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__parse_ca_info_file: ERR 5107: "
- "Fail to parse name in info file:(%s).\n", p_ch);
- goto Exit;
- }
-
- /* get the guid of the HCA */
- if (!(p_ch = strstr(file_buffer, "node GUID:")))
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__parse_ca_info_file: ERR 5108: "
- "Fail to obtain GUID in info file:(%s).\n", file_buffer);
- goto Exit;
- }
- if (sscanf(p_ch, "node GUID: %x:%x:%x:%x", &g1,&g2,&g3,&g4) != 4)
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__parse_ca_info_file: ERR 5109: "
- "Fail to parse GUID in info file:(%s).\n", p_ch);
- goto Exit;
- }
- sim_ca_info->guid = (uint64_t)g1 << 48 | (uint64_t)g1 << 32
- | (uint64_t)g1 << 16 | (uint64_t)g3 ;
-
- /* obtain number of ports */
- if (!(p_ch = strstr(file_buffer, "ports:")))
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__parse_ca_info_file: ERR 5110: "
- "Fail to obtain number of ports in info file:(%s).\n", file_buffer);
- goto Exit;
- }
- if (sscanf(p_ch, "ports: %d", &num_ports) != 1)
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__parse_ca_info_file: ERR 5111: "
- "Fail to parse num ports in info file:(%s).\n", p_ch);
- goto Exit;
- }
- sim_ca_info->num_ports = num_ports;
-
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "__parse_ca_info_file: "
- "CA1 = name:%s guid:0x%016llx ports:%d\n",
- sim_ca_info->name, sim_ca_info->guid, sim_ca_info->num_ports
- );
-
- status = IB_SUCCESS;
-Exit:
- OSM_LOG_EXIT( p_vend->p_log );
- return status;
+ ib_api_status_t status = IB_ERROR;
+ int info_file;
+ char file_name[256];
+ char file_buffer[3200];
+ char *p_ch;
+ int g1, g2, g3, g4;
+ int num_ports;
+ uint32_t len;
+
+ OSM_LOG_ENTER(p_vend->p_log, __parse_ca_info_file);
+
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__parse_ca_info_file: " "Querying CA %d.\n", idx);
+
+ /* we use the proc file system so we must be able to open the info file .. */
+ sprintf(file_name, "%s/ca%d/info", __get_simulator_dir(), idx);
+ info_file = open(file_name, O_RDONLY);
+ if (!info_file) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_ca_info_file: ERR 5105: "
+ "Fail to open HCA:%d info file:(%s).\n", idx,
+ file_name);
+ goto Exit;
+ }
+
+ /* read in the file */
+ len = read(info_file, file_buffer, 3200);
+ close(info_file);
+ file_buffer[len] = '\0';
+
+ /*
+ parse the file ...
+ name: InfiniHost0
+ provider: tavor
+ node GUID: 0002:c900:0120:3470
+ ports: 2
+ vendor ID: 0x2c9
+ device ID: 0x5a44
+ HW revision: 0xa1
+ FW revision: 0x300020080
+ */
+ if (!(p_ch = strstr(file_buffer, "name:"))) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_ca_info_file: ERR 5106: "
+ "Fail to obtain HCA name. In info file:(%s).\n",
+ file_buffer);
+ goto Exit;
+ }
+ if (sscanf(p_ch, "name: %s", sim_ca_info->name) != 1) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_ca_info_file: ERR 5107: "
+ "Fail to parse name in info file:(%s).\n", p_ch);
+ goto Exit;
+ }
+
+ /* get the guid of the HCA */
+ if (!(p_ch = strstr(file_buffer, "node GUID:"))) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_ca_info_file: ERR 5108: "
+ "Fail to obtain GUID in info file:(%s).\n",
+ file_buffer);
+ goto Exit;
+ }
+ if (sscanf(p_ch, "node GUID: %x:%x:%x:%x", &g1, &g2, &g3, &g4) != 4) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_ca_info_file: ERR 5109: "
+ "Fail to parse GUID in info file:(%s).\n", p_ch);
+ goto Exit;
+ }
+ sim_ca_info->guid = (uint64_t) g1 << 48 | (uint64_t) g1 << 32
+ | (uint64_t) g1 << 16 | (uint64_t) g3;
+
+ /* obtain number of ports */
+ if (!(p_ch = strstr(file_buffer, "ports:"))) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_ca_info_file: ERR 5110: "
+ "Fail to obtain number of ports in info file:(%s).\n",
+ file_buffer);
+ goto Exit;
+ }
+ if (sscanf(p_ch, "ports: %d", &num_ports) != 1) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_ca_info_file: ERR 5111: "
+ "Fail to parse num ports in info file:(%s).\n", p_ch);
+ goto Exit;
+ }
+ sim_ca_info->num_ports = num_ports;
+
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__parse_ca_info_file: "
+ "CA1 = name:%s guid:0x%016llx ports:%d\n",
+ sim_ca_info->name, sim_ca_info->guid, sim_ca_info->num_ports);
+
+ status = IB_SUCCESS;
+ Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return status;
}
/*
@@ -299,11 +289,11 @@ Exit:
IsCapabilityMaskNoticeSupported
*/
typedef struct _sim_port_info {
- uint8_t state;
- uint16_t lid;
- uint8_t lmc;
- uint16_t sm_lid;
- uint8_t sm_sl;
+ uint8_t state;
+ uint16_t lid;
+ uint8_t lmc;
+ uint16_t sm_lid;
+ uint8_t sm_sl;
} sim_port_info_t;
/**********************************************************************
@@ -311,156 +301,150 @@ typedef struct _sim_port_info {
* Port num is 1..N
**********************************************************************/
static ib_api_status_t
-__parse_port_info_file(
- IN osm_vendor_t * const p_vend,
- IN uint32_t hca_idx,
- IN uint8_t port_num,
- OUT sim_port_info_t *sim_port_info)
+__parse_port_info_file(IN osm_vendor_t * const p_vend,
+ IN uint32_t hca_idx,
+ IN uint8_t port_num, OUT sim_port_info_t * sim_port_info)
{
- ib_api_status_t status = IB_ERROR;
- int info_file;
- char file_name[256];
- char file_buffer[3200];
- char state[12];
- char *p_ch;
- int lid, sm_lid, lmc, sm_sl;
- uint32_t len;
-
- OSM_LOG_ENTER( p_vend->p_log, __parse_port_info_file );
-
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "__parse_port_info_file: "
- "Parsing Proc File System Port Info CA %d Port %d.\n", hca_idx, port_num );
-
- /* we use the proc file system so we must be able to open the info file .. */
- sprintf(file_name, "%s/ca%d/port%d/info", __get_simulator_dir(), hca_idx, port_num);
- info_file = open(file_name, O_RDONLY);
- if (! info_file)
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__parse_port_info_file: ERR 5112: "
- "Fail to open HCA:%d Port:%d info file:(%s).\n", hca_idx, port_num,
- file_name);
- goto Exit;
- }
-
- /* read in the file */
- len = read(info_file, file_buffer, 3200);
- close(info_file);
- file_buffer[len] = '\0';
-
- /*
- parse the file ...
- state: ACTIVE
- LID: 0x0001
- LMC: 0x0000
- SM LID: 0x0001
- SM SL: 0x0000
- ...
- */
- if (!(p_ch = strstr(file_buffer, "state:")))
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__parse_port_info_file: ERR 5113: "
- "Fail to obtain port state. In info file:(%s).\n", file_buffer);
- goto Exit;
- }
- if (sscanf(p_ch,"state: %s", state) != 1)
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__parse_port_info_file: ERR 5114: "
- "Fail to parse state from info file:(%s).\n", p_ch);
- goto Exit;
- }
-
- if (!strcmp(state, "ACTIVE"))
- sim_port_info->state = IB_LINK_ACTIVE;
- else if (!strcmp(state, "DOWN"))
- sim_port_info->state = IB_LINK_DOWN;
- else if (!strcmp(state, "INIT"))
- sim_port_info->state = IB_LINK_INIT;
- else if (!strcmp(state, "ARMED"))
- sim_port_info->state = IB_LINK_ARMED;
- else
- sim_port_info->state = 0;
-
- /* get lid */
- if (!(p_ch = strstr(file_buffer, "LID:")))
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__parse_port_info_file: ERR 5115: "
- "Fail to obtain port lid. In info file:(%s).\n", file_buffer);
- goto Exit;
- }
- if (sscanf(p_ch,"LID: %x", &lid) != 1)
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__parse_port_info_file: ERR 5116: "
- "Fail to parse lid from info file:(%s).\n", p_ch);
- goto Exit;
- }
- sim_port_info->lid = lid;
- /* get LMC */
- if (!(p_ch = strstr(file_buffer, "LMC:")))
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__parse_port_info_file: ERR 5117: "
- "Fail to obtain port LMC. In info file:(%s).\n", file_buffer);
- goto Exit;
- }
- if (sscanf(p_ch,"LMC: %x", &lmc) != 1)
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__parse_port_info_file: ERR 5118: "
- "Fail to parse LMC from info file:(%s).\n", p_ch);
- goto Exit;
- }
- sim_port_info->lmc = lmc;
-
- /* get SM LID */
- if (!(p_ch = strstr(file_buffer, "SM LID:")))
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__parse_port_info_file: ERR 5119: "
- "Fail to obtain port SM LID. In info file:(%s).\n", file_buffer);
- goto Exit;
- }
- if (sscanf(p_ch,"SM LID: %x", &sm_lid) != 1)
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__parse_port_info_file: ERR 5120: "
- "Fail to parse SM LID from info file:(%s).\n", p_ch);
- goto Exit;
- }
- sim_port_info->sm_lid = sm_lid;
-
- /* get SM LID */
- if (!(p_ch = strstr(file_buffer, "SM SL:")))
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__parse_port_info_file: ERR 5121: "
- "Fail to obtain port SM SL. In info file:(%s).\n", file_buffer);
- goto Exit;
- }
- if (sscanf(p_ch,"SM SL: %x", &sm_sl) != 1)
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__parse_port_info_file: ERR 5122: "
- "Fail to parse SM SL from info file:(%s).\n", p_ch);
- goto Exit;
- }
- sim_port_info->sm_sl = sm_sl;
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "__parse_port_info_file: "
- "Obtained Port:%d = state:%d, lid:0x%04X, lmc:%d, sm_lid:0x%04X, sm_sl:%d\n",
- port_num, sim_port_info->state, sim_port_info->lid,
- sim_port_info->lmc, sim_port_info->sm_lid, sim_port_info->sm_sl
- );
-
- status = IB_SUCCESS;
- Exit:
- OSM_LOG_EXIT( p_vend->p_log );
- return status;
+ ib_api_status_t status = IB_ERROR;
+ int info_file;
+ char file_name[256];
+ char file_buffer[3200];
+ char state[12];
+ char *p_ch;
+ int lid, sm_lid, lmc, sm_sl;
+ uint32_t len;
+
+ OSM_LOG_ENTER(p_vend->p_log, __parse_port_info_file);
+
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__parse_port_info_file: "
+ "Parsing Proc File System Port Info CA %d Port %d.\n", hca_idx,
+ port_num);
+
+ /* we use the proc file system so we must be able to open the info file .. */
+ sprintf(file_name, "%s/ca%d/port%d/info", __get_simulator_dir(),
+ hca_idx, port_num);
+ info_file = open(file_name, O_RDONLY);
+ if (!info_file) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_port_info_file: ERR 5112: "
+ "Fail to open HCA:%d Port:%d info file:(%s).\n",
+ hca_idx, port_num, file_name);
+ goto Exit;
+ }
+
+ /* read in the file */
+ len = read(info_file, file_buffer, 3200);
+ close(info_file);
+ file_buffer[len] = '\0';
+
+ /*
+ parse the file ...
+ state: ACTIVE
+ LID: 0x0001
+ LMC: 0x0000
+ SM LID: 0x0001
+ SM SL: 0x0000
+ ...
+ */
+ if (!(p_ch = strstr(file_buffer, "state:"))) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_port_info_file: ERR 5113: "
+ "Fail to obtain port state. In info file:(%s).\n",
+ file_buffer);
+ goto Exit;
+ }
+ if (sscanf(p_ch, "state: %s", state) != 1) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_port_info_file: ERR 5114: "
+ "Fail to parse state from info file:(%s).\n", p_ch);
+ goto Exit;
+ }
+
+ if (!strcmp(state, "ACTIVE"))
+ sim_port_info->state = IB_LINK_ACTIVE;
+ else if (!strcmp(state, "DOWN"))
+ sim_port_info->state = IB_LINK_DOWN;
+ else if (!strcmp(state, "INIT"))
+ sim_port_info->state = IB_LINK_INIT;
+ else if (!strcmp(state, "ARMED"))
+ sim_port_info->state = IB_LINK_ARMED;
+ else
+ sim_port_info->state = 0;
+
+ /* get lid */
+ if (!(p_ch = strstr(file_buffer, "LID:"))) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_port_info_file: ERR 5115: "
+ "Fail to obtain port lid. In info file:(%s).\n",
+ file_buffer);
+ goto Exit;
+ }
+ if (sscanf(p_ch, "LID: %x", &lid) != 1) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_port_info_file: ERR 5116: "
+ "Fail to parse lid from info file:(%s).\n", p_ch);
+ goto Exit;
+ }
+ sim_port_info->lid = lid;
+ /* get LMC */
+ if (!(p_ch = strstr(file_buffer, "LMC:"))) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_port_info_file: ERR 5117: "
+ "Fail to obtain port LMC. In info file:(%s).\n",
+ file_buffer);
+ goto Exit;
+ }
+ if (sscanf(p_ch, "LMC: %x", &lmc) != 1) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_port_info_file: ERR 5118: "
+ "Fail to parse LMC from info file:(%s).\n", p_ch);
+ goto Exit;
+ }
+ sim_port_info->lmc = lmc;
+
+ /* get SM LID */
+ if (!(p_ch = strstr(file_buffer, "SM LID:"))) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_port_info_file: ERR 5119: "
+ "Fail to obtain port SM LID. In info file:(%s).\n",
+ file_buffer);
+ goto Exit;
+ }
+ if (sscanf(p_ch, "SM LID: %x", &sm_lid) != 1) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_port_info_file: ERR 5120: "
+ "Fail to parse SM LID from info file:(%s).\n", p_ch);
+ goto Exit;
+ }
+ sim_port_info->sm_lid = sm_lid;
+
+ /* get SM LID */
+ if (!(p_ch = strstr(file_buffer, "SM SL:"))) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_port_info_file: ERR 5121: "
+ "Fail to obtain port SM SL. In info file:(%s).\n",
+ file_buffer);
+ goto Exit;
+ }
+ if (sscanf(p_ch, "SM SL: %x", &sm_sl) != 1) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__parse_port_info_file: ERR 5122: "
+ "Fail to parse SM SL from info file:(%s).\n", p_ch);
+ goto Exit;
+ }
+ sim_port_info->sm_sl = sm_sl;
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__parse_port_info_file: "
+ "Obtained Port:%d = state:%d, lid:0x%04X, lmc:%d, sm_lid:0x%04X, sm_sl:%d\n",
+ port_num, sim_port_info->state, sim_port_info->lid,
+ sim_port_info->lmc, sim_port_info->sm_lid,
+ sim_port_info->sm_sl);
+
+ status = IB_SUCCESS;
+ Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return status;
}
/**********************************************************************
@@ -469,172 +453,172 @@ __parse_port_info_file(
* [ 0] fe80:0000:0000:0000:0002:c900:0120:3472
**********************************************************************/
static ib_api_status_t
-__get_port_guid_from_port_gid_tbl(
- IN osm_vendor_t * const p_vend,
- IN uint32_t hca_idx,
- IN uint8_t port_num,
- OUT uint64_t *port_guid)
+__get_port_guid_from_port_gid_tbl(IN osm_vendor_t * const p_vend,
+ IN uint32_t hca_idx,
+ IN uint8_t port_num, OUT uint64_t * port_guid)
{
- ib_api_status_t status = IB_ERROR;
- int info_file;
- char file_name[256];
- char file_buffer[3200];
- char *p_ch;
- int g[8];
- uint32_t len;
-
- OSM_LOG_ENTER( p_vend->p_log, __get_port_guid_from_port_gid_tbl );
-
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "__get_port_guid_from_port_gid_tbl: "
- "Parsing Proc File System Port Guid Table CA %d Port %d.\n",
- hca_idx, port_num );
-
- /* we use the proc file system so we must be able to open the info file .. */
- sprintf(file_name, "%s/ca%d/port%d/gid_table",
- __get_simulator_dir(), hca_idx, port_num);
- info_file = open(file_name, O_RDONLY);
- if (! info_file)
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__get_port_guid_from_port_gid_tbl: ERR 5123: "
- "Fail to open HCA:%d Port:%d gid_table file:(%s).\n", hca_idx, port_num,
- file_name);
- goto Exit;
- }
-
- /* read in the file */
- len = read(info_file, file_buffer, 3200);
- close(info_file);
- file_buffer[len] = '\0';
-
- /*
- parse the file ...
- [ 0] fe80:0000:0000:0000:0002:c900:0120:3472
- ...
- */
- if (!(p_ch = strstr(file_buffer, "[ 0]")))
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__get_port_guid_from_port_gid_tbl: ERR 5124: "
- "Fail to obtain first gid index. In gid_table file:(%s).\n", file_buffer);
- goto Exit;
- }
- if (sscanf(p_ch+6,"%x:%x:%x:%x:%x:%x:%x:%x",
- &g[7],&g[6],&g[5],&g[4],&g[3],&g[2],&g[1],&g[0]) != 8)
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__get_port_guid_from_port_gid_tbl: ERR 5125: "
- "Fail to parse gid from gid_table file:(%s).\n", p_ch);
- goto Exit;
- }
-
- *port_guid = (uint64_t)g[3]<<48 | (uint64_t)g[2] << 32 | (uint64_t)g[1] << 16 | g[0];
- status = IB_SUCCESS;
-Exit:
- OSM_LOG_EXIT( p_vend->p_log );
- return status;
+ ib_api_status_t status = IB_ERROR;
+ int info_file;
+ char file_name[256];
+ char file_buffer[3200];
+ char *p_ch;
+ int g[8];
+ uint32_t len;
+
+ OSM_LOG_ENTER(p_vend->p_log, __get_port_guid_from_port_gid_tbl);
+
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__get_port_guid_from_port_gid_tbl: "
+ "Parsing Proc File System Port Guid Table CA %d Port %d.\n",
+ hca_idx, port_num);
+
+ /* we use the proc file system so we must be able to open the info file .. */
+ sprintf(file_name, "%s/ca%d/port%d/gid_table",
+ __get_simulator_dir(), hca_idx, port_num);
+ info_file = open(file_name, O_RDONLY);
+ if (!info_file) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__get_port_guid_from_port_gid_tbl: ERR 5123: "
+ "Fail to open HCA:%d Port:%d gid_table file:(%s).\n",
+ hca_idx, port_num, file_name);
+ goto Exit;
+ }
+
+ /* read in the file */
+ len = read(info_file, file_buffer, 3200);
+ close(info_file);
+ file_buffer[len] = '\0';
+
+ /*
+ parse the file ...
+ [ 0] fe80:0000:0000:0000:0002:c900:0120:3472
+ ...
+ */
+ if (!(p_ch = strstr(file_buffer, "[ 0]"))) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__get_port_guid_from_port_gid_tbl: ERR 5124: "
+ "Fail to obtain first gid index. In gid_table file:(%s).\n",
+ file_buffer);
+ goto Exit;
+ }
+ if (sscanf(p_ch + 6, "%x:%x:%x:%x:%x:%x:%x:%x",
+ &g[7], &g[6], &g[5], &g[4], &g[3], &g[2], &g[1], &g[0]) != 8)
+ {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__get_port_guid_from_port_gid_tbl: ERR 5125: "
+ "Fail to parse gid from gid_table file:(%s).\n", p_ch);
+ goto Exit;
+ }
+
+ *port_guid =
+ (uint64_t) g[3] << 48 | (uint64_t) g[2] << 32 | (uint64_t) g[1] <<
+ 16 | g[0];
+ status = IB_SUCCESS;
+ Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return status;
}
/**********************************************************************
* Initialize an Info Struct for the Given HCA by its index 1..N
**********************************************************************/
static ib_api_status_t
-__osm_ca_info_init( IN osm_vendor_t * const p_vend,
- IN uint32_t const idx,
- OUT osm_ca_info_t * const p_ca_info )
+__osm_ca_info_init(IN osm_vendor_t * const p_vend,
+ IN uint32_t const idx, OUT osm_ca_info_t * const p_ca_info)
{
- ib_api_status_t status = IB_ERROR;
- uint8_t port_num;
- uint64_t port_guid;
-
- sim_ca_info_t sim_ca_info;
-
- OSM_LOG_ENTER( p_vend->p_log, __osm_ca_info_init );
-
- /* parse the CA info file */
- if (__parse_ca_info_file(p_vend, idx, &sim_ca_info) != IB_SUCCESS)
- goto Exit;
-
- p_ca_info->guid = cl_hton64( sim_ca_info.guid );
-
- /* set size of attributes and allocate them */
- p_ca_info->attr_size = 1;
- p_ca_info->p_attr = ( ib_ca_attr_t * ) malloc( sizeof( ib_ca_attr_t ) );
-
- p_ca_info->p_attr->ca_guid = p_ca_info->guid;
- p_ca_info->p_attr->num_ports = sim_ca_info.num_ports;
-
- /* now obtain the attributes of the ports */
- p_ca_info->p_attr->p_port_attr =
- ( ib_port_attr_t * ) malloc( sim_ca_info.num_ports * sizeof( ib_port_attr_t ) );
-
- /* get all the ports info */
- for( port_num = 1; port_num <= sim_ca_info.num_ports; port_num++ )
- {
- sim_port_info_t sim_port_info;
- /* query the port attributes */
- if (__parse_port_info_file(p_vend, idx, port_num, &sim_port_info))
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__osm_ca_info_init: ERR 5126: "
- "Fail to get HCA:%d Port:%d Attributes.\n", idx, port_num );
- goto Exit;
- }
-
- /* HACK: the lids should have been converted to network but the rest of the code
- is wrong and provdes them as is (host order) - so we stick with it. */
- p_ca_info->p_attr->p_port_attr[port_num-1].lid = sim_port_info.lid;
- p_ca_info->p_attr->p_port_attr[port_num-1].link_state = sim_port_info.state;
- p_ca_info->p_attr->p_port_attr[port_num-1].sm_lid = sim_port_info.sm_lid;
-
- /* get the port guid */
- if (__get_port_guid_from_port_gid_tbl(p_vend, idx, port_num, &port_guid))
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__osm_ca_info_init: ERR 5127: "
- "Fail to get HCA:%d Port:%d Guid.\n", idx, port_num );
- goto Exit;
- }
- p_ca_info->p_attr->p_port_attr[port_num-1].port_guid =cl_hton64( port_guid );
- }
-
- status = IB_SUCCESS;
- Exit:
- OSM_LOG_EXIT( p_vend->p_log );
- return ( status );
+ ib_api_status_t status = IB_ERROR;
+ uint8_t port_num;
+ uint64_t port_guid;
+
+ sim_ca_info_t sim_ca_info;
+
+ OSM_LOG_ENTER(p_vend->p_log, __osm_ca_info_init);
+
+ /* parse the CA info file */
+ if (__parse_ca_info_file(p_vend, idx, &sim_ca_info) != IB_SUCCESS)
+ goto Exit;
+
+ p_ca_info->guid = cl_hton64(sim_ca_info.guid);
+
+ /* set size of attributes and allocate them */
+ p_ca_info->attr_size = 1;
+ p_ca_info->p_attr = (ib_ca_attr_t *) malloc(sizeof(ib_ca_attr_t));
+
+ p_ca_info->p_attr->ca_guid = p_ca_info->guid;
+ p_ca_info->p_attr->num_ports = sim_ca_info.num_ports;
+
+ /* now obtain the attributes of the ports */
+ p_ca_info->p_attr->p_port_attr =
+ (ib_port_attr_t *) malloc(sim_ca_info.num_ports *
+ sizeof(ib_port_attr_t));
+
+ /* get all the ports info */
+ for (port_num = 1; port_num <= sim_ca_info.num_ports; port_num++) {
+ sim_port_info_t sim_port_info;
+ /* query the port attributes */
+ if (__parse_port_info_file
+ (p_vend, idx, port_num, &sim_port_info)) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_ca_info_init: ERR 5126: "
+ "Fail to get HCA:%d Port:%d Attributes.\n", idx,
+ port_num);
+ goto Exit;
+ }
+
+ /* HACK: the lids should have been converted to network but the rest of the code
+ is wrong and provdes them as is (host order) - so we stick with it. */
+ p_ca_info->p_attr->p_port_attr[port_num - 1].lid =
+ sim_port_info.lid;
+ p_ca_info->p_attr->p_port_attr[port_num - 1].link_state =
+ sim_port_info.state;
+ p_ca_info->p_attr->p_port_attr[port_num - 1].sm_lid =
+ sim_port_info.sm_lid;
+
+ /* get the port guid */
+ if (__get_port_guid_from_port_gid_tbl
+ (p_vend, idx, port_num, &port_guid)) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_ca_info_init: ERR 5127: "
+ "Fail to get HCA:%d Port:%d Guid.\n", idx,
+ port_num);
+ goto Exit;
+ }
+ p_ca_info->p_attr->p_port_attr[port_num - 1].port_guid =
+ cl_hton64(port_guid);
+ }
+
+ status = IB_SUCCESS;
+ Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
}
/**********************************************************************
**********************************************************************/
void
-osm_ca_info_destroy( IN osm_vendor_t * const p_vend,
- IN osm_ca_info_t * const p_ca_info,
- IN uint8_t num_ca)
+osm_ca_info_destroy(IN osm_vendor_t * const p_vend,
+ IN osm_ca_info_t * const p_ca_info, IN uint8_t num_ca)
{
- osm_ca_info_t *p_ca;
- uint8_t i;
+ osm_ca_info_t *p_ca;
+ uint8_t i;
- OSM_LOG_ENTER( p_vend->p_log, osm_ca_info_destroy );
+ OSM_LOG_ENTER(p_vend->p_log, osm_ca_info_destroy);
- for (i=0; i < num_ca; i++)
- {
- p_ca = &p_ca_info[i];
+ for (i = 0; i < num_ca; i++) {
+ p_ca = &p_ca_info[i];
- if( NULL != p_ca->p_attr )
- {
- if(0 != p_ca->p_attr->num_ports)
- {
- free( p_ca->p_attr->p_port_attr );
- }
+ if (NULL != p_ca->p_attr) {
+ if (0 != p_ca->p_attr->num_ports) {
+ free(p_ca->p_attr->p_port_attr);
+ }
- free( p_ca->p_attr);
- }
- }
+ free(p_ca->p_attr);
+ }
+ }
- free( p_ca_info );
+ free(p_ca_info);
- OSM_LOG_EXIT( p_vend->p_log );
+ OSM_LOG_EXIT(p_vend->p_log);
}
/**********************************************************************
@@ -642,104 +626,97 @@ osm_ca_info_destroy( IN osm_vendor_t * const p_vend,
* avilable CAs on this machine.
**********************************************************************/
ib_api_status_t
-osm_vendor_get_all_port_attr( IN osm_vendor_t * const p_vend,
- IN ib_port_attr_t * const p_attr_array,
- IN uint32_t * const p_num_ports )
+osm_vendor_get_all_port_attr(IN osm_vendor_t * const p_vend,
+ IN ib_port_attr_t * const p_attr_array,
+ IN uint32_t * const p_num_ports)
{
- ib_api_status_t status = IB_SUCCESS;
-
- uint32_t caIdx;
- uint32_t ca_count = 0;
- uint32_t port_count = 0;
- uint8_t port_num;
- uint32_t total_ports = 0;
- osm_ca_info_t *p_ca_infos = NULL;
- uint32_t attr_array_sz = *p_num_ports;
-
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_get_all_port_attr );
-
- CL_ASSERT( p_vend );
-
- /* determine the number of CA's */
- ca_count = __hca_sim_get_num_cas();
- if (! ca_count)
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_all_port_attr: ERR 5128: "
- "Fail to get Any CA Ids.\n" );
- goto Exit;
- }
-
- /* Allocate an array big enough to hold the ca info objects*/
- p_ca_infos = malloc( ca_count * sizeof( osm_ca_info_t ) );
- if( p_ca_infos == NULL )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_all_port_attr: ERR 5129: "
- "Unable to allocate CA information array.\n" );
- goto Exit;
- }
-
- memset( p_ca_infos, 0, ca_count * sizeof( osm_ca_info_t ) );
-
- /*
- * For each CA, retrieve the CA info attributes
- */
- for( caIdx = 1; caIdx <= ca_count; caIdx++ )
- {
- status = __osm_ca_info_init( p_vend, caIdx, &p_ca_infos[caIdx-1] );
- if( status != IB_SUCCESS )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_all_port_attr: ERR 5130: "
- "Unable to initialize CA Info object (%s).\n",
- ib_get_err_str( status ) );
- goto Exit;
- }
- total_ports += p_ca_infos[caIdx-1].p_attr->num_ports;
- }
-
- *p_num_ports = total_ports;
- osm_log(p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_get_all_port_attr: total ports:%u \n",
- total_ports);
-
- /*
- * If the user supplied enough storage, return the port guids,
- * otherwise, return the appropriate error.
- */
- if( attr_array_sz >= total_ports )
- {
- for( caIdx = 1; caIdx <= ca_count; caIdx++ )
- {
- uint32_t num_ports;
-
- num_ports = p_ca_infos[caIdx-1].p_attr->num_ports;
-
- for( port_num = 0; port_num < num_ports; port_num++ )
- {
- p_attr_array[port_count] =
- *__osm_ca_info_get_port_attr_ptr( &p_ca_infos[caIdx-1], port_num );
- port_count++;
- }
- }
- }
- else
- {
- status = IB_INSUFFICIENT_MEMORY;
- goto Exit;
- }
-
- status = IB_SUCCESS;
-
- Exit:
- if ( p_ca_infos )
- {
- osm_ca_info_destroy(p_vend, p_ca_infos, ca_count);
- }
-
- OSM_LOG_EXIT( p_vend->p_log );
- return ( status );
+ ib_api_status_t status = IB_SUCCESS;
+
+ uint32_t caIdx;
+ uint32_t ca_count = 0;
+ uint32_t port_count = 0;
+ uint8_t port_num;
+ uint32_t total_ports = 0;
+ osm_ca_info_t *p_ca_infos = NULL;
+ uint32_t attr_array_sz = *p_num_ports;
+
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_get_all_port_attr);
+
+ CL_ASSERT(p_vend);
+
+ /* determine the number of CA's */
+ ca_count = __hca_sim_get_num_cas();
+ if (!ca_count) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_all_port_attr: ERR 5128: "
+ "Fail to get Any CA Ids.\n");
+ goto Exit;
+ }
+
+ /* Allocate an array big enough to hold the ca info objects */
+ p_ca_infos = malloc(ca_count * sizeof(osm_ca_info_t));
+ if (p_ca_infos == NULL) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_all_port_attr: ERR 5129: "
+ "Unable to allocate CA information array.\n");
+ goto Exit;
+ }
+
+ memset(p_ca_infos, 0, ca_count * sizeof(osm_ca_info_t));
+
+ /*
+ * For each CA, retrieve the CA info attributes
+ */
+ for (caIdx = 1; caIdx <= ca_count; caIdx++) {
+ status =
+ __osm_ca_info_init(p_vend, caIdx, &p_ca_infos[caIdx - 1]);
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_all_port_attr: ERR 5130: "
+ "Unable to initialize CA Info object (%s).\n",
+ ib_get_err_str(status));
+ goto Exit;
+ }
+ total_ports += p_ca_infos[caIdx - 1].p_attr->num_ports;
+ }
+
+ *p_num_ports = total_ports;
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_get_all_port_attr: total ports:%u \n", total_ports);
+
+ /*
+ * If the user supplied enough storage, return the port guids,
+ * otherwise, return the appropriate error.
+ */
+ if (attr_array_sz >= total_ports) {
+ for (caIdx = 1; caIdx <= ca_count; caIdx++) {
+ uint32_t num_ports;
+
+ num_ports = p_ca_infos[caIdx - 1].p_attr->num_ports;
+
+ for (port_num = 0; port_num < num_ports; port_num++) {
+ p_attr_array[port_count] =
+ *__osm_ca_info_get_port_attr_ptr(&p_ca_infos
+ [caIdx -
+ 1],
+ port_num);
+ port_count++;
+ }
+ }
+ } else {
+ status = IB_INSUFFICIENT_MEMORY;
+ goto Exit;
+ }
+
+ status = IB_SUCCESS;
+
+ Exit:
+ if (p_ca_infos) {
+ osm_ca_info_destroy(p_vend, p_ca_infos, ca_count);
+ }
+
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
}
/**********************************************************************
@@ -748,74 +725,73 @@ osm_vendor_get_all_port_attr( IN osm_vendor_t * const p_vend,
**********************************************************************/
ib_api_status_t
-osm_vendor_get_guid_ca_and_port(
- IN osm_vendor_t * const p_vend,
- IN ib_net64_t const guid,
- OUT uint32_t * p_hca_hndl,
- OUT char * p_hca_id,
- OUT uint8_t *p_hca_idx,
- OUT uint32_t * p_port_num )
+osm_vendor_get_guid_ca_and_port(IN osm_vendor_t * const p_vend,
+ IN ib_net64_t const guid,
+ OUT uint32_t * p_hca_hndl,
+ OUT char *p_hca_id,
+ OUT uint8_t * p_hca_idx,
+ OUT uint32_t * p_port_num)
{
- uint32_t caIdx;
- uint32_t ca_count = 0;
- uint8_t port_num;
- ib_api_status_t status = IB_ERROR;
-
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_get_guid_ca_and_port );
-
- CL_ASSERT( p_vend );
-
- /* determine the number of CA's */
- ca_count = __hca_sim_get_num_cas();
- if (! ca_count)
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_guid_ca_and_port: ERR 5131: "
- "Fail to get Any CA Ids.\n" );
- goto Exit;
- }
-
- /*
- * For each CA, retrieve the CA info attributes
- */
- for( caIdx = 1; caIdx <= ca_count; caIdx++ )
- {
- sim_ca_info_t sim_ca_info;
- if (__parse_ca_info_file(p_vend, caIdx, &sim_ca_info) == IB_SUCCESS)
- {
- /* get all the ports info */
- for( port_num = 1; port_num <= sim_ca_info.num_ports; port_num++ )
- {
- uint64_t port_guid;
- if (! __get_port_guid_from_port_gid_tbl(p_vend, caIdx, port_num, &port_guid))
- {
- if (cl_hton64(port_guid) == guid)
- {
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_get_guid_ca_and_port: "
- "Found Matching guid on HCA:%d Port:%d.\n", caIdx, port_num );
- strcpy(p_hca_id, sim_ca_info.name);
- *p_port_num = port_num;
- *p_hca_idx = caIdx - 1;
- *p_hca_hndl = 0;
- status = IB_SUCCESS;
- goto Exit;
- }
- }
- }
- }
- }
-
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_guid_ca_and_port: ERR 5132: "
- "Fail to find HCA and Port for Port Guid 0x%" PRIx64 "\n",
- cl_ntoh64(guid) );
- status = IB_INVALID_GUID;
-
- Exit:
-
- OSM_LOG_EXIT( p_vend->p_log );
- return ( status );
+ uint32_t caIdx;
+ uint32_t ca_count = 0;
+ uint8_t port_num;
+ ib_api_status_t status = IB_ERROR;
+
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_get_guid_ca_and_port);
+
+ CL_ASSERT(p_vend);
+
+ /* determine the number of CA's */
+ ca_count = __hca_sim_get_num_cas();
+ if (!ca_count) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_guid_ca_and_port: ERR 5131: "
+ "Fail to get Any CA Ids.\n");
+ goto Exit;
+ }
+
+ /*
+ * For each CA, retrieve the CA info attributes
+ */
+ for (caIdx = 1; caIdx <= ca_count; caIdx++) {
+ sim_ca_info_t sim_ca_info;
+ if (__parse_ca_info_file(p_vend, caIdx, &sim_ca_info) ==
+ IB_SUCCESS) {
+ /* get all the ports info */
+ for (port_num = 1; port_num <= sim_ca_info.num_ports;
+ port_num++) {
+ uint64_t port_guid;
+ if (!__get_port_guid_from_port_gid_tbl
+ (p_vend, caIdx, port_num, &port_guid)) {
+ if (cl_hton64(port_guid) == guid) {
+ osm_log(p_vend->p_log,
+ OSM_LOG_DEBUG,
+ "osm_vendor_get_guid_ca_and_port: "
+ "Found Matching guid on HCA:%d Port:%d.\n",
+ caIdx, port_num);
+ strcpy(p_hca_id,
+ sim_ca_info.name);
+ *p_port_num = port_num;
+ *p_hca_idx = caIdx - 1;
+ *p_hca_hndl = 0;
+ status = IB_SUCCESS;
+ goto Exit;
+ }
+ }
+ }
+ }
+ }
+
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_guid_ca_and_port: ERR 5132: "
+ "Fail to find HCA and Port for Port Guid 0x%" PRIx64 "\n",
+ cl_ntoh64(guid));
+ status = IB_INVALID_GUID;
+
+ Exit:
+
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
}
/**********************************************************************
@@ -824,68 +800,65 @@ osm_vendor_get_guid_ca_and_port(
**********************************************************************/
ib_api_status_t
-osm_vendor_get_guid_by_ca_and_port( IN osm_vendor_t * const p_vend,
- IN char *hca_id,
- IN uint32_t port_num,
- OUT uint64_t *p_port_guid)
+osm_vendor_get_guid_by_ca_and_port(IN osm_vendor_t * const p_vend,
+ IN char *hca_id,
+ IN uint32_t port_num,
+ OUT uint64_t * p_port_guid)
{
- uint32_t caIdx;
- uint32_t ca_count = 0;
- ib_api_status_t status = IB_ERROR;
-
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_get_guid_by_ca_and_port );
-
- CL_ASSERT( p_vend );
-
- /* determine the number of CA's */
- ca_count = __hca_sim_get_num_cas();
- if (! ca_count)
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_guid_by_ca_and_port: ERR 5133: "
- "Fail to get Any CA Ids.\n" );
- goto Exit;
- }
-
- /*
- * For each CA, retrieve the CA info attributes
- */
- for( caIdx = 1; caIdx <= ca_count; caIdx++ )
- {
- sim_ca_info_t sim_ca_info;
- if (__parse_ca_info_file(p_vend, caIdx, &sim_ca_info) == IB_SUCCESS)
- {
- /* if not identical by id - go to next one */
- if (strcmp(sim_ca_info.name, hca_id)) continue;
-
- if( (port_num < 1) || (port_num > sim_ca_info.num_ports))
- {
- return 1;
- }
-
-
- if (! __get_port_guid_from_port_gid_tbl(
- p_vend, caIdx, port_num, p_port_guid))
- {
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_get_guid_by_ca_and_port: "
- "Found Matching guid on HCA:%d Port:%d.\n", caIdx, port_num);
- status = IB_SUCCESS;
- goto Exit;
- }
- }
- }
-
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_guid_by_ca_and_port: ERR 5134: "
- "Fail to find HCA:%s\n",
- hca_id);
- status = IB_INVALID_GUID;
-
- Exit:
-
- OSM_LOG_EXIT( p_vend->p_log );
- return ( status );
+ uint32_t caIdx;
+ uint32_t ca_count = 0;
+ ib_api_status_t status = IB_ERROR;
+
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_get_guid_by_ca_and_port);
+
+ CL_ASSERT(p_vend);
+
+ /* determine the number of CA's */
+ ca_count = __hca_sim_get_num_cas();
+ if (!ca_count) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_guid_by_ca_and_port: ERR 5133: "
+ "Fail to get Any CA Ids.\n");
+ goto Exit;
+ }
+
+ /*
+ * For each CA, retrieve the CA info attributes
+ */
+ for (caIdx = 1; caIdx <= ca_count; caIdx++) {
+ sim_ca_info_t sim_ca_info;
+ if (__parse_ca_info_file(p_vend, caIdx, &sim_ca_info) ==
+ IB_SUCCESS) {
+ /* if not identical by id - go to next one */
+ if (strcmp(sim_ca_info.name, hca_id))
+ continue;
+
+ if ((port_num < 1)
+ || (port_num > sim_ca_info.num_ports)) {
+ return 1;
+ }
+
+ if (!__get_port_guid_from_port_gid_tbl
+ (p_vend, caIdx, port_num, p_port_guid)) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_get_guid_by_ca_and_port: "
+ "Found Matching guid on HCA:%d Port:%d.\n",
+ caIdx, port_num);
+ status = IB_SUCCESS;
+ goto Exit;
+ }
+ }
+ }
+
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_guid_by_ca_and_port: ERR 5134: "
+ "Fail to find HCA:%s\n", hca_id);
+ status = IB_INVALID_GUID;
+
+ Exit:
+
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
}
#endif
diff --git a/opensm/libvendor/osm_vendor_mlx_ibmgt.c b/opensm/libvendor/osm_vendor_mlx_ibmgt.c
index 45ec872..eca09c9 100644
--- a/opensm/libvendor/osm_vendor_mlx_ibmgt.c
+++ b/opensm/libvendor/osm_vendor_mlx_ibmgt.c
@@ -43,7 +43,7 @@
#if HAVE_CONFIG_H
# include <config.h>
-#endif /* HAVE_CONFIG_H */
+#endif /* HAVE_CONFIG_H */
#include <stdlib.h>
#include <string.h>
@@ -54,46 +54,41 @@
#include <opensm/osm_log.h>
typedef struct _osmv_IBMGT_transport_mgr_ {
- IB_MGT_mad_type_t mad_type;
- uint8_t mgmt_class; /* for gsi */
- /* for communication between send call back and send mad */
- boolean_t is_send_ok;
- cl_event_t send_done;
-}osmv_IBMGT_transport_mgr_t;
+ IB_MGT_mad_type_t mad_type;
+ uint8_t mgmt_class; /* for gsi */
+ /* for communication between send call back and send mad */
+ boolean_t is_send_ok;
+ cl_event_t send_done;
+} osmv_IBMGT_transport_mgr_t;
typedef struct _osmv_IBMGT_transport_info_ {
- IB_MGT_mad_hndl_t smi_h;
- cl_qlist_t* p_smi_list;
+ IB_MGT_mad_hndl_t smi_h;
+ cl_qlist_t *p_smi_list;
- IB_MGT_mad_hndl_t gsi_h;
- /* holds bind object list for every binded mgmt class */
- cl_qlist_t* gsi_mgmt_lists[15];
-}osmv_IBMGT_transport_info_t;
+ IB_MGT_mad_hndl_t gsi_h;
+ /* holds bind object list for every binded mgmt class */
+ cl_qlist_t *gsi_mgmt_lists[15];
+} osmv_IBMGT_transport_info_t;
static void
-__osmv_IBMGT_rcv_desc_to_osm_addr(
- IN IB_MGT_mad_rcv_desc_t *p_rcv_desc,
- IN uint8_t is_smi,
- OUT osm_mad_addr_t *p_mad_addr);
+__osmv_IBMGT_rcv_desc_to_osm_addr(IN IB_MGT_mad_rcv_desc_t * p_rcv_desc,
+ IN uint8_t is_smi,
+ OUT osm_mad_addr_t * p_mad_addr);
static void
-__osmv_IBMGT_osm_addr_to_ibmgt_addr(
- IN const osm_mad_addr_t *p_mad_addr,
- IN uint8_t is_smi,
- OUT IB_ud_av_t *p_av);
+__osmv_IBMGT_osm_addr_to_ibmgt_addr(IN const osm_mad_addr_t * p_mad_addr,
+ IN uint8_t is_smi, OUT IB_ud_av_t * p_av);
void
-__osmv_IBMGT_send_cb( IN IB_MGT_mad_hndl_t mad_hndl,
- IN u_int64_t wrid,
- IN IB_comp_status_t status,
- IN void *private_ctx_p );
+__osmv_IBMGT_send_cb(IN IB_MGT_mad_hndl_t mad_hndl,
+ IN u_int64_t wrid,
+ IN IB_comp_status_t status, IN void *private_ctx_p);
void
-__osmv_IBMGT_rcv_cb( IN IB_MGT_mad_hndl_t mad_hndl,
- IN void *private_ctx_p,
- IN void *payload_p,
- IN IB_MGT_mad_rcv_desc_t * rcv_remote_info_p );
-
+__osmv_IBMGT_rcv_cb(IN IB_MGT_mad_hndl_t mad_hndl,
+ IN void *private_ctx_p,
+ IN void *payload_p,
+ IN IB_MGT_mad_rcv_desc_t * rcv_remote_info_p);
/*
* NAME
@@ -104,262 +99,261 @@ __osmv_IBMGT_rcv_cb( IN IB_MGT_mad_hndl_t mad_hndl,
*/
ib_api_status_t
-osmv_transport_init(IN osm_bind_info_t *p_info,
- IN char hca_id[VENDOR_HCA_MAXNAMES],
- IN uint8_t hca_idx,
- IN osmv_bind_obj_t *p_bo)
+osmv_transport_init(IN osm_bind_info_t * p_info,
+ IN char hca_id[VENDOR_HCA_MAXNAMES],
+ IN uint8_t hca_idx, IN osmv_bind_obj_t * p_bo)
{
- ib_api_status_t st = IB_SUCCESS;
- IB_MGT_ret_t ret;
- IB_MGT_mad_type_t mad_type;
- osmv_IBMGT_transport_mgr_t* p_mgr;
- osmv_IBMGT_transport_info_t* p_tpot_info;
- cl_list_obj_t* p_obj = NULL;
- osm_log_t* p_log = p_bo->p_vendor->p_log;
- int i;
-
- UNUSED_PARAM( hca_idx );
-
- /* if first bind, allocate tranport_info at vendor*/
- if (NULL == p_bo->p_vendor->p_transport_info)
- {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "osmv_transport_init: first bind() for the vendor\n");
- p_bo->p_vendor->p_transport_info
- = (osmv_IBMGT_transport_info_t*) malloc(sizeof(osmv_IBMGT_transport_info_t));
- if (NULL == p_bo->p_vendor->p_transport_info)
- {
- return IB_INSUFFICIENT_MEMORY;
- }
- memset(p_bo->p_vendor->p_transport_info, 0, sizeof(osmv_IBMGT_transport_info_t));
- p_tpot_info = (osmv_IBMGT_transport_info_t*)(p_bo->p_vendor->p_transport_info);
-
- p_tpot_info->smi_h = 0xffffffff;
- p_tpot_info->p_smi_list = NULL;
-
- p_tpot_info->gsi_h = 0xffffffff;
- for (i=0; i< 15; i++) {
-
- p_tpot_info->gsi_mgmt_lists[i] = NULL;
- }
-
- } else {
-
- p_tpot_info = (osmv_IBMGT_transport_info_t*)(p_bo->p_vendor->p_transport_info);
- }
-
- /* Initialize the magic_ptr to the pointer of the p_bo info.
- This will be used to signal when the object is being destroyed, so no
- real action will be done then. */
- p_bo->magic_ptr = p_bo;
-
-
- /* allocate transport mgr */
- p_mgr = malloc(sizeof(osmv_IBMGT_transport_mgr_t));
- if (NULL == p_mgr)
- {
- free(p_tpot_info);
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "osmv_transport_init: ERR 7201: "
- "alloc failed \n");
- return IB_INSUFFICIENT_MEMORY;
- }
-
- memset(p_mgr, 0, sizeof(osmv_IBMGT_transport_mgr_t));
-
- p_bo->p_transp_mgr = p_mgr;
-
- switch ( p_info->mad_class ) {
- case IB_MCLASS_SUBN_LID:
- case IB_MCLASS_SUBN_DIR:
- mad_type = IB_MGT_SMI;
- break;
-
- case IB_MCLASS_SUBN_ADM:
- default:
- mad_type = IB_MGT_GSI;
- break;
- }
-
- /* we only support one class registration per SMI/GSI !!! */
- switch (mad_type) {
- case IB_MGT_SMI:
- /* we do not need to bind the handle if already available */
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "osmv_transport_init: SMI bind\n");
-
- if (p_tpot_info->smi_h == 0xffffffff)
- {
- ret = IB_MGT_get_handle(hca_id,
- p_bo->port_num,
- IB_MGT_SMI,
- &(p_tpot_info->smi_h));
- if ( IB_MGT_OK != ret )
- {
- osm_log(p_log, OSM_LOG_ERROR,
- "osmv_transport_init: ERR 7202: "
- "IB_MGT_get_handle for smi failed \n");
- st = IB_ERROR;
- free(p_mgr);
- goto Exit;
- }
-
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "osmv_transport_init: got smi handle:%d \n",
- p_tpot_info->smi_h);
-
- ret = IB_MGT_bind_sm( p_tpot_info->smi_h );
- if ( IB_MGT_OK != ret )
- {
- osm_log(p_log, OSM_LOG_ERROR,
- "osmv_transport_init: ERR 7203: "
- "IB_MGT_bind_sm failed \n");
- st = IB_ERROR;
- free( p_mgr);
- goto Exit;
- }
-
- /* init smi list */
- p_tpot_info->p_smi_list = malloc(sizeof(cl_qlist_t));
- if (NULL == p_tpot_info->p_smi_list)
- {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "osmv_transport_init: ERR 7204: "
- "alloc failed \n");
- IB_MGT_unbind_sm(p_tpot_info->smi_h);
- IB_MGT_release_handle(p_tpot_info->smi_h);
- free(p_mgr);
- return IB_INSUFFICIENT_MEMORY;
- }
- memset(p_tpot_info->p_smi_list, 0, sizeof(cl_qlist_t));
- cl_qlist_init(p_tpot_info->p_smi_list);
-
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "osmv_transport_init: before reg_cb\n");
- ret = IB_MGT_reg_cb(p_tpot_info->smi_h,
- &__osmv_IBMGT_rcv_cb,
- p_bo,
- &__osmv_IBMGT_send_cb,
- p_tpot_info->p_smi_list,
- IB_MGT_RCV_CB_MASK | IB_MGT_SEND_CB_MASK );
- if (ret != IB_SUCCESS)
- {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "osmv_transport_init: ERR 7205: "
- "reg_cb failed with return code:%x \n",
- ret
- );
- IB_MGT_unbind_sm(p_tpot_info->smi_h);
- IB_MGT_release_handle(p_tpot_info->smi_h);
- free(p_tpot_info->p_smi_list);
- free(p_mgr);
- st= IB_ERROR;
- goto Exit;
- }
-
- }
- /* insert to list of smi's - for raising callbacks later on */
- p_obj = malloc(sizeof(cl_list_obj_t));
- if (p_obj)
- memset(p_obj, 0, sizeof(cl_list_obj_t));
- cl_qlist_set_obj(p_obj, p_bo);
- cl_qlist_insert_tail(p_tpot_info->p_smi_list, &p_obj->list_item);
-
- break;
-
- case IB_MGT_GSI:
- /* we do not need to bind the handle if already available */
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "osmv_transport_init: ERR 7206: GSI bind\n" );
- if (p_tpot_info->gsi_h == 0xffffffff)
- {
- ret = IB_MGT_get_handle(hca_id,
- p_bo->port_num,
- IB_MGT_GSI,
- &(p_tpot_info->gsi_h));
- if ( IB_MGT_OK != ret )
- {
- osm_log(p_log, OSM_LOG_ERROR,
- "osmv_transport_init: ERR 7207: "
- "IB_MGT_get_handle for gsi failed \n");
- st = IB_ERROR;
- free(p_mgr);
- goto Exit;
- }
- }
-
- /* this mgmt class was not binded yet */
- if (p_tpot_info->gsi_mgmt_lists[p_info->mad_class] == NULL)
- {
- ret = IB_MGT_bind_gsi_class( p_tpot_info->gsi_h,p_info->mad_class);
- if ( IB_MGT_OK != ret )
- {
- osm_log(p_log, OSM_LOG_ERROR,
- "osmv_transport_init: ERR 7208: "
- "IB_MGT_bind_gsi_class failed \n");
- st = IB_ERROR;
- free( p_mgr);
- goto Exit;
- }
-
- p_tpot_info->gsi_mgmt_lists[p_info->mad_class] = malloc(sizeof(cl_qlist_t));
- if (NULL == p_tpot_info->gsi_mgmt_lists[p_info->mad_class])
- {
- IB_MGT_unbind_gsi_class(p_tpot_info->gsi_h,p_info->mad_class);
- free(p_mgr);
- return IB_INSUFFICIENT_MEMORY;
- }
- memset(p_tpot_info->gsi_mgmt_lists[p_info->mad_class], 0, sizeof(cl_qlist_t));
- cl_qlist_init(p_tpot_info->gsi_mgmt_lists[p_info->mad_class]);
- }
- /* insert to list of smi's - for raising callbacks later on */
- p_obj = malloc(sizeof(cl_list_obj_t));
- if (p_obj)
- memset(p_obj, 0, sizeof(cl_list_obj_t));
- cl_qlist_set_obj(p_obj,p_bo);
- cl_qlist_insert_tail(p_tpot_info->gsi_mgmt_lists[p_info->mad_class],&p_obj->list_item);
-
- p_mgr->mgmt_class = p_info->mad_class;
- ret = IB_MGT_reg_cb(p_tpot_info->gsi_h,
- &__osmv_IBMGT_rcv_cb,
- p_bo,
- &__osmv_IBMGT_send_cb,
- p_bo,
- IB_MGT_RCV_CB_MASK | IB_MGT_SEND_CB_MASK );
-
- if (ret != IB_SUCCESS)
- {
- IB_MGT_unbind_gsi_class(p_tpot_info->gsi_h,p_mgr->mgmt_class);
- free(p_tpot_info->gsi_mgmt_lists[p_mgr->mgmt_class]);
- free(p_mgr);
- st= IB_ERROR;
- goto Exit;
- }
-
- break;
-
- default:
- osm_log(p_log, OSM_LOG_ERROR,
- "osmv_transport_init: ERR 7209: unrecognized mgmt class \n" );
- st = IB_ERROR;
- free( p_mgr);
- goto Exit;
- }
-
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "osmv_transport_init: GSI bind\n");
- cl_event_construct(&p_mgr->send_done);
- cl_event_init(&p_mgr->send_done,TRUE);
- p_mgr->is_send_ok = FALSE;
- p_mgr->mad_type = mad_type;
-
- Exit:
- /* OSM_LOG_EXIT(p_log ); */
- return(ib_api_status_t)st;
+ ib_api_status_t st = IB_SUCCESS;
+ IB_MGT_ret_t ret;
+ IB_MGT_mad_type_t mad_type;
+ osmv_IBMGT_transport_mgr_t *p_mgr;
+ osmv_IBMGT_transport_info_t *p_tpot_info;
+ cl_list_obj_t *p_obj = NULL;
+ osm_log_t *p_log = p_bo->p_vendor->p_log;
+ int i;
+
+ UNUSED_PARAM(hca_idx);
+
+ /* if first bind, allocate tranport_info at vendor */
+ if (NULL == p_bo->p_vendor->p_transport_info) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "osmv_transport_init: first bind() for the vendor\n");
+ p_bo->p_vendor->p_transport_info
+ =
+ (osmv_IBMGT_transport_info_t *)
+ malloc(sizeof(osmv_IBMGT_transport_info_t));
+ if (NULL == p_bo->p_vendor->p_transport_info) {
+ return IB_INSUFFICIENT_MEMORY;
+ }
+ memset(p_bo->p_vendor->p_transport_info, 0,
+ sizeof(osmv_IBMGT_transport_info_t));
+ p_tpot_info =
+ (osmv_IBMGT_transport_info_t *) (p_bo->p_vendor->
+ p_transport_info);
+
+ p_tpot_info->smi_h = 0xffffffff;
+ p_tpot_info->p_smi_list = NULL;
+
+ p_tpot_info->gsi_h = 0xffffffff;
+ for (i = 0; i < 15; i++) {
+
+ p_tpot_info->gsi_mgmt_lists[i] = NULL;
+ }
+
+ } else {
+
+ p_tpot_info =
+ (osmv_IBMGT_transport_info_t *) (p_bo->p_vendor->
+ p_transport_info);
+ }
+
+ /* Initialize the magic_ptr to the pointer of the p_bo info.
+ This will be used to signal when the object is being destroyed, so no
+ real action will be done then. */
+ p_bo->magic_ptr = p_bo;
+
+ /* allocate transport mgr */
+ p_mgr = malloc(sizeof(osmv_IBMGT_transport_mgr_t));
+ if (NULL == p_mgr) {
+ free(p_tpot_info);
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "osmv_transport_init: ERR 7201: " "alloc failed \n");
+ return IB_INSUFFICIENT_MEMORY;
+ }
+
+ memset(p_mgr, 0, sizeof(osmv_IBMGT_transport_mgr_t));
+
+ p_bo->p_transp_mgr = p_mgr;
+
+ switch (p_info->mad_class) {
+ case IB_MCLASS_SUBN_LID:
+ case IB_MCLASS_SUBN_DIR:
+ mad_type = IB_MGT_SMI;
+ break;
+
+ case IB_MCLASS_SUBN_ADM:
+ default:
+ mad_type = IB_MGT_GSI;
+ break;
+ }
+
+ /* we only support one class registration per SMI/GSI !!! */
+ switch (mad_type) {
+ case IB_MGT_SMI:
+ /* we do not need to bind the handle if already available */
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "osmv_transport_init: SMI bind\n");
+
+ if (p_tpot_info->smi_h == 0xffffffff) {
+ ret = IB_MGT_get_handle(hca_id,
+ p_bo->port_num,
+ IB_MGT_SMI,
+ &(p_tpot_info->smi_h));
+ if (IB_MGT_OK != ret) {
+ osm_log(p_log, OSM_LOG_ERROR,
+ "osmv_transport_init: ERR 7202: "
+ "IB_MGT_get_handle for smi failed \n");
+ st = IB_ERROR;
+ free(p_mgr);
+ goto Exit;
+ }
+
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "osmv_transport_init: got smi handle:%d \n",
+ p_tpot_info->smi_h);
+
+ ret = IB_MGT_bind_sm(p_tpot_info->smi_h);
+ if (IB_MGT_OK != ret) {
+ osm_log(p_log, OSM_LOG_ERROR,
+ "osmv_transport_init: ERR 7203: "
+ "IB_MGT_bind_sm failed \n");
+ st = IB_ERROR;
+ free(p_mgr);
+ goto Exit;
+ }
+
+ /* init smi list */
+ p_tpot_info->p_smi_list = malloc(sizeof(cl_qlist_t));
+ if (NULL == p_tpot_info->p_smi_list) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "osmv_transport_init: ERR 7204: "
+ "alloc failed \n");
+ IB_MGT_unbind_sm(p_tpot_info->smi_h);
+ IB_MGT_release_handle(p_tpot_info->smi_h);
+ free(p_mgr);
+ return IB_INSUFFICIENT_MEMORY;
+ }
+ memset(p_tpot_info->p_smi_list, 0, sizeof(cl_qlist_t));
+ cl_qlist_init(p_tpot_info->p_smi_list);
+
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "osmv_transport_init: before reg_cb\n");
+ ret = IB_MGT_reg_cb(p_tpot_info->smi_h,
+ &__osmv_IBMGT_rcv_cb,
+ p_bo,
+ &__osmv_IBMGT_send_cb,
+ p_tpot_info->p_smi_list,
+ IB_MGT_RCV_CB_MASK |
+ IB_MGT_SEND_CB_MASK);
+ if (ret != IB_SUCCESS) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "osmv_transport_init: ERR 7205: "
+ "reg_cb failed with return code:%x \n",
+ ret);
+ IB_MGT_unbind_sm(p_tpot_info->smi_h);
+ IB_MGT_release_handle(p_tpot_info->smi_h);
+ free(p_tpot_info->p_smi_list);
+ free(p_mgr);
+ st = IB_ERROR;
+ goto Exit;
+ }
+
+ }
+ /* insert to list of smi's - for raising callbacks later on */
+ p_obj = malloc(sizeof(cl_list_obj_t));
+ if (p_obj)
+ memset(p_obj, 0, sizeof(cl_list_obj_t));
+ cl_qlist_set_obj(p_obj, p_bo);
+ cl_qlist_insert_tail(p_tpot_info->p_smi_list,
+ &p_obj->list_item);
+
+ break;
+
+ case IB_MGT_GSI:
+ /* we do not need to bind the handle if already available */
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "osmv_transport_init: ERR 7206: GSI bind\n");
+ if (p_tpot_info->gsi_h == 0xffffffff) {
+ ret = IB_MGT_get_handle(hca_id,
+ p_bo->port_num,
+ IB_MGT_GSI,
+ &(p_tpot_info->gsi_h));
+ if (IB_MGT_OK != ret) {
+ osm_log(p_log, OSM_LOG_ERROR,
+ "osmv_transport_init: ERR 7207: "
+ "IB_MGT_get_handle for gsi failed \n");
+ st = IB_ERROR;
+ free(p_mgr);
+ goto Exit;
+ }
+ }
+
+ /* this mgmt class was not binded yet */
+ if (p_tpot_info->gsi_mgmt_lists[p_info->mad_class] == NULL) {
+ ret =
+ IB_MGT_bind_gsi_class(p_tpot_info->gsi_h,
+ p_info->mad_class);
+ if (IB_MGT_OK != ret) {
+ osm_log(p_log, OSM_LOG_ERROR,
+ "osmv_transport_init: ERR 7208: "
+ "IB_MGT_bind_gsi_class failed \n");
+ st = IB_ERROR;
+ free(p_mgr);
+ goto Exit;
+ }
+
+ p_tpot_info->gsi_mgmt_lists[p_info->mad_class] =
+ malloc(sizeof(cl_qlist_t));
+ if (NULL ==
+ p_tpot_info->gsi_mgmt_lists[p_info->mad_class]) {
+ IB_MGT_unbind_gsi_class(p_tpot_info->gsi_h,
+ p_info->mad_class);
+ free(p_mgr);
+ return IB_INSUFFICIENT_MEMORY;
+ }
+ memset(p_tpot_info->gsi_mgmt_lists[p_info->mad_class],
+ 0, sizeof(cl_qlist_t));
+ cl_qlist_init(p_tpot_info->
+ gsi_mgmt_lists[p_info->mad_class]);
+ }
+ /* insert to list of smi's - for raising callbacks later on */
+ p_obj = malloc(sizeof(cl_list_obj_t));
+ if (p_obj)
+ memset(p_obj, 0, sizeof(cl_list_obj_t));
+ cl_qlist_set_obj(p_obj, p_bo);
+ cl_qlist_insert_tail(p_tpot_info->
+ gsi_mgmt_lists[p_info->mad_class],
+ &p_obj->list_item);
+
+ p_mgr->mgmt_class = p_info->mad_class;
+ ret = IB_MGT_reg_cb(p_tpot_info->gsi_h,
+ &__osmv_IBMGT_rcv_cb,
+ p_bo,
+ &__osmv_IBMGT_send_cb,
+ p_bo,
+ IB_MGT_RCV_CB_MASK | IB_MGT_SEND_CB_MASK);
+
+ if (ret != IB_SUCCESS) {
+ IB_MGT_unbind_gsi_class(p_tpot_info->gsi_h,
+ p_mgr->mgmt_class);
+ free(p_tpot_info->gsi_mgmt_lists[p_mgr->mgmt_class]);
+ free(p_mgr);
+ st = IB_ERROR;
+ goto Exit;
+ }
+
+ break;
+
+ default:
+ osm_log(p_log, OSM_LOG_ERROR,
+ "osmv_transport_init: ERR 7209: unrecognized mgmt class \n");
+ st = IB_ERROR;
+ free(p_mgr);
+ goto Exit;
+ }
+
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "osmv_transport_init: GSI bind\n");
+ cl_event_construct(&p_mgr->send_done);
+ cl_event_init(&p_mgr->send_done, TRUE);
+ p_mgr->is_send_ok = FALSE;
+ p_mgr->mad_type = mad_type;
+
+ Exit:
+ /* OSM_LOG_EXIT(p_log ); */
+ return (ib_api_status_t) st;
}
-
-
/*
* NAME
* osmv_transport_send_mad
@@ -370,439 +364,421 @@ osmv_transport_init(IN osm_bind_info_t *p_info,
ib_api_status_t
osmv_transport_mad_send(IN const osm_bind_handle_t h_bind,
- IN void *p_ib_mad,
- IN const osm_mad_addr_t *p_mad_addr){
-
- osmv_bind_obj_t* p_bo = (osmv_bind_obj_t*)h_bind;
- osmv_IBMGT_transport_info_t* p_tpot_info =
- (osmv_IBMGT_transport_info_t*)(p_bo->p_vendor->p_transport_info);
- osm_vendor_t const *p_vend = p_bo->p_vendor;
- ib_api_status_t status;
- IB_ud_av_t av;
- IB_MGT_ret_t ret;
- ib_mad_t* p_mad = p_ib_mad;
-
- OSM_LOG_ENTER( p_vend->p_log,osmv_transport_mad_send);
-
- CL_ASSERT(p_bo->p_vendor->p_transport_info);
-
- /*
- * For all sends other than directed route SM MADs,
- * acquire an address vector for the destination.
- */
- if ( p_mad->mgmt_class != IB_MCLASS_SUBN_DIR )
- {
- __osmv_IBMGT_osm_addr_to_ibmgt_addr(p_mad_addr,p_mad->mgmt_class == IB_MCLASS_SUBN_LID,&av);
- }
- else
- {
- /* is a directed route - we need to construct a permissive address */
- memset( &av, 0, sizeof( av ) );
- /* we do not need port number since it is part of the mad_hndl */
- av.dlid = IB_LID_PERMISSIVE;
- }
-
- /* send it */
- if ( (p_mad->mgmt_class == IB_MCLASS_SUBN_DIR) ||
- (p_mad->mgmt_class == IB_MCLASS_SUBN_LID)) {
-
- /* SMI CASE */
- if ( osm_log_is_active( p_vend->p_log, OSM_LOG_DEBUG ) )
- {
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "osmv_transport_mad_send: "
- "av.dlid:0x%X, "
- "av.static_rate:%d, "
- "av.path_bits:%d.\n",
- cl_ntoh16( av.dlid ), av.static_rate, av.src_path_bits );
- }
-
- ret = IB_MGT_send_mad(p_tpot_info->smi_h,p_mad, /* actual payload */
- &av, /* address vector */
- (u_int64_t)CAST_P2LONG(p_bo),
- IB_MGT_DEFAULT_SEND_TIME );
- }
- else
- {
- /* GSI CASE - Support Remote QP */
- if ( osm_log_is_active( p_vend->p_log, OSM_LOG_DEBUG ) )
- {
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "osmv_transport_mad_send: "
- "av.dlid:0x%X, av.static_rate:%d, av.path_bits:%d, remote qp:%d \n",
- cl_ntoh16( av.dlid ), av.static_rate, av.src_path_bits,
- cl_ntoh32(p_mad_addr->addr_type.gsi.remote_qp)
- );
- }
-
- ret = IB_MGT_send_mad_to_qp(p_tpot_info->gsi_h,
- p_mad, /* actual payload */
- &av, /* address vector */
- (u_int64_t)CAST_P2LONG(p_bo),
- IB_MGT_DEFAULT_SEND_TIME,
- cl_ntoh32(p_mad_addr->addr_type.gsi.remote_qp));
-
-
- }
-
- status = IB_SUCCESS;
- if ( ret != IB_MGT_OK )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osmv_transport_mad_send: ERR 7210: "
- "Error sending mad (%d).\n", ret );
- status = IB_ERROR;
- }
- else
- {
- osmv_IBMGT_transport_mgr_t* p_mgr =
- (osmv_IBMGT_transport_mgr_t* ) (p_bo->p_transp_mgr);
-
- /* Let the others work when I am sleeping ... */
- osmv_txn_unlock(p_bo);
-
- cl_event_wait_on(&(p_mgr->send_done),0xffffffff,TRUE);
-
- /* Re-acquire the lock */
- osmv_txn_lock(p_bo);
-
- if (TRUE == p_bo->is_closing)
- {
-
- osm_log(p_vend->p_log, OSM_LOG_ERROR,
- "osmv_transport_mad_send: ERR 7211: "
- "The handle %p is being unbound, cannot send.\n", h_bind);
- status = IB_ERROR;
- }
-
- if (p_mgr->is_send_ok == FALSE)
- {
- status = IB_ERROR;
- }
- }
-
- OSM_LOG_EXIT( p_vend->p_log );
- return(status);
-}
-
-
+ IN void *p_ib_mad, IN const osm_mad_addr_t * p_mad_addr)
+{
-void
-osmv_transport_done(IN const osm_bind_handle_t h_bind){
- osmv_bind_obj_t* p_bo = (osmv_bind_obj_t*)h_bind;
- osm_log_t* p_log = p_bo->p_vendor->p_log;
- osmv_IBMGT_transport_mgr_t* p_mgr;
- osmv_IBMGT_transport_info_t* p_tpot_info;
- IB_MGT_ret_t ret;
- cl_list_obj_t* p_obj = NULL;
- cl_list_item_t* p_item,*p_item_tmp;
- int i;
- cl_qlist_t* p_list = NULL;
-
- OSM_LOG_ENTER( p_log, osmv_transport_done );
-
- CL_ASSERT(p_bo);
-
- /* First of all - zero out the magic_ptr, so if a callback is called -
- it'll know that we are currently closing down, and will not handle the
- mad. */
- p_bo->magic_ptr = 0;
-
- p_mgr = (osmv_IBMGT_transport_mgr_t*)(p_bo->p_transp_mgr);
- p_tpot_info = (osmv_IBMGT_transport_info_t*)(p_bo->p_vendor->p_transport_info);
-
-
-
- switch (p_mgr->mad_type) {
- case IB_MGT_SMI:
- p_list = p_tpot_info->p_smi_list;
-
- /* remove from the bindings list */
- p_item = cl_qlist_head(p_list);
- while (p_item != cl_qlist_end(p_list)) {
- p_obj = PARENT_STRUCT(p_item,cl_list_obj_t,list_item);
- if (cl_qlist_obj(p_obj) == h_bind)
- {
- break;
- }
- p_item_tmp = cl_qlist_next(p_item);
- p_item = p_item_tmp;
- }
-
- CL_ASSERT(p_item != cl_qlist_end(p_list));
- cl_qlist_remove_item(p_list,p_item);
- if (p_obj) free(p_obj);
-
- /* no one is binded to smi anymore - we can free the list, unbind & realease the hndl*/
- if (cl_is_qlist_empty(p_list) == TRUE)
- {
- free(p_list);
- p_list = NULL;
-
- ret = IB_MGT_unbind_sm(p_tpot_info->smi_h);
- if ( ret != IB_MGT_OK )
- {
- osm_log( p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "osmv_transport_done: ERR 7212: "
- "Failed to unbind sm\n" );
- }
-
- ret= IB_MGT_release_handle(p_tpot_info->smi_h);
- if ( ret != IB_MGT_OK )
- {
- osm_log( p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "osmv_transport_done: ERR 7213: "
- "Failed to release smi handle\n" );
- }
- p_tpot_info->smi_h = 0xffffffff;
- }
- break;
-
- case IB_MGT_GSI:
- p_list = p_tpot_info->gsi_mgmt_lists[p_mgr->mgmt_class];
- /* remove from the bindings list */
- p_item = cl_qlist_head(p_list);
- while (p_item != cl_qlist_end(p_list)) {
- p_obj = PARENT_STRUCT(p_item,cl_list_obj_t,list_item);
- if (cl_qlist_obj(p_obj) == h_bind)
- {
- break;
- }
- p_item_tmp = cl_qlist_next(p_item);
- p_item = p_item_tmp;
- }
-
- CL_ASSERT(p_item != cl_qlist_end(p_list));
- cl_qlist_remove_item(p_list,p_item);
- if (p_obj) free(p_obj);
-
- /* no one is binded to this class anymore - we can free the list and unbind this class*/
- if (cl_is_qlist_empty(p_list) == TRUE)
- {
- free(p_list);
- p_list = NULL;
-
- ret = IB_MGT_unbind_gsi_class(p_tpot_info->gsi_h,p_mgr->mgmt_class);
- if ( ret != IB_MGT_OK )
- {
- osm_log( p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "osmv_transport_done: ERR 7214: "
- "Failed to unbind gsi class\n" );
- }
- }
-
- /* all the mgmt classes are unbinded - release gsi handle*/
- for (i=0; i< 15; i++) {
- if (p_tpot_info->gsi_mgmt_lists[i] != NULL)
- {
- break;
- }
- }
-
- if (i==15)
- {
- ret= IB_MGT_release_handle(p_tpot_info->gsi_h);
- if ( ret != IB_MGT_OK )
- {
- osm_log( p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "osmv_transport_done: ERR 7215: "
- "Failed to release gsi handle\n" );
- }
- p_tpot_info->gsi_h = 0xffffffff;
- }
- }/* end switch */
-
- free(p_mgr);
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ osmv_IBMGT_transport_info_t *p_tpot_info =
+ (osmv_IBMGT_transport_info_t *) (p_bo->p_vendor->p_transport_info);
+ osm_vendor_t const *p_vend = p_bo->p_vendor;
+ ib_api_status_t status;
+ IB_ud_av_t av;
+ IB_MGT_ret_t ret;
+ ib_mad_t *p_mad = p_ib_mad;
+
+ OSM_LOG_ENTER(p_vend->p_log, osmv_transport_mad_send);
+
+ CL_ASSERT(p_bo->p_vendor->p_transport_info);
+
+ /*
+ * For all sends other than directed route SM MADs,
+ * acquire an address vector for the destination.
+ */
+ if (p_mad->mgmt_class != IB_MCLASS_SUBN_DIR) {
+ __osmv_IBMGT_osm_addr_to_ibmgt_addr(p_mad_addr,
+ p_mad->mgmt_class ==
+ IB_MCLASS_SUBN_LID, &av);
+ } else {
+ /* is a directed route - we need to construct a permissive address */
+ memset(&av, 0, sizeof(av));
+ /* we do not need port number since it is part of the mad_hndl */
+ av.dlid = IB_LID_PERMISSIVE;
+ }
+
+ /* send it */
+ if ((p_mad->mgmt_class == IB_MCLASS_SUBN_DIR) ||
+ (p_mad->mgmt_class == IB_MCLASS_SUBN_LID)) {
+
+ /* SMI CASE */
+ if (osm_log_is_active(p_vend->p_log, OSM_LOG_DEBUG)) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osmv_transport_mad_send: "
+ "av.dlid:0x%X, "
+ "av.static_rate:%d, "
+ "av.path_bits:%d.\n",
+ cl_ntoh16(av.dlid), av.static_rate,
+ av.src_path_bits);
+ }
+
+ ret = IB_MGT_send_mad(p_tpot_info->smi_h, p_mad, /* actual payload */
+ &av, /* address vector */
+ (u_int64_t) CAST_P2LONG(p_bo),
+ IB_MGT_DEFAULT_SEND_TIME);
+ } else {
+ /* GSI CASE - Support Remote QP */
+ if (osm_log_is_active(p_vend->p_log, OSM_LOG_DEBUG)) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osmv_transport_mad_send: "
+ "av.dlid:0x%X, av.static_rate:%d, av.path_bits:%d, remote qp:%d \n",
+ cl_ntoh16(av.dlid), av.static_rate,
+ av.src_path_bits,
+ cl_ntoh32(p_mad_addr->addr_type.gsi.remote_qp)
+ );
+ }
+
+ ret = IB_MGT_send_mad_to_qp(p_tpot_info->gsi_h, p_mad, /* actual payload */
+ &av, /* address vector */
+ (u_int64_t) CAST_P2LONG(p_bo),
+ IB_MGT_DEFAULT_SEND_TIME,
+ cl_ntoh32(p_mad_addr->addr_type.gsi.
+ remote_qp));
+
+ }
+
+ status = IB_SUCCESS;
+ if (ret != IB_MGT_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osmv_transport_mad_send: ERR 7210: "
+ "Error sending mad (%d).\n", ret);
+ status = IB_ERROR;
+ } else {
+ osmv_IBMGT_transport_mgr_t *p_mgr =
+ (osmv_IBMGT_transport_mgr_t *) (p_bo->p_transp_mgr);
+
+ /* Let the others work when I am sleeping ... */
+ osmv_txn_unlock(p_bo);
+
+ cl_event_wait_on(&(p_mgr->send_done), 0xffffffff, TRUE);
+
+ /* Re-acquire the lock */
+ osmv_txn_lock(p_bo);
+
+ if (TRUE == p_bo->is_closing) {
+
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osmv_transport_mad_send: ERR 7211: "
+ "The handle %p is being unbound, cannot send.\n",
+ h_bind);
+ status = IB_ERROR;
+ }
+
+ if (p_mgr->is_send_ok == FALSE) {
+ status = IB_ERROR;
+ }
+ }
+
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
}
+void osmv_transport_done(IN const osm_bind_handle_t h_bind)
+{
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ osm_log_t *p_log = p_bo->p_vendor->p_log;
+ osmv_IBMGT_transport_mgr_t *p_mgr;
+ osmv_IBMGT_transport_info_t *p_tpot_info;
+ IB_MGT_ret_t ret;
+ cl_list_obj_t *p_obj = NULL;
+ cl_list_item_t *p_item, *p_item_tmp;
+ int i;
+ cl_qlist_t *p_list = NULL;
+
+ OSM_LOG_ENTER(p_log, osmv_transport_done);
+
+ CL_ASSERT(p_bo);
+
+ /* First of all - zero out the magic_ptr, so if a callback is called -
+ it'll know that we are currently closing down, and will not handle the
+ mad. */
+ p_bo->magic_ptr = 0;
+
+ p_mgr = (osmv_IBMGT_transport_mgr_t *) (p_bo->p_transp_mgr);
+ p_tpot_info =
+ (osmv_IBMGT_transport_info_t *) (p_bo->p_vendor->p_transport_info);
+
+ switch (p_mgr->mad_type) {
+ case IB_MGT_SMI:
+ p_list = p_tpot_info->p_smi_list;
+
+ /* remove from the bindings list */
+ p_item = cl_qlist_head(p_list);
+ while (p_item != cl_qlist_end(p_list)) {
+ p_obj = PARENT_STRUCT(p_item, cl_list_obj_t, list_item);
+ if (cl_qlist_obj(p_obj) == h_bind) {
+ break;
+ }
+ p_item_tmp = cl_qlist_next(p_item);
+ p_item = p_item_tmp;
+ }
+
+ CL_ASSERT(p_item != cl_qlist_end(p_list));
+ cl_qlist_remove_item(p_list, p_item);
+ if (p_obj)
+ free(p_obj);
+
+ /* no one is binded to smi anymore - we can free the list, unbind & realease the hndl */
+ if (cl_is_qlist_empty(p_list) == TRUE) {
+ free(p_list);
+ p_list = NULL;
+
+ ret = IB_MGT_unbind_sm(p_tpot_info->smi_h);
+ if (ret != IB_MGT_OK) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "osmv_transport_done: ERR 7212: "
+ "Failed to unbind sm\n");
+ }
+
+ ret = IB_MGT_release_handle(p_tpot_info->smi_h);
+ if (ret != IB_MGT_OK) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "osmv_transport_done: ERR 7213: "
+ "Failed to release smi handle\n");
+ }
+ p_tpot_info->smi_h = 0xffffffff;
+ }
+ break;
+
+ case IB_MGT_GSI:
+ p_list = p_tpot_info->gsi_mgmt_lists[p_mgr->mgmt_class];
+ /* remove from the bindings list */
+ p_item = cl_qlist_head(p_list);
+ while (p_item != cl_qlist_end(p_list)) {
+ p_obj = PARENT_STRUCT(p_item, cl_list_obj_t, list_item);
+ if (cl_qlist_obj(p_obj) == h_bind) {
+ break;
+ }
+ p_item_tmp = cl_qlist_next(p_item);
+ p_item = p_item_tmp;
+ }
+
+ CL_ASSERT(p_item != cl_qlist_end(p_list));
+ cl_qlist_remove_item(p_list, p_item);
+ if (p_obj)
+ free(p_obj);
+
+ /* no one is binded to this class anymore - we can free the list and unbind this class */
+ if (cl_is_qlist_empty(p_list) == TRUE) {
+ free(p_list);
+ p_list = NULL;
+
+ ret =
+ IB_MGT_unbind_gsi_class(p_tpot_info->gsi_h,
+ p_mgr->mgmt_class);
+ if (ret != IB_MGT_OK) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "osmv_transport_done: ERR 7214: "
+ "Failed to unbind gsi class\n");
+ }
+ }
+
+ /* all the mgmt classes are unbinded - release gsi handle */
+ for (i = 0; i < 15; i++) {
+ if (p_tpot_info->gsi_mgmt_lists[i] != NULL) {
+ break;
+ }
+ }
+
+ if (i == 15) {
+ ret = IB_MGT_release_handle(p_tpot_info->gsi_h);
+ if (ret != IB_MGT_OK) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "osmv_transport_done: ERR 7215: "
+ "Failed to release gsi handle\n");
+ }
+ p_tpot_info->gsi_h = 0xffffffff;
+ }
+ } /* end switch */
+
+ free(p_mgr);
+}
/**********************************************************************
* IB_MGT Receive callback : invoked after each receive
**********************************************************************/
void
-__osmv_IBMGT_rcv_cb( IN IB_MGT_mad_hndl_t mad_hndl,
- IN void *private_ctx_p,
- IN void *payload_p,
- IN IB_MGT_mad_rcv_desc_t * rcv_remote_info_p ){
- osmv_bind_obj_t *p_bo;
- osm_mad_addr_t mad_addr;
- cl_list_item_t* p_item;
- cl_list_obj_t* p_obj;
- cl_qlist_t* p_list;
- ib_mad_t* p_mad = (ib_mad_t*)payload_p;
- osm_vendor_t *p_vendor;
- osmv_IBMGT_transport_info_t *p_tinfo;
-
- __osmv_IBMGT_rcv_desc_to_osm_addr(rcv_remote_info_p,
- ( (p_mad->mgmt_class == IB_MCLASS_SUBN_LID)||
- (p_mad->mgmt_class == IB_MCLASS_SUBN_DIR)),
- &mad_addr);
-
- /* different handling of SMI and GSI */
- if ( (p_mad->mgmt_class == IB_MCLASS_SUBN_DIR) ||
- (p_mad->mgmt_class == IB_MCLASS_SUBN_LID)) {
- /* SMI CASE */
- p_bo = (osmv_bind_obj_t *)private_ctx_p;
- /* Make sure the p_bo object is still relevant */
- if (( p_bo->magic_ptr != p_bo) || p_bo->is_closing )
- return;
-
- p_vendor = p_bo->p_vendor;
- p_tinfo = (osmv_IBMGT_transport_info_t *)p_vendor->p_transport_info;
- p_list = p_tinfo->p_smi_list;
- }
- else
- {
- /* GSI CASE */
- p_bo = (osmv_bind_obj_t *)private_ctx_p;
- /* Make sure the p_bo object is still relevant */
- if (( p_bo->magic_ptr != p_bo) || p_bo->is_closing )
- return;
-
- p_vendor = p_bo->p_vendor;
- p_tinfo = (osmv_IBMGT_transport_info_t *)p_vendor->p_transport_info;
- p_list = p_tinfo->gsi_mgmt_lists[p_mad->mgmt_class];
- }
-
- /* go over the bindings list and send the mad, one of them will accept it,
- the others will drope
- */
- p_item = cl_qlist_head(p_list);
- while (p_item != cl_qlist_end(p_list)) {
- p_obj = PARENT_STRUCT(p_item,cl_list_obj_t,list_item);
- p_bo = cl_qlist_obj(p_obj);
- /* give upper layer the mad */
- osmv_dispatch_mad((osm_bind_handle_t)p_bo,payload_p,&mad_addr);
- /* Make sure the p_bo object is still relevant */
- if (( p_bo->magic_ptr != p_bo) || p_bo->is_closing )
- return;
-
- p_item = cl_qlist_next(p_item);
- }
+__osmv_IBMGT_rcv_cb(IN IB_MGT_mad_hndl_t mad_hndl,
+ IN void *private_ctx_p,
+ IN void *payload_p,
+ IN IB_MGT_mad_rcv_desc_t * rcv_remote_info_p)
+{
+ osmv_bind_obj_t *p_bo;
+ osm_mad_addr_t mad_addr;
+ cl_list_item_t *p_item;
+ cl_list_obj_t *p_obj;
+ cl_qlist_t *p_list;
+ ib_mad_t *p_mad = (ib_mad_t *) payload_p;
+ osm_vendor_t *p_vendor;
+ osmv_IBMGT_transport_info_t *p_tinfo;
+
+ __osmv_IBMGT_rcv_desc_to_osm_addr(rcv_remote_info_p,
+ ((p_mad->mgmt_class ==
+ IB_MCLASS_SUBN_LID)
+ || (p_mad->mgmt_class ==
+ IB_MCLASS_SUBN_DIR)), &mad_addr);
+
+ /* different handling of SMI and GSI */
+ if ((p_mad->mgmt_class == IB_MCLASS_SUBN_DIR) ||
+ (p_mad->mgmt_class == IB_MCLASS_SUBN_LID)) {
+ /* SMI CASE */
+ p_bo = (osmv_bind_obj_t *) private_ctx_p;
+ /* Make sure the p_bo object is still relevant */
+ if ((p_bo->magic_ptr != p_bo) || p_bo->is_closing)
+ return;
+
+ p_vendor = p_bo->p_vendor;
+ p_tinfo =
+ (osmv_IBMGT_transport_info_t *) p_vendor->p_transport_info;
+ p_list = p_tinfo->p_smi_list;
+ } else {
+ /* GSI CASE */
+ p_bo = (osmv_bind_obj_t *) private_ctx_p;
+ /* Make sure the p_bo object is still relevant */
+ if ((p_bo->magic_ptr != p_bo) || p_bo->is_closing)
+ return;
+
+ p_vendor = p_bo->p_vendor;
+ p_tinfo =
+ (osmv_IBMGT_transport_info_t *) p_vendor->p_transport_info;
+ p_list = p_tinfo->gsi_mgmt_lists[p_mad->mgmt_class];
+ }
+
+ /* go over the bindings list and send the mad, one of them will accept it,
+ the others will drope
+ */
+ p_item = cl_qlist_head(p_list);
+ while (p_item != cl_qlist_end(p_list)) {
+ p_obj = PARENT_STRUCT(p_item, cl_list_obj_t, list_item);
+ p_bo = cl_qlist_obj(p_obj);
+ /* give upper layer the mad */
+ osmv_dispatch_mad((osm_bind_handle_t) p_bo, payload_p,
+ &mad_addr);
+ /* Make sure the p_bo object is still relevant */
+ if ((p_bo->magic_ptr != p_bo) || p_bo->is_closing)
+ return;
+
+ p_item = cl_qlist_next(p_item);
+ }
}
/**********************************************************************
* IB_MGT Send callback : invoked after each send
**********************************************************************/
void
-__osmv_IBMGT_send_cb( IN IB_MGT_mad_hndl_t mad_hndl,
- IN u_int64_t wrid,
- IN IB_comp_status_t status,
- IN void *private_ctx_p ){
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t*)CAST_P2LONG(wrid);
-
- osmv_IBMGT_transport_mgr_t* p_mgr = (osmv_IBMGT_transport_mgr_t*)p_bo->p_transp_mgr;
-
- /* Make sure the p_bo object is still relevant */
- if ( p_bo->magic_ptr != p_bo )
- return;
-
- /* we assume that each send on a bind object is synchronized, and no paralel sends
- from diffrent threads with same object can be made */
- if (status == IB_COMP_SUCCESS)
- {
- p_mgr->is_send_ok = TRUE;
- } else p_mgr->is_send_ok = FALSE;
- cl_event_signal(&p_mgr->send_done);
+__osmv_IBMGT_send_cb(IN IB_MGT_mad_hndl_t mad_hndl,
+ IN u_int64_t wrid,
+ IN IB_comp_status_t status, IN void *private_ctx_p)
+{
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) CAST_P2LONG(wrid);
-}
+ osmv_IBMGT_transport_mgr_t *p_mgr =
+ (osmv_IBMGT_transport_mgr_t *) p_bo->p_transp_mgr;
+ /* Make sure the p_bo object is still relevant */
+ if (p_bo->magic_ptr != p_bo)
+ return;
+
+ /* we assume that each send on a bind object is synchronized, and no paralel sends
+ from diffrent threads with same object can be made */
+ if (status == IB_COMP_SUCCESS) {
+ p_mgr->is_send_ok = TRUE;
+ } else
+ p_mgr->is_send_ok = FALSE;
+ cl_event_signal(&p_mgr->send_done);
+
+}
/**********************************************************************
* IB_MGT to OSM ADDRESS VECTOR
**********************************************************************/
static void
-__osmv_IBMGT_rcv_desc_to_osm_addr(
- IN IB_MGT_mad_rcv_desc_t *p_rcv_desc,
- IN uint8_t is_smi,
- OUT osm_mad_addr_t *p_mad_addr){
- /* p_mad_addr->dest_lid = p_osm->subn.sm_base_lid; - for resp we use the dest lid ... */
- p_mad_addr->dest_lid = cl_hton16(p_rcv_desc->remote_lid);
- p_mad_addr->static_rate = 0; /* HACK - we do not know the rate ! */
- p_mad_addr->path_bits = p_rcv_desc->local_path_bits;
- /* Clear the grh any way to avoid unset fields */
- memset(&p_mad_addr->addr_type.gsi.grh_info, 0, sizeof(p_mad_addr->addr_type.gsi.grh_info));
-
- if (is_smi)
- {
- /* SMI */
- p_mad_addr->addr_type.smi.source_lid = cl_hton16(p_rcv_desc->remote_lid);
- p_mad_addr->addr_type.smi.port_num = 99; /* HACK - if used - should fail */
- }
- else
- {
- /* GSI */
- /* seems to me there is a IBMGT bug reversing the QPN ... */
- /* Does IBMGT supposed to provide the QPN is network or HOST ? */
- p_mad_addr->addr_type.gsi.remote_qp = cl_hton32(p_rcv_desc->qp);
-
-
- p_mad_addr->addr_type.gsi.remote_qkey = IB_QP1_WELL_KNOWN_Q_KEY;
- /* we do have the p_mad_addr->pkey_ix but how to get the PKey by index ? */
- /* the only way seems to be to use VAPI_query_hca_pkey_tbl and obtain */
- /* the full PKey table - than go by the index. */
- /* since this does not seem reasonable to me I simply use the default */
- /* There is a TAVOR limitation that only one P_KEY is supported per */
- /* QP - so QP1 must use IB_DEFAULT_PKEY */
- p_mad_addr->addr_type.gsi.pkey = IB_DEFAULT_PKEY;
- p_mad_addr->addr_type.gsi.service_level = p_rcv_desc->sl;
-
- p_mad_addr->addr_type.gsi.global_route = p_rcv_desc->grh_flag;
- /* copy the GRH data if relevant */
- if (p_mad_addr->addr_type.gsi.global_route)
- {
- p_mad_addr->addr_type.gsi.grh_info.ver_class_flow =
- ib_grh_set_ver_class_flow(p_rcv_desc->grh.IP_version,
- p_rcv_desc->grh.traffic_class,
- p_rcv_desc->grh.flow_label);
- p_mad_addr->addr_type.gsi.grh_info.hop_limit = p_rcv_desc->grh.hop_limit;
- memcpy(&p_mad_addr->addr_type.gsi.grh_info.src_gid.raw,
- &p_rcv_desc->grh.sgid, sizeof(ib_net64_t));
- memcpy(&p_mad_addr->addr_type.gsi.grh_info.dest_gid.raw,
- p_rcv_desc->grh.dgid, sizeof(ib_net64_t));
- }
- }
+__osmv_IBMGT_rcv_desc_to_osm_addr(IN IB_MGT_mad_rcv_desc_t * p_rcv_desc,
+ IN uint8_t is_smi,
+ OUT osm_mad_addr_t * p_mad_addr)
+{
+ /* p_mad_addr->dest_lid = p_osm->subn.sm_base_lid; - for resp we use the dest lid ... */
+ p_mad_addr->dest_lid = cl_hton16(p_rcv_desc->remote_lid);
+ p_mad_addr->static_rate = 0; /* HACK - we do not know the rate ! */
+ p_mad_addr->path_bits = p_rcv_desc->local_path_bits;
+ /* Clear the grh any way to avoid unset fields */
+ memset(&p_mad_addr->addr_type.gsi.grh_info, 0,
+ sizeof(p_mad_addr->addr_type.gsi.grh_info));
+
+ if (is_smi) {
+ /* SMI */
+ p_mad_addr->addr_type.smi.source_lid =
+ cl_hton16(p_rcv_desc->remote_lid);
+ p_mad_addr->addr_type.smi.port_num = 99; /* HACK - if used - should fail */
+ } else {
+ /* GSI */
+ /* seems to me there is a IBMGT bug reversing the QPN ... */
+ /* Does IBMGT supposed to provide the QPN is network or HOST ? */
+ p_mad_addr->addr_type.gsi.remote_qp = cl_hton32(p_rcv_desc->qp);
+
+ p_mad_addr->addr_type.gsi.remote_qkey = IB_QP1_WELL_KNOWN_Q_KEY;
+ /* we do have the p_mad_addr->pkey_ix but how to get the PKey by index ? */
+ /* the only way seems to be to use VAPI_query_hca_pkey_tbl and obtain */
+ /* the full PKey table - than go by the index. */
+ /* since this does not seem reasonable to me I simply use the default */
+ /* There is a TAVOR limitation that only one P_KEY is supported per */
+ /* QP - so QP1 must use IB_DEFAULT_PKEY */
+ p_mad_addr->addr_type.gsi.pkey = IB_DEFAULT_PKEY;
+ p_mad_addr->addr_type.gsi.service_level = p_rcv_desc->sl;
+
+ p_mad_addr->addr_type.gsi.global_route = p_rcv_desc->grh_flag;
+ /* copy the GRH data if relevant */
+ if (p_mad_addr->addr_type.gsi.global_route) {
+ p_mad_addr->addr_type.gsi.grh_info.ver_class_flow =
+ ib_grh_set_ver_class_flow(p_rcv_desc->grh.
+ IP_version,
+ p_rcv_desc->grh.
+ traffic_class,
+ p_rcv_desc->grh.
+ flow_label);
+ p_mad_addr->addr_type.gsi.grh_info.hop_limit =
+ p_rcv_desc->grh.hop_limit;
+ memcpy(&p_mad_addr->addr_type.gsi.grh_info.src_gid.raw,
+ &p_rcv_desc->grh.sgid, sizeof(ib_net64_t));
+ memcpy(&p_mad_addr->addr_type.gsi.grh_info.dest_gid.raw,
+ p_rcv_desc->grh.dgid, sizeof(ib_net64_t));
+ }
+ }
}
/**********************************************************************
* OSM ADDR VECTOR TO IB_MGT
**********************************************************************/
void
-__osmv_IBMGT_osm_addr_to_ibmgt_addr(
- IN const osm_mad_addr_t *p_mad_addr,
- IN uint8_t is_smi,
- OUT IB_ud_av_t *p_av){
-
- /* For global destination or Multicast address:*/
- u_int8_t ver;
-
- memset( p_av, 0, sizeof( IB_ud_av_t ) );
-
- p_av->src_path_bits = p_mad_addr->path_bits;
- p_av->static_rate = p_mad_addr->static_rate;
- p_av->dlid = cl_ntoh16(p_mad_addr->dest_lid);
-
- if (is_smi)
- {
- p_av->sl = 0; /* Just to note we use 0 here. */
- }
- else
- {
- p_av->sl = p_mad_addr->addr_type.gsi.service_level;
- p_av->grh_flag = p_mad_addr->addr_type.gsi.global_route;
-
- if (p_mad_addr->addr_type.gsi.global_route)
- {
- ib_grh_get_ver_class_flow(p_mad_addr->addr_type.gsi.grh_info.ver_class_flow,
- &ver,
- &p_av->traffic_class,
- &p_av->flow_label);
- p_av->hop_limit = p_mad_addr->addr_type.gsi.grh_info.hop_limit;
- p_av->sgid_index = 0; /* we always use source GID 0 */
- memcpy(&p_av->dgid,
- &p_mad_addr->addr_type.gsi.grh_info.dest_gid.raw,
- sizeof(ib_net64_t));
-
- }
- }
+__osmv_IBMGT_osm_addr_to_ibmgt_addr(IN const osm_mad_addr_t * p_mad_addr,
+ IN uint8_t is_smi, OUT IB_ud_av_t * p_av)
+{
+
+ /* For global destination or Multicast address: */
+ u_int8_t ver;
+
+ memset(p_av, 0, sizeof(IB_ud_av_t));
+
+ p_av->src_path_bits = p_mad_addr->path_bits;
+ p_av->static_rate = p_mad_addr->static_rate;
+ p_av->dlid = cl_ntoh16(p_mad_addr->dest_lid);
+
+ if (is_smi) {
+ p_av->sl = 0; /* Just to note we use 0 here. */
+ } else {
+ p_av->sl = p_mad_addr->addr_type.gsi.service_level;
+ p_av->grh_flag = p_mad_addr->addr_type.gsi.global_route;
+
+ if (p_mad_addr->addr_type.gsi.global_route) {
+ ib_grh_get_ver_class_flow(p_mad_addr->addr_type.gsi.
+ grh_info.ver_class_flow, &ver,
+ &p_av->traffic_class,
+ &p_av->flow_label);
+ p_av->hop_limit =
+ p_mad_addr->addr_type.gsi.grh_info.hop_limit;
+ p_av->sgid_index = 0; /* we always use source GID 0 */
+ memcpy(&p_av->dgid,
+ &p_mad_addr->addr_type.gsi.grh_info.dest_gid.raw,
+ sizeof(ib_net64_t));
+
+ }
+ }
}
diff --git a/opensm/libvendor/osm_vendor_mlx_rmpp_ctx.c b/opensm/libvendor/osm_vendor_mlx_rmpp_ctx.c
index b766713..303947e 100644
--- a/opensm/libvendor/osm_vendor_mlx_rmpp_ctx.c
+++ b/opensm/libvendor/osm_vendor_mlx_rmpp_ctx.c
@@ -35,7 +35,7 @@
#if HAVE_CONFIG_H
# include <config.h>
-#endif /* HAVE_CONFIG_H */
+#endif /* HAVE_CONFIG_H */
#include <stdlib.h>
#include <string.h>
@@ -45,349 +45,317 @@
#include <vendor/osm_vendor_mlx_rmpp_ctx.h>
#include <vendor/osm_vendor_mlx_svc.h>
-
ib_api_status_t
-osmv_rmpp_send_ctx_init(osmv_rmpp_send_ctx_t* p_ctx, void* p_arbt_mad, uint32_t mad_sz,
- osm_log_t* p_log)
+osmv_rmpp_send_ctx_init(osmv_rmpp_send_ctx_t * p_ctx, void *p_arbt_mad,
+ uint32_t mad_sz, osm_log_t * p_log)
{
- ib_api_status_t st = IB_SUCCESS;
- cl_status_t cl_st;
-
- CL_ASSERT(p_ctx);
- if (NULL == p_arbt_mad)
- {
- return IB_INVALID_PARAMETER;
- }
-
- if (osmv_mad_is_sa((ib_mad_t*)p_arbt_mad))
- {
- p_ctx->is_sa_mad = TRUE;
- }else p_ctx->is_sa_mad = FALSE;
-
- p_ctx->mad_sz = mad_sz;
-
- cl_event_construct(&p_ctx->event);
- cl_st = cl_event_init(&p_ctx->event, FALSE);
- if (cl_st != CL_SUCCESS)
- {
- return IB_ERROR;
- }
-
- st= osmv_rmpp_sar_init(&p_ctx->sar,p_arbt_mad, p_ctx->mad_sz, p_ctx->is_sa_mad);
- if (st == IB_SUCCESS)
- {
- p_ctx->window_first = 1;
- p_ctx->window_last = 1;
- }
-
- p_ctx->p_log = p_log;
- return st;
+ ib_api_status_t st = IB_SUCCESS;
+ cl_status_t cl_st;
+
+ CL_ASSERT(p_ctx);
+ if (NULL == p_arbt_mad) {
+ return IB_INVALID_PARAMETER;
+ }
+
+ if (osmv_mad_is_sa((ib_mad_t *) p_arbt_mad)) {
+ p_ctx->is_sa_mad = TRUE;
+ } else
+ p_ctx->is_sa_mad = FALSE;
+
+ p_ctx->mad_sz = mad_sz;
+
+ cl_event_construct(&p_ctx->event);
+ cl_st = cl_event_init(&p_ctx->event, FALSE);
+ if (cl_st != CL_SUCCESS) {
+ return IB_ERROR;
+ }
+
+ st = osmv_rmpp_sar_init(&p_ctx->sar, p_arbt_mad, p_ctx->mad_sz,
+ p_ctx->is_sa_mad);
+ if (st == IB_SUCCESS) {
+ p_ctx->window_first = 1;
+ p_ctx->window_last = 1;
+ }
+
+ p_ctx->p_log = p_log;
+ return st;
}
-void
-osmv_rmpp_send_ctx_done(IN osmv_rmpp_send_ctx_t *p_ctx)
+void osmv_rmpp_send_ctx_done(IN osmv_rmpp_send_ctx_t * p_ctx)
{
- CL_ASSERT(p_ctx);
- cl_event_destroy(&p_ctx->event);
- osmv_rmpp_sar_done(&p_ctx->sar);
- free(p_ctx);
+ CL_ASSERT(p_ctx);
+ cl_event_destroy(&p_ctx->event);
+ osmv_rmpp_sar_done(&p_ctx->sar);
+ free(p_ctx);
}
-
-uint32_t
-osmv_rmpp_send_ctx_get_num_segs(IN osmv_rmpp_send_ctx_t *p_send_ctx)
+uint32_t osmv_rmpp_send_ctx_get_num_segs(IN osmv_rmpp_send_ctx_t * p_send_ctx)
{
- uint32_t data_len, data_sz, num;
-
- CL_ASSERT(p_send_ctx);
-
- if (p_send_ctx->is_sa_mad)
- {
- data_len = p_send_ctx->mad_sz - IB_SA_MAD_HDR_SIZE;
- data_sz = IB_SA_DATA_SIZE;
- }
- else
- {
- data_len = p_send_ctx->mad_sz - MAD_RMPP_HDR_SIZE;
- data_sz = MAD_RMPP_DATA_SIZE;
- }
-
- num= data_len / data_sz ;
- if (0 == data_len || (data_len % data_sz) > 0)
- {
- num++;
- }
-
- return num;
-}
+ uint32_t data_len, data_sz, num;
+
+ CL_ASSERT(p_send_ctx);
+ if (p_send_ctx->is_sa_mad) {
+ data_len = p_send_ctx->mad_sz - IB_SA_MAD_HDR_SIZE;
+ data_sz = IB_SA_DATA_SIZE;
+ } else {
+ data_len = p_send_ctx->mad_sz - MAD_RMPP_HDR_SIZE;
+ data_sz = MAD_RMPP_DATA_SIZE;
+ }
+
+ num = data_len / data_sz;
+ if (0 == data_len || (data_len % data_sz) > 0) {
+ num++;
+ }
+
+ return num;
+}
ib_api_status_t
-osmv_rmpp_send_ctx_get_seg(IN osmv_rmpp_send_ctx_t *p_send_ctx,
- IN uint32_t seg_idx,
- IN uint32_t resp_timeout,
- OUT void* p_buf)
+osmv_rmpp_send_ctx_get_seg(IN osmv_rmpp_send_ctx_t * p_send_ctx,
+ IN uint32_t seg_idx,
+ IN uint32_t resp_timeout, OUT void *p_buf)
{
- ib_api_status_t st = IB_SUCCESS;
- uint32_t num_segs, paylen=0;
- ib_rmpp_mad_t *p_rmpp_mad;
-
- OSM_LOG_ENTER(p_send_ctx->p_log,osmv_rmpp_send_ctx_get_seg);
- CL_ASSERT(p_send_ctx);
-
- st = osmv_rmpp_sar_get_mad_seg(&p_send_ctx->sar,seg_idx, p_buf);
- if (st != IB_SUCCESS)
- {
- goto Exit;
- }
-
- p_rmpp_mad = (ib_rmpp_mad_t*)p_buf;
- /* Set the relevant bits in the RMPP hdr */
- p_rmpp_mad->rmpp_status = IB_RMPP_STATUS_SUCCESS;
- p_rmpp_mad->rmpp_flags |= IB_RMPP_FLAG_ACTIVE;
- p_rmpp_mad->rmpp_flags |= resp_timeout << 3;
-
- num_segs= osmv_rmpp_send_ctx_get_num_segs(p_send_ctx);
-
- if (1 == seg_idx)
- {
- p_rmpp_mad->rmpp_flags |= IB_RMPP_FLAG_FIRST;
-
- /* This is the first segment -
- the reported paylen is the total amount of data.
- */
- if (p_send_ctx->is_sa_mad)
- {
- /* sa mad hdr sz */
- paylen = p_send_ctx->mad_sz - IB_SA_MAD_HDR_SIZE;
- paylen += num_segs * (IB_SA_MAD_HDR_SIZE - MAD_RMPP_HDR_SIZE);
- }
- else
- {
- /* mad hdr sz */
- paylen = p_send_ctx->mad_sz - MAD_RMPP_HDR_SIZE;
- }
- }
-
- if (seg_idx == num_segs)
- {
- p_rmpp_mad->rmpp_flags |= IB_RMPP_FLAG_LAST;
-
- /*
- This is the last segment -
- the reported paylen is only the amount of data left on this segment.
- */
- if (p_send_ctx->is_sa_mad)
- {
- paylen = p_send_ctx->mad_sz - IB_SA_MAD_HDR_SIZE;
- paylen -= (num_segs - 1) * IB_SA_DATA_SIZE;
- paylen += (IB_SA_MAD_HDR_SIZE - MAD_RMPP_HDR_SIZE);
- }
- else
- {
- paylen = p_send_ctx->mad_sz - MAD_RMPP_HDR_SIZE;
- paylen -= (num_segs - 1) * (MAD_BLOCK_SIZE - MAD_RMPP_HDR_SIZE);
- }
- }
-
- p_rmpp_mad->rmpp_type = IB_RMPP_TYPE_DATA;
- p_rmpp_mad->rmpp_version = 1;
- p_rmpp_mad->paylen_newwin = cl_ntoh32(paylen);
- p_rmpp_mad->seg_num = cl_ntoh32(seg_idx);
-
- Exit:
- OSM_LOG_EXIT(p_send_ctx->p_log);
- return st;
+ ib_api_status_t st = IB_SUCCESS;
+ uint32_t num_segs, paylen = 0;
+ ib_rmpp_mad_t *p_rmpp_mad;
+
+ OSM_LOG_ENTER(p_send_ctx->p_log, osmv_rmpp_send_ctx_get_seg);
+ CL_ASSERT(p_send_ctx);
+
+ st = osmv_rmpp_sar_get_mad_seg(&p_send_ctx->sar, seg_idx, p_buf);
+ if (st != IB_SUCCESS) {
+ goto Exit;
+ }
+
+ p_rmpp_mad = (ib_rmpp_mad_t *) p_buf;
+ /* Set the relevant bits in the RMPP hdr */
+ p_rmpp_mad->rmpp_status = IB_RMPP_STATUS_SUCCESS;
+ p_rmpp_mad->rmpp_flags |= IB_RMPP_FLAG_ACTIVE;
+ p_rmpp_mad->rmpp_flags |= resp_timeout << 3;
+
+ num_segs = osmv_rmpp_send_ctx_get_num_segs(p_send_ctx);
+
+ if (1 == seg_idx) {
+ p_rmpp_mad->rmpp_flags |= IB_RMPP_FLAG_FIRST;
+
+ /* This is the first segment -
+ the reported paylen is the total amount of data.
+ */
+ if (p_send_ctx->is_sa_mad) {
+ /* sa mad hdr sz */
+ paylen = p_send_ctx->mad_sz - IB_SA_MAD_HDR_SIZE;
+ paylen +=
+ num_segs * (IB_SA_MAD_HDR_SIZE - MAD_RMPP_HDR_SIZE);
+ } else {
+ /* mad hdr sz */
+ paylen = p_send_ctx->mad_sz - MAD_RMPP_HDR_SIZE;
+ }
+ }
+
+ if (seg_idx == num_segs) {
+ p_rmpp_mad->rmpp_flags |= IB_RMPP_FLAG_LAST;
+
+ /*
+ This is the last segment -
+ the reported paylen is only the amount of data left on this segment.
+ */
+ if (p_send_ctx->is_sa_mad) {
+ paylen = p_send_ctx->mad_sz - IB_SA_MAD_HDR_SIZE;
+ paylen -= (num_segs - 1) * IB_SA_DATA_SIZE;
+ paylen += (IB_SA_MAD_HDR_SIZE - MAD_RMPP_HDR_SIZE);
+ } else {
+ paylen = p_send_ctx->mad_sz - MAD_RMPP_HDR_SIZE;
+ paylen -=
+ (num_segs - 1) * (MAD_BLOCK_SIZE -
+ MAD_RMPP_HDR_SIZE);
+ }
+ }
+
+ p_rmpp_mad->rmpp_type = IB_RMPP_TYPE_DATA;
+ p_rmpp_mad->rmpp_version = 1;
+ p_rmpp_mad->paylen_newwin = cl_ntoh32(paylen);
+ p_rmpp_mad->seg_num = cl_ntoh32(seg_idx);
+
+ Exit:
+ OSM_LOG_EXIT(p_send_ctx->p_log);
+ return st;
}
-
ib_api_status_t
-osmv_rmpp_recv_ctx_init(osmv_rmpp_recv_ctx_t* p_ctx, osm_log_t* p_log)
+osmv_rmpp_recv_ctx_init(osmv_rmpp_recv_ctx_t * p_ctx, osm_log_t * p_log)
{
- ib_api_status_t st = IB_SUCCESS;
+ ib_api_status_t st = IB_SUCCESS;
- CL_ASSERT(p_ctx);
+ CL_ASSERT(p_ctx);
- p_ctx->is_sa_mad = FALSE;
+ p_ctx->is_sa_mad = FALSE;
- p_ctx->p_rbuf = malloc(sizeof(cl_qlist_t));
- if (p_ctx->p_rbuf)
- {
- memset(p_ctx->p_rbuf, 0, sizeof(cl_qlist_t));
- cl_qlist_init(p_ctx->p_rbuf);
- p_ctx->expected_seg = 1;
- } else st= IB_INSUFFICIENT_MEMORY;
+ p_ctx->p_rbuf = malloc(sizeof(cl_qlist_t));
+ if (p_ctx->p_rbuf) {
+ memset(p_ctx->p_rbuf, 0, sizeof(cl_qlist_t));
+ cl_qlist_init(p_ctx->p_rbuf);
+ p_ctx->expected_seg = 1;
+ } else
+ st = IB_INSUFFICIENT_MEMORY;
- p_ctx->p_log = p_log;
+ p_ctx->p_log = p_log;
- return st;
+ return st;
}
-void
-osmv_rmpp_recv_ctx_done(IN osmv_rmpp_recv_ctx_t *p_ctx)
+void osmv_rmpp_recv_ctx_done(IN osmv_rmpp_recv_ctx_t * p_ctx)
{
- cl_list_item_t *p_list_item;
- cl_list_obj_t *p_obj;
+ cl_list_item_t *p_list_item;
+ cl_list_obj_t *p_obj;
- CL_ASSERT(p_ctx);
+ CL_ASSERT(p_ctx);
- /* go over all the items in the list and remove them */
- p_list_item = cl_qlist_remove_head(p_ctx->p_rbuf);
- while ( p_list_item != cl_qlist_end(p_ctx->p_rbuf) ) {
+ /* go over all the items in the list and remove them */
+ p_list_item = cl_qlist_remove_head(p_ctx->p_rbuf);
+ while (p_list_item != cl_qlist_end(p_ctx->p_rbuf)) {
- p_obj = PARENT_STRUCT(p_list_item,cl_list_obj_t,list_item);
+ p_obj = PARENT_STRUCT(p_list_item, cl_list_obj_t, list_item);
- free(cl_qlist_obj(p_obj));
- free(p_obj);
+ free(cl_qlist_obj(p_obj));
+ free(p_obj);
- p_list_item = cl_qlist_remove_head(p_ctx->p_rbuf);
- }
+ p_list_item = cl_qlist_remove_head(p_ctx->p_rbuf);
+ }
- osmv_rmpp_sar_done(&p_ctx->sar);
+ osmv_rmpp_sar_done(&p_ctx->sar);
- free(p_ctx->p_rbuf);
- free(p_ctx);
+ free(p_ctx->p_rbuf);
+ free(p_ctx);
}
-
-
ib_api_status_t
-osmv_rmpp_recv_ctx_store_mad_seg(IN osmv_rmpp_recv_ctx_t *p_recv_ctx, IN void* p_mad)
+osmv_rmpp_recv_ctx_store_mad_seg(IN osmv_rmpp_recv_ctx_t * p_recv_ctx,
+ IN void *p_mad)
{
- cl_list_obj_t* p_obj = NULL;
- void* p_list_mad;
-
- OSM_LOG_ENTER(p_recv_ctx->p_log, osmv_rmpp_recv_ctx_store_mad_seg);
-
- CL_ASSERT(p_recv_ctx);
- p_list_mad= malloc(MAD_BLOCK_SIZE);
- if (NULL == p_list_mad)
- {
- return IB_INSUFFICIENT_MEMORY;
- }
- memset(p_list_mad, 0, MAD_BLOCK_SIZE);
- memcpy(p_list_mad, p_mad, MAD_BLOCK_SIZE);
-
- p_obj = malloc(sizeof(cl_list_obj_t));
- if (NULL == p_obj)
- {
- free(p_list_mad);
- return IB_INSUFFICIENT_MEMORY;
- }
- memset(p_obj, 0, sizeof(cl_list_obj_t));
- cl_qlist_set_obj(p_obj, p_list_mad);
-
- cl_qlist_insert_tail(p_recv_ctx->p_rbuf,&p_obj->list_item);
-
- if (osmv_mad_is_sa((ib_mad_t*)p_mad))
- {
- p_recv_ctx->is_sa_mad = TRUE;
- }
-
- return IB_SUCCESS;
+ cl_list_obj_t *p_obj = NULL;
+ void *p_list_mad;
+
+ OSM_LOG_ENTER(p_recv_ctx->p_log, osmv_rmpp_recv_ctx_store_mad_seg);
+
+ CL_ASSERT(p_recv_ctx);
+ p_list_mad = malloc(MAD_BLOCK_SIZE);
+ if (NULL == p_list_mad) {
+ return IB_INSUFFICIENT_MEMORY;
+ }
+ memset(p_list_mad, 0, MAD_BLOCK_SIZE);
+ memcpy(p_list_mad, p_mad, MAD_BLOCK_SIZE);
+
+ p_obj = malloc(sizeof(cl_list_obj_t));
+ if (NULL == p_obj) {
+ free(p_list_mad);
+ return IB_INSUFFICIENT_MEMORY;
+ }
+ memset(p_obj, 0, sizeof(cl_list_obj_t));
+ cl_qlist_set_obj(p_obj, p_list_mad);
+
+ cl_qlist_insert_tail(p_recv_ctx->p_rbuf, &p_obj->list_item);
+
+ if (osmv_mad_is_sa((ib_mad_t *) p_mad)) {
+ p_recv_ctx->is_sa_mad = TRUE;
+ }
+
+ return IB_SUCCESS;
}
uint32_t
-osmv_rmpp_recv_ctx_get_cur_byte_num(IN osmv_rmpp_recv_ctx_t *p_recv_ctx)
+osmv_rmpp_recv_ctx_get_cur_byte_num(IN osmv_rmpp_recv_ctx_t * p_recv_ctx)
{
- uint32_t num_segs;
+ uint32_t num_segs;
- num_segs = cl_qlist_count(p_recv_ctx->p_rbuf);
- if (p_recv_ctx->is_sa_mad)
- return ((num_segs * IB_SA_DATA_SIZE) + IB_SA_MAD_HDR_SIZE);
- else return ((num_segs * MAD_RMPP_DATA_SIZE) + MAD_RMPP_HDR_SIZE);
+ num_segs = cl_qlist_count(p_recv_ctx->p_rbuf);
+ if (p_recv_ctx->is_sa_mad)
+ return ((num_segs * IB_SA_DATA_SIZE) + IB_SA_MAD_HDR_SIZE);
+ else
+ return ((num_segs * MAD_RMPP_DATA_SIZE) + MAD_RMPP_HDR_SIZE);
}
uint32_t
-osmv_rmpp_recv_ctx_get_byte_num_from_first(IN osmv_rmpp_recv_ctx_t *p_recv_ctx)
+osmv_rmpp_recv_ctx_get_byte_num_from_first(IN osmv_rmpp_recv_ctx_t * p_recv_ctx)
{
- cl_list_item_t* p_item;
- cl_list_obj_t* p_obj;
- void* p_list_mad;
- uint32_t num_bytes, num_segs;
-
- p_item = cl_qlist_head(p_recv_ctx->p_rbuf);
- p_obj = PARENT_STRUCT(p_item, cl_list_obj_t, list_item);
- p_list_mad = cl_qlist_obj(p_obj);
-
- /* mad data sz */
- num_bytes = cl_ntoh32( ((ib_rmpp_mad_t*)p_list_mad)->paylen_newwin);
- if (0 != num_bytes)
- {
- if (p_recv_ctx->is_sa_mad)
- {
- /* sa mad hdr sz */
- num_segs = cl_qlist_count(p_recv_ctx->p_rbuf);
- num_bytes -= num_segs * (IB_SA_MAD_HDR_SIZE - MAD_RMPP_HDR_SIZE);
- num_bytes += IB_SA_MAD_HDR_SIZE;
- }
- else
- {
- /* mad hdr sz */
- num_bytes += MAD_RMPP_HDR_SIZE;
- }
- }
-
- return num_bytes;
+ cl_list_item_t *p_item;
+ cl_list_obj_t *p_obj;
+ void *p_list_mad;
+ uint32_t num_bytes, num_segs;
+
+ p_item = cl_qlist_head(p_recv_ctx->p_rbuf);
+ p_obj = PARENT_STRUCT(p_item, cl_list_obj_t, list_item);
+ p_list_mad = cl_qlist_obj(p_obj);
+
+ /* mad data sz */
+ num_bytes = cl_ntoh32(((ib_rmpp_mad_t *) p_list_mad)->paylen_newwin);
+ if (0 != num_bytes) {
+ if (p_recv_ctx->is_sa_mad) {
+ /* sa mad hdr sz */
+ num_segs = cl_qlist_count(p_recv_ctx->p_rbuf);
+ num_bytes -=
+ num_segs * (IB_SA_MAD_HDR_SIZE - MAD_RMPP_HDR_SIZE);
+ num_bytes += IB_SA_MAD_HDR_SIZE;
+ } else {
+ /* mad hdr sz */
+ num_bytes += MAD_RMPP_HDR_SIZE;
+ }
+ }
+
+ return num_bytes;
}
uint32_t
-osmv_rmpp_recv_ctx_get_byte_num_from_last(IN osmv_rmpp_recv_ctx_t *p_recv_ctx)
+osmv_rmpp_recv_ctx_get_byte_num_from_last(IN osmv_rmpp_recv_ctx_t * p_recv_ctx)
{
- cl_list_item_t* p_item;
- cl_list_obj_t* p_obj;
- void* p_list_mad;
- uint32_t num_bytes, num_segs;
-
- p_item = cl_qlist_tail(p_recv_ctx->p_rbuf);
- p_obj = PARENT_STRUCT(p_item, cl_list_obj_t, list_item);
- p_list_mad = cl_qlist_obj(p_obj);
-
- /* mad data sz */
- num_segs = cl_qlist_count(p_recv_ctx->p_rbuf);
- num_bytes = cl_ntoh32( ((ib_rmpp_mad_t*)p_list_mad)->paylen_newwin);
-
- if (0 != num_bytes)
- {
- if (p_recv_ctx->is_sa_mad)
- {
- /* sa mad hdr sz */
- num_bytes += MAD_RMPP_HDR_SIZE;
- num_bytes += (num_segs-1) * IB_SA_DATA_SIZE;
- }
- else
- {
- /* mad hdr sz */
- num_bytes += MAD_RMPP_HDR_SIZE;
- num_bytes += (num_segs-1) * MAD_RMPP_DATA_SIZE;
- }
- }
-
- return num_bytes;
+ cl_list_item_t *p_item;
+ cl_list_obj_t *p_obj;
+ void *p_list_mad;
+ uint32_t num_bytes, num_segs;
+
+ p_item = cl_qlist_tail(p_recv_ctx->p_rbuf);
+ p_obj = PARENT_STRUCT(p_item, cl_list_obj_t, list_item);
+ p_list_mad = cl_qlist_obj(p_obj);
+
+ /* mad data sz */
+ num_segs = cl_qlist_count(p_recv_ctx->p_rbuf);
+ num_bytes = cl_ntoh32(((ib_rmpp_mad_t *) p_list_mad)->paylen_newwin);
+
+ if (0 != num_bytes) {
+ if (p_recv_ctx->is_sa_mad) {
+ /* sa mad hdr sz */
+ num_bytes += MAD_RMPP_HDR_SIZE;
+ num_bytes += (num_segs - 1) * IB_SA_DATA_SIZE;
+ } else {
+ /* mad hdr sz */
+ num_bytes += MAD_RMPP_HDR_SIZE;
+ num_bytes += (num_segs - 1) * MAD_RMPP_DATA_SIZE;
+ }
+ }
+
+ return num_bytes;
}
/* assuming that the last rmpp pkt arrived so that data member: total_bytes has the right value */
ib_api_status_t
-osmv_rmpp_recv_ctx_reassemble_arbt_mad( IN osmv_rmpp_recv_ctx_t *p_recv_ctx,
- IN uint32_t size,
- IN void *p_arbt_mad)
+osmv_rmpp_recv_ctx_reassemble_arbt_mad(IN osmv_rmpp_recv_ctx_t * p_recv_ctx,
+ IN uint32_t size, IN void *p_arbt_mad)
{
- ib_api_status_t st = IB_SUCCESS;
+ ib_api_status_t st = IB_SUCCESS;
- CL_ASSERT(p_recv_ctx);
+ CL_ASSERT(p_recv_ctx);
- st = osmv_rmpp_sar_init(&p_recv_ctx->sar,p_arbt_mad, size, p_recv_ctx->is_sa_mad);
- if (st != IB_SUCCESS)
- {
- return st;
- }
+ st = osmv_rmpp_sar_init(&p_recv_ctx->sar, p_arbt_mad, size,
+ p_recv_ctx->is_sa_mad);
+ if (st != IB_SUCCESS) {
+ return st;
+ }
- st = osmv_rmpp_sar_reassemble_arbt_mad(&p_recv_ctx->sar,p_recv_ctx->p_rbuf);
+ st = osmv_rmpp_sar_reassemble_arbt_mad(&p_recv_ctx->sar,
+ p_recv_ctx->p_rbuf);
- osmv_rmpp_sar_done(&p_recv_ctx->sar);
+ osmv_rmpp_sar_done(&p_recv_ctx->sar);
- return st;
+ return st;
}
-
-
diff --git a/opensm/libvendor/osm_vendor_mlx_sa.c b/opensm/libvendor/osm_vendor_mlx_sa.c
index 5b3f799..924a2b7 100644
--- a/opensm/libvendor/osm_vendor_mlx_sa.c
+++ b/opensm/libvendor/osm_vendor_mlx_sa.c
@@ -33,11 +33,9 @@
*
*/
-
-
#if HAVE_CONFIG_H
# include <config.h>
-#endif /* HAVE_CONFIG_H */
+#endif /* HAVE_CONFIG_H */
#include <stdlib.h>
#include <string.h>
@@ -47,21 +45,20 @@
#include <vendor/osm_vendor_api.h>
#include <vendor/osm_vendor_sa_api.h>
-
/*****************************************************************************
*****************************************************************************/
/* this struct is the internal rep of the bind handle */
typedef struct _osmv_sa_bind_info {
- osm_bind_handle_t h_bind;
- osm_log_t *p_log;
- osm_vendor_t *p_vendor;
- osm_mad_pool_t *p_mad_pool;
- uint64_t port_guid;
- cl_event_t sync_event;
- uint64_t last_lids_update_sec;
- uint16_t lid;
- uint16_t sm_lid;
+ osm_bind_handle_t h_bind;
+ osm_log_t *p_log;
+ osm_vendor_t *p_vendor;
+ osm_mad_pool_t *p_mad_pool;
+ uint64_t port_guid;
+ cl_event_t sync_event;
+ uint64_t last_lids_update_sec;
+ uint16_t lid;
+ uint16_t sm_lid;
} osmv_sa_bind_info_t;
/*****************************************************************************
@@ -77,117 +74,106 @@ typedef struct _osmv_sa_bind_info {
request structure) is attached as the p_madw->context.ni_context.node_guid
*/
void
-__osmv_sa_mad_rcv_cb(
- IN osm_madw_t *p_madw,
- IN void* bind_context,
- IN osm_madw_t *p_req_madw)
+__osmv_sa_mad_rcv_cb(IN osm_madw_t * p_madw,
+ IN void *bind_context, IN osm_madw_t * p_req_madw)
{
- osmv_sa_bind_info_t *p_bind = (osmv_sa_bind_info_t *)bind_context;
- osmv_query_req_t *p_query_req_copy = NULL;
- osmv_query_res_t query_res;
- ib_sa_mad_t *p_sa_mad;
- ib_net16_t mad_status;
-
- OSM_LOG_ENTER( p_bind->p_log, __osmv_sa_mad_rcv_cb );
-
- if (! p_req_madw)
- {
- osm_log( p_bind->p_log, OSM_LOG_DEBUG,
- "__osmv_sa_mad_rcv_cb: "
- "Ignoring a non-response mad\n");
- osm_mad_pool_put(p_bind->p_mad_pool, p_madw);
- goto Exit;
- }
-
- /* obtain the sent context */
- p_query_req_copy =
- (osmv_query_req_t *)(p_req_madw->context.arb_context.context1);
-
- /* provide the context of the original request in the result */
- query_res.query_context = p_query_req_copy->query_context;
-
- /* provide the resulting madw */
- query_res.p_result_madw = p_madw;
-
- /* update the req fields */
- p_sa_mad = ( ib_sa_mad_t * ) p_madw->p_mad;
-
- /* if we got a remote error track it in the status */
- mad_status = ( ib_net16_t ) ( p_sa_mad->status & IB_SMP_STATUS_MASK );
- if (mad_status != IB_SUCCESS)
- {
- osm_log( p_bind->p_log, OSM_LOG_ERROR,
- "__osmv_sa_mad_rcv_cb: ERR 0501: "
- "Remote error:0x%04X .\n", mad_status
- );
- query_res.status = IB_REMOTE_ERROR;
- }
- else
- {
- query_res.status = IB_SUCCESS;
- }
-
- /* what if we have got back an empty mad ? */
- if (! p_madw->mad_size)
- {
- osm_log( p_bind->p_log, OSM_LOG_ERROR,
- "__osmv_sa_mad_rcv_cb: ERR 0502: "
- "Got an empty mad.\n"
- );
- query_res.status = IB_ERROR;
- }
-
- if (IB_SUCCESS == mad_status)
- {
-
- /* if we are in not in a method response of an rmpp nature we must get only 1 */
- /* HACK: in the future we might need to be smarter for other methods... */
- if (p_sa_mad->method != IB_MAD_METHOD_GETTABLE_RESP)
- {
- query_res.result_cnt = 1;
- }
- else
- {
+ osmv_sa_bind_info_t *p_bind = (osmv_sa_bind_info_t *) bind_context;
+ osmv_query_req_t *p_query_req_copy = NULL;
+ osmv_query_res_t query_res;
+ ib_sa_mad_t *p_sa_mad;
+ ib_net16_t mad_status;
+
+ OSM_LOG_ENTER(p_bind->p_log, __osmv_sa_mad_rcv_cb);
+
+ if (!p_req_madw) {
+ osm_log(p_bind->p_log, OSM_LOG_DEBUG,
+ "__osmv_sa_mad_rcv_cb: "
+ "Ignoring a non-response mad\n");
+ osm_mad_pool_put(p_bind->p_mad_pool, p_madw);
+ goto Exit;
+ }
+
+ /* obtain the sent context */
+ p_query_req_copy =
+ (osmv_query_req_t *) (p_req_madw->context.arb_context.context1);
+
+ /* provide the context of the original request in the result */
+ query_res.query_context = p_query_req_copy->query_context;
+
+ /* provide the resulting madw */
+ query_res.p_result_madw = p_madw;
+
+ /* update the req fields */
+ p_sa_mad = (ib_sa_mad_t *) p_madw->p_mad;
+
+ /* if we got a remote error track it in the status */
+ mad_status = (ib_net16_t) (p_sa_mad->status & IB_SMP_STATUS_MASK);
+ if (mad_status != IB_SUCCESS) {
+ osm_log(p_bind->p_log, OSM_LOG_ERROR,
+ "__osmv_sa_mad_rcv_cb: ERR 0501: "
+ "Remote error:0x%04X .\n", mad_status);
+ query_res.status = IB_REMOTE_ERROR;
+ } else {
+ query_res.status = IB_SUCCESS;
+ }
+
+ /* what if we have got back an empty mad ? */
+ if (!p_madw->mad_size) {
+ osm_log(p_bind->p_log, OSM_LOG_ERROR,
+ "__osmv_sa_mad_rcv_cb: ERR 0502: "
+ "Got an empty mad.\n");
+ query_res.status = IB_ERROR;
+ }
+
+ if (IB_SUCCESS == mad_status) {
+
+ /* if we are in not in a method response of an rmpp nature we must get only 1 */
+ /* HACK: in the future we might need to be smarter for other methods... */
+ if (p_sa_mad->method != IB_MAD_METHOD_GETTABLE_RESP) {
+ query_res.result_cnt = 1;
+ } else {
#ifndef VENDOR_RMPP_SUPPORT
- if (mad_status != IB_SUCCESS)
- query_res.result_cnt = 0;
- else
- query_res.result_cnt = 1;
+ if (mad_status != IB_SUCCESS)
+ query_res.result_cnt = 0;
+ else
+ query_res.result_cnt = 1;
#else
- /* we used the offset value to calculate the number of
- records in here */
- query_res.result_cnt =
- (uintn_t)
- ( ( p_madw->mad_size - IB_SA_MAD_HDR_SIZE ) /
- ib_get_attr_size( p_sa_mad->attr_offset ) );
- osm_log( p_bind->p_log, OSM_LOG_DEBUG,
- "__osmv_sa_mad_rcv_cb: Count = %u = %u / %u (%u)\n",
- query_res.result_cnt, p_madw->mad_size - IB_SA_MAD_HDR_SIZE,
- ib_get_attr_size( p_sa_mad->attr_offset ),
- ( p_madw->mad_size - IB_SA_MAD_HDR_SIZE ) %
- ib_get_attr_size( p_sa_mad->attr_offset )
- );
+ /* we used the offset value to calculate the number of
+ records in here */
+ query_res.result_cnt = (uintn_t)
+ ((p_madw->mad_size - IB_SA_MAD_HDR_SIZE) /
+ ib_get_attr_size(p_sa_mad->attr_offset));
+ osm_log(p_bind->p_log, OSM_LOG_DEBUG,
+ "__osmv_sa_mad_rcv_cb: Count = %u = %u / %u (%u)\n",
+ query_res.result_cnt,
+ p_madw->mad_size - IB_SA_MAD_HDR_SIZE,
+ ib_get_attr_size(p_sa_mad->attr_offset),
+ (p_madw->mad_size -
+ IB_SA_MAD_HDR_SIZE) %
+ ib_get_attr_size(p_sa_mad->attr_offset)
+ );
#endif
- }
- }
+ }
+ }
- query_res.query_type = p_query_req_copy->query_type;
+ query_res.query_type = p_query_req_copy->query_type;
- p_query_req_copy->pfn_query_cb( &query_res );
+ p_query_req_copy->pfn_query_cb(&query_res);
- if ((p_query_req_copy->flags & OSM_SA_FLAGS_SYNC) == OSM_SA_FLAGS_SYNC)
- cl_event_signal( &p_bind->sync_event );
+ if ((p_query_req_copy->flags & OSM_SA_FLAGS_SYNC) == OSM_SA_FLAGS_SYNC)
+ cl_event_signal(&p_bind->sync_event);
- Exit:
+ Exit:
- /* free the copied query request if found */
- if (p_query_req_copy) free(p_query_req_copy);
+ /* free the copied query request if found */
+ if (p_query_req_copy)
+ free(p_query_req_copy);
- /* put back the request madw */
- if (p_req_madw)
- osm_mad_pool_put(p_bind->p_mad_pool, p_req_madw);
+ /* put back the request madw */
+ if (p_req_madw)
+ osm_mad_pool_put(p_bind->p_mad_pool, p_req_madw);
- OSM_LOG_EXIT( p_bind->p_log );
+ OSM_LOG_EXIT(p_bind->p_log);
}
/*****************************************************************************
@@ -197,39 +183,37 @@ __osmv_sa_mad_rcv_cb(
Only report the error and get rid of the mad wrapper
*/
-void
-__osmv_sa_mad_err_cb(
- IN void* bind_context,
- IN osm_madw_t *p_madw)
+void __osmv_sa_mad_err_cb(IN void *bind_context, IN osm_madw_t * p_madw)
{
- osmv_sa_bind_info_t *p_bind = (osmv_sa_bind_info_t *)bind_context;
- osmv_query_req_t *p_query_req_copy = NULL;
- osmv_query_res_t query_res;
+ osmv_sa_bind_info_t *p_bind = (osmv_sa_bind_info_t *) bind_context;
+ osmv_query_req_t *p_query_req_copy = NULL;
+ osmv_query_res_t query_res;
- OSM_LOG_ENTER( p_bind->p_log, __osmv_sa_mad_err_cb );
+ OSM_LOG_ENTER(p_bind->p_log, __osmv_sa_mad_err_cb);
- /* Obtain the sent context etc */
- p_query_req_copy =
- (osmv_query_req_t *)(p_madw->context.arb_context.context1);
+ /* Obtain the sent context etc */
+ p_query_req_copy =
+ (osmv_query_req_t *) (p_madw->context.arb_context.context1);
- /* provide the context of the original request in the result */
- query_res.query_context = p_query_req_copy->query_context;
+ /* provide the context of the original request in the result */
+ query_res.query_context = p_query_req_copy->query_context;
- query_res.p_result_madw = p_madw;
+ query_res.p_result_madw = p_madw;
- query_res.status = IB_TIMEOUT;
- query_res.result_cnt = 0;
- query_res.p_result_madw->status = IB_TIMEOUT;
- p_madw->status = IB_TIMEOUT;
- query_res.query_type = p_query_req_copy->query_type;
+ query_res.status = IB_TIMEOUT;
+ query_res.result_cnt = 0;
+ query_res.p_result_madw->status = IB_TIMEOUT;
+ p_madw->status = IB_TIMEOUT;
+ query_res.query_type = p_query_req_copy->query_type;
- p_query_req_copy->pfn_query_cb( &query_res );
+ p_query_req_copy->pfn_query_cb(&query_res);
- if ((p_query_req_copy->flags & OSM_SA_FLAGS_SYNC) == OSM_SA_FLAGS_SYNC)
- cl_event_signal( &p_bind->sync_event );
+ if ((p_query_req_copy->flags & OSM_SA_FLAGS_SYNC) == OSM_SA_FLAGS_SYNC)
+ cl_event_signal(&p_bind->sync_event);
- if (p_query_req_copy) free(p_query_req_copy);
- OSM_LOG_EXIT( p_bind->p_log );
+ if (p_query_req_copy)
+ free(p_query_req_copy);
+ OSM_LOG_EXIT(p_bind->p_log);
}
/*****************************************************************************
@@ -241,197 +225,176 @@ __osmv_sa_mad_err_cb(
we query for multiple guids.
*****************************************************************************/
ib_api_status_t
-__osmv_get_lid_and_sm_lid_by_port_guid(
- IN osm_vendor_t* const p_vend,
- IN ib_net64_t port_guid,
- IN OUT uint64_t* p_lids_update_time_sec,
- OUT uint16_t* lid,
- OUT uint16_t* sm_lid)
+__osmv_get_lid_and_sm_lid_by_port_guid(IN osm_vendor_t * const p_vend,
+ IN ib_net64_t port_guid,
+ IN OUT uint64_t * p_lids_update_time_sec,
+ OUT uint16_t * lid,
+ OUT uint16_t * sm_lid)
{
- ib_api_status_t status;
- ib_port_attr_t *p_attr_array;
- uint32_t num_ports;
- uint32_t port_num;
-
- OSM_LOG_ENTER( p_vend->p_log, __osmv_get_lid_and_sm_lid_by_port_guid );
-
- /* use prevous values if current time is close enough to previous query */
- if (cl_get_time_stamp_sec() <= *p_lids_update_time_sec + 30)
- {
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "__osmv_get_lid_and_sm_lid_by_port_guid: "
- "Using previously stored lid:0x%04x sm_lid:0x%04x\n",
- *lid, *sm_lid
- );
- status = IB_SUCCESS;
- goto Exit;
- }
-
- /* obtain the number of available ports */
- num_ports = 0;
- status = osm_vendor_get_all_port_attr(p_vend, NULL, &num_ports);
- if (status != IB_INSUFFICIENT_MEMORY)
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__osmv_get_lid_and_sm_lid_by_port_guid: ERR 0503: "
- "expected to get the IB_INSUFFICIENT_MEMORY but got: %s\n",
- ib_get_err_str(status)
- );
- status = IB_ERROR;
- goto Exit;
- }
-
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "__osmv_get_lid_and_sm_lid_by_port_guid: "
- "Found total of %u ports. Looking for guid:0x%016" PRIx64 "\n",
- num_ports, cl_ntoh64(port_guid)
- );
-
- /* allocate the attributes */
- p_attr_array =
- (ib_port_attr_t *)malloc(sizeof(ib_port_attr_t)*num_ports);
-
- /* obtain the attributes */
- status = osm_vendor_get_all_port_attr(p_vend, p_attr_array, &num_ports);
- if (status != IB_SUCCESS)
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__osmv_get_lid_and_sm_lid_by_port_guid: ERR 0504: "
- "Fail to get port attributes (error: %s)\n",
- ib_get_err_str(status)
- );
- free(p_attr_array);
- goto Exit;
- }
-
- status = IB_ERROR;
- /* find the port requested in the list */
- for (port_num = 0; (port_num<num_ports) && (status == IB_ERROR); port_num++)
- {
- if (p_attr_array[port_num].port_guid == port_guid)
- {
- *lid = p_attr_array[port_num].lid;
- *sm_lid = p_attr_array[port_num].sm_lid;
- *p_lids_update_time_sec = cl_get_time_stamp_sec();
- status = IB_SUCCESS;
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "__osmv_get_lid_and_sm_lid_by_port_guid: "
- "Found guid:0x%016" PRIx64 " with idx:%d\n",
- cl_ntoh64(port_guid), port_num);
- }
- }
-
- free(p_attr_array);
-
- Exit:
- OSM_LOG_EXIT( p_vend->p_log );
- return ( status );
+ ib_api_status_t status;
+ ib_port_attr_t *p_attr_array;
+ uint32_t num_ports;
+ uint32_t port_num;
+
+ OSM_LOG_ENTER(p_vend->p_log, __osmv_get_lid_and_sm_lid_by_port_guid);
+
+ /* use prevous values if current time is close enough to previous query */
+ if (cl_get_time_stamp_sec() <= *p_lids_update_time_sec + 30) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__osmv_get_lid_and_sm_lid_by_port_guid: "
+ "Using previously stored lid:0x%04x sm_lid:0x%04x\n",
+ *lid, *sm_lid);
+ status = IB_SUCCESS;
+ goto Exit;
+ }
+
+ /* obtain the number of available ports */
+ num_ports = 0;
+ status = osm_vendor_get_all_port_attr(p_vend, NULL, &num_ports);
+ if (status != IB_INSUFFICIENT_MEMORY) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osmv_get_lid_and_sm_lid_by_port_guid: ERR 0503: "
+ "expected to get the IB_INSUFFICIENT_MEMORY but got: %s\n",
+ ib_get_err_str(status)
+ );
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__osmv_get_lid_and_sm_lid_by_port_guid: "
+ "Found total of %u ports. Looking for guid:0x%016" PRIx64 "\n",
+ num_ports, cl_ntoh64(port_guid)
+ );
+
+ /* allocate the attributes */
+ p_attr_array =
+ (ib_port_attr_t *) malloc(sizeof(ib_port_attr_t) * num_ports);
+
+ /* obtain the attributes */
+ status = osm_vendor_get_all_port_attr(p_vend, p_attr_array, &num_ports);
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osmv_get_lid_and_sm_lid_by_port_guid: ERR 0504: "
+ "Fail to get port attributes (error: %s)\n",
+ ib_get_err_str(status)
+ );
+ free(p_attr_array);
+ goto Exit;
+ }
+
+ status = IB_ERROR;
+ /* find the port requested in the list */
+ for (port_num = 0; (port_num < num_ports) && (status == IB_ERROR);
+ port_num++) {
+ if (p_attr_array[port_num].port_guid == port_guid) {
+ *lid = p_attr_array[port_num].lid;
+ *sm_lid = p_attr_array[port_num].sm_lid;
+ *p_lids_update_time_sec = cl_get_time_stamp_sec();
+ status = IB_SUCCESS;
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__osmv_get_lid_and_sm_lid_by_port_guid: "
+ "Found guid:0x%016" PRIx64 " with idx:%d\n",
+ cl_ntoh64(port_guid), port_num);
+ }
+ }
+
+ free(p_attr_array);
+
+ Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
}
/*****************************************************************************
*****************************************************************************/
osm_bind_handle_t
-osmv_bind_sa(
- IN osm_vendor_t* const p_vend,
- IN osm_mad_pool_t* const p_mad_pool,
- IN ib_net64_t port_guid
- )
+osmv_bind_sa(IN osm_vendor_t * const p_vend,
+ IN osm_mad_pool_t * const p_mad_pool, IN ib_net64_t port_guid)
{
- osm_bind_info_t bind_info;
- osm_log_t *p_log = p_vend->p_log;
- ib_api_status_t status = IB_SUCCESS;
- osmv_sa_bind_info_t *p_sa_bind_info;
- cl_status_t cl_status;
-
- OSM_LOG_ENTER( p_log, osmv_bind_sa );
-
- osm_log( p_log, OSM_LOG_DEBUG,
- "osmv_bind_sa: "
- "Binding to port 0x%" PRIx64 ".\n",
- cl_ntoh64( port_guid ) );
-
- bind_info.port_guid = port_guid;
- bind_info.mad_class = IB_MCLASS_SUBN_ADM;
- bind_info.class_version = 2;
- bind_info.is_responder = TRUE;
- bind_info.is_trap_processor = FALSE;
- bind_info.is_report_processor = TRUE;
- bind_info.send_q_size = 256;
- bind_info.recv_q_size = 256;
-
- /* allocate the new sa bind info */
- p_sa_bind_info =
- (osmv_sa_bind_info_t *)malloc(sizeof(osmv_sa_bind_info_t));
- if (! p_sa_bind_info)
- {
- osm_log( p_log, OSM_LOG_ERROR,
- "osmv_bind_sa: ERR 0505: "
- "Fail to allocate new bidn structure\n" );
- p_sa_bind_info = OSM_BIND_INVALID_HANDLE;
- goto Exit;
- }
-
- /* store some important context */
- p_sa_bind_info->p_log = p_log;
- p_sa_bind_info->port_guid = port_guid;
- p_sa_bind_info->p_mad_pool = p_mad_pool;
- p_sa_bind_info->p_vendor = p_vend;
- p_sa_bind_info->last_lids_update_sec = 0;
-
- /* Bind to the lower level */
- p_sa_bind_info->h_bind =
- osm_vendor_bind( p_vend,
- &bind_info,
- p_mad_pool,
- __osmv_sa_mad_rcv_cb,
- __osmv_sa_mad_err_cb,
- p_sa_bind_info); /* context provided to CBs */
-
- if (p_sa_bind_info->h_bind == OSM_BIND_INVALID_HANDLE)
- {
- free(p_sa_bind_info);
- p_sa_bind_info = OSM_BIND_INVALID_HANDLE;
- osm_log( p_log, OSM_LOG_ERROR,
- "osmv_bind_sa: ERR 0506: "
- "Fail to bind to vendor SMI.\n" );
- goto Exit;
- }
-
- /* obtain the sm_lid from the vendor */
- status =
- __osmv_get_lid_and_sm_lid_by_port_guid(
- p_vend, port_guid,
- &p_sa_bind_info->last_lids_update_sec,
- &p_sa_bind_info->lid,
- &p_sa_bind_info->sm_lid);
- if (status != IB_SUCCESS)
- {
- free(p_sa_bind_info);
- p_sa_bind_info = OSM_BIND_INVALID_HANDLE;
- osm_log( p_log, OSM_LOG_ERROR,
- "osmv_bind_sa: ERR 0507: "
- "Fail to obtain the sm lid.\n" );
- goto Exit;
- }
-
- /* initialize the sync_event */
- cl_event_construct( &p_sa_bind_info->sync_event );
- cl_status = cl_event_init( &p_sa_bind_info->sync_event, TRUE );
- if( cl_status != CL_SUCCESS )
- {
- osm_log( p_log, OSM_LOG_ERROR,
- "osmv_bind_sa: ERR 0508: "
- "cl_init_event failed: %s\n",
- ib_get_err_str(cl_status)
- );
- free(p_sa_bind_info);
- p_sa_bind_info = OSM_BIND_INVALID_HANDLE;
- }
-
- Exit:
- OSM_LOG_EXIT( p_log );
- return ( p_sa_bind_info );
+ osm_bind_info_t bind_info;
+ osm_log_t *p_log = p_vend->p_log;
+ ib_api_status_t status = IB_SUCCESS;
+ osmv_sa_bind_info_t *p_sa_bind_info;
+ cl_status_t cl_status;
+
+ OSM_LOG_ENTER(p_log, osmv_bind_sa);
+
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "osmv_bind_sa: "
+ "Binding to port 0x%" PRIx64 ".\n", cl_ntoh64(port_guid));
+
+ bind_info.port_guid = port_guid;
+ bind_info.mad_class = IB_MCLASS_SUBN_ADM;
+ bind_info.class_version = 2;
+ bind_info.is_responder = TRUE;
+ bind_info.is_trap_processor = FALSE;
+ bind_info.is_report_processor = TRUE;
+ bind_info.send_q_size = 256;
+ bind_info.recv_q_size = 256;
+
+ /* allocate the new sa bind info */
+ p_sa_bind_info =
+ (osmv_sa_bind_info_t *) malloc(sizeof(osmv_sa_bind_info_t));
+ if (!p_sa_bind_info) {
+ osm_log(p_log, OSM_LOG_ERROR,
+ "osmv_bind_sa: ERR 0505: "
+ "Fail to allocate new bidn structure\n");
+ p_sa_bind_info = OSM_BIND_INVALID_HANDLE;
+ goto Exit;
+ }
+
+ /* store some important context */
+ p_sa_bind_info->p_log = p_log;
+ p_sa_bind_info->port_guid = port_guid;
+ p_sa_bind_info->p_mad_pool = p_mad_pool;
+ p_sa_bind_info->p_vendor = p_vend;
+ p_sa_bind_info->last_lids_update_sec = 0;
+
+ /* Bind to the lower level */
+ p_sa_bind_info->h_bind = osm_vendor_bind(p_vend, &bind_info, p_mad_pool, __osmv_sa_mad_rcv_cb, __osmv_sa_mad_err_cb, p_sa_bind_info); /* context provided to CBs */
+
+ if (p_sa_bind_info->h_bind == OSM_BIND_INVALID_HANDLE) {
+ free(p_sa_bind_info);
+ p_sa_bind_info = OSM_BIND_INVALID_HANDLE;
+ osm_log(p_log, OSM_LOG_ERROR,
+ "osmv_bind_sa: ERR 0506: "
+ "Fail to bind to vendor SMI.\n");
+ goto Exit;
+ }
+
+ /* obtain the sm_lid from the vendor */
+ status =
+ __osmv_get_lid_and_sm_lid_by_port_guid(p_vend, port_guid,
+ &p_sa_bind_info->
+ last_lids_update_sec,
+ &p_sa_bind_info->lid,
+ &p_sa_bind_info->sm_lid);
+ if (status != IB_SUCCESS) {
+ free(p_sa_bind_info);
+ p_sa_bind_info = OSM_BIND_INVALID_HANDLE;
+ osm_log(p_log, OSM_LOG_ERROR,
+ "osmv_bind_sa: ERR 0507: "
+ "Fail to obtain the sm lid.\n");
+ goto Exit;
+ }
+
+ /* initialize the sync_event */
+ cl_event_construct(&p_sa_bind_info->sync_event);
+ cl_status = cl_event_init(&p_sa_bind_info->sync_event, TRUE);
+ if (cl_status != CL_SUCCESS) {
+ osm_log(p_log, OSM_LOG_ERROR,
+ "osmv_bind_sa: ERR 0508: "
+ "cl_init_event failed: %s\n", ib_get_err_str(cl_status)
+ );
+ free(p_sa_bind_info);
+ p_sa_bind_info = OSM_BIND_INVALID_HANDLE;
+ }
+
+ Exit:
+ OSM_LOG_EXIT(p_log);
+ return (p_sa_bind_info);
}
/*****************************************************************************
@@ -447,15 +410,14 @@ osmv_bind_sa(
*
* SYNOPSIS
*/
-typedef struct _osmv_sa_mad_data
-{
- /* MAD data. */
- uint8_t method;
- ib_net16_t attr_id;
- ib_net16_t attr_offset;
- ib_net32_t attr_mod;
- ib_net64_t comp_mask;
- void *p_attr;
+typedef struct _osmv_sa_mad_data {
+ /* MAD data. */
+ uint8_t method;
+ ib_net16_t attr_id;
+ ib_net16_t attr_offset;
+ ib_net32_t attr_mod;
+ ib_net64_t comp_mask;
+ void *p_attr;
} osmv_sa_mad_data_t;
/*
* method
@@ -482,142 +444,130 @@ typedef struct _osmv_sa_mad_data
*****************************************************************************/
/* Send a MAD out on the GSI interface */
ib_api_status_t
-__osmv_send_sa_req(
- IN osmv_sa_bind_info_t* p_bind,
- IN const osmv_sa_mad_data_t * const p_sa_mad_data,
- IN const osmv_query_req_t * const p_query_req )
+__osmv_send_sa_req(IN osmv_sa_bind_info_t * p_bind,
+ IN const osmv_sa_mad_data_t * const p_sa_mad_data,
+ IN const osmv_query_req_t * const p_query_req)
{
- ib_api_status_t status;
- ib_mad_t *p_mad_hdr;
- ib_sa_mad_t *p_sa_mad;
- osm_madw_t *p_madw;
- osm_log_t *p_log = p_bind->p_log;
- static atomic32_t trans_id;
- boolean_t sync;
- osmv_query_req_t *p_query_req_copy;
-
- OSM_LOG_ENTER( p_log, __osmv_send_sa_req );
-
- /*
- since the sm_lid might change we obtain it every send
- (actually it is cached in the bind object and refreshed
- every 30sec by this proc )
- */
- status =
- __osmv_get_lid_and_sm_lid_by_port_guid(
- p_bind->p_vendor, p_bind->port_guid,
- &p_bind->last_lids_update_sec,
- &p_bind->lid,
- &p_bind->sm_lid);
- if (status != IB_SUCCESS)
- {
- osm_log( p_log, OSM_LOG_ERROR,
- "__osmv_send_sa_req: ERR 0509: "
- "Fail to obtain the sm lid.\n" );
- goto Exit;
- }
-
- /* Get a MAD wrapper for the send */
- p_madw = osm_mad_pool_get(
- p_bind->p_mad_pool,
- p_bind->h_bind,
- MAD_BLOCK_SIZE,
- NULL );
-
- if( p_madw == NULL )
- {
- osm_log( p_log, OSM_LOG_ERROR,
- "__osmv_send_sa_req: ERR 0510: "
- "Unable to acquire MAD.\n" );
- status = IB_INSUFFICIENT_RESOURCES;
- goto Exit;
- }
-
- /* Initialize the Sent MAD: */
-
- /* Initialize the MAD buffer for the send operation. */
- p_mad_hdr = osm_madw_get_mad_ptr( p_madw );
- p_sa_mad = osm_madw_get_sa_mad_ptr( p_madw );
-
- /* Get a new transaction Id */
- cl_atomic_inc( &trans_id );
-
- /* Cleanup the MAD from any residue */
- memset(p_sa_mad, 0, MAD_BLOCK_SIZE);
-
- /* Initialize the standard MAD header. */
- ib_mad_init_new(
- p_mad_hdr, /* mad pointer */
- IB_MCLASS_SUBN_ADM, /* class */
- ( uint8_t ) 2, /* version */
- p_sa_mad_data->method, /* method */
- cl_hton64( ( uint64_t ) trans_id ),/* tid */
- p_sa_mad_data->attr_id, /* attr id */
- p_sa_mad_data->attr_mod /* attr mod */
- );
-
- /* Set the query information. */
- p_sa_mad->sm_key = p_query_req->sm_key;
- p_sa_mad->attr_offset = 0;
- p_sa_mad->comp_mask = p_sa_mad_data->comp_mask;
- if( p_sa_mad->comp_mask )
- {
- memcpy( p_sa_mad->data, p_sa_mad_data->p_attr,
- ib_get_attr_size(p_sa_mad_data->attr_offset));
- }
-
- /*
- Provide the address to send to
- */
- /* Patch to handle IBAL - host order , where it should take destination lid in network order */
+ ib_api_status_t status;
+ ib_mad_t *p_mad_hdr;
+ ib_sa_mad_t *p_sa_mad;
+ osm_madw_t *p_madw;
+ osm_log_t *p_log = p_bind->p_log;
+ static atomic32_t trans_id;
+ boolean_t sync;
+ osmv_query_req_t *p_query_req_copy;
+
+ OSM_LOG_ENTER(p_log, __osmv_send_sa_req);
+
+ /*
+ since the sm_lid might change we obtain it every send
+ (actually it is cached in the bind object and refreshed
+ every 30sec by this proc )
+ */
+ status =
+ __osmv_get_lid_and_sm_lid_by_port_guid(p_bind->p_vendor,
+ p_bind->port_guid,
+ &p_bind->
+ last_lids_update_sec,
+ &p_bind->lid,
+ &p_bind->sm_lid);
+ if (status != IB_SUCCESS) {
+ osm_log(p_log, OSM_LOG_ERROR,
+ "__osmv_send_sa_req: ERR 0509: "
+ "Fail to obtain the sm lid.\n");
+ goto Exit;
+ }
+
+ /* Get a MAD wrapper for the send */
+ p_madw = osm_mad_pool_get(p_bind->p_mad_pool,
+ p_bind->h_bind, MAD_BLOCK_SIZE, NULL);
+
+ if (p_madw == NULL) {
+ osm_log(p_log, OSM_LOG_ERROR,
+ "__osmv_send_sa_req: ERR 0510: "
+ "Unable to acquire MAD.\n");
+ status = IB_INSUFFICIENT_RESOURCES;
+ goto Exit;
+ }
+
+ /* Initialize the Sent MAD: */
+
+ /* Initialize the MAD buffer for the send operation. */
+ p_mad_hdr = osm_madw_get_mad_ptr(p_madw);
+ p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
+
+ /* Get a new transaction Id */
+ cl_atomic_inc(&trans_id);
+
+ /* Cleanup the MAD from any residue */
+ memset(p_sa_mad, 0, MAD_BLOCK_SIZE);
+
+ /* Initialize the standard MAD header. */
+ ib_mad_init_new(p_mad_hdr, /* mad pointer */
+ IB_MCLASS_SUBN_ADM, /* class */
+ (uint8_t) 2, /* version */
+ p_sa_mad_data->method, /* method */
+ cl_hton64((uint64_t) trans_id), /* tid */
+ p_sa_mad_data->attr_id, /* attr id */
+ p_sa_mad_data->attr_mod /* attr mod */
+ );
+
+ /* Set the query information. */
+ p_sa_mad->sm_key = p_query_req->sm_key;
+ p_sa_mad->attr_offset = 0;
+ p_sa_mad->comp_mask = p_sa_mad_data->comp_mask;
+ if (p_sa_mad->comp_mask) {
+ memcpy(p_sa_mad->data, p_sa_mad_data->p_attr,
+ ib_get_attr_size(p_sa_mad_data->attr_offset));
+ }
+
+ /*
+ Provide the address to send to
+ */
+ /* Patch to handle IBAL - host order , where it should take destination lid in network order */
#ifdef OSM_VENDOR_INTF_AL
- p_madw->mad_addr.dest_lid = p_bind->sm_lid;
+ p_madw->mad_addr.dest_lid = p_bind->sm_lid;
#else
- p_madw->mad_addr.dest_lid = cl_hton16(p_bind->sm_lid);
+ p_madw->mad_addr.dest_lid = cl_hton16(p_bind->sm_lid);
#endif
- p_madw->mad_addr.addr_type.smi.source_lid =
- cl_hton16(p_bind->lid);
- p_madw->mad_addr.addr_type.gsi.remote_qp = CL_HTON32(1);
- p_madw->mad_addr.addr_type.gsi.remote_qkey = IB_QP1_WELL_KNOWN_Q_KEY;
- p_madw->mad_addr.addr_type.gsi.pkey = IB_DEFAULT_PKEY;
- p_madw->resp_expected = TRUE;
- p_madw->fail_msg = CL_DISP_MSGID_NONE;
-
- /*
- Provide MAD context such that the call back will know what to do.
- We have to keep the entire request structure so we know the CB.
- Since we can not rely on the client to keep it arroud until
- the response - we duplicate it and will later dispose it (in CB).
- To store on the MADW we cast it into what opensm has:
- p_madw->context.arb_context.context1
- */
- p_query_req_copy = malloc(sizeof(*p_query_req_copy));
- *p_query_req_copy = *p_query_req;
- p_madw->context.arb_context.context1 = p_query_req_copy;
-
- /* we can support async as well as sync calls */
- sync = ((p_query_req->flags & OSM_SA_FLAGS_SYNC) == OSM_SA_FLAGS_SYNC);
-
- /* send the mad asynchronously */
- status = osm_vendor_send(
- osm_madw_get_bind_handle( p_madw ),
- p_madw,
- p_madw->resp_expected );
-
- /* if synchronous - wait on the event */
- if (sync)
- {
- osm_log( p_log, OSM_LOG_DEBUG,
- "__osmv_send_sa_req: "
- "Waiting for async event.\n" );
- cl_event_wait_on( &p_bind->sync_event, EVENT_NO_TIMEOUT, FALSE );
- cl_event_reset(&p_bind->sync_event);
- status = p_madw->status;
- }
-
- Exit:
- OSM_LOG_EXIT( p_log );
- return status;
+ p_madw->mad_addr.addr_type.smi.source_lid = cl_hton16(p_bind->lid);
+ p_madw->mad_addr.addr_type.gsi.remote_qp = CL_HTON32(1);
+ p_madw->mad_addr.addr_type.gsi.remote_qkey = IB_QP1_WELL_KNOWN_Q_KEY;
+ p_madw->mad_addr.addr_type.gsi.pkey = IB_DEFAULT_PKEY;
+ p_madw->resp_expected = TRUE;
+ p_madw->fail_msg = CL_DISP_MSGID_NONE;
+
+ /*
+ Provide MAD context such that the call back will know what to do.
+ We have to keep the entire request structure so we know the CB.
+ Since we can not rely on the client to keep it arroud until
+ the response - we duplicate it and will later dispose it (in CB).
+ To store on the MADW we cast it into what opensm has:
+ p_madw->context.arb_context.context1
+ */
+ p_query_req_copy = malloc(sizeof(*p_query_req_copy));
+ *p_query_req_copy = *p_query_req;
+ p_madw->context.arb_context.context1 = p_query_req_copy;
+
+ /* we can support async as well as sync calls */
+ sync = ((p_query_req->flags & OSM_SA_FLAGS_SYNC) == OSM_SA_FLAGS_SYNC);
+
+ /* send the mad asynchronously */
+ status = osm_vendor_send(osm_madw_get_bind_handle(p_madw),
+ p_madw, p_madw->resp_expected);
+
+ /* if synchronous - wait on the event */
+ if (sync) {
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "__osmv_send_sa_req: " "Waiting for async event.\n");
+ cl_event_wait_on(&p_bind->sync_event, EVENT_NO_TIMEOUT, FALSE);
+ cl_event_reset(&p_bind->sync_event);
+ status = p_madw->status;
+ }
+
+ Exit:
+ OSM_LOG_EXIT(p_log);
+ return status;
}
/*****************************************************************************
@@ -626,243 +576,253 @@ __osmv_send_sa_req(
* Query the SA based on the user's request.
*/
ib_api_status_t
-osmv_query_sa(
- IN osm_bind_handle_t h_bind,
- IN const osmv_query_req_t * const p_query_req
- )
+osmv_query_sa(IN osm_bind_handle_t h_bind,
+ IN const osmv_query_req_t * const p_query_req)
{
- osmv_sa_bind_info_t *p_bind = (osmv_sa_bind_info_t *)h_bind;
- osmv_sa_mad_data_t sa_mad_data;
- osmv_user_query_t *p_user_query;
- ib_service_record_t svc_rec;
- ib_node_record_t node_rec;
- ib_portinfo_record_t port_info;
- ib_path_rec_t path_rec;
- ib_class_port_info_t class_port_info;
- osm_log_t *p_log = p_bind->p_log;
- ib_api_status_t status;
-
- OSM_LOG_ENTER( p_log, osmv_query_sa );
-
- /* Set the request information. */
- sa_mad_data.method = IB_MAD_METHOD_GETTABLE;
- sa_mad_data.attr_mod = 0;
-
- /* Set the MAD attributes and component mask correctly. */
- switch ( p_query_req->query_type )
- {
-
- case OSMV_QUERY_USER_DEFINED:
- osm_log( p_log, OSM_LOG_DEBUG,
- "osmv_query_sa DBG:001 %s", "USER_DEFINED\n" );
- p_user_query = ( osmv_user_query_t * ) p_query_req->p_query_input;
- if (p_user_query->method) sa_mad_data.method = p_user_query->method;
- sa_mad_data.attr_offset = p_user_query->attr_offset;
- sa_mad_data.attr_id = p_user_query->attr_id;
- sa_mad_data.attr_mod = p_user_query->attr_mod;
- sa_mad_data.comp_mask = p_user_query->comp_mask;
- sa_mad_data.p_attr = p_user_query->p_attr;
- break;
-
- case OSMV_QUERY_ALL_SVC_RECS:
- osm_log( p_log, OSM_LOG_DEBUG,
- "osmv_query_sa DBG:001 %s", "SVC_REC_BY_NAME\n" );
- sa_mad_data.method = IB_MAD_METHOD_GETTABLE;
- sa_mad_data.attr_id = IB_MAD_ATTR_SERVICE_RECORD;
- sa_mad_data.attr_offset =
- ib_get_attr_offset( sizeof( ib_service_record_t ) );
- sa_mad_data.comp_mask = 0;
- sa_mad_data.p_attr = &svc_rec;
- break;
-
- case OSMV_QUERY_SVC_REC_BY_NAME:
- osm_log( p_log, OSM_LOG_DEBUG,
- "osmv_query_sa DBG:001 %s", "SVC_REC_BY_NAME\n" );
- sa_mad_data.method = IB_MAD_METHOD_GET;
- sa_mad_data.attr_id = IB_MAD_ATTR_SERVICE_RECORD;
- sa_mad_data.comp_mask = IB_SR_COMPMASK_SNAME;
- sa_mad_data.attr_offset =
- ib_get_attr_offset( sizeof( ib_service_record_t ) );
- sa_mad_data.p_attr = &svc_rec;
- memcpy( svc_rec.service_name, p_query_req->p_query_input,
- sizeof( ib_svc_name_t ) );
- break;
-
- case OSMV_QUERY_SVC_REC_BY_ID:
- osm_log( p_log, OSM_LOG_DEBUG,
- "osmv_query_sa DBG:001 %s", "SVC_REC_BY_ID\n" );
- sa_mad_data.attr_id = IB_MAD_ATTR_SERVICE_RECORD;
- sa_mad_data.comp_mask = IB_SR_COMPMASK_SID;
- sa_mad_data.attr_offset =
- ib_get_attr_offset( sizeof( ib_service_record_t ) );
- sa_mad_data.p_attr = &svc_rec;
- svc_rec.service_id = *( ib_net64_t * ) ( p_query_req->p_query_input );
- break;
-
- case OSMV_QUERY_CLASS_PORT_INFO:
- osm_log( p_log, OSM_LOG_DEBUG,
- "osmv_query_sa DBG:001 %s","CLASS_PORT_INFO\n" );
- sa_mad_data.method = IB_MAD_METHOD_GET;
- sa_mad_data.attr_id = IB_MAD_ATTR_CLASS_PORT_INFO;
- sa_mad_data.attr_offset =
- ib_get_attr_offset( sizeof( ib_class_port_info_t ) );
- sa_mad_data.comp_mask = 0;
- sa_mad_data.p_attr = &class_port_info;
-
- break;
-
- case OSMV_QUERY_NODE_REC_BY_NODE_GUID:
- osm_log( p_log, OSM_LOG_DEBUG,
- "osmv_query_sa DBG:001 %s","NODE_REC_BY_NODE_GUID\n" );
- sa_mad_data.method = IB_MAD_METHOD_GETTABLE;
- sa_mad_data.attr_id = IB_MAD_ATTR_NODE_RECORD;
- sa_mad_data.attr_offset =
- ib_get_attr_offset( sizeof( ib_node_record_t ) );
- sa_mad_data.comp_mask = IB_NR_COMPMASK_NODEGUID;
- sa_mad_data.p_attr = &node_rec;
- node_rec.node_info.node_guid =
- *( ib_net64_t * ) ( p_query_req->p_query_input );
-
- break;
-
- case OSMV_QUERY_PORT_REC_BY_LID:
- osm_log( p_log, OSM_LOG_DEBUG,
- "osmv_query_sa DBG:001 %s","PORT_REC_BY_LID\n" );
- sa_mad_data.attr_id = IB_MAD_ATTR_PORTINFO_RECORD;
- sa_mad_data.attr_offset =
- ib_get_attr_offset( sizeof( ib_portinfo_record_t ) );
- sa_mad_data.comp_mask = IB_PIR_COMPMASK_LID;
- sa_mad_data.p_attr = &port_info;
- port_info.lid = *( ib_net16_t * ) ( p_query_req->p_query_input );
- break;
-
- case OSMV_QUERY_PORT_REC_BY_LID_AND_NUM:
- sa_mad_data.method = IB_MAD_METHOD_GET;
- p_user_query = ( osmv_user_query_t * ) p_query_req->p_query_input;
- osm_log( p_log, OSM_LOG_DEBUG,
- "osmv_query_sa DBG:001 %s","PORT_REC_BY_LID_AND_NUM\n" );
- sa_mad_data.attr_id = IB_MAD_ATTR_PORTINFO_RECORD;
- sa_mad_data.attr_offset =
- ib_get_attr_offset( sizeof( ib_portinfo_record_t ) );
- sa_mad_data.comp_mask = IB_PIR_COMPMASK_LID | IB_PIR_COMPMASK_PORTNUM;
- sa_mad_data.p_attr = p_user_query->p_attr;
- break;
-
- case OSMV_QUERY_VLARB_BY_LID_PORT_BLOCK:
- sa_mad_data.method = IB_MAD_METHOD_GET;
- p_user_query = ( osmv_user_query_t * ) p_query_req->p_query_input;
- osm_log( p_log, OSM_LOG_DEBUG,
- "osmv_query_sa DBG:001 %s","OSMV_QUERY_VLARB_BY_LID_PORT_BLOCK\n" );
- sa_mad_data.attr_id = IB_MAD_ATTR_VLARB_RECORD;
- sa_mad_data.attr_offset =
- ib_get_attr_offset( sizeof( ib_vl_arb_table_record_t ) );
- sa_mad_data.comp_mask = IB_VLA_COMPMASK_LID | IB_VLA_COMPMASK_OUT_PORT | IB_VLA_COMPMASK_BLOCK;
- sa_mad_data.p_attr = p_user_query->p_attr;
- break;
-
- case OSMV_QUERY_SLVL_BY_LID_AND_PORTS:
- sa_mad_data.method = IB_MAD_METHOD_GET;
- p_user_query = ( osmv_user_query_t * ) p_query_req->p_query_input;
- osm_log( p_log, OSM_LOG_DEBUG,
- "osmv_query_sa DBG:001 %s","OSMV_QUERY_VLARB_BY_LID_PORT_BLOCK\n" );
- sa_mad_data.attr_id = IB_MAD_ATTR_SLVL_RECORD;
- sa_mad_data.attr_offset =
- ib_get_attr_offset( sizeof( ib_slvl_table_record_t ) );
- sa_mad_data.comp_mask = IB_SLVL_COMPMASK_LID | IB_SLVL_COMPMASK_OUT_PORT | IB_SLVL_COMPMASK_IN_PORT;
- sa_mad_data.p_attr = p_user_query->p_attr;
- break;
-
- case OSMV_QUERY_PATH_REC_BY_PORT_GUIDS:
- osm_log( p_log, OSM_LOG_DEBUG,
- "osmv_query_sa DBG:001 %s","PATH_REC_BY_PORT_GUIDS\n" );
- memset(&path_rec, 0, sizeof(ib_path_rec_t ));
- sa_mad_data.attr_id = IB_MAD_ATTR_PATH_RECORD;
- sa_mad_data.attr_offset =
- ib_get_attr_offset( sizeof( ib_path_rec_t ) );
- sa_mad_data.comp_mask = ( IB_PR_COMPMASK_DGID | IB_PR_COMPMASK_SGID );
- sa_mad_data.p_attr = &path_rec;
- ib_gid_set_default( &path_rec.dgid,
- ( ( osmv_guid_pair_t * ) ( p_query_req->
- p_query_input ) )->
- dest_guid );
- ib_gid_set_default( &path_rec.sgid,
- ( ( osmv_guid_pair_t * ) ( p_query_req->
- p_query_input ) )->
- src_guid );
- break;
-
- case OSMV_QUERY_PATH_REC_BY_GIDS:
- osm_log( p_log, OSM_LOG_DEBUG,
- "osmv_query_sa DBG:001 %s","PATH_REC_BY_GIDS\n" );
- memset(&path_rec, 0, sizeof(ib_path_rec_t ));
- sa_mad_data.attr_id = IB_MAD_ATTR_PATH_RECORD;
- sa_mad_data.attr_offset =
- ib_get_attr_offset( sizeof( ib_path_rec_t ) );
- sa_mad_data.comp_mask = ( IB_PR_COMPMASK_DGID | IB_PR_COMPMASK_SGID );
- sa_mad_data.p_attr = &path_rec;
- memcpy( &path_rec.dgid,
- &( ( osmv_gid_pair_t * ) ( p_query_req->p_query_input ) )->
- dest_gid, sizeof( ib_gid_t ) );
- memcpy( &path_rec.sgid,
- &( ( osmv_gid_pair_t * ) ( p_query_req->p_query_input ) )->
- src_gid, sizeof( ib_gid_t ) );
- break;
-
- case OSMV_QUERY_PATH_REC_BY_LIDS:
- osm_log( p_log, OSM_LOG_DEBUG,
- "osmv_query_sa DBG:001 %s","PATH_REC_BY_LIDS\n" );
- memset(&path_rec, 0, sizeof(ib_path_rec_t ));
- sa_mad_data.method = IB_MAD_METHOD_GET;
- sa_mad_data.attr_id = IB_MAD_ATTR_PATH_RECORD;
- sa_mad_data.attr_offset =
- ib_get_attr_offset( sizeof( ib_path_rec_t ) );
- sa_mad_data.comp_mask = ( IB_PR_COMPMASK_DLID | IB_PR_COMPMASK_SLID );
- sa_mad_data.p_attr = &path_rec;
- path_rec.dlid =
- ( ( osmv_lid_pair_t * ) ( p_query_req->p_query_input ) )->dest_lid;
- path_rec.slid =
- ( ( osmv_lid_pair_t * ) ( p_query_req->p_query_input ) )->src_lid;
- break;
-
- case OSMV_QUERY_UD_MULTICAST_SET:
- sa_mad_data.method = IB_MAD_METHOD_SET;
- p_user_query = ( osmv_user_query_t * ) p_query_req->p_query_input;
- osm_log( p_log, OSM_LOG_DEBUG,
- "osmv_query_sa DBG:001 %s","OSMV_QUERY_UD_MULTICAST_SET\n" );
- sa_mad_data.attr_id = IB_MAD_ATTR_MCMEMBER_RECORD;
- sa_mad_data.attr_offset =
- ib_get_attr_offset( sizeof( ib_member_rec_t ) );
- sa_mad_data.comp_mask = p_user_query->comp_mask;
- sa_mad_data.p_attr = p_user_query->p_attr;
- break;
-
- case OSMV_QUERY_UD_MULTICAST_DELETE:
- sa_mad_data.method = IB_MAD_METHOD_DELETE;
- p_user_query = ( osmv_user_query_t * ) p_query_req->p_query_input;
- osm_log( p_log, OSM_LOG_DEBUG,
- "osmv_query_sa DBG:001 %s","OSMV_QUERY_UD_MULTICAST_DELETE\n" );
- sa_mad_data.attr_id = IB_MAD_ATTR_MCMEMBER_RECORD;
- sa_mad_data.attr_offset =
- ib_get_attr_offset( sizeof( ib_member_rec_t ) );
- sa_mad_data.comp_mask = p_user_query->comp_mask;
- sa_mad_data.p_attr = p_user_query->p_attr;
- break;
-
- default:
- osm_log( p_log, OSM_LOG_ERROR,
- "osmv_query_sa DBG:001 %s","UNKNOWN\n" );
- CL_ASSERT( 0 );
- return IB_ERROR;
- }
-
- status = __osmv_send_sa_req( h_bind, &sa_mad_data, p_query_req );
-
- OSM_LOG_EXIT( p_log );
- return status;
+ osmv_sa_bind_info_t *p_bind = (osmv_sa_bind_info_t *) h_bind;
+ osmv_sa_mad_data_t sa_mad_data;
+ osmv_user_query_t *p_user_query;
+ ib_service_record_t svc_rec;
+ ib_node_record_t node_rec;
+ ib_portinfo_record_t port_info;
+ ib_path_rec_t path_rec;
+ ib_class_port_info_t class_port_info;
+ osm_log_t *p_log = p_bind->p_log;
+ ib_api_status_t status;
+
+ OSM_LOG_ENTER(p_log, osmv_query_sa);
+
+ /* Set the request information. */
+ sa_mad_data.method = IB_MAD_METHOD_GETTABLE;
+ sa_mad_data.attr_mod = 0;
+
+ /* Set the MAD attributes and component mask correctly. */
+ switch (p_query_req->query_type) {
+
+ case OSMV_QUERY_USER_DEFINED:
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "osmv_query_sa DBG:001 %s", "USER_DEFINED\n");
+ p_user_query = (osmv_user_query_t *) p_query_req->p_query_input;
+ if (p_user_query->method)
+ sa_mad_data.method = p_user_query->method;
+ sa_mad_data.attr_offset = p_user_query->attr_offset;
+ sa_mad_data.attr_id = p_user_query->attr_id;
+ sa_mad_data.attr_mod = p_user_query->attr_mod;
+ sa_mad_data.comp_mask = p_user_query->comp_mask;
+ sa_mad_data.p_attr = p_user_query->p_attr;
+ break;
+
+ case OSMV_QUERY_ALL_SVC_RECS:
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "osmv_query_sa DBG:001 %s", "SVC_REC_BY_NAME\n");
+ sa_mad_data.method = IB_MAD_METHOD_GETTABLE;
+ sa_mad_data.attr_id = IB_MAD_ATTR_SERVICE_RECORD;
+ sa_mad_data.attr_offset =
+ ib_get_attr_offset(sizeof(ib_service_record_t));
+ sa_mad_data.comp_mask = 0;
+ sa_mad_data.p_attr = &svc_rec;
+ break;
+
+ case OSMV_QUERY_SVC_REC_BY_NAME:
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "osmv_query_sa DBG:001 %s", "SVC_REC_BY_NAME\n");
+ sa_mad_data.method = IB_MAD_METHOD_GET;
+ sa_mad_data.attr_id = IB_MAD_ATTR_SERVICE_RECORD;
+ sa_mad_data.comp_mask = IB_SR_COMPMASK_SNAME;
+ sa_mad_data.attr_offset =
+ ib_get_attr_offset(sizeof(ib_service_record_t));
+ sa_mad_data.p_attr = &svc_rec;
+ memcpy(svc_rec.service_name, p_query_req->p_query_input,
+ sizeof(ib_svc_name_t));
+ break;
+
+ case OSMV_QUERY_SVC_REC_BY_ID:
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "osmv_query_sa DBG:001 %s", "SVC_REC_BY_ID\n");
+ sa_mad_data.attr_id = IB_MAD_ATTR_SERVICE_RECORD;
+ sa_mad_data.comp_mask = IB_SR_COMPMASK_SID;
+ sa_mad_data.attr_offset =
+ ib_get_attr_offset(sizeof(ib_service_record_t));
+ sa_mad_data.p_attr = &svc_rec;
+ svc_rec.service_id =
+ *(ib_net64_t *) (p_query_req->p_query_input);
+ break;
+
+ case OSMV_QUERY_CLASS_PORT_INFO:
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "osmv_query_sa DBG:001 %s", "CLASS_PORT_INFO\n");
+ sa_mad_data.method = IB_MAD_METHOD_GET;
+ sa_mad_data.attr_id = IB_MAD_ATTR_CLASS_PORT_INFO;
+ sa_mad_data.attr_offset =
+ ib_get_attr_offset(sizeof(ib_class_port_info_t));
+ sa_mad_data.comp_mask = 0;
+ sa_mad_data.p_attr = &class_port_info;
+
+ break;
+
+ case OSMV_QUERY_NODE_REC_BY_NODE_GUID:
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "osmv_query_sa DBG:001 %s", "NODE_REC_BY_NODE_GUID\n");
+ sa_mad_data.method = IB_MAD_METHOD_GETTABLE;
+ sa_mad_data.attr_id = IB_MAD_ATTR_NODE_RECORD;
+ sa_mad_data.attr_offset =
+ ib_get_attr_offset(sizeof(ib_node_record_t));
+ sa_mad_data.comp_mask = IB_NR_COMPMASK_NODEGUID;
+ sa_mad_data.p_attr = &node_rec;
+ node_rec.node_info.node_guid =
+ *(ib_net64_t *) (p_query_req->p_query_input);
+
+ break;
+
+ case OSMV_QUERY_PORT_REC_BY_LID:
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "osmv_query_sa DBG:001 %s", "PORT_REC_BY_LID\n");
+ sa_mad_data.attr_id = IB_MAD_ATTR_PORTINFO_RECORD;
+ sa_mad_data.attr_offset =
+ ib_get_attr_offset(sizeof(ib_portinfo_record_t));
+ sa_mad_data.comp_mask = IB_PIR_COMPMASK_LID;
+ sa_mad_data.p_attr = &port_info;
+ port_info.lid = *(ib_net16_t *) (p_query_req->p_query_input);
+ break;
+
+ case OSMV_QUERY_PORT_REC_BY_LID_AND_NUM:
+ sa_mad_data.method = IB_MAD_METHOD_GET;
+ p_user_query = (osmv_user_query_t *) p_query_req->p_query_input;
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "osmv_query_sa DBG:001 %s",
+ "PORT_REC_BY_LID_AND_NUM\n");
+ sa_mad_data.attr_id = IB_MAD_ATTR_PORTINFO_RECORD;
+ sa_mad_data.attr_offset =
+ ib_get_attr_offset(sizeof(ib_portinfo_record_t));
+ sa_mad_data.comp_mask =
+ IB_PIR_COMPMASK_LID | IB_PIR_COMPMASK_PORTNUM;
+ sa_mad_data.p_attr = p_user_query->p_attr;
+ break;
+
+ case OSMV_QUERY_VLARB_BY_LID_PORT_BLOCK:
+ sa_mad_data.method = IB_MAD_METHOD_GET;
+ p_user_query = (osmv_user_query_t *) p_query_req->p_query_input;
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "osmv_query_sa DBG:001 %s",
+ "OSMV_QUERY_VLARB_BY_LID_PORT_BLOCK\n");
+ sa_mad_data.attr_id = IB_MAD_ATTR_VLARB_RECORD;
+ sa_mad_data.attr_offset =
+ ib_get_attr_offset(sizeof(ib_vl_arb_table_record_t));
+ sa_mad_data.comp_mask =
+ IB_VLA_COMPMASK_LID | IB_VLA_COMPMASK_OUT_PORT |
+ IB_VLA_COMPMASK_BLOCK;
+ sa_mad_data.p_attr = p_user_query->p_attr;
+ break;
+
+ case OSMV_QUERY_SLVL_BY_LID_AND_PORTS:
+ sa_mad_data.method = IB_MAD_METHOD_GET;
+ p_user_query = (osmv_user_query_t *) p_query_req->p_query_input;
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "osmv_query_sa DBG:001 %s",
+ "OSMV_QUERY_VLARB_BY_LID_PORT_BLOCK\n");
+ sa_mad_data.attr_id = IB_MAD_ATTR_SLVL_RECORD;
+ sa_mad_data.attr_offset =
+ ib_get_attr_offset(sizeof(ib_slvl_table_record_t));
+ sa_mad_data.comp_mask =
+ IB_SLVL_COMPMASK_LID | IB_SLVL_COMPMASK_OUT_PORT |
+ IB_SLVL_COMPMASK_IN_PORT;
+ sa_mad_data.p_attr = p_user_query->p_attr;
+ break;
+
+ case OSMV_QUERY_PATH_REC_BY_PORT_GUIDS:
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "osmv_query_sa DBG:001 %s", "PATH_REC_BY_PORT_GUIDS\n");
+ memset(&path_rec, 0, sizeof(ib_path_rec_t));
+ sa_mad_data.attr_id = IB_MAD_ATTR_PATH_RECORD;
+ sa_mad_data.attr_offset =
+ ib_get_attr_offset(sizeof(ib_path_rec_t));
+ sa_mad_data.comp_mask =
+ (IB_PR_COMPMASK_DGID | IB_PR_COMPMASK_SGID);
+ sa_mad_data.p_attr = &path_rec;
+ ib_gid_set_default(&path_rec.dgid,
+ ((osmv_guid_pair_t *) (p_query_req->
+ p_query_input))->
+ dest_guid);
+ ib_gid_set_default(&path_rec.sgid,
+ ((osmv_guid_pair_t *) (p_query_req->
+ p_query_input))->
+ src_guid);
+ break;
+
+ case OSMV_QUERY_PATH_REC_BY_GIDS:
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "osmv_query_sa DBG:001 %s", "PATH_REC_BY_GIDS\n");
+ memset(&path_rec, 0, sizeof(ib_path_rec_t));
+ sa_mad_data.attr_id = IB_MAD_ATTR_PATH_RECORD;
+ sa_mad_data.attr_offset =
+ ib_get_attr_offset(sizeof(ib_path_rec_t));
+ sa_mad_data.comp_mask =
+ (IB_PR_COMPMASK_DGID | IB_PR_COMPMASK_SGID);
+ sa_mad_data.p_attr = &path_rec;
+ memcpy(&path_rec.dgid,
+ &((osmv_gid_pair_t *) (p_query_req->p_query_input))->
+ dest_gid, sizeof(ib_gid_t));
+ memcpy(&path_rec.sgid,
+ &((osmv_gid_pair_t *) (p_query_req->p_query_input))->
+ src_gid, sizeof(ib_gid_t));
+ break;
+
+ case OSMV_QUERY_PATH_REC_BY_LIDS:
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "osmv_query_sa DBG:001 %s", "PATH_REC_BY_LIDS\n");
+ memset(&path_rec, 0, sizeof(ib_path_rec_t));
+ sa_mad_data.method = IB_MAD_METHOD_GET;
+ sa_mad_data.attr_id = IB_MAD_ATTR_PATH_RECORD;
+ sa_mad_data.attr_offset =
+ ib_get_attr_offset(sizeof(ib_path_rec_t));
+ sa_mad_data.comp_mask =
+ (IB_PR_COMPMASK_DLID | IB_PR_COMPMASK_SLID);
+ sa_mad_data.p_attr = &path_rec;
+ path_rec.dlid =
+ ((osmv_lid_pair_t *) (p_query_req->p_query_input))->
+ dest_lid;
+ path_rec.slid =
+ ((osmv_lid_pair_t *) (p_query_req->p_query_input))->src_lid;
+ break;
+
+ case OSMV_QUERY_UD_MULTICAST_SET:
+ sa_mad_data.method = IB_MAD_METHOD_SET;
+ p_user_query = (osmv_user_query_t *) p_query_req->p_query_input;
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "osmv_query_sa DBG:001 %s",
+ "OSMV_QUERY_UD_MULTICAST_SET\n");
+ sa_mad_data.attr_id = IB_MAD_ATTR_MCMEMBER_RECORD;
+ sa_mad_data.attr_offset =
+ ib_get_attr_offset(sizeof(ib_member_rec_t));
+ sa_mad_data.comp_mask = p_user_query->comp_mask;
+ sa_mad_data.p_attr = p_user_query->p_attr;
+ break;
+
+ case OSMV_QUERY_UD_MULTICAST_DELETE:
+ sa_mad_data.method = IB_MAD_METHOD_DELETE;
+ p_user_query = (osmv_user_query_t *) p_query_req->p_query_input;
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "osmv_query_sa DBG:001 %s",
+ "OSMV_QUERY_UD_MULTICAST_DELETE\n");
+ sa_mad_data.attr_id = IB_MAD_ATTR_MCMEMBER_RECORD;
+ sa_mad_data.attr_offset =
+ ib_get_attr_offset(sizeof(ib_member_rec_t));
+ sa_mad_data.comp_mask = p_user_query->comp_mask;
+ sa_mad_data.p_attr = p_user_query->p_attr;
+ break;
+
+ default:
+ osm_log(p_log, OSM_LOG_ERROR,
+ "osmv_query_sa DBG:001 %s", "UNKNOWN\n");
+ CL_ASSERT(0);
+ return IB_ERROR;
+ }
+
+ status = __osmv_send_sa_req(h_bind, &sa_mad_data, p_query_req);
+
+ OSM_LOG_EXIT(p_log);
+ return status;
}
-
/*****************************************************************************
*****************************************************************************/
-
-
diff --git a/opensm/libvendor/osm_vendor_mlx_sar.c b/opensm/libvendor/osm_vendor_mlx_sar.c
index 4108ae3..5523284 100644
--- a/opensm/libvendor/osm_vendor_mlx_sar.c
+++ b/opensm/libvendor/osm_vendor_mlx_sar.c
@@ -35,7 +35,7 @@
#if HAVE_CONFIG_H
# include <config.h>
-#endif /* HAVE_CONFIG_H */
+#endif /* HAVE_CONFIG_H */
#include <stdlib.h>
#include <string.h>
@@ -43,122 +43,112 @@
#include <vendor/osm_vendor_mlx_sar.h>
ib_api_status_t
-osmv_rmpp_sar_init(osmv_rmpp_sar_t* p_sar, void* p_arbt_mad,
- uint32_t mad_size, boolean_t is_sa_mad)
+osmv_rmpp_sar_init(osmv_rmpp_sar_t * p_sar, void *p_arbt_mad,
+ uint32_t mad_size, boolean_t is_sa_mad)
{
- CL_ASSERT(p_sar);
- p_sar->p_arbt_mad = p_arbt_mad;
- if (is_sa_mad)
- {
- p_sar->data_len = mad_size - IB_SA_MAD_HDR_SIZE;
- p_sar->hdr_sz = IB_SA_MAD_HDR_SIZE;
- p_sar->data_sz = IB_SA_DATA_SIZE;
- }
- else
- {
- p_sar->data_len = mad_size - MAD_RMPP_HDR_SIZE;
- p_sar->hdr_sz = MAD_RMPP_HDR_SIZE;
- p_sar->data_sz = MAD_RMPP_DATA_SIZE;
- }
- return IB_SUCCESS;
+ CL_ASSERT(p_sar);
+ p_sar->p_arbt_mad = p_arbt_mad;
+ if (is_sa_mad) {
+ p_sar->data_len = mad_size - IB_SA_MAD_HDR_SIZE;
+ p_sar->hdr_sz = IB_SA_MAD_HDR_SIZE;
+ p_sar->data_sz = IB_SA_DATA_SIZE;
+ } else {
+ p_sar->data_len = mad_size - MAD_RMPP_HDR_SIZE;
+ p_sar->hdr_sz = MAD_RMPP_HDR_SIZE;
+ p_sar->data_sz = MAD_RMPP_DATA_SIZE;
+ }
+ return IB_SUCCESS;
}
-
-void
-osmv_rmpp_sar_done(osmv_rmpp_sar_t* p_sar)
+void osmv_rmpp_sar_done(osmv_rmpp_sar_t * p_sar)
{
- p_sar->p_arbt_mad = NULL;
+ p_sar->p_arbt_mad = NULL;
}
-
/* the big mad should be with mad header, rmpp header ( &sa hdr) space */
ib_api_status_t
-osmv_rmpp_sar_get_mad_seg(
- IN osmv_rmpp_sar_t* p_sar,
- IN uint32_t seg_idx,
- OUT void* p_buf)
+osmv_rmpp_sar_get_mad_seg(IN osmv_rmpp_sar_t * p_sar,
+ IN uint32_t seg_idx, OUT void *p_buf)
{
- void* p_seg;
- uint32_t sz_left;
- uint32_t num_segs;
-
- CL_ASSERT(p_sar);
-
- num_segs = p_sar->data_len / p_sar->data_sz ;
- if ((p_sar->data_len % p_sar->data_sz) > 0)
- {
- num_segs++;
- }
-
- if ( (seg_idx > num_segs) && (seg_idx != 1) )
- {
- return IB_NOT_FOUND;
- }
-
- /* cleanup */
- memset(p_buf, 0, MAD_BLOCK_SIZE);
-
- /* attach header */
- memcpy(p_buf,p_sar->p_arbt_mad,p_sar->hdr_sz);
-
- /* fill data */
- p_seg = (char*)p_sar->p_arbt_mad + p_sar->hdr_sz + ((seg_idx-1) * p_sar->data_sz);
- sz_left = p_sar->data_len - ((seg_idx -1) * p_sar->data_sz);
- if (sz_left > p_sar->data_sz)
- memcpy((char*)p_buf+p_sar->hdr_sz,(char*)p_seg,p_sar->data_sz);
- else
- memcpy((char*)p_buf+ p_sar->hdr_sz, (char*)p_seg, sz_left);
-
- return IB_SUCCESS;
+ void *p_seg;
+ uint32_t sz_left;
+ uint32_t num_segs;
+
+ CL_ASSERT(p_sar);
+
+ num_segs = p_sar->data_len / p_sar->data_sz;
+ if ((p_sar->data_len % p_sar->data_sz) > 0) {
+ num_segs++;
+ }
+
+ if ((seg_idx > num_segs) && (seg_idx != 1)) {
+ return IB_NOT_FOUND;
+ }
+
+ /* cleanup */
+ memset(p_buf, 0, MAD_BLOCK_SIZE);
+
+ /* attach header */
+ memcpy(p_buf, p_sar->p_arbt_mad, p_sar->hdr_sz);
+
+ /* fill data */
+ p_seg =
+ (char *)p_sar->p_arbt_mad + p_sar->hdr_sz +
+ ((seg_idx - 1) * p_sar->data_sz);
+ sz_left = p_sar->data_len - ((seg_idx - 1) * p_sar->data_sz);
+ if (sz_left > p_sar->data_sz)
+ memcpy((char *)p_buf + p_sar->hdr_sz, (char *)p_seg,
+ p_sar->data_sz);
+ else
+ memcpy((char *)p_buf + p_sar->hdr_sz, (char *)p_seg, sz_left);
+
+ return IB_SUCCESS;
}
-
/* turns a list of mads to one big mad - including header */
/* ALSO - deallocates the list */
ib_api_status_t
-osmv_rmpp_sar_reassemble_arbt_mad(osmv_rmpp_sar_t* p_sar, cl_qlist_t* p_bufs)
+osmv_rmpp_sar_reassemble_arbt_mad(osmv_rmpp_sar_t * p_sar, cl_qlist_t * p_bufs)
{
- void* buf_tmp,*p_mad;
- cl_list_item_t* p_item;
- cl_list_obj_t* p_obj;
- uint32_t space_left = p_sar->data_len + p_sar->hdr_sz;
-
- CL_ASSERT(p_sar);
- CL_ASSERT(FALSE == cl_is_qlist_empty(p_bufs));
-
- /* attach header */
- p_mad = p_sar->p_arbt_mad;
- p_item = cl_qlist_head(p_bufs);
- p_obj = PARENT_STRUCT(p_item, cl_list_obj_t, list_item);
- buf_tmp = cl_qlist_obj(p_obj);
- memcpy(p_mad,buf_tmp,p_sar->hdr_sz);
- p_mad = (char*)p_mad + p_sar->hdr_sz;
- space_left-= p_sar->hdr_sz;
-
- /* reassemble data */
- while (FALSE == cl_is_qlist_empty(p_bufs)) {
-
- p_item = cl_qlist_remove_head(p_bufs);
- p_obj = PARENT_STRUCT(p_item, cl_list_obj_t, list_item);
- buf_tmp = cl_qlist_obj(p_obj);
-
- if (FALSE == cl_is_qlist_empty(p_bufs))
- {
- memcpy((char*)p_mad,(char*)buf_tmp+p_sar->hdr_sz,p_sar->data_sz);
- p_mad = (char*)p_mad + p_sar->data_sz;
- space_left-= p_sar->data_sz;
- }
- else
- {
- /* the last mad on the list */
- memcpy((char*)p_mad,(char*)buf_tmp+p_sar->hdr_sz,space_left);
- p_mad= (char*)p_mad+space_left;
- }
-
- free(buf_tmp);
- free(p_obj);
- }
-
- return IB_SUCCESS;
+ void *buf_tmp, *p_mad;
+ cl_list_item_t *p_item;
+ cl_list_obj_t *p_obj;
+ uint32_t space_left = p_sar->data_len + p_sar->hdr_sz;
+
+ CL_ASSERT(p_sar);
+ CL_ASSERT(FALSE == cl_is_qlist_empty(p_bufs));
+
+ /* attach header */
+ p_mad = p_sar->p_arbt_mad;
+ p_item = cl_qlist_head(p_bufs);
+ p_obj = PARENT_STRUCT(p_item, cl_list_obj_t, list_item);
+ buf_tmp = cl_qlist_obj(p_obj);
+ memcpy(p_mad, buf_tmp, p_sar->hdr_sz);
+ p_mad = (char *)p_mad + p_sar->hdr_sz;
+ space_left -= p_sar->hdr_sz;
+
+ /* reassemble data */
+ while (FALSE == cl_is_qlist_empty(p_bufs)) {
+
+ p_item = cl_qlist_remove_head(p_bufs);
+ p_obj = PARENT_STRUCT(p_item, cl_list_obj_t, list_item);
+ buf_tmp = cl_qlist_obj(p_obj);
+
+ if (FALSE == cl_is_qlist_empty(p_bufs)) {
+ memcpy((char *)p_mad, (char *)buf_tmp + p_sar->hdr_sz,
+ p_sar->data_sz);
+ p_mad = (char *)p_mad + p_sar->data_sz;
+ space_left -= p_sar->data_sz;
+ } else {
+ /* the last mad on the list */
+ memcpy((char *)p_mad, (char *)buf_tmp + p_sar->hdr_sz,
+ space_left);
+ p_mad = (char *)p_mad + space_left;
+ }
+
+ free(buf_tmp);
+ free(p_obj);
+ }
+
+ return IB_SUCCESS;
}
-
diff --git a/opensm/libvendor/osm_vendor_mlx_sender.c b/opensm/libvendor/osm_vendor_mlx_sender.c
index 624d3ee..5542e64 100644
--- a/opensm/libvendor/osm_vendor_mlx_sender.c
+++ b/opensm/libvendor/osm_vendor_mlx_sender.c
@@ -35,7 +35,7 @@
#if HAVE_CONFIG_H
# include <config.h>
-#endif /* HAVE_CONFIG_H */
+#endif /* HAVE_CONFIG_H */
#include <string.h>
#include <vendor/osm_vendor_mlx_sender.h>
@@ -44,9 +44,8 @@
#include <vendor/osm_pkt_randomizer.h>
static ib_api_status_t
-__osmv_rmpp_send_segment(IN osm_bind_handle_t h_bind,
- IN osmv_txn_ctx_t *p_txn,
- IN uint32_t seg_num);
+__osmv_rmpp_send_segment(IN osm_bind_handle_t h_bind,
+ IN osmv_txn_ctx_t * p_txn, IN uint32_t seg_num);
/****d* OSM Vendor/osmv_simple_send_madw
* NAME
@@ -62,67 +61,60 @@ __osmv_rmpp_send_segment(IN osm_bind_handle_t h_bind,
ib_api_status_t
osmv_simple_send_madw(IN osm_bind_handle_t h_bind,
- IN osm_madw_t *const p_madw,
- IN osmv_txn_ctx_t *p_txn,
- IN boolean_t is_retry)
+ IN osm_madw_t * const p_madw,
+ IN osmv_txn_ctx_t * p_txn, IN boolean_t is_retry)
{
- ib_api_status_t ret;
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t*)h_bind;
- osm_mad_addr_t *p_mad_addr = osm_madw_get_mad_addr_ptr(p_madw);
- uint8_t mad_buf[MAD_BLOCK_SIZE];
- ib_mad_t *p_mad = (ib_mad_t*)mad_buf;
- uint64_t key = 0;
-
- OSM_LOG_ENTER(p_bo->p_vendor->p_log, osmv_simple_send_madw);
-
- CL_ASSERT( p_madw->mad_size <= MAD_BLOCK_SIZE );
-
- memset(p_mad, 0, MAD_BLOCK_SIZE);
- memcpy(p_mad, osm_madw_get_mad_ptr(p_madw), p_madw->mad_size);
-
- if (NULL != p_txn)
- {
- /* Push a fake txn id to the MAD */
- key = osmv_txn_get_key(p_txn);
- p_mad->trans_id = cl_hton64(key);
- }
-
- /*
- Add call for packet drop randomizer.
- This is a testing feature. If run_randomizer flag is set to TRUE,
- the randomizer will be called, and randomally will drop
- a packet. This is used for simulating unstable fabric.
- */
- if ( p_bo->p_vendor->run_randomizer == TRUE )
- {
- /* Try the randomizer */
- if ( osm_pkt_randomizer_mad_drop( p_bo->p_vendor->p_log,
- p_bo->p_vendor->p_pkt_randomizer,
- p_mad ) == TRUE )
- {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "The MAD will not be sent. \n" );
- ret = IB_SUCCESS;
- }
- else
- {
- ret = osmv_transport_mad_send(h_bind, p_mad, p_mad_addr);
- }
- }
- else
- {
- ret = osmv_transport_mad_send(h_bind, p_mad, p_mad_addr);
- }
-
- if ((IB_SUCCESS == ret) && (NULL != p_txn) && (! is_retry))
- {
- /* Set the timeout for receiving the response MAD */
- ret = osmv_txn_set_timeout_ev(h_bind, key,
- p_bo->p_vendor->resp_timeout);
- }
-
- OSM_LOG_EXIT(p_bo->p_vendor->p_log);
- return ret;
+ ib_api_status_t ret;
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ osm_mad_addr_t *p_mad_addr = osm_madw_get_mad_addr_ptr(p_madw);
+ uint8_t mad_buf[MAD_BLOCK_SIZE];
+ ib_mad_t *p_mad = (ib_mad_t *) mad_buf;
+ uint64_t key = 0;
+
+ OSM_LOG_ENTER(p_bo->p_vendor->p_log, osmv_simple_send_madw);
+
+ CL_ASSERT(p_madw->mad_size <= MAD_BLOCK_SIZE);
+
+ memset(p_mad, 0, MAD_BLOCK_SIZE);
+ memcpy(p_mad, osm_madw_get_mad_ptr(p_madw), p_madw->mad_size);
+
+ if (NULL != p_txn) {
+ /* Push a fake txn id to the MAD */
+ key = osmv_txn_get_key(p_txn);
+ p_mad->trans_id = cl_hton64(key);
+ }
+
+ /*
+ Add call for packet drop randomizer.
+ This is a testing feature. If run_randomizer flag is set to TRUE,
+ the randomizer will be called, and randomally will drop
+ a packet. This is used for simulating unstable fabric.
+ */
+ if (p_bo->p_vendor->run_randomizer == TRUE) {
+ /* Try the randomizer */
+ if (osm_pkt_randomizer_mad_drop(p_bo->p_vendor->p_log,
+ p_bo->p_vendor->
+ p_pkt_randomizer,
+ p_mad) == TRUE) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "The MAD will not be sent. \n");
+ ret = IB_SUCCESS;
+ } else {
+ ret =
+ osmv_transport_mad_send(h_bind, p_mad, p_mad_addr);
+ }
+ } else {
+ ret = osmv_transport_mad_send(h_bind, p_mad, p_mad_addr);
+ }
+
+ if ((IB_SUCCESS == ret) && (NULL != p_txn) && (!is_retry)) {
+ /* Set the timeout for receiving the response MAD */
+ ret = osmv_txn_set_timeout_ev(h_bind, key,
+ p_bo->p_vendor->resp_timeout);
+ }
+
+ OSM_LOG_EXIT(p_bo->p_vendor->p_log);
+ return ret;
}
/***** OSM Vendor/osmv_rmpp_send_madw
@@ -143,110 +135,107 @@ osmv_simple_send_madw(IN osm_bind_handle_t h_bind,
ib_api_status_t
osmv_rmpp_send_madw(IN osm_bind_handle_t h_bind,
- IN osm_madw_t *const p_madw,
- IN osmv_txn_ctx_t *p_txn,
- IN boolean_t is_rmpp_ds)
+ IN osm_madw_t * const p_madw,
+ IN osmv_txn_ctx_t * p_txn, IN boolean_t is_rmpp_ds)
{
- ib_api_status_t ret=IB_SUCCESS;
- uint32_t i, total_segs;
-
- osmv_rmpp_send_ctx_t *p_send_ctx = osmv_txn_get_rmpp_send_ctx(p_txn);
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t*)h_bind;
-
- OSM_LOG_ENTER(p_bo->p_vendor->p_log, osmv_rmpp_send_madw);
-
- total_segs = osmv_rmpp_send_ctx_get_num_segs(p_send_ctx);
- CL_ASSERT(total_segs >= 1);
-
- /* In the double-sided transfer, wait for ACK 0 */
-
- for (;;) {
-
- if (p_send_ctx->window_first > total_segs)
- {
-
- /* Every segment is acknowledged */
- break;
- }
-
- /* Send the next burst. */
- for (i = p_send_ctx->window_first; i <= p_send_ctx->window_last; i++) {
-
- /* Send a segment and setup a timeout timer */
- ret = __osmv_rmpp_send_segment(h_bind, p_txn, i);
- if (IB_SUCCESS != ret)
- {
- goto send_done;
- }
- }
-
- /* Set the Response Timeout for the ACK on the last DATA segment */
- ret = osmv_txn_set_timeout_ev(h_bind, osmv_txn_get_key(p_txn),
- p_bo->p_vendor->resp_timeout);
- if (IB_SUCCESS != ret)
- {
- goto send_done;
- }
-
- /* Going to sleep. Let the others access the transaction DB */
- osmv_txn_unlock(p_bo);
-
- osm_log( p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "RMPP Sender thread (madw=%p) going to sleep ...\n", p_madw);
-
- /* Await the next event to happen */
- cl_event_wait_on(&p_send_ctx->event,
- EVENT_NO_TIMEOUT,
- TRUE /* interruptible */);
-
- /* Got a signal from the MAD dispatcher/timeout handler */
- osm_log( p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "RMPP Sender thread (madw=%p) waking up on a signal ...\n", p_madw);
-
- /* Let's see what changed... Make this atomic - re-acquire the lock. */
- osmv_txn_lock(p_bo);
-
- if (TRUE == p_bo->is_closing)
- {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "osmv_rmpp_send_madw: ERR 6601: "
- "The bind handle %p is being closed. "
- "Stopping the RMPP Send of MADW %p\n",
- h_bind, p_madw);
-
- ret = IB_TIMEOUT;
- return IB_INTERRUPTED;
- }
-
- /* STOP? ABORT? TIMEOUT? */
- if (IB_SUCCESS != p_send_ctx->status)
- {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "osmv_rmpp_send_madw: ERR 6602: "
- "An error (%s) happened during the RMPP send of %p. Bailing out.\n",
- ib_get_err_str(p_send_ctx->status), p_madw);
- ret = p_send_ctx->status;
- goto send_done;
- }
- }
-
- if (TRUE == is_rmpp_ds)
- {
- osm_log( p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "Double-sided RMPP - switching to be the receiver.\n");
-
- ret = osmv_txn_init_rmpp_receiver(h_bind, p_txn, FALSE/*Send was initiated by me*/);
-
- if (IB_SUCCESS == ret)
- {
- /* Send ACK on the 0 segment */
- ret = __osmv_rmpp_send_segment(h_bind, p_txn, 0);
- }
- }
-
- send_done:
- OSM_LOG_EXIT(p_bo->p_vendor->p_log);
- return ret;
+ ib_api_status_t ret = IB_SUCCESS;
+ uint32_t i, total_segs;
+
+ osmv_rmpp_send_ctx_t *p_send_ctx = osmv_txn_get_rmpp_send_ctx(p_txn);
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+
+ OSM_LOG_ENTER(p_bo->p_vendor->p_log, osmv_rmpp_send_madw);
+
+ total_segs = osmv_rmpp_send_ctx_get_num_segs(p_send_ctx);
+ CL_ASSERT(total_segs >= 1);
+
+ /* In the double-sided transfer, wait for ACK 0 */
+
+ for (;;) {
+
+ if (p_send_ctx->window_first > total_segs) {
+
+ /* Every segment is acknowledged */
+ break;
+ }
+
+ /* Send the next burst. */
+ for (i = p_send_ctx->window_first; i <= p_send_ctx->window_last;
+ i++) {
+
+ /* Send a segment and setup a timeout timer */
+ ret = __osmv_rmpp_send_segment(h_bind, p_txn, i);
+ if (IB_SUCCESS != ret) {
+ goto send_done;
+ }
+ }
+
+ /* Set the Response Timeout for the ACK on the last DATA segment */
+ ret = osmv_txn_set_timeout_ev(h_bind, osmv_txn_get_key(p_txn),
+ p_bo->p_vendor->resp_timeout);
+ if (IB_SUCCESS != ret) {
+ goto send_done;
+ }
+
+ /* Going to sleep. Let the others access the transaction DB */
+ osmv_txn_unlock(p_bo);
+
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "RMPP Sender thread (madw=%p) going to sleep ...\n",
+ p_madw);
+
+ /* Await the next event to happen */
+ cl_event_wait_on(&p_send_ctx->event,
+ EVENT_NO_TIMEOUT, TRUE /* interruptible */ );
+
+ /* Got a signal from the MAD dispatcher/timeout handler */
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "RMPP Sender thread (madw=%p) waking up on a signal ...\n",
+ p_madw);
+
+ /* Let's see what changed... Make this atomic - re-acquire the lock. */
+ osmv_txn_lock(p_bo);
+
+ if (TRUE == p_bo->is_closing) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "osmv_rmpp_send_madw: ERR 6601: "
+ "The bind handle %p is being closed. "
+ "Stopping the RMPP Send of MADW %p\n",
+ h_bind, p_madw);
+
+ ret = IB_TIMEOUT;
+ return IB_INTERRUPTED;
+ }
+
+ /* STOP? ABORT? TIMEOUT? */
+ if (IB_SUCCESS != p_send_ctx->status) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "osmv_rmpp_send_madw: ERR 6602: "
+ "An error (%s) happened during the RMPP send of %p. Bailing out.\n",
+ ib_get_err_str(p_send_ctx->status), p_madw);
+ ret = p_send_ctx->status;
+ goto send_done;
+ }
+ }
+
+ if (TRUE == is_rmpp_ds) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "Double-sided RMPP - switching to be the receiver.\n");
+
+ ret =
+ osmv_txn_init_rmpp_receiver(h_bind, p_txn,
+ FALSE
+ /*Send was initiated by me */ );
+
+ if (IB_SUCCESS == ret) {
+ /* Send ACK on the 0 segment */
+ ret = __osmv_rmpp_send_segment(h_bind, p_txn, 0);
+ }
+ }
+
+ send_done:
+ OSM_LOG_EXIT(p_bo->p_vendor->p_log);
+ return ret;
}
/*
@@ -257,33 +246,32 @@ osmv_rmpp_send_madw(IN osm_bind_handle_t h_bind,
*/
ib_api_status_t
-osmv_rmpp_send_ack(IN osm_bind_handle_t h_bind,
- IN const ib_mad_t *p_req_mad,
- IN uint32_t seg_num,
- IN uint32_t nwl,
- IN const osm_mad_addr_t *p_mad_addr)
+osmv_rmpp_send_ack(IN osm_bind_handle_t h_bind,
+ IN const ib_mad_t * p_req_mad,
+ IN uint32_t seg_num,
+ IN uint32_t nwl, IN const osm_mad_addr_t * p_mad_addr)
{
- uint8_t resp_mad[MAD_BLOCK_SIZE];
- ib_rmpp_mad_t *p_resp_mad = (ib_rmpp_mad_t*)resp_mad;
+ uint8_t resp_mad[MAD_BLOCK_SIZE];
+ ib_rmpp_mad_t *p_resp_mad = (ib_rmpp_mad_t *) resp_mad;
#ifdef OSMV_RANDOM_DROP
- if (TRUE == osmv_random_drop())
- {
- osm_log(((osmv_bind_obj_t*)h_bind)->p_vendor->p_log, OSM_LOG_DEBUG,
- "Error injection - dropping the RMPP ACK\n");
- return IB_SUCCESS;
- }
+ if (TRUE == osmv_random_drop()) {
+ osm_log(((osmv_bind_obj_t *) h_bind)->p_vendor->p_log,
+ OSM_LOG_DEBUG,
+ "Error injection - dropping the RMPP ACK\n");
+ return IB_SUCCESS;
+ }
#endif
- memcpy(p_resp_mad, p_req_mad, MAD_BLOCK_SIZE);
+ memcpy(p_resp_mad, p_req_mad, MAD_BLOCK_SIZE);
- p_resp_mad->common_hdr.method = osmv_invert_method(p_req_mad->method);
- p_resp_mad->rmpp_type = IB_RMPP_TYPE_ACK;
- p_resp_mad->seg_num = cl_hton32(seg_num);
- p_resp_mad->paylen_newwin = cl_hton32(nwl);
- p_resp_mad->rmpp_flags = IB_RMPP_FLAG_ACTIVE;
+ p_resp_mad->common_hdr.method = osmv_invert_method(p_req_mad->method);
+ p_resp_mad->rmpp_type = IB_RMPP_TYPE_ACK;
+ p_resp_mad->seg_num = cl_hton32(seg_num);
+ p_resp_mad->paylen_newwin = cl_hton32(nwl);
+ p_resp_mad->rmpp_flags = IB_RMPP_FLAG_ACTIVE;
- return osmv_transport_mad_send(h_bind, p_resp_mad, p_mad_addr);
+ return osmv_transport_mad_send(h_bind, p_resp_mad, p_mad_addr);
}
/*
@@ -293,22 +281,21 @@ osmv_rmpp_send_ack(IN osm_bind_handle_t h_bind,
*/
ib_api_status_t
-osmv_rmpp_send_nak(IN osm_bind_handle_t h_bind,
- IN const ib_mad_t *p_req_mad,
- IN const osm_mad_addr_t *p_mad_addr,
- IN uint8_t nak_type,
- IN uint8_t status)
+osmv_rmpp_send_nak(IN osm_bind_handle_t h_bind,
+ IN const ib_mad_t * p_req_mad,
+ IN const osm_mad_addr_t * p_mad_addr,
+ IN uint8_t nak_type, IN uint8_t status)
{
- uint8_t resp_mad[MAD_BLOCK_SIZE];
- ib_rmpp_mad_t *p_resp_mad = (ib_rmpp_mad_t*)resp_mad;
+ uint8_t resp_mad[MAD_BLOCK_SIZE];
+ ib_rmpp_mad_t *p_resp_mad = (ib_rmpp_mad_t *) resp_mad;
- memcpy(p_resp_mad, p_req_mad, MAD_BLOCK_SIZE);
+ memcpy(p_resp_mad, p_req_mad, MAD_BLOCK_SIZE);
- p_resp_mad->common_hdr.method = osmv_invert_method(p_req_mad->method);
- p_resp_mad->rmpp_type = nak_type;
- p_resp_mad->rmpp_status = status;
+ p_resp_mad->common_hdr.method = osmv_invert_method(p_req_mad->method);
+ p_resp_mad->rmpp_type = nak_type;
+ p_resp_mad->rmpp_status = status;
- return osmv_transport_mad_send(h_bind, p_resp_mad, p_mad_addr);
+ return osmv_transport_mad_send(h_bind, p_resp_mad, p_mad_addr);
}
/*
@@ -318,86 +305,87 @@ osmv_rmpp_send_nak(IN osm_bind_handle_t h_bind,
*/
static ib_api_status_t
-__osmv_rmpp_send_segment(IN osm_bind_handle_t h_bind,
- IN osmv_txn_ctx_t *p_txn,
- IN uint32_t seg_num)
+__osmv_rmpp_send_segment(IN osm_bind_handle_t h_bind,
+ IN osmv_txn_ctx_t * p_txn, IN uint32_t seg_num)
{
- ib_api_status_t ret;
- osmv_rmpp_send_ctx_t *p_send_ctx;
- uint8_t mad_buf[MAD_BLOCK_SIZE];
- ib_mad_t *p_mad = (ib_mad_t*)mad_buf;
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t*)h_bind;
- osm_mad_addr_t *p_mad_addr = osm_madw_get_mad_addr_ptr(osmv_txn_get_madw(p_txn));
- uint32_t timeout = p_bo->p_vendor->resp_timeout;
- uint64_t key;
-
- OSM_LOG_ENTER(p_bo->p_vendor->p_log, __osmv_rmpp_send_segment);
+ ib_api_status_t ret;
+ osmv_rmpp_send_ctx_t *p_send_ctx;
+ uint8_t mad_buf[MAD_BLOCK_SIZE];
+ ib_mad_t *p_mad = (ib_mad_t *) mad_buf;
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ osm_mad_addr_t *p_mad_addr =
+ osm_madw_get_mad_addr_ptr(osmv_txn_get_madw(p_txn));
+ uint32_t timeout = p_bo->p_vendor->resp_timeout;
+ uint64_t key;
+
+ OSM_LOG_ENTER(p_bo->p_vendor->p_log, __osmv_rmpp_send_segment);
#ifdef OSMV_RANDOM_DROP
- if (TRUE == osmv_random_drop())
- {
+ if (TRUE == osmv_random_drop()) {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "Error injection - simulating the RMPP segment drop\n");
- return IB_SUCCESS;
- }
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "Error injection - simulating the RMPP segment drop\n");
+ return IB_SUCCESS;
+ }
#endif
- p_send_ctx = osmv_txn_get_rmpp_send_ctx(p_txn);
- key = osmv_txn_get_key(p_txn);
-
- if (0 != seg_num)
- {
- ret = osmv_rmpp_send_ctx_get_seg(p_send_ctx, seg_num, timeout, p_mad);
- CL_ASSERT(IB_SUCCESS == ret);
-
- /* Put the segment to the wire ! */
- p_mad->trans_id = cl_hton64(key);
-
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "Sending RMPP segment #%d, on-wire TID=0x%llX\n",
- seg_num, p_mad->trans_id);
-
- /*
- Add call for packet drop randomizer.
- This is a testing feature. If run_randomizer flag is set to TRUE,
- the randomizer will be called, and randomally will drop
- a packet. This is used for simulating unstable fabric.
- */
- if ( p_bo->p_vendor->run_randomizer == TRUE )
- {
- /* Try the randomizer */
- if ( osm_pkt_randomizer_mad_drop( p_bo->p_vendor->p_log,
- p_bo->p_vendor->p_pkt_randomizer,
- p_mad ) == TRUE )
- {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "The MAD will not be sent. \n" );
- ret = IB_SUCCESS;
- }
- else
- {
- ret = osmv_transport_mad_send((osm_bind_handle_t)p_bo, p_mad, p_mad_addr);
- }
- }
- else
- {
- ret = osmv_transport_mad_send((osm_bind_handle_t)p_bo, p_mad, p_mad_addr);
- }
- }
- else
- {
- /* This is an ACK for double-sided handshake. Give it a special treatment. */
-
- /* It doesn't really matter which data to put. Only the header matters. */
- ret = osmv_rmpp_send_ctx_get_seg(p_send_ctx, 1, timeout, p_mad);
- CL_ASSERT(IB_SUCCESS == ret);
-
- p_mad->trans_id = cl_hton64(key);
- ret = osmv_rmpp_send_ack((osm_bind_handle_t)p_bo, p_mad, 0 /* segnum */,
- OSMV_RMPP_RECV_WIN /* NWL */, p_mad_addr);
- }
-
- OSM_LOG_EXIT(p_bo->p_vendor->p_log);
- return ret;
+ p_send_ctx = osmv_txn_get_rmpp_send_ctx(p_txn);
+ key = osmv_txn_get_key(p_txn);
+
+ if (0 != seg_num) {
+ ret =
+ osmv_rmpp_send_ctx_get_seg(p_send_ctx, seg_num, timeout,
+ p_mad);
+ CL_ASSERT(IB_SUCCESS == ret);
+
+ /* Put the segment to the wire ! */
+ p_mad->trans_id = cl_hton64(key);
+
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "Sending RMPP segment #%d, on-wire TID=0x%llX\n",
+ seg_num, p_mad->trans_id);
+
+ /*
+ Add call for packet drop randomizer.
+ This is a testing feature. If run_randomizer flag is set to TRUE,
+ the randomizer will be called, and randomally will drop
+ a packet. This is used for simulating unstable fabric.
+ */
+ if (p_bo->p_vendor->run_randomizer == TRUE) {
+ /* Try the randomizer */
+ if (osm_pkt_randomizer_mad_drop(p_bo->p_vendor->p_log,
+ p_bo->p_vendor->
+ p_pkt_randomizer,
+ p_mad) == TRUE) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "The MAD will not be sent. \n");
+ ret = IB_SUCCESS;
+ } else {
+ ret =
+ osmv_transport_mad_send((osm_bind_handle_t)
+ p_bo, p_mad,
+ p_mad_addr);
+ }
+ } else {
+ ret =
+ osmv_transport_mad_send((osm_bind_handle_t) p_bo,
+ p_mad, p_mad_addr);
+ }
+ } else {
+ /* This is an ACK for double-sided handshake. Give it a special treatment. */
+
+ /* It doesn't really matter which data to put. Only the header matters. */
+ ret = osmv_rmpp_send_ctx_get_seg(p_send_ctx, 1, timeout, p_mad);
+ CL_ASSERT(IB_SUCCESS == ret);
+
+ p_mad->trans_id = cl_hton64(key);
+ ret =
+ osmv_rmpp_send_ack((osm_bind_handle_t) p_bo, p_mad,
+ 0 /* segnum */ ,
+ OSMV_RMPP_RECV_WIN /* NWL */ ,
+ p_mad_addr);
+ }
+
+ OSM_LOG_EXIT(p_bo->p_vendor->p_log);
+ return ret;
}
diff --git a/opensm/libvendor/osm_vendor_mlx_sim.c b/opensm/libvendor/osm_vendor_mlx_sim.c
index 6159525..6d57c63 100644
--- a/opensm/libvendor/osm_vendor_mlx_sim.c
+++ b/opensm/libvendor/osm_vendor_mlx_sim.c
@@ -43,7 +43,7 @@
#if HAVE_CONFIG_H
# include <config.h>
-#endif /* HAVE_CONFIG_H */
+#endif /* HAVE_CONFIG_H */
#include <sys/types.h>
#include <sys/stat.h>
@@ -63,76 +63,79 @@
#include <ibmgtsim/ibms_client_api.h>
typedef struct _osmv_ibms_transport_mgr {
- ibms_conn_handle_t conHdl; /* the connection handle we talk to */
- ibms_bind_msg_t filter; /* the bind message defining the filtering */
- cl_thread_t receiver; /* the thread waiting for incomming messages */
+ ibms_conn_handle_t conHdl; /* the connection handle we talk to */
+ ibms_bind_msg_t filter; /* the bind message defining the filtering */
+ cl_thread_t receiver; /* the thread waiting for incomming messages */
} osmv_ibms_transport_mgr_t;
static void
-__osmv_ibms_mad_addr_to_osm_addr(
- IN osm_vendor_t const * p_vend,
- IN struct _ibms_mad_addr *p_ibms_addr,
- IN uint8_t is_smi,
- OUT osm_mad_addr_t *p_osm_addr);
+__osmv_ibms_mad_addr_to_osm_addr(IN osm_vendor_t const *p_vend,
+ IN struct _ibms_mad_addr *p_ibms_addr,
+ IN uint8_t is_smi,
+ OUT osm_mad_addr_t * p_osm_addr);
static void
-__osmv_ibms_osm_addr_to_mad_addr(
- IN const osm_mad_addr_t *p_osm_addr,
- IN uint8_t is_smi,
- OUT struct _ibms_mad_addr *p_ibms_addr);
+__osmv_ibms_osm_addr_to_mad_addr(IN const osm_mad_addr_t * p_osm_addr,
+ IN uint8_t is_smi,
+ OUT struct _ibms_mad_addr *p_ibms_addr);
/* this is the callback function the "server" will call on incoming
messages */
-void
-__osmv_ibms_receiver_callback(void* p_ctx, ibms_mad_msg_t *p_mad)
+void __osmv_ibms_receiver_callback(void *p_ctx, ibms_mad_msg_t * p_mad)
{
- osm_mad_addr_t mad_addr;
- osmv_bind_obj_t * const p_bo = (osmv_bind_obj_t *)p_ctx;
- ib_api_status_t status = IB_SUCCESS;
-
- /* Make sure the p_bo object is still relevant */
- if ( (p_bo->magic_ptr != p_bo) || p_bo->is_closing )
- return;
-
- {
- OSM_LOG_ENTER( p_bo->p_vendor->p_log, __osmv_ibms_receiver_callback );
-
-
- /* some logging */
- osm_log( p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "__osmv_ibms_receiver_callback: "
- "MAD QPN:%d SLID:0x%04x class:0x%02x "
- "method:0x%02x attr:0x%04x status:0x%04x "
- "tid:0x%016" PRIx64 "\n",
- p_mad->addr.dqpn,
- cl_ntoh16(p_mad->addr.slid),
- p_mad->header.mgmt_class,
- p_mad->header.method,
- cl_ntoh16(p_mad->header.attr_id),
- cl_ntoh16(p_mad->header.status),
- cl_ntoh64(p_mad->header.trans_id));
-
- /* first arrange an address */
- __osmv_ibms_mad_addr_to_osm_addr(
- p_bo->p_vendor,
- &p_mad->addr,
- ( ((ib_mad_t*)&p_mad->header)->mgmt_class == IB_MCLASS_SUBN_LID ) ||
- ( ((ib_mad_t*)&p_mad->header)->mgmt_class == IB_MCLASS_SUBN_DIR ),
- &mad_addr);
-
- /* call the receiver callback */
-
- status = osmv_dispatch_mad((osm_bind_handle_t)p_bo,(void*)&p_mad->header, &mad_addr);
-
- OSM_LOG_EXIT( p_bo->p_vendor->p_log );
- }
+ osm_mad_addr_t mad_addr;
+ osmv_bind_obj_t *const p_bo = (osmv_bind_obj_t *) p_ctx;
+ ib_api_status_t status = IB_SUCCESS;
+
+ /* Make sure the p_bo object is still relevant */
+ if ((p_bo->magic_ptr != p_bo) || p_bo->is_closing)
+ return;
+
+ {
+ OSM_LOG_ENTER(p_bo->p_vendor->p_log,
+ __osmv_ibms_receiver_callback);
+
+ /* some logging */
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "__osmv_ibms_receiver_callback: "
+ "MAD QPN:%d SLID:0x%04x class:0x%02x "
+ "method:0x%02x attr:0x%04x status:0x%04x "
+ "tid:0x%016" PRIx64 "\n",
+ p_mad->addr.dqpn,
+ cl_ntoh16(p_mad->addr.slid),
+ p_mad->header.mgmt_class,
+ p_mad->header.method,
+ cl_ntoh16(p_mad->header.attr_id),
+ cl_ntoh16(p_mad->header.status),
+ cl_ntoh64(p_mad->header.trans_id));
+
+ /* first arrange an address */
+ __osmv_ibms_mad_addr_to_osm_addr(p_bo->p_vendor,
+ &p_mad->addr,
+ (((ib_mad_t *) & p_mad->
+ header)->mgmt_class ==
+ IB_MCLASS_SUBN_LID)
+ ||
+ (((ib_mad_t *) & p_mad->
+ header)->mgmt_class ==
+ IB_MCLASS_SUBN_DIR),
+ &mad_addr);
+
+ /* call the receiver callback */
+
+ status =
+ osmv_dispatch_mad((osm_bind_handle_t) p_bo,
+ (void *)&p_mad->header, &mad_addr);
+
+ OSM_LOG_EXIT(p_bo->p_vendor->p_log);
+ }
}
ib_api_status_t
-osm_vendor_get_guid_by_ca_and_port( IN osm_vendor_t * const p_vend,
- IN char *hca_id,
- IN uint32_t port_num,
- OUT uint64_t *p_port_guid);
+osm_vendor_get_guid_by_ca_and_port(IN osm_vendor_t * const p_vend,
+ IN char *hca_id,
+ IN uint32_t port_num,
+ OUT uint64_t * p_port_guid);
/*
* NAME
@@ -143,98 +146,90 @@ osm_vendor_get_guid_by_ca_and_port( IN osm_vendor_t * const p_vend,
*/
ib_api_status_t
-osmv_transport_init(IN osm_bind_info_t *p_info,
- IN char hca_id[VENDOR_HCA_MAXNAMES],
- IN uint8_t hca_idx,
- IN osmv_bind_obj_t *p_bo)
+osmv_transport_init(IN osm_bind_info_t * p_info,
+ IN char hca_id[VENDOR_HCA_MAXNAMES],
+ IN uint8_t hca_idx, IN osmv_bind_obj_t * p_bo)
{
- ibms_conn_handle_t conHdl; /* the connection we talk to the simulator through */
- osmv_ibms_transport_mgr_t* p_mgr = malloc(sizeof(osmv_ibms_transport_mgr_t));
- int qpn;
- int ibms_status;
- uint64_t port_guid;
-
- if (!p_mgr)
- {
- return IB_INSUFFICIENT_MEMORY;
- }
-
- memset(p_mgr, 0, sizeof(osmv_ibms_transport_mgr_t));
-
- /* create the client socket connected to the simulator */
- /* also perform the "connect" message - such that we
- validate the target guid */
- if (osm_vendor_get_guid_by_ca_and_port(
- p_bo->p_vendor, hca_id, p_bo->port_num, &port_guid))
- {
- return IB_INVALID_GUID;
- }
-
- conHdl =
- ibms_connect(port_guid, __osmv_ibms_receiver_callback, (void*)p_bo);
- if (!conHdl)
- {
- printf("fail to connect to the server.\n");
- exit(1);
- }
-
- /*
- * Create the MAD filter on this file handle.
- */
-
- p_mgr->filter.port = p_bo->port_num;
- p_mgr->filter.only_input = 1;
- p_mgr->filter.mask =
- IBMS_BIND_MASK_PORT |
- IBMS_BIND_MASK_INPUT |
- IBMS_BIND_MASK_QP |
- IBMS_BIND_MASK_CLASS ;
-
- switch ( p_info->mad_class )
- {
- case IB_MCLASS_SUBN_LID:
- case IB_MCLASS_SUBN_DIR:
- qpn = 0;
- p_mgr->filter.qpn = qpn;
- p_mgr->filter.mgt_class = IB_MCLASS_SUBN_LID;
- ibms_status = ibms_bind(conHdl, &p_mgr->filter);
- if (ibms_status)
- {
- return IB_ERROR;
- }
-
- p_mgr->filter.mgt_class = IB_MCLASS_SUBN_DIR;
- ibms_status = ibms_bind(conHdl, &p_mgr->filter);
- if (ibms_status)
- {
- return IB_ERROR;
- }
-
- break;
-
- case IB_MCLASS_SUBN_ADM:
- default:
- qpn = 1;
- p_mgr->filter.qpn = qpn;
- p_mgr->filter.mgt_class = p_info->mad_class;
- ibms_status = ibms_bind(conHdl, &p_mgr->filter);
- if (ibms_status)
- {
- return IB_ERROR;
- }
- break;
- }
-
- p_mgr->conHdl = conHdl;
-
- p_bo->p_transp_mgr = p_mgr ;
-
- /* Initialize the magic_ptr to the pointer of the p_bo info.
- This will be used to signal when the object is being destroyed, so no
- real action will be done then. */
- p_bo->magic_ptr = p_bo;
-
- return IB_SUCCESS;
+ ibms_conn_handle_t conHdl; /* the connection we talk to the simulator through */
+ osmv_ibms_transport_mgr_t *p_mgr =
+ malloc(sizeof(osmv_ibms_transport_mgr_t));
+ int qpn;
+ int ibms_status;
+ uint64_t port_guid;
+
+ if (!p_mgr) {
+ return IB_INSUFFICIENT_MEMORY;
+ }
+
+ memset(p_mgr, 0, sizeof(osmv_ibms_transport_mgr_t));
+
+ /* create the client socket connected to the simulator */
+ /* also perform the "connect" message - such that we
+ validate the target guid */
+ if (osm_vendor_get_guid_by_ca_and_port
+ (p_bo->p_vendor, hca_id, p_bo->port_num, &port_guid)) {
+ return IB_INVALID_GUID;
+ }
+
+ conHdl =
+ ibms_connect(port_guid, __osmv_ibms_receiver_callback,
+ (void *)p_bo);
+ if (!conHdl) {
+ printf("fail to connect to the server.\n");
+ exit(1);
+ }
+
+ /*
+ * Create the MAD filter on this file handle.
+ */
+
+ p_mgr->filter.port = p_bo->port_num;
+ p_mgr->filter.only_input = 1;
+ p_mgr->filter.mask =
+ IBMS_BIND_MASK_PORT |
+ IBMS_BIND_MASK_INPUT | IBMS_BIND_MASK_QP | IBMS_BIND_MASK_CLASS;
+
+ switch (p_info->mad_class) {
+ case IB_MCLASS_SUBN_LID:
+ case IB_MCLASS_SUBN_DIR:
+ qpn = 0;
+ p_mgr->filter.qpn = qpn;
+ p_mgr->filter.mgt_class = IB_MCLASS_SUBN_LID;
+ ibms_status = ibms_bind(conHdl, &p_mgr->filter);
+ if (ibms_status) {
+ return IB_ERROR;
+ }
+
+ p_mgr->filter.mgt_class = IB_MCLASS_SUBN_DIR;
+ ibms_status = ibms_bind(conHdl, &p_mgr->filter);
+ if (ibms_status) {
+ return IB_ERROR;
+ }
+
+ break;
+
+ case IB_MCLASS_SUBN_ADM:
+ default:
+ qpn = 1;
+ p_mgr->filter.qpn = qpn;
+ p_mgr->filter.mgt_class = p_info->mad_class;
+ ibms_status = ibms_bind(conHdl, &p_mgr->filter);
+ if (ibms_status) {
+ return IB_ERROR;
+ }
+ break;
+ }
+
+ p_mgr->conHdl = conHdl;
+
+ p_bo->p_transp_mgr = p_mgr;
+
+ /* Initialize the magic_ptr to the pointer of the p_bo info.
+ This will be used to signal when the object is being destroyed, so no
+ real action will be done then. */
+ p_bo->magic_ptr = p_bo;
+
+ return IB_SUCCESS;
}
/*
@@ -246,183 +241,173 @@ osmv_transport_init(IN osm_bind_info_t *p_info,
*/
ib_api_status_t
-osmv_transport_mad_send(IN const osm_bind_handle_t h_bind,
- IN void *p_mad,
- IN const osm_mad_addr_t *p_mad_addr)
+osmv_transport_mad_send(IN const osm_bind_handle_t h_bind,
+ IN void *p_mad, IN const osm_mad_addr_t * p_mad_addr)
{
- osmv_bind_obj_t* p_bo = (osmv_bind_obj_t*)h_bind;
- osm_vendor_t const *p_vend = p_bo->p_vendor;
- int ret;
- ibms_mad_msg_t mad_msg;
- ib_api_status_t status;
-
- const ib_mad_t *p_mad_hdr = p_mad;
-
- OSM_LOG_ENTER( p_vend->p_log, osmv_transport_mad_send);
-
- memset(&mad_msg, 0, sizeof(mad_msg));
-
- /* Make sure the p_bo object is still relevant */
- if (( p_bo->magic_ptr != p_bo) || p_bo->is_closing )
- return IB_INVALID_CALLBACK;
-
- /*
- * Copy the MAD over to the sent mad
- */
- memcpy(&mad_msg.header, p_mad_hdr, MAD_BLOCK_SIZE);
-
- /*
- * For all sends other than directed route SM MADs,
- * acquire an address vector for the destination.
- */
- if( p_mad_hdr->mgmt_class != IB_MCLASS_SUBN_DIR )
- {
-
- __osmv_ibms_osm_addr_to_mad_addr(
- p_mad_addr,
- p_mad_hdr->mgmt_class == IB_MCLASS_SUBN_LID,
- &mad_msg.addr);
- }
- else
- {
- /* is a directed route - we need to construct a permissive address */
- /* we do not need port number since it is part of the mad_hndl */
- mad_msg.addr.dlid = IB_LID_PERMISSIVE;
- mad_msg.addr.slid = IB_LID_PERMISSIVE;
- mad_msg.addr.sqpn = 0;
- mad_msg.addr.dqpn = 0;
- }
-
- osm_log( p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "osmv_transport_mad_send: "
- "Sending QPN:%d DLID:0x%04x class:0x%02x "
- "method:0x%02x attr:0x%04x status:0x%04x "
- "tid:0x%016" PRIx64 "\n",
- mad_msg.addr.dqpn,
- cl_ntoh16(mad_msg.addr.dlid),
- mad_msg.header.mgmt_class,
- mad_msg.header.method,
- cl_ntoh16(mad_msg.header.attr_id),
- cl_ntoh16(mad_msg.header.status),
- cl_ntoh64(mad_msg.header.trans_id)
- );
-
- /* send it */
- ret = ibms_send(((osmv_ibms_transport_mgr_t*)(p_bo->p_transp_mgr))->conHdl,
- &mad_msg);
- if( ret )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osmv_transport_mad_send: ERR 5304: "
- "Error sending mad (%d).\n", ret );
- status = IB_ERROR;
- goto Exit;
- }
-
- status = IB_SUCCESS;
-
- Exit:
- OSM_LOG_EXIT( p_vend->p_log );
- return(status);
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ osm_vendor_t const *p_vend = p_bo->p_vendor;
+ int ret;
+ ibms_mad_msg_t mad_msg;
+ ib_api_status_t status;
+
+ const ib_mad_t *p_mad_hdr = p_mad;
+
+ OSM_LOG_ENTER(p_vend->p_log, osmv_transport_mad_send);
+
+ memset(&mad_msg, 0, sizeof(mad_msg));
+
+ /* Make sure the p_bo object is still relevant */
+ if ((p_bo->magic_ptr != p_bo) || p_bo->is_closing)
+ return IB_INVALID_CALLBACK;
+
+ /*
+ * Copy the MAD over to the sent mad
+ */
+ memcpy(&mad_msg.header, p_mad_hdr, MAD_BLOCK_SIZE);
+
+ /*
+ * For all sends other than directed route SM MADs,
+ * acquire an address vector for the destination.
+ */
+ if (p_mad_hdr->mgmt_class != IB_MCLASS_SUBN_DIR) {
+
+ __osmv_ibms_osm_addr_to_mad_addr(p_mad_addr,
+ p_mad_hdr->mgmt_class ==
+ IB_MCLASS_SUBN_LID,
+ &mad_msg.addr);
+ } else {
+ /* is a directed route - we need to construct a permissive address */
+ /* we do not need port number since it is part of the mad_hndl */
+ mad_msg.addr.dlid = IB_LID_PERMISSIVE;
+ mad_msg.addr.slid = IB_LID_PERMISSIVE;
+ mad_msg.addr.sqpn = 0;
+ mad_msg.addr.dqpn = 0;
+ }
+
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "osmv_transport_mad_send: "
+ "Sending QPN:%d DLID:0x%04x class:0x%02x "
+ "method:0x%02x attr:0x%04x status:0x%04x "
+ "tid:0x%016" PRIx64 "\n",
+ mad_msg.addr.dqpn,
+ cl_ntoh16(mad_msg.addr.dlid),
+ mad_msg.header.mgmt_class,
+ mad_msg.header.method,
+ cl_ntoh16(mad_msg.header.attr_id),
+ cl_ntoh16(mad_msg.header.status),
+ cl_ntoh64(mad_msg.header.trans_id)
+ );
+
+ /* send it */
+ ret =
+ ibms_send(((osmv_ibms_transport_mgr_t *) (p_bo->p_transp_mgr))->
+ conHdl, &mad_msg);
+ if (ret) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osmv_transport_mad_send: ERR 5304: "
+ "Error sending mad (%d).\n", ret);
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+ status = IB_SUCCESS;
+
+ Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
}
-void
-osmv_transport_done(IN const osm_bind_handle_t h_bind)
+void osmv_transport_done(IN const osm_bind_handle_t h_bind)
{
- osmv_bind_obj_t* p_bo = (osmv_bind_obj_t*)h_bind;
- osmv_ibms_transport_mgr_t* p_tpot_mgr =
- (osmv_ibms_transport_mgr_t*)(p_bo->p_transp_mgr);
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ osmv_ibms_transport_mgr_t *p_tpot_mgr =
+ (osmv_ibms_transport_mgr_t *) (p_bo->p_transp_mgr);
- CL_ASSERT(p_bo);
+ CL_ASSERT(p_bo);
- /* First of all - zero out the magic_ptr, so if a callback is called -
- it'll know that we are currently closing down, and will not handle the
- mad. */
- p_bo->magic_ptr = 0;
- /* usleep(3000000); */
+ /* First of all - zero out the magic_ptr, so if a callback is called -
+ it'll know that we are currently closing down, and will not handle the
+ mad. */
+ p_bo->magic_ptr = 0;
+ /* usleep(3000000); */
- ibms_disconnect(p_tpot_mgr->conHdl);
+ ibms_disconnect(p_tpot_mgr->conHdl);
- /* seems the only way to abort a blocking read is to make it read something */
- free(p_tpot_mgr);
+ /* seems the only way to abort a blocking read is to make it read something */
+ free(p_tpot_mgr);
}
static void
-__osmv_ibms_osm_addr_to_mad_addr(
- IN const osm_mad_addr_t *p_osm_addr,
- IN uint8_t is_smi,
- OUT struct _ibms_mad_addr *p_ibms_addr)
+__osmv_ibms_osm_addr_to_mad_addr(IN const osm_mad_addr_t * p_osm_addr,
+ IN uint8_t is_smi,
+ OUT struct _ibms_mad_addr *p_ibms_addr)
{
- /* For global destination or Multicast address:*/
- p_ibms_addr->dlid = cl_ntoh16(p_osm_addr->dest_lid);
- p_ibms_addr->sl = p_osm_addr->addr_type.gsi.service_level;
- if (is_smi)
- {
- p_ibms_addr->sqpn = 0;
- p_ibms_addr->dqpn = 0;
- }
- else
- {
- p_ibms_addr->sqpn = 1;
- p_ibms_addr->dqpn = cl_ntoh32(p_osm_addr->addr_type.gsi.remote_qp);
- }
- /*
- HACK we limit to the first PKey Index assuming it will
- always be the default PKey
- */
- p_ibms_addr->pkey_index = 0;
+ /* For global destination or Multicast address: */
+ p_ibms_addr->dlid = cl_ntoh16(p_osm_addr->dest_lid);
+ p_ibms_addr->sl = p_osm_addr->addr_type.gsi.service_level;
+ if (is_smi) {
+ p_ibms_addr->sqpn = 0;
+ p_ibms_addr->dqpn = 0;
+ } else {
+ p_ibms_addr->sqpn = 1;
+ p_ibms_addr->dqpn =
+ cl_ntoh32(p_osm_addr->addr_type.gsi.remote_qp);
+ }
+ /*
+ HACK we limit to the first PKey Index assuming it will
+ always be the default PKey
+ */
+ p_ibms_addr->pkey_index = 0;
}
static void
-__osmv_ibms_mad_addr_to_osm_addr(
- IN osm_vendor_t const * p_vend,
- IN struct _ibms_mad_addr *p_ibms_addr,
- IN uint8_t is_smi,
- OUT osm_mad_addr_t *p_osm_addr)
+__osmv_ibms_mad_addr_to_osm_addr(IN osm_vendor_t const *p_vend,
+ IN struct _ibms_mad_addr *p_ibms_addr,
+ IN uint8_t is_smi,
+ OUT osm_mad_addr_t * p_osm_addr)
{
- memset(p_osm_addr, 0, sizeof(osm_mad_addr_t));
- p_osm_addr->dest_lid = cl_hton16(p_ibms_addr->slid);
- p_osm_addr->static_rate = 0;
- p_osm_addr->path_bits = 0;
- if (is_smi)
- {
- /* SMI */
- p_osm_addr->addr_type.smi.source_lid = cl_hton16(p_ibms_addr->slid);
- p_osm_addr->addr_type.smi.port_num = 1; /* TODO add if required p_ibms_addr->port; */
- }
- else
- {
- /* GSI */
- p_osm_addr->addr_type.gsi.remote_qp = cl_ntoh32(p_ibms_addr->sqpn);
- p_osm_addr->addr_type.gsi.remote_qkey = IB_QP1_WELL_KNOWN_Q_KEY;
- /* we do have the p_osm_addr->pkey_ix but how to get the PKey by index ? */
- /* the only way seems to be to use VAPI_query_hca_pkey_tbl and obtain */
- /* the full PKey table - than go by the index. */
- /* since this does not seem reasonable to me I simply use the default */
- /* There is a TAVOR limitation that only one P_KEY is supported per */
- /* QP - so QP1 must use IB_DEFAULT_PKEY */
- p_osm_addr->addr_type.gsi.pkey = IB_DEFAULT_PKEY;
- p_osm_addr->addr_type.gsi.service_level = p_ibms_addr->sl;
-
- p_osm_addr->addr_type.gsi.global_route = FALSE;
- /* copy the GRH data if relevant - TopSpin imp doesnt relate to GRH!!!*/
- /*
- if (p_osm_addr->addr_type.gsi.global_route)
- {
- p_osm_addr->addr_type.gsi.grh_info.ver_class_flow =
- ib_grh_set_ver_class_flow(p_rcv_desc->grh.IP_version,
- p_rcv_desc->grh.traffic_class,
- p_rcv_desc->grh.flow_label);
- p_osm_addr->addr_type.gsi.grh_info.hop_limit = p_rcv_desc->grh.hop_limit;
- memcpy(&p_osm_addr->addr_type.gsi.grh_info.src_gid.raw,
- &p_rcv_desc->grh.sgid, sizeof(ib_net64_t));
- memcpy(&p_osm_addr->addr_type.gsi.grh_info.dest_gid.raw,
- p_rcv_desc->grh.dgid, sizeof(ib_net64_t));
- }
- */
- }
+ memset(p_osm_addr, 0, sizeof(osm_mad_addr_t));
+ p_osm_addr->dest_lid = cl_hton16(p_ibms_addr->slid);
+ p_osm_addr->static_rate = 0;
+ p_osm_addr->path_bits = 0;
+ if (is_smi) {
+ /* SMI */
+ p_osm_addr->addr_type.smi.source_lid =
+ cl_hton16(p_ibms_addr->slid);
+ p_osm_addr->addr_type.smi.port_num = 1; /* TODO add if required p_ibms_addr->port; */
+ } else {
+ /* GSI */
+ p_osm_addr->addr_type.gsi.remote_qp =
+ cl_ntoh32(p_ibms_addr->sqpn);
+ p_osm_addr->addr_type.gsi.remote_qkey = IB_QP1_WELL_KNOWN_Q_KEY;
+ /* we do have the p_osm_addr->pkey_ix but how to get the PKey by index ? */
+ /* the only way seems to be to use VAPI_query_hca_pkey_tbl and obtain */
+ /* the full PKey table - than go by the index. */
+ /* since this does not seem reasonable to me I simply use the default */
+ /* There is a TAVOR limitation that only one P_KEY is supported per */
+ /* QP - so QP1 must use IB_DEFAULT_PKEY */
+ p_osm_addr->addr_type.gsi.pkey = IB_DEFAULT_PKEY;
+ p_osm_addr->addr_type.gsi.service_level = p_ibms_addr->sl;
+
+ p_osm_addr->addr_type.gsi.global_route = FALSE;
+ /* copy the GRH data if relevant - TopSpin imp doesnt relate to GRH!!! */
+ /*
+ if (p_osm_addr->addr_type.gsi.global_route)
+ {
+ p_osm_addr->addr_type.gsi.grh_info.ver_class_flow =
+ ib_grh_set_ver_class_flow(p_rcv_desc->grh.IP_version,
+ p_rcv_desc->grh.traffic_class,
+ p_rcv_desc->grh.flow_label);
+ p_osm_addr->addr_type.gsi.grh_info.hop_limit = p_rcv_desc->grh.hop_limit;
+ memcpy(&p_osm_addr->addr_type.gsi.grh_info.src_gid.raw,
+ &p_rcv_desc->grh.sgid, sizeof(ib_net64_t));
+ memcpy(&p_osm_addr->addr_type.gsi.grh_info.dest_gid.raw,
+ p_rcv_desc->grh.dgid, sizeof(ib_net64_t));
+ }
+ */
+ }
}
/*
@@ -432,36 +417,30 @@ __osmv_ibms_mad_addr_to_osm_addr(
* according to the value given (TRUE or FALSE).
*/
-void
-osm_vendor_set_sm(
- IN osm_bind_handle_t h_bind,
- IN boolean_t is_sm_val )
+void osm_vendor_set_sm(IN osm_bind_handle_t h_bind, IN boolean_t is_sm_val)
{
- osmv_bind_obj_t *p_bo = ( osmv_bind_obj_t * ) h_bind;
- osm_vendor_t const *p_vend = p_bo->p_vendor;
- int ret;
- ibms_cap_msg_t cap_msg;
-
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_set_sm );
-
- cap_msg.mask = IB_PORT_CAP_IS_SM;
- if (is_sm_val)
- cap_msg.capabilities = IB_PORT_CAP_IS_SM;
- else
- cap_msg.capabilities = 0;
-
- ret = ibms_set_cap(
- ((osmv_ibms_transport_mgr_t*)(p_bo->p_transp_mgr))->conHdl,
- &cap_msg);
-
- if( ret )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_set_sm: ERR 5312: "
- "Unable set 'IS_SM' bit to:%u in port attributes.\n",
- is_sm_val );
- }
- OSM_LOG_EXIT( p_vend->p_log );
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ osm_vendor_t const *p_vend = p_bo->p_vendor;
+ int ret;
+ ibms_cap_msg_t cap_msg;
+
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_set_sm);
+
+ cap_msg.mask = IB_PORT_CAP_IS_SM;
+ if (is_sm_val)
+ cap_msg.capabilities = IB_PORT_CAP_IS_SM;
+ else
+ cap_msg.capabilities = 0;
+
+ ret = ibms_set_cap(((osmv_ibms_transport_mgr_t *) (p_bo->
+ p_transp_mgr))->
+ conHdl, &cap_msg);
+
+ if (ret) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_set_sm: ERR 5312: "
+ "Unable set 'IS_SM' bit to:%u in port attributes.\n",
+ is_sm_val);
+ }
+ OSM_LOG_EXIT(p_vend->p_log);
}
-
-
diff --git a/opensm/libvendor/osm_vendor_mlx_ts.c b/opensm/libvendor/osm_vendor_mlx_ts.c
index a980d3a..83ed1b1 100644
--- a/opensm/libvendor/osm_vendor_mlx_ts.c
+++ b/opensm/libvendor/osm_vendor_mlx_ts.c
@@ -43,7 +43,7 @@
#if HAVE_CONFIG_H
# include <config.h>
-#endif /* HAVE_CONFIG_H */
+#endif /* HAVE_CONFIG_H */
#include <sys/types.h>
#include <sys/stat.h>
@@ -61,112 +61,111 @@
#include <opensm/osm_ts_useraccess.h>
typedef struct _osmv_TOPSPIN_transport_mgr_ {
- int device_fd;
- osm_ts_user_mad_filter filter;
- cl_thread_t receiver;
-}osmv_TOPSPIN_transport_mgr_t;
+ int device_fd;
+ osm_ts_user_mad_filter filter;
+ cl_thread_t receiver;
+} osmv_TOPSPIN_transport_mgr_t;
static void
-__osmv_TOPSPIN_mad_addr_to_osm_addr(
- IN osm_vendor_t const * p_vend,
- IN struct ib_mad *p_mad,
- IN uint8_t is_smi,
- OUT osm_mad_addr_t *p_mad_addr);
+__osmv_TOPSPIN_mad_addr_to_osm_addr(IN osm_vendor_t const *p_vend,
+ IN struct ib_mad *p_mad,
+ IN uint8_t is_smi,
+ OUT osm_mad_addr_t * p_mad_addr);
static void
-__osmv_TOPSPIN_osm_addr_to_mad_addr(
- IN const osm_mad_addr_t *p_mad_addr,
- IN uint8_t is_smi,
- OUT struct ib_mad *p_mad);
+__osmv_TOPSPIN_osm_addr_to_mad_addr(IN const osm_mad_addr_t * p_mad_addr,
+ IN uint8_t is_smi,
+ OUT struct ib_mad *p_mad);
-
-
-void
-__osmv_TOPSPIN_receiver_thr(void* p_ctx)
+void __osmv_TOPSPIN_receiver_thr(void *p_ctx)
{
- int ts_ret_code;
- struct ib_mad mad;
- osm_mad_addr_t mad_addr;
- osmv_bind_obj_t * const p_bo = (osmv_bind_obj_t *)p_ctx;
- ib_api_status_t status = IB_SUCCESS;
-
- OSM_LOG_ENTER( p_bo->p_vendor->p_log, __osmv_TOPSPIN_receiver_thr );
-
- /* Make sure the p_bo object is still relevant */
- if ( (p_bo->magic_ptr != p_bo) || p_bo->is_closing )
- return;
-
- /* we set the type of cancelation for this thread */
- /* pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); */
-
- while( 1 )
- {
- /* Make sure the p_bo object is still relevant */
- if ( (p_bo->magic_ptr != p_bo) || p_bo->is_closing )
- return;
-
- /* we read one mad at a time and pass it to the read callback function */
- ts_ret_code = read(((osmv_TOPSPIN_transport_mgr_t*)(p_bo->p_transp_mgr))->device_fd,
- &mad, sizeof(mad));
- /* Make sure the p_bo object is still relevant */
- if (( p_bo->magic_ptr != p_bo) || p_bo->is_closing )
- return;
-
- if (ts_ret_code != sizeof(mad))
- {
- osm_log( p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "__osmv_TOPSPIN_receiver_thr: ERR 6803: "
- "error with read, bytes = %d, errno = %d\n",
- ts_ret_code, errno
- );
- break;
- }
- else
- {
- osm_log( p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "__osmv_TOPSPIN_receiver_thr: "
- "MAD QPN:%d SLID:0x%04x class:0x%02x "
- "method:0x%02x attr:0x%04x status:0x%04x "
- "tid:0x%016" PRIx64 "\n",
- mad.dqpn,
- cl_ntoh16(mad.slid),
- mad.mgmt_class,
- mad.r_method,
- cl_ntoh16(mad.attribute_id),
- cl_ntoh16(mad.status),
- cl_ntoh64(mad.transaction_id));
-
- /* first arrange an address */
- __osmv_TOPSPIN_mad_addr_to_osm_addr(
- p_bo->p_vendor,&mad,
- ( ((ib_mad_t*)&mad)->mgmt_class == IB_MCLASS_SUBN_LID ) ||
- ( ((ib_mad_t*)&mad)->mgmt_class == IB_MCLASS_SUBN_DIR ),
- &mad_addr);
-
- /* call the receiver callback */
-
- status = osmv_dispatch_mad((osm_bind_handle_t)p_bo,(void*)&mad,&mad_addr);
-
- /* Make sure the p_bo object is still relevant */
- if (( p_bo->magic_ptr != p_bo) || p_bo->is_closing )
- return;
-
- if (IB_INTERRUPTED == status)
- {
-
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "__osmv_TOPSPIN_receiver_thr: "
- "The bind handle %p is being closed. "
- "Breaking the loop.\n", p_bo);
- break;
- }
- }
- }
-
- OSM_LOG_EXIT( p_bo->p_vendor->p_log );
+ int ts_ret_code;
+ struct ib_mad mad;
+ osm_mad_addr_t mad_addr;
+ osmv_bind_obj_t *const p_bo = (osmv_bind_obj_t *) p_ctx;
+ ib_api_status_t status = IB_SUCCESS;
+
+ OSM_LOG_ENTER(p_bo->p_vendor->p_log, __osmv_TOPSPIN_receiver_thr);
+
+ /* Make sure the p_bo object is still relevant */
+ if ((p_bo->magic_ptr != p_bo) || p_bo->is_closing)
+ return;
+
+ /* we set the type of cancelation for this thread */
+ /* pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); */
+
+ while (1) {
+ /* Make sure the p_bo object is still relevant */
+ if ((p_bo->magic_ptr != p_bo) || p_bo->is_closing)
+ return;
+
+ /* we read one mad at a time and pass it to the read callback function */
+ ts_ret_code =
+ read(((osmv_TOPSPIN_transport_mgr_t *) (p_bo->
+ p_transp_mgr))->
+ device_fd, &mad, sizeof(mad));
+ /* Make sure the p_bo object is still relevant */
+ if ((p_bo->magic_ptr != p_bo) || p_bo->is_closing)
+ return;
+
+ if (ts_ret_code != sizeof(mad)) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "__osmv_TOPSPIN_receiver_thr: ERR 6803: "
+ "error with read, bytes = %d, errno = %d\n",
+ ts_ret_code, errno);
+ break;
+ } else {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "__osmv_TOPSPIN_receiver_thr: "
+ "MAD QPN:%d SLID:0x%04x class:0x%02x "
+ "method:0x%02x attr:0x%04x status:0x%04x "
+ "tid:0x%016" PRIx64 "\n",
+ mad.dqpn,
+ cl_ntoh16(mad.slid),
+ mad.mgmt_class,
+ mad.r_method,
+ cl_ntoh16(mad.attribute_id),
+ cl_ntoh16(mad.status),
+ cl_ntoh64(mad.transaction_id));
+
+ /* first arrange an address */
+ __osmv_TOPSPIN_mad_addr_to_osm_addr(p_bo->p_vendor,
+ &mad,
+ (((ib_mad_t *) &
+ mad)->
+ mgmt_class ==
+ IB_MCLASS_SUBN_LID)
+ ||
+ (((ib_mad_t *) &
+ mad)->
+ mgmt_class ==
+ IB_MCLASS_SUBN_DIR),
+ &mad_addr);
+
+ /* call the receiver callback */
+
+ status =
+ osmv_dispatch_mad((osm_bind_handle_t) p_bo,
+ (void *)&mad, &mad_addr);
+
+ /* Make sure the p_bo object is still relevant */
+ if ((p_bo->magic_ptr != p_bo) || p_bo->is_closing)
+ return;
+
+ if (IB_INTERRUPTED == status) {
+
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "__osmv_TOPSPIN_receiver_thr: "
+ "The bind handle %p is being closed. "
+ "Breaking the loop.\n", p_bo);
+ break;
+ }
+ }
+ }
+
+ OSM_LOG_EXIT(p_bo->p_vendor->p_log);
}
-
/*
* NAME
* osmv_transport_init
@@ -176,100 +175,96 @@ __osmv_TOPSPIN_receiver_thr(void* p_ctx)
*/
ib_api_status_t
-osmv_transport_init(IN osm_bind_info_t *p_info,
- IN char hca_id[VENDOR_HCA_MAXNAMES],
- IN uint8_t hca_idx,
- IN osmv_bind_obj_t *p_bo)
+osmv_transport_init(IN osm_bind_info_t * p_info,
+ IN char hca_id[VENDOR_HCA_MAXNAMES],
+ IN uint8_t hca_idx, IN osmv_bind_obj_t * p_bo)
{
- cl_status_t cl_st;
- char device_file[16];
- int device_fd;
- int ts_ioctl_ret;
- osmv_TOPSPIN_transport_mgr_t* p_mgr = malloc(sizeof(osmv_TOPSPIN_transport_mgr_t));
- int qpn;
-
- if (!p_mgr)
- {
- return IB_INSUFFICIENT_MEMORY;
- }
-
- memset(p_mgr, 0, sizeof(osmv_TOPSPIN_transport_mgr_t));
-
- /* open TopSpin file device */
- /* HACK: assume last char in hostid is the HCA index */
- sprintf(device_file, "/dev/ts_ua%u", hca_idx);
- device_fd = open(device_file, O_RDWR );
- if (device_fd < 0)
- {
- fprintf(stderr, "Fatal: Fail to open the file:%s err:%d\n", device_file, errno);
- return IB_ERROR;
- }
-
- /*
- * Create the MAD filter on this file handle.
- */
-
- p_mgr->filter.port = p_bo->port_num;
- p_mgr->filter.direction = TS_IB_MAD_DIRECTION_IN;
- p_mgr->filter.mask =
- TS_IB_MAD_FILTER_DIRECTION |
- TS_IB_MAD_FILTER_PORT |
- TS_IB_MAD_FILTER_QPN |
- TS_IB_MAD_FILTER_MGMT_CLASS;
-
- switch ( p_info->mad_class )
- {
- case IB_MCLASS_SUBN_LID:
- case IB_MCLASS_SUBN_DIR:
- qpn = 0;
- p_mgr->filter.qpn = qpn;
- p_mgr->filter.mgmt_class = IB_MCLASS_SUBN_LID;
- ts_ioctl_ret = ioctl(device_fd, TS_IB_IOCSMADFILTADD, &p_mgr->filter);
- if (ts_ioctl_ret < 0)
- {
- return IB_ERROR;
- }
-
- p_mgr->filter.mgmt_class = IB_MCLASS_SUBN_DIR;
- ts_ioctl_ret = ioctl(device_fd, TS_IB_IOCSMADFILTADD, &p_mgr->filter);
- if (ts_ioctl_ret < 0)
- {
- return IB_ERROR;
- }
-
- break;
-
- case IB_MCLASS_SUBN_ADM:
- default:
- qpn = 1;
- p_mgr->filter.qpn = qpn;
- p_mgr->filter.mgmt_class = p_info->mad_class;
- ts_ioctl_ret = ioctl(device_fd, TS_IB_IOCSMADFILTADD, &p_mgr->filter);
- if (ts_ioctl_ret < 0)
- {
- return IB_ERROR;
- }
- break;
- }
-
- p_mgr->device_fd = device_fd;
-
- p_bo->p_transp_mgr = p_mgr ;
-
- /* Initialize the magic_ptr to the pointer of the p_bo info.
- This will be used to signal when the object is being destroyed, so no
- real action will be done then. */
- p_bo->magic_ptr = p_bo;
-
- /* init receiver thread */
- cl_st = cl_thread_init(&p_mgr->receiver,__osmv_TOPSPIN_receiver_thr,(void*)p_bo,
- "osmv TOPSPIN rcv thr");
-
- return (ib_api_status_t)cl_st;
+ cl_status_t cl_st;
+ char device_file[16];
+ int device_fd;
+ int ts_ioctl_ret;
+ osmv_TOPSPIN_transport_mgr_t *p_mgr =
+ malloc(sizeof(osmv_TOPSPIN_transport_mgr_t));
+ int qpn;
+
+ if (!p_mgr) {
+ return IB_INSUFFICIENT_MEMORY;
+ }
+
+ memset(p_mgr, 0, sizeof(osmv_TOPSPIN_transport_mgr_t));
+
+ /* open TopSpin file device */
+ /* HACK: assume last char in hostid is the HCA index */
+ sprintf(device_file, "/dev/ts_ua%u", hca_idx);
+ device_fd = open(device_file, O_RDWR);
+ if (device_fd < 0) {
+ fprintf(stderr, "Fatal: Fail to open the file:%s err:%d\n",
+ device_file, errno);
+ return IB_ERROR;
+ }
+
+ /*
+ * Create the MAD filter on this file handle.
+ */
+
+ p_mgr->filter.port = p_bo->port_num;
+ p_mgr->filter.direction = TS_IB_MAD_DIRECTION_IN;
+ p_mgr->filter.mask =
+ TS_IB_MAD_FILTER_DIRECTION |
+ TS_IB_MAD_FILTER_PORT |
+ TS_IB_MAD_FILTER_QPN | TS_IB_MAD_FILTER_MGMT_CLASS;
+
+ switch (p_info->mad_class) {
+ case IB_MCLASS_SUBN_LID:
+ case IB_MCLASS_SUBN_DIR:
+ qpn = 0;
+ p_mgr->filter.qpn = qpn;
+ p_mgr->filter.mgmt_class = IB_MCLASS_SUBN_LID;
+ ts_ioctl_ret =
+ ioctl(device_fd, TS_IB_IOCSMADFILTADD, &p_mgr->filter);
+ if (ts_ioctl_ret < 0) {
+ return IB_ERROR;
+ }
+
+ p_mgr->filter.mgmt_class = IB_MCLASS_SUBN_DIR;
+ ts_ioctl_ret =
+ ioctl(device_fd, TS_IB_IOCSMADFILTADD, &p_mgr->filter);
+ if (ts_ioctl_ret < 0) {
+ return IB_ERROR;
+ }
+
+ break;
+
+ case IB_MCLASS_SUBN_ADM:
+ default:
+ qpn = 1;
+ p_mgr->filter.qpn = qpn;
+ p_mgr->filter.mgmt_class = p_info->mad_class;
+ ts_ioctl_ret =
+ ioctl(device_fd, TS_IB_IOCSMADFILTADD, &p_mgr->filter);
+ if (ts_ioctl_ret < 0) {
+ return IB_ERROR;
+ }
+ break;
+ }
+
+ p_mgr->device_fd = device_fd;
+
+ p_bo->p_transp_mgr = p_mgr;
+
+ /* Initialize the magic_ptr to the pointer of the p_bo info.
+ This will be used to signal when the object is being destroyed, so no
+ real action will be done then. */
+ p_bo->magic_ptr = p_bo;
+
+ /* init receiver thread */
+ cl_st =
+ cl_thread_init(&p_mgr->receiver, __osmv_TOPSPIN_receiver_thr,
+ (void *)p_bo, "osmv TOPSPIN rcv thr");
+
+ return (ib_api_status_t) cl_st;
}
-
-
/*
* NAME
* osmv_transport_send_mad
@@ -279,88 +274,83 @@ osmv_transport_init(IN osm_bind_info_t *p_info,
*/
ib_api_status_t
-osmv_transport_mad_send(IN const osm_bind_handle_t h_bind,
- IN void *p_mad,
- IN const osm_mad_addr_t *p_mad_addr)
+osmv_transport_mad_send(IN const osm_bind_handle_t h_bind,
+ IN void *p_mad, IN const osm_mad_addr_t * p_mad_addr)
{
- osmv_bind_obj_t* p_bo = (osmv_bind_obj_t*)h_bind;
- osm_vendor_t const *p_vend = p_bo->p_vendor;
- struct ib_mad ts_mad;
- int ret;
- ib_api_status_t status;
-
- const ib_mad_t *p_mad_hdr = p_mad;
-
- OSM_LOG_ENTER( p_vend->p_log, osmv_transport_mad_send);
-
- memset(&ts_mad, 0, sizeof(ts_mad));
-
- /* Make sure the p_bo object is still relevant */
- if (( p_bo->magic_ptr != p_bo) || p_bo->is_closing )
- return IB_INVALID_CALLBACK;
-
- /*
- * Copy the MAD over to the sent mad
- */
- memcpy(&ts_mad, p_mad_hdr, MAD_BLOCK_SIZE);
-
- /*
- * For all sends other than directed route SM MADs,
- * acquire an address vector for the destination.
- */
- if( p_mad_hdr->mgmt_class != IB_MCLASS_SUBN_DIR )
- {
-
- __osmv_TOPSPIN_osm_addr_to_mad_addr(
- p_mad_addr,
- p_mad_hdr->mgmt_class == IB_MCLASS_SUBN_LID,
- &ts_mad);
- }
- else
- {
- /* is a directed route - we need to construct a permissive address */
- /* we do not need port number since it is part of the mad_hndl */
- ts_mad.dlid = IB_LID_PERMISSIVE;
- ts_mad.slid = IB_LID_PERMISSIVE;
- ts_mad.sqpn = 0;
- ts_mad.dqpn = 0;
- }
-
- ts_mad.port = p_bo->port_num;
-
- osm_log( p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "osmv_transport_mad_send: "
- "Sending QPN:%d DLID:0x%04x class:0x%02x "
- "method:0x%02x attr:0x%04x status:0x%04x "
- "tid:0x%016" PRIx64 "\n",
- ts_mad.dqpn,
- cl_ntoh16(ts_mad.dlid),
- ts_mad.mgmt_class,
- ts_mad.r_method,
- cl_ntoh16(ts_mad.attribute_id),
- cl_ntoh16(ts_mad.status),
- cl_ntoh64(ts_mad.transaction_id)
- );
-
- /* send it */
- ret = write(((osmv_TOPSPIN_transport_mgr_t*)(p_bo->p_transp_mgr))->device_fd,
- &ts_mad, sizeof(ts_mad));
-
- if( ret != sizeof(ts_mad) )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osmv_transport_mad_send: ERR 6804: "
- "Error sending mad (%d).\n", ret );
- status = IB_ERROR;
- goto Exit;
- }
-
- status = IB_SUCCESS;
-
- Exit:
- OSM_LOG_EXIT( p_vend->p_log );
- return(status);
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ osm_vendor_t const *p_vend = p_bo->p_vendor;
+ struct ib_mad ts_mad;
+ int ret;
+ ib_api_status_t status;
+
+ const ib_mad_t *p_mad_hdr = p_mad;
+
+ OSM_LOG_ENTER(p_vend->p_log, osmv_transport_mad_send);
+
+ memset(&ts_mad, 0, sizeof(ts_mad));
+
+ /* Make sure the p_bo object is still relevant */
+ if ((p_bo->magic_ptr != p_bo) || p_bo->is_closing)
+ return IB_INVALID_CALLBACK;
+
+ /*
+ * Copy the MAD over to the sent mad
+ */
+ memcpy(&ts_mad, p_mad_hdr, MAD_BLOCK_SIZE);
+
+ /*
+ * For all sends other than directed route SM MADs,
+ * acquire an address vector for the destination.
+ */
+ if (p_mad_hdr->mgmt_class != IB_MCLASS_SUBN_DIR) {
+
+ __osmv_TOPSPIN_osm_addr_to_mad_addr(p_mad_addr,
+ p_mad_hdr->mgmt_class ==
+ IB_MCLASS_SUBN_LID,
+ &ts_mad);
+ } else {
+ /* is a directed route - we need to construct a permissive address */
+ /* we do not need port number since it is part of the mad_hndl */
+ ts_mad.dlid = IB_LID_PERMISSIVE;
+ ts_mad.slid = IB_LID_PERMISSIVE;
+ ts_mad.sqpn = 0;
+ ts_mad.dqpn = 0;
+ }
+
+ ts_mad.port = p_bo->port_num;
+
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "osmv_transport_mad_send: "
+ "Sending QPN:%d DLID:0x%04x class:0x%02x "
+ "method:0x%02x attr:0x%04x status:0x%04x "
+ "tid:0x%016" PRIx64 "\n",
+ ts_mad.dqpn,
+ cl_ntoh16(ts_mad.dlid),
+ ts_mad.mgmt_class,
+ ts_mad.r_method,
+ cl_ntoh16(ts_mad.attribute_id),
+ cl_ntoh16(ts_mad.status), cl_ntoh64(ts_mad.transaction_id)
+ );
+
+ /* send it */
+ ret =
+ write(((osmv_TOPSPIN_transport_mgr_t *) (p_bo->p_transp_mgr))->
+ device_fd, &ts_mad, sizeof(ts_mad));
+
+ if (ret != sizeof(ts_mad)) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osmv_transport_mad_send: ERR 6804: "
+ "Error sending mad (%d).\n", ret);
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+ status = IB_SUCCESS;
+
+ Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
}
/*
@@ -368,129 +358,118 @@ osmv_transport_mad_send(IN const osm_bind_handle_t h_bind,
and send a mad through - the main idea is to make
the filter catch it such that the read unblocks
*/
-void
-__osm_transport_gen_dummy_mad(osmv_bind_obj_t* p_bo)
+void __osm_transport_gen_dummy_mad(osmv_bind_obj_t * p_bo)
{
- struct ib_mad ts_mad;
- osmv_TOPSPIN_transport_mgr_t* p_mgr =
- (osmv_TOPSPIN_transport_mgr_t*)(p_bo->p_transp_mgr);
- struct ib_get_port_info_ioctl port_data;
- int ts_ioctl_ret;
-
- /* prepare the mad fields following the stored filter on the bind */
- memset(&ts_mad, 0, sizeof(ts_mad));
- ts_mad.format_version = 1;
- ts_mad.mgmt_class = p_mgr->filter.mgmt_class;
- ts_mad.attribute_id = 0x2;
- ts_mad.class_version = 1;
- ts_mad.r_method = cl_ntoh16(0x2);
- ts_mad.port = p_bo->port_num;
- ts_mad.sqpn = p_mgr->filter.qpn;
- ts_mad.dqpn = p_mgr->filter.qpn;
- ts_mad.slid = 0xffff;
- /* we must send to our local lid ... */
- port_data.port = p_bo->port_num;
- ts_ioctl_ret = ioctl(p_mgr->device_fd, TS_IB_IOCGPORTINFO, &port_data);
- ts_mad.dlid = port_data.port_info.lid;
- ts_mad.transaction_id = 0x9999;
- write(p_mgr->device_fd, &ts_mad, sizeof(ts_mad));
+ struct ib_mad ts_mad;
+ osmv_TOPSPIN_transport_mgr_t *p_mgr =
+ (osmv_TOPSPIN_transport_mgr_t *) (p_bo->p_transp_mgr);
+ struct ib_get_port_info_ioctl port_data;
+ int ts_ioctl_ret;
+
+ /* prepare the mad fields following the stored filter on the bind */
+ memset(&ts_mad, 0, sizeof(ts_mad));
+ ts_mad.format_version = 1;
+ ts_mad.mgmt_class = p_mgr->filter.mgmt_class;
+ ts_mad.attribute_id = 0x2;
+ ts_mad.class_version = 1;
+ ts_mad.r_method = cl_ntoh16(0x2);
+ ts_mad.port = p_bo->port_num;
+ ts_mad.sqpn = p_mgr->filter.qpn;
+ ts_mad.dqpn = p_mgr->filter.qpn;
+ ts_mad.slid = 0xffff;
+ /* we must send to our local lid ... */
+ port_data.port = p_bo->port_num;
+ ts_ioctl_ret = ioctl(p_mgr->device_fd, TS_IB_IOCGPORTINFO, &port_data);
+ ts_mad.dlid = port_data.port_info.lid;
+ ts_mad.transaction_id = 0x9999;
+ write(p_mgr->device_fd, &ts_mad, sizeof(ts_mad));
}
-void
-osmv_transport_done(IN const osm_bind_handle_t h_bind)
+void osmv_transport_done(IN const osm_bind_handle_t h_bind)
{
- osmv_bind_obj_t* p_bo = (osmv_bind_obj_t*)h_bind;
- osmv_TOPSPIN_transport_mgr_t* p_tpot_mgr =
- (osmv_TOPSPIN_transport_mgr_t*)(p_bo->p_transp_mgr);
-
- CL_ASSERT(p_bo);
-
- /* First of all - zero out the magic_ptr, so if a callback is called -
- it'll know that we are currently closing down, and will not handle the
- mad. */
- p_bo->magic_ptr = 0;
- /* usleep(3000000); */
-
- /* seems the only way to abort a blocking read is to make it read something */
- __osm_transport_gen_dummy_mad(p_bo);
- cl_thread_destroy(&(p_tpot_mgr->receiver));
- free(p_tpot_mgr);
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ osmv_TOPSPIN_transport_mgr_t *p_tpot_mgr =
+ (osmv_TOPSPIN_transport_mgr_t *) (p_bo->p_transp_mgr);
+
+ CL_ASSERT(p_bo);
+
+ /* First of all - zero out the magic_ptr, so if a callback is called -
+ it'll know that we are currently closing down, and will not handle the
+ mad. */
+ p_bo->magic_ptr = 0;
+ /* usleep(3000000); */
+
+ /* seems the only way to abort a blocking read is to make it read something */
+ __osm_transport_gen_dummy_mad(p_bo);
+ cl_thread_destroy(&(p_tpot_mgr->receiver));
+ free(p_tpot_mgr);
}
static void
-__osmv_TOPSPIN_osm_addr_to_mad_addr(
- IN const osm_mad_addr_t *p_mad_addr,
- IN uint8_t is_smi,
- OUT struct ib_mad *p_mad)
+__osmv_TOPSPIN_osm_addr_to_mad_addr(IN const osm_mad_addr_t * p_mad_addr,
+ IN uint8_t is_smi, OUT struct ib_mad *p_mad)
{
- /* For global destination or Multicast address:*/
- p_mad->dlid = cl_ntoh16(p_mad_addr->dest_lid);
- p_mad->sl = p_mad_addr->addr_type.gsi.service_level;
- if (is_smi)
- {
- p_mad->sqpn = 0;
- p_mad->dqpn = 0;
- }
- else
- {
- p_mad->sqpn = 1;
- p_mad->dqpn = cl_ntoh32(p_mad_addr->addr_type.gsi.remote_qp);
- }
- /*
- HACK we limit to the first PKey Index assuming it will
- always be the default PKey
- */
- p_mad->pkey_index = 0;
+ /* For global destination or Multicast address: */
+ p_mad->dlid = cl_ntoh16(p_mad_addr->dest_lid);
+ p_mad->sl = p_mad_addr->addr_type.gsi.service_level;
+ if (is_smi) {
+ p_mad->sqpn = 0;
+ p_mad->dqpn = 0;
+ } else {
+ p_mad->sqpn = 1;
+ p_mad->dqpn = cl_ntoh32(p_mad_addr->addr_type.gsi.remote_qp);
+ }
+ /*
+ HACK we limit to the first PKey Index assuming it will
+ always be the default PKey
+ */
+ p_mad->pkey_index = 0;
}
static void
-__osmv_TOPSPIN_mad_addr_to_osm_addr(
- IN osm_vendor_t const * p_vend,
- IN struct ib_mad *p_mad,
- IN uint8_t is_smi,
- OUT osm_mad_addr_t *p_mad_addr)
+__osmv_TOPSPIN_mad_addr_to_osm_addr(IN osm_vendor_t const *p_vend,
+ IN struct ib_mad *p_mad,
+ IN uint8_t is_smi,
+ OUT osm_mad_addr_t * p_mad_addr)
{
- p_mad_addr->dest_lid = cl_hton16(p_mad->slid);
- p_mad_addr->static_rate = 0;
- p_mad_addr->path_bits = 0;
- if (is_smi)
- {
- /* SMI */
- p_mad_addr->addr_type.smi.source_lid = cl_hton16(p_mad->slid);
- p_mad_addr->addr_type.smi.port_num = p_mad->port;
- }
- else
- {
- /* GSI */
- p_mad_addr->addr_type.gsi.remote_qp = cl_ntoh32(p_mad->sqpn);
- p_mad_addr->addr_type.gsi.remote_qkey = IB_QP1_WELL_KNOWN_Q_KEY;
- /* we do have the p_mad_addr->pkey_ix but how to get the PKey by index ? */
- /* the only way seems to be to use VAPI_query_hca_pkey_tbl and obtain */
- /* the full PKey table - than go by the index. */
- /* since this does not seem reasonable to me I simply use the default */
- /* There is a TAVOR limitation that only one P_KEY is supported per */
- /* QP - so QP1 must use IB_DEFAULT_PKEY */
- p_mad_addr->addr_type.gsi.pkey = IB_DEFAULT_PKEY;
- p_mad_addr->addr_type.gsi.service_level = p_mad->sl;
-
- p_mad_addr->addr_type.gsi.global_route = FALSE;
- /* copy the GRH data if relevant - TopSpin imp doesnt relate to GRH!!!*/
- /*
- if (p_mad_addr->addr_type.gsi.global_route)
- {
- p_mad_addr->addr_type.gsi.grh_info.ver_class_flow =
- ib_grh_set_ver_class_flow(p_rcv_desc->grh.IP_version,
- p_rcv_desc->grh.traffic_class,
- p_rcv_desc->grh.flow_label);
- p_mad_addr->addr_type.gsi.grh_info.hop_limit = p_rcv_desc->grh.hop_limit;
- memcpy(&p_mad_addr->addr_type.gsi.grh_info.src_gid.raw,
- &p_rcv_desc->grh.sgid, sizeof(ib_net64_t));
- memcpy(&p_mad_addr->addr_type.gsi.grh_info.dest_gid.raw,
- p_rcv_desc->grh.dgid, sizeof(ib_net64_t));
- }
- */
- }
+ p_mad_addr->dest_lid = cl_hton16(p_mad->slid);
+ p_mad_addr->static_rate = 0;
+ p_mad_addr->path_bits = 0;
+ if (is_smi) {
+ /* SMI */
+ p_mad_addr->addr_type.smi.source_lid = cl_hton16(p_mad->slid);
+ p_mad_addr->addr_type.smi.port_num = p_mad->port;
+ } else {
+ /* GSI */
+ p_mad_addr->addr_type.gsi.remote_qp = cl_ntoh32(p_mad->sqpn);
+ p_mad_addr->addr_type.gsi.remote_qkey = IB_QP1_WELL_KNOWN_Q_KEY;
+ /* we do have the p_mad_addr->pkey_ix but how to get the PKey by index ? */
+ /* the only way seems to be to use VAPI_query_hca_pkey_tbl and obtain */
+ /* the full PKey table - than go by the index. */
+ /* since this does not seem reasonable to me I simply use the default */
+ /* There is a TAVOR limitation that only one P_KEY is supported per */
+ /* QP - so QP1 must use IB_DEFAULT_PKEY */
+ p_mad_addr->addr_type.gsi.pkey = IB_DEFAULT_PKEY;
+ p_mad_addr->addr_type.gsi.service_level = p_mad->sl;
+
+ p_mad_addr->addr_type.gsi.global_route = FALSE;
+ /* copy the GRH data if relevant - TopSpin imp doesnt relate to GRH!!! */
+ /*
+ if (p_mad_addr->addr_type.gsi.global_route)
+ {
+ p_mad_addr->addr_type.gsi.grh_info.ver_class_flow =
+ ib_grh_set_ver_class_flow(p_rcv_desc->grh.IP_version,
+ p_rcv_desc->grh.traffic_class,
+ p_rcv_desc->grh.flow_label);
+ p_mad_addr->addr_type.gsi.grh_info.hop_limit = p_rcv_desc->grh.hop_limit;
+ memcpy(&p_mad_addr->addr_type.gsi.grh_info.src_gid.raw,
+ &p_rcv_desc->grh.sgid, sizeof(ib_net64_t));
+ memcpy(&p_mad_addr->addr_type.gsi.grh_info.dest_gid.raw,
+ p_rcv_desc->grh.dgid, sizeof(ib_net64_t));
+ }
+ */
+ }
}
/*
@@ -501,35 +480,31 @@ __osmv_TOPSPIN_mad_addr_to_osm_addr(
*/
#if (defined(OSM_VENDOR_INTF_TS_NO_VAPI) || defined(OSM_VENDOR_INTF_TS))
-void
-osm_vendor_set_sm(
- IN osm_bind_handle_t h_bind,
- IN boolean_t is_sm_val )
+void osm_vendor_set_sm(IN osm_bind_handle_t h_bind, IN boolean_t is_sm_val)
{
- osmv_bind_obj_t *p_bo = ( osmv_bind_obj_t * ) h_bind;
- osm_vendor_t const *p_vend = p_bo->p_vendor;
- int ts_ioctl_ret;
- int device_fd = ((osmv_TOPSPIN_transport_mgr_t*)(p_bo->p_transp_mgr))->device_fd;
- struct ib_set_port_info_ioctl set_port_data;
-
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_set_sm );
-
- memset(&set_port_data, 0, sizeof(set_port_data));
-
- set_port_data.port = p_bo->port_num;
- set_port_data.port_info.valid_fields = IB_PORT_IS_SM;
- set_port_data.port_info.is_sm = is_sm_val;
- ts_ioctl_ret = ioctl(device_fd, TS_IB_IOCSPORTINFO, &set_port_data);
- if ( ts_ioctl_ret < 0 )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_set_sm: ERR 6805: "
- "Unable set 'IS_SM' bit to:%u in port attributes (%d).\n",
- is_sm_val, ts_ioctl_ret );
- }
-
- OSM_LOG_EXIT( p_vend->p_log );
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ osm_vendor_t const *p_vend = p_bo->p_vendor;
+ int ts_ioctl_ret;
+ int device_fd =
+ ((osmv_TOPSPIN_transport_mgr_t *) (p_bo->p_transp_mgr))->device_fd;
+ struct ib_set_port_info_ioctl set_port_data;
+
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_set_sm);
+
+ memset(&set_port_data, 0, sizeof(set_port_data));
+
+ set_port_data.port = p_bo->port_num;
+ set_port_data.port_info.valid_fields = IB_PORT_IS_SM;
+ set_port_data.port_info.is_sm = is_sm_val;
+ ts_ioctl_ret = ioctl(device_fd, TS_IB_IOCSPORTINFO, &set_port_data);
+ if (ts_ioctl_ret < 0) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_set_sm: ERR 6805: "
+ "Unable set 'IS_SM' bit to:%u in port attributes (%d).\n",
+ is_sm_val, ts_ioctl_ret);
+ }
+
+ OSM_LOG_EXIT(p_vend->p_log);
}
#endif
-
diff --git a/opensm/libvendor/osm_vendor_mlx_ts_anafa.c b/opensm/libvendor/osm_vendor_mlx_ts_anafa.c
index f812405..f3569a7 100644
--- a/opensm/libvendor/osm_vendor_mlx_ts_anafa.c
+++ b/opensm/libvendor/osm_vendor_mlx_ts_anafa.c
@@ -43,7 +43,7 @@
#if HAVE_CONFIG_H
# include <config.h>
-#endif /* HAVE_CONFIG_H */
+#endif /* HAVE_CONFIG_H */
#include <sys/types.h>
#include <sys/stat.h>
@@ -63,18 +63,17 @@
#include <opensm/osm_ts_useraccess.h>
static void
- __osmv_TOPSPIN_ANAFA_mad_addr_to_osm_addr (IN osm_vendor_t const *p_vend,
- IN struct ib_mad *p_mad,
- IN uint8_t is_smi,
- OUT osm_mad_addr_t * p_mad_addr);
+__osmv_TOPSPIN_ANAFA_mad_addr_to_osm_addr(IN osm_vendor_t const *p_vend,
+ IN struct ib_mad *p_mad,
+ IN uint8_t is_smi,
+ OUT osm_mad_addr_t * p_mad_addr);
static void
- __osmv_TOPSPIN_ANAFA_osm_addr_to_mad_addr (IN const osm_mad_addr_t *
- p_mad_addr, IN uint8_t is_smi,
- OUT struct ib_mad *p_mad);
+__osmv_TOPSPIN_ANAFA_osm_addr_to_mad_addr(IN const osm_mad_addr_t *
+ p_mad_addr, IN uint8_t is_smi,
+ OUT struct ib_mad *p_mad);
-void
-__osmv_TOPSPIN_ANAFA_receiver_thr (void *p_ctx)
+void __osmv_TOPSPIN_ANAFA_receiver_thr(void *p_ctx)
{
int ts_ret_code;
struct ib_mad mad;
@@ -82,63 +81,62 @@ __osmv_TOPSPIN_ANAFA_receiver_thr (void *p_ctx)
osmv_bind_obj_t *const p_bo = (osmv_bind_obj_t *) p_ctx;
ib_api_status_t status = IB_SUCCESS;
- OSM_LOG_ENTER (p_bo->p_vendor->p_log,
- __osmv_TOPSPIN_ANAFA_receiver_thr);
+ OSM_LOG_ENTER(p_bo->p_vendor->p_log, __osmv_TOPSPIN_ANAFA_receiver_thr);
/* Make sure the p_bo object is still relevant */
- if (( p_bo->magic_ptr != p_bo) || p_bo->is_closing )
+ if ((p_bo->magic_ptr != p_bo) || p_bo->is_closing)
return;
/* we set the type of cancelation for this thread */
/* pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); */
while (1) {
- /* Make sure the p_bo object is still relevant */
- if (( p_bo->magic_ptr != p_bo) || p_bo->is_closing )
- return;
+ /* Make sure the p_bo object is still relevant */
+ if ((p_bo->magic_ptr != p_bo) || p_bo->is_closing)
+ return;
/* we read one mad at a time and pass it to the read callback function */
ts_ret_code =
- read (((osmv_TOPSPIN_ANAFA_transport_mgr_t *) (p_bo->
- p_transp_mgr))->
- device_fd, &mad, sizeof (mad));
-
- /* Make sure the p_bo object is still relevant */
- if (( p_bo->magic_ptr != p_bo) || p_bo->is_closing )
- return;
-
- if (ts_ret_code != sizeof (mad)) {
- osm_log (p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "__osmv_TOPSPIN_ANAFA_receiver_thr: ERR 6903: "
- "error with read, bytes = %d\n", ts_ret_code);
+ read(((osmv_TOPSPIN_ANAFA_transport_mgr_t *) (p_bo->
+ p_transp_mgr))->
+ device_fd, &mad, sizeof(mad));
+
+ /* Make sure the p_bo object is still relevant */
+ if ((p_bo->magic_ptr != p_bo) || p_bo->is_closing)
+ return;
+
+ if (ts_ret_code != sizeof(mad)) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "__osmv_TOPSPIN_ANAFA_receiver_thr: ERR 6903: "
+ "error with read, bytes = %d\n", ts_ret_code);
break;
} else {
- osm_log (p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "__osmv_TOPSPIN_ANAFA_receiver_thr: "
- "MAD QPN:%d SLID:0x%04x class:0x%02x "
- "method:0x%02x attr:0x%04x status:0x%04x "
- "tid:0x%016" PRIx64 "\n",
- mad.dqpn,
- cl_ntoh16 (mad.slid),
- mad.mgmt_class,
- mad.r_method,
- cl_ntoh16 (mad.attribute_id),
- cl_ntoh16 (mad.status),
- cl_ntoh64 (mad.transaction_id));
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "__osmv_TOPSPIN_ANAFA_receiver_thr: "
+ "MAD QPN:%d SLID:0x%04x class:0x%02x "
+ "method:0x%02x attr:0x%04x status:0x%04x "
+ "tid:0x%016" PRIx64 "\n",
+ mad.dqpn,
+ cl_ntoh16(mad.slid),
+ mad.mgmt_class,
+ mad.r_method,
+ cl_ntoh16(mad.attribute_id),
+ cl_ntoh16(mad.status),
+ cl_ntoh64(mad.transaction_id));
/* first arrange an address */
__osmv_TOPSPIN_ANAFA_mad_addr_to_osm_addr
(p_bo->p_vendor, &mad,
- (((ib_mad_t *) & mad)->mgmt_class ==
- IB_MCLASS_SUBN_LID)
- || (((ib_mad_t *) & mad)->mgmt_class ==
- IB_MCLASS_SUBN_DIR), &mad_addr);
+ (((ib_mad_t *) & mad)->mgmt_class ==
+ IB_MCLASS_SUBN_LID)
+ || (((ib_mad_t *) & mad)->mgmt_class ==
+ IB_MCLASS_SUBN_DIR), &mad_addr);
/* call the receiver callback */
status =
- osmv_dispatch_mad ((osm_bind_handle_t) p_bo,
- (void *)&mad, &mad_addr);
+ osmv_dispatch_mad((osm_bind_handle_t) p_bo,
+ (void *)&mad, &mad_addr);
/* Make sure the p_bo object is still relevant */
if (p_bo->magic_ptr != p_bo)
@@ -146,16 +144,16 @@ __osmv_TOPSPIN_ANAFA_receiver_thr (void *p_ctx)
if (IB_INTERRUPTED == status) {
- osm_log (p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "__osmv_TOPSPIN_ANAFA_receiver_thr: "
- "The bind handle %p is being closed. "
- "Breaking the loop.\n", p_bo);
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "__osmv_TOPSPIN_ANAFA_receiver_thr: "
+ "The bind handle %p is being closed. "
+ "Breaking the loop.\n", p_bo);
break;
}
}
}
- OSM_LOG_EXIT (p_bo->p_vendor->p_log);
+ OSM_LOG_EXIT(p_bo->p_vendor->p_log);
}
/*
@@ -167,11 +165,9 @@ __osmv_TOPSPIN_ANAFA_receiver_thr (void *p_ctx)
*/
ib_api_status_t
-osmv_transport_init (
- IN osm_bind_info_t * p_info,
- IN char hca_id[VENDOR_HCA_MAXNAMES],
- IN uint8_t hca_idx,
- IN osmv_bind_obj_t * p_bo)
+osmv_transport_init(IN osm_bind_info_t * p_info,
+ IN char hca_id[VENDOR_HCA_MAXNAMES],
+ IN uint8_t hca_idx, IN osmv_bind_obj_t * p_bo)
{
cl_status_t cl_st;
@@ -185,18 +181,18 @@ osmv_transport_init (
(osmv_TOPSPIN_ANAFA_transport_info_t *) p_bo->p_vendor->
p_transport_info;
- p_mgr = malloc (sizeof (osmv_TOPSPIN_ANAFA_transport_mgr_t));
+ p_mgr = malloc(sizeof(osmv_TOPSPIN_ANAFA_transport_mgr_t));
if (!p_mgr) {
return IB_INSUFFICIENT_MEMORY;
}
- memset(p_mgr, 0, sizeof (osmv_TOPSPIN_ANAFA_transport_mgr_t));
+ memset(p_mgr, 0, sizeof(osmv_TOPSPIN_ANAFA_transport_mgr_t));
/* open TopSpin file device */
- device_fd = open (device_file, O_RDWR);
+ device_fd = open(device_file, O_RDWR);
if (device_fd < 0) {
- fprintf (stderr, "Fatal: Fail to open the file:%s err:%d\n",
- device_file, errno);
+ fprintf(stderr, "Fatal: Fail to open the file:%s err:%d\n",
+ device_file, errno);
return IB_ERROR;
}
p_mgr->device_fd = device_fd;
@@ -205,7 +201,7 @@ osmv_transport_init (
* Create the MAD filter on this file handle.
*/
- filter.port = 0; /* Victor */
+ filter.port = 0; /* Victor */
filter.direction = TS_IB_MAD_DIRECTION_IN;
filter.mask =
TS_IB_MAD_FILTER_DIRECTION |
@@ -217,13 +213,13 @@ osmv_transport_init (
case IB_MCLASS_SUBN_DIR:
filter.qpn = 0;
filter.mgmt_class = IB_MCLASS_SUBN_LID;
- ts_ioctl_ret = ioctl (device_fd, TS_IB_IOCSMADFILTADD, &filter);
+ ts_ioctl_ret = ioctl(device_fd, TS_IB_IOCSMADFILTADD, &filter);
if (ts_ioctl_ret < 0) {
return IB_ERROR;
}
filter.mgmt_class = IB_MCLASS_SUBN_DIR;
- ts_ioctl_ret = ioctl (device_fd, TS_IB_IOCSMADFILTADD, &filter);
+ ts_ioctl_ret = ioctl(device_fd, TS_IB_IOCSMADFILTADD, &filter);
if (ts_ioctl_ret < 0) {
return IB_ERROR;
}
@@ -234,7 +230,7 @@ osmv_transport_init (
default:
filter.qpn = 1;
filter.mgmt_class = p_info->mad_class;
- ts_ioctl_ret = ioctl (device_fd, TS_IB_IOCSMADFILTADD, &filter);
+ ts_ioctl_ret = ioctl(device_fd, TS_IB_IOCSMADFILTADD, &filter);
if (ts_ioctl_ret < 0) {
return IB_ERROR;
}
@@ -250,8 +246,8 @@ osmv_transport_init (
/* init receiver thread */
cl_st =
- cl_thread_init (&p_mgr->receiver, __osmv_TOPSPIN_ANAFA_receiver_thr,
- (void *)p_bo, "osmv TOPSPIN_ANAFA rcv thr");
+ cl_thread_init(&p_mgr->receiver, __osmv_TOPSPIN_ANAFA_receiver_thr,
+ (void *)p_bo, "osmv TOPSPIN_ANAFA rcv thr");
return (ib_api_status_t) cl_st;
}
@@ -265,9 +261,8 @@ osmv_transport_init (
*/
ib_api_status_t
-osmv_transport_mad_send (IN const osm_bind_handle_t h_bind,
- IN void *p_mad,
- IN const osm_mad_addr_t * p_mad_addr)
+osmv_transport_mad_send(IN const osm_bind_handle_t h_bind,
+ IN void *p_mad, IN const osm_mad_addr_t * p_mad_addr)
{
osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
@@ -278,7 +273,7 @@ osmv_transport_mad_send (IN const osm_bind_handle_t h_bind,
const ib_mad_t *p_mad_hdr = p_mad;
- OSM_LOG_ENTER (p_vend->p_log, osmv_transport_mad_send);
+ OSM_LOG_ENTER(p_vend->p_log, osmv_transport_mad_send);
/* Make sure the p_bo object is still relevant */
if (p_bo->magic_ptr != p_bo)
@@ -287,7 +282,7 @@ osmv_transport_mad_send (IN const osm_bind_handle_t h_bind,
/*
* Copy the MAD over to the sent mad
*/
- memcpy (&ts_mad, p_mad_hdr, MAD_BLOCK_SIZE);
+ memcpy(&ts_mad, p_mad_hdr, MAD_BLOCK_SIZE);
/*
* For all sends other than directed route SM MADs,
@@ -295,11 +290,11 @@ osmv_transport_mad_send (IN const osm_bind_handle_t h_bind,
*/
if (p_mad_hdr->mgmt_class != IB_MCLASS_SUBN_DIR) {
- __osmv_TOPSPIN_ANAFA_osm_addr_to_mad_addr (p_mad_addr,
- p_mad_hdr->
- mgmt_class ==
- IB_MCLASS_SUBN_LID,
- &ts_mad);
+ __osmv_TOPSPIN_ANAFA_osm_addr_to_mad_addr(p_mad_addr,
+ p_mad_hdr->
+ mgmt_class ==
+ IB_MCLASS_SUBN_LID,
+ &ts_mad);
} else {
/* is a directed route - we need to construct a permissive address */
/* we do not need port number since it is part of the mad_hndl */
@@ -316,18 +311,18 @@ osmv_transport_mad_send (IN const osm_bind_handle_t h_bind,
}
/* ts_mad.port = p_bo->port_num; */
- ts_mad.port = 0; /* Victor */
+ ts_mad.port = 0; /* Victor */
/* send it */
ret =
- write (((osmv_TOPSPIN_ANAFA_transport_mgr_t *) (p_bo->
- p_transp_mgr))->
- device_fd, &ts_mad, sizeof (ts_mad));
-
- if (ret != sizeof (ts_mad)) {
- osm_log (p_vend->p_log, OSM_LOG_ERROR,
- "osmv_transport_mad_send: ERR 6904: "
- "Error sending mad (%d).\n", ret);
+ write(((osmv_TOPSPIN_ANAFA_transport_mgr_t *) (p_bo->
+ p_transp_mgr))->
+ device_fd, &ts_mad, sizeof(ts_mad));
+
+ if (ret != sizeof(ts_mad)) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osmv_transport_mad_send: ERR 6904: "
+ "Error sending mad (%d).\n", ret);
status = IB_ERROR;
goto Exit;
}
@@ -335,39 +330,38 @@ osmv_transport_mad_send (IN const osm_bind_handle_t h_bind,
status = IB_SUCCESS;
Exit:
- OSM_LOG_EXIT (p_vend->p_log);
+ OSM_LOG_EXIT(p_vend->p_log);
return (status);
}
-void
-osmv_transport_done (IN const osm_bind_handle_t h_bind)
+void osmv_transport_done(IN const osm_bind_handle_t h_bind)
{
osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
osmv_TOPSPIN_ANAFA_transport_mgr_t *p_tpot_mgr =
(osmv_TOPSPIN_ANAFA_transport_mgr_t *) (p_bo->p_transp_mgr);
- CL_ASSERT (p_bo);
+ CL_ASSERT(p_bo);
/* First of all - zero out the magic_ptr, so if a callback is called -
it'll know that we are currently closing down, and will not handle the
mad. */
p_bo->magic_ptr = 0;
- /* usleep(3000000); */
+ /* usleep(3000000); */
/* pthread_cancel (p_tpot_mgr->receiver.osd.id); */
- cl_thread_destroy (&(p_tpot_mgr->receiver));
- free (p_tpot_mgr);
+ cl_thread_destroy(&(p_tpot_mgr->receiver));
+ free(p_tpot_mgr);
}
static void
-__osmv_TOPSPIN_ANAFA_osm_addr_to_mad_addr (IN const osm_mad_addr_t * p_mad_addr,
- IN uint8_t is_smi,
- OUT struct ib_mad *p_mad)
+__osmv_TOPSPIN_ANAFA_osm_addr_to_mad_addr(IN const osm_mad_addr_t * p_mad_addr,
+ IN uint8_t is_smi,
+ OUT struct ib_mad *p_mad)
{
/* For global destination or Multicast address: */
- p_mad->dlid = cl_ntoh16 (p_mad_addr->dest_lid);
+ p_mad->dlid = cl_ntoh16(p_mad_addr->dest_lid);
p_mad->sl = p_mad_addr->addr_type.gsi.service_level;
if (is_smi) {
p_mad->sqpn = 0;
@@ -384,17 +378,17 @@ __osmv_TOPSPIN_ANAFA_osm_addr_to_mad_addr (IN const osm_mad_addr_t * p_mad_addr,
}
static void
-__osmv_TOPSPIN_ANAFA_mad_addr_to_osm_addr (IN osm_vendor_t const *p_vend,
- IN struct ib_mad *p_mad,
- IN uint8_t is_smi,
- OUT osm_mad_addr_t * p_mad_addr)
+__osmv_TOPSPIN_ANAFA_mad_addr_to_osm_addr(IN osm_vendor_t const *p_vend,
+ IN struct ib_mad *p_mad,
+ IN uint8_t is_smi,
+ OUT osm_mad_addr_t * p_mad_addr)
{
- p_mad_addr->dest_lid = cl_hton16 (p_mad->slid);
+ p_mad_addr->dest_lid = cl_hton16(p_mad->slid);
p_mad_addr->static_rate = 0;
p_mad_addr->path_bits = 0;
if (is_smi) {
/* SMI */
- p_mad_addr->addr_type.smi.source_lid = cl_hton16 (p_mad->slid);
+ p_mad_addr->addr_type.smi.source_lid = cl_hton16(p_mad->slid);
p_mad_addr->addr_type.smi.port_num = p_mad->port;
} else {
/* GSI */
@@ -427,6 +421,3 @@ __osmv_TOPSPIN_ANAFA_mad_addr_to_osm_addr (IN osm_vendor_t const *p_vend,
*/
}
}
-
-
-
diff --git a/opensm/libvendor/osm_vendor_mlx_txn.c b/opensm/libvendor/osm_vendor_mlx_txn.c
index 234e33b..1399ad6 100644
--- a/opensm/libvendor/osm_vendor_mlx_txn.c
+++ b/opensm/libvendor/osm_vendor_mlx_txn.c
@@ -35,7 +35,7 @@
#if HAVE_CONFIG_H
# include <config.h>
-#endif /* HAVE_CONFIG_H */
+#endif /* HAVE_CONFIG_H */
#include <stdlib.h>
@@ -46,147 +46,138 @@
#include <vendor/osm_vendor_mlx_sender.h>
static ib_api_status_t
-__osmv_txnmgr_lookup(IN osmv_txn_mgr_t *p_tx_mgr,
- IN uint64_t key,
- OUT osmv_txn_ctx_t **pp_txn);
+__osmv_txnmgr_lookup(IN osmv_txn_mgr_t * p_tx_mgr,
+ IN uint64_t key, OUT osmv_txn_ctx_t ** pp_txn);
static ib_api_status_t
-__osmv_txnmgr_insert_txn(IN osmv_txn_mgr_t *p_tx_mgr,
- IN osmv_txn_ctx_t *p_txn,
- IN uint64_t key);
+__osmv_txnmgr_insert_txn(IN osmv_txn_mgr_t * p_tx_mgr,
+ IN osmv_txn_ctx_t * p_txn, IN uint64_t key);
static ib_api_status_t
-__osmv_txnmgr_remove_txn(IN osmv_txn_mgr_t *p_tx_mgr,
- IN uint64_t key,
- OUT osmv_txn_ctx_t **pp_txn);
+__osmv_txnmgr_remove_txn(IN osmv_txn_mgr_t * p_tx_mgr,
+ IN uint64_t key, OUT osmv_txn_ctx_t ** pp_txn);
-static void
-__osmv_txn_all_done(osm_bind_handle_t h_bind);
+static void __osmv_txn_all_done(osm_bind_handle_t h_bind);
static uint64_t
__osmv_txn_timeout_cb(IN uint64_t key,
- IN uint32_t num_regs,
- IN void *cb_context);
+ IN uint32_t num_regs, IN void *cb_context);
ib_api_status_t
-osmv_txn_init(IN osm_bind_handle_t h_bind,
- IN uint64_t tid,
- IN uint64_t key,
- OUT osmv_txn_ctx_t **pp_txn)
+osmv_txn_init(IN osm_bind_handle_t h_bind,
+ IN uint64_t tid, IN uint64_t key, OUT osmv_txn_ctx_t ** pp_txn)
{
- ib_api_status_t st;
- osmv_txn_ctx_t *p_txn;
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t*)h_bind;
-
- OSM_LOG_ENTER( p_bo->p_vendor->p_log, osmv_txn_init);
-
- CL_ASSERT(NULL != h_bind && NULL != pp_txn);
-
- osm_log( p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "Starting transaction 0x%llX (key=0x%llX)\n", tid, key);
-
- p_txn = malloc(sizeof(osmv_txn_ctx_t));
- if (! p_txn)
- {
- return IB_INSUFFICIENT_MEMORY;
- }
-
- memset(p_txn, 0, sizeof(osmv_txn_ctx_t));
- p_txn->p_log = p_bo->txn_mgr.p_log;
- p_txn->tid = tid;
- p_txn->key = key;
- p_txn->p_madw = NULL;
- p_txn->rmpp_txfr.rmpp_state = OSMV_TXN_RMPP_NONE;
-
- /* insert into transaction manager DB */
- st= __osmv_txnmgr_insert_txn(&p_bo->txn_mgr, p_txn, key);
- if (IB_SUCCESS != st)
- {
- osm_log( p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "osmv_txn_init: ERR 6703: "
- "Failed to insert to transaction 0x%llX (key=0x%llX) to manager DB\n", tid, key);
- goto insert_txn_failed;
- }
-
- *pp_txn = p_txn;
- OSM_LOG_EXIT( p_bo->p_vendor->p_log );
- return IB_SUCCESS;
-
- insert_txn_failed:
- free(p_txn);
-
- OSM_LOG_EXIT( p_bo->p_vendor->p_log );
- return st;
+ ib_api_status_t st;
+ osmv_txn_ctx_t *p_txn;
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+
+ OSM_LOG_ENTER(p_bo->p_vendor->p_log, osmv_txn_init);
+
+ CL_ASSERT(NULL != h_bind && NULL != pp_txn);
+
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "Starting transaction 0x%llX (key=0x%llX)\n", tid, key);
+
+ p_txn = malloc(sizeof(osmv_txn_ctx_t));
+ if (!p_txn) {
+ return IB_INSUFFICIENT_MEMORY;
+ }
+
+ memset(p_txn, 0, sizeof(osmv_txn_ctx_t));
+ p_txn->p_log = p_bo->txn_mgr.p_log;
+ p_txn->tid = tid;
+ p_txn->key = key;
+ p_txn->p_madw = NULL;
+ p_txn->rmpp_txfr.rmpp_state = OSMV_TXN_RMPP_NONE;
+
+ /* insert into transaction manager DB */
+ st = __osmv_txnmgr_insert_txn(&p_bo->txn_mgr, p_txn, key);
+ if (IB_SUCCESS != st) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "osmv_txn_init: ERR 6703: "
+ "Failed to insert to transaction 0x%llX (key=0x%llX) to manager DB\n",
+ tid, key);
+ goto insert_txn_failed;
+ }
+
+ *pp_txn = p_txn;
+ OSM_LOG_EXIT(p_bo->p_vendor->p_log);
+ return IB_SUCCESS;
+
+ insert_txn_failed:
+ free(p_txn);
+
+ OSM_LOG_EXIT(p_bo->p_vendor->p_log);
+ return st;
}
ib_api_status_t
-osmv_txn_init_rmpp_sender(IN osm_bind_handle_t h_bind,
- IN osmv_txn_ctx_t *p_txn,
- IN osm_madw_t *p_madw)
+osmv_txn_init_rmpp_sender(IN osm_bind_handle_t h_bind,
+ IN osmv_txn_ctx_t * p_txn, IN osm_madw_t * p_madw)
{
- ib_api_status_t st;
+ ib_api_status_t st;
- CL_ASSERT(p_txn);
+ CL_ASSERT(p_txn);
- /* Double-Sided RMPP Direction Switch */
- osmv_txn_remove_timeout_ev(h_bind, osmv_txn_get_key(p_txn));
+ /* Double-Sided RMPP Direction Switch */
+ osmv_txn_remove_timeout_ev(h_bind, osmv_txn_get_key(p_txn));
- p_txn->rmpp_txfr.rmpp_state = OSMV_TXN_RMPP_SENDER;
- p_txn->rmpp_txfr.p_rmpp_send_ctx = malloc(sizeof(osmv_rmpp_send_ctx_t));
+ p_txn->rmpp_txfr.rmpp_state = OSMV_TXN_RMPP_SENDER;
+ p_txn->rmpp_txfr.p_rmpp_send_ctx = malloc(sizeof(osmv_rmpp_send_ctx_t));
- if (!p_txn->rmpp_txfr.p_rmpp_send_ctx)
- {
- return IB_INSUFFICIENT_MEMORY;
- }
+ if (!p_txn->rmpp_txfr.p_rmpp_send_ctx) {
+ return IB_INSUFFICIENT_MEMORY;
+ }
- memset(p_txn->rmpp_txfr.p_rmpp_send_ctx, 0, sizeof(osmv_rmpp_send_ctx_t));
+ memset(p_txn->rmpp_txfr.p_rmpp_send_ctx, 0,
+ sizeof(osmv_rmpp_send_ctx_t));
- st = osmv_rmpp_send_ctx_init(p_txn->rmpp_txfr.p_rmpp_send_ctx,
- (void*)p_madw->p_mad,
- p_madw->mad_size,
- p_txn->p_log);
- return st;
+ st = osmv_rmpp_send_ctx_init(p_txn->rmpp_txfr.p_rmpp_send_ctx,
+ (void *)p_madw->p_mad,
+ p_madw->mad_size, p_txn->p_log);
+ return st;
}
ib_api_status_t
-osmv_txn_init_rmpp_receiver(IN osm_bind_handle_t h_bind,
- IN osmv_txn_ctx_t *p_txn,
- IN boolean_t is_init_by_peer)
+osmv_txn_init_rmpp_receiver(IN osm_bind_handle_t h_bind,
+ IN osmv_txn_ctx_t * p_txn,
+ IN boolean_t is_init_by_peer)
{
- ib_api_status_t st;
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *)h_bind;
- uint64_t key = osmv_txn_get_key(p_txn);
+ ib_api_status_t st;
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ uint64_t key = osmv_txn_get_key(p_txn);
- CL_ASSERT(p_txn);
+ CL_ASSERT(p_txn);
- /* Double-Sided RMPP Direction Switch */
- osmv_txn_remove_timeout_ev(h_bind, key);
+ /* Double-Sided RMPP Direction Switch */
+ osmv_txn_remove_timeout_ev(h_bind, key);
- /* Set the Transaction Timeout value */
- st = osmv_txn_set_timeout_ev(h_bind, key, p_bo->p_vendor->ttime_timeout);
- if (IB_SUCCESS != st)
- {
+ /* Set the Transaction Timeout value */
+ st = osmv_txn_set_timeout_ev(h_bind, key,
+ p_bo->p_vendor->ttime_timeout);
+ if (IB_SUCCESS != st) {
- return st;
- }
+ return st;
+ }
- p_txn->rmpp_txfr.rmpp_state = OSMV_TXN_RMPP_RECEIVER;
- p_txn->rmpp_txfr.is_rmpp_init_by_peer = is_init_by_peer;
+ p_txn->rmpp_txfr.rmpp_state = OSMV_TXN_RMPP_RECEIVER;
+ p_txn->rmpp_txfr.is_rmpp_init_by_peer = is_init_by_peer;
- p_txn->rmpp_txfr.p_rmpp_recv_ctx = malloc(sizeof(osmv_rmpp_recv_ctx_t));
+ p_txn->rmpp_txfr.p_rmpp_recv_ctx = malloc(sizeof(osmv_rmpp_recv_ctx_t));
- if (!p_txn->rmpp_txfr.p_rmpp_recv_ctx)
- {
+ if (!p_txn->rmpp_txfr.p_rmpp_recv_ctx) {
- osmv_txn_remove_timeout_ev(h_bind, key);
- return IB_INSUFFICIENT_MEMORY;
- }
+ osmv_txn_remove_timeout_ev(h_bind, key);
+ return IB_INSUFFICIENT_MEMORY;
+ }
- memset(p_txn->rmpp_txfr.p_rmpp_recv_ctx, 0, sizeof(osmv_rmpp_recv_ctx_t));
+ memset(p_txn->rmpp_txfr.p_rmpp_recv_ctx, 0,
+ sizeof(osmv_rmpp_recv_ctx_t));
- st = osmv_rmpp_recv_ctx_init(p_txn->rmpp_txfr.p_rmpp_recv_ctx,p_txn->p_log);
+ st = osmv_rmpp_recv_ctx_init(p_txn->rmpp_txfr.p_rmpp_recv_ctx,
+ p_txn->p_log);
- return st;
+ return st;
}
/*
@@ -199,21 +190,18 @@ osmv_txn_init_rmpp_receiver(IN osm_bind_handle_t h_bind,
*
*/
ib_api_status_t
-osmv_txn_set_timeout_ev(IN osm_bind_handle_t h_bind,
- IN uint64_t key,
- IN uint64_t msec)
+osmv_txn_set_timeout_ev(IN osm_bind_handle_t h_bind,
+ IN uint64_t key, IN uint64_t msec)
{
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *)h_bind;
- cl_event_wheel_t *p_event_wheel = p_bo->txn_mgr.p_event_wheel;
- cl_status_t status;
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ cl_event_wheel_t *p_event_wheel = p_bo->txn_mgr.p_event_wheel;
+ cl_status_t status;
- status = cl_event_wheel_reg(p_event_wheel,
- key,
- cl_get_time_stamp() + 1000*msec, /* TTL */
- __osmv_txn_timeout_cb,
- p_bo /* The context */);
+ status = cl_event_wheel_reg(p_event_wheel, key, cl_get_time_stamp() + 1000 * msec, /* TTL */
+ __osmv_txn_timeout_cb,
+ p_bo /* The context */ );
- return (ib_api_status_t)status;
+ return (ib_api_status_t) status;
}
/*
@@ -225,493 +213,463 @@ osmv_txn_set_timeout_ev(IN osm_bind_handle_t h_bind,
* SEE ALSO
*
*/
-void
-osmv_txn_remove_timeout_ev(IN osm_bind_handle_t h_bind,
- IN uint64_t key)
+void osmv_txn_remove_timeout_ev(IN osm_bind_handle_t h_bind, IN uint64_t key)
{
- cl_event_wheel_t *p_event_wheel = ((osmv_bind_obj_t *)h_bind)->txn_mgr.p_event_wheel;
- cl_event_wheel_unreg(p_event_wheel, key);
+ cl_event_wheel_t *p_event_wheel =
+ ((osmv_bind_obj_t *) h_bind)->txn_mgr.p_event_wheel;
+ cl_event_wheel_unreg(p_event_wheel, key);
}
void
osmv_txn_done(IN osm_bind_handle_t h_bind,
- IN uint64_t key,
- IN boolean_t is_in_cb)
+ IN uint64_t key, IN boolean_t is_in_cb)
{
- osmv_txn_ctx_t* p_ctx;
- osmv_bind_obj_t * const p_bo = (osmv_bind_obj_t *)h_bind;
-
- OSM_LOG_ENTER(p_bo->p_vendor->p_log, osmv_txn_done);
-
- CL_ASSERT(h_bind);
-
- /* Cancel the (single) timeout possibly outstanding for this txn
- * Don't do this if you are in the callback context, for 2 reasons:
- * (1) The event wheel will remove the context itself.
- * (2) If we try to, there is a deadlock in the event wheel
- */
- if (FALSE == is_in_cb)
- {
- osmv_txn_remove_timeout_ev(h_bind, key);
- }
-
- /* Remove from DB */
- if (IB_NOT_FOUND == __osmv_txnmgr_remove_txn(&p_bo->txn_mgr, key, &p_ctx))
- {
- return;
- }
-
- /* Destroy the transaction's RMPP contexts
- * (can be more than one in the case of double sided transfer)
- */
-
- if (p_ctx->rmpp_txfr.p_rmpp_send_ctx)
- {
- osmv_rmpp_send_ctx_done(p_ctx->rmpp_txfr.p_rmpp_send_ctx);
- }
-
- if (p_ctx->rmpp_txfr.p_rmpp_recv_ctx)
- {
- osmv_rmpp_recv_ctx_done(p_ctx->rmpp_txfr.p_rmpp_recv_ctx);
- }
-
- free(p_ctx);
-
- OSM_LOG_EXIT(p_bo->p_vendor->p_log);
+ osmv_txn_ctx_t *p_ctx;
+ osmv_bind_obj_t *const p_bo = (osmv_bind_obj_t *) h_bind;
+
+ OSM_LOG_ENTER(p_bo->p_vendor->p_log, osmv_txn_done);
+
+ CL_ASSERT(h_bind);
+
+ /* Cancel the (single) timeout possibly outstanding for this txn
+ * Don't do this if you are in the callback context, for 2 reasons:
+ * (1) The event wheel will remove the context itself.
+ * (2) If we try to, there is a deadlock in the event wheel
+ */
+ if (FALSE == is_in_cb) {
+ osmv_txn_remove_timeout_ev(h_bind, key);
+ }
+
+ /* Remove from DB */
+ if (IB_NOT_FOUND ==
+ __osmv_txnmgr_remove_txn(&p_bo->txn_mgr, key, &p_ctx)) {
+ return;
+ }
+
+ /* Destroy the transaction's RMPP contexts
+ * (can be more than one in the case of double sided transfer)
+ */
+
+ if (p_ctx->rmpp_txfr.p_rmpp_send_ctx) {
+ osmv_rmpp_send_ctx_done(p_ctx->rmpp_txfr.p_rmpp_send_ctx);
+ }
+
+ if (p_ctx->rmpp_txfr.p_rmpp_recv_ctx) {
+ osmv_rmpp_recv_ctx_done(p_ctx->rmpp_txfr.p_rmpp_recv_ctx);
+ }
+
+ free(p_ctx);
+
+ OSM_LOG_EXIT(p_bo->p_vendor->p_log);
}
ib_api_status_t
osmv_txn_lookup(IN osm_bind_handle_t h_bind,
- IN uint64_t key,
- OUT osmv_txn_ctx_t **pp_txn)
+ IN uint64_t key, OUT osmv_txn_ctx_t ** pp_txn)
{
- return __osmv_txnmgr_lookup(&(((osmv_bind_obj_t*)h_bind)->txn_mgr), key, pp_txn);
+ return __osmv_txnmgr_lookup(&(((osmv_bind_obj_t *) h_bind)->txn_mgr),
+ key, pp_txn);
}
-
-void
-osmv_txn_abort_rmpp_txns(osm_bind_handle_t h_bind)
+void osmv_txn_abort_rmpp_txns(osm_bind_handle_t h_bind)
{
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t*)h_bind;
- cl_map_item_t *p_item;
- cl_map_obj_t *p_obj;
- osmv_txn_ctx_t *p_txn;
- osmv_rmpp_send_ctx_t *p_send_ctx;
- cl_qmap_t *p_map = p_bo->txn_mgr.p_txn_map;
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ cl_map_item_t *p_item;
+ cl_map_obj_t *p_obj;
+ osmv_txn_ctx_t *p_txn;
+ osmv_rmpp_send_ctx_t *p_send_ctx;
+ cl_qmap_t *p_map = p_bo->txn_mgr.p_txn_map;
- OSM_LOG_ENTER( p_bo->p_vendor->p_log, osmv_txn_abort_rmpp_txns);
+ OSM_LOG_ENTER(p_bo->p_vendor->p_log, osmv_txn_abort_rmpp_txns);
- while (FALSE == cl_is_qmap_empty(p_map)) {
+ while (FALSE == cl_is_qmap_empty(p_map)) {
- p_item = cl_qmap_head(p_map);
- p_obj = PARENT_STRUCT(p_item,cl_map_obj_t,item);
- p_txn = (osmv_txn_ctx_t*)cl_qmap_obj(p_obj);
- p_send_ctx = osmv_txn_get_rmpp_send_ctx(p_txn);
+ p_item = cl_qmap_head(p_map);
+ p_obj = PARENT_STRUCT(p_item, cl_map_obj_t, item);
+ p_txn = (osmv_txn_ctx_t *) cl_qmap_obj(p_obj);
+ p_send_ctx = osmv_txn_get_rmpp_send_ctx(p_txn);
- if (NULL != p_send_ctx)
- {
+ if (NULL != p_send_ctx) {
- p_send_ctx->status = IB_INTERRUPTED;
+ p_send_ctx->status = IB_INTERRUPTED;
- /* Wake up the sender thread to let it break out */
- cl_event_signal(&p_send_ctx->event);
- }
+ /* Wake up the sender thread to let it break out */
+ cl_event_signal(&p_send_ctx->event);
+ }
- cl_qmap_remove_item(p_map, p_item);
- }
+ cl_qmap_remove_item(p_map, p_item);
+ }
- OSM_LOG_EXIT(p_bo->p_vendor->p_log);
+ OSM_LOG_EXIT(p_bo->p_vendor->p_log);
}
-
ib_api_status_t
-osmv_txnmgr_init(IN osmv_txn_mgr_t *p_tx_mgr,
- IN osm_log_t *p_log,
- IN cl_spinlock_t *p_lock)
+osmv_txnmgr_init(IN osmv_txn_mgr_t * p_tx_mgr,
+ IN osm_log_t * p_log, IN cl_spinlock_t * p_lock)
{
- cl_status_t cl_st = CL_SUCCESS;
-
- p_tx_mgr->p_event_wheel = malloc(sizeof(cl_event_wheel_t));
- if (!p_tx_mgr->p_event_wheel)
- {
- return IB_INSUFFICIENT_MEMORY;
- }
-
- memset(p_tx_mgr->p_event_wheel, 0, sizeof(cl_event_wheel_t));
-
- cl_event_wheel_construct(p_tx_mgr->p_event_wheel);
-
- /* NOTE! We are using an extended constructor.
- * We tell the Event Wheel run in a non-protected manner in the reg/unreg calls,
- * and acquire an external lock in the asynchronous callback.
- */
- cl_st = cl_event_wheel_init_ex(p_tx_mgr->p_event_wheel, p_log, p_lock);
- if (cl_st != CL_SUCCESS)
- {
- free(p_tx_mgr->p_event_wheel);
- return (ib_api_status_t)cl_st;
- }
-
- p_tx_mgr->p_txn_map = malloc(sizeof(cl_qmap_t));
- if (!p_tx_mgr->p_txn_map)
- {
- cl_event_wheel_destroy(p_tx_mgr->p_event_wheel);
- free(p_tx_mgr->p_event_wheel);
- return IB_INSUFFICIENT_MEMORY;
- }
-
- memset(p_tx_mgr->p_txn_map, 0, sizeof(cl_qmap_t));
-
- cl_qmap_init(p_tx_mgr->p_txn_map);
- p_tx_mgr->p_log = p_log;
-
- return cl_st;
+ cl_status_t cl_st = CL_SUCCESS;
+
+ p_tx_mgr->p_event_wheel = malloc(sizeof(cl_event_wheel_t));
+ if (!p_tx_mgr->p_event_wheel) {
+ return IB_INSUFFICIENT_MEMORY;
+ }
+
+ memset(p_tx_mgr->p_event_wheel, 0, sizeof(cl_event_wheel_t));
+
+ cl_event_wheel_construct(p_tx_mgr->p_event_wheel);
+
+ /* NOTE! We are using an extended constructor.
+ * We tell the Event Wheel run in a non-protected manner in the reg/unreg calls,
+ * and acquire an external lock in the asynchronous callback.
+ */
+ cl_st = cl_event_wheel_init_ex(p_tx_mgr->p_event_wheel, p_log, p_lock);
+ if (cl_st != CL_SUCCESS) {
+ free(p_tx_mgr->p_event_wheel);
+ return (ib_api_status_t) cl_st;
+ }
+
+ p_tx_mgr->p_txn_map = malloc(sizeof(cl_qmap_t));
+ if (!p_tx_mgr->p_txn_map) {
+ cl_event_wheel_destroy(p_tx_mgr->p_event_wheel);
+ free(p_tx_mgr->p_event_wheel);
+ return IB_INSUFFICIENT_MEMORY;
+ }
+
+ memset(p_tx_mgr->p_txn_map, 0, sizeof(cl_qmap_t));
+
+ cl_qmap_init(p_tx_mgr->p_txn_map);
+ p_tx_mgr->p_log = p_log;
+
+ return cl_st;
}
-void
-osmv_txnmgr_done(IN osm_bind_handle_t h_bind)
+void osmv_txnmgr_done(IN osm_bind_handle_t h_bind)
{
- osmv_bind_obj_t* p_bo = (osmv_bind_obj_t*)h_bind;
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
- __osmv_txn_all_done(h_bind);
- free(p_bo->txn_mgr.p_txn_map);
+ __osmv_txn_all_done(h_bind);
+ free(p_bo->txn_mgr.p_txn_map);
- cl_event_wheel_destroy(p_bo->txn_mgr.p_event_wheel);
- free(p_bo->txn_mgr.p_event_wheel);
+ cl_event_wheel_destroy(p_bo->txn_mgr.p_event_wheel);
+ free(p_bo->txn_mgr.p_event_wheel);
}
ib_api_status_t
-__osmv_txnmgr_lookup(IN osmv_txn_mgr_t *p_tx_mgr,
- IN uint64_t key,
- OUT osmv_txn_ctx_t **pp_txn)
+__osmv_txnmgr_lookup(IN osmv_txn_mgr_t * p_tx_mgr,
+ IN uint64_t key, OUT osmv_txn_ctx_t ** pp_txn)
{
- ib_api_status_t status = IB_SUCCESS;
- cl_map_item_t* p_item;
- cl_map_obj_t* p_obj;
-
- uint64_t tmp_key;
-
- OSM_LOG_ENTER( p_tx_mgr->p_log, __osmv_txnmgr_lookup );
-
- CL_ASSERT(p_tx_mgr);
- CL_ASSERT(pp_txn);
-
- osm_log(p_tx_mgr->p_log, OSM_LOG_DEBUG,
- "__osmv_txnmgr_lookup: "
- "Looking for key: 0x%llX in map ptr:%p\n", key, p_tx_mgr->p_txn_map );
-
- p_item = cl_qmap_head(p_tx_mgr->p_txn_map);
- while( p_item != cl_qmap_end(p_tx_mgr->p_txn_map) )
- {
- tmp_key = cl_qmap_key(p_item);
- osm_log(p_tx_mgr->p_log, OSM_LOG_DEBUG,
- "__osmv_txnmgr_lookup: "
- "Found key 0x%llX \n", tmp_key );
- p_item = cl_qmap_next(p_item);
- }
-
- p_item= cl_qmap_get(p_tx_mgr->p_txn_map,key);
- if (cl_qmap_end(p_tx_mgr->p_txn_map) == p_item)
- {
- status = IB_NOT_FOUND;
- }
- else
- {
- p_obj = PARENT_STRUCT(p_item, cl_map_obj_t,item);
- *pp_txn = cl_qmap_obj(p_obj);
- }
-
- OSM_LOG_EXIT(p_tx_mgr->p_log);
- return status;
+ ib_api_status_t status = IB_SUCCESS;
+ cl_map_item_t *p_item;
+ cl_map_obj_t *p_obj;
+
+ uint64_t tmp_key;
+
+ OSM_LOG_ENTER(p_tx_mgr->p_log, __osmv_txnmgr_lookup);
+
+ CL_ASSERT(p_tx_mgr);
+ CL_ASSERT(pp_txn);
+
+ osm_log(p_tx_mgr->p_log, OSM_LOG_DEBUG,
+ "__osmv_txnmgr_lookup: "
+ "Looking for key: 0x%llX in map ptr:%p\n", key,
+ p_tx_mgr->p_txn_map);
+
+ p_item = cl_qmap_head(p_tx_mgr->p_txn_map);
+ while (p_item != cl_qmap_end(p_tx_mgr->p_txn_map)) {
+ tmp_key = cl_qmap_key(p_item);
+ osm_log(p_tx_mgr->p_log, OSM_LOG_DEBUG,
+ "__osmv_txnmgr_lookup: "
+ "Found key 0x%llX \n", tmp_key);
+ p_item = cl_qmap_next(p_item);
+ }
+
+ p_item = cl_qmap_get(p_tx_mgr->p_txn_map, key);
+ if (cl_qmap_end(p_tx_mgr->p_txn_map) == p_item) {
+ status = IB_NOT_FOUND;
+ } else {
+ p_obj = PARENT_STRUCT(p_item, cl_map_obj_t, item);
+ *pp_txn = cl_qmap_obj(p_obj);
+ }
+
+ OSM_LOG_EXIT(p_tx_mgr->p_log);
+ return status;
}
ib_api_status_t
-__osmv_txnmgr_insert_txn(IN osmv_txn_mgr_t *p_tx_mgr,
- IN osmv_txn_ctx_t *p_txn,
- IN uint64_t key)
+__osmv_txnmgr_insert_txn(IN osmv_txn_mgr_t * p_tx_mgr,
+ IN osmv_txn_ctx_t * p_txn, IN uint64_t key)
{
- cl_map_obj_t* p_obj = NULL;
- cl_map_item_t* p_item;
- uint64_t tmp_key;
-
- CL_ASSERT(p_tx_mgr);
- CL_ASSERT(p_txn);
-
- key = osmv_txn_get_key(p_txn);
- p_obj = malloc(sizeof(cl_map_obj_t));
- if (NULL == p_obj)
- return IB_INSUFFICIENT_MEMORY;
-
- osm_log(p_tx_mgr->p_log, OSM_LOG_DEBUG,
- "__osmv_txnmgr_insert_txn: "
- "Inserting key: 0x%llX to map ptr:%p\n", key, p_tx_mgr->p_txn_map );
-
- memset(p_obj, 0, sizeof(cl_map_obj_t));
-
- cl_qmap_set_obj(p_obj,p_txn);
- /* assuming lookup with this key was made and the result was IB_NOT_FOUND */
- cl_qmap_insert(p_tx_mgr->p_txn_map, key, &p_obj->item);
-
- p_item = cl_qmap_head(p_tx_mgr->p_txn_map);
- while( p_item != cl_qmap_end(p_tx_mgr->p_txn_map) )
- {
- tmp_key = cl_qmap_key(p_item);
- osm_log(p_tx_mgr->p_log, OSM_LOG_DEBUG,
- "__osmv_txnmgr_insert_txn: "
- "Found key 0x%llX \n", tmp_key );
- p_item = cl_qmap_next(p_item);
- }
-
- return IB_SUCCESS;
+ cl_map_obj_t *p_obj = NULL;
+ cl_map_item_t *p_item;
+ uint64_t tmp_key;
+
+ CL_ASSERT(p_tx_mgr);
+ CL_ASSERT(p_txn);
+
+ key = osmv_txn_get_key(p_txn);
+ p_obj = malloc(sizeof(cl_map_obj_t));
+ if (NULL == p_obj)
+ return IB_INSUFFICIENT_MEMORY;
+
+ osm_log(p_tx_mgr->p_log, OSM_LOG_DEBUG,
+ "__osmv_txnmgr_insert_txn: "
+ "Inserting key: 0x%llX to map ptr:%p\n", key,
+ p_tx_mgr->p_txn_map);
+
+ memset(p_obj, 0, sizeof(cl_map_obj_t));
+
+ cl_qmap_set_obj(p_obj, p_txn);
+ /* assuming lookup with this key was made and the result was IB_NOT_FOUND */
+ cl_qmap_insert(p_tx_mgr->p_txn_map, key, &p_obj->item);
+
+ p_item = cl_qmap_head(p_tx_mgr->p_txn_map);
+ while (p_item != cl_qmap_end(p_tx_mgr->p_txn_map)) {
+ tmp_key = cl_qmap_key(p_item);
+ osm_log(p_tx_mgr->p_log, OSM_LOG_DEBUG,
+ "__osmv_txnmgr_insert_txn: "
+ "Found key 0x%llX \n", tmp_key);
+ p_item = cl_qmap_next(p_item);
+ }
+
+ return IB_SUCCESS;
}
ib_api_status_t
-__osmv_txnmgr_remove_txn(IN osmv_txn_mgr_t *p_tx_mgr,
- IN uint64_t key,
- OUT osmv_txn_ctx_t **pp_txn)
+__osmv_txnmgr_remove_txn(IN osmv_txn_mgr_t * p_tx_mgr,
+ IN uint64_t key, OUT osmv_txn_ctx_t ** pp_txn)
{
- cl_map_obj_t* p_obj;
- cl_map_item_t* p_item;
+ cl_map_obj_t *p_obj;
+ cl_map_item_t *p_item;
- OSM_LOG_ENTER(p_tx_mgr->p_log, __osmv_txnmgr_remove_txn);
+ OSM_LOG_ENTER(p_tx_mgr->p_log, __osmv_txnmgr_remove_txn);
- CL_ASSERT(p_tx_mgr);
- CL_ASSERT(pp_txn);
+ CL_ASSERT(p_tx_mgr);
+ CL_ASSERT(pp_txn);
- p_item= cl_qmap_remove(p_tx_mgr->p_txn_map, key);
+ p_item = cl_qmap_remove(p_tx_mgr->p_txn_map, key);
- if (p_item == cl_qmap_end(p_tx_mgr->p_txn_map))
- {
+ if (p_item == cl_qmap_end(p_tx_mgr->p_txn_map)) {
- osm_log(p_tx_mgr->p_log, OSM_LOG_ERROR,
- "__osmv_txnmgr_remove_txn: ERR 6701: "
- "Could not remove the transaction 0x%llX - "
- "something is really wrong!\n", key);
- OSM_LOG_EXIT(p_tx_mgr->p_log);
- return IB_NOT_FOUND;
- }
+ osm_log(p_tx_mgr->p_log, OSM_LOG_ERROR,
+ "__osmv_txnmgr_remove_txn: ERR 6701: "
+ "Could not remove the transaction 0x%llX - "
+ "something is really wrong!\n", key);
+ OSM_LOG_EXIT(p_tx_mgr->p_log);
+ return IB_NOT_FOUND;
+ }
- p_obj = PARENT_STRUCT(p_item, cl_map_obj_t,item);
- *pp_txn = cl_qmap_obj(p_obj);
+ p_obj = PARENT_STRUCT(p_item, cl_map_obj_t, item);
+ *pp_txn = cl_qmap_obj(p_obj);
- free(p_obj);
+ free(p_obj);
- OSM_LOG_EXIT(p_tx_mgr->p_log);
- return IB_SUCCESS;
+ OSM_LOG_EXIT(p_tx_mgr->p_log);
+ return IB_SUCCESS;
}
-void
-__osmv_txn_all_done(osm_bind_handle_t h_bind)
+void __osmv_txn_all_done(osm_bind_handle_t h_bind)
{
- osmv_bind_obj_t* p_bo = (osmv_bind_obj_t*)h_bind;
- cl_map_item_t *p_item;
- cl_map_obj_t* p_obj;
- osmv_txn_ctx_t* p_txn;
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ cl_map_item_t *p_item;
+ cl_map_obj_t *p_obj;
+ osmv_txn_ctx_t *p_txn;
- OSM_LOG_ENTER( p_bo->p_vendor->p_log, __osmv_txn_all_done);
+ OSM_LOG_ENTER(p_bo->p_vendor->p_log, __osmv_txn_all_done);
- p_item = cl_qmap_head(p_bo->txn_mgr.p_txn_map);
- while ( p_item != cl_qmap_end(p_bo->txn_mgr.p_txn_map)) {
+ p_item = cl_qmap_head(p_bo->txn_mgr.p_txn_map);
+ while (p_item != cl_qmap_end(p_bo->txn_mgr.p_txn_map)) {
- p_obj = PARENT_STRUCT(p_item,cl_map_obj_t,item);
- p_txn = (osmv_txn_ctx_t*)cl_qmap_obj(p_obj);
- osmv_txn_done(h_bind, osmv_txn_get_key(p_txn), FALSE);
- free(p_obj);
- /* assuming osmv_txn_done has removed the txn from the map */
- p_item = cl_qmap_head(p_bo->txn_mgr.p_txn_map);
- }
+ p_obj = PARENT_STRUCT(p_item, cl_map_obj_t, item);
+ p_txn = (osmv_txn_ctx_t *) cl_qmap_obj(p_obj);
+ osmv_txn_done(h_bind, osmv_txn_get_key(p_txn), FALSE);
+ free(p_obj);
+ /* assuming osmv_txn_done has removed the txn from the map */
+ p_item = cl_qmap_head(p_bo->txn_mgr.p_txn_map);
+ }
- OSM_LOG_EXIT(p_bo->p_vendor->p_log);
+ OSM_LOG_EXIT(p_bo->p_vendor->p_log);
}
/******************************************************************************/
-void osmv_txn_lock(IN osm_bind_handle_t h_bind)
+void osmv_txn_lock(IN osm_bind_handle_t h_bind)
{
- osmv_bind_obj_t* p_bo = (osmv_bind_obj_t*)h_bind;
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "--> Acquiring lock %p on bind handle %p\n", &p_bo->lock, p_bo);
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "--> Acquiring lock %p on bind handle %p\n", &p_bo->lock, p_bo);
- cl_spinlock_acquire(&p_bo->lock);
+ cl_spinlock_acquire(&p_bo->lock);
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "--> Acquired lock %p on bind handle %p\n", &p_bo->lock, p_bo);
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "--> Acquired lock %p on bind handle %p\n", &p_bo->lock, p_bo);
}
-void osmv_txn_unlock(IN osm_bind_handle_t h_bind)
+void osmv_txn_unlock(IN osm_bind_handle_t h_bind)
{
- osmv_bind_obj_t* p_bo = (osmv_bind_obj_t*)h_bind;
- cl_spinlock_t* p_lock = &p_bo->lock;
- osm_log_t* p_log = p_bo->p_vendor->p_log;
-
- osm_log(p_log, OSM_LOG_DEBUG,
- "<-- Releasing lock %p on bind handle %p\n", p_lock, p_bo);
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind;
+ cl_spinlock_t *p_lock = &p_bo->lock;
+ osm_log_t *p_log = p_bo->p_vendor->p_log;
- cl_spinlock_release(&p_bo->lock);
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "<-- Releasing lock %p on bind handle %p\n", p_lock, p_bo);
- /* We'll use the saved ptrs, since now the p_bo can be destroyed already */
- osm_log(p_log, OSM_LOG_DEBUG,
- "<-- Released lock %p on bind handle %p\n", p_lock, p_bo);
+ cl_spinlock_release(&p_bo->lock);
+ /* We'll use the saved ptrs, since now the p_bo can be destroyed already */
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "<-- Released lock %p on bind handle %p\n", p_lock, p_bo);
}
static uint64_t
__osmv_txn_timeout_cb(IN uint64_t key,
- IN uint32_t num_regs,
- IN void *cb_context)
+ IN uint32_t num_regs, IN void *cb_context)
{
- osmv_bind_obj_t *p_bo = (osmv_bind_obj_t*)cb_context;
- uint64_t ret=0;
- osmv_txn_ctx_t *p_txn;
- osmv_rmpp_send_ctx_t *p_send_ctx;
- osm_madw_t *p_madw = NULL;
- ib_mad_t *p_mad;
- osm_mad_addr_t *p_mad_addr;
- boolean_t invoke_err_cb = FALSE;
-
- OSM_LOG_ENTER( p_bo->p_vendor->p_log, __osmv_txn_timeout_cb );
-
- /* Don't try to acquire a lock on the Bind Object -
- * it's taken by the mechanism that drives the timeout based events!
- * (Recall the special constructor that the Event Wheel is applied with)
- */
- if (p_bo->is_closing)
- {
- goto txn_done;
- }
-
- ret = osmv_txn_lookup(p_bo, key, &p_txn);
- if (IB_NOT_FOUND == ret)
- {
- /* Prevent a race - the transaction is already destroyed */
- goto txn_done;
- }
-
- p_madw = p_txn->p_madw;
-
- switch (osmv_txn_get_rmpp_state(p_txn)) {
-
- case OSMV_TXN_RMPP_NONE:
- if (num_regs <= OSMV_MAX_RETRANSMIT)
- {
- /* We still did not exceed the limit of retransmissions.
- * Set the next timeout's value.
- */
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "__osmv_txn_timeout_cb: "
- "The transaction request (tid=0x%llX) timed out %d times. "
- "Retrying the send.\n",
- osmv_txn_get_tid(p_txn), num_regs);
-
- /* resend this mad */
- ret = osmv_simple_send_madw((osm_bind_handle_t*)p_bo,
- p_madw, p_txn, TRUE);
- if (ret != IB_SUCCESS)
- {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "__osmv_txn_timeout_cb: "
- "Fail to send retry for transaction request (tid=0x%llX).\n",
- osmv_txn_get_tid(p_txn));
-
- osmv_txn_done((osm_bind_handle_t)p_bo, key,
- TRUE /*in timeout callback*/);
-
- /* This is a requester. Always apply the callback */
- invoke_err_cb = TRUE;
- }
- else
- {
- uint64_t next_timeout_ms;
- next_timeout_ms =
- p_bo->p_vendor->resp_timeout*(num_regs+1)*(num_regs+1);
- /* when do we need to timeout again */
- ret = cl_get_time_stamp() + (uint64_t)(1000*next_timeout_ms);
-
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "__osmv_txn_timeout_cb: "
- "Retry request timout in : %lu [msec].\n",
- next_timeout_ms);
- }
- }
- else
- {
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
- "__osmv_txn_timeout_cb: ERR 6702: "
- "The transaction request (tid=0x%llX) timed out (after %d retries). "
- "Invoking the error callback.\n",
- osmv_txn_get_tid(p_txn), num_regs);
-
- osmv_txn_done((osm_bind_handle_t)p_bo, key,
- TRUE /*in timeout callback*/);
-
- /* This is a requester. Always apply the callback */
- invoke_err_cb = TRUE;
- }
- break;
-
- case OSMV_TXN_RMPP_SENDER:
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "RMPP sender (tid=0x%llX) did not receive ACK "
- "on every segment in the current send window.\n",
- osmv_txn_get_tid(p_txn));
-
- p_send_ctx = osmv_txn_get_rmpp_send_ctx(p_txn);
- if (num_regs <= OSMV_MAX_RETRANSMIT)
- {
- /* We still did not exceed the limit of retransmissions.
- * Set the next timeout's value.
- */
- ret = cl_get_time_stamp() + 1000*p_bo->p_vendor->resp_timeout;
- }
- else
- {
- p_send_ctx->status = IB_TIMEOUT;
-
- p_mad = osm_madw_get_mad_ptr(p_madw);
- p_mad_addr = osm_madw_get_mad_addr_ptr(p_madw);
-
- /* Send an ABORT to the other side */
- osmv_rmpp_send_nak((osm_bind_handle_t)p_bo, p_mad, p_mad_addr,
- IB_RMPP_TYPE_ABORT,
- IB_RMPP_STATUS_T2L);
- }
-
- /* Wake the RMPP sender thread up */
- cl_event_signal(&p_send_ctx->event);
- break;
-
- case OSMV_TXN_RMPP_RECEIVER:
- osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
- "Transaction timeout on an RMPP receiver (tid=0x%llX). "
- "Dropping the transaction.\n", osmv_txn_get_tid(p_txn));
-
- osmv_txn_done((osm_bind_handle_t)p_bo, key,
- TRUE /*in timeout callback*/);
-
- if (FALSE == osmv_txn_is_rmpp_init_by_peer(p_txn))
- {
- /* This is a requester, still waiting for the reply. Apply the callback */
- invoke_err_cb = TRUE;
- }
-
- break;
-
- default: CL_ASSERT(FALSE);
- }
-
- if (TRUE == invoke_err_cb)
- {
- CL_ASSERT(NULL != p_madw);
- /* update the status in the p_madw */
- p_madw->status = IB_TIMEOUT;
- p_bo->send_err_cb(p_bo->cb_context, p_madw);
- /* no re-registration */
- ret = 0;
- }
-
- txn_done:
- OSM_LOG_EXIT(p_bo->p_vendor->p_log);
- return ret;
+ osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) cb_context;
+ uint64_t ret = 0;
+ osmv_txn_ctx_t *p_txn;
+ osmv_rmpp_send_ctx_t *p_send_ctx;
+ osm_madw_t *p_madw = NULL;
+ ib_mad_t *p_mad;
+ osm_mad_addr_t *p_mad_addr;
+ boolean_t invoke_err_cb = FALSE;
+
+ OSM_LOG_ENTER(p_bo->p_vendor->p_log, __osmv_txn_timeout_cb);
+
+ /* Don't try to acquire a lock on the Bind Object -
+ * it's taken by the mechanism that drives the timeout based events!
+ * (Recall the special constructor that the Event Wheel is applied with)
+ */
+ if (p_bo->is_closing) {
+ goto txn_done;
+ }
+
+ ret = osmv_txn_lookup(p_bo, key, &p_txn);
+ if (IB_NOT_FOUND == ret) {
+ /* Prevent a race - the transaction is already destroyed */
+ goto txn_done;
+ }
+
+ p_madw = p_txn->p_madw;
+
+ switch (osmv_txn_get_rmpp_state(p_txn)) {
+
+ case OSMV_TXN_RMPP_NONE:
+ if (num_regs <= OSMV_MAX_RETRANSMIT) {
+ /* We still did not exceed the limit of retransmissions.
+ * Set the next timeout's value.
+ */
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "__osmv_txn_timeout_cb: "
+ "The transaction request (tid=0x%llX) timed out %d times. "
+ "Retrying the send.\n",
+ osmv_txn_get_tid(p_txn), num_regs);
+
+ /* resend this mad */
+ ret = osmv_simple_send_madw((osm_bind_handle_t *) p_bo,
+ p_madw, p_txn, TRUE);
+ if (ret != IB_SUCCESS) {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "__osmv_txn_timeout_cb: "
+ "Fail to send retry for transaction request (tid=0x%llX).\n",
+ osmv_txn_get_tid(p_txn));
+
+ osmv_txn_done((osm_bind_handle_t) p_bo, key,
+ TRUE /*in timeout callback */ );
+
+ /* This is a requester. Always apply the callback */
+ invoke_err_cb = TRUE;
+ } else {
+ uint64_t next_timeout_ms;
+ next_timeout_ms =
+ p_bo->p_vendor->resp_timeout * (num_regs +
+ 1) *
+ (num_regs + 1);
+ /* when do we need to timeout again */
+ ret =
+ cl_get_time_stamp() +
+ (uint64_t) (1000 * next_timeout_ms);
+
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "__osmv_txn_timeout_cb: "
+ "Retry request timout in : %lu [msec].\n",
+ next_timeout_ms);
+ }
+ } else {
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_ERROR,
+ "__osmv_txn_timeout_cb: ERR 6702: "
+ "The transaction request (tid=0x%llX) timed out (after %d retries). "
+ "Invoking the error callback.\n",
+ osmv_txn_get_tid(p_txn), num_regs);
+
+ osmv_txn_done((osm_bind_handle_t) p_bo, key,
+ TRUE /*in timeout callback */ );
+
+ /* This is a requester. Always apply the callback */
+ invoke_err_cb = TRUE;
+ }
+ break;
+
+ case OSMV_TXN_RMPP_SENDER:
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "RMPP sender (tid=0x%llX) did not receive ACK "
+ "on every segment in the current send window.\n",
+ osmv_txn_get_tid(p_txn));
+
+ p_send_ctx = osmv_txn_get_rmpp_send_ctx(p_txn);
+ if (num_regs <= OSMV_MAX_RETRANSMIT) {
+ /* We still did not exceed the limit of retransmissions.
+ * Set the next timeout's value.
+ */
+ ret =
+ cl_get_time_stamp() +
+ 1000 * p_bo->p_vendor->resp_timeout;
+ } else {
+ p_send_ctx->status = IB_TIMEOUT;
+
+ p_mad = osm_madw_get_mad_ptr(p_madw);
+ p_mad_addr = osm_madw_get_mad_addr_ptr(p_madw);
+
+ /* Send an ABORT to the other side */
+ osmv_rmpp_send_nak((osm_bind_handle_t) p_bo, p_mad,
+ p_mad_addr, IB_RMPP_TYPE_ABORT,
+ IB_RMPP_STATUS_T2L);
+ }
+
+ /* Wake the RMPP sender thread up */
+ cl_event_signal(&p_send_ctx->event);
+ break;
+
+ case OSMV_TXN_RMPP_RECEIVER:
+ osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG,
+ "Transaction timeout on an RMPP receiver (tid=0x%llX). "
+ "Dropping the transaction.\n", osmv_txn_get_tid(p_txn));
+
+ osmv_txn_done((osm_bind_handle_t) p_bo, key,
+ TRUE /*in timeout callback */ );
+
+ if (FALSE == osmv_txn_is_rmpp_init_by_peer(p_txn)) {
+ /* This is a requester, still waiting for the reply. Apply the callback */
+ invoke_err_cb = TRUE;
+ }
+
+ break;
+
+ default:
+ CL_ASSERT(FALSE);
+ }
+
+ if (TRUE == invoke_err_cb) {
+ CL_ASSERT(NULL != p_madw);
+ /* update the status in the p_madw */
+ p_madw->status = IB_TIMEOUT;
+ p_bo->send_err_cb(p_bo->cb_context, p_madw);
+ /* no re-registration */
+ ret = 0;
+ }
+
+ txn_done:
+ OSM_LOG_EXIT(p_bo->p_vendor->p_log);
+ return ret;
}
diff --git a/opensm/libvendor/osm_vendor_mtl.c b/opensm/libvendor/osm_vendor_mtl.c
index 51561e7..1937ae7 100644
--- a/opensm/libvendor/osm_vendor_mtl.c
+++ b/opensm/libvendor/osm_vendor_mtl.c
@@ -33,10 +33,9 @@
*
*/
-
#if HAVE_CONFIG_H
# include <config.h>
-#endif /* HAVE_CONFIG_H */
+#endif /* HAVE_CONFIG_H */
#include <vendor/osm_vendor_select.h>
@@ -61,251 +60,239 @@
whether or not it is a response. A race can occure only on requests that did
not fail, and then the madw_p will be put back in the pool before the callback.
*/
-uint64_t
-__osm_set_wrid_by_p_madw(IN osm_madw_t *p_madw) {
- uint64_t wrid = 0;
+uint64_t __osm_set_wrid_by_p_madw(IN osm_madw_t * p_madw)
+{
+ uint64_t wrid = 0;
- CL_ASSERT(p_madw->p_mad);
+ CL_ASSERT(p_madw->p_mad);
- memcpy( &wrid, &p_madw, sizeof( osm_madw_t * ) );
- wrid = (wrid << 1) |
- ib_mad_is_response(p_madw->p_mad) |
- (p_madw->p_mad->method == IB_MAD_METHOD_TRAP_REPRESS);
- return wrid;
+ memcpy(&wrid, &p_madw, sizeof(osm_madw_t *));
+ wrid = (wrid << 1) |
+ ib_mad_is_response(p_madw->p_mad) |
+ (p_madw->p_mad->method == IB_MAD_METHOD_TRAP_REPRESS);
+ return wrid;
}
void
-__osm_set_p_madw_and_resp_by_wrid(
- IN uint64_t wrid,
- OUT uint8_t *is_resp,
- OUT osm_madw_t **pp_madw) {
- *is_resp = wrid & 0x0000000000000001;
- wrid = wrid >> 1;
- memcpy( pp_madw, &wrid, sizeof( osm_madw_t * ) );
+__osm_set_p_madw_and_resp_by_wrid(IN uint64_t wrid,
+ OUT uint8_t * is_resp,
+ OUT osm_madw_t ** pp_madw)
+{
+ *is_resp = wrid & 0x0000000000000001;
+ wrid = wrid >> 1;
+ memcpy(pp_madw, &wrid, sizeof(osm_madw_t *));
}
/**********************************************************************
* IB_MGT to OSM ADDRESS VECTOR
**********************************************************************/
void
-__osm_mtl_conv_ibmgt_rcv_desc_to_osm_addr(
- IN osm_vendor_t * const p_vend,
- IN IB_MGT_mad_rcv_desc_t *p_rcv_desc,
- IN uint8_t is_smi,
- OUT osm_mad_addr_t *p_mad_addr)
+__osm_mtl_conv_ibmgt_rcv_desc_to_osm_addr(IN osm_vendor_t * const p_vend,
+ IN IB_MGT_mad_rcv_desc_t * p_rcv_desc,
+ IN uint8_t is_smi,
+ OUT osm_mad_addr_t * p_mad_addr)
{
- /* p_mad_addr->dest_lid = p_osm->subn.sm_base_lid; - for resp we use the dest lid ... */
- p_mad_addr->dest_lid = cl_hton16(p_rcv_desc->remote_lid);
- p_mad_addr->static_rate = 0; /* HACK - we do not know the rate ! */
- p_mad_addr->path_bits = p_rcv_desc->local_path_bits;
- if (is_smi)
- {
- /* SMI */
- p_mad_addr->addr_type.smi.source_lid = cl_hton16(p_rcv_desc->remote_lid);
- p_mad_addr->addr_type.smi.port_num = 99; /* HACK - if used - should fail */
- }
- else
- {
- /* GSI */
- /* seems to me there is a IBMGT bug reversing the QPN ... */
- /* Does IBMGT supposed to provide the QPN is network or HOST ? */
- p_mad_addr->addr_type.gsi.remote_qp = cl_hton32(p_rcv_desc->qp);
-
- p_mad_addr->addr_type.gsi.remote_qkey = IB_QP1_WELL_KNOWN_Q_KEY;
- /* we do have the p_mad_addr->pkey_ix but how to get the PKey by index ? */
- /* the only way seems to be to use VAPI_query_hca_pkey_tbl and obtain */
- /* the full PKey table - than go by the index. */
- /* since this does not seem reasonable to me I simply use the default */
- /* There is a TAVOR limitation that only one P_KEY is supported per */
- /* QP - so QP1 must use IB_DEFAULT_PKEY */
- p_mad_addr->addr_type.gsi.pkey = IB_DEFAULT_PKEY;
- p_mad_addr->addr_type.gsi.service_level = p_rcv_desc->sl;
-
- p_mad_addr->addr_type.gsi.global_route = p_rcv_desc->grh_flag;
- /* copy the GRH data if relevant */
- if (p_mad_addr->addr_type.gsi.global_route)
- {
- p_mad_addr->addr_type.gsi.grh_info.ver_class_flow =
- ib_grh_set_ver_class_flow(p_rcv_desc->grh.IP_version,
- p_rcv_desc->grh.traffic_class,
- p_rcv_desc->grh.flow_label);
- p_mad_addr->addr_type.gsi.grh_info.hop_limit = p_rcv_desc->grh.hop_limit;
- memcpy(&p_mad_addr->addr_type.gsi.grh_info.src_gid.raw,
- &p_rcv_desc->grh.sgid, sizeof(ib_net64_t));
- memcpy(&p_mad_addr->addr_type.gsi.grh_info.dest_gid.raw,
- p_rcv_desc->grh.dgid, sizeof(ib_net64_t));
- }
- }
+ /* p_mad_addr->dest_lid = p_osm->subn.sm_base_lid; - for resp we use the dest lid ... */
+ p_mad_addr->dest_lid = cl_hton16(p_rcv_desc->remote_lid);
+ p_mad_addr->static_rate = 0; /* HACK - we do not know the rate ! */
+ p_mad_addr->path_bits = p_rcv_desc->local_path_bits;
+ if (is_smi) {
+ /* SMI */
+ p_mad_addr->addr_type.smi.source_lid =
+ cl_hton16(p_rcv_desc->remote_lid);
+ p_mad_addr->addr_type.smi.port_num = 99; /* HACK - if used - should fail */
+ } else {
+ /* GSI */
+ /* seems to me there is a IBMGT bug reversing the QPN ... */
+ /* Does IBMGT supposed to provide the QPN is network or HOST ? */
+ p_mad_addr->addr_type.gsi.remote_qp = cl_hton32(p_rcv_desc->qp);
+
+ p_mad_addr->addr_type.gsi.remote_qkey = IB_QP1_WELL_KNOWN_Q_KEY;
+ /* we do have the p_mad_addr->pkey_ix but how to get the PKey by index ? */
+ /* the only way seems to be to use VAPI_query_hca_pkey_tbl and obtain */
+ /* the full PKey table - than go by the index. */
+ /* since this does not seem reasonable to me I simply use the default */
+ /* There is a TAVOR limitation that only one P_KEY is supported per */
+ /* QP - so QP1 must use IB_DEFAULT_PKEY */
+ p_mad_addr->addr_type.gsi.pkey = IB_DEFAULT_PKEY;
+ p_mad_addr->addr_type.gsi.service_level = p_rcv_desc->sl;
+
+ p_mad_addr->addr_type.gsi.global_route = p_rcv_desc->grh_flag;
+ /* copy the GRH data if relevant */
+ if (p_mad_addr->addr_type.gsi.global_route) {
+ p_mad_addr->addr_type.gsi.grh_info.ver_class_flow =
+ ib_grh_set_ver_class_flow(p_rcv_desc->grh.
+ IP_version,
+ p_rcv_desc->grh.
+ traffic_class,
+ p_rcv_desc->grh.
+ flow_label);
+ p_mad_addr->addr_type.gsi.grh_info.hop_limit =
+ p_rcv_desc->grh.hop_limit;
+ memcpy(&p_mad_addr->addr_type.gsi.grh_info.src_gid.raw,
+ &p_rcv_desc->grh.sgid, sizeof(ib_net64_t));
+ memcpy(&p_mad_addr->addr_type.gsi.grh_info.dest_gid.raw,
+ p_rcv_desc->grh.dgid, sizeof(ib_net64_t));
+ }
+ }
}
/**********************************************************************
* OSM ADDR VECTOR TO IB_MGT
**********************************************************************/
void
-__osm_mtl_conv_osm_addr_to_ibmgt_addr(
- IN osm_mad_addr_t *p_mad_addr,
- IN uint8_t is_smi,
- OUT IB_ud_av_t *p_av)
+__osm_mtl_conv_osm_addr_to_ibmgt_addr(IN osm_mad_addr_t * p_mad_addr,
+ IN uint8_t is_smi, OUT IB_ud_av_t * p_av)
{
- /* For global destination or Multicast address:*/
- u_int8_t ver;
-
- memset( p_av, 0, sizeof( IB_ud_av_t ) );
-
- p_av->src_path_bits = p_mad_addr->path_bits;
- p_av->static_rate = p_mad_addr->static_rate;
- p_av->dlid = cl_ntoh16(p_mad_addr->dest_lid);
-
- if (is_smi)
- {
- p_av->sl = 0; /* Just to note we use 0 here. */
- }
- else
- {
- p_av->sl = p_mad_addr->addr_type.gsi.service_level;
- p_av->grh_flag = p_mad_addr->addr_type.gsi.global_route;
-
- if (p_mad_addr->addr_type.gsi.global_route)
- {
- ib_grh_get_ver_class_flow(p_mad_addr->addr_type.gsi.grh_info.ver_class_flow,
- &ver,
- &p_av->traffic_class,
- &p_av->flow_label);
- p_av->hop_limit = p_mad_addr->addr_type.gsi.grh_info.hop_limit;
- p_av->sgid_index = 0; /* we always use source GID 0 */
- memcpy(&p_av->dgid,
- &p_mad_addr->addr_type.gsi.grh_info.dest_gid.raw,
- sizeof(ib_net64_t));
-
- }
- }
+ /* For global destination or Multicast address: */
+ u_int8_t ver;
+
+ memset(p_av, 0, sizeof(IB_ud_av_t));
+
+ p_av->src_path_bits = p_mad_addr->path_bits;
+ p_av->static_rate = p_mad_addr->static_rate;
+ p_av->dlid = cl_ntoh16(p_mad_addr->dest_lid);
+
+ if (is_smi) {
+ p_av->sl = 0; /* Just to note we use 0 here. */
+ } else {
+ p_av->sl = p_mad_addr->addr_type.gsi.service_level;
+ p_av->grh_flag = p_mad_addr->addr_type.gsi.global_route;
+
+ if (p_mad_addr->addr_type.gsi.global_route) {
+ ib_grh_get_ver_class_flow(p_mad_addr->addr_type.gsi.
+ grh_info.ver_class_flow, &ver,
+ &p_av->traffic_class,
+ &p_av->flow_label);
+ p_av->hop_limit =
+ p_mad_addr->addr_type.gsi.grh_info.hop_limit;
+ p_av->sgid_index = 0; /* we always use source GID 0 */
+ memcpy(&p_av->dgid,
+ &p_mad_addr->addr_type.gsi.grh_info.dest_gid.raw,
+ sizeof(ib_net64_t));
+
+ }
+ }
}
/**********************************************************************
**********************************************************************/
-void
-__osm_vendor_clear_sm( IN osm_bind_handle_t h_bind )
+void __osm_vendor_clear_sm(IN osm_bind_handle_t h_bind)
{
- osm_mtl_bind_info_t *p_bind = ( osm_mtl_bind_info_t * ) h_bind;
- osm_vendor_t *p_vend = p_bind->p_vend;
- VAPI_ret_t status;
- VAPI_hca_attr_t attr_mod;
- VAPI_hca_attr_mask_t attr_mask;
-
- OSM_LOG_ENTER( p_vend->p_log, __osm_vendor_clear_sm );
-
- memset( &attr_mod, 0, sizeof( attr_mod ) );
- memset( &attr_mask, 0, sizeof( attr_mask ) );
-
- attr_mod.is_sm = FALSE;
- attr_mask = HCA_ATTR_IS_SM;
-
- status =
- VAPI_modify_hca_attr( p_bind->hca_hndl, p_bind->port_num, &attr_mod,
- &attr_mask );
- if( status != VAPI_OK )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__osm_vendor_clear_sm: ERR 3C21: "
- "Unable set 'IS_SM' bit in port attributes (%d).\n",
- status );
- }
-
- OSM_LOG_EXIT( p_vend->p_log );
+ osm_mtl_bind_info_t *p_bind = (osm_mtl_bind_info_t *) h_bind;
+ osm_vendor_t *p_vend = p_bind->p_vend;
+ VAPI_ret_t status;
+ VAPI_hca_attr_t attr_mod;
+ VAPI_hca_attr_mask_t attr_mask;
+
+ OSM_LOG_ENTER(p_vend->p_log, __osm_vendor_clear_sm);
+
+ memset(&attr_mod, 0, sizeof(attr_mod));
+ memset(&attr_mask, 0, sizeof(attr_mask));
+
+ attr_mod.is_sm = FALSE;
+ attr_mask = HCA_ATTR_IS_SM;
+
+ status =
+ VAPI_modify_hca_attr(p_bind->hca_hndl, p_bind->port_num, &attr_mod,
+ &attr_mask);
+ if (status != VAPI_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_vendor_clear_sm: ERR 3C21: "
+ "Unable set 'IS_SM' bit in port attributes (%d).\n",
+ status);
+ }
+
+ OSM_LOG_EXIT(p_vend->p_log);
}
/**********************************************************************
* ANY CONSTRUCTION OF THE osm_vendor_t OBJECT
**********************************************************************/
-void
-osm_vendor_construct( IN osm_vendor_t * const p_vend )
+void osm_vendor_construct(IN osm_vendor_t * const p_vend)
{
- memset( p_vend, 0, sizeof( *p_vend ) );
+ memset(p_vend, 0, sizeof(*p_vend));
}
/**********************************************************************
* DEALOCATE osm_vendor_t
**********************************************************************/
-void
-osm_vendor_destroy( IN osm_vendor_t * const p_vend )
+void osm_vendor_destroy(IN osm_vendor_t * const p_vend)
{
- osm_vendor_mgt_bind_t *vendor_mgt_bind_p;
- IB_MGT_ret_t mgt_ret;
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_destroy );
-
- if( p_vend->h_al != NULL )
- {
- vendor_mgt_bind_p = ( osm_vendor_mgt_bind_t * ) p_vend->h_al;
- if( vendor_mgt_bind_p->gsi_init )
- {
-
- /* un register the class */
- /* HACK WE ASSUME WE ONLY GOT SA CLASS REGISTERD ON GSI !!! */
- mgt_ret = IB_MGT_unbind_gsi_class(vendor_mgt_bind_p->gsi_mads_hdl, IB_MCLASS_SUBN_ADM);
- if ( mgt_ret != IB_MGT_OK )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_destroy: ERR 3C03: "
- "Fail to unbind the SA class.\n" );
- }
-
- /* un bind the handle */
- if( IB_MGT_release_handle( vendor_mgt_bind_p->gsi_mads_hdl ) !=
- IB_MGT_OK )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_destroy: ERR 3C02: "
- "Fail to unbind the SA GSI handle.\n" );
- }
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_destroy: DBG 1002: "
- "Unbind the GSI handles.\n" );
- }
- if( vendor_mgt_bind_p->smi_init )
- {
- /* first - clear the IS_SM in the capability mask */
- __osm_vendor_clear_sm( (osm_bind_handle_t)(vendor_mgt_bind_p->smi_p_bind) );
-
- /* un register the class */
- mgt_ret = IB_MGT_unbind_sm(vendor_mgt_bind_p->smi_mads_hdl);
- if ( mgt_ret != IB_MGT_OK )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_destroy: ERR 3C04: "
- "Fail to unbind the SM class.\n" );
- }
-
- /* un bind the handle */
- if( IB_MGT_release_handle( vendor_mgt_bind_p->smi_mads_hdl ) !=
- IB_MGT_OK )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_destroy: ERR 3C05: "
- "Fail to unbind the SMI handle.\n" );
- }
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_destroy: DBG 1003: "
- "Unbind the SMI handles.\n" );
-
- }
- }
- osm_transaction_mgr_destroy ( p_vend );
- /* __osm_mtl_destroy_tid_mad_map( p_vend ); */
- OSM_LOG_EXIT( p_vend->p_log );
+ osm_vendor_mgt_bind_t *vendor_mgt_bind_p;
+ IB_MGT_ret_t mgt_ret;
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_destroy);
+
+ if (p_vend->h_al != NULL) {
+ vendor_mgt_bind_p = (osm_vendor_mgt_bind_t *) p_vend->h_al;
+ if (vendor_mgt_bind_p->gsi_init) {
+
+ /* un register the class */
+ /* HACK WE ASSUME WE ONLY GOT SA CLASS REGISTERD ON GSI !!! */
+ mgt_ret =
+ IB_MGT_unbind_gsi_class(vendor_mgt_bind_p->
+ gsi_mads_hdl,
+ IB_MCLASS_SUBN_ADM);
+ if (mgt_ret != IB_MGT_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_destroy: ERR 3C03: "
+ "Fail to unbind the SA class.\n");
+ }
+
+ /* un bind the handle */
+ if (IB_MGT_release_handle
+ (vendor_mgt_bind_p->gsi_mads_hdl) != IB_MGT_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_destroy: ERR 3C02: "
+ "Fail to unbind the SA GSI handle.\n");
+ }
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_destroy: DBG 1002: "
+ "Unbind the GSI handles.\n");
+ }
+ if (vendor_mgt_bind_p->smi_init) {
+ /* first - clear the IS_SM in the capability mask */
+ __osm_vendor_clear_sm((osm_bind_handle_t)
+ (vendor_mgt_bind_p->smi_p_bind));
+
+ /* un register the class */
+ mgt_ret =
+ IB_MGT_unbind_sm(vendor_mgt_bind_p->smi_mads_hdl);
+ if (mgt_ret != IB_MGT_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_destroy: ERR 3C04: "
+ "Fail to unbind the SM class.\n");
+ }
+
+ /* un bind the handle */
+ if (IB_MGT_release_handle
+ (vendor_mgt_bind_p->smi_mads_hdl) != IB_MGT_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_destroy: ERR 3C05: "
+ "Fail to unbind the SMI handle.\n");
+ }
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_destroy: DBG 1003: "
+ "Unbind the SMI handles.\n");
+
+ }
+ }
+ osm_transaction_mgr_destroy(p_vend);
+ /* __osm_mtl_destroy_tid_mad_map( p_vend ); */
+ OSM_LOG_EXIT(p_vend->p_log);
}
/**********************************************************************
DEALLOCATE A POINTER TO osm_vendor_t
**********************************************************************/
-void
-osm_vendor_delete( IN osm_vendor_t ** const pp_vend )
+void osm_vendor_delete(IN osm_vendor_t ** const pp_vend)
{
- CL_ASSERT( pp_vend );
+ CL_ASSERT(pp_vend);
- osm_vendor_destroy( *pp_vend );
- free( *pp_vend );
- *pp_vend = NULL;
+ osm_vendor_destroy(*pp_vend);
+ free(*pp_vend);
+ *pp_vend = NULL;
}
/**********************************************************************
@@ -319,81 +306,71 @@ osm_vendor_delete( IN osm_vendor_t ** const pp_vend )
**********************************************************************/
ib_api_status_t
-osm_vendor_init( IN osm_vendor_t * const p_vend,
- IN osm_log_t * const p_log,
- IN const uint32_t timeout )
+osm_vendor_init(IN osm_vendor_t * const p_vend,
+ IN osm_log_t * const p_log, IN const uint32_t timeout)
{
- osm_vendor_mgt_bind_t *ib_mgt_hdl_p;
- ib_api_status_t status = IB_SUCCESS;
-
- OSM_LOG_ENTER( p_log, osm_vendor_init );
-
- p_vend->p_log = p_log;
-
- /*
- * HACK: We need no handle. Assuming the driver is up.
- */
- ib_mgt_hdl_p =
- ( osm_vendor_mgt_bind_t * )
- malloc( sizeof( osm_vendor_mgt_bind_t ) );
- if( ib_mgt_hdl_p == NULL )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_init: ERR 3C06: "
- "Fail to allocate vendor mgt handle.\n" );
- goto Exit;
- }
-
- ib_mgt_hdl_p->smi_init = FALSE;
- ib_mgt_hdl_p->gsi_init = FALSE;
- /* cast it into the ib_al_handle_t h_al */
- p_vend->h_al = ( ib_al_handle_t ) ib_mgt_hdl_p;
- p_vend->p_transaction_mgr = NULL;
- osm_transaction_mgr_init( p_vend );
- /* p_vend->madw_by_tid_map_p = NULL; */
- /* __osm_mtl_init_tid_mad_map( p_vend ); */
- p_vend->timeout = timeout;
-
- Exit:
- OSM_LOG_EXIT( p_log );
- return ( status );
+ osm_vendor_mgt_bind_t *ib_mgt_hdl_p;
+ ib_api_status_t status = IB_SUCCESS;
+
+ OSM_LOG_ENTER(p_log, osm_vendor_init);
+
+ p_vend->p_log = p_log;
+
+ /*
+ * HACK: We need no handle. Assuming the driver is up.
+ */
+ ib_mgt_hdl_p = (osm_vendor_mgt_bind_t *)
+ malloc(sizeof(osm_vendor_mgt_bind_t));
+ if (ib_mgt_hdl_p == NULL) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_init: ERR 3C06: "
+ "Fail to allocate vendor mgt handle.\n");
+ goto Exit;
+ }
+
+ ib_mgt_hdl_p->smi_init = FALSE;
+ ib_mgt_hdl_p->gsi_init = FALSE;
+ /* cast it into the ib_al_handle_t h_al */
+ p_vend->h_al = (ib_al_handle_t) ib_mgt_hdl_p;
+ p_vend->p_transaction_mgr = NULL;
+ osm_transaction_mgr_init(p_vend);
+ /* p_vend->madw_by_tid_map_p = NULL; */
+ /* __osm_mtl_init_tid_mad_map( p_vend ); */
+ p_vend->timeout = timeout;
+
+ Exit:
+ OSM_LOG_EXIT(p_log);
+ return (status);
}
/**********************************************************************
* Create and Initialize osm_vendor_t Object
**********************************************************************/
-osm_vendor_t *
-osm_vendor_new(
- IN osm_log_t* const p_log,
- IN const uint32_t timeout )
+osm_vendor_t *osm_vendor_new(IN osm_log_t * const p_log,
+ IN const uint32_t timeout)
{
- ib_api_status_t status;
- osm_vendor_t *p_vend;
-
- OSM_LOG_ENTER( p_log, osm_vendor_new );
-
- CL_ASSERT( p_log );
-
- p_vend = malloc( sizeof( *p_vend ) );
- if( p_vend != NULL )
- {
- memset( p_vend, 0, sizeof( *p_vend ) );
- status = osm_vendor_init( p_vend, p_log, timeout );
- if( status != IB_SUCCESS )
- {
- osm_vendor_delete( &p_vend );
- }
- }
- else
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_new: ERR 3C07: "
- "Fail to allocate vendor object.\n" );
- }
-
-
- OSM_LOG_EXIT( p_log );
- return ( p_vend );
+ ib_api_status_t status;
+ osm_vendor_t *p_vend;
+
+ OSM_LOG_ENTER(p_log, osm_vendor_new);
+
+ CL_ASSERT(p_log);
+
+ p_vend = malloc(sizeof(*p_vend));
+ if (p_vend != NULL) {
+ memset(p_vend, 0, sizeof(*p_vend));
+ status = osm_vendor_init(p_vend, p_log, timeout);
+ if (status != IB_SUCCESS) {
+ osm_vendor_delete(&p_vend);
+ }
+ } else {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_new: ERR 3C07: "
+ "Fail to allocate vendor object.\n");
+ }
+
+ OSM_LOG_EXIT(p_log);
+ return (p_vend);
}
/**********************************************************************
@@ -401,137 +378,136 @@ osm_vendor_new(
*
**********************************************************************/
void
-__osm_mtl_rcv_callback( IN IB_MGT_mad_hndl_t mad_hndl,
- IN void *private_ctx_p,
- IN void *payload_p,
- IN IB_MGT_mad_rcv_desc_t * rcv_remote_info_p )
+__osm_mtl_rcv_callback(IN IB_MGT_mad_hndl_t mad_hndl,
+ IN void *private_ctx_p,
+ IN void *payload_p,
+ IN IB_MGT_mad_rcv_desc_t * rcv_remote_info_p)
{
- IB_MGT_ret_t status;
- osm_mtl_bind_info_t *bind_info_p = private_ctx_p;
- osm_madw_t *req_madw_p = NULL;
- osm_madw_t *madw_p;
- osm_vend_wrap_t* p_new_vw;
- osm_mad_addr_t mad_addr;
- ib_mad_t *mad_buf_p;
- osm_log_t *const p_log = bind_info_p->p_vend->p_log;
-
- OSM_LOG_ENTER( p_log, __osm_mtl_rcv_callback );
-
-
- /* if it is a response MAD we mustbe able to get the request */
- if (ib_mad_is_response((ib_mad_t*)payload_p))
- {
- /* can we find a matching madw by this payload TID */
- status =
- osm_transaction_mgr_get_madw_for_tid(
- bind_info_p->p_vend, (ib_mad_t*)payload_p,
- &req_madw_p );
- if ( status != IB_MGT_OK )
- {
- osm_log( p_log, OSM_LOG_ERROR,
- "__osm_mtl_rcv_callback: ERR 3C08: "
- "Error obtaining request madw by TID (%d).\n", status );
- req_madw_p = NULL;
- }
-
- if (req_madw_p == NULL)
- {
- osm_log( p_log, OSM_LOG_ERROR,
- "__osm_mtl_rcv_callback: ERR 3C09: "
- "Fail to obtain request madw for received MAD.(method=%X attr=%X) Aborting CB.\n",
- ((ib_mad_t*)payload_p)->method,
- cl_ntoh16(((ib_mad_t*)payload_p)->attr_id)
-
- );
- goto Exit;
- }
- }
-
- /* do we have a request ??? */
- if( req_madw_p == NULL )
- {
-
- /* first arrange an address */
- __osm_mtl_conv_ibmgt_rcv_desc_to_osm_addr(
- bind_info_p->p_vend,
- rcv_remote_info_p,
- ( ((ib_mad_t*)payload_p)->mgmt_class == IB_MCLASS_SUBN_LID ) ||
- ( ((ib_mad_t*)payload_p)->mgmt_class == IB_MCLASS_SUBN_DIR ),
- &mad_addr);
-
- osm_log( p_log, OSM_LOG_ERROR,
- "__osm_mtl_rcv_callback: : "
- "Received MAD from QP:%X.\n",
- cl_ntoh32(mad_addr.addr_type.gsi.remote_qp)
- );
-
- /* if not - get new osm_madw and arrange it. */
- /* create the new madw in the pool */
- madw_p = osm_mad_pool_get( bind_info_p->p_osm_pool,
- ( osm_bind_handle_t ) bind_info_p,
- MAD_BLOCK_SIZE, &mad_addr );
- if( madw_p == NULL )
- {
- osm_log( p_log, OSM_LOG_ERROR,
- "__osm_mtl_rcv_callback: ERR 3C10: "
- "Error request for a new madw.\n" );
- goto Exit;
- }
- /* HACK: we cust to avoid the const ??? */
- mad_buf_p = (void *)madw_p->p_mad;
- }
- else
- {
- /* we have the madw defined during the send and stored in the vend_wrap */
- /* we need to make sure the wrapper is correctly init there */
- CL_ASSERT(req_madw_p->vend_wrap.p_resp_madw != 0);
- madw_p = req_madw_p->vend_wrap.p_resp_madw;
-
- /* HACK: we do not Support RMPP */
- CL_ASSERT(madw_p->h_bind);
- mad_buf_p = osm_vendor_get(madw_p->h_bind, MAD_BLOCK_SIZE, &madw_p->vend_wrap );
-
- if( mad_buf_p == NULL )
- {
- osm_log( p_log, OSM_LOG_ERROR,
- "__osm_mtl_rcv_callback: ERR 3C11: "
- "Unable to acquire wire MAD.\n" );
-
- goto Exit;
- }
-
- /*
- Finally, attach the wire MAD to this wrapper.
- */
- osm_madw_set_mad( madw_p, mad_buf_p );
-
- /* also we need to handle the size of the mad since we did not init ... */
- madw_p->mad_size = MAD_BLOCK_SIZE;
- }
-
-
- /* init some fields of the vendor wrapper */
- p_new_vw = osm_madw_get_vend_ptr( madw_p );
- p_new_vw->h_bind = bind_info_p;
- p_new_vw->size = MAD_BLOCK_SIZE;
- p_new_vw->p_resp_madw = NULL;
- p_new_vw->mad_buf_p = mad_buf_p;
-
- /* HACK: We do not support RMPP in receiving MADS */
- memcpy( p_new_vw->mad_buf_p, payload_p, MAD_BLOCK_SIZE );
-
- /* attach the buffer to the wrapper */
- madw_p->p_mad = mad_buf_p;
-
- /* we can also make sure we marked the size and bind on the returned madw */
- madw_p->h_bind = p_new_vw->h_bind;
-
- /* call the CB */
- ( *bind_info_p->rcv_callback ) ( madw_p, bind_info_p->client_context,
- req_madw_p );
-
- Exit:
- OSM_LOG_EXIT( p_log );
+ IB_MGT_ret_t status;
+ osm_mtl_bind_info_t *bind_info_p = private_ctx_p;
+ osm_madw_t *req_madw_p = NULL;
+ osm_madw_t *madw_p;
+ osm_vend_wrap_t *p_new_vw;
+ osm_mad_addr_t mad_addr;
+ ib_mad_t *mad_buf_p;
+ osm_log_t *const p_log = bind_info_p->p_vend->p_log;
+
+ OSM_LOG_ENTER(p_log, __osm_mtl_rcv_callback);
+
+ /* if it is a response MAD we mustbe able to get the request */
+ if (ib_mad_is_response((ib_mad_t *) payload_p)) {
+ /* can we find a matching madw by this payload TID */
+ status =
+ osm_transaction_mgr_get_madw_for_tid(bind_info_p->p_vend,
+ (ib_mad_t *) payload_p,
+ &req_madw_p);
+ if (status != IB_MGT_OK) {
+ osm_log(p_log, OSM_LOG_ERROR,
+ "__osm_mtl_rcv_callback: ERR 3C08: "
+ "Error obtaining request madw by TID (%d).\n",
+ status);
+ req_madw_p = NULL;
+ }
+
+ if (req_madw_p == NULL) {
+ osm_log(p_log, OSM_LOG_ERROR,
+ "__osm_mtl_rcv_callback: ERR 3C09: "
+ "Fail to obtain request madw for received MAD.(method=%X attr=%X) Aborting CB.\n",
+ ((ib_mad_t *) payload_p)->method,
+ cl_ntoh16(((ib_mad_t *) payload_p)->attr_id)
+
+ );
+ goto Exit;
+ }
+ }
+
+ /* do we have a request ??? */
+ if (req_madw_p == NULL) {
+
+ /* first arrange an address */
+ __osm_mtl_conv_ibmgt_rcv_desc_to_osm_addr(bind_info_p->p_vend,
+ rcv_remote_info_p,
+ (((ib_mad_t *)
+ payload_p)->
+ mgmt_class ==
+ IB_MCLASS_SUBN_LID)
+ ||
+ (((ib_mad_t *)
+ payload_p)->
+ mgmt_class ==
+ IB_MCLASS_SUBN_DIR),
+ &mad_addr);
+
+ osm_log(p_log, OSM_LOG_ERROR,
+ "__osm_mtl_rcv_callback: : "
+ "Received MAD from QP:%X.\n",
+ cl_ntoh32(mad_addr.addr_type.gsi.remote_qp)
+ );
+
+ /* if not - get new osm_madw and arrange it. */
+ /* create the new madw in the pool */
+ madw_p = osm_mad_pool_get(bind_info_p->p_osm_pool,
+ (osm_bind_handle_t) bind_info_p,
+ MAD_BLOCK_SIZE, &mad_addr);
+ if (madw_p == NULL) {
+ osm_log(p_log, OSM_LOG_ERROR,
+ "__osm_mtl_rcv_callback: ERR 3C10: "
+ "Error request for a new madw.\n");
+ goto Exit;
+ }
+ /* HACK: we cust to avoid the const ??? */
+ mad_buf_p = (void *)madw_p->p_mad;
+ } else {
+ /* we have the madw defined during the send and stored in the vend_wrap */
+ /* we need to make sure the wrapper is correctly init there */
+ CL_ASSERT(req_madw_p->vend_wrap.p_resp_madw != 0);
+ madw_p = req_madw_p->vend_wrap.p_resp_madw;
+
+ /* HACK: we do not Support RMPP */
+ CL_ASSERT(madw_p->h_bind);
+ mad_buf_p =
+ osm_vendor_get(madw_p->h_bind, MAD_BLOCK_SIZE,
+ &madw_p->vend_wrap);
+
+ if (mad_buf_p == NULL) {
+ osm_log(p_log, OSM_LOG_ERROR,
+ "__osm_mtl_rcv_callback: ERR 3C11: "
+ "Unable to acquire wire MAD.\n");
+
+ goto Exit;
+ }
+
+ /*
+ Finally, attach the wire MAD to this wrapper.
+ */
+ osm_madw_set_mad(madw_p, mad_buf_p);
+
+ /* also we need to handle the size of the mad since we did not init ... */
+ madw_p->mad_size = MAD_BLOCK_SIZE;
+ }
+
+ /* init some fields of the vendor wrapper */
+ p_new_vw = osm_madw_get_vend_ptr(madw_p);
+ p_new_vw->h_bind = bind_info_p;
+ p_new_vw->size = MAD_BLOCK_SIZE;
+ p_new_vw->p_resp_madw = NULL;
+ p_new_vw->mad_buf_p = mad_buf_p;
+
+ /* HACK: We do not support RMPP in receiving MADS */
+ memcpy(p_new_vw->mad_buf_p, payload_p, MAD_BLOCK_SIZE);
+
+ /* attach the buffer to the wrapper */
+ madw_p->p_mad = mad_buf_p;
+
+ /* we can also make sure we marked the size and bind on the returned madw */
+ madw_p->h_bind = p_new_vw->h_bind;
+
+ /* call the CB */
+ (*bind_info_p->rcv_callback) (madw_p, bind_info_p->client_context,
+ req_madw_p);
+
+ Exit:
+ OSM_LOG_EXIT(p_log);
}
/**********************************************************************
@@ -539,84 +515,78 @@ __osm_mtl_rcv_callback( IN IB_MGT_mad_hndl_t mad_hndl,
*
**********************************************************************/
void
-__osm_mtl_send_callback( IN IB_MGT_mad_hndl_t mad_hndl,
- IN u_int64_t wrid,
- IN IB_comp_status_t status,
- IN void *private_ctx_p )
+__osm_mtl_send_callback(IN IB_MGT_mad_hndl_t mad_hndl,
+ IN u_int64_t wrid,
+ IN IB_comp_status_t status, IN void *private_ctx_p)
{
- osm_madw_t *madw_p;
- osm_mtl_bind_info_t *bind_info_p = ( osm_mtl_bind_info_t * ) private_ctx_p;
- osm_log_t *const p_log = bind_info_p->p_vend->p_log;
- osm_vend_wrap_t* p_vw;
- uint8_t is_resp;
-
- OSM_LOG_ENTER( p_log, __osm_mtl_send_callback );
-
- /* obtain the madp from the wrid */
- __osm_set_p_madw_and_resp_by_wrid(wrid, &is_resp, &madw_p);
-
- osm_log( p_log, OSM_LOG_DEBUG,
- "__osm_mtl_send_callback: INFO 1008: "
- "Handling Send of MADW:%p Is Resp:%d.\n", madw_p, is_resp);
-
- /* we need to handle requests and responses differently */
- if (is_resp)
- {
- if (status != IB_COMP_SUCCESS)
- {
- osm_log( p_log, OSM_LOG_ERROR,
- "__osm_mtl_send_callback: ERR 3C12: "
- "Error Sending Response MADW:%p.\n", madw_p);
- }
- else
- {
- osm_log( p_log, OSM_LOG_DEBUG,
- "__osm_mtl_send_callback: DBG 1008: "
- "Completed Sending Response MADW:%p.\n", madw_p);
- }
-
- /* if we are a response - we need to clean it up */
- osm_mad_pool_put( bind_info_p->p_osm_pool, madw_p);
- }
- else
- {
-
- /* this call back is invoked on completion of send - error or not */
- if (status != IB_COMP_SUCCESS)
- {
-
- osm_log( p_log, OSM_LOG_ERROR,
- "__osm_mtl_send_callback: ERR 3C13: "
- "Received an Error from IB_MGT Send (%d).\n",status );
-
- p_vw = osm_madw_get_vend_ptr( madw_p );
- CL_ASSERT( p_vw );
-
- /*
- Return any wrappers to the pool that may have been
- pre-emptively allocated to handle a receive.
- */
- if( p_vw->p_resp_madw )
- {
- osm_mad_pool_put( bind_info_p->p_osm_pool, p_vw->p_resp_madw );
- p_vw->p_resp_madw = NULL;
- }
-
- /* invoke the CB */
- ( *bind_info_p->send_err_callback ) ( bind_info_p->client_context,
- madw_p );
- }
- else
- {
- /* successful request send - do nothing - the response will need the
- out mad */
- osm_log( p_log, OSM_LOG_DEBUG,
- "__osm_mtl_send_callback: DBG 1008: "
- "Completed Sending Request MADW:%p.\n", madw_p);
- }
- }
-
- OSM_LOG_EXIT( p_log );
+ osm_madw_t *madw_p;
+ osm_mtl_bind_info_t *bind_info_p =
+ (osm_mtl_bind_info_t *) private_ctx_p;
+ osm_log_t *const p_log = bind_info_p->p_vend->p_log;
+ osm_vend_wrap_t *p_vw;
+ uint8_t is_resp;
+
+ OSM_LOG_ENTER(p_log, __osm_mtl_send_callback);
+
+ /* obtain the madp from the wrid */
+ __osm_set_p_madw_and_resp_by_wrid(wrid, &is_resp, &madw_p);
+
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "__osm_mtl_send_callback: INFO 1008: "
+ "Handling Send of MADW:%p Is Resp:%d.\n", madw_p, is_resp);
+
+ /* we need to handle requests and responses differently */
+ if (is_resp) {
+ if (status != IB_COMP_SUCCESS) {
+ osm_log(p_log, OSM_LOG_ERROR,
+ "__osm_mtl_send_callback: ERR 3C12: "
+ "Error Sending Response MADW:%p.\n", madw_p);
+ } else {
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "__osm_mtl_send_callback: DBG 1008: "
+ "Completed Sending Response MADW:%p.\n",
+ madw_p);
+ }
+
+ /* if we are a response - we need to clean it up */
+ osm_mad_pool_put(bind_info_p->p_osm_pool, madw_p);
+ } else {
+
+ /* this call back is invoked on completion of send - error or not */
+ if (status != IB_COMP_SUCCESS) {
+
+ osm_log(p_log, OSM_LOG_ERROR,
+ "__osm_mtl_send_callback: ERR 3C13: "
+ "Received an Error from IB_MGT Send (%d).\n",
+ status);
+
+ p_vw = osm_madw_get_vend_ptr(madw_p);
+ CL_ASSERT(p_vw);
+
+ /*
+ Return any wrappers to the pool that may have been
+ pre-emptively allocated to handle a receive.
+ */
+ if (p_vw->p_resp_madw) {
+ osm_mad_pool_put(bind_info_p->p_osm_pool,
+ p_vw->p_resp_madw);
+ p_vw->p_resp_madw = NULL;
+ }
+
+ /* invoke the CB */
+ (*bind_info_p->send_err_callback) (bind_info_p->
+ client_context,
+ madw_p);
+ } else {
+ /* successful request send - do nothing - the response will need the
+ out mad */
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "__osm_mtl_send_callback: DBG 1008: "
+ "Completed Sending Request MADW:%p.\n", madw_p);
+ }
+ }
+
+ OSM_LOG_EXIT(p_log);
}
/**********************************************************************
@@ -624,318 +594,301 @@ __osm_mtl_send_callback( IN IB_MGT_mad_hndl_t mad_hndl,
* defined by the given: osm_bind_info_t
**********************************************************************/
osm_bind_handle_t
-osm_vendor_bind( IN osm_vendor_t * const p_vend,
- IN osm_bind_info_t * const p_user_bind,
- IN osm_mad_pool_t * const p_mad_pool,
- IN osm_vend_mad_recv_callback_t mad_recv_callback,
- IN osm_vend_mad_send_err_callback_t send_err_callback,
- IN void *context )
+osm_vendor_bind(IN osm_vendor_t * const p_vend,
+ IN osm_bind_info_t * const p_user_bind,
+ IN osm_mad_pool_t * const p_mad_pool,
+ IN osm_vend_mad_recv_callback_t mad_recv_callback,
+ IN osm_vend_mad_send_err_callback_t send_err_callback,
+ IN void *context)
{
- ib_net64_t port_guid;
- osm_mtl_bind_info_t *p_bind = NULL;
- VAPI_hca_hndl_t hca_hndl;
- VAPI_hca_id_t hca_id;
- IB_MGT_mad_type_t mad_type;
- uint32_t port_num;
- osm_vendor_mgt_bind_t *ib_mgt_hdl_p;
- IB_MGT_ret_t mgt_ret;
-
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_bind );
-
- CL_ASSERT( p_user_bind );
- CL_ASSERT( p_mad_pool );
- CL_ASSERT( mad_recv_callback );
- CL_ASSERT( send_err_callback );
-
- /* cast back the AL handle to vendor mgt bind */
- ib_mgt_hdl_p = ( osm_vendor_mgt_bind_t * ) p_vend->h_al;
-
- port_guid = p_user_bind->port_guid;
-
- osm_log( p_vend->p_log, OSM_LOG_INFO,
- "osm_vendor_bind: "
- "Binding to port 0x%" PRIx64 ".\n", cl_ntoh64( port_guid ) );
-
- /* obtain the hca name and port num from the guid */
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_bind: "
- "Finding CA and Port that owns port guid 0x%" PRIx64 ".\n",
- port_guid );
-
- mgt_ret =
- osm_vendor_get_guid_ca_and_port( p_vend, port_guid, &hca_hndl,
- &hca_id, &port_num );
- if( mgt_ret != IB_MGT_OK )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 3C14: "
- "Unable to obtain CA and port (%d).\n" );
- goto Exit;
- }
-
- /* create the bind object tracking this binding */
- p_bind = (osm_mtl_bind_info_t *)malloc( sizeof(osm_mtl_bind_info_t) );
- memset(p_bind, 0, sizeof(osm_mtl_bind_info_t));
- if( p_bind == NULL )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 3C15: "
- "Unable to allocate internal bind object.\n" );
- goto Exit;
- }
-
- /* track this bind request info */
- memcpy( p_bind->hca_id, hca_id, sizeof( VAPI_hca_id_t ) );
- p_bind->port_num = port_num;
- p_bind->p_vend = p_vend;
- p_bind->client_context = context;
- p_bind->rcv_callback = mad_recv_callback;
- p_bind->send_err_callback = send_err_callback;
- p_bind->p_osm_pool = p_mad_pool;
-
- CL_ASSERT( p_bind->port_num );
-
- /*
- * Get the proper CLASS
- */
-
- switch ( p_user_bind->mad_class )
- {
- case IB_MCLASS_SUBN_LID:
- case IB_MCLASS_SUBN_DIR:
- mad_type = IB_MGT_SMI;
- break;
-
- case IB_MCLASS_SUBN_ADM:
- default:
- mad_type = IB_MGT_GSI;
- break;
- }
-
- /* we split here - based on the type of MADS GSI / SMI */
- /* HACK: we only support one class registration per SMI/GSI !!! */
- if ( mad_type == IB_MGT_SMI )
- {
- /*
- * SMI CASE
- */
-
- /* we do not need to bind the handle if already available */
- if ( ib_mgt_hdl_p->smi_init == FALSE)
- {
-
- /* First we have to reg and get the handle for the mad */
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: " "Binding to IB_MGT SMI of %s port %u\n",
- hca_id, port_num
- );
-
- mgt_ret =
- IB_MGT_get_handle( hca_id, port_num, IB_MGT_SMI,
- &( ib_mgt_hdl_p->smi_mads_hdl ) );
- if( IB_MGT_OK != mgt_ret )
- {
- free( p_bind );
- p_bind = NULL;
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 3C16: "
- "Error obtaining IB_MGT handle to SMI.\n" );
- goto Exit;
- }
-
- /* bind it */
- mgt_ret = IB_MGT_bind_sm( ib_mgt_hdl_p->smi_mads_hdl );
- if( IB_MGT_OK != mgt_ret )
- {
- free( p_bind );
- p_bind = NULL;
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 3C17: "
- "Error binding IB_MGT handle to SM.\n" );
- goto Exit;
- }
-
- ib_mgt_hdl_p->smi_init = TRUE;
-
- }
-
- /* attach to this bind info */
- p_bind->mad_hndl = ib_mgt_hdl_p->smi_mads_hdl;
- ib_mgt_hdl_p->smi_p_bind = p_bind;
-
- /* now register the callback */
- mgt_ret = IB_MGT_reg_cb( p_bind->mad_hndl,
- &__osm_mtl_rcv_callback,
- p_bind,
- &__osm_mtl_send_callback,
- p_bind,
- IB_MGT_RCV_CB_MASK | IB_MGT_SEND_CB_MASK );
-
- }
- else
- {
- /*
- * GSI CASE
- */
-
- if ( ib_mgt_hdl_p->gsi_init == FALSE)
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: " "Binding to IB_MGT GSI\n");
-
- /* First we have to reg and get the handle for the mad */
- mgt_ret =
- IB_MGT_get_handle( hca_id, port_num, IB_MGT_GSI,
- &( ib_mgt_hdl_p->gsi_mads_hdl ) );
- if( IB_MGT_OK != mgt_ret )
- {
- free( p_bind );
- p_bind = NULL;
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 3C20: "
- "Error obtaining IB_MGT handle to GSI.\n" );
- goto Exit;
- }
-
- /* bind it */
- mgt_ret =
- IB_MGT_bind_gsi_class( ib_mgt_hdl_p->gsi_mads_hdl,
- p_user_bind->mad_class );
- if( IB_MGT_OK != mgt_ret )
- {
- free( p_bind );
- p_bind = NULL;
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 3C22: "
- "Error binding IB_MGT handle to GSI.\n" );
- goto Exit;
- }
-
- ib_mgt_hdl_p->gsi_init = TRUE;
-
- /* attach to this bind info */
- p_bind->mad_hndl = ib_mgt_hdl_p->gsi_mads_hdl;
-
- /* now register the callback */
- mgt_ret = IB_MGT_reg_cb( p_bind->mad_hndl,
- &__osm_mtl_rcv_callback,
- p_bind,
- &__osm_mtl_send_callback,
- p_bind,
- IB_MGT_RCV_CB_MASK | IB_MGT_SEND_CB_MASK );
-
- }
- else
- {
- /* we can use the existing handle */
- p_bind->mad_hndl = ib_mgt_hdl_p->gsi_mads_hdl;
- mgt_ret = IB_MGT_OK ;
- }
-
- }
-
- if( IB_MGT_OK != mgt_ret )
- {
- free( p_bind );
- p_bind = NULL;
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 3C23: "
- "Error binding IB_MGT CB (%d).\n", mgt_ret);
- goto Exit;
- }
-
- /* HACK: Do we need to initialize an address vector ???? */
-
- Exit:
- OSM_LOG_EXIT( p_vend->p_log );
- return ( ( osm_bind_handle_t ) p_bind );
+ ib_net64_t port_guid;
+ osm_mtl_bind_info_t *p_bind = NULL;
+ VAPI_hca_hndl_t hca_hndl;
+ VAPI_hca_id_t hca_id;
+ IB_MGT_mad_type_t mad_type;
+ uint32_t port_num;
+ osm_vendor_mgt_bind_t *ib_mgt_hdl_p;
+ IB_MGT_ret_t mgt_ret;
+
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_bind);
+
+ CL_ASSERT(p_user_bind);
+ CL_ASSERT(p_mad_pool);
+ CL_ASSERT(mad_recv_callback);
+ CL_ASSERT(send_err_callback);
+
+ /* cast back the AL handle to vendor mgt bind */
+ ib_mgt_hdl_p = (osm_vendor_mgt_bind_t *) p_vend->h_al;
+
+ port_guid = p_user_bind->port_guid;
+
+ osm_log(p_vend->p_log, OSM_LOG_INFO,
+ "osm_vendor_bind: "
+ "Binding to port 0x%" PRIx64 ".\n", cl_ntoh64(port_guid));
+
+ /* obtain the hca name and port num from the guid */
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_bind: "
+ "Finding CA and Port that owns port guid 0x%" PRIx64 ".\n",
+ port_guid);
+
+ mgt_ret =
+ osm_vendor_get_guid_ca_and_port(p_vend, port_guid, &hca_hndl,
+ &hca_id, &port_num);
+ if (mgt_ret != IB_MGT_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 3C14: "
+ "Unable to obtain CA and port (%d).\n");
+ goto Exit;
+ }
+
+ /* create the bind object tracking this binding */
+ p_bind = (osm_mtl_bind_info_t *) malloc(sizeof(osm_mtl_bind_info_t));
+ memset(p_bind, 0, sizeof(osm_mtl_bind_info_t));
+ if (p_bind == NULL) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 3C15: "
+ "Unable to allocate internal bind object.\n");
+ goto Exit;
+ }
+
+ /* track this bind request info */
+ memcpy(p_bind->hca_id, hca_id, sizeof(VAPI_hca_id_t));
+ p_bind->port_num = port_num;
+ p_bind->p_vend = p_vend;
+ p_bind->client_context = context;
+ p_bind->rcv_callback = mad_recv_callback;
+ p_bind->send_err_callback = send_err_callback;
+ p_bind->p_osm_pool = p_mad_pool;
+
+ CL_ASSERT(p_bind->port_num);
+
+ /*
+ * Get the proper CLASS
+ */
+
+ switch (p_user_bind->mad_class) {
+ case IB_MCLASS_SUBN_LID:
+ case IB_MCLASS_SUBN_DIR:
+ mad_type = IB_MGT_SMI;
+ break;
+
+ case IB_MCLASS_SUBN_ADM:
+ default:
+ mad_type = IB_MGT_GSI;
+ break;
+ }
+
+ /* we split here - based on the type of MADS GSI / SMI */
+ /* HACK: we only support one class registration per SMI/GSI !!! */
+ if (mad_type == IB_MGT_SMI) {
+ /*
+ * SMI CASE
+ */
+
+ /* we do not need to bind the handle if already available */
+ if (ib_mgt_hdl_p->smi_init == FALSE) {
+
+ /* First we have to reg and get the handle for the mad */
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: "
+ "Binding to IB_MGT SMI of %s port %u\n", hca_id,
+ port_num);
+
+ mgt_ret =
+ IB_MGT_get_handle(hca_id, port_num, IB_MGT_SMI,
+ &(ib_mgt_hdl_p->smi_mads_hdl));
+ if (IB_MGT_OK != mgt_ret) {
+ free(p_bind);
+ p_bind = NULL;
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 3C16: "
+ "Error obtaining IB_MGT handle to SMI.\n");
+ goto Exit;
+ }
+
+ /* bind it */
+ mgt_ret = IB_MGT_bind_sm(ib_mgt_hdl_p->smi_mads_hdl);
+ if (IB_MGT_OK != mgt_ret) {
+ free(p_bind);
+ p_bind = NULL;
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 3C17: "
+ "Error binding IB_MGT handle to SM.\n");
+ goto Exit;
+ }
+
+ ib_mgt_hdl_p->smi_init = TRUE;
+
+ }
+
+ /* attach to this bind info */
+ p_bind->mad_hndl = ib_mgt_hdl_p->smi_mads_hdl;
+ ib_mgt_hdl_p->smi_p_bind = p_bind;
+
+ /* now register the callback */
+ mgt_ret = IB_MGT_reg_cb(p_bind->mad_hndl,
+ &__osm_mtl_rcv_callback,
+ p_bind,
+ &__osm_mtl_send_callback,
+ p_bind,
+ IB_MGT_RCV_CB_MASK |
+ IB_MGT_SEND_CB_MASK);
+
+ } else {
+ /*
+ * GSI CASE
+ */
+
+ if (ib_mgt_hdl_p->gsi_init == FALSE) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: " "Binding to IB_MGT GSI\n");
+
+ /* First we have to reg and get the handle for the mad */
+ mgt_ret =
+ IB_MGT_get_handle(hca_id, port_num, IB_MGT_GSI,
+ &(ib_mgt_hdl_p->gsi_mads_hdl));
+ if (IB_MGT_OK != mgt_ret) {
+ free(p_bind);
+ p_bind = NULL;
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 3C20: "
+ "Error obtaining IB_MGT handle to GSI.\n");
+ goto Exit;
+ }
+
+ /* bind it */
+ mgt_ret =
+ IB_MGT_bind_gsi_class(ib_mgt_hdl_p->gsi_mads_hdl,
+ p_user_bind->mad_class);
+ if (IB_MGT_OK != mgt_ret) {
+ free(p_bind);
+ p_bind = NULL;
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 3C22: "
+ "Error binding IB_MGT handle to GSI.\n");
+ goto Exit;
+ }
+
+ ib_mgt_hdl_p->gsi_init = TRUE;
+
+ /* attach to this bind info */
+ p_bind->mad_hndl = ib_mgt_hdl_p->gsi_mads_hdl;
+
+ /* now register the callback */
+ mgt_ret = IB_MGT_reg_cb(p_bind->mad_hndl,
+ &__osm_mtl_rcv_callback,
+ p_bind,
+ &__osm_mtl_send_callback,
+ p_bind,
+ IB_MGT_RCV_CB_MASK |
+ IB_MGT_SEND_CB_MASK);
+
+ } else {
+ /* we can use the existing handle */
+ p_bind->mad_hndl = ib_mgt_hdl_p->gsi_mads_hdl;
+ mgt_ret = IB_MGT_OK;
+ }
+
+ }
+
+ if (IB_MGT_OK != mgt_ret) {
+ free(p_bind);
+ p_bind = NULL;
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 3C23: "
+ "Error binding IB_MGT CB (%d).\n", mgt_ret);
+ goto Exit;
+ }
+
+ /* HACK: Do we need to initialize an address vector ???? */
+
+ Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return ((osm_bind_handle_t) p_bind);
}
/**********************************************************************
Get a mad from the lower level.
The osm_vend_wrap_t is a wrapper used to connect the mad to the response.
**********************************************************************/
-ib_mad_t *
-osm_vendor_get( IN osm_bind_handle_t h_bind,
- IN const uint32_t mad_size,
- IN osm_vend_wrap_t * const p_vw )
+ib_mad_t *osm_vendor_get(IN osm_bind_handle_t h_bind,
+ IN const uint32_t mad_size,
+ IN osm_vend_wrap_t * const p_vw)
{
- ib_mad_t *mad_p;
- osm_mtl_bind_info_t *p_bind = ( osm_mtl_bind_info_t * ) h_bind;
- osm_vendor_t *p_vend = p_bind->p_vend;
-
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_get );
-
- CL_ASSERT( p_vw );
- /* HACK: We know we can not send through IB_MGT */
- CL_ASSERT( mad_size <= MAD_BLOCK_SIZE );
-
- /* IB_MGT assumes it is 256 - we must follow */
- p_vw->size = MAD_BLOCK_SIZE;
-
- /* allocate it */
- mad_p = ( ib_mad_t * ) malloc( p_vw->size );
- if( mad_p == NULL )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get: ERR 3C24: "
- "Error Obtaining MAD buffer.\n" );
- goto Exit;
- }
-
- memset( mad_p, 0, p_vw->size );
-
- /* track locally */
- p_vw->mad_buf_p = mad_p;
- p_vw->h_bind = h_bind;
- p_vw->p_resp_madw = NULL;
-
- if( osm_log_get_level( p_vend->p_log ) >= OSM_LOG_DEBUG )
- {
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_get: "
- "Acquired MAD %p, size = %u.\n", mad_p, p_vw->size );
- }
-
- Exit:
- OSM_LOG_EXIT( p_vend->p_log );
- return ( mad_p );
+ ib_mad_t *mad_p;
+ osm_mtl_bind_info_t *p_bind = (osm_mtl_bind_info_t *) h_bind;
+ osm_vendor_t *p_vend = p_bind->p_vend;
+
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_get);
+
+ CL_ASSERT(p_vw);
+ /* HACK: We know we can not send through IB_MGT */
+ CL_ASSERT(mad_size <= MAD_BLOCK_SIZE);
+
+ /* IB_MGT assumes it is 256 - we must follow */
+ p_vw->size = MAD_BLOCK_SIZE;
+
+ /* allocate it */
+ mad_p = (ib_mad_t *) malloc(p_vw->size);
+ if (mad_p == NULL) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get: ERR 3C24: "
+ "Error Obtaining MAD buffer.\n");
+ goto Exit;
+ }
+
+ memset(mad_p, 0, p_vw->size);
+
+ /* track locally */
+ p_vw->mad_buf_p = mad_p;
+ p_vw->h_bind = h_bind;
+ p_vw->p_resp_madw = NULL;
+
+ if (osm_log_get_level(p_vend->p_log) >= OSM_LOG_DEBUG) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_get: "
+ "Acquired MAD %p, size = %u.\n", mad_p, p_vw->size);
+ }
+
+ Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (mad_p);
}
/**********************************************************************
* Return a MAD by providing it's wrapper object.
**********************************************************************/
void
-osm_vendor_put( IN osm_bind_handle_t h_bind,
- IN osm_vend_wrap_t * const p_vw )
+osm_vendor_put(IN osm_bind_handle_t h_bind, IN osm_vend_wrap_t * const p_vw)
{
- osm_mtl_bind_info_t *p_bind = ( osm_mtl_bind_info_t * ) h_bind;
- osm_vendor_t *p_vend = p_bind->p_vend;
- osm_madw_t *p_madw;
+ osm_mtl_bind_info_t *p_bind = (osm_mtl_bind_info_t *) h_bind;
+ osm_vendor_t *p_vend = p_bind->p_vend;
+ osm_madw_t *p_madw;
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_put );
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_put);
- CL_ASSERT( p_vw );
- CL_ASSERT( p_vw->mad_buf_p );
+ CL_ASSERT(p_vw);
+ CL_ASSERT(p_vw->mad_buf_p);
- if( osm_log_get_level( p_vend->p_log ) >= OSM_LOG_DEBUG )
- {
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_put: " "Retiring MAD %p.\n", p_vw->mad_buf_p );
- }
+ if (osm_log_get_level(p_vend->p_log) >= OSM_LOG_DEBUG) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_put: " "Retiring MAD %p.\n",
+ p_vw->mad_buf_p);
+ }
- /*
- * We moved the removal of the transaction to immediatly after
- * it was looked up.
- */
+ /*
+ * We moved the removal of the transaction to immediatly after
+ * it was looked up.
+ */
- /* free the mad but the wrapper is part of the madw object */
- free( p_vw->mad_buf_p );
- p_vw->mad_buf_p = NULL;
- p_madw = PARENT_STRUCT( p_vw, osm_madw_t, vend_wrap);
- p_madw->p_mad = NULL;
+ /* free the mad but the wrapper is part of the madw object */
+ free(p_vw->mad_buf_p);
+ p_vw->mad_buf_p = NULL;
+ p_madw = PARENT_STRUCT(p_vw, osm_madw_t, vend_wrap);
+ p_madw->p_mad = NULL;
- OSM_LOG_EXIT( p_vend->p_log );
+ OSM_LOG_EXIT(p_vend->p_log);
}
/**********************************************************************
@@ -945,109 +898,96 @@ This is for internal use by osm_vendor_send and the transaction mgr
retry too.
**********************************************************************/
ib_api_status_t
-osm_mtl_send_mad(
- IN osm_mtl_bind_info_t *p_bind,
- IN osm_madw_t * const p_madw)
+osm_mtl_send_mad(IN osm_mtl_bind_info_t * p_bind, IN osm_madw_t * const p_madw)
{
- osm_vendor_t *const p_vend = p_bind->p_vend;
- osm_vend_wrap_t *const p_vw = osm_madw_get_vend_ptr( p_madw );
- osm_mad_addr_t *const p_mad_addr = osm_madw_get_mad_addr_ptr( p_madw );
- ib_mad_t *const p_mad = osm_madw_get_mad_ptr( p_madw );
- ib_api_status_t status;
- IB_MGT_ret_t mgt_res;
- IB_ud_av_t av;
- uint64_t wrid;
- uint32_t qpn;
-
- OSM_LOG_ENTER( p_vend->p_log, osm_mtl_send_mad );
-
- /*
- * For all sends other than directed route SM MADs,
- * acquire an address vector for the destination.
- */
- if( p_mad->mgmt_class != IB_MCLASS_SUBN_DIR )
- {
- __osm_mtl_conv_osm_addr_to_ibmgt_addr(p_mad_addr,
- p_mad->mgmt_class == IB_MCLASS_SUBN_LID,
- &av);
- }
- else
- {
- /* is a directed route - we need to construct a permissive address */
- memset( &av, 0, sizeof( av ) );
- /* we do not need port number since it is part of the mad_hndl */
- av.dlid = IB_LID_PERMISSIVE;
- }
-
- wrid = __osm_set_wrid_by_p_madw(p_madw);
-
- /* send it */
- if( (p_mad->mgmt_class == IB_MCLASS_SUBN_DIR) ||
- (p_mad->mgmt_class == IB_MCLASS_SUBN_LID)) {
-
- /* SMI CASE */
- if( osm_log_is_active( p_vend->p_log, OSM_LOG_DEBUG ) )
- {
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "osm_mtl_send_mad: "
- "av.dlid 0x%X, "
- "av.static_rate %d, "
- "av.path_bits %d.\n",
- cl_ntoh16( av.dlid ), av.static_rate, av.src_path_bits );
- }
-
- mgt_res = IB_MGT_send_mad( p_bind->mad_hndl, p_mad, /* actual payload */
- &av, /* address vector */
- wrid, /* casting the mad wrapper pointer for err cb */
- p_vend->timeout );
-
- }
- else
- {
- /* GSI CASE - Support Remote QP */
- if( osm_log_is_active( p_vend->p_log, OSM_LOG_DEBUG ) )
- {
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "osm_mtl_send_mad: "
- "av.dlid 0x%X, av.static_rate %d, "
- "av.path_bits %d, remote qp: 0x%06X \n",
- av.dlid,
- av.static_rate,
- av.src_path_bits,
- cl_ntoh32(p_mad_addr->addr_type.gsi.remote_qp)
- );
- }
-
- /* IBMGT have a bug sending to a QP not 1 -
- the QPN must be in network order except when it qpn 1 ... */
- qpn = cl_ntoh32(p_mad_addr->addr_type.gsi.remote_qp);
-
- mgt_res =
- IB_MGT_send_mad_to_qp(
- p_bind->mad_hndl, p_mad, /* actual payload */
- &av, /* address vector */
- wrid, /* casting the mad wrapper pointer for err cb */
- p_vend->timeout,
- qpn
- );
- }
-
- if( mgt_res != IB_MGT_OK )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_mtl_send_mad: ERR 3C26: "
- "Error sending mad (%d).\n", mgt_res );
- if( p_vw->p_resp_madw )
- osm_mad_pool_put( p_bind->p_osm_pool, p_vw->p_resp_madw );
- status = IB_ERROR;
- goto Exit;
- }
-
- status = IB_SUCCESS;
-
- Exit:
- OSM_LOG_EXIT( p_vend->p_log );
- return(status);
+ osm_vendor_t *const p_vend = p_bind->p_vend;
+ osm_vend_wrap_t *const p_vw = osm_madw_get_vend_ptr(p_madw);
+ osm_mad_addr_t *const p_mad_addr = osm_madw_get_mad_addr_ptr(p_madw);
+ ib_mad_t *const p_mad = osm_madw_get_mad_ptr(p_madw);
+ ib_api_status_t status;
+ IB_MGT_ret_t mgt_res;
+ IB_ud_av_t av;
+ uint64_t wrid;
+ uint32_t qpn;
+
+ OSM_LOG_ENTER(p_vend->p_log, osm_mtl_send_mad);
+
+ /*
+ * For all sends other than directed route SM MADs,
+ * acquire an address vector for the destination.
+ */
+ if (p_mad->mgmt_class != IB_MCLASS_SUBN_DIR) {
+ __osm_mtl_conv_osm_addr_to_ibmgt_addr(p_mad_addr,
+ p_mad->mgmt_class ==
+ IB_MCLASS_SUBN_LID, &av);
+ } else {
+ /* is a directed route - we need to construct a permissive address */
+ memset(&av, 0, sizeof(av));
+ /* we do not need port number since it is part of the mad_hndl */
+ av.dlid = IB_LID_PERMISSIVE;
+ }
+
+ wrid = __osm_set_wrid_by_p_madw(p_madw);
+
+ /* send it */
+ if ((p_mad->mgmt_class == IB_MCLASS_SUBN_DIR) ||
+ (p_mad->mgmt_class == IB_MCLASS_SUBN_LID)) {
+
+ /* SMI CASE */
+ if (osm_log_is_active(p_vend->p_log, OSM_LOG_DEBUG)) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_mtl_send_mad: "
+ "av.dlid 0x%X, "
+ "av.static_rate %d, "
+ "av.path_bits %d.\n",
+ cl_ntoh16(av.dlid), av.static_rate,
+ av.src_path_bits);
+ }
+
+ mgt_res = IB_MGT_send_mad(p_bind->mad_hndl, p_mad, /* actual payload */
+ &av, /* address vector */
+ wrid, /* casting the mad wrapper pointer for err cb */
+ p_vend->timeout);
+
+ } else {
+ /* GSI CASE - Support Remote QP */
+ if (osm_log_is_active(p_vend->p_log, OSM_LOG_DEBUG)) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_mtl_send_mad: "
+ "av.dlid 0x%X, av.static_rate %d, "
+ "av.path_bits %d, remote qp: 0x%06X \n",
+ av.dlid,
+ av.static_rate,
+ av.src_path_bits,
+ cl_ntoh32(p_mad_addr->addr_type.gsi.remote_qp)
+ );
+ }
+
+ /* IBMGT have a bug sending to a QP not 1 -
+ the QPN must be in network order except when it qpn 1 ... */
+ qpn = cl_ntoh32(p_mad_addr->addr_type.gsi.remote_qp);
+
+ mgt_res = IB_MGT_send_mad_to_qp(p_bind->mad_hndl, p_mad, /* actual payload */
+ &av, /* address vector */
+ wrid, /* casting the mad wrapper pointer for err cb */
+ p_vend->timeout, qpn);
+ }
+
+ if (mgt_res != IB_MGT_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_mtl_send_mad: ERR 3C26: "
+ "Error sending mad (%d).\n", mgt_res);
+ if (p_vw->p_resp_madw)
+ osm_mad_pool_put(p_bind->p_osm_pool, p_vw->p_resp_madw);
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+ status = IB_SUCCESS;
+
+ Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
}
/**********************************************************************
@@ -1057,125 +997,112 @@ What is unclear to me is the need for the setting of all the MAD Wrapper
fields. Seems like the OSM uses these values during it's processing...
**********************************************************************/
ib_api_status_t
-osm_vendor_send( IN osm_bind_handle_t h_bind,
- IN osm_madw_t * const p_madw,
- IN boolean_t const resp_expected )
+osm_vendor_send(IN osm_bind_handle_t h_bind,
+ IN osm_madw_t * const p_madw, IN boolean_t const resp_expected)
{
- osm_mtl_bind_info_t *const p_bind = (osm_mtl_bind_info_t *)h_bind;
- osm_vendor_t *const p_vend = p_bind->p_vend;
- osm_vend_wrap_t *const p_vw = osm_madw_get_vend_ptr( p_madw );
- ib_api_status_t status;
-
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_send );
-
- /*
- * If a response is expected to this MAD, then preallocate
- * a mad wrapper to contain the wire MAD received in the
- * response. Allocating a wrapper here allows for easier
- * failure paths than after we already received the wire mad.
- */
- if( resp_expected == TRUE )
- {
- /* we track it in the vendor wrapper */
- p_vw->p_resp_madw =
- osm_mad_pool_get_wrapper_raw( p_bind->p_osm_pool );
- if( p_vw->p_resp_madw == NULL )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_send: ERR 3C27: "
- "Unable to allocate MAD wrapper.\n" );
- status = IB_INSUFFICIENT_RESOURCES;
- goto Exit;
- }
-
- /* put some minimal info on that wrapper */
- ((osm_madw_t *)(p_vw->p_resp_madw))->h_bind = h_bind;
-
- /* we also want to track it in the TID based map */
- status = osm_transaction_mgr_insert_madw(
- (osm_bind_handle_t)p_bind, p_madw );
- if( status != IB_SUCCESS )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_send: ERR 3C25: "
- "Error inserting request madw by TID (%d).\n", status );
- }
-
- }
- else
- p_vw->p_resp_madw = NULL;
-
- /* do the actual send */
- status = osm_mtl_send_mad(p_bind, p_madw);
-
- Exit:
- OSM_LOG_EXIT( p_vend->p_log );
- return ( status );
+ osm_mtl_bind_info_t *const p_bind = (osm_mtl_bind_info_t *) h_bind;
+ osm_vendor_t *const p_vend = p_bind->p_vend;
+ osm_vend_wrap_t *const p_vw = osm_madw_get_vend_ptr(p_madw);
+ ib_api_status_t status;
+
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_send);
+
+ /*
+ * If a response is expected to this MAD, then preallocate
+ * a mad wrapper to contain the wire MAD received in the
+ * response. Allocating a wrapper here allows for easier
+ * failure paths than after we already received the wire mad.
+ */
+ if (resp_expected == TRUE) {
+ /* we track it in the vendor wrapper */
+ p_vw->p_resp_madw =
+ osm_mad_pool_get_wrapper_raw(p_bind->p_osm_pool);
+ if (p_vw->p_resp_madw == NULL) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_send: ERR 3C27: "
+ "Unable to allocate MAD wrapper.\n");
+ status = IB_INSUFFICIENT_RESOURCES;
+ goto Exit;
+ }
+
+ /* put some minimal info on that wrapper */
+ ((osm_madw_t *) (p_vw->p_resp_madw))->h_bind = h_bind;
+
+ /* we also want to track it in the TID based map */
+ status = osm_transaction_mgr_insert_madw((osm_bind_handle_t)
+ p_bind, p_madw);
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_send: ERR 3C25: "
+ "Error inserting request madw by TID (%d).\n",
+ status);
+ }
+
+ } else
+ p_vw->p_resp_madw = NULL;
+
+ /* do the actual send */
+ status = osm_mtl_send_mad(p_bind, p_madw);
+
+ Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
}
-
/**********************************************************************
* the idea here is to change the content of the bind such that it
* will hold the local address used for sending directed route by the SMA.
**********************************************************************/
-ib_api_status_t
-osm_vendor_local_lid_change( IN osm_bind_handle_t h_bind )
+ib_api_status_t osm_vendor_local_lid_change(IN osm_bind_handle_t h_bind)
{
- osm_vendor_t *p_vend = ( ( osm_mtl_bind_info_t * ) h_bind )->p_vend;
+ osm_vendor_t *p_vend = ((osm_mtl_bind_info_t *) h_bind)->p_vend;
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_local_lid_change );
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_local_lid_change);
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_local_lid_change: DEBUG 2202: " "Change of LID.\n" );
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_local_lid_change: DEBUG 2202: " "Change of LID.\n");
- OSM_LOG_EXIT( p_vend->p_log );
+ OSM_LOG_EXIT(p_vend->p_log);
- return ( IB_SUCCESS );
+ return (IB_SUCCESS);
}
/**********************************************************************
**********************************************************************/
-void
-osm_vendor_set_sm(
- IN osm_bind_handle_t h_bind,
- IN boolean_t is_sm_val )
+void osm_vendor_set_sm(IN osm_bind_handle_t h_bind, IN boolean_t is_sm_val)
{
- osm_mtl_bind_info_t *p_bind = ( osm_mtl_bind_info_t * ) h_bind;
- osm_vendor_t *p_vend = p_bind->p_vend;
- VAPI_ret_t status;
- VAPI_hca_attr_t attr_mod;
- VAPI_hca_attr_mask_t attr_mask;
-
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_set_sm );
-
- memset( &attr_mod, 0, sizeof( attr_mod ) );
- memset( &attr_mask, 0, sizeof( attr_mask ) );
-
- attr_mod.is_sm = is_sm_val;
- attr_mask = HCA_ATTR_IS_SM;
-
- status =
- VAPI_modify_hca_attr( p_bind->hca_hndl, p_bind->port_num, &attr_mod,
- &attr_mask );
- if( status != VAPI_OK )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_set_sm: ERR 3C28: "
- "Unable set 'IS_SM' bit to:%u in port attributes (%d).\n",
- is_sm_val, status );
- }
-
- OSM_LOG_EXIT( p_vend->p_log );
+ osm_mtl_bind_info_t *p_bind = (osm_mtl_bind_info_t *) h_bind;
+ osm_vendor_t *p_vend = p_bind->p_vend;
+ VAPI_ret_t status;
+ VAPI_hca_attr_t attr_mod;
+ VAPI_hca_attr_mask_t attr_mask;
+
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_set_sm);
+
+ memset(&attr_mod, 0, sizeof(attr_mod));
+ memset(&attr_mask, 0, sizeof(attr_mask));
+
+ attr_mod.is_sm = is_sm_val;
+ attr_mask = HCA_ATTR_IS_SM;
+
+ status =
+ VAPI_modify_hca_attr(p_bind->hca_hndl, p_bind->port_num, &attr_mod,
+ &attr_mask);
+ if (status != VAPI_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_set_sm: ERR 3C28: "
+ "Unable set 'IS_SM' bit to:%u in port attributes (%d).\n",
+ is_sm_val, status);
+ }
+
+ OSM_LOG_EXIT(p_vend->p_log);
}
/**********************************************************************
**********************************************************************/
-void
-osm_vendor_set_debug(
- IN osm_vendor_t* const p_vend,
- IN int32_t level )
+void osm_vendor_set_debug(IN osm_vendor_t * const p_vend, IN int32_t level)
{
}
-#endif /* OSM_VENDOR_INTF_TEST */
+#endif /* OSM_VENDOR_INTF_TEST */
diff --git a/opensm/libvendor/osm_vendor_mtl_hca_guid.c b/opensm/libvendor/osm_vendor_mtl_hca_guid.c
index 6f329ac..8ef4805 100644
--- a/opensm/libvendor/osm_vendor_mtl_hca_guid.c
+++ b/opensm/libvendor/osm_vendor_mtl_hca_guid.c
@@ -33,10 +33,9 @@
*
*/
-
#if HAVE_CONFIG_H
# include <config.h>
-#endif /* HAVE_CONFIG_H */
+#endif /* HAVE_CONFIG_H */
#if defined(OSM_VENDOR_INTF_MTL) | defined(OSM_VENDOR_INTF_TS)
#undef IN
@@ -61,11 +60,10 @@
**********************************************************************/
ib_api_status_t
-__osm_vendor_gid_to_guid( IN u_int8_t * gid,
- OUT VAPI_gid_t * guid )
+__osm_vendor_gid_to_guid(IN u_int8_t * gid, OUT VAPI_gid_t * guid)
{
- memcpy( guid, gid + 8, 8 );
- return ( IB_SUCCESS );
+ memcpy(guid, gid + 8, 8);
+ return (IB_SUCCESS);
}
/****f* OpenSM: CA Info/osm_ca_info_get_pi_ptr
@@ -78,11 +76,11 @@ __osm_vendor_gid_to_guid( IN u_int8_t * gid,
*
* SYNOPSIS
*/
-static ib_port_attr_t *
-__osm_ca_info_get_port_attr_ptr( IN const osm_ca_info_t * const p_ca_info,
- IN const uint8_t index )
+static ib_port_attr_t *__osm_ca_info_get_port_attr_ptr(IN const osm_ca_info_t *
+ const p_ca_info,
+ IN const uint8_t index)
{
- return ( &p_ca_info->p_attr->p_port_attr[index] );
+ return (&p_ca_info->p_attr->p_port_attr[index]);
}
/*
@@ -109,213 +107,199 @@ __osm_ca_info_get_port_attr_ptr( IN const osm_ca_info_t * const p_ca_info,
* NOTE: user of this function needs to deallocate p_hca_ids after usage.
********************************************************************************/
static ib_api_status_t
-__osm_vendor_get_ca_ids( IN osm_vendor_t * const p_vend,
- IN VAPI_hca_id_t ** const p_hca_ids,
- IN uint32_t * const p_num_guids )
+__osm_vendor_get_ca_ids(IN osm_vendor_t * const p_vend,
+ IN VAPI_hca_id_t ** const p_hca_ids,
+ IN uint32_t * const p_num_guids)
{
- ib_api_status_t status;
- VAPI_ret_t vapi_res;
-
- OSM_LOG_ENTER( p_vend->p_log, __osm_vendor_get_ca_ids );
-
- CL_ASSERT( p_hca_ids );
- CL_ASSERT( p_num_guids );
-
- /* first call is just to get the number */
- vapi_res = EVAPI_list_hcas( 0, p_num_guids, NULL );
-
- /* fail ? */
- if( vapi_res == VAPI_EINVAL_PARAM )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__osm_vendor_get_ca_ids: ERR 7101: "
- "Bad parameter in calling: EVAPI_list_hcas. (%d)\n",
- vapi_res );
- status = IB_ERROR;
- goto Exit;
- }
-
- /* NO HCA ? */
- if( *p_num_guids == 0 )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__osm_vendor_get_ca_ids: ERR 7102: "
- "No available channel adapters.\n" );
- status = IB_INSUFFICIENT_RESOURCES;
- goto Exit;
- }
-
- /* allocate and really call - user of this function needs to deallocate it */
- *p_hca_ids =
- ( VAPI_hca_id_t * ) malloc( *p_num_guids *
- sizeof( VAPI_hca_id_t ) );
-
- /* now call it really */
- vapi_res = EVAPI_list_hcas( *p_num_guids, p_num_guids, *p_hca_ids );
-
- /* too many ? */
- if( vapi_res == VAPI_EAGAIN )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__osm_vendor_get_ca_ids: ERR 7103: "
- "More CA GUIDs than allocated array (%d).\n", *p_num_guids );
- status = IB_ERROR;
- goto Exit;
- }
-
- /* fail ? */
- if( vapi_res != VAPI_OK )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__osm_vendor_get_ca_ids: ERR 7104: "
- "Bad parameter in calling: EVAPI_list_hcas.\n" );
- status = IB_ERROR;
- goto Exit;
- }
-
- if( osm_log_is_active( p_vend->p_log, OSM_LOG_DEBUG ) )
- {
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "__osm_vendor_get_ca_ids: "
- "Detected %u local channel adapters.\n", *p_num_guids );
- }
-
- status = IB_SUCCESS;
-
- Exit:
- OSM_LOG_EXIT( p_vend->p_log );
- return ( status );
+ ib_api_status_t status;
+ VAPI_ret_t vapi_res;
+
+ OSM_LOG_ENTER(p_vend->p_log, __osm_vendor_get_ca_ids);
+
+ CL_ASSERT(p_hca_ids);
+ CL_ASSERT(p_num_guids);
+
+ /* first call is just to get the number */
+ vapi_res = EVAPI_list_hcas(0, p_num_guids, NULL);
+
+ /* fail ? */
+ if (vapi_res == VAPI_EINVAL_PARAM) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_vendor_get_ca_ids: ERR 7101: "
+ "Bad parameter in calling: EVAPI_list_hcas. (%d)\n",
+ vapi_res);
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+ /* NO HCA ? */
+ if (*p_num_guids == 0) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_vendor_get_ca_ids: ERR 7102: "
+ "No available channel adapters.\n");
+ status = IB_INSUFFICIENT_RESOURCES;
+ goto Exit;
+ }
+
+ /* allocate and really call - user of this function needs to deallocate it */
+ *p_hca_ids =
+ (VAPI_hca_id_t *) malloc(*p_num_guids * sizeof(VAPI_hca_id_t));
+
+ /* now call it really */
+ vapi_res = EVAPI_list_hcas(*p_num_guids, p_num_guids, *p_hca_ids);
+
+ /* too many ? */
+ if (vapi_res == VAPI_EAGAIN) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_vendor_get_ca_ids: ERR 7103: "
+ "More CA GUIDs than allocated array (%d).\n",
+ *p_num_guids);
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+ /* fail ? */
+ if (vapi_res != VAPI_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_vendor_get_ca_ids: ERR 7104: "
+ "Bad parameter in calling: EVAPI_list_hcas.\n");
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+ if (osm_log_is_active(p_vend->p_log, OSM_LOG_DEBUG)) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__osm_vendor_get_ca_ids: "
+ "Detected %u local channel adapters.\n", *p_num_guids);
+ }
+
+ status = IB_SUCCESS;
+
+ Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
}
-
/**********************************************************************
* Initialize an Info Struct for the Given HCA by its Id
**********************************************************************/
static ib_api_status_t
-__osm_ca_info_init( IN osm_vendor_t * const p_vend,
- IN VAPI_hca_id_t ca_id,
- OUT osm_ca_info_t * const p_ca_info )
+__osm_ca_info_init(IN osm_vendor_t * const p_vend,
+ IN VAPI_hca_id_t ca_id, OUT osm_ca_info_t * const p_ca_info)
{
- ib_api_status_t status = IB_ERROR;
- VAPI_ret_t vapi_res;
- VAPI_hca_hndl_t hca_hndl;
- VAPI_hca_vendor_t hca_vendor;
- VAPI_hca_cap_t hca_cap;
- VAPI_hca_port_t hca_port;
- uint8_t port_num;
- IB_gid_t *p_port_gid;
- uint16_t maxNumGids;
-
- OSM_LOG_ENTER( p_vend->p_log, __osm_ca_info_init );
-
- /* get the HCA handle */
- vapi_res = EVAPI_get_hca_hndl( ca_id, &hca_hndl );
- if( vapi_res != VAPI_OK )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__osm_ca_info_init: ERR 7105: "
- "Fail to get HCA handle (%u).\n", vapi_res );
- goto Exit;
- }
-
- if( osm_log_is_active( p_vend->p_log, OSM_LOG_DEBUG ) )
- {
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "__osm_ca_info_init: " "Querying CA %s.\n", ca_id );
- }
-
- /* query and get the HCA capability */
- vapi_res = VAPI_query_hca_cap( hca_hndl, &hca_vendor, &hca_cap );
- if( vapi_res != VAPI_OK )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__osm_ca_info_init: ERR 7106: "
- "Fail to get HCA Capabilities (%u).\n", vapi_res );
- goto Exit;
- }
-
- /* get the guid of the HCA */
- memcpy( &( p_ca_info->guid ), hca_cap.node_guid, 8 * sizeof( u_int8_t ) );
- p_ca_info->attr_size = 1;
- p_ca_info->p_attr =
- ( ib_ca_attr_t * ) malloc( sizeof( ib_ca_attr_t ) );
- memcpy( &( p_ca_info->p_attr->ca_guid ), hca_cap.node_guid,
- 8 * sizeof( u_int8_t ) );
-
- /* now obtain the attributes of the ports */
- p_ca_info->p_attr->num_ports = hca_cap.phys_port_num;
- p_ca_info->p_attr->p_port_attr =
- ( ib_port_attr_t * ) malloc( hca_cap.phys_port_num *
- sizeof( ib_port_attr_t ) );
-
- for( port_num = 0; port_num < p_ca_info->p_attr->num_ports; port_num++ )
- {
-
- /* query the port attributes */
- vapi_res =
- VAPI_query_hca_port_prop( hca_hndl, port_num + 1, &hca_port );
- if( vapi_res != VAPI_OK )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__osm_ca_info_init: ERR 7107: "
- "Fail to get HCA Port Attributes (%d).\n", vapi_res );
- goto Exit;
- }
-
- /* first call to know the size of the gid table */
- vapi_res =
- VAPI_query_hca_gid_tbl( hca_hndl, port_num + 1, 0, &maxNumGids,
- NULL );
- p_port_gid =
- ( IB_gid_t * ) malloc( maxNumGids * sizeof( IB_gid_t ) );
-
- vapi_res =
- VAPI_query_hca_gid_tbl( hca_hndl, port_num + 1, maxNumGids,
- &maxNumGids, p_port_gid );
- if( vapi_res != VAPI_OK )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__osm_ca_info_init: ERR 7108: "
- "Fail to get HCA Port GID (%d).\n", vapi_res );
- goto Exit;
- }
-
- __osm_vendor_gid_to_guid( p_port_gid[0],
- ( IB_gid_t * ) & p_ca_info->p_attr->
- p_port_attr[port_num].port_guid );
- p_ca_info->p_attr->p_port_attr[port_num].lid = hca_port.lid;
- p_ca_info->p_attr->p_port_attr[port_num].link_state = hca_port.state;
- p_ca_info->p_attr->p_port_attr[port_num].sm_lid = hca_port.sm_lid;
-
- free( p_port_gid );
- }
-
- status = IB_SUCCESS;
- Exit:
- OSM_LOG_EXIT( p_vend->p_log );
- return ( status );
+ ib_api_status_t status = IB_ERROR;
+ VAPI_ret_t vapi_res;
+ VAPI_hca_hndl_t hca_hndl;
+ VAPI_hca_vendor_t hca_vendor;
+ VAPI_hca_cap_t hca_cap;
+ VAPI_hca_port_t hca_port;
+ uint8_t port_num;
+ IB_gid_t *p_port_gid;
+ uint16_t maxNumGids;
+
+ OSM_LOG_ENTER(p_vend->p_log, __osm_ca_info_init);
+
+ /* get the HCA handle */
+ vapi_res = EVAPI_get_hca_hndl(ca_id, &hca_hndl);
+ if (vapi_res != VAPI_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_ca_info_init: ERR 7105: "
+ "Fail to get HCA handle (%u).\n", vapi_res);
+ goto Exit;
+ }
+
+ if (osm_log_is_active(p_vend->p_log, OSM_LOG_DEBUG)) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__osm_ca_info_init: " "Querying CA %s.\n", ca_id);
+ }
+
+ /* query and get the HCA capability */
+ vapi_res = VAPI_query_hca_cap(hca_hndl, &hca_vendor, &hca_cap);
+ if (vapi_res != VAPI_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_ca_info_init: ERR 7106: "
+ "Fail to get HCA Capabilities (%u).\n", vapi_res);
+ goto Exit;
+ }
+
+ /* get the guid of the HCA */
+ memcpy(&(p_ca_info->guid), hca_cap.node_guid, 8 * sizeof(u_int8_t));
+ p_ca_info->attr_size = 1;
+ p_ca_info->p_attr = (ib_ca_attr_t *) malloc(sizeof(ib_ca_attr_t));
+ memcpy(&(p_ca_info->p_attr->ca_guid), hca_cap.node_guid,
+ 8 * sizeof(u_int8_t));
+
+ /* now obtain the attributes of the ports */
+ p_ca_info->p_attr->num_ports = hca_cap.phys_port_num;
+ p_ca_info->p_attr->p_port_attr =
+ (ib_port_attr_t *) malloc(hca_cap.phys_port_num *
+ sizeof(ib_port_attr_t));
+
+ for (port_num = 0; port_num < p_ca_info->p_attr->num_ports; port_num++) {
+
+ /* query the port attributes */
+ vapi_res =
+ VAPI_query_hca_port_prop(hca_hndl, port_num + 1, &hca_port);
+ if (vapi_res != VAPI_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_ca_info_init: ERR 7107: "
+ "Fail to get HCA Port Attributes (%d).\n",
+ vapi_res);
+ goto Exit;
+ }
+
+ /* first call to know the size of the gid table */
+ vapi_res =
+ VAPI_query_hca_gid_tbl(hca_hndl, port_num + 1, 0,
+ &maxNumGids, NULL);
+ p_port_gid = (IB_gid_t *) malloc(maxNumGids * sizeof(IB_gid_t));
+
+ vapi_res =
+ VAPI_query_hca_gid_tbl(hca_hndl, port_num + 1, maxNumGids,
+ &maxNumGids, p_port_gid);
+ if (vapi_res != VAPI_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_ca_info_init: ERR 7108: "
+ "Fail to get HCA Port GID (%d).\n", vapi_res);
+ goto Exit;
+ }
+
+ __osm_vendor_gid_to_guid(p_port_gid[0],
+ (IB_gid_t *) & p_ca_info->p_attr->
+ p_port_attr[port_num].port_guid);
+ p_ca_info->p_attr->p_port_attr[port_num].lid = hca_port.lid;
+ p_ca_info->p_attr->p_port_attr[port_num].link_state =
+ hca_port.state;
+ p_ca_info->p_attr->p_port_attr[port_num].sm_lid =
+ hca_port.sm_lid;
+
+ free(p_port_gid);
+ }
+
+ status = IB_SUCCESS;
+ Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
}
/**********************************************************************
**********************************************************************/
void
-osm_ca_info_destroy( IN osm_vendor_t * const p_vend,
- IN osm_ca_info_t * const p_ca_info )
+osm_ca_info_destroy(IN osm_vendor_t * const p_vend,
+ IN osm_ca_info_t * const p_ca_info)
{
- OSM_LOG_ENTER( p_vend->p_log, osm_ca_info_destroy );
+ OSM_LOG_ENTER(p_vend->p_log, osm_ca_info_destroy);
- if( p_ca_info->p_attr )
- {
- if( p_ca_info->p_attr->num_ports )
- {
- free( p_ca_info->p_attr->p_port_attr );
- }
- free( p_ca_info->p_attr );
- }
+ if (p_ca_info->p_attr) {
+ if (p_ca_info->p_attr->num_ports) {
+ free(p_ca_info->p_attr->p_port_attr);
+ }
+ free(p_ca_info->p_attr);
+ }
- free( p_ca_info );
+ free(p_ca_info);
- OSM_LOG_EXIT( p_vend->p_log );
+ OSM_LOG_EXIT(p_vend->p_log);
}
/**********************************************************************
@@ -325,118 +309,107 @@ osm_ca_info_destroy( IN osm_vendor_t * const p_vend,
* UPDATE THE VENDOR OBJECT LIST OF CA_INFO STRUCTS
**********************************************************************/
ib_api_status_t
-osm_vendor_get_all_port_attr( IN osm_vendor_t * const p_vend,
- IN ib_port_attr_t * const p_attr_array,
- IN uint32_t * const p_num_ports )
+osm_vendor_get_all_port_attr(IN osm_vendor_t * const p_vend,
+ IN ib_port_attr_t * const p_attr_array,
+ IN uint32_t * const p_num_ports)
{
- ib_api_status_t status;
-
- uint32_t ca;
- uint32_t ca_count;
- uint32_t port_count = 0;
- uint8_t port_num;
- uint32_t total_ports = 0;
- VAPI_hca_id_t *p_ca_ids = NULL;
- osm_ca_info_t *p_ca_info;
-
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_get_all_port_attr );
-
- CL_ASSERT( p_vend );
-
- /*
- * 1) Determine the number of CA's
- * 2) Allocate an array big enough to hold the ca info objects.
- * 3) Call again to retrieve the guids.
- */
- status = __osm_vendor_get_ca_ids( p_vend, &p_ca_ids, &ca_count );
- if( status != IB_SUCCESS )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_all_port_attr: ERR 7109: "
- "Fail to get CA Ids.\n" );
- goto Exit;
- }
-
- /* we keep track of all the CAs in this info array */
- p_vend->p_ca_info = malloc( ca_count * sizeof( *p_vend->p_ca_info ) );
- if( p_vend->p_ca_info == NULL )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_all_port_attr: ERR 7110: "
- "Unable to allocate CA information array.\n" );
- goto Exit;
- }
-
- memset( p_vend->p_ca_info, 0, ca_count * sizeof( *p_vend->p_ca_info ) );
- p_vend->ca_count = ca_count;
-
- /*
- * For each CA, retrieve the CA info attributes
- */
- for( ca = 0; ca < ca_count; ca++ )
- {
- p_ca_info = &p_vend->p_ca_info[ca];
-
- status = __osm_ca_info_init( p_vend, p_ca_ids[ca], p_ca_info );
-
- if( status != IB_SUCCESS )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_all_port_attr: ERR 7111: "
- "Unable to initialize CA Info object (%s).\n",
- ib_get_err_str( status ) );
- }
-
- total_ports += osm_ca_info_get_num_ports( p_ca_info );
-
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_get_all_port_attr: "
- "osm_vendor_get_all_port_attr: %u got %u ports total:%u\n",
- ca, osm_ca_info_get_num_ports( p_ca_info ),
- total_ports
- );
-
- }
-
- /*
- * If the user supplied enough storage, return the port guids,
- * otherwise, return the appropriate error.
- */
- if( *p_num_ports >= total_ports )
- {
- for( ca = 0; ca < ca_count; ca++ )
- {
- uint32_t num_ports;
-
- p_ca_info = &p_vend->p_ca_info[ca];
-
- num_ports = osm_ca_info_get_num_ports( p_ca_info );
-
- for( port_num = 0; port_num < num_ports; port_num++ )
- {
- p_attr_array[port_count] =
- *__osm_ca_info_get_port_attr_ptr( p_ca_info, port_num );
- port_count++;
- }
- }
- }
- else
- {
- status = IB_INSUFFICIENT_MEMORY;
- goto Exit;
- }
-
-
- status = IB_SUCCESS;
-
- Exit:
- *p_num_ports = total_ports;
-
- if( p_ca_ids )
- free( p_ca_ids );
-
- OSM_LOG_EXIT( p_vend->p_log );
- return ( status );
+ ib_api_status_t status;
+
+ uint32_t ca;
+ uint32_t ca_count;
+ uint32_t port_count = 0;
+ uint8_t port_num;
+ uint32_t total_ports = 0;
+ VAPI_hca_id_t *p_ca_ids = NULL;
+ osm_ca_info_t *p_ca_info;
+
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_get_all_port_attr);
+
+ CL_ASSERT(p_vend);
+
+ /*
+ * 1) Determine the number of CA's
+ * 2) Allocate an array big enough to hold the ca info objects.
+ * 3) Call again to retrieve the guids.
+ */
+ status = __osm_vendor_get_ca_ids(p_vend, &p_ca_ids, &ca_count);
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_all_port_attr: ERR 7109: "
+ "Fail to get CA Ids.\n");
+ goto Exit;
+ }
+
+ /* we keep track of all the CAs in this info array */
+ p_vend->p_ca_info = malloc(ca_count * sizeof(*p_vend->p_ca_info));
+ if (p_vend->p_ca_info == NULL) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_all_port_attr: ERR 7110: "
+ "Unable to allocate CA information array.\n");
+ goto Exit;
+ }
+
+ memset(p_vend->p_ca_info, 0, ca_count * sizeof(*p_vend->p_ca_info));
+ p_vend->ca_count = ca_count;
+
+ /*
+ * For each CA, retrieve the CA info attributes
+ */
+ for (ca = 0; ca < ca_count; ca++) {
+ p_ca_info = &p_vend->p_ca_info[ca];
+
+ status = __osm_ca_info_init(p_vend, p_ca_ids[ca], p_ca_info);
+
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_all_port_attr: ERR 7111: "
+ "Unable to initialize CA Info object (%s).\n",
+ ib_get_err_str(status));
+ }
+
+ total_ports += osm_ca_info_get_num_ports(p_ca_info);
+
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_get_all_port_attr: "
+ "osm_vendor_get_all_port_attr: %u got %u ports total:%u\n",
+ ca, osm_ca_info_get_num_ports(p_ca_info), total_ports);
+
+ }
+
+ /*
+ * If the user supplied enough storage, return the port guids,
+ * otherwise, return the appropriate error.
+ */
+ if (*p_num_ports >= total_ports) {
+ for (ca = 0; ca < ca_count; ca++) {
+ uint32_t num_ports;
+
+ p_ca_info = &p_vend->p_ca_info[ca];
+
+ num_ports = osm_ca_info_get_num_ports(p_ca_info);
+
+ for (port_num = 0; port_num < num_ports; port_num++) {
+ p_attr_array[port_count] =
+ *__osm_ca_info_get_port_attr_ptr(p_ca_info,
+ port_num);
+ port_count++;
+ }
+ }
+ } else {
+ status = IB_INSUFFICIENT_MEMORY;
+ goto Exit;
+ }
+
+ status = IB_SUCCESS;
+
+ Exit:
+ *p_num_ports = total_ports;
+
+ if (p_ca_ids)
+ free(p_ca_ids);
+
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
}
/**********************************************************************
@@ -445,128 +418,124 @@ osm_vendor_get_all_port_attr( IN osm_vendor_t * const p_vend,
**********************************************************************/
ib_api_status_t
-osm_vendor_get_guid_ca_and_port( IN osm_vendor_t * const p_vend,
- IN ib_net64_t const guid,
- OUT VAPI_hca_hndl_t * p_hca_hndl,
- OUT VAPI_hca_id_t * p_hca_id,
- OUT uint32_t * p_port_num )
+osm_vendor_get_guid_ca_and_port(IN osm_vendor_t * const p_vend,
+ IN ib_net64_t const guid,
+ OUT VAPI_hca_hndl_t * p_hca_hndl,
+ OUT VAPI_hca_id_t * p_hca_id,
+ OUT uint32_t * p_port_num)
{
- ib_api_status_t status;
- VAPI_hca_id_t *p_ca_ids = NULL;
- VAPI_ret_t vapi_res;
- VAPI_hca_hndl_t hca_hndl;
- VAPI_hca_vendor_t hca_vendor;
- VAPI_hca_cap_t hca_cap;
- IB_gid_t *p_port_gid = NULL;
- uint16_t maxNumGids;
- ib_net64_t port_guid;
- uint32_t ca, portIdx, ca_count;
-
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_get_guid_ca_and_port );
-
- CL_ASSERT( p_vend );
-
- /*
- * 1) Determine the number of CA's
- * 2) Allocate an array big enough to hold the ca info objects.
- * 3) Call again to retrieve the guids.
- */
- status = __osm_vendor_get_ca_ids( p_vend, &p_ca_ids, &ca_count );
- if( status != IB_SUCCESS )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_guid_ca_and_port: ERR 7112: "
- "Fail to get CA Ids.\n" );
- goto Exit;
- }
-
- /*
- * For each CA, retrieve the CA info attributes
- */
- for( ca = 0; ca < ca_count; ca++ )
- {
- /* get the HCA handle */
- vapi_res = EVAPI_get_hca_hndl( p_ca_ids[ca], &hca_hndl );
- if( vapi_res != VAPI_OK )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_guid_ca_and_port: ERR 7113: "
- "Fail to get HCA handle (%u).\n", vapi_res );
- goto Exit;
- }
-
- /* get the CA attributes - to know how many ports it has: */
- if( osm_log_is_active( p_vend->p_log, OSM_LOG_DEBUG) )
- {
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_get_guid_ca_and_port: "
- "Querying CA %s.\n", p_ca_ids[ca] );
- }
-
- /* query and get the HCA capability */
- vapi_res = VAPI_query_hca_cap( hca_hndl, &hca_vendor, &hca_cap );
- if( vapi_res != VAPI_OK )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_guid_ca_and_port: ERR 7114: "
- "Fail to get HCA Capabilities (%u).\n", vapi_res );
- goto Exit;
- }
-
- /* go over all ports - to obtail their guids */
- for( portIdx = 0; portIdx < hca_cap.phys_port_num; portIdx++ )
- {
- vapi_res =
- VAPI_query_hca_gid_tbl( hca_hndl, portIdx + 1, 0, &maxNumGids,
- NULL );
- p_port_gid =
- ( IB_gid_t * ) malloc( maxNumGids * sizeof( IB_gid_t ) );
-
- /* get the port guid */
- vapi_res =
- VAPI_query_hca_gid_tbl( hca_hndl, portIdx + 1, maxNumGids,
- &maxNumGids, p_port_gid );
- if( vapi_res != VAPI_OK )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_guid_ca_and_port: ERR 7115: "
- "Fail to get HCA Port GID (%d).\n", vapi_res );
- goto Exit;
- }
-
- /* convert to SF style */
- __osm_vendor_gid_to_guid( p_port_gid[0],
- ( VAPI_gid_t * ) & port_guid );
-
- /* finally did we find it ? */
- if( port_guid == guid )
- {
- *p_hca_hndl = hca_hndl;
- memcpy( p_hca_id, p_ca_ids[ca], sizeof ( VAPI_hca_id_t ) );
- *p_port_num = portIdx + 1;
- status = IB_SUCCESS;
- goto Exit;
- }
-
- free( p_port_gid );
- p_port_gid = NULL;
- } /* ALL PORTS */
- } /* all HCAs */
-
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get_guid_ca_and_port: ERR 7116: "
- "Fail to find HCA and Port for Port Guid 0x%" PRIx64 "\n",
- cl_ntoh64(guid) );
- status = IB_INVALID_GUID;
-
- Exit:
- if( p_ca_ids != NULL )
- free( p_ca_ids );
- if( p_port_gid != NULL )
- free( p_port_gid );
- OSM_LOG_EXIT( p_vend->p_log );
- return ( status );
+ ib_api_status_t status;
+ VAPI_hca_id_t *p_ca_ids = NULL;
+ VAPI_ret_t vapi_res;
+ VAPI_hca_hndl_t hca_hndl;
+ VAPI_hca_vendor_t hca_vendor;
+ VAPI_hca_cap_t hca_cap;
+ IB_gid_t *p_port_gid = NULL;
+ uint16_t maxNumGids;
+ ib_net64_t port_guid;
+ uint32_t ca, portIdx, ca_count;
+
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_get_guid_ca_and_port);
+
+ CL_ASSERT(p_vend);
+
+ /*
+ * 1) Determine the number of CA's
+ * 2) Allocate an array big enough to hold the ca info objects.
+ * 3) Call again to retrieve the guids.
+ */
+ status = __osm_vendor_get_ca_ids(p_vend, &p_ca_ids, &ca_count);
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_guid_ca_and_port: ERR 7112: "
+ "Fail to get CA Ids.\n");
+ goto Exit;
+ }
+
+ /*
+ * For each CA, retrieve the CA info attributes
+ */
+ for (ca = 0; ca < ca_count; ca++) {
+ /* get the HCA handle */
+ vapi_res = EVAPI_get_hca_hndl(p_ca_ids[ca], &hca_hndl);
+ if (vapi_res != VAPI_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_guid_ca_and_port: ERR 7113: "
+ "Fail to get HCA handle (%u).\n", vapi_res);
+ goto Exit;
+ }
+
+ /* get the CA attributes - to know how many ports it has: */
+ if (osm_log_is_active(p_vend->p_log, OSM_LOG_DEBUG)) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_get_guid_ca_and_port: "
+ "Querying CA %s.\n", p_ca_ids[ca]);
+ }
+
+ /* query and get the HCA capability */
+ vapi_res = VAPI_query_hca_cap(hca_hndl, &hca_vendor, &hca_cap);
+ if (vapi_res != VAPI_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_guid_ca_and_port: ERR 7114: "
+ "Fail to get HCA Capabilities (%u).\n",
+ vapi_res);
+ goto Exit;
+ }
+
+ /* go over all ports - to obtail their guids */
+ for (portIdx = 0; portIdx < hca_cap.phys_port_num; portIdx++) {
+ vapi_res =
+ VAPI_query_hca_gid_tbl(hca_hndl, portIdx + 1, 0,
+ &maxNumGids, NULL);
+ p_port_gid =
+ (IB_gid_t *) malloc(maxNumGids * sizeof(IB_gid_t));
+
+ /* get the port guid */
+ vapi_res =
+ VAPI_query_hca_gid_tbl(hca_hndl, portIdx + 1,
+ maxNumGids, &maxNumGids,
+ p_port_gid);
+ if (vapi_res != VAPI_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_guid_ca_and_port: ERR 7115: "
+ "Fail to get HCA Port GID (%d).\n",
+ vapi_res);
+ goto Exit;
+ }
+
+ /* convert to SF style */
+ __osm_vendor_gid_to_guid(p_port_gid[0],
+ (VAPI_gid_t *) & port_guid);
+
+ /* finally did we find it ? */
+ if (port_guid == guid) {
+ *p_hca_hndl = hca_hndl;
+ memcpy(p_hca_id, p_ca_ids[ca],
+ sizeof(VAPI_hca_id_t));
+ *p_port_num = portIdx + 1;
+ status = IB_SUCCESS;
+ goto Exit;
+ }
+
+ free(p_port_gid);
+ p_port_gid = NULL;
+ } /* ALL PORTS */
+ } /* all HCAs */
+
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get_guid_ca_and_port: ERR 7116: "
+ "Fail to find HCA and Port for Port Guid 0x%" PRIx64 "\n",
+ cl_ntoh64(guid));
+ status = IB_INVALID_GUID;
+
+ Exit:
+ if (p_ca_ids != NULL)
+ free(p_ca_ids);
+ if (p_port_gid != NULL)
+ free(p_port_gid);
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
}
#ifdef __TEST_HCA_GUID__
@@ -577,96 +546,88 @@ osm_vendor_get_guid_ca_and_port( IN osm_vendor_t * const p_vend,
/**********************************************************************
**********************************************************************/
-ib_net64_t
-get_port_guid( )
+ib_net64_t get_port_guid()
{
- uint32_t i;
- uint32_t choice = 0;
- boolean_t done_flag = FALSE;
- ib_api_status_t status;
- uint32_t num_ports = GUID_ARRAY_SIZE;
- ib_port_attr_t attr_array[GUID_ARRAY_SIZE];
- VAPI_hca_id_t ca_id;
- uint32_t portNum;
- osm_vendor_t vend;
- osm_vendor_t *p_vend;
- osm_log_t *p_osm_log, tlog;
-
- p_osm_log = &tlog;
-
- status = osm_log_init( p_osm_log, FALSE );
- if( status != IB_SUCCESS )
- return ( status );
-
- osm_log( p_osm_log, OSM_LOG_FUNCS,
- "get_port_guid: [\n" );
-
- p_vend = &vend;
- p_vend->p_log = p_osm_log;
-
- /*
- * Call the transport layer for a list of local port
- * GUID values.
- */
- status = osm_vendor_get_all_port_attr( p_vend, attr_array, &num_ports );
- if( status != IB_SUCCESS )
- {
- printf( "\nError from osm_opensm_init (%x)\n", status );
- return ( 0 );
- }
-
- if( num_ports == 0 )
- {
- printf( "\nNo local ports detected!\n" );
- return ( 0 );
- }
-
- while( done_flag == FALSE )
- {
- printf( "\nChoose a local port number with which to bind:\n\n" );
- for( i = 0; i < num_ports; i++ )
- {
- /*
- * Print the index + 1 since by convention, port numbers
- * start with 1 on host channel adapters.
- */
-
- printf( "\t%u: GUID = 0x%8" PRIx64 ", lid = 0x%04X, state = %s\n",
- i + 1, cl_ntoh64( attr_array[i].port_guid ),
- cl_ntoh16( attr_array[i].lid ),
- ib_get_port_state_str( attr_array[i].link_state ) );
- }
-
- printf( "\nEnter choice (1-%u): ", i );
- fflush( stdout );
- scanf( "%u", &choice );
- if( choice > num_ports )
- printf( "\nError: Lame choice!\n" );
- else
- done_flag = TRUE;
- }
-
- status =
- osm_vendor_get_guid_ca_and_port( p_vend,
- attr_array[choice - 1].port_guid,
- &ca_id, &portNum );
- if( status != IB_SUCCESS )
- {
- printf( "Error obtaining back the HCA and Port\n" );
- return ( 0 );
- }
-
- printf( "Selected: CA:%s Port:%d\n", ca_id, portNum );
-
- return ( attr_array[choice - 1].port_guid );
+ uint32_t i;
+ uint32_t choice = 0;
+ boolean_t done_flag = FALSE;
+ ib_api_status_t status;
+ uint32_t num_ports = GUID_ARRAY_SIZE;
+ ib_port_attr_t attr_array[GUID_ARRAY_SIZE];
+ VAPI_hca_id_t ca_id;
+ uint32_t portNum;
+ osm_vendor_t vend;
+ osm_vendor_t *p_vend;
+ osm_log_t *p_osm_log, tlog;
+
+ p_osm_log = &tlog;
+
+ status = osm_log_init(p_osm_log, FALSE);
+ if (status != IB_SUCCESS)
+ return (status);
+
+ osm_log(p_osm_log, OSM_LOG_FUNCS, "get_port_guid: [\n");
+
+ p_vend = &vend;
+ p_vend->p_log = p_osm_log;
+
+ /*
+ * Call the transport layer for a list of local port
+ * GUID values.
+ */
+ status = osm_vendor_get_all_port_attr(p_vend, attr_array, &num_ports);
+ if (status != IB_SUCCESS) {
+ printf("\nError from osm_opensm_init (%x)\n", status);
+ return (0);
+ }
+
+ if (num_ports == 0) {
+ printf("\nNo local ports detected!\n");
+ return (0);
+ }
+
+ while (done_flag == FALSE) {
+ printf("\nChoose a local port number with which to bind:\n\n");
+ for (i = 0; i < num_ports; i++) {
+ /*
+ * Print the index + 1 since by convention, port numbers
+ * start with 1 on host channel adapters.
+ */
+
+ printf("\t%u: GUID = 0x%8" PRIx64
+ ", lid = 0x%04X, state = %s\n", i + 1,
+ cl_ntoh64(attr_array[i].port_guid),
+ cl_ntoh16(attr_array[i].lid),
+ ib_get_port_state_str(attr_array[i].link_state));
+ }
+
+ printf("\nEnter choice (1-%u): ", i);
+ fflush(stdout);
+ scanf("%u", &choice);
+ if (choice > num_ports)
+ printf("\nError: Lame choice!\n");
+ else
+ done_flag = TRUE;
+ }
+
+ status =
+ osm_vendor_get_guid_ca_and_port(p_vend,
+ attr_array[choice - 1].port_guid,
+ &ca_id, &portNum);
+ if (status != IB_SUCCESS) {
+ printf("Error obtaining back the HCA and Port\n");
+ return (0);
+ }
+
+ printf("Selected: CA:%s Port:%d\n", ca_id, portNum);
+
+ return (attr_array[choice - 1].port_guid);
}
-int
-main( int argc,
- char **argv )
+int main(int argc, char **argv)
{
- get_port_guid( );
- return ( 0 );
+ get_port_guid();
+ return (0);
}
#endif
diff --git a/opensm/libvendor/osm_vendor_mtl_transaction_mgr.c b/opensm/libvendor/osm_vendor_mtl_transaction_mgr.c
index 8f2eb3a..05a5fab 100644
--- a/opensm/libvendor/osm_vendor_mtl_transaction_mgr.c
+++ b/opensm/libvendor/osm_vendor_mtl_transaction_mgr.c
@@ -33,10 +33,9 @@
*
*/
-
#if HAVE_CONFIG_H
# include <config.h>
-#endif /* HAVE_CONFIG_H */
+#endif /* HAVE_CONFIG_H */
#include <math.h>
#include <stdlib.h>
@@ -54,213 +53,215 @@
#endif
/* this is the callback function of the timer */
-void
-__osm_transaction_mgr_callback( IN void* context )
+void __osm_transaction_mgr_callback(IN void *context)
{
- osm_transaction_mgr_t *trans_mgr_p;
- osm_vendor_t* p_vend = (osm_vendor_t*)context;
- cl_list_item_t *p_list_item;
- cl_list_item_t *p_list_next_item;
- osm_madw_req_t *osm_madw_req_p;
- uint64_t current_time; /* [usec] */
- uint32_t new_timeout; /* [msec] */
- cl_status_t cl_status;
- ib_mad_t *p_mad;
+ osm_transaction_mgr_t *trans_mgr_p;
+ osm_vendor_t *p_vend = (osm_vendor_t *) context;
+ cl_list_item_t *p_list_item;
+ cl_list_item_t *p_list_next_item;
+ osm_madw_req_t *osm_madw_req_p;
+ uint64_t current_time; /* [usec] */
+ uint32_t new_timeout; /* [msec] */
+ cl_status_t cl_status;
+ ib_mad_t *p_mad;
#ifdef OSM_VENDOR_INTF_MTL
- osm_mtl_bind_info_t *p_bind;
+ osm_mtl_bind_info_t *p_bind;
#else
- osm_ts_bind_info_t *p_bind;
+ osm_ts_bind_info_t *p_bind;
#endif
- cl_list_t tmp_madw_p_list; /* this list will include all the madw_p that should be removed. */
- cl_list_t retry_madw_p_list; /* this list will include all the madw_p that were retried and need to be removed. */
- osm_madw_t *madw_p;
-
- OSM_LOG_ENTER( p_vend->p_log, __osm_transaction_mgr_callback );
-
- trans_mgr_p = (osm_transaction_mgr_t*)p_vend->p_transaction_mgr;
-
- /* initialize the tmp_madw_p_list */
- cl_list_construct(&tmp_madw_p_list);
- cl_status = cl_list_init(&tmp_madw_p_list, 50);
- if (cl_status != CL_SUCCESS)
- {
- osm_log (p_vend->p_log, OSM_LOG_ERROR,
- "__osm_transaction_mgr_callback : ERROR 1000: "
- "Failed to create tmp_madw_p_list\n" );
- }
-
- cl_list_construct(&retry_madw_p_list);
- cl_status = cl_list_init(&retry_madw_p_list, 50);
- if (cl_status != CL_SUCCESS)
- {
- osm_log (p_vend->p_log, OSM_LOG_ERROR,
- "__osm_transaction_mgr_callback : ERROR 1000: "
- "Failed to create retry_madw_p_list\n" );
- }
-
- current_time = cl_get_time_stamp();
- cl_spinlock_acquire( &(trans_mgr_p->transaction_mgr_lock) );
- p_list_item = cl_qlist_head(trans_mgr_p->madw_reqs_list_p);
- if (p_list_item == cl_qlist_end(trans_mgr_p->madw_reqs_list_p))
- {
- /* the list is empty - nothing to do */
- cl_spinlock_release( &trans_mgr_p->transaction_mgr_lock );
- osm_log (p_vend->p_log, OSM_LOG_DEBUG,
- "__osm_transaction_mgr_callback : Nothing to do\n");
- goto Exit;
- }
-
- /* non empty list: */
-
- /* get the osm_madw_req_p */
- osm_madw_req_p = PARENT_STRUCT(p_list_item, osm_madw_req_t, list_item);
-
- while (osm_madw_req_p->waking_time <= current_time)
- {
- /* this object was supposed to have gotten a response */
- /* we need to decide if we need to retry or done with it. */
- if (osm_madw_req_p->retry_cnt > 0)
- {
- /* add to the list of the retrys : */
- cl_list_insert_tail(&retry_madw_p_list, osm_madw_req_p);
-
- /* update wakeup time and retry count */
- osm_madw_req_p->waking_time = p_vend->timeout*1000 + cl_get_time_stamp();
- osm_madw_req_p->retry_cnt--;
-
- /* make sure we will get some timer call if not earlier */
- osm_log (p_vend->p_log, OSM_LOG_DEBUG,
- "__osm_transaction_mgr_callback : Timer restart:%u\n", p_vend->timeout);
-
- cl_status = cl_timer_start(&trans_mgr_p->madw_list_timer, p_vend->timeout);
-
- /* go to the next object and check if it also needs to be removed - didn't receive response */
- /* we need to do it before we move current item to the end of the list */
- p_list_next_item = cl_qlist_next(p_list_item);
-
- /* remove from the head */
- cl_qlist_remove_item( trans_mgr_p->madw_reqs_list_p, &(osm_madw_req_p->list_item) );
-
- /* insert the object to the qlist and the qmap */
- cl_qlist_insert_tail( trans_mgr_p->madw_reqs_list_p, &(osm_madw_req_p->list_item));
-
- }
- else
- {
- /* go to the next object and check if it also needs to be removed - didn't receive response */
- p_list_next_item = cl_qlist_next(p_list_item);
-
- /* remove from the head */
- cl_qlist_remove_item( trans_mgr_p->madw_reqs_list_p, &(osm_madw_req_p->list_item) );
-
- /* add it to the tmp_madw_p_list to be removed */
- cl_list_insert_tail(&tmp_madw_p_list, osm_madw_req_p->p_madw);
- osm_log (p_vend->p_log, OSM_LOG_DEBUG,
- "__osm_transaction_mgr_callback : Found failed transaction madw: %p\n",
- osm_madw_req_p->p_madw
- );
- }
-
- /* Advance */
- p_list_item = p_list_next_item;
- if (p_list_item == cl_qlist_end(trans_mgr_p->madw_reqs_list_p))
- {
- /* the list is empty - nothing to do */
- break;
- }
-
- /* get the osm_madw_req_p */
- osm_madw_req_p = PARENT_STRUCT(p_list_item, osm_madw_req_t, list_item);
- }
-
- /* look at the current p_list_item. If it is not the end item - then we need to */
- /* re-start the timer */
- if (p_list_item != cl_qlist_end(trans_mgr_p->madw_reqs_list_p))
- {
- /* get the osm_madw_req_p */
- osm_madw_req_p = PARENT_STRUCT(p_list_item, osm_madw_req_t, list_item);
-
- /* we have the object that still didn't get response - re-start the timer */
- /* start the timer to the timeout (in miliseconds) */
- new_timeout = (osm_madw_req_p->waking_time - cl_get_time_stamp())/1000 + 1;
- cl_status = cl_timer_start(&trans_mgr_p->madw_list_timer, new_timeout);
- osm_log (p_vend->p_log, OSM_LOG_DEBUG,
- "__osm_transaction_mgr_callback : Timer restart:%u\n", new_timeout);
-
- if (cl_status != CL_SUCCESS)
- {
- osm_log (p_vend->p_log, OSM_LOG_ERROR,
- "__osm_transaction_mgr_callback : ERROR 1000: "
- "Failed to start timer\n" );
- }
- }
- /* if not empty - retry on retry list: */
- if (!cl_is_list_empty(&retry_madw_p_list))
- {
-
- /* remove all elements that were retried: */
- osm_madw_req_p = (osm_madw_req_t *)(cl_list_remove_head(&retry_madw_p_list));
- while (osm_madw_req_p != NULL)
- {
-
- /* resend: */
- osm_log (p_vend->p_log, OSM_LOG_DEBUG,
- "__osm_transaction_mgr_callback : "
- "Retry %d of madw %p\n",
- OSM_DEFAULT_RETRY_COUNT - osm_madw_req_p->retry_cnt,
- osm_madw_req_p->p_madw
- );
-
- /* actually send it */
+ cl_list_t tmp_madw_p_list; /* this list will include all the madw_p that should be removed. */
+ cl_list_t retry_madw_p_list; /* this list will include all the madw_p that were retried and need to be removed. */
+ osm_madw_t *madw_p;
+
+ OSM_LOG_ENTER(p_vend->p_log, __osm_transaction_mgr_callback);
+
+ trans_mgr_p = (osm_transaction_mgr_t *) p_vend->p_transaction_mgr;
+
+ /* initialize the tmp_madw_p_list */
+ cl_list_construct(&tmp_madw_p_list);
+ cl_status = cl_list_init(&tmp_madw_p_list, 50);
+ if (cl_status != CL_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_transaction_mgr_callback : ERROR 1000: "
+ "Failed to create tmp_madw_p_list\n");
+ }
+
+ cl_list_construct(&retry_madw_p_list);
+ cl_status = cl_list_init(&retry_madw_p_list, 50);
+ if (cl_status != CL_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_transaction_mgr_callback : ERROR 1000: "
+ "Failed to create retry_madw_p_list\n");
+ }
+
+ current_time = cl_get_time_stamp();
+ cl_spinlock_acquire(&(trans_mgr_p->transaction_mgr_lock));
+ p_list_item = cl_qlist_head(trans_mgr_p->madw_reqs_list_p);
+ if (p_list_item == cl_qlist_end(trans_mgr_p->madw_reqs_list_p)) {
+ /* the list is empty - nothing to do */
+ cl_spinlock_release(&trans_mgr_p->transaction_mgr_lock);
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__osm_transaction_mgr_callback : Nothing to do\n");
+ goto Exit;
+ }
+
+ /* non empty list: */
+
+ /* get the osm_madw_req_p */
+ osm_madw_req_p = PARENT_STRUCT(p_list_item, osm_madw_req_t, list_item);
+
+ while (osm_madw_req_p->waking_time <= current_time) {
+ /* this object was supposed to have gotten a response */
+ /* we need to decide if we need to retry or done with it. */
+ if (osm_madw_req_p->retry_cnt > 0) {
+ /* add to the list of the retrys : */
+ cl_list_insert_tail(&retry_madw_p_list, osm_madw_req_p);
+
+ /* update wakeup time and retry count */
+ osm_madw_req_p->waking_time =
+ p_vend->timeout * 1000 + cl_get_time_stamp();
+ osm_madw_req_p->retry_cnt--;
+
+ /* make sure we will get some timer call if not earlier */
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__osm_transaction_mgr_callback : Timer restart:%u\n",
+ p_vend->timeout);
+
+ cl_status =
+ cl_timer_start(&trans_mgr_p->madw_list_timer,
+ p_vend->timeout);
+
+ /* go to the next object and check if it also needs to be removed - didn't receive response */
+ /* we need to do it before we move current item to the end of the list */
+ p_list_next_item = cl_qlist_next(p_list_item);
+
+ /* remove from the head */
+ cl_qlist_remove_item(trans_mgr_p->madw_reqs_list_p,
+ &(osm_madw_req_p->list_item));
+
+ /* insert the object to the qlist and the qmap */
+ cl_qlist_insert_tail(trans_mgr_p->madw_reqs_list_p,
+ &(osm_madw_req_p->list_item));
+
+ } else {
+ /* go to the next object and check if it also needs to be removed - didn't receive response */
+ p_list_next_item = cl_qlist_next(p_list_item);
+
+ /* remove from the head */
+ cl_qlist_remove_item(trans_mgr_p->madw_reqs_list_p,
+ &(osm_madw_req_p->list_item));
+
+ /* add it to the tmp_madw_p_list to be removed */
+ cl_list_insert_tail(&tmp_madw_p_list,
+ osm_madw_req_p->p_madw);
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__osm_transaction_mgr_callback : Found failed transaction madw: %p\n",
+ osm_madw_req_p->p_madw);
+ }
+
+ /* Advance */
+ p_list_item = p_list_next_item;
+ if (p_list_item == cl_qlist_end(trans_mgr_p->madw_reqs_list_p)) {
+ /* the list is empty - nothing to do */
+ break;
+ }
+
+ /* get the osm_madw_req_p */
+ osm_madw_req_p =
+ PARENT_STRUCT(p_list_item, osm_madw_req_t, list_item);
+ }
+
+ /* look at the current p_list_item. If it is not the end item - then we need to */
+ /* re-start the timer */
+ if (p_list_item != cl_qlist_end(trans_mgr_p->madw_reqs_list_p)) {
+ /* get the osm_madw_req_p */
+ osm_madw_req_p =
+ PARENT_STRUCT(p_list_item, osm_madw_req_t, list_item);
+
+ /* we have the object that still didn't get response - re-start the timer */
+ /* start the timer to the timeout (in miliseconds) */
+ new_timeout =
+ (osm_madw_req_p->waking_time - cl_get_time_stamp()) / 1000 +
+ 1;
+ cl_status =
+ cl_timer_start(&trans_mgr_p->madw_list_timer, new_timeout);
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__osm_transaction_mgr_callback : Timer restart:%u\n",
+ new_timeout);
+
+ if (cl_status != CL_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_transaction_mgr_callback : ERROR 1000: "
+ "Failed to start timer\n");
+ }
+ }
+ /* if not empty - retry on retry list: */
+ if (!cl_is_list_empty(&retry_madw_p_list)) {
+
+ /* remove all elements that were retried: */
+ osm_madw_req_p =
+ (osm_madw_req_t
+ *) (cl_list_remove_head(&retry_madw_p_list));
+ while (osm_madw_req_p != NULL) {
+
+ /* resend: */
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "__osm_transaction_mgr_callback : "
+ "Retry %d of madw %p\n",
+ OSM_DEFAULT_RETRY_COUNT -
+ osm_madw_req_p->retry_cnt,
+ osm_madw_req_p->p_madw);
+
+ /* actually send it */
#ifdef OSM_VENDOR_INTF_MTL
- osm_mtl_send_mad(
- (osm_mtl_bind_info_t *)osm_madw_req_p->p_bind,
- osm_madw_req_p->p_madw);
+ osm_mtl_send_mad((osm_mtl_bind_info_t *)
+ osm_madw_req_p->p_bind,
+ osm_madw_req_p->p_madw);
#else
- ib_api_status_t
- osm_ts_send_mad(osm_ts_bind_info_t *p_bind,osm_madw_t * const p_madw);
- osm_ts_send_mad(
- (osm_ts_bind_info_t *)osm_madw_req_p->p_bind,
- osm_madw_req_p->p_madw
- );
+ ib_api_status_t
+ osm_ts_send_mad(osm_ts_bind_info_t * p_bind,
+ osm_madw_t * const p_madw);
+ osm_ts_send_mad((osm_ts_bind_info_t *) osm_madw_req_p->
+ p_bind, osm_madw_req_p->p_madw);
#endif
- /* next one */
- osm_madw_req_p = (osm_madw_req_t *)(cl_list_remove_head(&retry_madw_p_list));
- }
- }
-
- /* if the tmp_madw_p_list has elements - need to call the send_err_callback */
- madw_p = (osm_madw_t *)(cl_list_remove_head(&tmp_madw_p_list));
- while (madw_p != NULL)
- {
- /* need to remove it from pool */
-
- /* obtain the madw_p stored as the wrid in the send call */
- p_mad = osm_madw_get_mad_ptr( madw_p );
- p_bind = madw_p->h_bind;
- /*
- Return any wrappers to the pool that may have been
- pre-emptively allocated to handle a receive.
- */
- if( madw_p->vend_wrap.p_resp_madw )
- {
+ /* next one */
+ osm_madw_req_p =
+ (osm_madw_req_t
+ *) (cl_list_remove_head(&retry_madw_p_list));
+ }
+ }
+
+ /* if the tmp_madw_p_list has elements - need to call the send_err_callback */
+ madw_p = (osm_madw_t *) (cl_list_remove_head(&tmp_madw_p_list));
+ while (madw_p != NULL) {
+ /* need to remove it from pool */
+
+ /* obtain the madw_p stored as the wrid in the send call */
+ p_mad = osm_madw_get_mad_ptr(madw_p);
+ p_bind = madw_p->h_bind;
+ /*
+ Return any wrappers to the pool that may have been
+ pre-emptively allocated to handle a receive.
+ */
+ if (madw_p->vend_wrap.p_resp_madw) {
#ifdef OSM_VENDOR_INTF_MTL
- osm_mad_pool_put(
- p_bind->p_osm_pool, madw_p->vend_wrap.p_resp_madw );
+ osm_mad_pool_put(p_bind->p_osm_pool,
+ madw_p->vend_wrap.p_resp_madw);
#else
- osm_mad_pool_put(
- p_bind->p_osm_pool, madw_p->vend_wrap.p_resp_madw );
+ osm_mad_pool_put(p_bind->p_osm_pool,
+ madw_p->vend_wrap.p_resp_madw);
#endif
- madw_p->vend_wrap.p_resp_madw = NULL;
- }
+ madw_p->vend_wrap.p_resp_madw = NULL;
+ }
- /* invoke the CB */
- ( *(osm_vend_mad_send_err_callback_t)(p_bind->send_err_callback) ) ( p_bind->client_context, madw_p );
- madw_p = (osm_madw_t *)(cl_list_remove_head(&tmp_madw_p_list));
- }
+ /* invoke the CB */
+ (*(osm_vend_mad_send_err_callback_t)
+ (p_bind->send_err_callback)) (p_bind->client_context, madw_p);
+ madw_p = (osm_madw_t *) (cl_list_remove_head(&tmp_madw_p_list));
+ }
- Exit:
- OSM_LOG_EXIT( p_vend->p_log );
+ Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
}
@@ -268,274 +269,278 @@ __osm_transaction_mgr_callback( IN void* context )
* Construct and Initialize
*/
-void
-osm_transaction_mgr_init( IN osm_vendor_t * const p_vend )
+void osm_transaction_mgr_init(IN osm_vendor_t * const p_vend)
{
- cl_status_t cl_status;
- osm_transaction_mgr_t *trans_mgr_p;
- OSM_LOG_ENTER( p_vend->p_log, osm_transaction_mgr_init );
-
- CL_ASSERT( p_vend->p_transaction_mgr == NULL );
-
- (osm_transaction_mgr_t*)p_vend->p_transaction_mgr =
- (osm_transaction_mgr_t * ) malloc( sizeof( osm_transaction_mgr_t ) );
-
- trans_mgr_p = (osm_transaction_mgr_t*)p_vend->p_transaction_mgr;
-
- /* construct lock object */
- cl_spinlock_construct( &(trans_mgr_p->transaction_mgr_lock) );
- CL_ASSERT( cl_spinlock_init( &(trans_mgr_p->transaction_mgr_lock) ) == CL_SUCCESS );
-
- /* initialize the qlist */
- trans_mgr_p->madw_reqs_list_p =
- ( cl_qlist_t * ) malloc( sizeof( cl_qlist_t ) );
- cl_qlist_init( trans_mgr_p->madw_reqs_list_p);
-
- /* initialize the qmap */
- trans_mgr_p->madw_by_tid_map_p =
- ( cl_qmap_t * ) malloc( sizeof( cl_qmap_t ) );
- cl_qmap_init( trans_mgr_p->madw_by_tid_map_p );
-
- /* create the timer used by the madw_req_list */
- cl_timer_construct( &(trans_mgr_p->madw_list_timer) );
-
- /* init the timer with timeout. */
- cl_status = cl_timer_init(&trans_mgr_p->madw_list_timer,
- __osm_transaction_mgr_callback,
- p_vend );
-
- if (cl_status != CL_SUCCESS)
- {
- osm_log (p_vend->p_log, OSM_LOG_ERROR,
- "osm_transaction_mgr_init : ERROR 1000: "
- "Failed to initialize madw_reqs_list timer\n" );
- }
- OSM_LOG_EXIT( p_vend->p_log );
+ cl_status_t cl_status;
+ osm_transaction_mgr_t *trans_mgr_p;
+ OSM_LOG_ENTER(p_vend->p_log, osm_transaction_mgr_init);
+
+ CL_ASSERT(p_vend->p_transaction_mgr == NULL);
+
+ (osm_transaction_mgr_t *) p_vend->p_transaction_mgr =
+ (osm_transaction_mgr_t *) malloc(sizeof(osm_transaction_mgr_t));
+
+ trans_mgr_p = (osm_transaction_mgr_t *) p_vend->p_transaction_mgr;
+
+ /* construct lock object */
+ cl_spinlock_construct(&(trans_mgr_p->transaction_mgr_lock));
+ CL_ASSERT(cl_spinlock_init(&(trans_mgr_p->transaction_mgr_lock)) ==
+ CL_SUCCESS);
+
+ /* initialize the qlist */
+ trans_mgr_p->madw_reqs_list_p =
+ (cl_qlist_t *) malloc(sizeof(cl_qlist_t));
+ cl_qlist_init(trans_mgr_p->madw_reqs_list_p);
+
+ /* initialize the qmap */
+ trans_mgr_p->madw_by_tid_map_p =
+ (cl_qmap_t *) malloc(sizeof(cl_qmap_t));
+ cl_qmap_init(trans_mgr_p->madw_by_tid_map_p);
+
+ /* create the timer used by the madw_req_list */
+ cl_timer_construct(&(trans_mgr_p->madw_list_timer));
+
+ /* init the timer with timeout. */
+ cl_status = cl_timer_init(&trans_mgr_p->madw_list_timer,
+ __osm_transaction_mgr_callback, p_vend);
+
+ if (cl_status != CL_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_transaction_mgr_init : ERROR 1000: "
+ "Failed to initialize madw_reqs_list timer\n");
+ }
+ OSM_LOG_EXIT(p_vend->p_log);
}
-void
-osm_transaction_mgr_destroy ( IN osm_vendor_t * const p_vend )
+void osm_transaction_mgr_destroy(IN osm_vendor_t * const p_vend)
{
- osm_transaction_mgr_t *trans_mgr_p;
- cl_list_item_t *p_list_item;
- cl_map_item_t *p_map_item;
- osm_madw_req_t *osm_madw_req_p;
-
- OSM_LOG_ENTER( p_vend->p_log, osm_transaction_mgr_destroy );
-
- trans_mgr_p = (osm_transaction_mgr_t*)p_vend->p_transaction_mgr;
-
- if( p_vend->p_transaction_mgr != NULL )
- {
- /* we need to get a lock */
- cl_spinlock_acquire( &trans_mgr_p->transaction_mgr_lock );
-
- /* go over all the items in the list and remove them */
- p_list_item = cl_qlist_remove_head(trans_mgr_p->madw_reqs_list_p);
- while ( p_list_item != cl_qlist_end(trans_mgr_p->madw_reqs_list_p) ) {
- osm_madw_req_p = (osm_madw_req_t*)p_list_item;
-
- if (osm_madw_req_p->p_madw->p_mad)
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "osm_transaction_mgr_destroy: "
- "Found outstanding MADW:%p TID:<0x%"PRIx64">.\n",
- osm_madw_req_p->p_madw,
- osm_madw_req_p->p_madw->p_mad->trans_id );
- else
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "osm_transaction_mgr_destroy: "
- "Found outstanding MADW:%p TID:UNDEFINED.\n",
- osm_madw_req_p->p_madw);
-
- /* each item - remove it from the map */
- p_map_item = &(osm_madw_req_p->map_item);
- cl_qmap_remove_item(trans_mgr_p->madw_by_tid_map_p, p_map_item);
- /* free the item */
- free(osm_madw_req_p);
- p_list_item = cl_qlist_remove_head(trans_mgr_p->madw_reqs_list_p);
- }
- /* free the qlist and qmap */
- free(trans_mgr_p->madw_reqs_list_p );
- free(trans_mgr_p->madw_by_tid_map_p );
- /* reliease and destroy the lock */
- cl_spinlock_release( &trans_mgr_p->transaction_mgr_lock );
- cl_spinlock_destroy( &(trans_mgr_p->transaction_mgr_lock) );
- /* destroy the timer */
- cl_timer_trim(&trans_mgr_p->madw_list_timer, 1);
- cl_timer_destroy( &trans_mgr_p->madw_list_timer );
- /* free the transaction_manager object */
- free(trans_mgr_p);
- trans_mgr_p = NULL; }
-
- OSM_LOG_EXIT( p_vend->p_log );
+ osm_transaction_mgr_t *trans_mgr_p;
+ cl_list_item_t *p_list_item;
+ cl_map_item_t *p_map_item;
+ osm_madw_req_t *osm_madw_req_p;
+
+ OSM_LOG_ENTER(p_vend->p_log, osm_transaction_mgr_destroy);
+
+ trans_mgr_p = (osm_transaction_mgr_t *) p_vend->p_transaction_mgr;
+
+ if (p_vend->p_transaction_mgr != NULL) {
+ /* we need to get a lock */
+ cl_spinlock_acquire(&trans_mgr_p->transaction_mgr_lock);
+
+ /* go over all the items in the list and remove them */
+ p_list_item =
+ cl_qlist_remove_head(trans_mgr_p->madw_reqs_list_p);
+ while (p_list_item !=
+ cl_qlist_end(trans_mgr_p->madw_reqs_list_p)) {
+ osm_madw_req_p = (osm_madw_req_t *) p_list_item;
+
+ if (osm_madw_req_p->p_madw->p_mad)
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_transaction_mgr_destroy: "
+ "Found outstanding MADW:%p TID:<0x%"
+ PRIx64 ">.\n", osm_madw_req_p->p_madw,
+ osm_madw_req_p->p_madw->p_mad->
+ trans_id);
+ else
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_transaction_mgr_destroy: "
+ "Found outstanding MADW:%p TID:UNDEFINED.\n",
+ osm_madw_req_p->p_madw);
+
+ /* each item - remove it from the map */
+ p_map_item = &(osm_madw_req_p->map_item);
+ cl_qmap_remove_item(trans_mgr_p->madw_by_tid_map_p,
+ p_map_item);
+ /* free the item */
+ free(osm_madw_req_p);
+ p_list_item =
+ cl_qlist_remove_head(trans_mgr_p->madw_reqs_list_p);
+ }
+ /* free the qlist and qmap */
+ free(trans_mgr_p->madw_reqs_list_p);
+ free(trans_mgr_p->madw_by_tid_map_p);
+ /* reliease and destroy the lock */
+ cl_spinlock_release(&trans_mgr_p->transaction_mgr_lock);
+ cl_spinlock_destroy(&(trans_mgr_p->transaction_mgr_lock));
+ /* destroy the timer */
+ cl_timer_trim(&trans_mgr_p->madw_list_timer, 1);
+ cl_timer_destroy(&trans_mgr_p->madw_list_timer);
+ /* free the transaction_manager object */
+ free(trans_mgr_p);
+ trans_mgr_p = NULL;
+ }
+
+ OSM_LOG_EXIT(p_vend->p_log);
}
-
ib_api_status_t
-osm_transaction_mgr_insert_madw( IN osm_bind_handle_t *const p_bind,
- IN osm_madw_t * p_madw )
+osm_transaction_mgr_insert_madw(IN osm_bind_handle_t * const p_bind,
+ IN osm_madw_t * p_madw)
{
#ifdef OSM_VENDOR_INTF_MTL
- osm_vendor_t *const p_vend = ((osm_mtl_bind_info_t *)p_bind)->p_vend;
+ osm_vendor_t *const p_vend = ((osm_mtl_bind_info_t *) p_bind)->p_vend;
#else
- osm_vendor_t *const p_vend = ((osm_ts_bind_info_t *)p_bind)->p_vend;
+ osm_vendor_t *const p_vend = ((osm_ts_bind_info_t *) p_bind)->p_vend;
#endif
- osm_transaction_mgr_t *trans_mgr_p;
- osm_madw_req_t *osm_madw_req_p;
- uint64_t timeout;
- uint64_t waking_time;
- cl_status_t cl_status;
- uint64_t key;
- const ib_mad_t *mad_p = p_madw->p_mad;
-
- OSM_LOG_ENTER( p_vend->p_log, osm_transaction_mgr_insert_madw );
-
- CL_ASSERT( mad_p );
-
- trans_mgr_p = (osm_transaction_mgr_t*)p_vend->p_transaction_mgr;
-
- timeout = (uint64_t)(p_vend->timeout) * 1000; /* change the miliseconds value of timeout to microseconds. */
- waking_time = timeout + cl_get_time_stamp();
-
- osm_madw_req_p = (osm_madw_req_t *)malloc( sizeof (osm_madw_req_t) );
-
- osm_madw_req_p->p_madw = p_madw;
- osm_madw_req_p->waking_time = waking_time;
- osm_madw_req_p->retry_cnt = OSM_DEFAULT_RETRY_COUNT;
- osm_madw_req_p->p_bind = p_bind;
-
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "osm_transaction_mgr_insert_madw: "
- "Inserting MADW:%p with waking_time: <0x%"PRIx64"> TID:<0x%"PRIx64">.\n",
- p_madw, waking_time, p_madw->p_mad->trans_id );
-
- /* Get the lock on the manager */
- cl_spinlock_acquire( &(trans_mgr_p->transaction_mgr_lock) );
- /* If the list is empty - need to start the timer with timer of timeout (in miliseconds) */
- if (cl_is_qlist_empty(trans_mgr_p->madw_reqs_list_p))
- {
- /* stop the timer if it is running */
- cl_timer_stop(&trans_mgr_p->madw_list_timer);
-
- /* start the timer to the timeout (in miliseconds) */
- cl_status = cl_timer_start(&trans_mgr_p->madw_list_timer,
- p_vend->timeout);
- if (cl_status != CL_SUCCESS)
- {
- osm_log (p_vend->p_log, OSM_LOG_ERROR,
- "osm_transaction_mgr_insert_madw : ERROR 1000: "
- "Failed to start timer\n" );
- }
- }
-
- /* insert the object to the qlist and the qmap */
- cl_qlist_insert_tail( trans_mgr_p->madw_reqs_list_p, &(osm_madw_req_p->list_item));
- /* get the key */
- key = ( uint64_t ) mad_p->trans_id;
- cl_qmap_insert( trans_mgr_p->madw_by_tid_map_p, key, &(osm_madw_req_p->map_item));
- cl_spinlock_release( &trans_mgr_p->transaction_mgr_lock );
-
- OSM_LOG_EXIT( p_vend->p_log );
-
- return ( IB_SUCCESS );
+ osm_transaction_mgr_t *trans_mgr_p;
+ osm_madw_req_t *osm_madw_req_p;
+ uint64_t timeout;
+ uint64_t waking_time;
+ cl_status_t cl_status;
+ uint64_t key;
+ const ib_mad_t *mad_p = p_madw->p_mad;
+
+ OSM_LOG_ENTER(p_vend->p_log, osm_transaction_mgr_insert_madw);
+
+ CL_ASSERT(mad_p);
+
+ trans_mgr_p = (osm_transaction_mgr_t *) p_vend->p_transaction_mgr;
+
+ timeout = (uint64_t) (p_vend->timeout) * 1000; /* change the miliseconds value of timeout to microseconds. */
+ waking_time = timeout + cl_get_time_stamp();
+
+ osm_madw_req_p = (osm_madw_req_t *) malloc(sizeof(osm_madw_req_t));
+
+ osm_madw_req_p->p_madw = p_madw;
+ osm_madw_req_p->waking_time = waking_time;
+ osm_madw_req_p->retry_cnt = OSM_DEFAULT_RETRY_COUNT;
+ osm_madw_req_p->p_bind = p_bind;
+
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_transaction_mgr_insert_madw: "
+ "Inserting MADW:%p with waking_time: <0x%" PRIx64 "> TID:<0x%"
+ PRIx64 ">.\n", p_madw, waking_time, p_madw->p_mad->trans_id);
+
+ /* Get the lock on the manager */
+ cl_spinlock_acquire(&(trans_mgr_p->transaction_mgr_lock));
+ /* If the list is empty - need to start the timer with timer of timeout (in miliseconds) */
+ if (cl_is_qlist_empty(trans_mgr_p->madw_reqs_list_p)) {
+ /* stop the timer if it is running */
+ cl_timer_stop(&trans_mgr_p->madw_list_timer);
+
+ /* start the timer to the timeout (in miliseconds) */
+ cl_status = cl_timer_start(&trans_mgr_p->madw_list_timer,
+ p_vend->timeout);
+ if (cl_status != CL_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_transaction_mgr_insert_madw : ERROR 1000: "
+ "Failed to start timer\n");
+ }
+ }
+
+ /* insert the object to the qlist and the qmap */
+ cl_qlist_insert_tail(trans_mgr_p->madw_reqs_list_p,
+ &(osm_madw_req_p->list_item));
+ /* get the key */
+ key = (uint64_t) mad_p->trans_id;
+ cl_qmap_insert(trans_mgr_p->madw_by_tid_map_p, key,
+ &(osm_madw_req_p->map_item));
+ cl_spinlock_release(&trans_mgr_p->transaction_mgr_lock);
+
+ OSM_LOG_EXIT(p_vend->p_log);
+
+ return (IB_SUCCESS);
}
ib_api_status_t
-osm_transaction_mgr_erase_madw( IN osm_vendor_t * const p_vend,
- IN ib_mad_t * p_mad )
+osm_transaction_mgr_erase_madw(IN osm_vendor_t * const p_vend,
+ IN ib_mad_t * p_mad)
{
- osm_transaction_mgr_t *trans_mgr_p;
- osm_madw_req_t *osm_madw_req_p;
- uint64_t key;
- cl_map_item_t *p_map_item;
- OSM_LOG_ENTER( p_vend->p_log, osm_transaction_mgr_erase_madw );
-
- trans_mgr_p = (osm_transaction_mgr_t*)p_vend->p_transaction_mgr;
-
- key = ( uint64_t ) p_mad->trans_id;
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "osm_transaction_mgr_erase_madw: "
- "Removing TID:<0x%"PRIx64">.\n", p_mad->trans_id );
-
- cl_spinlock_acquire( &trans_mgr_p->transaction_mgr_lock );
- p_map_item = cl_qmap_get( trans_mgr_p->madw_by_tid_map_p, key );
- if (p_map_item != cl_qmap_end(trans_mgr_p->madw_by_tid_map_p))
- {
- /* we found such an item. */
- /* get the osm_madw_req_p */
- osm_madw_req_p = PARENT_STRUCT(p_map_item, osm_madw_req_t, map_item);
-
- /* remove the item from the qlist */
- cl_qlist_remove_item( trans_mgr_p->madw_reqs_list_p, &(osm_madw_req_p->list_item) );
- /* remove the item from the qmap */
- cl_qmap_remove_item( trans_mgr_p->madw_by_tid_map_p, &(osm_madw_req_p->map_item) );
-
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "osm_transaction_mgr_erase_madw: "
- "Removed TID:<0x%"PRIx64">.\n", p_mad->trans_id );
-
- /* free the item */
- free(osm_madw_req_p);
- }
- else
- {
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "osm_transaction_mgr_erase_madw: "
- "osm_transaction_mgr_erase_madw:<0x%"PRIx64"> NOT FOUND.\n", p_mad->trans_id );
- }
- cl_spinlock_release( &trans_mgr_p->transaction_mgr_lock );
- OSM_LOG_EXIT( p_vend->p_log );
-
- return ( IB_SUCCESS );
+ osm_transaction_mgr_t *trans_mgr_p;
+ osm_madw_req_t *osm_madw_req_p;
+ uint64_t key;
+ cl_map_item_t *p_map_item;
+ OSM_LOG_ENTER(p_vend->p_log, osm_transaction_mgr_erase_madw);
+
+ trans_mgr_p = (osm_transaction_mgr_t *) p_vend->p_transaction_mgr;
+
+ key = (uint64_t) p_mad->trans_id;
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_transaction_mgr_erase_madw: "
+ "Removing TID:<0x%" PRIx64 ">.\n", p_mad->trans_id);
+
+ cl_spinlock_acquire(&trans_mgr_p->transaction_mgr_lock);
+ p_map_item = cl_qmap_get(trans_mgr_p->madw_by_tid_map_p, key);
+ if (p_map_item != cl_qmap_end(trans_mgr_p->madw_by_tid_map_p)) {
+ /* we found such an item. */
+ /* get the osm_madw_req_p */
+ osm_madw_req_p =
+ PARENT_STRUCT(p_map_item, osm_madw_req_t, map_item);
+
+ /* remove the item from the qlist */
+ cl_qlist_remove_item(trans_mgr_p->madw_reqs_list_p,
+ &(osm_madw_req_p->list_item));
+ /* remove the item from the qmap */
+ cl_qmap_remove_item(trans_mgr_p->madw_by_tid_map_p,
+ &(osm_madw_req_p->map_item));
+
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_transaction_mgr_erase_madw: "
+ "Removed TID:<0x%" PRIx64 ">.\n", p_mad->trans_id);
+
+ /* free the item */
+ free(osm_madw_req_p);
+ } else {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_transaction_mgr_erase_madw: "
+ "osm_transaction_mgr_erase_madw:<0x%" PRIx64
+ "> NOT FOUND.\n", p_mad->trans_id);
+ }
+ cl_spinlock_release(&trans_mgr_p->transaction_mgr_lock);
+ OSM_LOG_EXIT(p_vend->p_log);
+
+ return (IB_SUCCESS);
}
ib_api_status_t
-osm_transaction_mgr_get_madw_for_tid( IN osm_vendor_t * const p_vend,
- IN ib_mad_t * const p_mad,
- OUT osm_madw_t ** req_madw_p )
+osm_transaction_mgr_get_madw_for_tid(IN osm_vendor_t * const p_vend,
+ IN ib_mad_t * const p_mad,
+ OUT osm_madw_t ** req_madw_p)
{
- osm_transaction_mgr_t *trans_mgr_p;
- osm_madw_req_t *osm_madw_req_p;
- cl_map_item_t *p_map_item;
- uint64_t key;
- OSM_LOG_ENTER( p_vend->p_log, osm_transaction_mgr_get_madw_for_tid );
-
- trans_mgr_p = (osm_transaction_mgr_t*)p_vend->p_transaction_mgr;
-
- *req_madw_p = NULL;
-
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "osm_transaction_mgr_get_madw_for_tid: "
- "Looking for TID:<0x%"PRIx64">.\n", p_mad->trans_id );
-
- key = ( uint64_t ) p_mad->trans_id;
- cl_spinlock_acquire( &(trans_mgr_p->transaction_mgr_lock) );
- p_map_item = cl_qmap_get( trans_mgr_p->madw_by_tid_map_p, key );
- if (p_map_item != cl_qmap_end(trans_mgr_p->madw_by_tid_map_p))
- {
- /* we found such an item. */
- /* get the osm_madw_req_p */
- osm_madw_req_p = PARENT_STRUCT(p_map_item, osm_madw_req_t, map_item);
-
- /* Since the Transaction was looked up and provided for */
- /* processing we retire it */
- cl_qlist_remove_item( trans_mgr_p->madw_reqs_list_p, &(osm_madw_req_p->list_item) );
- /* remove the item from the qmap */
- cl_qmap_remove_item( trans_mgr_p->madw_by_tid_map_p, &(osm_madw_req_p->map_item) );
-
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "osm_transaction_mgr_get_madw_for_tid: "
- "Removed TID:<0x%"PRIx64">.\n", p_mad->trans_id );
-
- *req_madw_p = osm_madw_req_p->p_madw;
- }
-
- cl_spinlock_release( &(trans_mgr_p->transaction_mgr_lock) );
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "osm_transaction_mgr_get_madw_for_tid: "
- "Got MADW:%p.\n", *req_madw_p );
- OSM_LOG_EXIT( p_vend->p_log );
- return ( IB_SUCCESS );
+ osm_transaction_mgr_t *trans_mgr_p;
+ osm_madw_req_t *osm_madw_req_p;
+ cl_map_item_t *p_map_item;
+ uint64_t key;
+ OSM_LOG_ENTER(p_vend->p_log, osm_transaction_mgr_get_madw_for_tid);
+
+ trans_mgr_p = (osm_transaction_mgr_t *) p_vend->p_transaction_mgr;
+
+ *req_madw_p = NULL;
+
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_transaction_mgr_get_madw_for_tid: "
+ "Looking for TID:<0x%" PRIx64 ">.\n", p_mad->trans_id);
+
+ key = (uint64_t) p_mad->trans_id;
+ cl_spinlock_acquire(&(trans_mgr_p->transaction_mgr_lock));
+ p_map_item = cl_qmap_get(trans_mgr_p->madw_by_tid_map_p, key);
+ if (p_map_item != cl_qmap_end(trans_mgr_p->madw_by_tid_map_p)) {
+ /* we found such an item. */
+ /* get the osm_madw_req_p */
+ osm_madw_req_p =
+ PARENT_STRUCT(p_map_item, osm_madw_req_t, map_item);
+
+ /* Since the Transaction was looked up and provided for */
+ /* processing we retire it */
+ cl_qlist_remove_item(trans_mgr_p->madw_reqs_list_p,
+ &(osm_madw_req_p->list_item));
+ /* remove the item from the qmap */
+ cl_qmap_remove_item(trans_mgr_p->madw_by_tid_map_p,
+ &(osm_madw_req_p->map_item));
+
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_transaction_mgr_get_madw_for_tid: "
+ "Removed TID:<0x%" PRIx64 ">.\n", p_mad->trans_id);
+
+ *req_madw_p = osm_madw_req_p->p_madw;
+ }
+
+ cl_spinlock_release(&(trans_mgr_p->transaction_mgr_lock));
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_transaction_mgr_get_madw_for_tid: "
+ "Got MADW:%p.\n", *req_madw_p);
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (IB_SUCCESS);
}
#endif
diff --git a/opensm/libvendor/osm_vendor_test.c b/opensm/libvendor/osm_vendor_test.c
index 1b8f51f..30a43f9 100644
--- a/opensm/libvendor/osm_vendor_test.c
+++ b/opensm/libvendor/osm_vendor_test.c
@@ -33,7 +33,6 @@
*
*/
-
/*
* Abstract:
* Implementation of vendor specific transport interface.
@@ -49,7 +48,7 @@
#if HAVE_CONFIG_H
# include <config.h>
-#endif /* HAVE_CONFIG_H */
+#endif /* HAVE_CONFIG_H */
#include <vendor/osm_vendor_select.h>
@@ -63,255 +62,227 @@
/**********************************************************************
**********************************************************************/
-void
-osm_vendor_construct(
- IN osm_vendor_t* const p_vend )
+void osm_vendor_construct(IN osm_vendor_t * const p_vend)
{
- memset( p_vend, 0, sizeof(*p_vend) );
+ memset(p_vend, 0, sizeof(*p_vend));
}
/**********************************************************************
**********************************************************************/
-void
-osm_vendor_destroy(
- IN osm_vendor_t* const p_vend )
+void osm_vendor_destroy(IN osm_vendor_t * const p_vend)
{
- UNUSED_PARAM( p_vend );
+ UNUSED_PARAM(p_vend);
}
/**********************************************************************
**********************************************************************/
-void
-osm_vendor_delete(
- IN osm_vendor_t** const pp_vend )
+void osm_vendor_delete(IN osm_vendor_t ** const pp_vend)
{
- CL_ASSERT( pp_vend );
+ CL_ASSERT(pp_vend);
- osm_vendor_destroy( *pp_vend );
- free( *pp_vend );
- *pp_vend = NULL;
+ osm_vendor_destroy(*pp_vend);
+ free(*pp_vend);
+ *pp_vend = NULL;
}
/**********************************************************************
**********************************************************************/
ib_api_status_t
-osm_vendor_init(
- IN osm_vendor_t* const p_vend,
- IN osm_log_t* const p_log,
- IN const uint32_t timeout )
+osm_vendor_init(IN osm_vendor_t * const p_vend,
+ IN osm_log_t * const p_log, IN const uint32_t timeout)
{
- OSM_LOG_ENTER( p_log, osm_vendor_init );
+ OSM_LOG_ENTER(p_log, osm_vendor_init);
- CL_ASSERT( p_vend );
- CL_ASSERT( p_log );
+ CL_ASSERT(p_vend);
+ CL_ASSERT(p_log);
- p_vend->p_log = p_log;
- p_vend->timeout = timeout;
- OSM_LOG_EXIT( p_log );
- return( IB_SUCCESS );
+ p_vend->p_log = p_log;
+ p_vend->timeout = timeout;
+ OSM_LOG_EXIT(p_log);
+ return (IB_SUCCESS);
}
/**********************************************************************
**********************************************************************/
-osm_vendor_t*
-osm_vendor_new(
- IN osm_log_t* const p_log,
- IN const uint32_t timeout )
+osm_vendor_t *osm_vendor_new(IN osm_log_t * const p_log,
+ IN const uint32_t timeout)
{
- ib_api_status_t status;
- osm_vendor_t *p_vend;
- OSM_LOG_ENTER( p_log, osm_vendor_new );
-
- CL_ASSERT( p_log );
-
- p_vend = malloc( sizeof(*p_vend) );
- if( p_vend != NULL )
- {
- memset( p_vend, 0, sizeof(*p_vend) );
-
- status = osm_vendor_init( p_vend, p_log, timeout );
- if( status != IB_SUCCESS )
- {
- osm_vendor_delete( &p_vend );
- }
- }
-
- OSM_LOG_EXIT( p_log );
- return( p_vend );
+ ib_api_status_t status;
+ osm_vendor_t *p_vend;
+ OSM_LOG_ENTER(p_log, osm_vendor_new);
+
+ CL_ASSERT(p_log);
+
+ p_vend = malloc(sizeof(*p_vend));
+ if (p_vend != NULL) {
+ memset(p_vend, 0, sizeof(*p_vend));
+
+ status = osm_vendor_init(p_vend, p_log, timeout);
+ if (status != IB_SUCCESS) {
+ osm_vendor_delete(&p_vend);
+ }
+ }
+
+ OSM_LOG_EXIT(p_log);
+ return (p_vend);
}
/**********************************************************************
**********************************************************************/
-ib_mad_t*
-osm_vendor_get(
- IN osm_bind_handle_t h_bind,
- IN const uint32_t size,
- IN osm_vend_wrap_t* const p_vend_wrap )
+ib_mad_t *osm_vendor_get(IN osm_bind_handle_t h_bind,
+ IN const uint32_t size,
+ IN osm_vend_wrap_t * const p_vend_wrap)
{
- osm_vendor_t *p_vend;
- ib_mad_t *p_mad;
- OSM_LOG_ENTER( h_bind->p_vend->p_log, osm_vendor_get );
+ osm_vendor_t *p_vend;
+ ib_mad_t *p_mad;
+ OSM_LOG_ENTER(h_bind->p_vend->p_log, osm_vendor_get);
- UNUSED_PARAM( p_vend_wrap );
+ UNUSED_PARAM(p_vend_wrap);
- p_vend = h_bind->p_vend;
+ p_vend = h_bind->p_vend;
- /*
- Simply malloc the MAD off the heap.
- */
- p_mad = (ib_mad_t*)malloc( size );
+ /*
+ Simply malloc the MAD off the heap.
+ */
+ p_mad = (ib_mad_t *) malloc(size);
- osm_log( p_vend->p_log, OSM_LOG_VERBOSE,
- "osm_vendor_get: "
- "MAD %p.\n", p_mad );
+ osm_log(p_vend->p_log, OSM_LOG_VERBOSE,
+ "osm_vendor_get: " "MAD %p.\n", p_mad);
- if (p_mad)
- memset( p_mad, 0, size );
+ if (p_mad)
+ memset(p_mad, 0, size);
- OSM_LOG_EXIT( p_vend->p_log );
- return( p_mad );
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (p_mad);
}
/**********************************************************************
**********************************************************************/
void
-osm_vendor_put(
- IN osm_bind_handle_t h_bind,
- IN osm_vend_wrap_t* const p_vend_wrap,
- IN ib_mad_t* const p_mad )
+osm_vendor_put(IN osm_bind_handle_t h_bind,
+ IN osm_vend_wrap_t * const p_vend_wrap,
+ IN ib_mad_t * const p_mad)
{
- osm_vendor_t *p_vend;
+ osm_vendor_t *p_vend;
- OSM_LOG_ENTER( h_bind->p_vend->p_log, osm_vendor_put );
+ OSM_LOG_ENTER(h_bind->p_vend->p_log, osm_vendor_put);
- UNUSED_PARAM( p_vend_wrap );
+ UNUSED_PARAM(p_vend_wrap);
- p_vend = h_bind->p_vend;
+ p_vend = h_bind->p_vend;
- osm_log( p_vend->p_log, OSM_LOG_VERBOSE,
- "osm_vendor_put: "
- "MAD %p.\n", p_mad );
+ osm_log(p_vend->p_log, OSM_LOG_VERBOSE,
+ "osm_vendor_put: " "MAD %p.\n", p_mad);
- /*
- Return the MAD to the heap.
- */
- free( p_mad );
+ /*
+ Return the MAD to the heap.
+ */
+ free(p_mad);
- OSM_LOG_EXIT( p_vend->p_log );
+ OSM_LOG_EXIT(p_vend->p_log);
}
/**********************************************************************
**********************************************************************/
ib_api_status_t
-osm_vendor_send(
- IN osm_bind_handle_t h_bind,
- IN osm_vend_wrap_t* const p_vend_wrap,
- IN osm_mad_addr_t* const p_mad_addr,
- IN ib_mad_t* const p_mad,
- IN void *transaction_context,
- IN boolean_t const resp_expected )
+osm_vendor_send(IN osm_bind_handle_t h_bind,
+ IN osm_vend_wrap_t * const p_vend_wrap,
+ IN osm_mad_addr_t * const p_mad_addr,
+ IN ib_mad_t * const p_mad,
+ IN void *transaction_context, IN boolean_t const resp_expected)
{
- osm_vendor_t *p_vend = h_bind->p_vend;
+ osm_vendor_t *p_vend = h_bind->p_vend;
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_send );
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_send);
- UNUSED_PARAM( p_vend_wrap );
- UNUSED_PARAM( p_mad_addr );
- UNUSED_PARAM( transaction_context );
- UNUSED_PARAM( resp_expected );
+ UNUSED_PARAM(p_vend_wrap);
+ UNUSED_PARAM(p_mad_addr);
+ UNUSED_PARAM(transaction_context);
+ UNUSED_PARAM(resp_expected);
- osm_log( p_vend->p_log, OSM_LOG_VERBOSE,
- "osm_vendor_send: "
- "MAD %p.\n", p_mad );
+ osm_log(p_vend->p_log, OSM_LOG_VERBOSE,
+ "osm_vendor_send: " "MAD %p.\n", p_mad);
- OSM_LOG_EXIT( p_vend->p_log );
- return( IB_SUCCESS );
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (IB_SUCCESS);
}
/**********************************************************************
**********************************************************************/
osm_bind_handle_t
-osm_vendor_bind(
- IN osm_vendor_t* const p_vend,
- IN osm_bind_info_t* const p_bind_info,
- IN osm_mad_pool_t* const p_mad_pool,
- IN osm_vend_mad_recv_callback_t mad_recv_callback,
- IN void* context )
+osm_vendor_bind(IN osm_vendor_t * const p_vend,
+ IN osm_bind_info_t * const p_bind_info,
+ IN osm_mad_pool_t * const p_mad_pool,
+ IN osm_vend_mad_recv_callback_t mad_recv_callback,
+ IN void *context)
{
- osm_bind_handle_t h_bind;
-
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_bind );
-
- CL_ASSERT( p_vend );
- CL_ASSERT( p_bind_info );
- CL_ASSERT( p_mad_pool );
- CL_ASSERT( mad_recv_callback );
- CL_ASSERT( context );
-
- UNUSED_PARAM( p_vend );
- UNUSED_PARAM( p_mad_pool );
- UNUSED_PARAM( mad_recv_callback );
- UNUSED_PARAM( context );
-
- h_bind = (osm_bind_handle_t)malloc(sizeof(*h_bind) );
- if( h_bind != NULL )
- {
- memset(h_bind, 0, sizeof(*h_bind));
- h_bind->p_vend = p_vend;
- h_bind->port_guid = p_bind_info->port_guid;
- h_bind->mad_class = p_bind_info->mad_class;
- h_bind->class_version = p_bind_info->class_version;
- h_bind->is_responder = p_bind_info->is_responder;
- h_bind->is_trap_processor = p_bind_info->is_trap_processor;
- h_bind->is_report_processor = p_bind_info->is_report_processor;
- h_bind->send_q_size = p_bind_info->send_q_size;
- h_bind->recv_q_size = p_bind_info->recv_q_size;
- }
-
- OSM_LOG_EXIT( p_vend->p_log );
- return( h_bind );
+ osm_bind_handle_t h_bind;
+
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_bind);
+
+ CL_ASSERT(p_vend);
+ CL_ASSERT(p_bind_info);
+ CL_ASSERT(p_mad_pool);
+ CL_ASSERT(mad_recv_callback);
+ CL_ASSERT(context);
+
+ UNUSED_PARAM(p_vend);
+ UNUSED_PARAM(p_mad_pool);
+ UNUSED_PARAM(mad_recv_callback);
+ UNUSED_PARAM(context);
+
+ h_bind = (osm_bind_handle_t) malloc(sizeof(*h_bind));
+ if (h_bind != NULL) {
+ memset(h_bind, 0, sizeof(*h_bind));
+ h_bind->p_vend = p_vend;
+ h_bind->port_guid = p_bind_info->port_guid;
+ h_bind->mad_class = p_bind_info->mad_class;
+ h_bind->class_version = p_bind_info->class_version;
+ h_bind->is_responder = p_bind_info->is_responder;
+ h_bind->is_trap_processor = p_bind_info->is_trap_processor;
+ h_bind->is_report_processor = p_bind_info->is_report_processor;
+ h_bind->send_q_size = p_bind_info->send_q_size;
+ h_bind->recv_q_size = p_bind_info->recv_q_size;
+ }
+
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (h_bind);
}
/**********************************************************************
**********************************************************************/
ib_api_status_t
-osm_vendor_get_ports(
- IN osm_vendor_t* const p_vend,
- IN ib_net64_t* const p_guids,
- IN uint32_t* const num_guids )
+osm_vendor_get_ports(IN osm_vendor_t * const p_vend,
+ IN ib_net64_t * const p_guids,
+ IN uint32_t * const num_guids)
{
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_get_ports );
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_get_ports);
- *p_guids = CL_NTOH64( 0x0000000000001234 );
- *num_guids = 1;
+ *p_guids = CL_NTOH64(0x0000000000001234);
+ *num_guids = 1;
- OSM_LOG_EXIT( p_vend->p_log );
- return( IB_SUCCESS );
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (IB_SUCCESS);
}
/**********************************************************************
**********************************************************************/
-ib_api_status_t
-osm_vendor_local_lid_change(
- IN osm_bind_handle_t h_bind )
+ib_api_status_t osm_vendor_local_lid_change(IN osm_bind_handle_t h_bind)
{
- osm_vendor_t *p_vend = h_bind->p_vend;
+ osm_vendor_t *p_vend = h_bind->p_vend;
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_local_lid_change );
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_local_lid_change);
- OSM_LOG_EXIT( p_vend->p_log );
+ OSM_LOG_EXIT(p_vend->p_log);
- return( IB_SUCCESS );
+ return (IB_SUCCESS);
}
/**********************************************************************
**********************************************************************/
-void
-osm_vendor_set_debug(
- IN osm_vendor_t* const p_vend,
- IN int32_t level )
+void osm_vendor_set_debug(IN osm_vendor_t * const p_vend, IN int32_t level)
{
}
-#endif /* OSM_VENDOR_INTF_TEST */
+#endif /* OSM_VENDOR_INTF_TEST */
diff --git a/opensm/libvendor/osm_vendor_ts.c b/opensm/libvendor/osm_vendor_ts.c
index 763073b..04b4331 100644
--- a/opensm/libvendor/osm_vendor_ts.c
+++ b/opensm/libvendor/osm_vendor_ts.c
@@ -33,11 +33,10 @@
*
*/
-
#undef __init
#if HAVE_CONFIG_H
# include <config.h>
-#endif /* HAVE_CONFIG_H */
+#endif /* HAVE_CONFIG_H */
#include <stdlib.h>
#include <string.h>
@@ -55,179 +54,165 @@
not fail, and then the madw_p will be put back in the pool before the
callback.
*/
-uint64_t
-__osm_set_wrid_by_p_madw(IN osm_madw_t *p_madw) {
- uint64_t wrid = 0;
+uint64_t __osm_set_wrid_by_p_madw(IN osm_madw_t * p_madw)
+{
+ uint64_t wrid = 0;
- CL_ASSERT(p_madw->p_mad);
+ CL_ASSERT(p_madw->p_mad);
- memcpy( &wrid, &p_madw, sizeof( osm_madw_t * ) );
- wrid = (wrid << 1) |
- ib_mad_is_response(p_madw->p_mad) |
- (p_madw->p_mad->method == IB_MAD_METHOD_TRAP_REPRESS);
- return wrid;
+ memcpy(&wrid, &p_madw, sizeof(osm_madw_t *));
+ wrid = (wrid << 1) |
+ ib_mad_is_response(p_madw->p_mad) |
+ (p_madw->p_mad->method == IB_MAD_METHOD_TRAP_REPRESS);
+ return wrid;
}
void
-__osm_set_p_madw_and_resp_by_wrid(
- IN uint64_t wrid,
- OUT uint8_t *is_resp,
- OUT osm_madw_t **pp_madw) {
- *is_resp = wrid & 0x0000000000000001;
- wrid = wrid >> 1;
- memcpy( pp_madw, &wrid, sizeof( osm_madw_t * ) );
+__osm_set_p_madw_and_resp_by_wrid(IN uint64_t wrid,
+ OUT uint8_t * is_resp,
+ OUT osm_madw_t ** pp_madw)
+{
+ *is_resp = wrid & 0x0000000000000001;
+ wrid = wrid >> 1;
+ memcpy(pp_madw, &wrid, sizeof(osm_madw_t *));
}
/**********************************************************************
* TS MAD to OSM ADDRESS VECTOR
**********************************************************************/
void
-__osm_ts_conv_mad_rcv_desc_to_osm_addr(
- IN osm_vendor_t * const p_vend,
- IN struct ib_mad *p_mad,
- IN uint8_t is_smi,
- OUT osm_mad_addr_t *p_mad_addr)
+__osm_ts_conv_mad_rcv_desc_to_osm_addr(IN osm_vendor_t * const p_vend,
+ IN struct ib_mad *p_mad,
+ IN uint8_t is_smi,
+ OUT osm_mad_addr_t * p_mad_addr)
{
- p_mad_addr->dest_lid = cl_hton16(p_mad->slid);
- p_mad_addr->static_rate = 0; /* HACK - we do not know the rate ! */
- p_mad_addr->path_bits = 0; /* HACK - no way to know in TS */
- if (is_smi)
- {
- /* SMI */
- p_mad_addr->addr_type.smi.source_lid = cl_hton16(p_mad->slid);
- p_mad_addr->addr_type.smi.port_num = p_mad->port;
- }
- else
- {
- /* GSI */
- p_mad_addr->addr_type.gsi.remote_qp = p_mad->sqpn;
- p_mad_addr->addr_type.gsi.remote_qkey = IB_QP1_WELL_KNOWN_Q_KEY;
- /* we do have the p_mad_addr->pkey_ix but how to get the PKey by index ? */
- /* the only way seems to be to use VAPI_query_hca_pkey_tbl and obtain */
- /* the full PKey table - than go by the index. */
- /* since this does not seem reasonable to me I simply use the default */
- /* There is a TAVOR limitation that only one P_KEY is supported per */
- /* QP - so QP1 must use IB_DEFAULT_PKEY */
- p_mad_addr->addr_type.gsi.pkey = IB_DEFAULT_PKEY;
- p_mad_addr->addr_type.gsi.service_level = 0; /* HACK no way to know */
-
- p_mad_addr->addr_type.gsi.global_route = FALSE; /* HACK no way to know */
- /* copy the GRH data if relevant */
- /*
- if (p_mad_addr->addr_type.gsi.global_route)
- {
- p_mad_addr->addr_type.gsi.grh_info.ver_class_flow =
- ib_grh_set_ver_class_flow(p_rcv_desc->grh.IP_version,
- p_rcv_desc->grh.traffic_class,
- p_rcv_desc->grh.flow_label);
- p_mad_addr->addr_type.gsi.grh_info.hop_limit = p_rcv_desc->grh.hop_limit;
- memcpy(&p_mad_addr->addr_type.gsi.grh_info.src_gid.raw,
- &p_rcv_desc->grh.sgid, sizeof(ib_net64_t));
- memcpy(&p_mad_addr->addr_type.gsi.grh_info.dest_gid.raw,
- p_rcv_desc->grh.dgid, sizeof(ib_net64_t));
- }
- */
- }
+ p_mad_addr->dest_lid = cl_hton16(p_mad->slid);
+ p_mad_addr->static_rate = 0; /* HACK - we do not know the rate ! */
+ p_mad_addr->path_bits = 0; /* HACK - no way to know in TS */
+ if (is_smi) {
+ /* SMI */
+ p_mad_addr->addr_type.smi.source_lid = cl_hton16(p_mad->slid);
+ p_mad_addr->addr_type.smi.port_num = p_mad->port;
+ } else {
+ /* GSI */
+ p_mad_addr->addr_type.gsi.remote_qp = p_mad->sqpn;
+ p_mad_addr->addr_type.gsi.remote_qkey = IB_QP1_WELL_KNOWN_Q_KEY;
+ /* we do have the p_mad_addr->pkey_ix but how to get the PKey by index ? */
+ /* the only way seems to be to use VAPI_query_hca_pkey_tbl and obtain */
+ /* the full PKey table - than go by the index. */
+ /* since this does not seem reasonable to me I simply use the default */
+ /* There is a TAVOR limitation that only one P_KEY is supported per */
+ /* QP - so QP1 must use IB_DEFAULT_PKEY */
+ p_mad_addr->addr_type.gsi.pkey = IB_DEFAULT_PKEY;
+ p_mad_addr->addr_type.gsi.service_level = 0; /* HACK no way to know */
+
+ p_mad_addr->addr_type.gsi.global_route = FALSE; /* HACK no way to know */
+ /* copy the GRH data if relevant */
+ /*
+ if (p_mad_addr->addr_type.gsi.global_route)
+ {
+ p_mad_addr->addr_type.gsi.grh_info.ver_class_flow =
+ ib_grh_set_ver_class_flow(p_rcv_desc->grh.IP_version,
+ p_rcv_desc->grh.traffic_class,
+ p_rcv_desc->grh.flow_label);
+ p_mad_addr->addr_type.gsi.grh_info.hop_limit = p_rcv_desc->grh.hop_limit;
+ memcpy(&p_mad_addr->addr_type.gsi.grh_info.src_gid.raw,
+ &p_rcv_desc->grh.sgid, sizeof(ib_net64_t));
+ memcpy(&p_mad_addr->addr_type.gsi.grh_info.dest_gid.raw,
+ p_rcv_desc->grh.dgid, sizeof(ib_net64_t));
+ }
+ */
+ }
}
/**********************************************************************
* OSM ADDR VECTOR TO TS MAD:
**********************************************************************/
void
-__osm_ts_conv_osm_addr_to_ts_addr(
- IN osm_mad_addr_t *p_mad_addr,
- IN uint8_t is_smi,
- OUT struct ib_mad *p_mad)
+__osm_ts_conv_osm_addr_to_ts_addr(IN osm_mad_addr_t * p_mad_addr,
+ IN uint8_t is_smi, OUT struct ib_mad *p_mad)
{
- /* For global destination or Multicast address:*/
- p_mad->dlid = cl_ntoh16(p_mad_addr->dest_lid);
- p_mad->sl = 0;
- if (is_smi)
- {
- p_mad->sqpn = 0;
- p_mad->dqpn = 0;
- }
- else
- {
- p_mad->sqpn = 1;
- p_mad->dqpn = p_mad_addr->addr_type.gsi.remote_qp;
- }
+ /* For global destination or Multicast address: */
+ p_mad->dlid = cl_ntoh16(p_mad_addr->dest_lid);
+ p_mad->sl = 0;
+ if (is_smi) {
+ p_mad->sqpn = 0;
+ p_mad->dqpn = 0;
+ } else {
+ p_mad->sqpn = 1;
+ p_mad->dqpn = p_mad_addr->addr_type.gsi.remote_qp;
+ }
}
/**********************************************************************
**********************************************************************/
-void
-__osm_vendor_clear_sm( IN osm_bind_handle_t h_bind )
+void __osm_vendor_clear_sm(IN osm_bind_handle_t h_bind)
{
- osm_ts_bind_info_t *p_bind = ( osm_ts_bind_info_t * ) h_bind;
- osm_vendor_t *p_vend = p_bind->p_vend;
- VAPI_ret_t status;
- VAPI_hca_attr_t attr_mod;
- VAPI_hca_attr_mask_t attr_mask;
-
- OSM_LOG_ENTER( p_vend->p_log, __osm_vendor_clear_sm );
-
- memset( &attr_mod, 0, sizeof( attr_mod ) );
- memset( &attr_mask, 0, sizeof( attr_mask ) );
-
- attr_mod.is_sm = FALSE;
- attr_mask = HCA_ATTR_IS_SM;
-
- status =
- VAPI_modify_hca_attr( p_bind->hca_hndl, p_bind->port_num, &attr_mod,
- &attr_mask );
- if( status != VAPI_OK )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "__osm_vendor_clear_sm: ERR 5021: "
- "Unable set 'IS_SM' bit in port attributes (%d).\n",
- status );
- }
-
- OSM_LOG_EXIT( p_vend->p_log );
+ osm_ts_bind_info_t *p_bind = (osm_ts_bind_info_t *) h_bind;
+ osm_vendor_t *p_vend = p_bind->p_vend;
+ VAPI_ret_t status;
+ VAPI_hca_attr_t attr_mod;
+ VAPI_hca_attr_mask_t attr_mask;
+
+ OSM_LOG_ENTER(p_vend->p_log, __osm_vendor_clear_sm);
+
+ memset(&attr_mod, 0, sizeof(attr_mod));
+ memset(&attr_mask, 0, sizeof(attr_mask));
+
+ attr_mod.is_sm = FALSE;
+ attr_mask = HCA_ATTR_IS_SM;
+
+ status =
+ VAPI_modify_hca_attr(p_bind->hca_hndl, p_bind->port_num, &attr_mod,
+ &attr_mask);
+ if (status != VAPI_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_vendor_clear_sm: ERR 5021: "
+ "Unable set 'IS_SM' bit in port attributes (%d).\n",
+ status);
+ }
+
+ OSM_LOG_EXIT(p_vend->p_log);
}
/**********************************************************************
* ANY CONSTRUCTION OF THE osm_vendor_t OBJECT
**********************************************************************/
-void
-osm_vendor_construct( IN osm_vendor_t * const p_vend )
+void osm_vendor_construct(IN osm_vendor_t * const p_vend)
{
- memset( p_vend, 0, sizeof( *p_vend ) );
- cl_thread_construct( &(p_vend->smi_bind.poller) );
- cl_thread_construct( &(p_vend->gsi_bind.poller) );
+ memset(p_vend, 0, sizeof(*p_vend));
+ cl_thread_construct(&(p_vend->smi_bind.poller));
+ cl_thread_construct(&(p_vend->gsi_bind.poller));
}
/**********************************************************************
* DEALOCATE osm_vendor_t
**********************************************************************/
-void
-osm_vendor_destroy( IN osm_vendor_t * const p_vend )
+void osm_vendor_destroy(IN osm_vendor_t * const p_vend)
{
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_destroy );
- osm_transaction_mgr_destroy ( p_vend );
-
- /* Destroy the poller threads */
- /* HACK: can you destroy an un-initialized thread ? */
- pthread_cancel(p_vend->smi_bind.poller.osd.id);
- pthread_cancel(p_vend->gsi_bind.poller.osd.id);
- cl_thread_destroy( &(p_vend->smi_bind.poller) );
- cl_thread_destroy( &(p_vend->gsi_bind.poller) );
- OSM_LOG_EXIT( p_vend->p_log );
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_destroy);
+ osm_transaction_mgr_destroy(p_vend);
+
+ /* Destroy the poller threads */
+ /* HACK: can you destroy an un-initialized thread ? */
+ pthread_cancel(p_vend->smi_bind.poller.osd.id);
+ pthread_cancel(p_vend->gsi_bind.poller.osd.id);
+ cl_thread_destroy(&(p_vend->smi_bind.poller));
+ cl_thread_destroy(&(p_vend->gsi_bind.poller));
+ OSM_LOG_EXIT(p_vend->p_log);
}
/**********************************************************************
DEALLOCATE A POINTER TO osm_vendor_t
**********************************************************************/
-void
-osm_vendor_delete( IN osm_vendor_t ** const pp_vend )
+void osm_vendor_delete(IN osm_vendor_t ** const pp_vend)
{
- CL_ASSERT( pp_vend );
+ CL_ASSERT(pp_vend);
- osm_vendor_destroy( *pp_vend );
- free( *pp_vend );
- *pp_vend = NULL;
+ osm_vendor_destroy(*pp_vend);
+ free(*pp_vend);
+ *pp_vend = NULL;
}
/**********************************************************************
@@ -235,62 +220,55 @@ osm_vendor_delete( IN osm_vendor_t ** const pp_vend )
**********************************************************************/
ib_api_status_t
-osm_vendor_init( IN osm_vendor_t * const p_vend,
- IN osm_log_t * const p_log,
- IN const uint32_t timeout )
+osm_vendor_init(IN osm_vendor_t * const p_vend,
+ IN osm_log_t * const p_log, IN const uint32_t timeout)
{
- ib_api_status_t status = IB_SUCCESS;
+ ib_api_status_t status = IB_SUCCESS;
- OSM_LOG_ENTER( p_log, osm_vendor_init );
+ OSM_LOG_ENTER(p_log, osm_vendor_init);
- p_vend->p_log = p_log;
- p_vend->p_transaction_mgr = NULL;
- osm_transaction_mgr_init( p_vend );
- p_vend->timeout = timeout;
+ p_vend->p_log = p_log;
+ p_vend->p_transaction_mgr = NULL;
+ osm_transaction_mgr_init(p_vend);
+ p_vend->timeout = timeout;
- /* we use the file handle to track the binding */
- p_vend->smi_bind.ul_dev_fd = -1;
- p_vend->gsi_bind.ul_dev_fd = -1;
+ /* we use the file handle to track the binding */
+ p_vend->smi_bind.ul_dev_fd = -1;
+ p_vend->gsi_bind.ul_dev_fd = -1;
- OSM_LOG_EXIT( p_log );
- return ( status );
+ OSM_LOG_EXIT(p_log);
+ return (status);
}
/**********************************************************************
* Create and Initialize osm_vendor_t Object
**********************************************************************/
-osm_vendor_t *
-osm_vendor_new(
- IN osm_log_t* const p_log,
- IN const uint32_t timeout )
+osm_vendor_t *osm_vendor_new(IN osm_log_t * const p_log,
+ IN const uint32_t timeout)
{
- ib_api_status_t status;
- osm_vendor_t *p_vend;
-
- OSM_LOG_ENTER( p_log, osm_vendor_new );
-
- CL_ASSERT( p_log );
-
- p_vend = malloc( sizeof( *p_vend ) );
- if( p_vend != NULL )
- {
- memset( p_vend, 0, sizeof( *p_vend ) );
-
- status = osm_vendor_init( p_vend, p_log, timeout );
- if( status != IB_SUCCESS )
- {
- osm_vendor_delete( &p_vend );
- }
- }
- else
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_new: ERR 5007: "
- "Fail to allocate vendor object.\n" );
- }
-
- OSM_LOG_EXIT( p_log );
- return ( p_vend );
+ ib_api_status_t status;
+ osm_vendor_t *p_vend;
+
+ OSM_LOG_ENTER(p_log, osm_vendor_new);
+
+ CL_ASSERT(p_log);
+
+ p_vend = malloc(sizeof(*p_vend));
+ if (p_vend != NULL) {
+ memset(p_vend, 0, sizeof(*p_vend));
+
+ status = osm_vendor_init(p_vend, p_log, timeout);
+ if (status != IB_SUCCESS) {
+ osm_vendor_delete(&p_vend);
+ }
+ } else {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_new: ERR 5007: "
+ "Fail to allocate vendor object.\n");
+ }
+
+ OSM_LOG_EXIT(p_log);
+ return (p_vend);
}
/**********************************************************************
@@ -298,111 +276,104 @@ osm_vendor_new(
* HACK: - we need to make this support arbitrary size mads.
**********************************************************************/
void
-__osm_ts_rcv_callback(
- IN osm_ts_bind_info_t *p_bind,
- IN osm_mad_addr_t *p_mad_addr,
- IN uint32_t mad_size,
- IN void *p_mad )
+__osm_ts_rcv_callback(IN osm_ts_bind_info_t * p_bind,
+ IN osm_mad_addr_t * p_mad_addr,
+ IN uint32_t mad_size, IN void *p_mad)
{
- ib_api_status_t status;
- osm_madw_t *p_req_madw = NULL;
- osm_madw_t *p_madw;
- osm_vend_wrap_t* p_new_vw;
- ib_mad_t *p_mad_buf;
- osm_log_t *const p_log = p_bind->p_vend->p_log;
-
- OSM_LOG_ENTER( p_log, __osm_ts_rcv_callback );
-
- /* if it is a response MAD we mustbe able to get the request */
- if (ib_mad_is_response((ib_mad_t*)p_mad))
- {
- /* can we find a matching madw by this payload TID */
- status =
- osm_transaction_mgr_get_madw_for_tid(
- p_bind->p_vend, (ib_mad_t*)p_mad,
- &p_req_madw );
- if ( status != IB_SUCCESS )
- {
- osm_log( p_log, OSM_LOG_ERROR,
- "__osm_ts_rcv_callback: ERR 5008: "
- "Error obtaining request madw by TID (%d).\n", status );
- p_req_madw = NULL;
- }
-
- if (p_req_madw == NULL)
- {
- osm_log( p_log, OSM_LOG_ERROR,
- "__osm_ts_rcv_callback: ERR 5009: "
- "Fail to obtain request madw for receined MAD. Aborting CB.\n");
- goto Exit;
- }
- }
-
- /* do we have a request ??? */
- if( p_req_madw == NULL )
- {
-
- /* if not - get new osm_madw and arrange it. */
- /* create the new madw in the pool */
- p_madw = osm_mad_pool_get( p_bind->p_osm_pool,
- ( osm_bind_handle_t ) p_bind,
- mad_size, p_mad_addr );
- if( p_madw == NULL )
- {
- osm_log( p_log, OSM_LOG_ERROR,
- "__osm_ts_rcv_callback: ERR 5010: "
- "Error request for a new madw.\n" );
- goto Exit;
- }
- /* HACK: we cust to avoid the const ??? */
- p_mad_buf = (void *)p_madw->p_mad;
- }
- else
- {
- /* we have the madw defined during the send and stored in the vend_wrap */
- /* we need to make sure the wrapper is correctly init there */
- CL_ASSERT(p_req_madw->vend_wrap.p_resp_madw != 0);
- p_madw = p_req_madw->vend_wrap.p_resp_madw;
-
- CL_ASSERT(p_madw->h_bind);
- p_mad_buf = osm_vendor_get(p_madw->h_bind, mad_size, &p_madw->vend_wrap );
-
- if( p_mad_buf == NULL )
- {
- osm_log( p_log, OSM_LOG_ERROR,
- "__osm_ts_rcv_callback: ERR 5011: "
- "Unable to acquire wire MAD.\n" );
-
- goto Exit;
- }
-
- /*
- Finally, attach the wire MAD to this wrapper.
- */
- osm_madw_set_mad( p_madw, p_mad_buf );
- }
-
- /* init some fields of the vendor wrapper */
- p_new_vw = osm_madw_get_vend_ptr( p_madw );
- p_new_vw->h_bind = p_bind;
- p_new_vw->size = mad_size;
- p_new_vw->p_resp_madw = NULL;
- p_new_vw->p_mad_buf = p_mad_buf;
-
- memcpy( p_new_vw->p_mad_buf, p_mad, mad_size );
-
- /* attach the buffer to the wrapper */
- p_madw->p_mad = p_mad_buf;
-
- /* we can also make sure we marked the size and bind on the returned madw */
- p_madw->h_bind = p_new_vw->h_bind;
-
- /* call the CB */
- ( *(osm_vend_mad_recv_callback_t)p_bind->rcv_callback )
- ( p_madw, p_bind->client_context, p_req_madw );
-
- Exit:
- OSM_LOG_EXIT( p_log );
+ ib_api_status_t status;
+ osm_madw_t *p_req_madw = NULL;
+ osm_madw_t *p_madw;
+ osm_vend_wrap_t *p_new_vw;
+ ib_mad_t *p_mad_buf;
+ osm_log_t *const p_log = p_bind->p_vend->p_log;
+
+ OSM_LOG_ENTER(p_log, __osm_ts_rcv_callback);
+
+ /* if it is a response MAD we mustbe able to get the request */
+ if (ib_mad_is_response((ib_mad_t *) p_mad)) {
+ /* can we find a matching madw by this payload TID */
+ status =
+ osm_transaction_mgr_get_madw_for_tid(p_bind->p_vend,
+ (ib_mad_t *) p_mad,
+ &p_req_madw);
+ if (status != IB_SUCCESS) {
+ osm_log(p_log, OSM_LOG_ERROR,
+ "__osm_ts_rcv_callback: ERR 5008: "
+ "Error obtaining request madw by TID (%d).\n",
+ status);
+ p_req_madw = NULL;
+ }
+
+ if (p_req_madw == NULL) {
+ osm_log(p_log, OSM_LOG_ERROR,
+ "__osm_ts_rcv_callback: ERR 5009: "
+ "Fail to obtain request madw for receined MAD. Aborting CB.\n");
+ goto Exit;
+ }
+ }
+
+ /* do we have a request ??? */
+ if (p_req_madw == NULL) {
+
+ /* if not - get new osm_madw and arrange it. */
+ /* create the new madw in the pool */
+ p_madw = osm_mad_pool_get(p_bind->p_osm_pool,
+ (osm_bind_handle_t) p_bind,
+ mad_size, p_mad_addr);
+ if (p_madw == NULL) {
+ osm_log(p_log, OSM_LOG_ERROR,
+ "__osm_ts_rcv_callback: ERR 5010: "
+ "Error request for a new madw.\n");
+ goto Exit;
+ }
+ /* HACK: we cust to avoid the const ??? */
+ p_mad_buf = (void *)p_madw->p_mad;
+ } else {
+ /* we have the madw defined during the send and stored in the vend_wrap */
+ /* we need to make sure the wrapper is correctly init there */
+ CL_ASSERT(p_req_madw->vend_wrap.p_resp_madw != 0);
+ p_madw = p_req_madw->vend_wrap.p_resp_madw;
+
+ CL_ASSERT(p_madw->h_bind);
+ p_mad_buf =
+ osm_vendor_get(p_madw->h_bind, mad_size,
+ &p_madw->vend_wrap);
+
+ if (p_mad_buf == NULL) {
+ osm_log(p_log, OSM_LOG_ERROR,
+ "__osm_ts_rcv_callback: ERR 5011: "
+ "Unable to acquire wire MAD.\n");
+
+ goto Exit;
+ }
+
+ /*
+ Finally, attach the wire MAD to this wrapper.
+ */
+ osm_madw_set_mad(p_madw, p_mad_buf);
+ }
+
+ /* init some fields of the vendor wrapper */
+ p_new_vw = osm_madw_get_vend_ptr(p_madw);
+ p_new_vw->h_bind = p_bind;
+ p_new_vw->size = mad_size;
+ p_new_vw->p_resp_madw = NULL;
+ p_new_vw->p_mad_buf = p_mad_buf;
+
+ memcpy(p_new_vw->p_mad_buf, p_mad, mad_size);
+
+ /* attach the buffer to the wrapper */
+ p_madw->p_mad = p_mad_buf;
+
+ /* we can also make sure we marked the size and bind on the returned madw */
+ p_madw->h_bind = p_new_vw->h_bind;
+
+ /* call the CB */
+ (*(osm_vend_mad_recv_callback_t) p_bind->rcv_callback)
+ (p_madw, p_bind->client_context, p_req_madw);
+
+ Exit:
+ OSM_LOG_EXIT(p_log);
}
/**********************************************************************
@@ -410,140 +381,131 @@ __osm_ts_rcv_callback(
*
**********************************************************************/
void
-__osm_ts_send_callback(
- IN osm_ts_bind_info_t *bind_info_p,
- IN boolean_t is_resp,
- IN osm_madw_t *madw_p,
- IN IB_comp_status_t status)
+__osm_ts_send_callback(IN osm_ts_bind_info_t * bind_info_p,
+ IN boolean_t is_resp,
+ IN osm_madw_t * madw_p, IN IB_comp_status_t status)
{
- osm_log_t *const p_log = bind_info_p->p_vend->p_log;
- osm_vend_wrap_t* p_vw;
-
- OSM_LOG_ENTER( p_log, __osm_ts_send_callback );
-
- osm_log( p_log, OSM_LOG_DEBUG,
- "__osm_ts_send_callback: INFO 1008: "
- "Handling Send of MADW:%p Is Resp:%d.\n", madw_p, is_resp);
-
- /* we need to handle requests and responses differently */
- if (is_resp)
- {
- if (status != IB_COMP_SUCCESS)
- {
- osm_log( p_log, OSM_LOG_ERROR,
- "__osm_ts_send_callback: ERR 5012: "
- "Error Sending Response MADW:%p.\n", madw_p);
- }
- else
- {
- osm_log( p_log, OSM_LOG_DEBUG,
- "__osm_ts_send_callback: DBG 1008: "
- "Completed Sending Response MADW:%p.\n", madw_p);
- }
-
- /* if we are a response - we need to clean it up */
- osm_mad_pool_put( bind_info_p->p_osm_pool, madw_p);
- }
- else
- {
-
- /* this call back is invoked on completion of send - error or not */
- if (status != IB_COMP_SUCCESS)
- {
-
- osm_log( p_log, OSM_LOG_ERROR,
- "__osm_ts_send_callback: ERR 5013: "
- "Received an Error from IB_MGT Send (%d).\n",status );
-
- p_vw = osm_madw_get_vend_ptr( madw_p );
- CL_ASSERT( p_vw );
-
- /*
- Return any wrappers to the pool that may have been
- pre-emptively allocated to handle a receive.
- */
- if( p_vw->p_resp_madw )
- {
- osm_mad_pool_put( bind_info_p->p_osm_pool, p_vw->p_resp_madw );
- p_vw->p_resp_madw = NULL;
- }
-
- /* invoke the CB */
- ( *(osm_vend_mad_send_err_callback_t)bind_info_p->send_err_callback )
- ( bind_info_p->client_context, madw_p );
- }
- else
- {
- /* successful request send - do nothing - the response will need the
- out mad */
- osm_log( p_log, OSM_LOG_DEBUG,
- "__osm_ts_send_callback: DBG 1008: "
- "Completed Sending Request MADW:%p.\n", madw_p);
- }
- }
-
- OSM_LOG_EXIT( p_log );
+ osm_log_t *const p_log = bind_info_p->p_vend->p_log;
+ osm_vend_wrap_t *p_vw;
+
+ OSM_LOG_ENTER(p_log, __osm_ts_send_callback);
+
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "__osm_ts_send_callback: INFO 1008: "
+ "Handling Send of MADW:%p Is Resp:%d.\n", madw_p, is_resp);
+
+ /* we need to handle requests and responses differently */
+ if (is_resp) {
+ if (status != IB_COMP_SUCCESS) {
+ osm_log(p_log, OSM_LOG_ERROR,
+ "__osm_ts_send_callback: ERR 5012: "
+ "Error Sending Response MADW:%p.\n", madw_p);
+ } else {
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "__osm_ts_send_callback: DBG 1008: "
+ "Completed Sending Response MADW:%p.\n",
+ madw_p);
+ }
+
+ /* if we are a response - we need to clean it up */
+ osm_mad_pool_put(bind_info_p->p_osm_pool, madw_p);
+ } else {
+
+ /* this call back is invoked on completion of send - error or not */
+ if (status != IB_COMP_SUCCESS) {
+
+ osm_log(p_log, OSM_LOG_ERROR,
+ "__osm_ts_send_callback: ERR 5013: "
+ "Received an Error from IB_MGT Send (%d).\n",
+ status);
+
+ p_vw = osm_madw_get_vend_ptr(madw_p);
+ CL_ASSERT(p_vw);
+
+ /*
+ Return any wrappers to the pool that may have been
+ pre-emptively allocated to handle a receive.
+ */
+ if (p_vw->p_resp_madw) {
+ osm_mad_pool_put(bind_info_p->p_osm_pool,
+ p_vw->p_resp_madw);
+ p_vw->p_resp_madw = NULL;
+ }
+
+ /* invoke the CB */
+ (*(osm_vend_mad_send_err_callback_t) bind_info_p->
+ send_err_callback)
+ (bind_info_p->client_context, madw_p);
+ } else {
+ /* successful request send - do nothing - the response will need the
+ out mad */
+ osm_log(p_log, OSM_LOG_DEBUG,
+ "__osm_ts_send_callback: DBG 1008: "
+ "Completed Sending Request MADW:%p.\n", madw_p);
+ }
+ }
+
+ OSM_LOG_EXIT(p_log);
}
/**********************************************************************
* Poller thread:
* Always receive 256byte mads from the devcie file
**********************************************************************/
-void
-__osm_vendor_ts_poller(
- IN void *p_ptr )
+void __osm_vendor_ts_poller(IN void *p_ptr)
{
- int ts_ret_code;
- struct ib_mad mad;
- osm_mad_addr_t mad_addr;
- osm_ts_bind_info_t * const p_bind = (osm_ts_bind_info_t *)p_ptr;
-
- OSM_LOG_ENTER( p_bind->p_vend->p_log, __osm_vendor_ts_poller );
- /* we set the type of cancelation for this thread */
- pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
-
- while( 1 )
- {
- /* we read one mad at a time and pass it to the read callback function */
- ts_ret_code = read(p_bind->ul_dev_fd, &mad, sizeof(mad));
- if (ts_ret_code != sizeof(mad))
- {
- osm_log( p_bind->p_vend->p_log, OSM_LOG_ERROR,
- "__osm_vendor_ts_poller: ERR 5003: "
- "error with read, bytes = %d, errno = %d\n",
- ts_ret_code, errno
- );
- }
- else
- {
- osm_log( p_bind->p_vend->p_log, OSM_LOG_DEBUG,
- "__osm_vendor_ts_poller: "
- "MAD QPN:%d SLID:0x%04x class:0x%02x "
- "__osm_vendor_ts_poller:0x%02x attr:0x%04x status:0x%04x "
- "__osm_vendor_ts_poller:0x%016" PRIx64 "\n",
- cl_ntoh32(mad.dqpn),
- cl_ntoh16(mad.slid),
- mad.mgmt_class,
- mad.r_method,
- cl_ntoh16(mad.attribute_id),
- cl_ntoh16(mad.status),
- cl_ntoh64(mad.transaction_id));
-
- /* first arrange an address */
- __osm_ts_conv_mad_rcv_desc_to_osm_addr(
- p_bind->p_vend,
- &mad,
- ( ((ib_mad_t*)&mad)->mgmt_class == IB_MCLASS_SUBN_LID ) ||
- ( ((ib_mad_t*)&mad)->mgmt_class == IB_MCLASS_SUBN_DIR ),
- &mad_addr);
-
- /* call the receiver callback */
- /* HACK: this should be replaced with a call to the RMPP Assembly ... */
- __osm_ts_rcv_callback(p_bind, &mad_addr, 256, &mad);
- }
- }
-
- OSM_LOG_EXIT( p_bind->p_vend->p_log );
+ int ts_ret_code;
+ struct ib_mad mad;
+ osm_mad_addr_t mad_addr;
+ osm_ts_bind_info_t *const p_bind = (osm_ts_bind_info_t *) p_ptr;
+
+ OSM_LOG_ENTER(p_bind->p_vend->p_log, __osm_vendor_ts_poller);
+ /* we set the type of cancelation for this thread */
+ pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
+
+ while (1) {
+ /* we read one mad at a time and pass it to the read callback function */
+ ts_ret_code = read(p_bind->ul_dev_fd, &mad, sizeof(mad));
+ if (ts_ret_code != sizeof(mad)) {
+ osm_log(p_bind->p_vend->p_log, OSM_LOG_ERROR,
+ "__osm_vendor_ts_poller: ERR 5003: "
+ "error with read, bytes = %d, errno = %d\n",
+ ts_ret_code, errno);
+ } else {
+ osm_log(p_bind->p_vend->p_log, OSM_LOG_DEBUG,
+ "__osm_vendor_ts_poller: "
+ "MAD QPN:%d SLID:0x%04x class:0x%02x "
+ "__osm_vendor_ts_poller:0x%02x attr:0x%04x status:0x%04x "
+ "__osm_vendor_ts_poller:0x%016" PRIx64 "\n",
+ cl_ntoh32(mad.dqpn),
+ cl_ntoh16(mad.slid),
+ mad.mgmt_class,
+ mad.r_method,
+ cl_ntoh16(mad.attribute_id),
+ cl_ntoh16(mad.status),
+ cl_ntoh64(mad.transaction_id));
+
+ /* first arrange an address */
+ __osm_ts_conv_mad_rcv_desc_to_osm_addr(p_bind->p_vend,
+ &mad,
+ (((ib_mad_t *) &
+ mad)->
+ mgmt_class ==
+ IB_MCLASS_SUBN_LID)
+ ||
+ (((ib_mad_t *) &
+ mad)->
+ mgmt_class ==
+ IB_MCLASS_SUBN_DIR),
+ &mad_addr);
+
+ /* call the receiver callback */
+ /* HACK: this should be replaced with a call to the RMPP Assembly ... */
+ __osm_ts_rcv_callback(p_bind, &mad_addr, 256, &mad);
+ }
+ }
+
+ OSM_LOG_EXIT(p_bind->p_vend->p_log);
}
/**********************************************************************
@@ -551,236 +513,216 @@ __osm_vendor_ts_poller(
* defined by the given: osm_bind_info_t
**********************************************************************/
osm_bind_handle_t
-osm_vendor_bind( IN osm_vendor_t * const p_vend,
- IN osm_bind_info_t * const p_user_bind,
- IN osm_mad_pool_t * const p_mad_pool,
- IN osm_vend_mad_recv_callback_t mad_recv_callback,
- IN osm_vend_mad_send_err_callback_t send_err_callback,
- IN void *context )
+osm_vendor_bind(IN osm_vendor_t * const p_vend,
+ IN osm_bind_info_t * const p_user_bind,
+ IN osm_mad_pool_t * const p_mad_pool,
+ IN osm_vend_mad_recv_callback_t mad_recv_callback,
+ IN osm_vend_mad_send_err_callback_t send_err_callback,
+ IN void *context)
{
- ib_net64_t port_guid;
- osm_ts_bind_info_t *p_bind = NULL;
- VAPI_hca_hndl_t hca_hndl;
- VAPI_hca_id_t hca_id;
- uint32_t port_num;
- ib_api_status_t status;
- int device_fd;
- char device_file[16];
- osm_ts_user_mad_filter filter;
- int ts_ioctl_ret;
- int qpn;
-
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_bind );
-
- CL_ASSERT( p_mad_pool );
-
- port_guid = p_user_bind->port_guid;
-
- osm_log( p_vend->p_log, OSM_LOG_INFO,
- "osm_vendor_bind: "
- "Binding to port 0x%" PRIx64 ".\n", cl_ntoh64( port_guid ) );
-
- switch ( p_user_bind->mad_class )
- {
- case IB_MCLASS_SUBN_LID:
- case IB_MCLASS_SUBN_DIR:
- p_bind = &(p_vend->smi_bind);
- qpn = 0;
- break;
-
- case IB_MCLASS_SUBN_ADM:
- default:
- p_bind = &(p_vend->gsi_bind);
- qpn = 1;
- break;
- }
-
- /* Make sure we did not previously opened the file */
- if (p_bind->ul_dev_fd >= 0)
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 5004: "
- "Already binded to port %u\n",
- p_bind->port_num
- );
- goto Exit;
- }
-
- /*
- We need to figure out what is the TS file name to attach to.
- I guess it is following the index of the port in the table of
- ports.
- */
-
- /* obtain the hca name and port num from the guid */
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_bind: "
- "Finding CA and Port that owns port guid 0x%" PRIx64 ".\n",
- cl_ntoh64(port_guid) );
- status =
- osm_vendor_get_guid_ca_and_port(
- p_vend, port_guid, &hca_hndl, &hca_id, &port_num);
- if (status != IB_SUCCESS)
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 5005: "
- "Fail to find port number of port guid:0x%016"PRIx64"\n",
- port_guid
- );
- goto Exit;
- }
-
- /* the file name is just /dev/ts_ua0: */
- strcpy(device_file, "/dev/ts_ua0");
-
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: "
- "Opening TS UL dev file:%s\n",
- device_file
- );
-
- /* Open the file ... */
- device_fd = open(device_file, O_RDWR);
- if (device_fd < 0)
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 5006: "
- "Fail to open TS UL dev file:%s\n",
- device_file
- );
- goto Exit;
- }
-
- /* track this bind request info */
- p_bind->ul_dev_fd = device_fd;
- p_bind->port_num = port_num;
- p_bind->p_vend = p_vend;
- p_bind->client_context = context;
- p_bind->rcv_callback = mad_recv_callback;
- p_bind->send_err_callback = send_err_callback;
- p_bind->p_osm_pool = p_mad_pool;
- p_bind->hca_hndl = hca_hndl;
-
- /*
- * Create the MAD filter on this file handle.
- */
- filter.port = port_num;
-
- filter.qpn = qpn;
- filter.mgmt_class = p_user_bind->mad_class;
- filter.direction = TS_IB_MAD_DIRECTION_IN;
- filter.mask =
- TS_IB_MAD_FILTER_DIRECTION |
- TS_IB_MAD_FILTER_PORT |
- TS_IB_MAD_FILTER_QPN |
- TS_IB_MAD_FILTER_MGMT_CLASS;
-
- ts_ioctl_ret = ioctl(device_fd, TS_IB_IOCSMADFILTADD, &filter);
- if (ts_ioctl_ret < 0)
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_bind: ERR 5014: "
- "Fail to register MAD filter with err:%u\n",
- ts_ioctl_ret
- );
- goto Exit;
- }
-
- /* Initialize the listener thread for this port */
- status = cl_thread_init( &p_bind->poller,
- __osm_vendor_ts_poller, p_bind,
- "osm ts poller" );
- if( status != IB_SUCCESS )
- goto Exit;
-
- Exit:
- OSM_LOG_EXIT( p_vend->p_log );
- return ( ( osm_bind_handle_t ) p_bind );
+ ib_net64_t port_guid;
+ osm_ts_bind_info_t *p_bind = NULL;
+ VAPI_hca_hndl_t hca_hndl;
+ VAPI_hca_id_t hca_id;
+ uint32_t port_num;
+ ib_api_status_t status;
+ int device_fd;
+ char device_file[16];
+ osm_ts_user_mad_filter filter;
+ int ts_ioctl_ret;
+ int qpn;
+
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_bind);
+
+ CL_ASSERT(p_mad_pool);
+
+ port_guid = p_user_bind->port_guid;
+
+ osm_log(p_vend->p_log, OSM_LOG_INFO,
+ "osm_vendor_bind: "
+ "Binding to port 0x%" PRIx64 ".\n", cl_ntoh64(port_guid));
+
+ switch (p_user_bind->mad_class) {
+ case IB_MCLASS_SUBN_LID:
+ case IB_MCLASS_SUBN_DIR:
+ p_bind = &(p_vend->smi_bind);
+ qpn = 0;
+ break;
+
+ case IB_MCLASS_SUBN_ADM:
+ default:
+ p_bind = &(p_vend->gsi_bind);
+ qpn = 1;
+ break;
+ }
+
+ /* Make sure we did not previously opened the file */
+ if (p_bind->ul_dev_fd >= 0) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 5004: "
+ "Already binded to port %u\n", p_bind->port_num);
+ goto Exit;
+ }
+
+ /*
+ We need to figure out what is the TS file name to attach to.
+ I guess it is following the index of the port in the table of
+ ports.
+ */
+
+ /* obtain the hca name and port num from the guid */
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_bind: "
+ "Finding CA and Port that owns port guid 0x%" PRIx64 ".\n",
+ cl_ntoh64(port_guid));
+ status =
+ osm_vendor_get_guid_ca_and_port(p_vend, port_guid, &hca_hndl,
+ &hca_id, &port_num);
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 5005: "
+ "Fail to find port number of port guid:0x%016" PRIx64
+ "\n", port_guid);
+ goto Exit;
+ }
+
+ /* the file name is just /dev/ts_ua0: */
+ strcpy(device_file, "/dev/ts_ua0");
+
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: " "Opening TS UL dev file:%s\n", device_file);
+
+ /* Open the file ... */
+ device_fd = open(device_file, O_RDWR);
+ if (device_fd < 0) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 5006: "
+ "Fail to open TS UL dev file:%s\n", device_file);
+ goto Exit;
+ }
+
+ /* track this bind request info */
+ p_bind->ul_dev_fd = device_fd;
+ p_bind->port_num = port_num;
+ p_bind->p_vend = p_vend;
+ p_bind->client_context = context;
+ p_bind->rcv_callback = mad_recv_callback;
+ p_bind->send_err_callback = send_err_callback;
+ p_bind->p_osm_pool = p_mad_pool;
+ p_bind->hca_hndl = hca_hndl;
+
+ /*
+ * Create the MAD filter on this file handle.
+ */
+ filter.port = port_num;
+
+ filter.qpn = qpn;
+ filter.mgmt_class = p_user_bind->mad_class;
+ filter.direction = TS_IB_MAD_DIRECTION_IN;
+ filter.mask =
+ TS_IB_MAD_FILTER_DIRECTION |
+ TS_IB_MAD_FILTER_PORT |
+ TS_IB_MAD_FILTER_QPN | TS_IB_MAD_FILTER_MGMT_CLASS;
+
+ ts_ioctl_ret = ioctl(device_fd, TS_IB_IOCSMADFILTADD, &filter);
+ if (ts_ioctl_ret < 0) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_bind: ERR 5014: "
+ "Fail to register MAD filter with err:%u\n",
+ ts_ioctl_ret);
+ goto Exit;
+ }
+
+ /* Initialize the listener thread for this port */
+ status = cl_thread_init(&p_bind->poller,
+ __osm_vendor_ts_poller, p_bind,
+ "osm ts poller");
+ if (status != IB_SUCCESS)
+ goto Exit;
+
+ Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return ((osm_bind_handle_t) p_bind);
}
/**********************************************************************
Get a mad from the lower level.
The osm_vend_wrap_t is a wrapper used to connect the mad to the response.
**********************************************************************/
-ib_mad_t *
-osm_vendor_get( IN osm_bind_handle_t h_bind,
- IN const uint32_t mad_size,
- IN osm_vend_wrap_t * const p_vw )
+ib_mad_t *osm_vendor_get(IN osm_bind_handle_t h_bind,
+ IN const uint32_t mad_size,
+ IN osm_vend_wrap_t * const p_vw)
{
- ib_mad_t *p_mad;
- osm_ts_bind_info_t *p_bind = ( osm_ts_bind_info_t * ) h_bind;
- osm_vendor_t *p_vend = p_bind->p_vend;
-
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_get );
-
- CL_ASSERT( p_vw );
-
- p_vw->size = mad_size;
-
- /* allocate it */
- p_mad = ( ib_mad_t * ) malloc( p_vw->size );
- if( p_mad == NULL )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_get: ERR 5022: "
- "Error Obtaining MAD buffer.\n" );
- goto Exit;
- }
-
- memset( p_mad, 0, p_vw->size );
-
- /* track locally */
- p_vw->p_mad_buf = p_mad;
- p_vw->h_bind = h_bind;
- p_vw->p_resp_madw = NULL;
-
- if( osm_log_get_level( p_vend->p_log ) >= OSM_LOG_DEBUG )
- {
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_get: "
- "Acquired MAD %p, size = %u.\n", p_mad, p_vw->size );
- }
-
- Exit:
- OSM_LOG_EXIT( p_vend->p_log );
- return ( p_mad );
+ ib_mad_t *p_mad;
+ osm_ts_bind_info_t *p_bind = (osm_ts_bind_info_t *) h_bind;
+ osm_vendor_t *p_vend = p_bind->p_vend;
+
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_get);
+
+ CL_ASSERT(p_vw);
+
+ p_vw->size = mad_size;
+
+ /* allocate it */
+ p_mad = (ib_mad_t *) malloc(p_vw->size);
+ if (p_mad == NULL) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_get: ERR 5022: "
+ "Error Obtaining MAD buffer.\n");
+ goto Exit;
+ }
+
+ memset(p_mad, 0, p_vw->size);
+
+ /* track locally */
+ p_vw->p_mad_buf = p_mad;
+ p_vw->h_bind = h_bind;
+ p_vw->p_resp_madw = NULL;
+
+ if (osm_log_get_level(p_vend->p_log) >= OSM_LOG_DEBUG) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_get: "
+ "Acquired MAD %p, size = %u.\n", p_mad, p_vw->size);
+ }
+
+ Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (p_mad);
}
/**********************************************************************
* Return a MAD by providing it's wrapper object.
**********************************************************************/
void
-osm_vendor_put(
- IN osm_bind_handle_t h_bind,
- IN osm_vend_wrap_t * const p_vw )
+osm_vendor_put(IN osm_bind_handle_t h_bind, IN osm_vend_wrap_t * const p_vw)
{
- osm_ts_bind_info_t *p_bind = ( osm_ts_bind_info_t * ) h_bind;
- osm_vendor_t *p_vend = p_bind->p_vend;
- osm_madw_t *p_madw;
+ osm_ts_bind_info_t *p_bind = (osm_ts_bind_info_t *) h_bind;
+ osm_vendor_t *p_vend = p_bind->p_vend;
+ osm_madw_t *p_madw;
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_put );
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_put);
- CL_ASSERT( p_vw );
- CL_ASSERT( p_vw->p_mad_buf );
+ CL_ASSERT(p_vw);
+ CL_ASSERT(p_vw->p_mad_buf);
- if( osm_log_get_level( p_vend->p_log ) >= OSM_LOG_DEBUG )
- {
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_put: " "Retiring MAD %p.\n", p_vw->p_mad_buf );
- }
+ if (osm_log_get_level(p_vend->p_log) >= OSM_LOG_DEBUG) {
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_put: " "Retiring MAD %p.\n",
+ p_vw->p_mad_buf);
+ }
- /*
- * We moved the removal of the transaction to immediatly after
- * it was looked up.
- */
+ /*
+ * We moved the removal of the transaction to immediatly after
+ * it was looked up.
+ */
- /* free the mad but the wrapper is part of the madw object */
- free( p_vw->p_mad_buf );
- p_vw->p_mad_buf = NULL;
- p_madw = PARENT_STRUCT( p_vw, osm_madw_t, vend_wrap);
- p_madw->p_mad = NULL;
+ /* free the mad but the wrapper is part of the madw object */
+ free(p_vw->p_mad_buf);
+ p_vw->p_mad_buf = NULL;
+ p_madw = PARENT_STRUCT(p_vw, osm_madw_t, vend_wrap);
+ p_madw->p_mad = NULL;
- OSM_LOG_EXIT( p_vend->p_log );
+ OSM_LOG_EXIT(p_vend->p_log);
}
/**********************************************************************
@@ -791,72 +733,62 @@ This is for internal use by osm_vendor_send and the transaction mgr
retry too.
**********************************************************************/
ib_api_status_t
-osm_ts_send_mad(
- IN osm_ts_bind_info_t *p_bind,
- IN osm_madw_t * const p_madw)
+osm_ts_send_mad(IN osm_ts_bind_info_t * p_bind, IN osm_madw_t * const p_madw)
{
- osm_vendor_t *const p_vend = p_bind->p_vend;
- osm_mad_addr_t *const p_mad_addr = osm_madw_get_mad_addr_ptr( p_madw );
- ib_mad_t *const p_mad = osm_madw_get_mad_ptr( p_madw );
- struct ib_mad ts_mad;
- int ret;
- ib_api_status_t status;
-
- OSM_LOG_ENTER( p_vend->p_log, osm_ts_send_mad );
-
- /*
- * Copy the MAD over to the sent mad
- */
- memcpy(&ts_mad, p_mad, 256);
-
- /*
- * For all sends other than directed route SM MADs,
- * acquire an address vector for the destination.
- */
- if( p_mad->mgmt_class != IB_MCLASS_SUBN_DIR )
- {
- __osm_ts_conv_osm_addr_to_ts_addr(
- p_mad_addr,
- p_mad->mgmt_class == IB_MCLASS_SUBN_LID,
- &ts_mad);
- }
- else
- {
- /* is a directed route - we need to construct a permissive address */
- /* we do not need port number since it is part of the mad_hndl */
- ts_mad.dlid = IB_LID_PERMISSIVE;
- ts_mad.slid = IB_LID_PERMISSIVE;
- }
- if( (p_mad->mgmt_class == IB_MCLASS_SUBN_DIR ) ||
- (p_mad->mgmt_class == IB_MCLASS_SUBN_LID ) )
- {
- ts_mad.sqpn = 0;
- ts_mad.dqpn = 0;
- }
- else
- {
- ts_mad.sqpn = 1;
- ts_mad.dqpn = 1;
- }
- ts_mad.port = p_bind->port_num;
-
- /* send it */
- ret = write(p_bind->ul_dev_fd, &ts_mad, sizeof(ts_mad));
-
- if( ret != sizeof(ts_mad) )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_ts_send_mad: ERR 5026: "
- "Error sending mad (%d).\n", ret );
- status = IB_ERROR;
- goto Exit;
- }
-
- status = IB_SUCCESS;
-
- Exit:
- OSM_LOG_EXIT( p_vend->p_log );
- return(status);
+ osm_vendor_t *const p_vend = p_bind->p_vend;
+ osm_mad_addr_t *const p_mad_addr = osm_madw_get_mad_addr_ptr(p_madw);
+ ib_mad_t *const p_mad = osm_madw_get_mad_ptr(p_madw);
+ struct ib_mad ts_mad;
+ int ret;
+ ib_api_status_t status;
+
+ OSM_LOG_ENTER(p_vend->p_log, osm_ts_send_mad);
+
+ /*
+ * Copy the MAD over to the sent mad
+ */
+ memcpy(&ts_mad, p_mad, 256);
+
+ /*
+ * For all sends other than directed route SM MADs,
+ * acquire an address vector for the destination.
+ */
+ if (p_mad->mgmt_class != IB_MCLASS_SUBN_DIR) {
+ __osm_ts_conv_osm_addr_to_ts_addr(p_mad_addr,
+ p_mad->mgmt_class ==
+ IB_MCLASS_SUBN_LID, &ts_mad);
+ } else {
+ /* is a directed route - we need to construct a permissive address */
+ /* we do not need port number since it is part of the mad_hndl */
+ ts_mad.dlid = IB_LID_PERMISSIVE;
+ ts_mad.slid = IB_LID_PERMISSIVE;
+ }
+ if ((p_mad->mgmt_class == IB_MCLASS_SUBN_DIR) ||
+ (p_mad->mgmt_class == IB_MCLASS_SUBN_LID)) {
+ ts_mad.sqpn = 0;
+ ts_mad.dqpn = 0;
+ } else {
+ ts_mad.sqpn = 1;
+ ts_mad.dqpn = 1;
+ }
+ ts_mad.port = p_bind->port_num;
+
+ /* send it */
+ ret = write(p_bind->ul_dev_fd, &ts_mad, sizeof(ts_mad));
+
+ if (ret != sizeof(ts_mad)) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_ts_send_mad: ERR 5026: "
+ "Error sending mad (%d).\n", ret);
+ status = IB_ERROR;
+ goto Exit;
+ }
+
+ status = IB_SUCCESS;
+
+ Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
}
/**********************************************************************
@@ -866,127 +798,114 @@ What is unclear to me is the need for the setting of all the MAD Wrapper
fields. Seems like the OSM uses these values during it's processing...
**********************************************************************/
ib_api_status_t
-osm_vendor_send( IN osm_bind_handle_t h_bind,
- IN osm_madw_t * const p_madw,
- IN boolean_t const resp_expected )
+osm_vendor_send(IN osm_bind_handle_t h_bind,
+ IN osm_madw_t * const p_madw, IN boolean_t const resp_expected)
{
- osm_ts_bind_info_t *p_bind = ( osm_ts_bind_info_t * ) h_bind;
- osm_vendor_t *const p_vend = p_bind->p_vend;
- osm_vend_wrap_t *const p_vw = osm_madw_get_vend_ptr( p_madw );
- ib_api_status_t status;
-
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_send );
-
- /*
- * If a response is expected to this MAD, then preallocate
- * a mad wrapper to contain the wire MAD received in the
- * response. Allocating a wrapper here allows for easier
- * failure paths than after we already received the wire mad.
- */
- if( resp_expected == TRUE )
- {
- /* we track it in the vendor wrapper */
- p_vw->p_resp_madw =
- osm_mad_pool_get_wrapper_raw( p_bind->p_osm_pool );
- if( p_vw->p_resp_madw == NULL )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_send: ERR 5024: "
- "Unable to allocate MAD wrapper.\n" );
- status = IB_INSUFFICIENT_RESOURCES;
- goto Exit;
- }
-
- /* put some minimal info on that wrapper */
- ((osm_madw_t *)(p_vw->p_resp_madw))->h_bind = h_bind;
-
- /* we also want to track it in the TID based map */
- status = osm_transaction_mgr_insert_madw(
- (osm_bind_handle_t *)p_bind, p_madw );
- if( status != IB_SUCCESS )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_send: ERR 5025: "
- "Error inserting request madw by TID (%d).\n", status );
- }
- }
- else
- p_vw->p_resp_madw = NULL;
-
- /* do the actual send */
- /* HACK: to be replaced by call to RMPP Segmentation */
- status = osm_ts_send_mad(p_bind, p_madw);
-
- /* we do not get an asycn callback so call it ourselves */
- /* this will handle all cleanup if neccessary */
- __osm_ts_send_callback(p_bind, !resp_expected, p_madw, status);
-
- Exit:
- OSM_LOG_EXIT( p_vend->p_log );
- return ( status );
+ osm_ts_bind_info_t *p_bind = (osm_ts_bind_info_t *) h_bind;
+ osm_vendor_t *const p_vend = p_bind->p_vend;
+ osm_vend_wrap_t *const p_vw = osm_madw_get_vend_ptr(p_madw);
+ ib_api_status_t status;
+
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_send);
+
+ /*
+ * If a response is expected to this MAD, then preallocate
+ * a mad wrapper to contain the wire MAD received in the
+ * response. Allocating a wrapper here allows for easier
+ * failure paths than after we already received the wire mad.
+ */
+ if (resp_expected == TRUE) {
+ /* we track it in the vendor wrapper */
+ p_vw->p_resp_madw =
+ osm_mad_pool_get_wrapper_raw(p_bind->p_osm_pool);
+ if (p_vw->p_resp_madw == NULL) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_send: ERR 5024: "
+ "Unable to allocate MAD wrapper.\n");
+ status = IB_INSUFFICIENT_RESOURCES;
+ goto Exit;
+ }
+
+ /* put some minimal info on that wrapper */
+ ((osm_madw_t *) (p_vw->p_resp_madw))->h_bind = h_bind;
+
+ /* we also want to track it in the TID based map */
+ status = osm_transaction_mgr_insert_madw((osm_bind_handle_t *)
+ p_bind, p_madw);
+ if (status != IB_SUCCESS) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_send: ERR 5025: "
+ "Error inserting request madw by TID (%d).\n",
+ status);
+ }
+ } else
+ p_vw->p_resp_madw = NULL;
+
+ /* do the actual send */
+ /* HACK: to be replaced by call to RMPP Segmentation */
+ status = osm_ts_send_mad(p_bind, p_madw);
+
+ /* we do not get an asycn callback so call it ourselves */
+ /* this will handle all cleanup if neccessary */
+ __osm_ts_send_callback(p_bind, !resp_expected, p_madw, status);
+
+ Exit:
+ OSM_LOG_EXIT(p_vend->p_log);
+ return (status);
}
-
/**********************************************************************
* the idea here is to change the content of the bind such that it
* will hold the local address used for sending directed route by the SMA.
**********************************************************************/
-ib_api_status_t
-osm_vendor_local_lid_change( IN osm_bind_handle_t h_bind )
+ib_api_status_t osm_vendor_local_lid_change(IN osm_bind_handle_t h_bind)
{
- osm_vendor_t *p_vend = ( ( osm_ts_bind_info_t * ) h_bind )->p_vend;
+ osm_vendor_t *p_vend = ((osm_ts_bind_info_t *) h_bind)->p_vend;
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_local_lid_change );
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_local_lid_change);
- osm_log( p_vend->p_log, OSM_LOG_DEBUG,
- "osm_vendor_local_lid_change: DEBUG 2202: " "Change of LID.\n" );
+ osm_log(p_vend->p_log, OSM_LOG_DEBUG,
+ "osm_vendor_local_lid_change: DEBUG 2202: " "Change of LID.\n");
- OSM_LOG_EXIT( p_vend->p_log );
+ OSM_LOG_EXIT(p_vend->p_log);
- return ( IB_SUCCESS );
+ return (IB_SUCCESS);
}
/**********************************************************************
**********************************************************************/
-void
-osm_vendor_set_sm(
- IN osm_bind_handle_t h_bind,
- IN boolean_t is_sm_val )
+void osm_vendor_set_sm(IN osm_bind_handle_t h_bind, IN boolean_t is_sm_val)
{
- osm_ts_bind_info_t *p_bind = ( osm_ts_bind_info_t * ) h_bind;
- osm_vendor_t *p_vend = p_bind->p_vend;
- VAPI_ret_t status;
- VAPI_hca_attr_t attr_mod;
- VAPI_hca_attr_mask_t attr_mask;
-
- OSM_LOG_ENTER( p_vend->p_log, osm_vendor_set_sm );
-
- memset( &attr_mod, 0, sizeof( attr_mod ) );
- memset( &attr_mask, 0, sizeof( attr_mask ) );
-
- attr_mod.is_sm = is_sm_val;
- attr_mask = HCA_ATTR_IS_SM;
-
- status =
- VAPI_modify_hca_attr( p_bind->hca_hndl, p_bind->port_num, &attr_mod,
- &attr_mask );
- if( status != VAPI_OK )
- {
- osm_log( p_vend->p_log, OSM_LOG_ERROR,
- "osm_vendor_set_sm: ERR 5027: "
- "Unable set 'IS_SM' bit to:%u in port attributes (%d).\n",
- is_sm_val, status );
- }
-
- OSM_LOG_EXIT( p_vend->p_log );
+ osm_ts_bind_info_t *p_bind = (osm_ts_bind_info_t *) h_bind;
+ osm_vendor_t *p_vend = p_bind->p_vend;
+ VAPI_ret_t status;
+ VAPI_hca_attr_t attr_mod;
+ VAPI_hca_attr_mask_t attr_mask;
+
+ OSM_LOG_ENTER(p_vend->p_log, osm_vendor_set_sm);
+
+ memset(&attr_mod, 0, sizeof(attr_mod));
+ memset(&attr_mask, 0, sizeof(attr_mask));
+
+ attr_mod.is_sm = is_sm_val;
+ attr_mask = HCA_ATTR_IS_SM;
+
+ status =
+ VAPI_modify_hca_attr(p_bind->hca_hndl, p_bind->port_num, &attr_mod,
+ &attr_mask);
+ if (status != VAPI_OK) {
+ osm_log(p_vend->p_log, OSM_LOG_ERROR,
+ "osm_vendor_set_sm: ERR 5027: "
+ "Unable set 'IS_SM' bit to:%u in port attributes (%d).\n",
+ is_sm_val, status);
+ }
+
+ OSM_LOG_EXIT(p_vend->p_log);
}
/**********************************************************************
**********************************************************************/
-void
-osm_vendor_set_debug(
- IN osm_vendor_t* const p_vend,
- IN int32_t level )
+void osm_vendor_set_debug(IN osm_vendor_t * const p_vend, IN int32_t level)
{
}
diff --git a/opensm/libvendor/osm_vendor_umadt.c b/opensm/libvendor/osm_vendor_umadt.c
index 6458b8d..fd643fa 100644
--- a/opensm/libvendor/osm_vendor_umadt.c
+++ b/opensm/libvendor/osm_vendor_umadt.c
@@ -33,7 +33,6 @@
*
*/
-
/*
* Abstract:
* Implementation of osm_req_t.
@@ -52,7 +51,7 @@
#if HAVE_CONFIG_H
# include <config.h>
-#endif /* HAVE_CONFIG_H */
+#endif /* HAVE_CONFIG_H */
#include <vendor/osm_vendor_select.h>
@@ -96,655 +95,634 @@
/* //////////////////// */
/* Globals // */
/* //////////////////// */
-typedef struct _ib_sa_mad_vM3
-{
- uint8_t base_ver;
- uint8_t mgmt_class;
- uint8_t class_ver;
- uint8_t method;
- ib_net16_t status;
- ib_net16_t resv;
- ib_net64_t trans_id;
- ib_net16_t attr_id;
- ib_net16_t resv1;
- ib_net32_t attr_mod;
- ib_net64_t resv2;
- ib_net64_t sm_key;
-
-
+typedef struct _ib_sa_mad_vM3 {
+ uint8_t base_ver;
+ uint8_t mgmt_class;
+ uint8_t class_ver;
+ uint8_t method;
+ ib_net16_t status;
+ ib_net16_t resv;
+ ib_net64_t trans_id;
+ ib_net16_t attr_id;
+ ib_net16_t resv1;
+ ib_net32_t attr_mod;
+ ib_net64_t resv2;
+ ib_net64_t sm_key;
+
+ ib_net32_t seg_num;
+ ib_net32_t payload_len;
+ uint8_t frag_flag;
+ uint8_t edit_mod;
+ ib_net16_t window;
+ ib_net16_t attr_offset;
+ ib_net16_t resv3;
+
+ ib_net64_t comp_mask;
+
+ uint8_t data[IB_SA_DATA_SIZE];
+} ib_sa_mad_t_vM3;
+#define DEFAULT_TIMER_INTERVAL_MSEC 500 /* 500msec timer interval */
+void __mad_recv_processor(void *context);
- ib_net32_t seg_num;
- ib_net32_t payload_len;
- uint8_t frag_flag;
- uint8_t edit_mod;
- ib_net16_t window;
- ib_net16_t attr_offset;
- ib_net16_t resv3;
+boolean_t __valid_mad_handle(IN mad_bind_info_t * p_mad_bind_info);
- ib_net64_t comp_mask;
+cl_status_t
+__match_tid_context(const cl_list_item_t * const p_list_item, void *context);
+void __osm_vendor_timer_callback(IN void *context);
- uint8_t data[IB_SA_DATA_SIZE];
-} ib_sa_mad_t_vM3;
-#define DEFAULT_TIMER_INTERVAL_MSEC 500 /* 500msec timer interval */
+osm_vendor_t *osm_vendor_new(IN osm_log_t * const p_log,
+ IN const uint32_t timeout)
+{
+ ib_api_status_t status;
+ umadt_obj_t *p_umadt_obj;
-void
-__mad_recv_processor( void* context);
+ OSM_LOG_ENTER(p_log, osm_vendor_new);
-boolean_t
-__valid_mad_handle( IN mad_bind_info_t *p_mad_bind_info);
+ p_umadt_obj = malloc(sizeof(umadt_obj_t));
+ if (p_umadt_obj) {
+ memset(p_umadt_obj, 0, sizeof(umadt_obj_t));
-cl_status_t
-__match_tid_context( const cl_list_item_t* const p_list_item,
- void* context);
-void
-__osm_vendor_timer_callback(
- IN void* context );
+ status = osm_vendor_init((osm_vendor_t *) p_umadt_obj, p_log,
+ timeout);
+ if (status != IB_SUCCESS) {
+ osm_vendor_delete((osm_vendor_t **) & p_umadt_obj);
+ }
+ } else {
+ printf
+ ("osm_vendor_construct: ERROR! Unable to create Umadt object!\n");
+ }
+ OSM_LOG_EXIT(p_log);
-osm_vendor_t*
-osm_vendor_new(
- IN osm_log_t* const p_log,
- IN const uint32_t timeout )
-{
- ib_api_status_t status;
- umadt_obj_t* p_umadt_obj;
-
- OSM_LOG_ENTER( p_log, osm_vendor_new );
-
- p_umadt_obj = malloc(sizeof(umadt_obj_t));
- if( p_umadt_obj )
- {
- memset( p_umadt_obj, 0, sizeof(umadt_obj_t) );
-
- status = osm_vendor_init( (osm_vendor_t*)p_umadt_obj, p_log,
- timeout );
- if( status != IB_SUCCESS )
- {
- osm_vendor_delete( (osm_vendor_t**)&p_umadt_obj );
- }
- }
- else
- {
- printf("osm_vendor_construct: ERROR! Unable to create Umadt object!\n");
- }
-
- OSM_LOG_EXIT( p_log );
-
- return( (osm_vendor_t*)p_umadt_obj );
+ return ((osm_vendor_t *) p_umadt_obj);
}
-void
-osm_vendor_delete(
- IN osm_vendor_t** const pp_vend )
+void osm_vendor_delete(IN osm_vendor_t ** const pp_vend)
{
- umadt_obj_t *p_umadt_obj = (umadt_obj_t*)*pp_vend;
- cl_list_item_t* p_list_item;
- uint32_t count,i;
- mad_bind_info_t *p_mad_bind_info;
-
- OSM_LOG_ENTER( p_umadt_obj->p_log, osm_vendor_delete );
-
- cl_spinlock_acquire(&p_umadt_obj->register_lock);
- p_mad_bind_info = (mad_bind_info_t*)cl_qlist_head(
- &p_umadt_obj->register_list);
- count = cl_qlist_count(&p_umadt_obj->register_list);
- cl_spinlock_release(&p_umadt_obj->register_lock);
- for (i=0;i < count;i++)
- {
- cl_spinlock_acquire(&p_umadt_obj->register_lock);
- p_list_item = cl_qlist_next(&p_mad_bind_info->list_item);
- cl_spinlock_release(&p_umadt_obj->register_lock);
- /* Unbind this handle */
- /* osm_vendor_ubind also removesd the item from the list */
- /* osm_vendor_unbind takes the list lock so release it here */
- osm_vendor_unbind((osm_bind_handle_t)p_mad_bind_info);
- p_mad_bind_info = (mad_bind_info_t*)p_list_item;
- }
- dlclose(p_umadt_obj->umadt_handle);
- free(p_umadt_obj);
- *pp_vend = NULL;
-
- OSM_LOG_EXIT( p_umadt_obj->p_log );
+ umadt_obj_t *p_umadt_obj = (umadt_obj_t *) * pp_vend;
+ cl_list_item_t *p_list_item;
+ uint32_t count, i;
+ mad_bind_info_t *p_mad_bind_info;
+
+ OSM_LOG_ENTER(p_umadt_obj->p_log, osm_vendor_delete);
+
+ cl_spinlock_acquire(&p_umadt_obj->register_lock);
+ p_mad_bind_info =
+ (mad_bind_info_t *) cl_qlist_head(&p_umadt_obj->register_list);
+ count = cl_qlist_count(&p_umadt_obj->register_list);
+ cl_spinlock_release(&p_umadt_obj->register_lock);
+ for (i = 0; i < count; i++) {
+ cl_spinlock_acquire(&p_umadt_obj->register_lock);
+ p_list_item = cl_qlist_next(&p_mad_bind_info->list_item);
+ cl_spinlock_release(&p_umadt_obj->register_lock);
+ /* Unbind this handle */
+ /* osm_vendor_ubind also removesd the item from the list */
+ /* osm_vendor_unbind takes the list lock so release it here */
+ osm_vendor_unbind((osm_bind_handle_t) p_mad_bind_info);
+ p_mad_bind_info = (mad_bind_info_t *) p_list_item;
+ }
+ dlclose(p_umadt_obj->umadt_handle);
+ free(p_umadt_obj);
+ *pp_vend = NULL;
+
+ OSM_LOG_EXIT(p_umadt_obj->p_log);
}
-
/* //////////////////////////////////////////////////////////////////////// */
/* See VendorAbstractMadIntf.h for info */
/* //////////////////////////////////////////////////////////////////////// */
/* */
ib_api_status_t
-osm_vendor_init(
- IN osm_vendor_t* const p_vend,
- IN osm_log_t* const p_log,
- IN const uint32_t timeout )
+osm_vendor_init(IN osm_vendor_t * const p_vend,
+ IN osm_log_t * const p_log, IN const uint32_t timeout)
{
- FSTATUS Status;
- PUMADT_GET_INTERFACE uMadtGetInterface;
- char* error;
- umadt_obj_t *p_umadt_obj = (umadt_obj_t*)p_vend;
-
- OSM_LOG_ENTER( p_log, osm_vendor_init );
-
- p_umadt_obj->p_log = p_log;
- p_umadt_obj->timeout = timeout;
-
- p_umadt_obj->umadt_handle = dlopen("libibt.so", RTLD_NOW);
-
- if(!p_umadt_obj->umadt_handle)
- {
- printf("Could not load libibt.so <%s>\n", dlerror());
- return IB_ERROR;
- }
- uMadtGetInterface = dlsym(p_umadt_obj->umadt_handle, "uMadtGetInterface");
- if ((error = dlerror()) != NULL)
- {
- printf("Could not resolve symbol uMadtGetInterface ERROR<%s>\n", error);
- return IB_ERROR;
- }
-
- Status = (*uMadtGetInterface)(&p_umadt_obj->uMadtInterface);
- if ( Status != FSUCCESS)
- {
- printf(" Error in getting uMADT interface ERROR<%d>\n",Status);
- return IB_ERROR;
- }
-
- /* Initialize the register list and register list lock */
- cl_qlist_init(&p_umadt_obj->register_list);
-
- cl_spinlock_construct(&p_umadt_obj->register_lock);
- CL_ASSERT(cl_spinlock_init(&p_umadt_obj->register_lock) == CL_SUCCESS);
- p_umadt_obj->init_done = TRUE;
- printf("*****SUCCESS*****\n");
-
- OSM_LOG_EXIT( p_log );
- return IB_SUCCESS;
+ FSTATUS Status;
+ PUMADT_GET_INTERFACE uMadtGetInterface;
+ char *error;
+ umadt_obj_t *p_umadt_obj = (umadt_obj_t *) p_vend;
+
+ OSM_LOG_ENTER(p_log, osm_vendor_init);
+
+ p_umadt_obj->p_log = p_log;
+ p_umadt_obj->timeout = timeout;
+
+ p_umadt_obj->umadt_handle = dlopen("libibt.so", RTLD_NOW);
+
+ if (!p_umadt_obj->umadt_handle) {
+ printf("Could not load libibt.so <%s>\n", dlerror());
+ return IB_ERROR;
+ }
+ uMadtGetInterface =
+ dlsym(p_umadt_obj->umadt_handle, "uMadtGetInterface");
+ if ((error = dlerror()) != NULL) {
+ printf("Could not resolve symbol uMadtGetInterface ERROR<%s>\n",
+ error);
+ return IB_ERROR;
+ }
+
+ Status = (*uMadtGetInterface) (&p_umadt_obj->uMadtInterface);
+ if (Status != FSUCCESS) {
+ printf(" Error in getting uMADT interface ERROR<%d>\n", Status);
+ return IB_ERROR;
+ }
+
+ /* Initialize the register list and register list lock */
+ cl_qlist_init(&p_umadt_obj->register_list);
+
+ cl_spinlock_construct(&p_umadt_obj->register_lock);
+ CL_ASSERT(cl_spinlock_init(&p_umadt_obj->register_lock) == CL_SUCCESS);
+ p_umadt_obj->init_done = TRUE;
+ printf("*****SUCCESS*****\n");
+
+ OSM_LOG_EXIT(p_log);
+ return IB_SUCCESS;
}
+
/* //////////////////////////////////////////////////////////////////////// */
/* See VendorAbstractMadIntf.h for info */
/* //////////////////////////////////////////////////////////////////////// */
ib_api_status_t
-osm_vendor_get_ports(
- IN osm_vendor_t* const p_vend,
- IN ib_net64_t* const p_guids,
- IN uint32_t* const p_num_guids )
+osm_vendor_get_ports(IN osm_vendor_t * const p_vend,
+ IN ib_net64_t * const p_guids,
+ IN uint32_t * const p_num_guids)
{
- char* error = NULL;
- PIBT_GET_INTERFACE pfnIbtGetInterface;
- PIBT_INIT pfnIbtInitFunc;
-
- FSTATUS Status;
- uint32_t caCount, caGuidCount;
- IB_CA_ATTRIBUTES caAttributes;
- IB_HANDLE caHandle;
- uint32_t i;
- IB_PORT_ATTRIBUTES *pPortAttributesList;
- EUI64 CaGuidArray[8];
- void *context;
- uint64_t* p_port_guid;
- uint32_t free_guids;
-
- umadt_obj_t *p_umadt_obj = (umadt_obj_t*)p_vend;
-
- OSM_LOG_ENTER( p_umadt_obj->p_log, osm_vendor_get_ports );
-
- CL_ASSERT(p_guids);
- CL_ASSERT(p_num_guids);
-
- pfnIbtInitFunc = ( PIBT_INIT ) dlsym ( p_umadt_obj->umadt_handle, "IbtInit" );
-
- if ( !pfnIbtInitFunc )
- {
- printf ( "Error getting IbtInit function address.\n" );
- return IB_ERROR;
- }
-
- ( *pfnIbtInitFunc ) ( );
-
- pfnIbtGetInterface = ( PIBT_GET_INTERFACE ) dlsym ( p_umadt_obj->umadt_handle,
- "IbtGetInterface" );
-
- if ( !pfnIbtGetInterface || (error = dlerror()) != NULL)
- {
- printf( "Error getting IbtGetInterface function address.<%s>\n", error);
- return FALSE;
- }
- ( *pfnIbtGetInterface ) ( &p_umadt_obj->IbtInterface );
-
- caGuidCount = 8;
- Status = p_umadt_obj->IbtInterface.GetCaGuidArray ( &caGuidCount, &CaGuidArray[0] );
-
- if ( ( Status != FSUCCESS ) || ( caGuidCount == 0 ) )
- {
- return FALSE;
- }
-
- free_guids = *p_num_guids;
- p_port_guid = p_guids;
-
- /* query each ca & copy its info into callers buffer */
- for ( caCount = 0; caCount < caGuidCount; caCount++ )
- {
- memset ( &caAttributes, 0, sizeof ( IB_CA_ATTRIBUTES ) );
-
- /* Open the CA */
- Status = p_umadt_obj->IbtInterface.Vpi.OpenCA ( CaGuidArray[caCount], NULL, /* CACompletionCallback */
- NULL, /* AsyncEventCallback */
- NULL, &caHandle );
- if ( Status != FSUCCESS )
- {
- return IB_ERROR;
- }
-
- Status = p_umadt_obj->IbtInterface.Vpi.QueryCA ( caHandle,
- &caAttributes, &context );
-
- if ( Status != FSUCCESS )
- {
- p_umadt_obj->IbtInterface.Vpi.CloseCA ( caHandle );
- return IB_ERROR;
- }
-
- if ( caAttributes.Ports > free_guids)
- {
- *p_num_guids = 0;
- memset (p_guids, 0, (*p_num_guids)*sizeof(uint64_t));
- return IB_INSUFFICIENT_MEMORY;
- }
-
- pPortAttributesList =
- ( IB_PORT_ATTRIBUTES * ) malloc ( caAttributes.
- PortAttributesListSize );
-
- if ( pPortAttributesList == NULL )
- {
- p_umadt_obj->IbtInterface.Vpi.CloseCA ( caHandle );
- *p_num_guids = 0;
- memset (p_guids, 0, (*p_num_guids)*sizeof(uint64_t));
- return IB_INSUFFICIENT_MEMORY;
- }
-
- memset ( pPortAttributesList, 0,
- caAttributes.PortAttributesListSize );
-
- caAttributes.PortAttributesList = pPortAttributesList;
-
- Status = p_umadt_obj->IbtInterface.Vpi.QueryCA ( caHandle,
- &caAttributes, &context );
-
- if ( Status != FSUCCESS )
- {
- p_umadt_obj->IbtInterface.Vpi.CloseCA ( caHandle );
- *p_num_guids = 0;
- memset (p_guids, 0, (*p_num_guids)*sizeof(uint64_t));
- return IB_ERROR;
- }
-
- pPortAttributesList = caAttributes.PortAttributesList;
-
- for ( i = 0; i < caAttributes.Ports; i++ )
- {
- *(p_port_guid) = cl_hton64(( uint64_t)pPortAttributesList->GUID);
- pPortAttributesList = pPortAttributesList->Next;
- p_port_guid++;
- }
- free (caAttributes.PortAttributesList);
- p_umadt_obj->IbtInterface.Vpi.CloseCA ( caHandle );
-
- free_guids = free_guids - caAttributes.Ports ;
-
- }
- *p_num_guids = *p_num_guids - free_guids;
- return IB_SUCCESS;
+ char *error = NULL;
+ PIBT_GET_INTERFACE pfnIbtGetInterface;
+ PIBT_INIT pfnIbtInitFunc;
+
+ FSTATUS Status;
+ uint32_t caCount, caGuidCount;
+ IB_CA_ATTRIBUTES caAttributes;
+ IB_HANDLE caHandle;
+ uint32_t i;
+ IB_PORT_ATTRIBUTES *pPortAttributesList;
+ EUI64 CaGuidArray[8];
+ void *context;
+ uint64_t *p_port_guid;
+ uint32_t free_guids;
+
+ umadt_obj_t *p_umadt_obj = (umadt_obj_t *) p_vend;
+
+ OSM_LOG_ENTER(p_umadt_obj->p_log, osm_vendor_get_ports);
+
+ CL_ASSERT(p_guids);
+ CL_ASSERT(p_num_guids);
+
+ pfnIbtInitFunc =
+ (PIBT_INIT) dlsym(p_umadt_obj->umadt_handle, "IbtInit");
+
+ if (!pfnIbtInitFunc) {
+ printf("Error getting IbtInit function address.\n");
+ return IB_ERROR;
+ }
+
+ (*pfnIbtInitFunc) ();
+
+ pfnIbtGetInterface =
+ (PIBT_GET_INTERFACE) dlsym(p_umadt_obj->umadt_handle,
+ "IbtGetInterface");
+
+ if (!pfnIbtGetInterface || (error = dlerror()) != NULL) {
+ printf("Error getting IbtGetInterface function address.<%s>\n",
+ error);
+ return FALSE;
+ }
+ (*pfnIbtGetInterface) (&p_umadt_obj->IbtInterface);
+
+ caGuidCount = 8;
+ Status =
+ p_umadt_obj->IbtInterface.GetCaGuidArray(&caGuidCount,
+ &CaGuidArray[0]);
+
+ if ((Status != FSUCCESS) || (caGuidCount == 0)) {
+ return FALSE;
+ }
+
+ free_guids = *p_num_guids;
+ p_port_guid = p_guids;
+
+ /* query each ca & copy its info into callers buffer */
+ for (caCount = 0; caCount < caGuidCount; caCount++) {
+ memset(&caAttributes, 0, sizeof(IB_CA_ATTRIBUTES));
+
+ /* Open the CA */
+ Status = p_umadt_obj->IbtInterface.Vpi.OpenCA(CaGuidArray[caCount], NULL, /* CACompletionCallback */
+ NULL, /* AsyncEventCallback */
+ NULL, &caHandle);
+ if (Status != FSUCCESS) {
+ return IB_ERROR;
+ }
+
+ Status = p_umadt_obj->IbtInterface.Vpi.QueryCA(caHandle,
+ &caAttributes,
+ &context);
+
+ if (Status != FSUCCESS) {
+ p_umadt_obj->IbtInterface.Vpi.CloseCA(caHandle);
+ return IB_ERROR;
+ }
+
+ if (caAttributes.Ports > free_guids) {
+ *p_num_guids = 0;
+ memset(p_guids, 0, (*p_num_guids) * sizeof(uint64_t));
+ return IB_INSUFFICIENT_MEMORY;
+ }
+
+ pPortAttributesList =
+ (IB_PORT_ATTRIBUTES *) malloc(caAttributes.
+ PortAttributesListSize);
+
+ if (pPortAttributesList == NULL) {
+ p_umadt_obj->IbtInterface.Vpi.CloseCA(caHandle);
+ *p_num_guids = 0;
+ memset(p_guids, 0, (*p_num_guids) * sizeof(uint64_t));
+ return IB_INSUFFICIENT_MEMORY;
+ }
+
+ memset(pPortAttributesList, 0,
+ caAttributes.PortAttributesListSize);
+
+ caAttributes.PortAttributesList = pPortAttributesList;
+
+ Status = p_umadt_obj->IbtInterface.Vpi.QueryCA(caHandle,
+ &caAttributes,
+ &context);
+
+ if (Status != FSUCCESS) {
+ p_umadt_obj->IbtInterface.Vpi.CloseCA(caHandle);
+ *p_num_guids = 0;
+ memset(p_guids, 0, (*p_num_guids) * sizeof(uint64_t));
+ return IB_ERROR;
+ }
+
+ pPortAttributesList = caAttributes.PortAttributesList;
+
+ for (i = 0; i < caAttributes.Ports; i++) {
+ *(p_port_guid) =
+ cl_hton64((uint64_t) pPortAttributesList->GUID);
+ pPortAttributesList = pPortAttributesList->Next;
+ p_port_guid++;
+ }
+ free(caAttributes.PortAttributesList);
+ p_umadt_obj->IbtInterface.Vpi.CloseCA(caHandle);
+
+ free_guids = free_guids - caAttributes.Ports;
+
+ }
+ *p_num_guids = *p_num_guids - free_guids;
+ return IB_SUCCESS;
}
/* //////////////////////////////////////////////////////////////////////// */
/* See VendorAbstractMadIntf.h for info */
/* //////////////////////////////////////////////////////////////////////// */
-ib_mad_t*
-osm_vendor_get(
- IN osm_bind_handle_t h_bind,
- IN const uint32_t mad_size,
- IN osm_vend_wrap_t *p_vend_wrap )
+ib_mad_t *osm_vendor_get(IN osm_bind_handle_t h_bind,
+ IN const uint32_t mad_size,
+ IN osm_vend_wrap_t * p_vend_wrap)
{
- /* FSTATUS Status; */
- /* uint32_t mad_count = 0; */
- /* MadtStruct *p_madt_struct; */
- mad_bind_info_t *p_mad_bind_info = (mad_bind_info_t*)h_bind;
- umadt_obj_t *p_umadt_obj = p_mad_bind_info->p_umadt_obj;
- ib_mad_t *p_mad;
- OSM_LOG_ENTER( p_umadt_obj->p_log, osm_vendor_get );
+ /* FSTATUS Status; */
+ /* uint32_t mad_count = 0; */
+ /* MadtStruct *p_madt_struct; */
+ mad_bind_info_t *p_mad_bind_info = (mad_bind_info_t *) h_bind;
+ umadt_obj_t *p_umadt_obj = p_mad_bind_info->p_umadt_obj;
+ ib_mad_t *p_mad;
+ OSM_LOG_ENTER(p_umadt_obj->p_log, osm_vendor_get);
- CL_ASSERT(h_bind);
+ CL_ASSERT(h_bind);
- p_umadt_obj = p_mad_bind_info->p_umadt_obj;
-
- /* Sanity check */
- CL_ASSERT(p_umadt_obj->init_done);
- CL_ASSERT(p_vend_wrap);
- CL_ASSERT(__valid_mad_handle(p_mad_bind_info));
+ p_umadt_obj = p_mad_bind_info->p_umadt_obj;
+ /* Sanity check */
+ CL_ASSERT(p_umadt_obj->init_done);
+ CL_ASSERT(p_vend_wrap);
+ CL_ASSERT(__valid_mad_handle(p_mad_bind_info));
#if 0
- mad_count = 1;
- Status = p_umadt_obj->uMadtInterface.uMadtGetSendMad(p_mad_bind_info->umadt_handle,
- &mad_count,
- &p_madt_struct );
-
- if(Status != FSUCCESS || p_madt_struct == NULL)
- {
- p_vend_wrap->p_madt_struct = NULL;
- return NULL;
- }
- p_vend_wrap->p_madt_struct = p_madt_struct;
- p_vend_wrap->direction = SEND;
- return( (ib_mad_t*)&p_madt_struct->IBMad );
-#endif /* 0 */
- p_mad = (ib_mad_t*)malloc( mad_size );
- if ( !p_mad )
- {
- p_vend_wrap->p_madt_struct = NULL;
- return NULL;
- }
-
- memset(p_mad, 0, mad_size);
-
- p_vend_wrap->p_madt_struct = NULL;
- p_vend_wrap->direction = SEND;
- p_vend_wrap->size =mad_size;
- return( p_mad);
+ mad_count = 1;
+ Status =
+ p_umadt_obj->uMadtInterface.uMadtGetSendMad(p_mad_bind_info->
+ umadt_handle,
+ &mad_count,
+ &p_madt_struct);
+
+ if (Status != FSUCCESS || p_madt_struct == NULL) {
+ p_vend_wrap->p_madt_struct = NULL;
+ return NULL;
+ }
+ p_vend_wrap->p_madt_struct = p_madt_struct;
+ p_vend_wrap->direction = SEND;
+ return ((ib_mad_t *) & p_madt_struct->IBMad);
+#endif /* 0 */
+ p_mad = (ib_mad_t *) malloc(mad_size);
+ if (!p_mad) {
+ p_vend_wrap->p_madt_struct = NULL;
+ return NULL;
+ }
+
+ memset(p_mad, 0, mad_size);
+
+ p_vend_wrap->p_madt_struct = NULL;
+ p_vend_wrap->direction = SEND;
+ p_vend_wrap->size = mad_size;
+ return (p_mad);
}
+
/* //////////////////////////////////////////////////////////////////////// */
/* See VendorAbstractMadIntf.h for info */
/* //////////////////////////////////////////////////////////////////////// */
void
-osm_vendor_put(
- IN osm_bind_handle_t h_bind,
- IN osm_vend_wrap_t* const p_vend_wrap,
- IN ib_mad_t* const p_mad)
+osm_vendor_put(IN osm_bind_handle_t h_bind,
+ IN osm_vend_wrap_t * const p_vend_wrap,
+ IN ib_mad_t * const p_mad)
{
- FSTATUS Status;
-
- mad_bind_info_t *p_mad_bind_info;
- umadt_obj_t *p_umadt_obj;
-
- /* */
- /* Validate the vendor mad transport handle */
- /* */
- CL_ASSERT(h_bind);
- p_mad_bind_info = (mad_bind_info_t*)h_bind;
- p_umadt_obj = p_mad_bind_info->p_umadt_obj;
-
- /* sanity check */
- CL_ASSERT(p_umadt_obj->init_done);
- CL_ASSERT(h_bind);
- CL_ASSERT(__valid_mad_handle(p_mad_bind_info));
- CL_ASSERT(p_vend_wrap);
- /* CL_ASSERT( (ib_mad_t*)&p_vend_wrap->p_madt_struct->IBMad == p_mad ); */
-
- /* Release the MAD based on the direction of the MAD */
- if ( p_vend_wrap->direction == SEND)
- {
- /* */
- /* For a send the PostSend released the MAD with Umadt. Simply dealloacte the */
- /* local memory that was allocated on the osm_vendor_get() call. */
- /* */
- free(p_mad);
+ FSTATUS Status;
+
+ mad_bind_info_t *p_mad_bind_info;
+ umadt_obj_t *p_umadt_obj;
+
+ /* */
+ /* Validate the vendor mad transport handle */
+ /* */
+ CL_ASSERT(h_bind);
+ p_mad_bind_info = (mad_bind_info_t *) h_bind;
+ p_umadt_obj = p_mad_bind_info->p_umadt_obj;
+
+ /* sanity check */
+ CL_ASSERT(p_umadt_obj->init_done);
+ CL_ASSERT(h_bind);
+ CL_ASSERT(__valid_mad_handle(p_mad_bind_info));
+ CL_ASSERT(p_vend_wrap);
+ /* CL_ASSERT( (ib_mad_t*)&p_vend_wrap->p_madt_struct->IBMad == p_mad ); */
+
+ /* Release the MAD based on the direction of the MAD */
+ if (p_vend_wrap->direction == SEND) {
+ /* */
+ /* For a send the PostSend released the MAD with Umadt. Simply dealloacte the */
+ /* local memory that was allocated on the osm_vendor_get() call. */
+ /* */
+ free(p_mad);
#if 0
- Status = p_umadt_obj->uMadtInterface.uMadtReleaseSendMad(p_mad_bind_info->umadt_handle,
- p_vend_wrap->p_madt_struct);
- if(Status != FSUCCESS)
- {
- /* printf("uMadtReleaseSendMad: Status = <%d>\n", Status); */
- return ;
- }
+ Status =
+ p_umadt_obj->uMadtInterface.
+ uMadtReleaseSendMad(p_mad_bind_info->umadt_handle,
+ p_vend_wrap->p_madt_struct);
+ if (Status != FSUCCESS) {
+ /* printf("uMadtReleaseSendMad: Status = <%d>\n", Status); */
+ return;
+ }
#endif
- }
- else if (p_vend_wrap->direction == RECEIVE)
- {
- CL_ASSERT( (ib_mad_t*)&p_vend_wrap->p_madt_struct->IBMad == p_mad );
- Status = p_umadt_obj->uMadtInterface.uMadtReleaseRecvMad(p_mad_bind_info->umadt_handle,
- p_vend_wrap->p_madt_struct);
- if(Status != FSUCCESS)
- {
- /* printf("uMadtReleaseRecvMad Status=<%d>\n", Status); */
- return ;
- }
- }
- else{
- return ;
- }
- return ;
+ } else if (p_vend_wrap->direction == RECEIVE) {
+ CL_ASSERT((ib_mad_t *) & p_vend_wrap->p_madt_struct->IBMad ==
+ p_mad);
+ Status =
+ p_umadt_obj->uMadtInterface.
+ uMadtReleaseRecvMad(p_mad_bind_info->umadt_handle,
+ p_vend_wrap->p_madt_struct);
+ if (Status != FSUCCESS) {
+ /* printf("uMadtReleaseRecvMad Status=<%d>\n", Status); */
+ return;
+ }
+ } else {
+ return;
+ }
+ return;
}
+
/* //////////////////////////////////////////////////////////////////////// */
/* See VendorAbstractMadIntf.h for info */
/* //////////////////////////////////////////////////////////////////////// */
ib_api_status_t
-osm_vendor_send(
- IN osm_bind_handle_t h_bind,
- IN osm_vend_wrap_t* const p_vend_wrap,
- IN osm_mad_addr_t* const p_mad_addr,
- IN ib_mad_t* const p_mad,
- IN void* transaction_context,
- IN boolean_t const resp_expected )
+osm_vendor_send(IN osm_bind_handle_t h_bind,
+ IN osm_vend_wrap_t * const p_vend_wrap,
+ IN osm_mad_addr_t * const p_mad_addr,
+ IN ib_mad_t * const p_mad,
+ IN void *transaction_context, IN boolean_t const resp_expected)
{
- FSTATUS Status;
-
- MadAddrStruct destAddr = {0};
-
- mad_bind_info_t *p_mad_bind_info;
- trans_context_t *p_trans_context;
-
- umadt_obj_t *p_umadt_obj=NULL;
-
- uint32_t mad_count = 0;
- MadtStruct *p_madt_struct = NULL;
- uint32_t i;
- uint32_t num_mads=0;
- uint32_t seg_num=0;
- uint8_t *p_frag_data = NULL;
- ib_sa_mad_t_vM3 *p_sa_mad = NULL;
-
-
- CL_ASSERT(h_bind);
- p_mad_bind_info = (mad_bind_info_t*)h_bind;
- p_umadt_obj = p_mad_bind_info->p_umadt_obj;
-
- /* sanity check */
- CL_ASSERT(p_umadt_obj);
- CL_ASSERT(p_umadt_obj->init_done);
- CL_ASSERT(__valid_mad_handle(p_mad_bind_info));
- CL_ASSERT(p_vend_wrap);
- CL_ASSERT(p_mad_addr);
- CL_ASSERT(p_mad);
- /* CL_ASSERT( (ib_mad_t*)&p_vend_wrap->p_madt_struct->IBMad == p_mad ); */
-
- /* */
- /* based on the class, fill out the address info */
- /* */
- destAddr.DestLid = p_mad_addr->dest_lid;
- destAddr.PathBits = p_mad_addr->path_bits;
- destAddr.StaticRate = p_mad_addr->static_rate;
-
- if (p_mad_bind_info->umadt_reg_class.ClassId == IB_MCLASS_SUBN_LID ||
- p_mad_bind_info->umadt_reg_class.ClassId == IB_MCLASS_SUBN_DIR)
- {
- CL_ASSERT(p_mad_addr->addr_type.smi.source_lid);
- destAddr.AddrType.Smi.SourceLid = p_mad_addr->addr_type.smi.source_lid;
- }
- else
- {
- destAddr.AddrType.Gsi.RemoteQpNumber = p_mad_addr->addr_type.gsi.remote_qp;
- destAddr.AddrType.Gsi.RemoteQkey = p_mad_addr->addr_type.gsi.remote_qkey;
- destAddr.AddrType.Gsi.PKey = p_mad_addr->addr_type.gsi.pkey;
- destAddr.AddrType.Gsi.ServiceLevel = p_mad_addr->addr_type.gsi.service_level;
- destAddr.AddrType.Gsi.GlobalRoute = p_mad_addr->addr_type.gsi.global_route;
- /* destAddr.AddrType.Gsi.GRHInfo = p_mad_addr->addr_type.gsi.grh_info; */
- }
- p_mad->trans_id = cl_ntoh64(p_mad->trans_id)<<24;
-
- /* */
- /* Create a transaction context for this send and save the TID and client context. */
- /* */
-
- if ( resp_expected )
- {
- p_trans_context = malloc(sizeof(trans_context_t));
- CL_ASSERT(p_trans_context);
-
- memset(p_trans_context, 0, sizeof(trans_context_t));
- p_trans_context->trans_id = p_mad->trans_id;
- p_trans_context->context = transaction_context;
- p_trans_context->sent_time = cl_get_time_stamp();
-
- cl_spinlock_acquire(&p_mad_bind_info->trans_ctxt_lock);
- cl_qlist_insert_tail(&p_mad_bind_info->trans_ctxt_list,
- &p_trans_context->list_item);
- cl_spinlock_release(&p_mad_bind_info->trans_ctxt_lock);
- }
-
- if (p_mad_bind_info->umadt_reg_class.ClassId == IB_MCLASS_SUBN_LID ||
- p_mad_bind_info->umadt_reg_class.ClassId == IB_MCLASS_SUBN_DIR)
- {
- /* Get one mad from uMadt */
- mad_count = 1;
- Status = p_umadt_obj->uMadtInterface.uMadtGetSendMad(p_mad_bind_info->umadt_handle,
- &mad_count,
- &p_madt_struct );
-
- if(Status != FSUCCESS || p_madt_struct == NULL)
- {
- return IB_ERROR;
- }
-
- /* No Segmentation required */
- memcpy(&p_madt_struct->IBMad, p_mad, MAD_BLOCK_SIZE);
-
- /* Post the MAD */
-
- Status = p_umadt_obj->uMadtInterface.uMadtPostSend(p_mad_bind_info->umadt_handle,
- p_madt_struct,
- &destAddr);
- if(Status != FSUCCESS)
- {
- printf("uMadtPostSendMad: Status = <%d>\n", Status);
- return IB_ERROR;
- }
-
- /* Release send MAD */
- Status = p_umadt_obj->uMadtInterface.uMadtReleaseSendMad(p_mad_bind_info->umadt_handle,
- p_madt_struct);
- if(Status != FSUCCESS)
- {
- printf("uMadtReleaseSendMad: Status = <%d>\n", Status);
- return IB_ERROR;
- }
- }
- else
- {
-
- /* */
- /* Segment the MAD, get the required send mads from uMadt and post the MADs. */
- /* */
- uint32_t payload_len;
-
- payload_len = cl_ntoh32(((ib_sa_mad_t_vM3*)p_mad)->payload_len);
- num_mads = payload_len / IB_SA_DATA_SIZE;
- if ( payload_len % IB_SA_DATA_SIZE != 0)
- {
- num_mads++; /* Get one additional mad for the remainder */
- }
- for ( i = 0; i < num_mads; i++)
- {
- /* Get one mad from uMadt */
- mad_count = 1;
- Status = p_umadt_obj->uMadtInterface.uMadtGetSendMad(p_mad_bind_info->umadt_handle,
- &mad_count,
- &p_madt_struct );
-
- if(Status != FSUCCESS || p_madt_struct == NULL)
- {
- return IB_ERROR;
- }
- /* Copy client MAD into uMadt's MAD. */
- if ( i == 0) /* First Packet */
- {
- /* Since this is the first MAD, copy the entire MAD_SIZE */
- memcpy(&p_madt_struct->IBMad, p_mad, MAD_BLOCK_SIZE);
-
- p_frag_data = (uint8_t*)p_mad + MAD_BLOCK_SIZE;
-
- p_sa_mad = (ib_sa_mad_t_vM3*)&p_madt_struct->IBMad;
- if ( num_mads == 1) /* Only one Packet */
- {
- p_sa_mad->seg_num = 0;
- p_sa_mad->frag_flag = 5; /* Set bit 0 for first pkt and b4 for last pkt */
- /* the payload length gets copied with the mad header above */
- }
- else /* More than one packet in this response */
- {
- seg_num = 1;
- p_sa_mad->seg_num = cl_ntoh32(seg_num++);
- p_sa_mad->frag_flag = 1; /* Set bit 0 for first pkt */
- /* the payload length gets copied with the mad header above */
- }
-
- }
- else if ( i < num_mads -1) /* Not last packet */
- {
- /* First copy only the header */
- memcpy(&p_madt_struct->IBMad, p_mad, IB_SA_MAD_HDR_SIZE);
- /* Set the relevant fields in the SA_MAD_HEADER */
- p_sa_mad = (ib_sa_mad_t_vM3*)&p_madt_struct->IBMad;
- p_sa_mad->payload_len = cl_ntoh32(IB_SA_DATA_SIZE);
- p_sa_mad->seg_num = cl_ntoh32(seg_num++);
- p_sa_mad->frag_flag = 0;
- /* Now copy the fragmented data */
- memcpy(((uint8_t*)&p_madt_struct->IBMad) + IB_SA_MAD_HDR_SIZE, p_frag_data, IB_SA_DATA_SIZE);
- p_frag_data = p_frag_data + IB_SA_DATA_SIZE;
-
- }
- else if ( i == num_mads - 1) /* Last packet */
- {
- /* First copy only the header */
- memcpy(&p_madt_struct->IBMad, p_mad, IB_SA_MAD_HDR_SIZE);
- /* Set the relevant fields in the SA_MAD_HEADER */
- p_sa_mad = (ib_sa_mad_t_vM3*)&p_madt_struct->IBMad;
- p_sa_mad->seg_num = cl_ntoh32(seg_num++);
- p_sa_mad->frag_flag = 4; /* Set Bit 2 for last pkt */
- p_sa_mad->payload_len =
- cl_ntoh32(cl_ntoh32(((ib_sa_mad_t_vM3*)p_mad)->payload_len) % IB_SA_DATA_SIZE);
- /* Now copy the fragmented data */
- memcpy((((uint8_t*)&p_madt_struct->IBMad)) + IB_SA_MAD_HDR_SIZE,
- p_frag_data, cl_ntoh32(p_sa_mad->payload_len));
- p_frag_data = p_frag_data + IB_SA_DATA_SIZE;
-
- }
- /* Post the MAD */
- Status = p_umadt_obj->uMadtInterface.uMadtPostSend(p_mad_bind_info->umadt_handle,
- p_madt_struct,
- &destAddr);
- if(Status != FSUCCESS)
- {
- printf("uMadtPostSendMad: Status = <%d>\n", Status);
- return IB_ERROR;
- }
-
- /* Release send MAD */
- Status = p_umadt_obj->uMadtInterface.uMadtReleaseSendMad(p_mad_bind_info->umadt_handle,
- p_madt_struct);
- if(Status != FSUCCESS)
- {
- printf("uMadtReleaseSendMad: Status = <%d>\n", Status);
- return IB_ERROR;
- }
- }
- }
- return( IB_SUCCESS );
+ FSTATUS Status;
+
+ MadAddrStruct destAddr = { 0 };
+
+ mad_bind_info_t *p_mad_bind_info;
+ trans_context_t *p_trans_context;
+
+ umadt_obj_t *p_umadt_obj = NULL;
+
+ uint32_t mad_count = 0;
+ MadtStruct *p_madt_struct = NULL;
+ uint32_t i;
+ uint32_t num_mads = 0;
+ uint32_t seg_num = 0;
+ uint8_t *p_frag_data = NULL;
+ ib_sa_mad_t_vM3 *p_sa_mad = NULL;
+
+ CL_ASSERT(h_bind);
+ p_mad_bind_info = (mad_bind_info_t *) h_bind;
+ p_umadt_obj = p_mad_bind_info->p_umadt_obj;
+
+ /* sanity check */
+ CL_ASSERT(p_umadt_obj);
+ CL_ASSERT(p_umadt_obj->init_done);
+ CL_ASSERT(__valid_mad_handle(p_mad_bind_info));
+ CL_ASSERT(p_vend_wrap);
+ CL_ASSERT(p_mad_addr);
+ CL_ASSERT(p_mad);
+ /* CL_ASSERT( (ib_mad_t*)&p_vend_wrap->p_madt_struct->IBMad == p_mad ); */
+
+ /* */
+ /* based on the class, fill out the address info */
+ /* */
+ destAddr.DestLid = p_mad_addr->dest_lid;
+ destAddr.PathBits = p_mad_addr->path_bits;
+ destAddr.StaticRate = p_mad_addr->static_rate;
+
+ if (p_mad_bind_info->umadt_reg_class.ClassId == IB_MCLASS_SUBN_LID ||
+ p_mad_bind_info->umadt_reg_class.ClassId == IB_MCLASS_SUBN_DIR) {
+ CL_ASSERT(p_mad_addr->addr_type.smi.source_lid);
+ destAddr.AddrType.Smi.SourceLid =
+ p_mad_addr->addr_type.smi.source_lid;
+ } else {
+ destAddr.AddrType.Gsi.RemoteQpNumber =
+ p_mad_addr->addr_type.gsi.remote_qp;
+ destAddr.AddrType.Gsi.RemoteQkey =
+ p_mad_addr->addr_type.gsi.remote_qkey;
+ destAddr.AddrType.Gsi.PKey = p_mad_addr->addr_type.gsi.pkey;
+ destAddr.AddrType.Gsi.ServiceLevel =
+ p_mad_addr->addr_type.gsi.service_level;
+ destAddr.AddrType.Gsi.GlobalRoute =
+ p_mad_addr->addr_type.gsi.global_route;
+ /* destAddr.AddrType.Gsi.GRHInfo = p_mad_addr->addr_type.gsi.grh_info; */
+ }
+ p_mad->trans_id = cl_ntoh64(p_mad->trans_id) << 24;
+
+ /* */
+ /* Create a transaction context for this send and save the TID and client context. */
+ /* */
+
+ if (resp_expected) {
+ p_trans_context = malloc(sizeof(trans_context_t));
+ CL_ASSERT(p_trans_context);
+
+ memset(p_trans_context, 0, sizeof(trans_context_t));
+ p_trans_context->trans_id = p_mad->trans_id;
+ p_trans_context->context = transaction_context;
+ p_trans_context->sent_time = cl_get_time_stamp();
+
+ cl_spinlock_acquire(&p_mad_bind_info->trans_ctxt_lock);
+ cl_qlist_insert_tail(&p_mad_bind_info->trans_ctxt_list,
+ &p_trans_context->list_item);
+ cl_spinlock_release(&p_mad_bind_info->trans_ctxt_lock);
+ }
+
+ if (p_mad_bind_info->umadt_reg_class.ClassId == IB_MCLASS_SUBN_LID ||
+ p_mad_bind_info->umadt_reg_class.ClassId == IB_MCLASS_SUBN_DIR) {
+ /* Get one mad from uMadt */
+ mad_count = 1;
+ Status =
+ p_umadt_obj->uMadtInterface.
+ uMadtGetSendMad(p_mad_bind_info->umadt_handle, &mad_count,
+ &p_madt_struct);
+
+ if (Status != FSUCCESS || p_madt_struct == NULL) {
+ return IB_ERROR;
+ }
+
+ /* No Segmentation required */
+ memcpy(&p_madt_struct->IBMad, p_mad, MAD_BLOCK_SIZE);
+
+ /* Post the MAD */
+
+ Status =
+ p_umadt_obj->uMadtInterface.uMadtPostSend(p_mad_bind_info->
+ umadt_handle,
+ p_madt_struct,
+ &destAddr);
+ if (Status != FSUCCESS) {
+ printf("uMadtPostSendMad: Status = <%d>\n", Status);
+ return IB_ERROR;
+ }
+
+ /* Release send MAD */
+ Status =
+ p_umadt_obj->uMadtInterface.
+ uMadtReleaseSendMad(p_mad_bind_info->umadt_handle,
+ p_madt_struct);
+ if (Status != FSUCCESS) {
+ printf("uMadtReleaseSendMad: Status = <%d>\n", Status);
+ return IB_ERROR;
+ }
+ } else {
+
+ /* */
+ /* Segment the MAD, get the required send mads from uMadt and post the MADs. */
+ /* */
+ uint32_t payload_len;
+
+ payload_len =
+ cl_ntoh32(((ib_sa_mad_t_vM3 *) p_mad)->payload_len);
+ num_mads = payload_len / IB_SA_DATA_SIZE;
+ if (payload_len % IB_SA_DATA_SIZE != 0) {
+ num_mads++; /* Get one additional mad for the remainder */
+ }
+ for (i = 0; i < num_mads; i++) {
+ /* Get one mad from uMadt */
+ mad_count = 1;
+ Status =
+ p_umadt_obj->uMadtInterface.
+ uMadtGetSendMad(p_mad_bind_info->umadt_handle,
+ &mad_count, &p_madt_struct);
+
+ if (Status != FSUCCESS || p_madt_struct == NULL) {
+ return IB_ERROR;
+ }
+ /* Copy client MAD into uMadt's MAD. */
+ if (i == 0) { /* First Packet */
+ /* Since this is the first MAD, copy the entire MAD_SIZE */
+ memcpy(&p_madt_struct->IBMad, p_mad,
+ MAD_BLOCK_SIZE);
+
+ p_frag_data =
+ (uint8_t *) p_mad + MAD_BLOCK_SIZE;
+
+ p_sa_mad =
+ (ib_sa_mad_t_vM3 *) & p_madt_struct->IBMad;
+ if (num_mads == 1) { /* Only one Packet */
+ p_sa_mad->seg_num = 0;
+ p_sa_mad->frag_flag = 5; /* Set bit 0 for first pkt and b4 for last pkt */
+ /* the payload length gets copied with the mad header above */
+ } else { /* More than one packet in this response */
+
+ seg_num = 1;
+ p_sa_mad->seg_num =
+ cl_ntoh32(seg_num++);
+ p_sa_mad->frag_flag = 1; /* Set bit 0 for first pkt */
+ /* the payload length gets copied with the mad header above */
+ }
+
+ } else if (i < num_mads - 1) { /* Not last packet */
+ /* First copy only the header */
+ memcpy(&p_madt_struct->IBMad, p_mad,
+ IB_SA_MAD_HDR_SIZE);
+ /* Set the relevant fields in the SA_MAD_HEADER */
+ p_sa_mad =
+ (ib_sa_mad_t_vM3 *) & p_madt_struct->IBMad;
+ p_sa_mad->payload_len =
+ cl_ntoh32(IB_SA_DATA_SIZE);
+ p_sa_mad->seg_num = cl_ntoh32(seg_num++);
+ p_sa_mad->frag_flag = 0;
+ /* Now copy the fragmented data */
+ memcpy(((uint8_t *) & p_madt_struct->IBMad) +
+ IB_SA_MAD_HDR_SIZE, p_frag_data,
+ IB_SA_DATA_SIZE);
+ p_frag_data = p_frag_data + IB_SA_DATA_SIZE;
+
+ } else if (i == num_mads - 1) { /* Last packet */
+ /* First copy only the header */
+ memcpy(&p_madt_struct->IBMad, p_mad,
+ IB_SA_MAD_HDR_SIZE);
+ /* Set the relevant fields in the SA_MAD_HEADER */
+ p_sa_mad =
+ (ib_sa_mad_t_vM3 *) & p_madt_struct->IBMad;
+ p_sa_mad->seg_num = cl_ntoh32(seg_num++);
+ p_sa_mad->frag_flag = 4; /* Set Bit 2 for last pkt */
+ p_sa_mad->payload_len =
+ cl_ntoh32(cl_ntoh32
+ (((ib_sa_mad_t_vM3 *) p_mad)->
+ payload_len) % IB_SA_DATA_SIZE);
+ /* Now copy the fragmented data */
+ memcpy((((uint8_t *) & p_madt_struct->IBMad)) +
+ IB_SA_MAD_HDR_SIZE, p_frag_data,
+ cl_ntoh32(p_sa_mad->payload_len));
+ p_frag_data = p_frag_data + IB_SA_DATA_SIZE;
+
+ }
+ /* Post the MAD */
+ Status =
+ p_umadt_obj->uMadtInterface.
+ uMadtPostSend(p_mad_bind_info->umadt_handle,
+ p_madt_struct, &destAddr);
+ if (Status != FSUCCESS) {
+ printf("uMadtPostSendMad: Status = <%d>\n",
+ Status);
+ return IB_ERROR;
+ }
+
+ /* Release send MAD */
+ Status =
+ p_umadt_obj->uMadtInterface.
+ uMadtReleaseSendMad(p_mad_bind_info->umadt_handle,
+ p_madt_struct);
+ if (Status != FSUCCESS) {
+ printf("uMadtReleaseSendMad: Status = <%d>\n",
+ Status);
+ return IB_ERROR;
+ }
+ }
+ }
+ return (IB_SUCCESS);
}
/* //////////////////////////////////////////////////////////////////////// */
@@ -752,406 +730,395 @@ osm_vendor_send(
/* //////////////////////////////////////////////////////////////////////// */
osm_bind_handle_t
-osm_vendor_bind(
- IN osm_vendor_t* const p_vend,
- IN osm_bind_info_t* const p_osm_bind_info,
- IN osm_mad_pool_t* const p_mad_pool,
- IN osm_vend_mad_recv_callback_t mad_recv_callback,
- IN void* context )
+osm_vendor_bind(IN osm_vendor_t * const p_vend,
+ IN osm_bind_info_t * const p_osm_bind_info,
+ IN osm_mad_pool_t * const p_mad_pool,
+ IN osm_vend_mad_recv_callback_t mad_recv_callback,
+ IN void *context)
{
- cl_status_t cl_status;
- FSTATUS Status; /* GEN1 Status for Umadt */
-
- mad_bind_info_t *p_mad_bind_info;
- RegisterClassStruct *p_umadt_reg_class;
-
- umadt_obj_t *p_umadt_obj;
- OSM_LOG_ENTER( ((umadt_obj_t*)p_vend)->p_log, osm_vendor_bind );
-
- CL_ASSERT( p_vend );
-
- p_umadt_obj = (umadt_obj_t*)p_vend;
-
- /* Sanity check */
- CL_ASSERT( p_umadt_obj->init_done );
- CL_ASSERT( p_osm_bind_info );
- CL_ASSERT( p_mad_pool );
- CL_ASSERT( mad_recv_callback );
-
- /* Allocate memory for registering the handle. */
- p_mad_bind_info = (mad_bind_info_t*)malloc(sizeof(*p_mad_bind_info));
- if (p_mad_bind_info)
- {
- memset(p_mad_bind_info, 0, sizeof(*p_mad_bind_info));
- p_umadt_reg_class = &p_mad_bind_info->umadt_reg_class;
- }
- p_umadt_reg_class->PortGuid = cl_ntoh64( p_osm_bind_info->port_guid );
- p_umadt_reg_class->ClassId = p_osm_bind_info->mad_class;
- p_umadt_reg_class->ClassVersion = p_osm_bind_info->class_version;
- p_umadt_reg_class->isResponder = p_osm_bind_info->is_responder;
- p_umadt_reg_class->isTrapProcessor = p_osm_bind_info->is_trap_processor;
- p_umadt_reg_class->isReportProcessor = p_osm_bind_info->is_report_processor;
- p_umadt_reg_class->SendQueueSize = p_osm_bind_info->send_q_size;
- p_umadt_reg_class->RecvQueueSize = p_osm_bind_info->recv_q_size;
- p_umadt_reg_class->NotifySendCompletion = TRUE;
-
- p_mad_bind_info->p_umadt_obj = p_umadt_obj;
- p_mad_bind_info->p_mad_pool = p_mad_pool;
- p_mad_bind_info->mad_recv_callback = mad_recv_callback;
- p_mad_bind_info->client_context = context;
-
- /* register with Umadt for MAD interface */
- Status = p_umadt_obj->uMadtInterface.uMadtRegister(p_umadt_reg_class,
- &p_mad_bind_info->umadt_handle);
- if (Status != FSUCCESS)
- {
- free(p_mad_bind_info);
- OSM_LOG_EXIT( p_umadt_obj->p_log );
- return( OSM_BIND_INVALID_HANDLE );
- }
- CL_ASSERT(p_mad_bind_info->umadt_handle);
- /* */
- /* Start a worker thread to process receives. */
- /* */
- cl_thread_construct(&p_mad_bind_info->recv_processor_thread);
- cl_status = cl_thread_init( &p_mad_bind_info->recv_processor_thread,
- __mad_recv_processor,
- (void*)p_mad_bind_info,
- "mad_recv_worker");
- CL_ASSERT(cl_status == CL_SUCCESS );
-
- cl_qlist_init(&p_mad_bind_info->trans_ctxt_list);
- cl_spinlock_construct(&p_mad_bind_info->trans_ctxt_lock);
- cl_spinlock_init(&p_mad_bind_info->trans_ctxt_lock);
- cl_spinlock_construct(&p_mad_bind_info->timeout_list_lock);
- cl_spinlock_init(&p_mad_bind_info->timeout_list_lock);
-
- cl_status = cl_timer_init(&p_mad_bind_info->timeout_timer,
- __osm_vendor_timer_callback,
- (void*)p_mad_bind_info);
- CL_ASSERT(cl_status == CL_SUCCESS );
- cl_qlist_init(&p_mad_bind_info->timeout_list);
- /* */
- /* Insert the mad_reg_struct in list and return pointer to it as the handle */
- /* */
- cl_spinlock_acquire(&p_umadt_obj->register_lock);
-
- cl_qlist_insert_head(&p_umadt_obj->register_list,
- &p_mad_bind_info->list_item);
-
- cl_spinlock_release(&p_umadt_obj->register_lock);
-
- /*
- A timeout value of 0 means disable timeouts.
- */
- if( p_umadt_obj->timeout )
- {
- cl_timer_start(&p_mad_bind_info->timeout_timer,
- DEFAULT_TIMER_INTERVAL_MSEC);
- }
-
- OSM_LOG_EXIT( p_umadt_obj->p_log );
- return( (osm_bind_handle_t)p_mad_bind_info );
+ cl_status_t cl_status;
+ FSTATUS Status; /* GEN1 Status for Umadt */
+
+ mad_bind_info_t *p_mad_bind_info;
+ RegisterClassStruct *p_umadt_reg_class;
+
+ umadt_obj_t *p_umadt_obj;
+ OSM_LOG_ENTER(((umadt_obj_t *) p_vend)->p_log, osm_vendor_bind);
+
+ CL_ASSERT(p_vend);
+
+ p_umadt_obj = (umadt_obj_t *) p_vend;
+
+ /* Sanity check */
+ CL_ASSERT(p_umadt_obj->init_done);
+ CL_ASSERT(p_osm_bind_info);
+ CL_ASSERT(p_mad_pool);
+ CL_ASSERT(mad_recv_callback);
+
+ /* Allocate memory for registering the handle. */
+ p_mad_bind_info = (mad_bind_info_t *) malloc(sizeof(*p_mad_bind_info));
+ if (p_mad_bind_info) {
+ memset(p_mad_bind_info, 0, sizeof(*p_mad_bind_info));
+ p_umadt_reg_class = &p_mad_bind_info->umadt_reg_class;
+ }
+ p_umadt_reg_class->PortGuid = cl_ntoh64(p_osm_bind_info->port_guid);
+ p_umadt_reg_class->ClassId = p_osm_bind_info->mad_class;
+ p_umadt_reg_class->ClassVersion = p_osm_bind_info->class_version;
+ p_umadt_reg_class->isResponder = p_osm_bind_info->is_responder;
+ p_umadt_reg_class->isTrapProcessor = p_osm_bind_info->is_trap_processor;
+ p_umadt_reg_class->isReportProcessor =
+ p_osm_bind_info->is_report_processor;
+ p_umadt_reg_class->SendQueueSize = p_osm_bind_info->send_q_size;
+ p_umadt_reg_class->RecvQueueSize = p_osm_bind_info->recv_q_size;
+ p_umadt_reg_class->NotifySendCompletion = TRUE;
+
+ p_mad_bind_info->p_umadt_obj = p_umadt_obj;
+ p_mad_bind_info->p_mad_pool = p_mad_pool;
+ p_mad_bind_info->mad_recv_callback = mad_recv_callback;
+ p_mad_bind_info->client_context = context;
+
+ /* register with Umadt for MAD interface */
+ Status = p_umadt_obj->uMadtInterface.uMadtRegister(p_umadt_reg_class,
+ &p_mad_bind_info->
+ umadt_handle);
+ if (Status != FSUCCESS) {
+ free(p_mad_bind_info);
+ OSM_LOG_EXIT(p_umadt_obj->p_log);
+ return (OSM_BIND_INVALID_HANDLE);
+ }
+ CL_ASSERT(p_mad_bind_info->umadt_handle);
+ /* */
+ /* Start a worker thread to process receives. */
+ /* */
+ cl_thread_construct(&p_mad_bind_info->recv_processor_thread);
+ cl_status = cl_thread_init(&p_mad_bind_info->recv_processor_thread,
+ __mad_recv_processor,
+ (void *)p_mad_bind_info, "mad_recv_worker");
+ CL_ASSERT(cl_status == CL_SUCCESS);
+
+ cl_qlist_init(&p_mad_bind_info->trans_ctxt_list);
+ cl_spinlock_construct(&p_mad_bind_info->trans_ctxt_lock);
+ cl_spinlock_init(&p_mad_bind_info->trans_ctxt_lock);
+ cl_spinlock_construct(&p_mad_bind_info->timeout_list_lock);
+ cl_spinlock_init(&p_mad_bind_info->timeout_list_lock);
+
+ cl_status = cl_timer_init(&p_mad_bind_info->timeout_timer,
+ __osm_vendor_timer_callback,
+ (void *)p_mad_bind_info);
+ CL_ASSERT(cl_status == CL_SUCCESS);
+ cl_qlist_init(&p_mad_bind_info->timeout_list);
+ /* */
+ /* Insert the mad_reg_struct in list and return pointer to it as the handle */
+ /* */
+ cl_spinlock_acquire(&p_umadt_obj->register_lock);
+
+ cl_qlist_insert_head(&p_umadt_obj->register_list,
+ &p_mad_bind_info->list_item);
+
+ cl_spinlock_release(&p_umadt_obj->register_lock);
+
+ /*
+ A timeout value of 0 means disable timeouts.
+ */
+ if (p_umadt_obj->timeout) {
+ cl_timer_start(&p_mad_bind_info->timeout_timer,
+ DEFAULT_TIMER_INTERVAL_MSEC);
+ }
+
+ OSM_LOG_EXIT(p_umadt_obj->p_log);
+ return ((osm_bind_handle_t) p_mad_bind_info);
}
/**********************************************************************
**********************************************************************/
-void
-osm_vendor_unbind(IN osm_bind_handle_t h_bind)
+void osm_vendor_unbind(IN osm_bind_handle_t h_bind)
{
- mad_bind_info_t *p_mad_bind_info;
- umadt_obj_t *p_umadt_obj;
- cl_list_item_t *p_list_item, *p_next_list_item;
-
- CL_ASSERT(h_bind);
- p_mad_bind_info = (mad_bind_info_t*)h_bind;
- p_umadt_obj = p_mad_bind_info->p_umadt_obj;
-
- /* sanity check */
- CL_ASSERT(p_umadt_obj);
- CL_ASSERT(p_umadt_obj->init_done);
- CL_ASSERT(__valid_mad_handle(p_mad_bind_info));
-
- p_umadt_obj->uMadtInterface.uMadtDestroy( &p_mad_bind_info->umadt_handle);
- cl_timer_destroy(&p_mad_bind_info->timeout_timer);
- cl_thread_destroy(&p_mad_bind_info->recv_processor_thread);
-
- cl_spinlock_acquire(&p_mad_bind_info->trans_ctxt_lock);
- p_list_item = cl_qlist_head(&p_mad_bind_info->trans_ctxt_list);
- while ( p_list_item != cl_qlist_end(&p_mad_bind_info->trans_ctxt_list))
- {
- p_next_list_item = cl_qlist_next(p_list_item);
- cl_qlist_remove_item(&p_mad_bind_info->trans_ctxt_list,
- p_list_item);
- free(p_list_item);
- p_list_item = p_next_list_item;
- }
- cl_spinlock_release(&p_mad_bind_info->trans_ctxt_lock);
-
- cl_spinlock_acquire(&p_mad_bind_info->timeout_list_lock);
- p_list_item = cl_qlist_head(&p_mad_bind_info->timeout_list);
- while ( p_list_item != cl_qlist_end(&p_mad_bind_info->timeout_list))
- {
- p_next_list_item = cl_qlist_next(p_list_item);
- cl_qlist_remove_item(&p_mad_bind_info->timeout_list,
- p_list_item);
- free(p_list_item);
- p_list_item = p_next_list_item;
- }
- cl_spinlock_release(&p_mad_bind_info->timeout_list_lock);
-
- free(p_mad_bind_info);
+ mad_bind_info_t *p_mad_bind_info;
+ umadt_obj_t *p_umadt_obj;
+ cl_list_item_t *p_list_item, *p_next_list_item;
+
+ CL_ASSERT(h_bind);
+ p_mad_bind_info = (mad_bind_info_t *) h_bind;
+ p_umadt_obj = p_mad_bind_info->p_umadt_obj;
+
+ /* sanity check */
+ CL_ASSERT(p_umadt_obj);
+ CL_ASSERT(p_umadt_obj->init_done);
+ CL_ASSERT(__valid_mad_handle(p_mad_bind_info));
+
+ p_umadt_obj->uMadtInterface.uMadtDestroy(&p_mad_bind_info->
+ umadt_handle);
+ cl_timer_destroy(&p_mad_bind_info->timeout_timer);
+ cl_thread_destroy(&p_mad_bind_info->recv_processor_thread);
+
+ cl_spinlock_acquire(&p_mad_bind_info->trans_ctxt_lock);
+ p_list_item = cl_qlist_head(&p_mad_bind_info->trans_ctxt_list);
+ while (p_list_item != cl_qlist_end(&p_mad_bind_info->trans_ctxt_list)) {
+ p_next_list_item = cl_qlist_next(p_list_item);
+ cl_qlist_remove_item(&p_mad_bind_info->trans_ctxt_list,
+ p_list_item);
+ free(p_list_item);
+ p_list_item = p_next_list_item;
+ }
+ cl_spinlock_release(&p_mad_bind_info->trans_ctxt_lock);
+
+ cl_spinlock_acquire(&p_mad_bind_info->timeout_list_lock);
+ p_list_item = cl_qlist_head(&p_mad_bind_info->timeout_list);
+ while (p_list_item != cl_qlist_end(&p_mad_bind_info->timeout_list)) {
+ p_next_list_item = cl_qlist_next(p_list_item);
+ cl_qlist_remove_item(&p_mad_bind_info->timeout_list,
+ p_list_item);
+ free(p_list_item);
+ p_list_item = p_next_list_item;
+ }
+ cl_spinlock_release(&p_mad_bind_info->timeout_list_lock);
+
+ free(p_mad_bind_info);
}
/**********************************************************************
**********************************************************************/
-void
-__mad_recv_processor(
- IN void* context)
+void __mad_recv_processor(IN void *context)
{
- mad_bind_info_t *p_mad_bind_info = (mad_bind_info_t*)context;
- umadt_obj_t *p_umadt_obj;
- osm_madw_t *p_osm_madw = NULL;
- osm_vend_wrap_t *p_vend_wrap = NULL;
- osm_mad_addr_t osm_mad_addr = {0};
- cl_list_item_t *p_list_item;
- void* transaction_context;
-
- FSTATUS Status;
- MadtStruct *pRecvMad = NULL;
- MadWorkCompletion *pRecvCmp = NULL;
-
-
- CL_ASSERT(context);
-
- p_mad_bind_info = (mad_bind_info_t*)context;
- p_umadt_obj = p_mad_bind_info->p_umadt_obj;
- /* PollFor a completion */
- /* if FNOTFOND, then wait for a completion then again poll and return the MAD */
- while(1)
- {
- Status = p_umadt_obj->uMadtInterface.uMadtPollForRecvCompletion(p_mad_bind_info->umadt_handle,
- &pRecvMad,
- &pRecvCmp);
- if(Status != FSUCCESS)
- {
- if ( Status == FNOT_FOUND)
- {
- /* Wait for a completion */
- Status = p_umadt_obj->uMadtInterface.uMadtWaitForAnyCompletion(
- p_mad_bind_info->umadt_handle,
- RECV_COMPLETION,
- 0x5000); /* 5 sec timeout */
-
- if(Status == FTIMEOUT)
- {
- continue;
- }
- CL_ASSERT(Status == FSUCCESS);
-
- Status = p_umadt_obj->uMadtInterface.uMadtPollForRecvCompletion(
- p_mad_bind_info->umadt_handle,
- &pRecvMad,
- &pRecvCmp);
- if ( Status != FSUCCESS )
- {
- printf(" mad_recv_worker: Error in PollForRecv returning <%x>\n", Status);
- CL_ASSERT(0);
- }
- }
- else {
- printf("uMadtPollForRecvCompletion Status=<%x>\n", Status);
- CL_ASSERT(0);
- }
- }
- CL_ASSERT(pRecvMad);
- CL_ASSERT(pRecvCmp);
-
- if (((ib_sa_mad_t_vM3*)(&pRecvMad->IBMad))->frag_flag & 0x20 )
- {
- /* Ignore the ACK packet */
- Status = p_umadt_obj->uMadtInterface.uMadtReleaseRecvMad(
- p_mad_bind_info->umadt_handle,
- pRecvMad);
- continue;
- }
- /* */
- /* Extract the return address to pass it on to the client */
- /* */
- osm_mad_addr.dest_lid = pRecvCmp->AddressInfo.DestLid;
- osm_mad_addr.path_bits = pRecvCmp->AddressInfo.PathBits;
- osm_mad_addr.static_rate = pRecvCmp->AddressInfo.StaticRate;
-
- if (p_mad_bind_info->umadt_reg_class.ClassId == IB_MCLASS_SUBN_LID ||
- p_mad_bind_info->umadt_reg_class.ClassId == IB_MCLASS_SUBN_DIR)
- {
- osm_mad_addr.addr_type.smi.source_lid = pRecvCmp->AddressInfo.AddrType.Smi.SourceLid;
- /* osm_mad_addr.addr_type.smi.port_num = pRecvCmp->AddressInfo.AddrType.Smi.PortNumber; */
- }
- else
- {
- osm_mad_addr.addr_type.gsi.remote_qp = pRecvCmp->AddressInfo.AddrType.Gsi.RemoteQpNumber;
- osm_mad_addr.addr_type.gsi.remote_qkey = pRecvCmp->AddressInfo.AddrType.Gsi.RemoteQkey;
- osm_mad_addr.addr_type.gsi.pkey = pRecvCmp->AddressInfo.AddrType.Gsi.PKey;
- osm_mad_addr.addr_type.gsi.service_level = pRecvCmp->AddressInfo.AddrType.Gsi.ServiceLevel;
- osm_mad_addr.addr_type.gsi.global_route = pRecvCmp->AddressInfo.AddrType.Gsi.GlobalRoute;
- /* osm_mad_addr.addr_type.gsi.grh_info = pRecvCmp->AddressInfo.AddrType.Gsi.GRHInfo; */
- }
- p_osm_madw = osm_mad_pool_get_wrapper(p_mad_bind_info->p_mad_pool,
- p_mad_bind_info,
- MAD_BLOCK_SIZE,
- (ib_mad_t*)&pRecvMad->IBMad,
- &osm_mad_addr);
- CL_ASSERT(p_osm_madw);
- p_vend_wrap = osm_madw_get_vend_ptr(p_osm_madw);
- CL_ASSERT(p_vend_wrap);
- p_vend_wrap->p_madt_struct = pRecvMad;
- p_vend_wrap->direction = RECEIVE;
-
- osm_log( p_mad_bind_info->p_umadt_obj->p_log, OSM_LOG_DEBUG,
- "__mad_recv_processor: "
- "Received data p_osm_madw[0x%p].\n",
- p_osm_madw) ;
-
- /* */
- /* Do TID Processing. */
- /* */
- /* If R bit is set swap the TID */
-
- cl_spinlock_acquire(&p_mad_bind_info->trans_ctxt_lock);
- p_list_item= cl_qlist_find_from_head(
- &p_mad_bind_info->trans_ctxt_list,
- __match_tid_context,
- &p_osm_madw->p_mad->trans_id);
-
- if (p_list_item == cl_qlist_end(&p_mad_bind_info->trans_ctxt_list))
- {
- transaction_context = NULL;
- }
- else
- {
- transaction_context =((trans_context_t*)p_list_item)->context;
- cl_qlist_remove_item(&p_mad_bind_info->trans_ctxt_list,
- p_list_item);
- free(p_list_item);
- }
- cl_spinlock_release(&p_mad_bind_info->trans_ctxt_lock);
- ((ib_mad_t*)p_osm_madw->p_mad)->trans_id = cl_ntoh64(p_osm_madw->p_mad->trans_id>>24);
- osm_log( p_mad_bind_info->p_umadt_obj->p_log, OSM_LOG_DEBUG,
- "__mad_recv_processor: "
- "Received data p_osm_madw [0x%p]"
- "\n\t\t\t\tTID[0x%"PRIx64", context[%p]. \n",
- p_osm_madw, ((ib_mad_t*)p_osm_madw->p_mad)->trans_id,
- transaction_context) ;
-
- (*(p_mad_bind_info->mad_recv_callback))(p_osm_madw,
- p_mad_bind_info->client_context,
- transaction_context);
-
- }
+ mad_bind_info_t *p_mad_bind_info = (mad_bind_info_t *) context;
+ umadt_obj_t *p_umadt_obj;
+ osm_madw_t *p_osm_madw = NULL;
+ osm_vend_wrap_t *p_vend_wrap = NULL;
+ osm_mad_addr_t osm_mad_addr = { 0 };
+ cl_list_item_t *p_list_item;
+ void *transaction_context;
+
+ FSTATUS Status;
+ MadtStruct *pRecvMad = NULL;
+ MadWorkCompletion *pRecvCmp = NULL;
+
+ CL_ASSERT(context);
+
+ p_mad_bind_info = (mad_bind_info_t *) context;
+ p_umadt_obj = p_mad_bind_info->p_umadt_obj;
+ /* PollFor a completion */
+ /* if FNOTFOND, then wait for a completion then again poll and return the MAD */
+ while (1) {
+ Status =
+ p_umadt_obj->uMadtInterface.
+ uMadtPollForRecvCompletion(p_mad_bind_info->umadt_handle,
+ &pRecvMad, &pRecvCmp);
+ if (Status != FSUCCESS) {
+ if (Status == FNOT_FOUND) {
+ /* Wait for a completion */
+ Status = p_umadt_obj->uMadtInterface.uMadtWaitForAnyCompletion(p_mad_bind_info->umadt_handle, RECV_COMPLETION, 0x5000); /* 5 sec timeout */
+
+ if (Status == FTIMEOUT) {
+ continue;
+ }
+ CL_ASSERT(Status == FSUCCESS);
+
+ Status =
+ p_umadt_obj->uMadtInterface.
+ uMadtPollForRecvCompletion(p_mad_bind_info->
+ umadt_handle,
+ &pRecvMad,
+ &pRecvCmp);
+ if (Status != FSUCCESS) {
+ printf
+ (" mad_recv_worker: Error in PollForRecv returning <%x>\n",
+ Status);
+ CL_ASSERT(0);
+ }
+ } else {
+ printf
+ ("uMadtPollForRecvCompletion Status=<%x>\n",
+ Status);
+ CL_ASSERT(0);
+ }
+ }
+ CL_ASSERT(pRecvMad);
+ CL_ASSERT(pRecvCmp);
+
+ if (((ib_sa_mad_t_vM3 *) (&pRecvMad->IBMad))->frag_flag & 0x20) {
+ /* Ignore the ACK packet */
+ Status =
+ p_umadt_obj->uMadtInterface.
+ uMadtReleaseRecvMad(p_mad_bind_info->umadt_handle,
+ pRecvMad);
+ continue;
+ }
+ /* */
+ /* Extract the return address to pass it on to the client */
+ /* */
+ osm_mad_addr.dest_lid = pRecvCmp->AddressInfo.DestLid;
+ osm_mad_addr.path_bits = pRecvCmp->AddressInfo.PathBits;
+ osm_mad_addr.static_rate = pRecvCmp->AddressInfo.StaticRate;
+
+ if (p_mad_bind_info->umadt_reg_class.ClassId ==
+ IB_MCLASS_SUBN_LID
+ || p_mad_bind_info->umadt_reg_class.ClassId ==
+ IB_MCLASS_SUBN_DIR) {
+ osm_mad_addr.addr_type.smi.source_lid =
+ pRecvCmp->AddressInfo.AddrType.Smi.SourceLid;
+ /* osm_mad_addr.addr_type.smi.port_num = pRecvCmp->AddressInfo.AddrType.Smi.PortNumber; */
+ } else {
+ osm_mad_addr.addr_type.gsi.remote_qp =
+ pRecvCmp->AddressInfo.AddrType.Gsi.RemoteQpNumber;
+ osm_mad_addr.addr_type.gsi.remote_qkey =
+ pRecvCmp->AddressInfo.AddrType.Gsi.RemoteQkey;
+ osm_mad_addr.addr_type.gsi.pkey =
+ pRecvCmp->AddressInfo.AddrType.Gsi.PKey;
+ osm_mad_addr.addr_type.gsi.service_level =
+ pRecvCmp->AddressInfo.AddrType.Gsi.ServiceLevel;
+ osm_mad_addr.addr_type.gsi.global_route =
+ pRecvCmp->AddressInfo.AddrType.Gsi.GlobalRoute;
+ /* osm_mad_addr.addr_type.gsi.grh_info = pRecvCmp->AddressInfo.AddrType.Gsi.GRHInfo; */
+ }
+ p_osm_madw =
+ osm_mad_pool_get_wrapper(p_mad_bind_info->p_mad_pool,
+ p_mad_bind_info, MAD_BLOCK_SIZE,
+ (ib_mad_t *) & pRecvMad->IBMad,
+ &osm_mad_addr);
+ CL_ASSERT(p_osm_madw);
+ p_vend_wrap = osm_madw_get_vend_ptr(p_osm_madw);
+ CL_ASSERT(p_vend_wrap);
+ p_vend_wrap->p_madt_struct = pRecvMad;
+ p_vend_wrap->direction = RECEIVE;
+
+ osm_log(p_mad_bind_info->p_umadt_obj->p_log, OSM_LOG_DEBUG,
+ "__mad_recv_processor: "
+ "Received data p_osm_madw[0x%p].\n", p_osm_madw);
+
+ /* */
+ /* Do TID Processing. */
+ /* */
+ /* If R bit is set swap the TID */
+
+ cl_spinlock_acquire(&p_mad_bind_info->trans_ctxt_lock);
+ p_list_item =
+ cl_qlist_find_from_head(&p_mad_bind_info->trans_ctxt_list,
+ __match_tid_context,
+ &p_osm_madw->p_mad->trans_id);
+
+ if (p_list_item ==
+ cl_qlist_end(&p_mad_bind_info->trans_ctxt_list)) {
+ transaction_context = NULL;
+ } else {
+ transaction_context =
+ ((trans_context_t *) p_list_item)->context;
+ cl_qlist_remove_item(&p_mad_bind_info->trans_ctxt_list,
+ p_list_item);
+ free(p_list_item);
+ }
+ cl_spinlock_release(&p_mad_bind_info->trans_ctxt_lock);
+ ((ib_mad_t *) p_osm_madw->p_mad)->trans_id =
+ cl_ntoh64(p_osm_madw->p_mad->trans_id >> 24);
+ osm_log(p_mad_bind_info->p_umadt_obj->p_log, OSM_LOG_DEBUG,
+ "__mad_recv_processor: "
+ "Received data p_osm_madw [0x%p]" "\n\t\t\t\tTID[0x%"
+ PRIx64 ", context[%p]. \n", p_osm_madw,
+ ((ib_mad_t *) p_osm_madw->p_mad)->trans_id,
+ transaction_context);
+
+ (*(p_mad_bind_info->mad_recv_callback)) (p_osm_madw,
+ p_mad_bind_info->
+ client_context,
+ transaction_context);
+
+ }
}
+
/**********************************************************************
**********************************************************************/
-
cl_status_t
-__match_tid_context( const cl_list_item_t* const p_list_item,
- void* context)
+__match_tid_context(const cl_list_item_t * const p_list_item, void *context)
{
- if (((trans_context_t*)p_list_item)->trans_id == *((uint64_t*)context))
- return CL_SUCCESS;
- return CL_NOT_FOUND;
+ if (((trans_context_t *) p_list_item)->trans_id ==
+ *((uint64_t *) context))
+ return CL_SUCCESS;
+ return CL_NOT_FOUND;
}
+
/**********************************************************************
**********************************************************************/
-boolean_t
-__valid_mad_handle(
- IN mad_bind_info_t *p_mad_bind_info
- )
+boolean_t __valid_mad_handle(IN mad_bind_info_t * p_mad_bind_info)
{
- umadt_obj_t *p_umadt_obj;
+ umadt_obj_t *p_umadt_obj;
- p_umadt_obj = p_mad_bind_info->p_umadt_obj;
+ p_umadt_obj = p_mad_bind_info->p_umadt_obj;
- cl_spinlock_acquire(&p_umadt_obj->register_lock);
- if(!cl_is_item_in_qlist(&p_umadt_obj->register_list,
- &p_mad_bind_info->list_item))
- {
- cl_spinlock_release(&p_umadt_obj->register_lock);
- return FALSE;
- }
- cl_spinlock_release(&p_umadt_obj->register_lock);
- return TRUE;
+ cl_spinlock_acquire(&p_umadt_obj->register_lock);
+ if (!cl_is_item_in_qlist(&p_umadt_obj->register_list,
+ &p_mad_bind_info->list_item)) {
+ cl_spinlock_release(&p_umadt_obj->register_lock);
+ return FALSE;
+ }
+ cl_spinlock_release(&p_umadt_obj->register_lock);
+ return TRUE;
}
-void
-__osm_vendor_timer_callback(
- IN void* context )
+void __osm_vendor_timer_callback(IN void *context)
{
- uint64_t current_time;
- mad_bind_info_t *p_mad_bind_info;
- umadt_obj_t *p_umadt_obj;
- uint32_t timeout;
-
- cl_list_item_t *p_list_item, *p_next_list_item;
+ uint64_t current_time;
+ mad_bind_info_t *p_mad_bind_info;
+ umadt_obj_t *p_umadt_obj;
+ uint32_t timeout;
- CL_ASSERT(context);
+ cl_list_item_t *p_list_item, *p_next_list_item;
- p_mad_bind_info = (mad_bind_info_t*)context;
- p_umadt_obj = p_mad_bind_info->p_umadt_obj;
- timeout = p_umadt_obj->timeout * 1000;
+ CL_ASSERT(context);
- current_time = cl_get_time_stamp();
+ p_mad_bind_info = (mad_bind_info_t *) context;
+ p_umadt_obj = p_mad_bind_info->p_umadt_obj;
+ timeout = p_umadt_obj->timeout * 1000;
- cl_spinlock_acquire(&p_mad_bind_info->trans_ctxt_lock);
+ current_time = cl_get_time_stamp();
- p_list_item = cl_qlist_head(&p_mad_bind_info->trans_ctxt_list);
- while ( p_list_item != cl_qlist_end(&p_mad_bind_info->trans_ctxt_list))
- {
+ cl_spinlock_acquire(&p_mad_bind_info->trans_ctxt_lock);
- p_next_list_item = cl_qlist_next(p_list_item);
+ p_list_item = cl_qlist_head(&p_mad_bind_info->trans_ctxt_list);
+ while (p_list_item != cl_qlist_end(&p_mad_bind_info->trans_ctxt_list)) {
- /* DEFAULT_PKT_TIMEOUT is in milli seconds */
- if ( current_time - ((trans_context_t*)p_list_item)->sent_time
- > timeout )
- {
- /* Add this transaction to the timeout_list */
- cl_qlist_remove_item(&p_mad_bind_info->trans_ctxt_list,
- p_list_item);
- cl_qlist_insert_tail(&p_mad_bind_info->timeout_list,
- p_list_item );
- }
+ p_next_list_item = cl_qlist_next(p_list_item);
- p_list_item = p_next_list_item;
- }
+ /* DEFAULT_PKT_TIMEOUT is in milli seconds */
+ if (current_time - ((trans_context_t *) p_list_item)->sent_time
+ > timeout) {
+ /* Add this transaction to the timeout_list */
+ cl_qlist_remove_item(&p_mad_bind_info->trans_ctxt_list,
+ p_list_item);
+ cl_qlist_insert_tail(&p_mad_bind_info->timeout_list,
+ p_list_item);
+ }
- cl_spinlock_release(&p_mad_bind_info->trans_ctxt_lock);
+ p_list_item = p_next_list_item;
+ }
- p_list_item = cl_qlist_head(&p_mad_bind_info->timeout_list);
- while ( p_list_item != cl_qlist_end(&p_mad_bind_info->timeout_list))
- {
- osm_log( p_mad_bind_info->p_umadt_obj->p_log, OSM_LOG_DEBUG,
- "__osm_vendor_timer_callback: "
- "Timing out transaction context [0x%p].\n",
- ((trans_context_t*)p_list_item)->context) ;
+ cl_spinlock_release(&p_mad_bind_info->trans_ctxt_lock);
+ p_list_item = cl_qlist_head(&p_mad_bind_info->timeout_list);
+ while (p_list_item != cl_qlist_end(&p_mad_bind_info->timeout_list)) {
+ osm_log(p_mad_bind_info->p_umadt_obj->p_log, OSM_LOG_DEBUG,
+ "__osm_vendor_timer_callback: "
+ "Timing out transaction context [0x%p].\n",
+ ((trans_context_t *) p_list_item)->context);
- (*(p_mad_bind_info->mad_recv_callback))(NULL,
- p_mad_bind_info->client_context,
- ((trans_context_t*)p_list_item)->context);
+ (*(p_mad_bind_info->mad_recv_callback)) (NULL,
+ p_mad_bind_info->
+ client_context,
+ ((trans_context_t *)
+ p_list_item)->
+ context);
- p_next_list_item = cl_qlist_next(p_list_item);
- cl_qlist_remove_item(&p_mad_bind_info->timeout_list,
- p_list_item);
- free(p_list_item);
- p_list_item = p_next_list_item;
- }
+ p_next_list_item = cl_qlist_next(p_list_item);
+ cl_qlist_remove_item(&p_mad_bind_info->timeout_list,
+ p_list_item);
+ free(p_list_item);
+ p_list_item = p_next_list_item;
+ }
- cl_timer_start(&p_mad_bind_info->timeout_timer, DEFAULT_TIMER_INTERVAL_MSEC);
+ cl_timer_start(&p_mad_bind_info->timeout_timer,
+ DEFAULT_TIMER_INTERVAL_MSEC);
}
-
-#endif /* OSM_VENDOR_INTF_UMADT */
+#endif /* OSM_VENDOR_INTF_UMADT */
--
1.5.3.rc2.29.gc4640f
More information about the general
mailing list