Lines Matching refs:bp

25 static int bnxt_queue_to_tc(struct bnxt *bp, u8 queue_id)  in bnxt_queue_to_tc()  argument
29 for (i = 0; i < bp->max_tc; i++) { in bnxt_queue_to_tc()
30 if (bp->q_info[i].queue_id == queue_id) { in bnxt_queue_to_tc()
31 for (j = 0; j < bp->max_tc; j++) { in bnxt_queue_to_tc()
32 if (bp->tc_to_qidx[j] == i) in bnxt_queue_to_tc()
40 static int bnxt_hwrm_queue_pri2cos_cfg(struct bnxt *bp, struct ieee_ets *ets) in bnxt_hwrm_queue_pri2cos_cfg() argument
46 rc = hwrm_req_init(bp, req, HWRM_QUEUE_PRI2COS_CFG); in bnxt_hwrm_queue_pri2cos_cfg()
60 qidx = bp->tc_to_qidx[ets->prio_tc[i]]; in bnxt_hwrm_queue_pri2cos_cfg()
61 pri2cos[i] = bp->q_info[qidx].queue_id; in bnxt_hwrm_queue_pri2cos_cfg()
63 return hwrm_req_send(bp, req); in bnxt_hwrm_queue_pri2cos_cfg()
66 static int bnxt_hwrm_queue_pri2cos_qcfg(struct bnxt *bp, struct ieee_ets *ets) in bnxt_hwrm_queue_pri2cos_qcfg() argument
72 rc = hwrm_req_init(bp, req, HWRM_QUEUE_PRI2COS_QCFG); in bnxt_hwrm_queue_pri2cos_qcfg()
77 resp = hwrm_req_hold(bp, req); in bnxt_hwrm_queue_pri2cos_qcfg()
78 rc = hwrm_req_send(bp, req); in bnxt_hwrm_queue_pri2cos_qcfg()
87 tc = bnxt_queue_to_tc(bp, queue_id); in bnxt_hwrm_queue_pri2cos_qcfg()
92 hwrm_req_drop(bp, req); in bnxt_hwrm_queue_pri2cos_qcfg()
96 static int bnxt_hwrm_queue_cos2bw_cfg(struct bnxt *bp, struct ieee_ets *ets, in bnxt_hwrm_queue_cos2bw_cfg() argument
103 rc = hwrm_req_init(bp, req, HWRM_QUEUE_COS2BW_CFG); in bnxt_hwrm_queue_cos2bw_cfg()
108 u8 qidx = bp->tc_to_qidx[i]; in bnxt_hwrm_queue_cos2bw_cfg()
115 cos2bw.queue_id = bp->q_info[qidx].queue_id; in bnxt_hwrm_queue_cos2bw_cfg()
142 return hwrm_req_send(bp, req); in bnxt_hwrm_queue_cos2bw_cfg()
145 static int bnxt_hwrm_queue_cos2bw_qcfg(struct bnxt *bp, struct ieee_ets *ets) in bnxt_hwrm_queue_cos2bw_qcfg() argument
152 rc = hwrm_req_init(bp, req, HWRM_QUEUE_COS2BW_QCFG); in bnxt_hwrm_queue_cos2bw_qcfg()
156 resp = hwrm_req_hold(bp, req); in bnxt_hwrm_queue_cos2bw_qcfg()
157 rc = hwrm_req_send(bp, req); in bnxt_hwrm_queue_cos2bw_qcfg()
159 hwrm_req_drop(bp, req); in bnxt_hwrm_queue_cos2bw_qcfg()
163 for (i = 0; i < bp->max_tc; i++) { in bnxt_hwrm_queue_cos2bw_qcfg()
177 tc = bnxt_queue_to_tc(bp, cos2bw.queue_id); in bnxt_hwrm_queue_cos2bw_qcfg()
189 hwrm_req_drop(bp, req); in bnxt_hwrm_queue_cos2bw_qcfg()
193 static int bnxt_queue_remap(struct bnxt *bp, unsigned int lltc_mask) in bnxt_queue_remap() argument
196 int max = bp->max_tc; in bnxt_queue_remap()
202 if (BNXT_LLQ(bp->q_info[j].queue_profile)) { in bnxt_queue_remap()
203 bp->tc_to_qidx[i] = j; in bnxt_queue_remap()
217 bp->tc_to_qidx[i] = j; in bnxt_queue_remap()
222 if (netif_running(bp->dev)) { in bnxt_queue_remap()
223 bnxt_close_nic(bp, false, false); in bnxt_queue_remap()
224 rc = bnxt_open_nic(bp, false, false); in bnxt_queue_remap()
226 netdev_warn(bp->dev, "failed to open NIC, rc = %d\n", rc); in bnxt_queue_remap()
230 if (bp->ieee_ets) { in bnxt_queue_remap()
231 int tc = bp->num_tc; in bnxt_queue_remap()
235 rc = bnxt_hwrm_queue_cos2bw_cfg(bp, bp->ieee_ets, tc); in bnxt_queue_remap()
237 netdev_warn(bp->dev, "failed to config BW, rc = %d\n", rc); in bnxt_queue_remap()
240 rc = bnxt_hwrm_queue_pri2cos_cfg(bp, bp->ieee_ets); in bnxt_queue_remap()
242 netdev_warn(bp->dev, "failed to config prio, rc = %d\n", rc); in bnxt_queue_remap()
249 static int bnxt_hwrm_queue_pfc_cfg(struct bnxt *bp, struct ieee_pfc *pfc) in bnxt_hwrm_queue_pfc_cfg() argument
252 struct ieee_ets *my_ets = bp->ieee_ets; in bnxt_hwrm_queue_pfc_cfg()
261 for (i = 0; i < bp->max_tc; i++) { in bnxt_hwrm_queue_pfc_cfg()
272 if (lltc_count > bp->max_lltc) in bnxt_hwrm_queue_pfc_cfg()
275 for (i = 0; i < bp->max_tc; i++) { in bnxt_hwrm_queue_pfc_cfg()
277 u8 qidx = bp->tc_to_qidx[i]; in bnxt_hwrm_queue_pfc_cfg()
279 if (!BNXT_LLQ(bp->q_info[qidx].queue_profile)) { in bnxt_hwrm_queue_pfc_cfg()
287 bnxt_queue_remap(bp, tc_mask); in bnxt_hwrm_queue_pfc_cfg()
289 rc = hwrm_req_init(bp, req, HWRM_QUEUE_PFCENABLE_CFG); in bnxt_hwrm_queue_pfc_cfg()
294 return hwrm_req_send(bp, req); in bnxt_hwrm_queue_pfc_cfg()
297 static int bnxt_hwrm_queue_pfc_qcfg(struct bnxt *bp, struct ieee_pfc *pfc) in bnxt_hwrm_queue_pfc_qcfg() argument
304 rc = hwrm_req_init(bp, req, HWRM_QUEUE_PFCENABLE_QCFG); in bnxt_hwrm_queue_pfc_qcfg()
308 resp = hwrm_req_hold(bp, req); in bnxt_hwrm_queue_pfc_qcfg()
309 rc = hwrm_req_send(bp, req); in bnxt_hwrm_queue_pfc_qcfg()
311 hwrm_req_drop(bp, req); in bnxt_hwrm_queue_pfc_qcfg()
317 hwrm_req_drop(bp, req); in bnxt_hwrm_queue_pfc_qcfg()
321 static int bnxt_hwrm_set_dcbx_app(struct bnxt *bp, struct dcb_app *app, in bnxt_hwrm_set_dcbx_app() argument
332 if (bp->hwrm_spec_code < 0x10601) in bnxt_hwrm_set_dcbx_app()
335 rc = hwrm_req_init(bp, get, HWRM_FW_GET_STRUCTURED_DATA); in bnxt_hwrm_set_dcbx_app()
339 hwrm_req_hold(bp, get); in bnxt_hwrm_set_dcbx_app()
340 hwrm_req_alloc_flags(bp, get, GFP_KERNEL | __GFP_ZERO); in bnxt_hwrm_set_dcbx_app()
344 data = hwrm_req_dma_slice(bp, get, data_len, &mapping); in bnxt_hwrm_set_dcbx_app()
354 rc = hwrm_req_send(bp, get); in bnxt_hwrm_set_dcbx_app()
400 rc = hwrm_req_init(bp, set, HWRM_FW_SET_STRUCTURED_DATA); in bnxt_hwrm_set_dcbx_app()
407 rc = hwrm_req_send(bp, set); in bnxt_hwrm_set_dcbx_app()
410 hwrm_req_drop(bp, get); /* dropping get request and associated slice */ in bnxt_hwrm_set_dcbx_app()
414 static int bnxt_hwrm_queue_dscp_qcaps(struct bnxt *bp) in bnxt_hwrm_queue_dscp_qcaps() argument
420 bp->max_dscp_value = 0; in bnxt_hwrm_queue_dscp_qcaps()
421 if (bp->hwrm_spec_code < 0x10800 || BNXT_VF(bp)) in bnxt_hwrm_queue_dscp_qcaps()
424 rc = hwrm_req_init(bp, req, HWRM_QUEUE_DSCP_QCAPS); in bnxt_hwrm_queue_dscp_qcaps()
428 resp = hwrm_req_hold(bp, req); in bnxt_hwrm_queue_dscp_qcaps()
429 rc = hwrm_req_send_silent(bp, req); in bnxt_hwrm_queue_dscp_qcaps()
431 bp->max_dscp_value = (1 << resp->num_dscp_bits) - 1; in bnxt_hwrm_queue_dscp_qcaps()
432 if (bp->max_dscp_value < 0x3f) in bnxt_hwrm_queue_dscp_qcaps()
433 bp->max_dscp_value = 0; in bnxt_hwrm_queue_dscp_qcaps()
435 hwrm_req_drop(bp, req); in bnxt_hwrm_queue_dscp_qcaps()
439 static int bnxt_hwrm_queue_dscp2pri_cfg(struct bnxt *bp, struct dcb_app *app, in bnxt_hwrm_queue_dscp2pri_cfg() argument
447 if (bp->hwrm_spec_code < 0x10800) in bnxt_hwrm_queue_dscp2pri_cfg()
450 rc = hwrm_req_init(bp, req, HWRM_QUEUE_DSCP2PRI_CFG); in bnxt_hwrm_queue_dscp2pri_cfg()
454 dscp2pri = hwrm_req_dma_slice(bp, req, sizeof(*dscp2pri), &mapping); in bnxt_hwrm_queue_dscp2pri_cfg()
456 hwrm_req_drop(bp, req); in bnxt_hwrm_queue_dscp2pri_cfg()
468 rc = hwrm_req_send(bp, req); in bnxt_hwrm_queue_dscp2pri_cfg()
472 static int bnxt_ets_validate(struct bnxt *bp, struct ieee_ets *ets, u8 *tc) in bnxt_ets_validate() argument
480 if (ets->prio_tc[i] > bp->max_tc) { in bnxt_ets_validate()
481 netdev_err(bp->dev, "priority to TC mapping exceeds TC count %d\n", in bnxt_ets_validate()
488 if ((ets->tc_tx_bw[i] || ets->tc_tsa[i]) && i > bp->max_tc) in bnxt_ets_validate()
503 netdev_warn(bp->dev, "rejecting ETS config exceeding available bandwidth\n"); in bnxt_ets_validate()
507 netdev_warn(bp->dev, "rejecting ETS config starving a TC\n"); in bnxt_ets_validate()
511 if (max_tc >= bp->max_tc) in bnxt_ets_validate()
512 *tc = bp->max_tc; in bnxt_ets_validate()
520 struct bnxt *bp = netdev_priv(dev); in bnxt_dcbnl_ieee_getets() local
521 struct ieee_ets *my_ets = bp->ieee_ets; in bnxt_dcbnl_ieee_getets()
524 ets->ets_cap = bp->max_tc; in bnxt_dcbnl_ieee_getets()
527 if (bp->dcbx_cap & DCB_CAP_DCBX_HOST) in bnxt_dcbnl_ieee_getets()
533 rc = bnxt_hwrm_queue_cos2bw_qcfg(bp, my_ets); in bnxt_dcbnl_ieee_getets()
536 rc = bnxt_hwrm_queue_pri2cos_qcfg(bp, my_ets); in bnxt_dcbnl_ieee_getets()
541 bp->ieee_ets = my_ets; in bnxt_dcbnl_ieee_getets()
557 struct bnxt *bp = netdev_priv(dev); in bnxt_dcbnl_ieee_setets() local
558 struct ieee_ets *my_ets = bp->ieee_ets; in bnxt_dcbnl_ieee_setets()
562 if (!(bp->dcbx_cap & DCB_CAP_DCBX_VER_IEEE) || in bnxt_dcbnl_ieee_setets()
563 !(bp->dcbx_cap & DCB_CAP_DCBX_HOST)) in bnxt_dcbnl_ieee_setets()
566 rc = bnxt_ets_validate(bp, ets, &max_tc); in bnxt_dcbnl_ieee_setets()
575 bp->ieee_ets = my_ets; in bnxt_dcbnl_ieee_setets()
580 rc = bnxt_hwrm_queue_cos2bw_cfg(bp, ets, max_tc); in bnxt_dcbnl_ieee_setets()
583 rc = bnxt_hwrm_queue_pri2cos_cfg(bp, ets); in bnxt_dcbnl_ieee_setets()
593 struct bnxt *bp = netdev_priv(dev); in bnxt_dcbnl_ieee_getpfc() local
594 __le64 *stats = bp->port_stats.hw_stats; in bnxt_dcbnl_ieee_getpfc()
595 struct ieee_pfc *my_pfc = bp->ieee_pfc; in bnxt_dcbnl_ieee_getpfc()
599 pfc->pfc_cap = bp->max_lltc; in bnxt_dcbnl_ieee_getpfc()
602 if (bp->dcbx_cap & DCB_CAP_DCBX_HOST) in bnxt_dcbnl_ieee_getpfc()
608 bp->ieee_pfc = my_pfc; in bnxt_dcbnl_ieee_getpfc()
609 rc = bnxt_hwrm_queue_pfc_qcfg(bp, my_pfc); in bnxt_dcbnl_ieee_getpfc()
633 struct bnxt *bp = netdev_priv(dev); in bnxt_dcbnl_ieee_setpfc() local
634 struct ieee_pfc *my_pfc = bp->ieee_pfc; in bnxt_dcbnl_ieee_setpfc()
637 if (!(bp->dcbx_cap & DCB_CAP_DCBX_VER_IEEE) || in bnxt_dcbnl_ieee_setpfc()
638 !(bp->dcbx_cap & DCB_CAP_DCBX_HOST) || in bnxt_dcbnl_ieee_setpfc()
639 (bp->phy_flags & BNXT_PHY_FL_NO_PAUSE)) in bnxt_dcbnl_ieee_setpfc()
646 bp->ieee_pfc = my_pfc; in bnxt_dcbnl_ieee_setpfc()
648 rc = bnxt_hwrm_queue_pfc_cfg(bp, pfc); in bnxt_dcbnl_ieee_setpfc()
655 static int bnxt_dcbnl_ieee_dscp_app_prep(struct bnxt *bp, struct dcb_app *app) in bnxt_dcbnl_ieee_dscp_app_prep() argument
658 if (!bp->max_dscp_value) in bnxt_dcbnl_ieee_dscp_app_prep()
660 if (app->protocol > bp->max_dscp_value) in bnxt_dcbnl_ieee_dscp_app_prep()
668 struct bnxt *bp = netdev_priv(dev); in bnxt_dcbnl_ieee_setapp() local
671 if (!(bp->dcbx_cap & DCB_CAP_DCBX_VER_IEEE) || in bnxt_dcbnl_ieee_setapp()
672 !(bp->dcbx_cap & DCB_CAP_DCBX_HOST)) in bnxt_dcbnl_ieee_setapp()
675 rc = bnxt_dcbnl_ieee_dscp_app_prep(bp, app); in bnxt_dcbnl_ieee_setapp()
687 rc = bnxt_hwrm_set_dcbx_app(bp, app, true); in bnxt_dcbnl_ieee_setapp()
690 rc = bnxt_hwrm_queue_dscp2pri_cfg(bp, app, true); in bnxt_dcbnl_ieee_setapp()
697 struct bnxt *bp = netdev_priv(dev); in bnxt_dcbnl_ieee_delapp() local
700 if (!(bp->dcbx_cap & DCB_CAP_DCBX_VER_IEEE) || in bnxt_dcbnl_ieee_delapp()
701 !(bp->dcbx_cap & DCB_CAP_DCBX_HOST)) in bnxt_dcbnl_ieee_delapp()
704 rc = bnxt_dcbnl_ieee_dscp_app_prep(bp, app); in bnxt_dcbnl_ieee_delapp()
715 rc = bnxt_hwrm_set_dcbx_app(bp, app, false); in bnxt_dcbnl_ieee_delapp()
718 rc = bnxt_hwrm_queue_dscp2pri_cfg(bp, app, false); in bnxt_dcbnl_ieee_delapp()
725 struct bnxt *bp = netdev_priv(dev); in bnxt_dcbnl_getdcbx() local
727 return bp->dcbx_cap; in bnxt_dcbnl_getdcbx()
732 struct bnxt *bp = netdev_priv(dev); in bnxt_dcbnl_setdcbx() local
735 if (bp->dcbx_cap & DCB_CAP_DCBX_LLD_MANAGED) in bnxt_dcbnl_setdcbx()
739 if (BNXT_VF(bp) || (bp->fw_cap & BNXT_FW_CAP_LLDP_AGENT)) in bnxt_dcbnl_setdcbx()
748 if (mode == bp->dcbx_cap) in bnxt_dcbnl_setdcbx()
751 bp->dcbx_cap = mode; in bnxt_dcbnl_setdcbx()
766 void bnxt_dcb_init(struct bnxt *bp) in bnxt_dcb_init() argument
768 bp->dcbx_cap = 0; in bnxt_dcb_init()
769 if (bp->hwrm_spec_code < 0x10501) in bnxt_dcb_init()
772 bnxt_hwrm_queue_dscp_qcaps(bp); in bnxt_dcb_init()
773 bp->dcbx_cap = DCB_CAP_DCBX_VER_IEEE; in bnxt_dcb_init()
774 if (BNXT_PF(bp) && !(bp->fw_cap & BNXT_FW_CAP_LLDP_AGENT)) in bnxt_dcb_init()
775 bp->dcbx_cap |= DCB_CAP_DCBX_HOST; in bnxt_dcb_init()
776 else if (bp->fw_cap & BNXT_FW_CAP_DCBX_AGENT) in bnxt_dcb_init()
777 bp->dcbx_cap |= DCB_CAP_DCBX_LLD_MANAGED; in bnxt_dcb_init()
778 bp->dev->dcbnl_ops = &dcbnl_ops; in bnxt_dcb_init()
781 void bnxt_dcb_free(struct bnxt *bp) in bnxt_dcb_free() argument
783 kfree(bp->ieee_pfc); in bnxt_dcb_free()
784 kfree(bp->ieee_ets); in bnxt_dcb_free()
785 bp->ieee_pfc = NULL; in bnxt_dcb_free()
786 bp->ieee_ets = NULL; in bnxt_dcb_free()
791 void bnxt_dcb_init(struct bnxt *bp) in bnxt_dcb_init() argument
795 void bnxt_dcb_free(struct bnxt *bp) in bnxt_dcb_free() argument