Lines Matching refs:softc

39 bnxt_tx_queue_to_tc(struct bnxt_softc *softc, uint8_t queue_id)  in bnxt_tx_queue_to_tc()  argument
43 for (i = 0; i < softc->max_tc; i++) { in bnxt_tx_queue_to_tc()
44 if (softc->tx_q_info[i].queue_id == queue_id) { in bnxt_tx_queue_to_tc()
45 for (j = 0; j < softc->max_tc; j++) { in bnxt_tx_queue_to_tc()
46 if (softc->tc_to_qidx[j] == i) in bnxt_tx_queue_to_tc()
55 bnxt_hwrm_queue_pri2cos_cfg(struct bnxt_softc *softc, in bnxt_hwrm_queue_pri2cos_cfg() argument
64 bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_QUEUE_PRI2COS_CFG); in bnxt_hwrm_queue_pri2cos_cfg()
69 q_info = softc->tx_q_info; in bnxt_hwrm_queue_pri2cos_cfg()
71 q_info = softc->rx_q_info; in bnxt_hwrm_queue_pri2cos_cfg()
78 qidx = softc->tc_to_qidx[ets->prio_tc[i]]; in bnxt_hwrm_queue_pri2cos_cfg()
81 return _hwrm_send_message(softc, &req, sizeof(req)); in bnxt_hwrm_queue_pri2cos_cfg()
85 bnxt_hwrm_queue_pri2cos_qcfg(struct bnxt_softc *softc, struct bnxt_ieee_ets *ets) in bnxt_hwrm_queue_pri2cos_qcfg() argument
88 (void *)softc->hwrm_cmd_resp.idi_vaddr; in bnxt_hwrm_queue_pri2cos_qcfg()
92 bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_QUEUE_PRI2COS_QCFG); in bnxt_hwrm_queue_pri2cos_qcfg()
95 rc = _hwrm_send_message(softc, &req, sizeof(req)); in bnxt_hwrm_queue_pri2cos_qcfg()
104 tc = bnxt_tx_queue_to_tc(softc, queue_id); in bnxt_hwrm_queue_pri2cos_qcfg()
113 bnxt_hwrm_queue_cos2bw_cfg(struct bnxt_softc *softc, struct bnxt_ieee_ets *ets, in bnxt_hwrm_queue_cos2bw_cfg() argument
121 bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_QUEUE_COS2BW_CFG); in bnxt_hwrm_queue_cos2bw_cfg()
124 uint8_t qidx = softc->tc_to_qidx[i]; in bnxt_hwrm_queue_cos2bw_cfg()
130 cos2bw.queue_id = softc->tx_q_info[qidx].queue_id; in bnxt_hwrm_queue_cos2bw_cfg()
142 if (BNXT_FW_MAJ(softc) < 218) { in bnxt_hwrm_queue_cos2bw_cfg()
155 return _hwrm_send_message(softc, &req, sizeof(req)); in bnxt_hwrm_queue_cos2bw_cfg()
159 bnxt_hwrm_queue_cos2bw_qcfg(struct bnxt_softc *softc, struct bnxt_ieee_ets *ets) in bnxt_hwrm_queue_cos2bw_qcfg() argument
162 (void *)softc->hwrm_cmd_resp.idi_vaddr; in bnxt_hwrm_queue_cos2bw_qcfg()
168 bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_QUEUE_COS2BW_QCFG); in bnxt_hwrm_queue_cos2bw_qcfg()
170 rc = _hwrm_send_message(softc, &req, sizeof(req)); in bnxt_hwrm_queue_cos2bw_qcfg()
176 for (i = 0; i < softc->max_tc; i++, data += sizeof(cos2bw.cfg)) { in bnxt_hwrm_queue_cos2bw_qcfg()
183 tc = bnxt_tx_queue_to_tc(softc, cos2bw.queue_id); in bnxt_hwrm_queue_cos2bw_qcfg()
198 bnxt_queue_remap(struct bnxt_softc *softc, unsigned int lltc_mask) in bnxt_queue_remap() argument
201 int max = softc->max_tc; in bnxt_queue_remap()
207 if (BNXT_LLQ(softc->rx_q_info[j].queue_profile)) { in bnxt_queue_remap()
208 softc->tc_to_qidx[i] = j; in bnxt_queue_remap()
222 softc->tc_to_qidx[i] = j; in bnxt_queue_remap()
227 if (softc->ieee_ets) { in bnxt_queue_remap()
228 rc = bnxt_hwrm_queue_cos2bw_cfg(softc, softc->ieee_ets, softc->max_tc); in bnxt_queue_remap()
230 device_printf(softc->dev, "failed to config BW, rc = %d\n", rc); in bnxt_queue_remap()
233 rc = bnxt_hwrm_queue_pri2cos_cfg(softc, softc->ieee_ets, in bnxt_queue_remap()
236 device_printf(softc->dev, "failed to config prio, rc = %d\n", rc); in bnxt_queue_remap()
244 bnxt_hwrm_queue_pfc_cfg(struct bnxt_softc *softc, struct bnxt_ieee_pfc *pfc) in bnxt_hwrm_queue_pfc_cfg() argument
247 struct bnxt_ieee_ets *my_ets = softc->ieee_ets; in bnxt_hwrm_queue_pfc_cfg()
255 for (i = 0; i < softc->max_tc; i++) { in bnxt_hwrm_queue_pfc_cfg()
267 if (lltc_count > softc->max_lltc) { in bnxt_hwrm_queue_pfc_cfg()
268 device_printf(softc->dev, in bnxt_hwrm_queue_pfc_cfg()
270 "to configure PFC (cap %d)\n", lltc_count, softc->max_lltc); in bnxt_hwrm_queue_pfc_cfg()
274 for (i = 0; i < softc->max_tc; i++) { in bnxt_hwrm_queue_pfc_cfg()
276 uint8_t qidx = softc->tc_to_qidx[i]; in bnxt_hwrm_queue_pfc_cfg()
278 if (!BNXT_LLQ(softc->rx_q_info[qidx].queue_profile)) { in bnxt_hwrm_queue_pfc_cfg()
286 bnxt_queue_remap(softc, tc_mask); in bnxt_hwrm_queue_pfc_cfg()
288 bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_QUEUE_PFCENABLE_CFG); in bnxt_hwrm_queue_pfc_cfg()
291 return _hwrm_send_message(softc, &req, sizeof(req)); in bnxt_hwrm_queue_pfc_cfg()
295 bnxt_hwrm_queue_pfc_qcfg(struct bnxt_softc *softc, struct bnxt_ieee_pfc *pfc) in bnxt_hwrm_queue_pfc_qcfg() argument
298 (void *)softc->hwrm_cmd_resp.idi_vaddr; in bnxt_hwrm_queue_pfc_qcfg()
303 bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_QUEUE_PFCENABLE_QCFG); in bnxt_hwrm_queue_pfc_qcfg()
305 rc = _hwrm_send_message(softc, &req, sizeof(req)); in bnxt_hwrm_queue_pfc_qcfg()
316 bnxt_hwrm_get_dcbx_app(struct bnxt_softc *softc, struct bnxt_dcb_app *app, int *num_inputs) in bnxt_hwrm_get_dcbx_app() argument
325 if (softc->hwrm_spec_code < 0x10601) in bnxt_hwrm_get_dcbx_app()
328 bnxt_hwrm_cmd_hdr_init(softc, &get, HWRM_FW_GET_STRUCTURED_DATA); in bnxt_hwrm_get_dcbx_app()
332 rc = iflib_dma_alloc(softc->ctx, data_len, &dma_data, in bnxt_hwrm_get_dcbx_app()
340 rc = _hwrm_send_message(softc, &get, sizeof(get)); in bnxt_hwrm_get_dcbx_app()
366 bnxt_hwrm_set_dcbx_app(struct bnxt_softc *softc, struct bnxt_dcb_app *app, in bnxt_hwrm_set_dcbx_app() argument
377 if (softc->hwrm_spec_code < 0x10601) in bnxt_hwrm_set_dcbx_app()
380 bnxt_hwrm_cmd_hdr_init(softc, &get, HWRM_FW_GET_STRUCTURED_DATA); in bnxt_hwrm_set_dcbx_app()
384 rc = iflib_dma_alloc(softc->ctx, data_len, &dma_data, in bnxt_hwrm_set_dcbx_app()
392 rc = _hwrm_send_message(softc, &get, sizeof(get)); in bnxt_hwrm_set_dcbx_app()
439 bnxt_hwrm_cmd_hdr_init(softc, &set, HWRM_FW_SET_STRUCTURED_DATA); in bnxt_hwrm_set_dcbx_app()
444 rc = _hwrm_send_message(softc, &set, sizeof(set)); in bnxt_hwrm_set_dcbx_app()
452 bnxt_hwrm_queue_dscp_qcaps(struct bnxt_softc *softc) in bnxt_hwrm_queue_dscp_qcaps() argument
455 (void *)softc->hwrm_cmd_resp.idi_vaddr; in bnxt_hwrm_queue_dscp_qcaps()
459 softc->max_dscp_value = 0; in bnxt_hwrm_queue_dscp_qcaps()
460 if (softc->hwrm_spec_code < 0x10800 || BNXT_VF(softc)) in bnxt_hwrm_queue_dscp_qcaps()
463 bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_QUEUE_DSCP_QCAPS); in bnxt_hwrm_queue_dscp_qcaps()
465 rc = _hwrm_send_message(softc, &req, sizeof(req)); in bnxt_hwrm_queue_dscp_qcaps()
467 softc->max_dscp_value = (1 << resp->num_dscp_bits) - 1; in bnxt_hwrm_queue_dscp_qcaps()
468 if (softc->max_dscp_value < 0x3f) in bnxt_hwrm_queue_dscp_qcaps()
469 softc->max_dscp_value = 0; in bnxt_hwrm_queue_dscp_qcaps()
475 bnxt_hwrm_queue_dscp2pri_qcfg(struct bnxt_softc *softc, struct bnxt_dcb_app *app, int *num_inputs) in bnxt_hwrm_queue_dscp2pri_qcfg() argument
479 (void *)softc->hwrm_cmd_resp.idi_vaddr; in bnxt_hwrm_queue_dscp2pri_qcfg()
485 if (softc->hwrm_spec_code < 0x10800) in bnxt_hwrm_queue_dscp2pri_qcfg()
488 rc = iflib_dma_alloc(softc->ctx, sizeof(*dscp2pri) * 128, &dma_data, in bnxt_hwrm_queue_dscp2pri_qcfg()
495 bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_QUEUE_DSCP2PRI_QCFG); in bnxt_hwrm_queue_dscp2pri_qcfg()
499 req.port_id = htole16(softc->pf.port_id); in bnxt_hwrm_queue_dscp2pri_qcfg()
500 rc = _hwrm_send_message(softc, &req, sizeof(req)); in bnxt_hwrm_queue_dscp2pri_qcfg()
519 bnxt_hwrm_queue_dscp2pri_cfg(struct bnxt_softc *softc, struct bnxt_dcb_app *app, in bnxt_hwrm_queue_dscp2pri_cfg() argument
527 if (softc->hwrm_spec_code < 0x10800) in bnxt_hwrm_queue_dscp2pri_cfg()
530 rc = iflib_dma_alloc(softc->ctx, sizeof(*dscp2pri), &dma_data, in bnxt_hwrm_queue_dscp2pri_cfg()
535 bnxt_hwrm_cmd_hdr_init(softc, &req, HWRM_QUEUE_DSCP2PRI_CFG); in bnxt_hwrm_queue_dscp2pri_cfg()
546 req.port_id = htole16(softc->pf.port_id); in bnxt_hwrm_queue_dscp2pri_cfg()
547 rc = _hwrm_send_message(softc, &req, sizeof(req)); in bnxt_hwrm_queue_dscp2pri_cfg()
554 bnxt_ets_validate(struct bnxt_softc *softc, struct bnxt_ieee_ets *ets, uint8_t *tc) in bnxt_ets_validate() argument
562 if (ets->prio_tc[i] > softc->max_tc) { in bnxt_ets_validate()
563 device_printf(softc->dev, "priority to TC mapping exceeds TC count %d\n", in bnxt_ets_validate()
570 if ((ets->tc_tx_bw[i] || ets->tc_tsa[i]) && i > softc->max_tc) in bnxt_ets_validate()
585 device_printf(softc->dev, "rejecting ETS config exceeding available bandwidth\n"); in bnxt_ets_validate()
589 device_printf(softc->dev, "rejecting ETS config starving a TC\n"); in bnxt_ets_validate()
593 if (max_tc >= softc->max_tc) in bnxt_ets_validate()
594 *tc = softc->max_tc; in bnxt_ets_validate()
601 bnxt_dcb_ieee_getets(struct bnxt_softc *softc, struct bnxt_ieee_ets *ets) in bnxt_dcb_ieee_getets() argument
603 struct bnxt_ieee_ets *my_ets = softc->ieee_ets; in bnxt_dcb_ieee_getets()
609 rc = bnxt_hwrm_queue_cos2bw_qcfg(softc, my_ets); in bnxt_dcb_ieee_getets()
612 rc = bnxt_hwrm_queue_pri2cos_qcfg(softc, my_ets); in bnxt_dcb_ieee_getets()
618 ets->ets_cap = softc->max_tc; in bnxt_dcb_ieee_getets()
630 bnxt_dcb_ieee_setets(struct bnxt_softc *softc, struct bnxt_ieee_ets *ets) in bnxt_dcb_ieee_setets() argument
635 if (!(softc->dcbx_cap & BNXT_DCB_CAP_DCBX_VER_IEEE) || in bnxt_dcb_ieee_setets()
636 !(softc->dcbx_cap & BNXT_DCB_CAP_DCBX_HOST)) in bnxt_dcb_ieee_setets()
639 rc = bnxt_ets_validate(softc, ets, &max_tc); in bnxt_dcb_ieee_setets()
643 rc = bnxt_hwrm_queue_cos2bw_cfg(softc, ets, max_tc); in bnxt_dcb_ieee_setets()
647 if (!softc->is_asym_q) { in bnxt_dcb_ieee_setets()
648 rc = bnxt_hwrm_queue_pri2cos_cfg(softc, ets, in bnxt_dcb_ieee_setets()
653 rc = bnxt_hwrm_queue_pri2cos_cfg(softc, ets, in bnxt_dcb_ieee_setets()
658 rc = bnxt_hwrm_queue_pri2cos_cfg(softc, ets, in bnxt_dcb_ieee_setets()
664 memcpy(softc->ieee_ets, ets, sizeof(*ets)); in bnxt_dcb_ieee_setets()
671 bnxt_dcb_ieee_getpfc(struct bnxt_softc *softc, struct bnxt_ieee_pfc *pfc) in bnxt_dcb_ieee_getpfc() argument
673 struct bnxt_ieee_pfc *my_pfc = softc->ieee_pfc; in bnxt_dcb_ieee_getpfc()
679 pfc->pfc_cap = softc->max_lltc; in bnxt_dcb_ieee_getpfc()
681 rc = bnxt_hwrm_queue_pfc_qcfg(softc, my_pfc); in bnxt_dcb_ieee_getpfc()
693 bnxt_dcb_ieee_setpfc(struct bnxt_softc *softc, struct bnxt_ieee_pfc *pfc) in bnxt_dcb_ieee_setpfc() argument
695 struct bnxt_ieee_pfc *my_pfc = softc->ieee_pfc; in bnxt_dcb_ieee_setpfc()
701 if (!(softc->dcbx_cap & BNXT_DCB_CAP_DCBX_VER_IEEE) || in bnxt_dcb_ieee_setpfc()
702 !(softc->dcbx_cap & BNXT_DCB_CAP_DCBX_HOST) || in bnxt_dcb_ieee_setpfc()
703 (softc->phy_flags & BNXT_PHY_FL_NO_PAUSE)) in bnxt_dcb_ieee_setpfc()
706 rc = bnxt_hwrm_queue_pfc_cfg(softc, pfc); in bnxt_dcb_ieee_setpfc()
714 bnxt_dcb_ieee_dscp_app_prep(struct bnxt_softc *softc, struct bnxt_dcb_app *app) in bnxt_dcb_ieee_dscp_app_prep() argument
717 if (!softc->max_dscp_value) in bnxt_dcb_ieee_dscp_app_prep()
719 if (app->protocol > softc->max_dscp_value) in bnxt_dcb_ieee_dscp_app_prep()
726 bnxt_dcb_ieee_setapp(struct bnxt_softc *softc, struct bnxt_dcb_app *app) in bnxt_dcb_ieee_setapp() argument
731 if (!(softc->dcbx_cap & BNXT_DCB_CAP_DCBX_VER_IEEE) || in bnxt_dcb_ieee_setapp()
732 !(softc->dcbx_cap & BNXT_DCB_CAP_DCBX_HOST)) in bnxt_dcb_ieee_setapp()
735 rc = bnxt_dcb_ieee_dscp_app_prep(softc, app); in bnxt_dcb_ieee_setapp()
743 rc = bnxt_hwrm_set_dcbx_app(softc, app, true); in bnxt_dcb_ieee_setapp()
746 rc = bnxt_hwrm_queue_dscp2pri_cfg(softc, app, true); in bnxt_dcb_ieee_setapp()
752 bnxt_dcb_ieee_delapp(struct bnxt_softc *softc, struct bnxt_dcb_app *app) in bnxt_dcb_ieee_delapp() argument
756 if (!(softc->dcbx_cap & BNXT_DCB_CAP_DCBX_VER_IEEE) || in bnxt_dcb_ieee_delapp()
757 !(softc->dcbx_cap & BNXT_DCB_CAP_DCBX_HOST)) in bnxt_dcb_ieee_delapp()
760 rc = bnxt_dcb_ieee_dscp_app_prep(softc, app); in bnxt_dcb_ieee_delapp()
768 rc = bnxt_hwrm_set_dcbx_app(softc, app, false); in bnxt_dcb_ieee_delapp()
771 rc = bnxt_hwrm_queue_dscp2pri_cfg(softc, app, false); in bnxt_dcb_ieee_delapp()
777 bnxt_dcb_ieee_listapp(struct bnxt_softc *softc, struct bnxt_dcb_app *app, int *num_inputs) in bnxt_dcb_ieee_listapp() argument
779 bnxt_hwrm_get_dcbx_app(softc, app, num_inputs); in bnxt_dcb_ieee_listapp()
780 bnxt_hwrm_queue_dscp2pri_qcfg(softc, app, num_inputs); in bnxt_dcb_ieee_listapp()
786 bnxt_dcb_getdcbx(struct bnxt_softc *softc) in bnxt_dcb_getdcbx() argument
788 return softc->dcbx_cap; in bnxt_dcb_getdcbx()
792 bnxt_dcb_setdcbx(struct bnxt_softc *softc, uint8_t mode) in bnxt_dcb_setdcbx() argument
795 if (softc->dcbx_cap & BNXT_DCB_CAP_DCBX_LLD_MANAGED) in bnxt_dcb_setdcbx()
802 if ((softc->dcbx_cap & BNXT_DCB_CAP_DCBX_LLD_MANAGED) != in bnxt_dcb_setdcbx()
807 if (BNXT_VF(softc) || (softc->fw_cap & BNXT_FW_CAP_LLDP_AGENT)) in bnxt_dcb_setdcbx()
816 if (mode == softc->dcbx_cap) in bnxt_dcb_setdcbx()
819 softc->dcbx_cap = mode; in bnxt_dcb_setdcbx()
824 bnxt_dcb_init(struct bnxt_softc *softc) in bnxt_dcb_init() argument
829 softc->dcbx_cap = 0; in bnxt_dcb_init()
831 if (softc->hwrm_spec_code < 0x10501) in bnxt_dcb_init()
834 softc->ieee_ets = malloc(sizeof(struct bnxt_ieee_ets), M_DEVBUF, M_NOWAIT | M_ZERO); in bnxt_dcb_init()
835 if (!softc->ieee_ets) in bnxt_dcb_init()
838 softc->ieee_pfc = malloc(sizeof(struct bnxt_ieee_pfc), M_DEVBUF, M_NOWAIT | M_ZERO); in bnxt_dcb_init()
839 if (!softc->ieee_pfc) in bnxt_dcb_init()
842 bnxt_hwrm_queue_dscp_qcaps(softc); in bnxt_dcb_init()
843 softc->dcbx_cap = BNXT_DCB_CAP_DCBX_VER_IEEE; in bnxt_dcb_init()
844 if (BNXT_PF(softc) && !(softc->fw_cap & BNXT_FW_CAP_LLDP_AGENT)) in bnxt_dcb_init()
845 softc->dcbx_cap |= BNXT_DCB_CAP_DCBX_HOST; in bnxt_dcb_init()
846 else if (softc->fw_cap & BNXT_FW_CAP_DCBX_AGENT) in bnxt_dcb_init()
847 softc->dcbx_cap |= BNXT_DCB_CAP_DCBX_LLD_MANAGED; in bnxt_dcb_init()
849 bnxt_dcb_ieee_setets(softc, &ets); in bnxt_dcb_init()
850 bnxt_dcb_ieee_setpfc(softc, &pfc); in bnxt_dcb_init()
855 bnxt_dcb_free(struct bnxt_softc *softc) in bnxt_dcb_free() argument
857 free(softc->ieee_ets, M_DEVBUF); in bnxt_dcb_free()
858 softc->ieee_ets = NULL; in bnxt_dcb_free()
859 free(softc->ieee_pfc, M_DEVBUF); in bnxt_dcb_free()
860 softc->ieee_pfc = NULL; in bnxt_dcb_free()