Lines Matching refs:rdev

81 static void bnxt_re_remove_device(struct bnxt_re_dev *rdev);
84 static void bnxt_re_dev_stop(struct bnxt_re_dev *rdev);
86 static void bnxt_re_set_drv_mode(struct bnxt_re_dev *rdev, u8 mode) in bnxt_re_set_drv_mode() argument
90 cctx = rdev->chip_ctx; in bnxt_re_set_drv_mode()
91 cctx->modes.wqe_mode = bnxt_qplib_is_chip_gen_p5(rdev->chip_ctx) ? in bnxt_re_set_drv_mode()
95 static void bnxt_re_destroy_chip_ctx(struct bnxt_re_dev *rdev) in bnxt_re_destroy_chip_ctx() argument
99 if (!rdev->chip_ctx) in bnxt_re_destroy_chip_ctx()
101 chip_ctx = rdev->chip_ctx; in bnxt_re_destroy_chip_ctx()
102 rdev->chip_ctx = NULL; in bnxt_re_destroy_chip_ctx()
103 rdev->rcfw.res = NULL; in bnxt_re_destroy_chip_ctx()
104 rdev->qplib_res.cctx = NULL; in bnxt_re_destroy_chip_ctx()
105 rdev->qplib_res.pdev = NULL; in bnxt_re_destroy_chip_ctx()
106 rdev->qplib_res.netdev = NULL; in bnxt_re_destroy_chip_ctx()
110 static int bnxt_re_setup_chip_ctx(struct bnxt_re_dev *rdev, u8 wqe_mode) in bnxt_re_setup_chip_ctx() argument
116 en_dev = rdev->en_dev; in bnxt_re_setup_chip_ctx()
125 rdev->chip_ctx = chip_ctx; in bnxt_re_setup_chip_ctx()
128 rdev->qplib_res.cctx = rdev->chip_ctx; in bnxt_re_setup_chip_ctx()
129 rdev->rcfw.res = &rdev->qplib_res; in bnxt_re_setup_chip_ctx()
130 rdev->qplib_res.dattr = &rdev->dev_attr; in bnxt_re_setup_chip_ctx()
131 rdev->qplib_res.is_vf = BNXT_VF(bp); in bnxt_re_setup_chip_ctx()
133 bnxt_re_set_drv_mode(rdev, wqe_mode); in bnxt_re_setup_chip_ctx()
135 ibdev_info(&rdev->ibdev, in bnxt_re_setup_chip_ctx()
142 static void bnxt_re_get_sriov_func_type(struct bnxt_re_dev *rdev) in bnxt_re_get_sriov_func_type() argument
146 bp = netdev_priv(rdev->en_dev->net); in bnxt_re_get_sriov_func_type()
148 rdev->is_virtfn = 1; in bnxt_re_get_sriov_func_type()
156 static void bnxt_re_limit_pf_res(struct bnxt_re_dev *rdev) in bnxt_re_limit_pf_res() argument
162 attr = &rdev->dev_attr; in bnxt_re_limit_pf_res()
163 ctx = &rdev->qplib_ctx; in bnxt_re_limit_pf_res()
173 if (!bnxt_qplib_is_chip_gen_p5(rdev->chip_ctx)) in bnxt_re_limit_pf_res()
175 rdev->qplib_ctx.tqm_ctx.qcount[i] = in bnxt_re_limit_pf_res()
176 rdev->dev_attr.tqm_alloc_reqs[i]; in bnxt_re_limit_pf_res()
215 static void bnxt_re_set_resource_limits(struct bnxt_re_dev *rdev) in bnxt_re_set_resource_limits() argument
219 memset(&rdev->qplib_ctx.vf_res, 0, sizeof(struct bnxt_qplib_vf_res)); in bnxt_re_set_resource_limits()
220 bnxt_re_limit_pf_res(rdev); in bnxt_re_set_resource_limits()
222 num_vfs = bnxt_qplib_is_chip_gen_p5(rdev->chip_ctx) ? in bnxt_re_set_resource_limits()
223 BNXT_RE_GEN_P5_MAX_VF : rdev->num_vfs; in bnxt_re_set_resource_limits()
225 bnxt_re_limit_vf_res(&rdev->qplib_ctx, num_vfs); in bnxt_re_set_resource_limits()
231 struct bnxt_re_dev *rdev = p; in bnxt_re_stop() local
234 if (!rdev) in bnxt_re_stop()
244 bp = netdev_priv(rdev->netdev); in bnxt_re_stop()
246 ibdev_info(&rdev->ibdev, "Handle device stop call from L2 driver"); in bnxt_re_stop()
253 set_bit(ERR_DEVICE_DETACHED, &rdev->rcfw.cmdq.flags); in bnxt_re_stop()
255 bnxt_re_dev_stop(rdev); in bnxt_re_stop()
256 bnxt_re_stop_irq(rdev); in bnxt_re_stop()
260 set_bit(BNXT_RE_FLAG_ERR_DEVICE_DETACHED, &rdev->flags); in bnxt_re_stop()
261 set_bit(ERR_DEVICE_DETACHED, &rdev->rcfw.cmdq.flags); in bnxt_re_stop()
270 struct bnxt_re_dev *rdev = p; in bnxt_re_sriov_config() local
272 if (!rdev) in bnxt_re_sriov_config()
275 if (test_bit(BNXT_RE_FLAG_ERR_DEVICE_DETACHED, &rdev->flags)) in bnxt_re_sriov_config()
277 rdev->num_vfs = num_vfs; in bnxt_re_sriov_config()
278 if (!bnxt_qplib_is_chip_gen_p5(rdev->chip_ctx)) { in bnxt_re_sriov_config()
279 bnxt_re_set_resource_limits(rdev); in bnxt_re_sriov_config()
280 bnxt_qplib_set_func_resources(&rdev->qplib_res, &rdev->rcfw, in bnxt_re_sriov_config()
281 &rdev->qplib_ctx); in bnxt_re_sriov_config()
287 struct bnxt_re_dev *rdev = p; in bnxt_re_shutdown() local
289 if (!rdev) in bnxt_re_shutdown()
293 bnxt_re_stop_irq(rdev); in bnxt_re_shutdown()
294 ib_unregister_device_queued(&rdev->ibdev); in bnxt_re_shutdown()
299 struct bnxt_re_dev *rdev = (struct bnxt_re_dev *)handle; in bnxt_re_stop_irq() local
300 struct bnxt_qplib_rcfw *rcfw = &rdev->rcfw; in bnxt_re_stop_irq()
304 for (indx = BNXT_RE_NQ_IDX; indx < rdev->num_msix; indx++) { in bnxt_re_stop_irq()
305 nq = &rdev->nq[indx - 1]; in bnxt_re_stop_irq()
314 struct bnxt_re_dev *rdev = (struct bnxt_re_dev *)handle; in bnxt_re_start_irq() local
315 struct bnxt_msix_entry *msix_ent = rdev->msix_entries; in bnxt_re_start_irq()
316 struct bnxt_qplib_rcfw *rcfw = &rdev->rcfw; in bnxt_re_start_irq()
326 ibdev_err(&rdev->ibdev, "Failed to re-start IRQs\n"); in bnxt_re_start_irq()
333 for (indx = 0; indx < rdev->num_msix; indx++) in bnxt_re_start_irq()
334 rdev->msix_entries[indx].vector = ent[indx].vector; in bnxt_re_start_irq()
338 for (indx = BNXT_RE_NQ_IDX ; indx < rdev->num_msix; indx++) { in bnxt_re_start_irq()
339 nq = &rdev->nq[indx - 1]; in bnxt_re_start_irq()
343 ibdev_warn(&rdev->ibdev, "Failed to reinit NQ index %d\n", in bnxt_re_start_irq()
363 static int bnxt_re_unregister_netdev(struct bnxt_re_dev *rdev) in bnxt_re_unregister_netdev() argument
368 if (!rdev) in bnxt_re_unregister_netdev()
371 en_dev = rdev->en_dev; in bnxt_re_unregister_netdev()
373 rc = en_dev->en_ops->bnxt_unregister_device(rdev->en_dev, in bnxt_re_unregister_netdev()
378 static int bnxt_re_register_netdev(struct bnxt_re_dev *rdev) in bnxt_re_register_netdev() argument
383 if (!rdev) in bnxt_re_register_netdev()
386 en_dev = rdev->en_dev; in bnxt_re_register_netdev()
389 &bnxt_re_ulp_ops, rdev); in bnxt_re_register_netdev()
390 rdev->qplib_res.pdev = rdev->en_dev->pdev; in bnxt_re_register_netdev()
394 static int bnxt_re_free_msix(struct bnxt_re_dev *rdev) in bnxt_re_free_msix() argument
399 if (!rdev) in bnxt_re_free_msix()
402 en_dev = rdev->en_dev; in bnxt_re_free_msix()
405 rc = en_dev->en_ops->bnxt_free_msix(rdev->en_dev, BNXT_ROCE_ULP); in bnxt_re_free_msix()
410 static int bnxt_re_request_msix(struct bnxt_re_dev *rdev) in bnxt_re_request_msix() argument
415 if (!rdev) in bnxt_re_request_msix()
418 en_dev = rdev->en_dev; in bnxt_re_request_msix()
423 rdev->msix_entries, in bnxt_re_request_msix()
430 ibdev_warn(&rdev->ibdev, in bnxt_re_request_msix()
434 rdev->num_msix = num_msix_got; in bnxt_re_request_msix()
439 static void bnxt_re_init_hwrm_hdr(struct bnxt_re_dev *rdev, struct input *hdr, in bnxt_re_init_hwrm_hdr() argument
458 static int bnxt_re_net_ring_free(struct bnxt_re_dev *rdev, in bnxt_re_net_ring_free() argument
461 struct bnxt_en_dev *en_dev = rdev->en_dev; in bnxt_re_net_ring_free()
470 if (test_bit(BNXT_RE_FLAG_ERR_DEVICE_DETACHED, &rdev->flags)) in bnxt_re_net_ring_free()
475 bnxt_re_init_hwrm_hdr(rdev, (void *)&req, HWRM_RING_FREE, -1, -1); in bnxt_re_net_ring_free()
482 ibdev_err(&rdev->ibdev, "Failed to free HW ring:%d :%#x", in bnxt_re_net_ring_free()
487 static int bnxt_re_net_ring_alloc(struct bnxt_re_dev *rdev, in bnxt_re_net_ring_alloc() argument
491 struct bnxt_en_dev *en_dev = rdev->en_dev; in bnxt_re_net_ring_alloc()
501 bnxt_re_init_hwrm_hdr(rdev, (void *)&req, HWRM_RING_ALLOC, -1, -1); in bnxt_re_net_ring_alloc()
524 static int bnxt_re_net_stats_ctx_free(struct bnxt_re_dev *rdev, in bnxt_re_net_stats_ctx_free() argument
527 struct bnxt_en_dev *en_dev = rdev->en_dev; in bnxt_re_net_stats_ctx_free()
536 if (test_bit(BNXT_RE_FLAG_ERR_DEVICE_DETACHED, &rdev->flags)) in bnxt_re_net_stats_ctx_free()
541 bnxt_re_init_hwrm_hdr(rdev, (void *)&req, HWRM_STAT_CTX_FREE, -1, -1); in bnxt_re_net_stats_ctx_free()
547 ibdev_err(&rdev->ibdev, "Failed to free HW stats context %#x", in bnxt_re_net_stats_ctx_free()
553 static int bnxt_re_net_stats_ctx_alloc(struct bnxt_re_dev *rdev, in bnxt_re_net_stats_ctx_alloc() argument
557 struct bnxt_qplib_chip_ctx *chip_ctx = rdev->chip_ctx; in bnxt_re_net_stats_ctx_alloc()
560 struct bnxt_en_dev *en_dev = rdev->en_dev; in bnxt_re_net_stats_ctx_alloc()
571 bnxt_re_init_hwrm_hdr(rdev, (void *)&req, HWRM_STAT_CTX_ALLOC, -1, -1); in bnxt_re_net_stats_ctx_alloc()
640 struct bnxt_re_dev *rdev = in hw_rev_show() local
643 return sysfs_emit(buf, "0x%x\n", rdev->en_dev->pdev->vendor); in hw_rev_show()
650 struct bnxt_re_dev *rdev = in hca_type_show() local
653 return sysfs_emit(buf, "%s\n", rdev->ibdev.node_desc); in hca_type_show()
721 static int bnxt_re_register_ib(struct bnxt_re_dev *rdev) in bnxt_re_register_ib() argument
723 struct ib_device *ibdev = &rdev->ibdev; in bnxt_re_register_ib()
732 addrconf_addr_eui48((u8 *)&ibdev->node_guid, rdev->netdev->dev_addr); in bnxt_re_register_ib()
734 ibdev->num_comp_vectors = rdev->num_msix - 1; in bnxt_re_register_ib()
735 ibdev->dev.parent = &rdev->en_dev->pdev->dev; in bnxt_re_register_ib()
739 ret = ib_device_set_netdev(&rdev->ibdev, rdev->netdev, 1); in bnxt_re_register_ib()
743 dma_set_max_seg_size(&rdev->en_dev->pdev->dev, UINT_MAX); in bnxt_re_register_ib()
744 return ib_register_device(ibdev, "bnxt_re%d", &rdev->en_dev->pdev->dev); in bnxt_re_register_ib()
747 static void bnxt_re_dev_remove(struct bnxt_re_dev *rdev) in bnxt_re_dev_remove() argument
749 dev_put(rdev->netdev); in bnxt_re_dev_remove()
750 rdev->netdev = NULL; in bnxt_re_dev_remove()
752 list_del_rcu(&rdev->list); in bnxt_re_dev_remove()
761 struct bnxt_re_dev *rdev; in bnxt_re_dev_add() local
764 rdev = ib_alloc_device(bnxt_re_dev, ibdev); in bnxt_re_dev_add()
765 if (!rdev) { in bnxt_re_dev_add()
771 rdev->netdev = netdev; in bnxt_re_dev_add()
772 dev_hold(rdev->netdev); in bnxt_re_dev_add()
773 rdev->en_dev = en_dev; in bnxt_re_dev_add()
774 rdev->id = rdev->en_dev->pdev->devfn; in bnxt_re_dev_add()
775 INIT_LIST_HEAD(&rdev->qp_list); in bnxt_re_dev_add()
776 mutex_init(&rdev->qp_lock); in bnxt_re_dev_add()
777 atomic_set(&rdev->qp_count, 0); in bnxt_re_dev_add()
778 atomic_set(&rdev->cq_count, 0); in bnxt_re_dev_add()
779 atomic_set(&rdev->srq_count, 0); in bnxt_re_dev_add()
780 atomic_set(&rdev->mr_count, 0); in bnxt_re_dev_add()
781 atomic_set(&rdev->mw_count, 0); in bnxt_re_dev_add()
782 atomic_set(&rdev->ah_count, 0); in bnxt_re_dev_add()
783 atomic_set(&rdev->pd_count, 0); in bnxt_re_dev_add()
784 rdev->cosq[0] = 0xFFFF; in bnxt_re_dev_add()
785 rdev->cosq[1] = 0xFFFF; in bnxt_re_dev_add()
788 list_add_tail_rcu(&rdev->list, &bnxt_re_dev_list); in bnxt_re_dev_add()
790 return rdev; in bnxt_re_dev_add()
840 event.device = &qp->rdev->ibdev; in bnxt_re_handle_qp_async_event()
897 ib_event.device = &srq->rdev->ibdev; in bnxt_re_srqn_handler()
928 static u32 bnxt_re_get_nqdb_offset(struct bnxt_re_dev *rdev, u16 indx) in bnxt_re_get_nqdb_offset() argument
930 return bnxt_qplib_is_chip_gen_p5(rdev->chip_ctx) ? in bnxt_re_get_nqdb_offset()
931 (rdev->is_virtfn ? BNXT_RE_GEN_P5_VF_NQ_DB : in bnxt_re_get_nqdb_offset()
933 rdev->msix_entries[indx].db_offset; in bnxt_re_get_nqdb_offset()
936 static void bnxt_re_cleanup_res(struct bnxt_re_dev *rdev) in bnxt_re_cleanup_res() argument
940 for (i = 1; i < rdev->num_msix; i++) in bnxt_re_cleanup_res()
941 bnxt_qplib_disable_nq(&rdev->nq[i - 1]); in bnxt_re_cleanup_res()
943 if (rdev->qplib_res.rcfw) in bnxt_re_cleanup_res()
944 bnxt_qplib_cleanup_res(&rdev->qplib_res); in bnxt_re_cleanup_res()
947 static int bnxt_re_init_res(struct bnxt_re_dev *rdev) in bnxt_re_init_res() argument
953 bnxt_qplib_init_res(&rdev->qplib_res); in bnxt_re_init_res()
955 for (i = 1; i < rdev->num_msix ; i++) { in bnxt_re_init_res()
956 db_offt = bnxt_re_get_nqdb_offset(rdev, i); in bnxt_re_init_res()
957 rc = bnxt_qplib_enable_nq(rdev->en_dev->pdev, &rdev->nq[i - 1], in bnxt_re_init_res()
958 i - 1, rdev->msix_entries[i].vector, in bnxt_re_init_res()
962 ibdev_err(&rdev->ibdev, in bnxt_re_init_res()
971 bnxt_qplib_disable_nq(&rdev->nq[i]); in bnxt_re_init_res()
975 static void bnxt_re_free_nq_res(struct bnxt_re_dev *rdev) in bnxt_re_free_nq_res() argument
980 for (i = 0; i < rdev->num_msix - 1; i++) { in bnxt_re_free_nq_res()
981 type = bnxt_qplib_get_ring_type(rdev->chip_ctx); in bnxt_re_free_nq_res()
982 bnxt_re_net_ring_free(rdev, rdev->nq[i].ring_id, type); in bnxt_re_free_nq_res()
983 bnxt_qplib_free_nq(&rdev->nq[i]); in bnxt_re_free_nq_res()
984 rdev->nq[i].res = NULL; in bnxt_re_free_nq_res()
988 static void bnxt_re_free_res(struct bnxt_re_dev *rdev) in bnxt_re_free_res() argument
990 bnxt_re_free_nq_res(rdev); in bnxt_re_free_res()
992 if (rdev->qplib_res.dpi_tbl.max) { in bnxt_re_free_res()
993 bnxt_qplib_dealloc_dpi(&rdev->qplib_res, in bnxt_re_free_res()
994 &rdev->qplib_res.dpi_tbl, in bnxt_re_free_res()
995 &rdev->dpi_privileged); in bnxt_re_free_res()
997 if (rdev->qplib_res.rcfw) { in bnxt_re_free_res()
998 bnxt_qplib_free_res(&rdev->qplib_res); in bnxt_re_free_res()
999 rdev->qplib_res.rcfw = NULL; in bnxt_re_free_res()
1003 static int bnxt_re_alloc_res(struct bnxt_re_dev *rdev) in bnxt_re_alloc_res() argument
1011 rdev->qplib_res.rcfw = &rdev->rcfw; in bnxt_re_alloc_res()
1012 rc = bnxt_qplib_get_dev_attr(&rdev->rcfw, &rdev->dev_attr, in bnxt_re_alloc_res()
1013 rdev->is_virtfn); in bnxt_re_alloc_res()
1017 rc = bnxt_qplib_alloc_res(&rdev->qplib_res, rdev->en_dev->pdev, in bnxt_re_alloc_res()
1018 rdev->netdev, &rdev->dev_attr); in bnxt_re_alloc_res()
1022 rc = bnxt_qplib_alloc_dpi(&rdev->qplib_res.dpi_tbl, in bnxt_re_alloc_res()
1023 &rdev->dpi_privileged, in bnxt_re_alloc_res()
1024 rdev); in bnxt_re_alloc_res()
1028 for (i = 0; i < rdev->num_msix - 1; i++) { in bnxt_re_alloc_res()
1031 nq = &rdev->nq[i]; in bnxt_re_alloc_res()
1033 rc = bnxt_qplib_alloc_nq(&rdev->qplib_res, &rdev->nq[i]); in bnxt_re_alloc_res()
1035 ibdev_err(&rdev->ibdev, "Alloc Failed NQ%d rc:%#x", in bnxt_re_alloc_res()
1039 type = bnxt_qplib_get_ring_type(rdev->chip_ctx); in bnxt_re_alloc_res()
1041 rattr.pages = nq->hwq.pbl[rdev->nq[i].hwq.level].pg_count; in bnxt_re_alloc_res()
1045 rattr.lrid = rdev->msix_entries[i + 1].ring_idx; in bnxt_re_alloc_res()
1046 rc = bnxt_re_net_ring_alloc(rdev, &rattr, &nq->ring_id); in bnxt_re_alloc_res()
1048 ibdev_err(&rdev->ibdev, in bnxt_re_alloc_res()
1051 bnxt_qplib_free_nq(&rdev->nq[i]); in bnxt_re_alloc_res()
1059 type = bnxt_qplib_get_ring_type(rdev->chip_ctx); in bnxt_re_alloc_res()
1060 bnxt_re_net_ring_free(rdev, rdev->nq[i].ring_id, type); in bnxt_re_alloc_res()
1061 bnxt_qplib_free_nq(&rdev->nq[i]); in bnxt_re_alloc_res()
1063 bnxt_qplib_dealloc_dpi(&rdev->qplib_res, in bnxt_re_alloc_res()
1064 &rdev->qplib_res.dpi_tbl, in bnxt_re_alloc_res()
1065 &rdev->dpi_privileged); in bnxt_re_alloc_res()
1067 bnxt_qplib_free_res(&rdev->qplib_res); in bnxt_re_alloc_res()
1070 rdev->qplib_res.rcfw = NULL; in bnxt_re_alloc_res()
1094 static int bnxt_re_query_hwrm_pri2cos(struct bnxt_re_dev *rdev, u8 dir, in bnxt_re_query_hwrm_pri2cos() argument
1098 struct bnxt *bp = netdev_priv(rdev->netdev); in bnxt_re_query_hwrm_pri2cos()
1100 struct bnxt_en_dev *en_dev = rdev->en_dev; in bnxt_re_query_hwrm_pri2cos()
1110 bnxt_re_init_hwrm_hdr(rdev, (void *)&req, in bnxt_re_query_hwrm_pri2cos()
1124 ibdev_warn(&rdev->ibdev, in bnxt_re_query_hwrm_pri2cos()
1126 ibdev_warn(&rdev->ibdev, in bnxt_re_query_hwrm_pri2cos()
1137 static bool bnxt_re_is_qp1_or_shadow_qp(struct bnxt_re_dev *rdev, in bnxt_re_is_qp1_or_shadow_qp() argument
1141 (qp == rdev->gsi_ctx.gsi_sqp); in bnxt_re_is_qp1_or_shadow_qp()
1144 static void bnxt_re_dev_stop(struct bnxt_re_dev *rdev) in bnxt_re_dev_stop() argument
1151 mutex_lock(&rdev->qp_lock); in bnxt_re_dev_stop()
1152 list_for_each_entry(qp, &rdev->qp_list, list) { in bnxt_re_dev_stop()
1154 if (!bnxt_re_is_qp1_or_shadow_qp(rdev, qp)) { in bnxt_re_dev_stop()
1159 bnxt_re_dispatch_event(&rdev->ibdev, &qp->ib_qp, in bnxt_re_dev_stop()
1166 mutex_unlock(&rdev->qp_lock); in bnxt_re_dev_stop()
1169 static int bnxt_re_update_gid(struct bnxt_re_dev *rdev) in bnxt_re_update_gid() argument
1171 struct bnxt_qplib_sgid_tbl *sgid_tbl = &rdev->qplib_res.sgid_tbl; in bnxt_re_update_gid()
1176 if (!ib_device_try_get(&rdev->ibdev)) in bnxt_re_update_gid()
1180 ibdev_err(&rdev->ibdev, "QPLIB: SGID table not allocated"); in bnxt_re_update_gid()
1200 rdev->qplib_res.netdev->dev_addr); in bnxt_re_update_gid()
1203 ib_device_put(&rdev->ibdev); in bnxt_re_update_gid()
1207 static u32 bnxt_re_get_priority_mask(struct bnxt_re_dev *rdev) in bnxt_re_get_priority_mask() argument
1213 netdev = rdev->netdev; in bnxt_re_get_priority_mask()
1244 static int bnxt_re_setup_qos(struct bnxt_re_dev *rdev) in bnxt_re_setup_qos() argument
1251 prio_map = bnxt_re_get_priority_mask(rdev); in bnxt_re_setup_qos()
1253 if (prio_map == rdev->cur_prio_map) in bnxt_re_setup_qos()
1255 rdev->cur_prio_map = prio_map; in bnxt_re_setup_qos()
1257 rc = bnxt_re_query_hwrm_pri2cos(rdev, 0, &cid_map); in bnxt_re_setup_qos()
1259 ibdev_warn(&rdev->ibdev, "no cos for p_mask %x\n", prio_map); in bnxt_re_setup_qos()
1263 bnxt_re_parse_cid_map(prio_map, (u8 *)&cid_map, rdev->cosq); in bnxt_re_setup_qos()
1266 rc = bnxt_qplib_map_tc2cos(&rdev->qplib_res, rdev->cosq); in bnxt_re_setup_qos()
1268 ibdev_warn(&rdev->ibdev, "no tc for cos{%x, %x}\n", in bnxt_re_setup_qos()
1269 rdev->cosq[0], rdev->cosq[1]); in bnxt_re_setup_qos()
1276 if ((prio_map == 0 && rdev->qplib_res.prio) || in bnxt_re_setup_qos()
1277 (prio_map != 0 && !rdev->qplib_res.prio)) { in bnxt_re_setup_qos()
1278 rdev->qplib_res.prio = prio_map ? true : false; in bnxt_re_setup_qos()
1280 bnxt_re_update_gid(rdev); in bnxt_re_setup_qos()
1286 static void bnxt_re_query_hwrm_intf_version(struct bnxt_re_dev *rdev) in bnxt_re_query_hwrm_intf_version() argument
1288 struct bnxt_en_dev *en_dev = rdev->en_dev; in bnxt_re_query_hwrm_intf_version()
1295 bnxt_re_init_hwrm_hdr(rdev, (void *)&req, in bnxt_re_query_hwrm_intf_version()
1304 ibdev_err(&rdev->ibdev, "Failed to query HW version, rc = 0x%x", in bnxt_re_query_hwrm_intf_version()
1308 rdev->qplib_ctx.hwrm_intf_ver = in bnxt_re_query_hwrm_intf_version()
1315 static int bnxt_re_ib_init(struct bnxt_re_dev *rdev) in bnxt_re_ib_init() argument
1321 rc = bnxt_re_register_ib(rdev); in bnxt_re_ib_init()
1326 dev_info(rdev_to_dev(rdev), "Device registered successfully"); in bnxt_re_ib_init()
1327 ib_get_eth_speed(&rdev->ibdev, 1, &rdev->active_speed, in bnxt_re_ib_init()
1328 &rdev->active_width); in bnxt_re_ib_init()
1329 set_bit(BNXT_RE_FLAG_ISSUE_ROCE_STATS, &rdev->flags); in bnxt_re_ib_init()
1331 event = netif_running(rdev->netdev) && netif_carrier_ok(rdev->netdev) ? in bnxt_re_ib_init()
1334 bnxt_re_dispatch_event(&rdev->ibdev, NULL, 1, event); in bnxt_re_ib_init()
1339 static void bnxt_re_dev_uninit(struct bnxt_re_dev *rdev) in bnxt_re_dev_uninit() argument
1344 if (test_and_clear_bit(BNXT_RE_FLAG_QOS_WORK_REG, &rdev->flags)) in bnxt_re_dev_uninit()
1345 cancel_delayed_work_sync(&rdev->worker); in bnxt_re_dev_uninit()
1348 &rdev->flags)) in bnxt_re_dev_uninit()
1349 bnxt_re_cleanup_res(rdev); in bnxt_re_dev_uninit()
1350 if (test_and_clear_bit(BNXT_RE_FLAG_RESOURCES_ALLOCATED, &rdev->flags)) in bnxt_re_dev_uninit()
1351 bnxt_re_free_res(rdev); in bnxt_re_dev_uninit()
1353 if (test_and_clear_bit(BNXT_RE_FLAG_RCFW_CHANNEL_EN, &rdev->flags)) { in bnxt_re_dev_uninit()
1354 rc = bnxt_qplib_deinit_rcfw(&rdev->rcfw); in bnxt_re_dev_uninit()
1356 ibdev_warn(&rdev->ibdev, in bnxt_re_dev_uninit()
1358 bnxt_re_net_stats_ctx_free(rdev, rdev->qplib_ctx.stats.fw_id); in bnxt_re_dev_uninit()
1359 bnxt_qplib_free_ctx(&rdev->qplib_res, &rdev->qplib_ctx); in bnxt_re_dev_uninit()
1360 bnxt_qplib_disable_rcfw_channel(&rdev->rcfw); in bnxt_re_dev_uninit()
1361 type = bnxt_qplib_get_ring_type(rdev->chip_ctx); in bnxt_re_dev_uninit()
1362 bnxt_re_net_ring_free(rdev, rdev->rcfw.creq.ring_id, type); in bnxt_re_dev_uninit()
1363 bnxt_qplib_free_rcfw_channel(&rdev->rcfw); in bnxt_re_dev_uninit()
1365 if (test_and_clear_bit(BNXT_RE_FLAG_GOT_MSIX, &rdev->flags)) { in bnxt_re_dev_uninit()
1366 rc = bnxt_re_free_msix(rdev); in bnxt_re_dev_uninit()
1368 ibdev_warn(&rdev->ibdev, in bnxt_re_dev_uninit()
1372 bnxt_re_destroy_chip_ctx(rdev); in bnxt_re_dev_uninit()
1373 if (test_and_clear_bit(BNXT_RE_FLAG_NETDEV_REGISTERED, &rdev->flags)) { in bnxt_re_dev_uninit()
1374 rc = bnxt_re_unregister_netdev(rdev); in bnxt_re_dev_uninit()
1376 ibdev_warn(&rdev->ibdev, in bnxt_re_dev_uninit()
1384 struct bnxt_re_dev *rdev = container_of(work, struct bnxt_re_dev, in bnxt_re_worker() local
1387 bnxt_re_setup_qos(rdev); in bnxt_re_worker()
1388 schedule_delayed_work(&rdev->worker, msecs_to_jiffies(30000)); in bnxt_re_worker()
1391 static int bnxt_re_dev_init(struct bnxt_re_dev *rdev, u8 wqe_mode) in bnxt_re_dev_init() argument
1402 rc = bnxt_re_register_netdev(rdev); in bnxt_re_dev_init()
1404 ibdev_err(&rdev->ibdev, in bnxt_re_dev_init()
1408 set_bit(BNXT_RE_FLAG_NETDEV_REGISTERED, &rdev->flags); in bnxt_re_dev_init()
1410 rc = bnxt_re_setup_chip_ctx(rdev, wqe_mode); in bnxt_re_dev_init()
1412 ibdev_err(&rdev->ibdev, "Failed to get chip context\n"); in bnxt_re_dev_init()
1417 bnxt_re_get_sriov_func_type(rdev); in bnxt_re_dev_init()
1419 rc = bnxt_re_request_msix(rdev); in bnxt_re_dev_init()
1421 ibdev_err(&rdev->ibdev, in bnxt_re_dev_init()
1426 set_bit(BNXT_RE_FLAG_GOT_MSIX, &rdev->flags); in bnxt_re_dev_init()
1428 bnxt_re_query_hwrm_intf_version(rdev); in bnxt_re_dev_init()
1433 rc = bnxt_qplib_alloc_rcfw_channel(&rdev->qplib_res, &rdev->rcfw, in bnxt_re_dev_init()
1434 &rdev->qplib_ctx, in bnxt_re_dev_init()
1437 ibdev_err(&rdev->ibdev, in bnxt_re_dev_init()
1442 type = bnxt_qplib_get_ring_type(rdev->chip_ctx); in bnxt_re_dev_init()
1443 creq = &rdev->rcfw.creq; in bnxt_re_dev_init()
1449 rattr.lrid = rdev->msix_entries[BNXT_RE_AEQ_IDX].ring_idx; in bnxt_re_dev_init()
1450 rc = bnxt_re_net_ring_alloc(rdev, &rattr, &creq->ring_id); in bnxt_re_dev_init()
1452 ibdev_err(&rdev->ibdev, "Failed to allocate CREQ: %#x\n", rc); in bnxt_re_dev_init()
1455 db_offt = bnxt_re_get_nqdb_offset(rdev, BNXT_RE_AEQ_IDX); in bnxt_re_dev_init()
1456 vid = rdev->msix_entries[BNXT_RE_AEQ_IDX].vector; in bnxt_re_dev_init()
1457 rc = bnxt_qplib_enable_rcfw_channel(&rdev->rcfw, in bnxt_re_dev_init()
1458 vid, db_offt, rdev->is_virtfn, in bnxt_re_dev_init()
1461 ibdev_err(&rdev->ibdev, "Failed to enable RCFW channel: %#x\n", in bnxt_re_dev_init()
1466 rc = bnxt_qplib_get_dev_attr(&rdev->rcfw, &rdev->dev_attr, in bnxt_re_dev_init()
1467 rdev->is_virtfn); in bnxt_re_dev_init()
1471 bnxt_re_set_resource_limits(rdev); in bnxt_re_dev_init()
1473 rc = bnxt_qplib_alloc_ctx(&rdev->qplib_res, &rdev->qplib_ctx, 0, in bnxt_re_dev_init()
1474 bnxt_qplib_is_chip_gen_p5(rdev->chip_ctx)); in bnxt_re_dev_init()
1476 ibdev_err(&rdev->ibdev, in bnxt_re_dev_init()
1480 rc = bnxt_re_net_stats_ctx_alloc(rdev, in bnxt_re_dev_init()
1481 rdev->qplib_ctx.stats.dma_map, in bnxt_re_dev_init()
1482 &rdev->qplib_ctx.stats.fw_id); in bnxt_re_dev_init()
1484 ibdev_err(&rdev->ibdev, in bnxt_re_dev_init()
1489 rc = bnxt_qplib_init_rcfw(&rdev->rcfw, &rdev->qplib_ctx, in bnxt_re_dev_init()
1490 rdev->is_virtfn); in bnxt_re_dev_init()
1492 ibdev_err(&rdev->ibdev, in bnxt_re_dev_init()
1496 set_bit(BNXT_RE_FLAG_RCFW_CHANNEL_EN, &rdev->flags); in bnxt_re_dev_init()
1499 rc = bnxt_re_alloc_res(rdev); in bnxt_re_dev_init()
1501 ibdev_err(&rdev->ibdev, in bnxt_re_dev_init()
1505 set_bit(BNXT_RE_FLAG_RESOURCES_ALLOCATED, &rdev->flags); in bnxt_re_dev_init()
1506 rc = bnxt_re_init_res(rdev); in bnxt_re_dev_init()
1508 ibdev_err(&rdev->ibdev, in bnxt_re_dev_init()
1513 set_bit(BNXT_RE_FLAG_RESOURCES_INITIALIZED, &rdev->flags); in bnxt_re_dev_init()
1515 if (!rdev->is_virtfn) { in bnxt_re_dev_init()
1516 rc = bnxt_re_setup_qos(rdev); in bnxt_re_dev_init()
1518 ibdev_info(&rdev->ibdev, in bnxt_re_dev_init()
1521 INIT_DELAYED_WORK(&rdev->worker, bnxt_re_worker); in bnxt_re_dev_init()
1522 set_bit(BNXT_RE_FLAG_QOS_WORK_REG, &rdev->flags); in bnxt_re_dev_init()
1523 schedule_delayed_work(&rdev->worker, msecs_to_jiffies(30000)); in bnxt_re_dev_init()
1528 bnxt_re_net_stats_ctx_free(rdev, rdev->qplib_ctx.stats.fw_id); in bnxt_re_dev_init()
1530 bnxt_qplib_free_ctx(&rdev->qplib_res, &rdev->qplib_ctx); in bnxt_re_dev_init()
1532 bnxt_qplib_disable_rcfw_channel(&rdev->rcfw); in bnxt_re_dev_init()
1534 type = bnxt_qplib_get_ring_type(rdev->chip_ctx); in bnxt_re_dev_init()
1535 bnxt_re_net_ring_free(rdev, rdev->rcfw.creq.ring_id, type); in bnxt_re_dev_init()
1537 bnxt_qplib_free_rcfw_channel(&rdev->rcfw); in bnxt_re_dev_init()
1539 bnxt_re_dev_uninit(rdev); in bnxt_re_dev_init()
1544 static void bnxt_re_dev_unreg(struct bnxt_re_dev *rdev) in bnxt_re_dev_unreg() argument
1546 struct net_device *netdev = rdev->netdev; in bnxt_re_dev_unreg()
1548 bnxt_re_dev_remove(rdev); in bnxt_re_dev_unreg()
1554 static int bnxt_re_dev_reg(struct bnxt_re_dev **rdev, struct net_device *netdev) in bnxt_re_dev_reg() argument
1565 ibdev_err(&(*rdev)->ibdev, "%s: Failed to probe\n", in bnxt_re_dev_reg()
1570 *rdev = bnxt_re_dev_add(netdev, en_dev); in bnxt_re_dev_reg()
1571 if (!*rdev) { in bnxt_re_dev_reg()
1580 static void bnxt_re_remove_device(struct bnxt_re_dev *rdev) in bnxt_re_remove_device() argument
1582 bnxt_re_dev_uninit(rdev); in bnxt_re_remove_device()
1583 pci_dev_put(rdev->en_dev->pdev); in bnxt_re_remove_device()
1584 bnxt_re_dev_unreg(rdev); in bnxt_re_remove_device()
1587 static int bnxt_re_add_device(struct bnxt_re_dev **rdev, in bnxt_re_add_device() argument
1592 rc = bnxt_re_dev_reg(rdev, netdev); in bnxt_re_add_device()
1601 pci_dev_get((*rdev)->en_dev->pdev); in bnxt_re_add_device()
1602 rc = bnxt_re_dev_init(*rdev, wqe_mode); in bnxt_re_add_device()
1604 pci_dev_put((*rdev)->en_dev->pdev); in bnxt_re_add_device()
1605 bnxt_re_dev_unreg(*rdev); in bnxt_re_add_device()
1613 struct bnxt_re_dev *rdev = in bnxt_re_dealloc_driver() local
1616 dev_info(rdev_to_dev(rdev), "Unregistering Device"); in bnxt_re_dealloc_driver()
1619 bnxt_re_remove_device(rdev); in bnxt_re_dealloc_driver()
1627 struct bnxt_re_dev *rdev; in bnxt_re_task() local
1631 rdev = re_work->rdev; in bnxt_re_task()
1634 rc = bnxt_re_ib_init(rdev); in bnxt_re_task()
1636 ibdev_err(&rdev->ibdev, in bnxt_re_task()
1639 bnxt_re_remove_device(rdev); in bnxt_re_task()
1646 if (!ib_device_try_get(&rdev->ibdev)) in bnxt_re_task()
1651 bnxt_re_dispatch_event(&rdev->ibdev, NULL, 1, in bnxt_re_task()
1655 bnxt_re_dev_stop(rdev); in bnxt_re_task()
1658 if (!netif_carrier_ok(rdev->netdev)) in bnxt_re_task()
1659 bnxt_re_dev_stop(rdev); in bnxt_re_task()
1660 else if (netif_carrier_ok(rdev->netdev)) in bnxt_re_task()
1661 bnxt_re_dispatch_event(&rdev->ibdev, NULL, 1, in bnxt_re_task()
1663 ib_get_eth_speed(&rdev->ibdev, 1, &rdev->active_speed, in bnxt_re_task()
1664 &rdev->active_width); in bnxt_re_task()
1669 ib_device_put(&rdev->ibdev); in bnxt_re_task()
1671 put_device(&rdev->ibdev.dev); in bnxt_re_task()
1694 struct bnxt_re_dev *rdev; in bnxt_re_netdev_event() local
1703 rdev = bnxt_re_from_netdev(real_dev); in bnxt_re_netdev_event()
1704 if (!rdev && event != NETDEV_REGISTER) in bnxt_re_netdev_event()
1712 if (rdev) in bnxt_re_netdev_event()
1714 rc = bnxt_re_add_device(&rdev, real_dev, in bnxt_re_netdev_event()
1722 ib_unregister_device_queued(&rdev->ibdev); in bnxt_re_netdev_event()
1733 get_device(&rdev->ibdev.dev); in bnxt_re_netdev_event()
1734 re_work->rdev = rdev; in bnxt_re_netdev_event()
1744 if (rdev && release) in bnxt_re_netdev_event()
1745 ib_device_put(&rdev->ibdev); in bnxt_re_netdev_event()
1781 struct bnxt_re_dev *rdev; in bnxt_re_mod_exit() local
1786 list_for_each_entry(rdev, &bnxt_re_dev_list, list) { in bnxt_re_mod_exit()
1792 if (rdev->is_virtfn) in bnxt_re_mod_exit()
1793 ib_unregister_device(&rdev->ibdev); in bnxt_re_mod_exit()