Commit e340be92 authored by Shradha Shah's avatar Shradha Shah Committed by David S. Miller

sfc: add ndo_set_vf_mac() function for EF10

Implement a response to this entrypoint.
The ndo_set_vf_mac() entrypoint is only exposed in the driver if
CONFIG_SFC_SRIOV is defined.
Signed-off-by: default avatarShradha Shah <sshah@solarflare.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent aa09a3da
...@@ -431,3 +431,93 @@ void efx_ef10_sriov_fini(struct efx_nic *efx) ...@@ -431,3 +431,93 @@ void efx_ef10_sriov_fini(struct efx_nic *efx)
else else
netif_dbg(efx, drv, efx->net_dev, "SRIOV disabled\n"); netif_dbg(efx, drv, efx->net_dev, "SRIOV disabled\n");
} }
static int efx_ef10_vport_del_vf_mac(struct efx_nic *efx, unsigned int port_id,
u8 *mac)
{
MCDI_DECLARE_BUF(inbuf, MC_CMD_VPORT_DEL_MAC_ADDRESS_IN_LEN);
MCDI_DECLARE_BUF_ERR(outbuf);
size_t outlen;
int rc;
MCDI_SET_DWORD(inbuf, VPORT_DEL_MAC_ADDRESS_IN_VPORT_ID, port_id);
ether_addr_copy(MCDI_PTR(inbuf, VPORT_DEL_MAC_ADDRESS_IN_MACADDR), mac);
rc = efx_mcdi_rpc(efx, MC_CMD_VPORT_DEL_MAC_ADDRESS, inbuf,
sizeof(inbuf), outbuf, sizeof(outbuf), &outlen);
return rc;
}
int efx_ef10_sriov_set_vf_mac(struct efx_nic *efx, int vf_i, u8 *mac)
{
struct efx_ef10_nic_data *nic_data = efx->nic_data;
struct ef10_vf *vf;
int rc;
if (!nic_data->vf)
return -EOPNOTSUPP;
if (vf_i >= efx->vf_count)
return -EINVAL;
vf = nic_data->vf + vf_i;
if (vf->efx) {
efx_device_detach_sync(vf->efx);
efx_net_stop(vf->efx->net_dev);
down_write(&vf->efx->filter_sem);
vf->efx->type->filter_table_remove(vf->efx);
rc = efx_ef10_vadaptor_free(vf->efx, EVB_PORT_ID_ASSIGNED);
if (rc) {
up_write(&vf->efx->filter_sem);
return rc;
}
}
rc = efx_ef10_evb_port_assign(efx, EVB_PORT_ID_NULL, vf_i);
if (rc)
return rc;
if (!is_zero_ether_addr(vf->mac)) {
rc = efx_ef10_vport_del_vf_mac(efx, vf->vport_id, vf->mac);
if (rc)
return rc;
}
if (!is_zero_ether_addr(mac)) {
rc = efx_ef10_vport_add_mac(efx, vf->vport_id, mac);
if (rc) {
eth_zero_addr(vf->mac);
goto fail;
}
if (vf->efx)
ether_addr_copy(vf->efx->net_dev->dev_addr, mac);
}
ether_addr_copy(vf->mac, mac);
rc = efx_ef10_evb_port_assign(efx, vf->vport_id, vf_i);
if (rc)
goto fail;
if (vf->efx) {
/* VF cannot use the vport_id that the PF created */
rc = efx_ef10_vadaptor_alloc(vf->efx, EVB_PORT_ID_ASSIGNED);
if (rc) {
up_write(&vf->efx->filter_sem);
return rc;
}
vf->efx->type->filter_table_probe(vf->efx);
up_write(&vf->efx->filter_sem);
efx_net_open(vf->efx->net_dev);
netif_device_attach(vf->efx->net_dev);
}
return 0;
fail:
memset(vf->mac, 0, ETH_ALEN);
return rc;
}
...@@ -41,11 +41,7 @@ static inline void efx_ef10_sriov_reset(struct efx_nic *efx) {} ...@@ -41,11 +41,7 @@ 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) {}
static inline int efx_ef10_sriov_set_vf_mac(struct efx_nic *efx, int vf, int efx_ef10_sriov_set_vf_mac(struct efx_nic *efx, int vf, u8 *mac);
u8 *mac)
{
return -EOPNOTSUPP;
}
static inline int efx_ef10_sriov_set_vf_vlan(struct efx_nic *efx, int vf, static inline int efx_ef10_sriov_set_vf_vlan(struct efx_nic *efx, int vf,
u16 vlan, u8 qos) u16 vlan, u8 qos)
......
...@@ -2113,7 +2113,7 @@ static int efx_busy_poll(struct napi_struct *napi) ...@@ -2113,7 +2113,7 @@ static int efx_busy_poll(struct napi_struct *napi)
*************************************************************************/ *************************************************************************/
/* Context: process, rtnl_lock() held. */ /* Context: process, rtnl_lock() held. */
static int efx_net_open(struct net_device *net_dev) int efx_net_open(struct net_device *net_dev)
{ {
struct efx_nic *efx = netdev_priv(net_dev); struct efx_nic *efx = netdev_priv(net_dev);
int rc; int rc;
...@@ -2142,7 +2142,7 @@ static int efx_net_open(struct net_device *net_dev) ...@@ -2142,7 +2142,7 @@ static int efx_net_open(struct net_device *net_dev)
* Note that the kernel will ignore our return code; this method * Note that the kernel will ignore our return code; this method
* should really be a void. * should really be a void.
*/ */
static int efx_net_stop(struct net_device *net_dev) int efx_net_stop(struct net_device *net_dev)
{ {
struct efx_nic *efx = netdev_priv(net_dev); struct efx_nic *efx = netdev_priv(net_dev);
......
...@@ -19,6 +19,9 @@ ...@@ -19,6 +19,9 @@
#define EFX_MEM_BAR 2 #define EFX_MEM_BAR 2
#define EFX_MEM_VF_BAR 0 #define EFX_MEM_VF_BAR 0
int efx_net_open(struct net_device *net_dev);
int efx_net_stop(struct net_device *net_dev);
/* TX */ /* TX */
int efx_probe_tx_queue(struct efx_tx_queue *tx_queue); int efx_probe_tx_queue(struct efx_tx_queue *tx_queue);
void efx_remove_tx_queue(struct efx_tx_queue *tx_queue); void efx_remove_tx_queue(struct efx_tx_queue *tx_queue);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment