scsi_low.c (71508) | scsi_low.c (71999) |
---|---|
1/* $FreeBSD: head/sys/cam/scsi/scsi_low.c 71508 2001-01-24 01:46:57Z jhb $ */ | 1/* $FreeBSD: head/sys/cam/scsi/scsi_low.c 71999 2001-02-04 13:13:25Z phk $ */ |
2/* $NecBSD: scsi_low.c,v 1.24 1999/07/26 06:27:01 honda Exp $ */ 3/* $NetBSD$ */ 4 5#define SCSI_LOW_STATICS 6#define SCSI_LOW_WARNINGS 7#ifdef __NetBSD__ 8#define SCSI_LOW_TARGET_OPEN 9#define SCSI_LOW_INFORM --- 265 unchanged lines hidden (view full) --- 275 **************************************************************/ 276static struct targ_info * 277scsi_low_alloc_ti(slp, targ) 278 struct scsi_low_softc *slp; 279 int targ; 280{ 281 struct targ_info *ti; 282 | 2/* $NecBSD: scsi_low.c,v 1.24 1999/07/26 06:27:01 honda Exp $ */ 3/* $NetBSD$ */ 4 5#define SCSI_LOW_STATICS 6#define SCSI_LOW_WARNINGS 7#ifdef __NetBSD__ 8#define SCSI_LOW_TARGET_OPEN 9#define SCSI_LOW_INFORM --- 265 unchanged lines hidden (view full) --- 275 **************************************************************/ 276static struct targ_info * 277scsi_low_alloc_ti(slp, targ) 278 struct scsi_low_softc *slp; 279 int targ; 280{ 281 struct targ_info *ti; 282 |
283 if (slp->sl_titab.tqh_first == NULL) | 283 if (TAILQ_FIRST(&slp->sl_titab) == NULL) |
284 TAILQ_INIT(&slp->sl_titab); 285 286 ti = malloc(sizeof(struct targ_info), M_DEVBUF, M_NOWAIT); 287 if (ti == NULL) 288 panic("%s short of memory\n", slp->sl_xname); 289 290 memset(ti, 0, sizeof(struct targ_info)); 291 ti->ti_id = targ; --- 9 unchanged lines hidden (view full) --- 301 302static void 303scsi_low_free_ti(slp) 304 struct scsi_low_softc *slp; 305{ 306 struct targ_info *ti, *tib; 307 struct lun_info *li, *nli; 308 | 284 TAILQ_INIT(&slp->sl_titab); 285 286 ti = malloc(sizeof(struct targ_info), M_DEVBUF, M_NOWAIT); 287 if (ti == NULL) 288 panic("%s short of memory\n", slp->sl_xname); 289 290 memset(ti, 0, sizeof(struct targ_info)); 291 ti->ti_id = targ; --- 9 unchanged lines hidden (view full) --- 301 302static void 303scsi_low_free_ti(slp) 304 struct scsi_low_softc *slp; 305{ 306 struct targ_info *ti, *tib; 307 struct lun_info *li, *nli; 308 |
309 for (ti = slp->sl_titab.tqh_first; ti; ti = tib) | 309 for (ti = TAILQ_FIRST(&slp->sl_titab); ti; ti = tib) |
310 { | 310 { |
311 tib = ti->ti_chain.tqe_next; | 311 tib = TAILQ_NEXT(ti, ti_chain); |
312 for (li = LIST_FIRST(&ti->ti_litab); li != NULL; li = nli) 313 { 314 nli = LIST_NEXT(li, lun_chain); 315 free(li, M_DEVBUF); 316 } 317 free(ti, M_DEVBUF); 318 } 319} --- 16 unchanged lines hidden (view full) --- 336 cb->ccb_tc -= SCSI_LOW_TIMEOUT_CHECK_INTERVAL; 337 if (cb->ccb_tc < 0) 338 goto bus_reset; 339 } 340 else if (slp->sl_disc > 0) 341 { 342 struct targ_info *ti; 343 | 312 for (li = LIST_FIRST(&ti->ti_litab); li != NULL; li = nli) 313 { 314 nli = LIST_NEXT(li, lun_chain); 315 free(li, M_DEVBUF); 316 } 317 free(ti, M_DEVBUF); 318 } 319} --- 16 unchanged lines hidden (view full) --- 336 cb->ccb_tc -= SCSI_LOW_TIMEOUT_CHECK_INTERVAL; 337 if (cb->ccb_tc < 0) 338 goto bus_reset; 339 } 340 else if (slp->sl_disc > 0) 341 { 342 struct targ_info *ti; 343 |
344 for (ti = slp->sl_titab.tqh_first; ti != NULL; 345 ti = ti->ti_chain.tqe_next) | 344 for (ti = TAILQ_FIRST(&slp->sl_titab); ti != NULL; 345 ti = TAILQ_NEXT(ti, ti_chain)) |
346 { | 346 { |
347 for (cb = ti->ti_discq.tqh_first; cb != NULL; 348 cb = cb->ccb_chain.tqe_next) | 347 for (cb = TAILQ_FIRST(&ti->ti_discq); cb != NULL; 348 cb = TAILQ_NEXT(cb, ccb_chain)) |
349 { 350 cb->ccb_tc -= SCSI_LOW_TIMEOUT_CHECK_INTERVAL; 351 if (cb->ccb_tc < 0) 352 goto bus_reset; 353 } 354 } 355 } 356 else 357 { | 349 { 350 cb->ccb_tc -= SCSI_LOW_TIMEOUT_CHECK_INTERVAL; 351 if (cb->ccb_tc < 0) 352 goto bus_reset; 353 } 354 } 355 } 356 else 357 { |
358 cb = slp->sl_start.tqh_first; | 358 cb = TAILQ_FIRST(&slp->sl_start); |
359 if (cb != NULL) 360 { 361 cb->ccb_tc -= SCSI_LOW_TIMEOUT_CHECK_INTERVAL; 362 if (cb->ccb_tc < 0) 363 goto bus_reset; 364 } 365 else if ((slp->sl_flags & HW_POWERCTRL) != 0) 366 { --- 233 unchanged lines hidden (view full) --- 600} 601#endif 602 603int 604scsi_low_dettach(slp) 605 struct scsi_low_softc *slp; 606{ 607 | 359 if (cb != NULL) 360 { 361 cb->ccb_tc -= SCSI_LOW_TIMEOUT_CHECK_INTERVAL; 362 if (cb->ccb_tc < 0) 363 goto bus_reset; 364 } 365 else if ((slp->sl_flags & HW_POWERCTRL) != 0) 366 { --- 233 unchanged lines hidden (view full) --- 600} 601#endif 602 603int 604scsi_low_dettach(slp) 605 struct scsi_low_softc *slp; 606{ 607 |
608 if (slp->sl_disc > 0 || slp->sl_start.tqh_first != NULL) | 608 if (slp->sl_disc > 0 || TAILQ_FIRST(&slp->sl_start) != NULL) |
609 return EBUSY; 610 611 /* 612 * scsipi does not have dettach bus fucntion. 613 * 614 scsipi_dettach_scsibus(&slp->sl_link); 615 */ 616 --- 308 unchanged lines hidden (view full) --- 925 ti = slp->sl_nexus; 926 if (ti != NULL) 927 { 928 scsi_low_info(slp, NULL, "NEXUS INCOSISTENT"); 929 panic("%s: inconsistent(target)\n", slp->sl_xname); 930 } 931#endif /* SCSI_LOW_DIAGNOSTIC */ 932 | 609 return EBUSY; 610 611 /* 612 * scsipi does not have dettach bus fucntion. 613 * 614 scsipi_dettach_scsibus(&slp->sl_link); 615 */ 616 --- 308 unchanged lines hidden (view full) --- 925 ti = slp->sl_nexus; 926 if (ti != NULL) 927 { 928 scsi_low_info(slp, NULL, "NEXUS INCOSISTENT"); 929 panic("%s: inconsistent(target)\n", slp->sl_xname); 930 } 931#endif /* SCSI_LOW_DIAGNOSTIC */ 932 |
933 for (cb = slp->sl_start.tqh_first; cb != NULL; 934 cb = cb->ccb_chain.tqe_next) | 933 for (cb = TAILQ_FIRST(&slp->sl_start); cb != NULL; 934 cb = TAILQ_NEXT(cb, ccb_chain)) |
935 { 936 ti = cb->ti; 937 li = cb->li; 938 if (ti->ti_phase == PH_NULL) 939 goto scsi_low_cmd_start; 940 if (ti->ti_phase == PH_DISC && li->li_disc < li->li_maxnexus) 941 goto scsi_low_cmd_start; 942 } --- 357 unchanged lines hidden (view full) --- 1300 1301 /* free our target */ 1302 TAILQ_REMOVE(&slp->sl_start, cb, ccb_chain); 1303 scsi_low_free_ccb(cb); 1304 return SCSI_LOW_DONE_COMPLETE; 1305 1306retry: 1307 cb->ccb_rcnt ++; | 935 { 936 ti = cb->ti; 937 li = cb->li; 938 if (ti->ti_phase == PH_NULL) 939 goto scsi_low_cmd_start; 940 if (ti->ti_phase == PH_DISC && li->li_disc < li->li_maxnexus) 941 goto scsi_low_cmd_start; 942 } --- 357 unchanged lines hidden (view full) --- 1300 1301 /* free our target */ 1302 TAILQ_REMOVE(&slp->sl_start, cb, ccb_chain); 1303 scsi_low_free_ccb(cb); 1304 return SCSI_LOW_DONE_COMPLETE; 1305 1306retry: 1307 cb->ccb_rcnt ++; |
1308 if (slp->sl_start.tqh_first != cb) | 1308 if (TAILQ_FIRST(&slp->sl_start) != cb) |
1309 { 1310 TAILQ_REMOVE(&slp->sl_start, cb, ccb_chain); 1311 TAILQ_INSERT_HEAD(&slp->sl_start, cb, ccb_chain); 1312 } 1313 return SCSI_LOW_DONE_RETRY; 1314} 1315 1316/************************************************************** --- 25 unchanged lines hidden (view full) --- 1342 if (fdone != 0 && cb->ccb_rcnt ++ >= slp->sl_max_retry) 1343 { 1344 cb->ccb_error |= FATALIO; 1345 scsi_low_done(slp, cb); 1346 } 1347 } 1348 1349 /* disconnected nexus */ | 1309 { 1310 TAILQ_REMOVE(&slp->sl_start, cb, ccb_chain); 1311 TAILQ_INSERT_HEAD(&slp->sl_start, cb, ccb_chain); 1312 } 1313 return SCSI_LOW_DONE_RETRY; 1314} 1315 1316/************************************************************** --- 25 unchanged lines hidden (view full) --- 1342 if (fdone != 0 && cb->ccb_rcnt ++ >= slp->sl_max_retry) 1343 { 1344 cb->ccb_error |= FATALIO; 1345 scsi_low_done(slp, cb); 1346 } 1347 } 1348 1349 /* disconnected nexus */ |
1350 for (ti = slp->sl_titab.tqh_first; ti != NULL; 1351 ti = ti->ti_chain.tqe_next) | 1350 for (ti = TAILQ_FIRST(&slp->sl_titab); ti != NULL; 1351 ti = TAILQ_NEXT(ti, ti_chain)) |
1352 { | 1352 { |
1353 for (cb = ti->ti_discq.tqh_first; cb != NULL; cb = ncb) | 1353 for (cb = TAILQ_FIRST(&ti->ti_discq); cb != NULL; cb = ncb) |
1354 { | 1354 { |
1355 ncb = cb->ccb_chain.tqe_next; | 1355 ncb = TAILQ_NEXT(cb, ccb_chain); |
1356 TAILQ_REMOVE(&ti->ti_discq, cb, ccb_chain); 1357 TAILQ_INSERT_HEAD(&slp->sl_start, cb, ccb_chain); 1358 scsi_low_clear_ccb(cb); 1359 if (fdone != 0 && cb->ccb_rcnt ++ >= slp->sl_max_retry) 1360 { 1361 cb->ccb_error |= FATALIO; 1362 scsi_low_done(slp, cb); 1363 } --- 91 unchanged lines hidden (view full) --- 1455 scsi_low_tag_t tag; 1456{ 1457 struct scsi_low_softc *slp = ti->ti_sc; 1458 struct slccb *cb; 1459 1460 /* 1461 * Search ccb matching with lun and tag. 1462 */ | 1356 TAILQ_REMOVE(&ti->ti_discq, cb, ccb_chain); 1357 TAILQ_INSERT_HEAD(&slp->sl_start, cb, ccb_chain); 1358 scsi_low_clear_ccb(cb); 1359 if (fdone != 0 && cb->ccb_rcnt ++ >= slp->sl_max_retry) 1360 { 1361 cb->ccb_error |= FATALIO; 1362 scsi_low_done(slp, cb); 1363 } --- 91 unchanged lines hidden (view full) --- 1455 scsi_low_tag_t tag; 1456{ 1457 struct scsi_low_softc *slp = ti->ti_sc; 1458 struct slccb *cb; 1459 1460 /* 1461 * Search ccb matching with lun and tag. 1462 */ |
1463 cb = ti->ti_discq.tqh_first; 1464 for ( ; cb != NULL; cb = cb->ccb_chain.tqe_next) | 1463 cb = TAILQ_FIRST(&ti->ti_discq); 1464 for ( ; cb != NULL; cb = TAILQ_NEXT(cb, ccb_chain)) |
1465 if (cb->li == li && cb->ccb_tag == tag) 1466 goto found; 1467 return cb; 1468 1469 /* 1470 * establish our ccb nexus 1471 */ 1472found: --- 1018 unchanged lines hidden (view full) --- 2491 struct scsi_low_softc *slp; 2492 struct targ_info *ti; 2493 u_char *s; 2494{ 2495 2496 printf("%s: SCSI_LOW: %s\n", slp->sl_xname, s); 2497 if (ti == NULL) 2498 { | 1465 if (cb->li == li && cb->ccb_tag == tag) 1466 goto found; 1467 return cb; 1468 1469 /* 1470 * establish our ccb nexus 1471 */ 1472found: --- 1018 unchanged lines hidden (view full) --- 2491 struct scsi_low_softc *slp; 2492 struct targ_info *ti; 2493 u_char *s; 2494{ 2495 2496 printf("%s: SCSI_LOW: %s\n", slp->sl_xname, s); 2497 if (ti == NULL) 2498 { |
2499 for (ti = slp->sl_titab.tqh_first; ti != NULL; 2500 ti = ti->ti_chain.tqe_next) | 2499 for (ti = TAILQ_FIRST(&slp->sl_titab); ti != NULL; 2500 ti = TAILQ_NEXT(ti, ti_chain)) |
2501 scsi_low_print(slp, ti); 2502 } 2503 else 2504 scsi_low_print(slp, ti); 2505 2506} 2507 2508static u_char *phase[] = --- 83 unchanged lines hidden --- | 2501 scsi_low_print(slp, ti); 2502 } 2503 else 2504 scsi_low_print(slp, ti); 2505 2506} 2507 2508static u_char *phase[] = --- 83 unchanged lines hidden --- |