• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-WNDR4500v2-V1.0.0.60_1.0.38/src/linux/linux-2.6/drivers/scsi/

Lines Matching refs:host_index

496 	int host_index, ihost_index;
506 for (host_index = 0; hosts[host_index] && !(inb(IM_STAT_REG(host_index)) & IM_INTR_REQUEST); host_index++);
508 if (!hosts[host_index]) {
515 if ((reset_status(host_index) == IM_RESET_NOT_IN_PROGRESS_NO_INT) || (reset_status(host_index) == IM_RESET_FINISHED_OK_NO_INT)) {
516 reset_status(host_index) = IM_RESET_NOT_IN_PROGRESS;
523 if (!(inb(IM_STAT_REG(host_index)) & IM_BUSY))
527 ihost_index = host_index;
706 static void issue_cmd(int host_index, unsigned long cmd_reg, unsigned char attn_reg)
711 spin_lock_irqsave(hosts[host_index]->host_lock, flags);
712 if (!(inb(IM_STAT_REG(host_index)) & IM_BUSY))
714 spin_unlock_irqrestore(hosts[host_index]->host_lock, flags);
717 outl(cmd_reg, IM_CMD_REG(host_index));
718 outb(attn_reg, IM_ATTN_REG(host_index));
719 spin_unlock_irqrestore(hosts[host_index]->host_lock, flags);
729 static int device_inquiry(int host_index, int ldn)
736 scb = &(ld(host_index)[ldn].scb);
737 tsb = &(ld(host_index)[ldn].tsb);
738 buf = (unsigned char *) (&(ld(host_index)[ldn].buf));
739 ld(host_index)[ldn].tsb.dev_status = 0; /* prepare statusblock */
744 last_scsi_command(host_index)[ldn] = IM_DEVICE_INQUIRY_CMD;
745 last_scsi_type(host_index)[ldn] = IM_SCB;
750 got_interrupt(host_index) = 0;
751 issue_cmd(host_index, isa_virt_to_bus(scb), IM_SCB | ldn);
752 while (!got_interrupt(host_index))
756 if ((stat_result(host_index) == IM_SCB_CMD_COMPLETED) || (stat_result(host_index) == IM_SCB_CMD_COMPLETED_WITH_RETRIES))
766 static int read_capacity(int host_index, int ldn)
773 scb = &(ld(host_index)[ldn].scb);
774 tsb = &(ld(host_index)[ldn].tsb);
775 buf = (unsigned char *) (&(ld(host_index)[ldn].buf));
776 ld(host_index)[ldn].tsb.dev_status = 0;
781 last_scsi_command(host_index)[ldn] = IM_READ_CAPACITY_CMD;
782 last_scsi_type(host_index)[ldn] = IM_SCB;
787 got_interrupt(host_index) = 0;
788 issue_cmd(host_index, isa_virt_to_bus(scb), IM_SCB | ldn);
789 while (!got_interrupt(host_index))
793 if ((stat_result(host_index) == IM_SCB_CMD_COMPLETED) || (stat_result(host_index) == IM_SCB_CMD_COMPLETED_WITH_RETRIES))
803 static int get_pos_info(int host_index)
810 scb = &(ld(host_index)[MAX_LOG_DEV].scb);
811 tsb = &(ld(host_index)[MAX_LOG_DEV].tsb);
812 buf = (unsigned char *) (&(ld(host_index)[MAX_LOG_DEV].buf));
813 ld(host_index)[MAX_LOG_DEV].tsb.dev_status = 0;
818 last_scsi_command(host_index)[MAX_LOG_DEV] = IM_GET_POS_INFO_CMD;
819 last_scsi_type(host_index)[MAX_LOG_DEV] = IM_SCB;
821 if (special(host_index) == IBM_SCSI2_FW)
827 got_interrupt(host_index) = 0;
828 issue_cmd(host_index, isa_virt_to_bus(scb), IM_SCB | MAX_LOG_DEV);
830 while (!got_interrupt(host_index))
834 if ((stat_result(host_index) == IM_SCB_CMD_COMPLETED) || (stat_result(host_index) == IM_SCB_CMD_COMPLETED_WITH_RETRIES))
847 static int immediate_assign(int host_index, unsigned int pun, unsigned int lun, unsigned int ldn, unsigned int operation)
854 switch (special(host_index)) {
863 imm_cmd = inl(IM_CMD_REG(host_index));
872 last_scsi_command(host_index)[MAX_LOG_DEV] = IM_ASSIGN_IMM_CMD;
873 last_scsi_type(host_index)[MAX_LOG_DEV] = IM_IMM_CMD;
874 got_interrupt(host_index) = 0;
875 issue_cmd(host_index, (unsigned long) (imm_cmd), IM_IMM_CMD | MAX_LOG_DEV);
876 while (!got_interrupt(host_index))
880 if (stat_result(host_index) == IM_IMMEDIATE_CMD_COMPLETED)
889 static int immediate_feature(int host_index, unsigned int speed, unsigned int timeout)
899 last_scsi_command(host_index)[MAX_LOG_DEV] = IM_FEATURE_CTR_IMM_CMD;
900 last_scsi_type(host_index)[MAX_LOG_DEV] = IM_IMM_CMD;
901 got_interrupt(host_index) = 0;
905 issue_cmd(host_index, (unsigned long) (imm_cmd), IM_IMM_CMD | MAX_LOG_DEV);
907 while (!got_interrupt(host_index))
915 if (stat_result(host_index) == IM_IMMEDIATE_CMD_COMPLETED)
925 static int immediate_reset(int host_index, unsigned int ldn)
932 imm_command = inl(IM_CMD_REG(host_index));
935 last_scsi_command(host_index)[ldn] = IM_RESET_IMM_CMD;
936 last_scsi_type(host_index)[ldn] = IM_IMM_CMD;
937 got_interrupt(host_index) = 0;
938 reset_status(host_index) = IM_RESET_IN_PROGRESS;
939 issue_cmd(host_index, (unsigned long) (imm_command), IM_IMM_CMD | ldn);
941 while (reset_status(host_index) == IM_RESET_IN_PROGRESS && --ticks) {
948 reset_status(host_index) = IM_RESET_FINISHED_OK;
953 if (stat_result(host_index) == IM_IMMEDIATE_CMD_COMPLETED)
1055 static int probe_bus_mode(int host_index)
1061 info = (struct im_pos_info *) (&(ld(host_index)[MAX_LOG_DEV].buf));
1062 if (get_pos_info(host_index)) {
1064 subsystem_connector_size(host_index) = 16;
1066 subsystem_connector_size(host_index) = 32;
1069 if ((special(host_index) == IBM_SCSI_WCACHE) || (special(host_index) == IBM_7568_WCACHE)) {
1071 ld(host_index)[ldn].cache_flag = 0;
1074 ld(host_index)[ldn].retry_flag = 0;
1079 printk("%d", ld(host_index)[ldn].cache_flag);
1083 printk("%d", ld(host_index)[ldn].retry_flag);
1092 static void check_devices(int host_index, int adaptertype)
1103 IBM_DS(host_index).dyn_flag = 0; /* normally no need for dynamical ldn management */
1104 IBM_DS(host_index).total_errors = 0; /* set errorcounter to 0 */
1105 next_ldn(host_index) = 7; /* next ldn to be assigned is 7, because 0-6 is 'hardwired' */
1108 memset(ld(host_index), 0, sizeof(ld(host_index)));
1110 last_scsi_command(host_index)[ldn] = NO_SCSI; /* emptify last SCSI-command storage */
1111 last_scsi_type(host_index)[ldn] = 0;
1112 ld(host_index)[ldn].cache_flag = 1;
1113 ld(host_index)[ldn].retry_flag = 1;
1115 memset(get_ldn(host_index), TYPE_NO_DEVICE, sizeof(get_ldn(host_index))); /* this is essential ! */
1116 memset(get_scsi(host_index), TYPE_NO_DEVICE, sizeof(get_scsi(host_index))); /* this is essential ! */
1119 get_scsi(host_index)[subsystem_pun(host_index)][lun] = TYPE_IBM_SCSI_ADAPTER;
1120 get_ldn(host_index)[subsystem_pun(host_index)][lun] = MAX_LOG_DEV; /* make sure, the subsystem
1129 adapter_speed(host_index) = global_adapter_speed;
1130 speedrun = adapter_speed(host_index);
1131 while (immediate_feature(host_index, speedrun, adapter_timeout) == 2) {
1139 adapter_speed(host_index) = speedrun;
1142 num_bus = probe_bus_mode(host_index);
1149 subsystem_maxid(host_index) = 16;
1152 subsystem_maxid(host_index) = 8;
1159 max_pun = subsystem_maxid(host_index);
1162 printk("IBM MCA SCSI: Current SCSI-host index: %d\n", host_index);
1172 immediate_assign(host_index, 0, 0, ldn, REMOVE_LDN); /* remove ldn (wherever) */
1191 if (id != subsystem_pun(host_index)) {
1194 immediate_assign(host_index, id, lun, PROBE_LDN, SET_LDN);
1195 if (device_inquiry(host_index, PROBE_LDN)) { /* probe device */
1196 get_scsi(host_index)[id][lun] = (unsigned char) (ld(host_index)[PROBE_LDN].buf[0]);
1198 if (ld(host_index)[PROBE_LDN].buf[0] != TYPE_NO_LUN)
1202 immediate_assign(host_index, id, lun, PROBE_LDN, REMOVE_LDN);
1222 if (id != subsystem_pun(host_index)) {
1223 if (get_scsi(host_index)[id][lun] != TYPE_NO_LUN && get_scsi(host_index)[id][lun] != TYPE_NO_DEVICE) {
1226 immediate_assign(host_index, id, lun, ldn, SET_LDN);
1227 get_ldn(host_index)[id][lun] = ldn; /* map ldn */
1228 if (device_exists(host_index, ldn, &ld(host_index)[ldn].block_length, &ld(host_index)[ldn].device_type)) {
1231 immediate_reset(host_index, ldn);
1239 get_ldn(host_index)[id][lun] = TYPE_NO_DEVICE;
1240 immediate_assign(host_index, 0, 0, ldn, REMOVE_LDN);
1246 immediate_assign(host_index, id, lun, ldn, SET_LDN);
1247 get_ldn(host_index)[id][lun] = ldn; /* map ldn */
1257 if (get_scsi(host_index)[id][lun] == TYPE_NO_LUN || get_scsi(host_index)[id][lun] == TYPE_NO_DEVICE) {
1263 immediate_assign(host_index, id, lun, ldn, SET_LDN);
1264 get_ldn(host_index)[id][lun] = ldn;
1287 printk("%2s ", ti_p(get_scsi(host_index)[id][lun]));
1290 printk("%2s ", ti_l(get_ldn(host_index)[id][lun]));
1296 IBM_DS(host_index).total_scsi_devices = count_devices;
1301 IBM_DS(host_index).dyn_flag = 1; /* dynamical assignment is necessary */
1303 IBM_DS(host_index).dyn_flag = 0; /* dynamical assignment is not necessary */
1310 IBM_DS(host_index).scbs = 0;
1311 IBM_DS(host_index).long_scbs = 0;
1312 IBM_DS(host_index).total_accesses = 0;
1313 IBM_DS(host_index).total_interrupts = 0;
1314 IBM_DS(host_index).dynamical_assignments = 0;
1315 memset(IBM_DS(host_index).ldn_access, 0x0, sizeof(IBM_DS(host_index).ldn_access));
1316 memset(IBM_DS(host_index).ldn_read_access, 0x0, sizeof(IBM_DS(host_index).ldn_read_access));
1317 memset(IBM_DS(host_index).ldn_write_access, 0x0, sizeof(IBM_DS(host_index).ldn_write_access));
1318 memset(IBM_DS(host_index).ldn_inquiry_access, 0x0, sizeof(IBM_DS(host_index).ldn_inquiry_access));
1319 memset(IBM_DS(host_index).ldn_modeselect_access, 0x0, sizeof(IBM_DS(host_index).ldn_modeselect_access));
1320 memset(IBM_DS(host_index).ldn_assignments, 0x0, sizeof(IBM_DS(host_index).ldn_assignments));
1325 static int device_exists(int host_index, int ldn, int *block_length, int *device_type)
1329 if (!(device_inquiry(host_index, ldn)))
1331 buf = (unsigned char *) (&(ld(host_index)[ldn].buf));
1344 if (read_capacity(host_index, ldn)) {
1352 if (read_capacity(host_index, ldn)) {
1800 int host_index;
1807 for (host_index = 0; hosts[host_index] && hosts[host_index]->host_no != shpnt->host_no; host_index++);
1809 if (!hosts[host_index]) { /* invalid hostadapter descriptor address */
1815 max_pun = subsystem_maxid(host_index);
1818 if ((target <= subsystem_pun(host_index)) && (cmd->device->id <= subsystem_pun(host_index)))
1820 else if ((target >= subsystem_pun(host_index)) && (cmd->device->id >= subsystem_pun(host_index)))
1826 if ((get_scsi(host_index)[target][cmd->device->lun] == TYPE_NO_LUN) || (get_scsi(host_index)[target][cmd->device->lun] == TYPE_NO_DEVICE)) {
1834 ldn = get_ldn(host_index)[target][cmd->device->lun];
1837 current_ldn = next_ldn(host_index); /* stop-value for one circle */
1838 while (ld(host_index)[next_ldn(host_index)].cmd) { /* search for a occupied, but not in */
1840 next_ldn(host_index)++;
1841 if (next_ldn(host_index) >= MAX_LOG_DEV)
1842 next_ldn(host_index) = 7;
1843 if (current_ldn == next_ldn(host_index)) { /* One circle done ? */
1859 if (get_ldn(host_index)[id][lun] == next_ldn(host_index)) {
1860 get_ldn(host_index)[id][lun] = TYPE_NO_DEVICE;
1861 get_scsi(host_index)[id][lun] = TYPE_NO_DEVICE;
1866 local_checking_phase_flag(host_index) = 1;
1868 get_ldn(host_index)[target][cmd->device->lun] = next_ldn(host_index);
1870 ldn = next_ldn(host_index);
1872 immediate_assign(host_index, 0, 0, 0, REMOVE_LDN);
1874 immediate_assign(host_index, target, cmd->device->lun, ldn, SET_LDN);
1876 if (device_exists(host_index, ldn, &ld(host_index)[ldn].block_length, &ld(host_index)[ldn].device_type)) {
1877 ld(host_index)[ldn].cmd = NULL; /* To prevent panic set 0, because
1880 get_scsi(host_index)[target][cmd->device->lun] = ld(host_index)[ldn].device_type;
1882 IBM_DS(host_index).dynamical_assignments++;
1883 IBM_DS(host_index).ldn_assignments[ldn]++;
1889 immediate_assign(host_index, 0, 0, 0, REMOVE_LDN);
1896 if (get_ldn(host_index)[id][lun] <= MAX_LOG_DEV)
1897 immediate_assign(host_index, id, lun, get_ldn(host_index)[id][lun], SET_LDN);
1900 local_checking_phase_flag(host_index) = 0;
1906 next_ldn(host_index)++;
1907 if (next_ldn(host_index) >= MAX_LOG_DEV)
1908 next_ldn(host_index) = 7;
1918 if (ld(host_index)[ldn].cmd)
1923 ld(host_index)[ldn].cmd = cmd;
1926 scb = &(ld(host_index)[ldn].scb);
1927 ld(host_index)[ldn].tsb.dev_status = 0;
1929 scb->tsb_adr = isa_virt_to_bus(&(ld(host_index)[ldn].tsb));
1938 ld(host_index)[ldn].sge[i].address = (void *) (isa_page_to_bus(sl[i].page) + sl[i].offset);
1939 ld(host_index)[ldn].sge[i].byte_length = sl[i].length;
1942 scb->sys_buf_adr = isa_virt_to_bus(&(ld(host_index)[ldn].sge[0]));
1977 if (ld(host_index)[ldn].device_type == IM_DEBUG_CMD_DEVICE)
1978 printk("(SCSI-device-type=0x%x) issue scsi cmd=%02x to ldn=%d\n", ld(host_index)[ldn].device_type, scsi_cmd, ldn);
1982 last_scsi_command(host_index)[ldn] = scsi_cmd;
1983 last_scsi_type(host_index)[ldn] = IM_SCB;
1985 IBM_DS(host_index).total_accesses++;
1986 IBM_DS(host_index).ldn_access[ldn]++;
1998 switch (ld(host_index)[ldn].device_type) {
2005 IBM_DS(host_index).ldn_read_access[ldn]++; /* increase READ-access on ldn stat. */
2008 IBM_DS(host_index).ldn_write_access[ldn]++; /* increase write-count on ldn stat. */
2018 last_scsi_logical_block(host_index)[ldn] = scb->u1.log_blk_adr;
2019 last_scsi_blockcount(host_index)[ldn] = scb->u2.blk.count;
2020 scb->u2.blk.length = ld(host_index)[ldn].block_length;
2041 last_scsi_type(host_index)[ldn] = IM_LONG_SCB;
2048 IBM_DS(host_index).ldn_inquiry_access[ldn]++;
2059 last_scsi_type(host_index)[ldn] = IM_LONG_SCB;
2076 IBM_DS(host_index).ldn_modeselect_access[ldn]++;
2081 last_scsi_type(host_index)[ldn] = IM_LONG_SCB;
2090 last_scsi_type(host_index)[ldn] = IM_LONG_SCB;
2097 if (last_scsi_type(host_index)[ldn] == IM_LONG_SCB) {
2098 issue_cmd(host_index, isa_virt_to_bus(scb), IM_LONG_SCB | ldn);
2099 IBM_DS(host_index).long_scbs++;
2101 issue_cmd(host_index, isa_virt_to_bus(scb), IM_SCB | ldn);
2102 IBM_DS(host_index).scbs++;
2117 int host_index;
2127 for (host_index = 0; hosts[host_index] && hosts[host_index]->host_no != shpnt->host_no; host_index++);
2129 if (!hosts[host_index]) { /* invalid hostadapter descriptor address */
2139 max_pun = subsystem_maxid(host_index);
2142 if ((target <= subsystem_pun(host_index)) && (cmd->device->id <= subsystem_pun(host_index)))
2144 else if ((target >= subsystem_pun(host_index)) && (cmd->device->id >= subsystem_pun(host_index)))
2151 ldn = get_ldn(host_index)[target][cmd->device->lun];
2154 if (!ld(host_index)[ldn].cmd) {
2165 last_scsi_command(host_index)[ldn] = IM_ABORT_IMM_CMD;
2166 last_scsi_type(host_index)[ldn] = IM_IMM_CMD;
2167 imm_command = inl(IM_CMD_REG(host_index));
2172 if (!(inb(IM_STAT_REG(host_index)) & IM_BUSY))
2176 outl(imm_command, IM_CMD_REG(host_index));
2177 outb(IM_IMM_CMD | ldn, IM_ATTN_REG(host_index));
2196 ld(host_index)[ldn].cmd = NULL;
2205 ld(host_index)[ldn].cmd = NULL;
2230 int host_index;
2238 for (host_index = 0; hosts[host_index] && hosts[host_index]->host_no != shpnt->host_no; host_index++);
2240 if (!hosts[host_index]) /* invalid hostadapter descriptor address */
2243 if (local_checking_phase_flag(host_index)) {
2250 reset_status(host_index) = IM_RESET_IN_PROGRESS;
2251 last_scsi_command(host_index)[0xf] = IM_RESET_IMM_CMD;
2252 last_scsi_type(host_index)[0xf] = IM_IMM_CMD;
2253 imm_command = inl(IM_CMD_REG(host_index));
2258 if (!(inb(IM_STAT_REG(host_index)) & IM_BUSY))
2265 outl(imm_command, IM_CMD_REG(host_index));
2266 outb(IM_IMM_CMD | 0xf, IM_ATTN_REG(host_index));
2270 while (reset_status(host_index) == IM_RESET_IN_PROGRESS && --ticks && ((inb(IM_INTR_REG(host_index)) & 0x8f) != 0x8f)) {
2277 reset_status(host_index) = IM_RESET_FINISHED_FAIL;
2281 if ((inb(IM_INTR_REG(host_index)) & 0x8f) == 0x8f) {
2283 if (inb(IM_INTR_REG(host_index)) == 0xaf)
2284 reset_status(host_index) = IM_RESET_FINISHED_OK_NO_INT;
2285 else if (inb(IM_INTR_REG(host_index)) == 0xcf)
2286 reset_status(host_index) = IM_RESET_FINISHED_FAIL;
2288 reset_status(host_index) = IM_RESET_NOT_IN_PROGRESS_NO_INT;
2289 outb(IM_EOI | 0xf, IM_ATTN_REG(host_index));
2293 if (reset_status(host_index) == IM_RESET_FINISHED_FAIL) {
2301 cmd_aid = ld(host_index)[i].cmd;
2303 ld(host_index)[i].cmd = NULL;
2344 static int ldn_access_load(int host_index, int ldn)
2346 if (IBM_DS(host_index).total_accesses == 0)
2348 if (IBM_DS(host_index).ldn_access[ldn] == 0)
2350 return (IBM_DS(host_index).ldn_access[ldn] * 100) / IBM_DS(host_index).total_accesses;
2354 static int ldn_access_total_read_write(int host_index)
2361 a += IBM_DS(host_index).ldn_read_access[i] + IBM_DS(host_index).ldn_write_access[i];
2365 static int ldn_access_total_inquiry(int host_index)
2372 a += IBM_DS(host_index).ldn_inquiry_access[i];
2376 static int ldn_access_total_modeselect(int host_index)
2383 a += IBM_DS(host_index).ldn_modeselect_access[i];
2391 int i, id, lun, host_index;
2398 host_index = i;
2403 max_pun = subsystem_maxid(host_index);
2414 len += sprintf(buffer + len, " Base I/O-Port............: 0x%x\n", (unsigned int) (IM_CMD_REG(host_index)));
2416 len += sprintf(buffer + len, " Total Interrupts.........: %d\n", IBM_DS(host_index).total_interrupts);
2417 len += sprintf(buffer + len, " Total SCSI Accesses......: %d\n", IBM_DS(host_index).total_accesses);
2418 len += sprintf(buffer + len, " Total short SCBs.........: %d\n", IBM_DS(host_index).scbs);
2419 len += sprintf(buffer + len, " Total long SCBs..........: %d\n", IBM_DS(host_index).long_scbs);
2420 len += sprintf(buffer + len, " Total SCSI READ/WRITE..: %d\n", ldn_access_total_read_write(host_index));
2421 len += sprintf(buffer + len, " Total SCSI Inquiries...: %d\n", ldn_access_total_inquiry(host_index));
2422 len += sprintf(buffer + len, " Total SCSI Modeselects.: %d\n", ldn_access_total_modeselect(host_index));
2423 len += sprintf(buffer + len, " Total SCSI other cmds..: %d\n", IBM_DS(host_index).total_accesses - ldn_access_total_read_write(host_index)
2424 - ldn_access_total_modeselect(host_index)
2425 - ldn_access_total_inquiry(host_index));
2426 len += sprintf(buffer + len, " Total SCSI command fails.: %d\n\n", IBM_DS(host_index).total_errors);
2431 len += sprintf(buffer + len, " %2X | %3d | %8d | %8d | %8d\n", i, ldn_access_load(host_index, i), IBM_DS(host_index).ldn_read_access[i], IBM_DS(host_index).ldn_write_access[i], IBM_DS(host_index).ldn_assignments[i]);
2434 len += sprintf(buffer + len, " Number of physical SCSI-devices..: %d (+ Adapter)\n", IBM_DS(host_index).total_scsi_devices);
2435 len += sprintf(buffer + len, " Dynamical Assignment necessary...: %s\n", IBM_DS(host_index).dyn_flag ? "Yes" : "No ");
2436 len += sprintf(buffer + len, " Next LDN to be assigned..........: 0x%x\n", next_ldn(host_index));
2437 len += sprintf(buffer + len, " Dynamical assignments done yet...: %d\n", IBM_DS(host_index).dynamical_assignments);
2444 len += sprintf(buffer + len, "%2s ", ti_p(get_scsi(host_index)[id][lun]));
2447 len += sprintf(buffer + len, "%2s ", ti_l(get_ldn(host_index)[id][lun]));