src/dpdk/drivers/net/ice/base/ice_dcb.c
static void
ice_cee_to_dcb_cfg(struct ice_aqc_get_cee_dcb_cfg_resp *cee_cfg,
		   struct ice_port_info *pi)
{
	u32 status, tlv_status = LE32_TO_CPU(cee_cfg->tlv_status);
	u32 ice_aqc_cee_status_mask, ice_aqc_cee_status_shift;
	u8 i, j, err, sync, oper, app_index, ice_app_sel_type;
	u16 app_prio = LE16_TO_CPU(cee_cfg->oper_app_prio);
	u16 ice_aqc_cee_app_mask, ice_aqc_cee_app_shift;
	struct ice_dcbx_cfg *cmp_dcbcfg, *dcbcfg;
	u16 ice_app_prot_id_type;

	dcbcfg = &pi->qos_cfg.local_dcbx_cfg;
	dcbcfg->dcbx_mode = ICE_DCBX_MODE_CEE;
	dcbcfg->tlv_status = tlv_status;

	/* CEE PG data */
	dcbcfg->etscfg.maxtcs = cee_cfg->oper_num_tc;

	/* Note that the FW creates the oper_prio_tc nibbles reversed
	 * from those in the CEE Priority Group sub-TLV.
	 */
	for (i = 0; i < ICE_MAX_TRAFFIC_CLASS / 2; i++) {
		dcbcfg->etscfg.prio_table[i * 2] =
			((cee_cfg->oper_prio_tc[i] & ICE_CEE_PGID_PRIO_0_M) >>
			 ICE_CEE_PGID_PRIO_0_S);
		dcbcfg->etscfg.prio_table[i * 2 + 1] =
			((cee_cfg->oper_prio_tc[i] & ICE_CEE_PGID_PRIO_1_M) >>
			 ICE_CEE_PGID_PRIO_1_S);
	}

	ice_for_each_traffic_class(i) {
		dcbcfg->etscfg.tcbwtable[i] = cee_cfg->oper_tc_bw[i];

		if (dcbcfg->etscfg.prio_table[i] == ICE_CEE_PGID_STRICT) {
			/* Map it to next empty TC */
			dcbcfg->etscfg.prio_table[i] = cee_cfg->oper_num_tc - 1;
			dcbcfg->etscfg.tsatable[i] = ICE_IEEE_TSA_STRICT;
		} else {
			dcbcfg->etscfg.tsatable[i] = ICE_IEEE_TSA_ETS;
		}
	}

	/* CEE PFC data */
	dcbcfg->pfc.pfcena = cee_cfg->oper_pfc_en;
	dcbcfg->pfc.pfccap = ICE_MAX_TRAFFIC_CLASS;

	/* CEE APP TLV data */
	if (dcbcfg->app_mode == ICE_DCBX_APPS_NON_WILLING)
		cmp_dcbcfg = &pi->qos_cfg.desired_dcbx_cfg;
	else
		cmp_dcbcfg = &pi->qos_cfg.remote_dcbx_cfg;

	app_index = 0;
	for (i = 0; i < 3; i++) {
		if (i == 0) {
			/* FCoE APP */
			ice_aqc_cee_status_mask = ICE_AQC_CEE_FCOE_STATUS_M;
			ice_aqc_cee_status_shift = ICE_AQC_CEE_FCOE_STATUS_S;
			ice_aqc_cee_app_mask = ICE_AQC_CEE_APP_FCOE_M;
			ice_aqc_cee_app_shift = ICE_AQC_CEE_APP_FCOE_S;
			ice_app_sel_type = ICE_APP_SEL_ETHTYPE;
			ice_app_prot_id_type = ICE_APP_PROT_ID_FCOE;
		} else if (i == 1) {
			/* iSCSI APP */
			ice_aqc_cee_status_mask = ICE_AQC_CEE_ISCSI_STATUS_M;
			ice_aqc_cee_status_shift = ICE_AQC_CEE_ISCSI_STATUS_S;
			ice_aqc_cee_app_mask = ICE_AQC_CEE_APP_ISCSI_M;
			ice_aqc_cee_app_shift = ICE_AQC_CEE_APP_ISCSI_S;
			ice_app_sel_type = ICE_APP_SEL_TCPIP;
			ice_app_prot_id_type = ICE_APP_PROT_ID_ISCSI;

			for (j = 0; j < cmp_dcbcfg->numapps; j++) {
				u16 prot_id = cmp_dcbcfg->app[j].prot_id;
				u8 sel = cmp_dcbcfg->app[j].selector;

				if  (sel == ICE_APP_SEL_TCPIP &&
				     (prot_id == ICE_APP_PROT_ID_ISCSI ||
				      prot_id == ICE_APP_PROT_ID_ISCSI_860)) {
					ice_app_prot_id_type = prot_id;
					break;
				}
			}
		} else {
			/* FIP APP */
			ice_aqc_cee_status_mask = ICE_AQC_CEE_FIP_STATUS_M;
			ice_aqc_cee_status_shift = ICE_AQC_CEE_FIP_STATUS_S;
			ice_aqc_cee_app_mask = ICE_AQC_CEE_APP_FIP_M;
			ice_aqc_cee_app_shift = ICE_AQC_CEE_APP_FIP_S;
			ice_app_sel_type = ICE_APP_SEL_ETHTYPE;
			ice_app_prot_id_type = ICE_APP_PROT_ID_FIP;
		}

		status = (tlv_status & ice_aqc_cee_status_mask) >>
			 ice_aqc_cee_status_shift;
		err = (status & ICE_TLV_STATUS_ERR) ? 1 : 0;
		sync = (status & ICE_TLV_STATUS_SYNC) ? 1 : 0;
		oper = (status & ICE_TLV_STATUS_OPER) ? 1 : 0;
		/* Add FCoE/iSCSI/FIP APP if Error is False and
		 * Oper/Sync is True
		 */
		if (!err && sync && oper) {
			dcbcfg->app[app_index].priority =
				(app_prio & ice_aqc_cee_app_mask) >>
				ice_aqc_cee_app_shift;
			dcbcfg->app[app_index].selector = ice_app_sel_type;
			dcbcfg->app[app_index].prot_id = ice_app_prot_id_type;
			app_index++;
		}
	}

