cam_xpt.c (75f51904b5b62332719ffaaedafb36cef6940905) cam_xpt.c (c19cf05d0d8403e03e76918a9b3ebbed483787b2)
1/*
2 * Implementation of the Common Access Method Transport (XPT) layer.
3 *
4 * Copyright (c) 1997, 1998, 1999 Justin T. Gibbs.
5 * Copyright (c) 1997, 1998, 1999 Kenneth D. Merry.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 110 unchanged lines hidden (view full) ---

119 struct cam_ccbq ccbq; /* Queue of pending ccbs */
120 struct async_list asyncs; /* Async callback info for this B/T/L */
121 struct periph_list periphs; /* All attached devices */
122 u_int generation; /* Generation number */
123 struct cam_periph *owner; /* Peripheral driver's ownership tag */
124 struct xpt_quirk_entry *quirk; /* Oddities about this device */
125 /* Storage for the inquiry data */
126 struct scsi_inquiry_data inq_data;
1/*
2 * Implementation of the Common Access Method Transport (XPT) layer.
3 *
4 * Copyright (c) 1997, 1998, 1999 Justin T. Gibbs.
5 * Copyright (c) 1997, 1998, 1999 Kenneth D. Merry.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 110 unchanged lines hidden (view full) ---

119 struct cam_ccbq ccbq; /* Queue of pending ccbs */
120 struct async_list asyncs; /* Async callback info for this B/T/L */
121 struct periph_list periphs; /* All attached devices */
122 u_int generation; /* Generation number */
123 struct cam_periph *owner; /* Peripheral driver's ownership tag */
124 struct xpt_quirk_entry *quirk; /* Oddities about this device */
125 /* Storage for the inquiry data */
126 struct scsi_inquiry_data inq_data;
127 u_int8_t inq_len; /* valid length in inq_data */
128 u_int8_t inq_flags; /*
129 * Current settings for inquiry flags.
130 * This allows us to override settings
131 * like disconnection and tagged
132 * queuing for a device.
133 */
134 u_int8_t queue_flags; /* Queue flags from the control page */
135 u_int8_t serial_num_len;

--- 2779 unchanged lines hidden (view full) ---

2915 struct ccb_getdev *cgd;
2916 struct cam_eb *bus;
2917 struct cam_et *tar;
2918
2919 cgd = &start_ccb->cgd;
2920 bus = cgd->ccb_h.path->bus;
2921 tar = cgd->ccb_h.path->target;
2922 cgd->inq_data = dev->inq_data;
127 u_int8_t inq_flags; /*
128 * Current settings for inquiry flags.
129 * This allows us to override settings
130 * like disconnection and tagged
131 * queuing for a device.
132 */
133 u_int8_t queue_flags; /* Queue flags from the control page */
134 u_int8_t serial_num_len;

--- 2779 unchanged lines hidden (view full) ---

2914 struct ccb_getdev *cgd;
2915 struct cam_eb *bus;
2916 struct cam_et *tar;
2917
2918 cgd = &start_ccb->cgd;
2919 bus = cgd->ccb_h.path->bus;
2920 tar = cgd->ccb_h.path->target;
2921 cgd->inq_data = dev->inq_data;
2923 cgd->inq_len = dev->inq_len;
2924 cgd->ccb_h.status = CAM_REQ_CMP;
2925 cgd->serial_num_len = dev->serial_num_len;
2926 if ((dev->serial_num_len > 0)
2927 && (dev->serial_num != NULL))
2928 bcopy(dev->serial_num, cgd->serial_num,
2929 dev->serial_num_len);
2930 }
2931 splx(s);

--- 2336 unchanged lines hidden (view full) ---

5268 MSG_SIMPLE_Q_TAG,
5269 SSD_FULL_SIZE,
5270 /*timeout*/60000);
5271 break;
5272 }
5273 case PROBE_INQUIRY:
5274 case PROBE_FULL_INQUIRY:
5275 {
2922 cgd->ccb_h.status = CAM_REQ_CMP;
2923 cgd->serial_num_len = dev->serial_num_len;
2924 if ((dev->serial_num_len > 0)
2925 && (dev->serial_num != NULL))
2926 bcopy(dev->serial_num, cgd->serial_num,
2927 dev->serial_num_len);
2928 }
2929 splx(s);

--- 2336 unchanged lines hidden (view full) ---

