Lines Matching refs:bp

24 static int bnxt_queue_to_tc(struct bnxt *bp, u8 queue_id)  in bnxt_queue_to_tc()  argument
28 for (i = 0; i < bp->max_tc; i++) { in bnxt_queue_to_tc()
29 if (bp->q_info[i].queue_id == queue_id) { in bnxt_queue_to_tc()
30 for (j = 0; j < bp->max_tc; j++) { in bnxt_queue_to_tc()
31 if (bp->tc_to_qidx[j] == i) in bnxt_queue_to_tc()
39 static int bnxt_hwrm_queue_pri2cos_cfg(struct bnxt *bp, struct ieee_ets *ets) in bnxt_hwrm_queue_pri2cos_cfg() argument
45 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_QUEUE_PRI2COS_CFG, -1, -1); in bnxt_hwrm_queue_pri2cos_cfg()
56 qidx = bp->tc_to_qidx[ets->prio_tc[i]]; in bnxt_hwrm_queue_pri2cos_cfg()
57 pri2cos[i] = bp->q_info[qidx].queue_id; in bnxt_hwrm_queue_pri2cos_cfg()
59 rc = hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_queue_pri2cos_cfg()
63 static int bnxt_hwrm_queue_pri2cos_qcfg(struct bnxt *bp, struct ieee_ets *ets) in bnxt_hwrm_queue_pri2cos_qcfg() argument
65 struct hwrm_queue_pri2cos_qcfg_output *resp = bp->hwrm_cmd_resp_addr; in bnxt_hwrm_queue_pri2cos_qcfg()
69 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_QUEUE_PRI2COS_QCFG, -1, -1); in bnxt_hwrm_queue_pri2cos_qcfg()
72 mutex_lock(&bp->hwrm_cmd_lock); in bnxt_hwrm_queue_pri2cos_qcfg()
73 rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_queue_pri2cos_qcfg()
82 tc = bnxt_queue_to_tc(bp, queue_id); in bnxt_hwrm_queue_pri2cos_qcfg()
87 mutex_unlock(&bp->hwrm_cmd_lock); in bnxt_hwrm_queue_pri2cos_qcfg()
91 static int bnxt_hwrm_queue_cos2bw_cfg(struct bnxt *bp, struct ieee_ets *ets, in bnxt_hwrm_queue_cos2bw_cfg() argument
99 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_QUEUE_COS2BW_CFG, -1, -1); in bnxt_hwrm_queue_cos2bw_cfg()
101 u8 qidx = bp->tc_to_qidx[i]; in bnxt_hwrm_queue_cos2bw_cfg()
108 cos2bw.queue_id = bp->q_info[qidx].queue_id; in bnxt_hwrm_queue_cos2bw_cfg()
131 rc = hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_queue_cos2bw_cfg()
135 static int bnxt_hwrm_queue_cos2bw_qcfg(struct bnxt *bp, struct ieee_ets *ets) in bnxt_hwrm_queue_cos2bw_qcfg() argument
137 struct hwrm_queue_cos2bw_qcfg_output *resp = bp->hwrm_cmd_resp_addr; in bnxt_hwrm_queue_cos2bw_qcfg()
143 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_QUEUE_COS2BW_QCFG, -1, -1); in bnxt_hwrm_queue_cos2bw_qcfg()
145 mutex_lock(&bp->hwrm_cmd_lock); in bnxt_hwrm_queue_cos2bw_qcfg()
146 rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_queue_cos2bw_qcfg()
148 mutex_unlock(&bp->hwrm_cmd_lock); in bnxt_hwrm_queue_cos2bw_qcfg()
153 for (i = 0; i < bp->max_tc; i++, data += sizeof(cos2bw) - 4) { in bnxt_hwrm_queue_cos2bw_qcfg()
160 tc = bnxt_queue_to_tc(bp, cos2bw.queue_id); in bnxt_hwrm_queue_cos2bw_qcfg()
172 mutex_unlock(&bp->hwrm_cmd_lock); in bnxt_hwrm_queue_cos2bw_qcfg()
176 static int bnxt_queue_remap(struct bnxt *bp, unsigned int lltc_mask) in bnxt_queue_remap() argument
179 int max = bp->max_tc; in bnxt_queue_remap()
185 if (BNXT_LLQ(bp->q_info[j].queue_profile)) { in bnxt_queue_remap()
186 bp->tc_to_qidx[i] = j; in bnxt_queue_remap()
200 bp->tc_to_qidx[i] = j; in bnxt_queue_remap()
205 if (netif_running(bp->dev)) { in bnxt_queue_remap()
206 bnxt_close_nic(bp, false, false); in bnxt_queue_remap()
207 rc = bnxt_open_nic(bp, false, false); in bnxt_queue_remap()
209 netdev_warn(bp->dev, "failed to open NIC, rc = %d\n", rc); in bnxt_queue_remap()
213 if (bp->ieee_ets) { in bnxt_queue_remap()
214 int tc = netdev_get_num_tc(bp->dev); in bnxt_queue_remap()
218 rc = bnxt_hwrm_queue_cos2bw_cfg(bp, bp->ieee_ets, tc); in bnxt_queue_remap()
220 netdev_warn(bp->dev, "failed to config BW, rc = %d\n", rc); in bnxt_queue_remap()
223 rc = bnxt_hwrm_queue_pri2cos_cfg(bp, bp->ieee_ets); in bnxt_queue_remap()
225 netdev_warn(bp->dev, "failed to config prio, rc = %d\n", rc); in bnxt_queue_remap()
232 static int bnxt_hwrm_queue_pfc_cfg(struct bnxt *bp, struct ieee_pfc *pfc) in bnxt_hwrm_queue_pfc_cfg() argument
235 struct ieee_ets *my_ets = bp->ieee_ets; in bnxt_hwrm_queue_pfc_cfg()
244 for (i = 0; i < bp->max_tc; i++) { in bnxt_hwrm_queue_pfc_cfg()
255 if (lltc_count > bp->max_lltc) in bnxt_hwrm_queue_pfc_cfg()
258 for (i = 0; i < bp->max_tc; i++) { in bnxt_hwrm_queue_pfc_cfg()
260 u8 qidx = bp->tc_to_qidx[i]; in bnxt_hwrm_queue_pfc_cfg()
262 if (!BNXT_LLQ(bp->q_info[qidx].queue_profile)) { in bnxt_hwrm_queue_pfc_cfg()
270 rc = bnxt_queue_remap(bp, tc_mask); in bnxt_hwrm_queue_pfc_cfg()
272 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_QUEUE_PFCENABLE_CFG, -1, -1); in bnxt_hwrm_queue_pfc_cfg()
274 rc = hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_queue_pfc_cfg()
281 static int bnxt_hwrm_queue_pfc_qcfg(struct bnxt *bp, struct ieee_pfc *pfc) in bnxt_hwrm_queue_pfc_qcfg() argument
283 struct hwrm_queue_pfcenable_qcfg_output *resp = bp->hwrm_cmd_resp_addr; in bnxt_hwrm_queue_pfc_qcfg()
288 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_QUEUE_PFCENABLE_QCFG, -1, -1); in bnxt_hwrm_queue_pfc_qcfg()
290 mutex_lock(&bp->hwrm_cmd_lock); in bnxt_hwrm_queue_pfc_qcfg()
291 rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_queue_pfc_qcfg()
293 mutex_unlock(&bp->hwrm_cmd_lock); in bnxt_hwrm_queue_pfc_qcfg()
299 mutex_unlock(&bp->hwrm_cmd_lock); in bnxt_hwrm_queue_pfc_qcfg()
303 static int bnxt_hwrm_set_dcbx_app(struct bnxt *bp, struct dcb_app *app, in bnxt_hwrm_set_dcbx_app() argument
314 if (bp->hwrm_spec_code < 0x10601) in bnxt_hwrm_set_dcbx_app()
319 data = dma_zalloc_coherent(&bp->pdev->dev, data_len, &mapping, in bnxt_hwrm_set_dcbx_app()
324 bnxt_hwrm_cmd_hdr_init(bp, &get, HWRM_FW_GET_STRUCTURED_DATA, -1, -1); in bnxt_hwrm_set_dcbx_app()
329 rc = hwrm_send_message(bp, &get, sizeof(get), HWRM_CMD_TIMEOUT); in bnxt_hwrm_set_dcbx_app()
375 bnxt_hwrm_cmd_hdr_init(bp, &set, HWRM_FW_SET_STRUCTURED_DATA, -1, -1); in bnxt_hwrm_set_dcbx_app()
379 rc = hwrm_send_message(bp, &set, sizeof(set), HWRM_CMD_TIMEOUT); in bnxt_hwrm_set_dcbx_app()
384 dma_free_coherent(&bp->pdev->dev, data_len, data, mapping); in bnxt_hwrm_set_dcbx_app()
388 static int bnxt_hwrm_queue_dscp_qcaps(struct bnxt *bp) in bnxt_hwrm_queue_dscp_qcaps() argument
390 struct hwrm_queue_dscp_qcaps_output *resp = bp->hwrm_cmd_resp_addr; in bnxt_hwrm_queue_dscp_qcaps()
394 if (bp->hwrm_spec_code < 0x10800 || BNXT_VF(bp)) in bnxt_hwrm_queue_dscp_qcaps()
397 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_QUEUE_DSCP_QCAPS, -1, -1); in bnxt_hwrm_queue_dscp_qcaps()
398 mutex_lock(&bp->hwrm_cmd_lock); in bnxt_hwrm_queue_dscp_qcaps()
399 rc = _hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_queue_dscp_qcaps()
401 bp->max_dscp_value = (1 << resp->num_dscp_bits) - 1; in bnxt_hwrm_queue_dscp_qcaps()
402 if (bp->max_dscp_value < 0x3f) in bnxt_hwrm_queue_dscp_qcaps()
403 bp->max_dscp_value = 0; in bnxt_hwrm_queue_dscp_qcaps()
406 mutex_unlock(&bp->hwrm_cmd_lock); in bnxt_hwrm_queue_dscp_qcaps()
410 static int bnxt_hwrm_queue_dscp2pri_cfg(struct bnxt *bp, struct dcb_app *app, in bnxt_hwrm_queue_dscp2pri_cfg() argument
418 if (bp->hwrm_spec_code < 0x10800) in bnxt_hwrm_queue_dscp2pri_cfg()
421 bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_QUEUE_DSCP2PRI_CFG, -1, -1); in bnxt_hwrm_queue_dscp2pri_cfg()
422 dscp2pri = dma_alloc_coherent(&bp->pdev->dev, sizeof(*dscp2pri), in bnxt_hwrm_queue_dscp2pri_cfg()
435 rc = hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); in bnxt_hwrm_queue_dscp2pri_cfg()
438 dma_free_coherent(&bp->pdev->dev, sizeof(*dscp2pri), dscp2pri, in bnxt_hwrm_queue_dscp2pri_cfg()
443 static int bnxt_ets_validate(struct bnxt *bp, struct ieee_ets *ets, u8 *tc) in bnxt_ets_validate() argument
450 if (ets->prio_tc[i] > bp->max_tc) { in bnxt_ets_validate()
451 netdev_err(bp->dev, "priority to TC mapping exceeds TC count %d\n", in bnxt_ets_validate()
458 if ((ets->tc_tx_bw[i] || ets->tc_tsa[i]) && i > bp->max_tc) in bnxt_ets_validate()
480 struct bnxt *bp = netdev_priv(dev); in bnxt_dcbnl_ieee_getets() local
481 struct ieee_ets *my_ets = bp->ieee_ets; in bnxt_dcbnl_ieee_getets()
483 ets->ets_cap = bp->max_tc; in bnxt_dcbnl_ieee_getets()
488 if (bp->dcbx_cap & DCB_CAP_DCBX_HOST) in bnxt_dcbnl_ieee_getets()
494 rc = bnxt_hwrm_queue_cos2bw_qcfg(bp, my_ets); in bnxt_dcbnl_ieee_getets()
497 rc = bnxt_hwrm_queue_pri2cos_qcfg(bp, my_ets); in bnxt_dcbnl_ieee_getets()
512 struct bnxt *bp = netdev_priv(dev); in bnxt_dcbnl_ieee_setets() local
513 struct ieee_ets *my_ets = bp->ieee_ets; in bnxt_dcbnl_ieee_setets()
517 if (!(bp->dcbx_cap & DCB_CAP_DCBX_VER_IEEE) || in bnxt_dcbnl_ieee_setets()
518 !(bp->dcbx_cap & DCB_CAP_DCBX_HOST)) in bnxt_dcbnl_ieee_setets()
521 rc = bnxt_ets_validate(bp, ets, &max_tc); in bnxt_dcbnl_ieee_setets()
530 bp->ieee_ets = my_ets; in bnxt_dcbnl_ieee_setets()
535 rc = bnxt_hwrm_queue_cos2bw_cfg(bp, ets, max_tc); in bnxt_dcbnl_ieee_setets()
538 rc = bnxt_hwrm_queue_pri2cos_cfg(bp, ets); in bnxt_dcbnl_ieee_setets()
548 struct bnxt *bp = netdev_priv(dev); in bnxt_dcbnl_ieee_getpfc() local
549 __le64 *stats = (__le64 *)bp->hw_rx_port_stats; in bnxt_dcbnl_ieee_getpfc()
550 struct ieee_pfc *my_pfc = bp->ieee_pfc; in bnxt_dcbnl_ieee_getpfc()
554 pfc->pfc_cap = bp->max_lltc; in bnxt_dcbnl_ieee_getpfc()
557 if (bp->dcbx_cap & DCB_CAP_DCBX_HOST) in bnxt_dcbnl_ieee_getpfc()
563 bp->ieee_pfc = my_pfc; in bnxt_dcbnl_ieee_getpfc()
564 rc = bnxt_hwrm_queue_pfc_qcfg(bp, my_pfc); in bnxt_dcbnl_ieee_getpfc()
588 struct bnxt *bp = netdev_priv(dev); in bnxt_dcbnl_ieee_setpfc() local
589 struct ieee_pfc *my_pfc = bp->ieee_pfc; in bnxt_dcbnl_ieee_setpfc()
592 if (!(bp->dcbx_cap & DCB_CAP_DCBX_VER_IEEE) || in bnxt_dcbnl_ieee_setpfc()
593 !(bp->dcbx_cap & DCB_CAP_DCBX_HOST)) in bnxt_dcbnl_ieee_setpfc()
600 bp->ieee_pfc = my_pfc; in bnxt_dcbnl_ieee_setpfc()
602 rc = bnxt_hwrm_queue_pfc_cfg(bp, pfc); in bnxt_dcbnl_ieee_setpfc()
609 static int bnxt_dcbnl_ieee_dscp_app_prep(struct bnxt *bp, struct dcb_app *app) in bnxt_dcbnl_ieee_dscp_app_prep() argument
612 if (!bp->max_dscp_value) in bnxt_dcbnl_ieee_dscp_app_prep()
614 if (app->protocol > bp->max_dscp_value) in bnxt_dcbnl_ieee_dscp_app_prep()
622 struct bnxt *bp = netdev_priv(dev); in bnxt_dcbnl_ieee_setapp() local
625 if (!(bp->dcbx_cap & DCB_CAP_DCBX_VER_IEEE) || in bnxt_dcbnl_ieee_setapp()
626 !(bp->dcbx_cap & DCB_CAP_DCBX_HOST)) in bnxt_dcbnl_ieee_setapp()
629 rc = bnxt_dcbnl_ieee_dscp_app_prep(bp, app); in bnxt_dcbnl_ieee_setapp()
641 rc = bnxt_hwrm_set_dcbx_app(bp, app, true); in bnxt_dcbnl_ieee_setapp()
644 rc = bnxt_hwrm_queue_dscp2pri_cfg(bp, app, true); in bnxt_dcbnl_ieee_setapp()
651 struct bnxt *bp = netdev_priv(dev); in bnxt_dcbnl_ieee_delapp() local
654 if (!(bp->dcbx_cap & DCB_CAP_DCBX_VER_IEEE) || in bnxt_dcbnl_ieee_delapp()
655 !(bp->dcbx_cap & DCB_CAP_DCBX_HOST)) in bnxt_dcbnl_ieee_delapp()
658 rc = bnxt_dcbnl_ieee_dscp_app_prep(bp, app); in bnxt_dcbnl_ieee_delapp()
669 rc = bnxt_hwrm_set_dcbx_app(bp, app, false); in bnxt_dcbnl_ieee_delapp()
672 rc = bnxt_hwrm_queue_dscp2pri_cfg(bp, app, false); in bnxt_dcbnl_ieee_delapp()
679 struct bnxt *bp = netdev_priv(dev); in bnxt_dcbnl_getdcbx() local
681 return bp->dcbx_cap; in bnxt_dcbnl_getdcbx()
686 struct bnxt *bp = netdev_priv(dev); in bnxt_dcbnl_setdcbx() local
689 if (bp->dcbx_cap & DCB_CAP_DCBX_LLD_MANAGED) in bnxt_dcbnl_setdcbx()
693 if (BNXT_VF(bp) || (bp->fw_cap & BNXT_FW_CAP_LLDP_AGENT)) in bnxt_dcbnl_setdcbx()
702 if (mode == bp->dcbx_cap) in bnxt_dcbnl_setdcbx()
705 bp->dcbx_cap = mode; in bnxt_dcbnl_setdcbx()
720 void bnxt_dcb_init(struct bnxt *bp) in bnxt_dcb_init() argument
722 if (bp->hwrm_spec_code < 0x10501) in bnxt_dcb_init()
725 bnxt_hwrm_queue_dscp_qcaps(bp); in bnxt_dcb_init()
726 bp->dcbx_cap = DCB_CAP_DCBX_VER_IEEE; in bnxt_dcb_init()
727 if (BNXT_PF(bp) && !(bp->fw_cap & BNXT_FW_CAP_LLDP_AGENT)) in bnxt_dcb_init()
728 bp->dcbx_cap |= DCB_CAP_DCBX_HOST; in bnxt_dcb_init()
729 else if (bp->fw_cap & BNXT_FW_CAP_DCBX_AGENT) in bnxt_dcb_init()
730 bp->dcbx_cap |= DCB_CAP_DCBX_LLD_MANAGED; in bnxt_dcb_init()
731 bp->dev->dcbnl_ops = &dcbnl_ops; in bnxt_dcb_init()
734 void bnxt_dcb_free(struct bnxt *bp) in bnxt_dcb_free() argument
736 kfree(bp->ieee_pfc); in bnxt_dcb_free()
737 kfree(bp->ieee_ets); in bnxt_dcb_free()
738 bp->ieee_pfc = NULL; in bnxt_dcb_free()
739 bp->ieee_ets = NULL; in bnxt_dcb_free()
744 void bnxt_dcb_init(struct bnxt *bp) in bnxt_dcb_init() argument
748 void bnxt_dcb_free(struct bnxt *bp) in bnxt_dcb_free() argument