aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Pieczko <dpieczko@solarflare.com>2015-07-07 06:37:00 -0400
committerDavid S. Miller <davem@davemloft.net>2015-07-08 19:07:33 -0400
commit9e9f665a18008999e749bd41394efcbf5c37a726 (patch)
tree56f4a76f76ae951e6f0edd5d68c8b0d26a1ad655
parentb5a983f3141239b5b0b4a4e66efa31f8a26354b8 (diff)
sfc: refactor code in efx_ef10_set_mac_address()
Re-organize the structure of error handling to avoid having to duplicate the netif_err() around the ifdefs. The only change to the behaviour of the error-handling is that the PF's data structure to record VF details should only be updated if the original command succeeded. Signed-off-by: Shradha Shah <sshah@solarflare.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/sfc/ef10.c45
1 files changed, 20 insertions, 25 deletions
diff --git a/drivers/net/ethernet/sfc/ef10.c b/drivers/net/ethernet/sfc/ef10.c
index 847643455468..9740cd02f81d 100644
--- a/drivers/net/ethernet/sfc/ef10.c
+++ b/drivers/net/ethernet/sfc/ef10.c
@@ -3829,38 +3829,27 @@ static int efx_ef10_set_mac_address(struct efx_nic *efx)
3829 efx_net_open(efx->net_dev); 3829 efx_net_open(efx->net_dev);
3830 netif_device_attach(efx->net_dev); 3830 netif_device_attach(efx->net_dev);
3831 3831
3832#if !defined(CONFIG_SFC_SRIOV) 3832#ifdef CONFIG_SFC_SRIOV
3833 if (rc == -EPERM) 3833 if (efx->pci_dev->is_virtfn && efx->pci_dev->physfn) {
3834 netif_err(efx, drv, efx->net_dev,
3835 "Cannot change MAC address; use sfboot to enable mac-spoofing"
3836 " on this interface\n");
3837#else
3838 if (rc == -EPERM) {
3839 struct pci_dev *pci_dev_pf = efx->pci_dev->physfn; 3834 struct pci_dev *pci_dev_pf = efx->pci_dev->physfn;
3840 3835
3841 /* Switch to PF and change MAC address on vport */ 3836 if (rc == -EPERM) {
3842 if (efx->pci_dev->is_virtfn && pci_dev_pf) { 3837 struct efx_nic *efx_pf;
3843 struct efx_nic *efx_pf = pci_get_drvdata(pci_dev_pf);
3844 3838
3845 if (!efx_ef10_sriov_set_vf_mac(efx_pf, 3839 /* Switch to PF and change MAC address on vport */
3846 nic_data->vf_index, 3840 efx_pf = pci_get_drvdata(pci_dev_pf);
3847 efx->net_dev->dev_addr))
3848 return 0;
3849 }
3850 netif_err(efx, drv, efx->net_dev,
3851 "Cannot change MAC address; use sfboot to enable mac-spoofing"
3852 " on this interface\n");
3853 } else if (efx->pci_dev->is_virtfn) {
3854 /* Successfully changed by VF (with MAC spoofing), so update the
3855 * parent PF if possible.
3856 */
3857 struct pci_dev *pci_dev_pf = efx->pci_dev->physfn;
3858 3841
3859 if (pci_dev_pf) { 3842 rc = efx_ef10_sriov_set_vf_mac(efx_pf,
3843 nic_data->vf_index,
3844 efx->net_dev->dev_addr);
3845 } else if (!rc) {
3860 struct efx_nic *efx_pf = pci_get_drvdata(pci_dev_pf); 3846 struct efx_nic *efx_pf = pci_get_drvdata(pci_dev_pf);
3861 struct efx_ef10_nic_data *nic_data = efx_pf->nic_data; 3847 struct efx_ef10_nic_data *nic_data = efx_pf->nic_data;
3862 unsigned int i; 3848 unsigned int i;
3863 3849
3850 /* MAC address successfully changed by VF (with MAC
3851 * spoofing) so update the parent PF if possible.
3852 */
3864 for (i = 0; i < efx_pf->vf_count; ++i) { 3853 for (i = 0; i < efx_pf->vf_count; ++i) {
3865 struct ef10_vf *vf = nic_data->vf + i; 3854 struct ef10_vf *vf = nic_data->vf + i;
3866 3855
@@ -3871,8 +3860,14 @@ static int efx_ef10_set_mac_address(struct efx_nic *efx)
3871 } 3860 }
3872 } 3861 }
3873 } 3862 }
3874 } 3863 } else
3875#endif 3864#endif
3865 if (rc == -EPERM) {
3866 netif_err(efx, drv, efx->net_dev,
3867 "Cannot change MAC address; use sfboot to enable"
3868 " mac-spoofing on this interface\n");
3869 }
3870
3876 return rc; 3871 return rc;
3877} 3872}
3878 3873