Lines Matching +full:non +full:- +full:contiguous

1 // SPDX-License-Identifier: GPL-2.0
9 * ice_dcb_get_ena_tc - return bitmap of enabled TCs
43 if (vsi->tc_cfg.ena_tc & BIT(i)) in ice_is_pfc_causing_hung_q()
47 for (tc = 0; tc < num_tcs - 1; tc++) in ice_is_pfc_causing_hung_q()
48 if (ice_find_q_in_range(vsi->tc_cfg.tc_info[tc].qoffset, in ice_is_pfc_causing_hung_q()
49 vsi->tc_cfg.tc_info[tc + 1].qoffset, in ice_is_pfc_causing_hung_q()
56 up2tc = rd32(&pf->hw, PRTDCB_TUP2TC); in ice_is_pfc_causing_hung_q()
70 ref_prio_xoff[i] = pf->stats.priority_xoff_rx[i]; in ice_is_pfc_causing_hung_q()
76 if (pf->stats.priority_xoff_rx[i] > ref_prio_xoff[i]) in ice_is_pfc_causing_hung_q()
83 * ice_dcb_get_mode - gets the DCB mode
96 if (port_info->qos_cfg.local_dcbx_cfg.dcbx_mode & ICE_DCBX_MODE_CEE) in ice_dcb_get_mode()
103 * ice_dcb_get_num_tc - Get the number of TCs from DCBX config
117 num_tc |= BIT(dcbcfg->etscfg.prio_table[i]); in ice_dcb_get_num_tc()
119 /* Scan bitmask for contiguous TCs starting with TC0 */ in ice_dcb_get_num_tc()
125 pr_err("Non-contiguous TCs - Disabling DCB\n"); in ice_dcb_get_num_tc()
141 * ice_get_first_droptc - returns number of first droptc
151 struct ice_dcbx_cfg *cfg = &vsi->port_info->qos_cfg.local_dcbx_cfg; in ice_get_first_droptc()
152 struct device *dev = ice_pf_to_dev(vsi->back); in ice_get_first_droptc()
162 pfc_ena_map = cfg->pfc.pfcena; in ice_get_first_droptc()
177 * ice_vsi_set_dcb_tc_cfg - Set VSI's TC based on DCB configuration
182 struct ice_dcbx_cfg *cfg = &vsi->port_info->qos_cfg.local_dcbx_cfg; in ice_vsi_set_dcb_tc_cfg()
184 switch (vsi->type) { in ice_vsi_set_dcb_tc_cfg()
186 vsi->tc_cfg.ena_tc = ice_dcb_get_ena_tc(cfg); in ice_vsi_set_dcb_tc_cfg()
187 vsi->tc_cfg.numtc = ice_dcb_get_num_tc(cfg); in ice_vsi_set_dcb_tc_cfg()
191 vsi->tc_cfg.ena_tc = BIT(ice_get_first_droptc(vsi)); in ice_vsi_set_dcb_tc_cfg()
192 vsi->tc_cfg.numtc = 1; in ice_vsi_set_dcb_tc_cfg()
197 vsi->tc_cfg.ena_tc = ICE_DFLT_TRAFFIC_CLASS; in ice_vsi_set_dcb_tc_cfg()
198 vsi->tc_cfg.numtc = 1; in ice_vsi_set_dcb_tc_cfg()
203 * ice_dcb_get_tc - Get the TC associated with the queue
209 return vsi->tx_rings[queue_index]->dcb_tc; in ice_dcb_get_tc()
213 * ice_vsi_cfg_dcb_rings - Update rings to reflect DCB TC
223 if (!test_bit(ICE_FLAG_DCB_ENA, vsi->back->flags)) { in ice_vsi_cfg_dcb_rings()
226 tx_ring = vsi->tx_rings[i]; in ice_vsi_cfg_dcb_rings()
227 tx_ring->dcb_tc = 0; in ice_vsi_cfg_dcb_rings()
230 rx_ring = vsi->rx_rings[i]; in ice_vsi_cfg_dcb_rings()
231 rx_ring->dcb_tc = 0; in ice_vsi_cfg_dcb_rings()
237 if (!(vsi->tc_cfg.ena_tc & BIT(n))) in ice_vsi_cfg_dcb_rings()
240 qoffset = vsi->tc_cfg.tc_info[n].qoffset; in ice_vsi_cfg_dcb_rings()
241 qcount = vsi->tc_cfg.tc_info[n].qcount_tx; in ice_vsi_cfg_dcb_rings()
243 vsi->tx_rings[i]->dcb_tc = n; in ice_vsi_cfg_dcb_rings()
245 qcount = vsi->tc_cfg.tc_info[n].qcount_rx; in ice_vsi_cfg_dcb_rings()
247 vsi->rx_rings[i]->dcb_tc = n; in ice_vsi_cfg_dcb_rings()
252 if (vsi->all_enatc) { in ice_vsi_cfg_dcb_rings()
259 if (!(vsi->all_enatc & BIT(n))) in ice_vsi_cfg_dcb_rings()
262 qoffset = vsi->mqprio_qopt.qopt.offset[n]; in ice_vsi_cfg_dcb_rings()
263 qcount = vsi->mqprio_qopt.qopt.count[n]; in ice_vsi_cfg_dcb_rings()
265 vsi->tx_rings[i]->dcb_tc = first_droptc; in ice_vsi_cfg_dcb_rings()
266 vsi->rx_rings[i]->dcb_tc = first_droptc; in ice_vsi_cfg_dcb_rings()
273 * ice_dcb_ena_dis_vsi - disable certain VSIs for DCB config/reconfig
288 struct ice_vsi *vsi = pf->vsi[i]; in ice_dcb_ena_dis_vsi()
293 switch (vsi->type) { in ice_dcb_ena_dis_vsi()
308 * ice_dcb_bwchk - check if ETS bandwidth input parameters are correct
314 struct ice_dcb_ets_cfg *etscfg = &dcbcfg->etscfg; in ice_dcb_bwchk()
318 /* returns number of contigous TCs and 1 TC for non-contigous TCs, in ice_dcb_bwchk()
327 etscfg->tcbwtable[0] = ICE_TC_MAX_BW; in ice_dcb_bwchk()
332 total_bw += etscfg->tcbwtable[i]; in ice_dcb_bwchk()
335 etscfg->tcbwtable[0] = ICE_TC_MAX_BW; in ice_dcb_bwchk()
338 return -EINVAL; in ice_dcb_bwchk()
345 * ice_pf_dcb_cfg - Apply new DCB configuration
359 curr_cfg = &pf->hw.port_info->qos_cfg.local_dcbx_cfg; in ice_pf_dcb_cfg()
362 if (!pf->hw.port_info->qos_cfg.is_sw_lldp) in ice_pf_dcb_cfg()
368 if (pf->hw.port_info->is_custom_tx_enabled) { in ice_pf_dcb_cfg()
370 return -EBUSY; in ice_pf_dcb_cfg()
374 set_bit(ICE_FLAG_DCB_ENA, pf->flags); in ice_pf_dcb_cfg()
377 clear_bit(ICE_FLAG_DCB_ENA, pf->flags); in ice_pf_dcb_cfg()
386 return -EINVAL; in ice_pf_dcb_cfg()
391 return -ENOMEM; in ice_pf_dcb_cfg()
397 ret = -EINVAL; in ice_pf_dcb_cfg()
404 ret = -ENOMEM; in ice_pf_dcb_cfg()
408 set_bit(IIDC_EVENT_BEFORE_TC_CHANGE, event->type); in ice_pf_dcb_cfg()
413 * re-enabling the VSI in ice_pf_dcb_cfg()
422 memcpy(&curr_cfg->etsrec, &curr_cfg->etscfg, sizeof(curr_cfg->etsrec)); in ice_pf_dcb_cfg()
423 memcpy(&new_cfg->etsrec, &curr_cfg->etscfg, sizeof(curr_cfg->etsrec)); in ice_pf_dcb_cfg()
428 if (pf->hw.port_info->qos_cfg.is_sw_lldp) { in ice_pf_dcb_cfg()
429 ret = ice_set_dcb_cfg(pf->hw.port_info); in ice_pf_dcb_cfg()
438 ret = ice_query_port_ets(pf->hw.port_info, &buf, sizeof(buf), NULL); in ice_pf_dcb_cfg()
457 * ice_cfg_etsrec_defaults - Set default ETS recommended DCB config
462 struct ice_dcbx_cfg *dcbcfg = &pi->qos_cfg.local_dcbx_cfg; in ice_cfg_etsrec_defaults()
466 if (dcbcfg->etsrec.maxtcs) in ice_cfg_etsrec_defaults()
470 dcbcfg->etsrec.maxtcs = 1; in ice_cfg_etsrec_defaults()
472 dcbcfg->etsrec.tcbwtable[i] = i ? 0 : 100; in ice_cfg_etsrec_defaults()
473 dcbcfg->etsrec.tsatable[i] = i ? ICE_IEEE_TSA_STRICT : in ice_cfg_etsrec_defaults()
479 * ice_dcb_need_recfg - Check if DCB needs reconfig
492 if (memcmp(&new_cfg->etscfg, &old_cfg->etscfg, in ice_dcb_need_recfg()
493 sizeof(new_cfg->etscfg))) { in ice_dcb_need_recfg()
495 if (memcmp(&new_cfg->etscfg.prio_table, in ice_dcb_need_recfg()
496 &old_cfg->etscfg.prio_table, in ice_dcb_need_recfg()
497 sizeof(new_cfg->etscfg.prio_table))) { in ice_dcb_need_recfg()
502 if (memcmp(&new_cfg->etscfg.tcbwtable, in ice_dcb_need_recfg()
503 &old_cfg->etscfg.tcbwtable, in ice_dcb_need_recfg()
504 sizeof(new_cfg->etscfg.tcbwtable))) in ice_dcb_need_recfg()
507 if (memcmp(&new_cfg->etscfg.tsatable, in ice_dcb_need_recfg()
508 &old_cfg->etscfg.tsatable, in ice_dcb_need_recfg()
509 sizeof(new_cfg->etscfg.tsatable))) in ice_dcb_need_recfg()
514 if (memcmp(&new_cfg->pfc, &old_cfg->pfc, sizeof(new_cfg->pfc))) { in ice_dcb_need_recfg()
520 if (memcmp(&new_cfg->app, &old_cfg->app, sizeof(new_cfg->app))) { in ice_dcb_need_recfg()
530 * ice_dcb_rebuild - rebuild DCB post reset
540 ret = ice_query_port_ets(pf->hw.port_info, &buf, sizeof(buf), NULL); in ice_dcb_rebuild()
546 mutex_lock(&pf->tc_mutex); in ice_dcb_rebuild()
548 if (!pf->hw.port_info->qos_cfg.is_sw_lldp) in ice_dcb_rebuild()
549 ice_cfg_etsrec_defaults(pf->hw.port_info); in ice_dcb_rebuild()
551 ret = ice_set_dcb_cfg(pf->hw.port_info); in ice_dcb_rebuild()
557 if (!pf->hw.port_info->qos_cfg.is_sw_lldp) { in ice_dcb_rebuild()
558 ret = ice_cfg_lldp_mib_change(&pf->hw, true); in ice_dcb_rebuild()
559 if (ret && !pf->hw.port_info->qos_cfg.is_sw_lldp) { in ice_dcb_rebuild()
566 ret = ice_query_port_ets(pf->hw.port_info, &buf, sizeof(buf), NULL); in ice_dcb_rebuild()
572 mutex_unlock(&pf->tc_mutex); in ice_dcb_rebuild()
580 mutex_unlock(&pf->tc_mutex); in ice_dcb_rebuild()
584 err_cfg->etscfg.willing = true; in ice_dcb_rebuild()
585 err_cfg->etscfg.tcbwtable[0] = ICE_TC_MAX_BW; in ice_dcb_rebuild()
586 err_cfg->etscfg.tsatable[0] = ICE_IEEE_TSA_ETS; in ice_dcb_rebuild()
587 memcpy(&err_cfg->etsrec, &err_cfg->etscfg, sizeof(err_cfg->etsrec)); in ice_dcb_rebuild()
597 mutex_unlock(&pf->tc_mutex); in ice_dcb_rebuild()
601 * ice_dcb_init_cfg - set the initial DCB config in SW
611 pi = pf->hw.port_info; in ice_dcb_init_cfg()
612 newcfg = kmemdup(&pi->qos_cfg.local_dcbx_cfg, sizeof(*newcfg), in ice_dcb_init_cfg()
615 return -ENOMEM; in ice_dcb_init_cfg()
617 memset(&pi->qos_cfg.local_dcbx_cfg, 0, sizeof(*newcfg)); in ice_dcb_init_cfg()
621 ret = -EINVAL; in ice_dcb_init_cfg()
629 * ice_dcb_sw_dflt_cfg - Apply a default DCB config
642 hw = &pf->hw; in ice_dcb_sw_dflt_cfg()
643 pi = hw->port_info; in ice_dcb_sw_dflt_cfg()
646 return -ENOMEM; in ice_dcb_sw_dflt_cfg()
648 memset(&pi->qos_cfg.local_dcbx_cfg, 0, sizeof(*dcbcfg)); in ice_dcb_sw_dflt_cfg()
650 dcbcfg->etscfg.willing = ets_willing ? 1 : 0; in ice_dcb_sw_dflt_cfg()
651 dcbcfg->etscfg.maxtcs = hw->func_caps.common_cap.maxtc; in ice_dcb_sw_dflt_cfg()
652 dcbcfg->etscfg.tcbwtable[0] = 100; in ice_dcb_sw_dflt_cfg()
653 dcbcfg->etscfg.tsatable[0] = ICE_IEEE_TSA_ETS; in ice_dcb_sw_dflt_cfg()
655 memcpy(&dcbcfg->etsrec, &dcbcfg->etscfg, in ice_dcb_sw_dflt_cfg()
656 sizeof(dcbcfg->etsrec)); in ice_dcb_sw_dflt_cfg()
657 dcbcfg->etsrec.willing = 0; in ice_dcb_sw_dflt_cfg()
659 dcbcfg->pfc.willing = 1; in ice_dcb_sw_dflt_cfg()
660 dcbcfg->pfc.pfccap = hw->func_caps.common_cap.maxtc; in ice_dcb_sw_dflt_cfg()
662 dcbcfg->numapps = 1; in ice_dcb_sw_dflt_cfg()
663 dcbcfg->app[0].selector = ICE_APP_SEL_ETHTYPE; in ice_dcb_sw_dflt_cfg()
664 dcbcfg->app[0].priority = 3; in ice_dcb_sw_dflt_cfg()
665 dcbcfg->app[0].prot_id = ETH_P_FCOE; in ice_dcb_sw_dflt_cfg()
676 * ice_dcb_tc_contig - Check that TCs are contiguous
679 * Check if TCs begin with TC0 and are contiguous
704 * ice_dcb_noncontig_cfg - Configure DCB for non-contiguous TCs
707 * If non-contiguous TCs, then configure SW DCB with TC0 and ETS non-willing
711 struct ice_dcbx_cfg *dcbcfg = &pf->hw.port_info->qos_cfg.local_dcbx_cfg; in ice_dcb_noncontig_cfg()
715 /* Configure SW DCB default with ETS non-willing */ in ice_dcb_noncontig_cfg()
723 dcbcfg->etscfg.willing = 1; in ice_dcb_noncontig_cfg()
724 ret = ice_set_dcb_cfg(pf->hw.port_info); in ice_dcb_noncontig_cfg()
732 * ice_pf_dcb_recfg - Reconfigure all VEBs and VSIs
742 struct ice_dcbx_cfg *dcbcfg = &pf->hw.port_info->qos_cfg.local_dcbx_cfg; in ice_pf_dcb_recfg()
749 struct ice_vsi *vsi = pf->vsi[v]; in ice_pf_dcb_recfg()
754 if (vsi->type == ICE_VSI_PF) { in ice_pf_dcb_recfg()
757 /* If DCBX request non-contiguous TC, then configure in ice_pf_dcb_recfg()
760 if (!ice_dcb_tc_contig(dcbcfg->etscfg.prio_table)) { in ice_pf_dcb_recfg()
764 } else if (vsi->type == ICE_VSI_CHNL) { in ice_pf_dcb_recfg()
773 vsi->idx); in ice_pf_dcb_recfg()
779 if (vsi->type == ICE_VSI_CHNL) in ice_pf_dcb_recfg()
783 if (vsi->type == ICE_VSI_PF) in ice_pf_dcb_recfg()
792 set_bit(IIDC_EVENT_AFTER_TC_CHANGE, event->type); in ice_pf_dcb_recfg()
799 * ice_init_pf_dcb - initialize DCB for a PF
807 struct ice_hw *hw = &pf->hw; in ice_init_pf_dcb()
810 port_info = hw->port_info; in ice_init_pf_dcb()
813 if (err && !port_info->qos_cfg.is_sw_lldp) { in ice_init_pf_dcb()
819 pf->hw.func_caps.common_cap.maxtc); in ice_init_pf_dcb()
825 clear_bit(ICE_FLAG_FW_LLDP_AGENT, pf->flags); in ice_init_pf_dcb()
826 err = ice_aq_set_pfc_mode(&pf->hw, ICE_AQC_PFC_VLAN_BASED_PFC, in ice_init_pf_dcb()
835 err = -EIO; in ice_init_pf_dcb()
845 err = -EIO; in ice_init_pf_dcb()
851 pf->dcbx_cap = ice_dcb_get_mode(port_info, true); in ice_init_pf_dcb()
855 set_bit(ICE_FLAG_FW_LLDP_AGENT, pf->flags); in ice_init_pf_dcb()
858 pf->dcbx_cap = ice_dcb_get_mode(port_info, false); in ice_init_pf_dcb()
872 * ice_update_dcb_stats - Update DCB stats counters
878 struct ice_hw *hw = &pf->hw; in ice_update_dcb_stats()
882 port = hw->port_info->lport; in ice_update_dcb_stats()
883 prev_ps = &pf->stats_prev; in ice_update_dcb_stats()
884 cur_ps = &pf->stats; in ice_update_dcb_stats()
886 if (ice_is_reset_in_progress(pf->state)) in ice_update_dcb_stats()
887 pf->stat_prev_loaded = false; in ice_update_dcb_stats()
891 pf->stat_prev_loaded, in ice_update_dcb_stats()
892 &prev_ps->priority_xoff_rx[i], in ice_update_dcb_stats()
893 &cur_ps->priority_xoff_rx[i]); in ice_update_dcb_stats()
895 pf->stat_prev_loaded, in ice_update_dcb_stats()
896 &prev_ps->priority_xon_rx[i], in ice_update_dcb_stats()
897 &cur_ps->priority_xon_rx[i]); in ice_update_dcb_stats()
899 pf->stat_prev_loaded, in ice_update_dcb_stats()
900 &prev_ps->priority_xon_tx[i], in ice_update_dcb_stats()
901 &cur_ps->priority_xon_tx[i]); in ice_update_dcb_stats()
903 pf->stat_prev_loaded, in ice_update_dcb_stats()
904 &prev_ps->priority_xoff_tx[i], in ice_update_dcb_stats()
905 &cur_ps->priority_xoff_tx[i]); in ice_update_dcb_stats()
907 pf->stat_prev_loaded, in ice_update_dcb_stats()
908 &prev_ps->priority_xon_2_xoff[i], in ice_update_dcb_stats()
909 &cur_ps->priority_xon_2_xoff[i]); in ice_update_dcb_stats()
914 * ice_tx_prepare_vlan_flags_dcb - prepare VLAN tagging for DCB
925 struct sk_buff *skb = first->skb; in ice_tx_prepare_vlan_flags_dcb()
927 if (!test_bit(ICE_FLAG_DCB_ENA, tx_ring->vsi->back->flags)) in ice_tx_prepare_vlan_flags_dcb()
931 if ((first->tx_flags & ICE_TX_FLAGS_HW_VLAN || in ice_tx_prepare_vlan_flags_dcb()
932 first->tx_flags & ICE_TX_FLAGS_HW_OUTER_SINGLE_VLAN) || in ice_tx_prepare_vlan_flags_dcb()
933 skb->priority != TC_PRIO_CONTROL) { in ice_tx_prepare_vlan_flags_dcb()
934 first->vid &= ~VLAN_PRIO_MASK; in ice_tx_prepare_vlan_flags_dcb()
936 first->vid |= FIELD_PREP(VLAN_PRIO_MASK, skb->priority); in ice_tx_prepare_vlan_flags_dcb()
940 if (tx_ring->flags & ICE_TX_FLAGS_RING_VLAN_L2TAG2) in ice_tx_prepare_vlan_flags_dcb()
941 first->tx_flags |= ICE_TX_FLAGS_HW_OUTER_SINGLE_VLAN; in ice_tx_prepare_vlan_flags_dcb()
943 first->tx_flags |= ICE_TX_FLAGS_HW_VLAN; in ice_tx_prepare_vlan_flags_dcb()
948 * ice_dcb_is_mib_change_pending - Check if MIB change is pending
958 * ice_dcb_process_lldp_set_mib_change - Process MIB change
977 if (!(test_bit(ICE_FLAG_DCB_CAPABLE, pf->flags))) in ice_dcb_process_lldp_set_mib_change()
980 if (pf->dcbx_cap & DCB_CAP_DCBX_HOST) { in ice_dcb_process_lldp_set_mib_change()
985 pi = pf->hw.port_info; in ice_dcb_process_lldp_set_mib_change()
986 mib = (struct ice_aqc_lldp_get_mib *)&event->desc.params.raw; in ice_dcb_process_lldp_set_mib_change()
989 mib_type = FIELD_GET(ICE_AQ_LLDP_BRID_TYPE_M, mib->type); in ice_dcb_process_lldp_set_mib_change()
999 if (ice_dcb_is_mib_change_pending(mib->state)) in ice_dcb_process_lldp_set_mib_change()
1003 mib_type = FIELD_GET(ICE_AQ_LLDP_MIB_TYPE_M, mib->type); in ice_dcb_process_lldp_set_mib_change()
1011 ice_aq_get_dcb_cfg(pi->hw, ICE_AQ_LLDP_MIB_REMOTE, in ice_dcb_process_lldp_set_mib_change()
1013 &pi->qos_cfg.remote_dcbx_cfg); in ice_dcb_process_lldp_set_mib_change()
1021 mutex_lock(&pf->tc_mutex); in ice_dcb_process_lldp_set_mib_change()
1024 tmp_dcbx_cfg = pi->qos_cfg.local_dcbx_cfg; in ice_dcb_process_lldp_set_mib_change()
1027 memset(&pi->qos_cfg.local_dcbx_cfg, 0, in ice_dcb_process_lldp_set_mib_change()
1028 sizeof(pi->qos_cfg.local_dcbx_cfg)); in ice_dcb_process_lldp_set_mib_change()
1042 if (!memcmp(&tmp_dcbx_cfg, &pi->qos_cfg.local_dcbx_cfg, in ice_dcb_process_lldp_set_mib_change()
1048 pf->dcbx_cap = ice_dcb_get_mode(pi, false); in ice_dcb_process_lldp_set_mib_change()
1051 &pi->qos_cfg.local_dcbx_cfg); in ice_dcb_process_lldp_set_mib_change()
1052 ice_dcbnl_flush_apps(pf, &tmp_dcbx_cfg, &pi->qos_cfg.local_dcbx_cfg); in ice_dcb_process_lldp_set_mib_change()
1057 if (ice_dcb_get_num_tc(&pi->qos_cfg.local_dcbx_cfg) > 1) { in ice_dcb_process_lldp_set_mib_change()
1059 set_bit(ICE_FLAG_DCB_ENA, pf->flags); in ice_dcb_process_lldp_set_mib_change()
1062 clear_bit(ICE_FLAG_DCB_ENA, pf->flags); in ice_dcb_process_lldp_set_mib_change()
1067 ice_lldp_execute_pending_mib(&pf->hw); in ice_dcb_process_lldp_set_mib_change()
1089 mutex_unlock(&pf->tc_mutex); in ice_dcb_process_lldp_set_mib_change()
1093 ice_lldp_execute_pending_mib(&pf->hw); in ice_dcb_process_lldp_set_mib_change()