aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDhananjay Phadke <dhananjay@netxen.com>2009-07-26 16:07:39 -0400
committerDavid S. Miller <davem@davemloft.net>2009-07-27 13:57:31 -0400
commit83ac51fa747c3a74372417629fcad4b110857b77 (patch)
tree02b85bda7727c4cb7b45c1f4e6a32e4aca8f91e7
parentca2ef330b5eb30e3bc7047f99fd4be9f1bad22be (diff)
netxen: annotate dma watchdog setup
o remove superfluous code to setup PCI dma watchdog for NX2031. o disable dma watchdog completely for NX3031 (not required). Signed-off-by: Dhananjay Phadke <dhananjay@netxen.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/netxen/netxen_nic.h73
-rw-r--r--drivers/net/netxen/netxen_nic_hdr.h2
-rw-r--r--drivers/net/netxen/netxen_nic_init.c59
-rw-r--r--drivers/net/netxen/netxen_nic_main.c8
4 files changed, 43 insertions, 99 deletions
diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
index 6b9e759d3523..3368af0c129b 100644
--- a/drivers/net/netxen/netxen_nic.h
+++ b/drivers/net/netxen/netxen_nic.h
@@ -1324,24 +1324,6 @@ struct netxen_adapter {
1324 const struct firmware *fw; 1324 const struct firmware *fw;
1325}; 1325};
1326 1326
1327/*
1328 * NetXen dma watchdog control structure
1329 *
1330 * Bit 0 : enabled => R/O: 1 watchdog active, 0 inactive
1331 * Bit 1 : disable_request => 1 req disable dma watchdog
1332 * Bit 2 : enable_request => 1 req enable dma watchdog
1333 * Bit 3-31 : unused
1334 */
1335
1336#define netxen_set_dma_watchdog_disable_req(config_word) \
1337 _netxen_set_bits(config_word, 1, 1, 1)
1338#define netxen_set_dma_watchdog_enable_req(config_word) \
1339 _netxen_set_bits(config_word, 2, 1, 1)
1340#define netxen_get_dma_watchdog_enabled(config_word) \
1341 ((config_word) & 0x1)
1342#define netxen_get_dma_watchdog_disabled(config_word) \
1343 (((config_word) >> 1) & 0x1)
1344
1345int netxen_niu_xgbe_enable_phy_interrupts(struct netxen_adapter *adapter); 1327int netxen_niu_xgbe_enable_phy_interrupts(struct netxen_adapter *adapter);
1346int netxen_niu_gbe_enable_phy_interrupts(struct netxen_adapter *adapter); 1328int netxen_niu_gbe_enable_phy_interrupts(struct netxen_adapter *adapter);
1347int netxen_niu_xgbe_disable_phy_interrupts(struct netxen_adapter *adapter); 1329int netxen_niu_xgbe_disable_phy_interrupts(struct netxen_adapter *adapter);
@@ -1402,8 +1384,9 @@ unsigned long netxen_nic_pci_set_window_2M(struct netxen_adapter *adapter,
1402 unsigned long long addr); 1384 unsigned long long addr);
1403 1385
1404/* Functions from netxen_nic_init.c */ 1386/* Functions from netxen_nic_init.c */
1405void netxen_free_adapter_offload(struct netxen_adapter *adapter); 1387int netxen_init_dummy_dma(struct netxen_adapter *adapter);
1406int netxen_initialize_adapter_offload(struct netxen_adapter *adapter); 1388void netxen_free_dummy_dma(struct netxen_adapter *adapter);
1389
1407int netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val); 1390int netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val);
1408int netxen_load_firmware(struct netxen_adapter *adapter); 1391int netxen_load_firmware(struct netxen_adapter *adapter);
1409int netxen_need_fw_reset(struct netxen_adapter *adapter); 1392int netxen_need_fw_reset(struct netxen_adapter *adapter);
@@ -1510,56 +1493,6 @@ static inline void get_brd_name_by_type(u32 type, char *name)
1510 name = "Unknown"; 1493 name = "Unknown";
1511} 1494}
1512 1495
1513static inline int
1514dma_watchdog_shutdown_request(struct netxen_adapter *adapter)
1515{
1516 u32 ctrl;
1517
1518 /* check if already inactive */
1519 ctrl = adapter->hw_read_wx(adapter,
1520 NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL));
1521
1522 if (netxen_get_dma_watchdog_enabled(ctrl) == 0)
1523 return 1;
1524
1525 /* Send the disable request */
1526 netxen_set_dma_watchdog_disable_req(ctrl);
1527 NXWR32(adapter, NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL), ctrl);
1528
1529 return 0;
1530}
1531
1532static inline int
1533dma_watchdog_shutdown_poll_result(struct netxen_adapter *adapter)
1534{
1535 u32 ctrl;
1536
1537 ctrl = adapter->hw_read_wx(adapter,
1538 NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL));
1539
1540 return (netxen_get_dma_watchdog_enabled(ctrl) == 0);
1541}
1542
1543static inline int
1544dma_watchdog_wakeup(struct netxen_adapter *adapter)
1545{
1546 u32 ctrl;
1547
1548 ctrl = adapter->hw_read_wx(adapter,
1549 NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL));
1550
1551 if (netxen_get_dma_watchdog_enabled(ctrl))
1552 return 1;
1553
1554 /* send the wakeup request */
1555 netxen_set_dma_watchdog_enable_req(ctrl);
1556
1557 NXWR32(adapter, NETXEN_CAM_RAM(NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL), ctrl);
1558
1559 return 0;
1560}
1561
1562
1563static inline u32 netxen_tx_avail(struct nx_host_tx_ring *tx_ring) 1496static inline u32 netxen_tx_avail(struct nx_host_tx_ring *tx_ring)
1564{ 1497{
1565 smp_mb(); 1498 smp_mb();
diff --git a/drivers/net/netxen/netxen_nic_hdr.h b/drivers/net/netxen/netxen_nic_hdr.h
index 824103675648..a7328584a21a 100644
--- a/drivers/net/netxen/netxen_nic_hdr.h
+++ b/drivers/net/netxen/netxen_nic_hdr.h
@@ -852,7 +852,7 @@ enum {
852#define NX_PEG_TUNE_MN_PRESENT 0x1 852#define NX_PEG_TUNE_MN_PRESENT 0x1
853#define NX_PEG_TUNE_CAPABILITY (NETXEN_CAM_RAM(0x02c)) 853#define NX_PEG_TUNE_CAPABILITY (NETXEN_CAM_RAM(0x02c))
854 854
855#define NETXEN_CAM_RAM_DMA_WATCHDOG_CTRL (0x14) 855#define NETXEN_DMA_WATCHDOG_CTRL (NETXEN_CAM_RAM(0x14))
856#define NETXEN_PEG_ALIVE_COUNTER (NETXEN_CAM_RAM(0xb0)) 856#define NETXEN_PEG_ALIVE_COUNTER (NETXEN_CAM_RAM(0xb0))
857 857
858#define ISR_MSI_INT_TRIGGER(FUNC) (NETXEN_PCIX_PS_REG(PCIX_MSI_F(FUNC))) 858#define ISR_MSI_INT_TRIGGER(FUNC) (NETXEN_PCIX_PS_REG(PCIX_MSI_F(FUNC)))
diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c
index 5d7a2c453363..91358459adb4 100644
--- a/drivers/net/netxen/netxen_nic_init.c
+++ b/drivers/net/netxen/netxen_nic_init.c
@@ -954,19 +954,20 @@ netxen_release_firmware(struct netxen_adapter *adapter)
954 release_firmware(adapter->fw); 954 release_firmware(adapter->fw);
955} 955}
956 956
957int netxen_initialize_adapter_offload(struct netxen_adapter *adapter) 957int netxen_init_dummy_dma(struct netxen_adapter *adapter)
958{ 958{
959 uint64_t addr; 959 u64 addr;
960 uint32_t hi; 960 u32 hi, lo;
961 uint32_t lo;
962 961
963 adapter->dummy_dma.addr = 962 if (!NX_IS_REVISION_P2(adapter->ahw.revision_id))
964 pci_alloc_consistent(adapter->pdev, 963 return 0;
964
965 adapter->dummy_dma.addr = pci_alloc_consistent(adapter->pdev,
965 NETXEN_HOST_DUMMY_DMA_SIZE, 966 NETXEN_HOST_DUMMY_DMA_SIZE,
966 &adapter->dummy_dma.phys_addr); 967 &adapter->dummy_dma.phys_addr);
967 if (adapter->dummy_dma.addr == NULL) { 968 if (adapter->dummy_dma.addr == NULL) {
968 printk("%s: ERROR: Could not allocate dummy DMA memory\n", 969 dev_err(&adapter->pdev->dev,
969 __func__); 970 "ERROR: Could not allocate dummy DMA memory\n");
970 return -ENOMEM; 971 return -ENOMEM;
971 } 972 }
972 973
@@ -977,29 +978,41 @@ int netxen_initialize_adapter_offload(struct netxen_adapter *adapter)
977 NXWR32(adapter, CRB_HOST_DUMMY_BUF_ADDR_HI, hi); 978 NXWR32(adapter, CRB_HOST_DUMMY_BUF_ADDR_HI, hi);
978 NXWR32(adapter, CRB_HOST_DUMMY_BUF_ADDR_LO, lo); 979 NXWR32(adapter, CRB_HOST_DUMMY_BUF_ADDR_LO, lo);
979 980
980 if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) {
981 uint32_t temp = 0;
982 NXWR32(adapter, CRB_HOST_DUMMY_BUF, temp);
983 }
984
985 return 0; 981 return 0;
986} 982}
987 983
988void netxen_free_adapter_offload(struct netxen_adapter *adapter) 984/*
985 * NetXen DMA watchdog control:
986 *
987 * Bit 0 : enabled => R/O: 1 watchdog active, 0 inactive
988 * Bit 1 : disable_request => 1 req disable dma watchdog
989 * Bit 2 : enable_request => 1 req enable dma watchdog
990 * Bit 3-31 : unused
991 */
992void netxen_free_dummy_dma(struct netxen_adapter *adapter)
989{ 993{
990 int i = 100; 994 int i = 100;
995 u32 ctrl;
996
997 if (!NX_IS_REVISION_P2(adapter->ahw.revision_id))
998 return;
991 999
992 if (!adapter->dummy_dma.addr) 1000 if (!adapter->dummy_dma.addr)
993 return; 1001 return;
994 1002
995 if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) { 1003 ctrl = NXRD32(adapter, NETXEN_DMA_WATCHDOG_CTRL);
996 do { 1004 if ((ctrl & 0x1) != 0) {
997 if (dma_watchdog_shutdown_request(adapter) == 1) 1005 NXWR32(adapter, NETXEN_DMA_WATCHDOG_CTRL, (ctrl | 0x2));
998 break; 1006
1007 while ((ctrl & 0x1) != 0) {
1008
999 msleep(50); 1009 msleep(50);
1000 if (dma_watchdog_shutdown_poll_result(adapter) == 1) 1010
1011 ctrl = NXRD32(adapter, NETXEN_DMA_WATCHDOG_CTRL);
1012
1013 if (--i == 0)
1001 break; 1014 break;
1002 } while (--i); 1015 };
1003 } 1016 }
1004 1017
1005 if (i) { 1018 if (i) {
@@ -1008,10 +1021,8 @@ void netxen_free_adapter_offload(struct netxen_adapter *adapter)
1008 adapter->dummy_dma.addr, 1021 adapter->dummy_dma.addr,
1009 adapter->dummy_dma.phys_addr); 1022 adapter->dummy_dma.phys_addr);
1010 adapter->dummy_dma.addr = NULL; 1023 adapter->dummy_dma.addr = NULL;
1011 } else { 1024 } else
1012 printk(KERN_ERR "%s: dma_watchdog_shutdown failed\n", 1025 dev_err(&adapter->pdev->dev, "dma_watchdog_shutdown failed\n");
1013 adapter->netdev->name);
1014 }
1015} 1026}
1016 1027
1017int netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val) 1028int netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val)
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c
index 76bdd5cee438..fb976cbf9c71 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -745,7 +745,7 @@ netxen_start_firmware(struct netxen_adapter *adapter, int request_fw)
745 745
746 } 746 }
747 747
748 err = netxen_initialize_adapter_offload(adapter); 748 err = netxen_init_dummy_dma(adapter);
749 if (err) 749 if (err)
750 return err; 750 return err;
751 751
@@ -761,7 +761,7 @@ wait_init:
761 /* Handshake with the card before we register the devices. */ 761 /* Handshake with the card before we register the devices. */
762 err = netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE); 762 err = netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE);
763 if (err) { 763 if (err) {
764 netxen_free_adapter_offload(adapter); 764 netxen_free_dummy_dma(adapter);
765 return err; 765 return err;
766 } 766 }
767 767
@@ -1154,7 +1154,7 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1154err_out_disable_msi: 1154err_out_disable_msi:
1155 netxen_teardown_intr(adapter); 1155 netxen_teardown_intr(adapter);
1156 1156
1157 netxen_free_adapter_offload(adapter); 1157 netxen_free_dummy_dma(adapter);
1158 1158
1159err_out_iounmap: 1159err_out_iounmap:
1160 netxen_cleanup_pci_map(adapter); 1160 netxen_cleanup_pci_map(adapter);
@@ -1189,7 +1189,7 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev)
1189 } 1189 }
1190 1190
1191 if (adapter->portnum == 0) 1191 if (adapter->portnum == 0)
1192 netxen_free_adapter_offload(adapter); 1192 netxen_free_dummy_dma(adapter);
1193 1193
1194 netxen_teardown_intr(adapter); 1194 netxen_teardown_intr(adapter);
1195 netxen_free_sds_rings(&adapter->recv_ctx); 1195 netxen_free_sds_rings(&adapter->recv_ctx);