Lines Matching +full:legacy +full:- +full:mode
1 /* Broadcom NetXtreme-C/E network driver.
3 * Copyright (c) 2016-2017 Broadcom Limited
37 req->vf_id = cpu_to_le16(vf_idx); in hwrm_cfa_vfr_alloc()
38 sprintf(req->vfr_name, "vfr%d", vf_idx); in hwrm_cfa_vfr_alloc()
43 *tx_cfa_action = le16_to_cpu(resp->tx_cfa_action); in hwrm_cfa_vfr_alloc()
44 *rx_cfa_code = le16_to_cpu(resp->rx_cfa_code); 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()
51 netdev_info(bp->dev, "%s error rc=%d\n", __func__, rc); in hwrm_cfa_vfr_alloc()
62 sprintf(req->vfr_name, "vfr%d", vf_idx); in hwrm_cfa_vfr_free()
66 netdev_info(bp->dev, "%s error rc=%d\n", __func__, rc); in hwrm_cfa_vfr_free()
82 req->fid = cpu_to_le16(bp->pf.vf[vf_rep->vf_idx].fw_fid); in bnxt_hwrm_vfr_qcfg()
86 mtu = le16_to_cpu(resp->max_mtu_configured); in bnxt_hwrm_vfr_qcfg()
99 struct bnxt *bp = vf_rep->bp; in bnxt_vf_rep_open()
102 if (netif_running(bp->dev)) { in bnxt_vf_rep_open()
121 int rc, len = skb->len; in bnxt_vf_rep_xmit()
124 dst_hold((struct dst_entry *)vf_rep->dst); in bnxt_vf_rep_xmit()
125 skb_dst_set(skb, (struct dst_entry *)vf_rep->dst); in bnxt_vf_rep_xmit()
126 skb->dev = vf_rep->dst->u.port_info.lower_dev; in bnxt_vf_rep_xmit()
130 vf_rep->tx_stats.packets++; in bnxt_vf_rep_xmit()
131 vf_rep->tx_stats.bytes += len; in bnxt_vf_rep_xmit()
142 stats->rx_packets = vf_rep->rx_stats.packets; in bnxt_vf_rep_get_stats64()
143 stats->rx_bytes = vf_rep->rx_stats.bytes; in bnxt_vf_rep_get_stats64()
144 stats->tx_packets = vf_rep->tx_stats.packets; in bnxt_vf_rep_get_stats64()
145 stats->tx_bytes = vf_rep->tx_stats.bytes; in bnxt_vf_rep_get_stats64()
153 struct bnxt *bp = vf_rep->bp; in bnxt_vf_rep_setup_tc_block_cb()
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()
158 return -EOPNOTSUPP; in bnxt_vf_rep_setup_tc_block_cb()
164 return -EOPNOTSUPP; in bnxt_vf_rep_setup_tc_block_cb()
182 return -EOPNOTSUPP; in bnxt_vf_rep_setup_tc()
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()
200 struct bnxt_vf_rep *vf_rep = netdev_priv(skb->dev); in bnxt_vf_rep_rx()
202 vf_rep->rx_stats.bytes += skb->len; in bnxt_vf_rep_rx()
203 vf_rep->rx_stats.packets++; in bnxt_vf_rep_rx()
212 struct pci_dev *pf_pdev = vf_rep->bp->pdev; in bnxt_vf_rep_get_phys_port_name()
215 rc = snprintf(buf, len, "pf%dvf%d", PCI_FUNC(pf_pdev->devfn), in bnxt_vf_rep_get_phys_port_name()
216 vf_rep->vf_idx); in bnxt_vf_rep_get_phys_port_name()
218 return -EOPNOTSUPP; in bnxt_vf_rep_get_phys_port_name()
225 strscpy(info->driver, DRV_MODULE_NAME, sizeof(info->driver)); in bnxt_vf_rep_get_drvinfo()
234 * between PF and VF-rep for now. in bnxt_vf_rep_get_port_parent_id()
236 return bnxt_get_port_parent_id(vf_rep->bp->dev, ppid); in bnxt_vf_rep_get_port_parent_id()
255 return dev->netdev_ops == &bnxt_vf_rep_netdev_ops; in bnxt_dev_is_vf_rep()
259 * As the mode transition from SWITCHDEV to LEGACY
267 if (bp->eswitch_mode != DEVLINK_ESWITCH_MODE_SWITCHDEV) in bnxt_vf_reps_close()
270 num_vfs = pci_num_vf(bp->pdev); in bnxt_vf_reps_close()
272 vf_rep = bp->vf_reps[i]; in bnxt_vf_reps_close()
273 if (netif_running(vf_rep->dev)) in bnxt_vf_reps_close()
274 bnxt_vf_rep_close(vf_rep->dev); in bnxt_vf_reps_close()
278 /* Called when the parent PF interface is opened (re-opened):
279 * As the mode transition from SWITCHDEV to LEGACY
286 if (bp->eswitch_mode != DEVLINK_ESWITCH_MODE_SWITCHDEV) in bnxt_vf_reps_open()
289 for (i = 0; i < pci_num_vf(bp->pdev); i++) { in bnxt_vf_reps_open()
290 /* Open the VF-Rep only if it is allocated in the FW */ in bnxt_vf_reps_open()
291 if (bp->vf_reps[i]->tx_cfa_action != CFA_HANDLE_INVALID) in bnxt_vf_reps_open()
292 bnxt_vf_rep_open(bp->vf_reps[i]->dev); in bnxt_vf_reps_open()
301 if (vf_rep->dst) { in __bnxt_free_one_vf_rep()
302 dst_release((struct dst_entry *)vf_rep->dst); in __bnxt_free_one_vf_rep()
303 vf_rep->dst = NULL; in __bnxt_free_one_vf_rep()
305 if (vf_rep->tx_cfa_action != CFA_HANDLE_INVALID) { in __bnxt_free_one_vf_rep()
306 hwrm_cfa_vfr_free(bp, vf_rep->vf_idx); in __bnxt_free_one_vf_rep()
307 vf_rep->tx_cfa_action = CFA_HANDLE_INVALID; in __bnxt_free_one_vf_rep()
313 u16 num_vfs = pci_num_vf(bp->pdev); in __bnxt_vf_reps_destroy()
318 vf_rep = bp->vf_reps[i]; in __bnxt_vf_reps_destroy()
321 if (vf_rep->dev) { in __bnxt_vf_reps_destroy()
325 if (vf_rep->dev->netdev_ops) in __bnxt_vf_reps_destroy()
326 unregister_netdev(vf_rep->dev); in __bnxt_vf_reps_destroy()
327 free_netdev(vf_rep->dev); in __bnxt_vf_reps_destroy()
332 kfree(bp->vf_reps); in __bnxt_vf_reps_destroy()
333 bp->vf_reps = NULL; in __bnxt_vf_reps_destroy()
340 if (bp->eswitch_mode != DEVLINK_ESWITCH_MODE_SWITCHDEV) in bnxt_vf_reps_destroy()
343 if (!bp->vf_reps) in bnxt_vf_reps_destroy()
346 /* Ensure that parent PF's and VF-reps' RX/TX has been quiesced in bnxt_vf_reps_destroy()
347 * before proceeding with VF-rep cleanup. in bnxt_vf_reps_destroy()
349 netdev_lock(bp->dev); in bnxt_vf_reps_destroy()
350 if (netif_running(bp->dev)) { in bnxt_vf_reps_destroy()
354 /* un-publish cfa_code_map so that RX path can't see it anymore */ in bnxt_vf_reps_destroy()
355 kfree(bp->cfa_code_map); in bnxt_vf_reps_destroy()
356 bp->cfa_code_map = NULL; in bnxt_vf_reps_destroy()
359 /* Temporarily set legacy mode to avoid re-opening in bnxt_vf_reps_destroy()
360 * representors and restore switchdev mode after that. in bnxt_vf_reps_destroy()
362 bp->eswitch_mode = DEVLINK_ESWITCH_MODE_LEGACY; in bnxt_vf_reps_destroy()
364 bp->eswitch_mode = DEVLINK_ESWITCH_MODE_SWITCHDEV; in bnxt_vf_reps_destroy()
366 netdev_unlock(bp->dev); in bnxt_vf_reps_destroy()
374 /* Free the VF-Reps in firmware, during firmware hot-reset processing.
375 * Note that the VF-Rep netdevs are still active (not unregistered) during
376 * this process. As the mode transition from SWITCHDEV to LEGACY happens
381 u16 num_vfs = pci_num_vf(bp->pdev); in bnxt_vf_reps_free()
384 if (bp->eswitch_mode != DEVLINK_ESWITCH_MODE_SWITCHDEV) in bnxt_vf_reps_free()
388 __bnxt_free_one_vf_rep(bp, bp->vf_reps[i]); in bnxt_vf_reps_free()
395 if (hwrm_cfa_vfr_alloc(bp, vf_rep->vf_idx, &vf_rep->tx_cfa_action, in bnxt_alloc_vf_rep()
396 &vf_rep->rx_cfa_code)) in bnxt_alloc_vf_rep()
397 return -ENOLINK; in bnxt_alloc_vf_rep()
399 cfa_code_map[vf_rep->rx_cfa_code] = vf_rep->vf_idx; in bnxt_alloc_vf_rep()
400 vf_rep->dst = metadata_dst_alloc(0, METADATA_HW_PORT_MUX, GFP_KERNEL); in bnxt_alloc_vf_rep()
401 if (!vf_rep->dst) in bnxt_alloc_vf_rep()
402 return -ENOMEM; in bnxt_alloc_vf_rep()
405 vf_rep->dst->u.port_info.port_id = vf_rep->tx_cfa_action; in bnxt_alloc_vf_rep()
406 vf_rep->dst->u.port_info.lower_dev = bp->dev; in bnxt_alloc_vf_rep()
411 /* Allocate the VF-Reps in firmware, during firmware hot-reset processing.
412 * Note that the VF-Rep netdevs are still active (not unregistered) during
413 * this process. As the mode transition from SWITCHDEV to LEGACY happens
418 u16 *cfa_code_map = bp->cfa_code_map, num_vfs = pci_num_vf(bp->pdev); in bnxt_vf_reps_alloc()
422 if (bp->eswitch_mode != DEVLINK_ESWITCH_MODE_SWITCHDEV) in bnxt_vf_reps_alloc()
426 return -EINVAL; in bnxt_vf_reps_alloc()
432 vf_rep = bp->vf_reps[i]; in bnxt_vf_reps_alloc()
433 vf_rep->vf_idx = i; in bnxt_vf_reps_alloc()
443 netdev_info(bp->dev, "%s error=%d\n", __func__, rc); in bnxt_vf_reps_alloc()
449 * for the same VF-rep each time
466 struct net_device *pf_dev = bp->dev; in bnxt_vf_rep_netdev_init()
469 SET_NETDEV_DEV(dev, &bp->pdev->dev); in bnxt_vf_rep_netdev_init()
470 dev->netdev_ops = &bnxt_vf_rep_netdev_ops; in bnxt_vf_rep_netdev_init()
471 dev->ethtool_ops = &bnxt_vf_rep_ethtool_ops; in bnxt_vf_rep_netdev_init()
472 /* Just inherit all the featues of the parent PF as the VF-R in bnxt_vf_rep_netdev_init()
475 dev->hw_features = pf_dev->hw_features; in bnxt_vf_rep_netdev_init()
476 dev->gso_partial_features = pf_dev->gso_partial_features; in bnxt_vf_rep_netdev_init()
477 dev->vlan_features = pf_dev->vlan_features; in bnxt_vf_rep_netdev_init()
478 dev->hw_enc_features = pf_dev->hw_enc_features; in bnxt_vf_rep_netdev_init()
479 dev->features |= pf_dev->features; in bnxt_vf_rep_netdev_init()
480 bnxt_vf_rep_eth_addr_gen(bp->pf.mac_addr, vf_rep->vf_idx, in bnxt_vf_rep_netdev_init()
481 dev->perm_addr); in bnxt_vf_rep_netdev_init()
482 eth_hw_addr_set(dev, dev->perm_addr); in bnxt_vf_rep_netdev_init()
483 /* Set VF-Rep's max-mtu to the corresponding VF's max-mtu */ in bnxt_vf_rep_netdev_init()
485 dev->max_mtu = max_mtu; in bnxt_vf_rep_netdev_init()
486 dev->min_mtu = ETH_ZLEN; in bnxt_vf_rep_netdev_init()
491 u16 *cfa_code_map = NULL, num_vfs = pci_num_vf(bp->pdev); in bnxt_vf_reps_create()
496 if (!(bp->flags & BNXT_FLAG_DSN_VALID)) in bnxt_vf_reps_create()
497 return -ENODEV; in bnxt_vf_reps_create()
499 bp->vf_reps = kcalloc(num_vfs, sizeof(vf_rep), GFP_KERNEL); in bnxt_vf_reps_create()
500 if (!bp->vf_reps) in bnxt_vf_reps_create()
501 return -ENOMEM; in bnxt_vf_reps_create()
503 /* storage for cfa_code to vf-idx mapping */ in bnxt_vf_reps_create()
504 cfa_code_map = kmalloc_array(MAX_CFA_CODE, sizeof(*bp->cfa_code_map), in bnxt_vf_reps_create()
507 rc = -ENOMEM; in bnxt_vf_reps_create()
516 rc = -ENOMEM; in bnxt_vf_reps_create()
521 bp->vf_reps[i] = vf_rep; in bnxt_vf_reps_create()
522 vf_rep->dev = dev; in bnxt_vf_reps_create()
523 vf_rep->bp = bp; in bnxt_vf_reps_create()
524 vf_rep->vf_idx = i; in bnxt_vf_reps_create()
525 vf_rep->tx_cfa_action = CFA_HANDLE_INVALID; in bnxt_vf_reps_create()
535 dev->netdev_ops = NULL; in bnxt_vf_reps_create()
540 /* publish cfa_code_map only after all VF-reps have been initialized */ in bnxt_vf_reps_create()
541 bp->cfa_code_map = cfa_code_map; in bnxt_vf_reps_create()
542 netif_keep_dst(bp->dev); in bnxt_vf_reps_create()
546 netdev_info(bp->dev, "%s error=%d\n", __func__, rc); in bnxt_vf_reps_create()
553 int bnxt_dl_eswitch_mode_get(struct devlink *devlink, u16 *mode) in bnxt_dl_eswitch_mode_get() argument
557 *mode = bp->eswitch_mode; in bnxt_dl_eswitch_mode_get()
561 int bnxt_dl_eswitch_mode_set(struct devlink *devlink, u16 mode, in bnxt_dl_eswitch_mode_set() argument
567 if (bp->eswitch_mode == mode) { in bnxt_dl_eswitch_mode_set()
568 netdev_info(bp->dev, "already in %s eswitch mode\n", in bnxt_dl_eswitch_mode_set()
569 mode == DEVLINK_ESWITCH_MODE_LEGACY ? in bnxt_dl_eswitch_mode_set()
570 "legacy" : "switchdev"); in bnxt_dl_eswitch_mode_set()
571 return -EINVAL; in bnxt_dl_eswitch_mode_set()
574 switch (mode) { in bnxt_dl_eswitch_mode_set()
580 if (bp->hwrm_spec_code < 0x10803) { in bnxt_dl_eswitch_mode_set()
581 netdev_warn(bp->dev, "FW does not support SRIOV E-Switch SWITCHDEV mode\n"); in bnxt_dl_eswitch_mode_set()
582 return -ENOTSUPP; in bnxt_dl_eswitch_mode_set()
586 if (pci_num_vf(bp->pdev) > 0) in bnxt_dl_eswitch_mode_set()
591 return -EINVAL; in bnxt_dl_eswitch_mode_set()
595 bp->eswitch_mode = mode; in bnxt_dl_eswitch_mode_set()