iir.c (113350) | iir.c (114001) |
---|---|
1/* $FreeBSD: head/sys/dev/iir/iir.c 113350 2003-04-10 23:50:06Z mux $ */ | 1/* $FreeBSD: head/sys/dev/iir/iir.c 114001 2003-04-25 05:37:04Z scottl $ */ |
2/* | 2/* |
3 * Copyright (c) 2000-01 Intel Corporation | 3 * Copyright (c) 2000-03 Intel Corporation |
4 * All Rights Reserved 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions, and the following disclaimer, 11 * without modification, immediately at the beginning of the file. --- 24 unchanged lines hidden (view full) --- 36 * 37 * credits: Niklas Hallqvist; OpenBSD driver for the ICP Controllers. 38 * Mike Smith; Some driver source code. 39 * FreeBSD.ORG; Great O/S to work on and for. 40 * 41 * TODO: 42 */ 43 | 4 * All Rights Reserved 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions, and the following disclaimer, 11 * without modification, immediately at the beginning of the file. --- 24 unchanged lines hidden (view full) --- 36 * 37 * credits: Niklas Hallqvist; OpenBSD driver for the ICP Controllers. 38 * Mike Smith; Some driver source code. 39 * FreeBSD.ORG; Great O/S to work on and for. 40 * 41 * TODO: 42 */ 43 |
44#ident "$Id: iir.c 1.2 2001/06/21 20:28:32 achim Exp $" | 44#ident "$Id: iir.c 1.3 2003/03/21 16:28:32 achim Exp $" |
45 46#define _IIR_C_ 47 48/* #include "opt_iir.h" */ 49#include <sys/param.h> 50#include <sys/systm.h> 51#include <sys/endian.h> 52#include <sys/eventhandler.h> --- 148 unchanged lines hidden (view full) --- 201 SLIST_INIT(&gdt->sc_free_gccb); 202 SLIST_INIT(&gdt->sc_pending_gccb); 203 TAILQ_INIT(&gdt->sc_ccb_queue); 204 TAILQ_INIT(&gdt->sc_ucmd_queue); 205 TAILQ_INSERT_TAIL(&gdt_softcs, gdt, links); 206 207 /* DMA tag for mapping buffers into device visible space. */ 208 if (bus_dma_tag_create(gdt->sc_parent_dmat, /*alignment*/1, /*boundary*/0, | 45 46#define _IIR_C_ 47 48/* #include "opt_iir.h" */ 49#include <sys/param.h> 50#include <sys/systm.h> 51#include <sys/endian.h> 52#include <sys/eventhandler.h> --- 148 unchanged lines hidden (view full) --- 201 SLIST_INIT(&gdt->sc_free_gccb); 202 SLIST_INIT(&gdt->sc_pending_gccb); 203 TAILQ_INIT(&gdt->sc_ccb_queue); 204 TAILQ_INIT(&gdt->sc_ucmd_queue); 205 TAILQ_INSERT_TAIL(&gdt_softcs, gdt, links); 206 207 /* DMA tag for mapping buffers into device visible space. */ 208 if (bus_dma_tag_create(gdt->sc_parent_dmat, /*alignment*/1, /*boundary*/0, |
209 /*lowaddr*/BUS_SPACE_MAXADDR, | 209 /*lowaddr*/BUS_SPACE_MAXADDR_32BIT, |
210 /*highaddr*/BUS_SPACE_MAXADDR, 211 /*filter*/NULL, /*filterarg*/NULL, 212 /*maxsize*/MAXBSIZE, /*nsegments*/GDT_MAXSG, 213 /*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT, 214 /*flags*/BUS_DMA_ALLOCNOW, 215 &gdt->sc_buffer_dmat) != 0) { 216 printf("iir%d: bus_dma_tag_create(...,gdt->sc_buffer_dmat) failed\n", 217 gdt->sc_hanum); 218 return (1); 219 } 220 gdt->sc_init_level++; 221 222 /* DMA tag for our ccb structures */ | 210 /*highaddr*/BUS_SPACE_MAXADDR, 211 /*filter*/NULL, /*filterarg*/NULL, 212 /*maxsize*/MAXBSIZE, /*nsegments*/GDT_MAXSG, 213 /*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT, 214 /*flags*/BUS_DMA_ALLOCNOW, 215 &gdt->sc_buffer_dmat) != 0) { 216 printf("iir%d: bus_dma_tag_create(...,gdt->sc_buffer_dmat) failed\n", 217 gdt->sc_hanum); 218 return (1); 219 } 220 gdt->sc_init_level++; 221 222 /* DMA tag for our ccb structures */ |
223 if (bus_dma_tag_create(gdt->sc_parent_dmat, /*alignment*/1, /*boundary*/0, 224 /*lowaddr*/BUS_SPACE_MAXADDR, | 223 if (bus_dma_tag_create(gdt->sc_parent_dmat, 224 /*alignment*/1, 225 /*boundary*/0, 226 /*lowaddr*/BUS_SPACE_MAXADDR_32BIT, |
225 /*highaddr*/BUS_SPACE_MAXADDR, | 227 /*highaddr*/BUS_SPACE_MAXADDR, |
226 /*filter*/NULL, /*filterarg*/NULL, 227 GDT_MAXCMDS * sizeof(struct gdt_ccb), | 228 /*filter*/NULL, 229 /*filterarg*/NULL, 230 GDT_MAXCMDS * sizeof(struct gdt_ccb), /* maxsize */ |
228 /*nsegments*/1, 229 /*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT, 230 /*flags*/0, &gdt->sc_gccb_dmat) != 0) { 231 printf("iir%d: bus_dma_tag_create(...,gdt->sc_gccb_dmat) failed\n", 232 gdt->sc_hanum); 233 return (1); 234 } 235 gdt->sc_init_level++; --- 152 unchanged lines hidden (view full) --- 388 panic("iir%d: Scatter/Gather Cache Service " 389 "required but not supported!\n", gdt->sc_hanum); 390 gdt_free_ccb(gdt, gccb); 391 return (1); 392 } 393 } 394 } 395 | 231 /*nsegments*/1, 232 /*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT, 233 /*flags*/0, &gdt->sc_gccb_dmat) != 0) { 234 printf("iir%d: bus_dma_tag_create(...,gdt->sc_gccb_dmat) failed\n", 235 gdt->sc_hanum); 236 return (1); 237 } 238 gdt->sc_init_level++; --- 152 unchanged lines hidden (view full) --- 391 panic("iir%d: Scatter/Gather Cache Service " 392 "required but not supported!\n", gdt->sc_hanum); 393 gdt_free_ccb(gdt, gccb); 394 return (1); 395 } 396 } 397 } 398 |
399 /* OEM */ 400 gdt_enc32(gccb->gc_scratch + GDT_OEM_VERSION, 0x01); 401 gdt_enc32(gccb->gc_scratch + GDT_OEM_BUFSIZE, sizeof(gdt_oem_record_t)); 402 if (gdt_internal_cmd(gdt, gccb, GDT_CACHESERVICE, GDT_IOCTL, 403 GDT_OEM_STR_RECORD, GDT_INVALID_CHANNEL, 404 sizeof(gdt_oem_str_record_t))) { 405 strncpy(gdt->oem_name, ((gdt_oem_str_record_t *) 406 gccb->gc_scratch)->text.scsi_host_drive_inquiry_vendor_id, 7); 407 gdt->oem_name[7]='\0'; 408 } else { 409 /* Old method, based on PCI ID */ 410 if (gdt->sc_vendor == INTEL_VENDOR_ID) 411 strcpy(gdt->oem_name,"Intel "); 412 else 413 strcpy(gdt->oem_name,"ICP "); 414 } 415 |
|
396 /* Scan for cache devices */ 397 for (i = 0; i < cdev_cnt && i < GDT_MAX_HDRIVES; i++) { 398 if (gdt_internal_cmd(gdt, gccb, GDT_CACHESERVICE, GDT_INFO, 399 i, 0, 0)) { 400 gdt->sc_hdr[i].hd_present = 1; 401 gdt->sc_hdr[i].hd_size = gdt->sc_info; 402 403 /* --- 339 unchanged lines hidden (view full) --- 743 sim_links.tqe); 744 ++gdt_stat.req_queue_act; 745 if (gdt_stat.req_queue_act > gdt_stat.req_queue_max) 746 gdt_stat.req_queue_max = gdt_stat.req_queue_act; 747 next_cmd = FALSE; 748 } 749 } else if (target >= GDT_MAX_HDRIVES || 750 !gdt->sc_hdr[target].hd_present || lun != 0) { | 416 /* Scan for cache devices */ 417 for (i = 0; i < cdev_cnt && i < GDT_MAX_HDRIVES; i++) { 418 if (gdt_internal_cmd(gdt, gccb, GDT_CACHESERVICE, GDT_INFO, 419 i, 0, 0)) { 420 gdt->sc_hdr[i].hd_present = 1; 421 gdt->sc_hdr[i].hd_size = gdt->sc_info; 422 423 /* --- 339 unchanged lines hidden (view full) --- 763 sim_links.tqe); 764 ++gdt_stat.req_queue_act; 765 if (gdt_stat.req_queue_act > gdt_stat.req_queue_max) 766 gdt_stat.req_queue_max = gdt_stat.req_queue_act; 767 next_cmd = FALSE; 768 } 769 } else if (target >= GDT_MAX_HDRIVES || 770 !gdt->sc_hdr[target].hd_present || lun != 0) { |
751 ccbh->status = CAM_SEL_TIMEOUT; | 771 ccbh->status = CAM_DEV_NOT_THERE; |
752 --gdt_stat.io_count_act; 753 xpt_done(ccb); 754 } else { 755 /* cache service command */ 756 if (cmd == READ_6 || cmd == WRITE_6 || 757 cmd == READ_10 || cmd == WRITE_10) { 758 if ((gccb = gdt_cache_cmd(gdt, ccb, &lock)) == NULL) { 759 TAILQ_INSERT_HEAD(&gdt->sc_ccb_queue, &ccb->ccb_h, --- 415 unchanged lines hidden (view full) --- 1175 bzero(inq, sizeof(struct scsi_inquiry_data)); 1176 inq->device = (gdt->sc_hdr[t].hd_devtype & 4) ? 1177 T_CDROM : T_DIRECT; 1178 inq->dev_qual2 = (gdt->sc_hdr[t].hd_devtype & 1) ? 0x80 : 0; 1179 inq->version = SCSI_REV_2; 1180 inq->response_format = 2; 1181 inq->additional_length = 32; 1182 inq->flags = SID_CmdQue | SID_Sync; | 772 --gdt_stat.io_count_act; 773 xpt_done(ccb); 774 } else { 775 /* cache service command */ 776 if (cmd == READ_6 || cmd == WRITE_6 || 777 cmd == READ_10 || cmd == WRITE_10) { 778 if ((gccb = gdt_cache_cmd(gdt, ccb, &lock)) == NULL) { 779 TAILQ_INSERT_HEAD(&gdt->sc_ccb_queue, &ccb->ccb_h, --- 415 unchanged lines hidden (view full) --- 1195 bzero(inq, sizeof(struct scsi_inquiry_data)); 1196 inq->device = (gdt->sc_hdr[t].hd_devtype & 4) ? 1197 T_CDROM : T_DIRECT; 1198 inq->dev_qual2 = (gdt->sc_hdr[t].hd_devtype & 1) ? 0x80 : 0; 1199 inq->version = SCSI_REV_2; 1200 inq->response_format = 2; 1201 inq->additional_length = 32; 1202 inq->flags = SID_CmdQue | SID_Sync; |
1183 strcpy(inq->vendor, "IIR "); | 1203 strcpy(inq->vendor, gdt->oem_name); |
1184 sprintf(inq->product, "Host Drive #%02d", t); 1185 strcpy(inq->revision, " "); 1186 break; 1187 } 1188 case MODE_SENSE_6: 1189 { 1190 struct mpd_data { 1191 struct scsi_mode_hdr_6 hd; --- 97 unchanged lines hidden (view full) --- 1289 gdt_enc32(gdt->sc_cmd + GDT_CMD_UNION + GDT_RAW_SDATA, 1290 0xffffffffUL); 1291 1292 gdt->sc_cmd_len = roundup(GDT_CMD_UNION + GDT_RAW_SG_LST + 1293 nseg * GDT_SG_SZ, sizeof(u_int32_t)); 1294 } 1295 1296 if (nseg != 0) { | 1204 sprintf(inq->product, "Host Drive #%02d", t); 1205 strcpy(inq->revision, " "); 1206 break; 1207 } 1208 case MODE_SENSE_6: 1209 { 1210 struct mpd_data { 1211 struct scsi_mode_hdr_6 hd; --- 97 unchanged lines hidden (view full) --- 1309 gdt_enc32(gdt->sc_cmd + GDT_CMD_UNION + GDT_RAW_SDATA, 1310 0xffffffffUL); 1311 1312 gdt->sc_cmd_len = roundup(GDT_CMD_UNION + GDT_RAW_SG_LST + 1313 nseg * GDT_SG_SZ, sizeof(u_int32_t)); 1314 } 1315 1316 if (nseg != 0) { |
1297 int op; 1298 1299 if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) 1300 op = BUS_DMASYNC_PREREAD; 1301 else 1302 op = BUS_DMASYNC_PREWRITE; 1303 bus_dmamap_sync(gdt->sc_buffer_dmat, gccb->gc_dmamap, op); | 1317 bus_dmamap_sync(gdt->sc_buffer_dmat, gccb->gc_dmamap, 1318 (ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN ? 1319 BUS_DMASYNC_PREREAD : BUS_DMASYNC_PREWRITE); |
1304 } 1305 1306 /* We must NOT abort the command here if CAM_REQ_INPROG is not set, 1307 * because command semaphore is already set! 1308 */ 1309 1310 ccb->ccb_h.status |= CAM_SIM_QUEUED; 1311 /* timeout handling */ --- 365 unchanged lines hidden (view full) --- 1677 gdt_sync_event(gdt, ctx.service, ctx.istatus, gccb); 1678 if (!(gdt->sc_state & GDT_POLLING)) 1679 splx(lock); 1680 gdt_next(gdt); 1681 break; 1682 } 1683} 1684 | 1320 } 1321 1322 /* We must NOT abort the command here if CAM_REQ_INPROG is not set, 1323 * because command semaphore is already set! 1324 */ 1325 1326 ccb->ccb_h.status |= CAM_SIM_QUEUED; 1327 /* timeout handling */ --- 365 unchanged lines hidden (view full) --- 1693 gdt_sync_event(gdt, ctx.service, ctx.istatus, gccb); 1694 if (!(gdt->sc_state & GDT_POLLING)) 1695 splx(lock); 1696 gdt_next(gdt); 1697 break; 1698 } 1699} 1700 |
1685static int | 1701int |
1686gdt_async_event(struct gdt_softc *gdt, int service) 1687{ 1688 struct gdt_ccb *gccb; 1689 1690 GDT_DPRINTF(GDT_D_INTR, ("gdt_async_event(%p, %d)\n", gdt, service)); 1691 1692 if (service == GDT_SCREENSERVICE) { 1693 if (gdt->sc_status == GDT_MSG_REQUEST) { --- 43 unchanged lines hidden (view full) --- 1737 } 1738 gdt_store_event(GDT_ES_ASYNC, service, &gdt->sc_dvr); 1739 printf("iir%d: %s\n", gdt->sc_hanum, gdt->sc_dvr.event_string); 1740 } 1741 1742 return (0); 1743} 1744 | 1702gdt_async_event(struct gdt_softc *gdt, int service) 1703{ 1704 struct gdt_ccb *gccb; 1705 1706 GDT_DPRINTF(GDT_D_INTR, ("gdt_async_event(%p, %d)\n", gdt, service)); 1707 1708 if (service == GDT_SCREENSERVICE) { 1709 if (gdt->sc_status == GDT_MSG_REQUEST) { --- 43 unchanged lines hidden (view full) --- 1753 } 1754 gdt_store_event(GDT_ES_ASYNC, service, &gdt->sc_dvr); 1755 printf("iir%d: %s\n", gdt->sc_hanum, gdt->sc_dvr.event_string); 1756 } 1757 1758 return (0); 1759} 1760 |
1745static int | 1761int |
1746gdt_sync_event(struct gdt_softc *gdt, int service, 1747 u_int8_t index, struct gdt_ccb *gccb) 1748{ 1749 union ccb *ccb; | 1762gdt_sync_event(struct gdt_softc *gdt, int service, 1763 u_int8_t index, struct gdt_ccb *gccb) 1764{ 1765 union ccb *ccb; |
1750 int op; | |
1751 1752 GDT_DPRINTF(GDT_D_INTR, 1753 ("gdt_sync_event(%p, %d, %d, %p)\n", gdt,service,index,gccb)); 1754 1755 ccb = gccb->gc_ccb; 1756 1757 if (service == GDT_SCREENSERVICE) { 1758 u_int32_t msg_len; --- 90 unchanged lines hidden (view full) --- 1849 gdt, gccb)); 1850 TAILQ_INSERT_HEAD(&gdt->sc_ccb_queue, &ccb->ccb_h, sim_links.tqe); 1851 ++gdt_stat.req_queue_act; 1852 if (gdt_stat.req_queue_act > gdt_stat.req_queue_max) 1853 gdt_stat.req_queue_max = gdt_stat.req_queue_act; 1854 return (2); 1855 } 1856 | 1766 1767 GDT_DPRINTF(GDT_D_INTR, 1768 ("gdt_sync_event(%p, %d, %d, %p)\n", gdt,service,index,gccb)); 1769 1770 ccb = gccb->gc_ccb; 1771 1772 if (service == GDT_SCREENSERVICE) { 1773 u_int32_t msg_len; --- 90 unchanged lines hidden (view full) --- 1864 gdt, gccb)); 1865 TAILQ_INSERT_HEAD(&gdt->sc_ccb_queue, &ccb->ccb_h, sim_links.tqe); 1866 ++gdt_stat.req_queue_act; 1867 if (gdt_stat.req_queue_act > gdt_stat.req_queue_max) 1868 gdt_stat.req_queue_max = gdt_stat.req_queue_act; 1869 return (2); 1870 } 1871 |
1857 if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) 1858 op = BUS_DMASYNC_POSTREAD; 1859 else 1860 op = BUS_DMASYNC_POSTWRITE; 1861 bus_dmamap_sync(gdt->sc_buffer_dmat, gccb->gc_dmamap, op); | 1872 bus_dmamap_sync(gdt->sc_buffer_dmat, gccb->gc_dmamap, 1873 (ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN ? 1874 BUS_DMASYNC_POSTREAD : BUS_DMASYNC_POSTWRITE); |
1862 1863 ccb->csio.resid = 0; 1864 if (gdt->sc_status == GDT_S_OK) { 1865 ccb->ccb_h.status = CAM_REQ_CMP; 1866 } else { 1867 /* error */ 1868 if (gccb->gc_service == GDT_CACHESERVICE) { 1869 ccb->ccb_h.status = CAM_SCSI_STATUS_ERROR | CAM_AUTOSNS_VALID; --- 11 unchanged lines hidden (view full) --- 1881 gdt->sc_dvr.eu.sync.hostdrive = ccb->ccb_h.target_id; 1882 if (gdt->sc_status >= 0x8000) 1883 gdt_store_event(GDT_ES_SYNC, 0, &gdt->sc_dvr); 1884 else 1885 gdt_store_event(GDT_ES_SYNC, service, &gdt->sc_dvr); 1886 } else { 1887 /* raw service */ 1888 if (gdt->sc_status != GDT_S_RAW_SCSI || gdt->sc_info >= 0x100) { | 1875 1876 ccb->csio.resid = 0; 1877 if (gdt->sc_status == GDT_S_OK) { 1878 ccb->ccb_h.status = CAM_REQ_CMP; 1879 } else { 1880 /* error */ 1881 if (gccb->gc_service == GDT_CACHESERVICE) { 1882 ccb->ccb_h.status = CAM_SCSI_STATUS_ERROR | CAM_AUTOSNS_VALID; --- 11 unchanged lines hidden (view full) --- 1894 gdt->sc_dvr.eu.sync.hostdrive = ccb->ccb_h.target_id; 1895 if (gdt->sc_status >= 0x8000) 1896 gdt_store_event(GDT_ES_SYNC, 0, &gdt->sc_dvr); 1897 else 1898 gdt_store_event(GDT_ES_SYNC, service, &gdt->sc_dvr); 1899 } else { 1900 /* raw service */ 1901 if (gdt->sc_status != GDT_S_RAW_SCSI || gdt->sc_info >= 0x100) { |
1889 ccb->ccb_h.status = CAM_SEL_TIMEOUT; | 1902 ccb->ccb_h.status = CAM_DEV_NOT_THERE; |
1890 } else { 1891 ccb->ccb_h.status = CAM_SCSI_STATUS_ERROR|CAM_AUTOSNS_VALID; 1892 ccb->csio.scsi_status = gdt->sc_info; 1893 bcopy(gccb->gc_scratch, &ccb->csio.sense_data, 1894 ccb->csio.sense_len); 1895 } 1896 } 1897 } --- 120 unchanged lines hidden --- | 1903 } else { 1904 ccb->ccb_h.status = CAM_SCSI_STATUS_ERROR|CAM_AUTOSNS_VALID; 1905 ccb->csio.scsi_status = gdt->sc_info; 1906 bcopy(gccb->gc_scratch, &ccb->csio.sense_data, 1907 ccb->csio.sense_len); 1908 } 1909 } 1910 } --- 120 unchanged lines hidden --- |