1 /****************************************************************************
2 * Driver for Solarflare network controllers and boards
3 * Copyright 2015 Solarflare Communications Inc.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published
7 * by the Free Software Foundation, incorporated herein by reference.
10 #include <linux/module.h>
11 #include "net_driver.h"
12 #include "ef10_sriov.h"
15 #include "mcdi_pcol.h"
17 static int efx_ef10_evb_port_assign(struct efx_nic *efx, unsigned int port_id,
20 MCDI_DECLARE_BUF(inbuf, MC_CMD_EVB_PORT_ASSIGN_IN_LEN);
21 struct efx_ef10_nic_data *nic_data = efx->nic_data;
23 MCDI_SET_DWORD(inbuf, EVB_PORT_ASSIGN_IN_PORT_ID, port_id);
24 MCDI_POPULATE_DWORD_2(inbuf, EVB_PORT_ASSIGN_IN_FUNCTION,
25 EVB_PORT_ASSIGN_IN_PF, nic_data->pf_index,
26 EVB_PORT_ASSIGN_IN_VF, vf_fn);
28 return efx_mcdi_rpc(efx, MC_CMD_EVB_PORT_ASSIGN, inbuf, sizeof(inbuf),
32 static int efx_ef10_vport_add_mac(struct efx_nic *efx,
33 unsigned int port_id, u8 *mac)
35 MCDI_DECLARE_BUF(inbuf, MC_CMD_VPORT_ADD_MAC_ADDRESS_IN_LEN);
37 MCDI_SET_DWORD(inbuf, VPORT_ADD_MAC_ADDRESS_IN_VPORT_ID, port_id);
38 ether_addr_copy(MCDI_PTR(inbuf, VPORT_ADD_MAC_ADDRESS_IN_MACADDR), mac);
40 return efx_mcdi_rpc(efx, MC_CMD_VPORT_ADD_MAC_ADDRESS, inbuf,
41 sizeof(inbuf), NULL, 0, NULL);
44 static int efx_ef10_vport_del_mac(struct efx_nic *efx,
45 unsigned int port_id, u8 *mac)
47 MCDI_DECLARE_BUF(inbuf, MC_CMD_VPORT_DEL_MAC_ADDRESS_IN_LEN);
49 MCDI_SET_DWORD(inbuf, VPORT_DEL_MAC_ADDRESS_IN_VPORT_ID, port_id);
50 ether_addr_copy(MCDI_PTR(inbuf, VPORT_DEL_MAC_ADDRESS_IN_MACADDR), mac);
52 return efx_mcdi_rpc(efx, MC_CMD_VPORT_DEL_MAC_ADDRESS, inbuf,
53 sizeof(inbuf), NULL, 0, NULL);
56 static int efx_ef10_vswitch_alloc(struct efx_nic *efx, unsigned int port_id,
57 unsigned int vswitch_type)
59 MCDI_DECLARE_BUF(inbuf, MC_CMD_VSWITCH_ALLOC_IN_LEN);
62 MCDI_SET_DWORD(inbuf, VSWITCH_ALLOC_IN_UPSTREAM_PORT_ID, port_id);
63 MCDI_SET_DWORD(inbuf, VSWITCH_ALLOC_IN_TYPE, vswitch_type);
64 MCDI_SET_DWORD(inbuf, VSWITCH_ALLOC_IN_NUM_VLAN_TAGS, 2);
65 MCDI_POPULATE_DWORD_1(inbuf, VSWITCH_ALLOC_IN_FLAGS,
66 VSWITCH_ALLOC_IN_FLAG_AUTO_PORT, 0);
68 /* Quietly try to allocate 2 VLAN tags */
69 rc = efx_mcdi_rpc_quiet(efx, MC_CMD_VSWITCH_ALLOC, inbuf, sizeof(inbuf),
72 /* If 2 VLAN tags is too many, revert to trying with 1 VLAN tags */
74 MCDI_SET_DWORD(inbuf, VSWITCH_ALLOC_IN_NUM_VLAN_TAGS, 1);
75 rc = efx_mcdi_rpc(efx, MC_CMD_VSWITCH_ALLOC, inbuf,
76 sizeof(inbuf), NULL, 0, NULL);
78 efx_mcdi_display_error(efx, MC_CMD_VSWITCH_ALLOC,
79 MC_CMD_VSWITCH_ALLOC_IN_LEN,
85 static int efx_ef10_vswitch_free(struct efx_nic *efx, unsigned int port_id)
87 MCDI_DECLARE_BUF(inbuf, MC_CMD_VSWITCH_FREE_IN_LEN);
89 MCDI_SET_DWORD(inbuf, VSWITCH_FREE_IN_UPSTREAM_PORT_ID, port_id);
91 return efx_mcdi_rpc(efx, MC_CMD_VSWITCH_FREE, inbuf, sizeof(inbuf),
95 static int efx_ef10_vport_alloc(struct efx_nic *efx,
96 unsigned int port_id_in,
97 unsigned int vport_type,
99 unsigned int *port_id_out)
101 MCDI_DECLARE_BUF(inbuf, MC_CMD_VPORT_ALLOC_IN_LEN);
102 MCDI_DECLARE_BUF(outbuf, MC_CMD_VPORT_ALLOC_OUT_LEN);
106 EFX_WARN_ON_PARANOID(!port_id_out);
108 MCDI_SET_DWORD(inbuf, VPORT_ALLOC_IN_UPSTREAM_PORT_ID, port_id_in);
109 MCDI_SET_DWORD(inbuf, VPORT_ALLOC_IN_TYPE, vport_type);
110 MCDI_SET_DWORD(inbuf, VPORT_ALLOC_IN_NUM_VLAN_TAGS,
111 (vlan != EFX_EF10_NO_VLAN));
112 MCDI_POPULATE_DWORD_1(inbuf, VPORT_ALLOC_IN_FLAGS,
113 VPORT_ALLOC_IN_FLAG_AUTO_PORT, 0);
114 if (vlan != EFX_EF10_NO_VLAN)
115 MCDI_POPULATE_DWORD_1(inbuf, VPORT_ALLOC_IN_VLAN_TAGS,
116 VPORT_ALLOC_IN_VLAN_TAG_0, vlan);
118 rc = efx_mcdi_rpc(efx, MC_CMD_VPORT_ALLOC, inbuf, sizeof(inbuf),
119 outbuf, sizeof(outbuf), &outlen);
122 if (outlen < MC_CMD_VPORT_ALLOC_OUT_LEN)
125 *port_id_out = MCDI_DWORD(outbuf, VPORT_ALLOC_OUT_VPORT_ID);
129 static int efx_ef10_vport_free(struct efx_nic *efx, unsigned int port_id)
131 MCDI_DECLARE_BUF(inbuf, MC_CMD_VPORT_FREE_IN_LEN);
133 MCDI_SET_DWORD(inbuf, VPORT_FREE_IN_VPORT_ID, port_id);
135 return efx_mcdi_rpc(efx, MC_CMD_VPORT_FREE, inbuf, sizeof(inbuf),
139 static int efx_ef10_vadaptor_alloc(struct efx_nic *efx, unsigned int port_id)
141 MCDI_DECLARE_BUF(inbuf, MC_CMD_VADAPTOR_ALLOC_IN_LEN);
143 MCDI_SET_DWORD(inbuf, VADAPTOR_ALLOC_IN_UPSTREAM_PORT_ID, port_id);
144 return efx_mcdi_rpc(efx, MC_CMD_VADAPTOR_ALLOC, inbuf, sizeof(inbuf),
148 static int efx_ef10_vadaptor_free(struct efx_nic *efx, unsigned int port_id)
150 MCDI_DECLARE_BUF(inbuf, MC_CMD_VADAPTOR_FREE_IN_LEN);
152 MCDI_SET_DWORD(inbuf, VADAPTOR_FREE_IN_UPSTREAM_PORT_ID, port_id);
153 return efx_mcdi_rpc(efx, MC_CMD_VADAPTOR_FREE, inbuf, sizeof(inbuf),
157 static void efx_ef10_sriov_free_vf_vports(struct efx_nic *efx)
159 struct efx_ef10_nic_data *nic_data = efx->nic_data;
165 for (i = 0; i < efx->vf_count; i++) {
166 struct ef10_vf *vf = nic_data->vf + i;
168 /* If VF is assigned, do not free the vport */
170 vf->pci_dev->dev_flags & PCI_DEV_FLAGS_ASSIGNED)
173 if (vf->vport_assigned) {
174 efx_ef10_evb_port_assign(efx, EVB_PORT_ID_NULL, i);
175 vf->vport_assigned = 0;
178 if (!is_zero_ether_addr(vf->mac)) {
179 efx_ef10_vport_del_mac(efx, vf->vport_id, vf->mac);
180 eth_zero_addr(vf->mac);
184 efx_ef10_vport_free(efx, vf->vport_id);
192 static void efx_ef10_sriov_free_vf_vswitching(struct efx_nic *efx)
194 struct efx_ef10_nic_data *nic_data = efx->nic_data;
196 efx_ef10_sriov_free_vf_vports(efx);
201 static int efx_ef10_sriov_assign_vf_vport(struct efx_nic *efx,
204 struct efx_ef10_nic_data *nic_data = efx->nic_data;
205 struct ef10_vf *vf = nic_data->vf + vf_i;
208 if (WARN_ON_ONCE(!nic_data->vf))
211 rc = efx_ef10_vport_alloc(efx, EVB_PORT_ID_ASSIGNED,
212 MC_CMD_VPORT_ALLOC_IN_VPORT_TYPE_NORMAL,
213 vf->vlan, &vf->vport_id);
217 rc = efx_ef10_vport_add_mac(efx, vf->vport_id, vf->mac);
219 eth_zero_addr(vf->mac);
223 rc = efx_ef10_evb_port_assign(efx, vf->vport_id, vf_i);
227 vf->vport_assigned = 1;
231 static int efx_ef10_sriov_alloc_vf_vswitching(struct efx_nic *efx)
233 struct efx_ef10_nic_data *nic_data = efx->nic_data;
237 nic_data->vf = kcalloc(efx->vf_count, sizeof(struct ef10_vf),
242 for (i = 0; i < efx->vf_count; i++) {
243 random_ether_addr(nic_data->vf[i].mac);
244 nic_data->vf[i].efx = NULL;
245 nic_data->vf[i].vlan = EFX_EF10_NO_VLAN;
247 rc = efx_ef10_sriov_assign_vf_vport(efx, i);
254 efx_ef10_sriov_free_vf_vports(efx);
260 static int efx_ef10_sriov_restore_vf_vswitching(struct efx_nic *efx)
265 for (i = 0; i < efx->vf_count; i++) {
266 rc = efx_ef10_sriov_assign_vf_vport(efx, i);
273 efx_ef10_sriov_free_vf_vswitching(efx);
277 /* On top of the default firmware vswitch setup, create a VEB vswitch and
278 * expansion vport for use by this function.
280 int efx_ef10_vswitching_probe_pf(struct efx_nic *efx)
282 struct efx_ef10_nic_data *nic_data = efx->nic_data;
283 struct net_device *net_dev = efx->net_dev;
286 if (pci_sriov_get_totalvfs(efx->pci_dev) <= 0) {
287 /* vswitch not needed as we have no VFs */
288 efx_ef10_vadaptor_alloc(efx, nic_data->vport_id);
292 rc = efx_ef10_vswitch_alloc(efx, EVB_PORT_ID_ASSIGNED,
293 MC_CMD_VSWITCH_ALLOC_IN_VSWITCH_TYPE_VEB);
297 rc = efx_ef10_vport_alloc(efx, EVB_PORT_ID_ASSIGNED,
298 MC_CMD_VPORT_ALLOC_IN_VPORT_TYPE_NORMAL,
299 EFX_EF10_NO_VLAN, &nic_data->vport_id);
303 rc = efx_ef10_vport_add_mac(efx, nic_data->vport_id, net_dev->dev_addr);
306 ether_addr_copy(nic_data->vport_mac, net_dev->dev_addr);
308 rc = efx_ef10_vadaptor_alloc(efx, nic_data->vport_id);
314 efx_ef10_vport_del_mac(efx, nic_data->vport_id, nic_data->vport_mac);
315 eth_zero_addr(nic_data->vport_mac);
317 efx_ef10_vport_free(efx, nic_data->vport_id);
318 nic_data->vport_id = EVB_PORT_ID_ASSIGNED;
320 efx_ef10_vswitch_free(efx, EVB_PORT_ID_ASSIGNED);
325 int efx_ef10_vswitching_probe_vf(struct efx_nic *efx)
327 struct efx_ef10_nic_data *nic_data = efx->nic_data;
329 return efx_ef10_vadaptor_alloc(efx, nic_data->vport_id);
332 int efx_ef10_vswitching_restore_pf(struct efx_nic *efx)
334 struct efx_ef10_nic_data *nic_data = efx->nic_data;
337 if (!nic_data->must_probe_vswitching)
340 rc = efx_ef10_vswitching_probe_pf(efx);
344 rc = efx_ef10_sriov_restore_vf_vswitching(efx);
348 nic_data->must_probe_vswitching = false;
353 int efx_ef10_vswitching_restore_vf(struct efx_nic *efx)
355 struct efx_ef10_nic_data *nic_data = efx->nic_data;
358 if (!nic_data->must_probe_vswitching)
361 rc = efx_ef10_vadaptor_free(efx, EVB_PORT_ID_ASSIGNED);
365 nic_data->must_probe_vswitching = false;
369 void efx_ef10_vswitching_remove_pf(struct efx_nic *efx)
371 struct efx_ef10_nic_data *nic_data = efx->nic_data;
373 efx_ef10_sriov_free_vf_vswitching(efx);
375 efx_ef10_vadaptor_free(efx, nic_data->vport_id);
377 if (nic_data->vport_id == EVB_PORT_ID_ASSIGNED)
378 return; /* No vswitch was ever created */
380 if (!is_zero_ether_addr(nic_data->vport_mac)) {
381 efx_ef10_vport_del_mac(efx, nic_data->vport_id,
382 efx->net_dev->dev_addr);
383 eth_zero_addr(nic_data->vport_mac);
385 efx_ef10_vport_free(efx, nic_data->vport_id);
386 nic_data->vport_id = EVB_PORT_ID_ASSIGNED;
388 /* Only free the vswitch if no VFs are assigned */
389 if (!pci_vfs_assigned(efx->pci_dev))
390 efx_ef10_vswitch_free(efx, nic_data->vport_id);
393 void efx_ef10_vswitching_remove_vf(struct efx_nic *efx)
395 efx_ef10_vadaptor_free(efx, EVB_PORT_ID_ASSIGNED);
398 static int efx_ef10_pci_sriov_enable(struct efx_nic *efx, int num_vfs)
401 struct pci_dev *dev = efx->pci_dev;
403 efx->vf_count = num_vfs;
405 rc = efx_ef10_sriov_alloc_vf_vswitching(efx);
409 rc = pci_enable_sriov(dev, num_vfs);
415 efx_ef10_sriov_free_vf_vswitching(efx);
418 netif_err(efx, probe, efx->net_dev,
419 "Failed to enable SRIOV VFs\n");
423 static int efx_ef10_pci_sriov_disable(struct efx_nic *efx, bool force)
425 struct pci_dev *dev = efx->pci_dev;
426 unsigned int vfs_assigned = 0;
428 vfs_assigned = pci_vfs_assigned(dev);
430 if (vfs_assigned && !force) {
431 netif_info(efx, drv, efx->net_dev, "VFs are assigned to guests; "
432 "please detach them before disabling SR-IOV\n");
437 pci_disable_sriov(dev);
439 efx_ef10_sriov_free_vf_vswitching(efx);
444 int efx_ef10_sriov_configure(struct efx_nic *efx, int num_vfs)
447 return efx_ef10_pci_sriov_disable(efx, false);
449 return efx_ef10_pci_sriov_enable(efx, num_vfs);
452 int efx_ef10_sriov_init(struct efx_nic *efx)
457 void efx_ef10_sriov_fini(struct efx_nic *efx)
459 struct efx_ef10_nic_data *nic_data = efx->nic_data;
464 /* Remove any un-assigned orphaned VFs */
465 if (pci_num_vf(efx->pci_dev) && !pci_vfs_assigned(efx->pci_dev))
466 pci_disable_sriov(efx->pci_dev);
470 /* Remove any VFs in the host */
471 for (i = 0; i < efx->vf_count; ++i) {
472 struct efx_nic *vf_efx = nic_data->vf[i].efx;
475 vf_efx->pci_dev->driver->remove(vf_efx->pci_dev);
478 rc = efx_ef10_pci_sriov_disable(efx, true);
480 netif_dbg(efx, drv, efx->net_dev,
481 "Disabling SRIOV was not successful rc=%d\n", rc);
483 netif_dbg(efx, drv, efx->net_dev, "SRIOV disabled\n");
486 static int efx_ef10_vport_del_vf_mac(struct efx_nic *efx, unsigned int port_id,
489 MCDI_DECLARE_BUF(inbuf, MC_CMD_VPORT_DEL_MAC_ADDRESS_IN_LEN);
490 MCDI_DECLARE_BUF_ERR(outbuf);
494 MCDI_SET_DWORD(inbuf, VPORT_DEL_MAC_ADDRESS_IN_VPORT_ID, port_id);
495 ether_addr_copy(MCDI_PTR(inbuf, VPORT_DEL_MAC_ADDRESS_IN_MACADDR), mac);
497 rc = efx_mcdi_rpc(efx, MC_CMD_VPORT_DEL_MAC_ADDRESS, inbuf,
498 sizeof(inbuf), outbuf, sizeof(outbuf), &outlen);
503 int efx_ef10_sriov_set_vf_mac(struct efx_nic *efx, int vf_i, u8 *mac)
505 struct efx_ef10_nic_data *nic_data = efx->nic_data;
512 if (vf_i >= efx->vf_count)
514 vf = nic_data->vf + vf_i;
517 efx_device_detach_sync(vf->efx);
518 efx_net_stop(vf->efx->net_dev);
520 down_write(&vf->efx->filter_sem);
521 vf->efx->type->filter_table_remove(vf->efx);
523 rc = efx_ef10_vadaptor_free(vf->efx, EVB_PORT_ID_ASSIGNED);
525 up_write(&vf->efx->filter_sem);
530 rc = efx_ef10_evb_port_assign(efx, EVB_PORT_ID_NULL, vf_i);
534 if (!is_zero_ether_addr(vf->mac)) {
535 rc = efx_ef10_vport_del_vf_mac(efx, vf->vport_id, vf->mac);
540 if (!is_zero_ether_addr(mac)) {
541 rc = efx_ef10_vport_add_mac(efx, vf->vport_id, mac);
543 eth_zero_addr(vf->mac);
547 ether_addr_copy(vf->efx->net_dev->dev_addr, mac);
550 ether_addr_copy(vf->mac, mac);
552 rc = efx_ef10_evb_port_assign(efx, vf->vport_id, vf_i);
557 /* VF cannot use the vport_id that the PF created */
558 rc = efx_ef10_vadaptor_alloc(vf->efx, EVB_PORT_ID_ASSIGNED);
560 up_write(&vf->efx->filter_sem);
563 vf->efx->type->filter_table_probe(vf->efx);
564 up_write(&vf->efx->filter_sem);
565 efx_net_open(vf->efx->net_dev);
566 netif_device_attach(vf->efx->net_dev);
572 memset(vf->mac, 0, ETH_ALEN);
576 int efx_ef10_sriov_set_vf_vlan(struct efx_nic *efx, int vf_i, u16 vlan,
579 struct efx_ef10_nic_data *nic_data = efx->nic_data;
581 u16 old_vlan, new_vlan;
584 if (vf_i >= efx->vf_count)
589 vf = nic_data->vf + vf_i;
591 new_vlan = (vlan == 0) ? EFX_EF10_NO_VLAN : vlan;
592 if (new_vlan == vf->vlan)
596 efx_device_detach_sync(vf->efx);
597 efx_net_stop(vf->efx->net_dev);
599 down_write(&vf->efx->filter_sem);
600 vf->efx->type->filter_table_remove(vf->efx);
602 rc = efx_ef10_vadaptor_free(vf->efx, EVB_PORT_ID_ASSIGNED);
604 goto restore_filters;
607 if (vf->vport_assigned) {
608 rc = efx_ef10_evb_port_assign(efx, EVB_PORT_ID_NULL, vf_i);
610 netif_warn(efx, drv, efx->net_dev,
611 "Failed to change vlan on VF %d.\n", vf_i);
612 netif_warn(efx, drv, efx->net_dev,
613 "This is likely because the VF is bound to a driver in a VM.\n");
614 netif_warn(efx, drv, efx->net_dev,
615 "Please unload the driver in the VM.\n");
616 goto restore_vadaptor;
618 vf->vport_assigned = 0;
621 if (!is_zero_ether_addr(vf->mac)) {
622 rc = efx_ef10_vport_del_mac(efx, vf->vport_id, vf->mac);
624 goto restore_evb_port;
628 rc = efx_ef10_vport_free(efx, vf->vport_id);
634 /* Do the actual vlan change */
638 /* Restore everything in reverse order */
639 rc = efx_ef10_vport_alloc(efx, EVB_PORT_ID_ASSIGNED,
640 MC_CMD_VPORT_ALLOC_IN_VPORT_TYPE_NORMAL,
641 vf->vlan, &vf->vport_id);
646 if (!is_zero_ether_addr(vf->mac)) {
647 rc2 = efx_ef10_vport_add_mac(efx, vf->vport_id, vf->mac);
649 eth_zero_addr(vf->mac);
655 rc2 = efx_ef10_evb_port_assign(efx, vf->vport_id, vf_i);
659 vf->vport_assigned = 1;
663 rc2 = efx_ef10_vadaptor_alloc(vf->efx, EVB_PORT_ID_ASSIGNED);
670 rc2 = vf->efx->type->filter_table_probe(vf->efx);
674 up_write(&vf->efx->filter_sem);
676 rc2 = efx_net_open(vf->efx->net_dev);
680 netif_device_attach(vf->efx->net_dev);
686 up_write(&vf->efx->filter_sem);
687 netif_err(efx, drv, efx->net_dev,
688 "Failed to restore VF - scheduling reset.\n");
689 efx_schedule_reset(vf->efx, RESET_TYPE_DATAPATH);
691 netif_err(efx, drv, efx->net_dev,
692 "Failed to restore the VF and cannot reset the VF "
693 "- VF is not functional.\n");
694 netif_err(efx, drv, efx->net_dev,
695 "Please reload the driver attached to the VF.\n");
698 return rc ? rc : rc2;
701 int efx_ef10_sriov_set_vf_spoofchk(struct efx_nic *efx, int vf_i,
704 return spoofchk ? -EOPNOTSUPP : 0;
707 int efx_ef10_sriov_set_vf_link_state(struct efx_nic *efx, int vf_i,
710 MCDI_DECLARE_BUF(inbuf, MC_CMD_LINK_STATE_MODE_IN_LEN);
711 struct efx_ef10_nic_data *nic_data = efx->nic_data;
713 BUILD_BUG_ON(IFLA_VF_LINK_STATE_AUTO !=
714 MC_CMD_LINK_STATE_MODE_IN_LINK_STATE_AUTO);
715 BUILD_BUG_ON(IFLA_VF_LINK_STATE_ENABLE !=
716 MC_CMD_LINK_STATE_MODE_IN_LINK_STATE_UP);
717 BUILD_BUG_ON(IFLA_VF_LINK_STATE_DISABLE !=
718 MC_CMD_LINK_STATE_MODE_IN_LINK_STATE_DOWN);
719 MCDI_POPULATE_DWORD_2(inbuf, LINK_STATE_MODE_IN_FUNCTION,
720 LINK_STATE_MODE_IN_FUNCTION_PF,
722 LINK_STATE_MODE_IN_FUNCTION_VF, vf_i);
723 MCDI_SET_DWORD(inbuf, LINK_STATE_MODE_IN_NEW_MODE, link_state);
724 return efx_mcdi_rpc(efx, MC_CMD_LINK_STATE_MODE, inbuf, sizeof(inbuf),
725 NULL, 0, NULL); /* don't care what old mode was */
728 int efx_ef10_sriov_get_vf_config(struct efx_nic *efx, int vf_i,
729 struct ifla_vf_info *ivf)
731 MCDI_DECLARE_BUF(inbuf, MC_CMD_LINK_STATE_MODE_IN_LEN);
732 MCDI_DECLARE_BUF(outbuf, MC_CMD_LINK_STATE_MODE_OUT_LEN);
734 struct efx_ef10_nic_data *nic_data = efx->nic_data;
739 if (vf_i >= efx->vf_count)
745 vf = nic_data->vf + vf_i;
748 ivf->min_tx_rate = 0;
749 ivf->max_tx_rate = 0;
750 ether_addr_copy(ivf->mac, vf->mac);
751 ivf->vlan = (vf->vlan == EFX_EF10_NO_VLAN) ? 0 : vf->vlan;
754 MCDI_POPULATE_DWORD_2(inbuf, LINK_STATE_MODE_IN_FUNCTION,
755 LINK_STATE_MODE_IN_FUNCTION_PF,
757 LINK_STATE_MODE_IN_FUNCTION_VF, vf_i);
758 MCDI_SET_DWORD(inbuf, LINK_STATE_MODE_IN_NEW_MODE,
759 MC_CMD_LINK_STATE_MODE_IN_DO_NOT_CHANGE);
760 rc = efx_mcdi_rpc(efx, MC_CMD_LINK_STATE_MODE, inbuf, sizeof(inbuf),
761 outbuf, sizeof(outbuf), &outlen);
764 if (outlen < MC_CMD_LINK_STATE_MODE_OUT_LEN)
766 ivf->linkstate = MCDI_DWORD(outbuf, LINK_STATE_MODE_OUT_OLD_MODE);
771 int efx_ef10_sriov_get_phys_port_id(struct efx_nic *efx,
772 struct netdev_phys_item_id *ppid)
774 struct efx_ef10_nic_data *nic_data = efx->nic_data;
776 if (!is_valid_ether_addr(nic_data->port_id))
779 ppid->id_len = ETH_ALEN;
780 memcpy(ppid->id, nic_data->port_id, ppid->id_len);