Lines Matching defs:efx
11 #include "efx.h"
15 static int efx_ef10_evb_port_assign(struct efx_nic *efx, unsigned int port_id,
19 struct efx_ef10_nic_data *nic_data = efx->nic_data;
26 return efx_mcdi_rpc(efx, MC_CMD_EVB_PORT_ASSIGN, inbuf, sizeof(inbuf),
30 static int efx_ef10_vswitch_alloc(struct efx_nic *efx, unsigned int port_id,
43 rc = efx_mcdi_rpc_quiet(efx, MC_CMD_VSWITCH_ALLOC, inbuf, sizeof(inbuf),
49 rc = efx_mcdi_rpc(efx, MC_CMD_VSWITCH_ALLOC, inbuf,
52 efx_mcdi_display_error(efx, MC_CMD_VSWITCH_ALLOC,
59 static int efx_ef10_vswitch_free(struct efx_nic *efx, unsigned int port_id)
65 return efx_mcdi_rpc(efx, MC_CMD_VSWITCH_FREE, inbuf, sizeof(inbuf),
69 static int efx_ef10_vport_alloc(struct efx_nic *efx,
92 rc = efx_mcdi_rpc(efx, MC_CMD_VPORT_ALLOC, inbuf, sizeof(inbuf),
103 static int efx_ef10_vport_free(struct efx_nic *efx, unsigned int port_id)
109 return efx_mcdi_rpc(efx, MC_CMD_VPORT_FREE, inbuf, sizeof(inbuf),
113 static void efx_ef10_sriov_free_vf_vports(struct efx_nic *efx)
115 struct efx_ef10_nic_data *nic_data = efx->nic_data;
121 for (i = 0; i < efx->vf_count; i++) {
130 efx_ef10_evb_port_assign(efx, EVB_PORT_ID_NULL, i);
135 efx_ef10_vport_del_mac(efx, vf->vport_id, vf->mac);
140 efx_ef10_vport_free(efx, vf->vport_id);
144 vf->efx = NULL;
148 static void efx_ef10_sriov_free_vf_vswitching(struct efx_nic *efx)
150 struct efx_ef10_nic_data *nic_data = efx->nic_data;
152 efx_ef10_sriov_free_vf_vports(efx);
157 static int efx_ef10_sriov_assign_vf_vport(struct efx_nic *efx,
160 struct efx_ef10_nic_data *nic_data = efx->nic_data;
167 rc = efx_ef10_vport_alloc(efx, EVB_PORT_ID_ASSIGNED,
173 rc = efx_ef10_vport_add_mac(efx, vf->vport_id, vf->mac);
179 rc = efx_ef10_evb_port_assign(efx, vf->vport_id, vf_i);
187 static int efx_ef10_sriov_alloc_vf_vswitching(struct efx_nic *efx)
189 struct efx_ef10_nic_data *nic_data = efx->nic_data;
193 nic_data->vf = kcalloc(efx->vf_count, sizeof(struct ef10_vf),
198 for (i = 0; i < efx->vf_count; i++) {
200 nic_data->vf[i].efx = NULL;
203 rc = efx_ef10_sriov_assign_vf_vport(efx, i);
210 efx_ef10_sriov_free_vf_vports(efx);
216 static int efx_ef10_sriov_restore_vf_vswitching(struct efx_nic *efx)
221 for (i = 0; i < efx->vf_count; i++) {
222 rc = efx_ef10_sriov_assign_vf_vport(efx, i);
229 efx_ef10_sriov_free_vf_vswitching(efx);
233 static int efx_ef10_vadaptor_alloc_set_features(struct efx_nic *efx)
238 rc = efx_ef10_vadaptor_alloc(efx, efx->vport_id);
242 rc = efx_ef10_vadaptor_query(efx, efx->vport_id,
249 efx->fixed_features |= NETIF_F_HW_VLAN_CTAG_FILTER;
251 efx->fixed_features &= ~NETIF_F_HW_VLAN_CTAG_FILTER;
256 efx_ef10_vadaptor_free(efx, EVB_PORT_ID_ASSIGNED);
264 int efx_ef10_vswitching_probe_pf(struct efx_nic *efx)
266 struct efx_ef10_nic_data *nic_data = efx->nic_data;
267 struct net_device *net_dev = efx->net_dev;
270 if (pci_sriov_get_totalvfs(efx->pci_dev) <= 0) {
272 efx_ef10_vadaptor_alloc_set_features(efx);
276 rc = efx_ef10_vswitch_alloc(efx, EVB_PORT_ID_ASSIGNED,
281 rc = efx_ef10_vport_alloc(efx, EVB_PORT_ID_ASSIGNED,
283 EFX_EF10_NO_VLAN, &efx->vport_id);
287 rc = efx_ef10_vport_add_mac(efx, efx->vport_id, net_dev->dev_addr);
292 rc = efx_ef10_vadaptor_alloc_set_features(efx);
298 efx_ef10_vport_del_mac(efx, efx->vport_id, nic_data->vport_mac);
301 efx_ef10_vport_free(efx, efx->vport_id);
302 efx->vport_id = EVB_PORT_ID_ASSIGNED;
304 efx_ef10_vswitch_free(efx, EVB_PORT_ID_ASSIGNED);
309 int efx_ef10_vswitching_probe_vf(struct efx_nic *efx)
311 return efx_ef10_vadaptor_alloc_set_features(efx);
314 int efx_ef10_vswitching_restore_pf(struct efx_nic *efx)
316 struct efx_ef10_nic_data *nic_data = efx->nic_data;
322 rc = efx_ef10_vswitching_probe_pf(efx);
326 rc = efx_ef10_sriov_restore_vf_vswitching(efx);
335 int efx_ef10_vswitching_restore_vf(struct efx_nic *efx)
337 struct efx_ef10_nic_data *nic_data = efx->nic_data;
343 rc = efx_ef10_vadaptor_free(efx, EVB_PORT_ID_ASSIGNED);
351 void efx_ef10_vswitching_remove_pf(struct efx_nic *efx)
353 struct efx_ef10_nic_data *nic_data = efx->nic_data;
355 efx_ef10_sriov_free_vf_vswitching(efx);
357 efx_ef10_vadaptor_free(efx, efx->vport_id);
359 if (efx->vport_id == EVB_PORT_ID_ASSIGNED)
363 efx_ef10_vport_del_mac(efx, efx->vport_id,
364 efx->net_dev->dev_addr);
367 efx_ef10_vport_free(efx, efx->vport_id);
368 efx->vport_id = EVB_PORT_ID_ASSIGNED;
371 if (!pci_vfs_assigned(efx->pci_dev))
372 efx_ef10_vswitch_free(efx, efx->vport_id);
375 void efx_ef10_vswitching_remove_vf(struct efx_nic *efx)
377 efx_ef10_vadaptor_free(efx, EVB_PORT_ID_ASSIGNED);
380 static int efx_ef10_pci_sriov_enable(struct efx_nic *efx, int num_vfs)
383 struct pci_dev *dev = efx->pci_dev;
385 efx->vf_count = num_vfs;
387 rc = efx_ef10_sriov_alloc_vf_vswitching(efx);
397 efx_ef10_sriov_free_vf_vswitching(efx);
399 efx->vf_count = 0;
400 netif_err(efx, probe, efx->net_dev,
411 static int efx_ef10_pci_sriov_disable(struct efx_nic *efx, bool force)
413 struct pci_dev *dev = efx->pci_dev;
414 struct efx_ef10_nic_data *nic_data = efx->nic_data;
419 netif_info(efx, drv, efx->net_dev, "VFs are assigned to guests; "
425 for (i = 0; i < efx->vf_count; i++)
432 efx_ef10_sriov_free_vf_vswitching(efx);
433 efx->vf_count = 0;
437 int efx_ef10_sriov_configure(struct efx_nic *efx, int num_vfs)
440 return efx_ef10_pci_sriov_disable(efx, false);
442 return efx_ef10_pci_sriov_enable(efx, num_vfs);
445 int efx_ef10_sriov_init(struct efx_nic *efx)
450 void efx_ef10_sriov_fini(struct efx_nic *efx)
452 struct efx_ef10_nic_data *nic_data = efx->nic_data;
457 if (pci_num_vf(efx->pci_dev) && !pci_vfs_assigned(efx->pci_dev))
458 pci_disable_sriov(efx->pci_dev);
463 rc = efx_ef10_pci_sriov_disable(efx, true);
465 netif_dbg(efx, drv, efx->net_dev,
468 netif_dbg(efx, drv, efx->net_dev, "SRIOV disabled\n");
471 static int efx_ef10_vport_del_vf_mac(struct efx_nic *efx, unsigned int port_id,
482 rc = efx_mcdi_rpc(efx, MC_CMD_VPORT_DEL_MAC_ADDRESS, inbuf,
488 int efx_ef10_sriov_set_vf_mac(struct efx_nic *efx, int vf_i, u8 *mac)
490 struct efx_ef10_nic_data *nic_data = efx->nic_data;
497 if (vf_i >= efx->vf_count)
501 if (vf->efx) {
502 efx_device_detach_sync(vf->efx);
503 efx_net_stop(vf->efx->net_dev);
505 down_write(&vf->efx->filter_sem);
506 vf->efx->type->filter_table_remove(vf->efx);
508 rc = efx_ef10_vadaptor_free(vf->efx, EVB_PORT_ID_ASSIGNED);
510 up_write(&vf->efx->filter_sem);
515 rc = efx_ef10_evb_port_assign(efx, EVB_PORT_ID_NULL, vf_i);
520 rc = efx_ef10_vport_del_vf_mac(efx, vf->vport_id, vf->mac);
526 rc = efx_ef10_vport_add_mac(efx, vf->vport_id, mac);
530 if (vf->efx)
531 ether_addr_copy(vf->efx->net_dev->dev_addr, mac);
536 rc = efx_ef10_evb_port_assign(efx, vf->vport_id, vf_i);
540 if (vf->efx) {
542 rc = efx_ef10_vadaptor_alloc(vf->efx, EVB_PORT_ID_ASSIGNED);
544 up_write(&vf->efx->filter_sem);
547 vf->efx->type->filter_table_probe(vf->efx);
548 up_write(&vf->efx->filter_sem);
549 efx_net_open(vf->efx->net_dev);
550 efx_device_attach_if_not_resetting(vf->efx);
560 int efx_ef10_sriov_set_vf_vlan(struct efx_nic *efx, int vf_i, u16 vlan,
563 struct efx_ef10_nic_data *nic_data = efx->nic_data;
568 if (vf_i >= efx->vf_count)
579 if (vf->efx) {
580 efx_device_detach_sync(vf->efx);
581 efx_net_stop(vf->efx->net_dev);
583 mutex_lock(&vf->efx->mac_lock);
584 down_write(&vf->efx->filter_sem);
585 vf->efx->type->filter_table_remove(vf->efx);
587 rc = efx_ef10_vadaptor_free(vf->efx, EVB_PORT_ID_ASSIGNED);
593 rc = efx_ef10_evb_port_assign(efx, EVB_PORT_ID_NULL, vf_i);
595 netif_warn(efx, drv, efx->net_dev,
597 netif_warn(efx, drv, efx->net_dev,
599 netif_warn(efx, drv, efx->net_dev,
607 rc = efx_ef10_vport_del_mac(efx, vf->vport_id, vf->mac);
613 rc = efx_ef10_vport_free(efx, vf->vport_id);
623 rc = efx_ef10_vport_alloc(efx, EVB_PORT_ID_ASSIGNED,
631 rc2 = efx_ef10_vport_add_mac(efx, vf->vport_id, vf->mac);
639 rc2 = efx_ef10_evb_port_assign(efx, vf->vport_id, vf_i);
646 if (vf->efx) {
647 rc2 = efx_ef10_vadaptor_alloc(vf->efx, EVB_PORT_ID_ASSIGNED);
653 if (vf->efx) {
654 rc2 = vf->efx->type->filter_table_probe(vf->efx);
658 up_write(&vf->efx->filter_sem);
659 mutex_unlock(&vf->efx->mac_lock);
661 rc2 = efx_net_open(vf->efx->net_dev);
665 efx_device_attach_if_not_resetting(vf->efx);
670 if (vf->efx) {
671 up_write(&vf->efx->filter_sem);
672 mutex_unlock(&vf->efx->mac_lock);
675 if (vf->efx) {
676 netif_err(efx, drv, efx->net_dev,
678 efx_schedule_reset(vf->efx, RESET_TYPE_DATAPATH);
680 netif_err(efx, drv, efx->net_dev,
683 netif_err(efx, drv, efx->net_dev,
690 static int efx_ef10_sriov_set_privilege_mask(struct efx_nic *efx, int vf_i,
695 struct efx_ef10_nic_data *nic_data = efx->nic_data;
707 rc = efx_mcdi_rpc(efx, MC_CMD_PRIVILEGE_MASK,
729 rc = efx_mcdi_rpc(efx, MC_CMD_PRIVILEGE_MASK,
741 int efx_ef10_sriov_set_vf_spoofchk(struct efx_nic *efx, int vf_i, bool spoofchk)
743 struct efx_ef10_nic_data *nic_data = efx->nic_data;
751 return efx_ef10_sriov_set_privilege_mask(efx, vf_i,
756 int efx_ef10_sriov_set_vf_link_state(struct efx_nic *efx, int vf_i,
760 struct efx_ef10_nic_data *nic_data = efx->nic_data;
773 return efx_mcdi_rpc(efx, MC_CMD_LINK_STATE_MODE, inbuf, sizeof(inbuf),
777 int efx_ef10_sriov_get_vf_config(struct efx_nic *efx, int vf_i,
783 struct efx_ef10_nic_data *nic_data = efx->nic_data;
788 if (vf_i >= efx->vf_count)
809 rc = efx_mcdi_rpc(efx, MC_CMD_LINK_STATE_MODE, inbuf, sizeof(inbuf),