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
104 rc = hwrm_req_init(bp, req, HWRM_QUEUE_COS2BW_CFG); in bnxt_hwrm_queue_cos2bw_cfg()
109 u8 qidx = bp->tc_to_qidx[i]; in bnxt_hwrm_queue_cos2bw_cfg()
116 cos2bw.queue_id = bp->q_info[qidx].queue_id; in bnxt_hwrm_queue_cos2bw_cfg()
139 return hwrm_req_send(bp, req); in bnxt_hwrm_queue_cos2bw_cfg()
142 static int bnxt_hwrm_queue_cos2bw_qcfg(struct bnxt *bp, struct ieee_ets *ets) in bnxt_hwrm_queue_cos2bw_qcfg() argument
150 rc = hwrm_req_init(bp, req, HWRM_QUEUE_COS2BW_QCFG); in bnxt_hwrm_queue_cos2bw_qcfg()
154 resp = hwrm_req_hold(bp, req); in bnxt_hwrm_queue_cos2bw_qcfg()
155 rc = hwrm_req_send(bp, req); in bnxt_hwrm_queue_cos2bw_qcfg()
157 hwrm_req_drop(bp, req); in bnxt_hwrm_queue_cos2bw_qcfg()
162 for (i = 0; i < bp->max_tc; i++, data += sizeof(cos2bw) - 4) { in bnxt_hwrm_queue_cos2bw_qcfg()
169 tc = bnxt_queue_to_tc(bp, cos2bw.queue_id); in bnxt_hwrm_queue_cos2bw_qcfg()
181 hwrm_req_drop(bp, req); in bnxt_hwrm_queue_cos2bw_qcfg()
185 static int bnxt_queue_remap(struct bnxt *bp, unsigned int lltc_mask) in bnxt_queue_remap() argument
188 int max = bp->max_tc; in bnxt_queue_remap()
194 if (BNXT_LLQ(bp->q_info[j].queue_profile)) { in bnxt_queue_remap()
195 bp->tc_to_qidx[i] = j; in bnxt_queue_remap()
209 bp->tc_to_qidx[i] = j; in bnxt_queue_remap()
214 if (netif_running(bp->dev)) { in bnxt_queue_remap()
215 bnxt_close_nic(bp, false, false); in bnxt_queue_remap()
216 rc = bnxt_open_nic(bp, false, false); in bnxt_queue_remap()
218 netdev_warn(bp->dev, "failed to open NIC, rc = %d\n", rc); in bnxt_queue_remap()
222 if (bp->ieee_ets) { in bnxt_queue_remap()
223 int tc = netdev_get_num_tc(bp->dev); in bnxt_queue_remap()
227 rc = bnxt_hwrm_queue_cos2bw_cfg(bp, bp->ieee_ets, tc); in bnxt_queue_remap()
229 netdev_warn(bp->dev, "failed to config BW, rc = %d\n", rc); in bnxt_queue_remap()
232 rc = bnxt_hwrm_queue_pri2cos_cfg(bp, bp->ieee_ets); in bnxt_queue_remap()
234 netdev_warn(bp->dev, "failed to config prio, rc = %d\n", rc); in bnxt_queue_remap()
241 static int bnxt_hwrm_queue_pfc_cfg(struct bnxt *bp, struct ieee_pfc *pfc) in bnxt_hwrm_queue_pfc_cfg() argument
244 struct ieee_ets *my_ets = bp->ieee_ets; in bnxt_hwrm_queue_pfc_cfg()
253 for (i = 0; i < bp->max_tc; i++) { in bnxt_hwrm_queue_pfc_cfg()
264 if (lltc_count > bp->max_lltc) in bnxt_hwrm_queue_pfc_cfg()
267 for (i = 0; i < bp->max_tc; i++) { in bnxt_hwrm_queue_pfc_cfg()
269 u8 qidx = bp->tc_to_qidx[i]; in bnxt_hwrm_queue_pfc_cfg()
271 if (!BNXT_LLQ(bp->q_info[qidx].queue_profile)) { in bnxt_hwrm_queue_pfc_cfg()
279 bnxt_queue_remap(bp, tc_mask); in bnxt_hwrm_queue_pfc_cfg()
281 rc = hwrm_req_init(bp, req, HWRM_QUEUE_PFCENABLE_CFG); in bnxt_hwrm_queue_pfc_cfg()
286 return hwrm_req_send(bp, req); in bnxt_hwrm_queue_pfc_cfg()
289 static int bnxt_hwrm_queue_pfc_qcfg(struct bnxt *bp, struct ieee_pfc *pfc) in bnxt_hwrm_queue_pfc_qcfg() argument
296 rc = hwrm_req_init(bp, req, HWRM_QUEUE_PFCENABLE_QCFG); in bnxt_hwrm_queue_pfc_qcfg()
300 resp = hwrm_req_hold(bp, req); in bnxt_hwrm_queue_pfc_qcfg()
301 rc = hwrm_req_send(bp, req); in bnxt_hwrm_queue_pfc_qcfg()
303 hwrm_req_drop(bp, req); in bnxt_hwrm_queue_pfc_qcfg()
309 hwrm_req_drop(bp, req); in bnxt_hwrm_queue_pfc_qcfg()
313 static int bnxt_hwrm_set_dcbx_app(struct bnxt *bp, struct dcb_app *app, in bnxt_hwrm_set_dcbx_app() argument
324 if (bp->hwrm_spec_code < 0x10601) in bnxt_hwrm_set_dcbx_app()
327 rc = hwrm_req_init(bp, get, HWRM_FW_GET_STRUCTURED_DATA); in bnxt_hwrm_set_dcbx_app()
331 hwrm_req_hold(bp, get); in bnxt_hwrm_set_dcbx_app()
332 hwrm_req_alloc_flags(bp, get, GFP_KERNEL | __GFP_ZERO); in bnxt_hwrm_set_dcbx_app()
336 data = hwrm_req_dma_slice(bp, get, data_len, &mapping); in bnxt_hwrm_set_dcbx_app()
346 rc = hwrm_req_send(bp, get); in bnxt_hwrm_set_dcbx_app()
392 rc = hwrm_req_init(bp, set, HWRM_FW_SET_STRUCTURED_DATA); in bnxt_hwrm_set_dcbx_app()
399 rc = hwrm_req_send(bp, set); in bnxt_hwrm_set_dcbx_app()
402 hwrm_req_drop(bp, get); /* dropping get request and associated slice */ in bnxt_hwrm_set_dcbx_app()
406 static int bnxt_hwrm_queue_dscp_qcaps(struct bnxt *bp) in bnxt_hwrm_queue_dscp_qcaps() argument
412 bp->max_dscp_value = 0; in bnxt_hwrm_queue_dscp_qcaps()
413 if (bp->hwrm_spec_code < 0x10800 || BNXT_VF(bp)) in bnxt_hwrm_queue_dscp_qcaps()
416 rc = hwrm_req_init(bp, req, HWRM_QUEUE_DSCP_QCAPS); in bnxt_hwrm_queue_dscp_qcaps()
420 resp = hwrm_req_hold(bp, req); in bnxt_hwrm_queue_dscp_qcaps()
421 rc = hwrm_req_send_silent(bp, req); in bnxt_hwrm_queue_dscp_qcaps()
423 bp->max_dscp_value = (1 << resp->num_dscp_bits) - 1; in bnxt_hwrm_queue_dscp_qcaps()
424 if (bp->max_dscp_value < 0x3f) in bnxt_hwrm_queue_dscp_qcaps()
425 bp->max_dscp_value = 0; in bnxt_hwrm_queue_dscp_qcaps()
427 hwrm_req_drop(bp, req); in bnxt_hwrm_queue_dscp_qcaps()
431 static int bnxt_hwrm_queue_dscp2pri_cfg(struct bnxt *bp, struct dcb_app *app, in bnxt_hwrm_queue_dscp2pri_cfg() argument
439 if (bp->hwrm_spec_code < 0x10800) in bnxt_hwrm_queue_dscp2pri_cfg()
442 rc = hwrm_req_init(bp, req, HWRM_QUEUE_DSCP2PRI_CFG); in bnxt_hwrm_queue_dscp2pri_cfg()
446 dscp2pri = hwrm_req_dma_slice(bp, req, sizeof(*dscp2pri), &mapping); in bnxt_hwrm_queue_dscp2pri_cfg()
448 hwrm_req_drop(bp, req); in bnxt_hwrm_queue_dscp2pri_cfg()
460 rc = hwrm_req_send(bp, req); in bnxt_hwrm_queue_dscp2pri_cfg()
464 static int bnxt_ets_validate(struct bnxt *bp, struct ieee_ets *ets, u8 *tc) in bnxt_ets_validate() argument
472 if (ets->prio_tc[i] > bp->max_tc) { in bnxt_ets_validate()
473 netdev_err(bp->dev, "priority to TC mapping exceeds TC count %d\n", in bnxt_ets_validate()
480 if ((ets->tc_tx_bw[i] || ets->tc_tsa[i]) && i > bp->max_tc) in bnxt_ets_validate()
495 netdev_warn(bp->dev, "rejecting ETS config exceeding available bandwidth\n"); in bnxt_ets_validate()
499 netdev_warn(bp->dev, "rejecting ETS config starving a TC\n"); in bnxt_ets_validate()
503 if (max_tc >= bp->max_tc) in bnxt_ets_validate()
504 *tc = bp->max_tc; in bnxt_ets_validate()
512 struct bnxt *bp = netdev_priv(dev); in bnxt_dcbnl_ieee_getets() local
513 struct ieee_ets *my_ets = bp->ieee_ets; in bnxt_dcbnl_ieee_getets()
516 ets->ets_cap = bp->max_tc; in bnxt_dcbnl_ieee_getets()
519 if (bp->dcbx_cap & DCB_CAP_DCBX_HOST) in bnxt_dcbnl_ieee_getets()
525 rc = bnxt_hwrm_queue_cos2bw_qcfg(bp, my_ets); in bnxt_dcbnl_ieee_getets()
528 rc = bnxt_hwrm_queue_pri2cos_qcfg(bp, my_ets); in bnxt_dcbnl_ieee_getets()
533 bp->ieee_ets = my_ets; in bnxt_dcbnl_ieee_getets()
549 struct bnxt *bp = netdev_priv(dev); in bnxt_dcbnl_ieee_setets() local
550 struct ieee_ets *my_ets = bp->ieee_ets; in bnxt_dcbnl_ieee_setets()
554 if (!(bp->dcbx_cap & DCB_CAP_DCBX_VER_IEEE) || in bnxt_dcbnl_ieee_setets()
555 !(bp->dcbx_cap & DCB_CAP_DCBX_HOST)) in bnxt_dcbnl_ieee_setets()
558 rc = bnxt_ets_validate(bp, ets, &max_tc); in bnxt_dcbnl_ieee_setets()
567 bp->ieee_ets = my_ets; in bnxt_dcbnl_ieee_setets()
572 rc = bnxt_hwrm_queue_cos2bw_cfg(bp, ets, max_tc); in bnxt_dcbnl_ieee_setets()
575 rc = bnxt_hwrm_queue_pri2cos_cfg(bp, ets); in bnxt_dcbnl_ieee_setets()
585 struct bnxt *bp = netdev_priv(dev); in bnxt_dcbnl_ieee_getpfc() local
586 __le64 *stats = bp->port_stats.hw_stats; in bnxt_dcbnl_ieee_getpfc()
587 struct ieee_pfc *my_pfc = bp->ieee_pfc; in bnxt_dcbnl_ieee_getpfc()
591 pfc->pfc_cap = bp->max_lltc; in bnxt_dcbnl_ieee_getpfc()
594 if (bp->dcbx_cap & DCB_CAP_DCBX_HOST) in bnxt_dcbnl_ieee_getpfc()
600 bp->ieee_pfc = my_pfc; in bnxt_dcbnl_ieee_getpfc()
601 rc = bnxt_hwrm_queue_pfc_qcfg(bp, my_pfc); in bnxt_dcbnl_ieee_getpfc()
625 struct bnxt *bp = netdev_priv(dev); in bnxt_dcbnl_ieee_setpfc() local
626 struct ieee_pfc *my_pfc = bp->ieee_pfc; in bnxt_dcbnl_ieee_setpfc()
629 if (!(bp->dcbx_cap & DCB_CAP_DCBX_VER_IEEE) || in bnxt_dcbnl_ieee_setpfc()
630 !(bp->dcbx_cap & DCB_CAP_DCBX_HOST)) in bnxt_dcbnl_ieee_setpfc()
637 bp->ieee_pfc = my_pfc; in bnxt_dcbnl_ieee_setpfc()
639 rc = bnxt_hwrm_queue_pfc_cfg(bp, pfc); in bnxt_dcbnl_ieee_setpfc()
646 static int bnxt_dcbnl_ieee_dscp_app_prep(struct bnxt *bp, struct dcb_app *app) in bnxt_dcbnl_ieee_dscp_app_prep() argument
649 if (!bp->max_dscp_value) in bnxt_dcbnl_ieee_dscp_app_prep()
651 if (app->protocol > bp->max_dscp_value) in bnxt_dcbnl_ieee_dscp_app_prep()
659 struct bnxt *bp = netdev_priv(dev); in bnxt_dcbnl_ieee_setapp() local
662 if (!(bp->dcbx_cap & DCB_CAP_DCBX_VER_IEEE) || in bnxt_dcbnl_ieee_setapp()
663 !(bp->dcbx_cap & DCB_CAP_DCBX_HOST)) in bnxt_dcbnl_ieee_setapp()
666 rc = bnxt_dcbnl_ieee_dscp_app_prep(bp, app); in bnxt_dcbnl_ieee_setapp()
678 rc = bnxt_hwrm_set_dcbx_app(bp, app, true); in bnxt_dcbnl_ieee_setapp()
681 rc = bnxt_hwrm_queue_dscp2pri_cfg(bp, app, true); in bnxt_dcbnl_ieee_setapp()
688 struct bnxt *bp = netdev_priv(dev); in bnxt_dcbnl_ieee_delapp() local
691 if (!(bp->dcbx_cap & DCB_CAP_DCBX_VER_IEEE) || in bnxt_dcbnl_ieee_delapp()
692 !(bp->dcbx_cap & DCB_CAP_DCBX_HOST)) in bnxt_dcbnl_ieee_delapp()
695 rc = bnxt_dcbnl_ieee_dscp_app_prep(bp, app); in bnxt_dcbnl_ieee_delapp()
706 rc = bnxt_hwrm_set_dcbx_app(bp, app, false); in bnxt_dcbnl_ieee_delapp()
709 rc = bnxt_hwrm_queue_dscp2pri_cfg(bp, app, false); in bnxt_dcbnl_ieee_delapp()
716 struct bnxt *bp = netdev_priv(dev); in bnxt_dcbnl_getdcbx() local
718 return bp->dcbx_cap; in bnxt_dcbnl_getdcbx()
723 struct bnxt *bp = netdev_priv(dev); in bnxt_dcbnl_setdcbx() local
726 if (bp->dcbx_cap & DCB_CAP_DCBX_LLD_MANAGED) in bnxt_dcbnl_setdcbx()
730 if (BNXT_VF(bp) || (bp->fw_cap & BNXT_FW_CAP_LLDP_AGENT)) in bnxt_dcbnl_setdcbx()
739 if (mode == bp->dcbx_cap) in bnxt_dcbnl_setdcbx()
742 bp->dcbx_cap = mode; in bnxt_dcbnl_setdcbx()
757 void bnxt_dcb_init(struct bnxt *bp) in bnxt_dcb_init() argument
759 bp->dcbx_cap = 0; in bnxt_dcb_init()
760 if (bp->hwrm_spec_code < 0x10501) in bnxt_dcb_init()
763 bnxt_hwrm_queue_dscp_qcaps(bp); in bnxt_dcb_init()
764 bp->dcbx_cap = DCB_CAP_DCBX_VER_IEEE; in bnxt_dcb_init()
765 if (BNXT_PF(bp) && !(bp->fw_cap & BNXT_FW_CAP_LLDP_AGENT)) in bnxt_dcb_init()
766 bp->dcbx_cap |= DCB_CAP_DCBX_HOST; in bnxt_dcb_init()
767 else if (bp->fw_cap & BNXT_FW_CAP_DCBX_AGENT) in bnxt_dcb_init()
768 bp->dcbx_cap |= DCB_CAP_DCBX_LLD_MANAGED; in bnxt_dcb_init()
769 bp->dev->dcbnl_ops = &dcbnl_ops; in bnxt_dcb_init()
772 void bnxt_dcb_free(struct bnxt *bp) in bnxt_dcb_free() argument
774 kfree(bp->ieee_pfc); in bnxt_dcb_free()
775 kfree(bp->ieee_ets); in bnxt_dcb_free()
776 bp->ieee_pfc = NULL; in bnxt_dcb_free()
777 bp->ieee_ets = NULL; in bnxt_dcb_free()
782 void bnxt_dcb_init(struct bnxt *bp) in bnxt_dcb_init() argument
786 void bnxt_dcb_free(struct bnxt *bp) in bnxt_dcb_free() argument