34 ql4_printk(
KERN_ERR, ha,
"%s: Failed to set register window : addr written 0x%x, read 0x%x!\n",
47 ret_val = qla4_83xx_set_win_base(ha, addr);
63 ret_val = qla4_83xx_set_win_base(ha, addr);
69 __func__, addr, data);
81 while (lock_status == 0) {
116 ret_val = qla4_83xx_flash_lock(ha);
118 goto exit_lock_error;
124 goto exit_flash_read;
127 for (i = 0; i < u32_word_count; i++) {
130 (addr & 0xFFFF0000));
134 goto exit_flash_read;
143 goto exit_flash_read;
152 qla4_83xx_flash_unlock(ha);
174 goto exit_lockless_read;
182 goto exit_lockless_read;
186 if ((flash_offset + (u32_word_count *
sizeof(
uint32_t))) >
190 for (i = 0; i < u32_word_count; i++) {
197 goto exit_lockless_read;
203 flash_offset = flash_offset + 4;
213 goto exit_lockless_read;
220 for (i = 0; i < u32_word_count; i++) {
227 goto exit_lockless_read;
242 if (qla4_83xx_flash_lock(ha))
249 qla4_83xx_flash_unlock(ha);
273 goto exit_ms_mem_write;
283 goto exit_ms_mem_write_unlock;
286 for (i = 0; i <
count; i++, addr += 16) {
292 goto exit_ms_mem_write_unlock;
313 goto exit_ms_mem_write_unlock;
324 goto exit_ms_mem_write_unlock;
334 goto exit_ms_mem_write_unlock;
341 if (j >= MAX_CTL_CHECK) {
345 goto exit_ms_mem_write_unlock;
349 exit_ms_mem_write_unlock:
356 #define INTENT_TO_RECOVER 0x01
357 #define PROCEED_TO_RECOVER 0x02
368 if ((lockid & 0x3) != 0)
369 goto exit_lock_recovery;
379 if ((lockid & 0x3C) != (ha->
func_num << 2))
380 goto exit_lock_recovery;
400 lockid = ((lockid + (1 << 8)) & ~0xFF) | ha->
func_num;
409 #define QLA83XX_DRV_LOCK_MSLEEP 200
422 while (status == 0) {
428 lock_id = ((lock_id + (1 << 8)) & ~0xFF) | ha->
func_num;
436 first_owner = ha->
isp_ops->rd_reg_direct(ha,
442 func_num = tmo_owner & 0xFF;
443 lock_cnt = tmo_owner >> 8;
444 ql4_printk(
KERN_INFO, ha,
"%s: Lock by func %d failed after 2s, lock held by func %d, lock count %d, first_owner %d\n",
445 __func__, ha->
func_num, func_num, lock_cnt,
446 (first_owner & 0xFF));
448 if (first_owner != tmo_owner) {
459 ret_val = qla4_83xx_lock_recovery(ha);
487 __func__, ha->
func_num, (
id & 0xFF));
541 static int qla4_83xx_can_perform_reset(
struct scsi_qla_host *ha)
544 uint32_t dev_part, dev_part1, dev_part2;
550 int iscsi_present = 0;
551 int iscsi_func_low = 0;
562 dev_part = dev_part1;
563 for (i = nibble = 0; i <= 15; i++, nibble++) {
564 func_nibble = dev_part & (0xF << (nibble * 4));
565 func_nibble >>= (nibble * 4);
568 device_map[
i].
port_num = func_nibble & 0xC;
571 if (drv_active & (1 << device_map[i].
func_num)) {
576 if (drv_active & (1 << device_map[i].
func_num)) {
577 if (!iscsi_present ||
579 (iscsi_func_low > device_map[i].func_num)))
580 iscsi_func_low = device_map[i].func_num;
589 dev_part = dev_part2;
596 if (!nic_present && (ha->
func_num == iscsi_func_low)) {
598 "%s: can reset - NIC not present and lower iSCSI function is %d\n",
615 unsigned long reset_timeout, dev_init_timeout;
640 dev_state = qla4_8xxx_rd_direct(ha,
650 __func__, drv_state, drv_active);
652 while (drv_state != drv_active) {
654 ql4_printk(
KERN_INFO, ha,
"%s: %s: RESET TIMEOUT! drv_state: 0x%08x, drv_active: 0x%08x\n",
664 drv_state = qla4_8xxx_rd_direct(ha,
666 drv_active = qla4_8xxx_rd_direct(ha,
670 if (drv_state != drv_active) {
671 ql4_printk(
KERN_INFO, ha,
"%s: Reset_owner turning off drv_active of non-acking function 0x%x\n",
672 __func__, (drv_active ^ drv_state));
673 drv_active = drv_active & drv_state;
699 "%s: ha->nx_dev_init_timeout = %d, ha->nx_reset_timeout = %d\n",
706 static void qla4_83xx_dump_reset_seq_hdr(
struct scsi_qla_host *ha)
719 "Reset Template: 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X 0x%X\n",
720 *phdr, *(phdr+1), *(phdr+2), *(phdr+3), *(phdr+4),
721 *(phdr+5), *(phdr+6), *(phdr+7), *(phdr + 8),
722 *(phdr+9), *(phdr+10), *(phdr+11), *(phdr+12),
723 *(phdr+13), *(phdr+14), *(phdr+15)));
726 static int qla4_83xx_copy_bootloader(
struct scsi_qla_host *ha)
739 size = (size + 16) & ~0xF;
745 if (p_cache ==
NULL) {
749 goto exit_copy_bootloader;
757 goto exit_copy_error;
763 ret_val = qla4_83xx_ms_mem_write_128b(ha, dest, (
uint32_t *)p_cache,
768 goto exit_copy_error;
777 exit_copy_bootloader:
781 static int qla4_83xx_check_cmd_peg_status(
struct scsi_qla_host *ha)
790 "%s: Command Peg initialization complete. State=0x%x\n",
823 retries = duration / 10;
825 if ((value & test_mask) != test_result) {
842 __func__, value, test_mask, test_result);
848 static int qla4_83xx_reset_seq_checksum_test(
struct scsi_qla_host *ha)
855 while (u16_count-- > 0)
859 sum = (sum & 0xFFFF) + (sum >> 16);
888 goto exit_read_reset_template;
898 "%s: Read template hdr size %d from Flash\n",
899 __func__, tmplt_hdr_def_size));
907 goto exit_read_template_error;
914 tmplt_hdr_size = ha->
reset_tmplt.hdr->hdr_size/
sizeof(uint32_t);
915 if ((tmplt_hdr_size != tmplt_hdr_def_size) ||
917 ql4_printk(
KERN_ERR, ha,
"%s: Template Header size %d is invalid, tmplt_hdr_def_size %d\n",
918 __func__, tmplt_hdr_size, tmplt_hdr_def_size);
919 goto exit_read_template_error;
928 "%s: Read rest of the template size %d\n",
937 goto exit_read_template_error;
941 if (qla4_83xx_reset_seq_checksum_test(ha)) {
944 goto exit_read_template_error;
947 "%s: Reset Seq checksum passed, Get stop, start and init seq offsets\n",
957 qla4_83xx_dump_reset_seq_hdr(ha);
959 goto exit_read_reset_template;
961 exit_read_template_error:
964 exit_read_reset_template:
975 static void qla4_83xx_read_write_crb_reg(
struct scsi_qla_host *ha,
1007 value <<= p_rmw_hdr->
shl;
1008 value >>= p_rmw_hdr->
shr;
1026 for (i = 0; i < p_hdr->
count; i++, p_entry++) {
1033 static void qla4_83xx_read_write_list(
struct scsi_qla_host *ha,
1042 for (i = 0; i < p_hdr->
count; i++, p_entry++) {
1043 qla4_83xx_read_write_crb_reg(ha, p_entry->
arg1, p_entry->
arg2);
1068 for (i = 0; i < p_hdr->
count; i++, p_entry++) {
1069 qla4_83xx_poll_reg(ha, p_entry->
arg1, delay,
1074 for (i = 0; i < p_hdr->
count; i++, p_entry++) {
1075 if (qla4_83xx_poll_reg(ha, p_entry->
arg1, delay,
1087 static void qla4_83xx_poll_write_list(
struct scsi_qla_host *ha,
1101 for (i = 0; i < p_hdr->
count; i++, p_entry++) {
1107 if (qla4_83xx_poll_reg(ha, p_entry->
ar_addr, delay,
1111 "%s: Timeout Error: poll list, item_num %d, entry_num %d\n",
1119 static void qla4_83xx_read_modify_write(
struct scsi_qla_host *ha,
1131 for (i = 0; i < p_hdr->
count; i++, p_entry++) {
1132 qla4_83xx_rmw_crb_reg(ha, p_entry->
arg1, p_entry->
arg2,
1146 static void qla4_83xx_poll_read_list(
struct scsi_qla_host *ha,
1162 for (i = 0; i < p_hdr->
count; i++, p_entry++) {
1166 if (qla4_83xx_poll_reg(ha, p_entry->
ar_addr, delay,
1170 "%s: Timeout Error: poll list, Item_num %d, entry_num %d\n",
1192 static void qla4_83xx_template_end(
struct scsi_qla_host *ha,
1199 "%s: Reset sequence completed SUCCESSFULLY.\n",
1218 static void qla4_83xx_process_reset_template(
struct scsi_qla_host *ha,
1223 char *p_entry = p_buff;
1230 for (; (!ha->
reset_tmplt.seq_end) && (index < entries); index++) {
1233 switch (p_hdr->
cmd) {
1237 qla4_83xx_write_list(ha, p_hdr);
1240 qla4_83xx_read_write_list(ha, p_hdr);
1243 qla4_83xx_poll_list(ha, p_hdr);
1246 qla4_83xx_poll_write_list(ha, p_hdr);
1249 qla4_83xx_read_modify_write(ha, p_hdr);
1252 qla4_83xx_pause(ha, p_hdr);
1255 qla4_83xx_seq_end(ha, p_hdr);
1258 qla4_83xx_template_end(ha, p_hdr);
1261 qla4_83xx_poll_read_list(ha, p_hdr);
1265 __func__, p_hdr->
cmd, index);
1270 p_entry += p_hdr->
size;
1276 static void qla4_83xx_process_stop_seq(
struct scsi_qla_host *ha)
1279 qla4_83xx_process_reset_template(ha, ha->
reset_tmplt.stop_offset);
1286 static void qla4_83xx_process_start_seq(
struct scsi_qla_host *ha)
1288 qla4_83xx_process_reset_template(ha, ha->
reset_tmplt.start_offset);
1295 static void qla4_83xx_process_init_seq(
struct scsi_qla_host *ha)
1297 qla4_83xx_process_reset_template(ha, ha->
reset_tmplt.init_offset);
1308 qla4_83xx_process_stop_seq(ha);
1314 qla4_83xx_process_init_seq(ha);
1316 if (qla4_83xx_copy_bootloader(ha)) {
1324 qla4_83xx_process_start_seq(ha);
1334 ret_val = qla4_83xx_restart(ha);
1343 ret_val = qla4_83xx_check_cmd_peg_status(ha);
1385 for (i = 1; i < incount; i++)
1403 ha->
isp_ops->interrupt_service_routine(ha, intr_status);
1429 goto exit_isp_reset;
1445 "%s: HW state already set to NEED_RESET\n",
1452 if (qla4_83xx_can_perform_reset(ha))
1469 static void qla4_83xx_dump_pause_control_regs(
struct scsi_qla_host *ha)
1471 u32 val = 0, val1 = 0;
1479 "Port 0 Rx Buffer Pause Threshold Registers[TC7..TC0]:"));
1480 for (i = 0; i < 8; i++) {
1490 "Port 1 Rx Buffer Pause Threshold Registers[TC7..TC0]:"));
1491 for (i = 0; i < 8; i++) {
1501 "Port 0 RxB Traffic Class Max Cell Registers[3..0]:"));
1502 for (i = 0; i < 4; i++) {
1512 "Port 1 RxB Traffic Class Max Cell Registers[3..0]:"));
1513 for (i = 0; i < 4; i++) {
1523 "Port 0 RxB Rx Traffic Class Stats [TC7..TC0]"));
1524 for (i = 7; i >= 0; i--) {
1528 val &= ~(0x7 << 29);
1541 "Port 1 RxB Rx Traffic Class Stats [TC7..TC0]"));
1542 for (i = 7; i >= 0; i--) {
1546 val &= ~(0x7 << 29);
1563 "IFB-Pause Thresholds: Port 2:0x%x, Port 3:0x%x\n",
1567 static void __qla4_83xx_disable_pause(
struct scsi_qla_host *ha)
1575 for (i = 0; i < 8; i++) {
1586 for (i = 0; i < 4; i++) {
1608 qla4_83xx_dump_pause_control_regs(ha);
1609 __qla4_83xx_disable_pause(ha);