opensm/osm_trap_rcv.c: Minor reorganization of trap_rcv_process_request
PATCH 1/1 opensm/osm_trap_rcv.c: Minor reorganization of trap_rcv_process_request
Move some code out into separate log_trap_info routine for readability/maintainability
---
opensm/opensm/osm_trap_rcv.c +47 -53
@@ -275,11 +275,51 @@ static int disable_port(osm_sm_t *sm, osm_physp_t *p)return ret; } +static void log_trap_info (osm_log_t *p_log,ib_mad_notice_attr_t *p_ntci, +ib_net16_t source_lid,ib_net64_t trans_id) +{ +if (ib_notice_is_generic (p_ntci)) { +if ((p_ntci->g_or_v.generic.trap_num ==CL_HTON16 (129 )) || + (p_ntci->g_or_v.generic.trap_num ==CL_HTON16 (130 )) || + (p_ntci->g_or_v.generic.trap_num ==CL_HTON16 (131 ))) +OSM_LOG (p_log,OSM_LOG_ERROR , +"Received Generic Notice type:%u " +"num:%u (%s) Producer:%u (%s) " +"from LID:%u Port %d TID:0x%016" PRIx64"\n" , +ib_notice_get_type (p_ntci), +cl_ntoh16 (p_ntci->g_or_v.generic.trap_num), +ib_get_trap_str (p_ntci->g_or_v.generic.trap_num), +cl_ntoh32 (ib_notice_get_prod_type (p_ntci)), +ib_get_producer_type_str (ib_notice_get_prod_type (p_ntci)), +cl_hton16 (source_lid), + p_ntci->data_details.ntc_129_131.port_num, +cl_ntoh64 (trans_id)); +else +OSM_LOG (p_log,OSM_LOG_ERROR , +"Received Generic Notice type:%u " +"num:%u (%s) Producer:%u (%s) " +"from LID:%u TID:0x%016" PRIx64"\n" , +ib_notice_get_type (p_ntci), +cl_ntoh16 (p_ntci->g_or_v.generic.trap_num), +ib_get_trap_str (p_ntci->g_or_v.generic.trap_num), +cl_ntoh32 (ib_notice_get_prod_type (p_ntci)), +ib_get_producer_type_str (ib_notice_get_prod_type (p_ntci)), +cl_hton16 (source_lid), +cl_ntoh64 (trans_id)); + }else +OSM_LOG (p_log,OSM_LOG_ERROR , +"Received Vendor Notice type:%u vend:0x%06X " +"dev:%u from LID:%u TID:0x%016" PRIx64"\n" , +ib_notice_get_type (p_ntci), +cl_ntoh32 (ib_notice_get_vend_id (p_ntci)), +cl_ntoh16 (p_ntci->g_or_v.vend.dev_id), +cl_ntoh16 (source_lid),cl_ntoh64 (trans_id)); +} +/********************************************************************** **********************************************************************/ static void -trap_rcv_process_request(IN osm_sm_t * sm, - IN const osm_madw_t * const p_madw) +trap_rcv_process_request(IN osm_sm_t * sm, IN const osm_madw_t * const p_madw) {uint8_t payload[sizeof (ib_mad_notice_attr_t)];ib_smp_t *p_smp;
@@ -362,59 +402,13 @@ trap_rcv_process_request(IN osm_sm_t * sm, source_lid = tmp_madw.mad_addr.addr_type.smi.source_lid;/* Print some info about the incoming Trap */ -if (ib_notice_is_generic (p_ntci)) { -if ((p_ntci->g_or_v.generic.trap_num ==CL_HTON16 (129 )) - || (p_ntci->g_or_v.generic.trap_num == -CL_HTON16 (130 )) - || (p_ntci->g_or_v.generic.trap_num == -CL_HTON16 (131 ))) -OSM_LOG (sm->p_log,OSM_LOG_ERROR , -"Received Generic Notice type:%u " -"num:%u (%s) Producer:%u (%s) " -"from LID:%u Port %d TID:0x%016" - PRIx64"\n" ,ib_notice_get_type (p_ntci), -cl_ntoh16 (p_ntci->g_or_v.generic. - trap_num), -ib_get_trap_str (p_ntci->g_or_v.generic. - trap_num), -cl_ntoh32 (ib_notice_get_prod_type - (p_ntci)), -ib_get_producer_type_str - (ib_notice_get_prod_type (p_ntci)), -cl_hton16 (source_lid), - p_ntci->data_details.ntc_129_131. - port_num,cl_ntoh64 (p_smp->trans_id)); -else -OSM_LOG (sm->p_log,OSM_LOG_ERROR , -"Received Generic Notice type:%u " -"num:%u (%s) Producer:%u (%s) " -"from LID:%u TID:0x%016" PRIx64 -"\n" ,ib_notice_get_type (p_ntci), -cl_ntoh16 (p_ntci->g_or_v.generic. - trap_num), -ib_get_trap_str (p_ntci->g_or_v.generic. - trap_num), -cl_ntoh32 (ib_notice_get_prod_type - (p_ntci)), -ib_get_producer_type_str - (ib_notice_get_prod_type (p_ntci)), -cl_hton16 (source_lid), -cl_ntoh64 (p_smp->trans_id)); - }else -OSM_LOG (sm->p_log,OSM_LOG_ERROR , -"Received Vendor Notice type:%u vend:0x%06X " -"dev:%u from LID:%u TID:0x%016" PRIx64"\n" , -ib_notice_get_type (p_ntci), -cl_ntoh32 (ib_notice_get_vend_id (p_ntci)), -cl_ntoh16 (p_ntci->g_or_v.vend.dev_id), -cl_ntoh16 (source_lid), -cl_ntoh64 (p_smp->trans_id)); +log_trap_info (sm->p_log, p_ntci, source_lid, p_smp->trans_id); }osm_dump_notice (sm->p_log, p_ntci,OSM_LOG_VERBOSE ); - p_physp =osm_get_physp_by_mad_addr (sm->p_log, - sm->p_subn, &tmp_madw.mad_addr); + p_physp =osm_get_physp_by_mad_addr (sm->p_log, sm->p_subn, + &tmp_madw.mad_addr);if (p_physp) p_smp->m_key = p_physp->port_info.m_key;else
@@ -528,8 +522,8 @@ trap_rcv_process_request(IN osm_sm_t * sm, }/* restart the aging anyway */ -/* If physp_change_trap is TRUE - then use a callback to unset the -healthy bit. If not - no need to use a callback. */ +/* If physp_change_trap is TRUE - then use a callback to unset +the healthy bit. If not - no need to use a callback. */ if (physp_change_trap == TRUE)cl_event_wheel_reg (&sm->trap_aging_tracker, trap_key,cl_get_time_stamp () + event_wheel_timeout, osm_trap_rcv_aging_tracker_callback,/* no callback */ sm/* no context */ );
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
A message that is not in the archive (sent off-list or not yet received): [email protected]
Sasha Khapyorsky
AppliedQuoted 5 lines · Hal Rosenstock
Move some code out into separate
log_trap_inforoutine for readability/maintainabilitySigned-off-by Hal Rosenstock <[email protected]>
Applied. Thanks.
Sasha
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 1/1 opensm/osm_trap_rcv.c: Improvements in log_trap_info()
In reply to a message not in the archiveIn log_trap_info() return when log level is not requested, merge generic notice logging code.
--- opensm/opensm/osm_trap_rcv.c | 42 +++++++++++++++++++----------------------- 1 files changed, 19 insertions(+), 23 deletions(-)
opensm/opensm/osm_trap_rcv.c +19 -23
@@ -278,34 +278,30 @@ static int disable_port(osm_sm_t *sm, osm_physp_t *p)static void log_trap_info (osm_log_t *p_log,ib_mad_notice_attr_t *p_ntci,ib_net16_t source_lid,ib_net64_t trans_id) { +if (!osm_log_is_active (p_log,OSM_LOG_ERROR )) +return ; +if (ib_notice_is_generic (p_ntci)) { +char str[32 ]; +if ((p_ntci->g_or_v.generic.trap_num ==CL_HTON16 (129 )) || (p_ntci->g_or_v.generic.trap_num ==CL_HTON16 (130 )) || (p_ntci->g_or_v.generic.trap_num ==CL_HTON16 (131 ))) -OSM_LOG (p_log,OSM_LOG_ERROR , -"Received Generic Notice type:%u " -"num:%u (%s) Producer:%u (%s) " -"from LID:%u Port %d TID:0x%016" PRIx64"\n" , -ib_notice_get_type (p_ntci), -cl_ntoh16 (p_ntci->g_or_v.generic.trap_num), -ib_get_trap_str (p_ntci->g_or_v.generic.trap_num), -cl_ntoh32 (ib_notice_get_prod_type (p_ntci)), -ib_get_producer_type_str (ib_notice_get_prod_type (p_ntci)), -cl_hton16 (source_lid), - p_ntci->data_details.ntc_129_131.port_num, -cl_ntoh64 (trans_id)); +snprintf (str,sizeof (str)," Port %u" , + p_ntci->data_details.ntc_129_131.port_num);else -OSM_LOG (p_log,OSM_LOG_ERROR , -"Received Generic Notice type:%u " -"num:%u (%s) Producer:%u (%s) " -"from LID:%u TID:0x%016" PRIx64"\n" , -ib_notice_get_type (p_ntci), -cl_ntoh16 (p_ntci->g_or_v.generic.trap_num), -ib_get_trap_str (p_ntci->g_or_v.generic.trap_num), -cl_ntoh32 (ib_notice_get_prod_type (p_ntci)), -ib_get_producer_type_str (ib_notice_get_prod_type (p_ntci)), -cl_hton16 (source_lid), -cl_ntoh64 (trans_id)); + str[0 ] ='\0' ; + +OSM_LOG (p_log,OSM_LOG_ERROR , +"Received Generic Notice type:%u " +"num:%u (%s) Producer:%u (%s) " +"from LID:%u%s TID:0x%016" PRIx64"\n" , +ib_notice_get_type (p_ntci), +cl_ntoh16 (p_ntci->g_or_v.generic.trap_num), +ib_get_trap_str (p_ntci->g_or_v.generic.trap_num), +cl_ntoh32 (ib_notice_get_prod_type (p_ntci)), +ib_get_producer_type_str (ib_notice_get_prod_type (p_ntci)), +cl_hton16 (source_lid), str,cl_ntoh64 (trans_id)); }else OSM_LOG (p_log,OSM_LOG_ERROR , "Received Vendor Notice type:%u vend:0x%06X "
Signature · 6 lines
1.6.5.1 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html