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

sfc: Add NIC type operations to replace direct calls from efx.c into siena_sriov.c

Also add dummy functions where required to avoid NULL pointer dereference.
Signed-off-by: default avatarShradha Shah <sshah@solarflare.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 327c685e
...@@ -3688,6 +3688,11 @@ const struct efx_nic_type efx_hunt_a0_nic_type = { ...@@ -3688,6 +3688,11 @@ const struct efx_nic_type efx_hunt_a0_nic_type = {
.ptp_write_host_time = efx_ef10_ptp_write_host_time, .ptp_write_host_time = efx_ef10_ptp_write_host_time,
.ptp_set_ts_sync_events = efx_ef10_ptp_set_ts_sync_events, .ptp_set_ts_sync_events = efx_ef10_ptp_set_ts_sync_events,
.ptp_set_ts_config = efx_ef10_ptp_set_ts_config, .ptp_set_ts_config = efx_ef10_ptp_set_ts_config,
.sriov_init = efx_ef10_sriov_init,
.sriov_fini = efx_ef10_sriov_fini,
.sriov_mac_address_changed = efx_ef10_sriov_mac_address_changed,
.sriov_wanted = efx_ef10_sriov_wanted,
.sriov_reset = efx_ef10_sriov_reset,
.revision = EFX_REV_HUNT_A0, .revision = EFX_REV_HUNT_A0,
.max_dma_mask = DMA_BIT_MASK(ESF_DZ_TX_KER_BUF_ADDR_WIDTH), .max_dma_mask = DMA_BIT_MASK(ESF_DZ_TX_KER_BUF_ADDR_WIDTH),
......
...@@ -1314,7 +1314,7 @@ static unsigned int efx_wanted_parallelism(struct efx_nic *efx) ...@@ -1314,7 +1314,7 @@ static unsigned int efx_wanted_parallelism(struct efx_nic *efx)
/* If RSS is requested for the PF *and* VFs then we can't write RSS /* If RSS is requested for the PF *and* VFs then we can't write RSS
* table entries that are inaccessible to VFs * table entries that are inaccessible to VFs
*/ */
if (efx_siena_sriov_wanted(efx) && efx_vf_size(efx) > 1 && if (efx->type->sriov_wanted(efx) && efx_vf_size(efx) > 1 &&
count > efx_vf_size(efx)) { count > efx_vf_size(efx)) {
netif_warn(efx, probe, efx->net_dev, netif_warn(efx, probe, efx->net_dev,
"Reducing number of RSS channels from %u to %u for " "Reducing number of RSS channels from %u to %u for "
...@@ -1426,8 +1426,9 @@ static int efx_probe_interrupts(struct efx_nic *efx) ...@@ -1426,8 +1426,9 @@ static int efx_probe_interrupts(struct efx_nic *efx)
} }
/* RSS might be usable on VFs even if it is disabled on the PF */ /* RSS might be usable on VFs even if it is disabled on the PF */
efx->rss_spread = ((efx->n_rx_channels > 1 || efx->rss_spread = ((efx->n_rx_channels > 1 ||
!efx_siena_sriov_wanted(efx)) ? !efx->type->sriov_wanted(efx)) ?
efx->n_rx_channels : efx_vf_size(efx)); efx->n_rx_channels : efx_vf_size(efx));
return 0; return 0;
...@@ -2167,7 +2168,7 @@ static int efx_set_mac_address(struct net_device *net_dev, void *data) ...@@ -2167,7 +2168,7 @@ static int efx_set_mac_address(struct net_device *net_dev, void *data)
} }
ether_addr_copy(net_dev->dev_addr, new_addr); ether_addr_copy(net_dev->dev_addr, new_addr);
efx_siena_sriov_mac_address_changed(efx); efx->type->sriov_mac_address_changed(efx);
/* Reconfigure the MAC */ /* Reconfigure the MAC */
mutex_lock(&efx->mac_lock); mutex_lock(&efx->mac_lock);
...@@ -2434,7 +2435,7 @@ int efx_reset_up(struct efx_nic *efx, enum reset_type method, bool ok) ...@@ -2434,7 +2435,7 @@ int efx_reset_up(struct efx_nic *efx, enum reset_type method, bool ok)
if (rc) if (rc)
goto fail; goto fail;
efx_restore_filters(efx); efx_restore_filters(efx);
efx_siena_sriov_reset(efx); efx->type->sriov_reset(efx);
mutex_unlock(&efx->mac_lock); mutex_unlock(&efx->mac_lock);
...@@ -2827,7 +2828,7 @@ static void efx_pci_remove(struct pci_dev *pci_dev) ...@@ -2827,7 +2828,7 @@ static void efx_pci_remove(struct pci_dev *pci_dev)
efx_disable_interrupts(efx); efx_disable_interrupts(efx);
rtnl_unlock(); rtnl_unlock();
efx_siena_sriov_fini(efx); efx->type->sriov_fini(efx);
efx_unregister_netdev(efx); efx_unregister_netdev(efx);
efx_mtd_remove(efx); efx_mtd_remove(efx);
...@@ -3024,7 +3025,7 @@ static int efx_pci_probe(struct pci_dev *pci_dev, ...@@ -3024,7 +3025,7 @@ static int efx_pci_probe(struct pci_dev *pci_dev,
if (rc) if (rc)
goto fail4; goto fail4;
rc = efx_siena_sriov_init(efx); rc = efx->type->sriov_init(efx);
if (rc) if (rc)
netif_err(efx, probe, efx->net_dev, netif_err(efx, probe, efx->net_dev,
"SR-IOV can't be enabled rc %d\n", rc); "SR-IOV can't be enabled rc %d\n", rc);
......
...@@ -2766,6 +2766,11 @@ const struct efx_nic_type falcon_a1_nic_type = { ...@@ -2766,6 +2766,11 @@ const struct efx_nic_type falcon_a1_nic_type = {
.mtd_write = falcon_mtd_write, .mtd_write = falcon_mtd_write,
.mtd_sync = falcon_mtd_sync, .mtd_sync = falcon_mtd_sync,
#endif #endif
.sriov_init = efx_falcon_sriov_init,
.sriov_fini = efx_falcon_sriov_fini,
.sriov_mac_address_changed = efx_falcon_sriov_mac_address_changed,
.sriov_wanted = efx_falcon_sriov_wanted,
.sriov_reset = efx_falcon_sriov_reset,
.revision = EFX_REV_FALCON_A1, .revision = EFX_REV_FALCON_A1,
.txd_ptr_tbl_base = FR_AA_TX_DESC_PTR_TBL_KER, .txd_ptr_tbl_base = FR_AA_TX_DESC_PTR_TBL_KER,
...@@ -2862,6 +2867,11 @@ const struct efx_nic_type falcon_b0_nic_type = { ...@@ -2862,6 +2867,11 @@ const struct efx_nic_type falcon_b0_nic_type = {
.mtd_write = falcon_mtd_write, .mtd_write = falcon_mtd_write,
.mtd_sync = falcon_mtd_sync, .mtd_sync = falcon_mtd_sync,
#endif #endif
.sriov_init = efx_falcon_sriov_init,
.sriov_fini = efx_falcon_sriov_fini,
.sriov_mac_address_changed = efx_falcon_sriov_mac_address_changed,
.sriov_wanted = efx_falcon_sriov_wanted,
.sriov_reset = efx_falcon_sriov_reset,
.revision = EFX_REV_FALCON_B0, .revision = EFX_REV_FALCON_B0,
.txd_ptr_tbl_base = FR_BZ_TX_DESC_PTR_TBL, .txd_ptr_tbl_base = FR_BZ_TX_DESC_PTR_TBL,
......
...@@ -1685,7 +1685,7 @@ void efx_farch_dimension_resources(struct efx_nic *efx, unsigned sram_lim_qw) ...@@ -1685,7 +1685,7 @@ void efx_farch_dimension_resources(struct efx_nic *efx, unsigned sram_lim_qw)
vi_count = max(efx->n_channels, efx->n_tx_channels * EFX_TXQ_TYPES); vi_count = max(efx->n_channels, efx->n_tx_channels * EFX_TXQ_TYPES);
#ifdef CONFIG_SFC_SRIOV #ifdef CONFIG_SFC_SRIOV
if (efx_siena_sriov_wanted(efx)) { if (efx->type->sriov_wanted(efx)) {
unsigned vi_dc_entries, buftbl_free, entries_per_vf, vf_limit; unsigned vi_dc_entries, buftbl_free, entries_per_vf, vf_limit;
nic_data->vf_buftbl_base = buftbl_min; nic_data->vf_buftbl_base = buftbl_min;
......
...@@ -1330,6 +1330,11 @@ struct efx_nic_type { ...@@ -1330,6 +1330,11 @@ struct efx_nic_type {
int (*ptp_set_ts_sync_events)(struct efx_nic *efx, bool en, bool temp); int (*ptp_set_ts_sync_events)(struct efx_nic *efx, bool en, bool temp);
int (*ptp_set_ts_config)(struct efx_nic *efx, int (*ptp_set_ts_config)(struct efx_nic *efx,
struct hwtstamp_config *init); struct hwtstamp_config *init);
int (*sriov_init)(struct efx_nic *efx);
void (*sriov_fini)(struct efx_nic *efx);
void (*sriov_mac_address_changed)(struct efx_nic *efx);
bool (*sriov_wanted)(struct efx_nic *efx);
void (*sriov_reset)(struct efx_nic *efx);
int revision; int revision;
unsigned int txd_ptr_tbl_base; unsigned int txd_ptr_tbl_base;
......
...@@ -540,6 +540,7 @@ struct efx_ef10_nic_data { ...@@ -540,6 +540,7 @@ struct efx_ef10_nic_data {
#ifdef CONFIG_SFC_SRIOV #ifdef CONFIG_SFC_SRIOV
/* SIENA */
static inline bool efx_siena_sriov_wanted(struct efx_nic *efx) static inline bool efx_siena_sriov_wanted(struct efx_nic *efx)
{ {
return efx->vf_count != 0; return efx->vf_count != 0;
...@@ -568,12 +569,19 @@ void efx_siena_sriov_reset(struct efx_nic *efx); ...@@ -568,12 +569,19 @@ void efx_siena_sriov_reset(struct efx_nic *efx);
void efx_siena_sriov_fini(struct efx_nic *efx); void efx_siena_sriov_fini(struct efx_nic *efx);
void efx_fini_sriov(void); void efx_fini_sriov(void);
/* EF10 */
static inline bool efx_ef10_sriov_wanted(struct efx_nic *efx) { return false; }
static inline int efx_ef10_sriov_init(struct efx_nic *efx) { return -EOPNOTSUPP; }
static inline void efx_ef10_sriov_mac_address_changed(struct efx_nic *efx) {}
static inline void efx_ef10_sriov_reset(struct efx_nic *efx) {}
static inline void efx_ef10_sriov_fini(struct efx_nic *efx) {}
#else #else
/* SIENA */
static inline bool efx_siena_sriov_wanted(struct efx_nic *efx) { return false; } static inline bool efx_siena_sriov_wanted(struct efx_nic *efx) { return false; }
static inline bool efx_siena_sriov_enabled(struct efx_nic *efx) { return false; } static inline bool efx_siena_sriov_enabled(struct efx_nic *efx) { return false; }
static inline unsigned int efx_vf_size(struct efx_nic *efx) { return 0; } static inline unsigned int efx_vf_size(struct efx_nic *efx) { return 0; }
static inline int efx_init_sriov(void) { return 0; } static inline int efx_init_sriov(void) { return 0; }
static inline void efx_siena_sriov_probe(struct efx_nic *efx) {} static inline void efx_siena_sriov_probe(struct efx_nic *efx) {}
static inline int efx_siena_sriov_init(struct efx_nic *efx) { return -EOPNOTSUPP; } static inline int efx_siena_sriov_init(struct efx_nic *efx) { return -EOPNOTSUPP; }
...@@ -591,8 +599,22 @@ static inline void efx_siena_sriov_reset(struct efx_nic *efx) {} ...@@ -591,8 +599,22 @@ static inline void efx_siena_sriov_reset(struct efx_nic *efx) {}
static inline void efx_siena_sriov_fini(struct efx_nic *efx) {} static inline void efx_siena_sriov_fini(struct efx_nic *efx) {}
static inline void efx_fini_sriov(void) {} static inline void efx_fini_sriov(void) {}
/* EF10 */
static inline bool efx_ef10_sriov_wanted(struct efx_nic *efx) { return false; }
static inline int efx_ef10_sriov_init(struct efx_nic *efx) { return -EOPNOTSUPP; }
static inline void efx_ef10_sriov_mac_address_changed(struct efx_nic *efx) {}
static inline void efx_ef10_sriov_reset(struct efx_nic *efx) {}
static inline void efx_ef10_sriov_fini(struct efx_nic *efx) {}
#endif #endif
/* FALCON */
static inline bool efx_falcon_sriov_wanted(struct efx_nic *efx) { return false; }
static inline int efx_falcon_sriov_init(struct efx_nic *efx) { return -EOPNOTSUPP; }
static inline void efx_falcon_sriov_mac_address_changed(struct efx_nic *efx) {}
static inline void efx_falcon_sriov_reset(struct efx_nic *efx) {}
static inline void efx_falcon_sriov_fini(struct efx_nic *efx) {}
int efx_siena_sriov_set_vf_mac(struct net_device *dev, int vf, u8 *mac); int efx_siena_sriov_set_vf_mac(struct net_device *dev, int vf, u8 *mac);
int efx_siena_sriov_set_vf_vlan(struct net_device *dev, int vf, int efx_siena_sriov_set_vf_vlan(struct net_device *dev, int vf,
u16 vlan, u8 qos); u16 vlan, u8 qos);
......
...@@ -997,6 +997,11 @@ const struct efx_nic_type siena_a0_nic_type = { ...@@ -997,6 +997,11 @@ const struct efx_nic_type siena_a0_nic_type = {
#endif #endif
.ptp_write_host_time = siena_ptp_write_host_time, .ptp_write_host_time = siena_ptp_write_host_time,
.ptp_set_ts_config = siena_ptp_set_ts_config, .ptp_set_ts_config = siena_ptp_set_ts_config,
.sriov_init = efx_siena_sriov_init,
.sriov_fini = efx_siena_sriov_fini,
.sriov_mac_address_changed = efx_siena_sriov_mac_address_changed,
.sriov_wanted = efx_siena_sriov_wanted,
.sriov_reset = efx_siena_sriov_reset,
.revision = EFX_REV_SIENA_A0, .revision = EFX_REV_SIENA_A0,
.txd_ptr_tbl_base = FR_BZ_TX_DESC_PTR_TBL, .txd_ptr_tbl_base = FR_BZ_TX_DESC_PTR_TBL,
......
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