• Home
  • Raw
  • Download

Lines Matching refs:bp

28 static int hwrm_cfa_vfr_alloc(struct bnxt *bp, u16 vf_idx,  in hwrm_cfa_vfr_alloc()  argument
35 rc = hwrm_req_init(bp, req, HWRM_CFA_VFR_ALLOC); in hwrm_cfa_vfr_alloc()
40 resp = hwrm_req_hold(bp, req); in hwrm_cfa_vfr_alloc()
41 rc = hwrm_req_send(bp, req); in hwrm_cfa_vfr_alloc()
45 netdev_dbg(bp->dev, "tx_cfa_action=0x%x, rx_cfa_code=0x%x", in hwrm_cfa_vfr_alloc()
48 hwrm_req_drop(bp, req); in hwrm_cfa_vfr_alloc()
51 netdev_info(bp->dev, "%s error rc=%d\n", __func__, rc); in hwrm_cfa_vfr_alloc()
55 static int hwrm_cfa_vfr_free(struct bnxt *bp, u16 vf_idx) in hwrm_cfa_vfr_free() argument
60 rc = hwrm_req_init(bp, req, HWRM_CFA_VFR_FREE); in hwrm_cfa_vfr_free()
63 rc = hwrm_req_send(bp, req); in hwrm_cfa_vfr_free()
66 netdev_info(bp->dev, "%s error rc=%d\n", __func__, rc); in hwrm_cfa_vfr_free()
70 static int bnxt_hwrm_vfr_qcfg(struct bnxt *bp, struct bnxt_vf_rep *vf_rep, in bnxt_hwrm_vfr_qcfg() argument
78 rc = hwrm_req_init(bp, req, HWRM_FUNC_QCFG); in bnxt_hwrm_vfr_qcfg()
82 req->fid = cpu_to_le16(bp->pf.vf[vf_rep->vf_idx].fw_fid); in bnxt_hwrm_vfr_qcfg()
83 resp = hwrm_req_hold(bp, req); in bnxt_hwrm_vfr_qcfg()
84 rc = hwrm_req_send(bp, req); in bnxt_hwrm_vfr_qcfg()
92 hwrm_req_drop(bp, req); in bnxt_hwrm_vfr_qcfg()
99 struct bnxt *bp = vf_rep->bp; in bnxt_vf_rep_open() local
102 if (netif_running(bp->dev)) { in bnxt_vf_rep_open()
153 struct bnxt *bp = vf_rep->bp; in bnxt_vf_rep_setup_tc_block_cb() local
154 int vf_fid = bp->pf.vf[vf_rep->vf_idx].fw_fid; in bnxt_vf_rep_setup_tc_block_cb()
156 if (!bnxt_tc_flower_enabled(vf_rep->bp) || in bnxt_vf_rep_setup_tc_block_cb()
157 !tc_cls_can_offload_and_chain0(bp->dev, type_data)) in bnxt_vf_rep_setup_tc_block_cb()
162 return bnxt_tc_setup_flower(bp, vf_fid, type_data); in bnxt_vf_rep_setup_tc_block_cb()
186 struct net_device *bnxt_get_vf_rep(struct bnxt *bp, u16 cfa_code) in bnxt_get_vf_rep() argument
190 if (cfa_code && bp->cfa_code_map && BNXT_PF(bp)) { in bnxt_get_vf_rep()
191 vf_idx = bp->cfa_code_map[cfa_code]; in bnxt_get_vf_rep()
193 return bp->vf_reps[vf_idx]->dev; in bnxt_get_vf_rep()
198 void bnxt_vf_rep_rx(struct bnxt *bp, struct sk_buff *skb) in bnxt_vf_rep_rx() argument
212 struct pci_dev *pf_pdev = vf_rep->bp->pdev; in bnxt_vf_rep_get_phys_port_name()
236 return bnxt_get_port_parent_id(vf_rep->bp->dev, ppid); in bnxt_vf_rep_get_port_parent_id()
263 void bnxt_vf_reps_close(struct bnxt *bp) in bnxt_vf_reps_close() argument
268 if (bp->eswitch_mode != DEVLINK_ESWITCH_MODE_SWITCHDEV) in bnxt_vf_reps_close()
271 num_vfs = pci_num_vf(bp->pdev); in bnxt_vf_reps_close()
273 vf_rep = bp->vf_reps[i]; in bnxt_vf_reps_close()
284 void bnxt_vf_reps_open(struct bnxt *bp) in bnxt_vf_reps_open() argument
288 if (bp->eswitch_mode != DEVLINK_ESWITCH_MODE_SWITCHDEV) in bnxt_vf_reps_open()
291 for (i = 0; i < pci_num_vf(bp->pdev); i++) { in bnxt_vf_reps_open()
293 if (bp->vf_reps[i]->tx_cfa_action != CFA_HANDLE_INVALID) in bnxt_vf_reps_open()
294 bnxt_vf_rep_open(bp->vf_reps[i]->dev); in bnxt_vf_reps_open()
298 static void __bnxt_free_one_vf_rep(struct bnxt *bp, struct bnxt_vf_rep *vf_rep) in __bnxt_free_one_vf_rep() argument
308 hwrm_cfa_vfr_free(bp, vf_rep->vf_idx); in __bnxt_free_one_vf_rep()
313 static void __bnxt_vf_reps_destroy(struct bnxt *bp) in __bnxt_vf_reps_destroy() argument
315 u16 num_vfs = pci_num_vf(bp->pdev); in __bnxt_vf_reps_destroy()
320 vf_rep = bp->vf_reps[i]; in __bnxt_vf_reps_destroy()
322 __bnxt_free_one_vf_rep(bp, vf_rep); in __bnxt_vf_reps_destroy()
334 kfree(bp->vf_reps); in __bnxt_vf_reps_destroy()
335 bp->vf_reps = NULL; in __bnxt_vf_reps_destroy()
338 void bnxt_vf_reps_destroy(struct bnxt *bp) in bnxt_vf_reps_destroy() argument
342 if (bp->eswitch_mode != DEVLINK_ESWITCH_MODE_SWITCHDEV) in bnxt_vf_reps_destroy()
345 if (!bp->vf_reps) in bnxt_vf_reps_destroy()
352 if (netif_running(bp->dev)) { in bnxt_vf_reps_destroy()
353 bnxt_close_nic(bp, false, false); in bnxt_vf_reps_destroy()
357 kfree(bp->cfa_code_map); in bnxt_vf_reps_destroy()
358 bp->cfa_code_map = NULL; in bnxt_vf_reps_destroy()
359 bp->eswitch_mode = DEVLINK_ESWITCH_MODE_LEGACY; in bnxt_vf_reps_destroy()
362 bnxt_open_nic(bp, false, false); in bnxt_vf_reps_destroy()
368 __bnxt_vf_reps_destroy(bp); in bnxt_vf_reps_destroy()
376 void bnxt_vf_reps_free(struct bnxt *bp) in bnxt_vf_reps_free() argument
378 u16 num_vfs = pci_num_vf(bp->pdev); in bnxt_vf_reps_free()
381 if (bp->eswitch_mode != DEVLINK_ESWITCH_MODE_SWITCHDEV) in bnxt_vf_reps_free()
385 __bnxt_free_one_vf_rep(bp, bp->vf_reps[i]); in bnxt_vf_reps_free()
388 static int bnxt_alloc_vf_rep(struct bnxt *bp, struct bnxt_vf_rep *vf_rep, in bnxt_alloc_vf_rep() argument
392 if (hwrm_cfa_vfr_alloc(bp, vf_rep->vf_idx, &vf_rep->tx_cfa_action, in bnxt_alloc_vf_rep()
403 vf_rep->dst->u.port_info.lower_dev = bp->dev; in bnxt_alloc_vf_rep()
413 int bnxt_vf_reps_alloc(struct bnxt *bp) in bnxt_vf_reps_alloc() argument
415 u16 *cfa_code_map = bp->cfa_code_map, num_vfs = pci_num_vf(bp->pdev); in bnxt_vf_reps_alloc()
419 if (bp->eswitch_mode != DEVLINK_ESWITCH_MODE_SWITCHDEV) in bnxt_vf_reps_alloc()
429 vf_rep = bp->vf_reps[i]; in bnxt_vf_reps_alloc()
432 rc = bnxt_alloc_vf_rep(bp, vf_rep, cfa_code_map); in bnxt_vf_reps_alloc()
440 netdev_info(bp->dev, "%s error=%d\n", __func__, rc); in bnxt_vf_reps_alloc()
441 bnxt_vf_reps_free(bp); in bnxt_vf_reps_alloc()
460 static void bnxt_vf_rep_netdev_init(struct bnxt *bp, struct bnxt_vf_rep *vf_rep, in bnxt_vf_rep_netdev_init() argument
463 struct net_device *pf_dev = bp->dev; in bnxt_vf_rep_netdev_init()
476 bnxt_vf_rep_eth_addr_gen(bp->pf.mac_addr, vf_rep->vf_idx, in bnxt_vf_rep_netdev_init()
480 if (!bnxt_hwrm_vfr_qcfg(bp, vf_rep, &max_mtu)) in bnxt_vf_rep_netdev_init()
485 static int bnxt_vf_reps_create(struct bnxt *bp) in bnxt_vf_reps_create() argument
487 u16 *cfa_code_map = NULL, num_vfs = pci_num_vf(bp->pdev); in bnxt_vf_reps_create()
492 if (!(bp->flags & BNXT_FLAG_DSN_VALID)) in bnxt_vf_reps_create()
495 bp->vf_reps = kcalloc(num_vfs, sizeof(vf_rep), GFP_KERNEL); in bnxt_vf_reps_create()
496 if (!bp->vf_reps) in bnxt_vf_reps_create()
500 cfa_code_map = kmalloc_array(MAX_CFA_CODE, sizeof(*bp->cfa_code_map), in bnxt_vf_reps_create()
517 bp->vf_reps[i] = vf_rep; in bnxt_vf_reps_create()
519 vf_rep->bp = bp; in bnxt_vf_reps_create()
523 rc = bnxt_alloc_vf_rep(bp, vf_rep, cfa_code_map); in bnxt_vf_reps_create()
527 bnxt_vf_rep_netdev_init(bp, vf_rep, dev); in bnxt_vf_reps_create()
537 bp->cfa_code_map = cfa_code_map; in bnxt_vf_reps_create()
538 bp->eswitch_mode = DEVLINK_ESWITCH_MODE_SWITCHDEV; in bnxt_vf_reps_create()
539 netif_keep_dst(bp->dev); in bnxt_vf_reps_create()
543 netdev_info(bp->dev, "%s error=%d\n", __func__, rc); in bnxt_vf_reps_create()
545 __bnxt_vf_reps_destroy(bp); in bnxt_vf_reps_create()
552 struct bnxt *bp = bnxt_get_bp_from_dl(devlink); in bnxt_dl_eswitch_mode_get() local
554 *mode = bp->eswitch_mode; in bnxt_dl_eswitch_mode_get()
561 struct bnxt *bp = bnxt_get_bp_from_dl(devlink); in bnxt_dl_eswitch_mode_set() local
564 mutex_lock(&bp->sriov_lock); in bnxt_dl_eswitch_mode_set()
565 if (bp->eswitch_mode == mode) { in bnxt_dl_eswitch_mode_set()
566 netdev_info(bp->dev, "already in %s eswitch mode\n", in bnxt_dl_eswitch_mode_set()
575 bnxt_vf_reps_destroy(bp); in bnxt_dl_eswitch_mode_set()
579 if (bp->hwrm_spec_code < 0x10803) { in bnxt_dl_eswitch_mode_set()
580 netdev_warn(bp->dev, "FW does not support SRIOV E-Switch SWITCHDEV mode\n"); in bnxt_dl_eswitch_mode_set()
585 if (pci_num_vf(bp->pdev) == 0) { in bnxt_dl_eswitch_mode_set()
586 netdev_info(bp->dev, "Enable VFs before setting switchdev mode\n"); in bnxt_dl_eswitch_mode_set()
590 rc = bnxt_vf_reps_create(bp); in bnxt_dl_eswitch_mode_set()
598 mutex_unlock(&bp->sriov_lock); in bnxt_dl_eswitch_mode_set()