Lines Matching refs:efx
17 static int efx_ef10_evb_port_assign(struct efx_nic *efx, unsigned int port_id, in efx_ef10_evb_port_assign() argument
21 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_evb_port_assign()
28 return efx_mcdi_rpc(efx, MC_CMD_EVB_PORT_ASSIGN, inbuf, sizeof(inbuf), in efx_ef10_evb_port_assign()
32 static int efx_ef10_vswitch_alloc(struct efx_nic *efx, unsigned int port_id, in efx_ef10_vswitch_alloc() argument
45 rc = efx_mcdi_rpc_quiet(efx, MC_CMD_VSWITCH_ALLOC, inbuf, sizeof(inbuf), in efx_ef10_vswitch_alloc()
51 rc = efx_mcdi_rpc(efx, MC_CMD_VSWITCH_ALLOC, inbuf, in efx_ef10_vswitch_alloc()
54 efx_mcdi_display_error(efx, MC_CMD_VSWITCH_ALLOC, in efx_ef10_vswitch_alloc()
61 static int efx_ef10_vswitch_free(struct efx_nic *efx, unsigned int port_id) in efx_ef10_vswitch_free() argument
67 return efx_mcdi_rpc(efx, MC_CMD_VSWITCH_FREE, inbuf, sizeof(inbuf), in efx_ef10_vswitch_free()
71 static int efx_ef10_vport_alloc(struct efx_nic *efx, in efx_ef10_vport_alloc() argument
94 rc = efx_mcdi_rpc(efx, MC_CMD_VPORT_ALLOC, inbuf, sizeof(inbuf), in efx_ef10_vport_alloc()
105 static int efx_ef10_vport_free(struct efx_nic *efx, unsigned int port_id) in efx_ef10_vport_free() argument
111 return efx_mcdi_rpc(efx, MC_CMD_VPORT_FREE, inbuf, sizeof(inbuf), in efx_ef10_vport_free()
115 static void efx_ef10_sriov_free_vf_vports(struct efx_nic *efx) in efx_ef10_sriov_free_vf_vports() argument
117 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_sriov_free_vf_vports()
123 for (i = 0; i < efx->vf_count; i++) { in efx_ef10_sriov_free_vf_vports()
132 efx_ef10_evb_port_assign(efx, EVB_PORT_ID_NULL, i); in efx_ef10_sriov_free_vf_vports()
137 efx_ef10_vport_del_mac(efx, vf->vport_id, vf->mac); in efx_ef10_sriov_free_vf_vports()
142 efx_ef10_vport_free(efx, vf->vport_id); in efx_ef10_sriov_free_vf_vports()
146 vf->efx = NULL; in efx_ef10_sriov_free_vf_vports()
150 static void efx_ef10_sriov_free_vf_vswitching(struct efx_nic *efx) in efx_ef10_sriov_free_vf_vswitching() argument
152 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_sriov_free_vf_vswitching()
154 efx_ef10_sriov_free_vf_vports(efx); in efx_ef10_sriov_free_vf_vswitching()
159 static int efx_ef10_sriov_assign_vf_vport(struct efx_nic *efx, in efx_ef10_sriov_assign_vf_vport() argument
162 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_sriov_assign_vf_vport()
169 rc = efx_ef10_vport_alloc(efx, EVB_PORT_ID_ASSIGNED, in efx_ef10_sriov_assign_vf_vport()
175 rc = efx_ef10_vport_add_mac(efx, vf->vport_id, vf->mac); in efx_ef10_sriov_assign_vf_vport()
181 rc = efx_ef10_evb_port_assign(efx, vf->vport_id, vf_i); in efx_ef10_sriov_assign_vf_vport()
189 static int efx_ef10_sriov_alloc_vf_vswitching(struct efx_nic *efx) in efx_ef10_sriov_alloc_vf_vswitching() argument
191 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_sriov_alloc_vf_vswitching()
195 nic_data->vf = kcalloc(efx->vf_count, sizeof(struct ef10_vf), in efx_ef10_sriov_alloc_vf_vswitching()
200 for (i = 0; i < efx->vf_count; i++) { in efx_ef10_sriov_alloc_vf_vswitching()
202 nic_data->vf[i].efx = NULL; in efx_ef10_sriov_alloc_vf_vswitching()
205 rc = efx_ef10_sriov_assign_vf_vport(efx, i); in efx_ef10_sriov_alloc_vf_vswitching()
212 efx_ef10_sriov_free_vf_vports(efx); in efx_ef10_sriov_alloc_vf_vswitching()
218 static int efx_ef10_sriov_restore_vf_vswitching(struct efx_nic *efx) in efx_ef10_sriov_restore_vf_vswitching() argument
223 for (i = 0; i < efx->vf_count; i++) { in efx_ef10_sriov_restore_vf_vswitching()
224 rc = efx_ef10_sriov_assign_vf_vport(efx, i); in efx_ef10_sriov_restore_vf_vswitching()
231 efx_ef10_sriov_free_vf_vswitching(efx); in efx_ef10_sriov_restore_vf_vswitching()
238 int efx_ef10_vswitching_probe_pf(struct efx_nic *efx) in efx_ef10_vswitching_probe_pf() argument
240 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_vswitching_probe_pf()
241 struct net_device *net_dev = efx->net_dev; in efx_ef10_vswitching_probe_pf()
244 if (pci_sriov_get_totalvfs(efx->pci_dev) <= 0) { in efx_ef10_vswitching_probe_pf()
246 efx_ef10_vadaptor_alloc(efx, nic_data->vport_id); in efx_ef10_vswitching_probe_pf()
250 rc = efx_ef10_vswitch_alloc(efx, EVB_PORT_ID_ASSIGNED, in efx_ef10_vswitching_probe_pf()
255 rc = efx_ef10_vport_alloc(efx, EVB_PORT_ID_ASSIGNED, in efx_ef10_vswitching_probe_pf()
261 rc = efx_ef10_vport_add_mac(efx, nic_data->vport_id, net_dev->dev_addr); in efx_ef10_vswitching_probe_pf()
266 rc = efx_ef10_vadaptor_alloc(efx, nic_data->vport_id); in efx_ef10_vswitching_probe_pf()
272 efx_ef10_vport_del_mac(efx, nic_data->vport_id, nic_data->vport_mac); in efx_ef10_vswitching_probe_pf()
275 efx_ef10_vport_free(efx, nic_data->vport_id); in efx_ef10_vswitching_probe_pf()
278 efx_ef10_vswitch_free(efx, EVB_PORT_ID_ASSIGNED); in efx_ef10_vswitching_probe_pf()
283 int efx_ef10_vswitching_probe_vf(struct efx_nic *efx) in efx_ef10_vswitching_probe_vf() argument
285 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_vswitching_probe_vf()
287 return efx_ef10_vadaptor_alloc(efx, nic_data->vport_id); in efx_ef10_vswitching_probe_vf()
290 int efx_ef10_vswitching_restore_pf(struct efx_nic *efx) in efx_ef10_vswitching_restore_pf() argument
292 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_vswitching_restore_pf()
298 rc = efx_ef10_vswitching_probe_pf(efx); in efx_ef10_vswitching_restore_pf()
302 rc = efx_ef10_sriov_restore_vf_vswitching(efx); in efx_ef10_vswitching_restore_pf()
311 int efx_ef10_vswitching_restore_vf(struct efx_nic *efx) in efx_ef10_vswitching_restore_vf() argument
313 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_vswitching_restore_vf()
319 rc = efx_ef10_vadaptor_free(efx, EVB_PORT_ID_ASSIGNED); in efx_ef10_vswitching_restore_vf()
327 void efx_ef10_vswitching_remove_pf(struct efx_nic *efx) in efx_ef10_vswitching_remove_pf() argument
329 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_vswitching_remove_pf()
331 efx_ef10_sriov_free_vf_vswitching(efx); in efx_ef10_vswitching_remove_pf()
333 efx_ef10_vadaptor_free(efx, nic_data->vport_id); in efx_ef10_vswitching_remove_pf()
339 efx_ef10_vport_del_mac(efx, nic_data->vport_id, in efx_ef10_vswitching_remove_pf()
340 efx->net_dev->dev_addr); in efx_ef10_vswitching_remove_pf()
343 efx_ef10_vport_free(efx, nic_data->vport_id); in efx_ef10_vswitching_remove_pf()
347 if (!pci_vfs_assigned(efx->pci_dev)) in efx_ef10_vswitching_remove_pf()
348 efx_ef10_vswitch_free(efx, nic_data->vport_id); in efx_ef10_vswitching_remove_pf()
351 void efx_ef10_vswitching_remove_vf(struct efx_nic *efx) in efx_ef10_vswitching_remove_vf() argument
353 efx_ef10_vadaptor_free(efx, EVB_PORT_ID_ASSIGNED); in efx_ef10_vswitching_remove_vf()
356 static int efx_ef10_pci_sriov_enable(struct efx_nic *efx, int num_vfs) in efx_ef10_pci_sriov_enable() argument
359 struct pci_dev *dev = efx->pci_dev; in efx_ef10_pci_sriov_enable()
361 efx->vf_count = num_vfs; in efx_ef10_pci_sriov_enable()
363 rc = efx_ef10_sriov_alloc_vf_vswitching(efx); in efx_ef10_pci_sriov_enable()
373 efx_ef10_sriov_free_vf_vswitching(efx); in efx_ef10_pci_sriov_enable()
375 efx->vf_count = 0; in efx_ef10_pci_sriov_enable()
376 netif_err(efx, probe, efx->net_dev, in efx_ef10_pci_sriov_enable()
387 static int efx_ef10_pci_sriov_disable(struct efx_nic *efx, bool force) in efx_ef10_pci_sriov_disable() argument
389 struct pci_dev *dev = efx->pci_dev; in efx_ef10_pci_sriov_disable()
394 netif_info(efx, drv, efx->net_dev, "VFs are assigned to guests; " in efx_ef10_pci_sriov_disable()
404 efx_ef10_sriov_free_vf_vswitching(efx); in efx_ef10_pci_sriov_disable()
405 efx->vf_count = 0; in efx_ef10_pci_sriov_disable()
409 int efx_ef10_sriov_configure(struct efx_nic *efx, int num_vfs) in efx_ef10_sriov_configure() argument
412 return efx_ef10_pci_sriov_disable(efx, false); in efx_ef10_sriov_configure()
414 return efx_ef10_pci_sriov_enable(efx, num_vfs); in efx_ef10_sriov_configure()
417 int efx_ef10_sriov_init(struct efx_nic *efx) in efx_ef10_sriov_init() argument
422 void efx_ef10_sriov_fini(struct efx_nic *efx) in efx_ef10_sriov_fini() argument
424 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_sriov_fini()
429 if (pci_num_vf(efx->pci_dev) && !pci_vfs_assigned(efx->pci_dev)) in efx_ef10_sriov_fini()
430 pci_disable_sriov(efx->pci_dev); in efx_ef10_sriov_fini()
435 rc = efx_ef10_pci_sriov_disable(efx, true); in efx_ef10_sriov_fini()
437 netif_dbg(efx, drv, efx->net_dev, in efx_ef10_sriov_fini()
440 netif_dbg(efx, drv, efx->net_dev, "SRIOV disabled\n"); in efx_ef10_sriov_fini()
443 static int efx_ef10_vport_del_vf_mac(struct efx_nic *efx, unsigned int port_id, in efx_ef10_vport_del_vf_mac() argument
454 rc = efx_mcdi_rpc(efx, MC_CMD_VPORT_DEL_MAC_ADDRESS, inbuf, in efx_ef10_vport_del_vf_mac()
460 int efx_ef10_sriov_set_vf_mac(struct efx_nic *efx, int vf_i, u8 *mac) in efx_ef10_sriov_set_vf_mac() argument
462 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_sriov_set_vf_mac()
469 if (vf_i >= efx->vf_count) in efx_ef10_sriov_set_vf_mac()
473 if (vf->efx) { in efx_ef10_sriov_set_vf_mac()
474 efx_device_detach_sync(vf->efx); in efx_ef10_sriov_set_vf_mac()
475 efx_net_stop(vf->efx->net_dev); in efx_ef10_sriov_set_vf_mac()
477 down_write(&vf->efx->filter_sem); in efx_ef10_sriov_set_vf_mac()
478 vf->efx->type->filter_table_remove(vf->efx); in efx_ef10_sriov_set_vf_mac()
480 rc = efx_ef10_vadaptor_free(vf->efx, EVB_PORT_ID_ASSIGNED); in efx_ef10_sriov_set_vf_mac()
482 up_write(&vf->efx->filter_sem); in efx_ef10_sriov_set_vf_mac()
487 rc = efx_ef10_evb_port_assign(efx, EVB_PORT_ID_NULL, vf_i); in efx_ef10_sriov_set_vf_mac()
492 rc = efx_ef10_vport_del_vf_mac(efx, vf->vport_id, vf->mac); in efx_ef10_sriov_set_vf_mac()
498 rc = efx_ef10_vport_add_mac(efx, vf->vport_id, mac); in efx_ef10_sriov_set_vf_mac()
503 if (vf->efx) in efx_ef10_sriov_set_vf_mac()
504 ether_addr_copy(vf->efx->net_dev->dev_addr, mac); in efx_ef10_sriov_set_vf_mac()
509 rc = efx_ef10_evb_port_assign(efx, vf->vport_id, vf_i); in efx_ef10_sriov_set_vf_mac()
513 if (vf->efx) { in efx_ef10_sriov_set_vf_mac()
515 rc = efx_ef10_vadaptor_alloc(vf->efx, EVB_PORT_ID_ASSIGNED); in efx_ef10_sriov_set_vf_mac()
517 up_write(&vf->efx->filter_sem); in efx_ef10_sriov_set_vf_mac()
520 vf->efx->type->filter_table_probe(vf->efx); in efx_ef10_sriov_set_vf_mac()
521 up_write(&vf->efx->filter_sem); in efx_ef10_sriov_set_vf_mac()
522 efx_net_open(vf->efx->net_dev); in efx_ef10_sriov_set_vf_mac()
523 netif_device_attach(vf->efx->net_dev); in efx_ef10_sriov_set_vf_mac()
533 int efx_ef10_sriov_set_vf_vlan(struct efx_nic *efx, int vf_i, u16 vlan, in efx_ef10_sriov_set_vf_vlan() argument
536 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_sriov_set_vf_vlan()
541 if (vf_i >= efx->vf_count) in efx_ef10_sriov_set_vf_vlan()
552 if (vf->efx) { in efx_ef10_sriov_set_vf_vlan()
553 efx_device_detach_sync(vf->efx); in efx_ef10_sriov_set_vf_vlan()
554 efx_net_stop(vf->efx->net_dev); in efx_ef10_sriov_set_vf_vlan()
556 down_write(&vf->efx->filter_sem); in efx_ef10_sriov_set_vf_vlan()
557 vf->efx->type->filter_table_remove(vf->efx); in efx_ef10_sriov_set_vf_vlan()
559 rc = efx_ef10_vadaptor_free(vf->efx, EVB_PORT_ID_ASSIGNED); in efx_ef10_sriov_set_vf_vlan()
565 rc = efx_ef10_evb_port_assign(efx, EVB_PORT_ID_NULL, vf_i); in efx_ef10_sriov_set_vf_vlan()
567 netif_warn(efx, drv, efx->net_dev, in efx_ef10_sriov_set_vf_vlan()
569 netif_warn(efx, drv, efx->net_dev, in efx_ef10_sriov_set_vf_vlan()
571 netif_warn(efx, drv, efx->net_dev, in efx_ef10_sriov_set_vf_vlan()
579 rc = efx_ef10_vport_del_mac(efx, vf->vport_id, vf->mac); in efx_ef10_sriov_set_vf_vlan()
585 rc = efx_ef10_vport_free(efx, vf->vport_id); in efx_ef10_sriov_set_vf_vlan()
596 rc = efx_ef10_vport_alloc(efx, EVB_PORT_ID_ASSIGNED, in efx_ef10_sriov_set_vf_vlan()
604 rc2 = efx_ef10_vport_add_mac(efx, vf->vport_id, vf->mac); in efx_ef10_sriov_set_vf_vlan()
612 rc2 = efx_ef10_evb_port_assign(efx, vf->vport_id, vf_i); in efx_ef10_sriov_set_vf_vlan()
619 if (vf->efx) { in efx_ef10_sriov_set_vf_vlan()
620 rc2 = efx_ef10_vadaptor_alloc(vf->efx, EVB_PORT_ID_ASSIGNED); in efx_ef10_sriov_set_vf_vlan()
626 if (vf->efx) { in efx_ef10_sriov_set_vf_vlan()
627 rc2 = vf->efx->type->filter_table_probe(vf->efx); in efx_ef10_sriov_set_vf_vlan()
631 up_write(&vf->efx->filter_sem); in efx_ef10_sriov_set_vf_vlan()
633 up_write(&vf->efx->filter_sem); in efx_ef10_sriov_set_vf_vlan()
635 rc2 = efx_net_open(vf->efx->net_dev); in efx_ef10_sriov_set_vf_vlan()
639 netif_device_attach(vf->efx->net_dev); in efx_ef10_sriov_set_vf_vlan()
644 if (vf->efx) in efx_ef10_sriov_set_vf_vlan()
645 up_write(&vf->efx->filter_sem); in efx_ef10_sriov_set_vf_vlan()
648 if (vf->efx) { in efx_ef10_sriov_set_vf_vlan()
649 netif_err(efx, drv, efx->net_dev, in efx_ef10_sriov_set_vf_vlan()
651 efx_schedule_reset(vf->efx, RESET_TYPE_DATAPATH); in efx_ef10_sriov_set_vf_vlan()
653 netif_err(efx, drv, efx->net_dev, in efx_ef10_sriov_set_vf_vlan()
656 netif_err(efx, drv, efx->net_dev, in efx_ef10_sriov_set_vf_vlan()
663 int efx_ef10_sriov_set_vf_spoofchk(struct efx_nic *efx, int vf_i, in efx_ef10_sriov_set_vf_spoofchk() argument
669 int efx_ef10_sriov_set_vf_link_state(struct efx_nic *efx, int vf_i, in efx_ef10_sriov_set_vf_link_state() argument
673 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_sriov_set_vf_link_state()
686 return efx_mcdi_rpc(efx, MC_CMD_LINK_STATE_MODE, inbuf, sizeof(inbuf), in efx_ef10_sriov_set_vf_link_state()
690 int efx_ef10_sriov_get_vf_config(struct efx_nic *efx, int vf_i, in efx_ef10_sriov_get_vf_config() argument
696 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_sriov_get_vf_config()
701 if (vf_i >= efx->vf_count) in efx_ef10_sriov_get_vf_config()
722 rc = efx_mcdi_rpc(efx, MC_CMD_LINK_STATE_MODE, inbuf, sizeof(inbuf), in efx_ef10_sriov_get_vf_config()
733 int efx_ef10_sriov_get_phys_port_id(struct efx_nic *efx, in efx_ef10_sriov_get_phys_port_id() argument
736 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_sriov_get_phys_port_id()