scsi: define SCSI_DEVICE_MAX_LUN_COUNT to set a custom max lun count.
* virtio_scsi can have 16384 luns, though we cap at 256 as our scsi_ccb only uses uchar as a type for target_lun and target_id members. * minor code cleanup in scsi_scan_bus().
This commit is contained in:
@@ -288,6 +288,8 @@ typedef struct {
|
|||||||
|
|
||||||
// maximum targets on scsi bus
|
// maximum targets on scsi bus
|
||||||
#define SCSI_DEVICE_MAX_TARGET_COUNT "scsi/max_target_count"
|
#define SCSI_DEVICE_MAX_TARGET_COUNT "scsi/max_target_count"
|
||||||
|
// maximum luns on scsi bus
|
||||||
|
#define SCSI_DEVICE_MAX_LUN_COUNT "scsi/max_lun_count"
|
||||||
|
|
||||||
// directory containing links to peripheral drivers
|
// directory containing links to peripheral drivers
|
||||||
#define SCSI_PERIPHERAL_DRIVERS_DIR "scsi"
|
#define SCSI_PERIPHERAL_DRIVERS_DIR "scsi"
|
||||||
|
|||||||
@@ -101,6 +101,15 @@ scsi_create_bus(device_node *node, uint8 path_id)
|
|||||||
|
|
||||||
if (pnp->get_attr_uint32(node, SCSI_DEVICE_MAX_TARGET_COUNT, &bus->max_target_count, true) != B_OK)
|
if (pnp->get_attr_uint32(node, SCSI_DEVICE_MAX_TARGET_COUNT, &bus->max_target_count, true) != B_OK)
|
||||||
bus->max_target_count = MAX_TARGET_ID + 1;
|
bus->max_target_count = MAX_TARGET_ID + 1;
|
||||||
|
if (pnp->get_attr_uint32(node, SCSI_DEVICE_MAX_LUN_COUNT, &bus->max_lun_count, true) != B_OK)
|
||||||
|
bus->max_lun_count = MAX_LUN_ID + 1;
|
||||||
|
|
||||||
|
// our scsi_ccb only has a uchar for target_id
|
||||||
|
if (bus->max_target_count > 256)
|
||||||
|
bus->max_target_count = 256;
|
||||||
|
// our scsi_ccb only has a uchar for target_lun
|
||||||
|
if (bus->max_lun_count > 256)
|
||||||
|
bus->max_lun_count = 256;
|
||||||
|
|
||||||
bus->node = node;
|
bus->node = node;
|
||||||
bus->lock_count = bus->blocked[0] = bus->blocked[1] = 0;
|
bus->lock_count = bus->blocked[0] = bus->blocked[1] = 0;
|
||||||
|
|||||||
@@ -251,18 +251,16 @@ err:
|
|||||||
status_t
|
status_t
|
||||||
scsi_scan_bus(scsi_bus_info *bus)
|
scsi_scan_bus(scsi_bus_info *bus)
|
||||||
{
|
{
|
||||||
int initiator_id, target_id;
|
|
||||||
scsi_path_inquiry inquiry;
|
scsi_path_inquiry inquiry;
|
||||||
uchar res;
|
|
||||||
|
|
||||||
SHOW_FLOW0( 3, "" );
|
SHOW_FLOW0( 3, "" );
|
||||||
|
|
||||||
// get ID of initiator (i.e. controller)
|
// get ID of initiator (i.e. controller)
|
||||||
res = scsi_inquiry_path(bus, &inquiry);
|
uchar res = scsi_inquiry_path(bus, &inquiry);
|
||||||
if (res != SCSI_REQ_CMP)
|
if (res != SCSI_REQ_CMP)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
initiator_id = inquiry.initiator_id;
|
uint initiator_id = inquiry.initiator_id;
|
||||||
|
|
||||||
SHOW_FLOW(3, "initiator_id=%d", initiator_id);
|
SHOW_FLOW(3, "initiator_id=%d", initiator_id);
|
||||||
|
|
||||||
@@ -270,9 +268,7 @@ scsi_scan_bus(scsi_bus_info *bus)
|
|||||||
// as this function is optional for SIM, we ignore its result
|
// as this function is optional for SIM, we ignore its result
|
||||||
bus->interface->scan_bus(bus->sim_cookie);
|
bus->interface->scan_bus(bus->sim_cookie);
|
||||||
|
|
||||||
for (target_id = 0; target_id < (int)bus->max_target_count; ++target_id) {
|
for (uint target_id = 0; target_id < bus->max_target_count; ++target_id) {
|
||||||
int lun;
|
|
||||||
|
|
||||||
SHOW_FLOW(3, "target: %d", target_id);
|
SHOW_FLOW(3, "target: %d", target_id);
|
||||||
|
|
||||||
if (target_id == initiator_id)
|
if (target_id == initiator_id)
|
||||||
@@ -281,12 +277,10 @@ scsi_scan_bus(scsi_bus_info *bus)
|
|||||||
// TODO: there are a lot of devices out there that go mad if you probe
|
// TODO: there are a lot of devices out there that go mad if you probe
|
||||||
// anything but LUN 0, so we should probably add a black-list
|
// anything but LUN 0, so we should probably add a black-list
|
||||||
// or something
|
// or something
|
||||||
for (lun = 0; lun <= MAX_LUN_ID; ++lun) {
|
for (uint lun = 0; lun < bus->max_lun_count; ++lun) {
|
||||||
status_t status;
|
|
||||||
|
|
||||||
SHOW_FLOW(3, "lun: %d", lun);
|
SHOW_FLOW(3, "lun: %d", lun);
|
||||||
|
|
||||||
status = scsi_scan_lun(bus, target_id, lun);
|
status_t status = scsi_scan_lun(bus, target_id, lun);
|
||||||
|
|
||||||
// if there is no device at lun 0, there's probably no device at all
|
// if there is no device at lun 0, there's probably no device at all
|
||||||
if (lun == 0 && status != B_OK)
|
if (lun == 0 && status != B_OK)
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ typedef struct scsi_bus_info {
|
|||||||
|
|
||||||
uchar path_id; // SCSI path id
|
uchar path_id; // SCSI path id
|
||||||
uint32 max_target_count; // maximum count of target_ids on the bus
|
uint32 max_target_count; // maximum count of target_ids on the bus
|
||||||
|
uint32 max_lun_count; // maximum count of lun_ids on the bus
|
||||||
|
|
||||||
thread_id service_thread; // service thread
|
thread_id service_thread; // service thread
|
||||||
sem_id start_service; // released whenever service thread has work to do
|
sem_id start_service; // released whenever service thread has work to do
|
||||||
|
|||||||
@@ -205,6 +205,7 @@ virtio_scsi_register_device(device_node *parent)
|
|||||||
return status;
|
return status;
|
||||||
|
|
||||||
uint32 max_targets = config.max_target + 1;
|
uint32 max_targets = config.max_target + 1;
|
||||||
|
uint32 max_luns = config.max_lun + 1;
|
||||||
uint32 max_blocks = 0x10000;
|
uint32 max_blocks = 0x10000;
|
||||||
if (config.max_sectors != 0)
|
if (config.max_sectors != 0)
|
||||||
max_blocks = config.max_sectors;
|
max_blocks = config.max_sectors;
|
||||||
@@ -212,6 +213,8 @@ virtio_scsi_register_device(device_node *parent)
|
|||||||
device_attr attrs[] = {
|
device_attr attrs[] = {
|
||||||
{ SCSI_DEVICE_MAX_TARGET_COUNT, B_UINT32_TYPE,
|
{ SCSI_DEVICE_MAX_TARGET_COUNT, B_UINT32_TYPE,
|
||||||
{ ui32: max_targets }},
|
{ ui32: max_targets }},
|
||||||
|
{ SCSI_DEVICE_MAX_LUN_COUNT, B_UINT32_TYPE,
|
||||||
|
{ ui32: max_luns }},
|
||||||
{ B_DEVICE_PRETTY_NAME, B_STRING_TYPE,
|
{ B_DEVICE_PRETTY_NAME, B_STRING_TYPE,
|
||||||
{ string: VIRTIO_SCSI_BRIDGE_PRETTY_NAME }},
|
{ string: VIRTIO_SCSI_BRIDGE_PRETTY_NAME }},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user