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 ice_pf_dcb_cfg(pf, prev_cfg, false);
404 * ice_dcb_init_cfg - set the initial DCB config in SW
405 * @pf: PF to apply config to
406 * @locked: Is the RTNL held
408 static int ice_dcb_init_cfg(struct ice_pf *pf, bool locked)
410 struct ice_dcbx_cfg *newcfg;
411 struct ice_port_info *pi;
414 pi = pf->hw.port_info;
415 newcfg = kmemdup(&pi->local_dcbx_cfg, sizeof(*newcfg), GFP_KERNEL);
419 memset(&pi->local_dcbx_cfg, 0, sizeof(*newcfg));
421 dev_info(ice_pf_to_dev(pf), "Configuring initial DCB values\n");
422 if (ice_pf_dcb_cfg(pf, newcfg, locked))
431 * ice_dcb_sw_default_config - Apply a default DCB config
432 * @pf: PF to apply config to
433 * @ets_willing: configure ets willing
434 * @locked: was this function called with RTNL held
436 static int ice_dcb_sw_dflt_cfg(struct ice_pf *pf, bool ets_willing, bool locked)
438 struct ice_aqc_port_ets_elem buf = { 0 };
439 struct ice_dcbx_cfg *dcbcfg;
440 struct ice_port_info *pi;
446 dcbcfg = kzalloc(sizeof(*dcbcfg), GFP_KERNEL);
450 memset(&pi->local_dcbx_cfg, 0, sizeof(*dcbcfg));
452 dcbcfg->etscfg.willing = ets_willing ? 1 : 0;
453 dcbcfg->etscfg.maxtcs = hw->func_caps.common_cap.maxtc;
454 dcbcfg->etscfg.tcbwtable[0] = 100;
455 dcbcfg->etscfg.tsatable[0] = ICE_IEEE_TSA_ETS;
457 memcpy(&dcbcfg->etsrec, &dcbcfg->etscfg,
458 sizeof(dcbcfg->etsrec));
459 dcbcfg->etsrec.willing = 0;
461 dcbcfg->pfc.willing = 1;
462 dcbcfg->pfc.pfccap = hw->func_caps.common_cap.maxtc;
465 dcbcfg->app[0].selector = ICE_APP_SEL_ETHTYPE;
466 dcbcfg->app[0].priority = 3;
467 dcbcfg->app[0].prot_id = ICE_APP_PROT_ID_FCOE;
469 ret = ice_pf_dcb_cfg(pf, dcbcfg, locked);
474 return ice_query_port_ets(pi, &buf, sizeof(buf), NULL);
478 * ice_dcb_tc_contig - Check that TCs are contiguous
479 * @prio_table: pointer to priority table
481 * Check if TCs begin with TC0 and are contiguous
483 static bool ice_dcb_tc_contig(u8 *prio_table)
488 for (i = 0; i < CEE_DCBX_MAX_PRIO; i++) {
489 u8 cur_tc = prio_table[i];
493 else if (cur_tc == max_tc)
501 * ice_dcb_noncontig_cfg - Configure DCB for non-contiguous TCs
502 * @pf: pointer to the PF struct
504 * If non-contiguous TCs, then configure SW DCB with TC0 and ETS non-willing
506 static int ice_dcb_noncontig_cfg(struct ice_pf *pf)
508 struct ice_dcbx_cfg *dcbcfg = &pf->hw.port_info->local_dcbx_cfg;
509 struct device *dev = ice_pf_to_dev(pf);
512 /* Configure SW DCB default with ETS non-willing */
513 ret = ice_dcb_sw_dflt_cfg(pf, false, true);
515 dev_err(dev, "Failed to set local DCB config %d\n", ret);
519 /* Reconfigure with ETS willing so that FW will send LLDP MIB event */
520 dcbcfg->etscfg.willing = 1;
521 ret = ice_set_dcb_cfg(pf->hw.port_info);
523 dev_err(dev, "Failed to set DCB to unwilling\n");
529 * ice_pf_dcb_recfg - Reconfigure all VEBs and VSIs
530 * @pf: pointer to the PF struct
532 * Assumed caller has already disabled all VSIs before
533 * calling this function. Reconfiguring DCB based on
536 void ice_pf_dcb_recfg(struct ice_pf *pf)
538 struct ice_dcbx_cfg *dcbcfg = &pf->hw.port_info->local_dcbx_cfg;
542 /* Update each VSI */
543 ice_for_each_vsi(pf, v) {
544 struct ice_vsi *vsi = pf->vsi[v];
549 if (vsi->type == ICE_VSI_PF) {
550 tc_map = ice_dcb_get_ena_tc(dcbcfg);
552 /* If DCBX request non-contiguous TC, then configure
555 if (!ice_dcb_tc_contig(dcbcfg->etscfg.prio_table)) {
556 tc_map = ICE_DFLT_TRAFFIC_CLASS;
557 ice_dcb_noncontig_cfg(pf);
560 tc_map = ICE_DFLT_TRAFFIC_CLASS;
563 ret = ice_vsi_cfg_tc(vsi, tc_map);
565 dev_err(ice_pf_to_dev(pf), "Failed to config TC for VSI index: %d\n",
570 ice_vsi_map_rings_to_vectors(vsi);
571 if (vsi->type == ICE_VSI_PF)
572 ice_dcbnl_set_all(vsi);
577 * ice_init_pf_dcb - initialize DCB for a PF
578 * @pf: PF to initialize DCB for
579 * @locked: Was function called with RTNL held
581 int ice_init_pf_dcb(struct ice_pf *pf, bool locked)
583 struct device *dev = ice_pf_to_dev(pf);
584 struct ice_port_info *port_info;
585 struct ice_hw *hw = &pf->hw;
588 port_info = hw->port_info;
590 err = ice_init_dcb(hw, false);
591 if (err && !port_info->is_sw_lldp) {
592 dev_err(dev, "Error initializing DCB %d\n", err);
597 "DCB is enabled in the hardware, max number of TCs supported on this port are %d\n",
598 pf->hw.func_caps.common_cap.maxtc);
600 struct ice_vsi *pf_vsi;
602 /* FW LLDP is disabled, activate SW DCBX/LLDP mode */
603 dev_info(dev, "FW LLDP is disabled, DCBx/LLDP in SW mode.\n");
604 clear_bit(ICE_FLAG_FW_LLDP_AGENT, pf->flags);
605 err = ice_dcb_sw_dflt_cfg(pf, true, locked);
608 "Failed to set local DCB config %d\n", err);
613 /* If the FW DCBX engine is not running then Rx LLDP packets
614 * need to be redirected up the stack.
616 pf_vsi = ice_get_main_vsi(pf);
618 dev_err(dev, "Failed to set local DCB config\n");
623 ice_cfg_sw_lldp(pf_vsi, false, true);
625 pf->dcbx_cap = DCB_CAP_DCBX_HOST | DCB_CAP_DCBX_VER_IEEE;
629 set_bit(ICE_FLAG_FW_LLDP_AGENT, pf->flags);
631 /* DCBX in FW and LLDP enabled in FW */
632 pf->dcbx_cap = DCB_CAP_DCBX_LLD_MANAGED | DCB_CAP_DCBX_VER_IEEE;
634 err = ice_dcb_init_cfg(pf, locked);
641 dev_err(dev, "DCB init failed\n");
646 * ice_update_dcb_stats - Update DCB stats counters
647 * @pf: PF whose stats needs to be updated
649 void ice_update_dcb_stats(struct ice_pf *pf)
651 struct ice_hw_port_stats *prev_ps, *cur_ps;
652 struct ice_hw *hw = &pf->hw;
656 port = hw->port_info->lport;
657 prev_ps = &pf->stats_prev;
660 for (i = 0; i < 8; i++) {
661 ice_stat_update32(hw, GLPRT_PXOFFRXC(port, i),
662 pf->stat_prev_loaded,
663 &prev_ps->priority_xoff_rx[i],
664 &cur_ps->priority_xoff_rx[i]);
665 ice_stat_update32(hw, GLPRT_PXONRXC(port, i),
666 pf->stat_prev_loaded,
667 &prev_ps->priority_xon_rx[i],
668 &cur_ps->priority_xon_rx[i]);
669 ice_stat_update32(hw, GLPRT_PXONTXC(port, i),
670 pf->stat_prev_loaded,
671 &prev_ps->priority_xon_tx[i],
672 &cur_ps->priority_xon_tx[i]);
673 ice_stat_update32(hw, GLPRT_PXOFFTXC(port, i),
674 pf->stat_prev_loaded,
675 &prev_ps->priority_xoff_tx[i],
676 &cur_ps->priority_xoff_tx[i]);
677 ice_stat_update32(hw, GLPRT_RXON2OFFCNT(port, i),
678 pf->stat_prev_loaded,
679 &prev_ps->priority_xon_2_xoff[i],
680 &cur_ps->priority_xon_2_xoff[i]);
685 * ice_tx_prepare_vlan_flags_dcb - prepare VLAN tagging for DCB
686 * @tx_ring: ring to send buffer on
687 * @first: pointer to struct ice_tx_buf
690 ice_tx_prepare_vlan_flags_dcb(struct ice_ring *tx_ring,
691 struct ice_tx_buf *first)
693 struct sk_buff *skb = first->skb;
695 if (!test_bit(ICE_FLAG_DCB_ENA, tx_ring->vsi->back->flags))
698 /* Insert 802.1p priority into VLAN header */
699 if ((first->tx_flags & (ICE_TX_FLAGS_HW_VLAN | ICE_TX_FLAGS_SW_VLAN)) ||
700 skb->priority != TC_PRIO_CONTROL) {
701 first->tx_flags &= ~ICE_TX_FLAGS_VLAN_PR_M;
702 /* Mask the lower 3 bits to set the 802.1p priority */
703 first->tx_flags |= (skb->priority & 0x7) <<
704 ICE_TX_FLAGS_VLAN_PR_S;
705 if (first->tx_flags & ICE_TX_FLAGS_SW_VLAN) {
706 struct vlan_ethhdr *vhdr;
709 rc = skb_cow_head(skb, 0);
712 vhdr = (struct vlan_ethhdr *)skb->data;
713 vhdr->h_vlan_TCI = htons(first->tx_flags >>
714 ICE_TX_FLAGS_VLAN_S);
716 first->tx_flags |= ICE_TX_FLAGS_HW_VLAN;
724 * ice_dcb_process_lldp_set_mib_change - Process MIB change
726 * @event: pointer to the admin queue receive event
729 ice_dcb_process_lldp_set_mib_change(struct ice_pf *pf,
730 struct ice_rq_event_info *event)
732 struct ice_aqc_port_ets_elem buf = { 0 };
733 struct device *dev = ice_pf_to_dev(pf);
734 struct ice_aqc_lldp_get_mib *mib;
735 struct ice_dcbx_cfg tmp_dcbx_cfg;
736 bool need_reconfig = false;
737 struct ice_port_info *pi;
738 struct ice_vsi *pf_vsi;
742 /* Not DCB capable or capability disabled */
743 if (!(test_bit(ICE_FLAG_DCB_CAPABLE, pf->flags)))
746 if (pf->dcbx_cap & DCB_CAP_DCBX_HOST) {
747 dev_dbg(dev, "MIB Change Event in HOST mode\n");
751 pi = pf->hw.port_info;
752 mib = (struct ice_aqc_lldp_get_mib *)&event->desc.params.raw;
753 /* Ignore if event is not for Nearest Bridge */
754 type = ((mib->type >> ICE_AQ_LLDP_BRID_TYPE_S) &
755 ICE_AQ_LLDP_BRID_TYPE_M);
756 dev_dbg(dev, "LLDP event MIB bridge type 0x%x\n", type);
757 if (type != ICE_AQ_LLDP_BRID_TYPE_NEAREST_BRID)
760 /* Check MIB Type and return if event for Remote MIB update */
761 type = mib->type & ICE_AQ_LLDP_MIB_TYPE_M;
762 dev_dbg(dev, "LLDP event mib type %s\n", type ? "remote" : "local");
763 if (type == ICE_AQ_LLDP_MIB_REMOTE) {
764 /* Update the remote cached instance and return */
765 ret = ice_aq_get_dcb_cfg(pi->hw, ICE_AQ_LLDP_MIB_REMOTE,
766 ICE_AQ_LLDP_BRID_TYPE_NEAREST_BRID,
767 &pi->remote_dcbx_cfg);
769 dev_err(dev, "Failed to get remote DCB config\n");
774 /* store the old configuration */
775 tmp_dcbx_cfg = pf->hw.port_info->local_dcbx_cfg;
777 /* Reset the old DCBX configuration data */
778 memset(&pi->local_dcbx_cfg, 0, sizeof(pi->local_dcbx_cfg));
780 /* Get updated DCBX data from firmware */
781 ret = ice_get_dcb_cfg(pf->hw.port_info);
783 dev_err(dev, "Failed to get DCB config\n");
787 /* No change detected in DCBX configs */
788 if (!memcmp(&tmp_dcbx_cfg, &pi->local_dcbx_cfg, sizeof(tmp_dcbx_cfg))) {
789 dev_dbg(dev, "No change detected in DCBX configuration.\n");
793 need_reconfig = ice_dcb_need_recfg(pf, &tmp_dcbx_cfg,
794 &pi->local_dcbx_cfg);
795 ice_dcbnl_flush_apps(pf, &tmp_dcbx_cfg, &pi->local_dcbx_cfg);
799 /* Enable DCB tagging only when more than one TC */
800 if (ice_dcb_get_num_tc(&pi->local_dcbx_cfg) > 1) {
801 dev_dbg(dev, "DCB tagging enabled (num TC > 1)\n");
802 set_bit(ICE_FLAG_DCB_ENA, pf->flags);
804 dev_dbg(dev, "DCB tagging disabled (num TC = 1)\n");
805 clear_bit(ICE_FLAG_DCB_ENA, pf->flags);
808 pf_vsi = ice_get_main_vsi(pf);
810 dev_dbg(dev, "PF VSI doesn't exist\n");
815 ice_dis_vsi(pf_vsi, true);
817 ret = ice_query_port_ets(pf->hw.port_info, &buf, sizeof(buf), NULL);
819 dev_err(dev, "Query Port ETS failed\n");
824 /* changes in configuration update VSI */
825 ice_pf_dcb_recfg(pf);
827 ice_ena_vsi(pf_vsi, true);