[PATCH 2/2] RE: How to add/drop SCSI drives from within the driver?

From: Bagalkote, Sreenivas
Date: Thu Dec 09 2004 - 20:32:22 EST


>>
>>I believe, per the discussion, that this was unnecessary and possibly
>>even incorrect. Please repost one more time with this removed.
>>
>
>Yes, thank you. I will do that. The patch that I submitted
>earlier had an one more critical fix. I will separate them
>into two patches and submit them as PATCH 1/2 & 2/2 as well.
>
>Thanks,
>Sreenivas
>LSI Logic
>

diff -Naur b/Documentation/scsi/ChangeLog.megaraid
c/Documentation/scsi/ChangeLog.megaraid
--- b/Documentation/scsi/ChangeLog.megaraid 2004-12-09
19:05:47.795231320 -0500
+++ c/Documentation/scsi/ChangeLog.megaraid 2004-12-09
19:14:33.662287376 -0500
@@ -1,3 +1,21 @@
+Release Date : Thu Dec 9 19:10:23 EST 2004 - Sreenivas Bagalkote
<sreenib@xxxxxxxx>
+
+Current Version : 2.20.4.2 (scsi module), 2.20.2.4 (cmm module)
+Older Version : 2.20.4.1 (scsi module), 2.20.2.3 (cmm module)
+
+i. Introduced driver ioctl that returns scsi address for a given ld.
+
+ "Why can't the existing sysfs interfaces be used to do this?"
+ - Brian King (brking@xxxxxxxxxx)
+
+ "I've looked into solving this another way, but I cannot see how
+ to get this driver-private mapping of logical drive number-> HCTL
+ without putting code something like this into the driver."
+
+ "...and by providing a mapping a function to userspace, the driver
+ is free to change its mapping algorithm in the future if necessary
.."
+ - Matt Domsch (Matt_Domsch@xxxxxxxx)
+
Release Date : Thu Dec 9 19:02:14 EST 2004 - Sreenivas Bagalkote
<sreenib@xxxxxxxx>

Current Version : 2.20.4.1 (scsi module), 2.20.2.3 (cmm module)
diff -Naur b/drivers/scsi/megaraid/megaraid_ioctl.h
c/drivers/scsi/megaraid/megaraid_ioctl.h
--- b/drivers/scsi/megaraid/megaraid_ioctl.h 2004-12-09
19:00:59.000000000 -0500
+++ c/drivers/scsi/megaraid/megaraid_ioctl.h 2004-12-09
19:15:59.524234376 -0500
@@ -51,6 +51,7 @@
#define MEGAIOC_QNADAP 'm' /* Query # of adapters */
#define MEGAIOC_QDRVRVER 'e' /* Query driver version */
#define MEGAIOC_QADAPINFO 'g' /* Query adapter information */
+#define MEGAIOC_GET_SADDR 'a' /* Get SCSI address of an LD */

#define USCSICMD 0x80
#define UIOC_RD 0x00001
@@ -62,6 +63,7 @@
#define GET_ADAP_INFO 0x30000
#define GET_CAP 0x40000
#define GET_STATS 0x50000
+#define GET_LD_SADDR 0x60000
#define GET_IOCTL_VERSION 0x01

#define EXT_IOCTL_SIGN_SZ 16
@@ -217,6 +219,27 @@

} __attribute__ ((packed)) mcontroller_t;

+/**
+ * ld_device_address : SCSI device address for the logical drives
+ *
+ * @host_no : host# to which LD belogs; as understood by
mid-layer
+ * @channel : channel on which LD is exported
+ * @target : target on which the LD is exported
+ * @lun : lun on which the LD is exported
+ * @ld : the LD for which this information is sought
+ * @reserved : reserved fields; must be set to zero
+ *
+ * NOTE : Applications set the LD number and expect
the
+ * SCSI address to be returned in the first four
fields
+ */
+struct ld_device_address {
+ uint32_t host_no;
+ uint32_t channel;
+ uint32_t scsi_id;
+ uint32_t lun;
+ uint32_t ld;
+ uint32_t reserved[3];
+};

