1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2019, Intel Corporation. */
3 
4 #include "ice_dcb_lib.h"
5 
6 /**
7  * ice_dcb_get_ena_tc - return bitmap of enabled TCs
8  * @dcbcfg: DCB config to evaluate for enabled TCs
9  */
10 u8 ice_dcb_get_ena_tc(struct ice_dcbx_cfg *dcbcfg)
11 {
12 	u8 i, num_tc, ena_tc = 1;
13 
14 	num_tc = ice_dcb_get_num_tc(dcbcfg);
15 
16 	for (i = 0; i < num_tc; i++)
17 		ena_tc |= BIT(i);
18 
19 	return ena_tc;
20 }
21 
22 /**
23  * ice_dcb_get_num_tc - Get the number of TCs from DCBX config
24  * @dcbcfg: config to retrieve number of TCs from
25  */
26 u8 ice_dcb_get_num_tc(struct ice_dcbx_cfg *dcbcfg)
27 {
28 	bool tc_unused = false;
29 	u8 num_tc = 0;
30 	u8 ret = 0;
31 	int i;
32 
33 	/* Scan the ETS Config Priority Table to find traffic classes
34 	 * enabled and create a bitmask of enabled TCs
35 	 */
36 	for (i = 0; i < CEE_DCBX_MAX_PRIO; i++)
37 		num_tc |= BIT(dcbcfg->etscfg.prio_table[i]);
38 
39 	/* Scan bitmask for contiguous TCs starting with TC0 */
40 	for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) {
41 		if (num_tc & BIT(i)) {
42 			if (!tc_unused) {
43 				ret++;
44 			} else {
45 				pr_err("Non-contiguous TCs - Disabling DCB\n");
46 				return 1;
47 			}
48 		} else {
49 			tc_unused = true;
50 		}
51 	}
52 
53 	/* There is always at least 1 TC */
54 	if (!ret)
55 		ret = 1;
56 
57 	return ret;
58 }
59 
60 /**
61  * ice_vsi_cfg_dcb_rings - Update rings to reflect DCB TC
62  * @vsi: VSI owner of rings being updated
63  */
64 void ice_vsi_cfg_dcb_rings(struct ice_vsi *vsi)
65 {
66 	struct ice_ring *tx_ring, *rx_ring;
67 	u16 qoffset, qcount;
68 	int i, n;
69 
70 	if (!test_bit(ICE_FLAG_DCB_ENA, vsi->back->flags)) {
71 		/* Reset the TC information */
72 		for (i = 0; i < vsi->num_txq; i++) {
73 			tx_ring = vsi->tx_rings[i];
74 			tx_ring->dcb_tc = 0;
75 		}
76 		for (i = 0; i < vsi->num_rxq; i++) {
77 			rx_ring = vsi->rx_rings[i];
78 			rx_ring->dcb_tc = 0;
79 		}
80 		return;
81 	}
82 
83 	ice_for_each_traffic_class(n) {
84 		if (!(vsi->tc_cfg.ena_tc & BIT(n)))
85 			break;
86 
87 		qoffset = vsi->tc_cfg.tc_info[n].qoffset;
88 		qcount = vsi->tc_cfg.tc_info[n].qcount_tx;
89 		for (i = qoffset; i < (qoffset + qcount); i++) {
90 			tx_ring = vsi->tx_rings[i];
91 			rx_ring = vsi->rx_rings[i];
92 			tx_ring->dcb_tc = n;
93 			rx_ring->dcb_tc = n;
94 		}
95 	}
96 }
97 
98 /**
99  * ice_pf_dcb_recfg - Reconfigure all VEBs and VSIs
100  * @pf: pointer to the PF struct
101  *
102  * Assumed caller has already disabled all VSIs before
103  * calling this function. Reconfiguring DCB based on
104  * local_dcbx_cfg.
105  */
106 static void ice_pf_dcb_recfg(struct ice_pf *pf)
107 {
108 	struct ice_dcbx_cfg *dcbcfg = &pf->hw.port_info->local_dcbx_cfg;
109 	u8 tc_map = 0;
110 	int v, ret;
111 
112 	/* Update each VSI */
113 	ice_for_each_vsi(pf, v) {
114 		if (!pf->vsi[v])
115 			continue;
116 
117 		if (pf->vsi[v]->type == ICE_VSI_PF)
118 			tc_map = ice_dcb_get_ena_tc(dcbcfg);
119 		else
120 			tc_map = ICE_DFLT_TRAFFIC_CLASS;
121 
122 		ret = ice_vsi_cfg_tc(pf->vsi[v], tc_map);
123 		if (ret) {
124 			dev_err(&pf->pdev->dev,
125 				"Failed to config TC for VSI index: %d\n",
126 				pf->vsi[v]->idx);
127 			continue;
128 		}
129 
130 		ice_vsi_map_rings_to_vectors(pf->vsi[v]);
131 	}
132 }
133 
134 /**
135  * ice_pf_dcb_cfg - Apply new DCB configuration
136  * @pf: pointer to the PF struct
137  * @new_cfg: DCBX config to apply
138  * @locked: is the RTNL held
139  */
140 static
141 int ice_pf_dcb_cfg(struct ice_pf *pf, struct ice_dcbx_cfg *new_cfg, bool locked)
142 {
143 	struct ice_dcbx_cfg *old_cfg, *curr_cfg;
144 	struct ice_aqc_port_ets_elem buf = { 0 };
145 	int ret = 0;
146 
147 	curr_cfg = &pf->hw.port_info->local_dcbx_cfg;
148 
149 	/* Enable DCB tagging only when more than one TC */
150 	if (ice_dcb_get_num_tc(new_cfg) > 1) {
151 		dev_dbg(&pf->pdev->dev, "DCB tagging enabled (num TC > 1)\n");
152 		set_bit(ICE_FLAG_DCB_ENA, pf->flags);
153 	} else {
154 		dev_dbg(&pf->pdev->dev, "DCB tagging disabled (num TC = 1)\n");
155 		clear_bit(ICE_FLAG_DCB_ENA, pf->flags);
156 	}
157 
158 	if (!memcmp(new_cfg, curr_cfg, sizeof(*new_cfg))) {
159 		dev_dbg(&pf->pdev->dev, "No change in DCB config required\n");
160 		return ret;
161 	}
162 
163 	/* Store old config in case FW config fails */
164 	old_cfg = devm_kzalloc(&pf->pdev->dev, sizeof(*old_cfg), GFP_KERNEL);
165 	memcpy(old_cfg, curr_cfg, sizeof(*old_cfg));
166 
167 	/* avoid race conditions by holding the lock while disabling and
168 	 * re-enabling the VSI
169 	 */
170 	if (!locked)
171 		rtnl_lock();
172 	ice_pf_dis_all_vsi(pf, true);
173 
174 	memcpy(curr_cfg, new_cfg, sizeof(*curr_cfg));
175 	memcpy(&curr_cfg->etsrec, &curr_cfg->etscfg, sizeof(curr_cfg->etsrec));
176 
177 	/* Only send new config to HW if we are in SW LLDP mode. Otherwise,
178 	 * the new config came from the HW in the first place.
179 	 */
180 	if (pf->hw.port_info->is_sw_lldp) {
181 		ret = ice_set_dcb_cfg(pf->hw.port_info);
182 		if (ret) {
183 			dev_err(&pf->pdev->dev, "Set DCB Config failed\n");
184 			/* Restore previous settings to local config */
185 			memcpy(curr_cfg, old_cfg, sizeof(*curr_cfg));
186 			goto out;
187 		}
188 	}
189 
190 	ret = ice_query_port_ets(pf->hw.port_info, &buf, sizeof(buf), NULL);
191 	if (ret) {
192 		dev_err(&pf->pdev->dev, "Query Port ETS failed\n");
193 		goto out;
194 	}
195 
196 	ice_pf_dcb_recfg(pf);
197 
198 out:
199 	ice_pf_ena_all_vsi(pf, true);
200 	if (!locked)
201 		rtnl_unlock();
202 	devm_kfree(&pf->pdev->dev, old_cfg);
203 	return ret;
204 }
205 
206 /**
207  * ice_dcb_rebuild - rebuild DCB post reset
208  * @pf: physical function instance
209  */
210 void ice_dcb_rebuild(struct ice_pf *pf)
211 {
212 	struct ice_aqc_port_ets_elem buf = { 0 };
213 	struct ice_dcbx_cfg *prev_cfg;
214 	enum ice_status ret;
215 	u8 willing;
216 
217 	ret = ice_query_port_ets(pf->hw.port_info, &buf, sizeof(buf), NULL);
218 	if (ret) {
219 		dev_err(&pf->pdev->dev, "Query Port ETS failed\n");
220 		goto dcb_error;
221 	}
222 
223 	/* If DCB was not enabled previously, we are done */
224 	if (!test_bit(ICE_FLAG_DCB_ENA, pf->flags))
225 		return;
226 
227 	/* Save current willing state and force FW to unwilling */
228 	willing = pf->hw.port_info->local_dcbx_cfg.etscfg.willing;
229 	pf->hw.port_info->local_dcbx_cfg.etscfg.willing = 0x0;
230 	ret = ice_set_dcb_cfg(pf->hw.port_info);
231 	if (ret) {
232 		dev_err(&pf->pdev->dev, "Failed to set DCB to unwilling\n");
233 		goto dcb_error;
234 	}
235 
236 	/* Retrieve DCB config and ensure same as current in SW */
237 	prev_cfg = devm_kmemdup(&pf->pdev->dev,
238 				&pf->hw.port_info->local_dcbx_cfg,
239 				sizeof(*prev_cfg), GFP_KERNEL);
240 	if (!prev_cfg) {
241 		dev_err(&pf->pdev->dev, "Failed to alloc space for DCB cfg\n");
242 		goto dcb_error;
243 	}
244 
245 	ice_init_dcb(&pf->hw);
246 	if (memcmp(prev_cfg, &pf->hw.port_info->local_dcbx_cfg,
247 		   sizeof(*prev_cfg))) {
248 		/* difference in cfg detected - disable DCB till next MIB */
249 		dev_err(&pf->pdev->dev, "Set local MIB not accurate\n");
250 		devm_kfree(&pf->pdev->dev, prev_cfg);
251 		goto dcb_error;
252 	}
253 
254 	/* fetched config congruent to previous configuration */
255 	devm_kfree(&pf->pdev->dev, prev_cfg);
256 
257 	/* Configuration replayed - reset willing state to previous */
258 	pf->hw.port_info->local_dcbx_cfg.etscfg.willing = willing;
259 	ret = ice_set_dcb_cfg(pf->hw.port_info);
260 	if (ret) {
261 		dev_err(&pf->pdev->dev, "Fail restoring prev willing state\n");
262 		goto dcb_error;
263 	}
264 	dev_info(&pf->pdev->dev, "DCB restored after reset\n");
265 	ret = ice_query_port_ets(pf->hw.port_info, &buf, sizeof(buf), NULL);
266 	if (ret) {
267 		dev_err(&pf->pdev->dev, "Query Port ETS failed\n");
268 		goto dcb_error;
269 	}
270 
271 	return;
272 
273 dcb_error:
274 	dev_err(&pf->pdev->dev, "Disabling DCB until new settings occur\n");
275 	prev_cfg = devm_kzalloc(&pf->pdev->dev, sizeof(*prev_cfg), GFP_KERNEL);
276 	prev_cfg->etscfg.willing = true;
277 	prev_cfg->etscfg.tcbwtable[0] = ICE_TC_MAX_BW;
278 	prev_cfg->etscfg.tsatable[0] = ICE_IEEE_TSA_ETS;
279 	memcpy(&prev_cfg->etsrec, &prev_cfg->etscfg, sizeof(prev_cfg->etsrec));
280 	ice_pf_dcb_cfg(pf, prev_cfg, false);
281 	devm_kfree(&pf->pdev->dev, prev_cfg);
282 }
283 
284 /**
285  * ice_dcb_init_cfg - set the initial DCB config in SW
286  * @pf: PF to apply config to
287  * @locked: Is the RTNL held
288  */
289 static int ice_dcb_init_cfg(struct ice_pf *pf, bool locked)
290 {
291 	struct ice_dcbx_cfg *newcfg;
292 	struct ice_port_info *pi;
293 	int ret = 0;
294 
295 	pi = pf->hw.port_info;
296 	newcfg = devm_kzalloc(&pf->pdev->dev, sizeof(*newcfg), GFP_KERNEL);
297 	if (!newcfg)
298 		return -ENOMEM;
299 
300 	memcpy(newcfg, &pi->local_dcbx_cfg, sizeof(*newcfg));
301 	memset(&pi->local_dcbx_cfg, 0, sizeof(*newcfg));
302 
303 	dev_info(&pf->pdev->dev, "Configuring initial DCB values\n");
304 	if (ice_pf_dcb_cfg(pf, newcfg, locked))
305 		ret = -EINVAL;
306 
307 	devm_kfree(&pf->pdev->dev, newcfg);
308 
309 	return ret;
310 }
311 
312 /**
313  * ice_dcb_sw_default_config - Apply a default DCB config
314  * @pf: PF to apply config to
315  * @locked: was this function called with RTNL held
316  */
317 static int ice_dcb_sw_dflt_cfg(struct ice_pf *pf, bool locked)
318 {
319 	struct ice_aqc_port_ets_elem buf = { 0 };
320 	struct ice_dcbx_cfg *dcbcfg;
321 	struct ice_port_info *pi;
322 	struct ice_hw *hw;
323 	int ret;
324 
325 	hw = &pf->hw;
326 	pi = hw->port_info;
327 	dcbcfg = devm_kzalloc(&pf->pdev->dev, sizeof(*dcbcfg), GFP_KERNEL);
328 
329 	memset(dcbcfg, 0, sizeof(*dcbcfg));
330 	memset(&pi->local_dcbx_cfg, 0, sizeof(*dcbcfg));
331 
332 	dcbcfg->etscfg.willing = 1;
333 	dcbcfg->etscfg.maxtcs = 8;
334 	dcbcfg->etscfg.tcbwtable[0] = 100;
335 	dcbcfg->etscfg.tsatable[0] = ICE_IEEE_TSA_ETS;
336 
337 	memcpy(&dcbcfg->etsrec, &dcbcfg->etscfg,
338 	       sizeof(dcbcfg->etsrec));
339 	dcbcfg->etsrec.willing = 0;
340 
341 	dcbcfg->pfc.willing = 1;
342 	dcbcfg->pfc.pfccap = IEEE_8021QAZ_MAX_TCS;
343 
344 	dcbcfg->numapps = 1;
345 	dcbcfg->app[0].selector = ICE_APP_SEL_ETHTYPE;
346 	dcbcfg->app[0].priority = 3;
347 	dcbcfg->app[0].prot_id = ICE_APP_PROT_ID_FCOE;
348 
349 	ret = ice_pf_dcb_cfg(pf, dcbcfg, locked);
350 	devm_kfree(&pf->pdev->dev, dcbcfg);
351 	if (ret)
352 		return ret;
353 
354 	return ice_query_port_ets(pi, &buf, sizeof(buf), NULL);
355 }
356 
357 /**
358  * ice_init_pf_dcb - initialize DCB for a PF
359  * @pf: PF to initialize DCB for
360  * @locked: Was function called with RTNL held
361  */
362 int ice_init_pf_dcb(struct ice_pf *pf, bool locked)
363 {
364 	struct device *dev = &pf->pdev->dev;
365 	struct ice_port_info *port_info;
366 	struct ice_hw *hw = &pf->hw;
367 	int sw_default = 0;
368 	int err;
369 
370 	port_info = hw->port_info;
371 
372 	err = ice_init_dcb(hw);
373 	if (err) {
374 		/* FW LLDP is not active, default to SW DCBX/LLDP */
375 		dev_info(&pf->pdev->dev, "FW LLDP is not active\n");
376 		hw->port_info->dcbx_status = ICE_DCBX_STATUS_NOT_STARTED;
377 		hw->port_info->is_sw_lldp = true;
378 	}
379 
380 	if (port_info->dcbx_status == ICE_DCBX_STATUS_DIS)
381 		dev_info(&pf->pdev->dev, "DCBX disabled\n");
382 
383 	/* LLDP disabled in FW */
384 	if (port_info->is_sw_lldp) {
385 		sw_default = 1;
386 		dev_info(&pf->pdev->dev, "DCBx/LLDP in SW mode.\n");
387 		clear_bit(ICE_FLAG_ENABLE_FW_LLDP, pf->flags);
388 	} else {
389 		set_bit(ICE_FLAG_ENABLE_FW_LLDP, pf->flags);
390 	}
391 
392 	if (port_info->dcbx_status == ICE_DCBX_STATUS_NOT_STARTED)
393 		dev_info(&pf->pdev->dev, "DCBX not started\n");
394 
395 	if (sw_default) {
396 		err = ice_dcb_sw_dflt_cfg(pf, locked);
397 		if (err) {
398 			dev_err(&pf->pdev->dev,
399 				"Failed to set local DCB config %d\n", err);
400 			err = -EIO;
401 			goto dcb_init_err;
402 		}
403 
404 		pf->dcbx_cap = DCB_CAP_DCBX_HOST | DCB_CAP_DCBX_VER_IEEE;
405 		set_bit(ICE_FLAG_DCB_CAPABLE, pf->flags);
406 		set_bit(ICE_FLAG_DCB_ENA, pf->flags);
407 		return 0;
408 	}
409 
410 	/* DCBX in FW and LLDP enabled in FW */
411 	pf->dcbx_cap = DCB_CAP_DCBX_LLD_MANAGED | DCB_CAP_DCBX_VER_IEEE;
412 
413 	set_bit(ICE_FLAG_DCB_CAPABLE, pf->flags);
414 
415 	err = ice_dcb_init_cfg(pf, locked);
416 	if (err)
417 		goto dcb_init_err;
418 
419 	dev_info(&pf->pdev->dev, "DCBX offload supported\n");
420 	return err;
421 
422 dcb_init_err:
423 	dev_err(dev, "DCB init failed\n");
424 	return err;
425 }
426 
427 /**
428  * ice_update_dcb_stats - Update DCB stats counters
429  * @pf: PF whose stats needs to be updated
430  */
431 void ice_update_dcb_stats(struct ice_pf *pf)
432 {
433 	struct ice_hw_port_stats *prev_ps, *cur_ps;
434 	struct ice_hw *hw = &pf->hw;
435 	u8 pf_id = hw->pf_id;
436 	int i;
437 
438 	prev_ps = &pf->stats_prev;
439 	cur_ps = &pf->stats;
440 
441 	for (i = 0; i < 8; i++) {
442 		ice_stat_update32(hw, GLPRT_PXOFFRXC(pf_id, i),
443 				  pf->stat_prev_loaded,
444 				  &prev_ps->priority_xoff_rx[i],
445 				  &cur_ps->priority_xoff_rx[i]);
446 		ice_stat_update32(hw, GLPRT_PXONRXC(pf_id, i),
447 				  pf->stat_prev_loaded,
448 				  &prev_ps->priority_xon_rx[i],
449 				  &cur_ps->priority_xon_rx[i]);
450 		ice_stat_update32(hw, GLPRT_PXONTXC(pf_id, i),
451 				  pf->stat_prev_loaded,
452 				  &prev_ps->priority_xon_tx[i],
453 				  &cur_ps->priority_xon_tx[i]);
454 		ice_stat_update32(hw, GLPRT_PXOFFTXC(pf_id, i),
455 				  pf->stat_prev_loaded,
456 				  &prev_ps->priority_xoff_tx[i],
457 				  &cur_ps->priority_xoff_tx[i]);
458 		ice_stat_update32(hw, GLPRT_RXON2OFFCNT(pf_id, i),
459 				  pf->stat_prev_loaded,
460 				  &prev_ps->priority_xon_2_xoff[i],
461 				  &cur_ps->priority_xon_2_xoff[i]);
462 	}
463 }
464 
465 /**
466  * ice_tx_prepare_vlan_flags_dcb - prepare VLAN tagging for DCB
467  * @tx_ring: ring to send buffer on
468  * @first: pointer to struct ice_tx_buf
469  */
470 int
471 ice_tx_prepare_vlan_flags_dcb(struct ice_ring *tx_ring,
472 			      struct ice_tx_buf *first)
473 {
474 	struct sk_buff *skb = first->skb;
475 
476 	if (!test_bit(ICE_FLAG_DCB_ENA, tx_ring->vsi->back->flags))
477 		return 0;
478 
479 	/* Insert 802.1p priority into VLAN header */
480 	if ((first->tx_flags & (ICE_TX_FLAGS_HW_VLAN | ICE_TX_FLAGS_SW_VLAN)) ||
481 	    skb->priority != TC_PRIO_CONTROL) {
482 		first->tx_flags &= ~ICE_TX_FLAGS_VLAN_PR_M;
483 		/* Mask the lower 3 bits to set the 802.1p priority */
484 		first->tx_flags |= (skb->priority & 0x7) <<
485 				   ICE_TX_FLAGS_VLAN_PR_S;
486 		if (first->tx_flags & ICE_TX_FLAGS_SW_VLAN) {
487 			struct vlan_ethhdr *vhdr;
488 			int rc;
489 
490 			rc = skb_cow_head(skb, 0);
491 			if (rc < 0)
492 				return rc;
493 			vhdr = (struct vlan_ethhdr *)skb->data;
494 			vhdr->h_vlan_TCI = htons(first->tx_flags >>
495 						 ICE_TX_FLAGS_VLAN_S);
496 		} else {
497 			first->tx_flags |= ICE_TX_FLAGS_HW_VLAN;
498 		}
499 	}
500 
501 	return 0;
502 }
503 
504 /**
505  * ice_dcb_need_recfg - Check if DCB needs reconfig
506  * @pf: board private structure
507  * @old_cfg: current DCB config
508  * @new_cfg: new DCB config
509  */
510 static bool ice_dcb_need_recfg(struct ice_pf *pf, struct ice_dcbx_cfg *old_cfg,
511 			       struct ice_dcbx_cfg *new_cfg)
512 {
513 	bool need_reconfig = false;
514 
515 	/* Check if ETS configuration has changed */
516 	if (memcmp(&new_cfg->etscfg, &old_cfg->etscfg,
517 		   sizeof(new_cfg->etscfg))) {
518 		/* If Priority Table has changed reconfig is needed */
519 		if (memcmp(&new_cfg->etscfg.prio_table,
520 			   &old_cfg->etscfg.prio_table,
521 			   sizeof(new_cfg->etscfg.prio_table))) {
522 			need_reconfig = true;
523 			dev_dbg(&pf->pdev->dev, "ETS UP2TC changed.\n");
524 		}
525 
526 		if (memcmp(&new_cfg->etscfg.tcbwtable,
527 			   &old_cfg->etscfg.tcbwtable,
528 			   sizeof(new_cfg->etscfg.tcbwtable)))
529 			dev_dbg(&pf->pdev->dev, "ETS TC BW Table changed.\n");
530 
531 		if (memcmp(&new_cfg->etscfg.tsatable,
532 			   &old_cfg->etscfg.tsatable,
533 			   sizeof(new_cfg->etscfg.tsatable)))
534 			dev_dbg(&pf->pdev->dev, "ETS TSA Table changed.\n");
535 	}
536 
537 	/* Check if PFC configuration has changed */
538 	if (memcmp(&new_cfg->pfc, &old_cfg->pfc, sizeof(new_cfg->pfc))) {
539 		need_reconfig = true;
540 		dev_dbg(&pf->pdev->dev, "PFC config change detected.\n");
541 	}
542 
543 	/* Check if APP Table has changed */
544 	if (memcmp(&new_cfg->app, &old_cfg->app, sizeof(new_cfg->app))) {
545 		need_reconfig = true;
546 		dev_dbg(&pf->pdev->dev, "APP Table change detected.\n");
547 	}
548 
549 	dev_dbg(&pf->pdev->dev, "dcb need_reconfig=%d\n", need_reconfig);
550 	return need_reconfig;
551 }
552 
553 /**
554  * ice_dcb_process_lldp_set_mib_change - Process MIB change
555  * @pf: ptr to ice_pf
556  * @event: pointer to the admin queue receive event
557  */
558 void
559 ice_dcb_process_lldp_set_mib_change(struct ice_pf *pf,
560 				    struct ice_rq_event_info *event)
561 {
562 	struct ice_aqc_port_ets_elem buf = { 0 };
563 	struct ice_aqc_lldp_get_mib *mib;
564 	struct ice_dcbx_cfg tmp_dcbx_cfg;
565 	bool need_reconfig = false;
566 	struct ice_port_info *pi;
567 	u8 type;
568 	int ret;
569 
570 	/* Not DCB capable or capability disabled */
571 	if (!(test_bit(ICE_FLAG_DCB_CAPABLE, pf->flags)))
572 		return;
573 
574 	if (pf->dcbx_cap & DCB_CAP_DCBX_HOST) {
575 		dev_dbg(&pf->pdev->dev,
576 			"MIB Change Event in HOST mode\n");
577 		return;
578 	}
579 
580 	pi = pf->hw.port_info;
581 	mib = (struct ice_aqc_lldp_get_mib *)&event->desc.params.raw;
582 	/* Ignore if event is not for Nearest Bridge */
583 	type = ((mib->type >> ICE_AQ_LLDP_BRID_TYPE_S) &
584 		ICE_AQ_LLDP_BRID_TYPE_M);
585 	dev_dbg(&pf->pdev->dev, "LLDP event MIB bridge type 0x%x\n", type);
586 	if (type != ICE_AQ_LLDP_BRID_TYPE_NEAREST_BRID)
587 		return;
588 
589 	/* Check MIB Type and return if event for Remote MIB update */
590 	type = mib->type & ICE_AQ_LLDP_MIB_TYPE_M;
591 	dev_dbg(&pf->pdev->dev,
592 		"LLDP event mib type %s\n", type ? "remote" : "local");
593 	if (type == ICE_AQ_LLDP_MIB_REMOTE) {
594 		/* Update the remote cached instance and return */
595 		ret = ice_aq_get_dcb_cfg(pi->hw, ICE_AQ_LLDP_MIB_REMOTE,
596 					 ICE_AQ_LLDP_BRID_TYPE_NEAREST_BRID,
597 					 &pi->remote_dcbx_cfg);
598 		if (ret) {
599 			dev_err(&pf->pdev->dev, "Failed to get remote DCB config\n");
600 			return;
601 		}
602 	}
603 
604 	/* store the old configuration */
605 	tmp_dcbx_cfg = pf->hw.port_info->local_dcbx_cfg;
606 
607 	/* Reset the old DCBX configuration data */
608 	memset(&pi->local_dcbx_cfg, 0, sizeof(pi->local_dcbx_cfg));
609 
610 	/* Get updated DCBX data from firmware */
611 	ret = ice_get_dcb_cfg(pf->hw.port_info);
612 	if (ret) {
613 		dev_err(&pf->pdev->dev, "Failed to get DCB config\n");
614 		return;
615 	}
616 
617 	/* No change detected in DCBX configs */
618 	if (!memcmp(&tmp_dcbx_cfg, &pi->local_dcbx_cfg, sizeof(tmp_dcbx_cfg))) {
619 		dev_dbg(&pf->pdev->dev,
620 			"No change detected in DCBX configuration.\n");
621 		return;
622 	}
623 
624 	need_reconfig = ice_dcb_need_recfg(pf, &tmp_dcbx_cfg,
625 					   &pi->local_dcbx_cfg);
626 	if (!need_reconfig)
627 		return;
628 
629 	/* Enable DCB tagging only when more than one TC */
630 	if (ice_dcb_get_num_tc(&pi->local_dcbx_cfg) > 1) {
631 		dev_dbg(&pf->pdev->dev, "DCB tagging enabled (num TC > 1)\n");
632 		set_bit(ICE_FLAG_DCB_ENA, pf->flags);
633 	} else {
634 		dev_dbg(&pf->pdev->dev, "DCB tagging disabled (num TC = 1)\n");
635 		clear_bit(ICE_FLAG_DCB_ENA, pf->flags);
636 	}
637 
638 	rtnl_lock();
639 	ice_pf_dis_all_vsi(pf, true);
640 
641 	ret = ice_query_port_ets(pf->hw.port_info, &buf, sizeof(buf), NULL);
642 	if (ret) {
643 		dev_err(&pf->pdev->dev, "Query Port ETS failed\n");
644 		rtnl_unlock();
645 		return;
646 	}
647 
648 	/* changes in configuration update VSI */
649 	ice_pf_dcb_recfg(pf);
650 
651 	ice_pf_ena_all_vsi(pf, true);
652 	rtnl_unlock();
653 }
654