1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2019, Intel Corporation. */
4 #include "ice_dcb_lib.h"
5 #include "ice_dcb_nl.h"
8 * ice_vsi_cfg_netdev_tc - Setup the netdev TC configuration
9 * @vsi: the VSI being configured
10 * @ena_tc: TC map to be enabled
12 void ice_vsi_cfg_netdev_tc(struct ice_vsi *vsi, u8 ena_tc)
14 struct net_device *netdev = vsi->netdev;
15 struct ice_pf *pf = vsi->back;
16 struct ice_dcbx_cfg *dcbcfg;
24 netdev_reset_tc(netdev);
28 if (netdev_set_num_tc(netdev, vsi->tc_cfg.numtc))
31 dcbcfg = &pf->hw.port_info->local_dcbx_cfg;
33 ice_for_each_traffic_class(i)
34 if (vsi->tc_cfg.ena_tc & BIT(i))
35 netdev_set_tc_queue(netdev,
36 vsi->tc_cfg.tc_info[i].netdev_tc,
37 vsi->tc_cfg.tc_info[i].qcount_tx,
38 vsi->tc_cfg.tc_info[i].qoffset);
40 for (i = 0; i < ICE_MAX_USER_PRIORITY; i++) {
41 u8 ets_tc = dcbcfg->etscfg.prio_table[i];
43 /* Get the mapped netdev TC# for the UP */
44 netdev_tc = vsi->tc_cfg.tc_info[ets_tc].netdev_tc;
45 netdev_set_prio_tc_map(netdev, i, netdev_tc);
50 * ice_dcb_get_ena_tc - return bitmap of enabled TCs
51 * @dcbcfg: DCB config to evaluate for enabled TCs
53 u8 ice_dcb_get_ena_tc(struct ice_dcbx_cfg *dcbcfg)
55 u8 i, num_tc, ena_tc = 1;
57 num_tc = ice_dcb_get_num_tc(dcbcfg);
59 for (i = 0; i < num_tc; i++)
66 * ice_dcb_get_num_tc - Get the number of TCs from DCBX config
67 * @dcbcfg: config to retrieve number of TCs from
69 u8 ice_dcb_get_num_tc(struct ice_dcbx_cfg *dcbcfg)
71 bool tc_unused = false;
76 /* Scan the ETS Config Priority Table to find traffic classes
77 * enabled and create a bitmask of enabled TCs
79 for (i = 0; i < CEE_DCBX_MAX_PRIO; i++)
80 num_tc |= BIT(dcbcfg->etscfg.prio_table[i]);
82 /* Scan bitmask for contiguous TCs starting with TC0 */
83 for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) {
84 if (num_tc & BIT(i)) {
88 pr_err("Non-contiguous TCs - Disabling DCB\n");
96 /* There is always at least 1 TC */
104 * ice_dcb_get_tc - Get the TC associated with the queue
105 * @vsi: ptr to the VSI
106 * @queue_index: queue number associated with VSI
108 u8 ice_dcb_get_tc(struct ice_vsi *vsi, int queue_index)
110 return vsi->tx_rings[queue_index]->dcb_tc;
114 * ice_vsi_cfg_dcb_rings - Update rings to reflect DCB TC
115 * @vsi: VSI owner of rings being updated
117 void ice_vsi_cfg_dcb_rings(struct ice_vsi *vsi)
119 struct ice_ring *tx_ring, *rx_ring;
123 if (!test_bit(ICE_FLAG_DCB_ENA, vsi->back->flags)) {
124 /* Reset the TC information */
125 for (i = 0; i < vsi->num_txq; i++) {
126 tx_ring = vsi->tx_rings[i];
129 for (i = 0; i < vsi->num_rxq; i++) {
130 rx_ring = vsi->rx_rings[i];
136 ice_for_each_traffic_class(n) {
137 if (!(vsi->tc_cfg.ena_tc & BIT(n)))
140 qoffset = vsi->tc_cfg.tc_info[n].qoffset;
141 qcount = vsi->tc_cfg.tc_info[n].qcount_tx;
142 for (i = qoffset; i < (qoffset + qcount); i++) {
143 tx_ring = vsi->tx_rings[i];
144 rx_ring = vsi->rx_rings[i];
152 * ice_pf_dcb_cfg - Apply new DCB configuration
153 * @pf: pointer to the PF struct
154 * @new_cfg: DCBX config to apply
155 * @locked: is the RTNL held
157 int ice_pf_dcb_cfg(struct ice_pf *pf, struct ice_dcbx_cfg *new_cfg, bool locked)
159 struct ice_aqc_port_ets_elem buf = { 0 };
160 struct ice_dcbx_cfg *old_cfg, *curr_cfg;
161 struct device *dev = ice_pf_to_dev(pf);
162 int ret = ICE_DCB_NO_HW_CHG;
163 struct ice_vsi *pf_vsi;
165 curr_cfg = &pf->hw.port_info->local_dcbx_cfg;
167 /* FW does not care if change happened */
168 if (!pf->hw.port_info->is_sw_lldp)
169 ret = ICE_DCB_HW_CHG_RST;
171 /* Enable DCB tagging only when more than one TC */
172 if (ice_dcb_get_num_tc(new_cfg) > 1) {
173 dev_dbg(dev, "DCB tagging enabled (num TC > 1)\n");
174 set_bit(ICE_FLAG_DCB_ENA, pf->flags);
176 dev_dbg(dev, "DCB tagging disabled (num TC = 1)\n");
177 clear_bit(ICE_FLAG_DCB_ENA, pf->flags);
180 if (!memcmp(new_cfg, curr_cfg, sizeof(*new_cfg))) {
181 dev_dbg(dev, "No change in DCB config required\n");
185 /* Store old config in case FW config fails */
186 old_cfg = kmemdup(curr_cfg, sizeof(*old_cfg), GFP_KERNEL);
190 dev_info(dev, "Commit DCB Configuration to the hardware\n");
191 pf_vsi = ice_get_main_vsi(pf);
193 dev_dbg(dev, "PF VSI doesn't exist\n");
198 /* avoid race conditions by holding the lock while disabling and
199 * re-enabling the VSI
203 ice_dis_vsi(pf_vsi, true);
205 memcpy(curr_cfg, new_cfg, sizeof(*curr_cfg));
206 memcpy(&curr_cfg->etsrec, &curr_cfg->etscfg, sizeof(curr_cfg->etsrec));
207 memcpy(&new_cfg->etsrec, &curr_cfg->etscfg, sizeof(curr_cfg->etsrec));
209 /* Only send new config to HW if we are in SW LLDP mode. Otherwise,
210 * the new config came from the HW in the first place.
212 if (pf->hw.port_info->is_sw_lldp) {
213 ret = ice_set_dcb_cfg(pf->hw.port_info);
215 dev_err(dev, "Set DCB Config failed\n");
216 /* Restore previous settings to local config */
217 memcpy(curr_cfg, old_cfg, sizeof(*curr_cfg));
222 ret = ice_query_port_ets(pf->hw.port_info, &buf, sizeof(buf), NULL);
224 dev_err(dev, "Query Port ETS failed\n");
228 ice_pf_dcb_recfg(pf);
231 ice_ena_vsi(pf_vsi, true);
240 * ice_cfg_etsrec_defaults - Set default ETS recommended DCB config
241 * @pi: port information structure
243 static void ice_cfg_etsrec_defaults(struct ice_port_info *pi)
245 struct ice_dcbx_cfg *dcbcfg = &pi->local_dcbx_cfg;
248 /* Ensure ETS recommended DCB configuration is not already set */
249 if (dcbcfg->etsrec.maxtcs)
252 /* In CEE mode, set the default to 1 TC */
253 dcbcfg->etsrec.maxtcs = 1;
254 for (i = 0; i < ICE_MAX_TRAFFIC_CLASS; i++) {
255 dcbcfg->etsrec.tcbwtable[i] = i ? 0 : 100;
256 dcbcfg->etsrec.tsatable[i] = i ? ICE_IEEE_TSA_STRICT :
262 * ice_dcb_need_recfg - Check if DCB needs reconfig
263 * @pf: board private structure
264 * @old_cfg: current DCB config
265 * @new_cfg: new DCB config
268 ice_dcb_need_recfg(struct ice_pf *pf, struct ice_dcbx_cfg *old_cfg,
269 struct ice_dcbx_cfg *new_cfg)
271 struct device *dev = ice_pf_to_dev(pf);
272 bool need_reconfig = false;
274 /* Check if ETS configuration has changed */
275 if (memcmp(&new_cfg->etscfg, &old_cfg->etscfg,
276 sizeof(new_cfg->etscfg))) {
277 /* If Priority Table has changed reconfig is needed */
278 if (memcmp(&new_cfg->etscfg.prio_table,
279 &old_cfg->etscfg.prio_table,
280 sizeof(new_cfg->etscfg.prio_table))) {
281 need_reconfig = true;
282 dev_dbg(dev, "ETS UP2TC changed.\n");
285 if (memcmp(&new_cfg->etscfg.tcbwtable,
286 &old_cfg->etscfg.tcbwtable,
287 sizeof(new_cfg->etscfg.tcbwtable)))
288 dev_dbg(dev, "ETS TC BW Table changed.\n");
290 if (memcmp(&new_cfg->etscfg.tsatable,
291 &old_cfg->etscfg.tsatable,
292 sizeof(new_cfg->etscfg.tsatable)))
293 dev_dbg(dev, "ETS TSA Table changed.\n");
296 /* Check if PFC configuration has changed */
297 if (memcmp(&new_cfg->pfc, &old_cfg->pfc, sizeof(new_cfg->pfc))) {
298 need_reconfig = true;
299 dev_dbg(dev, "PFC config change detected.\n");
302 /* Check if APP Table has changed */
303 if (memcmp(&new_cfg->app, &old_cfg->app, sizeof(new_cfg->app))) {
304 need_reconfig = true;
305 dev_dbg(dev, "APP Table change detected.\n");
308 dev_dbg(dev, "dcb need_reconfig=%d\n", need_reconfig);
309 return need_reconfig;
313 * ice_dcb_rebuild - rebuild DCB post reset
314 * @pf: physical function instance
316 void ice_dcb_rebuild(struct ice_pf *pf)
318 struct ice_dcbx_cfg *local_dcbx_cfg, *desired_dcbx_cfg, *prev_cfg;
319 struct ice_aqc_port_ets_elem buf = { 0 };
320 struct device *dev = ice_pf_to_dev(pf);
323 ret = ice_query_port_ets(pf->hw.port_info, &buf, sizeof(buf), NULL);
325 dev_err(dev, "Query Port ETS failed\n");
329 /* If DCB was not enabled previously, we are done */
330 if (!test_bit(ICE_FLAG_DCB_ENA, pf->flags))
333 local_dcbx_cfg = &pf->hw.port_info->local_dcbx_cfg;
334 desired_dcbx_cfg = &pf->hw.port_info->desired_dcbx_cfg;
336 /* Save current willing state and force FW to unwilling */
337 local_dcbx_cfg->etscfg.willing = 0x0;
338 local_dcbx_cfg->pfc.willing = 0x0;
339 local_dcbx_cfg->app_mode = ICE_DCBX_APPS_NON_WILLING;
341 ice_cfg_etsrec_defaults(pf->hw.port_info);
342 ret = ice_set_dcb_cfg(pf->hw.port_info);
344 dev_err(dev, "Failed to set DCB to unwilling\n");
348 /* Retrieve DCB config and ensure same as current in SW */
349 prev_cfg = kmemdup(local_dcbx_cfg, sizeof(*prev_cfg), GFP_KERNEL);
353 ice_init_dcb(&pf->hw, true);
354 if (pf->hw.port_info->dcbx_status == ICE_DCBX_STATUS_DIS)
355 pf->hw.port_info->is_sw_lldp = true;
357 pf->hw.port_info->is_sw_lldp = false;
359 if (ice_dcb_need_recfg(pf, prev_cfg, local_dcbx_cfg)) {
360 /* difference in cfg detected - disable DCB till next MIB */
361 dev_err(dev, "Set local MIB not accurate\n");
366 /* fetched config congruent to previous configuration */
369 /* Set the local desired config */
370 if (local_dcbx_cfg->dcbx_mode == ICE_DCBX_MODE_CEE)
371 memcpy(local_dcbx_cfg, desired_dcbx_cfg,
372 sizeof(*local_dcbx_cfg));
374 ice_cfg_etsrec_defaults(pf->hw.port_info);
375 ret = ice_set_dcb_cfg(pf->hw.port_info);
377 dev_err(dev, "Failed to set desired config\n");
380 dev_info(dev, "DCB restored after reset\n");
381 ret = ice_query_port_ets(pf->hw.port_info, &buf, sizeof(buf), NULL);
383 dev_err(dev, "Query Port ETS failed\n");
390 dev_err(dev, "Disabling DCB until new settings occur\n");
391 prev_cfg = kzalloc(sizeof(*prev_cfg), GFP_KERNEL);
395 prev_cfg->etscfg.willing = true;
396 prev_cfg->etscfg.tcbwtable[0] = ICE_TC_MAX_BW;
397 prev_cfg->etscfg.tsatable[0] = ICE_IEEE_TSA_ETS;
398 memcpy(&prev_cfg->etsrec, &prev_cfg->etscfg, sizeof(prev_cfg->etsrec));
399 /* Coverity warns the return code of ice_pf_dcb_cfg() is not checked
400 * here as is done for other calls to that function. That check is
401 * not necessary since this is in this function's error cleanup path.
402 * Suppress the Coverity warning with the following comment...
404 /* coverity[check_return] */
405 ice_pf_dcb_cfg(pf, prev_cfg, false);
410 * ice_dcb_init_cfg - set the initial DCB config in SW
411 * @pf: PF to apply config to
412 * @locked: Is the RTNL held
414 static int ice_dcb_init_cfg(struct ice_pf *pf, bool locked)
416 struct ice_dcbx_cfg *newcfg;
417 struct ice_port_info *pi;
420 pi = pf->hw.port_info;
421 newcfg = kmemdup(&pi->local_dcbx_cfg, sizeof(*newcfg), GFP_KERNEL);
425 memset(&pi->local_dcbx_cfg, 0, sizeof(*newcfg));
427 dev_info(ice_pf_to_dev(pf), "Configuring initial DCB values\n");
428 if (ice_pf_dcb_cfg(pf, newcfg, locked))
437 * ice_dcb_sw_default_config - Apply a default DCB config
438 * @pf: PF to apply config to
439 * @ets_willing: configure ets willing
440 * @locked: was this function called with RTNL held
442 static int ice_dcb_sw_dflt_cfg(struct ice_pf *pf, bool ets_willing, bool locked)
444 struct ice_aqc_port_ets_elem buf = { 0 };
445 struct ice_dcbx_cfg *dcbcfg;
446 struct ice_port_info *pi;
452 dcbcfg = kzalloc(sizeof(*dcbcfg), GFP_KERNEL);
456 memset(&pi->local_dcbx_cfg, 0, sizeof(*dcbcfg));
458 dcbcfg->etscfg.willing = ets_willing ? 1 : 0;
459 dcbcfg->etscfg.maxtcs = hw->func_caps.common_cap.maxtc;
460 dcbcfg->etscfg.tcbwtable[0] = 100;
461 dcbcfg->etscfg.tsatable[0] = ICE_IEEE_TSA_ETS;
463 memcpy(&dcbcfg->etsrec, &dcbcfg->etscfg,
464 sizeof(dcbcfg->etsrec));
465 dcbcfg->etsrec.willing = 0;
467 dcbcfg->pfc.willing = 1;
468 dcbcfg->pfc.pfccap = hw->func_caps.common_cap.maxtc;
471 dcbcfg->app[0].selector = ICE_APP_SEL_ETHTYPE;
472 dcbcfg->app[0].priority = 3;
473 dcbcfg->app[0].prot_id = ICE_APP_PROT_ID_FCOE;
475 ret = ice_pf_dcb_cfg(pf, dcbcfg, locked);
480 return ice_query_port_ets(pi, &buf, sizeof(buf), NULL);
484 * ice_dcb_tc_contig - Check that TCs are contiguous
485 * @prio_table: pointer to priority table
487 * Check if TCs begin with TC0 and are contiguous
489 static bool ice_dcb_tc_contig(u8 *prio_table)
494 for (i = 0; i < CEE_DCBX_MAX_PRIO; i++) {
495 u8 cur_tc = prio_table[i];
499 else if (cur_tc == max_tc)
507 * ice_dcb_noncontig_cfg - Configure DCB for non-contiguous TCs
508 * @pf: pointer to the PF struct
510 * If non-contiguous TCs, then configure SW DCB with TC0 and ETS non-willing
512 static int ice_dcb_noncontig_cfg(struct ice_pf *pf)
514 struct ice_dcbx_cfg *dcbcfg = &pf->hw.port_info->local_dcbx_cfg;
515 struct device *dev = ice_pf_to_dev(pf);
518 /* Configure SW DCB default with ETS non-willing */
519 ret = ice_dcb_sw_dflt_cfg(pf, false, true);
521 dev_err(dev, "Failed to set local DCB config %d\n", ret);
525 /* Reconfigure with ETS willing so that FW will send LLDP MIB event */
526 dcbcfg->etscfg.willing = 1;
527 ret = ice_set_dcb_cfg(pf->hw.port_info);
529 dev_err(dev, "Failed to set DCB to unwilling\n");
535 * ice_pf_dcb_recfg - Reconfigure all VEBs and VSIs
536 * @pf: pointer to the PF struct
538 * Assumed caller has already disabled all VSIs before
539 * calling this function. Reconfiguring DCB based on
542 void ice_pf_dcb_recfg(struct ice_pf *pf)
544 struct ice_dcbx_cfg *dcbcfg = &pf->hw.port_info->local_dcbx_cfg;
548 /* Update each VSI */
549 ice_for_each_vsi(pf, v) {
550 struct ice_vsi *vsi = pf->vsi[v];
555 if (vsi->type == ICE_VSI_PF) {
556 tc_map = ice_dcb_get_ena_tc(dcbcfg);
558 /* If DCBX request non-contiguous TC, then configure
561 if (!ice_dcb_tc_contig(dcbcfg->etscfg.prio_table)) {
562 tc_map = ICE_DFLT_TRAFFIC_CLASS;
563 ice_dcb_noncontig_cfg(pf);
566 tc_map = ICE_DFLT_TRAFFIC_CLASS;
569 ret = ice_vsi_cfg_tc(vsi, tc_map);
571 dev_err(ice_pf_to_dev(pf), "Failed to config TC for VSI index: %d\n",
576 ice_vsi_map_rings_to_vectors(vsi);
577 if (vsi->type == ICE_VSI_PF)
578 ice_dcbnl_set_all(vsi);
583 * ice_init_pf_dcb - initialize DCB for a PF
584 * @pf: PF to initialize DCB for
585 * @locked: Was function called with RTNL held
587 int ice_init_pf_dcb(struct ice_pf *pf, bool locked)
589 struct device *dev = ice_pf_to_dev(pf);
590 struct ice_port_info *port_info;
591 struct ice_hw *hw = &pf->hw;
594 port_info = hw->port_info;
596 err = ice_init_dcb(hw, false);
597 if (err && !port_info->is_sw_lldp) {
598 dev_err(dev, "Error initializing DCB %d\n", err);
603 "DCB is enabled in the hardware, max number of TCs supported on this port are %d\n",
604 pf->hw.func_caps.common_cap.maxtc);
606 struct ice_vsi *pf_vsi;
608 /* FW LLDP is disabled, activate SW DCBX/LLDP mode */
609 dev_info(dev, "FW LLDP is disabled, DCBx/LLDP in SW mode.\n");
610 clear_bit(ICE_FLAG_FW_LLDP_AGENT, pf->flags);
611 err = ice_dcb_sw_dflt_cfg(pf, true, locked);
614 "Failed to set local DCB config %d\n", err);
619 /* If the FW DCBX engine is not running then Rx LLDP packets
620 * need to be redirected up the stack.
622 pf_vsi = ice_get_main_vsi(pf);
624 dev_err(dev, "Failed to set local DCB config\n");
629 ice_cfg_sw_lldp(pf_vsi, false, true);
631 pf->dcbx_cap = DCB_CAP_DCBX_HOST | DCB_CAP_DCBX_VER_IEEE;
635 set_bit(ICE_FLAG_FW_LLDP_AGENT, pf->flags);
637 /* DCBX in FW and LLDP enabled in FW */
638 pf->dcbx_cap = DCB_CAP_DCBX_LLD_MANAGED | DCB_CAP_DCBX_VER_IEEE;
640 err = ice_dcb_init_cfg(pf, locked);
647 dev_err(dev, "DCB init failed\n");
652 * ice_update_dcb_stats - Update DCB stats counters
653 * @pf: PF whose stats needs to be updated
655 void ice_update_dcb_stats(struct ice_pf *pf)
657 struct ice_hw_port_stats *prev_ps, *cur_ps;
658 struct ice_hw *hw = &pf->hw;
662 port = hw->port_info->lport;
663 prev_ps = &pf->stats_prev;
666 for (i = 0; i < 8; i++) {
667 ice_stat_update32(hw, GLPRT_PXOFFRXC(port, i),
668 pf->stat_prev_loaded,
669 &prev_ps->priority_xoff_rx[i],
670 &cur_ps->priority_xoff_rx[i]);
671 ice_stat_update32(hw, GLPRT_PXONRXC(port, i),
672 pf->stat_prev_loaded,
673 &prev_ps->priority_xon_rx[i],
674 &cur_ps->priority_xon_rx[i]);
675 ice_stat_update32(hw, GLPRT_PXONTXC(port, i),
676 pf->stat_prev_loaded,
677 &prev_ps->priority_xon_tx[i],
678 &cur_ps->priority_xon_tx[i]);
679 ice_stat_update32(hw, GLPRT_PXOFFTXC(port, i),
680 pf->stat_prev_loaded,
681 &prev_ps->priority_xoff_tx[i],
682 &cur_ps->priority_xoff_tx[i]);
683 ice_stat_update32(hw, GLPRT_RXON2OFFCNT(port, i),
684 pf->stat_prev_loaded,
685 &prev_ps->priority_xon_2_xoff[i],
686 &cur_ps->priority_xon_2_xoff[i]);
691 * ice_tx_prepare_vlan_flags_dcb - prepare VLAN tagging for DCB
692 * @tx_ring: ring to send buffer on
693 * @first: pointer to struct ice_tx_buf
696 ice_tx_prepare_vlan_flags_dcb(struct ice_ring *tx_ring,
697 struct ice_tx_buf *first)
699 struct sk_buff *skb = first->skb;
701 if (!test_bit(ICE_FLAG_DCB_ENA, tx_ring->vsi->back->flags))
704 /* Insert 802.1p priority into VLAN header */
705 if ((first->tx_flags & (ICE_TX_FLAGS_HW_VLAN | ICE_TX_FLAGS_SW_VLAN)) ||
706 skb->priority != TC_PRIO_CONTROL) {
707 first->tx_flags &= ~ICE_TX_FLAGS_VLAN_PR_M;
708 /* Mask the lower 3 bits to set the 802.1p priority */
709 first->tx_flags |= (skb->priority & 0x7) <<
710 ICE_TX_FLAGS_VLAN_PR_S;
711 if (first->tx_flags & ICE_TX_FLAGS_SW_VLAN) {
712 struct vlan_ethhdr *vhdr;
715 rc = skb_cow_head(skb, 0);
718 vhdr = (struct vlan_ethhdr *)skb->data;
719 vhdr->h_vlan_TCI = htons(first->tx_flags >>
720 ICE_TX_FLAGS_VLAN_S);
722 first->tx_flags |= ICE_TX_FLAGS_HW_VLAN;
730 * ice_dcb_process_lldp_set_mib_change - Process MIB change
732 * @event: pointer to the admin queue receive event
735 ice_dcb_process_lldp_set_mib_change(struct ice_pf *pf,
736 struct ice_rq_event_info *event)
738 struct ice_aqc_port_ets_elem buf = { 0 };
739 struct device *dev = ice_pf_to_dev(pf);
740 struct ice_aqc_lldp_get_mib *mib;
741 struct ice_dcbx_cfg tmp_dcbx_cfg;
742 bool need_reconfig = false;
743 struct ice_port_info *pi;
744 struct ice_vsi *pf_vsi;
748 /* Not DCB capable or capability disabled */
749 if (!(test_bit(ICE_FLAG_DCB_CAPABLE, pf->flags)))
752 if (pf->dcbx_cap & DCB_CAP_DCBX_HOST) {
753 dev_dbg(dev, "MIB Change Event in HOST mode\n");
757 pi = pf->hw.port_info;
758 mib = (struct ice_aqc_lldp_get_mib *)&event->desc.params.raw;
759 /* Ignore if event is not for Nearest Bridge */
760 type = ((mib->type >> ICE_AQ_LLDP_BRID_TYPE_S) &
761 ICE_AQ_LLDP_BRID_TYPE_M);
762 dev_dbg(dev, "LLDP event MIB bridge type 0x%x\n", type);
763 if (type != ICE_AQ_LLDP_BRID_TYPE_NEAREST_BRID)
766 /* Check MIB Type and return if event for Remote MIB update */
767 type = mib->type & ICE_AQ_LLDP_MIB_TYPE_M;
768 dev_dbg(dev, "LLDP event mib type %s\n", type ? "remote" : "local");
769 if (type == ICE_AQ_LLDP_MIB_REMOTE) {
770 /* Update the remote cached instance and return */
771 ret = ice_aq_get_dcb_cfg(pi->hw, ICE_AQ_LLDP_MIB_REMOTE,
772 ICE_AQ_LLDP_BRID_TYPE_NEAREST_BRID,
773 &pi->remote_dcbx_cfg);
775 dev_err(dev, "Failed to get remote DCB config\n");
780 /* store the old configuration */
781 tmp_dcbx_cfg = pf->hw.port_info->local_dcbx_cfg;
783 /* Reset the old DCBX configuration data */
784 memset(&pi->local_dcbx_cfg, 0, sizeof(pi->local_dcbx_cfg));
786 /* Get updated DCBX data from firmware */
787 ret = ice_get_dcb_cfg(pf->hw.port_info);
789 dev_err(dev, "Failed to get DCB config\n");
793 /* No change detected in DCBX configs */
794 if (!memcmp(&tmp_dcbx_cfg, &pi->local_dcbx_cfg, sizeof(tmp_dcbx_cfg))) {
795 dev_dbg(dev, "No change detected in DCBX configuration.\n");
799 need_reconfig = ice_dcb_need_recfg(pf, &tmp_dcbx_cfg,
800 &pi->local_dcbx_cfg);
801 ice_dcbnl_flush_apps(pf, &tmp_dcbx_cfg, &pi->local_dcbx_cfg);
805 /* Enable DCB tagging only when more than one TC */
806 if (ice_dcb_get_num_tc(&pi->local_dcbx_cfg) > 1) {
807 dev_dbg(dev, "DCB tagging enabled (num TC > 1)\n");
808 set_bit(ICE_FLAG_DCB_ENA, pf->flags);
810 dev_dbg(dev, "DCB tagging disabled (num TC = 1)\n");
811 clear_bit(ICE_FLAG_DCB_ENA, pf->flags);
814 pf_vsi = ice_get_main_vsi(pf);
816 dev_dbg(dev, "PF VSI doesn't exist\n");
821 ice_dis_vsi(pf_vsi, true);
823 ret = ice_query_port_ets(pf->hw.port_info, &buf, sizeof(buf), NULL);
825 dev_err(dev, "Query Port ETS failed\n");
830 /* changes in configuration update VSI */
831 ice_pf_dcb_recfg(pf);
833 ice_ena_vsi(pf_vsi, true);