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()
129 efx_ef10_evb_port_assign(efx, EVB_PORT_ID_NULL, i); 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()
139 efx_ef10_vport_free(efx, vf->vport_id); in efx_ef10_sriov_free_vf_vports()
143 vf->efx = NULL; in efx_ef10_sriov_free_vf_vports()
147 static void efx_ef10_sriov_free_vf_vswitching(struct efx_nic *efx) in efx_ef10_sriov_free_vf_vswitching() argument
149 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_sriov_free_vf_vswitching()
151 efx_ef10_sriov_free_vf_vports(efx); in efx_ef10_sriov_free_vf_vswitching()
156 static int efx_ef10_sriov_assign_vf_vport(struct efx_nic *efx, in efx_ef10_sriov_assign_vf_vport() argument
159 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_sriov_assign_vf_vport()
166 rc = efx_ef10_vport_alloc(efx, EVB_PORT_ID_ASSIGNED, 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()
178 rc = efx_ef10_evb_port_assign(efx, vf->vport_id, vf_i); in efx_ef10_sriov_assign_vf_vport()
186 static int efx_ef10_sriov_alloc_vf_vswitching(struct efx_nic *efx) in efx_ef10_sriov_alloc_vf_vswitching() argument
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()
197 for (i = 0; i < efx->vf_count; i++) { in efx_ef10_sriov_alloc_vf_vswitching()
199 nic_data->vf[i].efx = NULL; in efx_ef10_sriov_alloc_vf_vswitching()
202 rc = efx_ef10_sriov_assign_vf_vport(efx, i); in efx_ef10_sriov_alloc_vf_vswitching()
209 efx_ef10_sriov_free_vf_vswitching(efx); in efx_ef10_sriov_alloc_vf_vswitching()
213 static int efx_ef10_sriov_restore_vf_vswitching(struct efx_nic *efx) in efx_ef10_sriov_restore_vf_vswitching() argument
218 for (i = 0; i < efx->vf_count; i++) { in efx_ef10_sriov_restore_vf_vswitching()
219 rc = efx_ef10_sriov_assign_vf_vport(efx, i); in efx_ef10_sriov_restore_vf_vswitching()
226 efx_ef10_sriov_free_vf_vswitching(efx); in efx_ef10_sriov_restore_vf_vswitching()
230 static int efx_ef10_vadaptor_alloc_set_features(struct efx_nic *efx) in efx_ef10_vadaptor_alloc_set_features() argument
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()
253 efx_ef10_vadaptor_free(efx, EVB_PORT_ID_ASSIGNED); in efx_ef10_vadaptor_alloc_set_features()
261 int efx_ef10_vswitching_probe_pf(struct efx_nic *efx) in efx_ef10_vswitching_probe_pf() argument
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()
269 efx_ef10_vadaptor_alloc_set_features(efx); in efx_ef10_vswitching_probe_pf()
273 rc = efx_ef10_vswitch_alloc(efx, EVB_PORT_ID_ASSIGNED, in efx_ef10_vswitching_probe_pf()
278 rc = efx_ef10_vport_alloc(efx, EVB_PORT_ID_ASSIGNED, 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()
289 rc = efx_ef10_vadaptor_alloc_set_features(efx); 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()
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()
301 efx_ef10_vswitch_free(efx, EVB_PORT_ID_ASSIGNED); in efx_ef10_vswitching_probe_pf()
306 int efx_ef10_vswitching_probe_vf(struct efx_nic *efx) in efx_ef10_vswitching_probe_vf() argument
308 return efx_ef10_vadaptor_alloc_set_features(efx); in efx_ef10_vswitching_probe_vf()
311 int efx_ef10_vswitching_restore_pf(struct efx_nic *efx) in efx_ef10_vswitching_restore_pf() argument
313 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_vswitching_restore_pf()
319 rc = efx_ef10_vswitching_probe_pf(efx); in efx_ef10_vswitching_restore_pf()
323 rc = efx_ef10_sriov_restore_vf_vswitching(efx); in efx_ef10_vswitching_restore_pf()
332 int efx_ef10_vswitching_restore_vf(struct efx_nic *efx) in efx_ef10_vswitching_restore_vf() argument
334 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_vswitching_restore_vf()
340 rc = efx_ef10_vadaptor_free(efx, EVB_PORT_ID_ASSIGNED); in efx_ef10_vswitching_restore_vf()
348 void efx_ef10_vswitching_remove_pf(struct efx_nic *efx) in efx_ef10_vswitching_remove_pf() argument
350 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_vswitching_remove_pf()
352 efx_ef10_sriov_free_vf_vswitching(efx); 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()
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()
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()
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()
372 void efx_ef10_vswitching_remove_vf(struct efx_nic *efx) in efx_ef10_vswitching_remove_vf() argument
374 efx_ef10_vadaptor_free(efx, EVB_PORT_ID_ASSIGNED); in efx_ef10_vswitching_remove_vf()
377 static int efx_ef10_pci_sriov_enable(struct efx_nic *efx, int num_vfs) in efx_ef10_pci_sriov_enable() argument
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()
384 rc = efx_ef10_sriov_alloc_vf_vswitching(efx); in efx_ef10_pci_sriov_enable()
394 efx_ef10_sriov_free_vf_vswitching(efx); 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()
408 static int efx_ef10_pci_sriov_disable(struct efx_nic *efx, bool force) in efx_ef10_pci_sriov_disable() argument
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()
422 for (i = 0; i < efx->vf_count; i++) in efx_ef10_pci_sriov_disable()
429 efx_ef10_sriov_free_vf_vswitching(efx); in efx_ef10_pci_sriov_disable()
430 efx->vf_count = 0; in efx_ef10_pci_sriov_disable()
434 int efx_ef10_sriov_configure(struct efx_nic *efx, int num_vfs) in efx_ef10_sriov_configure() argument
437 return efx_ef10_pci_sriov_disable(efx, false); in efx_ef10_sriov_configure()
439 return efx_ef10_pci_sriov_enable(efx, num_vfs); in efx_ef10_sriov_configure()
442 int efx_ef10_sriov_init(struct efx_nic *efx) in efx_ef10_sriov_init() argument
447 void efx_ef10_sriov_fini(struct efx_nic *efx) in efx_ef10_sriov_fini() argument
449 struct efx_ef10_nic_data *nic_data = efx->nic_data; 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()
462 rc = efx_ef10_pci_sriov_disable(efx, true); 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()
470 static int efx_ef10_vport_del_vf_mac(struct efx_nic *efx, unsigned int port_id, in efx_ef10_vport_del_vf_mac() argument
481 rc = efx_mcdi_rpc(efx, MC_CMD_VPORT_DEL_MAC_ADDRESS, inbuf, 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()
496 if (vf_i >= efx->vf_count) 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()
511 rc = efx_ef10_evb_port_assign(efx, EVB_PORT_ID_NULL, vf_i); 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()
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()
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()
553 int efx_ef10_sriov_set_vf_vlan(struct efx_nic *efx, int vf_i, u16 vlan, in efx_ef10_sriov_set_vf_vlan() argument
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()
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()
585 rc = efx_ef10_evb_port_assign(efx, EVB_PORT_ID_NULL, vf_i); 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()
599 rc = efx_ef10_vport_del_mac(efx, vf->vport_id, vf->mac); in efx_ef10_sriov_set_vf_vlan()
605 rc = efx_ef10_vport_free(efx, vf->vport_id); in efx_ef10_sriov_set_vf_vlan()
615 rc = efx_ef10_vport_alloc(efx, EVB_PORT_ID_ASSIGNED, 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()
631 rc2 = efx_ef10_evb_port_assign(efx, vf->vport_id, vf_i); 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()
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()
672 netif_err(efx, drv, efx->net_dev, in efx_ef10_sriov_set_vf_vlan()
679 static int efx_ef10_sriov_set_privilege_mask(struct efx_nic *efx, int vf_i, in efx_ef10_sriov_set_privilege_mask() argument
684 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_sriov_set_privilege_mask()
696 rc = efx_mcdi_rpc(efx, MC_CMD_PRIVILEGE_MASK, in efx_ef10_sriov_set_privilege_mask()
718 rc = efx_mcdi_rpc(efx, MC_CMD_PRIVILEGE_MASK, in efx_ef10_sriov_set_privilege_mask()
730 int efx_ef10_sriov_set_vf_spoofchk(struct efx_nic *efx, int vf_i, bool spoofchk) in efx_ef10_sriov_set_vf_spoofchk() argument
732 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_sriov_set_vf_spoofchk()
740 return efx_ef10_sriov_set_privilege_mask(efx, vf_i, in efx_ef10_sriov_set_vf_spoofchk()
745 int efx_ef10_sriov_set_vf_link_state(struct efx_nic *efx, int vf_i, in efx_ef10_sriov_set_vf_link_state() argument
749 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_sriov_set_vf_link_state()
762 return efx_mcdi_rpc(efx, MC_CMD_LINK_STATE_MODE, inbuf, sizeof(inbuf), in efx_ef10_sriov_set_vf_link_state()
766 int efx_ef10_sriov_get_vf_config(struct efx_nic *efx, int vf_i, in efx_ef10_sriov_get_vf_config() argument
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()
798 rc = efx_mcdi_rpc(efx, MC_CMD_LINK_STATE_MODE, inbuf, sizeof(inbuf), in efx_ef10_sriov_get_vf_config()