[openib-general] [PATCH v2] opensm: remove obsolete p_report_buf
Sasha Khapyorsky
sashak at voltaire.com
Wed Nov 1 10:45:59 PST 2006
This removes obsolete now shared sm->p_report_buf buffer and cleans
up related code. And also introduces new log function osm_log_printf()
which currently trivially sends formatted output to stdout.
Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
---
osm/include/opensm/osm_base.h | 5 --
osm/include/opensm/osm_log.h | 3 +
osm/include/opensm/osm_sm.h | 2 -
osm/include/opensm/osm_state_mgr.h | 8 --
osm/include/opensm/osm_ucast_mgr.h | 5 --
osm/opensm/libopensm.map | 3 +-
osm/opensm/osm_log.c | 19 +++++
osm/opensm/osm_mcast_mgr.c | 11 ++--
osm/opensm/osm_sm.c | 15 +----
osm/opensm/osm_state_mgr.c | 138 ++++++++++++-----------------------
osm/opensm/osm_ucast_mgr.c | 80 +++++++--------------
11 files changed, 104 insertions(+), 185 deletions(-)
diff --git a/osm/include/opensm/osm_base.h b/osm/include/opensm/osm_base.h
index 57dd4fd..20e2cc3 100644
--- a/osm/include/opensm/osm_base.h
+++ b/osm/include/opensm/osm_base.h
@@ -714,11 +714,6 @@ typedef enum _osm_state_mgr_mode
*
**********/
-#define OSM_REPORT_BUF_SIZE 0x10000
-#define OSM_REPORT_LINE_SIZE 0x256
-#define OSM_REPORT_BUF_THRESHOLD (OSM_REPORT_BUF_SIZE / OSM_REPORT_LINE_SIZE)
-
-
/****d* OpenSM: Base/osm_sm_signal_t
* NAME
* osm_sm_signal_t
diff --git a/osm/include/opensm/osm_log.h b/osm/include/opensm/osm_log.h
index 62f3a0c..6a1a93f 100644
--- a/osm/include/opensm/osm_log.h
+++ b/osm/include/opensm/osm_log.h
@@ -370,6 +370,9 @@ osm_log_is_active(
* osm_log_destroy
*********/
+extern int osm_log_printf(osm_log_t *p_log, osm_log_level_t level,
+ const char *fmt, ...);
+
void
osm_log(
IN osm_log_t* const p_log,
diff --git a/osm/include/opensm/osm_sm.h b/osm/include/opensm/osm_sm.h
index bc812f3..05b87ac 100644
--- a/osm/include/opensm/osm_sm.h
+++ b/osm/include/opensm/osm_sm.h
@@ -178,8 +178,6 @@ typedef struct _osm_sm
osm_vla_rcv_ctrl_t vla_rcv_ctrl;
osm_pkey_rcv_t pkey_rcv;
osm_pkey_rcv_ctrl_t pkey_rcv_ctrl;
- char* p_report_buf;
-
} osm_sm_t;
/*
* FIELDS
diff --git a/osm/include/opensm/osm_state_mgr.h b/osm/include/opensm/osm_state_mgr.h
index ad4afa0..7aaab58 100644
--- a/osm/include/opensm/osm_state_mgr.h
+++ b/osm/include/opensm/osm_state_mgr.h
@@ -121,7 +121,6 @@ typedef struct _osm_state_mgr
cl_qlist_t idle_time_list;
cl_plock_t *p_lock;
cl_event_t *p_subnet_up_event;
- char *p_report_buf;
osm_sm_state_t state;
osm_state_mgr_mode_t state_step_mode;
osm_signal_t next_stage_signal;
@@ -170,9 +169,6 @@ typedef struct _osm_state_mgr
* p_subnet_up_event
* Pointer to the event to set if/when the subnet comes up.
*
-* p_report_buf
-* Pointer to the large log buffer used for user reports.
-*
* state
* State of the SM.
*
@@ -380,7 +376,6 @@ osm_state_mgr_init(
IN const osm_sm_mad_ctrl_t* const p_mad_ctrl,
IN cl_plock_t* const p_lock,
IN cl_event_t* const p_subnet_up_event,
- IN char* const p_report_buf,
IN osm_log_t* const p_log );
/*
* PARAMETERS
@@ -420,9 +415,6 @@ osm_state_mgr_init(
* p_subnet_up_event
* [in] Pointer to the event to set if/when the subnet comes up.
*
-* p_report_buf
-* [in] Pointer to the large log buffer used for user reports.
-*
* p_log
* [in] Pointer to the log object.
*
diff --git a/osm/include/opensm/osm_ucast_mgr.h b/osm/include/opensm/osm_ucast_mgr.h
index 0fbfc66..1c10abb 100644
--- a/osm/include/opensm/osm_ucast_mgr.h
+++ b/osm/include/opensm/osm_ucast_mgr.h
@@ -105,7 +105,6 @@ typedef struct _osm_ucast_mgr
osm_req_t *p_req;
osm_log_t *p_log;
cl_plock_t *p_lock;
- char *p_report_buf;
} osm_ucast_mgr_t;
/*
* FIELDS
@@ -204,7 +203,6 @@ osm_ucast_mgr_init(
IN osm_ucast_mgr_t* const p_mgr,
IN osm_req_t* const p_req,
IN osm_subn_t* const p_subn,
- IN char* const p_report_buf,
IN osm_log_t* const p_log,
IN cl_plock_t* const p_lock );
/*
@@ -218,9 +216,6 @@ osm_ucast_mgr_init(
* p_subn
* [in] Pointer to the Subnet object for this subnet.
*
-* p_report_buf
-* [in] Pointer to the large log buffer used for user reporting.
-*
* p_log
* [in] Pointer to the log object.
*
diff --git a/osm/opensm/libopensm.map b/osm/opensm/libopensm.map
index 60d532f..25370b1 100644
--- a/osm/opensm/libopensm.map
+++ b/osm/opensm/libopensm.map
@@ -1,6 +1,7 @@
-OPENSM_1.3 {
+OPENSM_1.4 {
global:
osm_log;
+ osm_log_printf;
osm_is_debug;
osm_log_init;
osm_log_init_v2;
diff --git a/osm/opensm/osm_log.c b/osm/opensm/osm_log.c
index 8ac7f8f..c6cc072 100644
--- a/osm/opensm/osm_log.c
+++ b/osm/opensm/osm_log.c
@@ -109,6 +109,25 @@ static void truncate_log_file(osm_log_t*
}
#endif /* ndef WIN32 */
+int osm_log_printf(osm_log_t *p_log, osm_log_level_t level,
+ const char *fmt, ...)
+{
+ va_list args;
+ int ret;
+
+ if (!(p_log->level&level))
+ return 0;
+
+ va_start(args, fmt);
+ ret = vfprintf(stdout, fmt, args);
+ va_end(args);
+
+ if (p_log->flush || level&OSM_LOG_ERROR)
+ fflush( stdout );
+
+ return ret;
+}
+
void
osm_log(
IN osm_log_t* const p_log,
diff --git a/osm/opensm/osm_mcast_mgr.c b/osm/opensm/osm_mcast_mgr.c
index 5a01578..82ef7c3 100644
--- a/osm/opensm/osm_mcast_mgr.c
+++ b/osm/opensm/osm_mcast_mgr.c
@@ -1382,14 +1382,13 @@ static void
mcast_mgr_dump_sw_routes(
IN const osm_mcast_mgr_t* const p_mgr,
IN const osm_switch_t* const p_sw,
- IN FILE *p_mcfdbFile )
+ IN FILE *file )
{
osm_mcast_tbl_t* p_tbl;
int16_t mlid_ho = 0;
int16_t mlid_start_ho;
uint8_t position = 0;
int16_t block_num = 0;
- char line[OSM_REPORT_LINE_SIZE];
boolean_t print_lid;
const osm_node_t* p_node;
uint16_t i, j;
@@ -1404,7 +1403,7 @@ mcast_mgr_dump_sw_routes(
p_tbl = osm_switch_get_mcast_tbl_ptr( p_sw );
- fprintf( p_mcfdbFile, "\nSwitch 0x%016" PRIx64 "\n"
+ fprintf( file, "\nSwitch 0x%016" PRIx64 "\n"
"LID : Out Port(s)\n",
cl_ntoh64( osm_node_get_node_guid( p_node ) ) );
while ( block_num <= p_tbl->max_block_in_use )
@@ -1415,7 +1414,7 @@ mcast_mgr_dump_sw_routes(
mlid_ho = mlid_start_ho + i;
position = 0;
print_lid = FALSE;
- sprintf( line, "0x%04X :", mlid_ho + IB_LID_MCAST_START_HO );
+ fprintf( file, "0x%04X :", mlid_ho + IB_LID_MCAST_START_HO );
while ( position <= p_tbl->max_position )
{
mask_entry = cl_ntoh16((*p_tbl->p_mask_tbl)[mlid_ho][position]);
@@ -1428,13 +1427,13 @@ mcast_mgr_dump_sw_routes(
for (j = 0 ; j < 16 ; j++)
{
if ( (1 << j) & mask_entry )
- sprintf( line, "%s 0x%03X ", line, j+(position*16) );
+ fprintf( file, " 0x%03X ", j+(position*16) );
}
position++;
}
if (print_lid)
{
- fprintf( p_mcfdbFile, "%s\n", line );
+ fprintf( file, "\n" );
}
}
block_num++;
diff --git a/osm/opensm/osm_sm.c b/osm/opensm/osm_sm.c
index fef3cac..fb4f759 100644
--- a/osm/opensm/osm_sm.c
+++ b/osm/opensm/osm_sm.c
@@ -256,9 +256,6 @@ osm_sm_destroy(
cl_event_destroy( &p_sm->signal );
cl_event_destroy( &p_sm->subnet_up_event );
- if( p_sm->p_report_buf != NULL )
- free( p_sm->p_report_buf );
-
osm_log( p_sm->p_log, OSM_LOG_SYS, "Exiting SM\n" ); /* Format Waived */
OSM_LOG_EXIT( p_sm->p_log );
}
@@ -291,15 +288,6 @@ osm_sm_init(
p_sm->p_disp = p_disp;
p_sm->p_lock = p_lock;
- p_sm->p_report_buf = malloc( OSM_REPORT_BUF_SIZE );
- if( p_sm->p_report_buf == NULL )
- {
- osm_log( p_sm->p_log, OSM_LOG_ERROR,
- "osm_sm_init: ERR 2E09: "
- "Can't allocate report buffer\n" );
- status = IB_INSUFFICIENT_MEMORY;
- goto Exit;
- }
status = cl_event_init( &p_sm->signal, FALSE );
if( status != CL_SUCCESS )
goto Exit;
@@ -385,7 +373,6 @@ osm_sm_init(
status = osm_ucast_mgr_init( &p_sm->ucast_mgr,
&p_sm->req,
p_sm->p_subn,
- p_sm->p_report_buf,
p_sm->p_log, p_sm->p_lock );
if( status != IB_SUCCESS )
goto Exit;
@@ -409,7 +396,7 @@ osm_sm_init(
&p_sm->mad_ctrl,
p_sm->p_lock,
&p_sm->subnet_up_event,
- p_sm->p_report_buf, p_sm->p_log );
+ p_sm->p_log );
if( status != IB_SUCCESS )
goto Exit;
diff --git a/osm/opensm/osm_state_mgr.c b/osm/opensm/osm_state_mgr.c
index a2efee4..66da6fa 100644
--- a/osm/opensm/osm_state_mgr.c
+++ b/osm/opensm/osm_state_mgr.c
@@ -118,7 +118,6 @@ osm_state_mgr_init(
IN const osm_sm_mad_ctrl_t * const p_mad_ctrl,
IN cl_plock_t * const p_lock,
IN cl_event_t * const p_subnet_up_event,
- IN char *const p_report_buf,
IN osm_log_t * const p_log )
{
cl_status_t status;
@@ -136,7 +135,6 @@ osm_state_mgr_init(
CL_ASSERT( p_sm_state_mgr );
CL_ASSERT( p_mad_ctrl );
CL_ASSERT( p_lock );
- CL_ASSERT( p_report_buf );
osm_state_mgr_construct( p_mgr );
@@ -154,7 +152,6 @@ osm_state_mgr_init(
p_mgr->state = OSM_SM_STATE_IDLE;
p_mgr->p_lock = p_lock;
p_mgr->p_subnet_up_event = p_subnet_up_event;
- p_mgr->p_report_buf = p_report_buf;
p_mgr->state_step_mode = OSM_STATE_STEP_CONTINUOUS;
p_mgr->next_stage_signal = OSM_SIGNAL_NONE;
@@ -1255,16 +1252,19 @@ __osm_state_mgr_report(
uint8_t port_num;
uint8_t start_port;
uint32_t num_ports;
- char line[OSM_REPORT_LINE_SIZE];
uint8_t node_type;
- uint32_t line_num = 0;
+
+ if( !osm_log_is_active( p_mgr->p_log, OSM_LOG_VERBOSE ) )
+ return;
OSM_LOG_ENTER( p_mgr->p_log, __osm_state_mgr_report );
- if( !osm_log_is_active( p_mgr->p_log, OSM_LOG_VERBOSE ) )
- {
- goto Exit;
- }
+ osm_log_printf( p_mgr->p_log, OSM_LOG_VERBOSE,
+ "\n==================================================="
+ "===================================================="
+ "\nVendor : Ty "
+ ": # : Sta : LID : LMC : MTU : LWA : LSA : Port GUID "
+ " : Neighbor Port (Port #)\n" );
p_tbl = &p_mgr->p_subn->port_guid_tbl;
@@ -1294,29 +1294,16 @@ __osm_state_mgr_report(
num_ports = osm_port_get_num_physp( p_port );
for( port_num = start_port; port_num < num_ports; port_num++ )
{
- if( line_num == 0 )
- {
- strcpy( p_mgr->p_report_buf,
- "\n==================================================="
- "====================================================" );
- strcat( p_mgr->p_report_buf,
- "\nVendor : Ty "
- ": # : Sta : LID : LMC : MTU : LWA : LSA : Port GUID "
- " : Neighbor Port (Port #)\n" );
- line_num++;
- }
-
p_physp = osm_port_get_phys_ptr( p_port, port_num );
if( ( p_physp == NULL ) || ( !osm_physp_is_valid( p_physp ) ) )
continue;
- sprintf( line, "%s : %s : %02X :",
- osm_get_manufacturer_str( cl_ntoh64
- ( osm_node_get_node_guid
- ( p_node ) ) ),
- osm_get_node_type_str_fixed_width( node_type ), port_num );
-
- strcat( p_mgr->p_report_buf, line );
+ osm_log_printf( p_mgr->p_log, OSM_LOG_VERBOSE, "%s : %s : %02X :",
+ osm_get_manufacturer_str( cl_ntoh64
+ ( osm_node_get_node_guid
+ ( p_node ) ) ),
+ osm_get_node_type_str_fixed_width( node_type ),
+ port_num );
p_pi = osm_physp_get_port_info_ptr( p_physp );
@@ -1324,61 +1311,40 @@ __osm_state_mgr_report(
* Port state is not defined for switch port 0
*/
if( port_num == 0 )
- strcat( p_mgr->p_report_buf, " :" );
+ osm_log_printf( p_mgr->p_log, OSM_LOG_VERBOSE, " :" );
else
- {
- sprintf( line, " %s :",
- osm_get_port_state_str_fixed_width
- ( ib_port_info_get_port_state( p_pi ) ) );
- strcat( p_mgr->p_report_buf, line );
- }
+ osm_log_printf( p_mgr->p_log, OSM_LOG_VERBOSE, " %s :",
+ osm_get_port_state_str_fixed_width
+ ( ib_port_info_get_port_state( p_pi ) ) );
/*
* LID values are only meaningful in select cases.
*/
- if( ib_port_info_get_port_state( p_pi ) != IB_LINK_DOWN )
- {
- if( ( ( node_type == IB_NODE_TYPE_SWITCH ) && ( port_num == 0 ) )
- || ( node_type != IB_NODE_TYPE_SWITCH ) )
- {
- sprintf( line, " %04X : %01X :",
- cl_ntoh16( p_pi->base_lid ),
- ib_port_info_get_lmc( p_pi ) );
-
- strcat( p_mgr->p_report_buf, line );
- }
- else
- strcat( p_mgr->p_report_buf, " : :" );
- }
+ if( ib_port_info_get_port_state( p_pi ) != IB_LINK_DOWN
+ && ( ( node_type == IB_NODE_TYPE_SWITCH && port_num == 0 )
+ || node_type != IB_NODE_TYPE_SWITCH ) )
+ osm_log_printf( p_mgr->p_log, OSM_LOG_VERBOSE, " %04X : %01X :",
+ cl_ntoh16( p_pi->base_lid ),
+ ib_port_info_get_lmc( p_pi ) );
else
- strcat( p_mgr->p_report_buf, " : :" );
+ osm_log_printf( p_mgr->p_log, OSM_LOG_VERBOSE, " : :" );
if( port_num != 0 )
- {
- sprintf( line, " %s : %s : %s ",
- osm_get_mtu_str( ib_port_info_get_neighbor_mtu( p_pi ) ),
- osm_get_lwa_str( p_pi->link_width_active ),
- osm_get_lsa_str( ib_port_info_get_link_speed_active
- ( p_pi ) ) );
- }
+ osm_log_printf( p_mgr->p_log, OSM_LOG_VERBOSE, " %s : %s : %s ",
+ osm_get_mtu_str( ib_port_info_get_neighbor_mtu( p_pi ) ),
+ osm_get_lwa_str( p_pi->link_width_active ),
+ osm_get_lsa_str( ib_port_info_get_link_speed_active
+ ( p_pi ) ) );
else
- {
- sprintf( line, " %s : %s : %s ", " ", " ", " " );
- }
- strcat( p_mgr->p_report_buf, line );
+ osm_log_printf( p_mgr->p_log, OSM_LOG_VERBOSE, " : : " );
if( osm_physp_get_port_guid( p_physp ) ==
p_mgr->p_subn->sm_port_guid )
- {
- sprintf( line, "* %016" PRIx64 " *",
- cl_ntoh64( osm_physp_get_port_guid( p_physp ) ) );
- }
+ osm_log_printf( p_mgr->p_log, OSM_LOG_VERBOSE, "* %016" PRIx64 " *",
+ cl_ntoh64( osm_physp_get_port_guid( p_physp ) ) );
else
- {
- sprintf( line, ": %016" PRIx64 " :",
- cl_ntoh64( osm_physp_get_port_guid( p_physp ) ) );
- }
- strcat( p_mgr->p_report_buf, line );
+ osm_log_printf( p_mgr->p_log, OSM_LOG_VERBOSE, ": %016" PRIx64 " :",
+ cl_ntoh64( osm_physp_get_port_guid( p_physp ) ) );
if( port_num &&
( ib_port_info_get_port_state( p_pi ) != IB_LINK_DOWN ) )
@@ -1386,36 +1352,26 @@ __osm_state_mgr_report(
p_remote_physp = osm_physp_get_remote( p_physp );
if( p_remote_physp && osm_physp_is_valid( p_remote_physp ) )
{
- sprintf( line, " %016" PRIx64 " (%02X)",
- cl_ntoh64( osm_physp_get_port_guid
- ( p_remote_physp ) ),
- osm_physp_get_port_num( p_remote_physp ) );
- strcat( p_mgr->p_report_buf, line );
+ osm_log_printf( p_mgr->p_log, OSM_LOG_VERBOSE,
+ " %016" PRIx64 " (%02X)",
+ cl_ntoh64( osm_physp_get_port_guid
+ ( p_remote_physp ) ),
+ osm_physp_get_port_num( p_remote_physp ) );
}
else
- strcat( p_mgr->p_report_buf, " UNKNOWN" );
+ osm_log_printf( p_mgr->p_log, OSM_LOG_VERBOSE, " UNKNOWN" );
}
- strcat( p_mgr->p_report_buf, "\n" );
-
- if( ++line_num >= OSM_REPORT_BUF_THRESHOLD )
- {
- osm_log_raw( p_mgr->p_log, OSM_LOG_VERBOSE, p_mgr->p_report_buf );
- line_num = 0;
- }
+ osm_log_printf( p_mgr->p_log, OSM_LOG_VERBOSE, "\n" );
}
- strcat( p_mgr->p_report_buf,
- "------------------------------------------------------"
- "------------------------------------------------\n" );
+
+ osm_log_printf( p_mgr->p_log, OSM_LOG_VERBOSE,
+ "------------------------------------------------------"
+ "------------------------------------------------\n" );
p_port = ( osm_port_t * ) cl_qmap_next( &p_port->map_item );
}
CL_PLOCK_RELEASE( p_mgr->p_lock );
-
- if( line_num != 0 )
- osm_log_raw( p_mgr->p_log, OSM_LOG_VERBOSE, p_mgr->p_report_buf );
-
- Exit:
OSM_LOG_EXIT( p_mgr->p_log );
}
diff --git a/osm/opensm/osm_ucast_mgr.c b/osm/opensm/osm_ucast_mgr.c
index f1d085c..fc97094 100644
--- a/osm/opensm/osm_ucast_mgr.c
+++ b/osm/opensm/osm_ucast_mgr.c
@@ -103,7 +103,6 @@ osm_ucast_mgr_init(
IN osm_ucast_mgr_t* const p_mgr,
IN osm_req_t* const p_req,
IN osm_subn_t* const p_subn,
- IN char* const p_report_buf,
IN osm_log_t* const p_log,
IN cl_plock_t* const p_lock )
{
@@ -121,7 +120,6 @@ osm_ucast_mgr_init(
p_mgr->p_subn = p_subn;
p_mgr->p_lock = p_lock;
p_mgr->p_req = p_req;
- p_mgr->p_report_buf = p_report_buf;
OSM_LOG_EXIT( p_mgr->p_log );
return( status );
@@ -184,26 +182,25 @@ __osm_ucast_mgr_dump_path_distribution(
ib_net64_t remote_guid_ho;
osm_switch_t* p_sw = (osm_switch_t *)p_map_item;
osm_ucast_mgr_t* p_mgr = ((struct ucast_mgr_dump_context *)cxt)->p_mgr;
- char line[OSM_REPORT_LINE_SIZE];
OSM_LOG_ENTER( p_mgr->p_log, __osm_ucast_mgr_dump_path_distribution );
p_node = osm_switch_get_node_ptr( p_sw );
num_ports = osm_switch_get_num_ports( p_sw );
- sprintf( p_mgr->p_report_buf, "__osm_ucast_mgr_dump_path_distribution: "
- "Switch 0x%" PRIx64 "\n"
- "Port : Path Count Through Port",
- cl_ntoh64( osm_node_get_node_guid( p_node ) ) );
+ osm_log_printf( p_mgr->p_log, OSM_LOG_DEBUG,
+ "__osm_ucast_mgr_dump_path_distribution: "
+ "Switch 0x%" PRIx64 "\n"
+ "Port : Path Count Through Port",
+ cl_ntoh64( osm_node_get_node_guid( p_node ) ) );
for( i = 0; i < num_ports; i++ )
{
num_paths = osm_switch_path_count_get( p_sw , i );
- sprintf( line, "\n %03u : %u", i, num_paths );
- strcat( p_mgr->p_report_buf, line );
+ osm_log_printf( p_mgr->p_log, OSM_LOG_DEBUG,"\n %03u : %u", i, num_paths );
if( i == 0 )
{
- strcat( p_mgr->p_report_buf, " (switch management port)" );
+ osm_log_printf( p_mgr->p_log, OSM_LOG_DEBUG, " (switch management port)" );
continue;
}
@@ -216,26 +213,24 @@ __osm_ucast_mgr_dump_path_distribution(
switch( osm_node_get_remote_type( p_node, i ) )
{
case IB_NODE_TYPE_SWITCH:
- strcat( p_mgr->p_report_buf, " (link to switch" );
+ osm_log_printf( p_mgr->p_log, OSM_LOG_DEBUG, " (link to switch" );
break;
case IB_NODE_TYPE_ROUTER:
- strcat( p_mgr->p_report_buf, " (link to router" );
+ osm_log_printf( p_mgr->p_log, OSM_LOG_DEBUG, " (link to router" );
break;
case IB_NODE_TYPE_CA:
- strcat( p_mgr->p_report_buf, " (link to CA" );
+ osm_log_printf( p_mgr->p_log, OSM_LOG_DEBUG, " (link to CA" );
break;
default:
- strcat( p_mgr->p_report_buf, " (link to unknown node type" );
+ osm_log_printf( p_mgr->p_log, OSM_LOG_DEBUG, " (link to unknown node type" );
break;
}
- sprintf( line, " 0x%" PRIx64 ")", remote_guid_ho );
- strcat( p_mgr->p_report_buf, line );
+ osm_log_printf( p_mgr->p_log, OSM_LOG_DEBUG, " 0x%" PRIx64 ")",
+ remote_guid_ho );
}
- strcat( p_mgr->p_report_buf, "\n" );
-
- osm_log_raw( p_mgr->p_log, OSM_LOG_ROUTING, p_mgr->p_report_buf );
+ osm_log_printf( p_mgr->p_log, OSM_LOG_DEBUG, "\n" );
OSM_LOG_EXIT( p_mgr->p_log );
}
@@ -254,29 +249,24 @@ __osm_ucast_mgr_dump_ucast_routes(
uint8_t best_port;
uint16_t max_lid_ho;
uint16_t lid_ho;
- uint32_t line_num = 0;
boolean_t ui_ucast_fdb_assign_func_defined;
osm_switch_t* p_sw = (osm_switch_t *)p_map_item;
osm_ucast_mgr_t* p_mgr = ((struct ucast_mgr_dump_context *)cxt)->p_mgr;
- FILE *p_fdbFile = ((struct ucast_mgr_dump_context *)cxt)->file;
- char line[OSM_REPORT_LINE_SIZE];
-
+ FILE *file = ((struct ucast_mgr_dump_context *)cxt)->file;
+
OSM_LOG_ENTER( p_mgr->p_log, __osm_ucast_mgr_dump_ucast_routes );
p_node = osm_switch_get_node_ptr( p_sw );
max_lid_ho = osm_switch_get_max_lid_ho( p_sw );
+ fprintf( file, "__osm_ucast_mgr_dump_ucast_routes: "
+ "Switch 0x%016" PRIx64 "\n"
+ "LID : Port : Hops : Optimal\n",
+ cl_ntoh64( osm_node_get_node_guid( p_node ) ) );
for( lid_ho = 1; lid_ho <= max_lid_ho; lid_ho++ )
{
- if( line_num == 0 )
- {
- sprintf( p_mgr->p_report_buf, "__osm_ucast_mgr_dump_ucast_routes: "
- "Switch 0x%016" PRIx64 "\n"
- "LID : Port : Hops : Optimal\n",
- cl_ntoh64( osm_node_get_node_guid( p_node ) ) );
- line_num++;
- }
+ fprintf(file, "0x%04X : ", lid_ho);
port_num = osm_switch_get_port_by_lid( p_sw, lid_ho );
if( port_num == OSM_NO_PATH )
@@ -287,9 +277,7 @@ __osm_ucast_mgr_dump_ucast_routes(
will reassign and compress the LID range. The
subnet should work fine either way.
*/
- sprintf( line, "0x%04X : UNREACHABLE\n", lid_ho );
- strcat( p_mgr->p_report_buf, line );
- line_num++;
+ fprintf( file, "UNREACHABLE\n" );
continue;
}
/*
@@ -301,19 +289,15 @@ __osm_ucast_mgr_dump_ucast_routes(
num_hops = osm_switch_get_hop_count( p_sw, lid_ho, port_num );
if( num_hops == OSM_NO_PATH )
{
- sprintf( line, "0x%04X : UNREACHABLE\n", lid_ho );
- strcat( p_mgr->p_report_buf, line );
- line_num++;
+ fprintf( file, "UNREACHABLE\n" );
continue;
}
best_hops = osm_switch_get_least_hops( p_sw, lid_ho );
- sprintf( line, "0x%04X : %03u : %02u : ",
- lid_ho, port_num, num_hops );
- strcat( p_mgr->p_report_buf, line );
+ fprintf( file, "%03u : %02u : ", port_num, num_hops );
if( best_hops == num_hops )
- strcat( p_mgr->p_report_buf, "yes" );
+ fprintf( file, "yes" );
else
{
if (p_mgr->p_subn->p_osm->routing_engine.ucast_fdb_assign)
@@ -328,23 +312,13 @@ __osm_ucast_mgr_dump_ucast_routes(
p_sw, lid_ho, TRUE,
NULL, NULL, NULL, NULL, /* No LMC Optimization */
ui_ucast_fdb_assign_func_defined );
- sprintf( line, "No %u hop path possible via port %u!",
+ fprintf( file, "No %u hop path possible via port %u!",
best_hops, best_port );
- strcat( p_mgr->p_report_buf, line );
}
- strcat( p_mgr->p_report_buf, "\n" );
-
- if( ++line_num >= OSM_REPORT_BUF_THRESHOLD )
- {
- fprintf(p_fdbFile,"%s",p_mgr->p_report_buf );
- line_num = 0;
- }
+ fprintf( file, "\n" );
}
- if( line_num != 0 )
- fprintf(p_fdbFile,"%s\n",p_mgr->p_report_buf );
-
OSM_LOG_EXIT( p_mgr->p_log );
}
--
1.4.3.2.g4bf7
More information about the general
mailing list