提交 cfc77c2f 编写于 作者: S Shradha Shah 提交者: David S. Miller

sfc: save old MAC address in case sriov_mac_address_changed fails

Otherwise the PF and VF can disagree on the VF's MAC address and
this leads to strange behaviour, up to and including kernel panics.
Signed-off-by: NShradha Shah <sshah@solarflare.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 88a37de6
...@@ -31,7 +31,10 @@ static inline bool efx_ef10_sriov_wanted(struct efx_nic *efx) ...@@ -31,7 +31,10 @@ static inline bool efx_ef10_sriov_wanted(struct efx_nic *efx)
int efx_ef10_sriov_configure(struct efx_nic *efx, int num_vfs); int efx_ef10_sriov_configure(struct efx_nic *efx, int num_vfs);
int efx_ef10_sriov_init(struct efx_nic *efx); int efx_ef10_sriov_init(struct efx_nic *efx);
static inline void efx_ef10_sriov_mac_address_changed(struct efx_nic *efx) {} static inline int efx_ef10_sriov_mac_address_changed(struct efx_nic *efx)
{
return -EOPNOTSUPP;
}
static inline void efx_ef10_sriov_reset(struct efx_nic *efx) {} static inline void efx_ef10_sriov_reset(struct efx_nic *efx) {}
void efx_ef10_sriov_fini(struct efx_nic *efx); void efx_ef10_sriov_fini(struct efx_nic *efx);
static inline void efx_ef10_sriov_flr(struct efx_nic *efx, unsigned vf_i) {} static inline void efx_ef10_sriov_flr(struct efx_nic *efx, unsigned vf_i) {}
......
...@@ -2196,6 +2196,8 @@ static int efx_set_mac_address(struct net_device *net_dev, void *data) ...@@ -2196,6 +2196,8 @@ static int efx_set_mac_address(struct net_device *net_dev, void *data)
struct efx_nic *efx = netdev_priv(net_dev); struct efx_nic *efx = netdev_priv(net_dev);
struct sockaddr *addr = data; struct sockaddr *addr = data;
u8 *new_addr = addr->sa_data; u8 *new_addr = addr->sa_data;
u8 old_addr[6];
int rc;
if (!is_valid_ether_addr(new_addr)) { if (!is_valid_ether_addr(new_addr)) {
netif_err(efx, drv, efx->net_dev, netif_err(efx, drv, efx->net_dev,
...@@ -2204,9 +2206,16 @@ static int efx_set_mac_address(struct net_device *net_dev, void *data) ...@@ -2204,9 +2206,16 @@ static int efx_set_mac_address(struct net_device *net_dev, void *data)
return -EADDRNOTAVAIL; return -EADDRNOTAVAIL;
} }
/* save old address */
ether_addr_copy(old_addr, net_dev->dev_addr);
ether_addr_copy(net_dev->dev_addr, new_addr); ether_addr_copy(net_dev->dev_addr, new_addr);
if (efx->type->sriov_mac_address_changed) if (efx->type->sriov_mac_address_changed) {
efx->type->sriov_mac_address_changed(efx); rc = efx->type->sriov_mac_address_changed(efx);
if (rc) {
ether_addr_copy(net_dev->dev_addr, old_addr);
return rc;
}
}
/* Reconfigure the MAC */ /* Reconfigure the MAC */
mutex_lock(&efx->mac_lock); mutex_lock(&efx->mac_lock);
......
...@@ -1334,7 +1334,7 @@ struct efx_nic_type { ...@@ -1334,7 +1334,7 @@ struct efx_nic_type {
int (*sriov_configure)(struct efx_nic *efx, int num_vfs); int (*sriov_configure)(struct efx_nic *efx, int num_vfs);
int (*sriov_init)(struct efx_nic *efx); int (*sriov_init)(struct efx_nic *efx);
void (*sriov_fini)(struct efx_nic *efx); void (*sriov_fini)(struct efx_nic *efx);
void (*sriov_mac_address_changed)(struct efx_nic *efx); int (*sriov_mac_address_changed)(struct efx_nic *efx);
bool (*sriov_wanted)(struct efx_nic *efx); bool (*sriov_wanted)(struct efx_nic *efx);
void (*sriov_reset)(struct efx_nic *efx); void (*sriov_reset)(struct efx_nic *efx);
void (*sriov_flr)(struct efx_nic *efx, unsigned vf_i); void (*sriov_flr)(struct efx_nic *efx, unsigned vf_i);
......
...@@ -1476,16 +1476,18 @@ void efx_siena_sriov_flr(struct efx_nic *efx, unsigned vf_i) ...@@ -1476,16 +1476,18 @@ void efx_siena_sriov_flr(struct efx_nic *efx, unsigned vf_i)
vf->evq0_count = 0; vf->evq0_count = 0;
} }
void efx_siena_sriov_mac_address_changed(struct efx_nic *efx) int efx_siena_sriov_mac_address_changed(struct efx_nic *efx)
{ {
struct siena_nic_data *nic_data = efx->nic_data; struct siena_nic_data *nic_data = efx->nic_data;
struct vfdi_status *vfdi_status = nic_data->vfdi_status.addr; struct vfdi_status *vfdi_status = nic_data->vfdi_status.addr;
if (!efx->vf_init_count) if (!efx->vf_init_count)
return; return 0;
ether_addr_copy(vfdi_status->peers[0].mac_addr, ether_addr_copy(vfdi_status->peers[0].mac_addr,
efx->net_dev->dev_addr); efx->net_dev->dev_addr);
queue_work(vfdi_workqueue, &nic_data->peer_work); queue_work(vfdi_workqueue, &nic_data->peer_work);
return 0;
} }
void efx_siena_sriov_tx_flush_done(struct efx_nic *efx, efx_qword_t *event) void efx_siena_sriov_tx_flush_done(struct efx_nic *efx, efx_qword_t *event)
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
int efx_siena_sriov_configure(struct efx_nic *efx, int num_vfs); int efx_siena_sriov_configure(struct efx_nic *efx, int num_vfs);
int efx_siena_sriov_init(struct efx_nic *efx); int efx_siena_sriov_init(struct efx_nic *efx);
void efx_siena_sriov_fini(struct efx_nic *efx); void efx_siena_sriov_fini(struct efx_nic *efx);
void efx_siena_sriov_mac_address_changed(struct efx_nic *efx); int efx_siena_sriov_mac_address_changed(struct efx_nic *efx);
bool efx_siena_sriov_wanted(struct efx_nic *efx); bool efx_siena_sriov_wanted(struct efx_nic *efx);
void efx_siena_sriov_reset(struct efx_nic *efx); void efx_siena_sriov_reset(struct efx_nic *efx);
void efx_siena_sriov_flr(struct efx_nic *efx, unsigned flr); void efx_siena_sriov_flr(struct efx_nic *efx, unsigned flr);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册