Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sfc: Store the efx_nic struct of the current VF in the VF data struct

Initialised in efx_probe_vf and removal is dealt with in
efx_ef10_remove.

vf->efx is needed in future patches to change the MAC address
of the VF via the parent PF, while the driver is bound to the
VF.
Example: ip link set dev vf NUM mac LLADDR

Signed-off-by: Shradha Shah <sshah@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Shradha Shah and committed by
David S. Miller
f1122a34 cfc77c2f

+37
+32
drivers/net/ethernet/sfc/ef10.c
··· 544 544 struct efx_ef10_nic_data *nic_data = efx->nic_data; 545 545 int rc; 546 546 547 + #ifdef CONFIG_SFC_SRIOV 548 + struct efx_ef10_nic_data *nic_data_pf; 549 + struct pci_dev *pci_dev_pf; 550 + struct efx_nic *efx_pf; 551 + struct ef10_vf *vf; 552 + 553 + if (efx->pci_dev->is_virtfn) { 554 + pci_dev_pf = efx->pci_dev->physfn; 555 + if (pci_dev_pf) { 556 + efx_pf = pci_get_drvdata(pci_dev_pf); 557 + nic_data_pf = efx_pf->nic_data; 558 + vf = nic_data_pf->vf + nic_data->vf_index; 559 + vf->efx = NULL; 560 + } else 561 + netif_info(efx, drv, efx->net_dev, 562 + "Could not get the PF id from VF\n"); 563 + } 564 + #endif 565 + 547 566 efx_ptp_remove(efx); 548 567 549 568 efx_mcdi_mon_remove(efx); ··· 600 581 rc = efx_ef10_get_vf_index(efx); 601 582 if (rc) 602 583 goto fail; 584 + 585 + if (efx->pci_dev->is_virtfn) { 586 + if (efx->pci_dev->physfn) { 587 + struct efx_nic *efx_pf = 588 + pci_get_drvdata(efx->pci_dev->physfn); 589 + struct efx_ef10_nic_data *nic_data_p = efx_pf->nic_data; 590 + struct efx_ef10_nic_data *nic_data = efx->nic_data; 591 + 592 + nic_data_p->vf[nic_data->vf_index].efx = efx; 593 + } else 594 + netif_info(efx, drv, efx->net_dev, 595 + "Could not get the PF id from VF\n"); 596 + } 603 597 604 598 return 0; 605 599
+3
drivers/net/ethernet/sfc/ef10_sriov.c
··· 160 160 efx_ef10_vport_free(efx, vf->vport_id); 161 161 vf->vport_id = 0; 162 162 } 163 + 164 + vf->efx = NULL; 163 165 } 164 166 } 165 167 ··· 217 215 218 216 for (i = 0; i < efx->vf_count; i++) { 219 217 random_ether_addr(nic_data->vf[i].mac); 218 + nic_data->vf[i].efx = NULL; 220 219 221 220 rc = efx_ef10_sriov_assign_vf_vport(efx, i); 222 221 if (rc)
+2
drivers/net/ethernet/sfc/ef10_sriov.h
··· 14 14 15 15 /** 16 16 * struct ef10_vf - PF's store of VF data 17 + * @efx: efx_nic struct for the current VF 17 18 * @vport_id: vport ID for the VF 18 19 * @vport_assigned: record whether the vport is currently assigned to the VF 19 20 * @mac: MAC address for the VF, zero when address is removed from the vport 20 21 */ 21 22 struct ef10_vf { 23 + struct efx_nic *efx; 22 24 unsigned int vport_id; 23 25 unsigned int vport_assigned; 24 26 u8 mac[ETH_ALEN];