5266 MSG_SIMPLE_Q_TAG,
5267 SSD_FULL_SIZE,
5268 /*timeout*/60000);
5269 break;
5270 }
5271 case PROBE_INQUIRY:
5272 case PROBE_FULL_INQUIRY:
5273 {
5274 u_int inquiry_len;
5276 struct scsi_inquiry_data *inq_buf;
5277
5278 inq_buf = &periph->path->device->inq_data;
5279 /*
5280 * If the device is currently configured, we calculate an
5281 * MD5 checksum of the inquiry data, and if the serial number
5282 * length is greater than 0, add the serial number data
5283 * into the checksum as well. Once the inquiry and the

--- 11 unchanged lines hidden (view full) ---

5295 periph->path->device->serial_num,
5296 periph->path->device->serial_num_len);
5297 softc->flags |= PROBE_SERIAL_CKSUM;
5298 }
5299 MD5Final(softc->digest, &softc->context);
5300 }
5301
5302 if (softc->action == PROBE_INQUIRY)
5275 struct scsi_inquiry_data *inq_buf;
5276
5277 inq_buf = &periph->path->device->inq_data;
5278 /*
5279 * If the device is currently configured, we calculate an
5280 * MD5 checksum of the inquiry data, and if the serial number
5281 * length is greater than 0, add the serial number data
5282 * into the checksum as well. Once the inquiry and the

--- 11 unchanged lines hidden (view full) ---

5294 periph->path->device->serial_num,
5295 periph->path->device->serial_num_len);
5296 softc->flags |= PROBE_SERIAL_CKSUM;
5297 }
5298 MD5Final(softc->digest, &softc->context);
5299 }
5300
5301 if (softc->action == PROBE_INQUIRY)
5303 periph->path->device->inq_len = SHORT_INQUIRY_LENGTH;
5302 inquiry_len = SHORT_INQUIRY_LENGTH;
5303 else
5304 inquiry_len = inq_buf->additional_length + 4;
5304
5305 scsi_inquiry(csio,
5306 /*retries*/4,
5307 probedone,
5308 MSG_SIMPLE_Q_TAG,
5309 (u_int8_t *)inq_buf,
5305
5306 scsi_inquiry(csio,
5307 /*retries*/4,
5308 probedone,
5309 MSG_SIMPLE_Q_TAG,
5310 (u_int8_t *)inq_buf,
5310 (size_t) periph->path->device->inq_len,
5311 inquiry_len,
5311 /*evpd*/FALSE,
5312 /*page_code*/0,
5313 SSD_MIN_SIZE,
5314 /*timeout*/60 * 1000);
5315 break;
5316 }
5317 case PROBE_MODE_SENSE:
5318 {

--- 112 unchanged lines hidden (view full) ---

5431 }
5432 case PROBE_INQUIRY:
5433 case PROBE_FULL_INQUIRY:
5434 {
5435 if ((done_ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) {
5436 struct scsi_inquiry_data *inq_buf;
5437 u_int8_t periph_qual;
5438 u_int8_t periph_dtype;
5312 /*evpd*/FALSE,
5313 /*page_code*/0,
5314 SSD_MIN_SIZE,
5315 /*timeout*/60 * 1000);
5316 break;
5317 }
5318 case PROBE_MODE_SENSE:
5319 {

--- 112 unchanged lines hidden (view full) ---

5432 }
5433 case PROBE_INQUIRY:
5434 case PROBE_FULL_INQUIRY:
5435 {
5436 if ((done_ccb->ccb_h.status & CAM_STATUS_MASK) == CAM_REQ_CMP) {
5437 struct scsi_inquiry_data *inq_buf;
5438 u_int8_t periph_qual;
5439 u_int8_t periph_dtype;
5439 u_int8_t alen;
5440
5441 path->device->flags |= CAM_DEV_INQUIRY_DATA_VALID;
5442 inq_buf = &path->device->inq_data;
5443
5444 periph_qual = SID_QUAL(inq_buf);
5445 periph_dtype = SID_TYPE(inq_buf);
5440
5441 path->device->flags |= CAM_DEV_INQUIRY_DATA_VALID;
5442 inq_buf = &path->device->inq_data;
5443
5444 periph_qual = SID_QUAL(inq_buf);
5445 periph_dtype = SID_TYPE(inq_buf);
5446
5447 /*
5448 * We conservatively request only SHORT_INQUIRY_LEN
5449 * bytes of inquiry information during our first try
5450 * at sending an INQUIRY. If the device has more
5451 * information to give, perform a second reques
5452 * specifying the amount of information the device
5453 * is willing to give (but not overflowing the amount
5454 * of room we have for it).
5455 */
5456
5457 alen = inq_buf->additional_length;
5458
5459 if (periph_dtype != T_NODEVICE
5460 && periph_qual == SID_QUAL_LU_CONNECTED
5461 && softc->action == PROBE_INQUIRY
5462 && alen > (SHORT_INQUIRY_LENGTH - 8)) {
5463
5464 path->device->inq_len =
5465 min(alen + 8, sizeof (*inq_buf));
5466 softc->action = PROBE_FULL_INQUIRY;
5467 xpt_release_ccb(done_ccb);
5468 xpt_schedule(periph, priority);
5469 return;
5470 }
5471
5472
5473
5474 if (periph_dtype != T_NODEVICE) {
5475 switch(periph_qual) {
5476 case SID_QUAL_LU_CONNECTED:
5477 {
5446
5447 if (periph_dtype != T_NODEVICE) {
5448 switch(periph_qual) {
5449 case SID_QUAL_LU_CONNECTED:
5450 {
5451 u_int8_t alen;
5452
5453 /*
5454 * We conservatively request only
5455 * SHORT_INQUIRY_LEN bytes of inquiry
5456 * information during our first try
5457 * at sending an INQUIRY. If the device
5458 * has more information to give,
5459 * perform a second request specifying
5460 * the amount of information the device
5461 * is willing to give.
5462 */
5463 alen = inq_buf->additional_length;
5464 if (softc->action == PROBE_INQUIRY
5465 && alen > (SHORT_INQUIRY_LENGTH - 4)) {
5466 softc->action =
5467 PROBE_FULL_INQUIRY;
5468 xpt_release_ccb(done_ccb);
5469 xpt_schedule(periph, priority);
5470 return;
5471 }
5472
5478 xpt_find_quirk(path->device);
5479
5480 if ((inq_buf->flags & SID_CmdQue) != 0)
5481 softc->action =
5482 PROBE_MODE_SENSE;
5483 else
5484 softc->action =
5485 PROBE_SERIAL_NUM;

--- 824 unchanged lines hidden ---
5473 xpt_find_quirk(path->device);
5474
5475 if ((inq_buf->flags & SID_CmdQue) != 0)
5476 softc->action =
5477 PROBE_MODE_SENSE;
5478 else
5479 softc->action =
5480 PROBE_SERIAL_NUM;

--- 824 unchanged lines hidden ---