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
238 rc = efx_ef10_vadaptor_alloc(efx, efx->vport_id); in efx_ef10_vadaptor_alloc_set_features()
242 rc = efx_ef10_vadaptor_query(efx, efx->vport_id, in efx_ef10_vadaptor_alloc_set_features()
249 efx->fixed_features |= NETIF_F_HW_VLAN_CTAG_FILTER; in efx_ef10_vadaptor_alloc_set_features()
251 efx->fixed_features &= ~NETIF_F_HW_VLAN_CTAG_FILTER; in efx_ef10_vadaptor_alloc_set_features()
256 efx_ef10_vadaptor_free(efx, EVB_PORT_ID_ASSIGNED); in efx_ef10_vadaptor_alloc_set_features()
264 int efx_ef10_vswitching_probe_pf(struct efx_nic *efx) in efx_ef10_vswitching_probe_pf() argument
266 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_vswitching_probe_pf()
267 struct net_device *net_dev = efx->net_dev; in efx_ef10_vswitching_probe_pf()
270 if (pci_sriov_get_totalvfs(efx->pci_dev) <= 0) { in efx_ef10_vswitching_probe_pf()
272 efx_ef10_vadaptor_alloc_set_features(efx); in efx_ef10_vswitching_probe_pf()
276 rc = efx_ef10_vswitch_alloc(efx, EVB_PORT_ID_ASSIGNED, in efx_ef10_vswitching_probe_pf()
281 rc = efx_ef10_vport_alloc(efx, EVB_PORT_ID_ASSIGNED, in efx_ef10_vswitching_probe_pf()
283 EFX_EF10_NO_VLAN, &efx->vport_id); in efx_ef10_vswitching_probe_pf()
287 rc = efx_ef10_vport_add_mac(efx, efx->vport_id, net_dev->dev_addr); in efx_ef10_vswitching_probe_pf()
292 rc = efx_ef10_vadaptor_alloc_set_features(efx); in efx_ef10_vswitching_probe_pf()
298 efx_ef10_vport_del_mac(efx, efx->vport_id, nic_data->vport_mac); in efx_ef10_vswitching_probe_pf()
301 efx_ef10_vport_free(efx, efx->vport_id); in efx_ef10_vswitching_probe_pf()
302 efx->vport_id = EVB_PORT_ID_ASSIGNED; in efx_ef10_vswitching_probe_pf()
304 efx_ef10_vswitch_free(efx, EVB_PORT_ID_ASSIGNED); in efx_ef10_vswitching_probe_pf()
309 int efx_ef10_vswitching_probe_vf(struct efx_nic *efx) in efx_ef10_vswitching_probe_vf() argument
311 return efx_ef10_vadaptor_alloc_set_features(efx); in efx_ef10_vswitching_probe_vf()
314 int efx_ef10_vswitching_restore_pf(struct efx_nic *efx) in efx_ef10_vswitching_restore_pf() argument
316 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_vswitching_restore_pf()
322 rc = efx_ef10_vswitching_probe_pf(efx); in efx_ef10_vswitching_restore_pf()
326 rc = efx_ef10_sriov_restore_vf_vswitching(efx); in efx_ef10_vswitching_restore_pf()
335 int efx_ef10_vswitching_restore_vf(struct efx_nic *efx) in efx_ef10_vswitching_restore_vf() argument
337 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_vswitching_restore_vf()
343 rc = efx_ef10_vadaptor_free(efx, EVB_PORT_ID_ASSIGNED); in efx_ef10_vswitching_restore_vf()
351 void efx_ef10_vswitching_remove_pf(struct efx_nic *efx) in efx_ef10_vswitching_remove_pf() argument
353 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_vswitching_remove_pf()
355 efx_ef10_sriov_free_vf_vswitching(efx); in efx_ef10_vswitching_remove_pf()
357 efx_ef10_vadaptor_free(efx, efx->vport_id); in efx_ef10_vswitching_remove_pf()
359 if (efx->vport_id == EVB_PORT_ID_ASSIGNED) in efx_ef10_vswitching_remove_pf()
363 efx_ef10_vport_del_mac(efx, efx->vport_id, in efx_ef10_vswitching_remove_pf()
364 efx->net_dev->dev_addr); in efx_ef10_vswitching_remove_pf()
367 efx_ef10_vport_free(efx, efx->vport_id); in efx_ef10_vswitching_remove_pf()
368 efx->vport_id = EVB_PORT_ID_ASSIGNED; in efx_ef10_vswitching_remove_pf()
371 if (!pci_vfs_assigned(efx->pci_dev)) in efx_ef10_vswitching_remove_pf()
372 efx_ef10_vswitch_free(efx, efx->vport_id); in efx_ef10_vswitching_remove_pf()
375 void efx_ef10_vswitching_remove_vf(struct efx_nic *efx) in efx_ef10_vswitching_remove_vf() argument
377 efx_ef10_vadaptor_free(efx, EVB_PORT_ID_ASSIGNED); in efx_ef10_vswitching_remove_vf()
380 static int efx_ef10_pci_sriov_enable(struct efx_nic *efx, int num_vfs) in efx_ef10_pci_sriov_enable() argument
383 struct pci_dev *dev = efx->pci_dev; in efx_ef10_pci_sriov_enable()
385 efx->vf_count = num_vfs; in efx_ef10_pci_sriov_enable()
387 rc = efx_ef10_sriov_alloc_vf_vswitching(efx); in efx_ef10_pci_sriov_enable()
397 efx_ef10_sriov_free_vf_vswitching(efx); in efx_ef10_pci_sriov_enable()
399 efx->vf_count = 0; in efx_ef10_pci_sriov_enable()
400 netif_err(efx, probe, efx->net_dev, in efx_ef10_pci_sriov_enable()
405 static int efx_ef10_pci_sriov_disable(struct efx_nic *efx, bool force) in efx_ef10_pci_sriov_disable() argument
407 struct pci_dev *dev = efx->pci_dev; in efx_ef10_pci_sriov_disable()
413 netif_info(efx, drv, efx->net_dev, "VFs are assigned to guests; " in efx_ef10_pci_sriov_disable()
421 efx_ef10_sriov_free_vf_vswitching(efx); in efx_ef10_pci_sriov_disable()
422 efx->vf_count = 0; in efx_ef10_pci_sriov_disable()
426 int efx_ef10_sriov_configure(struct efx_nic *efx, int num_vfs) in efx_ef10_sriov_configure() argument
429 return efx_ef10_pci_sriov_disable(efx, false); in efx_ef10_sriov_configure()
431 return efx_ef10_pci_sriov_enable(efx, num_vfs); in efx_ef10_sriov_configure()
434 int efx_ef10_sriov_init(struct efx_nic *efx) in efx_ef10_sriov_init() argument
439 void efx_ef10_sriov_fini(struct efx_nic *efx) in efx_ef10_sriov_fini() argument
441 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_sriov_fini()
447 if (pci_num_vf(efx->pci_dev) && !pci_vfs_assigned(efx->pci_dev)) in efx_ef10_sriov_fini()
448 pci_disable_sriov(efx->pci_dev); in efx_ef10_sriov_fini()
453 for (i = 0; i < efx->vf_count; ++i) { in efx_ef10_sriov_fini()
454 struct efx_nic *vf_efx = nic_data->vf[i].efx; in efx_ef10_sriov_fini()
460 rc = efx_ef10_pci_sriov_disable(efx, true); in efx_ef10_sriov_fini()
462 netif_dbg(efx, drv, efx->net_dev, in efx_ef10_sriov_fini()
465 netif_dbg(efx, drv, efx->net_dev, "SRIOV disabled\n"); in efx_ef10_sriov_fini()
468 static int efx_ef10_vport_del_vf_mac(struct efx_nic *efx, unsigned int port_id, in efx_ef10_vport_del_vf_mac() argument
479 rc = efx_mcdi_rpc(efx, MC_CMD_VPORT_DEL_MAC_ADDRESS, inbuf, in efx_ef10_vport_del_vf_mac()
485 int efx_ef10_sriov_set_vf_mac(struct efx_nic *efx, int vf_i, u8 *mac) in efx_ef10_sriov_set_vf_mac() argument
487 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_sriov_set_vf_mac()
494 if (vf_i >= efx->vf_count) in efx_ef10_sriov_set_vf_mac()
498 if (vf->efx) { in efx_ef10_sriov_set_vf_mac()
499 efx_device_detach_sync(vf->efx); in efx_ef10_sriov_set_vf_mac()
500 efx_net_stop(vf->efx->net_dev); in efx_ef10_sriov_set_vf_mac()
502 down_write(&vf->efx->filter_sem); in efx_ef10_sriov_set_vf_mac()
503 vf->efx->type->filter_table_remove(vf->efx); in efx_ef10_sriov_set_vf_mac()
505 rc = efx_ef10_vadaptor_free(vf->efx, EVB_PORT_ID_ASSIGNED); in efx_ef10_sriov_set_vf_mac()
507 up_write(&vf->efx->filter_sem); in efx_ef10_sriov_set_vf_mac()
512 rc = efx_ef10_evb_port_assign(efx, EVB_PORT_ID_NULL, vf_i); in efx_ef10_sriov_set_vf_mac()
517 rc = efx_ef10_vport_del_vf_mac(efx, vf->vport_id, vf->mac); in efx_ef10_sriov_set_vf_mac()
523 rc = efx_ef10_vport_add_mac(efx, vf->vport_id, mac); in efx_ef10_sriov_set_vf_mac()
527 if (vf->efx) in efx_ef10_sriov_set_vf_mac()
528 ether_addr_copy(vf->efx->net_dev->dev_addr, mac); in efx_ef10_sriov_set_vf_mac()
533 rc = efx_ef10_evb_port_assign(efx, vf->vport_id, vf_i); in efx_ef10_sriov_set_vf_mac()
537 if (vf->efx) { in efx_ef10_sriov_set_vf_mac()
539 rc = efx_ef10_vadaptor_alloc(vf->efx, EVB_PORT_ID_ASSIGNED); in efx_ef10_sriov_set_vf_mac()
541 up_write(&vf->efx->filter_sem); in efx_ef10_sriov_set_vf_mac()
544 vf->efx->type->filter_table_probe(vf->efx); in efx_ef10_sriov_set_vf_mac()
545 up_write(&vf->efx->filter_sem); in efx_ef10_sriov_set_vf_mac()
546 efx_net_open(vf->efx->net_dev); in efx_ef10_sriov_set_vf_mac()
547 efx_device_attach_if_not_resetting(vf->efx); in efx_ef10_sriov_set_vf_mac()
557 int efx_ef10_sriov_set_vf_vlan(struct efx_nic *efx, int vf_i, u16 vlan, in efx_ef10_sriov_set_vf_vlan() argument
560 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_sriov_set_vf_vlan()
565 if (vf_i >= efx->vf_count) in efx_ef10_sriov_set_vf_vlan()
576 if (vf->efx) { in efx_ef10_sriov_set_vf_vlan()
577 efx_device_detach_sync(vf->efx); in efx_ef10_sriov_set_vf_vlan()
578 efx_net_stop(vf->efx->net_dev); in efx_ef10_sriov_set_vf_vlan()
580 mutex_lock(&vf->efx->mac_lock); in efx_ef10_sriov_set_vf_vlan()
581 down_write(&vf->efx->filter_sem); in efx_ef10_sriov_set_vf_vlan()
582 vf->efx->type->filter_table_remove(vf->efx); in efx_ef10_sriov_set_vf_vlan()
584 rc = efx_ef10_vadaptor_free(vf->efx, EVB_PORT_ID_ASSIGNED); in efx_ef10_sriov_set_vf_vlan()
590 rc = efx_ef10_evb_port_assign(efx, EVB_PORT_ID_NULL, vf_i); in efx_ef10_sriov_set_vf_vlan()
592 netif_warn(efx, drv, efx->net_dev, 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()
604 rc = efx_ef10_vport_del_mac(efx, vf->vport_id, vf->mac); in efx_ef10_sriov_set_vf_vlan()
610 rc = efx_ef10_vport_free(efx, vf->vport_id); in efx_ef10_sriov_set_vf_vlan()
620 rc = efx_ef10_vport_alloc(efx, EVB_PORT_ID_ASSIGNED, in efx_ef10_sriov_set_vf_vlan()
628 rc2 = efx_ef10_vport_add_mac(efx, vf->vport_id, vf->mac); in efx_ef10_sriov_set_vf_vlan()
636 rc2 = efx_ef10_evb_port_assign(efx, vf->vport_id, vf_i); in efx_ef10_sriov_set_vf_vlan()
643 if (vf->efx) { in efx_ef10_sriov_set_vf_vlan()
644 rc2 = efx_ef10_vadaptor_alloc(vf->efx, EVB_PORT_ID_ASSIGNED); in efx_ef10_sriov_set_vf_vlan()
650 if (vf->efx) { in efx_ef10_sriov_set_vf_vlan()
651 rc2 = vf->efx->type->filter_table_probe(vf->efx); in efx_ef10_sriov_set_vf_vlan()
655 up_write(&vf->efx->filter_sem); in efx_ef10_sriov_set_vf_vlan()
656 mutex_unlock(&vf->efx->mac_lock); in efx_ef10_sriov_set_vf_vlan()
658 rc2 = efx_net_open(vf->efx->net_dev); in efx_ef10_sriov_set_vf_vlan()
662 efx_device_attach_if_not_resetting(vf->efx); in efx_ef10_sriov_set_vf_vlan()
667 if (vf->efx) { in efx_ef10_sriov_set_vf_vlan()
668 up_write(&vf->efx->filter_sem); in efx_ef10_sriov_set_vf_vlan()
669 mutex_unlock(&vf->efx->mac_lock); in efx_ef10_sriov_set_vf_vlan()
672 if (vf->efx) { in efx_ef10_sriov_set_vf_vlan()
673 netif_err(efx, drv, efx->net_dev, in efx_ef10_sriov_set_vf_vlan()
675 efx_schedule_reset(vf->efx, RESET_TYPE_DATAPATH); in efx_ef10_sriov_set_vf_vlan()
677 netif_err(efx, drv, efx->net_dev, in efx_ef10_sriov_set_vf_vlan()
680 netif_err(efx, drv, efx->net_dev, in efx_ef10_sriov_set_vf_vlan()
687 static int efx_ef10_sriov_set_privilege_mask(struct efx_nic *efx, int vf_i, in efx_ef10_sriov_set_privilege_mask() argument
692 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_sriov_set_privilege_mask()
704 rc = efx_mcdi_rpc(efx, MC_CMD_PRIVILEGE_MASK, in efx_ef10_sriov_set_privilege_mask()
726 rc = efx_mcdi_rpc(efx, MC_CMD_PRIVILEGE_MASK, in efx_ef10_sriov_set_privilege_mask()
738 int efx_ef10_sriov_set_vf_spoofchk(struct efx_nic *efx, int vf_i, bool spoofchk) in efx_ef10_sriov_set_vf_spoofchk() argument
740 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_sriov_set_vf_spoofchk()
748 return efx_ef10_sriov_set_privilege_mask(efx, vf_i, in efx_ef10_sriov_set_vf_spoofchk()
753 int efx_ef10_sriov_set_vf_link_state(struct efx_nic *efx, int vf_i, in efx_ef10_sriov_set_vf_link_state() argument
757 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_sriov_set_vf_link_state()
770 return efx_mcdi_rpc(efx, MC_CMD_LINK_STATE_MODE, inbuf, sizeof(inbuf), in efx_ef10_sriov_set_vf_link_state()
774 int efx_ef10_sriov_get_vf_config(struct efx_nic *efx, int vf_i, in efx_ef10_sriov_get_vf_config() argument
780 struct efx_ef10_nic_data *nic_data = efx->nic_data; in efx_ef10_sriov_get_vf_config()
785 if (vf_i >= efx->vf_count) in efx_ef10_sriov_get_vf_config()
806 rc = efx_mcdi_rpc(efx, MC_CMD_LINK_STATE_MODE, inbuf, sizeof(inbuf), in efx_ef10_sriov_get_vf_config()