1 // SPDX-License-Identifier: GPL-2.0-only
2 /****************************************************************************
3 * Driver for Solarflare network controllers and boards
4 * Copyright 2015 Solarflare Communications Inc.
6 #include <linux/etherdevice.h>
8 #include <linux/module.h>
9 #include "net_driver.h"
10 #include "ef10_sriov.h"
13 #include "mcdi_pcol.h"
15 static int efx_ef10_evb_port_assign(struct efx_nic
*efx
, unsigned int port_id
,
18 MCDI_DECLARE_BUF(inbuf
, MC_CMD_EVB_PORT_ASSIGN_IN_LEN
);
19 struct efx_ef10_nic_data
*nic_data
= efx
->nic_data
;
21 MCDI_SET_DWORD(inbuf
, EVB_PORT_ASSIGN_IN_PORT_ID
, port_id
);
22 MCDI_POPULATE_DWORD_2(inbuf
, EVB_PORT_ASSIGN_IN_FUNCTION
,
23 EVB_PORT_ASSIGN_IN_PF
, nic_data
->pf_index
,
24 EVB_PORT_ASSIGN_IN_VF
, vf_fn
);
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
,
31 unsigned int vswitch_type
)
33 MCDI_DECLARE_BUF(inbuf
, MC_CMD_VSWITCH_ALLOC_IN_LEN
);
36 MCDI_SET_DWORD(inbuf
, VSWITCH_ALLOC_IN_UPSTREAM_PORT_ID
, port_id
);
37 MCDI_SET_DWORD(inbuf
, VSWITCH_ALLOC_IN_TYPE
, vswitch_type
);
38 MCDI_SET_DWORD(inbuf
, VSWITCH_ALLOC_IN_NUM_VLAN_TAGS
, 2);
39 MCDI_POPULATE_DWORD_1(inbuf
, VSWITCH_ALLOC_IN_FLAGS
,
40 VSWITCH_ALLOC_IN_FLAG_AUTO_PORT
, 0);
42 /* Quietly try to allocate 2 VLAN tags */
43 rc
= efx_mcdi_rpc_quiet(efx
, MC_CMD_VSWITCH_ALLOC
, inbuf
, sizeof(inbuf
),
46 /* If 2 VLAN tags is too many, revert to trying with 1 VLAN tags */
48 MCDI_SET_DWORD(inbuf
, VSWITCH_ALLOC_IN_NUM_VLAN_TAGS
, 1);
49 rc
= efx_mcdi_rpc(efx
, MC_CMD_VSWITCH_ALLOC
, inbuf
,
50 sizeof(inbuf
), NULL
, 0, NULL
);
52 efx_mcdi_display_error(efx
, MC_CMD_VSWITCH_ALLOC
,
53 MC_CMD_VSWITCH_ALLOC_IN_LEN
,
59 static int efx_ef10_vswitch_free(struct efx_nic
*efx
, unsigned int port_id
)
61 MCDI_DECLARE_BUF(inbuf
, MC_CMD_VSWITCH_FREE_IN_LEN
);
63 MCDI_SET_DWORD(inbuf
, VSWITCH_FREE_IN_UPSTREAM_PORT_ID
, 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
,
70 unsigned int port_id_in
,
71 unsigned int vport_type
,
73 unsigned int *port_id_out
)
75 MCDI_DECLARE_BUF(inbuf
, MC_CMD_VPORT_ALLOC_IN_LEN
);
76 MCDI_DECLARE_BUF(outbuf
, MC_CMD_VPORT_ALLOC_OUT_LEN
);
80 EFX_WARN_ON_PARANOID(!port_id_out
);
82 MCDI_SET_DWORD(inbuf
, VPORT_ALLOC_IN_UPSTREAM_PORT_ID
, port_id_in
);
83 MCDI_SET_DWORD(inbuf
, VPORT_ALLOC_IN_TYPE
, vport_type
);
84 MCDI_SET_DWORD(inbuf
, VPORT_ALLOC_IN_NUM_VLAN_TAGS
,
85 (vlan
!= EFX_EF10_NO_VLAN
));
86 MCDI_POPULATE_DWORD_1(inbuf
, VPORT_ALLOC_IN_FLAGS
,
87 VPORT_ALLOC_IN_FLAG_AUTO_PORT
, 0);
88 if (vlan
!= EFX_EF10_NO_VLAN
)
89 MCDI_POPULATE_DWORD_1(inbuf
, VPORT_ALLOC_IN_VLAN_TAGS
,
90 VPORT_ALLOC_IN_VLAN_TAG_0
, vlan
);
92 rc
= efx_mcdi_rpc(efx
, MC_CMD_VPORT_ALLOC
, inbuf
, sizeof(inbuf
),
93 outbuf
, sizeof(outbuf
), &outlen
);
96 if (outlen
< MC_CMD_VPORT_ALLOC_OUT_LEN
)
99 *port_id_out
= MCDI_DWORD(outbuf
, VPORT_ALLOC_OUT_VPORT_ID
);
103 static int efx_ef10_vport_free(struct efx_nic
*efx
, unsigned int port_id
)
105 MCDI_DECLARE_BUF(inbuf
, MC_CMD_VPORT_FREE_IN_LEN
);
107 MCDI_SET_DWORD(inbuf
, VPORT_FREE_IN_VPORT_ID
, 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
++) {
122 struct ef10_vf
*vf
= nic_data
->vf
+ i
;
124 /* If VF is assigned, do not free the vport */
126 vf
->pci_dev
->dev_flags
& PCI_DEV_FLAGS_ASSIGNED
)
129 if (vf
->vport_assigned
) {
130 efx_ef10_evb_port_assign(efx
, EVB_PORT_ID_NULL
, i
);
131 vf
->vport_assigned
= 0;
134 if (!is_zero_ether_addr(vf
->mac
)) {
135 efx_ef10_vport_del_mac(efx
, vf
->vport_id
, vf
->mac
);
136 eth_zero_addr(vf
->mac
);
140 efx_ef10_vport_free(efx
, vf
->vport_id
);
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
;
161 struct ef10_vf
*vf
= nic_data
->vf
+ vf_i
;
164 if (WARN_ON_ONCE(!nic_data
->vf
))
167 rc
= efx_ef10_vport_alloc(efx
, EVB_PORT_ID_ASSIGNED
,
168 MC_CMD_VPORT_ALLOC_IN_VPORT_TYPE_NORMAL
,
169 vf
->vlan
, &vf
->vport_id
);
173 rc
= efx_ef10_vport_add_mac(efx
, vf
->vport_id
, vf
->mac
);
175 eth_zero_addr(vf
->mac
);
179 rc
= efx_ef10_evb_port_assign(efx
, vf
->vport_id
, vf_i
);
183 vf
->vport_assigned
= 1;
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
++) {
199 eth_random_addr(nic_data
->vf
[i
].mac
);
200 nic_data
->vf
[i
].efx
= NULL
;
201 nic_data
->vf
[i
].vlan
= EFX_EF10_NO_VLAN
;
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
)
235 struct efx_ef10_nic_data
*nic_data
= efx
->nic_data
;
239 rc
= efx_ef10_vadaptor_alloc(efx
, nic_data
->vport_id
);
241 goto fail_vadaptor_alloc
;
243 rc
= efx_ef10_vadaptor_query(efx
, nic_data
->vport_id
,
244 &port_flags
, NULL
, NULL
);
246 goto fail_vadaptor_query
;
249 (1 << MC_CMD_VPORT_ALLOC_IN_FLAG_VLAN_RESTRICT_LBN
))
250 efx
->fixed_features
|= NETIF_F_HW_VLAN_CTAG_FILTER
;
252 efx
->fixed_features
&= ~NETIF_F_HW_VLAN_CTAG_FILTER
;
257 efx_ef10_vadaptor_free(efx
, EVB_PORT_ID_ASSIGNED
);
262 /* On top of the default firmware vswitch setup, create a VEB vswitch and
263 * expansion vport for use by this function.
265 int efx_ef10_vswitching_probe_pf(struct efx_nic
*efx
)
267 struct efx_ef10_nic_data
*nic_data
= efx
->nic_data
;
268 struct net_device
*net_dev
= efx
->net_dev
;
271 if (pci_sriov_get_totalvfs(efx
->pci_dev
) <= 0) {
272 /* vswitch not needed as we have no VFs */
273 efx_ef10_vadaptor_alloc_set_features(efx
);
277 rc
= efx_ef10_vswitch_alloc(efx
, EVB_PORT_ID_ASSIGNED
,
278 MC_CMD_VSWITCH_ALLOC_IN_VSWITCH_TYPE_VEB
);
282 rc
= efx_ef10_vport_alloc(efx
, EVB_PORT_ID_ASSIGNED
,
283 MC_CMD_VPORT_ALLOC_IN_VPORT_TYPE_NORMAL
,
284 EFX_EF10_NO_VLAN
, &nic_data
->vport_id
);
288 rc
= efx_ef10_vport_add_mac(efx
, nic_data
->vport_id
, net_dev
->dev_addr
);
291 ether_addr_copy(nic_data
->vport_mac
, net_dev
->dev_addr
);
293 rc
= efx_ef10_vadaptor_alloc_set_features(efx
);
299 efx_ef10_vport_del_mac(efx
, nic_data
->vport_id
, nic_data
->vport_mac
);
300 eth_zero_addr(nic_data
->vport_mac
);
302 efx_ef10_vport_free(efx
, nic_data
->vport_id
);
303 nic_data
->vport_id
= EVB_PORT_ID_ASSIGNED
;
305 efx_ef10_vswitch_free(efx
, EVB_PORT_ID_ASSIGNED
);
310 int efx_ef10_vswitching_probe_vf(struct efx_nic
*efx
)
312 return efx_ef10_vadaptor_alloc_set_features(efx
);
315 int efx_ef10_vswitching_restore_pf(struct efx_nic
*efx
)
317 struct efx_ef10_nic_data
*nic_data
= efx
->nic_data
;
320 if (!nic_data
->must_probe_vswitching
)
323 rc
= efx_ef10_vswitching_probe_pf(efx
);
327 rc
= efx_ef10_sriov_restore_vf_vswitching(efx
);
331 nic_data
->must_probe_vswitching
= false;
336 int efx_ef10_vswitching_restore_vf(struct efx_nic
*efx
)
338 struct efx_ef10_nic_data
*nic_data
= efx
->nic_data
;
341 if (!nic_data
->must_probe_vswitching
)
344 rc
= efx_ef10_vadaptor_free(efx
, EVB_PORT_ID_ASSIGNED
);
348 nic_data
->must_probe_vswitching
= false;
352 void efx_ef10_vswitching_remove_pf(struct efx_nic
*efx
)
354 struct efx_ef10_nic_data
*nic_data
= efx
->nic_data
;
356 efx_ef10_sriov_free_vf_vswitching(efx
);
358 efx_ef10_vadaptor_free(efx
, nic_data
->vport_id
);
360 if (nic_data
->vport_id
== EVB_PORT_ID_ASSIGNED
)
361 return; /* No vswitch was ever created */
363 if (!is_zero_ether_addr(nic_data
->vport_mac
)) {
364 efx_ef10_vport_del_mac(efx
, nic_data
->vport_id
,
365 efx
->net_dev
->dev_addr
);
366 eth_zero_addr(nic_data
->vport_mac
);
368 efx_ef10_vport_free(efx
, nic_data
->vport_id
);
369 nic_data
->vport_id
= EVB_PORT_ID_ASSIGNED
;
371 /* Only free the vswitch if no VFs are assigned */
372 if (!pci_vfs_assigned(efx
->pci_dev
))
373 efx_ef10_vswitch_free(efx
, nic_data
->vport_id
);
376 void efx_ef10_vswitching_remove_vf(struct efx_nic
*efx
)
378 efx_ef10_vadaptor_free(efx
, EVB_PORT_ID_ASSIGNED
);
381 static int efx_ef10_pci_sriov_enable(struct efx_nic
*efx
, int num_vfs
)
384 struct pci_dev
*dev
= efx
->pci_dev
;
386 efx
->vf_count
= num_vfs
;
388 rc
= efx_ef10_sriov_alloc_vf_vswitching(efx
);
392 rc
= pci_enable_sriov(dev
, num_vfs
);
398 efx_ef10_sriov_free_vf_vswitching(efx
);
401 netif_err(efx
, probe
, efx
->net_dev
,
402 "Failed to enable SRIOV VFs\n");
406 static int efx_ef10_pci_sriov_disable(struct efx_nic
*efx
, bool force
)
408 struct pci_dev
*dev
= efx
->pci_dev
;
409 unsigned int vfs_assigned
= 0;
411 vfs_assigned
= pci_vfs_assigned(dev
);
413 if (vfs_assigned
&& !force
) {
414 netif_info(efx
, drv
, efx
->net_dev
, "VFs are assigned to guests; "
415 "please detach them before disabling SR-IOV\n");
420 pci_disable_sriov(dev
);
422 efx_ef10_sriov_free_vf_vswitching(efx
);
427 int efx_ef10_sriov_configure(struct efx_nic
*efx
, int num_vfs
)
430 return efx_ef10_pci_sriov_disable(efx
, false);
432 return efx_ef10_pci_sriov_enable(efx
, num_vfs
);
435 int efx_ef10_sriov_init(struct efx_nic
*efx
)
440 void efx_ef10_sriov_fini(struct efx_nic
*efx
)
442 struct efx_ef10_nic_data
*nic_data
= efx
->nic_data
;
447 /* Remove any un-assigned orphaned VFs */
448 if (pci_num_vf(efx
->pci_dev
) && !pci_vfs_assigned(efx
->pci_dev
))
449 pci_disable_sriov(efx
->pci_dev
);
453 /* Remove any VFs in the host */
454 for (i
= 0; i
< efx
->vf_count
; ++i
) {
455 struct efx_nic
*vf_efx
= nic_data
->vf
[i
].efx
;
458 vf_efx
->pci_dev
->driver
->remove(vf_efx
->pci_dev
);
461 rc
= efx_ef10_pci_sriov_disable(efx
, true);
463 netif_dbg(efx
, drv
, efx
->net_dev
,
464 "Disabling SRIOV was not successful rc=%d\n", rc
);
466 netif_dbg(efx
, drv
, efx
->net_dev
, "SRIOV disabled\n");
469 static int efx_ef10_vport_del_vf_mac(struct efx_nic
*efx
, unsigned int port_id
,
472 MCDI_DECLARE_BUF(inbuf
, MC_CMD_VPORT_DEL_MAC_ADDRESS_IN_LEN
);
473 MCDI_DECLARE_BUF_ERR(outbuf
);
477 MCDI_SET_DWORD(inbuf
, VPORT_DEL_MAC_ADDRESS_IN_VPORT_ID
, port_id
);
478 ether_addr_copy(MCDI_PTR(inbuf
, VPORT_DEL_MAC_ADDRESS_IN_MACADDR
), mac
);
480 rc
= efx_mcdi_rpc(efx
, MC_CMD_VPORT_DEL_MAC_ADDRESS
, inbuf
,
481 sizeof(inbuf
), outbuf
, sizeof(outbuf
), &outlen
);
486 int efx_ef10_sriov_set_vf_mac(struct efx_nic
*efx
, int vf_i
, u8
*mac
)
488 struct efx_ef10_nic_data
*nic_data
= efx
->nic_data
;
495 if (vf_i
>= efx
->vf_count
)
497 vf
= nic_data
->vf
+ vf_i
;
500 efx_device_detach_sync(vf
->efx
);
501 efx_net_stop(vf
->efx
->net_dev
);
503 down_write(&vf
->efx
->filter_sem
);
504 vf
->efx
->type
->filter_table_remove(vf
->efx
);
506 rc
= efx_ef10_vadaptor_free(vf
->efx
, EVB_PORT_ID_ASSIGNED
);
508 up_write(&vf
->efx
->filter_sem
);
513 rc
= efx_ef10_evb_port_assign(efx
, EVB_PORT_ID_NULL
, vf_i
);
517 if (!is_zero_ether_addr(vf
->mac
)) {
518 rc
= efx_ef10_vport_del_vf_mac(efx
, vf
->vport_id
, vf
->mac
);
523 if (!is_zero_ether_addr(mac
)) {
524 rc
= efx_ef10_vport_add_mac(efx
, vf
->vport_id
, mac
);
529 ether_addr_copy(vf
->efx
->net_dev
->dev_addr
, mac
);
532 ether_addr_copy(vf
->mac
, mac
);
534 rc
= efx_ef10_evb_port_assign(efx
, vf
->vport_id
, vf_i
);
539 /* VF cannot use the vport_id that the PF created */
540 rc
= efx_ef10_vadaptor_alloc(vf
->efx
, EVB_PORT_ID_ASSIGNED
);
542 up_write(&vf
->efx
->filter_sem
);
545 vf
->efx
->type
->filter_table_probe(vf
->efx
);
546 up_write(&vf
->efx
->filter_sem
);
547 efx_net_open(vf
->efx
->net_dev
);
548 efx_device_attach_if_not_resetting(vf
->efx
);
554 eth_zero_addr(vf
->mac
);
558 int efx_ef10_sriov_set_vf_vlan(struct efx_nic
*efx
, int vf_i
, u16 vlan
,
561 struct efx_ef10_nic_data
*nic_data
= efx
->nic_data
;
566 if (vf_i
>= efx
->vf_count
)
571 vf
= nic_data
->vf
+ vf_i
;
573 new_vlan
= (vlan
== 0) ? EFX_EF10_NO_VLAN
: vlan
;
574 if (new_vlan
== vf
->vlan
)
578 efx_device_detach_sync(vf
->efx
);
579 efx_net_stop(vf
->efx
->net_dev
);
581 mutex_lock(&vf
->efx
->mac_lock
);
582 down_write(&vf
->efx
->filter_sem
);
583 vf
->efx
->type
->filter_table_remove(vf
->efx
);
585 rc
= efx_ef10_vadaptor_free(vf
->efx
, EVB_PORT_ID_ASSIGNED
);
587 goto restore_filters
;
590 if (vf
->vport_assigned
) {
591 rc
= efx_ef10_evb_port_assign(efx
, EVB_PORT_ID_NULL
, vf_i
);
593 netif_warn(efx
, drv
, efx
->net_dev
,
594 "Failed to change vlan on VF %d.\n", vf_i
);
595 netif_warn(efx
, drv
, efx
->net_dev
,
596 "This is likely because the VF is bound to a driver in a VM.\n");
597 netif_warn(efx
, drv
, efx
->net_dev
,
598 "Please unload the driver in the VM.\n");
599 goto restore_vadaptor
;
601 vf
->vport_assigned
= 0;
604 if (!is_zero_ether_addr(vf
->mac
)) {
605 rc
= efx_ef10_vport_del_mac(efx
, vf
->vport_id
, vf
->mac
);
607 goto restore_evb_port
;
611 rc
= efx_ef10_vport_free(efx
, vf
->vport_id
);
617 /* Do the actual vlan change */
620 /* Restore everything in reverse order */
621 rc
= efx_ef10_vport_alloc(efx
, EVB_PORT_ID_ASSIGNED
,
622 MC_CMD_VPORT_ALLOC_IN_VPORT_TYPE_NORMAL
,
623 vf
->vlan
, &vf
->vport_id
);
625 goto reset_nic_up_write
;
628 if (!is_zero_ether_addr(vf
->mac
)) {
629 rc2
= efx_ef10_vport_add_mac(efx
, vf
->vport_id
, vf
->mac
);
631 eth_zero_addr(vf
->mac
);
632 goto reset_nic_up_write
;
637 rc2
= efx_ef10_evb_port_assign(efx
, vf
->vport_id
, vf_i
);
639 goto reset_nic_up_write
;
641 vf
->vport_assigned
= 1;
645 rc2
= efx_ef10_vadaptor_alloc(vf
->efx
, EVB_PORT_ID_ASSIGNED
);
647 goto reset_nic_up_write
;
652 rc2
= vf
->efx
->type
->filter_table_probe(vf
->efx
);
654 goto reset_nic_up_write
;
656 up_write(&vf
->efx
->filter_sem
);
657 mutex_unlock(&vf
->efx
->mac_lock
);
659 rc2
= efx_net_open(vf
->efx
->net_dev
);
663 efx_device_attach_if_not_resetting(vf
->efx
);
669 up_write(&vf
->efx
->filter_sem
);
670 mutex_unlock(&vf
->efx
->mac_lock
);
674 netif_err(efx
, drv
, efx
->net_dev
,
675 "Failed to restore VF - scheduling reset.\n");
676 efx_schedule_reset(vf
->efx
, RESET_TYPE_DATAPATH
);
678 netif_err(efx
, drv
, efx
->net_dev
,
679 "Failed to restore the VF and cannot reset the VF "
680 "- VF is not functional.\n");
681 netif_err(efx
, drv
, efx
->net_dev
,
682 "Please reload the driver attached to the VF.\n");
685 return rc
? rc
: rc2
;
688 int efx_ef10_sriov_set_vf_spoofchk(struct efx_nic
*efx
, int vf_i
,
691 return spoofchk
? -EOPNOTSUPP
: 0;
694 int efx_ef10_sriov_set_vf_link_state(struct efx_nic
*efx
, int vf_i
,
697 MCDI_DECLARE_BUF(inbuf
, MC_CMD_LINK_STATE_MODE_IN_LEN
);
698 struct efx_ef10_nic_data
*nic_data
= efx
->nic_data
;
700 BUILD_BUG_ON(IFLA_VF_LINK_STATE_AUTO
!=
701 MC_CMD_LINK_STATE_MODE_IN_LINK_STATE_AUTO
);
702 BUILD_BUG_ON(IFLA_VF_LINK_STATE_ENABLE
!=
703 MC_CMD_LINK_STATE_MODE_IN_LINK_STATE_UP
);
704 BUILD_BUG_ON(IFLA_VF_LINK_STATE_DISABLE
!=
705 MC_CMD_LINK_STATE_MODE_IN_LINK_STATE_DOWN
);
706 MCDI_POPULATE_DWORD_2(inbuf
, LINK_STATE_MODE_IN_FUNCTION
,
707 LINK_STATE_MODE_IN_FUNCTION_PF
,
709 LINK_STATE_MODE_IN_FUNCTION_VF
, vf_i
);
710 MCDI_SET_DWORD(inbuf
, LINK_STATE_MODE_IN_NEW_MODE
, link_state
);
711 return efx_mcdi_rpc(efx
, MC_CMD_LINK_STATE_MODE
, inbuf
, sizeof(inbuf
),
712 NULL
, 0, NULL
); /* don't care what old mode was */
715 int efx_ef10_sriov_get_vf_config(struct efx_nic
*efx
, int vf_i
,
716 struct ifla_vf_info
*ivf
)
718 MCDI_DECLARE_BUF(inbuf
, MC_CMD_LINK_STATE_MODE_IN_LEN
);
719 MCDI_DECLARE_BUF(outbuf
, MC_CMD_LINK_STATE_MODE_OUT_LEN
);
721 struct efx_ef10_nic_data
*nic_data
= efx
->nic_data
;
726 if (vf_i
>= efx
->vf_count
)
732 vf
= nic_data
->vf
+ vf_i
;
735 ivf
->min_tx_rate
= 0;
736 ivf
->max_tx_rate
= 0;
737 ether_addr_copy(ivf
->mac
, vf
->mac
);
738 ivf
->vlan
= (vf
->vlan
== EFX_EF10_NO_VLAN
) ? 0 : vf
->vlan
;
741 MCDI_POPULATE_DWORD_2(inbuf
, LINK_STATE_MODE_IN_FUNCTION
,
742 LINK_STATE_MODE_IN_FUNCTION_PF
,
744 LINK_STATE_MODE_IN_FUNCTION_VF
, vf_i
);
745 MCDI_SET_DWORD(inbuf
, LINK_STATE_MODE_IN_NEW_MODE
,
746 MC_CMD_LINK_STATE_MODE_IN_DO_NOT_CHANGE
);
747 rc
= efx_mcdi_rpc(efx
, MC_CMD_LINK_STATE_MODE
, inbuf
, sizeof(inbuf
),
748 outbuf
, sizeof(outbuf
), &outlen
);
751 if (outlen
< MC_CMD_LINK_STATE_MODE_OUT_LEN
)
753 ivf
->linkstate
= MCDI_DWORD(outbuf
, LINK_STATE_MODE_OUT_OLD_MODE
);