aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDhananjay Phadke <dhananjay@netxen.com>2009-07-01 07:41:43 -0400
committerDavid S. Miller <davem@davemloft.net>2009-07-02 16:16:51 -0400
commit67c38fc61af930fa03b042932b6b14fbf8126222 (patch)
tree2577cebc515dba4a9a37a77368bfe4051d975c18 /drivers
parent98e31bb00983a5b6d638a31e4ff77e5ca1ccf93e (diff)
netxen: avoid frequent firmware reset
Restrict firmware reset to following cases - o chip rev is NX2031 (firmare doesn't support heartbit). o firmware is dead. o previous attempt to init firmware had failed. o we have got newer file firmware. This speeds up module load tremendously (by upto 8 sec), also avoids downtime for NCSI (management) pass-thru traffic. Signed-off-by: Dhananjay Phadke <dhananjay@netxen.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/netxen/netxen_nic.h4
-rw-r--r--drivers/net/netxen/netxen_nic_hdr.h1
-rw-r--r--drivers/net/netxen/netxen_nic_init.c86
-rw-r--r--drivers/net/netxen/netxen_nic_main.c4
4 files changed, 86 insertions, 9 deletions
diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
index 26afcb5658d4..e1cdba752e09 100644
--- a/drivers/net/netxen/netxen_nic.h
+++ b/drivers/net/netxen/netxen_nic.h
@@ -625,6 +625,7 @@ struct netxen_new_user_info {
625#define NX_P2_MN_ROMIMAGE 0 625#define NX_P2_MN_ROMIMAGE 0
626#define NX_P3_CT_ROMIMAGE 1 626#define NX_P3_CT_ROMIMAGE 1
627#define NX_P3_MN_ROMIMAGE 2 627#define NX_P3_MN_ROMIMAGE 2
628#define NX_FLASH_ROMIMAGE 3
628 629
629#define NETXEN_USER_START_OLD NETXEN_PXE_START /* for backward compatibility */ 630#define NETXEN_USER_START_OLD NETXEN_PXE_START /* for backward compatibility */
630 631
@@ -1254,7 +1255,7 @@ struct netxen_adapter {
1254 u32 resv3; 1255 u32 resv3;
1255 1256
1256 u8 has_link_events; 1257 u8 has_link_events;
1257 u8 resv1; 1258 u8 fw_type;
1258 u16 tx_context_id; 1259 u16 tx_context_id;
1259 u16 mtu; 1260 u16 mtu;
1260 u16 is_up; 1261 u16 is_up;
@@ -1398,6 +1399,7 @@ void netxen_free_adapter_offload(struct netxen_adapter *adapter);
1398int netxen_initialize_adapter_offload(struct netxen_adapter *adapter); 1399int netxen_initialize_adapter_offload(struct netxen_adapter *adapter);
1399int netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val); 1400int netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val);
1400int netxen_load_firmware(struct netxen_adapter *adapter); 1401int netxen_load_firmware(struct netxen_adapter *adapter);
1402int netxen_need_fw_reset(struct netxen_adapter *adapter);
1401void netxen_request_firmware(struct netxen_adapter *adapter); 1403void netxen_request_firmware(struct netxen_adapter *adapter);
1402void netxen_release_firmware(struct netxen_adapter *adapter); 1404void netxen_release_firmware(struct netxen_adapter *adapter);
1403int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose); 1405int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose);
diff --git a/drivers/net/netxen/netxen_nic_hdr.h b/drivers/net/netxen/netxen_nic_hdr.h
index 3cc047844af3..824103675648 100644
--- a/drivers/net/netxen/netxen_nic_hdr.h
+++ b/drivers/net/netxen/netxen_nic_hdr.h
@@ -853,6 +853,7 @@ enum {
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_CAM_RAM_DMA_WATCHDOG_CTRL (0x14)
856#define NETXEN_PEG_ALIVE_COUNTER (NETXEN_CAM_RAM(0xb0))
856 857
857#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)))
858#define ISR_LEGACY_INT_TRIGGERED(VAL) (((VAL) & 0x300) == 0x200) 859#define ISR_LEGACY_INT_TRIGGERED(VAL) (((VAL) & 0x300) == 0x200)
diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c
index 7bdcbc67342f..b899bd51fcd8 100644
--- a/drivers/net/netxen/netxen_nic_init.c
+++ b/drivers/net/netxen/netxen_nic_init.c
@@ -684,11 +684,84 @@ int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose)
684} 684}
685 685
686int 686int
687netxen_need_fw_reset(struct netxen_adapter *adapter)
688{
689 u32 count, old_count;
690 u32 val, version, major, minor, build;
691 int i, timeout;
692 u8 fw_type;
693
694 /* NX2031 firmware doesn't support heartbit */
695 if (NX_IS_REVISION_P2(adapter->ahw.revision_id))
696 return 1;
697
698 /* last attempt had failed */
699 if (NXRD32(adapter, CRB_CMDPEG_STATE) == PHAN_INITIALIZE_FAILED)
700 return 1;
701
702 old_count = count = NXRD32(adapter, NETXEN_PEG_ALIVE_COUNTER);
703
704 for (i = 0; i < 10; i++) {
705
706 timeout = msleep_interruptible(200);
707 if (timeout) {
708 NXWR32(adapter, CRB_CMDPEG_STATE,
709 PHAN_INITIALIZE_FAILED);
710 return -EINTR;
711 }
712
713 count = NXRD32(adapter, NETXEN_PEG_ALIVE_COUNTER);
714 if (count != old_count)
715 break;
716 }
717
718 /* firmware is dead */
719 if (count == old_count)
720 return 1;
721
722 /* check if we have got newer or different file firmware */
723 if (adapter->fw) {
724
725 const struct firmware *fw = adapter->fw;
726
727 val = cpu_to_le32(*(u32 *)&fw->data[NX_FW_VERSION_OFFSET]);
728 version = NETXEN_DECODE_VERSION(val);
729
730 major = NXRD32(adapter, NETXEN_FW_VERSION_MAJOR);
731 minor = NXRD32(adapter, NETXEN_FW_VERSION_MINOR);
732 build = NXRD32(adapter, NETXEN_FW_VERSION_SUB);
733
734 if (version > NETXEN_VERSION_CODE(major, minor, build))
735 return 1;
736
737 if (version == NETXEN_VERSION_CODE(major, minor, build)) {
738
739 val = NXRD32(adapter, NETXEN_MIU_MN_CONTROL);
740 fw_type = (val & 0x4) ?
741 NX_P3_CT_ROMIMAGE : NX_P3_MN_ROMIMAGE;
742
743 if (adapter->fw_type != fw_type)
744 return 1;
745 }
746 }
747
748 return 0;
749}
750
751static char *fw_name[] = {
752 "nxromimg.bin", "nx3fwct.bin", "nx3fwmn.bin", "flash",
753};
754
755int
687netxen_load_firmware(struct netxen_adapter *adapter) 756netxen_load_firmware(struct netxen_adapter *adapter)
688{ 757{
689 u64 *ptr64; 758 u64 *ptr64;
690 u32 i, flashaddr, size; 759 u32 i, flashaddr, size;
691 const struct firmware *fw = adapter->fw; 760 const struct firmware *fw = adapter->fw;
761 struct pci_dev *pdev = adapter->pdev;
762
763 dev_info(&pdev->dev, "loading firmware from %s\n",
764 fw_name[adapter->fw_type]);
692 765
693 if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) 766 if (NX_IS_REVISION_P2(adapter->ahw.revision_id))
694 NXWR32(adapter, NETXEN_ROMUSB_GLB_CAS_RST, 1); 767 NXWR32(adapter, NETXEN_ROMUSB_GLB_CAS_RST, 1);
@@ -806,12 +879,10 @@ netxen_validate_firmware(struct netxen_adapter *adapter, const char *fwname)
806 return 0; 879 return 0;
807} 880}
808 881
809static char *fw_name[] = { "nxromimg.bin", "nx3fwct.bin", "nx3fwmn.bin" };
810
811void netxen_request_firmware(struct netxen_adapter *adapter) 882void netxen_request_firmware(struct netxen_adapter *adapter)
812{ 883{
813 u32 capability, flashed_ver; 884 u32 capability, flashed_ver;
814 int fw_type; 885 u8 fw_type;
815 struct pci_dev *pdev = adapter->pdev; 886 struct pci_dev *pdev = adapter->pdev;
816 int rc = 0; 887 int rc = 0;
817 888
@@ -838,6 +909,7 @@ request_mn:
838 } 909 }
839 } 910 }
840 911
912 fw_type = NX_FLASH_ROMIMAGE;
841 adapter->fw = NULL; 913 adapter->fw = NULL;
842 goto done; 914 goto done;
843 915
@@ -849,6 +921,7 @@ request_fw:
849 goto request_mn; 921 goto request_mn;
850 } 922 }
851 923
924 fw_type = NX_FLASH_ROMIMAGE;
852 adapter->fw = NULL; 925 adapter->fw = NULL;
853 goto done; 926 goto done;
854 } 927 }
@@ -862,16 +935,13 @@ request_fw:
862 goto request_mn; 935 goto request_mn;
863 } 936 }
864 937
938 fw_type = NX_FLASH_ROMIMAGE;
865 adapter->fw = NULL; 939 adapter->fw = NULL;
866 goto done; 940 goto done;
867 } 941 }
868 942
869done: 943done:
870 if (adapter->fw) 944 adapter->fw_type = fw_type;
871 dev_info(&pdev->dev, "loading firmware from file %s\n",
872 fw_name[fw_type]);
873 else
874 dev_info(&pdev->dev, "loading firmware from flash\n");
875} 945}
876 946
877 947
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c
index 2919a2d12bf4..27539ddf94c4 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -718,6 +718,10 @@ netxen_start_firmware(struct netxen_adapter *adapter, int request_fw)
718 if (request_fw) 718 if (request_fw)
719 netxen_request_firmware(adapter); 719 netxen_request_firmware(adapter);
720 720
721 err = netxen_need_fw_reset(adapter);
722 if (err <= 0)
723 return err;
724
721 if (first_boot != 0x55555555) { 725 if (first_boot != 0x55555555) {
722 NXWR32(adapter, CRB_CMDPEG_STATE, 0); 726 NXWR32(adapter, CRB_CMDPEG_STATE, 0);
723 netxen_pinit_from_rom(adapter, 0); 727 netxen_pinit_from_rom(adapter, 0);