Lines Matching refs:efx
15 static int efx_ef10_evb_port_assign(struct efx_nic *efx, unsigned int port_id, in efx_ef10_evb_port_assign() argument
19 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_evb_port_assign()
26 return efx_mcdi_rpc(efx, MC_CMD_EVB_PORT_ASSIGN, inbuf, sizeof(inbuf), in efx_ef10_evb_port_assign()
30 static int efx_ef10_vswitch_alloc(struct efx_nic *efx, unsigned int port_id, in efx_ef10_vswitch_alloc() argument
43 rc = efx_mcdi_rpc_quiet(efx, MC_CMD_VSWITCH_ALLOC, inbuf, sizeof(inbuf), in efx_ef10_vswitch_alloc()
49 rc = efx_mcdi_rpc(efx, MC_CMD_VSWITCH_ALLOC, inbuf, in efx_ef10_vswitch_alloc()
52 efx_mcdi_display_error(efx, MC_CMD_VSWITCH_ALLOC, in efx_ef10_vswitch_alloc()
59 static int efx_ef10_vswitch_free(struct efx_nic *efx, unsigned int port_id) in efx_ef10_vswitch_free() argument
65 return efx_mcdi_rpc(efx, MC_CMD_VSWITCH_FREE, inbuf, sizeof(inbuf), in efx_ef10_vswitch_free()
69 static int efx_ef10_vport_alloc(struct efx_nic *efx, in efx_ef10_vport_alloc() argument
92 rc = efx_mcdi_rpc(efx, MC_CMD_VPORT_ALLOC, inbuf, sizeof(inbuf), in efx_ef10_vport_alloc()
103 static int efx_ef10_vport_free(struct efx_nic *efx, unsigned int port_id) in efx_ef10_vport_free() argument
109 return efx_mcdi_rpc(efx, MC_CMD_VPORT_FREE, inbuf, sizeof(inbuf), in efx_ef10_vport_free()
113 static void efx_ef10_sriov_free_vf_vports(struct efx_nic *efx) in efx_ef10_sriov_free_vf_vports() argument
115 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_sriov_free_vf_vports()
121 for (i = 0; i < efx->vf_count; i++) { in efx_ef10_sriov_free_vf_vports()
130 efx_ef10_evb_port_assign(efx, EVB_PORT_ID_NULL, i); in efx_ef10_sriov_free_vf_vports()
135 efx_ef10_vport_del_mac(efx, vf->vport_id, vf->mac); in efx_ef10_sriov_free_vf_vports()
140 efx_ef10_vport_free(efx, vf->vport_id); in efx_ef10_sriov_free_vf_vports()
144 vf->efx = NULL; in efx_ef10_sriov_free_vf_vports()
148 static void efx_ef10_sriov_free_vf_vswitching(struct efx_nic *efx) in efx_ef10_sriov_free_vf_vswitching() argument
150 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_sriov_free_vf_vswitching()
152 efx_ef10_sriov_free_vf_vports(efx); in efx_ef10_sriov_free_vf_vswitching()
157 static int efx_ef10_sriov_assign_vf_vport(struct efx_nic *efx, in efx_ef10_sriov_assign_vf_vport() argument
160 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_sriov_assign_vf_vport()
167 rc = efx_ef10_vport_alloc(efx, EVB_PORT_ID_ASSIGNED, in efx_ef10_sriov_assign_vf_vport()
173 rc = efx_ef10_vport_add_mac(efx, vf->vport_id, vf->mac); in efx_ef10_sriov_assign_vf_vport()
179 rc = efx_ef10_evb_port_assign(efx, vf->vport_id, vf_i); in efx_ef10_sriov_assign_vf_vport()
187 static int efx_ef10_sriov_alloc_vf_vswitching(struct efx_nic *efx) in efx_ef10_sriov_alloc_vf_vswitching() argument
189 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_sriov_alloc_vf_vswitching()
193 nic_data->vf = kcalloc(efx->vf_count, sizeof(struct ef10_vf), in efx_ef10_sriov_alloc_vf_vswitching()
198 for (i = 0; i < efx->vf_count; i++) { in efx_ef10_sriov_alloc_vf_vswitching()
200 nic_data->vf[i].efx = NULL; in efx_ef10_sriov_alloc_vf_vswitching()
203 rc = efx_ef10_sriov_assign_vf_vport(efx, i); in efx_ef10_sriov_alloc_vf_vswitching()
210 efx_ef10_sriov_free_vf_vports(efx); in efx_ef10_sriov_alloc_vf_vswitching()
216 static int efx_ef10_sriov_restore_vf_vswitching(struct efx_nic *efx) in efx_ef10_sriov_restore_vf_vswitching() argument
221 for (i = 0; i < efx->vf_count; i++) { in efx_ef10_sriov_restore_vf_vswitching()
222 rc = efx_ef10_sriov_assign_vf_vport(efx, i); in efx_ef10_sriov_restore_vf_vswitching()
229 efx_ef10_sriov_free_vf_vswitching(efx); in efx_ef10_sriov_restore_vf_vswitching()
233 static int efx_ef10_vadaptor_alloc_set_features(struct efx_nic *efx) in efx_ef10_vadaptor_alloc_set_features() argument
235 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_vadaptor_alloc_set_features()
239 rc = efx_ef10_vadaptor_alloc(efx, nic_data->vport_id); in efx_ef10_vadaptor_alloc_set_features()
243 rc = efx_ef10_vadaptor_query(efx, nic_data->vport_id, in efx_ef10_vadaptor_alloc_set_features()
250 efx->fixed_features |= NETIF_F_HW_VLAN_CTAG_FILTER; in efx_ef10_vadaptor_alloc_set_features()
252 efx->fixed_features &= ~NETIF_F_HW_VLAN_CTAG_FILTER; in efx_ef10_vadaptor_alloc_set_features()
257 efx_ef10_vadaptor_free(efx, EVB_PORT_ID_ASSIGNED); in efx_ef10_vadaptor_alloc_set_features()
265 int efx_ef10_vswitching_probe_pf(struct efx_nic *efx) in efx_ef10_vswitching_probe_pf() argument
267 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_vswitching_probe_pf()
268 struct net_device *net_dev = efx->net_dev; in efx_ef10_vswitching_probe_pf()
271 if (pci_sriov_get_totalvfs(efx->pci_dev) <= 0) { in efx_ef10_vswitching_probe_pf()
273 efx_ef10_vadaptor_alloc_set_features(efx); in efx_ef10_vswitching_probe_pf()
277 rc = efx_ef10_vswitch_alloc(efx, EVB_PORT_ID_ASSIGNED, in efx_ef10_vswitching_probe_pf()
282 rc = efx_ef10_vport_alloc(efx, EVB_PORT_ID_ASSIGNED, in efx_ef10_vswitching_probe_pf()
288 rc = efx_ef10_vport_add_mac(efx, nic_data->vport_id, net_dev->dev_addr); in efx_ef10_vswitching_probe_pf()
293 rc = efx_ef10_vadaptor_alloc_set_features(efx); in efx_ef10_vswitching_probe_pf()
299 efx_ef10_vport_del_mac(efx, nic_data->vport_id, nic_data->vport_mac); in efx_ef10_vswitching_probe_pf()
302 efx_ef10_vport_free(efx, nic_data->vport_id); in efx_ef10_vswitching_probe_pf()
305 efx_ef10_vswitch_free(efx, EVB_PORT_ID_ASSIGNED); in efx_ef10_vswitching_probe_pf()
310 int efx_ef10_vswitching_probe_vf(struct efx_nic *efx) in efx_ef10_vswitching_probe_vf() argument
312 return efx_ef10_vadaptor_alloc_set_features(efx); in efx_ef10_vswitching_probe_vf()
315 int efx_ef10_vswitching_restore_pf(struct efx_nic *efx) in efx_ef10_vswitching_restore_pf() argument
317 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_vswitching_restore_pf()
323 rc = efx_ef10_vswitching_probe_pf(efx); in efx_ef10_vswitching_restore_pf()
327 rc = efx_ef10_sriov_restore_vf_vswitching(efx); in efx_ef10_vswitching_restore_pf()
336 int efx_ef10_vswitching_restore_vf(struct efx_nic *efx) in efx_ef10_vswitching_restore_vf() argument
338 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_vswitching_restore_vf()
344 rc = efx_ef10_vadaptor_free(efx, EVB_PORT_ID_ASSIGNED); in efx_ef10_vswitching_restore_vf()
352 void efx_ef10_vswitching_remove_pf(struct efx_nic *efx) in efx_ef10_vswitching_remove_pf() argument
354 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_vswitching_remove_pf()
356 efx_ef10_sriov_free_vf_vswitching(efx); in efx_ef10_vswitching_remove_pf()
358 efx_ef10_vadaptor_free(efx, nic_data->vport_id); in efx_ef10_vswitching_remove_pf()
364 efx_ef10_vport_del_mac(efx, nic_data->vport_id, in efx_ef10_vswitching_remove_pf()
365 efx->net_dev->dev_addr); in efx_ef10_vswitching_remove_pf()
368 efx_ef10_vport_free(efx, nic_data->vport_id); in efx_ef10_vswitching_remove_pf()
372 if (!pci_vfs_assigned(efx->pci_dev)) in efx_ef10_vswitching_remove_pf()
373 efx_ef10_vswitch_free(efx, nic_data->vport_id); in efx_ef10_vswitching_remove_pf()
376 void efx_ef10_vswitching_remove_vf(struct efx_nic *efx) in efx_ef10_vswitching_remove_vf() argument
378 efx_ef10_vadaptor_free(efx, EVB_PORT_ID_ASSIGNED); in efx_ef10_vswitching_remove_vf()
381 static int efx_ef10_pci_sriov_enable(struct efx_nic *efx, int num_vfs) in efx_ef10_pci_sriov_enable() argument
384 struct pci_dev *dev = efx->pci_dev; in efx_ef10_pci_sriov_enable()
386 efx->vf_count = num_vfs; in efx_ef10_pci_sriov_enable()
388 rc = efx_ef10_sriov_alloc_vf_vswitching(efx); in efx_ef10_pci_sriov_enable()
398 efx_ef10_sriov_free_vf_vswitching(efx); in efx_ef10_pci_sriov_enable()
400 efx->vf_count = 0; in efx_ef10_pci_sriov_enable()
401 netif_err(efx, probe, efx->net_dev, in efx_ef10_pci_sriov_enable()
406 static int efx_ef10_pci_sriov_disable(struct efx_nic *efx, bool force) in efx_ef10_pci_sriov_disable() argument
408 struct pci_dev *dev = efx->pci_dev; in efx_ef10_pci_sriov_disable()
414 netif_info(efx, drv, efx->net_dev, "VFs are assigned to guests; " in efx_ef10_pci_sriov_disable()
422 efx_ef10_sriov_free_vf_vswitching(efx); in efx_ef10_pci_sriov_disable()
423 efx->vf_count = 0; in efx_ef10_pci_sriov_disable()
427 int efx_ef10_sriov_configure(struct efx_nic *efx, int num_vfs) in efx_ef10_sriov_configure() argument
430 return efx_ef10_pci_sriov_disable(efx, false); in efx_ef10_sriov_configure()
432 return efx_ef10_pci_sriov_enable(efx, num_vfs); in efx_ef10_sriov_configure()
435 int efx_ef10_sriov_init(struct efx_nic *efx) in efx_ef10_sriov_init() argument
440 void efx_ef10_sriov_fini(struct efx_nic *efx) in efx_ef10_sriov_fini() argument
442 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_sriov_fini()
448 if (pci_num_vf(efx->pci_dev) && !pci_vfs_assigned(efx->pci_dev)) in efx_ef10_sriov_fini()
449 pci_disable_sriov(efx->pci_dev); in efx_ef10_sriov_fini()
454 for (i = 0; i < efx->vf_count; ++i) { in efx_ef10_sriov_fini()
455 struct efx_nic *vf_efx = nic_data->vf[i].efx; in efx_ef10_sriov_fini()
461 rc = efx_ef10_pci_sriov_disable(efx, true); in efx_ef10_sriov_fini()
463 netif_dbg(efx, drv, efx->net_dev, in efx_ef10_sriov_fini()
466 netif_dbg(efx, drv, efx->net_dev, "SRIOV disabled\n"); in efx_ef10_sriov_fini()
469 static int efx_ef10_vport_del_vf_mac(struct efx_nic *efx, unsigned int port_id, in efx_ef10_vport_del_vf_mac() argument
480 rc = efx_mcdi_rpc(efx, MC_CMD_VPORT_DEL_MAC_ADDRESS, inbuf, in efx_ef10_vport_del_vf_mac()
486 int efx_ef10_sriov_set_vf_mac(struct efx_nic *efx, int vf_i, u8 *mac) in efx_ef10_sriov_set_vf_mac() argument
488 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_sriov_set_vf_mac()
495 if (vf_i >= efx->vf_count) in efx_ef10_sriov_set_vf_mac()
499 if (vf->efx) { in efx_ef10_sriov_set_vf_mac()
500 efx_device_detach_sync(vf->efx); in efx_ef10_sriov_set_vf_mac()
501 efx_net_stop(vf->efx->net_dev); in efx_ef10_sriov_set_vf_mac()
503 down_write(&vf->efx->filter_sem); 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()
508 up_write(&vf->efx->filter_sem); in efx_ef10_sriov_set_vf_mac()
513 rc = efx_ef10_evb_port_assign(efx, EVB_PORT_ID_NULL, vf_i); in efx_ef10_sriov_set_vf_mac()
518 rc = efx_ef10_vport_del_vf_mac(efx, vf->vport_id, vf->mac); in efx_ef10_sriov_set_vf_mac()
524 rc = efx_ef10_vport_add_mac(efx, vf->vport_id, mac); in efx_ef10_sriov_set_vf_mac()
529 if (vf->efx) in efx_ef10_sriov_set_vf_mac()
530 ether_addr_copy(vf->efx->net_dev->dev_addr, mac); in efx_ef10_sriov_set_vf_mac()
535 rc = efx_ef10_evb_port_assign(efx, vf->vport_id, vf_i); in efx_ef10_sriov_set_vf_mac()
539 if (vf->efx) { in efx_ef10_sriov_set_vf_mac()
541 rc = efx_ef10_vadaptor_alloc(vf->efx, EVB_PORT_ID_ASSIGNED); in efx_ef10_sriov_set_vf_mac()
543 up_write(&vf->efx->filter_sem); in efx_ef10_sriov_set_vf_mac()
546 vf->efx->type->filter_table_probe(vf->efx); in efx_ef10_sriov_set_vf_mac()
547 up_write(&vf->efx->filter_sem); in efx_ef10_sriov_set_vf_mac()
548 efx_net_open(vf->efx->net_dev); in efx_ef10_sriov_set_vf_mac()
549 efx_device_attach_if_not_resetting(vf->efx); in efx_ef10_sriov_set_vf_mac()
559 int efx_ef10_sriov_set_vf_vlan(struct efx_nic *efx, int vf_i, u16 vlan, in efx_ef10_sriov_set_vf_vlan() argument
562 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_sriov_set_vf_vlan()
567 if (vf_i >= efx->vf_count) in efx_ef10_sriov_set_vf_vlan()
578 if (vf->efx) { in efx_ef10_sriov_set_vf_vlan()
579 efx_device_detach_sync(vf->efx); in efx_ef10_sriov_set_vf_vlan()
580 efx_net_stop(vf->efx->net_dev); in efx_ef10_sriov_set_vf_vlan()
582 mutex_lock(&vf->efx->mac_lock); in efx_ef10_sriov_set_vf_vlan()
583 down_write(&vf->efx->filter_sem); in efx_ef10_sriov_set_vf_vlan()
584 vf->efx->type->filter_table_remove(vf->efx); in efx_ef10_sriov_set_vf_vlan()
586 rc = efx_ef10_vadaptor_free(vf->efx, EVB_PORT_ID_ASSIGNED); in efx_ef10_sriov_set_vf_vlan()
592 rc = efx_ef10_evb_port_assign(efx, EVB_PORT_ID_NULL, vf_i); in efx_ef10_sriov_set_vf_vlan()
594 netif_warn(efx, drv, efx->net_dev, in efx_ef10_sriov_set_vf_vlan()
596 netif_warn(efx, drv, efx->net_dev, in efx_ef10_sriov_set_vf_vlan()
598 netif_warn(efx, drv, efx->net_dev, in efx_ef10_sriov_set_vf_vlan()
606 rc = efx_ef10_vport_del_mac(efx, vf->vport_id, vf->mac); in efx_ef10_sriov_set_vf_vlan()
612 rc = efx_ef10_vport_free(efx, vf->vport_id); in efx_ef10_sriov_set_vf_vlan()
622 rc = efx_ef10_vport_alloc(efx, EVB_PORT_ID_ASSIGNED, in efx_ef10_sriov_set_vf_vlan()
630 rc2 = efx_ef10_vport_add_mac(efx, vf->vport_id, vf->mac); in efx_ef10_sriov_set_vf_vlan()
638 rc2 = efx_ef10_evb_port_assign(efx, vf->vport_id, vf_i); in efx_ef10_sriov_set_vf_vlan()
645 if (vf->efx) { in efx_ef10_sriov_set_vf_vlan()
646 rc2 = efx_ef10_vadaptor_alloc(vf->efx, EVB_PORT_ID_ASSIGNED); in efx_ef10_sriov_set_vf_vlan()
652 if (vf->efx) { in efx_ef10_sriov_set_vf_vlan()
653 rc2 = vf->efx->type->filter_table_probe(vf->efx); in efx_ef10_sriov_set_vf_vlan()
657 up_write(&vf->efx->filter_sem); in efx_ef10_sriov_set_vf_vlan()
658 mutex_unlock(&vf->efx->mac_lock); in efx_ef10_sriov_set_vf_vlan()
660 rc2 = efx_net_open(vf->efx->net_dev); in efx_ef10_sriov_set_vf_vlan()
664 efx_device_attach_if_not_resetting(vf->efx); in efx_ef10_sriov_set_vf_vlan()
669 if (vf->efx) { in efx_ef10_sriov_set_vf_vlan()
670 up_write(&vf->efx->filter_sem); in efx_ef10_sriov_set_vf_vlan()
671 mutex_unlock(&vf->efx->mac_lock); in efx_ef10_sriov_set_vf_vlan()
674 if (vf->efx) { in efx_ef10_sriov_set_vf_vlan()
675 netif_err(efx, drv, efx->net_dev, in efx_ef10_sriov_set_vf_vlan()
677 efx_schedule_reset(vf->efx, RESET_TYPE_DATAPATH); in efx_ef10_sriov_set_vf_vlan()
679 netif_err(efx, drv, efx->net_dev, in efx_ef10_sriov_set_vf_vlan()
682 netif_err(efx, drv, efx->net_dev, in efx_ef10_sriov_set_vf_vlan()
689 int efx_ef10_sriov_set_vf_spoofchk(struct efx_nic *efx, int vf_i, in efx_ef10_sriov_set_vf_spoofchk() argument
695 int efx_ef10_sriov_set_vf_link_state(struct efx_nic *efx, int vf_i, in efx_ef10_sriov_set_vf_link_state() argument
699 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_sriov_set_vf_link_state()
712 return efx_mcdi_rpc(efx, MC_CMD_LINK_STATE_MODE, inbuf, sizeof(inbuf), in efx_ef10_sriov_set_vf_link_state()
716 int efx_ef10_sriov_get_vf_config(struct efx_nic *efx, int vf_i, in efx_ef10_sriov_get_vf_config() argument
722 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_sriov_get_vf_config()
727 if (vf_i >= efx->vf_count) in efx_ef10_sriov_get_vf_config()
748 rc = efx_mcdi_rpc(efx, MC_CMD_LINK_STATE_MODE, inbuf, sizeof(inbuf), in efx_ef10_sriov_get_vf_config()