	dcbcfg->numapps = app_index;
}
/**
 * ice_cee_to_dcb_cfg
 * @cee_cfg: pointer to CEE configuration struct
 * @pi: port information structure
 *
 * Convert CEE configuration from firmware to DCB configuration
 */
ice_cee_to_dcb_cfg
@cee_cfg: pointer to CEE configuration struct
@pi: port information structure

Convert CEE configuration from firmware to DCB configuration
ice_cee_to_dcb_cfg @cee_cfg : pointer to CEE configuration struct @pi : port information structure Convert CEE configuration from firmware to DCB configuration
static void
ice_cee_to_dcb_cfg(struct ice_aqc_get_cee_dcb_cfg_resp *cee_cfg,
		   struct ice_port_info *pi)
{
	u32 status, tlv_status = LE32_TO_CPU(cee_cfg->tlv_status);
	u32 ice_aqc_cee_status_mask, ice_aqc_cee_status_shift;
	u8 i, j, err, sync, oper, app_index, ice_app_sel_type;
	u16 app_prio = LE16_TO_CPU(cee_cfg->oper_app_prio);
	u16 ice_aqc_cee_app_mask, ice_aqc_cee_app_shift;
	struct ice_dcbx_cfg *cmp_dcbcfg, *dcbcfg;
	u16 ice_app_prot_id_type;
	dcbcfg = &pi->qos_cfg.local_dcbx_cfg;
	dcbcfg->dcbx_mode = ICE_DCBX_MODE_CEE;
	dcbcfg->tlv_status = tlv_status;
	dcbcfg->etscfg.maxtcs = cee_cfg->oper_num_tc;
	for (i = 0; i < ICE_MAX_TRAFFIC_CLASS / 2; i++) {
		dcbcfg->etscfg.prio_table[i * 2] =
			((cee_cfg->oper_prio_tc[i] & ICE_CEE_PGID_PRIO_0_M) >>
			 ICE_CEE_PGID_PRIO_0_S);
		dcbcfg->etscfg.prio_table[i * 2 + 1] =
			((cee_cfg->oper_prio_tc[i] & ICE_CEE_PGID_PRIO_1_M) >>
			 ICE_CEE_PGID_PRIO_1_S);
	}
	ice_for_each_traffic_class(i) {
		dcbcfg->etscfg.tcbwtable[i] = cee_cfg->oper_tc_bw[i];
		if (dcbcfg->etscfg.prio_table[i] == ICE_CEE_PGID_STRICT) {
			dcbcfg->etscfg.prio_table[i] = cee_cfg->oper_num_tc - 1;
			dcbcfg->etscfg.tsatable[i] = ICE_IEEE_TSA_STRICT;
		} else {
			dcbcfg->etscfg.tsatable[i] = ICE_IEEE_TSA_ETS;
		}
	}
	dcbcfg->pfc.pfcena = cee_cfg->oper_pfc_en;
	dcbcfg->pfc.pfccap = ICE_MAX_TRAFFIC_CLASS;
	if (dcbcfg->app_mode == ICE_DCBX_APPS_NON_WILLING)
		cmp_dcbcfg = &pi->qos_cfg.desired_dcbx_cfg;
	else
		cmp_dcbcfg = &pi->qos_cfg.remote_dcbx_cfg;
	app_index = 0;
	for (i = 0; i < 3; i++) {
		if (i == 0) {
			ice_aqc_cee_status_mask = ICE_AQC_CEE_FCOE_STATUS_M;
			ice_aqc_cee_status_shift = ICE_AQC_CEE_FCOE_STATUS_S;
			ice_aqc_cee_app_mask = ICE_AQC_CEE_APP_FCOE_M;
			ice_aqc_cee_app_shift = ICE_AQC_CEE_APP_FCOE_S;
			ice_app_sel_type = ICE_APP_SEL_ETHTYPE;
			ice_app_prot_id_type = ICE_APP_PROT_ID_FCOE;
		} else if (i == 1) {
			ice_aqc_cee_status_mask = ICE_AQC_CEE_ISCSI_STATUS_M;
			ice_aqc_cee_status_shift = ICE_AQC_CEE_ISCSI_STATUS_S;
			ice_aqc_cee_app_mask = ICE_AQC_CEE_APP_ISCSI_M;
			ice_aqc_cee_app_shift = ICE_AQC_CEE_APP_ISCSI_S;
			ice_app_sel_type = ICE_APP_SEL_TCPIP;
			ice_app_prot_id_type = ICE_APP_PROT_ID_ISCSI;
			for (j = 0; j < cmp_dcbcfg->numapps; j++) {
				u16 prot_id = cmp_dcbcfg->app[j].prot_id;
				u8 sel = cmp_dcbcfg->app[j].selector;
				if  (sel == ICE_APP_SEL_TCPIP &&
				     (prot_id == ICE_APP_PROT_ID_ISCSI ||
				      prot_id == ICE_APP_PROT_ID_ISCSI_860)) {
					ice_app_prot_id_type = prot_id;
					break;
				}
			}
		} else {
			ice_aqc_cee_status_mask = ICE_AQC_CEE_FIP_STATUS_M;
			ice_aqc_cee_status_shift = ICE_AQC_CEE_FIP_STATUS_S;
			ice_aqc_cee_app_mask = ICE_AQC_CEE_APP_FIP_M;
			ice_aqc_cee_app_shift = ICE_AQC_CEE_APP_FIP_S;
			ice_app_sel_type = ICE_APP_SEL_ETHTYPE;
			ice_app_prot_id_type = ICE_APP_PROT_ID_FIP;
		}
		status = (tlv_status & ice_aqc_cee_status_mask) >>
			 ice_aqc_cee_status_shift;
		err = (status & ICE_TLV_STATUS_ERR) ? 1 : 0;
		sync = (status & ICE_TLV_STATUS_SYNC) ? 1 : 0;
		oper = (status & ICE_TLV_STATUS_OPER) ? 1 : 0;
		if (!err && sync && oper) {
			dcbcfg->app[app_index].priority =
				(app_prio & ice_aqc_cee_app_mask) >>
				ice_aqc_cee_app_shift;
			dcbcfg->app[app_index].selector = ice_app_sel_type;
			dcbcfg->app[app_index].prot_id = ice_app_prot_id_type;
			app_index++;
		}
	}
	dcbcfg->numapps = app_index;
}
static void ice_cee_to_dcb_cfg ( struct ice_aqc_get_cee_dcb_cfg_resp * cee_cfg , struct ice_port_info * pi ) { u32 status , tlv_status = LE32_TO_CPU ( cee_cfg -> tlv_status ) ; u32 ice_aqc_cee_status_mask , ice_aqc_cee_status_shift ; u8 i , j , err , sync , oper , app_index , ice_app_sel_type ; u16 app_prio = LE16_TO_CPU ( cee_cfg -> oper_app_prio ) ; u16 ice_aqc_cee_app_mask , ice_aqc_cee_app_shift ; struct ice_dcbx_cfg * cmp_dcbcfg , * dcbcfg ; u16 ice_app_prot_id_type ; dcbcfg = & pi -> qos_cfg . local_dcbx_cfg ; dcbcfg -> dcbx_mode = ICE_DCBX_MODE_CEE ; dcbcfg -> tlv_status = tlv_status ; dcbcfg -> etscfg . maxtcs = cee_cfg -> oper_num_tc ; for ( i = 0 ; i < ICE_MAX_TRAFFIC_CLASS / 2 ; i ++ ) { dcbcfg -> etscfg . prio_table [ i * 2 ] = ( ( cee_cfg -> oper_prio_tc [ i ] & ICE_CEE_PGID_PRIO_0_M ) >> ICE_CEE_PGID_PRIO_0_S ) ; dcbcfg -> etscfg . prio_table [ i * 2 + 1 ] = ( ( cee_cfg -> oper_prio_tc [ i ] & ICE_CEE_PGID_PRIO_1_M ) >> ICE_CEE_PGID_PRIO_1_S ) ; } ice_for_each_traffic_class ( i ) { dcbcfg -> etscfg . tcbwtable [ i ] = cee_cfg -> oper_tc_bw [ i ] ; if ( dcbcfg -> etscfg . prio_table [ i ] == ICE_CEE_PGID_STRICT ) { dcbcfg -> etscfg . prio_table [ i ] = cee_cfg -> oper_num_tc - 1 ; dcbcfg -> etscfg . tsatable [ i ] = ICE_IEEE_TSA_STRICT ; } else { dcbcfg -> etscfg . tsatable [ i ] = ICE_IEEE_TSA_ETS ; } } dcbcfg -> pfc . pfcena = cee_cfg -> oper_pfc_en ; dcbcfg -> pfc . pfccap = ICE_MAX_TRAFFIC_CLASS ; if ( dcbcfg -> app_mode == ICE_DCBX_APPS_NON_WILLING ) cmp_dcbcfg = & pi -> qos_cfg . desired_dcbx_cfg ; else cmp_dcbcfg = & pi -> qos_cfg . remote_dcbx_cfg ; app_index = 0 ; for ( i = 0 ; i < 3 ; i ++ ) { if ( i == 0 ) { ice_aqc_cee_status_mask = ICE_AQC_CEE_FCOE_STATUS_M ; ice_aqc_cee_status_shift = ICE_AQC_CEE_FCOE_STATUS_S ; ice_aqc_cee_app_mask = ICE_AQC_CEE_APP_FCOE_M ; ice_aqc_cee_app_shift = ICE_AQC_CEE_APP_FCOE_S ; ice_app_sel_type = ICE_APP_SEL_ETHTYPE ; ice_app_prot_id_type = ICE_APP_PROT_ID_FCOE ; } else if ( i == 1 ) { ice_aqc_cee_status_mask = ICE_AQC_CEE_ISCSI_STATUS_M ; ice_aqc_cee_status_shift = ICE_AQC_CEE_ISCSI_STATUS_S ; ice_aqc_cee_app_mask = ICE_AQC_CEE_APP_ISCSI_M ; ice_aqc_cee_app_shift = ICE_AQC_CEE_APP_ISCSI_S ; ice_app_sel_type = ICE_APP_SEL_TCPIP ; ice_app_prot_id_type = ICE_APP_PROT_ID_ISCSI ; for ( j = 0 ; j < cmp_dcbcfg -> numapps ; j ++ ) { u16 prot_id = cmp_dcbcfg -> app [ j ] . prot_id ; u8 sel = cmp_dcbcfg -> app [ j ] . selector ; if ( sel == ICE_APP_SEL_TCPIP && ( prot_id == ICE_APP_PROT_ID_ISCSI || prot_id == ICE_APP_PROT_ID_ISCSI_860 ) ) { ice_app_prot_id_type = prot_id ; break ; } } } else { ice_aqc_cee_status_mask = ICE_AQC_CEE_FIP_STATUS_M ; ice_aqc_cee_status_shift = ICE_AQC_CEE_FIP_STATUS_S ; ice_aqc_cee_app_mask = ICE_AQC_CEE_APP_FIP_M ; ice_aqc_cee_app_shift = ICE_AQC_CEE_APP_FIP_S ; ice_app_sel_type = ICE_APP_SEL_ETHTYPE ; ice_app_prot_id_type = ICE_APP_PROT_ID_FIP ; } status = ( tlv_status & ice_aqc_cee_status_mask ) >> ice_aqc_cee_status_shift ; err = ( status & ICE_TLV_STATUS_ERR ) ? 1 : 0 ; sync = ( status & ICE_TLV_STATUS_SYNC ) ? 1 : 0 ; oper = ( status & ICE_TLV_STATUS_OPER ) ? 1 : 0 ; if ( ! err && sync && oper ) { dcbcfg -> app [ app_index ] . priority = ( app_prio & ice_aqc_cee_app_mask ) >> ice_aqc_cee_app_shift ; dcbcfg -> app [ app_index ] . selector = ice_app_sel_type ; dcbcfg -> app [ app_index ] . prot_id = ice_app_prot_id_type ; app_index ++ ; } } dcbcfg -> numapps = app_index ; }
ice_cee_to_dcb_cfg
 @cee_cfg: pointer to CEE configuration struct
 @pi: port information structure
ice_cee_to_dcb_cfg @cee_cfg : pointer to CEE configuration struct @pi : port information structure
/* CEE PG data */ /* Note that the FW creates the oper_prio_tc nibbles reversed
	 * from those in the CEE Priority Group sub-TLV.
	 */ /* Map it to next empty TC */ /* CEE PFC data */ /* CEE APP TLV data */ /* FCoE APP */ /* iSCSI APP */ /* FIP APP */ /* Add FCoE/iSCSI/FIP APP if Error is False and
		 * Oper/Sync is True
		 */