diff options
author | Shradha Shah <sshah@solarflare.com> | 2014-11-05 07:16:46 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-11-06 14:43:09 -0500 |
commit | d98a4ffe0d7a8946c67d115f8b3bd8e5bb1df86d (patch) | |
tree | 8759bd88647af178390ac8c16e03b9a6f794c762 | |
parent | 327c685eb745e3c56ed52734d3671dcf6f4f6940 (diff) |
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: Shradha Shah <sshah@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/sfc/ef10.c | 5 | ||||
-rw-r--r-- | drivers/net/ethernet/sfc/efx.c | 13 | ||||
-rw-r--r-- | drivers/net/ethernet/sfc/falcon.c | 10 | ||||
-rw-r--r-- | drivers/net/ethernet/sfc/farch.c | 2 | ||||
-rw-r--r-- | drivers/net/ethernet/sfc/net_driver.h | 5 | ||||
-rw-r--r-- | drivers/net/ethernet/sfc/nic.h | 24 | ||||
-rw-r--r-- | drivers/net/ethernet/sfc/siena.c | 5 |
7 files changed, 56 insertions, 8 deletions
diff --git a/drivers/net/ethernet/sfc/ef10.c b/drivers/net/ethernet/sfc/ef10.c index 002d4cdc319f..ff55a1983014 100644 --- a/drivers/net/ethernet/sfc/ef10.c +++ b/drivers/net/ethernet/sfc/ef10.c | |||
@@ -3688,6 +3688,11 @@ const struct efx_nic_type efx_hunt_a0_nic_type = { | |||
3688 | .ptp_write_host_time = efx_ef10_ptp_write_host_time, | 3688 | .ptp_write_host_time = efx_ef10_ptp_write_host_time, |
3689 | .ptp_set_ts_sync_events = efx_ef10_ptp_set_ts_sync_events, | 3689 | .ptp_set_ts_sync_events = efx_ef10_ptp_set_ts_sync_events, |
3690 | .ptp_set_ts_config = efx_ef10_ptp_set_ts_config, | 3690 | .ptp_set_ts_config = efx_ef10_ptp_set_ts_config, |
3691 | .sriov_init = efx_ef10_sriov_init, | ||
3692 | .sriov_fini = efx_ef10_sriov_fini, | ||
3693 | .sriov_mac_address_changed = efx_ef10_sriov_mac_address_changed, | ||
3694 | .sriov_wanted = efx_ef10_sriov_wanted, | ||
3695 | .sriov_reset = efx_ef10_sriov_reset, | ||
3691 | 3696 | ||
3692 | .revision = EFX_REV_HUNT_A0, | 3697 | .revision = EFX_REV_HUNT_A0, |
3693 | .max_dma_mask = DMA_BIT_MASK(ESF_DZ_TX_KER_BUF_ADDR_WIDTH), | 3698 | .max_dma_mask = DMA_BIT_MASK(ESF_DZ_TX_KER_BUF_ADDR_WIDTH), |
diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c index 2236ffc6de32..b49d04886d4f 100644 --- a/drivers/net/ethernet/sfc/efx.c +++ b/drivers/net/ethernet/sfc/efx.c | |||
@@ -1314,7 +1314,7 @@ static unsigned int efx_wanted_parallelism(struct efx_nic *efx) | |||
1314 | /* If RSS is requested for the PF *and* VFs then we can't write RSS | 1314 | /* If RSS is requested for the PF *and* VFs then we can't write RSS |
1315 | * table entries that are inaccessible to VFs | 1315 | * table entries that are inaccessible to VFs |
1316 | */ | 1316 | */ |
1317 | if (efx_siena_sriov_wanted(efx) && efx_vf_size(efx) > 1 && | 1317 | if (efx->type->sriov_wanted(efx) && efx_vf_size(efx) > 1 && |
1318 | count > efx_vf_size(efx)) { | 1318 | count > efx_vf_size(efx)) { |
1319 | netif_warn(efx, probe, efx->net_dev, | 1319 | netif_warn(efx, probe, efx->net_dev, |
1320 | "Reducing number of RSS channels from %u to %u for " | 1320 | "Reducing number of RSS channels from %u to %u for " |
@@ -1426,8 +1426,9 @@ static int efx_probe_interrupts(struct efx_nic *efx) | |||
1426 | } | 1426 | } |
1427 | 1427 | ||
1428 | /* RSS might be usable on VFs even if it is disabled on the PF */ | 1428 | /* RSS might be usable on VFs even if it is disabled on the PF */ |
1429 | |||
1429 | efx->rss_spread = ((efx->n_rx_channels > 1 || | 1430 | efx->rss_spread = ((efx->n_rx_channels > 1 || |
1430 | !efx_siena_sriov_wanted(efx)) ? | 1431 | !efx->type->sriov_wanted(efx)) ? |
1431 | efx->n_rx_channels : efx_vf_size(efx)); | 1432 | efx->n_rx_channels : efx_vf_size(efx)); |
1432 | 1433 | ||
1433 | return 0; | 1434 | return 0; |
@@ -2167,7 +2168,7 @@ static int efx_set_mac_address(struct net_device *net_dev, void *data) | |||
2167 | } | 2168 | } |
2168 | 2169 | ||
2169 | ether_addr_copy(net_dev->dev_addr, new_addr); | 2170 | ether_addr_copy(net_dev->dev_addr, new_addr); |
2170 | efx_siena_sriov_mac_address_changed(efx); | 2171 | efx->type->sriov_mac_address_changed(efx); |
2171 | 2172 | ||
2172 | /* Reconfigure the MAC */ | 2173 | /* Reconfigure the MAC */ |
2173 | mutex_lock(&efx->mac_lock); | 2174 | mutex_lock(&efx->mac_lock); |
@@ -2434,7 +2435,7 @@ int efx_reset_up(struct efx_nic *efx, enum reset_type method, bool ok) | |||
2434 | if (rc) | 2435 | if (rc) |
2435 | goto fail; | 2436 | goto fail; |
2436 | efx_restore_filters(efx); | 2437 | efx_restore_filters(efx); |
2437 | efx_siena_sriov_reset(efx); | 2438 | efx->type->sriov_reset(efx); |
2438 | 2439 | ||
2439 | mutex_unlock(&efx->mac_lock); | 2440 | mutex_unlock(&efx->mac_lock); |
2440 | 2441 | ||
@@ -2827,7 +2828,7 @@ static void efx_pci_remove(struct pci_dev *pci_dev) | |||
2827 | efx_disable_interrupts(efx); | 2828 | efx_disable_interrupts(efx); |
2828 | rtnl_unlock(); | 2829 | rtnl_unlock(); |
2829 | 2830 | ||
2830 | efx_siena_sriov_fini(efx); | 2831 | efx->type->sriov_fini(efx); |
2831 | efx_unregister_netdev(efx); | 2832 | efx_unregister_netdev(efx); |
2832 | 2833 | ||
2833 | efx_mtd_remove(efx); | 2834 | efx_mtd_remove(efx); |
@@ -3024,7 +3025,7 @@ static int efx_pci_probe(struct pci_dev *pci_dev, | |||
3024 | if (rc) | 3025 | if (rc) |
3025 | goto fail4; | 3026 | goto fail4; |
3026 | 3027 | ||
3027 | rc = efx_siena_sriov_init(efx); | 3028 | rc = efx->type->sriov_init(efx); |
3028 | if (rc) | 3029 | if (rc) |
3029 | netif_err(efx, probe, efx->net_dev, | 3030 | netif_err(efx, probe, efx->net_dev, |
3030 | "SR-IOV can't be enabled rc %d\n", rc); | 3031 | "SR-IOV can't be enabled rc %d\n", rc); |
diff --git a/drivers/net/ethernet/sfc/falcon.c b/drivers/net/ethernet/sfc/falcon.c index 157037546d30..f166c8ef38a3 100644 --- a/drivers/net/ethernet/sfc/falcon.c +++ b/drivers/net/ethernet/sfc/falcon.c | |||
@@ -2766,6 +2766,11 @@ const struct efx_nic_type falcon_a1_nic_type = { | |||
2766 | .mtd_write = falcon_mtd_write, | 2766 | .mtd_write = falcon_mtd_write, |
2767 | .mtd_sync = falcon_mtd_sync, | 2767 | .mtd_sync = falcon_mtd_sync, |
2768 | #endif | 2768 | #endif |
2769 | .sriov_init = efx_falcon_sriov_init, | ||
2770 | .sriov_fini = efx_falcon_sriov_fini, | ||
2771 | .sriov_mac_address_changed = efx_falcon_sriov_mac_address_changed, | ||
2772 | .sriov_wanted = efx_falcon_sriov_wanted, | ||
2773 | .sriov_reset = efx_falcon_sriov_reset, | ||
2769 | 2774 | ||
2770 | .revision = EFX_REV_FALCON_A1, | 2775 | .revision = EFX_REV_FALCON_A1, |
2771 | .txd_ptr_tbl_base = FR_AA_TX_DESC_PTR_TBL_KER, | 2776 | .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 | .mtd_write = falcon_mtd_write, | 2867 | .mtd_write = falcon_mtd_write, |
2863 | .mtd_sync = falcon_mtd_sync, | 2868 | .mtd_sync = falcon_mtd_sync, |
2864 | #endif | 2869 | #endif |
2870 | .sriov_init = efx_falcon_sriov_init, | ||
2871 | .sriov_fini = efx_falcon_sriov_fini, | ||
2872 | .sriov_mac_address_changed = efx_falcon_sriov_mac_address_changed, | ||
2873 | .sriov_wanted = efx_falcon_sriov_wanted, | ||
2874 | .sriov_reset = efx_falcon_sriov_reset, | ||
2865 | 2875 | ||
2866 | .revision = EFX_REV_FALCON_B0, | 2876 | .revision = EFX_REV_FALCON_B0, |
2867 | .txd_ptr_tbl_base = FR_BZ_TX_DESC_PTR_TBL, | 2877 | .txd_ptr_tbl_base = FR_BZ_TX_DESC_PTR_TBL, |
diff --git a/drivers/net/ethernet/sfc/farch.c b/drivers/net/ethernet/sfc/farch.c index f5549a94e0c3..75975328e020 100644 --- a/drivers/net/ethernet/sfc/farch.c +++ b/drivers/net/ethernet/sfc/farch.c | |||
@@ -1685,7 +1685,7 @@ void efx_farch_dimension_resources(struct efx_nic *efx, unsigned sram_lim_qw) | |||
1685 | vi_count = max(efx->n_channels, efx->n_tx_channels * EFX_TXQ_TYPES); | 1685 | vi_count = max(efx->n_channels, efx->n_tx_channels * EFX_TXQ_TYPES); |
1686 | 1686 | ||
1687 | #ifdef CONFIG_SFC_SRIOV | 1687 | #ifdef CONFIG_SFC_SRIOV |
1688 | if (efx_siena_sriov_wanted(efx)) { | 1688 | if (efx->type->sriov_wanted(efx)) { |
1689 | unsigned vi_dc_entries, buftbl_free, entries_per_vf, vf_limit; | 1689 | unsigned vi_dc_entries, buftbl_free, entries_per_vf, vf_limit; |
1690 | 1690 | ||
1691 | nic_data->vf_buftbl_base = buftbl_min; | 1691 | nic_data->vf_buftbl_base = buftbl_min; |
diff --git a/drivers/net/ethernet/sfc/net_driver.h b/drivers/net/ethernet/sfc/net_driver.h index 779a1f59a010..325dd94bca46 100644 --- a/drivers/net/ethernet/sfc/net_driver.h +++ b/drivers/net/ethernet/sfc/net_driver.h | |||
@@ -1330,6 +1330,11 @@ struct efx_nic_type { | |||
1330 | int (*ptp_set_ts_sync_events)(struct efx_nic *efx, bool en, bool temp); | 1330 | int (*ptp_set_ts_sync_events)(struct efx_nic *efx, bool en, bool temp); |
1331 | int (*ptp_set_ts_config)(struct efx_nic *efx, | 1331 | int (*ptp_set_ts_config)(struct efx_nic *efx, |
1332 | struct hwtstamp_config *init); | 1332 | struct hwtstamp_config *init); |
1333 | int (*sriov_init)(struct efx_nic *efx); | ||
1334 | void (*sriov_fini)(struct efx_nic *efx); | ||
1335 | void (*sriov_mac_address_changed)(struct efx_nic *efx); | ||
1336 | bool (*sriov_wanted)(struct efx_nic *efx); | ||
1337 | void (*sriov_reset)(struct efx_nic *efx); | ||
1333 | 1338 | ||
1334 | int revision; | 1339 | int revision; |
1335 | unsigned int txd_ptr_tbl_base; | 1340 | unsigned int txd_ptr_tbl_base; |
diff --git a/drivers/net/ethernet/sfc/nic.h b/drivers/net/ethernet/sfc/nic.h index 1ab3eda9a690..93d10cbbd1cf 100644 --- a/drivers/net/ethernet/sfc/nic.h +++ b/drivers/net/ethernet/sfc/nic.h | |||
@@ -540,6 +540,7 @@ struct efx_ef10_nic_data { | |||
540 | 540 | ||
541 | #ifdef CONFIG_SFC_SRIOV | 541 | #ifdef CONFIG_SFC_SRIOV |
542 | 542 | ||
543 | /* SIENA */ | ||
543 | static inline bool efx_siena_sriov_wanted(struct efx_nic *efx) | 544 | static inline bool efx_siena_sriov_wanted(struct efx_nic *efx) |
544 | { | 545 | { |
545 | return efx->vf_count != 0; | 546 | return efx->vf_count != 0; |
@@ -568,12 +569,19 @@ void efx_siena_sriov_reset(struct efx_nic *efx); | |||
568 | void efx_siena_sriov_fini(struct efx_nic *efx); | 569 | void efx_siena_sriov_fini(struct efx_nic *efx); |
569 | void efx_fini_sriov(void); | 570 | void efx_fini_sriov(void); |
570 | 571 | ||
572 | /* EF10 */ | ||
573 | static inline bool efx_ef10_sriov_wanted(struct efx_nic *efx) { return false; } | ||
574 | static inline int efx_ef10_sriov_init(struct efx_nic *efx) { return -EOPNOTSUPP; } | ||
575 | static inline void efx_ef10_sriov_mac_address_changed(struct efx_nic *efx) {} | ||
576 | static inline void efx_ef10_sriov_reset(struct efx_nic *efx) {} | ||
577 | static inline void efx_ef10_sriov_fini(struct efx_nic *efx) {} | ||
578 | |||
571 | #else | 579 | #else |
572 | 580 | ||
581 | /* SIENA */ | ||
573 | static inline bool efx_siena_sriov_wanted(struct efx_nic *efx) { return false; } | 582 | static inline bool efx_siena_sriov_wanted(struct efx_nic *efx) { return false; } |
574 | static inline bool efx_siena_sriov_enabled(struct efx_nic *efx) { return false; } | 583 | static inline bool efx_siena_sriov_enabled(struct efx_nic *efx) { return false; } |
575 | static inline unsigned int efx_vf_size(struct efx_nic *efx) { return 0; } | 584 | static inline unsigned int efx_vf_size(struct efx_nic *efx) { return 0; } |
576 | |||
577 | static inline int efx_init_sriov(void) { return 0; } | 585 | static inline int efx_init_sriov(void) { return 0; } |
578 | static inline void efx_siena_sriov_probe(struct efx_nic *efx) {} | 586 | static inline void efx_siena_sriov_probe(struct efx_nic *efx) {} |
579 | static inline int efx_siena_sriov_init(struct efx_nic *efx) { return -EOPNOTSUPP; } | 587 | 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 | static inline void efx_siena_sriov_fini(struct efx_nic *efx) {} | 599 | static inline void efx_siena_sriov_fini(struct efx_nic *efx) {} |
592 | static inline void efx_fini_sriov(void) {} | 600 | static inline void efx_fini_sriov(void) {} |
593 | 601 | ||
602 | /* EF10 */ | ||
603 | static inline bool efx_ef10_sriov_wanted(struct efx_nic *efx) { return false; } | ||
604 | static inline int efx_ef10_sriov_init(struct efx_nic *efx) { return -EOPNOTSUPP; } | ||
605 | static inline void efx_ef10_sriov_mac_address_changed(struct efx_nic *efx) {} | ||
606 | static inline void efx_ef10_sriov_reset(struct efx_nic *efx) {} | ||
607 | static inline void efx_ef10_sriov_fini(struct efx_nic *efx) {} | ||
608 | |||
594 | #endif | 609 | #endif |
595 | 610 | ||
611 | /* FALCON */ | ||
612 | static inline bool efx_falcon_sriov_wanted(struct efx_nic *efx) { return false; } | ||
613 | static inline int efx_falcon_sriov_init(struct efx_nic *efx) { return -EOPNOTSUPP; } | ||
614 | static inline void efx_falcon_sriov_mac_address_changed(struct efx_nic *efx) {} | ||
615 | static inline void efx_falcon_sriov_reset(struct efx_nic *efx) {} | ||
616 | static inline void efx_falcon_sriov_fini(struct efx_nic *efx) {} | ||
617 | |||
596 | int efx_siena_sriov_set_vf_mac(struct net_device *dev, int vf, u8 *mac); | 618 | int efx_siena_sriov_set_vf_mac(struct net_device *dev, int vf, u8 *mac); |
597 | int efx_siena_sriov_set_vf_vlan(struct net_device *dev, int vf, | 619 | int efx_siena_sriov_set_vf_vlan(struct net_device *dev, int vf, |
598 | u16 vlan, u8 qos); | 620 | u16 vlan, u8 qos); |
diff --git a/drivers/net/ethernet/sfc/siena.c b/drivers/net/ethernet/sfc/siena.c index cf40d602230e..3583f0208a6e 100644 --- a/drivers/net/ethernet/sfc/siena.c +++ b/drivers/net/ethernet/sfc/siena.c | |||
@@ -997,6 +997,11 @@ const struct efx_nic_type siena_a0_nic_type = { | |||
997 | #endif | 997 | #endif |
998 | .ptp_write_host_time = siena_ptp_write_host_time, | 998 | .ptp_write_host_time = siena_ptp_write_host_time, |
999 | .ptp_set_ts_config = siena_ptp_set_ts_config, | 999 | .ptp_set_ts_config = siena_ptp_set_ts_config, |
1000 | .sriov_init = efx_siena_sriov_init, | ||
1001 | .sriov_fini = efx_siena_sriov_fini, | ||
1002 | .sriov_mac_address_changed = efx_siena_sriov_mac_address_changed, | ||
1003 | .sriov_wanted = efx_siena_sriov_wanted, | ||
1004 | .sriov_reset = efx_siena_sriov_reset, | ||
1000 | 1005 | ||
1001 | .revision = EFX_REV_SIENA_A0, | 1006 | .revision = EFX_REV_SIENA_A0, |
1002 | .txd_ptr_tbl_base = FR_BZ_TX_DESC_PTR_TBL, | 1007 | .txd_ptr_tbl_base = FR_BZ_TX_DESC_PTR_TBL, |