Lines Matching refs:ha

99 static int qla4xxx_wait_for_hba_online(struct scsi_qla_host *ha);
103 static void qla4xxx_config_dma_addressing(struct scsi_qla_host *ha);
298 static int qla4xxx_isp_check_reg(struct scsi_qla_host *ha) in qla4xxx_isp_check_reg() argument
303 if (is_qla8022(ha)) in qla4xxx_isp_check_reg()
304 reg_val = readl(&ha->qla4_82xx_reg->host_status); in qla4xxx_isp_check_reg()
305 else if (is_qla8032(ha) || is_qla8042(ha)) in qla4xxx_isp_check_reg()
306 reg_val = qla4_8xxx_rd_direct(ha, QLA8XXX_PEG_ALIVE_COUNTER); in qla4xxx_isp_check_reg()
308 reg_val = readw(&ha->reg->ctrl_status); in qla4xxx_isp_check_reg()
320 struct scsi_qla_host *ha = to_qla_host(shost); in qla4xxx_send_ping() local
333 DEBUG2(ql4_printk(KERN_INFO, ha, "%s: IPv4 Ping src: %pI4 " in qla4xxx_send_ping()
335 &ha->ip_config.ip_address, ipaddr)); in qla4xxx_send_ping()
336 rval = qla4xxx_ping_iocb(ha, options, payload_size, pid, in qla4xxx_send_ping()
350 DEBUG2(ql4_printk(KERN_INFO, ha, "%s: LinkLocal Ping " in qla4xxx_send_ping()
352 &ha->ip_config.ipv6_link_local_addr, in qla4xxx_send_ping()
355 rval = qla4xxx_ping_iocb(ha, options, payload_size, in qla4xxx_send_ping()
358 ql4_printk(KERN_WARNING, ha, "%s: iface num = %d " in qla4xxx_send_ping()
372 DEBUG2(ql4_printk(KERN_INFO, ha, "%s: IPv6 " in qla4xxx_send_ping()
375 &ha->ip_config.ipv6_addr0, in qla4xxx_send_ping()
379 DEBUG2(ql4_printk(KERN_INFO, ha, "%s: IPv6 " in qla4xxx_send_ping()
382 &ha->ip_config.ipv6_addr1, in qla4xxx_send_ping()
385 rval = qla4xxx_ping_iocb(ha, options, payload_size, in qla4xxx_send_ping()
631 static void qla4xxx_create_chap_list(struct scsi_qla_host *ha) in qla4xxx_create_chap_list() argument
639 if (is_qla40XX(ha)) in qla4xxx_create_chap_list()
645 chap_size = ha->hw.flt_chap_size / 2; in qla4xxx_create_chap_list()
647 chap_flash_data = dma_alloc_coherent(&ha->pdev->dev, chap_size, in qla4xxx_create_chap_list()
650 ql4_printk(KERN_ERR, ha, "No memory for chap_flash_data\n"); in qla4xxx_create_chap_list()
654 if (is_qla40XX(ha)) { in qla4xxx_create_chap_list()
657 offset = FLASH_RAW_ACCESS_ADDR + (ha->hw.flt_region_chap << 2); in qla4xxx_create_chap_list()
658 if (ha->port_num == 1) in qla4xxx_create_chap_list()
662 rval = qla4xxx_get_flash(ha, chap_dma, offset, chap_size); in qla4xxx_create_chap_list()
666 if (ha->chap_list == NULL) in qla4xxx_create_chap_list()
667 ha->chap_list = vmalloc(chap_size); in qla4xxx_create_chap_list()
668 if (ha->chap_list == NULL) { in qla4xxx_create_chap_list()
669 ql4_printk(KERN_ERR, ha, "No memory for ha->chap_list\n"); in qla4xxx_create_chap_list()
673 memset(ha->chap_list, 0, chap_size); in qla4xxx_create_chap_list()
674 memcpy(ha->chap_list, chap_flash_data, chap_size); in qla4xxx_create_chap_list()
677 dma_free_coherent(&ha->pdev->dev, chap_size, chap_flash_data, chap_dma); in qla4xxx_create_chap_list()
680 static int qla4xxx_get_chap_by_index(struct scsi_qla_host *ha, in qla4xxx_get_chap_by_index() argument
687 if (!ha->chap_list) { in qla4xxx_get_chap_by_index()
688 ql4_printk(KERN_ERR, ha, "CHAP table cache is empty!\n"); in qla4xxx_get_chap_by_index()
692 if (is_qla80XX(ha)) in qla4xxx_get_chap_by_index()
693 max_chap_entries = (ha->hw.flt_chap_size / 2) / in qla4xxx_get_chap_by_index()
699 ql4_printk(KERN_ERR, ha, "Invalid Chap index\n"); in qla4xxx_get_chap_by_index()
703 *chap_entry = (struct ql4_chap_table *)ha->chap_list + chap_index; in qla4xxx_get_chap_by_index()
724 static int qla4xxx_find_free_chap_index(struct scsi_qla_host *ha, in qla4xxx_find_free_chap_index() argument
732 if (is_qla80XX(ha)) in qla4xxx_find_free_chap_index()
733 max_chap_entries = (ha->hw.flt_chap_size / 2) / in qla4xxx_find_free_chap_index()
738 if (!ha->chap_list) { in qla4xxx_find_free_chap_index()
739 ql4_printk(KERN_ERR, ha, "CHAP table cache is empty!\n"); in qla4xxx_find_free_chap_index()
745 chap_table = (struct ql4_chap_table *)ha->chap_list + i; in qla4xxx_find_free_chap_index()
769 struct scsi_qla_host *ha = to_qla_host(shost); in qla4xxx_get_chap_list() local
776 if (is_qla80XX(ha)) in qla4xxx_get_chap_list()
777 max_chap_entries = (ha->hw.flt_chap_size / 2) / in qla4xxx_get_chap_list()
782 ql4_printk(KERN_INFO, ha, "%s: num_entries = %d, CHAP idx = %d\n", in qla4xxx_get_chap_list()
790 qla4xxx_create_chap_list(ha); in qla4xxx_get_chap_list()
793 mutex_lock(&ha->chap_sem); in qla4xxx_get_chap_list()
795 chap_table = (struct ql4_chap_table *)ha->chap_list + i; in qla4xxx_get_chap_list()
819 mutex_unlock(&ha->chap_sem); in qla4xxx_get_chap_list()
822 ql4_printk(KERN_INFO, ha, "%s: Valid CHAP Entries = %d\n", in qla4xxx_get_chap_list()
866 struct scsi_qla_host *ha = to_qla_host(shost); in qla4xxx_delete_chap() local
874 chap_table = dma_pool_zalloc(ha->chap_dma_pool, GFP_KERNEL, &chap_dma); in qla4xxx_delete_chap()
878 if (is_qla80XX(ha)) in qla4xxx_delete_chap()
879 max_chap_entries = (ha->hw.flt_chap_size / 2) / in qla4xxx_delete_chap()
893 ql4_printk(KERN_INFO, ha, "CHAP entry %d is in use, cannot " in qla4xxx_delete_chap()
900 if (is_qla40XX(ha)) in qla4xxx_delete_chap()
903 offset = FLASH_RAW_ACCESS_ADDR + (ha->hw.flt_region_chap << 2); in qla4xxx_delete_chap()
907 if (ha->port_num == 1) in qla4xxx_delete_chap()
908 offset += (ha->hw.flt_chap_size / 2); in qla4xxx_delete_chap()
912 ret = qla4xxx_get_flash(ha, chap_dma, offset, chap_size); in qla4xxx_delete_chap()
918 DEBUG2(ql4_printk(KERN_INFO, ha, "Chap Cookie: x%x\n", in qla4xxx_delete_chap()
922 ql4_printk(KERN_ERR, ha, "No valid chap entry found\n"); in qla4xxx_delete_chap()
930 ret = qla4xxx_set_flash(ha, chap_dma, offset, chap_size, in qla4xxx_delete_chap()
932 if (ret == QLA_SUCCESS && ha->chap_list) { in qla4xxx_delete_chap()
933 mutex_lock(&ha->chap_sem); in qla4xxx_delete_chap()
935 memcpy((struct ql4_chap_table *)ha->chap_list + chap_tbl_idx, in qla4xxx_delete_chap()
937 mutex_unlock(&ha->chap_sem); in qla4xxx_delete_chap()
943 dma_pool_free(ha->chap_dma_pool, chap_table, chap_dma); in qla4xxx_delete_chap()
957 struct scsi_qla_host *ha = to_qla_host(shost); in qla4xxx_set_chap_entry() local
994 ql4_printk(KERN_ERR, ha, in qla4xxx_set_chap_entry()
1006 if (is_qla80XX(ha)) in qla4xxx_set_chap_entry()
1007 max_chap_entries = (ha->hw.flt_chap_size / 2) / in qla4xxx_set_chap_entry()
1012 mutex_lock(&ha->chap_sem); in qla4xxx_set_chap_entry()
1014 rc = qla4xxx_get_chap_by_index(ha, chap_rec.chap_tbl_idx, in qla4xxx_set_chap_entry()
1018 ql4_printk(KERN_INFO, ha, in qla4xxx_set_chap_entry()
1029 ql4_printk(KERN_INFO, ha, in qla4xxx_set_chap_entry()
1037 rc = qla4xxx_find_free_chap_index(ha, &chap_rec.chap_tbl_idx); in qla4xxx_set_chap_entry()
1039 ql4_printk(KERN_INFO, ha, "CHAP entry not available\n"); in qla4xxx_set_chap_entry()
1045 rc = qla4xxx_set_chap(ha, chap_rec.username, chap_rec.password, in qla4xxx_set_chap_entry()
1049 mutex_unlock(&ha->chap_sem); in qla4xxx_set_chap_entry()
1058 struct scsi_qla_host *ha = to_qla_host(shost); in qla4xxx_get_host_stats() local
1067 DEBUG2(ql4_printk(KERN_INFO, ha, "Func: %s\n", __func__)); in qla4xxx_get_host_stats()
1072 ql4_printk(KERN_INFO, ha, "%s: host_stats size mismatch expected = %d, is = %d\n", in qla4xxx_get_host_stats()
1086 ql_iscsi_stats = dma_alloc_coherent(&ha->pdev->dev, stats_size, in qla4xxx_get_host_stats()
1089 ql4_printk(KERN_ERR, ha, in qla4xxx_get_host_stats()
1095 ret = qla4xxx_get_mgmt_data(ha, ddb_idx, stats_size, in qla4xxx_get_host_stats()
1098 ql4_printk(KERN_ERR, ha, in qla4xxx_get_host_stats()
1252 dma_free_coherent(&ha->pdev->dev, stats_size, in qla4xxx_get_host_stats()
1255 ql4_printk(KERN_INFO, ha, "%s: Get host stats done\n", in qla4xxx_get_host_stats()
1265 struct scsi_qla_host *ha = to_qla_host(shost); in qla4xxx_get_iface_param() local
1273 len = sprintf(buf, "%pI4\n", &ha->ip_config.ip_address); in qla4xxx_get_iface_param()
1277 &ha->ip_config.subnet_mask); in qla4xxx_get_iface_param()
1280 len = sprintf(buf, "%pI4\n", &ha->ip_config.gateway); in qla4xxx_get_iface_param()
1284 OP_STATE(ha->ip_config.ipv4_options, in qla4xxx_get_iface_param()
1287 OP_STATE(ha->ip_config.ipv6_options, in qla4xxx_get_iface_param()
1295 (ha->ip_config.tcp_options & in qla4xxx_get_iface_param()
1302 &ha->ip_config.ipv6_addr0); in qla4xxx_get_iface_param()
1305 &ha->ip_config.ipv6_addr1); in qla4xxx_get_iface_param()
1309 &ha->ip_config.ipv6_link_local_addr); in qla4xxx_get_iface_param()
1313 &ha->ip_config.ipv6_default_router_addr); in qla4xxx_get_iface_param()
1316 pval = (ha->ip_config.ipv6_addl_options & in qla4xxx_get_iface_param()
1323 pval = (ha->ip_config.ipv6_addl_options & in qla4xxx_get_iface_param()
1331 ival = ha->ip_config.ipv4_vlan_tag & in qla4xxx_get_iface_param()
1334 ival = ha->ip_config.ipv6_vlan_tag & in qla4xxx_get_iface_param()
1341 ival = (ha->ip_config.ipv4_vlan_tag >> 13) & in qla4xxx_get_iface_param()
1344 ival = (ha->ip_config.ipv6_vlan_tag >> 13) & in qla4xxx_get_iface_param()
1351 OP_STATE(ha->ip_config.ipv4_options, in qla4xxx_get_iface_param()
1354 OP_STATE(ha->ip_config.ipv6_options, in qla4xxx_get_iface_param()
1360 len = sprintf(buf, "%d\n", ha->ip_config.eth_mtu_size); in qla4xxx_get_iface_param()
1365 ha->ip_config.ipv4_port); in qla4xxx_get_iface_param()
1368 ha->ip_config.ipv6_port); in qla4xxx_get_iface_param()
1373 ha->ip_config.ipv4_addr_state); in qla4xxx_get_iface_param()
1377 ha->ip_config.ipv6_addr0_state); in qla4xxx_get_iface_param()
1380 ha->ip_config.ipv6_addr1_state); in qla4xxx_get_iface_param()
1387 ha->ip_config.ipv6_link_local_state); in qla4xxx_get_iface_param()
1392 ha->ip_config.ipv6_default_router_state); in qla4xxx_get_iface_param()
1397 OP_STATE(~ha->ip_config.tcp_options, in qla4xxx_get_iface_param()
1400 OP_STATE(~ha->ip_config.ipv6_tcp_options, in qla4xxx_get_iface_param()
1407 OP_STATE(~ha->ip_config.tcp_options, in qla4xxx_get_iface_param()
1410 OP_STATE(~ha->ip_config.ipv6_tcp_options, in qla4xxx_get_iface_param()
1417 OP_STATE(~ha->ip_config.tcp_options, in qla4xxx_get_iface_param()
1420 OP_STATE(~ha->ip_config.ipv6_tcp_options, in qla4xxx_get_iface_param()
1429 ha->ip_config.tcp_wsf); in qla4xxx_get_iface_param()
1432 ha->ip_config.ipv6_tcp_wsf); in qla4xxx_get_iface_param()
1436 ival = (ha->ip_config.tcp_options & in qla4xxx_get_iface_param()
1439 ival = (ha->ip_config.ipv6_tcp_options & in qla4xxx_get_iface_param()
1446 OP_STATE(ha->ip_config.tcp_options, in qla4xxx_get_iface_param()
1449 OP_STATE(ha->ip_config.ipv6_tcp_options, in qla4xxx_get_iface_param()
1457 ha->ip_config.ipv4_cache_id); in qla4xxx_get_iface_param()
1460 ha->ip_config.ipv6_cache_id); in qla4xxx_get_iface_param()
1463 OP_STATE(ha->ip_config.tcp_options, in qla4xxx_get_iface_param()
1469 OP_STATE(ha->ip_config.tcp_options, in qla4xxx_get_iface_param()
1475 OP_STATE(ha->ip_config.ipv4_options, in qla4xxx_get_iface_param()
1481 len = sprintf(buf, "%d\n", ha->ip_config.ipv4_tos); in qla4xxx_get_iface_param()
1484 OP_STATE(ha->ip_config.ipv4_options, in qla4xxx_get_iface_param()
1490 OP_STATE(ha->ip_config.ipv4_options, IPOPT_ALT_CID_EN, in qla4xxx_get_iface_param()
1496 pval = (ha->ip_config.ipv4_alt_cid_len) ? in qla4xxx_get_iface_param()
1497 (char *)ha->ip_config.ipv4_alt_cid : ""; in qla4xxx_get_iface_param()
1502 OP_STATE(ha->ip_config.ipv4_options, in qla4xxx_get_iface_param()
1508 OP_STATE(ha->ip_config.ipv4_options, in qla4xxx_get_iface_param()
1514 pval = (ha->ip_config.ipv4_vid_len) ? in qla4xxx_get_iface_param()
1515 (char *)ha->ip_config.ipv4_vid : ""; in qla4xxx_get_iface_param()
1520 OP_STATE(ha->ip_config.ipv4_options, in qla4xxx_get_iface_param()
1526 OP_STATE(~ha->ip_config.ipv4_options, in qla4xxx_get_iface_param()
1532 OP_STATE(ha->ip_config.ipv4_options, in qla4xxx_get_iface_param()
1539 OP_STATE(ha->ip_config.ipv4_options, in qla4xxx_get_iface_param()
1542 OP_STATE(ha->ip_config.ipv6_options, in qla4xxx_get_iface_param()
1548 len = sprintf(buf, "%d\n", ha->ip_config.ipv4_ttl); in qla4xxx_get_iface_param()
1551 OP_STATE(ha->ip_config.ipv6_options, in qla4xxx_get_iface_param()
1557 OP_STATE(ha->ip_config.ipv6_addl_options, in qla4xxx_get_iface_param()
1563 len = sprintf(buf, "%u\n", ha->ip_config.ipv6_flow_lbl); in qla4xxx_get_iface_param()
1567 ha->ip_config.ipv6_traffic_class); in qla4xxx_get_iface_param()
1571 ha->ip_config.ipv6_hop_limit); in qla4xxx_get_iface_param()
1575 ha->ip_config.ipv6_nd_reach_time); in qla4xxx_get_iface_param()
1579 ha->ip_config.ipv6_nd_rexmit_timer); in qla4xxx_get_iface_param()
1583 ha->ip_config.ipv6_nd_stale_timeout); in qla4xxx_get_iface_param()
1587 ha->ip_config.ipv6_dup_addr_detect_count); in qla4xxx_get_iface_param()
1591 ha->ip_config.ipv6_gw_advrt_mtu); in qla4xxx_get_iface_param()
1599 len = sprintf(buf, "%d\n", ha->ip_config.def_timeout); in qla4xxx_get_iface_param()
1602 OP_STATE(ha->ip_config.iscsi_options, in qla4xxx_get_iface_param()
1608 OP_STATE(ha->ip_config.iscsi_options, in qla4xxx_get_iface_param()
1614 OP_STATE(ha->ip_config.iscsi_options, in qla4xxx_get_iface_param()
1620 OP_STATE(ha->ip_config.iscsi_options, in qla4xxx_get_iface_param()
1626 OP_STATE(ha->ip_config.iscsi_options, in qla4xxx_get_iface_param()
1632 OP_STATE(ha->ip_config.iscsi_options, in qla4xxx_get_iface_param()
1639 (ha->ip_config.iscsi_options & in qla4xxx_get_iface_param()
1644 ha->ip_config.iscsi_max_pdu_size * in qla4xxx_get_iface_param()
1649 ha->ip_config.iscsi_first_burst_len * in qla4xxx_get_iface_param()
1654 ha->ip_config.iscsi_max_outstnd_r2t); in qla4xxx_get_iface_param()
1658 ha->ip_config.iscsi_max_burst_len * in qla4xxx_get_iface_param()
1662 OP_STATE(ha->ip_config.iscsi_options, in qla4xxx_get_iface_param()
1668 OP_STATE(ha->ip_config.iscsi_options, in qla4xxx_get_iface_param()
1674 OP_STATE(ha->ip_config.iscsi_options, in qla4xxx_get_iface_param()
1680 OP_STATE(ha->ip_config.iscsi_options, in qla4xxx_get_iface_param()
1686 OP_STATE(ha->ip_config.iscsi_options, in qla4xxx_get_iface_param()
1692 len = sprintf(buf, "%s\n", ha->ip_config.iscsi_name); in qla4xxx_get_iface_param()
1709 struct scsi_qla_host *ha; in qla4xxx_ep_connect() local
1719 ha = iscsi_host_priv(shost); in qla4xxx_ep_connect()
1731 DEBUG2(ql4_printk(KERN_INFO, ha, "%s: %pI4\n", __func__, in qla4xxx_ep_connect()
1737 DEBUG2(ql4_printk(KERN_INFO, ha, "%s: %pI6\n", __func__, in qla4xxx_ep_connect()
1740 ql4_printk(KERN_WARNING, ha, "%s: Invalid endpoint\n", in qla4xxx_ep_connect()
1752 struct scsi_qla_host *ha; in qla4xxx_ep_poll() local
1756 ha = to_qla_host(qla_ep->host); in qla4xxx_ep_poll()
1757 DEBUG2(pr_info_ratelimited("%s: host: %ld\n", __func__, ha->host_no)); in qla4xxx_ep_poll()
1759 if (adapter_up(ha) && !test_bit(AF_BUILD_DDB_LIST, &ha->flags)) in qla4xxx_ep_poll()
1768 struct scsi_qla_host *ha; in qla4xxx_ep_disconnect() local
1771 ha = to_qla_host(qla_ep->host); in qla4xxx_ep_disconnect()
1772 DEBUG2(ql4_printk(KERN_INFO, ha, "%s: host: %ld\n", __func__, in qla4xxx_ep_disconnect()
1773 ha->host_no)); in qla4xxx_ep_disconnect()
1783 struct scsi_qla_host *ha; in qla4xxx_get_ep_param() local
1788 ha = to_qla_host(qla_ep->host); in qla4xxx_get_ep_param()
1789 DEBUG2(ql4_printk(KERN_INFO, ha, "%s: host: %ld\n", __func__, in qla4xxx_get_ep_param()
1790 ha->host_no)); in qla4xxx_get_ep_param()
1812 struct scsi_qla_host *ha; in qla4xxx_conn_get_stats() local
1821 ha = ddb_entry->ha; in qla4xxx_conn_get_stats()
1823 DEBUG2(ql4_printk(KERN_INFO, ha, "%s: host: %ld\n", __func__, in qla4xxx_conn_get_stats()
1824 ha->host_no)); in qla4xxx_conn_get_stats()
1827 ql_iscsi_stats = dma_alloc_coherent(&ha->pdev->dev, stats_size, in qla4xxx_conn_get_stats()
1830 ql4_printk(KERN_ERR, ha, in qla4xxx_conn_get_stats()
1835 ret = qla4xxx_get_mgmt_data(ha, ddb_entry->fw_ddb_index, stats_size, in qla4xxx_conn_get_stats()
1838 ql4_printk(KERN_ERR, ha, in qla4xxx_conn_get_stats()
1868 dma_free_coherent(&ha->pdev->dev, stats_size, ql_iscsi_stats, in qla4xxx_conn_get_stats()
1892 struct scsi_qla_host *ha = to_qla_host(shost); in qla4xxx_set_port_speed() local
1896 qla4xxx_get_firmware_state(ha); in qla4xxx_set_port_speed()
1898 switch (ha->addl_fw_state & 0x0F00) { in qla4xxx_set_port_speed()
1917 struct scsi_qla_host *ha = to_qla_host(shost); in qla4xxx_set_port_state() local
1921 if (test_bit(AF_LINK_UP, &ha->flags)) in qla4xxx_set_port_state()
1930 struct scsi_qla_host *ha = to_qla_host(shost); in qla4xxx_host_get_param() local
1935 len = sysfs_format_mac(buf, ha->my_mac, MAC_ADDR_LEN); in qla4xxx_host_get_param()
1938 len = sprintf(buf, "%pI4\n", &ha->ip_config.ip_address); in qla4xxx_host_get_param()
1941 len = sprintf(buf, "%s\n", ha->name_string); in qla4xxx_host_get_param()
1958 static void qla4xxx_create_ipv4_iface(struct scsi_qla_host *ha) in qla4xxx_create_ipv4_iface() argument
1960 if (ha->iface_ipv4) in qla4xxx_create_ipv4_iface()
1964 ha->iface_ipv4 = iscsi_create_iface(ha->host, in qla4xxx_create_ipv4_iface()
1967 if (!ha->iface_ipv4) in qla4xxx_create_ipv4_iface()
1968 ql4_printk(KERN_ERR, ha, "Could not create IPv4 iSCSI " in qla4xxx_create_ipv4_iface()
1972 static void qla4xxx_create_ipv6_iface(struct scsi_qla_host *ha) in qla4xxx_create_ipv6_iface() argument
1974 if (!ha->iface_ipv6_0) in qla4xxx_create_ipv6_iface()
1976 ha->iface_ipv6_0 = iscsi_create_iface(ha->host, in qla4xxx_create_ipv6_iface()
1980 if (!ha->iface_ipv6_0) in qla4xxx_create_ipv6_iface()
1981 ql4_printk(KERN_ERR, ha, "Could not create IPv6 iSCSI " in qla4xxx_create_ipv6_iface()
1984 if (!ha->iface_ipv6_1) in qla4xxx_create_ipv6_iface()
1986 ha->iface_ipv6_1 = iscsi_create_iface(ha->host, in qla4xxx_create_ipv6_iface()
1990 if (!ha->iface_ipv6_1) in qla4xxx_create_ipv6_iface()
1991 ql4_printk(KERN_ERR, ha, "Could not create IPv6 iSCSI " in qla4xxx_create_ipv6_iface()
1995 static void qla4xxx_create_ifaces(struct scsi_qla_host *ha) in qla4xxx_create_ifaces() argument
1997 if (ha->ip_config.ipv4_options & IPOPT_IPV4_PROTOCOL_ENABLE) in qla4xxx_create_ifaces()
1998 qla4xxx_create_ipv4_iface(ha); in qla4xxx_create_ifaces()
2000 if (ha->ip_config.ipv6_options & IPV6_OPT_IPV6_PROTOCOL_ENABLE) in qla4xxx_create_ifaces()
2001 qla4xxx_create_ipv6_iface(ha); in qla4xxx_create_ifaces()
2004 static void qla4xxx_destroy_ipv4_iface(struct scsi_qla_host *ha) in qla4xxx_destroy_ipv4_iface() argument
2006 if (ha->iface_ipv4) { in qla4xxx_destroy_ipv4_iface()
2007 iscsi_destroy_iface(ha->iface_ipv4); in qla4xxx_destroy_ipv4_iface()
2008 ha->iface_ipv4 = NULL; in qla4xxx_destroy_ipv4_iface()
2012 static void qla4xxx_destroy_ipv6_iface(struct scsi_qla_host *ha) in qla4xxx_destroy_ipv6_iface() argument
2014 if (ha->iface_ipv6_0) { in qla4xxx_destroy_ipv6_iface()
2015 iscsi_destroy_iface(ha->iface_ipv6_0); in qla4xxx_destroy_ipv6_iface()
2016 ha->iface_ipv6_0 = NULL; in qla4xxx_destroy_ipv6_iface()
2018 if (ha->iface_ipv6_1) { in qla4xxx_destroy_ipv6_iface()
2019 iscsi_destroy_iface(ha->iface_ipv6_1); in qla4xxx_destroy_ipv6_iface()
2020 ha->iface_ipv6_1 = NULL; in qla4xxx_destroy_ipv6_iface()
2024 static void qla4xxx_destroy_ifaces(struct scsi_qla_host *ha) in qla4xxx_destroy_ifaces() argument
2026 qla4xxx_destroy_ipv4_iface(ha); in qla4xxx_destroy_ifaces()
2027 qla4xxx_destroy_ipv6_iface(ha); in qla4xxx_destroy_ifaces()
2030 static void qla4xxx_set_ipv6(struct scsi_qla_host *ha, in qla4xxx_set_ipv6() argument
2075 ql4_printk(KERN_ERR, ha, in qla4xxx_set_ipv6()
2092 ql4_printk(KERN_ERR, ha, in qla4xxx_set_ipv6()
2108 qla4xxx_create_ipv6_iface(ha); in qla4xxx_set_ipv6()
2113 qla4xxx_destroy_ipv6_iface(ha); in qla4xxx_set_ipv6()
2273 ql4_printk(KERN_ERR, ha, "Unknown IPv6 param = %d\n", in qla4xxx_set_ipv6()
2279 static void qla4xxx_set_ipv4(struct scsi_qla_host *ha, in qla4xxx_set_ipv4() argument
2304 ql4_printk(KERN_ERR, ha, "Invalid IPv4 bootproto\n"); in qla4xxx_set_ipv4()
2310 qla4xxx_create_ipv4_iface(ha); in qla4xxx_set_ipv4()
2315 qla4xxx_destroy_ipv4_iface(ha); in qla4xxx_set_ipv4()
2531 ql4_printk(KERN_ERR, ha, "Unknown IPv4 param = %d\n", in qla4xxx_set_ipv4()
2537 static void qla4xxx_set_iscsi_param(struct scsi_qla_host *ha, in qla4xxx_set_iscsi_param() argument
2693 ql4_printk(KERN_ERR, ha, "Unknown iscsi param = %d\n", in qla4xxx_set_iscsi_param()
2724 struct scsi_qla_host *ha = to_qla_host(shost); in qla4xxx_iface_set_param() local
2734 init_fw_cb = dma_alloc_coherent(&ha->pdev->dev, in qla4xxx_iface_set_param()
2738 ql4_printk(KERN_ERR, ha, "%s: Unable to alloc init_cb\n", in qla4xxx_iface_set_param()
2746 if (qla4xxx_get_ifcb(ha, &mbox_cmd[0], &mbox_sts[0], init_fw_cb_dma)) { in qla4xxx_iface_set_param()
2747 ql4_printk(KERN_ERR, ha, "%s: get ifcb failed\n", __func__); in qla4xxx_iface_set_param()
2760 qla4xxx_set_ipv4(ha, iface_param, in qla4xxx_iface_set_param()
2765 ql4_printk(KERN_ERR, ha, in qla4xxx_iface_set_param()
2775 qla4xxx_set_ipv6(ha, iface_param, in qla4xxx_iface_set_param()
2780 ql4_printk(KERN_ERR, ha, in qla4xxx_iface_set_param()
2787 ql4_printk(KERN_ERR, ha, in qla4xxx_iface_set_param()
2792 qla4xxx_set_iscsi_param(ha, iface_param, in qla4xxx_iface_set_param()
2801 rval = qla4xxx_set_flash(ha, init_fw_cb_dma, FLASH_SEGMENT_IFCB, in qla4xxx_iface_set_param()
2805 ql4_printk(KERN_ERR, ha, "%s: set flash mbx failed\n", in qla4xxx_iface_set_param()
2811 rval = qla4xxx_disable_acb(ha); in qla4xxx_iface_set_param()
2813 ql4_printk(KERN_ERR, ha, "%s: disable acb mbx failed\n", in qla4xxx_iface_set_param()
2819 wait_for_completion_timeout(&ha->disable_acb_comp, in qla4xxx_iface_set_param()
2824 rval = qla4xxx_set_acb(ha, &mbox_cmd[0], &mbox_sts[0], init_fw_cb_dma); in qla4xxx_iface_set_param()
2826 ql4_printk(KERN_ERR, ha, "%s: set acb mbx failed\n", in qla4xxx_iface_set_param()
2833 qla4xxx_update_local_ifcb(ha, &mbox_cmd[0], &mbox_sts[0], init_fw_cb, in qla4xxx_iface_set_param()
2837 dma_free_coherent(&ha->pdev->dev, sizeof(struct addr_ctrl_blk), in qla4xxx_iface_set_param()
2848 struct scsi_qla_host *ha = ddb_entry->ha; in qla4xxx_session_get_param() local
2857 rval = qla4xxx_get_chap_index(ha, sess->username_in, in qla4xxx_session_get_param()
2874 rval = qla4xxx_get_chap_index(ha, sess->username, in qla4xxx_session_get_param()
2893 rval = qla4xxx_get_uni_chap_at_index(ha, chap_tbl.name, in qla4xxx_session_get_param()
2934 int qla4xxx_get_ddb_index(struct scsi_qla_host *ha, uint16_t *ddb_index) in qla4xxx_get_ddb_index() argument
2941 tmp_ddb_index = find_first_zero_bit(ha->ddb_idx_map, MAX_DDB_ENTRIES); in qla4xxx_get_ddb_index()
2944 DEBUG2(ql4_printk(KERN_INFO, ha, in qla4xxx_get_ddb_index()
2950 if (test_and_set_bit(tmp_ddb_index, ha->ddb_idx_map)) in qla4xxx_get_ddb_index()
2953 DEBUG2(ql4_printk(KERN_INFO, ha, in qla4xxx_get_ddb_index()
2955 ret = qla4xxx_req_ddb_entry(ha, tmp_ddb_index, &mbx_sts); in qla4xxx_get_ddb_index()
2958 ql4_printk(KERN_INFO, ha, in qla4xxx_get_ddb_index()
2963 DEBUG2(ql4_printk(KERN_INFO, ha, in qla4xxx_get_ddb_index()
2973 static int qla4xxx_match_ipaddress(struct scsi_qla_host *ha, in qla4xxx_match_ipaddress() argument
3007 static int qla4xxx_match_fwdb_session(struct scsi_qla_host *ha, in qla4xxx_match_fwdb_session() argument
3024 max_ddbs = is_qla40XX(ha) ? MAX_DEV_DB_ENTRIES_40XX : in qla4xxx_match_fwdb_session()
3028 ddb_entry = qla4xxx_lookup_ddb_by_fw_index(ha, idx); in qla4xxx_match_fwdb_session()
3043 DEBUG2(ql4_printk(KERN_INFO, ha, in qla4xxx_match_fwdb_session()
3048 DEBUG2(ql4_printk(KERN_INFO, ha, in qla4xxx_match_fwdb_session()
3053 DEBUG2(ql4_printk(KERN_INFO, ha, in qla4xxx_match_fwdb_session()
3060 rval = qla4xxx_match_ipaddress(ha, ddb_entry, in qla4xxx_match_fwdb_session()
3073 DEBUG2(ql4_printk(KERN_INFO, ha, in qla4xxx_match_fwdb_session()
3084 struct scsi_qla_host *ha; in qla4xxx_session_create() local
3097 ha = to_qla_host(qla_ep->host); in qla4xxx_session_create()
3098 DEBUG2(ql4_printk(KERN_INFO, ha, "%s: host: %ld\n", __func__, in qla4xxx_session_create()
3099 ha->host_no)); in qla4xxx_session_create()
3101 ret = qla4xxx_get_ddb_index(ha, &ddb_index); in qla4xxx_session_create()
3116 ddb_entry->ha = ha; in qla4xxx_session_create()
3122 ha->fw_ddb_index_map[ddb_entry->fw_ddb_index] = ddb_entry; in qla4xxx_session_create()
3123 ha->tot_ddbs++; in qla4xxx_session_create()
3132 struct scsi_qla_host *ha; in qla4xxx_session_destroy() local
3141 ha = ddb_entry->ha; in qla4xxx_session_destroy()
3142 DEBUG2(ql4_printk(KERN_INFO, ha, "%s: host: %ld\n", __func__, in qla4xxx_session_destroy()
3143 ha->host_no)); in qla4xxx_session_destroy()
3145 fw_ddb_entry = dma_alloc_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry), in qla4xxx_session_destroy()
3148 ql4_printk(KERN_ERR, ha, in qla4xxx_session_destroy()
3155 ret = qla4xxx_get_fwddb_entry(ha, ddb_entry->fw_ddb_index, in qla4xxx_session_destroy()
3170 qla4xxx_clear_ddb_entry(ha, ddb_entry->fw_ddb_index); in qla4xxx_session_destroy()
3172 clear_bit(ddb_entry->fw_ddb_index, ha->ddb_idx_map); in qla4xxx_session_destroy()
3173 spin_lock_irqsave(&ha->hardware_lock, flags); in qla4xxx_session_destroy()
3174 qla4xxx_free_ddb(ha, ddb_entry); in qla4xxx_session_destroy()
3175 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla4xxx_session_destroy()
3180 dma_free_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry), in qla4xxx_session_destroy()
3190 struct scsi_qla_host *ha; in qla4xxx_conn_create() local
3204 ha = ddb_entry->ha; in qla4xxx_conn_create()
3205 DEBUG2(ql4_printk(KERN_INFO, ha, "%s: conn_idx = %u\n", __func__, in qla4xxx_conn_create()
3218 struct scsi_qla_host *ha; in qla4xxx_conn_bind() local
3223 ha = ddb_entry->ha; in qla4xxx_conn_bind()
3225 DEBUG2(ql4_printk(KERN_INFO, ha, "%s: sid = %d, cid = %d\n", __func__, in qla4xxx_conn_bind()
3245 struct scsi_qla_host *ha; in qla4xxx_conn_start() local
3254 ha = ddb_entry->ha; in qla4xxx_conn_start()
3255 DEBUG2(ql4_printk(KERN_INFO, ha, "%s: sid = %d, cid = %d\n", __func__, in qla4xxx_conn_start()
3262 ret = qla4xxx_match_fwdb_session(ha, cls_conn); in qla4xxx_conn_start()
3264 ql4_printk(KERN_INFO, ha, in qla4xxx_conn_start()
3270 fw_ddb_entry = dma_alloc_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry), in qla4xxx_conn_start()
3273 ql4_printk(KERN_ERR, ha, in qla4xxx_conn_start()
3279 ret = qla4xxx_set_param_ddbentry(ha, ddb_entry, cls_conn, &mbx_sts); in qla4xxx_conn_start()
3293 ql4_printk(KERN_ERR, ha, "%s: Failed set param for index[%d]\n", in qla4xxx_conn_start()
3298 status = qla4xxx_conn_open(ha, ddb_entry->fw_ddb_index); in qla4xxx_conn_start()
3300 ql4_printk(KERN_ERR, ha, "%s: Login failed: %s\n", __func__, in qla4xxx_conn_start()
3317 dma_free_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry), in qla4xxx_conn_start()
3326 struct scsi_qla_host *ha; in qla4xxx_conn_destroy() local
3332 ha = ddb_entry->ha; in qla4xxx_conn_destroy()
3333 DEBUG2(ql4_printk(KERN_INFO, ha, "%s: cid = %d\n", __func__, in qla4xxx_conn_destroy()
3337 if (qla4xxx_session_logout_ddb(ha, ddb_entry, options) == QLA_ERROR) in qla4xxx_conn_destroy()
3338 ql4_printk(KERN_ERR, ha, "%s: Logout failed\n", __func__); in qla4xxx_conn_destroy()
3344 struct scsi_qla_host *ha; in qla4xxx_task_work() local
3355 ha = task_data->ha; in qla4xxx_task_work()
3378 ql4_printk(KERN_ERR, ha, "Passthru failed status = 0x%x\n", in qla4xxx_task_work()
3390 struct scsi_qla_host *ha; in qla4xxx_alloc_pdu() local
3395 ha = ddb_entry->ha; in qla4xxx_alloc_pdu()
3400 ql4_printk(KERN_INFO, ha, in qla4xxx_alloc_pdu()
3406 task_data->ha = ha; in qla4xxx_alloc_pdu()
3410 task_data->data_dma = dma_map_single(&ha->pdev->dev, task->data, in qla4xxx_alloc_pdu()
3415 DEBUG2(ql4_printk(KERN_INFO, ha, "%s: MaxRecvLen %u, iscsi hrd %d\n", in qla4xxx_alloc_pdu()
3419 task_data->resp_buffer = dma_alloc_coherent(&ha->pdev->dev, in qla4xxx_alloc_pdu()
3427 task_data->req_buffer = dma_alloc_coherent(&ha->pdev->dev, in qla4xxx_alloc_pdu()
3442 dma_free_coherent(&ha->pdev->dev, task_data->resp_len, in qla4xxx_alloc_pdu()
3446 dma_free_coherent(&ha->pdev->dev, task_data->req_len, in qla4xxx_alloc_pdu()
3456 struct scsi_qla_host *ha; in qla4xxx_task_cleanup() local
3462 ha = ddb_entry->ha; in qla4xxx_task_cleanup()
3466 dma_unmap_single(&ha->pdev->dev, task_data->data_dma, in qla4xxx_task_cleanup()
3470 DEBUG2(ql4_printk(KERN_INFO, ha, "%s: MaxRecvLen %u, iscsi hrd %d\n", in qla4xxx_task_cleanup()
3473 dma_free_coherent(&ha->pdev->dev, task_data->resp_len, in qla4xxx_task_cleanup()
3475 dma_free_coherent(&ha->pdev->dev, task_data->req_len, in qla4xxx_task_cleanup()
3485 struct scsi_qla_host *ha = ddb_entry->ha; in qla4xxx_task_xmit() local
3490 ql4_printk(KERN_INFO, ha, "%s: scsi cmd xmit not implemented\n", in qla4xxx_task_xmit()
3843 static void qla4xxx_copy_fwddb_param(struct scsi_qla_host *ha, in qla4xxx_copy_fwddb_param() argument
3885 (char *)ha->name_string, buflen); in qla4xxx_copy_fwddb_param()
3888 if (!qla4xxx_get_uni_chap_at_index(ha, chap_tbl.name, in qla4xxx_copy_fwddb_param()
3901 void qla4xxx_update_session_conn_fwddb_param(struct scsi_qla_host *ha, in qla4xxx_update_session_conn_fwddb_param() argument
3910 fw_ddb_entry = dma_alloc_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry), in qla4xxx_update_session_conn_fwddb_param()
3913 ql4_printk(KERN_ERR, ha, in qla4xxx_update_session_conn_fwddb_param()
3918 if (qla4xxx_get_fwddb_entry(ha, ddb_entry->fw_ddb_index, fw_ddb_entry, in qla4xxx_update_session_conn_fwddb_param()
3921 DEBUG2(ql4_printk(KERN_ERR, ha, "scsi%ld: %s: failed " in qla4xxx_update_session_conn_fwddb_param()
3923 ha->host_no, __func__, in qla4xxx_update_session_conn_fwddb_param()
3933 qla4xxx_copy_fwddb_param(ha, fw_ddb_entry, cls_sess, cls_conn); in qla4xxx_update_session_conn_fwddb_param()
3937 dma_free_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry), in qla4xxx_update_session_conn_fwddb_param()
3941 void qla4xxx_update_session_conn_param(struct scsi_qla_host *ha, in qla4xxx_update_session_conn_param() argument
3952 fw_ddb_entry = dma_alloc_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry), in qla4xxx_update_session_conn_param()
3955 ql4_printk(KERN_ERR, ha, in qla4xxx_update_session_conn_param()
3960 if (qla4xxx_get_fwddb_entry(ha, ddb_entry->fw_ddb_index, fw_ddb_entry, in qla4xxx_update_session_conn_param()
3963 DEBUG2(ql4_printk(KERN_ERR, ha, "scsi%ld: %s: failed " in qla4xxx_update_session_conn_param()
3965 ha->host_no, __func__, in qla4xxx_update_session_conn_param()
3988 memcpy(sess->initiatorname, ha->name_string, in qla4xxx_update_session_conn_param()
3989 min(sizeof(ha->name_string), sizeof(sess->initiatorname))); in qla4xxx_update_session_conn_param()
3993 dma_free_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry), in qla4xxx_update_session_conn_param()
4002 static void qla4xxx_start_timer(struct scsi_qla_host *ha, in qla4xxx_start_timer() argument
4006 __func__, ha->host->host_no)); in qla4xxx_start_timer()
4007 timer_setup(&ha->timer, qla4xxx_timer, 0); in qla4xxx_start_timer()
4008 ha->timer.expires = jiffies + interval * HZ; in qla4xxx_start_timer()
4009 add_timer(&ha->timer); in qla4xxx_start_timer()
4010 ha->timer_active = 1; in qla4xxx_start_timer()
4013 static void qla4xxx_stop_timer(struct scsi_qla_host *ha) in qla4xxx_stop_timer() argument
4015 del_timer_sync(&ha->timer); in qla4xxx_stop_timer()
4016 ha->timer_active = 0; in qla4xxx_stop_timer()
4037 void qla4xxx_mark_all_devices_missing(struct scsi_qla_host *ha) in qla4xxx_mark_all_devices_missing() argument
4039 iscsi_host_for_each_session(ha->host, qla4xxx_mark_device_missing); in qla4xxx_mark_all_devices_missing()
4042 static struct srb* qla4xxx_get_new_srb(struct scsi_qla_host *ha, in qla4xxx_get_new_srb() argument
4048 srb = mempool_alloc(ha->srb_mempool, GFP_ATOMIC); in qla4xxx_get_new_srb()
4053 srb->ha = ha; in qla4xxx_get_new_srb()
4062 static void qla4xxx_srb_free_dma(struct scsi_qla_host *ha, struct srb *srb) in qla4xxx_srb_free_dma() argument
4077 struct scsi_qla_host *ha = srb->ha; in qla4xxx_srb_compl() local
4079 qla4xxx_srb_free_dma(ha, srb); in qla4xxx_srb_compl()
4081 mempool_free(srb, ha->srb_mempool); in qla4xxx_srb_compl()
4101 struct scsi_qla_host *ha = to_qla_host(host); in qla4xxx_queuecommand() local
4107 if (test_bit(AF_EEH_BUSY, &ha->flags)) { in qla4xxx_queuecommand()
4108 if (test_bit(AF_PCI_CHANNEL_IO_PERM_FAILURE, &ha->flags)) in qla4xxx_queuecommand()
4126 if (test_bit(DPC_RESET_HA_INTR, &ha->dpc_flags) || in qla4xxx_queuecommand()
4127 test_bit(DPC_RESET_ACTIVE, &ha->dpc_flags) || in qla4xxx_queuecommand()
4128 test_bit(DPC_RESET_HA, &ha->dpc_flags) || in qla4xxx_queuecommand()
4129 test_bit(DPC_HA_UNRECOVERABLE, &ha->dpc_flags) || in qla4xxx_queuecommand()
4130 test_bit(DPC_HA_NEED_QUIESCENT, &ha->dpc_flags) || in qla4xxx_queuecommand()
4131 !test_bit(AF_ONLINE, &ha->flags) || in qla4xxx_queuecommand()
4132 !test_bit(AF_LINK_UP, &ha->flags) || in qla4xxx_queuecommand()
4133 test_bit(AF_LOOPBACK, &ha->flags) || in qla4xxx_queuecommand()
4134 test_bit(DPC_POST_IDC_ACK, &ha->dpc_flags) || in qla4xxx_queuecommand()
4135 test_bit(DPC_RESTORE_ACB, &ha->dpc_flags) || in qla4xxx_queuecommand()
4136 test_bit(DPC_RESET_HA_FW_CONTEXT, &ha->dpc_flags)) in qla4xxx_queuecommand()
4139 srb = qla4xxx_get_new_srb(ha, ddb_entry, cmd); in qla4xxx_queuecommand()
4143 rval = qla4xxx_send_command_to_isp(ha, srb); in qla4xxx_queuecommand()
4150 qla4xxx_srb_free_dma(ha, srb); in qla4xxx_queuecommand()
4151 mempool_free(srb, ha->srb_mempool); in qla4xxx_queuecommand()
4168 static void qla4xxx_mem_free(struct scsi_qla_host *ha) in qla4xxx_mem_free() argument
4170 if (ha->queues) in qla4xxx_mem_free()
4171 dma_free_coherent(&ha->pdev->dev, ha->queues_len, ha->queues, in qla4xxx_mem_free()
4172 ha->queues_dma); in qla4xxx_mem_free()
4174 vfree(ha->fw_dump); in qla4xxx_mem_free()
4176 ha->queues_len = 0; in qla4xxx_mem_free()
4177 ha->queues = NULL; in qla4xxx_mem_free()
4178 ha->queues_dma = 0; in qla4xxx_mem_free()
4179 ha->request_ring = NULL; in qla4xxx_mem_free()
4180 ha->request_dma = 0; in qla4xxx_mem_free()
4181 ha->response_ring = NULL; in qla4xxx_mem_free()
4182 ha->response_dma = 0; in qla4xxx_mem_free()
4183 ha->shadow_regs = NULL; in qla4xxx_mem_free()
4184 ha->shadow_regs_dma = 0; in qla4xxx_mem_free()
4185 ha->fw_dump = NULL; in qla4xxx_mem_free()
4186 ha->fw_dump_size = 0; in qla4xxx_mem_free()
4189 mempool_destroy(ha->srb_mempool); in qla4xxx_mem_free()
4190 ha->srb_mempool = NULL; in qla4xxx_mem_free()
4192 dma_pool_destroy(ha->chap_dma_pool); in qla4xxx_mem_free()
4194 vfree(ha->chap_list); in qla4xxx_mem_free()
4195 ha->chap_list = NULL; in qla4xxx_mem_free()
4197 dma_pool_destroy(ha->fw_ddb_dma_pool); in qla4xxx_mem_free()
4200 if (is_qla8022(ha)) { in qla4xxx_mem_free()
4201 if (ha->nx_pcibase) in qla4xxx_mem_free()
4203 (struct device_reg_82xx __iomem *)ha->nx_pcibase); in qla4xxx_mem_free()
4204 } else if (is_qla8032(ha) || is_qla8042(ha)) { in qla4xxx_mem_free()
4205 if (ha->nx_pcibase) in qla4xxx_mem_free()
4207 (struct device_reg_83xx __iomem *)ha->nx_pcibase); in qla4xxx_mem_free()
4208 } else if (ha->reg) { in qla4xxx_mem_free()
4209 iounmap(ha->reg); in qla4xxx_mem_free()
4212 vfree(ha->reset_tmplt.buff); in qla4xxx_mem_free()
4214 pci_release_regions(ha->pdev); in qla4xxx_mem_free()
4224 static int qla4xxx_mem_alloc(struct scsi_qla_host *ha) in qla4xxx_mem_alloc() argument
4229 ha->queues_len = ((REQUEST_QUEUE_DEPTH * QUEUE_SIZE) + in qla4xxx_mem_alloc()
4234 ha->queues = dma_alloc_coherent(&ha->pdev->dev, ha->queues_len, in qla4xxx_mem_alloc()
4235 &ha->queues_dma, GFP_KERNEL); in qla4xxx_mem_alloc()
4236 if (ha->queues == NULL) { in qla4xxx_mem_alloc()
4237 ql4_printk(KERN_WARNING, ha, in qla4xxx_mem_alloc()
4248 if ((unsigned long)ha->queues_dma & (MEM_ALIGN_VALUE - 1)) in qla4xxx_mem_alloc()
4249 align = MEM_ALIGN_VALUE - ((unsigned long)ha->queues_dma & in qla4xxx_mem_alloc()
4253 ha->request_dma = ha->queues_dma + align; in qla4xxx_mem_alloc()
4254 ha->request_ring = (struct queue_entry *) (ha->queues + align); in qla4xxx_mem_alloc()
4255 ha->response_dma = ha->queues_dma + align + in qla4xxx_mem_alloc()
4257 ha->response_ring = (struct queue_entry *) (ha->queues + align + in qla4xxx_mem_alloc()
4260 ha->shadow_regs_dma = ha->queues_dma + align + in qla4xxx_mem_alloc()
4263 ha->shadow_regs = (struct shadow_regs *) (ha->queues + align + in qla4xxx_mem_alloc()
4270 ha->srb_mempool = mempool_create(SRB_MIN_REQ, mempool_alloc_slab, in qla4xxx_mem_alloc()
4272 if (ha->srb_mempool == NULL) { in qla4xxx_mem_alloc()
4273 ql4_printk(KERN_WARNING, ha, in qla4xxx_mem_alloc()
4279 ha->chap_dma_pool = dma_pool_create("ql4_chap", &ha->pdev->dev, in qla4xxx_mem_alloc()
4282 if (ha->chap_dma_pool == NULL) { in qla4xxx_mem_alloc()
4283 ql4_printk(KERN_WARNING, ha, in qla4xxx_mem_alloc()
4288 ha->fw_ddb_dma_pool = dma_pool_create("ql4_fw_ddb", &ha->pdev->dev, in qla4xxx_mem_alloc()
4291 if (ha->fw_ddb_dma_pool == NULL) { in qla4xxx_mem_alloc()
4292 ql4_printk(KERN_WARNING, ha, in qla4xxx_mem_alloc()
4310 static int qla4_8xxx_check_temp(struct scsi_qla_host *ha) in qla4_8xxx_check_temp() argument
4315 temp = qla4_8xxx_rd_direct(ha, QLA8XXX_CRB_TEMP_STATE); in qla4_8xxx_check_temp()
4321 ql4_printk(KERN_WARNING, ha, "Device temperature %d degrees C" in qla4_8xxx_check_temp()
4326 if (ha->temperature == QLA82XX_TEMP_NORMAL) in qla4_8xxx_check_temp()
4327 ql4_printk(KERN_WARNING, ha, "Device temperature %d" in qla4_8xxx_check_temp()
4331 if (ha->temperature == QLA82XX_TEMP_WARN) in qla4_8xxx_check_temp()
4332 ql4_printk(KERN_INFO, ha, "Device temperature is" in qla4_8xxx_check_temp()
4336 ha->temperature = temp_state; in qla4_8xxx_check_temp()
4346 static int qla4_8xxx_check_fw_alive(struct scsi_qla_host *ha) in qla4_8xxx_check_fw_alive() argument
4351 fw_heartbeat_counter = qla4_8xxx_rd_direct(ha, in qla4_8xxx_check_fw_alive()
4357 ha->host_no, __func__)); in qla4_8xxx_check_fw_alive()
4361 if (ha->fw_heartbeat_counter == fw_heartbeat_counter) { in qla4_8xxx_check_fw_alive()
4362 ha->seconds_since_last_heartbeat++; in qla4_8xxx_check_fw_alive()
4364 if (ha->seconds_since_last_heartbeat == 2) { in qla4_8xxx_check_fw_alive()
4365 ha->seconds_since_last_heartbeat = 0; in qla4_8xxx_check_fw_alive()
4366 qla4_8xxx_dump_peg_reg(ha); in qla4_8xxx_check_fw_alive()
4370 ha->seconds_since_last_heartbeat = 0; in qla4_8xxx_check_fw_alive()
4372 ha->fw_heartbeat_counter = fw_heartbeat_counter; in qla4_8xxx_check_fw_alive()
4376 static void qla4_8xxx_process_fw_error(struct scsi_qla_host *ha) in qla4_8xxx_process_fw_error() argument
4381 halt_status = qla4_8xxx_rd_direct(ha, QLA8XXX_PEG_HALT_STATUS1); in qla4_8xxx_process_fw_error()
4383 if (is_qla8022(ha)) { in qla4_8xxx_process_fw_error()
4384 ql4_printk(KERN_INFO, ha, "%s: disabling pause transmit on port 0 & 1.\n", in qla4_8xxx_process_fw_error()
4386 qla4_82xx_wr_32(ha, QLA82XX_CRB_NIU + 0x98, in qla4_8xxx_process_fw_error()
4391 …ql4_printk(KERN_ERR, ha, "%s: Firmware aborted with error code 0x00006700. Device is being reset\n… in qla4_8xxx_process_fw_error()
4395 } else if (is_qla8032(ha) || is_qla8042(ha)) { in qla4_8xxx_process_fw_error()
4397 ql4_printk(KERN_ERR, ha, "%s: Firmware error detected device is being reset\n", in qla4_8xxx_process_fw_error()
4408 set_bit(DPC_HA_UNRECOVERABLE, &ha->dpc_flags); in qla4_8xxx_process_fw_error()
4410 ql4_printk(KERN_INFO, ha, "%s: detect abort needed!\n", in qla4_8xxx_process_fw_error()
4412 set_bit(DPC_RESET_HA, &ha->dpc_flags); in qla4_8xxx_process_fw_error()
4414 qla4xxx_mailbox_premature_completion(ha); in qla4_8xxx_process_fw_error()
4415 qla4xxx_wake_dpc(ha); in qla4_8xxx_process_fw_error()
4424 void qla4_8xxx_watchdog(struct scsi_qla_host *ha) in qla4_8xxx_watchdog() argument
4429 if (is_qla8032(ha) && in qla4_8xxx_watchdog()
4430 (qla4_83xx_is_detached(ha) == QLA_SUCCESS)) in qla4_8xxx_watchdog()
4432 __func__, ha->func_num); in qla4_8xxx_watchdog()
4435 if (!(test_bit(DPC_RESET_ACTIVE, &ha->dpc_flags) || in qla4_8xxx_watchdog()
4436 test_bit(DPC_RESET_HA, &ha->dpc_flags) || in qla4_8xxx_watchdog()
4437 test_bit(DPC_RETRY_RESET_HA, &ha->dpc_flags))) { in qla4_8xxx_watchdog()
4438 dev_state = qla4_8xxx_rd_direct(ha, QLA8XXX_CRB_DEV_STATE); in qla4_8xxx_watchdog()
4440 if (qla4_8xxx_check_temp(ha)) { in qla4_8xxx_watchdog()
4441 if (is_qla8022(ha)) { in qla4_8xxx_watchdog()
4442 ql4_printk(KERN_INFO, ha, "disabling pause transmit on port 0 & 1.\n"); in qla4_8xxx_watchdog()
4443 qla4_82xx_wr_32(ha, QLA82XX_CRB_NIU + 0x98, in qla4_8xxx_watchdog()
4447 set_bit(DPC_HA_UNRECOVERABLE, &ha->dpc_flags); in qla4_8xxx_watchdog()
4448 qla4xxx_wake_dpc(ha); in qla4_8xxx_watchdog()
4450 !test_bit(DPC_RESET_HA, &ha->dpc_flags)) { in qla4_8xxx_watchdog()
4452 ql4_printk(KERN_INFO, ha, "%s: HW State: NEED RESET!\n", in qla4_8xxx_watchdog()
4455 if (is_qla8032(ha) || is_qla8042(ha)) { in qla4_8xxx_watchdog()
4456 idc_ctrl = qla4_83xx_rd_reg(ha, in qla4_8xxx_watchdog()
4459 ql4_printk(KERN_INFO, ha, "%s: Graceful reset bit is not set\n", in qla4_8xxx_watchdog()
4462 ha); in qla4_8xxx_watchdog()
4466 if ((is_qla8032(ha) || is_qla8042(ha)) || in qla4_8xxx_watchdog()
4467 (is_qla8022(ha) && !ql4xdontresethba)) { in qla4_8xxx_watchdog()
4468 set_bit(DPC_RESET_HA, &ha->dpc_flags); in qla4_8xxx_watchdog()
4469 qla4xxx_wake_dpc(ha); in qla4_8xxx_watchdog()
4472 !test_bit(DPC_HA_NEED_QUIESCENT, &ha->dpc_flags)) { in qla4_8xxx_watchdog()
4473 ql4_printk(KERN_INFO, ha, "%s: HW State: NEED QUIES!\n", in qla4_8xxx_watchdog()
4475 set_bit(DPC_HA_NEED_QUIESCENT, &ha->dpc_flags); in qla4_8xxx_watchdog()
4476 qla4xxx_wake_dpc(ha); in qla4_8xxx_watchdog()
4479 if (qla4_8xxx_check_fw_alive(ha)) in qla4_8xxx_watchdog()
4480 qla4_8xxx_process_fw_error(ha); in qla4_8xxx_watchdog()
4489 struct scsi_qla_host *ha; in qla4xxx_check_relogin_flash_ddb() local
4493 ha = ddb_entry->ha; in qla4xxx_check_relogin_flash_ddb()
4498 if (adapter_up(ha) && !test_bit(DF_RELOGIN, &ddb_entry->flags) && in qla4xxx_check_relogin_flash_ddb()
4506 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags); in qla4xxx_check_relogin_flash_ddb()
4508 DEBUG2(ql4_printk(KERN_INFO, ha, in qla4xxx_check_relogin_flash_ddb()
4526 DEBUG2(ql4_printk(KERN_INFO, ha, in qla4xxx_check_relogin_flash_ddb()
4532 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags); in qla4xxx_check_relogin_flash_ddb()
4545 struct scsi_qla_host *ha = from_timer(ha, t, timer); in qla4xxx_timer() local
4549 iscsi_host_for_each_session(ha->host, qla4xxx_check_relogin_flash_ddb); in qla4xxx_timer()
4554 if (test_bit(AF_EEH_BUSY, &ha->flags)) { in qla4xxx_timer()
4555 mod_timer(&ha->timer, jiffies + HZ); in qla4xxx_timer()
4560 if (!pci_channel_offline(ha->pdev)) in qla4xxx_timer()
4561 pci_read_config_word(ha->pdev, PCI_VENDOR_ID, &w); in qla4xxx_timer()
4563 if (is_qla80XX(ha)) in qla4xxx_timer()
4564 qla4_8xxx_watchdog(ha); in qla4xxx_timer()
4566 if (is_qla40XX(ha)) { in qla4xxx_timer()
4568 if (ha->firmware_options & FWOPT_HEARTBEAT_ENABLE && in qla4xxx_timer()
4569 ha->heartbeat_interval != 0) { in qla4xxx_timer()
4570 ha->seconds_since_last_heartbeat++; in qla4xxx_timer()
4571 if (ha->seconds_since_last_heartbeat > in qla4xxx_timer()
4572 ha->heartbeat_interval + 2) in qla4xxx_timer()
4573 set_bit(DPC_RESET_HA, &ha->dpc_flags); in qla4xxx_timer()
4578 if (!list_empty(&ha->work_list)) in qla4xxx_timer()
4583 test_bit(DPC_RESET_HA, &ha->dpc_flags) || in qla4xxx_timer()
4584 test_bit(DPC_RETRY_RESET_HA, &ha->dpc_flags) || in qla4xxx_timer()
4585 test_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags) || in qla4xxx_timer()
4586 test_bit(DPC_RESET_HA_FW_CONTEXT, &ha->dpc_flags) || in qla4xxx_timer()
4587 test_bit(DPC_RESET_HA_INTR, &ha->dpc_flags) || in qla4xxx_timer()
4588 test_bit(DPC_GET_DHCP_IP_ADDR, &ha->dpc_flags) || in qla4xxx_timer()
4589 test_bit(DPC_LINK_CHANGED, &ha->dpc_flags) || in qla4xxx_timer()
4590 test_bit(DPC_HA_UNRECOVERABLE, &ha->dpc_flags) || in qla4xxx_timer()
4591 test_bit(DPC_HA_NEED_QUIESCENT, &ha->dpc_flags) || in qla4xxx_timer()
4592 test_bit(DPC_SYSFS_DDB_EXPORT, &ha->dpc_flags) || in qla4xxx_timer()
4593 test_bit(DPC_AEN, &ha->dpc_flags)) { in qla4xxx_timer()
4596 ha->host_no, __func__, ha->dpc_flags)); in qla4xxx_timer()
4597 qla4xxx_wake_dpc(ha); in qla4xxx_timer()
4601 mod_timer(&ha->timer, jiffies + HZ); in qla4xxx_timer()
4603 DEBUG2(ha->seconds_since_last_intr++); in qla4xxx_timer()
4613 static int qla4xxx_cmd_wait(struct scsi_qla_host *ha) in qla4xxx_cmd_wait() argument
4621 if (is_qla40XX(ha)) in qla4xxx_cmd_wait()
4624 wtmo = ha->nx_reset_timeout / 2; in qla4xxx_cmd_wait()
4628 DEBUG2(ql4_printk(KERN_INFO, ha, in qla4xxx_cmd_wait()
4633 spin_lock_irqsave(&ha->hardware_lock, flags); in qla4xxx_cmd_wait()
4635 for (index = 0; index < ha->host->can_queue; index++) { in qla4xxx_cmd_wait()
4636 cmd = scsi_host_find_tag(ha->host, index); in qla4xxx_cmd_wait()
4646 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla4xxx_cmd_wait()
4649 if (index == ha->host->can_queue) in qla4xxx_cmd_wait()
4659 int qla4xxx_hw_reset(struct scsi_qla_host *ha) in qla4xxx_hw_reset() argument
4664 DEBUG2(printk(KERN_ERR "scsi%ld: %s\n", ha->host_no, __func__)); in qla4xxx_hw_reset()
4666 if (ql4xxx_lock_drvr_wait(ha) != QLA_SUCCESS) in qla4xxx_hw_reset()
4669 spin_lock_irqsave(&ha->hardware_lock, flags); in qla4xxx_hw_reset()
4675 ctrl_status = readw(&ha->reg->ctrl_status); in qla4xxx_hw_reset()
4677 writel(set_rmask(CSR_SCSI_RESET_INTR), &ha->reg->ctrl_status); in qla4xxx_hw_reset()
4680 writel(set_rmask(CSR_SOFT_RESET), &ha->reg->ctrl_status); in qla4xxx_hw_reset()
4681 readl(&ha->reg->ctrl_status); in qla4xxx_hw_reset()
4683 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla4xxx_hw_reset()
4691 int qla4xxx_soft_reset(struct scsi_qla_host *ha) in qla4xxx_soft_reset() argument
4698 status = qla4xxx_hw_reset(ha); in qla4xxx_soft_reset()
4706 spin_lock_irqsave(&ha->hardware_lock, flags); in qla4xxx_soft_reset()
4707 ctrl_status = readw(&ha->reg->ctrl_status); in qla4xxx_soft_reset()
4708 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla4xxx_soft_reset()
4720 ha->host_no)); in qla4xxx_soft_reset()
4721 spin_lock_irqsave(&ha->hardware_lock, flags); in qla4xxx_soft_reset()
4722 writel(set_rmask(CSR_NET_RESET_INTR), &ha->reg->ctrl_status); in qla4xxx_soft_reset()
4723 readl(&ha->reg->ctrl_status); in qla4xxx_soft_reset()
4724 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla4xxx_soft_reset()
4730 spin_lock_irqsave(&ha->hardware_lock, flags); in qla4xxx_soft_reset()
4731 ctrl_status = readw(&ha->reg->ctrl_status); in qla4xxx_soft_reset()
4732 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla4xxx_soft_reset()
4746 spin_lock_irqsave(&ha->hardware_lock, flags); in qla4xxx_soft_reset()
4747 ctrl_status = readw(&ha->reg->ctrl_status); in qla4xxx_soft_reset()
4749 writel(set_rmask(CSR_SCSI_RESET_INTR), &ha->reg->ctrl_status); in qla4xxx_soft_reset()
4750 readl(&ha->reg->ctrl_status); in qla4xxx_soft_reset()
4752 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla4xxx_soft_reset()
4762 spin_lock_irqsave(&ha->hardware_lock, flags); in qla4xxx_soft_reset()
4763 writel(set_rmask(CSR_FORCE_SOFT_RESET), &ha->reg->ctrl_status); in qla4xxx_soft_reset()
4764 readl(&ha->reg->ctrl_status); in qla4xxx_soft_reset()
4765 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla4xxx_soft_reset()
4769 spin_lock_irqsave(&ha->hardware_lock, flags); in qla4xxx_soft_reset()
4770 ctrl_status = readw(&ha->reg->ctrl_status); in qla4xxx_soft_reset()
4771 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla4xxx_soft_reset()
4795 static void qla4xxx_abort_active_cmds(struct scsi_qla_host *ha, int res) in qla4xxx_abort_active_cmds() argument
4801 spin_lock_irqsave(&ha->hardware_lock, flags); in qla4xxx_abort_active_cmds()
4802 for (i = 0; i < ha->host->can_queue; i++) { in qla4xxx_abort_active_cmds()
4803 srb = qla4xxx_del_from_active_array(ha, i); in qla4xxx_abort_active_cmds()
4809 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla4xxx_abort_active_cmds()
4812 void qla4xxx_dead_adapter_cleanup(struct scsi_qla_host *ha) in qla4xxx_dead_adapter_cleanup() argument
4814 clear_bit(AF_ONLINE, &ha->flags); in qla4xxx_dead_adapter_cleanup()
4817 ql4_printk(KERN_INFO, ha, "Disabling the board\n"); in qla4xxx_dead_adapter_cleanup()
4819 qla4xxx_abort_active_cmds(ha, DID_NO_CONNECT << 16); in qla4xxx_dead_adapter_cleanup()
4820 qla4xxx_mark_all_devices_missing(ha); in qla4xxx_dead_adapter_cleanup()
4821 clear_bit(AF_INIT_DONE, &ha->flags); in qla4xxx_dead_adapter_cleanup()
4844 static int qla4xxx_recover_adapter(struct scsi_qla_host *ha) in qla4xxx_recover_adapter() argument
4852 scsi_block_requests(ha->host); in qla4xxx_recover_adapter()
4853 clear_bit(AF_ONLINE, &ha->flags); in qla4xxx_recover_adapter()
4854 clear_bit(AF_LINK_UP, &ha->flags); in qla4xxx_recover_adapter()
4856 DEBUG2(ql4_printk(KERN_INFO, ha, "%s: adapter OFFLINE\n", __func__)); in qla4xxx_recover_adapter()
4858 set_bit(DPC_RESET_ACTIVE, &ha->dpc_flags); in qla4xxx_recover_adapter()
4860 if ((is_qla8032(ha) || is_qla8042(ha)) && in qla4xxx_recover_adapter()
4861 !test_bit(DPC_RESET_HA_FW_CONTEXT, &ha->dpc_flags)) { in qla4xxx_recover_adapter()
4862 ql4_printk(KERN_INFO, ha, "%s: disabling pause transmit on port 0 & 1.\n", in qla4xxx_recover_adapter()
4865 qla4_83xx_disable_pause(ha); in qla4xxx_recover_adapter()
4868 iscsi_host_for_each_session(ha->host, qla4xxx_fail_session); in qla4xxx_recover_adapter()
4870 if (test_bit(DPC_RESET_HA, &ha->dpc_flags)) in qla4xxx_recover_adapter()
4875 if (test_bit(DPC_RESET_HA_INTR, &ha->dpc_flags)) { in qla4xxx_recover_adapter()
4882 if (is_qla80XX(ha) && !reset_chip && in qla4xxx_recover_adapter()
4883 test_bit(DPC_RESET_HA_FW_CONTEXT, &ha->dpc_flags)) { in qla4xxx_recover_adapter()
4885 DEBUG2(ql4_printk(KERN_INFO, ha, in qla4xxx_recover_adapter()
4887 ha->host_no, __func__)); in qla4xxx_recover_adapter()
4888 status = ha->isp_ops->reset_firmware(ha); in qla4xxx_recover_adapter()
4890 ha->isp_ops->disable_intrs(ha); in qla4xxx_recover_adapter()
4891 qla4xxx_process_aen(ha, FLUSH_DDB_CHANGED_AENS); in qla4xxx_recover_adapter()
4892 qla4xxx_abort_active_cmds(ha, DID_RESET << 16); in qla4xxx_recover_adapter()
4897 clear_bit(DPC_RESET_HA_FW_CONTEXT, &ha->dpc_flags); in qla4xxx_recover_adapter()
4898 set_bit(DPC_RESET_HA, &ha->dpc_flags); in qla4xxx_recover_adapter()
4905 if (is_qla40XX(ha) || reset_chip) { in qla4xxx_recover_adapter()
4906 if (is_qla40XX(ha)) in qla4xxx_recover_adapter()
4912 if (test_bit(AF_FW_RECOVERY, &ha->flags)) in qla4xxx_recover_adapter()
4917 if (qla4_8xxx_check_fw_alive(ha)) { in qla4xxx_recover_adapter()
4918 qla4xxx_mailbox_premature_completion(ha); in qla4xxx_recover_adapter()
4926 if (!test_bit(AF_FW_RECOVERY, &ha->flags)) in qla4xxx_recover_adapter()
4927 qla4xxx_cmd_wait(ha); in qla4xxx_recover_adapter()
4929 qla4xxx_process_aen(ha, FLUSH_DDB_CHANGED_AENS); in qla4xxx_recover_adapter()
4930 DEBUG2(ql4_printk(KERN_INFO, ha, in qla4xxx_recover_adapter()
4932 ha->host_no, __func__)); in qla4xxx_recover_adapter()
4933 status = ha->isp_ops->reset_chip(ha); in qla4xxx_recover_adapter()
4934 qla4xxx_abort_active_cmds(ha, DID_RESET << 16); in qla4xxx_recover_adapter()
4938 qla4xxx_process_aen(ha, FLUSH_DDB_CHANGED_AENS); in qla4xxx_recover_adapter()
4946 if (is_qla40XX(ha) && (ha->mac_index == 3)) in qla4xxx_recover_adapter()
4951 status = qla4xxx_initialize_adapter(ha, RESET_ADAPTER); in qla4xxx_recover_adapter()
4952 if (is_qla80XX(ha) && (status == QLA_ERROR)) { in qla4xxx_recover_adapter()
4953 status = qla4_8xxx_check_init_adapter_retry(ha); in qla4xxx_recover_adapter()
4955 ql4_printk(KERN_INFO, ha, "scsi%ld: %s: Don't retry recover adapter\n", in qla4xxx_recover_adapter()
4956 ha->host_no, __func__); in qla4xxx_recover_adapter()
4957 qla4xxx_dead_adapter_cleanup(ha); in qla4xxx_recover_adapter()
4958 clear_bit(DPC_RETRY_RESET_HA, &ha->dpc_flags); in qla4xxx_recover_adapter()
4959 clear_bit(DPC_RESET_HA, &ha->dpc_flags); in qla4xxx_recover_adapter()
4961 &ha->dpc_flags); in qla4xxx_recover_adapter()
4970 if (!test_bit(AF_ONLINE, &ha->flags) && in qla4xxx_recover_adapter()
4971 !test_bit(DPC_RESET_HA_INTR, &ha->dpc_flags)) { in qla4xxx_recover_adapter()
4977 if (is_qla80XX(ha)) { in qla4xxx_recover_adapter()
4978 ha->isp_ops->idc_lock(ha); in qla4xxx_recover_adapter()
4979 dev_state = qla4_8xxx_rd_direct(ha, in qla4xxx_recover_adapter()
4981 ha->isp_ops->idc_unlock(ha); in qla4xxx_recover_adapter()
4983 ql4_printk(KERN_INFO, ha, "%s: don't retry " in qla4xxx_recover_adapter()
4986 qla4xxx_dead_adapter_cleanup(ha); in qla4xxx_recover_adapter()
4987 clear_bit(DPC_RETRY_RESET_HA, &ha->dpc_flags); in qla4xxx_recover_adapter()
4988 clear_bit(DPC_RESET_HA, &ha->dpc_flags); in qla4xxx_recover_adapter()
4990 &ha->dpc_flags); in qla4xxx_recover_adapter()
4997 if (!test_bit(DPC_RETRY_RESET_HA, &ha->dpc_flags)) { in qla4xxx_recover_adapter()
4998 ha->retry_reset_ha_cnt = MAX_RESET_HA_RETRIES; in qla4xxx_recover_adapter()
5000 "(%d) more times\n", ha->host_no, in qla4xxx_recover_adapter()
5001 ha->retry_reset_ha_cnt)); in qla4xxx_recover_adapter()
5002 set_bit(DPC_RETRY_RESET_HA, &ha->dpc_flags); in qla4xxx_recover_adapter()
5005 if (ha->retry_reset_ha_cnt > 0) { in qla4xxx_recover_adapter()
5007 ha->retry_reset_ha_cnt--; in qla4xxx_recover_adapter()
5010 ha->host_no, in qla4xxx_recover_adapter()
5011 ha->retry_reset_ha_cnt)); in qla4xxx_recover_adapter()
5015 if (ha->retry_reset_ha_cnt == 0) { in qla4xxx_recover_adapter()
5020 ha->host_no)); in qla4xxx_recover_adapter()
5021 qla4xxx_dead_adapter_cleanup(ha); in qla4xxx_recover_adapter()
5022 clear_bit(DPC_RETRY_RESET_HA, &ha->dpc_flags); in qla4xxx_recover_adapter()
5023 clear_bit(DPC_RESET_HA, &ha->dpc_flags); in qla4xxx_recover_adapter()
5025 &ha->dpc_flags); in qla4xxx_recover_adapter()
5030 clear_bit(DPC_RESET_HA, &ha->dpc_flags); in qla4xxx_recover_adapter()
5031 clear_bit(DPC_RESET_HA_FW_CONTEXT, &ha->dpc_flags); in qla4xxx_recover_adapter()
5032 clear_bit(DPC_RETRY_RESET_HA, &ha->dpc_flags); in qla4xxx_recover_adapter()
5036 ha->adapter_error_count++; in qla4xxx_recover_adapter()
5038 if (test_bit(AF_ONLINE, &ha->flags)) in qla4xxx_recover_adapter()
5039 ha->isp_ops->enable_intrs(ha); in qla4xxx_recover_adapter()
5041 scsi_unblock_requests(ha->host); in qla4xxx_recover_adapter()
5043 clear_bit(DPC_RESET_ACTIVE, &ha->dpc_flags); in qla4xxx_recover_adapter()
5044 DEBUG2(printk("scsi%ld: recover adapter: %s\n", ha->host_no, in qla4xxx_recover_adapter()
5054 struct scsi_qla_host *ha; in qla4xxx_relogin_devices() local
5058 ha = ddb_entry->ha; in qla4xxx_relogin_devices()
5061 ql4_printk(KERN_INFO, ha, "scsi%ld: %s: ddb[%d]" in qla4xxx_relogin_devices()
5062 " unblock session\n", ha->host_no, __func__, in qla4xxx_relogin_devices()
5083 struct scsi_qla_host *ha; in qla4xxx_unblock_flash_ddb() local
5087 ha = ddb_entry->ha; in qla4xxx_unblock_flash_ddb()
5088 ql4_printk(KERN_INFO, ha, "scsi%ld: %s: ddb[%d]" in qla4xxx_unblock_flash_ddb()
5089 " unblock session\n", ha->host_no, __func__, in qla4xxx_unblock_flash_ddb()
5095 if (test_bit(AF_ONLINE, &ha->flags)) { in qla4xxx_unblock_flash_ddb()
5096 ql4_printk(KERN_INFO, ha, "scsi%ld: %s: ddb[%d]" in qla4xxx_unblock_flash_ddb()
5097 " start scan\n", ha->host_no, __func__, in qla4xxx_unblock_flash_ddb()
5099 scsi_queue_work(ha->host, &ddb_entry->sess->scan_work); in qla4xxx_unblock_flash_ddb()
5108 struct scsi_qla_host *ha; in qla4xxx_unblock_ddb() local
5113 ha = ddb_entry->ha; in qla4xxx_unblock_ddb()
5114 ql4_printk(KERN_INFO, ha, "scsi%ld: %s: ddb[%d]" in qla4xxx_unblock_ddb()
5115 " unblock user space session\n", ha->host_no, __func__, in qla4xxx_unblock_ddb()
5123 ql4_printk(KERN_INFO, ha, in qla4xxx_unblock_ddb()
5125 ha->host_no, __func__, ddb_entry->fw_ddb_index, in qla4xxx_unblock_ddb()
5133 static void qla4xxx_relogin_all_devices(struct scsi_qla_host *ha) in qla4xxx_relogin_all_devices() argument
5135 iscsi_host_for_each_session(ha->host, qla4xxx_relogin_devices); in qla4xxx_relogin_all_devices()
5143 struct scsi_qla_host *ha; in qla4xxx_relogin_flash_ddb() local
5147 ha = ddb_entry->ha; in qla4xxx_relogin_flash_ddb()
5153 DEBUG2(ql4_printk(KERN_INFO, ha, in qla4xxx_relogin_flash_ddb()
5154 "scsi%ld: Relogin index [%d]. TOV=%d\n", ha->host_no, in qla4xxx_relogin_flash_ddb()
5164 struct scsi_qla_host *ha; in qla4xxx_dpc_relogin() local
5168 ha = ddb_entry->ha; in qla4xxx_dpc_relogin()
5178 DEBUG2(ql4_printk(KERN_INFO, ha, in qla4xxx_dpc_relogin()
5184 void qla4xxx_wake_dpc(struct scsi_qla_host *ha) in qla4xxx_wake_dpc() argument
5186 if (ha->dpc_thread) in qla4xxx_wake_dpc()
5187 queue_work(ha->dpc_thread, &ha->dpc_work); in qla4xxx_wake_dpc()
5191 qla4xxx_alloc_work(struct scsi_qla_host *ha, uint32_t data_size, in qla4xxx_alloc_work() argument
5206 static void qla4xxx_post_work(struct scsi_qla_host *ha, in qla4xxx_post_work() argument
5211 spin_lock_irqsave(&ha->work_lock, flags); in qla4xxx_post_work()
5212 list_add_tail(&e->list, &ha->work_list); in qla4xxx_post_work()
5213 spin_unlock_irqrestore(&ha->work_lock, flags); in qla4xxx_post_work()
5214 qla4xxx_wake_dpc(ha); in qla4xxx_post_work()
5217 int qla4xxx_post_aen_work(struct scsi_qla_host *ha, in qla4xxx_post_aen_work() argument
5223 e = qla4xxx_alloc_work(ha, data_size, QLA4_EVENT_AEN); in qla4xxx_post_aen_work()
5231 qla4xxx_post_work(ha, e); in qla4xxx_post_aen_work()
5236 int qla4xxx_post_ping_evt_work(struct scsi_qla_host *ha, in qla4xxx_post_ping_evt_work() argument
5242 e = qla4xxx_alloc_work(ha, data_size, QLA4_EVENT_PING_STATUS); in qla4xxx_post_ping_evt_work()
5251 qla4xxx_post_work(ha, e); in qla4xxx_post_ping_evt_work()
5256 static void qla4xxx_do_work(struct scsi_qla_host *ha) in qla4xxx_do_work() argument
5262 spin_lock_irqsave(&ha->work_lock, flags); in qla4xxx_do_work()
5263 list_splice_init(&ha->work_list, &work); in qla4xxx_do_work()
5264 spin_unlock_irqrestore(&ha->work_lock, flags); in qla4xxx_do_work()
5271 iscsi_post_host_event(ha->host_no, in qla4xxx_do_work()
5278 iscsi_ping_comp_event(ha->host_no, in qla4xxx_do_work()
5286 ql4_printk(KERN_WARNING, ha, "event type: 0x%x not " in qla4xxx_do_work()
5306 struct scsi_qla_host *ha = in qla4xxx_do_dpc() local
5310 DEBUG2(ql4_printk(KERN_INFO, ha, in qla4xxx_do_dpc()
5312 ha->host_no, __func__, ha->flags, ha->dpc_flags)); in qla4xxx_do_dpc()
5315 if (!test_bit(AF_INIT_DONE, &ha->flags)) in qla4xxx_do_dpc()
5318 if (test_bit(AF_EEH_BUSY, &ha->flags)) { in qla4xxx_do_dpc()
5320 ha->host_no, __func__, ha->flags)); in qla4xxx_do_dpc()
5325 qla4xxx_do_work(ha); in qla4xxx_do_dpc()
5327 if (is_qla80XX(ha)) { in qla4xxx_do_dpc()
5328 if (test_bit(DPC_HA_UNRECOVERABLE, &ha->dpc_flags)) { in qla4xxx_do_dpc()
5329 if (is_qla8032(ha) || is_qla8042(ha)) { in qla4xxx_do_dpc()
5330 ql4_printk(KERN_INFO, ha, "%s: disabling pause transmit on port 0 & 1.\n", in qla4xxx_do_dpc()
5333 qla4_83xx_disable_pause(ha); in qla4xxx_do_dpc()
5336 ha->isp_ops->idc_lock(ha); in qla4xxx_do_dpc()
5337 qla4_8xxx_wr_direct(ha, QLA8XXX_CRB_DEV_STATE, in qla4xxx_do_dpc()
5339 ha->isp_ops->idc_unlock(ha); in qla4xxx_do_dpc()
5340 ql4_printk(KERN_INFO, ha, "HW State: FAILED\n"); in qla4xxx_do_dpc()
5341 qla4_8xxx_device_state_handler(ha); in qla4xxx_do_dpc()
5344 if (test_bit(DPC_POST_IDC_ACK, &ha->dpc_flags)) { in qla4xxx_do_dpc()
5345 if (is_qla8042(ha)) { in qla4xxx_do_dpc()
5346 if (ha->idc_info.info2 & in qla4xxx_do_dpc()
5348 ql4_printk(KERN_INFO, ha, "%s: Disabling ACB\n", in qla4xxx_do_dpc()
5350 status = qla4_84xx_config_acb(ha, in qla4xxx_do_dpc()
5353 ql4_printk(KERN_INFO, ha, "%s: ACB config failed\n", in qla4xxx_do_dpc()
5358 qla4_83xx_post_idc_ack(ha); in qla4xxx_do_dpc()
5359 clear_bit(DPC_POST_IDC_ACK, &ha->dpc_flags); in qla4xxx_do_dpc()
5362 if (is_qla8042(ha) && in qla4xxx_do_dpc()
5363 test_bit(DPC_RESTORE_ACB, &ha->dpc_flags)) { in qla4xxx_do_dpc()
5364 ql4_printk(KERN_INFO, ha, "%s: Restoring ACB\n", in qla4xxx_do_dpc()
5366 if (qla4_84xx_config_acb(ha, ACB_CONFIG_SET) != in qla4xxx_do_dpc()
5368 ql4_printk(KERN_INFO, ha, "%s: ACB config failed ", in qla4xxx_do_dpc()
5371 clear_bit(DPC_RESTORE_ACB, &ha->dpc_flags); in qla4xxx_do_dpc()
5374 if (test_and_clear_bit(DPC_HA_NEED_QUIESCENT, &ha->dpc_flags)) { in qla4xxx_do_dpc()
5375 qla4_8xxx_need_qsnt_handler(ha); in qla4xxx_do_dpc()
5379 if (!test_bit(DPC_RESET_ACTIVE, &ha->dpc_flags) && in qla4xxx_do_dpc()
5380 (test_bit(DPC_RESET_HA, &ha->dpc_flags) || in qla4xxx_do_dpc()
5381 test_bit(DPC_RESET_HA_INTR, &ha->dpc_flags) || in qla4xxx_do_dpc()
5382 test_bit(DPC_RESET_HA_FW_CONTEXT, &ha->dpc_flags))) { in qla4xxx_do_dpc()
5383 if ((is_qla8022(ha) && ql4xdontresethba) || in qla4xxx_do_dpc()
5384 ((is_qla8032(ha) || is_qla8042(ha)) && in qla4xxx_do_dpc()
5385 qla4_83xx_idc_dontreset(ha))) { in qla4xxx_do_dpc()
5387 ha->host_no, __func__)); in qla4xxx_do_dpc()
5388 clear_bit(DPC_RESET_HA, &ha->dpc_flags); in qla4xxx_do_dpc()
5389 clear_bit(DPC_RESET_HA_INTR, &ha->dpc_flags); in qla4xxx_do_dpc()
5390 clear_bit(DPC_RESET_HA_FW_CONTEXT, &ha->dpc_flags); in qla4xxx_do_dpc()
5393 if (test_bit(DPC_RESET_HA_FW_CONTEXT, &ha->dpc_flags) || in qla4xxx_do_dpc()
5394 test_bit(DPC_RESET_HA, &ha->dpc_flags)) in qla4xxx_do_dpc()
5395 qla4xxx_recover_adapter(ha); in qla4xxx_do_dpc()
5397 if (test_bit(DPC_RESET_HA_INTR, &ha->dpc_flags)) { in qla4xxx_do_dpc()
5400 while ((readw(&ha->reg->ctrl_status) & in qla4xxx_do_dpc()
5409 ha->host_no, __func__)); in qla4xxx_do_dpc()
5410 qla4xxx_abort_active_cmds(ha, DID_RESET << 16); in qla4xxx_do_dpc()
5411 if (ql4xxx_lock_drvr_wait(ha) == QLA_SUCCESS) { in qla4xxx_do_dpc()
5412 qla4xxx_process_aen(ha, FLUSH_DDB_CHANGED_AENS); in qla4xxx_do_dpc()
5413 status = qla4xxx_recover_adapter(ha); in qla4xxx_do_dpc()
5415 clear_bit(DPC_RESET_HA_INTR, &ha->dpc_flags); in qla4xxx_do_dpc()
5417 ha->isp_ops->enable_intrs(ha); in qla4xxx_do_dpc()
5423 if (test_and_clear_bit(DPC_AEN, &ha->dpc_flags)) in qla4xxx_do_dpc()
5424 qla4xxx_process_aen(ha, PROCESS_ALL_AENS); in qla4xxx_do_dpc()
5427 if (test_and_clear_bit(DPC_GET_DHCP_IP_ADDR, &ha->dpc_flags)) in qla4xxx_do_dpc()
5428 qla4xxx_get_dhcp_ip_address(ha); in qla4xxx_do_dpc()
5431 if (adapter_up(ha) && in qla4xxx_do_dpc()
5432 test_and_clear_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags)) { in qla4xxx_do_dpc()
5433 iscsi_host_for_each_session(ha->host, qla4xxx_dpc_relogin); in qla4xxx_do_dpc()
5437 if (!test_bit(AF_LOOPBACK, &ha->flags) && in qla4xxx_do_dpc()
5438 test_and_clear_bit(DPC_LINK_CHANGED, &ha->dpc_flags)) { in qla4xxx_do_dpc()
5439 if (!test_bit(AF_LINK_UP, &ha->flags)) { in qla4xxx_do_dpc()
5441 qla4xxx_mark_all_devices_missing(ha); in qla4xxx_do_dpc()
5449 if (test_and_clear_bit(AF_BUILD_DDB_LIST, &ha->flags)) { in qla4xxx_do_dpc()
5450 qla4xxx_build_ddb_list(ha, ha->is_reset); in qla4xxx_do_dpc()
5451 iscsi_host_for_each_session(ha->host, in qla4xxx_do_dpc()
5454 qla4xxx_relogin_all_devices(ha); in qla4xxx_do_dpc()
5457 if (test_and_clear_bit(DPC_SYSFS_DDB_EXPORT, &ha->dpc_flags)) { in qla4xxx_do_dpc()
5458 if (qla4xxx_sysfs_ddb_export(ha)) in qla4xxx_do_dpc()
5459 ql4_printk(KERN_ERR, ha, "%s: Error exporting ddb to sysfs\n", in qla4xxx_do_dpc()
5468 static void qla4xxx_free_adapter(struct scsi_qla_host *ha) in qla4xxx_free_adapter() argument
5470 qla4xxx_abort_active_cmds(ha, DID_NO_CONNECT << 16); in qla4xxx_free_adapter()
5473 ha->isp_ops->disable_intrs(ha); in qla4xxx_free_adapter()
5475 if (is_qla40XX(ha)) { in qla4xxx_free_adapter()
5477 &ha->reg->ctrl_status); in qla4xxx_free_adapter()
5478 readl(&ha->reg->ctrl_status); in qla4xxx_free_adapter()
5479 } else if (is_qla8022(ha)) { in qla4xxx_free_adapter()
5480 writel(0, &ha->qla4_82xx_reg->host_int); in qla4xxx_free_adapter()
5481 readl(&ha->qla4_82xx_reg->host_int); in qla4xxx_free_adapter()
5482 } else if (is_qla8032(ha) || is_qla8042(ha)) { in qla4xxx_free_adapter()
5483 writel(0, &ha->qla4_83xx_reg->risc_intr); in qla4xxx_free_adapter()
5484 readl(&ha->qla4_83xx_reg->risc_intr); in qla4xxx_free_adapter()
5488 if (ha->timer_active) in qla4xxx_free_adapter()
5489 qla4xxx_stop_timer(ha); in qla4xxx_free_adapter()
5492 if (ha->dpc_thread) in qla4xxx_free_adapter()
5493 destroy_workqueue(ha->dpc_thread); in qla4xxx_free_adapter()
5496 if (ha->task_wq) in qla4xxx_free_adapter()
5497 destroy_workqueue(ha->task_wq); in qla4xxx_free_adapter()
5500 ha->isp_ops->reset_firmware(ha); in qla4xxx_free_adapter()
5502 if (is_qla80XX(ha)) { in qla4xxx_free_adapter()
5503 ha->isp_ops->idc_lock(ha); in qla4xxx_free_adapter()
5504 qla4_8xxx_clear_drv_active(ha); in qla4xxx_free_adapter()
5505 ha->isp_ops->idc_unlock(ha); in qla4xxx_free_adapter()
5509 qla4xxx_free_irqs(ha); in qla4xxx_free_adapter()
5512 qla4xxx_mem_free(ha); in qla4xxx_free_adapter()
5515 int qla4_8xxx_iospace_config(struct scsi_qla_host *ha) in qla4_8xxx_iospace_config() argument
5519 struct pci_dev *pdev = ha->pdev; in qla4_8xxx_iospace_config()
5525 "status=%d\n", ha->host_no, pci_name(pdev), status); in qla4_8xxx_iospace_config()
5531 ha->revision_id = pdev->revision; in qla4_8xxx_iospace_config()
5540 ha->nx_pcibase = (unsigned long)ioremap(mem_base, mem_len); in qla4_8xxx_iospace_config()
5541 if (!ha->nx_pcibase) { in qla4_8xxx_iospace_config()
5544 pci_release_regions(ha->pdev); in qla4_8xxx_iospace_config()
5551 if (is_qla8022(ha)) { in qla4_8xxx_iospace_config()
5552 ha->qla4_82xx_reg = (struct device_reg_82xx __iomem *) in qla4_8xxx_iospace_config()
5553 ((uint8_t *)ha->nx_pcibase + 0xbc000 + in qla4_8xxx_iospace_config()
5554 (ha->pdev->devfn << 11)); in qla4_8xxx_iospace_config()
5555 ha->nx_db_wr_ptr = (ha->pdev->devfn == 4 ? QLA82XX_CAM_RAM_DB1 : in qla4_8xxx_iospace_config()
5557 } else if (is_qla8032(ha) || is_qla8042(ha)) { in qla4_8xxx_iospace_config()
5558 ha->qla4_83xx_reg = (struct device_reg_83xx __iomem *) in qla4_8xxx_iospace_config()
5559 ((uint8_t *)ha->nx_pcibase); in qla4_8xxx_iospace_config()
5574 int qla4xxx_iospace_config(struct scsi_qla_host *ha) in qla4xxx_iospace_config() argument
5579 pio = pci_resource_start(ha->pdev, 0); in qla4xxx_iospace_config()
5580 pio_len = pci_resource_len(ha->pdev, 0); in qla4xxx_iospace_config()
5581 pio_flags = pci_resource_flags(ha->pdev, 0); in qla4xxx_iospace_config()
5584 ql4_printk(KERN_WARNING, ha, in qla4xxx_iospace_config()
5589 ql4_printk(KERN_WARNING, ha, "region #0 not a PIO resource\n"); in qla4xxx_iospace_config()
5594 mmio = pci_resource_start(ha->pdev, 1); in qla4xxx_iospace_config()
5595 mmio_len = pci_resource_len(ha->pdev, 1); in qla4xxx_iospace_config()
5596 mmio_flags = pci_resource_flags(ha->pdev, 1); in qla4xxx_iospace_config()
5599 ql4_printk(KERN_ERR, ha, in qla4xxx_iospace_config()
5606 ql4_printk(KERN_ERR, ha, in qla4xxx_iospace_config()
5611 if (pci_request_regions(ha->pdev, DRIVER_NAME)) { in qla4xxx_iospace_config()
5612 ql4_printk(KERN_WARNING, ha, in qla4xxx_iospace_config()
5618 ha->pio_address = pio; in qla4xxx_iospace_config()
5619 ha->pio_length = pio_len; in qla4xxx_iospace_config()
5620 ha->reg = ioremap(mmio, MIN_IOBASE_LEN); in qla4xxx_iospace_config()
5621 if (!ha->reg) { in qla4xxx_iospace_config()
5622 ql4_printk(KERN_ERR, ha, in qla4xxx_iospace_config()
5709 uint16_t qla4xxx_rd_shdw_req_q_out(struct scsi_qla_host *ha) in qla4xxx_rd_shdw_req_q_out() argument
5711 return (uint16_t)le32_to_cpu(ha->shadow_regs->req_q_out); in qla4xxx_rd_shdw_req_q_out()
5714 uint16_t qla4_82xx_rd_shdw_req_q_out(struct scsi_qla_host *ha) in qla4_82xx_rd_shdw_req_q_out() argument
5716 return (uint16_t)le32_to_cpu(readl(&ha->qla4_82xx_reg->req_q_out)); in qla4_82xx_rd_shdw_req_q_out()
5719 uint16_t qla4xxx_rd_shdw_rsp_q_in(struct scsi_qla_host *ha) in qla4xxx_rd_shdw_rsp_q_in() argument
5721 return (uint16_t)le32_to_cpu(ha->shadow_regs->rsp_q_in); in qla4xxx_rd_shdw_rsp_q_in()
5724 uint16_t qla4_82xx_rd_shdw_rsp_q_in(struct scsi_qla_host *ha) in qla4_82xx_rd_shdw_rsp_q_in() argument
5726 return (uint16_t)le32_to_cpu(readl(&ha->qla4_82xx_reg->rsp_q_in)); in qla4_82xx_rd_shdw_rsp_q_in()
5731 struct scsi_qla_host *ha = data; in qla4xxx_show_boot_eth_info() local
5743 rc = sysfs_format_mac(str, ha->my_mac, in qla4xxx_show_boot_eth_info()
5772 struct scsi_qla_host *ha = data; in qla4xxx_show_boot_ini_info() local
5778 rc = sprintf(str, "%s\n", ha->name_string); in qla4xxx_show_boot_ini_info()
5860 struct scsi_qla_host *ha = data; in qla4xxx_show_boot_tgt_pri_info() local
5861 struct ql4_boot_session_info *boot_sess = &(ha->boot_tgt.boot_pri_sess); in qla4xxx_show_boot_tgt_pri_info()
5868 struct scsi_qla_host *ha = data; in qla4xxx_show_boot_tgt_sec_info() local
5869 struct ql4_boot_session_info *boot_sess = &(ha->boot_tgt.boot_sec_sess); in qla4xxx_show_boot_tgt_sec_info()
5899 struct scsi_qla_host *ha = data; in qla4xxx_boot_release() local
5901 scsi_host_put(ha->host); in qla4xxx_boot_release()
5904 static int get_fw_boot_info(struct scsi_qla_host *ha, uint16_t ddb_index[]) in get_fw_boot_info() argument
5915 func_num = PCI_FUNC(ha->pdev->devfn); in get_fw_boot_info()
5917 ql4_printk(KERN_INFO, ha, "%s: Get FW boot info for 0x%x func %d\n", in get_fw_boot_info()
5918 __func__, ha->pdev->device, func_num); in get_fw_boot_info()
5920 if (is_qla40XX(ha)) { in get_fw_boot_info()
5935 val = rd_nvram_byte(ha, addr); in get_fw_boot_info()
5937 DEBUG2(ql4_printk(KERN_INFO, ha, "%s: Adapter boot " in get_fw_boot_info()
5944 val = rd_nvram_byte(ha, pri_addr); in get_fw_boot_info()
5949 val = rd_nvram_byte(ha, sec_addr); in get_fw_boot_info()
5953 } else if (is_qla80XX(ha)) { in get_fw_boot_info()
5954 buf = dma_alloc_coherent(&ha->pdev->dev, size, in get_fw_boot_info()
5957 DEBUG2(ql4_printk(KERN_ERR, ha, in get_fw_boot_info()
5964 if (ha->port_num == 0) in get_fw_boot_info()
5966 else if (ha->port_num == 1) in get_fw_boot_info()
5972 addr = FLASH_RAW_ACCESS_ADDR + (ha->hw.flt_iscsi_param * 4) + in get_fw_boot_info()
5974 if (qla4xxx_get_flash(ha, buf_dma, addr, in get_fw_boot_info()
5976 DEBUG2(ql4_printk(KERN_ERR, ha, "scsi%ld: %s: Get Flash" in get_fw_boot_info()
5977 " failed\n", ha->host_no, __func__)); in get_fw_boot_info()
5983 DEBUG2(ql4_printk(KERN_INFO, ha, "Firmware boot options" in get_fw_boot_info()
6001 DEBUG2(ql4_printk(KERN_INFO, ha, "%s: Primary target ID %d, Secondary" in get_fw_boot_info()
6006 dma_free_coherent(&ha->pdev->dev, size, buf, buf_dma); in get_fw_boot_info()
6008 ha->pri_ddb_idx = ddb_index[0]; in get_fw_boot_info()
6009 ha->sec_ddb_idx = ddb_index[1]; in get_fw_boot_info()
6024 static int qla4xxx_get_bidi_chap(struct scsi_qla_host *ha, char *username, in qla4xxx_get_bidi_chap() argument
6031 if (is_qla80XX(ha)) in qla4xxx_get_bidi_chap()
6032 max_chap_entries = (ha->hw.flt_chap_size / 2) / in qla4xxx_get_bidi_chap()
6037 if (!ha->chap_list) { in qla4xxx_get_bidi_chap()
6038 ql4_printk(KERN_ERR, ha, "Do not have CHAP table cache\n"); in qla4xxx_get_bidi_chap()
6042 mutex_lock(&ha->chap_sem); in qla4xxx_get_bidi_chap()
6044 chap_table = (struct ql4_chap_table *)ha->chap_list + i; in qla4xxx_get_bidi_chap()
6061 mutex_unlock(&ha->chap_sem); in qla4xxx_get_bidi_chap()
6067 static int qla4xxx_get_boot_target(struct scsi_qla_host *ha, in qla4xxx_get_boot_target() argument
6078 fw_ddb_entry = dma_alloc_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry), in qla4xxx_get_boot_target()
6081 DEBUG2(ql4_printk(KERN_ERR, ha, in qla4xxx_get_boot_target()
6088 if (qla4xxx_bootdb_by_index(ha, fw_ddb_entry, in qla4xxx_get_boot_target()
6090 DEBUG2(ql4_printk(KERN_INFO, ha, "%s: No Flash DDB found at " in qla4xxx_get_boot_target()
6118 DEBUG2(ql4_printk(KERN_INFO, ha, "Setting chap\n")); in qla4xxx_get_boot_target()
6120 ret = qla4xxx_get_chap(ha, (char *)&boot_conn->chap. in qla4xxx_get_boot_target()
6125 ql4_printk(KERN_ERR, ha, "Failed to set chap\n"); in qla4xxx_get_boot_target()
6136 DEBUG2(ql4_printk(KERN_INFO, ha, "Setting BIDI chap\n")); in qla4xxx_get_boot_target()
6138 ret = qla4xxx_get_bidi_chap(ha, in qla4xxx_get_boot_target()
6143 ql4_printk(KERN_ERR, ha, "Failed to set BIDI chap\n"); in qla4xxx_get_boot_target()
6153 dma_free_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry), in qla4xxx_get_boot_target()
6158 static int qla4xxx_get_boot_info(struct scsi_qla_host *ha) in qla4xxx_get_boot_info() argument
6167 ret = get_fw_boot_info(ha, ddb_index); in qla4xxx_get_boot_info()
6169 DEBUG2(ql4_printk(KERN_INFO, ha, in qla4xxx_get_boot_info()
6180 rval = qla4xxx_get_boot_target(ha, &(ha->boot_tgt.boot_pri_sess), in qla4xxx_get_boot_info()
6183 DEBUG2(ql4_printk(KERN_INFO, ha, "%s: Primary boot target not " in qla4xxx_get_boot_info()
6192 rval = qla4xxx_get_boot_target(ha, &(ha->boot_tgt.boot_sec_sess), in qla4xxx_get_boot_info()
6195 DEBUG2(ql4_printk(KERN_INFO, ha, "%s: Secondary boot target not" in qla4xxx_get_boot_info()
6204 static int qla4xxx_setup_boot_info(struct scsi_qla_host *ha) in qla4xxx_setup_boot_info() argument
6208 if (qla4xxx_get_boot_info(ha) != QLA_SUCCESS) in qla4xxx_setup_boot_info()
6212 ql4_printk(KERN_INFO, ha, in qla4xxx_setup_boot_info()
6219 ha->boot_kset = iscsi_boot_create_host_kset(ha->host->host_no); in qla4xxx_setup_boot_info()
6220 if (!ha->boot_kset) in qla4xxx_setup_boot_info()
6223 if (!scsi_host_get(ha->host)) in qla4xxx_setup_boot_info()
6225 boot_kobj = iscsi_boot_create_target(ha->boot_kset, 0, ha, in qla4xxx_setup_boot_info()
6232 if (!scsi_host_get(ha->host)) in qla4xxx_setup_boot_info()
6234 boot_kobj = iscsi_boot_create_target(ha->boot_kset, 1, ha, in qla4xxx_setup_boot_info()
6241 if (!scsi_host_get(ha->host)) in qla4xxx_setup_boot_info()
6243 boot_kobj = iscsi_boot_create_initiator(ha->boot_kset, 0, ha, in qla4xxx_setup_boot_info()
6250 if (!scsi_host_get(ha->host)) in qla4xxx_setup_boot_info()
6252 boot_kobj = iscsi_boot_create_ethernet(ha->boot_kset, 0, ha, in qla4xxx_setup_boot_info()
6262 scsi_host_put(ha->host); in qla4xxx_setup_boot_info()
6264 iscsi_boot_destroy_kset(ha->boot_kset); in qla4xxx_setup_boot_info()
6314 static int qla4xxx_compare_tuple_ddb(struct scsi_qla_host *ha, in qla4xxx_compare_tuple_ddb() argument
6335 DEBUG2(ql4_printk(KERN_INFO, ha, in qla4xxx_compare_tuple_ddb()
6344 DEBUG2(ql4_printk(KERN_INFO, ha, in qla4xxx_compare_tuple_ddb()
6353 static int qla4xxx_is_session_exists(struct scsi_qla_host *ha, in qla4xxx_is_session_exists() argument
6365 DEBUG2(ql4_printk(KERN_WARNING, ha, in qla4xxx_is_session_exists()
6373 DEBUG2(ql4_printk(KERN_WARNING, ha, in qla4xxx_is_session_exists()
6382 ddb_entry = qla4xxx_lookup_ddb_by_fw_index(ha, idx); in qla4xxx_is_session_exists()
6387 if (!qla4xxx_compare_tuple_ddb(ha, fw_tddb, tmp_tddb, false)) { in qla4xxx_is_session_exists()
6435 static int qla4xxx_update_isid(struct scsi_qla_host *ha, in qla4xxx_update_isid() argument
6463 static int qla4xxx_should_update_isid(struct scsi_qla_host *ha, in qla4xxx_should_update_isid() argument
6497 static int qla4xxx_is_flash_ddb_exists(struct scsi_qla_host *ha, in qla4xxx_is_flash_ddb_exists() argument
6508 DEBUG2(ql4_printk(KERN_WARNING, ha, in qla4xxx_is_flash_ddb_exists()
6516 DEBUG2(ql4_printk(KERN_WARNING, ha, in qla4xxx_is_flash_ddb_exists()
6527 ret = qla4xxx_compare_tuple_ddb(ha, fw_tddb, tmp_tddb, true); in qla4xxx_is_flash_ddb_exists()
6536 ret = qla4xxx_should_update_isid(ha, tmp_tddb, fw_tddb); in qla4xxx_is_flash_ddb_exists()
6538 rval = qla4xxx_update_isid(ha, list_nt, fw_ddb_entry); in qla4xxx_is_flash_ddb_exists()
6564 static struct iscsi_endpoint *qla4xxx_get_ep_fwdb(struct scsi_qla_host *ha, in qla4xxx_get_ep_fwdb() argument
6596 ep = qla4xxx_ep_connect(ha->host, (struct sockaddr *)dst_addr, 0); in qla4xxx_get_ep_fwdb()
6601 static int qla4xxx_verify_boot_idx(struct scsi_qla_host *ha, uint16_t idx) in qla4xxx_verify_boot_idx() argument
6605 if (idx == ha->pri_ddb_idx || idx == ha->sec_ddb_idx) in qla4xxx_verify_boot_idx()
6610 static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha, in qla4xxx_setup_flash_ddb_entry() argument
6619 ddb_entry->ha = ha; in qla4xxx_setup_flash_ddb_entry()
6635 (idx == ha->pri_ddb_idx || idx == ha->sec_ddb_idx)) in qla4xxx_setup_flash_ddb_entry()
6639 static void qla4xxx_wait_for_ip_configuration(struct scsi_qla_host *ha) in qla4xxx_wait_for_ip_configuration() argument
6654 ret = qla4xxx_get_ip_state(ha, 0, ip_idx[idx], sts); in qla4xxx_wait_for_ip_configuration()
6663 DEBUG2(ql4_printk(KERN_INFO, ha, in qla4xxx_wait_for_ip_configuration()
6708 static int qla4xxx_find_flash_st_idx(struct scsi_qla_host *ha, in qla4xxx_find_flash_st_idx() argument
6718 max_ddbs = is_qla40XX(ha) ? MAX_DEV_DB_ENTRIES_40XX : in qla4xxx_find_flash_st_idx()
6721 flash_ddb_entry = dma_pool_alloc(ha->fw_ddb_dma_pool, GFP_KERNEL, in qla4xxx_find_flash_st_idx()
6724 ql4_printk(KERN_ERR, ha, "Out of memory\n"); in qla4xxx_find_flash_st_idx()
6728 status = qla4xxx_flashdb_by_index(ha, flash_ddb_entry, in qla4xxx_find_flash_st_idx()
6740 status = qla4xxx_flashdb_by_index(ha, flash_ddb_entry, in qla4xxx_find_flash_st_idx()
6754 ql4_printk(KERN_ERR, ha, "Failed to find ST [%d] in flash\n", in qla4xxx_find_flash_st_idx()
6759 dma_pool_free(ha->fw_ddb_dma_pool, flash_ddb_entry, in qla4xxx_find_flash_st_idx()
6765 static void qla4xxx_build_st_list(struct scsi_qla_host *ha, in qla4xxx_build_st_list() argument
6779 fw_ddb_entry = dma_pool_alloc(ha->fw_ddb_dma_pool, GFP_KERNEL, in qla4xxx_build_st_list()
6782 DEBUG2(ql4_printk(KERN_ERR, ha, "Out of memory\n")); in qla4xxx_build_st_list()
6786 max_ddbs = is_qla40XX(ha) ? MAX_DEV_DB_ENTRIES_40XX : in qla4xxx_build_st_list()
6791 ret = qla4xxx_get_fwddb_entry(ha, idx, fw_ddb_entry, fw_ddb_dma, in qla4xxx_build_st_list()
6809 ret = qla4xxx_find_flash_st_idx(ha, fw_ddb_entry, idx, in qla4xxx_build_st_list()
6812 ql4_printk(KERN_ERR, ha, in qla4xxx_build_st_list()
6816 ql4_printk(KERN_INFO, ha, in qla4xxx_build_st_list()
6832 dma_pool_free(ha->fw_ddb_dma_pool, fw_ddb_entry, fw_ddb_dma); in qla4xxx_build_st_list()
6843 static void qla4xxx_remove_failed_ddb(struct scsi_qla_host *ha, in qla4xxx_remove_failed_ddb() argument
6852 ret = qla4xxx_get_fwddb_entry(ha, ddb_idx->fw_ddb_idx, in qla4xxx_remove_failed_ddb()
6866 static void qla4xxx_update_sess_disc_idx(struct scsi_qla_host *ha, in qla4xxx_update_sess_disc_idx() argument
6875 max_ddbs = is_qla40XX(ha) ? MAX_DEV_DB_ENTRIES_40XX : in qla4xxx_update_sess_disc_idx()
6888 static int qla4xxx_sess_conn_setup(struct scsi_qla_host *ha, in qla4xxx_sess_conn_setup() argument
6906 cls_sess = iscsi_session_setup(&qla4xxx_iscsi_transport, ha->host, in qla4xxx_sess_conn_setup()
6928 qla4xxx_setup_flash_ddb_entry(ha, ddb_entry, idx); in qla4xxx_sess_conn_setup()
6940 ep = qla4xxx_get_ep_fwdb(ha, fw_ddb_entry); in qla4xxx_sess_conn_setup()
6945 DEBUG2(ql4_printk(KERN_ERR, ha, "Unable to get ep\n")); in qla4xxx_sess_conn_setup()
6951 qla4xxx_copy_fwddb_param(ha, fw_ddb_entry, cls_sess, cls_conn); in qla4xxx_sess_conn_setup()
6952 qla4xxx_update_sess_disc_idx(ha, ddb_entry, fw_ddb_entry); in qla4xxx_sess_conn_setup()
6961 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags); in qla4xxx_sess_conn_setup()
6969 static void qla4xxx_update_fw_ddb_link(struct scsi_qla_host *ha, in qla4xxx_update_fw_ddb_link() argument
6980 DEBUG2(ql4_printk(KERN_INFO, ha, in qla4xxx_update_fw_ddb_link()
6990 static void qla4xxx_build_nt_list(struct scsi_qla_host *ha, in qla4xxx_build_nt_list() argument
7008 fw_ddb_entry = dma_pool_alloc(ha->fw_ddb_dma_pool, GFP_KERNEL, in qla4xxx_build_nt_list()
7011 DEBUG2(ql4_printk(KERN_ERR, ha, "Out of memory\n")); in qla4xxx_build_nt_list()
7014 max_ddbs = is_qla40XX(ha) ? MAX_DEV_DB_ENTRIES_40XX : in qla4xxx_build_nt_list()
7019 ret = qla4xxx_get_fwddb_entry(ha, idx, fw_ddb_entry, fw_ddb_dma, in qla4xxx_build_nt_list()
7025 if (qla4xxx_verify_boot_idx(ha, idx) != QLA_SUCCESS) in qla4xxx_build_nt_list()
7034 qla4xxx_update_fw_ddb_link(ha, list_st, fw_ddb_entry); in qla4xxx_build_nt_list()
7041 DEBUG2(ql4_printk(KERN_INFO, ha, in qla4xxx_build_nt_list()
7059 ret = qla4xxx_is_flash_ddb_exists(ha, list_nt, in qla4xxx_build_nt_list()
7073 ret = qla4xxx_is_session_exists(ha, fw_ddb_entry, in qla4xxx_build_nt_list()
7076 ddb_entry = qla4xxx_lookup_ddb_by_fw_index(ha, in qla4xxx_build_nt_list()
7079 qla4xxx_update_sess_disc_idx(ha, in qla4xxx_build_nt_list()
7086 ret = qla4xxx_sess_conn_setup(ha, fw_ddb_entry, is_reset, idx); in qla4xxx_build_nt_list()
7097 dma_pool_free(ha->fw_ddb_dma_pool, fw_ddb_entry, fw_ddb_dma); in qla4xxx_build_nt_list()
7100 static void qla4xxx_build_new_nt_list(struct scsi_qla_host *ha, in qla4xxx_build_new_nt_list() argument
7114 fw_ddb_entry = dma_pool_alloc(ha->fw_ddb_dma_pool, GFP_KERNEL, in qla4xxx_build_new_nt_list()
7117 DEBUG2(ql4_printk(KERN_ERR, ha, "Out of memory\n")); in qla4xxx_build_new_nt_list()
7120 max_ddbs = is_qla40XX(ha) ? MAX_DEV_DB_ENTRIES_40XX : in qla4xxx_build_new_nt_list()
7125 ret = qla4xxx_get_fwddb_entry(ha, idx, fw_ddb_entry, fw_ddb_dma, in qla4xxx_build_new_nt_list()
7138 DEBUG2(ql4_printk(KERN_INFO, ha, in qla4xxx_build_new_nt_list()
7147 ret = qla4xxx_is_session_exists(ha, fw_ddb_entry, NULL); in qla4xxx_build_new_nt_list()
7159 ret = qla4xxx_sess_conn_setup(ha, fw_ddb_entry, RESET_ADAPTER, in qla4xxx_build_new_nt_list()
7171 dma_pool_free(ha->fw_ddb_dma_pool, fw_ddb_entry, fw_ddb_dma); in qla4xxx_build_new_nt_list()
7211 static int qla4xxx_sysfs_ddb_tgt_create(struct scsi_qla_host *ha, in qla4xxx_sysfs_ddb_tgt_create() argument
7219 fnode_sess = iscsi_create_flashnode_sess(ha->host, *idx, in qla4xxx_sysfs_ddb_tgt_create()
7222 ql4_printk(KERN_ERR, ha, in qla4xxx_sysfs_ddb_tgt_create()
7224 __func__, *idx, ha->host_no); in qla4xxx_sysfs_ddb_tgt_create()
7228 fnode_conn = iscsi_create_flashnode_conn(ha->host, fnode_sess, in qla4xxx_sysfs_ddb_tgt_create()
7231 ql4_printk(KERN_ERR, ha, in qla4xxx_sysfs_ddb_tgt_create()
7233 __func__, *idx, ha->host_no); in qla4xxx_sysfs_ddb_tgt_create()
7242 if (*idx == ha->pri_ddb_idx || *idx == ha->sec_ddb_idx) in qla4xxx_sysfs_ddb_tgt_create()
7253 ql4_printk(KERN_INFO, ha, "%s: sysfs entry %s created\n", in qla4xxx_sysfs_ddb_tgt_create()
7256 ql4_printk(KERN_INFO, ha, "%s: sysfs entry %s created\n", in qla4xxx_sysfs_ddb_tgt_create()
7280 struct scsi_qla_host *ha = to_qla_host(shost); in qla4xxx_sysfs_ddb_add() local
7291 DEBUG2(ql4_printk(KERN_ERR, ha, "%s: Invalid portal type\n", in qla4xxx_sysfs_ddb_add()
7296 max_ddbs = is_qla40XX(ha) ? MAX_PRST_DEV_DB_ENTRIES : in qla4xxx_sysfs_ddb_add()
7299 fw_ddb_entry = dma_alloc_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry), in qla4xxx_sysfs_ddb_add()
7302 DEBUG2(ql4_printk(KERN_ERR, ha, in qla4xxx_sysfs_ddb_add()
7308 dev = iscsi_find_flashnode_sess(ha->host, NULL, in qla4xxx_sysfs_ddb_add()
7311 ql4_printk(KERN_ERR, ha, in qla4xxx_sysfs_ddb_add()
7320 if (qla4xxx_flashdb_by_index(ha, fw_ddb_entry, in qla4xxx_sysfs_ddb_add()
7331 rval = qla4xxx_get_default_ddb(ha, options, fw_ddb_entry_dma); in qla4xxx_sysfs_ddb_add()
7335 rval = qla4xxx_sysfs_ddb_tgt_create(ha, fw_ddb_entry, &idx, 1); in qla4xxx_sysfs_ddb_add()
7339 dma_free_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry), in qla4xxx_sysfs_ddb_add()
7359 struct scsi_qla_host *ha = to_qla_host(shost); in qla4xxx_sysfs_ddb_apply() local
7366 fw_ddb_entry = dma_alloc_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry), in qla4xxx_sysfs_ddb_apply()
7369 DEBUG2(ql4_printk(KERN_ERR, ha, in qla4xxx_sysfs_ddb_apply()
7379 rval = qla4xxx_get_default_ddb(ha, options, fw_ddb_entry_dma); in qla4xxx_sysfs_ddb_apply()
7389 rval = qla4xxx_set_flash(ha, fw_ddb_entry_dma, dev_db_start_offset, in qla4xxx_sysfs_ddb_apply()
7394 ql4_printk(KERN_INFO, ha, in qla4xxx_sysfs_ddb_apply()
7396 __func__, fnode_sess->target_id, ha->host_no); in qla4xxx_sysfs_ddb_apply()
7399 ql4_printk(KERN_ERR, ha, in qla4xxx_sysfs_ddb_apply()
7401 __func__, fnode_sess->target_id, ha->host_no); in qla4xxx_sysfs_ddb_apply()
7406 dma_free_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry), in qla4xxx_sysfs_ddb_apply()
7411 static ssize_t qla4xxx_sysfs_ddb_conn_open(struct scsi_qla_host *ha, in qla4xxx_sysfs_ddb_conn_open() argument
7423 ddb_entry = dma_alloc_coherent(&ha->pdev->dev, sizeof(*ddb_entry), in qla4xxx_sysfs_ddb_conn_open()
7426 DEBUG2(ql4_printk(KERN_ERR, ha, in qla4xxx_sysfs_ddb_conn_open()
7434 ret = qla4xxx_set_ddb_entry(ha, idx, ddb_entry_dma, &mbx_sts); in qla4xxx_sysfs_ddb_conn_open()
7436 DEBUG2(ql4_printk(KERN_ERR, ha, in qla4xxx_sysfs_ddb_conn_open()
7442 qla4xxx_conn_open(ha, idx); in qla4xxx_sysfs_ddb_conn_open()
7445 tmo = ((ha->def_timeout > LOGIN_TOV) && in qla4xxx_sysfs_ddb_conn_open()
7446 (ha->def_timeout < LOGIN_TOV * 10) ? in qla4xxx_sysfs_ddb_conn_open()
7447 ha->def_timeout : LOGIN_TOV); in qla4xxx_sysfs_ddb_conn_open()
7449 DEBUG2(ql4_printk(KERN_INFO, ha, in qla4xxx_sysfs_ddb_conn_open()
7454 ret = qla4xxx_get_fwddb_entry(ha, idx, NULL, 0, NULL, in qla4xxx_sysfs_ddb_conn_open()
7469 dma_free_coherent(&ha->pdev->dev, sizeof(*ddb_entry), in qla4xxx_sysfs_ddb_conn_open()
7474 static int qla4xxx_ddb_login_st(struct scsi_qla_host *ha, in qla4xxx_ddb_login_st() argument
7483 if (test_bit(AF_ST_DISCOVERY_IN_PROGRESS, &ha->flags)) { in qla4xxx_ddb_login_st()
7484 ql4_printk(KERN_WARNING, ha, in qla4xxx_ddb_login_st()
7491 set_bit(AF_ST_DISCOVERY_IN_PROGRESS, &ha->flags); in qla4xxx_ddb_login_st()
7493 ret = qla4xxx_get_ddb_index(ha, &ddb_index); in qla4xxx_ddb_login_st()
7497 ret = qla4xxx_sysfs_ddb_conn_open(ha, fw_ddb_entry, ddb_index); in qla4xxx_ddb_login_st()
7501 qla4xxx_build_new_nt_list(ha, &list_nt, target_id); in qla4xxx_ddb_login_st()
7505 qla4xxx_clear_ddb_entry(ha, ddb_idx->fw_ddb_idx); in qla4xxx_ddb_login_st()
7510 if (qla4xxx_clear_ddb_entry(ha, ddb_index) == QLA_ERROR) { in qla4xxx_ddb_login_st()
7511 ql4_printk(KERN_ERR, ha, in qla4xxx_ddb_login_st()
7515 clear_bit(ddb_index, ha->ddb_idx_map); in qla4xxx_ddb_login_st()
7518 clear_bit(AF_ST_DISCOVERY_IN_PROGRESS, &ha->flags); in qla4xxx_ddb_login_st()
7522 static int qla4xxx_ddb_login_nt(struct scsi_qla_host *ha, in qla4xxx_ddb_login_nt() argument
7528 ret = qla4xxx_is_session_exists(ha, fw_ddb_entry, NULL); in qla4xxx_ddb_login_nt()
7530 ret = qla4xxx_sess_conn_setup(ha, fw_ddb_entry, RESET_ADAPTER, in qla4xxx_ddb_login_nt()
7549 struct scsi_qla_host *ha = to_qla_host(shost); in qla4xxx_sysfs_ddb_login() local
7556 ql4_printk(KERN_ERR, ha, in qla4xxx_sysfs_ddb_login()
7562 fw_ddb_entry = dma_alloc_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry), in qla4xxx_sysfs_ddb_login()
7565 DEBUG2(ql4_printk(KERN_ERR, ha, in qla4xxx_sysfs_ddb_login()
7575 ret = qla4xxx_get_default_ddb(ha, options, fw_ddb_entry_dma); in qla4xxx_sysfs_ddb_login()
7583 ret = qla4xxx_ddb_login_st(ha, fw_ddb_entry, in qla4xxx_sysfs_ddb_login()
7586 ret = qla4xxx_ddb_login_nt(ha, fw_ddb_entry, in qla4xxx_sysfs_ddb_login()
7594 dma_free_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry), in qla4xxx_sysfs_ddb_login()
7609 struct scsi_qla_host *ha; in qla4xxx_sysfs_ddb_logout_sid() local
7620 ha = ddb_entry->ha; in qla4xxx_sysfs_ddb_logout_sid()
7623 ql4_printk(KERN_ERR, ha, "%s: Not a flash node session\n", in qla4xxx_sysfs_ddb_logout_sid()
7630 ql4_printk(KERN_ERR, ha, in qla4xxx_sysfs_ddb_logout_sid()
7637 fw_ddb_entry = dma_alloc_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry), in qla4xxx_sysfs_ddb_logout_sid()
7640 ql4_printk(KERN_ERR, ha, in qla4xxx_sysfs_ddb_logout_sid()
7649 ret = qla4xxx_get_fwddb_entry(ha, ddb_entry->fw_ddb_index, in qla4xxx_sysfs_ddb_logout_sid()
7675 qla4xxx_session_logout_ddb(ha, ddb_entry, options); in qla4xxx_sysfs_ddb_logout_sid()
7680 ret = qla4xxx_get_fwddb_entry(ha, ddb_entry->fw_ddb_index, in qla4xxx_sysfs_ddb_logout_sid()
7695 qla4xxx_clear_ddb_entry(ha, ddb_entry->fw_ddb_index); in qla4xxx_sysfs_ddb_logout_sid()
7705 spin_lock_irqsave(&ha->hardware_lock, flags); in qla4xxx_sysfs_ddb_logout_sid()
7706 qla4xxx_free_ddb(ha, ddb_entry); in qla4xxx_sysfs_ddb_logout_sid()
7707 clear_bit(ddb_entry->fw_ddb_index, ha->ddb_idx_map); in qla4xxx_sysfs_ddb_logout_sid()
7708 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla4xxx_sysfs_ddb_logout_sid()
7717 dma_free_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry), in qla4xxx_sysfs_ddb_logout_sid()
7733 struct scsi_qla_host *ha = to_qla_host(shost); in qla4xxx_sysfs_ddb_logout() local
7745 fw_ddb_entry = dma_pool_alloc(ha->fw_ddb_dma_pool, GFP_KERNEL, in qla4xxx_sysfs_ddb_logout()
7748 ql4_printk(KERN_ERR, ha, "%s:Out of memory\n", __func__); in qla4xxx_sysfs_ddb_logout()
7755 ql4_printk(KERN_WARNING, ha, in qla4xxx_sysfs_ddb_logout()
7763 ql4_printk(KERN_WARNING, ha, in qla4xxx_sysfs_ddb_logout()
7770 ql4_printk(KERN_ERR, ha, in qla4xxx_sysfs_ddb_logout()
7778 ql4_printk(KERN_ERR, ha, in qla4xxx_sysfs_ddb_logout()
7799 ddb_entry = qla4xxx_lookup_ddb_by_fw_index(ha, idx); in qla4xxx_sysfs_ddb_logout()
7807 status = qla4xxx_get_fwddb_entry(ha, index, fw_ddb_entry, in qla4xxx_sysfs_ddb_logout()
7818 status = qla4xxx_compare_tuple_ddb(ha, flash_tddb, tmp_tddb, in qla4xxx_sysfs_ddb_logout()
7833 dma_pool_free(ha->fw_ddb_dma_pool, fw_ddb_entry, fw_ddb_dma); in qla4xxx_sysfs_ddb_logout()
7843 struct scsi_qla_host *ha = to_qla_host(shost); in qla4xxx_sysfs_ddb_get_param() local
8045 qla4xxx_get_uni_chap_at_index(ha, in qla4xxx_sysfs_ddb_get_param()
8056 qla4xxx_get_uni_chap_at_index(ha, in qla4xxx_sysfs_ddb_get_param()
8098 struct scsi_qla_host *ha = to_qla_host(shost); in qla4xxx_sysfs_ddb_set_param() local
8292 if (!qla4xxx_get_uni_chap_at_index(ha, in qla4xxx_sysfs_ddb_set_param()
8302 ql4_printk(KERN_ERR, ha, in qla4xxx_sysfs_ddb_set_param()
8324 struct scsi_qla_host *ha = to_qla_host(shost); in qla4xxx_sysfs_ddb_delete() local
8337 DEBUG2(ql4_printk(KERN_ERR, ha, in qla4xxx_sysfs_ddb_delete()
8346 if (is_qla40XX(ha)) { in qla4xxx_sysfs_ddb_delete()
8354 (ha->hw.flt_region_ddb << 2); in qla4xxx_sysfs_ddb_delete()
8358 if (ha->port_num == 1) in qla4xxx_sysfs_ddb_delete()
8359 dev_db_start_offset += (ha->hw.flt_ddb_size / 2); in qla4xxx_sysfs_ddb_delete()
8362 (ha->hw.flt_ddb_size / 2); in qla4xxx_sysfs_ddb_delete()
8371 DEBUG2(ql4_printk(KERN_ERR, ha, "%s: start offset=%u, end offset=%u\n", in qla4xxx_sysfs_ddb_delete()
8376 DEBUG2(ql4_printk(KERN_ERR, ha, "%s:Invalid DDB index %u\n", in qla4xxx_sysfs_ddb_delete()
8381 pddb = dma_alloc_coherent(&ha->pdev->dev, ddb_size, in qla4xxx_sysfs_ddb_delete()
8385 DEBUG2(ql4_printk(KERN_ERR, ha, in qla4xxx_sysfs_ddb_delete()
8391 if (is_qla40XX(ha)) { in qla4xxx_sysfs_ddb_delete()
8401 qla4xxx_set_flash(ha, fw_ddb_entry_dma, dev_db_start_offset, in qla4xxx_sysfs_ddb_delete()
8407 ql4_printk(KERN_INFO, ha, in qla4xxx_sysfs_ddb_delete()
8409 __func__, target_id, ha->host_no); in qla4xxx_sysfs_ddb_delete()
8412 dma_free_coherent(&ha->pdev->dev, ddb_size, pddb, in qla4xxx_sysfs_ddb_delete()
8423 int qla4xxx_sysfs_ddb_export(struct scsi_qla_host *ha) in qla4xxx_sysfs_ddb_export() argument
8431 fw_ddb_entry = dma_alloc_coherent(&ha->pdev->dev, in qla4xxx_sysfs_ddb_export()
8435 DEBUG2(ql4_printk(KERN_ERR, ha, in qla4xxx_sysfs_ddb_export()
8441 max_ddbs = is_qla40XX(ha) ? MAX_PRST_DEV_DB_ENTRIES : in qla4xxx_sysfs_ddb_export()
8445 if (qla4xxx_flashdb_by_index(ha, fw_ddb_entry, fw_ddb_entry_dma, in qla4xxx_sysfs_ddb_export()
8449 ret = qla4xxx_sysfs_ddb_tgt_create(ha, fw_ddb_entry, &idx, 0); in qla4xxx_sysfs_ddb_export()
8456 dma_free_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry), fw_ddb_entry, in qla4xxx_sysfs_ddb_export()
8462 static void qla4xxx_sysfs_ddb_remove(struct scsi_qla_host *ha) in qla4xxx_sysfs_ddb_remove() argument
8464 iscsi_destroy_all_flashnode(ha->host); in qla4xxx_sysfs_ddb_remove()
8477 void qla4xxx_build_ddb_list(struct scsi_qla_host *ha, int is_reset) in qla4xxx_build_ddb_list() argument
8484 if (!test_bit(AF_LINK_UP, &ha->flags)) { in qla4xxx_build_ddb_list()
8485 set_bit(AF_BUILD_DDB_LIST, &ha->flags); in qla4xxx_build_ddb_list()
8486 ha->is_reset = is_reset; in qla4xxx_build_ddb_list()
8493 qla4xxx_build_st_list(ha, &list_st); in qla4xxx_build_ddb_list()
8498 qla4xxx_wait_for_ip_configuration(ha); in qla4xxx_build_ddb_list()
8502 qla4xxx_conn_open(ha, st_ddb_idx->fw_ddb_idx); in qla4xxx_build_ddb_list()
8506 tmo = ((ha->def_timeout > LOGIN_TOV) && in qla4xxx_build_ddb_list()
8507 (ha->def_timeout < LOGIN_TOV * 10) ? in qla4xxx_build_ddb_list()
8508 ha->def_timeout : LOGIN_TOV); in qla4xxx_build_ddb_list()
8510 DEBUG2(ql4_printk(KERN_INFO, ha, in qla4xxx_build_ddb_list()
8518 qla4xxx_remove_failed_ddb(ha, &list_st); in qla4xxx_build_ddb_list()
8523 qla4xxx_build_nt_list(ha, &list_nt, &list_st, is_reset); in qla4xxx_build_ddb_list()
8528 qla4xxx_free_ddb_index(ha); in qla4xxx_build_ddb_list()
8540 static void qla4xxx_wait_login_resp_boot_tgt(struct scsi_qla_host *ha) in qla4xxx_wait_login_resp_boot_tgt() argument
8549 max_ddbs = is_qla40XX(ha) ? MAX_DEV_DB_ENTRIES_40XX : in qla4xxx_wait_login_resp_boot_tgt()
8552 fw_ddb_entry = dma_alloc_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry), in qla4xxx_wait_login_resp_boot_tgt()
8555 ql4_printk(KERN_ERR, ha, in qla4xxx_wait_login_resp_boot_tgt()
8563 ddb_entry = qla4xxx_lookup_ddb_by_fw_index(ha, idx); in qla4xxx_wait_login_resp_boot_tgt()
8568 DEBUG2(ql4_printk(KERN_INFO, ha, in qla4xxx_wait_login_resp_boot_tgt()
8572 ret = qla4xxx_get_fwddb_entry(ha, in qla4xxx_wait_login_resp_boot_tgt()
8589 DEBUG2(ql4_printk(KERN_INFO, ha, in qla4xxx_wait_login_resp_boot_tgt()
8599 dma_free_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry), in qla4xxx_wait_login_resp_boot_tgt()
8617 struct scsi_qla_host *ha; in qla4xxx_probe_adapter() local
8626 host = iscsi_host_alloc(&qla4xxx_driver_template, sizeof(*ha), 0); in qla4xxx_probe_adapter()
8634 ha = to_qla_host(host); in qla4xxx_probe_adapter()
8635 memset(ha, 0, sizeof(*ha)); in qla4xxx_probe_adapter()
8638 ha->pdev = pdev; in qla4xxx_probe_adapter()
8639 ha->host = host; in qla4xxx_probe_adapter()
8640 ha->host_no = host->host_no; in qla4xxx_probe_adapter()
8641 ha->func_num = PCI_FUNC(ha->pdev->devfn); in qla4xxx_probe_adapter()
8646 if (is_qla8022(ha)) { in qla4xxx_probe_adapter()
8647 ha->isp_ops = &qla4_82xx_isp_ops; in qla4xxx_probe_adapter()
8648 ha->reg_tbl = (uint32_t *) qla4_82xx_reg_tbl; in qla4xxx_probe_adapter()
8649 ha->qdr_sn_window = -1; in qla4xxx_probe_adapter()
8650 ha->ddr_mn_window = -1; in qla4xxx_probe_adapter()
8651 ha->curr_window = 255; in qla4xxx_probe_adapter()
8652 nx_legacy_intr = &legacy_intr[ha->func_num]; in qla4xxx_probe_adapter()
8653 ha->nx_legacy_intr.int_vec_bit = nx_legacy_intr->int_vec_bit; in qla4xxx_probe_adapter()
8654 ha->nx_legacy_intr.tgt_status_reg = in qla4xxx_probe_adapter()
8656 ha->nx_legacy_intr.tgt_mask_reg = nx_legacy_intr->tgt_mask_reg; in qla4xxx_probe_adapter()
8657 ha->nx_legacy_intr.pci_int_reg = nx_legacy_intr->pci_int_reg; in qla4xxx_probe_adapter()
8658 } else if (is_qla8032(ha) || is_qla8042(ha)) { in qla4xxx_probe_adapter()
8659 ha->isp_ops = &qla4_83xx_isp_ops; in qla4xxx_probe_adapter()
8660 ha->reg_tbl = (uint32_t *)qla4_83xx_reg_tbl; in qla4xxx_probe_adapter()
8662 ha->isp_ops = &qla4xxx_isp_ops; in qla4xxx_probe_adapter()
8665 if (is_qla80XX(ha)) { in qla4xxx_probe_adapter()
8666 rwlock_init(&ha->hw_lock); in qla4xxx_probe_adapter()
8667 ha->pf_bit = ha->func_num << 16; in qla4xxx_probe_adapter()
8673 ret = ha->isp_ops->iospace_config(ha); in qla4xxx_probe_adapter()
8677 ql4_printk(KERN_INFO, ha, "Found an ISP%04x, irq %d, iobase 0x%p\n", in qla4xxx_probe_adapter()
8678 pdev->device, pdev->irq, ha->reg); in qla4xxx_probe_adapter()
8680 qla4xxx_config_dma_addressing(ha); in qla4xxx_probe_adapter()
8683 INIT_LIST_HEAD(&ha->free_srb_q); in qla4xxx_probe_adapter()
8685 mutex_init(&ha->mbox_sem); in qla4xxx_probe_adapter()
8686 mutex_init(&ha->chap_sem); in qla4xxx_probe_adapter()
8687 init_completion(&ha->mbx_intr_comp); in qla4xxx_probe_adapter()
8688 init_completion(&ha->disable_acb_comp); in qla4xxx_probe_adapter()
8689 init_completion(&ha->idc_comp); in qla4xxx_probe_adapter()
8690 init_completion(&ha->link_up_comp); in qla4xxx_probe_adapter()
8692 spin_lock_init(&ha->hardware_lock); in qla4xxx_probe_adapter()
8693 spin_lock_init(&ha->work_lock); in qla4xxx_probe_adapter()
8696 INIT_LIST_HEAD(&ha->work_list); in qla4xxx_probe_adapter()
8699 if (qla4xxx_mem_alloc(ha)) { in qla4xxx_probe_adapter()
8700 ql4_printk(KERN_WARNING, ha, in qla4xxx_probe_adapter()
8715 pci_set_drvdata(pdev, ha); in qla4xxx_probe_adapter()
8721 if (is_qla80XX(ha)) in qla4xxx_probe_adapter()
8722 qla4_8xxx_get_flash_info(ha); in qla4xxx_probe_adapter()
8724 if (is_qla8032(ha) || is_qla8042(ha)) { in qla4xxx_probe_adapter()
8725 qla4_83xx_read_reset_template(ha); in qla4xxx_probe_adapter()
8733 qla4_83xx_set_idc_dontreset(ha); in qla4xxx_probe_adapter()
8741 status = qla4xxx_initialize_adapter(ha, INIT_ADAPTER); in qla4xxx_probe_adapter()
8744 if (is_qla80XX(ha) && (status == QLA_ERROR)) in qla4xxx_probe_adapter()
8747 while ((!test_bit(AF_ONLINE, &ha->flags)) && in qla4xxx_probe_adapter()
8750 if (is_qla80XX(ha)) { in qla4xxx_probe_adapter()
8751 ha->isp_ops->idc_lock(ha); in qla4xxx_probe_adapter()
8752 dev_state = qla4_8xxx_rd_direct(ha, in qla4xxx_probe_adapter()
8754 ha->isp_ops->idc_unlock(ha); in qla4xxx_probe_adapter()
8756 ql4_printk(KERN_WARNING, ha, "%s: don't retry " in qla4xxx_probe_adapter()
8765 if (ha->isp_ops->reset_chip(ha) == QLA_ERROR) in qla4xxx_probe_adapter()
8768 status = qla4xxx_initialize_adapter(ha, INIT_ADAPTER); in qla4xxx_probe_adapter()
8769 if (is_qla80XX(ha) && (status == QLA_ERROR)) { in qla4xxx_probe_adapter()
8770 if (qla4_8xxx_check_init_adapter_retry(ha) == QLA_ERROR) in qla4xxx_probe_adapter()
8776 if (!test_bit(AF_ONLINE, &ha->flags)) { in qla4xxx_probe_adapter()
8777 ql4_printk(KERN_WARNING, ha, "Failed to initialize adapter\n"); in qla4xxx_probe_adapter()
8779 if ((is_qla8022(ha) && ql4xdontresethba) || in qla4xxx_probe_adapter()
8780 ((is_qla8032(ha) || is_qla8042(ha)) && in qla4xxx_probe_adapter()
8781 qla4_83xx_idc_dontreset(ha))) { in qla4xxx_probe_adapter()
8784 ha->isp_ops->idc_lock(ha); in qla4xxx_probe_adapter()
8785 qla4_8xxx_wr_direct(ha, QLA8XXX_CRB_DEV_STATE, in qla4xxx_probe_adapter()
8787 ha->isp_ops->idc_unlock(ha); in qla4xxx_probe_adapter()
8796 sprintf(buf, "qla4xxx_%lu_dpc", ha->host_no); in qla4xxx_probe_adapter()
8797 ha->dpc_thread = create_singlethread_workqueue(buf); in qla4xxx_probe_adapter()
8798 if (!ha->dpc_thread) { in qla4xxx_probe_adapter()
8799 ql4_printk(KERN_WARNING, ha, "Unable to start DPC thread!\n"); in qla4xxx_probe_adapter()
8803 INIT_WORK(&ha->dpc_work, qla4xxx_do_dpc); in qla4xxx_probe_adapter()
8805 ha->task_wq = alloc_workqueue("qla4xxx_%lu_task", WQ_MEM_RECLAIM, 1, in qla4xxx_probe_adapter()
8806 ha->host_no); in qla4xxx_probe_adapter()
8807 if (!ha->task_wq) { in qla4xxx_probe_adapter()
8808 ql4_printk(KERN_WARNING, ha, "Unable to start task thread!\n"); in qla4xxx_probe_adapter()
8819 if (is_qla40XX(ha)) { in qla4xxx_probe_adapter()
8820 ret = qla4xxx_request_irqs(ha); in qla4xxx_probe_adapter()
8822 ql4_printk(KERN_WARNING, ha, "Failed to reserve " in qla4xxx_probe_adapter()
8828 pci_save_state(ha->pdev); in qla4xxx_probe_adapter()
8829 ha->isp_ops->enable_intrs(ha); in qla4xxx_probe_adapter()
8832 qla4xxx_start_timer(ha, 1); in qla4xxx_probe_adapter()
8834 set_bit(AF_INIT_DONE, &ha->flags); in qla4xxx_probe_adapter()
8836 qla4_8xxx_alloc_sysfs_attr(ha); in qla4xxx_probe_adapter()
8841 qla4xxx_version_str, ha->pdev->device, pci_name(ha->pdev), in qla4xxx_probe_adapter()
8842 ha->host_no, ha->fw_info.fw_major, ha->fw_info.fw_minor, in qla4xxx_probe_adapter()
8843 ha->fw_info.fw_patch, ha->fw_info.fw_build); in qla4xxx_probe_adapter()
8846 if (is_qla80XX(ha)) in qla4xxx_probe_adapter()
8847 qla4_8xxx_set_param(ha, SET_DRVR_VERSION); in qla4xxx_probe_adapter()
8849 if (qla4xxx_setup_boot_info(ha)) in qla4xxx_probe_adapter()
8850 ql4_printk(KERN_ERR, ha, in qla4xxx_probe_adapter()
8853 set_bit(DPC_SYSFS_DDB_EXPORT, &ha->dpc_flags); in qla4xxx_probe_adapter()
8855 qla4xxx_build_ddb_list(ha, INIT_ADAPTER); in qla4xxx_probe_adapter()
8856 iscsi_host_for_each_session(ha->host, qla4xxx_login_flash_ddb); in qla4xxx_probe_adapter()
8857 qla4xxx_wait_login_resp_boot_tgt(ha); in qla4xxx_probe_adapter()
8859 qla4xxx_create_chap_list(ha); in qla4xxx_probe_adapter()
8861 qla4xxx_create_ifaces(ha); in qla4xxx_probe_adapter()
8865 scsi_remove_host(ha->host); in qla4xxx_probe_adapter()
8868 qla4xxx_free_adapter(ha); in qla4xxx_probe_adapter()
8872 scsi_host_put(ha->host); in qla4xxx_probe_adapter()
8888 static void qla4xxx_prevent_other_port_reinit(struct scsi_qla_host *ha) in qla4xxx_prevent_other_port_reinit() argument
8895 if (PCI_FUNC(ha->pdev->devfn) & BIT_1) in qla4xxx_prevent_other_port_reinit()
8899 pci_get_domain_bus_and_slot(pci_domain_nr(ha->pdev->bus), in qla4xxx_prevent_other_port_reinit()
8900 ha->pdev->bus->number, PCI_DEVFN(PCI_SLOT(ha->pdev->devfn), in qla4xxx_prevent_other_port_reinit()
8909 DEBUG2(ql4_printk(KERN_INFO, ha, "%s: " in qla4xxx_prevent_other_port_reinit()
8918 static void qla4xxx_destroy_ddb(struct scsi_qla_host *ha, in qla4xxx_destroy_ddb() argument
8929 if (qla4xxx_session_logout_ddb(ha, ddb_entry, options) == QLA_ERROR) { in qla4xxx_destroy_ddb()
8930 ql4_printk(KERN_ERR, ha, "%s: Logout failed\n", __func__); in qla4xxx_destroy_ddb()
8934 fw_ddb_entry = dma_alloc_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry), in qla4xxx_destroy_ddb()
8937 ql4_printk(KERN_ERR, ha, in qla4xxx_destroy_ddb()
8944 status = qla4xxx_get_fwddb_entry(ha, ddb_entry->fw_ddb_index, in qla4xxx_destroy_ddb()
8959 dma_free_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry), in qla4xxx_destroy_ddb()
8962 qla4xxx_clear_ddb_entry(ha, ddb_entry->fw_ddb_index); in qla4xxx_destroy_ddb()
8965 static void qla4xxx_destroy_fw_ddb_session(struct scsi_qla_host *ha) in qla4xxx_destroy_fw_ddb_session() argument
8972 ddb_entry = qla4xxx_lookup_ddb_by_fw_index(ha, idx); in qla4xxx_destroy_fw_ddb_session()
8976 qla4xxx_destroy_ddb(ha, ddb_entry); in qla4xxx_destroy_fw_ddb_session()
8985 qla4xxx_free_ddb(ha, ddb_entry); in qla4xxx_destroy_fw_ddb_session()
8996 struct scsi_qla_host *ha; in qla4xxx_remove_adapter() local
9005 ha = pci_get_drvdata(pdev); in qla4xxx_remove_adapter()
9007 if (is_qla40XX(ha)) in qla4xxx_remove_adapter()
9008 qla4xxx_prevent_other_port_reinit(ha); in qla4xxx_remove_adapter()
9011 qla4xxx_destroy_ifaces(ha); in qla4xxx_remove_adapter()
9013 if ((!ql4xdisablesysfsboot) && ha->boot_kset) in qla4xxx_remove_adapter()
9014 iscsi_boot_destroy_kset(ha->boot_kset); in qla4xxx_remove_adapter()
9016 qla4xxx_destroy_fw_ddb_session(ha); in qla4xxx_remove_adapter()
9017 qla4_8xxx_free_sysfs_attr(ha); in qla4xxx_remove_adapter()
9019 qla4xxx_sysfs_ddb_remove(ha); in qla4xxx_remove_adapter()
9020 scsi_remove_host(ha->host); in qla4xxx_remove_adapter()
9022 qla4xxx_free_adapter(ha); in qla4xxx_remove_adapter()
9024 scsi_host_put(ha->host); in qla4xxx_remove_adapter()
9034 static void qla4xxx_config_dma_addressing(struct scsi_qla_host *ha) in qla4xxx_config_dma_addressing() argument
9037 if (dma_set_mask_and_coherent(&ha->pdev->dev, DMA_BIT_MASK(64))) { in qla4xxx_config_dma_addressing()
9038 dev_dbg(&ha->pdev->dev, in qla4xxx_config_dma_addressing()
9041 dma_set_mask_and_coherent(&ha->pdev->dev, DMA_BIT_MASK(32)); in qla4xxx_config_dma_addressing()
9072 struct srb *qla4xxx_del_from_active_array(struct scsi_qla_host *ha, in qla4xxx_del_from_active_array() argument
9078 cmd = scsi_host_find_tag(ha->host, index); in qla4xxx_del_from_active_array()
9088 ha->iocb_cnt -= srb->iocb_cnt; in qla4xxx_del_from_active_array()
9104 static int qla4xxx_eh_wait_on_command(struct scsi_qla_host *ha, in qla4xxx_eh_wait_on_command() argument
9115 if (unlikely(pci_channel_offline(ha->pdev)) || in qla4xxx_eh_wait_on_command()
9116 (test_bit(AF_EEH_BUSY, &ha->flags))) { in qla4xxx_eh_wait_on_command()
9117 ql4_printk(KERN_WARNING, ha, "scsi%ld: Return from %s\n", in qla4xxx_eh_wait_on_command()
9118 ha->host_no, __func__); in qla4xxx_eh_wait_on_command()
9140 static int qla4xxx_wait_for_hba_online(struct scsi_qla_host *ha) in qla4xxx_wait_for_hba_online() argument
9147 if (adapter_up(ha)) in qla4xxx_wait_for_hba_online()
9165 static int qla4xxx_eh_wait_for_commands(struct scsi_qla_host *ha, in qla4xxx_eh_wait_for_commands() argument
9177 for (cnt = 0; cnt < ha->host->can_queue; cnt++) { in qla4xxx_eh_wait_for_commands()
9178 cmd = scsi_host_find_tag(ha->host, cnt); in qla4xxx_eh_wait_for_commands()
9181 if (!qla4xxx_eh_wait_on_command(ha, cmd)) { in qla4xxx_eh_wait_for_commands()
9199 struct scsi_qla_host *ha = to_qla_host(cmd->device->host); in qla4xxx_eh_abort() local
9208 ql4_printk(KERN_INFO, ha, "scsi%ld:%d:%llu: Abort command issued cmd=%p, cdb=0x%x\n", in qla4xxx_eh_abort()
9209 ha->host_no, id, lun, cmd, cmd->cmnd[0]); in qla4xxx_eh_abort()
9211 rval = qla4xxx_isp_check_reg(ha); in qla4xxx_eh_abort()
9213 ql4_printk(KERN_INFO, ha, "PCI/Register disconnect, exiting.\n"); in qla4xxx_eh_abort()
9217 spin_lock_irqsave(&ha->hardware_lock, flags); in qla4xxx_eh_abort()
9220 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla4xxx_eh_abort()
9221 ql4_printk(KERN_INFO, ha, "scsi%ld:%d:%llu: Specified command has already completed.\n", in qla4xxx_eh_abort()
9222 ha->host_no, id, lun); in qla4xxx_eh_abort()
9226 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla4xxx_eh_abort()
9228 if (qla4xxx_abort_task(ha, srb) != QLA_SUCCESS) { in qla4xxx_eh_abort()
9230 ha->host_no, id, lun)); in qla4xxx_eh_abort()
9234 ha->host_no, id, lun)); in qla4xxx_eh_abort()
9242 if (!qla4xxx_eh_wait_on_command(ha, cmd)) { in qla4xxx_eh_abort()
9244 ha->host_no, id, lun)); in qla4xxx_eh_abort()
9249 ql4_printk(KERN_INFO, ha, in qla4xxx_eh_abort()
9251 ha->host_no, id, lun, (ret == SUCCESS) ? "succeeded" : "failed"); in qla4xxx_eh_abort()
9265 struct scsi_qla_host *ha = to_qla_host(cmd->device->host); in qla4xxx_eh_device_reset() local
9278 ql4_printk(KERN_INFO, ha, in qla4xxx_eh_device_reset()
9279 "scsi%ld:%d:%d:%llu: DEVICE RESET ISSUED.\n", ha->host_no, in qla4xxx_eh_device_reset()
9284 "dpc_flags=%lx, status=%x allowed=%d\n", ha->host_no, in qla4xxx_eh_device_reset()
9286 ha->dpc_flags, cmd->result, cmd->allowed)); in qla4xxx_eh_device_reset()
9288 rval = qla4xxx_isp_check_reg(ha); in qla4xxx_eh_device_reset()
9290 ql4_printk(KERN_INFO, ha, "PCI/Register disconnect, exiting.\n"); in qla4xxx_eh_device_reset()
9295 stat = qla4xxx_reset_lun(ha, ddb_entry, cmd->device->lun); in qla4xxx_eh_device_reset()
9297 ql4_printk(KERN_INFO, ha, "DEVICE RESET FAILED. %d\n", stat); in qla4xxx_eh_device_reset()
9301 if (qla4xxx_eh_wait_for_commands(ha, scsi_target(cmd->device), in qla4xxx_eh_device_reset()
9303 ql4_printk(KERN_INFO, ha, in qla4xxx_eh_device_reset()
9310 if (qla4xxx_send_marker_iocb(ha, ddb_entry, cmd->device->lun, in qla4xxx_eh_device_reset()
9314 ql4_printk(KERN_INFO, ha, in qla4xxx_eh_device_reset()
9316 ha->host_no, cmd->device->channel, cmd->device->id, in qla4xxx_eh_device_reset()
9334 struct scsi_qla_host *ha = to_qla_host(cmd->device->host); in qla4xxx_eh_target_reset() local
9352 ha->host_no, cmd, jiffies, scsi_cmd_to_rq(cmd)->timeout / HZ, in qla4xxx_eh_target_reset()
9353 ha->dpc_flags, cmd->result, cmd->allowed)); in qla4xxx_eh_target_reset()
9355 rval = qla4xxx_isp_check_reg(ha); in qla4xxx_eh_target_reset()
9357 ql4_printk(KERN_INFO, ha, "PCI/Register disconnect, exiting.\n"); in qla4xxx_eh_target_reset()
9361 stat = qla4xxx_reset_target(ha, ddb_entry); in qla4xxx_eh_target_reset()
9368 if (qla4xxx_eh_wait_for_commands(ha, scsi_target(cmd->device), in qla4xxx_eh_target_reset()
9377 if (qla4xxx_send_marker_iocb(ha, ddb_entry, cmd->device->lun, in qla4xxx_eh_target_reset()
9414 struct scsi_qla_host *ha; in qla4xxx_eh_host_reset() local
9417 ha = to_qla_host(cmd->device->host); in qla4xxx_eh_host_reset()
9419 rval = qla4xxx_isp_check_reg(ha); in qla4xxx_eh_host_reset()
9421 ql4_printk(KERN_INFO, ha, "PCI/Register disconnect, exiting.\n"); in qla4xxx_eh_host_reset()
9425 if ((is_qla8032(ha) || is_qla8042(ha)) && ql4xdontresethba) in qla4xxx_eh_host_reset()
9426 qla4_83xx_set_idc_dontreset(ha); in qla4xxx_eh_host_reset()
9433 ((is_qla8032(ha) || is_qla8042(ha)) && in qla4xxx_eh_host_reset()
9434 qla4_83xx_idc_dontreset(ha))) { in qla4xxx_eh_host_reset()
9436 ha->host_no, __func__)); in qla4xxx_eh_host_reset()
9440 qla4xxx_abort_active_cmds(ha, DID_ABORT << 16); in qla4xxx_eh_host_reset()
9445 ql4_printk(KERN_INFO, ha, in qla4xxx_eh_host_reset()
9446 "scsi(%ld:%d:%d:%llu): HOST RESET ISSUED.\n", ha->host_no, in qla4xxx_eh_host_reset()
9449 if (qla4xxx_wait_for_hba_online(ha) != QLA_SUCCESS) { in qla4xxx_eh_host_reset()
9451 "DEAD.\n", ha->host_no, cmd->device->channel, in qla4xxx_eh_host_reset()
9457 if (!test_bit(DPC_RESET_HA, &ha->dpc_flags)) { in qla4xxx_eh_host_reset()
9458 if (is_qla80XX(ha)) in qla4xxx_eh_host_reset()
9459 set_bit(DPC_RESET_HA_FW_CONTEXT, &ha->dpc_flags); in qla4xxx_eh_host_reset()
9461 set_bit(DPC_RESET_HA, &ha->dpc_flags); in qla4xxx_eh_host_reset()
9464 if (qla4xxx_recover_adapter(ha) == QLA_SUCCESS) in qla4xxx_eh_host_reset()
9467 ql4_printk(KERN_INFO, ha, "HOST RESET %s.\n", in qla4xxx_eh_host_reset()
9473 static int qla4xxx_context_reset(struct scsi_qla_host *ha) in qla4xxx_context_reset() argument
9482 acb = dma_alloc_coherent(&ha->pdev->dev, in qla4xxx_context_reset()
9486 ql4_printk(KERN_ERR, ha, "%s: Unable to alloc acb\n", in qla4xxx_context_reset()
9494 rval = qla4xxx_get_acb(ha, acb_dma, PRIMARI_ACB, acb_len); in qla4xxx_context_reset()
9500 rval = qla4xxx_disable_acb(ha); in qla4xxx_context_reset()
9506 wait_for_completion_timeout(&ha->disable_acb_comp, in qla4xxx_context_reset()
9509 rval = qla4xxx_set_acb(ha, &mbox_cmd[0], &mbox_sts[0], acb_dma); in qla4xxx_context_reset()
9516 dma_free_coherent(&ha->pdev->dev, sizeof(struct addr_ctrl_blk_def), in qla4xxx_context_reset()
9519 DEBUG2(ql4_printk(KERN_INFO, ha, "%s %s\n", __func__, in qla4xxx_context_reset()
9526 struct scsi_qla_host *ha = to_qla_host(shost); in qla4xxx_host_reset() local
9531 DEBUG2(ql4_printk(KERN_INFO, ha, "%s: Don't Reset HBA\n", in qla4xxx_host_reset()
9537 if (test_bit(DPC_RESET_HA, &ha->dpc_flags)) in qla4xxx_host_reset()
9542 set_bit(DPC_RESET_HA, &ha->dpc_flags); in qla4xxx_host_reset()
9545 if (!test_bit(DPC_RESET_HA, &ha->dpc_flags)) { in qla4xxx_host_reset()
9546 if (is_qla80XX(ha)) in qla4xxx_host_reset()
9549 &ha->dpc_flags); in qla4xxx_host_reset()
9551 rval = qla4xxx_context_reset(ha); in qla4xxx_host_reset()
9561 if ((is_qla8032(ha) || is_qla8042(ha)) && in qla4xxx_host_reset()
9562 test_bit(DPC_RESET_HA, &ha->dpc_flags)) { in qla4xxx_host_reset()
9563 idc_ctrl = qla4_83xx_rd_reg(ha, QLA83XX_IDC_DRV_CTRL); in qla4xxx_host_reset()
9564 qla4_83xx_wr_reg(ha, QLA83XX_IDC_DRV_CTRL, in qla4xxx_host_reset()
9568 rval = qla4xxx_recover_adapter(ha); in qla4xxx_host_reset()
9570 DEBUG2(ql4_printk(KERN_INFO, ha, "%s: recover adapter fail\n", in qla4xxx_host_reset()
9597 struct scsi_qla_host *ha = pci_get_drvdata(pdev); in qla4xxx_pci_error_detected() local
9599 ql4_printk(KERN_WARNING, ha, "scsi%ld: %s: error detected:state %x\n", in qla4xxx_pci_error_detected()
9600 ha->host_no, __func__, state); in qla4xxx_pci_error_detected()
9602 if (!is_aer_supported(ha)) in qla4xxx_pci_error_detected()
9607 clear_bit(AF_EEH_BUSY, &ha->flags); in qla4xxx_pci_error_detected()
9610 set_bit(AF_EEH_BUSY, &ha->flags); in qla4xxx_pci_error_detected()
9611 qla4xxx_mailbox_premature_completion(ha); in qla4xxx_pci_error_detected()
9612 qla4xxx_free_irqs(ha); in qla4xxx_pci_error_detected()
9615 qla4xxx_abort_active_cmds(ha, DID_RESET << 16); in qla4xxx_pci_error_detected()
9618 set_bit(AF_EEH_BUSY, &ha->flags); in qla4xxx_pci_error_detected()
9619 set_bit(AF_PCI_CHANNEL_IO_PERM_FAILURE, &ha->flags); in qla4xxx_pci_error_detected()
9620 qla4xxx_abort_active_cmds(ha, DID_NO_CONNECT << 16); in qla4xxx_pci_error_detected()
9635 struct scsi_qla_host *ha = pci_get_drvdata(pdev); in qla4xxx_pci_mmio_enabled() local
9637 if (!is_aer_supported(ha)) in qla4xxx_pci_mmio_enabled()
9643 static uint32_t qla4_8xxx_error_recovery(struct scsi_qla_host *ha) in qla4_8xxx_error_recovery() argument
9649 ql4_printk(KERN_WARNING, ha, "scsi%ld: In %s\n", ha->host_no, __func__); in qla4_8xxx_error_recovery()
9651 set_bit(DPC_RESET_ACTIVE, &ha->dpc_flags); in qla4_8xxx_error_recovery()
9653 if (test_bit(AF_ONLINE, &ha->flags)) { in qla4_8xxx_error_recovery()
9654 clear_bit(AF_ONLINE, &ha->flags); in qla4_8xxx_error_recovery()
9655 clear_bit(AF_LINK_UP, &ha->flags); in qla4_8xxx_error_recovery()
9656 iscsi_host_for_each_session(ha->host, qla4xxx_fail_session); in qla4_8xxx_error_recovery()
9657 qla4xxx_process_aen(ha, FLUSH_DDB_CHANGED_AENS); in qla4_8xxx_error_recovery()
9660 fn = PCI_FUNC(ha->pdev->devfn); in qla4_8xxx_error_recovery()
9661 if (is_qla8022(ha)) { in qla4_8xxx_error_recovery()
9664 ql4_printk(KERN_INFO, ha, "scsi%ld: %s: Finding PCI device at func %x\n", in qla4_8xxx_error_recovery()
9665 ha->host_no, __func__, fn); in qla4_8xxx_error_recovery()
9669 pci_domain_nr(ha->pdev->bus), in qla4_8xxx_error_recovery()
9670 ha->pdev->bus->number, in qla4_8xxx_error_recovery()
9671 PCI_DEVFN(PCI_SLOT(ha->pdev->devfn), in qla4_8xxx_error_recovery()
9678 ql4_printk(KERN_INFO, ha, "scsi%ld: %s: Found PCI func in enabled state%x\n", in qla4_8xxx_error_recovery()
9679 ha->host_no, __func__, fn); in qla4_8xxx_error_recovery()
9687 if (qla4_83xx_can_perform_reset(ha)) { in qla4_8xxx_error_recovery()
9698 ql4_printk(KERN_INFO, ha, "scsi%ld: %s: devfn being reset " in qla4_8xxx_error_recovery()
9699 "0x%x is the owner\n", ha->host_no, __func__, in qla4_8xxx_error_recovery()
9700 ha->pdev->devfn); in qla4_8xxx_error_recovery()
9702 ha->isp_ops->idc_lock(ha); in qla4_8xxx_error_recovery()
9703 qla4_8xxx_wr_direct(ha, QLA8XXX_CRB_DEV_STATE, in qla4_8xxx_error_recovery()
9705 ha->isp_ops->idc_unlock(ha); in qla4_8xxx_error_recovery()
9707 rval = qla4_8xxx_update_idc_reg(ha); in qla4_8xxx_error_recovery()
9709 ql4_printk(KERN_INFO, ha, "scsi%ld: %s: HW State: FAILED\n", in qla4_8xxx_error_recovery()
9710 ha->host_no, __func__); in qla4_8xxx_error_recovery()
9711 ha->isp_ops->idc_lock(ha); in qla4_8xxx_error_recovery()
9712 qla4_8xxx_wr_direct(ha, QLA8XXX_CRB_DEV_STATE, in qla4_8xxx_error_recovery()
9714 ha->isp_ops->idc_unlock(ha); in qla4_8xxx_error_recovery()
9718 clear_bit(AF_FW_RECOVERY, &ha->flags); in qla4_8xxx_error_recovery()
9719 rval = qla4xxx_initialize_adapter(ha, RESET_ADAPTER); in qla4_8xxx_error_recovery()
9722 ql4_printk(KERN_INFO, ha, "scsi%ld: %s: HW State: " in qla4_8xxx_error_recovery()
9723 "FAILED\n", ha->host_no, __func__); in qla4_8xxx_error_recovery()
9724 qla4xxx_free_irqs(ha); in qla4_8xxx_error_recovery()
9725 ha->isp_ops->idc_lock(ha); in qla4_8xxx_error_recovery()
9726 qla4_8xxx_clear_drv_active(ha); in qla4_8xxx_error_recovery()
9727 qla4_8xxx_wr_direct(ha, QLA8XXX_CRB_DEV_STATE, in qla4_8xxx_error_recovery()
9729 ha->isp_ops->idc_unlock(ha); in qla4_8xxx_error_recovery()
9731 ql4_printk(KERN_INFO, ha, "scsi%ld: %s: HW State: " in qla4_8xxx_error_recovery()
9732 "READY\n", ha->host_no, __func__); in qla4_8xxx_error_recovery()
9733 ha->isp_ops->idc_lock(ha); in qla4_8xxx_error_recovery()
9734 qla4_8xxx_wr_direct(ha, QLA8XXX_CRB_DEV_STATE, in qla4_8xxx_error_recovery()
9737 qla4_8xxx_wr_direct(ha, QLA8XXX_CRB_DRV_STATE, 0); in qla4_8xxx_error_recovery()
9738 qla4_8xxx_set_drv_active(ha); in qla4_8xxx_error_recovery()
9739 ha->isp_ops->idc_unlock(ha); in qla4_8xxx_error_recovery()
9740 ha->isp_ops->enable_intrs(ha); in qla4_8xxx_error_recovery()
9743 ql4_printk(KERN_INFO, ha, "scsi%ld: %s: devfn 0x%x is not " in qla4_8xxx_error_recovery()
9744 "the reset owner\n", ha->host_no, __func__, in qla4_8xxx_error_recovery()
9745 ha->pdev->devfn); in qla4_8xxx_error_recovery()
9746 if ((qla4_8xxx_rd_direct(ha, QLA8XXX_CRB_DEV_STATE) == in qla4_8xxx_error_recovery()
9748 clear_bit(AF_FW_RECOVERY, &ha->flags); in qla4_8xxx_error_recovery()
9749 rval = qla4xxx_initialize_adapter(ha, RESET_ADAPTER); in qla4_8xxx_error_recovery()
9751 ha->isp_ops->enable_intrs(ha); in qla4_8xxx_error_recovery()
9753 qla4xxx_free_irqs(ha); in qla4_8xxx_error_recovery()
9755 ha->isp_ops->idc_lock(ha); in qla4_8xxx_error_recovery()
9756 qla4_8xxx_set_drv_active(ha); in qla4_8xxx_error_recovery()
9757 ha->isp_ops->idc_unlock(ha); in qla4_8xxx_error_recovery()
9761 clear_bit(DPC_RESET_ACTIVE, &ha->dpc_flags); in qla4_8xxx_error_recovery()
9769 struct scsi_qla_host *ha = pci_get_drvdata(pdev); in qla4xxx_pci_slot_reset() local
9772 ql4_printk(KERN_WARNING, ha, "scsi%ld: %s: slot_reset\n", in qla4xxx_pci_slot_reset()
9773 ha->host_no, __func__); in qla4xxx_pci_slot_reset()
9775 if (!is_aer_supported(ha)) in qla4xxx_pci_slot_reset()
9792 ql4_printk(KERN_WARNING, ha, "scsi%ld: %s: Can't re-enable " in qla4xxx_pci_slot_reset()
9793 "device after reset\n", ha->host_no, __func__); in qla4xxx_pci_slot_reset()
9797 ha->isp_ops->disable_intrs(ha); in qla4xxx_pci_slot_reset()
9799 if (is_qla80XX(ha)) { in qla4xxx_pci_slot_reset()
9800 if (qla4_8xxx_error_recovery(ha) == QLA_SUCCESS) { in qla4xxx_pci_slot_reset()
9808 ql4_printk(KERN_WARNING, ha, "scsi%ld: %s: Return=%x\n" in qla4xxx_pci_slot_reset()
9809 "device after reset\n", ha->host_no, __func__, ret); in qla4xxx_pci_slot_reset()
9816 struct scsi_qla_host *ha = pci_get_drvdata(pdev); in qla4xxx_pci_resume() local
9819 ql4_printk(KERN_WARNING, ha, "scsi%ld: %s: pci_resume\n", in qla4xxx_pci_resume()
9820 ha->host_no, __func__); in qla4xxx_pci_resume()
9822 ret = qla4xxx_wait_for_hba_online(ha); in qla4xxx_pci_resume()
9824 ql4_printk(KERN_ERR, ha, "scsi%ld: %s: the device failed to " in qla4xxx_pci_resume()
9825 "resume I/O from slot/link_reset\n", ha->host_no, in qla4xxx_pci_resume()
9829 clear_bit(AF_EEH_BUSY, &ha->flags); in qla4xxx_pci_resume()