Lines Matching refs:rdev
81 static void bnxt_re_remove_device(struct bnxt_re_dev *rdev);
85 static void bnxt_re_set_drv_mode(struct bnxt_re_dev *rdev, u8 mode) in bnxt_re_set_drv_mode() argument
89 cctx = rdev->chip_ctx; in bnxt_re_set_drv_mode()
90 cctx->modes.wqe_mode = bnxt_qplib_is_chip_gen_p5(rdev->chip_ctx) ? in bnxt_re_set_drv_mode()
94 static void bnxt_re_destroy_chip_ctx(struct bnxt_re_dev *rdev) in bnxt_re_destroy_chip_ctx() argument
98 if (!rdev->chip_ctx) in bnxt_re_destroy_chip_ctx()
100 chip_ctx = rdev->chip_ctx; in bnxt_re_destroy_chip_ctx()
101 rdev->chip_ctx = NULL; in bnxt_re_destroy_chip_ctx()
102 rdev->rcfw.res = NULL; in bnxt_re_destroy_chip_ctx()
103 rdev->qplib_res.cctx = NULL; in bnxt_re_destroy_chip_ctx()
104 rdev->qplib_res.pdev = NULL; in bnxt_re_destroy_chip_ctx()
105 rdev->qplib_res.netdev = NULL; in bnxt_re_destroy_chip_ctx()
109 static int bnxt_re_setup_chip_ctx(struct bnxt_re_dev *rdev, u8 wqe_mode) in bnxt_re_setup_chip_ctx() argument
115 en_dev = rdev->en_dev; in bnxt_re_setup_chip_ctx()
124 rdev->chip_ctx = chip_ctx; in bnxt_re_setup_chip_ctx()
127 rdev->qplib_res.cctx = rdev->chip_ctx; in bnxt_re_setup_chip_ctx()
128 rdev->rcfw.res = &rdev->qplib_res; in bnxt_re_setup_chip_ctx()
130 bnxt_re_set_drv_mode(rdev, wqe_mode); in bnxt_re_setup_chip_ctx()
136 static void bnxt_re_get_sriov_func_type(struct bnxt_re_dev *rdev) in bnxt_re_get_sriov_func_type() argument
140 bp = netdev_priv(rdev->en_dev->net); in bnxt_re_get_sriov_func_type()
142 rdev->is_virtfn = 1; in bnxt_re_get_sriov_func_type()
150 static void bnxt_re_limit_pf_res(struct bnxt_re_dev *rdev) in bnxt_re_limit_pf_res() argument
156 attr = &rdev->dev_attr; in bnxt_re_limit_pf_res()
157 ctx = &rdev->qplib_ctx; in bnxt_re_limit_pf_res()
167 if (!bnxt_qplib_is_chip_gen_p5(rdev->chip_ctx)) in bnxt_re_limit_pf_res()
169 rdev->qplib_ctx.tqm_ctx.qcount[i] = in bnxt_re_limit_pf_res()
170 rdev->dev_attr.tqm_alloc_reqs[i]; in bnxt_re_limit_pf_res()
209 static void bnxt_re_set_resource_limits(struct bnxt_re_dev *rdev) in bnxt_re_set_resource_limits() argument
213 memset(&rdev->qplib_ctx.vf_res, 0, sizeof(struct bnxt_qplib_vf_res)); in bnxt_re_set_resource_limits()
214 bnxt_re_limit_pf_res(rdev); in bnxt_re_set_resource_limits()
216 num_vfs = bnxt_qplib_is_chip_gen_p5(rdev->chip_ctx) ? in bnxt_re_set_resource_limits()
217 BNXT_RE_GEN_P5_MAX_VF : rdev->num_vfs; in bnxt_re_set_resource_limits()
219 bnxt_re_limit_vf_res(&rdev->qplib_ctx, num_vfs); in bnxt_re_set_resource_limits()
233 struct bnxt_re_dev *rdev = p; in bnxt_re_sriov_config() local
235 if (!rdev) in bnxt_re_sriov_config()
238 rdev->num_vfs = num_vfs; in bnxt_re_sriov_config()
239 if (!bnxt_qplib_is_chip_gen_p5(rdev->chip_ctx)) { in bnxt_re_sriov_config()
240 bnxt_re_set_resource_limits(rdev); in bnxt_re_sriov_config()
241 bnxt_qplib_set_func_resources(&rdev->qplib_res, &rdev->rcfw, in bnxt_re_sriov_config()
242 &rdev->qplib_ctx); in bnxt_re_sriov_config()
248 struct bnxt_re_dev *rdev = p; in bnxt_re_shutdown() local
250 if (!rdev) in bnxt_re_shutdown()
254 bnxt_re_stop_irq(rdev); in bnxt_re_shutdown()
255 ib_unregister_device_queued(&rdev->ibdev); in bnxt_re_shutdown()
260 struct bnxt_re_dev *rdev = (struct bnxt_re_dev *)handle; in bnxt_re_stop_irq() local
261 struct bnxt_qplib_rcfw *rcfw = &rdev->rcfw; in bnxt_re_stop_irq()
265 for (indx = BNXT_RE_NQ_IDX; indx < rdev->num_msix; indx++) { in bnxt_re_stop_irq()
266 nq = &rdev->nq[indx - 1]; in bnxt_re_stop_irq()
275 struct bnxt_re_dev *rdev = (struct bnxt_re_dev *)handle; in bnxt_re_start_irq() local
276 struct bnxt_msix_entry *msix_ent = rdev->msix_entries; in bnxt_re_start_irq()
277 struct bnxt_qplib_rcfw *rcfw = &rdev->rcfw; in bnxt_re_start_irq()
287 ibdev_err(&rdev->ibdev, "Failed to re-start IRQs\n"); in bnxt_re_start_irq()
294 for (indx = 0; indx < rdev->num_msix; indx++) in bnxt_re_start_irq()
295 rdev->msix_entries[indx].vector = ent[indx].vector; in bnxt_re_start_irq()
299 for (indx = BNXT_RE_NQ_IDX ; indx < rdev->num_msix; indx++) { in bnxt_re_start_irq()
300 nq = &rdev->nq[indx - 1]; in bnxt_re_start_irq()
304 ibdev_warn(&rdev->ibdev, "Failed to reinit NQ index %d\n", in bnxt_re_start_irq()
324 static int bnxt_re_unregister_netdev(struct bnxt_re_dev *rdev) in bnxt_re_unregister_netdev() argument
329 if (!rdev) in bnxt_re_unregister_netdev()
332 en_dev = rdev->en_dev; in bnxt_re_unregister_netdev()
334 rc = en_dev->en_ops->bnxt_unregister_device(rdev->en_dev, in bnxt_re_unregister_netdev()
339 static int bnxt_re_register_netdev(struct bnxt_re_dev *rdev) in bnxt_re_register_netdev() argument
344 if (!rdev) in bnxt_re_register_netdev()
347 en_dev = rdev->en_dev; in bnxt_re_register_netdev()
350 &bnxt_re_ulp_ops, rdev); in bnxt_re_register_netdev()
351 rdev->qplib_res.pdev = rdev->en_dev->pdev; in bnxt_re_register_netdev()
355 static int bnxt_re_free_msix(struct bnxt_re_dev *rdev) in bnxt_re_free_msix() argument
360 if (!rdev) in bnxt_re_free_msix()
363 en_dev = rdev->en_dev; in bnxt_re_free_msix()
366 rc = en_dev->en_ops->bnxt_free_msix(rdev->en_dev, BNXT_ROCE_ULP); in bnxt_re_free_msix()
371 static int bnxt_re_request_msix(struct bnxt_re_dev *rdev) in bnxt_re_request_msix() argument
376 if (!rdev) in bnxt_re_request_msix()
379 en_dev = rdev->en_dev; in bnxt_re_request_msix()
384 rdev->msix_entries, in bnxt_re_request_msix()
391 ibdev_warn(&rdev->ibdev, in bnxt_re_request_msix()
395 rdev->num_msix = num_msix_got; in bnxt_re_request_msix()
400 static void bnxt_re_init_hwrm_hdr(struct bnxt_re_dev *rdev, struct input *hdr, in bnxt_re_init_hwrm_hdr() argument
419 static int bnxt_re_net_ring_free(struct bnxt_re_dev *rdev, in bnxt_re_net_ring_free() argument
422 struct bnxt_en_dev *en_dev = rdev->en_dev; in bnxt_re_net_ring_free()
433 bnxt_re_init_hwrm_hdr(rdev, (void *)&req, HWRM_RING_FREE, -1, -1); in bnxt_re_net_ring_free()
440 ibdev_err(&rdev->ibdev, "Failed to free HW ring:%d :%#x", in bnxt_re_net_ring_free()
445 static int bnxt_re_net_ring_alloc(struct bnxt_re_dev *rdev, in bnxt_re_net_ring_alloc() argument
449 struct bnxt_en_dev *en_dev = rdev->en_dev; in bnxt_re_net_ring_alloc()
459 bnxt_re_init_hwrm_hdr(rdev, (void *)&req, HWRM_RING_ALLOC, -1, -1); in bnxt_re_net_ring_alloc()
482 static int bnxt_re_net_stats_ctx_free(struct bnxt_re_dev *rdev, in bnxt_re_net_stats_ctx_free() argument
485 struct bnxt_en_dev *en_dev = rdev->en_dev; in bnxt_re_net_stats_ctx_free()
495 bnxt_re_init_hwrm_hdr(rdev, (void *)&req, HWRM_STAT_CTX_FREE, -1, -1); in bnxt_re_net_stats_ctx_free()
501 ibdev_err(&rdev->ibdev, "Failed to free HW stats context %#x", in bnxt_re_net_stats_ctx_free()
507 static int bnxt_re_net_stats_ctx_alloc(struct bnxt_re_dev *rdev, in bnxt_re_net_stats_ctx_alloc() argument
511 struct bnxt_qplib_chip_ctx *chip_ctx = rdev->chip_ctx; in bnxt_re_net_stats_ctx_alloc()
514 struct bnxt_en_dev *en_dev = rdev->en_dev; in bnxt_re_net_stats_ctx_alloc()
525 bnxt_re_init_hwrm_hdr(rdev, (void *)&req, HWRM_STAT_CTX_ALLOC, -1, -1); in bnxt_re_net_stats_ctx_alloc()
610 struct bnxt_re_dev *rdev = in hw_rev_show() local
613 return scnprintf(buf, PAGE_SIZE, "0x%x\n", rdev->en_dev->pdev->vendor); in hw_rev_show()
620 struct bnxt_re_dev *rdev = in hca_type_show() local
623 return scnprintf(buf, PAGE_SIZE, "%s\n", rdev->ibdev.node_desc); in hca_type_show()
689 static int bnxt_re_register_ib(struct bnxt_re_dev *rdev) in bnxt_re_register_ib() argument
691 struct ib_device *ibdev = &rdev->ibdev; in bnxt_re_register_ib()
700 bnxt_qplib_get_guid(rdev->netdev->dev_addr, (u8 *)&ibdev->node_guid); in bnxt_re_register_ib()
702 ibdev->num_comp_vectors = rdev->num_msix - 1; in bnxt_re_register_ib()
703 ibdev->dev.parent = &rdev->en_dev->pdev->dev; in bnxt_re_register_ib()
737 ret = ib_device_set_netdev(&rdev->ibdev, rdev->netdev, 1); in bnxt_re_register_ib()
741 dma_set_max_seg_size(&rdev->en_dev->pdev->dev, UINT_MAX); in bnxt_re_register_ib()
742 return ib_register_device(ibdev, "bnxt_re%d", &rdev->en_dev->pdev->dev); in bnxt_re_register_ib()
745 static void bnxt_re_dev_remove(struct bnxt_re_dev *rdev) in bnxt_re_dev_remove() argument
747 dev_put(rdev->netdev); in bnxt_re_dev_remove()
748 rdev->netdev = NULL; in bnxt_re_dev_remove()
750 list_del_rcu(&rdev->list); in bnxt_re_dev_remove()
759 struct bnxt_re_dev *rdev; in bnxt_re_dev_add() local
762 rdev = ib_alloc_device(bnxt_re_dev, ibdev); in bnxt_re_dev_add()
763 if (!rdev) { in bnxt_re_dev_add()
769 rdev->netdev = netdev; in bnxt_re_dev_add()
770 dev_hold(rdev->netdev); in bnxt_re_dev_add()
771 rdev->en_dev = en_dev; in bnxt_re_dev_add()
772 rdev->id = rdev->en_dev->pdev->devfn; in bnxt_re_dev_add()
773 INIT_LIST_HEAD(&rdev->qp_list); in bnxt_re_dev_add()
774 mutex_init(&rdev->qp_lock); in bnxt_re_dev_add()
775 atomic_set(&rdev->qp_count, 0); in bnxt_re_dev_add()
776 atomic_set(&rdev->cq_count, 0); in bnxt_re_dev_add()
777 atomic_set(&rdev->srq_count, 0); in bnxt_re_dev_add()
778 atomic_set(&rdev->mr_count, 0); in bnxt_re_dev_add()
779 atomic_set(&rdev->mw_count, 0); in bnxt_re_dev_add()
780 rdev->cosq[0] = 0xFFFF; in bnxt_re_dev_add()
781 rdev->cosq[1] = 0xFFFF; in bnxt_re_dev_add()
784 list_add_tail_rcu(&rdev->list, &bnxt_re_dev_list); in bnxt_re_dev_add()
786 return rdev; in bnxt_re_dev_add()
836 event.device = &qp->rdev->ibdev; in bnxt_re_handle_qp_async_event()
900 ib_event.device = &srq->rdev->ibdev; in bnxt_re_srqn_handler()
937 static u32 bnxt_re_get_nqdb_offset(struct bnxt_re_dev *rdev, u16 indx) in bnxt_re_get_nqdb_offset() argument
939 return bnxt_qplib_is_chip_gen_p5(rdev->chip_ctx) ? in bnxt_re_get_nqdb_offset()
940 (rdev->is_virtfn ? BNXT_RE_GEN_P5_VF_NQ_DB : in bnxt_re_get_nqdb_offset()
942 rdev->msix_entries[indx].db_offset; in bnxt_re_get_nqdb_offset()
945 static void bnxt_re_cleanup_res(struct bnxt_re_dev *rdev) in bnxt_re_cleanup_res() argument
949 for (i = 1; i < rdev->num_msix; i++) in bnxt_re_cleanup_res()
950 bnxt_qplib_disable_nq(&rdev->nq[i - 1]); in bnxt_re_cleanup_res()
952 if (rdev->qplib_res.rcfw) in bnxt_re_cleanup_res()
953 bnxt_qplib_cleanup_res(&rdev->qplib_res); in bnxt_re_cleanup_res()
956 static int bnxt_re_init_res(struct bnxt_re_dev *rdev) in bnxt_re_init_res() argument
962 bnxt_qplib_init_res(&rdev->qplib_res); in bnxt_re_init_res()
964 for (i = 1; i < rdev->num_msix ; i++) { in bnxt_re_init_res()
965 db_offt = bnxt_re_get_nqdb_offset(rdev, i); in bnxt_re_init_res()
966 rc = bnxt_qplib_enable_nq(rdev->en_dev->pdev, &rdev->nq[i - 1], in bnxt_re_init_res()
967 i - 1, rdev->msix_entries[i].vector, in bnxt_re_init_res()
971 ibdev_err(&rdev->ibdev, in bnxt_re_init_res()
980 bnxt_qplib_disable_nq(&rdev->nq[i]); in bnxt_re_init_res()
984 static void bnxt_re_free_nq_res(struct bnxt_re_dev *rdev) in bnxt_re_free_nq_res() argument
989 for (i = 0; i < rdev->num_msix - 1; i++) { in bnxt_re_free_nq_res()
990 type = bnxt_qplib_get_ring_type(rdev->chip_ctx); in bnxt_re_free_nq_res()
991 bnxt_re_net_ring_free(rdev, rdev->nq[i].ring_id, type); in bnxt_re_free_nq_res()
992 bnxt_qplib_free_nq(&rdev->nq[i]); in bnxt_re_free_nq_res()
993 rdev->nq[i].res = NULL; in bnxt_re_free_nq_res()
997 static void bnxt_re_free_res(struct bnxt_re_dev *rdev) in bnxt_re_free_res() argument
999 bnxt_re_free_nq_res(rdev); in bnxt_re_free_res()
1001 if (rdev->qplib_res.dpi_tbl.max) { in bnxt_re_free_res()
1002 bnxt_qplib_dealloc_dpi(&rdev->qplib_res, in bnxt_re_free_res()
1003 &rdev->qplib_res.dpi_tbl, in bnxt_re_free_res()
1004 &rdev->dpi_privileged); in bnxt_re_free_res()
1006 if (rdev->qplib_res.rcfw) { in bnxt_re_free_res()
1007 bnxt_qplib_free_res(&rdev->qplib_res); in bnxt_re_free_res()
1008 rdev->qplib_res.rcfw = NULL; in bnxt_re_free_res()
1012 static int bnxt_re_alloc_res(struct bnxt_re_dev *rdev) in bnxt_re_alloc_res() argument
1020 rdev->qplib_res.rcfw = &rdev->rcfw; in bnxt_re_alloc_res()
1021 rc = bnxt_qplib_get_dev_attr(&rdev->rcfw, &rdev->dev_attr, in bnxt_re_alloc_res()
1022 rdev->is_virtfn); in bnxt_re_alloc_res()
1026 rc = bnxt_qplib_alloc_res(&rdev->qplib_res, rdev->en_dev->pdev, in bnxt_re_alloc_res()
1027 rdev->netdev, &rdev->dev_attr); in bnxt_re_alloc_res()
1031 rc = bnxt_qplib_alloc_dpi(&rdev->qplib_res.dpi_tbl, in bnxt_re_alloc_res()
1032 &rdev->dpi_privileged, in bnxt_re_alloc_res()
1033 rdev); in bnxt_re_alloc_res()
1037 for (i = 0; i < rdev->num_msix - 1; i++) { in bnxt_re_alloc_res()
1040 nq = &rdev->nq[i]; in bnxt_re_alloc_res()
1042 rc = bnxt_qplib_alloc_nq(&rdev->qplib_res, &rdev->nq[i]); in bnxt_re_alloc_res()
1044 ibdev_err(&rdev->ibdev, "Alloc Failed NQ%d rc:%#x", in bnxt_re_alloc_res()
1048 type = bnxt_qplib_get_ring_type(rdev->chip_ctx); in bnxt_re_alloc_res()
1050 rattr.pages = nq->hwq.pbl[rdev->nq[i].hwq.level].pg_count; in bnxt_re_alloc_res()
1054 rattr.lrid = rdev->msix_entries[i + 1].ring_idx; in bnxt_re_alloc_res()
1055 rc = bnxt_re_net_ring_alloc(rdev, &rattr, &nq->ring_id); in bnxt_re_alloc_res()
1057 ibdev_err(&rdev->ibdev, in bnxt_re_alloc_res()
1060 bnxt_qplib_free_nq(&rdev->nq[i]); in bnxt_re_alloc_res()
1068 type = bnxt_qplib_get_ring_type(rdev->chip_ctx); in bnxt_re_alloc_res()
1069 bnxt_re_net_ring_free(rdev, rdev->nq[i].ring_id, type); in bnxt_re_alloc_res()
1070 bnxt_qplib_free_nq(&rdev->nq[i]); in bnxt_re_alloc_res()
1072 bnxt_qplib_dealloc_dpi(&rdev->qplib_res, in bnxt_re_alloc_res()
1073 &rdev->qplib_res.dpi_tbl, in bnxt_re_alloc_res()
1074 &rdev->dpi_privileged); in bnxt_re_alloc_res()
1076 bnxt_qplib_free_res(&rdev->qplib_res); in bnxt_re_alloc_res()
1079 rdev->qplib_res.rcfw = NULL; in bnxt_re_alloc_res()
1103 static int bnxt_re_query_hwrm_pri2cos(struct bnxt_re_dev *rdev, u8 dir, in bnxt_re_query_hwrm_pri2cos() argument
1107 struct bnxt *bp = netdev_priv(rdev->netdev); in bnxt_re_query_hwrm_pri2cos()
1109 struct bnxt_en_dev *en_dev = rdev->en_dev; in bnxt_re_query_hwrm_pri2cos()
1119 bnxt_re_init_hwrm_hdr(rdev, (void *)&req, in bnxt_re_query_hwrm_pri2cos()
1133 ibdev_warn(&rdev->ibdev, in bnxt_re_query_hwrm_pri2cos()
1135 ibdev_warn(&rdev->ibdev, in bnxt_re_query_hwrm_pri2cos()
1146 static bool bnxt_re_is_qp1_or_shadow_qp(struct bnxt_re_dev *rdev, in bnxt_re_is_qp1_or_shadow_qp() argument
1150 (qp == rdev->gsi_ctx.gsi_sqp); in bnxt_re_is_qp1_or_shadow_qp()
1153 static void bnxt_re_dev_stop(struct bnxt_re_dev *rdev) in bnxt_re_dev_stop() argument
1160 mutex_lock(&rdev->qp_lock); in bnxt_re_dev_stop()
1161 list_for_each_entry(qp, &rdev->qp_list, list) { in bnxt_re_dev_stop()
1163 if (!bnxt_re_is_qp1_or_shadow_qp(rdev, qp)) { in bnxt_re_dev_stop()
1168 bnxt_re_dispatch_event(&rdev->ibdev, &qp->ib_qp, in bnxt_re_dev_stop()
1175 mutex_unlock(&rdev->qp_lock); in bnxt_re_dev_stop()
1178 static int bnxt_re_update_gid(struct bnxt_re_dev *rdev) in bnxt_re_update_gid() argument
1180 struct bnxt_qplib_sgid_tbl *sgid_tbl = &rdev->qplib_res.sgid_tbl; in bnxt_re_update_gid()
1185 if (!ib_device_try_get(&rdev->ibdev)) in bnxt_re_update_gid()
1189 ibdev_err(&rdev->ibdev, "QPLIB: SGID table not allocated"); in bnxt_re_update_gid()
1209 rdev->qplib_res.netdev->dev_addr); in bnxt_re_update_gid()
1212 ib_device_put(&rdev->ibdev); in bnxt_re_update_gid()
1216 static u32 bnxt_re_get_priority_mask(struct bnxt_re_dev *rdev) in bnxt_re_get_priority_mask() argument
1222 netdev = rdev->netdev; in bnxt_re_get_priority_mask()
1253 static int bnxt_re_setup_qos(struct bnxt_re_dev *rdev) in bnxt_re_setup_qos() argument
1260 prio_map = bnxt_re_get_priority_mask(rdev); in bnxt_re_setup_qos()
1262 if (prio_map == rdev->cur_prio_map) in bnxt_re_setup_qos()
1264 rdev->cur_prio_map = prio_map; in bnxt_re_setup_qos()
1266 rc = bnxt_re_query_hwrm_pri2cos(rdev, 0, &cid_map); in bnxt_re_setup_qos()
1268 ibdev_warn(&rdev->ibdev, "no cos for p_mask %x\n", prio_map); in bnxt_re_setup_qos()
1272 bnxt_re_parse_cid_map(prio_map, (u8 *)&cid_map, rdev->cosq); in bnxt_re_setup_qos()
1275 rc = bnxt_qplib_map_tc2cos(&rdev->qplib_res, rdev->cosq); in bnxt_re_setup_qos()
1277 ibdev_warn(&rdev->ibdev, "no tc for cos{%x, %x}\n", in bnxt_re_setup_qos()
1278 rdev->cosq[0], rdev->cosq[1]); in bnxt_re_setup_qos()
1285 if ((prio_map == 0 && rdev->qplib_res.prio) || in bnxt_re_setup_qos()
1286 (prio_map != 0 && !rdev->qplib_res.prio)) { in bnxt_re_setup_qos()
1287 rdev->qplib_res.prio = prio_map ? true : false; in bnxt_re_setup_qos()
1289 bnxt_re_update_gid(rdev); in bnxt_re_setup_qos()
1295 static void bnxt_re_query_hwrm_intf_version(struct bnxt_re_dev *rdev) in bnxt_re_query_hwrm_intf_version() argument
1297 struct bnxt_en_dev *en_dev = rdev->en_dev; in bnxt_re_query_hwrm_intf_version()
1304 bnxt_re_init_hwrm_hdr(rdev, (void *)&req, in bnxt_re_query_hwrm_intf_version()
1313 ibdev_err(&rdev->ibdev, "Failed to query HW version, rc = 0x%x", in bnxt_re_query_hwrm_intf_version()
1317 rdev->qplib_ctx.hwrm_intf_ver = in bnxt_re_query_hwrm_intf_version()
1324 static int bnxt_re_ib_init(struct bnxt_re_dev *rdev) in bnxt_re_ib_init() argument
1330 rc = bnxt_re_register_ib(rdev); in bnxt_re_ib_init()
1335 dev_info(rdev_to_dev(rdev), "Device registered successfully"); in bnxt_re_ib_init()
1336 ib_get_eth_speed(&rdev->ibdev, 1, &rdev->active_speed, in bnxt_re_ib_init()
1337 &rdev->active_width); in bnxt_re_ib_init()
1338 set_bit(BNXT_RE_FLAG_ISSUE_ROCE_STATS, &rdev->flags); in bnxt_re_ib_init()
1340 event = netif_running(rdev->netdev) && netif_carrier_ok(rdev->netdev) ? in bnxt_re_ib_init()
1343 bnxt_re_dispatch_event(&rdev->ibdev, NULL, 1, event); in bnxt_re_ib_init()
1348 static void bnxt_re_dev_uninit(struct bnxt_re_dev *rdev) in bnxt_re_dev_uninit() argument
1353 if (test_and_clear_bit(BNXT_RE_FLAG_QOS_WORK_REG, &rdev->flags)) in bnxt_re_dev_uninit()
1354 cancel_delayed_work_sync(&rdev->worker); in bnxt_re_dev_uninit()
1357 &rdev->flags)) in bnxt_re_dev_uninit()
1358 bnxt_re_cleanup_res(rdev); in bnxt_re_dev_uninit()
1359 if (test_and_clear_bit(BNXT_RE_FLAG_RESOURCES_ALLOCATED, &rdev->flags)) in bnxt_re_dev_uninit()
1360 bnxt_re_free_res(rdev); in bnxt_re_dev_uninit()
1362 if (test_and_clear_bit(BNXT_RE_FLAG_RCFW_CHANNEL_EN, &rdev->flags)) { in bnxt_re_dev_uninit()
1363 rc = bnxt_qplib_deinit_rcfw(&rdev->rcfw); in bnxt_re_dev_uninit()
1365 ibdev_warn(&rdev->ibdev, in bnxt_re_dev_uninit()
1367 bnxt_re_net_stats_ctx_free(rdev, rdev->qplib_ctx.stats.fw_id); in bnxt_re_dev_uninit()
1368 bnxt_qplib_free_ctx(&rdev->qplib_res, &rdev->qplib_ctx); in bnxt_re_dev_uninit()
1369 bnxt_qplib_disable_rcfw_channel(&rdev->rcfw); in bnxt_re_dev_uninit()
1370 type = bnxt_qplib_get_ring_type(rdev->chip_ctx); in bnxt_re_dev_uninit()
1371 bnxt_re_net_ring_free(rdev, rdev->rcfw.creq.ring_id, type); in bnxt_re_dev_uninit()
1372 bnxt_qplib_free_rcfw_channel(&rdev->rcfw); in bnxt_re_dev_uninit()
1374 if (test_and_clear_bit(BNXT_RE_FLAG_GOT_MSIX, &rdev->flags)) { in bnxt_re_dev_uninit()
1375 rc = bnxt_re_free_msix(rdev); in bnxt_re_dev_uninit()
1377 ibdev_warn(&rdev->ibdev, in bnxt_re_dev_uninit()
1381 bnxt_re_destroy_chip_ctx(rdev); in bnxt_re_dev_uninit()
1382 if (test_and_clear_bit(BNXT_RE_FLAG_NETDEV_REGISTERED, &rdev->flags)) { in bnxt_re_dev_uninit()
1383 rc = bnxt_re_unregister_netdev(rdev); in bnxt_re_dev_uninit()
1385 ibdev_warn(&rdev->ibdev, in bnxt_re_dev_uninit()
1393 struct bnxt_re_dev *rdev = container_of(work, struct bnxt_re_dev, in bnxt_re_worker() local
1396 bnxt_re_setup_qos(rdev); in bnxt_re_worker()
1397 schedule_delayed_work(&rdev->worker, msecs_to_jiffies(30000)); in bnxt_re_worker()
1400 static int bnxt_re_dev_init(struct bnxt_re_dev *rdev, u8 wqe_mode) in bnxt_re_dev_init() argument
1411 rc = bnxt_re_register_netdev(rdev); in bnxt_re_dev_init()
1413 ibdev_err(&rdev->ibdev, in bnxt_re_dev_init()
1417 set_bit(BNXT_RE_FLAG_NETDEV_REGISTERED, &rdev->flags); in bnxt_re_dev_init()
1419 rc = bnxt_re_setup_chip_ctx(rdev, wqe_mode); in bnxt_re_dev_init()
1421 ibdev_err(&rdev->ibdev, "Failed to get chip context\n"); in bnxt_re_dev_init()
1426 bnxt_re_get_sriov_func_type(rdev); in bnxt_re_dev_init()
1428 rc = bnxt_re_request_msix(rdev); in bnxt_re_dev_init()
1430 ibdev_err(&rdev->ibdev, in bnxt_re_dev_init()
1435 set_bit(BNXT_RE_FLAG_GOT_MSIX, &rdev->flags); in bnxt_re_dev_init()
1437 bnxt_re_query_hwrm_intf_version(rdev); in bnxt_re_dev_init()
1442 rc = bnxt_qplib_alloc_rcfw_channel(&rdev->qplib_res, &rdev->rcfw, in bnxt_re_dev_init()
1443 &rdev->qplib_ctx, in bnxt_re_dev_init()
1446 ibdev_err(&rdev->ibdev, in bnxt_re_dev_init()
1451 type = bnxt_qplib_get_ring_type(rdev->chip_ctx); in bnxt_re_dev_init()
1452 creq = &rdev->rcfw.creq; in bnxt_re_dev_init()
1458 rattr.lrid = rdev->msix_entries[BNXT_RE_AEQ_IDX].ring_idx; in bnxt_re_dev_init()
1459 rc = bnxt_re_net_ring_alloc(rdev, &rattr, &creq->ring_id); in bnxt_re_dev_init()
1461 ibdev_err(&rdev->ibdev, "Failed to allocate CREQ: %#x\n", rc); in bnxt_re_dev_init()
1464 db_offt = bnxt_re_get_nqdb_offset(rdev, BNXT_RE_AEQ_IDX); in bnxt_re_dev_init()
1465 vid = rdev->msix_entries[BNXT_RE_AEQ_IDX].vector; in bnxt_re_dev_init()
1466 rc = bnxt_qplib_enable_rcfw_channel(&rdev->rcfw, in bnxt_re_dev_init()
1467 vid, db_offt, rdev->is_virtfn, in bnxt_re_dev_init()
1470 ibdev_err(&rdev->ibdev, "Failed to enable RCFW channel: %#x\n", in bnxt_re_dev_init()
1475 rc = bnxt_qplib_get_dev_attr(&rdev->rcfw, &rdev->dev_attr, in bnxt_re_dev_init()
1476 rdev->is_virtfn); in bnxt_re_dev_init()
1480 bnxt_re_set_resource_limits(rdev); in bnxt_re_dev_init()
1482 rc = bnxt_qplib_alloc_ctx(&rdev->qplib_res, &rdev->qplib_ctx, 0, in bnxt_re_dev_init()
1483 bnxt_qplib_is_chip_gen_p5(rdev->chip_ctx)); in bnxt_re_dev_init()
1485 ibdev_err(&rdev->ibdev, in bnxt_re_dev_init()
1489 rc = bnxt_re_net_stats_ctx_alloc(rdev, in bnxt_re_dev_init()
1490 rdev->qplib_ctx.stats.dma_map, in bnxt_re_dev_init()
1491 &rdev->qplib_ctx.stats.fw_id); in bnxt_re_dev_init()
1493 ibdev_err(&rdev->ibdev, in bnxt_re_dev_init()
1498 rc = bnxt_qplib_init_rcfw(&rdev->rcfw, &rdev->qplib_ctx, in bnxt_re_dev_init()
1499 rdev->is_virtfn); in bnxt_re_dev_init()
1501 ibdev_err(&rdev->ibdev, in bnxt_re_dev_init()
1505 set_bit(BNXT_RE_FLAG_RCFW_CHANNEL_EN, &rdev->flags); in bnxt_re_dev_init()
1508 rc = bnxt_re_alloc_res(rdev); in bnxt_re_dev_init()
1510 ibdev_err(&rdev->ibdev, in bnxt_re_dev_init()
1514 set_bit(BNXT_RE_FLAG_RESOURCES_ALLOCATED, &rdev->flags); in bnxt_re_dev_init()
1515 rc = bnxt_re_init_res(rdev); in bnxt_re_dev_init()
1517 ibdev_err(&rdev->ibdev, in bnxt_re_dev_init()
1522 set_bit(BNXT_RE_FLAG_RESOURCES_INITIALIZED, &rdev->flags); in bnxt_re_dev_init()
1524 if (!rdev->is_virtfn) { in bnxt_re_dev_init()
1525 rc = bnxt_re_setup_qos(rdev); in bnxt_re_dev_init()
1527 ibdev_info(&rdev->ibdev, in bnxt_re_dev_init()
1530 INIT_DELAYED_WORK(&rdev->worker, bnxt_re_worker); in bnxt_re_dev_init()
1531 set_bit(BNXT_RE_FLAG_QOS_WORK_REG, &rdev->flags); in bnxt_re_dev_init()
1532 schedule_delayed_work(&rdev->worker, msecs_to_jiffies(30000)); in bnxt_re_dev_init()
1537 bnxt_re_net_stats_ctx_free(rdev, rdev->qplib_ctx.stats.fw_id); in bnxt_re_dev_init()
1539 bnxt_qplib_free_ctx(&rdev->qplib_res, &rdev->qplib_ctx); in bnxt_re_dev_init()
1541 bnxt_qplib_disable_rcfw_channel(&rdev->rcfw); in bnxt_re_dev_init()
1543 type = bnxt_qplib_get_ring_type(rdev->chip_ctx); in bnxt_re_dev_init()
1544 bnxt_re_net_ring_free(rdev, rdev->rcfw.creq.ring_id, type); in bnxt_re_dev_init()
1546 bnxt_qplib_free_rcfw_channel(&rdev->rcfw); in bnxt_re_dev_init()
1548 bnxt_re_dev_uninit(rdev); in bnxt_re_dev_init()
1553 static void bnxt_re_dev_unreg(struct bnxt_re_dev *rdev) in bnxt_re_dev_unreg() argument
1555 struct bnxt_en_dev *en_dev = rdev->en_dev; in bnxt_re_dev_unreg()
1556 struct net_device *netdev = rdev->netdev; in bnxt_re_dev_unreg()
1558 bnxt_re_dev_remove(rdev); in bnxt_re_dev_unreg()
1564 static int bnxt_re_dev_reg(struct bnxt_re_dev **rdev, struct net_device *netdev) in bnxt_re_dev_reg() argument
1575 ibdev_err(&(*rdev)->ibdev, "%s: Failed to probe\n", in bnxt_re_dev_reg()
1580 *rdev = bnxt_re_dev_add(netdev, en_dev); in bnxt_re_dev_reg()
1581 if (!*rdev) { in bnxt_re_dev_reg()
1590 static void bnxt_re_remove_device(struct bnxt_re_dev *rdev) in bnxt_re_remove_device() argument
1592 bnxt_re_dev_uninit(rdev); in bnxt_re_remove_device()
1593 pci_dev_put(rdev->en_dev->pdev); in bnxt_re_remove_device()
1594 bnxt_re_dev_unreg(rdev); in bnxt_re_remove_device()
1597 static int bnxt_re_add_device(struct bnxt_re_dev **rdev, in bnxt_re_add_device() argument
1602 rc = bnxt_re_dev_reg(rdev, netdev); in bnxt_re_add_device()
1611 pci_dev_get((*rdev)->en_dev->pdev); in bnxt_re_add_device()
1612 rc = bnxt_re_dev_init(*rdev, wqe_mode); in bnxt_re_add_device()
1614 pci_dev_put((*rdev)->en_dev->pdev); in bnxt_re_add_device()
1615 bnxt_re_dev_unreg(*rdev); in bnxt_re_add_device()
1623 struct bnxt_re_dev *rdev = in bnxt_re_dealloc_driver() local
1626 dev_info(rdev_to_dev(rdev), "Unregistering Device"); in bnxt_re_dealloc_driver()
1629 bnxt_re_remove_device(rdev); in bnxt_re_dealloc_driver()
1637 struct bnxt_re_dev *rdev; in bnxt_re_task() local
1641 rdev = re_work->rdev; in bnxt_re_task()
1644 rc = bnxt_re_ib_init(rdev); in bnxt_re_task()
1646 ibdev_err(&rdev->ibdev, in bnxt_re_task()
1649 bnxt_re_remove_device(rdev); in bnxt_re_task()
1656 if (!ib_device_try_get(&rdev->ibdev)) in bnxt_re_task()
1661 bnxt_re_dispatch_event(&rdev->ibdev, NULL, 1, in bnxt_re_task()
1665 bnxt_re_dev_stop(rdev); in bnxt_re_task()
1668 if (!netif_carrier_ok(rdev->netdev)) in bnxt_re_task()
1669 bnxt_re_dev_stop(rdev); in bnxt_re_task()
1670 else if (netif_carrier_ok(rdev->netdev)) in bnxt_re_task()
1671 bnxt_re_dispatch_event(&rdev->ibdev, NULL, 1, in bnxt_re_task()
1673 ib_get_eth_speed(&rdev->ibdev, 1, &rdev->active_speed, in bnxt_re_task()
1674 &rdev->active_width); in bnxt_re_task()
1679 ib_device_put(&rdev->ibdev); in bnxt_re_task()
1681 put_device(&rdev->ibdev.dev); in bnxt_re_task()
1704 struct bnxt_re_dev *rdev; in bnxt_re_netdev_event() local
1713 rdev = bnxt_re_from_netdev(real_dev); in bnxt_re_netdev_event()
1714 if (!rdev && event != NETDEV_REGISTER) in bnxt_re_netdev_event()
1722 if (rdev) in bnxt_re_netdev_event()
1724 rc = bnxt_re_add_device(&rdev, real_dev, in bnxt_re_netdev_event()
1732 ib_unregister_device_queued(&rdev->ibdev); in bnxt_re_netdev_event()
1743 get_device(&rdev->ibdev.dev); in bnxt_re_netdev_event()
1744 re_work->rdev = rdev; in bnxt_re_netdev_event()
1754 if (rdev && release) in bnxt_re_netdev_event()
1755 ib_device_put(&rdev->ibdev); in bnxt_re_netdev_event()
1791 struct bnxt_re_dev *rdev; in bnxt_re_mod_exit() local
1796 list_for_each_entry(rdev, &bnxt_re_dev_list, list) { in bnxt_re_mod_exit()
1802 if (rdev->is_virtfn) in bnxt_re_mod_exit()
1803 ib_unregister_device(&rdev->ibdev); in bnxt_re_mod_exit()