vpo.c (184130) | vpo.c (185003) |
---|---|
1/*- 2 * Copyright (c) 1997, 1998, 1999 Nicolas Souchu 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 12 unchanged lines hidden (view full) --- 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 */ 27 28#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1997, 1998, 1999 Nicolas Souchu 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 12 unchanged lines hidden (view full) --- 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * 26 */ 27 28#include <sys/cdefs.h> |
29__FBSDID("$FreeBSD: head/sys/dev/ppbus/vpo.c 184130 2008-10-21 18:30:10Z jhb $"); | 29__FBSDID("$FreeBSD: head/sys/dev/ppbus/vpo.c 185003 2008-11-16 17:42:02Z jhb $"); |
30 31#include <sys/param.h> 32#include <sys/systm.h> 33#include <sys/module.h> 34#include <sys/bus.h> 35#include <sys/lock.h> 36#include <sys/mutex.h> 37#include <sys/malloc.h> --- 135 unchanged lines hidden (view full) --- 173 vpo_cam_rescan(vpo); /* have CAM rescan the bus */ 174 175 return (0); 176} 177 178static void 179vpo_cam_rescan_callback(struct cam_periph *periph, union ccb *ccb) 180{ | 30 31#include <sys/param.h> 32#include <sys/systm.h> 33#include <sys/module.h> 34#include <sys/bus.h> 35#include <sys/lock.h> 36#include <sys/mutex.h> 37#include <sys/malloc.h> --- 135 unchanged lines hidden (view full) --- 173 vpo_cam_rescan(vpo); /* have CAM rescan the bus */ 174 175 return (0); 176} 177 178static void 179vpo_cam_rescan_callback(struct cam_periph *periph, union ccb *ccb) 180{ |
181 free(ccb, M_TEMP); | 181 182 free(ccb, M_TEMP); |
182} 183 184static void 185vpo_cam_rescan(struct vpo_data *vpo) 186{ | 183} 184 185static void 186vpo_cam_rescan(struct vpo_data *vpo) 187{ |
187 struct cam_path *path; 188 union ccb *ccb = malloc(sizeof(union ccb), M_TEMP, M_WAITOK | M_ZERO); | 188 struct cam_path *path; 189 union ccb *ccb = malloc(sizeof(union ccb), M_TEMP, M_WAITOK | M_ZERO); |
189 | 190 |
190 if (xpt_create_path(&path, xpt_periph, cam_sim_path(vpo->sim), 0, 0) 191 != CAM_REQ_CMP) { | 191 if (xpt_create_path(&path, xpt_periph, cam_sim_path(vpo->sim), 0, 0) 192 != CAM_REQ_CMP) { |
192 /* A failure is benign as the user can do a manual rescan */ 193 free(ccb, M_TEMP); | 193 /* A failure is benign as the user can do a manual rescan */ 194 free(ccb, M_TEMP); |
194 return; | 195 return; |
195 } 196 | 196 } 197 |
197 xpt_setup_ccb(&ccb->ccb_h, path, 5/*priority (low)*/); 198 ccb->ccb_h.func_code = XPT_SCAN_BUS; 199 ccb->ccb_h.cbfcnp = vpo_cam_rescan_callback; 200 ccb->crcn.flags = CAM_FLAG_NONE; 201 xpt_action(ccb); | 198 xpt_setup_ccb(&ccb->ccb_h, path, 5/*priority (low)*/); 199 ccb->ccb_h.func_code = XPT_SCAN_BUS; 200 ccb->ccb_h.cbfcnp = vpo_cam_rescan_callback; 201 ccb->crcn.flags = CAM_FLAG_NONE; 202 xpt_action(ccb); |
202 | 203 |
203 /* The scan is in progress now. */ | 204 /* The scan is in progress now. */ |
204} 205 206/* 207 * vpo_intr() 208 */ 209static void 210vpo_intr(struct vpo_data *vpo, struct ccb_scsiio *csio) 211{ --- 15 unchanged lines hidden (view full) --- 227 errno = vpoio_do_scsi(&vpo->vpo_io, VP0_INITIATOR, 228 csio->ccb_h.target_id, 229 (char *)&csio->cdb_io.cdb_bytes, csio->cdb_len, 230 (char *)csio->data_ptr, csio->dxfer_len, 231 &vpo->vpo_stat, &vpo->vpo_count, &vpo->vpo_error); 232 } 233 234#ifdef VP0_DEBUG | 205} 206 207/* 208 * vpo_intr() 209 */ 210static void 211vpo_intr(struct vpo_data *vpo, struct ccb_scsiio *csio) 212{ --- 15 unchanged lines hidden (view full) --- 228 errno = vpoio_do_scsi(&vpo->vpo_io, VP0_INITIATOR, 229 csio->ccb_h.target_id, 230 (char *)&csio->cdb_io.cdb_bytes, csio->cdb_len, 231 (char *)csio->data_ptr, csio->dxfer_len, 232 &vpo->vpo_stat, &vpo->vpo_count, &vpo->vpo_error); 233 } 234 235#ifdef VP0_DEBUG |
235 printf("vpo_do_scsi = %d, status = 0x%x, count = %d, vpo_error = %d\n", | 236 printf("vpo_do_scsi = %d, status = 0x%x, count = %d, vpo_error = %d\n", |
236 errno, vpo->vpo_stat, vpo->vpo_count, vpo->vpo_error); 237 238 /* dump of command */ 239 for (i=0; i<csio->cdb_len; i++) 240 printf("%x ", ((char *)&csio->cdb_io.cdb_bytes)[i]); 241 242 printf("\n"); 243#endif --- 37 unchanged lines hidden (view full) --- 281 errno = vpoio_do_scsi(&vpo->vpo_io, VP0_INITIATOR, 282 csio->ccb_h.target_id, 283 (char *)&vpo->vpo_sense.cmd, 284 sizeof(vpo->vpo_sense.cmd), 285 (char *)&csio->sense_data, csio->sense_len, 286 &vpo->vpo_sense.stat, &vpo->vpo_sense.count, 287 &vpo->vpo_error); 288 } | 237 errno, vpo->vpo_stat, vpo->vpo_count, vpo->vpo_error); 238 239 /* dump of command */ 240 for (i=0; i<csio->cdb_len; i++) 241 printf("%x ", ((char *)&csio->cdb_io.cdb_bytes)[i]); 242 243 printf("\n"); 244#endif --- 37 unchanged lines hidden (view full) --- 282 errno = vpoio_do_scsi(&vpo->vpo_io, VP0_INITIATOR, 283 csio->ccb_h.target_id, 284 (char *)&vpo->vpo_sense.cmd, 285 sizeof(vpo->vpo_sense.cmd), 286 (char *)&csio->sense_data, csio->sense_len, 287 &vpo->vpo_sense.stat, &vpo->vpo_sense.count, 288 &vpo->vpo_error); 289 } |
289 | |
290 | 290 |
291 |
|
291#ifdef VP0_DEBUG | 292#ifdef VP0_DEBUG |
292 printf("(sense) vpo_do_scsi = %d, status = 0x%x, count = %d, vpo_error = %d\n", | 293 printf("(sense) vpo_do_scsi = %d, status = 0x%x, count = %d, vpo_error = %d\n", |
293 errno, vpo->vpo_sense.stat, vpo->vpo_sense.count, vpo->vpo_error); 294#endif 295 296 /* check sense return status */ 297 if (errno == 0 && vpo->vpo_sense.stat == SCSI_STATUS_OK) { 298 /* sense ok */ 299 csio->ccb_h.status = CAM_AUTOSNS_VALID | CAM_SCSI_STATUS_ERROR; 300 csio->sense_resid = csio->sense_len - vpo->vpo_sense.count; --- 7 unchanged lines hidden (view full) --- 308#endif 309 310 } else { 311 /* sense failed */ 312 csio->ccb_h.status = CAM_AUTOSENSE_FAIL; 313 } 314 } else { 315 /* no sense */ | 294 errno, vpo->vpo_sense.stat, vpo->vpo_sense.count, vpo->vpo_error); 295#endif 296 297 /* check sense return status */ 298 if (errno == 0 && vpo->vpo_sense.stat == SCSI_STATUS_OK) { 299 /* sense ok */ 300 csio->ccb_h.status = CAM_AUTOSNS_VALID | CAM_SCSI_STATUS_ERROR; 301 csio->sense_resid = csio->sense_len - vpo->vpo_sense.count; --- 7 unchanged lines hidden (view full) --- 309#endif 310 311 } else { 312 /* sense failed */ 313 csio->ccb_h.status = CAM_AUTOSENSE_FAIL; 314 } 315 } else { 316 /* no sense */ |
316 csio->ccb_h.status = CAM_SCSI_STATUS_ERROR; | 317 csio->ccb_h.status = CAM_SCSI_STATUS_ERROR; |
317 } 318 319 goto error; 320 } 321 322 csio->resid = csio->dxfer_len - vpo->vpo_count; 323 csio->ccb_h.status = CAM_REQ_CMP; 324 --- 15 unchanged lines hidden (view full) --- 340 struct ccb_scsiio *csio; 341 342 csio = &ccb->csio; 343 344#ifdef VP0_DEBUG 345 device_printf(vpo->vpo_dev, "XPT_SCSI_IO (0x%x) request\n", 346 csio->cdb_io.cdb_bytes[0]); 347#endif | 318 } 319 320 goto error; 321 } 322 323 csio->resid = csio->dxfer_len - vpo->vpo_count; 324 csio->ccb_h.status = CAM_REQ_CMP; 325 --- 15 unchanged lines hidden (view full) --- 341 struct ccb_scsiio *csio; 342 343 csio = &ccb->csio; 344 345#ifdef VP0_DEBUG 346 device_printf(vpo->vpo_dev, "XPT_SCSI_IO (0x%x) request\n", 347 csio->cdb_io.cdb_bytes[0]); 348#endif |
348 | 349 |
349 vpo_intr(vpo, csio); 350 351 xpt_done(ccb); 352 353 break; 354 } 355 case XPT_CALC_GEOMETRY: 356 { --- 42 unchanged lines hidden (view full) --- 399 400 ccb->ccb_h.status = CAM_REQ_CMP; 401 xpt_done(ccb); 402 break; 403 } 404 case XPT_PATH_INQ: /* Path routing inquiry */ 405 { 406 struct ccb_pathinq *cpi = &ccb->cpi; | 350 vpo_intr(vpo, csio); 351 352 xpt_done(ccb); 353 354 break; 355 } 356 case XPT_CALC_GEOMETRY: 357 { --- 42 unchanged lines hidden (view full) --- 400 401 ccb->ccb_h.status = CAM_REQ_CMP; 402 xpt_done(ccb); 403 break; 404 } 405 case XPT_PATH_INQ: /* Path routing inquiry */ 406 { 407 struct ccb_pathinq *cpi = &ccb->cpi; |
407 | 408 |
408#ifdef VP0_DEBUG 409 device_printf(vpo->vpo_dev, "XPT_PATH_INQ request\n"); 410#endif 411 cpi->version_num = 1; /* XXX??? */ 412 cpi->hba_inquiry = 0; 413 cpi->target_sprt = 0; 414 cpi->hba_misc = 0; 415 cpi->hba_eng_cnt = 0; --- 17 unchanged lines hidden (view full) --- 433 break; 434 } 435 436 return; 437} 438 439static void 440vpo_poll(struct cam_sim *sim) | 409#ifdef VP0_DEBUG 410 device_printf(vpo->vpo_dev, "XPT_PATH_INQ request\n"); 411#endif 412 cpi->version_num = 1; /* XXX??? */ 413 cpi->hba_inquiry = 0; 414 cpi->target_sprt = 0; 415 cpi->hba_misc = 0; 416 cpi->hba_eng_cnt = 0; --- 17 unchanged lines hidden (view full) --- 434 break; 435 } 436 437 return; 438} 439 440static void 441vpo_poll(struct cam_sim *sim) |
441{ 442 /* The ZIP is actually always polled throw vpo_action() */ 443 return; | 442{ 443 444 /* The ZIP is actually always polled throw vpo_action(). */ |
444} 445 446static devclass_t vpo_devclass; 447 448static device_method_t vpo_methods[] = { 449 /* device interface */ 450 DEVMETHOD(device_identify, vpo_identify), 451 DEVMETHOD(device_probe, vpo_probe), --- 13 unchanged lines hidden --- | 445} 446 447static devclass_t vpo_devclass; 448 449static device_method_t vpo_methods[] = { 450 /* device interface */ 451 DEVMETHOD(device_identify, vpo_identify), 452 DEVMETHOD(device_probe, vpo_probe), --- 13 unchanged lines hidden --- |