diff options
author | Ben Hutchings <bhutchings@solarflare.com> | 2009-11-28 22:42:31 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-11-29 19:46:27 -0500 |
commit | ef2b90ee4dba7a3d9001f1f0003b860b39a4aaae (patch) | |
tree | 5eec233a05fab4fd0c79dc9c1eb6541d45cead53 /drivers | |
parent | 4b0d29dcfca9eafbf6e940862ab022df3ef2dd6f (diff) |
sfc: Move Falcon NIC operations to efx_nic_type
This is preparation for adding differing implementations for new NICs.
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/sfc/efx.c | 44 | ||||
-rw-r--r-- | drivers/net/sfc/ethtool.c | 2 | ||||
-rw-r--r-- | drivers/net/sfc/falcon.c | 79 | ||||
-rw-r--r-- | drivers/net/sfc/falcon.h | 12 | ||||
-rw-r--r-- | drivers/net/sfc/net_driver.h | 29 | ||||
-rw-r--r-- | drivers/net/sfc/selftest.c | 2 |
6 files changed, 105 insertions, 63 deletions
diff --git a/drivers/net/sfc/efx.c b/drivers/net/sfc/efx.c index f5e81114270a..73ab246d9f2a 100644 --- a/drivers/net/sfc/efx.c +++ b/drivers/net/sfc/efx.c | |||
@@ -274,14 +274,14 @@ static int efx_poll(struct napi_struct *napi, int budget) | |||
274 | irq_adapt_low_thresh)) { | 274 | irq_adapt_low_thresh)) { |
275 | if (channel->irq_moderation > 1) { | 275 | if (channel->irq_moderation > 1) { |
276 | channel->irq_moderation -= 1; | 276 | channel->irq_moderation -= 1; |
277 | falcon_set_int_moderation(channel); | 277 | efx->type->push_irq_moderation(channel); |
278 | } | 278 | } |
279 | } else if (unlikely(channel->irq_mod_score > | 279 | } else if (unlikely(channel->irq_mod_score > |
280 | irq_adapt_high_thresh)) { | 280 | irq_adapt_high_thresh)) { |
281 | if (channel->irq_moderation < | 281 | if (channel->irq_moderation < |
282 | efx->irq_rx_moderation) { | 282 | efx->irq_rx_moderation) { |
283 | channel->irq_moderation += 1; | 283 | channel->irq_moderation += 1; |
284 | falcon_set_int_moderation(channel); | 284 | efx->type->push_irq_moderation(channel); |
285 | } | 285 | } |
286 | } | 286 | } |
287 | channel->irq_count = 0; | 287 | channel->irq_count = 0; |
@@ -637,7 +637,7 @@ void __efx_reconfigure_port(struct efx_nic *efx) | |||
637 | netif_addr_unlock_bh(efx->net_dev); | 637 | netif_addr_unlock_bh(efx->net_dev); |
638 | } | 638 | } |
639 | 639 | ||
640 | falcon_stop_nic_stats(efx); | 640 | efx->type->stop_stats(efx); |
641 | falcon_deconfigure_mac_wrapper(efx); | 641 | falcon_deconfigure_mac_wrapper(efx); |
642 | 642 | ||
643 | /* Reconfigure the PHY, disabling transmit in mac level loopback. */ | 643 | /* Reconfigure the PHY, disabling transmit in mac level loopback. */ |
@@ -652,7 +652,7 @@ void __efx_reconfigure_port(struct efx_nic *efx) | |||
652 | 652 | ||
653 | efx->mac_op->reconfigure(efx); | 653 | efx->mac_op->reconfigure(efx); |
654 | 654 | ||
655 | falcon_start_nic_stats(efx); | 655 | efx->type->start_stats(efx); |
656 | 656 | ||
657 | /* Inform kernel of loss/gain of carrier */ | 657 | /* Inform kernel of loss/gain of carrier */ |
658 | efx_link_status_changed(efx); | 658 | efx_link_status_changed(efx); |
@@ -684,7 +684,7 @@ static void efx_mac_work(struct work_struct *data) | |||
684 | 684 | ||
685 | mutex_lock(&efx->mac_lock); | 685 | mutex_lock(&efx->mac_lock); |
686 | if (efx->port_enabled) { | 686 | if (efx->port_enabled) { |
687 | falcon_push_multicast_hash(efx); | 687 | efx->type->push_multicast_hash(efx); |
688 | efx->mac_op->reconfigure(efx); | 688 | efx->mac_op->reconfigure(efx); |
689 | } | 689 | } |
690 | mutex_unlock(&efx->mac_lock); | 690 | mutex_unlock(&efx->mac_lock); |
@@ -696,8 +696,8 @@ static int efx_probe_port(struct efx_nic *efx) | |||
696 | 696 | ||
697 | EFX_LOG(efx, "create port\n"); | 697 | EFX_LOG(efx, "create port\n"); |
698 | 698 | ||
699 | /* Connect up MAC/PHY operations table and read MAC address */ | 699 | /* Connect up MAC/PHY operations table */ |
700 | rc = falcon_probe_port(efx); | 700 | rc = efx->type->probe_port(efx); |
701 | if (rc) | 701 | if (rc) |
702 | goto err; | 702 | goto err; |
703 | 703 | ||
@@ -765,7 +765,7 @@ static void efx_start_port(struct efx_nic *efx) | |||
765 | 765 | ||
766 | /* efx_mac_work() might have been scheduled after efx_stop_port(), | 766 | /* efx_mac_work() might have been scheduled after efx_stop_port(), |
767 | * and then cancelled by efx_flush_all() */ | 767 | * and then cancelled by efx_flush_all() */ |
768 | falcon_push_multicast_hash(efx); | 768 | efx->type->push_multicast_hash(efx); |
769 | efx->mac_op->reconfigure(efx); | 769 | efx->mac_op->reconfigure(efx); |
770 | 770 | ||
771 | mutex_unlock(&efx->mac_lock); | 771 | mutex_unlock(&efx->mac_lock); |
@@ -805,7 +805,7 @@ static void efx_remove_port(struct efx_nic *efx) | |||
805 | { | 805 | { |
806 | EFX_LOG(efx, "destroying port\n"); | 806 | EFX_LOG(efx, "destroying port\n"); |
807 | 807 | ||
808 | falcon_remove_port(efx); | 808 | efx->type->remove_port(efx); |
809 | } | 809 | } |
810 | 810 | ||
811 | /************************************************************************** | 811 | /************************************************************************** |
@@ -1042,7 +1042,7 @@ static int efx_probe_nic(struct efx_nic *efx) | |||
1042 | EFX_LOG(efx, "creating NIC\n"); | 1042 | EFX_LOG(efx, "creating NIC\n"); |
1043 | 1043 | ||
1044 | /* Carry out hardware-type specific initialisation */ | 1044 | /* Carry out hardware-type specific initialisation */ |
1045 | rc = falcon_probe_nic(efx); | 1045 | rc = efx->type->probe(efx); |
1046 | if (rc) | 1046 | if (rc) |
1047 | return rc; | 1047 | return rc; |
1048 | 1048 | ||
@@ -1063,7 +1063,7 @@ static void efx_remove_nic(struct efx_nic *efx) | |||
1063 | EFX_LOG(efx, "destroying NIC\n"); | 1063 | EFX_LOG(efx, "destroying NIC\n"); |
1064 | 1064 | ||
1065 | efx_remove_interrupts(efx); | 1065 | efx_remove_interrupts(efx); |
1066 | falcon_remove_nic(efx); | 1066 | efx->type->remove(efx); |
1067 | } | 1067 | } |
1068 | 1068 | ||
1069 | /************************************************************************** | 1069 | /************************************************************************** |
@@ -1145,12 +1145,12 @@ static void efx_start_all(struct efx_nic *efx) | |||
1145 | 1145 | ||
1146 | falcon_enable_interrupts(efx); | 1146 | falcon_enable_interrupts(efx); |
1147 | 1147 | ||
1148 | /* Start hardware monitor if we're in RUNNING */ | 1148 | /* Start the hardware monitor (if there is one) if we're in RUNNING */ |
1149 | if (efx->state == STATE_RUNNING) | 1149 | if (efx->state == STATE_RUNNING && efx->type->monitor != NULL) |
1150 | queue_delayed_work(efx->workqueue, &efx->monitor_work, | 1150 | queue_delayed_work(efx->workqueue, &efx->monitor_work, |
1151 | efx_monitor_interval); | 1151 | efx_monitor_interval); |
1152 | 1152 | ||
1153 | falcon_start_nic_stats(efx); | 1153 | efx->type->start_stats(efx); |
1154 | } | 1154 | } |
1155 | 1155 | ||
1156 | /* Flush all delayed work. Should only be called when no more delayed work | 1156 | /* Flush all delayed work. Should only be called when no more delayed work |
@@ -1186,7 +1186,7 @@ static void efx_stop_all(struct efx_nic *efx) | |||
1186 | if (!efx->port_enabled) | 1186 | if (!efx->port_enabled) |
1187 | return; | 1187 | return; |
1188 | 1188 | ||
1189 | falcon_stop_nic_stats(efx); | 1189 | efx->type->stop_stats(efx); |
1190 | 1190 | ||
1191 | /* Disable interrupts and wait for ISR to complete */ | 1191 | /* Disable interrupts and wait for ISR to complete */ |
1192 | falcon_disable_interrupts(efx); | 1192 | falcon_disable_interrupts(efx); |
@@ -1284,6 +1284,7 @@ static void efx_monitor(struct work_struct *data) | |||
1284 | 1284 | ||
1285 | EFX_TRACE(efx, "hardware monitor executing on CPU %d\n", | 1285 | EFX_TRACE(efx, "hardware monitor executing on CPU %d\n", |
1286 | raw_smp_processor_id()); | 1286 | raw_smp_processor_id()); |
1287 | BUG_ON(efx->type->monitor == NULL); | ||
1287 | 1288 | ||
1288 | /* If the mac_lock is already held then it is likely a port | 1289 | /* If the mac_lock is already held then it is likely a port |
1289 | * reconfiguration is already in place, which will likely do | 1290 | * reconfiguration is already in place, which will likely do |
@@ -1292,7 +1293,7 @@ static void efx_monitor(struct work_struct *data) | |||
1292 | goto out_requeue; | 1293 | goto out_requeue; |
1293 | if (!efx->port_enabled) | 1294 | if (!efx->port_enabled) |
1294 | goto out_unlock; | 1295 | goto out_unlock; |
1295 | falcon_monitor(efx); | 1296 | efx->type->monitor(efx); |
1296 | 1297 | ||
1297 | out_unlock: | 1298 | out_unlock: |
1298 | mutex_unlock(&efx->mac_lock); | 1299 | mutex_unlock(&efx->mac_lock); |
@@ -1430,7 +1431,7 @@ static struct net_device_stats *efx_net_stats(struct net_device *net_dev) | |||
1430 | struct net_device_stats *stats = &net_dev->stats; | 1431 | struct net_device_stats *stats = &net_dev->stats; |
1431 | 1432 | ||
1432 | spin_lock_bh(&efx->stats_lock); | 1433 | spin_lock_bh(&efx->stats_lock); |
1433 | falcon_update_nic_stats(efx); | 1434 | efx->type->update_stats(efx); |
1434 | spin_unlock_bh(&efx->stats_lock); | 1435 | spin_unlock_bh(&efx->stats_lock); |
1435 | 1436 | ||
1436 | stats->rx_packets = mac_stats->rx_packets; | 1437 | stats->rx_packets = mac_stats->rx_packets; |
@@ -1695,6 +1696,7 @@ void efx_reset_down(struct efx_nic *efx, enum reset_type method, | |||
1695 | efx_fini_channels(efx); | 1696 | efx_fini_channels(efx); |
1696 | if (efx->port_initialized && method != RESET_TYPE_INVISIBLE) | 1697 | if (efx->port_initialized && method != RESET_TYPE_INVISIBLE) |
1697 | efx->phy_op->fini(efx); | 1698 | efx->phy_op->fini(efx); |
1699 | efx->type->fini(efx); | ||
1698 | } | 1700 | } |
1699 | 1701 | ||
1700 | /* This function will always ensure that the locks acquired in | 1702 | /* This function will always ensure that the locks acquired in |
@@ -1709,7 +1711,7 @@ int efx_reset_up(struct efx_nic *efx, enum reset_type method, | |||
1709 | 1711 | ||
1710 | EFX_ASSERT_RESET_SERIALISED(efx); | 1712 | EFX_ASSERT_RESET_SERIALISED(efx); |
1711 | 1713 | ||
1712 | rc = falcon_init_nic(efx); | 1714 | rc = efx->type->init(efx); |
1713 | if (rc) { | 1715 | if (rc) { |
1714 | EFX_ERR(efx, "failed to initialise NIC\n"); | 1716 | EFX_ERR(efx, "failed to initialise NIC\n"); |
1715 | ok = false; | 1717 | ok = false; |
@@ -1769,7 +1771,7 @@ static int efx_reset(struct efx_nic *efx) | |||
1769 | 1771 | ||
1770 | efx_reset_down(efx, method, &ecmd); | 1772 | efx_reset_down(efx, method, &ecmd); |
1771 | 1773 | ||
1772 | rc = falcon_reset_hw(efx, method); | 1774 | rc = efx->type->reset(efx, method); |
1773 | if (rc) { | 1775 | if (rc) { |
1774 | EFX_ERR(efx, "failed to reset hardware\n"); | 1776 | EFX_ERR(efx, "failed to reset hardware\n"); |
1775 | goto out_disable; | 1777 | goto out_disable; |
@@ -2005,6 +2007,7 @@ static void efx_pci_remove_main(struct efx_nic *efx) | |||
2005 | falcon_fini_interrupt(efx); | 2007 | falcon_fini_interrupt(efx); |
2006 | efx_fini_channels(efx); | 2008 | efx_fini_channels(efx); |
2007 | efx_fini_port(efx); | 2009 | efx_fini_port(efx); |
2010 | efx->type->fini(efx); | ||
2008 | efx_fini_napi(efx); | 2011 | efx_fini_napi(efx); |
2009 | efx_remove_all(efx); | 2012 | efx_remove_all(efx); |
2010 | } | 2013 | } |
@@ -2064,7 +2067,7 @@ static int efx_pci_probe_main(struct efx_nic *efx) | |||
2064 | if (rc) | 2067 | if (rc) |
2065 | goto fail2; | 2068 | goto fail2; |
2066 | 2069 | ||
2067 | rc = falcon_init_nic(efx); | 2070 | rc = efx->type->init(efx); |
2068 | if (rc) { | 2071 | if (rc) { |
2069 | EFX_ERR(efx, "failed to initialise NIC\n"); | 2072 | EFX_ERR(efx, "failed to initialise NIC\n"); |
2070 | goto fail3; | 2073 | goto fail3; |
@@ -2088,6 +2091,7 @@ static int efx_pci_probe_main(struct efx_nic *efx) | |||
2088 | efx_fini_channels(efx); | 2091 | efx_fini_channels(efx); |
2089 | efx_fini_port(efx); | 2092 | efx_fini_port(efx); |
2090 | fail4: | 2093 | fail4: |
2094 | efx->type->fini(efx); | ||
2091 | fail3: | 2095 | fail3: |
2092 | efx_fini_napi(efx); | 2096 | efx_fini_napi(efx); |
2093 | fail2: | 2097 | fail2: |
diff --git a/drivers/net/sfc/ethtool.c b/drivers/net/sfc/ethtool.c index d3da360f09bc..49e0aed920d3 100644 --- a/drivers/net/sfc/ethtool.c +++ b/drivers/net/sfc/ethtool.c | |||
@@ -649,7 +649,7 @@ static int efx_ethtool_set_coalesce(struct net_device *net_dev, | |||
649 | 649 | ||
650 | efx_init_irq_moderation(efx, tx_usecs, rx_usecs, adaptive); | 650 | efx_init_irq_moderation(efx, tx_usecs, rx_usecs, adaptive); |
651 | efx_for_each_channel(channel, efx) | 651 | efx_for_each_channel(channel, efx) |
652 | falcon_set_int_moderation(channel); | 652 | efx->type->push_irq_moderation(channel); |
653 | 653 | ||
654 | return 0; | 654 | return 0; |
655 | } | 655 | } |
diff --git a/drivers/net/sfc/falcon.c b/drivers/net/sfc/falcon.c index 040f553de665..f6d10213d0b7 100644 --- a/drivers/net/sfc/falcon.c +++ b/drivers/net/sfc/falcon.c | |||
@@ -1041,7 +1041,7 @@ int falcon_process_eventq(struct efx_channel *channel, int rx_quota) | |||
1041 | return rx_packets; | 1041 | return rx_packets; |
1042 | } | 1042 | } |
1043 | 1043 | ||
1044 | void falcon_set_int_moderation(struct efx_channel *channel) | 1044 | static void falcon_push_irq_moderation(struct efx_channel *channel) |
1045 | { | 1045 | { |
1046 | efx_dword_t timer_cmd; | 1046 | efx_dword_t timer_cmd; |
1047 | struct efx_nic *efx = channel->efx; | 1047 | struct efx_nic *efx = channel->efx; |
@@ -1098,7 +1098,7 @@ void falcon_init_eventq(struct efx_channel *channel) | |||
1098 | efx_writeo_table(efx, &evq_ptr, efx->type->evq_ptr_tbl_base, | 1098 | efx_writeo_table(efx, &evq_ptr, efx->type->evq_ptr_tbl_base, |
1099 | channel->channel); | 1099 | channel->channel); |
1100 | 1100 | ||
1101 | falcon_set_int_moderation(channel); | 1101 | falcon_push_irq_moderation(channel); |
1102 | } | 1102 | } |
1103 | 1103 | ||
1104 | void falcon_fini_eventq(struct efx_channel *channel) | 1104 | void falcon_fini_eventq(struct efx_channel *channel) |
@@ -1212,7 +1212,8 @@ int falcon_flush_queues(struct efx_nic *efx) | |||
1212 | struct efx_tx_queue *tx_queue; | 1212 | struct efx_tx_queue *tx_queue; |
1213 | int i, tx_pending, rx_pending; | 1213 | int i, tx_pending, rx_pending; |
1214 | 1214 | ||
1215 | falcon_prepare_flush(efx); | 1215 | /* If necessary prepare the hardware for flushing */ |
1216 | efx->type->prepare_flush(efx); | ||
1216 | 1217 | ||
1217 | /* Flush all tx queues in parallel */ | 1218 | /* Flush all tx queues in parallel */ |
1218 | efx_for_each_tx_queue(tx_queue, efx) | 1219 | efx_for_each_tx_queue(tx_queue, efx) |
@@ -1825,6 +1826,16 @@ int falcon_spi_write(const struct efx_spi_device *spi, loff_t start, | |||
1825 | ************************************************************************** | 1826 | ************************************************************************** |
1826 | */ | 1827 | */ |
1827 | 1828 | ||
1829 | static void falcon_push_multicast_hash(struct efx_nic *efx) | ||
1830 | { | ||
1831 | union efx_multicast_hash *mc_hash = &efx->multicast_hash; | ||
1832 | |||
1833 | WARN_ON(!mutex_is_locked(&efx->mac_lock)); | ||
1834 | |||
1835 | efx_writeo(efx, &mc_hash->oword[0], FR_AB_MAC_MC_HASH_REG0); | ||
1836 | efx_writeo(efx, &mc_hash->oword[1], FR_AB_MAC_MC_HASH_REG1); | ||
1837 | } | ||
1838 | |||
1828 | static int falcon_reset_macs(struct efx_nic *efx) | 1839 | static int falcon_reset_macs(struct efx_nic *efx) |
1829 | { | 1840 | { |
1830 | efx_oword_t reg; | 1841 | efx_oword_t reg; |
@@ -2240,7 +2251,7 @@ out: | |||
2240 | } | 2251 | } |
2241 | 2252 | ||
2242 | /* This call is responsible for hooking in the MAC and PHY operations */ | 2253 | /* This call is responsible for hooking in the MAC and PHY operations */ |
2243 | int falcon_probe_port(struct efx_nic *efx) | 2254 | static int falcon_probe_port(struct efx_nic *efx) |
2244 | { | 2255 | { |
2245 | int rc; | 2256 | int rc; |
2246 | 2257 | ||
@@ -2299,31 +2310,13 @@ int falcon_probe_port(struct efx_nic *efx) | |||
2299 | return 0; | 2310 | return 0; |
2300 | } | 2311 | } |
2301 | 2312 | ||
2302 | void falcon_remove_port(struct efx_nic *efx) | 2313 | static void falcon_remove_port(struct efx_nic *efx) |
2303 | { | 2314 | { |
2304 | falcon_free_buffer(efx, &efx->stats_buffer); | 2315 | falcon_free_buffer(efx, &efx->stats_buffer); |
2305 | } | 2316 | } |
2306 | 2317 | ||
2307 | /************************************************************************** | 2318 | /************************************************************************** |
2308 | * | 2319 | * |
2309 | * Multicast filtering | ||
2310 | * | ||
2311 | ************************************************************************** | ||
2312 | */ | ||
2313 | |||
2314 | void falcon_push_multicast_hash(struct efx_nic *efx) | ||
2315 | { | ||
2316 | union efx_multicast_hash *mc_hash = &efx->multicast_hash; | ||
2317 | |||
2318 | WARN_ON(!mutex_is_locked(&efx->mac_lock)); | ||
2319 | |||
2320 | efx_writeo(efx, &mc_hash->oword[0], FR_AB_MAC_MC_HASH_REG0); | ||
2321 | efx_writeo(efx, &mc_hash->oword[1], FR_AB_MAC_MC_HASH_REG1); | ||
2322 | } | ||
2323 | |||
2324 | |||
2325 | /************************************************************************** | ||
2326 | * | ||
2327 | * Falcon test code | 2320 | * Falcon test code |
2328 | * | 2321 | * |
2329 | **************************************************************************/ | 2322 | **************************************************************************/ |
@@ -2503,7 +2496,7 @@ fail: | |||
2503 | 2496 | ||
2504 | /* Resets NIC to known state. This routine must be called in process | 2497 | /* Resets NIC to known state. This routine must be called in process |
2505 | * context and is allowed to sleep. */ | 2498 | * context and is allowed to sleep. */ |
2506 | int falcon_reset_hw(struct efx_nic *efx, enum reset_type method) | 2499 | static int falcon_reset_hw(struct efx_nic *efx, enum reset_type method) |
2507 | { | 2500 | { |
2508 | struct falcon_nic_data *nic_data = efx->nic_data; | 2501 | struct falcon_nic_data *nic_data = efx->nic_data; |
2509 | efx_oword_t glb_ctl_reg_ker; | 2502 | efx_oword_t glb_ctl_reg_ker; |
@@ -2592,7 +2585,7 @@ fail5: | |||
2592 | return rc; | 2585 | return rc; |
2593 | } | 2586 | } |
2594 | 2587 | ||
2595 | void falcon_monitor(struct efx_nic *efx) | 2588 | static void falcon_monitor(struct efx_nic *efx) |
2596 | { | 2589 | { |
2597 | bool link_changed; | 2590 | bool link_changed; |
2598 | int rc; | 2591 | int rc; |
@@ -2850,7 +2843,7 @@ static void falcon_probe_spi_devices(struct efx_nic *efx) | |||
2850 | large_eeprom_type); | 2843 | large_eeprom_type); |
2851 | } | 2844 | } |
2852 | 2845 | ||
2853 | int falcon_probe_nic(struct efx_nic *efx) | 2846 | static int falcon_probe_nic(struct efx_nic *efx) |
2854 | { | 2847 | { |
2855 | struct falcon_nic_data *nic_data; | 2848 | struct falcon_nic_data *nic_data; |
2856 | struct falcon_board *board; | 2849 | struct falcon_board *board; |
@@ -3006,7 +2999,7 @@ static void falcon_init_rx_cfg(struct efx_nic *efx) | |||
3006 | * defining the descriptor cache sizes and number of RSS channels. | 2999 | * defining the descriptor cache sizes and number of RSS channels. |
3007 | * It does not set up any buffers, descriptor rings or event queues. | 3000 | * It does not set up any buffers, descriptor rings or event queues. |
3008 | */ | 3001 | */ |
3009 | int falcon_init_nic(struct efx_nic *efx) | 3002 | static int falcon_init_nic(struct efx_nic *efx) |
3010 | { | 3003 | { |
3011 | efx_oword_t temp; | 3004 | efx_oword_t temp; |
3012 | int rc; | 3005 | int rc; |
@@ -3139,7 +3132,7 @@ int falcon_init_nic(struct efx_nic *efx) | |||
3139 | return 0; | 3132 | return 0; |
3140 | } | 3133 | } |
3141 | 3134 | ||
3142 | void falcon_remove_nic(struct efx_nic *efx) | 3135 | static void falcon_remove_nic(struct efx_nic *efx) |
3143 | { | 3136 | { |
3144 | struct falcon_nic_data *nic_data = efx->nic_data; | 3137 | struct falcon_nic_data *nic_data = efx->nic_data; |
3145 | struct falcon_board *board = falcon_board(efx); | 3138 | struct falcon_board *board = falcon_board(efx); |
@@ -3168,7 +3161,7 @@ void falcon_remove_nic(struct efx_nic *efx) | |||
3168 | efx->nic_data = NULL; | 3161 | efx->nic_data = NULL; |
3169 | } | 3162 | } |
3170 | 3163 | ||
3171 | void falcon_update_nic_stats(struct efx_nic *efx) | 3164 | static void falcon_update_nic_stats(struct efx_nic *efx) |
3172 | { | 3165 | { |
3173 | struct falcon_nic_data *nic_data = efx->nic_data; | 3166 | struct falcon_nic_data *nic_data = efx->nic_data; |
3174 | efx_oword_t cnt; | 3167 | efx_oword_t cnt; |
@@ -3232,6 +3225,20 @@ void falcon_stop_nic_stats(struct efx_nic *efx) | |||
3232 | */ | 3225 | */ |
3233 | 3226 | ||
3234 | struct efx_nic_type falcon_a1_nic_type = { | 3227 | struct efx_nic_type falcon_a1_nic_type = { |
3228 | .probe = falcon_probe_nic, | ||
3229 | .remove = falcon_remove_nic, | ||
3230 | .init = falcon_init_nic, | ||
3231 | .fini = efx_port_dummy_op_void, | ||
3232 | .monitor = falcon_monitor, | ||
3233 | .reset = falcon_reset_hw, | ||
3234 | .probe_port = falcon_probe_port, | ||
3235 | .remove_port = falcon_remove_port, | ||
3236 | .prepare_flush = falcon_prepare_flush, | ||
3237 | .update_stats = falcon_update_nic_stats, | ||
3238 | .start_stats = falcon_start_nic_stats, | ||
3239 | .stop_stats = falcon_stop_nic_stats, | ||
3240 | .push_irq_moderation = falcon_push_irq_moderation, | ||
3241 | .push_multicast_hash = falcon_push_multicast_hash, | ||
3235 | .default_mac_ops = &falcon_xmac_operations, | 3242 | .default_mac_ops = &falcon_xmac_operations, |
3236 | 3243 | ||
3237 | .revision = EFX_REV_FALCON_A1, | 3244 | .revision = EFX_REV_FALCON_A1, |
@@ -3250,6 +3257,20 @@ struct efx_nic_type falcon_a1_nic_type = { | |||
3250 | }; | 3257 | }; |
3251 | 3258 | ||
3252 | struct efx_nic_type falcon_b0_nic_type = { | 3259 | struct efx_nic_type falcon_b0_nic_type = { |
3260 | .probe = falcon_probe_nic, | ||
3261 | .remove = falcon_remove_nic, | ||
3262 | .init = falcon_init_nic, | ||
3263 | .fini = efx_port_dummy_op_void, | ||
3264 | .monitor = falcon_monitor, | ||
3265 | .reset = falcon_reset_hw, | ||
3266 | .probe_port = falcon_probe_port, | ||
3267 | .remove_port = falcon_remove_port, | ||
3268 | .prepare_flush = falcon_prepare_flush, | ||
3269 | .update_stats = falcon_update_nic_stats, | ||
3270 | .start_stats = falcon_start_nic_stats, | ||
3271 | .stop_stats = falcon_stop_nic_stats, | ||
3272 | .push_irq_moderation = falcon_push_irq_moderation, | ||
3273 | .push_multicast_hash = falcon_push_multicast_hash, | ||
3253 | .default_mac_ops = &falcon_xmac_operations, | 3274 | .default_mac_ops = &falcon_xmac_operations, |
3254 | 3275 | ||
3255 | .revision = EFX_REV_FALCON_B0, | 3276 | .revision = EFX_REV_FALCON_B0, |
diff --git a/drivers/net/sfc/falcon.h b/drivers/net/sfc/falcon.h index 81196a0fb504..3fe64849c98d 100644 --- a/drivers/net/sfc/falcon.h +++ b/drivers/net/sfc/falcon.h | |||
@@ -129,10 +129,6 @@ extern void falcon_remove_eventq(struct efx_channel *channel); | |||
129 | extern int falcon_process_eventq(struct efx_channel *channel, int rx_quota); | 129 | extern int falcon_process_eventq(struct efx_channel *channel, int rx_quota); |
130 | extern void falcon_eventq_read_ack(struct efx_channel *channel); | 130 | extern void falcon_eventq_read_ack(struct efx_channel *channel); |
131 | 131 | ||
132 | /* Ports */ | ||
133 | extern int falcon_probe_port(struct efx_nic *efx); | ||
134 | extern void falcon_remove_port(struct efx_nic *efx); | ||
135 | |||
136 | /* MAC/PHY */ | 132 | /* MAC/PHY */ |
137 | extern int falcon_switch_mac(struct efx_nic *efx); | 133 | extern int falcon_switch_mac(struct efx_nic *efx); |
138 | extern bool falcon_xaui_link_ok(struct efx_nic *efx); | 134 | extern bool falcon_xaui_link_ok(struct efx_nic *efx); |
@@ -146,23 +142,15 @@ extern void falcon_enable_interrupts(struct efx_nic *efx); | |||
146 | extern void falcon_generate_test_event(struct efx_channel *channel, | 142 | extern void falcon_generate_test_event(struct efx_channel *channel, |
147 | unsigned int magic); | 143 | unsigned int magic); |
148 | extern void falcon_generate_interrupt(struct efx_nic *efx); | 144 | extern void falcon_generate_interrupt(struct efx_nic *efx); |
149 | extern void falcon_set_int_moderation(struct efx_channel *channel); | ||
150 | extern void falcon_disable_interrupts(struct efx_nic *efx); | 145 | extern void falcon_disable_interrupts(struct efx_nic *efx); |
151 | extern void falcon_fini_interrupt(struct efx_nic *efx); | 146 | extern void falcon_fini_interrupt(struct efx_nic *efx); |
152 | 147 | ||
153 | #define FALCON_IRQ_MOD_RESOLUTION 5 | 148 | #define FALCON_IRQ_MOD_RESOLUTION 5 |
154 | 149 | ||
155 | /* Global Resources */ | 150 | /* Global Resources */ |
156 | extern int falcon_probe_nic(struct efx_nic *efx); | ||
157 | extern int falcon_init_nic(struct efx_nic *efx); | ||
158 | extern int falcon_flush_queues(struct efx_nic *efx); | 151 | extern int falcon_flush_queues(struct efx_nic *efx); |
159 | extern int falcon_reset_hw(struct efx_nic *efx, enum reset_type method); | ||
160 | extern void falcon_monitor(struct efx_nic *efx); | ||
161 | extern void falcon_remove_nic(struct efx_nic *efx); | ||
162 | extern void falcon_update_nic_stats(struct efx_nic *efx); | ||
163 | extern void falcon_start_nic_stats(struct efx_nic *efx); | 152 | extern void falcon_start_nic_stats(struct efx_nic *efx); |
164 | extern void falcon_stop_nic_stats(struct efx_nic *efx); | 153 | extern void falcon_stop_nic_stats(struct efx_nic *efx); |
165 | extern void falcon_push_multicast_hash(struct efx_nic *efx); | ||
166 | extern int falcon_reset_xaui(struct efx_nic *efx); | 154 | extern int falcon_reset_xaui(struct efx_nic *efx); |
167 | 155 | ||
168 | /* Tests */ | 156 | /* Tests */ |
diff --git a/drivers/net/sfc/net_driver.h b/drivers/net/sfc/net_driver.h index fddf8f5870ce..32806f9a7e49 100644 --- a/drivers/net/sfc/net_driver.h +++ b/drivers/net/sfc/net_driver.h | |||
@@ -843,6 +843,21 @@ static inline const char *efx_dev_name(struct efx_nic *efx) | |||
843 | 843 | ||
844 | /** | 844 | /** |
845 | * struct efx_nic_type - Efx device type definition | 845 | * struct efx_nic_type - Efx device type definition |
846 | * @probe: Probe the controller | ||
847 | * @remove: Free resources allocated by probe() | ||
848 | * @init: Initialise the controller | ||
849 | * @fini: Shut down the controller | ||
850 | * @monitor: Periodic function for polling link state and hardware monitor | ||
851 | * @reset: Reset the controller hardware and possibly the PHY. This will | ||
852 | * be called while the controller is uninitialised. | ||
853 | * @probe_port: Probe the MAC and PHY | ||
854 | * @remove_port: Free resources allocated by probe_port() | ||
855 | * @prepare_flush: Prepare the hardware for flushing the DMA queues | ||
856 | * @update_stats: Update statistics not provided by event handling | ||
857 | * @start_stats: Start the regular fetching of statistics | ||
858 | * @stop_stats: Stop the regular fetching of statistics | ||
859 | * @push_irq_moderation: Apply interrupt moderation value | ||
860 | * @push_multicast_hash: Apply multicast hash table | ||
846 | * @default_mac_ops: efx_mac_operations to set at startup | 861 | * @default_mac_ops: efx_mac_operations to set at startup |
847 | * @revision: Hardware architecture revision | 862 | * @revision: Hardware architecture revision |
848 | * @mem_map_size: Memory BAR mapped size | 863 | * @mem_map_size: Memory BAR mapped size |
@@ -861,6 +876,20 @@ static inline const char *efx_dev_name(struct efx_nic *efx) | |||
861 | * @rx_dc_base: Base address in SRAM of RX queue descriptor caches | 876 | * @rx_dc_base: Base address in SRAM of RX queue descriptor caches |
862 | */ | 877 | */ |
863 | struct efx_nic_type { | 878 | struct efx_nic_type { |
879 | int (*probe)(struct efx_nic *efx); | ||
880 | void (*remove)(struct efx_nic *efx); | ||
881 | int (*init)(struct efx_nic *efx); | ||
882 | void (*fini)(struct efx_nic *efx); | ||
883 | void (*monitor)(struct efx_nic *efx); | ||
884 | int (*reset)(struct efx_nic *efx, enum reset_type method); | ||
885 | int (*probe_port)(struct efx_nic *efx); | ||
886 | void (*remove_port)(struct efx_nic *efx); | ||
887 | void (*prepare_flush)(struct efx_nic *efx); | ||
888 | void (*update_stats)(struct efx_nic *efx); | ||
889 | void (*start_stats)(struct efx_nic *efx); | ||
890 | void (*stop_stats)(struct efx_nic *efx); | ||
891 | void (*push_irq_moderation)(struct efx_channel *channel); | ||
892 | void (*push_multicast_hash)(struct efx_nic *efx); | ||
864 | struct efx_mac_operations *default_mac_ops; | 893 | struct efx_mac_operations *default_mac_ops; |
865 | 894 | ||
866 | int revision; | 895 | int revision; |
diff --git a/drivers/net/sfc/selftest.c b/drivers/net/sfc/selftest.c index 74e84afd5b6b..15d4d9c81362 100644 --- a/drivers/net/sfc/selftest.c +++ b/drivers/net/sfc/selftest.c | |||
@@ -719,7 +719,7 @@ int efx_selftest(struct efx_nic *efx, struct efx_self_tests *tests, | |||
719 | rc_test = rc; | 719 | rc_test = rc; |
720 | 720 | ||
721 | /* reset the chip to recover from the register test */ | 721 | /* reset the chip to recover from the register test */ |
722 | rc_reset = falcon_reset_hw(efx, reset_method); | 722 | rc_reset = efx->type->reset(efx, reset_method); |
723 | 723 | ||
724 | /* Ensure that the phy is powered and out of loopback | 724 | /* Ensure that the phy is powered and out of loopback |
725 | * for the bist and loopback tests */ | 725 | * for the bist and loopback tests */ |