diff options
author | Sony Chacko <sony.chacko@qlogic.com> | 2010-08-19 01:08:31 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-08-19 19:52:42 -0400 |
commit | d4066833bb1b35fefb1dd45eb2b10659d46bf151 (patch) | |
tree | 5581df2bf56a12509855a53c6e9aaa1a9825bcda | |
parent | 63e74e9cb7944b073c49159db934f69ca98a4ae6 (diff) |
qlcnic: firmware initialization update
Cleanup legacy code which is not valid for Qlogic
CNA adapters.
Signed-off-by: Sony Chacko <sony.chacko@qlogic.com>
Signed-off-by: Amit Kumar Salecha <amit.salecha@qlogic.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/qlcnic/qlcnic.h | 4 | ||||
-rw-r--r-- | drivers/net/qlcnic/qlcnic_hdr.h | 3 | ||||
-rw-r--r-- | drivers/net/qlcnic/qlcnic_init.c | 133 | ||||
-rw-r--r-- | drivers/net/qlcnic/qlcnic_main.c | 38 |
4 files changed, 47 insertions, 131 deletions
diff --git a/drivers/net/qlcnic/qlcnic.h b/drivers/net/qlcnic/qlcnic.h index b58c4119f279..43cb925fd77b 100644 --- a/drivers/net/qlcnic/qlcnic.h +++ b/drivers/net/qlcnic/qlcnic.h | |||
@@ -54,6 +54,8 @@ | |||
54 | #define _QLCNIC_LINUX_SUBVERSION 7 | 54 | #define _QLCNIC_LINUX_SUBVERSION 7 |
55 | #define QLCNIC_LINUX_VERSIONID "5.0.7" | 55 | #define QLCNIC_LINUX_VERSIONID "5.0.7" |
56 | #define QLCNIC_DRV_IDC_VER 0x01 | 56 | #define QLCNIC_DRV_IDC_VER 0x01 |
57 | #define QLCNIC_DRIVER_VERSION ((_QLCNIC_LINUX_MAJOR << 16) |\ | ||
58 | (_QLCNIC_LINUX_MINOR << 8) | (_QLCNIC_LINUX_SUBVERSION)) | ||
57 | 59 | ||
58 | #define QLCNIC_VERSION_CODE(a, b, c) (((a) << 24) + ((b) << 16) + (c)) | 60 | #define QLCNIC_VERSION_CODE(a, b, c) (((a) << 24) + ((b) << 16) + (c)) |
59 | #define _major(v) (((v) >> 24) & 0xff) | 61 | #define _major(v) (((v) >> 24) & 0xff) |
@@ -1233,7 +1235,7 @@ void qlcnic_reset_rx_buffers_list(struct qlcnic_adapter *adapter); | |||
1233 | void qlcnic_release_rx_buffers(struct qlcnic_adapter *adapter); | 1235 | void qlcnic_release_rx_buffers(struct qlcnic_adapter *adapter); |
1234 | void qlcnic_release_tx_buffers(struct qlcnic_adapter *adapter); | 1236 | void qlcnic_release_tx_buffers(struct qlcnic_adapter *adapter); |
1235 | 1237 | ||
1236 | int qlcnic_init_firmware(struct qlcnic_adapter *adapter); | 1238 | int qlcnic_check_fw_status(struct qlcnic_adapter *adapter); |
1237 | void qlcnic_watchdog_task(struct work_struct *work); | 1239 | void qlcnic_watchdog_task(struct work_struct *work); |
1238 | void qlcnic_post_rx_buffers(struct qlcnic_adapter *adapter, u32 ringid, | 1240 | void qlcnic_post_rx_buffers(struct qlcnic_adapter *adapter, u32 ringid, |
1239 | struct qlcnic_host_rds_ring *rds_ring); | 1241 | struct qlcnic_host_rds_ring *rds_ring); |
diff --git a/drivers/net/qlcnic/qlcnic_hdr.h b/drivers/net/qlcnic/qlcnic_hdr.h index eae03b5b0323..794f6572e8fd 100644 --- a/drivers/net/qlcnic/qlcnic_hdr.h +++ b/drivers/net/qlcnic/qlcnic_hdr.h | |||
@@ -747,7 +747,8 @@ enum { | |||
747 | 747 | ||
748 | #define QLCNIC_RESET_TIMEOUT_SECS 10 | 748 | #define QLCNIC_RESET_TIMEOUT_SECS 10 |
749 | #define QLCNIC_INIT_TIMEOUT_SECS 30 | 749 | #define QLCNIC_INIT_TIMEOUT_SECS 30 |
750 | 750 | #define QLCNIC_HEARTBEAT_PERIOD_MSECS 200 | |
751 | #define QLCNIC_HEARTBEAT_RETRY_COUNT 30 | ||
751 | 752 | ||
752 | #define ISR_MSI_INT_TRIGGER(FUNC) (QLCNIC_PCIX_PS_REG(PCIX_MSI_F(FUNC))) | 753 | #define ISR_MSI_INT_TRIGGER(FUNC) (QLCNIC_PCIX_PS_REG(PCIX_MSI_F(FUNC))) |
753 | #define ISR_LEGACY_INT_TRIGGERED(VAL) (((VAL) & 0x300) == 0x200) | 754 | #define ISR_LEGACY_INT_TRIGGERED(VAL) (((VAL) & 0x300) == 0x200) |
diff --git a/drivers/net/qlcnic/qlcnic_init.c b/drivers/net/qlcnic/qlcnic_init.c index 90766757c314..e7a399f90326 100644 --- a/drivers/net/qlcnic/qlcnic_init.c +++ b/drivers/net/qlcnic/qlcnic_init.c | |||
@@ -435,11 +435,14 @@ int qlcnic_pinit_from_rom(struct qlcnic_adapter *adapter) | |||
435 | u32 off; | 435 | u32 off; |
436 | struct pci_dev *pdev = adapter->pdev; | 436 | struct pci_dev *pdev = adapter->pdev; |
437 | 437 | ||
438 | /* resetall */ | 438 | QLCWR32(adapter, CRB_CMDPEG_STATE, 0); |
439 | QLCWR32(adapter, CRB_RCVPEG_STATE, 0); | ||
440 | |||
439 | qlcnic_rom_lock(adapter); | 441 | qlcnic_rom_lock(adapter); |
440 | QLCWR32(adapter, QLCNIC_ROMUSB_GLB_SW_RESET, 0xfeffffff); | 442 | QLCWR32(adapter, QLCNIC_ROMUSB_GLB_SW_RESET, 0xfeffffff); |
441 | qlcnic_rom_unlock(adapter); | 443 | qlcnic_rom_unlock(adapter); |
442 | 444 | ||
445 | /* Init HW CRB block */ | ||
443 | if (qlcnic_rom_fast_read(adapter, 0, &n) != 0 || (n != 0xcafecafe) || | 446 | if (qlcnic_rom_fast_read(adapter, 0, &n) != 0 || (n != 0xcafecafe) || |
444 | qlcnic_rom_fast_read(adapter, 4, &n) != 0) { | 447 | qlcnic_rom_fast_read(adapter, 4, &n) != 0) { |
445 | dev_err(&pdev->dev, "ERROR Reading crb_init area: val:%x\n", n); | 448 | dev_err(&pdev->dev, "ERROR Reading crb_init area: val:%x\n", n); |
@@ -520,13 +523,10 @@ int qlcnic_pinit_from_rom(struct qlcnic_adapter *adapter) | |||
520 | } | 523 | } |
521 | kfree(buf); | 524 | kfree(buf); |
522 | 525 | ||
523 | /* p2dn replyCount */ | 526 | /* Initialize protocol process engine */ |
524 | QLCWR32(adapter, QLCNIC_CRB_PEG_NET_D + 0xec, 0x1e); | 527 | QLCWR32(adapter, QLCNIC_CRB_PEG_NET_D + 0xec, 0x1e); |
525 | /* disable_peg_cache 0 & 1*/ | ||
526 | QLCWR32(adapter, QLCNIC_CRB_PEG_NET_D + 0x4c, 8); | 528 | QLCWR32(adapter, QLCNIC_CRB_PEG_NET_D + 0x4c, 8); |
527 | QLCWR32(adapter, QLCNIC_CRB_PEG_NET_I + 0x4c, 8); | 529 | QLCWR32(adapter, QLCNIC_CRB_PEG_NET_I + 0x4c, 8); |
528 | |||
529 | /* peg_clr_all */ | ||
530 | QLCWR32(adapter, QLCNIC_CRB_PEG_NET_0 + 0x8, 0); | 530 | QLCWR32(adapter, QLCNIC_CRB_PEG_NET_0 + 0x8, 0); |
531 | QLCWR32(adapter, QLCNIC_CRB_PEG_NET_0 + 0xc, 0); | 531 | QLCWR32(adapter, QLCNIC_CRB_PEG_NET_0 + 0xc, 0); |
532 | QLCWR32(adapter, QLCNIC_CRB_PEG_NET_1 + 0x8, 0); | 532 | QLCWR32(adapter, QLCNIC_CRB_PEG_NET_1 + 0x8, 0); |
@@ -535,10 +535,36 @@ int qlcnic_pinit_from_rom(struct qlcnic_adapter *adapter) | |||
535 | QLCWR32(adapter, QLCNIC_CRB_PEG_NET_2 + 0xc, 0); | 535 | QLCWR32(adapter, QLCNIC_CRB_PEG_NET_2 + 0xc, 0); |
536 | QLCWR32(adapter, QLCNIC_CRB_PEG_NET_3 + 0x8, 0); | 536 | QLCWR32(adapter, QLCNIC_CRB_PEG_NET_3 + 0x8, 0); |
537 | QLCWR32(adapter, QLCNIC_CRB_PEG_NET_3 + 0xc, 0); | 537 | QLCWR32(adapter, QLCNIC_CRB_PEG_NET_3 + 0xc, 0); |
538 | QLCWR32(adapter, QLCNIC_CRB_PEG_NET_4 + 0x8, 0); | ||
539 | QLCWR32(adapter, QLCNIC_CRB_PEG_NET_4 + 0xc, 0); | ||
540 | msleep(1); | ||
541 | QLCWR32(adapter, QLCNIC_PEG_HALT_STATUS1, 0); | ||
542 | QLCWR32(adapter, QLCNIC_PEG_HALT_STATUS2, 0); | ||
538 | return 0; | 543 | return 0; |
539 | } | 544 | } |
540 | 545 | ||
541 | int | 546 | int |
547 | qlcnic_check_fw_status(struct qlcnic_adapter *adapter) | ||
548 | { | ||
549 | u32 heartbit, ret = -EIO; | ||
550 | int retries = QLCNIC_HEARTBEAT_RETRY_COUNT; | ||
551 | |||
552 | adapter->heartbit = QLCRD32(adapter, QLCNIC_PEG_ALIVE_COUNTER); | ||
553 | do { | ||
554 | msleep(QLCNIC_HEARTBEAT_PERIOD_MSECS); | ||
555 | heartbit = QLCRD32(adapter, QLCNIC_PEG_ALIVE_COUNTER); | ||
556 | if (heartbit != adapter->heartbit) { | ||
557 | /* Complete firmware handshake */ | ||
558 | QLCWR32(adapter, CRB_CMDPEG_STATE, PHAN_INITIALIZE_ACK); | ||
559 | ret = QLCNIC_RCODE_SUCCESS; | ||
560 | break; | ||
561 | } | ||
562 | } while (--retries); | ||
563 | |||
564 | return ret; | ||
565 | } | ||
566 | |||
567 | int | ||
542 | qlcnic_setup_idc_param(struct qlcnic_adapter *adapter) { | 568 | qlcnic_setup_idc_param(struct qlcnic_adapter *adapter) { |
543 | 569 | ||
544 | int timeo; | 570 | int timeo; |
@@ -905,35 +931,12 @@ qlcnic_get_bios_version(struct qlcnic_adapter *adapter) | |||
905 | int | 931 | int |
906 | qlcnic_need_fw_reset(struct qlcnic_adapter *adapter) | 932 | qlcnic_need_fw_reset(struct qlcnic_adapter *adapter) |
907 | { | 933 | { |
908 | u32 count, old_count; | ||
909 | u32 val, version, major, minor, build; | 934 | u32 val, version, major, minor, build; |
910 | int i, timeout; | ||
911 | 935 | ||
912 | if (adapter->need_fw_reset) | 936 | if (adapter->need_fw_reset) |
913 | return 1; | 937 | return 1; |
914 | 938 | ||
915 | /* last attempt had failed */ | 939 | if (qlcnic_check_fw_status(adapter)) |
916 | if (QLCRD32(adapter, CRB_CMDPEG_STATE) == PHAN_INITIALIZE_FAILED) | ||
917 | return 1; | ||
918 | |||
919 | old_count = QLCRD32(adapter, QLCNIC_PEG_ALIVE_COUNTER); | ||
920 | |||
921 | for (i = 0; i < 10; i++) { | ||
922 | |||
923 | timeout = msleep_interruptible(200); | ||
924 | if (timeout) { | ||
925 | QLCWR32(adapter, CRB_CMDPEG_STATE, | ||
926 | PHAN_INITIALIZE_FAILED); | ||
927 | return -EINTR; | ||
928 | } | ||
929 | |||
930 | count = QLCRD32(adapter, QLCNIC_PEG_ALIVE_COUNTER); | ||
931 | if (count != old_count) | ||
932 | break; | ||
933 | } | ||
934 | |||
935 | /* firmware is dead */ | ||
936 | if (count == old_count) | ||
937 | return 1; | 940 | return 1; |
938 | 941 | ||
939 | /* check if we have got newer or different file firmware */ | 942 | /* check if we have got newer or different file firmware */ |
@@ -1158,78 +1161,6 @@ qlcnic_release_firmware(struct qlcnic_adapter *adapter) | |||
1158 | adapter->fw = NULL; | 1161 | adapter->fw = NULL; |
1159 | } | 1162 | } |
1160 | 1163 | ||
1161 | static int qlcnic_cmd_peg_ready(struct qlcnic_adapter *adapter) | ||
1162 | { | ||
1163 | u32 val; | ||
1164 | int retries = 60; | ||
1165 | |||
1166 | do { | ||
1167 | val = QLCRD32(adapter, CRB_CMDPEG_STATE); | ||
1168 | |||
1169 | switch (val) { | ||
1170 | case PHAN_INITIALIZE_COMPLETE: | ||
1171 | case PHAN_INITIALIZE_ACK: | ||
1172 | return 0; | ||
1173 | case PHAN_INITIALIZE_FAILED: | ||
1174 | goto out_err; | ||
1175 | default: | ||
1176 | break; | ||
1177 | } | ||
1178 | |||
1179 | msleep(500); | ||
1180 | |||
1181 | } while (--retries); | ||
1182 | |||
1183 | QLCWR32(adapter, CRB_CMDPEG_STATE, PHAN_INITIALIZE_FAILED); | ||
1184 | |||
1185 | out_err: | ||
1186 | dev_err(&adapter->pdev->dev, "Command Peg initialization not " | ||
1187 | "complete, state: 0x%x.\n", val); | ||
1188 | return -EIO; | ||
1189 | } | ||
1190 | |||
1191 | static int | ||
1192 | qlcnic_receive_peg_ready(struct qlcnic_adapter *adapter) | ||
1193 | { | ||
1194 | u32 val; | ||
1195 | int retries = 2000; | ||
1196 | |||
1197 | do { | ||
1198 | val = QLCRD32(adapter, CRB_RCVPEG_STATE); | ||
1199 | |||
1200 | if (val == PHAN_PEG_RCV_INITIALIZED) | ||
1201 | return 0; | ||
1202 | |||
1203 | msleep(10); | ||
1204 | |||
1205 | } while (--retries); | ||
1206 | |||
1207 | if (!retries) { | ||
1208 | dev_err(&adapter->pdev->dev, "Receive Peg initialization not " | ||
1209 | "complete, state: 0x%x.\n", val); | ||
1210 | return -EIO; | ||
1211 | } | ||
1212 | |||
1213 | return 0; | ||
1214 | } | ||
1215 | |||
1216 | int qlcnic_init_firmware(struct qlcnic_adapter *adapter) | ||
1217 | { | ||
1218 | int err; | ||
1219 | |||
1220 | err = qlcnic_cmd_peg_ready(adapter); | ||
1221 | if (err) | ||
1222 | return err; | ||
1223 | |||
1224 | err = qlcnic_receive_peg_ready(adapter); | ||
1225 | if (err) | ||
1226 | return err; | ||
1227 | |||
1228 | QLCWR32(adapter, CRB_CMDPEG_STATE, PHAN_INITIALIZE_ACK); | ||
1229 | |||
1230 | return err; | ||
1231 | } | ||
1232 | |||
1233 | static void | 1164 | static void |
1234 | qlcnic_handle_linkevent(struct qlcnic_adapter *adapter, | 1165 | qlcnic_handle_linkevent(struct qlcnic_adapter *adapter, |
1235 | struct qlcnic_fw_msg *msg) | 1166 | struct qlcnic_fw_msg *msg) |
diff --git a/drivers/net/qlcnic/qlcnic_main.c b/drivers/net/qlcnic/qlcnic_main.c index 6e246c819204..fa87a9633939 100644 --- a/drivers/net/qlcnic/qlcnic_main.c +++ b/drivers/net/qlcnic/qlcnic_main.c | |||
@@ -940,18 +940,13 @@ static int qlcnic_check_npar_opertional(struct qlcnic_adapter *adapter) | |||
940 | static int | 940 | static int |
941 | qlcnic_start_firmware(struct qlcnic_adapter *adapter) | 941 | qlcnic_start_firmware(struct qlcnic_adapter *adapter) |
942 | { | 942 | { |
943 | int val, err, first_boot; | 943 | int err; |
944 | 944 | ||
945 | err = qlcnic_can_start_firmware(adapter); | 945 | err = qlcnic_can_start_firmware(adapter); |
946 | if (err < 0) | 946 | if (err < 0) |
947 | return err; | 947 | return err; |
948 | else if (!err) | 948 | else if (!err) |
949 | goto wait_init; | 949 | goto check_fw_status; |
950 | |||
951 | first_boot = QLCRD32(adapter, QLCNIC_CAM_RAM(0x1fc)); | ||
952 | if (first_boot == 0x55555555) | ||
953 | /* This is the first boot after power up */ | ||
954 | QLCWR32(adapter, QLCNIC_CAM_RAM(0x1fc), QLCNIC_BDINFO_MAGIC); | ||
955 | 950 | ||
956 | if (load_fw_file) | 951 | if (load_fw_file) |
957 | qlcnic_request_firmware(adapter); | 952 | qlcnic_request_firmware(adapter); |
@@ -963,21 +958,12 @@ qlcnic_start_firmware(struct qlcnic_adapter *adapter) | |||
963 | } | 958 | } |
964 | 959 | ||
965 | err = qlcnic_need_fw_reset(adapter); | 960 | err = qlcnic_need_fw_reset(adapter); |
966 | if (err < 0) | ||
967 | goto err_out; | ||
968 | if (err == 0) | 961 | if (err == 0) |
969 | goto wait_init; | 962 | goto set_dev_ready; |
970 | |||
971 | if (first_boot != 0x55555555) { | ||
972 | QLCWR32(adapter, CRB_CMDPEG_STATE, 0); | ||
973 | QLCWR32(adapter, CRB_RCVPEG_STATE, 0); | ||
974 | qlcnic_pinit_from_rom(adapter); | ||
975 | msleep(1); | ||
976 | } | ||
977 | |||
978 | QLCWR32(adapter, QLCNIC_PEG_HALT_STATUS1, 0); | ||
979 | QLCWR32(adapter, QLCNIC_PEG_HALT_STATUS2, 0); | ||
980 | 963 | ||
964 | err = qlcnic_pinit_from_rom(adapter); | ||
965 | if (err) | ||
966 | goto err_out; | ||
981 | qlcnic_set_port_mode(adapter); | 967 | qlcnic_set_port_mode(adapter); |
982 | 968 | ||
983 | err = qlcnic_load_firmware(adapter); | 969 | err = qlcnic_load_firmware(adapter); |
@@ -985,18 +971,14 @@ qlcnic_start_firmware(struct qlcnic_adapter *adapter) | |||
985 | goto err_out; | 971 | goto err_out; |
986 | 972 | ||
987 | qlcnic_release_firmware(adapter); | 973 | qlcnic_release_firmware(adapter); |
974 | QLCWR32(adapter, CRB_DRIVER_VERSION, QLCNIC_DRIVER_VERSION); | ||
988 | 975 | ||
989 | val = (_QLCNIC_LINUX_MAJOR << 16) | 976 | check_fw_status: |
990 | | ((_QLCNIC_LINUX_MINOR << 8)) | 977 | err = qlcnic_check_fw_status(adapter); |
991 | | (_QLCNIC_LINUX_SUBVERSION); | ||
992 | QLCWR32(adapter, CRB_DRIVER_VERSION, val); | ||
993 | |||
994 | wait_init: | ||
995 | /* Handshake with the card before we register the devices. */ | ||
996 | err = qlcnic_init_firmware(adapter); | ||
997 | if (err) | 978 | if (err) |
998 | goto err_out; | 979 | goto err_out; |
999 | 980 | ||
981 | set_dev_ready: | ||
1000 | QLCWR32(adapter, QLCNIC_CRB_DEV_STATE, QLCNIC_DEV_READY); | 982 | QLCWR32(adapter, QLCNIC_CRB_DEV_STATE, QLCNIC_DEV_READY); |
1001 | qlcnic_idc_debug_info(adapter, 1); | 983 | qlcnic_idc_debug_info(adapter, 1); |
1002 | err = qlcnic_check_npar_opertional(adapter); | 984 | err = qlcnic_check_npar_opertional(adapter); |