Lines Matching refs: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++) {
129 efx_ef10_evb_port_assign(efx, EVB_PORT_ID_NULL, i);
134 efx_ef10_vport_del_mac(efx, vf->vport_id, vf->mac);
139 efx_ef10_vport_free(efx, vf->vport_id);
143 vf->efx = NULL;
147 static void efx_ef10_sriov_free_vf_vswitching(struct efx_nic *efx)
149 struct efx_ef10_nic_data *nic_data = efx->nic_data;
151 efx_ef10_sriov_free_vf_vports(efx);
156 static int efx_ef10_sriov_assign_vf_vport(struct efx_nic *efx,
159 struct efx_ef10_nic_data *nic_data = efx->nic_data;
166 rc = efx_ef10_vport_alloc(efx, EVB_PORT_ID_ASSIGNED,
172 rc = efx_ef10_vport_add_mac(efx, vf->vport_id, vf->mac);
178 rc = efx_ef10_evb_port_assign(efx, vf->vport_id, vf_i);
186 static int efx_ef10_sriov_alloc_vf_vswitching(struct efx_nic *efx)
188 struct efx_ef10_nic_data *nic_data = efx->nic_data;
192 nic_data->vf = kcalloc(efx->vf_count, sizeof(struct ef10_vf),
197 for (i = 0; i < efx->vf_count; i++) {
199 nic_data->vf[i].efx = NULL;
202 rc = efx_ef10_sriov_assign_vf_vport(efx, i);
209 efx_ef10_sriov_free_vf_vswitching(efx);
213 static int efx_ef10_sriov_restore_vf_vswitching(struct efx_nic *efx)
218 for (i = 0; i < efx->vf_count; i++) {
219 rc = efx_ef10_sriov_assign_vf_vport(efx, i);
226 efx_ef10_sriov_free_vf_vswitching(efx);
230 static int efx_ef10_vadaptor_alloc_set_features(struct efx_nic *efx)
235 rc = efx_ef10_vadaptor_alloc(efx, efx->vport_id);
239 rc = efx_ef10_vadaptor_query(efx, efx->vport_id,
246 efx->fixed_features |= NETIF_F_HW_VLAN_CTAG_FILTER;
248 efx->fixed_features &= ~NETIF_F_HW_VLAN_CTAG_FILTER;
253 efx_ef10_vadaptor_free(efx, EVB_PORT_ID_ASSIGNED);
261 int efx_ef10_vswitching_probe_pf(struct efx_nic *efx)
263 struct efx_ef10_nic_data *nic_data = efx->nic_data;
264 struct net_device *net_dev = efx->net_dev;
267 if (pci_sriov_get_totalvfs(efx->pci_dev) <= 0) {
269 efx_ef10_vadaptor_alloc_set_features(efx);
273 rc = efx_ef10_vswitch_alloc(efx, EVB_PORT_ID_ASSIGNED,
278 rc = efx_ef10_vport_alloc(efx, EVB_PORT_ID_ASSIGNED,
280 EFX_EF10_NO_VLAN, &efx->vport_id);
284 rc = efx_ef10_vport_add_mac(efx, efx->vport_id, net_dev->dev_addr);
289 rc = efx_ef10_vadaptor_alloc_set_features(efx);
295 efx_ef10_vport_del_mac(efx, efx->vport_id, nic_data->vport_mac);
298 efx_ef10_vport_free(efx, efx->vport_id);
299 efx->vport_id = EVB_PORT_ID_ASSIGNED;
301 efx_ef10_vswitch_free(efx, EVB_PORT_ID_ASSIGNED);
306 int efx_ef10_vswitching_probe_vf(struct efx_nic *efx)
308 return efx_ef10_vadaptor_alloc_set_features(efx);
311 int efx_ef10_vswitching_restore_pf(struct efx_nic *efx)
313 struct efx_ef10_nic_data *nic_data = efx->nic_data;
319 rc = efx_ef10_vswitching_probe_pf(efx);
323 rc = efx_ef10_sriov_restore_vf_vswitching(efx);
332 int efx_ef10_vswitching_restore_vf(struct efx_nic *efx)
334 struct efx_ef10_nic_data *nic_data = efx->nic_data;
340 rc = efx_ef10_vadaptor_free(efx, EVB_PORT_ID_ASSIGNED);
348 void efx_ef10_vswitching_remove_pf(struct efx_nic *efx)
350 struct efx_ef10_nic_data *nic_data = efx->nic_data;
352 efx_ef10_sriov_free_vf_vswitching(efx);
354 efx_ef10_vadaptor_free(efx, efx->vport_id);
356 if (efx->vport_id == EVB_PORT_ID_ASSIGNED)
360 efx_ef10_vport_del_mac(efx, efx->vport_id,
361 efx->net_dev->dev_addr);
364 efx_ef10_vport_free(efx, efx->vport_id);
365 efx->vport_id = EVB_PORT_ID_ASSIGNED;
368 if (!pci_vfs_assigned(efx->pci_dev))
369 efx_ef10_vswitch_free(efx, efx->vport_id);
372 void efx_ef10_vswitching_remove_vf(struct efx_nic *efx)
374 efx_ef10_vadaptor_free(efx, EVB_PORT_ID_ASSIGNED);
377 static int efx_ef10_pci_sriov_enable(struct efx_nic *efx, int num_vfs)
380 struct pci_dev *dev = efx->pci_dev;
382 efx->vf_count = num_vfs;
384 rc = efx_ef10_sriov_alloc_vf_vswitching(efx);
394 efx_ef10_sriov_free_vf_vswitching(efx);
396 efx->vf_count = 0;
397 netif_err(efx, probe, efx->net_dev,
408 static int efx_ef10_pci_sriov_disable(struct efx_nic *efx, bool force)
410 struct pci_dev *dev = efx->pci_dev;
411 struct efx_ef10_nic_data *nic_data = efx->nic_data;
416 netif_info(efx, drv, efx->net_dev, "VFs are assigned to guests; "
422 for (i = 0; i < efx->vf_count; i++)
429 efx_ef10_sriov_free_vf_vswitching(efx);
430 efx->vf_count = 0;
434 int efx_ef10_sriov_configure(struct efx_nic *efx, int num_vfs)
437 return efx_ef10_pci_sriov_disable(efx, false);
439 return efx_ef10_pci_sriov_enable(efx, num_vfs);
442 int efx_ef10_sriov_init(struct efx_nic *efx)
447 void efx_ef10_sriov_fini(struct efx_nic *efx)
449 struct efx_ef10_nic_data *nic_data = efx->nic_data;
456 if (pci_num_vf(efx->pci_dev) && !pci_vfs_assigned(efx->pci_dev))
457 pci_disable_sriov(efx->pci_dev);
462 rc = efx_ef10_pci_sriov_disable(efx, true);
464 netif_dbg(efx, drv, efx->net_dev,
467 netif_dbg(efx, drv, efx->net_dev, "SRIOV disabled\n");
470 static int efx_ef10_vport_del_vf_mac(struct efx_nic *efx, unsigned int port_id,
481 rc = efx_mcdi_rpc(efx, MC_CMD_VPORT_DEL_MAC_ADDRESS, inbuf,
487 int efx_ef10_sriov_set_vf_mac(struct efx_nic *efx, int vf_i, const u8 *mac)
489 struct efx_ef10_nic_data *nic_data = efx->nic_data;
496 if (vf_i >= efx->vf_count)
500 if (vf->efx) {
501 efx_device_detach_sync(vf->efx);
502 efx_net_stop(vf->efx->net_dev);
504 vf->efx->type->filter_table_remove(vf->efx);
506 rc = efx_ef10_vadaptor_free(vf->efx, EVB_PORT_ID_ASSIGNED);
511 rc = efx_ef10_evb_port_assign(efx, EVB_PORT_ID_NULL, vf_i);
516 rc = efx_ef10_vport_del_vf_mac(efx, vf->vport_id, vf->mac);
522 rc = efx_ef10_vport_add_mac(efx, vf->vport_id, mac);
526 if (vf->efx)
527 eth_hw_addr_set(vf->efx->net_dev, mac);
532 rc = efx_ef10_evb_port_assign(efx, vf->vport_id, vf_i);
536 if (vf->efx) {
538 rc = efx_ef10_vadaptor_alloc(vf->efx, EVB_PORT_ID_ASSIGNED);
541 vf->efx->type->filter_table_probe(vf->efx);
542 efx_net_open(vf->efx->net_dev);
543 efx_device_attach_if_not_resetting(vf->efx);
553 int efx_ef10_sriov_set_vf_vlan(struct efx_nic *efx, int vf_i, u16 vlan,
556 struct efx_ef10_nic_data *nic_data = efx->nic_data;
561 if (vf_i >= efx->vf_count)
572 if (vf->efx) {
573 efx_device_detach_sync(vf->efx);
574 efx_net_stop(vf->efx->net_dev);
576 mutex_lock(&vf->efx->mac_lock);
577 vf->efx->type->filter_table_remove(vf->efx);
579 rc = efx_ef10_vadaptor_free(vf->efx, EVB_PORT_ID_ASSIGNED);
585 rc = efx_ef10_evb_port_assign(efx, EVB_PORT_ID_NULL, vf_i);
587 netif_warn(efx, drv, efx->net_dev,
589 netif_warn(efx, drv, efx->net_dev,
591 netif_warn(efx, drv, efx->net_dev,
599 rc = efx_ef10_vport_del_mac(efx, vf->vport_id, vf->mac);
605 rc = efx_ef10_vport_free(efx, vf->vport_id);
615 rc = efx_ef10_vport_alloc(efx, EVB_PORT_ID_ASSIGNED,
623 rc2 = efx_ef10_vport_add_mac(efx, vf->vport_id, vf->mac);
631 rc2 = efx_ef10_evb_port_assign(efx, vf->vport_id, vf_i);
638 if (vf->efx) {
639 rc2 = efx_ef10_vadaptor_alloc(vf->efx, EVB_PORT_ID_ASSIGNED);
645 if (vf->efx) {
646 rc2 = vf->efx->type->filter_table_probe(vf->efx);
650 mutex_unlock(&vf->efx->mac_lock);
652 rc2 = efx_net_open(vf->efx->net_dev);
656 efx_device_attach_if_not_resetting(vf->efx);
661 if (vf->efx)
662 mutex_unlock(&vf->efx->mac_lock);
664 if (vf->efx) {
665 netif_err(efx, drv, efx->net_dev,
667 efx_schedule_reset(vf->efx, RESET_TYPE_DATAPATH);
669 netif_err(efx, drv, efx->net_dev,
672 netif_err(efx, drv, efx->net_dev,
679 static int efx_ef10_sriov_set_privilege_mask(struct efx_nic *efx, int vf_i,
684 struct efx_ef10_nic_data *nic_data = efx->nic_data;
696 rc = efx_mcdi_rpc(efx, MC_CMD_PRIVILEGE_MASK,
718 rc = efx_mcdi_rpc(efx, MC_CMD_PRIVILEGE_MASK,
730 int efx_ef10_sriov_set_vf_spoofchk(struct efx_nic *efx, int vf_i, bool spoofchk)
732 struct efx_ef10_nic_data *nic_data = efx->nic_data;
740 return efx_ef10_sriov_set_privilege_mask(efx, vf_i,
745 int efx_ef10_sriov_set_vf_link_state(struct efx_nic *efx, int vf_i,
749 struct efx_ef10_nic_data *nic_data = efx->nic_data;
762 return efx_mcdi_rpc(efx, MC_CMD_LINK_STATE_MODE, inbuf, sizeof(inbuf),
766 int efx_ef10_sriov_get_vf_config(struct efx_nic *efx, int vf_i,
772 struct efx_ef10_nic_data *nic_data = efx->nic_data;
777 if (vf_i >= efx->vf_count)
798 rc = efx_mcdi_rpc(efx, MC_CMD_LINK_STATE_MODE, inbuf, sizeof(inbuf),