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()
381 static int efx_ef10_pci_sriov_disable(struct efx_nic *efx, bool force) in efx_ef10_pci_sriov_disable() argument
383 struct pci_dev *dev = efx->pci_dev; in efx_ef10_pci_sriov_disable()
389 netif_info(efx, drv, efx->net_dev, "VFs are assigned to guests; " in efx_ef10_pci_sriov_disable()
397 efx_ef10_sriov_free_vf_vswitching(efx); in efx_ef10_pci_sriov_disable()
398 efx->vf_count = 0; in efx_ef10_pci_sriov_disable()
402 int efx_ef10_sriov_configure(struct efx_nic *efx, int num_vfs) in efx_ef10_sriov_configure() argument
405 return efx_ef10_pci_sriov_disable(efx, false); in efx_ef10_sriov_configure()
407 return efx_ef10_pci_sriov_enable(efx, num_vfs); in efx_ef10_sriov_configure()
410 int efx_ef10_sriov_init(struct efx_nic *efx) in efx_ef10_sriov_init() argument
415 void efx_ef10_sriov_fini(struct efx_nic *efx) in efx_ef10_sriov_fini() argument
417 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_sriov_fini()
423 if (pci_num_vf(efx->pci_dev) && !pci_vfs_assigned(efx->pci_dev)) in efx_ef10_sriov_fini()
424 pci_disable_sriov(efx->pci_dev); in efx_ef10_sriov_fini()
429 for (i = 0; i < efx->vf_count; ++i) { in efx_ef10_sriov_fini()
430 struct efx_nic *vf_efx = nic_data->vf[i].efx; in efx_ef10_sriov_fini()
436 rc = efx_ef10_pci_sriov_disable(efx, true); in efx_ef10_sriov_fini()
438 netif_dbg(efx, drv, efx->net_dev, in efx_ef10_sriov_fini()
441 netif_dbg(efx, drv, efx->net_dev, "SRIOV disabled\n"); in efx_ef10_sriov_fini()
444 static int efx_ef10_vport_del_vf_mac(struct efx_nic *efx, unsigned int port_id, in efx_ef10_vport_del_vf_mac() argument
455 rc = efx_mcdi_rpc(efx, MC_CMD_VPORT_DEL_MAC_ADDRESS, inbuf, in efx_ef10_vport_del_vf_mac()
461 int efx_ef10_sriov_set_vf_mac(struct efx_nic *efx, int vf_i, u8 *mac) in efx_ef10_sriov_set_vf_mac() argument
463 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_sriov_set_vf_mac()
470 if (vf_i >= efx->vf_count) in efx_ef10_sriov_set_vf_mac()
474 if (vf->efx) { in efx_ef10_sriov_set_vf_mac()
475 efx_device_detach_sync(vf->efx); in efx_ef10_sriov_set_vf_mac()
476 efx_net_stop(vf->efx->net_dev); in efx_ef10_sriov_set_vf_mac()
478 down_write(&vf->efx->filter_sem); in efx_ef10_sriov_set_vf_mac()
479 vf->efx->type->filter_table_remove(vf->efx); in efx_ef10_sriov_set_vf_mac()
481 rc = efx_ef10_vadaptor_free(vf->efx, EVB_PORT_ID_ASSIGNED); in efx_ef10_sriov_set_vf_mac()
483 up_write(&vf->efx->filter_sem); in efx_ef10_sriov_set_vf_mac()
488 rc = efx_ef10_evb_port_assign(efx, EVB_PORT_ID_NULL, vf_i); in efx_ef10_sriov_set_vf_mac()
493 rc = efx_ef10_vport_del_vf_mac(efx, vf->vport_id, vf->mac); in efx_ef10_sriov_set_vf_mac()
499 rc = efx_ef10_vport_add_mac(efx, vf->vport_id, mac); in efx_ef10_sriov_set_vf_mac()
504 if (vf->efx) in efx_ef10_sriov_set_vf_mac()
505 ether_addr_copy(vf->efx->net_dev->dev_addr, mac); in efx_ef10_sriov_set_vf_mac()
510 rc = efx_ef10_evb_port_assign(efx, vf->vport_id, vf_i); in efx_ef10_sriov_set_vf_mac()
514 if (vf->efx) { in efx_ef10_sriov_set_vf_mac()
516 rc = efx_ef10_vadaptor_alloc(vf->efx, EVB_PORT_ID_ASSIGNED); in efx_ef10_sriov_set_vf_mac()
518 up_write(&vf->efx->filter_sem); in efx_ef10_sriov_set_vf_mac()
521 vf->efx->type->filter_table_probe(vf->efx); in efx_ef10_sriov_set_vf_mac()
522 up_write(&vf->efx->filter_sem); in efx_ef10_sriov_set_vf_mac()
523 efx_net_open(vf->efx->net_dev); in efx_ef10_sriov_set_vf_mac()
524 netif_device_attach(vf->efx->net_dev); in efx_ef10_sriov_set_vf_mac()
534 int efx_ef10_sriov_set_vf_vlan(struct efx_nic *efx, int vf_i, u16 vlan, in efx_ef10_sriov_set_vf_vlan() argument
537 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_sriov_set_vf_vlan()
542 if (vf_i >= efx->vf_count) in efx_ef10_sriov_set_vf_vlan()
553 if (vf->efx) { in efx_ef10_sriov_set_vf_vlan()
554 efx_device_detach_sync(vf->efx); in efx_ef10_sriov_set_vf_vlan()
555 efx_net_stop(vf->efx->net_dev); in efx_ef10_sriov_set_vf_vlan()
557 down_write(&vf->efx->filter_sem); in efx_ef10_sriov_set_vf_vlan()
558 vf->efx->type->filter_table_remove(vf->efx); in efx_ef10_sriov_set_vf_vlan()
560 rc = efx_ef10_vadaptor_free(vf->efx, EVB_PORT_ID_ASSIGNED); in efx_ef10_sriov_set_vf_vlan()
566 rc = efx_ef10_evb_port_assign(efx, EVB_PORT_ID_NULL, vf_i); in efx_ef10_sriov_set_vf_vlan()
568 netif_warn(efx, drv, efx->net_dev, in efx_ef10_sriov_set_vf_vlan()
570 netif_warn(efx, drv, efx->net_dev, in efx_ef10_sriov_set_vf_vlan()
572 netif_warn(efx, drv, efx->net_dev, in efx_ef10_sriov_set_vf_vlan()
580 rc = efx_ef10_vport_del_mac(efx, vf->vport_id, vf->mac); in efx_ef10_sriov_set_vf_vlan()
586 rc = efx_ef10_vport_free(efx, vf->vport_id); in efx_ef10_sriov_set_vf_vlan()
597 rc = efx_ef10_vport_alloc(efx, EVB_PORT_ID_ASSIGNED, in efx_ef10_sriov_set_vf_vlan()
605 rc2 = efx_ef10_vport_add_mac(efx, vf->vport_id, vf->mac); in efx_ef10_sriov_set_vf_vlan()
613 rc2 = efx_ef10_evb_port_assign(efx, vf->vport_id, vf_i); in efx_ef10_sriov_set_vf_vlan()
620 if (vf->efx) { in efx_ef10_sriov_set_vf_vlan()
621 rc2 = efx_ef10_vadaptor_alloc(vf->efx, EVB_PORT_ID_ASSIGNED); in efx_ef10_sriov_set_vf_vlan()
627 if (vf->efx) { in efx_ef10_sriov_set_vf_vlan()
628 rc2 = vf->efx->type->filter_table_probe(vf->efx); in efx_ef10_sriov_set_vf_vlan()
632 up_write(&vf->efx->filter_sem); in efx_ef10_sriov_set_vf_vlan()
634 up_write(&vf->efx->filter_sem); in efx_ef10_sriov_set_vf_vlan()
636 rc2 = efx_net_open(vf->efx->net_dev); in efx_ef10_sriov_set_vf_vlan()
640 netif_device_attach(vf->efx->net_dev); in efx_ef10_sriov_set_vf_vlan()
645 if (vf->efx) in efx_ef10_sriov_set_vf_vlan()
646 up_write(&vf->efx->filter_sem); in efx_ef10_sriov_set_vf_vlan()
649 if (vf->efx) { in efx_ef10_sriov_set_vf_vlan()
650 netif_err(efx, drv, efx->net_dev, in efx_ef10_sriov_set_vf_vlan()
652 efx_schedule_reset(vf->efx, RESET_TYPE_DATAPATH); in efx_ef10_sriov_set_vf_vlan()
654 netif_err(efx, drv, efx->net_dev, in efx_ef10_sriov_set_vf_vlan()
657 netif_err(efx, drv, efx->net_dev, in efx_ef10_sriov_set_vf_vlan()
664 int efx_ef10_sriov_set_vf_spoofchk(struct efx_nic *efx, int vf_i, in efx_ef10_sriov_set_vf_spoofchk() argument
670 int efx_ef10_sriov_set_vf_link_state(struct efx_nic *efx, int vf_i, in efx_ef10_sriov_set_vf_link_state() argument
674 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_sriov_set_vf_link_state()
687 return efx_mcdi_rpc(efx, MC_CMD_LINK_STATE_MODE, inbuf, sizeof(inbuf), in efx_ef10_sriov_set_vf_link_state()
691 int efx_ef10_sriov_get_vf_config(struct efx_nic *efx, int vf_i, in efx_ef10_sriov_get_vf_config() argument
697 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_sriov_get_vf_config()
702 if (vf_i >= efx->vf_count) in efx_ef10_sriov_get_vf_config()
723 rc = efx_mcdi_rpc(efx, MC_CMD_LINK_STATE_MODE, inbuf, sizeof(inbuf), in efx_ef10_sriov_get_vf_config()
734 int efx_ef10_sriov_get_phys_port_id(struct efx_nic *efx, in efx_ef10_sriov_get_phys_port_id() argument
737 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_sriov_get_phys_port_id()