Lines Matching +full:mac +full:- +full:only

1 // SPDX-License-Identifier: GPL-2.0-only
19 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_evb_port_assign()
23 EVB_PORT_ASSIGN_IN_PF, nic_data->pf_index, in efx_ef10_evb_port_assign()
47 if (rc == -EPROTO) { in efx_ef10_vswitch_alloc()
97 return -EIO; in efx_ef10_vport_alloc()
115 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_sriov_free_vf_vports()
118 if (!nic_data->vf) in efx_ef10_sriov_free_vf_vports()
121 for (i = 0; i < efx->vf_count; i++) { in efx_ef10_sriov_free_vf_vports()
122 struct ef10_vf *vf = nic_data->vf + i; in efx_ef10_sriov_free_vf_vports()
125 if (vf->pci_dev && pci_is_dev_assigned(vf->pci_dev)) in efx_ef10_sriov_free_vf_vports()
128 if (vf->vport_assigned) { in efx_ef10_sriov_free_vf_vports()
130 vf->vport_assigned = 0; in efx_ef10_sriov_free_vf_vports()
133 if (!is_zero_ether_addr(vf->mac)) { in efx_ef10_sriov_free_vf_vports()
134 efx_ef10_vport_del_mac(efx, vf->vport_id, vf->mac); in efx_ef10_sriov_free_vf_vports()
135 eth_zero_addr(vf->mac); in efx_ef10_sriov_free_vf_vports()
138 if (vf->vport_id) { in efx_ef10_sriov_free_vf_vports()
139 efx_ef10_vport_free(efx, vf->vport_id); in efx_ef10_sriov_free_vf_vports()
140 vf->vport_id = 0; in efx_ef10_sriov_free_vf_vports()
143 vf->efx = NULL; in efx_ef10_sriov_free_vf_vports()
149 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_sriov_free_vf_vswitching()
152 kfree(nic_data->vf); in efx_ef10_sriov_free_vf_vswitching()
153 nic_data->vf = NULL; in efx_ef10_sriov_free_vf_vswitching()
159 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_sriov_assign_vf_vport()
160 struct ef10_vf *vf = nic_data->vf + vf_i; in efx_ef10_sriov_assign_vf_vport()
163 if (WARN_ON_ONCE(!nic_data->vf)) in efx_ef10_sriov_assign_vf_vport()
164 return -EOPNOTSUPP; in efx_ef10_sriov_assign_vf_vport()
168 vf->vlan, &vf->vport_id); in efx_ef10_sriov_assign_vf_vport()
172 rc = efx_ef10_vport_add_mac(efx, vf->vport_id, vf->mac); in efx_ef10_sriov_assign_vf_vport()
174 eth_zero_addr(vf->mac); in efx_ef10_sriov_assign_vf_vport()
178 rc = efx_ef10_evb_port_assign(efx, vf->vport_id, vf_i); in efx_ef10_sriov_assign_vf_vport()
182 vf->vport_assigned = 1; in efx_ef10_sriov_assign_vf_vport()
188 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_sriov_alloc_vf_vswitching()
192 nic_data->vf = kcalloc(efx->vf_count, sizeof(struct ef10_vf), in efx_ef10_sriov_alloc_vf_vswitching()
194 if (!nic_data->vf) in efx_ef10_sriov_alloc_vf_vswitching()
195 return -ENOMEM; in efx_ef10_sriov_alloc_vf_vswitching()
197 for (i = 0; i < efx->vf_count; i++) { in efx_ef10_sriov_alloc_vf_vswitching()
198 eth_random_addr(nic_data->vf[i].mac); in efx_ef10_sriov_alloc_vf_vswitching()
199 nic_data->vf[i].efx = NULL; in efx_ef10_sriov_alloc_vf_vswitching()
200 nic_data->vf[i].vlan = EFX_EF10_NO_VLAN; in efx_ef10_sriov_alloc_vf_vswitching()
218 for (i = 0; i < efx->vf_count; i++) { in efx_ef10_sriov_restore_vf_vswitching()
235 rc = efx_ef10_vadaptor_alloc(efx, efx->vport_id); in efx_ef10_vadaptor_alloc_set_features()
239 rc = efx_ef10_vadaptor_query(efx, efx->vport_id, in efx_ef10_vadaptor_alloc_set_features()
246 efx->fixed_features |= NETIF_F_HW_VLAN_CTAG_FILTER; in efx_ef10_vadaptor_alloc_set_features()
248 efx->fixed_features &= ~NETIF_F_HW_VLAN_CTAG_FILTER; in efx_ef10_vadaptor_alloc_set_features()
263 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_vswitching_probe_pf()
264 struct net_device *net_dev = efx->net_dev; in efx_ef10_vswitching_probe_pf()
267 if (pci_sriov_get_totalvfs(efx->pci_dev) <= 0) { in efx_ef10_vswitching_probe_pf()
280 EFX_EF10_NO_VLAN, &efx->vport_id); in efx_ef10_vswitching_probe_pf()
284 rc = efx_ef10_vport_add_mac(efx, efx->vport_id, net_dev->dev_addr); in efx_ef10_vswitching_probe_pf()
287 ether_addr_copy(nic_data->vport_mac, net_dev->dev_addr); in efx_ef10_vswitching_probe_pf()
295 efx_ef10_vport_del_mac(efx, efx->vport_id, nic_data->vport_mac); in efx_ef10_vswitching_probe_pf()
296 eth_zero_addr(nic_data->vport_mac); in efx_ef10_vswitching_probe_pf()
298 efx_ef10_vport_free(efx, efx->vport_id); in efx_ef10_vswitching_probe_pf()
299 efx->vport_id = EVB_PORT_ID_ASSIGNED; in efx_ef10_vswitching_probe_pf()
313 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_vswitching_restore_pf()
316 if (!nic_data->must_probe_vswitching) in efx_ef10_vswitching_restore_pf()
327 nic_data->must_probe_vswitching = false; in efx_ef10_vswitching_restore_pf()
334 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_vswitching_restore_vf()
337 if (!nic_data->must_probe_vswitching) in efx_ef10_vswitching_restore_vf()
344 nic_data->must_probe_vswitching = false; in efx_ef10_vswitching_restore_vf()
350 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_vswitching_remove_pf()
354 efx_ef10_vadaptor_free(efx, efx->vport_id); in efx_ef10_vswitching_remove_pf()
356 if (efx->vport_id == EVB_PORT_ID_ASSIGNED) in efx_ef10_vswitching_remove_pf()
359 if (!is_zero_ether_addr(nic_data->vport_mac)) { in efx_ef10_vswitching_remove_pf()
360 efx_ef10_vport_del_mac(efx, efx->vport_id, in efx_ef10_vswitching_remove_pf()
361 efx->net_dev->dev_addr); in efx_ef10_vswitching_remove_pf()
362 eth_zero_addr(nic_data->vport_mac); in efx_ef10_vswitching_remove_pf()
364 efx_ef10_vport_free(efx, efx->vport_id); in efx_ef10_vswitching_remove_pf()
365 efx->vport_id = EVB_PORT_ID_ASSIGNED; in efx_ef10_vswitching_remove_pf()
367 /* Only free the vswitch if no VFs are assigned */ in efx_ef10_vswitching_remove_pf()
368 if (!pci_vfs_assigned(efx->pci_dev)) in efx_ef10_vswitching_remove_pf()
369 efx_ef10_vswitch_free(efx, efx->vport_id); in efx_ef10_vswitching_remove_pf()
380 struct pci_dev *dev = efx->pci_dev; in efx_ef10_pci_sriov_enable()
382 efx->vf_count = num_vfs; in efx_ef10_pci_sriov_enable()
396 efx->vf_count = 0; in efx_ef10_pci_sriov_enable()
397 netif_err(efx, probe, efx->net_dev, in efx_ef10_pci_sriov_enable()
403 * If some VFs are attached to a guest (using Xen, only) nothing is
405 * attachedc ones, only) but SRIOV is not disabled and VFs are not
410 struct pci_dev *dev = efx->pci_dev; in efx_ef10_pci_sriov_disable()
411 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_pci_sriov_disable()
416 netif_info(efx, drv, efx->net_dev, "VFs are assigned to guests; " in efx_ef10_pci_sriov_disable()
417 "please detach them before disabling SR-IOV\n"); in efx_ef10_pci_sriov_disable()
418 return -EBUSY; in efx_ef10_pci_sriov_disable()
422 for (i = 0; i < efx->vf_count; i++) in efx_ef10_pci_sriov_disable()
423 nic_data->vf[i].pci_dev = NULL; in efx_ef10_pci_sriov_disable()
426 rc = -EBUSY; in efx_ef10_pci_sriov_disable()
430 efx->vf_count = 0; in efx_ef10_pci_sriov_disable()
449 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_sriov_fini()
452 if (!nic_data->vf) { in efx_ef10_sriov_fini()
453 /* Remove any un-assigned orphaned VFs. This can happen if the PF driver in efx_ef10_sriov_fini()
454 * was unloaded while any VF was assigned to a guest (using Xen, only). in efx_ef10_sriov_fini()
456 if (pci_num_vf(efx->pci_dev) && !pci_vfs_assigned(efx->pci_dev)) in efx_ef10_sriov_fini()
457 pci_disable_sriov(efx->pci_dev); in efx_ef10_sriov_fini()
464 netif_dbg(efx, drv, efx->net_dev, in efx_ef10_sriov_fini()
467 netif_dbg(efx, drv, efx->net_dev, "SRIOV disabled\n"); in efx_ef10_sriov_fini()
471 u8 *mac) in efx_ef10_vport_del_vf_mac() argument
479 ether_addr_copy(MCDI_PTR(inbuf, VPORT_DEL_MAC_ADDRESS_IN_MACADDR), mac); in efx_ef10_vport_del_vf_mac()
487 int efx_ef10_sriov_set_vf_mac(struct efx_nic *efx, int vf_i, const u8 *mac) in efx_ef10_sriov_set_vf_mac() argument
489 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_sriov_set_vf_mac()
493 if (!nic_data->vf) in efx_ef10_sriov_set_vf_mac()
494 return -EOPNOTSUPP; in efx_ef10_sriov_set_vf_mac()
496 if (vf_i >= efx->vf_count) in efx_ef10_sriov_set_vf_mac()
497 return -EINVAL; in efx_ef10_sriov_set_vf_mac()
498 vf = nic_data->vf + vf_i; in efx_ef10_sriov_set_vf_mac()
500 if (vf->efx) { in efx_ef10_sriov_set_vf_mac()
501 efx_device_detach_sync(vf->efx); in efx_ef10_sriov_set_vf_mac()
502 efx_net_stop(vf->efx->net_dev); in efx_ef10_sriov_set_vf_mac()
504 vf->efx->type->filter_table_remove(vf->efx); in efx_ef10_sriov_set_vf_mac()
506 rc = efx_ef10_vadaptor_free(vf->efx, EVB_PORT_ID_ASSIGNED); in efx_ef10_sriov_set_vf_mac()
515 if (!is_zero_ether_addr(vf->mac)) { in efx_ef10_sriov_set_vf_mac()
516 rc = efx_ef10_vport_del_vf_mac(efx, vf->vport_id, vf->mac); in efx_ef10_sriov_set_vf_mac()
521 if (!is_zero_ether_addr(mac)) { in efx_ef10_sriov_set_vf_mac()
522 rc = efx_ef10_vport_add_mac(efx, vf->vport_id, mac); in efx_ef10_sriov_set_vf_mac()
526 if (vf->efx) in efx_ef10_sriov_set_vf_mac()
527 eth_hw_addr_set(vf->efx->net_dev, mac); in efx_ef10_sriov_set_vf_mac()
530 ether_addr_copy(vf->mac, mac); in efx_ef10_sriov_set_vf_mac()
532 rc = efx_ef10_evb_port_assign(efx, vf->vport_id, vf_i); in efx_ef10_sriov_set_vf_mac()
536 if (vf->efx) { in efx_ef10_sriov_set_vf_mac()
538 rc = efx_ef10_vadaptor_alloc(vf->efx, EVB_PORT_ID_ASSIGNED); in efx_ef10_sriov_set_vf_mac()
541 vf->efx->type->filter_table_probe(vf->efx); in efx_ef10_sriov_set_vf_mac()
542 efx_net_open(vf->efx->net_dev); in efx_ef10_sriov_set_vf_mac()
543 efx_device_attach_if_not_resetting(vf->efx); in efx_ef10_sriov_set_vf_mac()
549 eth_zero_addr(vf->mac); in efx_ef10_sriov_set_vf_mac()
556 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_sriov_set_vf_vlan()
561 if (vf_i >= efx->vf_count) in efx_ef10_sriov_set_vf_vlan()
562 return -EINVAL; in efx_ef10_sriov_set_vf_vlan()
564 return -EINVAL; in efx_ef10_sriov_set_vf_vlan()
566 vf = nic_data->vf + vf_i; in efx_ef10_sriov_set_vf_vlan()
569 if (new_vlan == vf->vlan) in efx_ef10_sriov_set_vf_vlan()
572 if (vf->efx) { in efx_ef10_sriov_set_vf_vlan()
573 efx_device_detach_sync(vf->efx); in efx_ef10_sriov_set_vf_vlan()
574 efx_net_stop(vf->efx->net_dev); in efx_ef10_sriov_set_vf_vlan()
576 mutex_lock(&vf->efx->mac_lock); in efx_ef10_sriov_set_vf_vlan()
577 vf->efx->type->filter_table_remove(vf->efx); in efx_ef10_sriov_set_vf_vlan()
579 rc = efx_ef10_vadaptor_free(vf->efx, EVB_PORT_ID_ASSIGNED); in efx_ef10_sriov_set_vf_vlan()
584 if (vf->vport_assigned) { in efx_ef10_sriov_set_vf_vlan()
587 netif_warn(efx, drv, efx->net_dev, in efx_ef10_sriov_set_vf_vlan()
589 netif_warn(efx, drv, efx->net_dev, in efx_ef10_sriov_set_vf_vlan()
591 netif_warn(efx, drv, efx->net_dev, in efx_ef10_sriov_set_vf_vlan()
595 vf->vport_assigned = 0; in efx_ef10_sriov_set_vf_vlan()
598 if (!is_zero_ether_addr(vf->mac)) { in efx_ef10_sriov_set_vf_vlan()
599 rc = efx_ef10_vport_del_mac(efx, vf->vport_id, vf->mac); in efx_ef10_sriov_set_vf_vlan()
604 if (vf->vport_id) { in efx_ef10_sriov_set_vf_vlan()
605 rc = efx_ef10_vport_free(efx, vf->vport_id); in efx_ef10_sriov_set_vf_vlan()
608 vf->vport_id = 0; in efx_ef10_sriov_set_vf_vlan()
612 vf->vlan = new_vlan; in efx_ef10_sriov_set_vf_vlan()
617 vf->vlan, &vf->vport_id); in efx_ef10_sriov_set_vf_vlan()
622 if (!is_zero_ether_addr(vf->mac)) { in efx_ef10_sriov_set_vf_vlan()
623 rc2 = efx_ef10_vport_add_mac(efx, vf->vport_id, vf->mac); in efx_ef10_sriov_set_vf_vlan()
625 eth_zero_addr(vf->mac); in efx_ef10_sriov_set_vf_vlan()
631 rc2 = efx_ef10_evb_port_assign(efx, vf->vport_id, vf_i); in efx_ef10_sriov_set_vf_vlan()
635 vf->vport_assigned = 1; in efx_ef10_sriov_set_vf_vlan()
638 if (vf->efx) { in efx_ef10_sriov_set_vf_vlan()
639 rc2 = efx_ef10_vadaptor_alloc(vf->efx, EVB_PORT_ID_ASSIGNED); in efx_ef10_sriov_set_vf_vlan()
645 if (vf->efx) { in efx_ef10_sriov_set_vf_vlan()
646 rc2 = vf->efx->type->filter_table_probe(vf->efx); in efx_ef10_sriov_set_vf_vlan()
650 mutex_unlock(&vf->efx->mac_lock); in efx_ef10_sriov_set_vf_vlan()
652 rc2 = efx_net_open(vf->efx->net_dev); in efx_ef10_sriov_set_vf_vlan()
656 efx_device_attach_if_not_resetting(vf->efx); in efx_ef10_sriov_set_vf_vlan()
661 if (vf->efx) in efx_ef10_sriov_set_vf_vlan()
662 mutex_unlock(&vf->efx->mac_lock); in efx_ef10_sriov_set_vf_vlan()
664 if (vf->efx) { in efx_ef10_sriov_set_vf_vlan()
665 netif_err(efx, drv, efx->net_dev, in efx_ef10_sriov_set_vf_vlan()
666 "Failed to restore VF - scheduling reset.\n"); in efx_ef10_sriov_set_vf_vlan()
667 efx_schedule_reset(vf->efx, RESET_TYPE_DATAPATH); in efx_ef10_sriov_set_vf_vlan()
669 netif_err(efx, drv, efx->net_dev, in efx_ef10_sriov_set_vf_vlan()
671 "- VF is not functional.\n"); in efx_ef10_sriov_set_vf_vlan()
672 netif_err(efx, drv, efx->net_dev, in efx_ef10_sriov_set_vf_vlan()
684 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_sriov_set_privilege_mask()
693 PRIVILEGE_MASK_IN_FUNCTION_PF, nic_data->pf_index, in efx_ef10_sriov_set_privilege_mask()
703 return -EIO; in efx_ef10_sriov_set_privilege_mask()
725 return -EIO; in efx_ef10_sriov_set_privilege_mask()
732 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_sriov_set_vf_spoofchk()
735 if (!(nic_data->datapath_caps & in efx_ef10_sriov_set_vf_spoofchk()
738 return -EOPNOTSUPP; in efx_ef10_sriov_set_vf_spoofchk()
749 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_sriov_set_vf_link_state()
759 nic_data->pf_index, in efx_ef10_sriov_set_vf_link_state()
772 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_sriov_get_vf_config()
777 if (vf_i >= efx->vf_count) in efx_ef10_sriov_get_vf_config()
778 return -EINVAL; in efx_ef10_sriov_get_vf_config()
780 if (!nic_data->vf) in efx_ef10_sriov_get_vf_config()
781 return -EOPNOTSUPP; in efx_ef10_sriov_get_vf_config()
783 vf = nic_data->vf + vf_i; in efx_ef10_sriov_get_vf_config()
785 ivf->vf = vf_i; in efx_ef10_sriov_get_vf_config()
786 ivf->min_tx_rate = 0; in efx_ef10_sriov_get_vf_config()
787 ivf->max_tx_rate = 0; in efx_ef10_sriov_get_vf_config()
788 ether_addr_copy(ivf->mac, vf->mac); in efx_ef10_sriov_get_vf_config()
789 ivf->vlan = (vf->vlan == EFX_EF10_NO_VLAN) ? 0 : vf->vlan; in efx_ef10_sriov_get_vf_config()
790 ivf->qos = 0; in efx_ef10_sriov_get_vf_config()
794 nic_data->pf_index, in efx_ef10_sriov_get_vf_config()
803 return -EIO; in efx_ef10_sriov_get_vf_config()
804 ivf->linkstate = MCDI_DWORD(outbuf, LINK_STATE_MODE_OUT_OLD_MODE); in efx_ef10_sriov_get_vf_config()