43 #include <linux/module.h>
44 #include <linux/kernel.h>
45 #include <linux/types.h>
46 #include <linux/string.h>
53 #include <linux/prefetch.h>
54 #include <linux/pci.h>
63 #include <scsi/scsi.h>
69 #define OSM_NAME "scsi-osm"
70 #define OSM_VERSION "1.316"
71 #define OSM_DESCRIPTION "I2O SCSI Peripheral OSM"
75 static unsigned int i2o_scsi_max_id = 16;
76 static unsigned int i2o_scsi_max_lun = 255;
87 #define I2O_SCSI_CAN_QUEUE 4
106 #ifdef CONFIG_I2O_EXT_ADAPTEC
123 size = max_channel *
sizeof(
struct i2o_device *)
128 osm_warn(
"Could not allocate SCSI host\n");
133 scsi_host->
max_id = i2o_scsi_max_id;
134 scsi_host->
max_lun = i2o_scsi_max_lun;
148 i2o_shost->
channel[i++] = i2o_dev;
150 if (i >= max_channel)
180 static int i2o_scsi_remove(
struct device *
dev)
189 i2o_shost = i2o_scsi_get_host(c);
211 static int i2o_scsi_probe(
struct device *
dev)
224 i2o_shost = i2o_scsi_get_host(c);
233 #ifdef CONFIG_I2O_EXT_ADAPTEC
263 osm_warn(
"can not find parent of device %03x\n",
268 for (i = 0; i <= i2o_shost->
scsi_host->max_channel; i++)
269 if (i2o_shost->
channel[i] == parent)
278 osm_warn(
"can not find channel of device %03x\n",
284 osm_warn(
"SCSI device id (%d) >= max_id of I2O host (%d)",
290 osm_warn(
"SCSI device lun (%lu) >= max_lun of I2O host (%d)",
300 if (IS_ERR(scsi_dev)) {
301 osm_warn(
"can not add SCSI device %03x\n",
303 return PTR_ERR(scsi_dev);
307 &scsi_dev->sdev_gendev.kobj,
"scsi");
311 osm_info(
"device added (TID: %03x) channel: %d, id: %d, lun: %ld\n",
322 static const char *i2o_scsi_info(
struct Scsi_Host *SChost)
326 return hostdata->
iop->name;
353 osm_err(
"NULL reply received!\n");
365 cmd->
result = error & 0xff;
375 if ((error >> 8) & 0xff)
376 osm_err(
"SCSI error %08x\n", error);
395 static void i2o_scsi_notify_device_add(
struct i2o_device *i2o_dev)
400 i2o_scsi_probe(&i2o_dev->
device);
415 static void i2o_scsi_notify_device_remove(
struct i2o_device *i2o_dev)
420 i2o_scsi_remove(&i2o_dev->
device);
435 static void i2o_scsi_notify_controller_add(
struct i2o_controller *c)
440 i2o_shost = i2o_scsi_host_alloc(c);
441 if (IS_ERR(i2o_shost)) {
442 osm_err(
"Could not initialize SCSI host\n");
448 osm_err(
"Could not add SCSI host\n");
453 c->
driver_data[i2o_scsi_driver.context] = i2o_shost;
465 static void i2o_scsi_notify_controller_remove(
struct i2o_controller *c)
468 i2o_shost = i2o_scsi_get_host(c);
482 .reply = i2o_scsi_reply,
483 .classes = i2o_scsi_class_id,
484 .notify_device_add = i2o_scsi_notify_device_add,
485 .notify_device_remove = i2o_scsi_notify_device_remove,
486 .notify_controller_add = i2o_scsi_notify_controller_add,
487 .notify_controller_remove = i2o_scsi_notify_controller_remove,
489 .probe = i2o_scsi_probe,
490 .remove = i2o_scsi_remove,
508 static int i2o_scsi_queuecommand_lck(
struct scsi_cmnd *SCpnt,
520 u32 scsi_flags = 0x20a00000;
529 i2o_dev = SCpnt->
device->hostdata;
534 osm_warn(
"no I2O device in request\n");
556 scsi_flags |= 0x80000000;
562 scsi_flags |= 0x40000000;
578 msg = i2o_msg_get(c);
584 mptr = &msg->
body[0];
587 #ifdef CONFIG_I2O_EXT_ADAPTEC
591 if (SCpnt->sc_request && SCpnt->sc_request->upper_private_data) {
594 upper_private_data))->
header.
598 get_user(adpt_flags, &usr_ptr->flags);
665 if (scsi_sg_count(SCpnt)) {
667 scsi_sg_count(SCpnt),
678 i2o_msg_post(c, msg);
713 osm_warn(
"Aborting command block.\n");
715 i2o_dev = SCpnt->
device->hostdata;
745 static int i2o_scsi_bios_param(
struct scsi_device *sdev,
754 if ((ip[2] = size >> 11) > 1024) {
757 ip[2] = size / (255 * 63);
765 .info = i2o_scsi_info,
766 .queuecommand = i2o_scsi_queuecommand,
767 .eh_abort_handler = i2o_scsi_abort,
768 .bios_param = i2o_scsi_bios_param,
782 static int __init i2o_scsi_init(
void)
791 osm_err(
"Could not register SCSI driver\n");
803 static void __exit i2o_scsi_exit(
void)