aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/sfc/efx.c
diff options
context:
space:
mode:
authorBen Hutchings <bhutchings@solarflare.com>2009-11-28 22:42:31 -0500
committerDavid S. Miller <davem@davemloft.net>2009-11-29 19:46:27 -0500
commitef2b90ee4dba7a3d9001f1f0003b860b39a4aaae (patch)
tree5eec233a05fab4fd0c79dc9c1eb6541d45cead53 /drivers/net/sfc/efx.c
parent4b0d29dcfca9eafbf6e940862ab022df3ef2dd6f (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/net/sfc/efx.c')
-rw-r--r--drivers/net/sfc/efx.c44
1 files changed, 24 insertions, 20 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
1297out_unlock: 1298out_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: