FreeBSD/sys/cam/scsi/smp_all.c
/*
 * Decode the SMP REPORT GENERAL response.  The format is current as of SPL
 * Revision 7, but the parsing should be backward compatible for older
 * versions of the spec.
 */
Decode the SMP REPORT GENERAL response.  The format is current as of SPL
Revision 7, but the parsing should be backward compatible for older
versions of the spec.
Decode the SMP REPORT GENERAL response . The format is current as of SPL Revision 7 but the parsing should be backward compatible for older versions of the spec .
void
smp_report_general_sbuf(struct smp_report_general_response *response,
			int response_len, struct sbuf *sb)
{
	sbuf_printf(sb, "Report General\n");
	sbuf_printf(sb, "Response Length: %d words (%d bytes)\n",
		    response->response_len,
		    response->response_len * SMP_WORD_LEN);
	sbuf_printf(sb, "Expander Change Count: %d\n",
		    scsi_2btoul(response->expander_change_count));
	sbuf_printf(sb, "Expander Route Indexes: %d\n", 
		    scsi_2btoul(response->expander_route_indexes));
	sbuf_printf(sb, "Long Response: %s\n",
		    smp_yesno(response->long_response &
			      SMP_RG_LONG_RESPONSE));
	sbuf_printf(sb, "Number of Phys: %d\n", response->num_phys);
	sbuf_printf(sb, "Table to Table Supported: %s\n",
		    smp_yesno(response->config_bits0 &
		    SMP_RG_TABLE_TO_TABLE_SUP));
	sbuf_printf(sb, "Zone Configuring: %s\n", 
		    smp_yesno(response->config_bits0 &
		    SMP_RG_ZONE_CONFIGURING));
	sbuf_printf(sb, "Self Configuring: %s\n", 
		    smp_yesno(response->config_bits0 &
		    SMP_RG_SELF_CONFIGURING));
	sbuf_printf(sb, "STP Continue AWT: %s\n", 
		    smp_yesno(response->config_bits0 &
		    SMP_RG_STP_CONTINUE_AWT));
	sbuf_printf(sb, "Open Reject Retry Supported: %s\n", 
		    smp_yesno(response->config_bits0 &
		    SMP_RG_OPEN_REJECT_RETRY_SUP));
	sbuf_printf(sb, "Configures Others: %s\n", 
		    smp_yesno(response->config_bits0 &
		    SMP_RG_CONFIGURES_OTHERS));
	sbuf_printf(sb, "Configuring: %s\n", 
		    smp_yesno(response->config_bits0 &
		    SMP_RG_CONFIGURING));
	sbuf_printf(sb, "Externally Configurable Route Table: %s\n", 
		    smp_yesno(response->config_bits0 &
		    SMP_RG_CONFIGURING));
	sbuf_printf(sb, "Enclosure Logical Identifier: 0x%016jx\n",
		    (uintmax_t)scsi_8btou64(response->encl_logical_id));
	if ((response->response_len == 0)
	 || (response_len < (sizeof(struct smp_report_general_response) -
	     sizeof(response->crc))))
		return;
	sbuf_printf(sb, "STP Bus Inactivity Time Limit: %d\n",
		    scsi_2btoul(response->stp_bus_inact_time_limit));
	sbuf_printf(sb, "STP Maximum Connect Time Limit: %d\n",
		    scsi_2btoul(response->stp_max_conn_time_limit));
	sbuf_printf(sb, "STP SMP I_T Nexus Loss Time: %d\n",
		    scsi_2btoul(response->stp_smp_it_nexus_loss_time));
	sbuf_printf(sb, "Number of Zone Groups: %d\n",
		    (response->config_bits1 & SMP_RG_NUM_ZONE_GROUPS_MASK) >>
		    SMP_RG_NUM_ZONE_GROUPS_SHIFT);
	sbuf_printf(sb, "Zone Locked: %s\n",
		    smp_yesno(response->config_bits1 & SMP_RG_ZONE_LOCKED));
	sbuf_printf(sb, "Physical Presence Supported: %s\n",
		    smp_yesno(response->config_bits1 & SMP_RG_PP_SUPPORTED));
	sbuf_printf(sb, "Physical Presence Asserted: %s\n",
		    smp_yesno(response->config_bits1 & SMP_RG_PP_ASSERTED));
	sbuf_printf(sb, "Zoning Supported: %s\n",
		    smp_yesno(response->config_bits1 &
			      SMP_RG_ZONING_SUPPORTED));
	sbuf_printf(sb, "Zoning Enabled: %s\n",
		    smp_yesno(response->config_bits1 & SMP_RG_ZONING_ENABLED));
	sbuf_printf(sb, "Saving: %s\n",
		    smp_yesno(response->config_bits2 & SMP_RG_SAVING));
	sbuf_printf(sb, "Saving Zone Manager Password Supported: %s\n",
		    smp_yesno(response->config_bits2 &
			      SMP_RG_SAVING_ZM_PWD_SUP));
	sbuf_printf(sb, "Saving Zone Phy Information Supported: %s\n",
		    smp_yesno(response->config_bits2 &
			      SMP_RG_SAVING_PHY_INFO_SUP));
	sbuf_printf(sb, "Saving Zone Permission Table Supported: %s\n",
		    smp_yesno(response->config_bits2 &
			      SMP_RG_SAVING_ZPERM_TAB_SUP));
	sbuf_printf(sb, "Saving Zoning Enabled Supported: %s\n",
		    smp_yesno(response->config_bits2 &
			      SMP_RG_SAVING_ZENABLED_SUP));
	sbuf_printf(sb, "Maximum Number of Routed SAS Addresses: %d\n",
		    scsi_2btoul(response->max_num_routed_addrs));
	sbuf_printf(sb, "Active Zone Manager SAS Address: 0x%016jx\n",
		    scsi_8btou64(response->active_zm_address));
	sbuf_printf(sb, "Zone Inactivity Time Limit: %d\n",
		    scsi_2btoul(response->zone_lock_inact_time_limit));
	sbuf_printf(sb, "First Enclosure Connector Element Index: %d\n",
		    response->first_encl_conn_el_index);
	sbuf_printf(sb, "Number of Enclosure Connector Element Indexes: %d\n",
		    response->num_encl_conn_el_indexes);
	sbuf_printf(sb, "Reduced Functionality: %s\n",
		    smp_yesno(response->reduced_functionality &
			      SMP_RG_REDUCED_FUNCTIONALITY));
	sbuf_printf(sb, "Time to Reduced Functionality: %d\n",
		    response->time_to_reduced_func);
	sbuf_printf(sb, "Initial Time to Reduced Functionality: %d\n",
		    response->initial_time_to_reduced_func);
	sbuf_printf(sb, "Maximum Reduced Functionality Time: %d\n",
		    response->max_reduced_func_time);
	sbuf_printf(sb, "Last Self-Configuration Status Descriptor Index: %d\n",
		    scsi_2btoul(response->last_sc_stat_desc_index));
	sbuf_printf(sb, "Maximum Number of Storated Self-Configuration "
		    "Status Descriptors: %d\n",
		    scsi_2btoul(response->max_sc_stat_descs));
	sbuf_printf(sb, "Last Phy Event List Descriptor Index: %d\n",
		    scsi_2btoul(response->last_phy_evl_desc_index));
	sbuf_printf(sb, "Maximum Number of Stored Phy Event List "
		    "Descriptors: %d\n",
		    scsi_2btoul(response->max_stored_pel_descs));
	sbuf_printf(sb, "STP Reject to Open Limit: %d\n",
		    scsi_2btoul(response->stp_reject_to_open_limit));
}
void smp_report_general_sbuf ( struct smp_report_general_response * response , int response_len , struct sbuf * sb ) { sbuf_printf ( sb , " \n " ) ; sbuf_printf ( sb , " \n " , response -> response_len , response -> response_len * SMP_WORD_LEN ) ; sbuf_printf ( sb , " \n " , scsi_2btoul ( response -> expander_change_count ) ) ; sbuf_printf ( sb , " \n " , scsi_2btoul ( response -> expander_route_indexes ) ) ; sbuf_printf ( sb , " \n " , smp_yesno ( response -> long_response & SMP_RG_LONG_RESPONSE ) ) ; sbuf_printf ( sb , " \n " , response -> num_phys ) ; sbuf_printf ( sb , " \n " , smp_yesno ( response -> config_bits0 & SMP_RG_TABLE_TO_TABLE_SUP ) ) ; sbuf_printf ( sb , " \n " , smp_yesno ( response -> config_bits0 & SMP_RG_ZONE_CONFIGURING ) ) ; sbuf_printf ( sb , " \n " , smp_yesno ( response -> config_bits0 & SMP_RG_SELF_CONFIGURING ) ) ; sbuf_printf ( sb , " \n " , smp_yesno ( response -> config_bits0 & SMP_RG_STP_CONTINUE_AWT ) ) ; sbuf_printf ( sb , " \n " , smp_yesno ( response -> config_bits0 & SMP_RG_OPEN_REJECT_RETRY_SUP ) ) ; sbuf_printf ( sb , " \n " , smp_yesno ( response -> config_bits0 & SMP_RG_CONFIGURES_OTHERS ) ) ; sbuf_printf ( sb , " \n " , smp_yesno ( response -> config_bits0 & SMP_RG_CONFIGURING ) ) ; sbuf_printf ( sb , " \n " , smp_yesno ( response -> config_bits0 & SMP_RG_CONFIGURING ) ) ; sbuf_printf ( sb , " \n " , ( uintmax_t ) scsi_8btou64 ( response -> encl_logical_id ) ) ; if ( ( response -> response_len == 0 ) || ( response_len < ( sizeof ( struct smp_report_general_response ) - sizeof ( response -> crc ) ) ) ) return ; sbuf_printf ( sb , " \n " , scsi_2btoul ( response -> stp_bus_inact_time_limit ) ) ; sbuf_printf ( sb , " \n " , scsi_2btoul ( response -> stp_max_conn_time_limit ) ) ; sbuf_printf ( sb , " \n " , scsi_2btoul ( response -> stp_smp_it_nexus_loss_time ) ) ; sbuf_printf ( sb , " \n " , ( response -> config_bits1 & SMP_RG_NUM_ZONE_GROUPS_MASK ) >> SMP_RG_NUM_ZONE_GROUPS_SHIFT ) ; sbuf_printf ( sb , " \n " , smp_yesno ( response -> config_bits1 & SMP_RG_ZONE_LOCKED ) ) ; sbuf_printf ( sb , " \n " , smp_yesno ( response -> config_bits1 & SMP_RG_PP_SUPPORTED ) ) ; sbuf_printf ( sb , " \n " , smp_yesno ( response -> config_bits1 & SMP_RG_PP_ASSERTED ) ) ; sbuf_printf ( sb , " \n " , smp_yesno ( response -> config_bits1 & SMP_RG_ZONING_SUPPORTED ) ) ; sbuf_printf ( sb , " \n " , smp_yesno ( response -> config_bits1 & SMP_RG_ZONING_ENABLED ) ) ; sbuf_printf ( sb , " \n " , smp_yesno ( response -> config_bits2 & SMP_RG_SAVING ) ) ; sbuf_printf ( sb , " \n " , smp_yesno ( response -> config_bits2 & SMP_RG_SAVING_ZM_PWD_SUP ) ) ; sbuf_printf ( sb , " \n " , smp_yesno ( response -> config_bits2 & SMP_RG_SAVING_PHY_INFO_SUP ) ) ; sbuf_printf ( sb , " \n " , smp_yesno ( response -> config_bits2 & SMP_RG_SAVING_ZPERM_TAB_SUP ) ) ; sbuf_printf ( sb , " \n " , smp_yesno ( response -> config_bits2 & SMP_RG_SAVING_ZENABLED_SUP ) ) ; sbuf_printf ( sb , " \n " , scsi_2btoul ( response -> max_num_routed_addrs ) ) ; sbuf_printf ( sb , " \n " , scsi_8btou64 ( response -> active_zm_address ) ) ; sbuf_printf ( sb , " \n " , scsi_2btoul ( response -> zone_lock_inact_time_limit ) ) ; sbuf_printf ( sb , " \n " , response -> first_encl_conn_el_index ) ; sbuf_printf ( sb , " \n " , response -> num_encl_conn_el_indexes ) ; sbuf_printf ( sb , " \n " , smp_yesno ( response -> reduced_functionality & SMP_RG_REDUCED_FUNCTIONALITY ) ) ; sbuf_printf ( sb , " \n " , response -> time_to_reduced_func ) ; sbuf_printf ( sb , " \n " , response -> initial_time_to_reduced_func ) ; sbuf_printf ( sb , " \n " , response -> max_reduced_func_time ) ; sbuf_printf ( sb , " \n " , scsi_2btoul ( response -> last_sc_stat_desc_index ) ) ; sbuf_printf ( sb , " " " \n " , scsi_2btoul ( response -> max_sc_stat_descs ) ) ; sbuf_printf ( sb , " \n " , scsi_2btoul ( response -> last_phy_evl_desc_index ) ) ; sbuf_printf ( sb , " " " \n " , scsi_2btoul ( response -> max_stored_pel_descs ) ) ; sbuf_printf ( sb , " \n " , scsi_2btoul ( response -> stp_reject_to_open_limit ) ) ; }
Decode the SMP REPORT GENERAL response.
Decode the SMP REPORT GENERAL response .
/*
	 * If the response->response_len is 0, then we don't have the
	 * extended information.  Also, if the user didn't allocate enough
	 * space for the full request, don't try to parse it.
	 */