/**
* mm_dmapool_t : Represents one dma pool with just one buffer
diff -Naur b/drivers/scsi/megaraid/megaraid_mbox.c
c/drivers/scsi/megaraid/megaraid_mbox.c
--- b/drivers/scsi/megaraid/megaraid_mbox.c 2004-12-09
18:56:56.000000000 -0500
+++ c/drivers/scsi/megaraid/megaraid_mbox.c 2004-12-09
17:42:33.000000000 -0500
@@ -10,7 +10,7 @@
* 2 of the License, or (at your option) any later version.
*
* FILE : megaraid_mbox.c
- * Version : v2.20.4.1 (Nov 04 2004)
+ * Version : v2.20.4.2 (Dec 9 2004)
*
* Authors:
* Atul Mukker <Atul.Mukker@xxxxxxxx>
@@ -3642,6 +3642,7 @@
megaraid_mbox_mm_handler(unsigned long drvr_data, uioc_t *kioc, uint32_t
action)
{
adapter_t *adapter;
+ struct ld_device_address* lda;

if (action != IOCTL_ISSUE) {
con_log(CL_ANN, (KERN_WARNING
@@ -3670,6 +3671,30 @@

return kioc->status;

+ case GET_LD_SADDR:
+
+ lda = (struct ld_device_address*)(unsigned
long)kioc->buf_vaddr;
+
+ if (lda->ld > MAX_LOGICAL_DRIVES_40LD) {
+ lda->host_no = 0xffffffff;
+ lda->channel = 0xffffffff;
+ lda->scsi_id = 0xffffffff;
+ lda->lun = 0xffffffff;
+ kioc->status = -ENODEV;
+ kioc->done(kioc);
+ return kioc->status;
+ }
+
+ lda->host_no = adapter->host->host_no;
+ lda->channel = adapter->max_channel;
+ lda->scsi_id = (lda->ld < adapter->init_id) ?
+ lda->ld : lda->ld + 1;
+ lda->lun = 0;
+ kioc->status = 0;
+ kioc->done(kioc);
+
+ return kioc->status;
+
case MBOX_CMD:

return megaraid_mbox_mm_command(adapter, kioc);
diff -Naur b/drivers/scsi/megaraid/megaraid_mbox.h
c/drivers/scsi/megaraid/megaraid_mbox.h
--- b/drivers/scsi/megaraid/megaraid_mbox.h 2004-12-09
18:56:56.000000000 -0500
+++ c/drivers/scsi/megaraid/megaraid_mbox.h 2004-12-09
19:10:32.381967560 -0500
@@ -21,8 +21,8 @@
#include "megaraid_ioctl.h"


-#define MEGARAID_VERSION "2.20.4.1"
-#define MEGARAID_EXT_VERSION "(Release Date: Thu Nov 4 17:44:59 EST
2004)"
+#define MEGARAID_VERSION "2.20.4.2"
+#define MEGARAID_EXT_VERSION "(Release Date: Thu Dec 9 19:10:23 EST
2004)"


/*
diff -Naur b/drivers/scsi/megaraid/megaraid_mm.c
c/drivers/scsi/megaraid/megaraid_mm.c
--- b/drivers/scsi/megaraid/megaraid_mm.c 2004-12-09
19:03:27.000000000 -0500
+++ c/drivers/scsi/megaraid/megaraid_mm.c 2004-12-09
19:10:01.449669984 -0500
@@ -10,7 +10,7 @@
* 2 of the License, or (at your option) any later version.
*
* FILE : megaraid_mm.c
- * Version : v2.20.2.3 (Dec 09 2004)
+ * Version : v2.20.2.4 (Dec 9 2004)
*
* Common management module
*/
@@ -373,6 +373,20 @@
if (mraid_mm_attach_buf(adp, kioc, kioc->xferlen))
return (-ENOMEM);
}
+ else if (subopcode == MEGAIOC_GET_SADDR) {
+
+ kioc->opcode = GET_LD_SADDR;
+ kioc->data_dir = UIOC_RD;
+ kioc->xferlen = sizeof(struct ld_device_address);
+
+ if (mraid_mm_attach_buf(adp, kioc, kioc->xferlen))
+ return (-ENOMEM);
+
+ if (copy_from_user(kioc->buf_vaddr, mimd.data,
+ kioc->xferlen )) {
+ return (-EFAULT);
+ }
+ }
else {
con_log(CL_ANN, (KERN_WARNING
"megaraid cmm: Invalid subop\n"));
@@ -813,6 +827,15 @@

return 0;

+ case MEGAIOC_GET_SADDR:
+
+ if (copy_to_user(kmimd.data, kioc->buf_vaddr,
+ sizeof(struct ld_device_address))) {
+ return (-EFAULT);
+ }
+
+ return kioc->status;
+
default:
return (-EINVAL);
}
diff -Naur b/drivers/scsi/megaraid/megaraid_mm.h
c/drivers/scsi/megaraid/megaraid_mm.h
--- b/drivers/scsi/megaraid/megaraid_mm.h 2004-12-09
19:03:00.000000000 -0500
+++ c/drivers/scsi/megaraid/megaraid_mm.h 2004-12-09
19:12:15.729256384 -0500
@@ -29,9 +29,10 @@
#include "megaraid_ioctl.h"


-#define LSI_COMMON_MOD_VERSION "2.20.2.3"
+#define LSI_COMMON_MOD_VERSION "2.20.2.4"
#define LSI_COMMON_MOD_EXT_VERSION \
- "(Release Date: Thu Dec 9 19:02:14 EST 2004)"
+ "(Release Date: Thu Dec 9 19:10:23 EST 2004)"
+

#define LSI_DBGLVL dbglevel


Attachment: megaraid-hctl.patch
Description: Binary data