ata_xpt.c (1a6f09b826dbab7e472bf84567222cd0f451006b) ata_xpt.c (066f913a94b134b6d5e32b6af88f297c7da9c031)
1/*-
2 * Copyright (c) 2009 Alexander Motin <mav@FreeBSD.org>
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

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

361 if (path->device->transport == XPORT_ATA) {
362 cts.xport_specific.ata.mode = mode;
363 cts.xport_specific.ata.valid = CTS_ATA_VALID_MODE;
364 } else {
365 cts.xport_specific.sata.mode = mode;
366 cts.xport_specific.sata.valid = CTS_SATA_VALID_MODE;
367 }
368 xpt_action((union ccb *)&cts);
1/*-
2 * Copyright (c) 2009 Alexander Motin <mav@FreeBSD.org>
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

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

361 if (path->device->transport == XPORT_ATA) {
362 cts.xport_specific.ata.mode = mode;
363 cts.xport_specific.ata.valid = CTS_ATA_VALID_MODE;
364 } else {
365 cts.xport_specific.sata.mode = mode;
366 cts.xport_specific.sata.valid = CTS_SATA_VALID_MODE;
367 }
368 xpt_action((union ccb *)&cts);
369 /* Fetch user modes from SIM. */
369 /* Fetch current modes from SIM. */
370 bzero(&cts, sizeof(cts));
371 xpt_setup_ccb(&cts.ccb_h, path, CAM_PRIORITY_NORMAL);
372 cts.ccb_h.func_code = XPT_GET_TRAN_SETTINGS;
373 cts.type = CTS_TYPE_CURRENT_SETTINGS;
374 xpt_action((union ccb *)&cts);
375 if (path->device->transport == XPORT_ATA) {
376 if (cts.xport_specific.ata.valid & CTS_ATA_VALID_MODE)
377 mode = cts.xport_specific.ata.mode;

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

390 /*data_ptr*/NULL,
391 /*dxfer_len*/0,
392 30 * 1000);
393 ata_28bit_cmd(ataio, ATA_SETFEATURES, ATA_SF_SETXFER, 0, mode);
394 break;
395 }
396 case PROBE_SET_MULTI:
397 {
370 bzero(&cts, sizeof(cts));
371 xpt_setup_ccb(&cts.ccb_h, path, CAM_PRIORITY_NORMAL);
372 cts.ccb_h.func_code = XPT_GET_TRAN_SETTINGS;
373 cts.type = CTS_TYPE_CURRENT_SETTINGS;
374 xpt_action((union ccb *)&cts);
375 if (path->device->transport == XPORT_ATA) {
376 if (cts.xport_specific.ata.valid & CTS_ATA_VALID_MODE)
377 mode = cts.xport_specific.ata.mode;

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

390 /*data_ptr*/NULL,
391 /*dxfer_len*/0,
392 30 * 1000);
393 ata_28bit_cmd(ataio, ATA_SETFEATURES, ATA_SF_SETXFER, 0, mode);
394 break;
395 }
396 case PROBE_SET_MULTI:
397 {
398 u_int sectors;
398 u_int sectors, bytecount;
399
399
400 sectors = max(1, min(ident_buf->sectors_intr & 0xff, 16));
401
400 bytecount = 8192; /* SATA maximum */
401 /* Fetch user bytecount from SIM. */
402 bzero(&cts, sizeof(cts));
403 xpt_setup_ccb(&cts.ccb_h, path, CAM_PRIORITY_NORMAL);
404 cts.ccb_h.func_code = XPT_GET_TRAN_SETTINGS;
405 cts.type = CTS_TYPE_USER_SETTINGS;
406 xpt_action((union ccb *)&cts);
407 if (path->device->transport == XPORT_ATA) {
408 if (cts.xport_specific.ata.valid & CTS_ATA_VALID_BYTECOUNT)
409 bytecount = cts.xport_specific.ata.bytecount;
410 } else {
411 if (cts.xport_specific.sata.valid & CTS_SATA_VALID_BYTECOUNT)
412 bytecount = cts.xport_specific.sata.bytecount;
413 }
414 /* Honor device capabilities. */
415 sectors = max(1, min(ident_buf->sectors_intr & 0xff,
416 bytecount / ata_logical_sector_size(ident_buf)));
402 /* Report bytecount to SIM. */
403 bzero(&cts, sizeof(cts));
404 xpt_setup_ccb(&cts.ccb_h, path, CAM_PRIORITY_NORMAL);
405 cts.ccb_h.func_code = XPT_SET_TRAN_SETTINGS;
406 cts.type = CTS_TYPE_CURRENT_SETTINGS;
407 if (path->device->transport == XPORT_ATA) {
408 cts.xport_specific.ata.bytecount = sectors *
409 ata_logical_sector_size(ident_buf);
410 cts.xport_specific.ata.valid = CTS_ATA_VALID_BYTECOUNT;
411 } else {
412 cts.xport_specific.sata.bytecount = sectors *
413 ata_logical_sector_size(ident_buf);
414 cts.xport_specific.sata.valid = CTS_SATA_VALID_BYTECOUNT;
415 }
416 xpt_action((union ccb *)&cts);
417 /* Report bytecount to SIM. */
418 bzero(&cts, sizeof(cts));
419 xpt_setup_ccb(&cts.ccb_h, path, CAM_PRIORITY_NORMAL);
420 cts.ccb_h.func_code = XPT_SET_TRAN_SETTINGS;
421 cts.type = CTS_TYPE_CURRENT_SETTINGS;
422 if (path->device->transport == XPORT_ATA) {
423 cts.xport_specific.ata.bytecount = sectors *
424 ata_logical_sector_size(ident_buf);
425 cts.xport_specific.ata.valid = CTS_ATA_VALID_BYTECOUNT;
426 } else {
427 cts.xport_specific.sata.bytecount = sectors *
428 ata_logical_sector_size(ident_buf);
429 cts.xport_specific.sata.valid = CTS_SATA_VALID_BYTECOUNT;
430 }
431 xpt_action((union ccb *)&cts);
432 /* Fetch current bytecount from SIM. */
433 bzero(&cts, sizeof(cts));
434 xpt_setup_ccb(&cts.ccb_h, path, CAM_PRIORITY_NORMAL);
435 cts.ccb_h.func_code = XPT_GET_TRAN_SETTINGS;
436 cts.type = CTS_TYPE_CURRENT_SETTINGS;
437 xpt_action((union ccb *)&cts);
438 if (path->device->transport == XPORT_ATA) {
439 if (cts.xport_specific.ata.valid & CTS_ATA_VALID_BYTECOUNT)
440 bytecount = cts.xport_specific.ata.bytecount;
441 } else {
442 if (cts.xport_specific.sata.valid & CTS_SATA_VALID_BYTECOUNT)
443 bytecount = cts.xport_specific.sata.bytecount;
444 }
445 sectors = bytecount / ata_logical_sector_size(ident_buf);
417
418 cam_fill_ataio(ataio,
419 1,
420 probedone,
421 CAM_DIR_NONE,
422 0,
423 NULL,
424 0,
425 30*1000);
426 ata_28bit_cmd(ataio, ATA_SET_MULTI, 0, 0, sectors);
427 break;
428 }
429 case PROBE_INQUIRY:
446
447 cam_fill_ataio(ataio,
448 1,
449 probedone,
450 CAM_DIR_NONE,
451 0,
452 NULL,
453 0,
454 30*1000);
455 ata_28bit_cmd(ataio, ATA_SET_MULTI, 0, 0, sectors);
456 break;
457 }
458 case PROBE_INQUIRY:
459 {
460 u_int bytecount;
461
462 bytecount = 8192; /* SATA maximum */
463 /* Fetch user bytecount from SIM. */
464 bzero(&cts, sizeof(cts));
465 xpt_setup_ccb(&cts.ccb_h, path, CAM_PRIORITY_NORMAL);
466 cts.ccb_h.func_code = XPT_GET_TRAN_SETTINGS;
467 cts.type = CTS_TYPE_USER_SETTINGS;
468 xpt_action((union ccb *)&cts);
469 if (path->device->transport == XPORT_ATA) {
470 if (cts.xport_specific.ata.valid & CTS_ATA_VALID_BYTECOUNT)
471 bytecount = cts.xport_specific.ata.bytecount;
472 } else {
473 if (cts.xport_specific.sata.valid & CTS_SATA_VALID_BYTECOUNT)
474 bytecount = cts.xport_specific.sata.bytecount;
475 }
476 /* Honor device capabilities. */
477 bytecount &= ~1;
478 bytecount = max(2, min(65534, bytecount));
479 if (ident_buf->satacapabilities != 0x0000 &&
480 ident_buf->satacapabilities != 0xffff) {
481 bytecount = min(8192, bytecount);
482 }
483 /* Report bytecount to SIM. */
484 bzero(&cts, sizeof(cts));
485 xpt_setup_ccb(&cts.ccb_h, path, CAM_PRIORITY_NORMAL);
486 cts.ccb_h.func_code = XPT_SET_TRAN_SETTINGS;
487 cts.type = CTS_TYPE_CURRENT_SETTINGS;
488 if (path->device->transport == XPORT_ATA) {
489 cts.xport_specific.ata.bytecount = bytecount;
490 cts.xport_specific.ata.valid = CTS_ATA_VALID_BYTECOUNT;
491 } else {
492 cts.xport_specific.sata.bytecount = bytecount;
493 cts.xport_specific.sata.valid = CTS_SATA_VALID_BYTECOUNT;
494 }
495 xpt_action((union ccb *)&cts);
496 /* FALLTHROUGH */
497 }
430 case PROBE_FULL_INQUIRY:
431 {
432 u_int inquiry_len;
433 struct scsi_inquiry_data *inq_buf =
434 &periph->path->device->inq_data;
435
436 if (softc->action == PROBE_INQUIRY)
437 inquiry_len = SHORT_INQUIRY_LENGTH;

--- 1066 unchanged lines hidden ---
498 case PROBE_FULL_INQUIRY:
499 {
500 u_int inquiry_len;
501 struct scsi_inquiry_data *inq_buf =
502 &periph->path->device->inq_data;
503
504 if (softc->action == PROBE_INQUIRY)
505 inquiry_len = SHORT_INQUIRY_LENGTH;

--- 1066 unchanged lines hidden ---