On Tue, Feb 08, 2005 at 05:19:23PM -0600, Matt Domsch wrote: > On Mon, Feb 07, 2005 at 12:27:53PM -0600, Matt Domsch wrote: > > Below is a patch to add some hotplug infrastructure to the Linux SCSI > > subsystem. > > I've added and reworked the megaraid_mbox driver to make use of this > new infrastructure. I'll send that patch next. The rest is unchanged > from yesterday.
And these are the changes megaid_mbox to use the new infrastructure. -- Matt Domsch Software Architect Dell Linux Solutions linux.dell.com & www.dell.com/linux Linux on Dell mailing lists @ http://lists.us.dell.com You can import this changeset into BK by piping this whole message to '| bk receive [path to repository]' or apply the patch as usual. =================================================================== [EMAIL PROTECTED], 2005-02-08 16:46:03-06:00, [EMAIL PROTECTED] Release Date : Tue Feb 08 12:27:22 EST 2005 - Matt Domsch <[EMAIL PROTECTED]> Current Version : 2.20.4.6 (scsi module), 2.20.2.5 (cmm module) Older Version : 2.20.4.5 (scsi module), 2.20.2.5 (cmm module) 1. Added two new megaraid_shost_attrs /sys/class/scsi_host |-- host0 | |-- logical_drive_created | |-- logical_drive_destroyed and helper functions for them. Written to from userspace by a management application, these invoke SCSI hotplug infrastructure for informing the kernel that a logical drive has been created, or will be destroyed quite soon. echo "2" > logical_drive_created after creating logical drive #2 in the management app echo "4" > logical_drive_destroyed immediately before destroying logical drive #4 in the management app. Eventually these functions should be called directly from the management app. 2. Made class_device_megaraid_mbox_app_hndl and dev_attr_megaraid_mbox_ld static. Signed-off-by: Matt Domsch <[EMAIL PROTECTED]> Documentation/scsi/ChangeLog.megaraid | 26 +++++++++ drivers/scsi/megaraid/megaraid_mbox.c | 97 ++++++++++++++++++++++++++++++---- drivers/scsi/megaraid/megaraid_mbox.h | 4 - 3 files changed, 116 insertions, 11 deletions diff -Nru a/Documentation/scsi/ChangeLog.megaraid b/Documentation/scsi/ChangeLog.megaraid --- a/Documentation/scsi/ChangeLog.megaraid 2005-02-08 17:16:27 -06:00 +++ b/Documentation/scsi/ChangeLog.megaraid 2005-02-08 17:16:27 -06:00 @@ -1,3 +1,29 @@ +Release Date : Tue Feb 08 12:27:22 EST 2005 - Matt Domsch <[EMAIL PROTECTED]> +Current Version : 2.20.4.6 (scsi module), 2.20.2.5 (cmm module) +Older Version : 2.20.4.5 (scsi module), 2.20.2.5 (cmm module) + +1. Added two new megaraid_shost_attrs + /sys/class/scsi_host + |-- host0 + | |-- logical_drive_created + | |-- logical_drive_destroyed + + and helper functions for them. Written to from userspace by + a management application, these invoke SCSI hotplug + infrastructure for informing the kernel that a logical drive + has been created, or will be destroyed quite soon. + echo "2" > logical_drive_created + after creating logical drive #2 in the management app + echo "4" > logical_drive_destroyed + immediately before destroying logical drive #4 in the + management app. Eventually these functions should be called + directly from the management app. + +2. Made class_device_megaraid_mbox_app_hndl and + dev_attr_megaraid_mbox_ld static. + + + Release Date : Thu Feb 03 12:27:22 EST 2005 - Seokmann Ju <[EMAIL PROTECTED]> Current Version : 2.20.4.5 (scsi module), 2.20.2.5 (cmm module) Older Version : 2.20.4.4 (scsi module), 2.20.2.4 (cmm module) diff -Nru a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c --- a/drivers/scsi/megaraid/megaraid_mbox.c 2005-02-08 17:16:27 -06:00 +++ b/drivers/scsi/megaraid/megaraid_mbox.c 2005-02-08 17:16:27 -06:00 @@ -69,6 +69,7 @@ * For history of changes, see Documentation/ChangeLog.megaraid */ +#include <scsi/scsi_hotplug.h> #include "megaraid_mbox.h" static int megaraid_init(void); @@ -470,29 +471,107 @@ } }; +/* + * sysfs class device support + * creates two files: + * /sys/class/scsi_host + * |-- host0 + * | |-- logical_drive_created + * | |-- logical_drive_destroyed + * + * These make the midlayer invoke /sbin/hotplug, which then calls back into sysfs + * /sys/class/scsi_host + * |-- host0 + * | |-- scan + * + * and + * + * /sys/devices/pci0000:0x/0000:0x:0x.0/host0 + * |-- 0:0:0:0 + * | |-- delete + * + * respectively. This allows userspace applications to work + * using their logical drive number, and lets the driver translate + * that into host, channel, id, and lun values which the other + * mechanisms require. This is similar to how hot plug CPU works. + */ +/** + * lda_to_hcil() + * @adapter + * @lda - logical drive address + * @host_no + * @channel + * @id + * @lun + * + * converts a logical drive address into a host, channel id, lun tuple. + */ -// definitions for the device attributes for exporting logical drive number -// for a scsi address (Host, Channel, Id, Lun) - -CLASS_DEVICE_ATTR(megaraid_mbox_app_hndl, S_IRUSR, megaraid_sysfs_show_app_hndl, +static inline int megaraid_lda_to_hcil(struct Scsi_Host *shost, u32 lda, + u32 *host_no, u32 *channel, u32 *id, u32 *lun) +{ + if (lda > MAX_LOGICAL_DRIVES_40LD) + return -EINVAL; + *host_no = shost->host_no; + *channel = shost->max_channel; + *id = (lda < shost->this_id) ? lda : lda + 1; + *lun = 0; + return 0; +} + +static int megaraid_host_store(struct class_device *class_dev, const char *buf, size_t count, + enum scsi_topology_action action) +{ + struct Scsi_Host *shost = class_to_shost(class_dev); + int fields=0, rc=-EINVAL; + u32 lda=0, host_no=0, channel=0, id=0, lun=0; + fields = sscanf(buf, "%u", &lda); + if (fields != 1) + return rc; + if (lda > MAX_LOGICAL_DRIVES_40LD) + return rc; + rc = megaraid_lda_to_hcil(shost, lda, &host_no, &channel, &id, &lun); + if (rc) + return rc; + + rc = scsi_topology_hctl_action(shost, channel, id, lun, action); + + if (rc) + return rc; + return count; +} + +static ssize_t megaraid_host_store_ld_created(struct class_device *class_dev, const char *buf, size_t count) +{ + return megaraid_host_store(class_dev, buf, count, SCSI_TOPOLOGY_ADDED); +} +static ssize_t megaraid_host_store_ld_destroyed(struct class_device *class_dev, const char *buf, size_t count) +{ + return megaraid_host_store(class_dev, buf, count, SCSI_TOPOLOGY_REMOVED); +} + +#define MEGARAID_HOST_WOATTR(_name,_store) \ +CLASS_DEVICE_ATTR(_name, S_IWUSR|S_IWGRP, NULL, _store) + +static MEGARAID_HOST_WOATTR(logical_drive_created, megaraid_host_store_ld_created); +static MEGARAID_HOST_WOATTR(logical_drive_destroyed, megaraid_host_store_ld_destroyed); +static CLASS_DEVICE_ATTR(megaraid_mbox_app_hndl, S_IRUSR, megaraid_sysfs_show_app_hndl, NULL); -// Host template initializer for megaraid mbox sysfs device attributes static struct class_device_attribute *megaraid_shost_attrs[] = { &class_device_attr_megaraid_mbox_app_hndl, + &class_device_attr_logical_drive_created, + &class_device_attr_logical_drive_destroyed, NULL, }; +static DEVICE_ATTR(megaraid_mbox_ld, S_IRUSR, megaraid_sysfs_show_ldnum, NULL); -DEVICE_ATTR(megaraid_mbox_ld, S_IRUSR, megaraid_sysfs_show_ldnum, NULL); - -// Host template initializer for megaraid mbox sysfs device attributes static struct device_attribute *megaraid_sdev_attrs[] = { &dev_attr_megaraid_mbox_ld, NULL, }; - /* * Scsi host template for megaraid unified driver diff -Nru a/drivers/scsi/megaraid/megaraid_mbox.h b/drivers/scsi/megaraid/megaraid_mbox.h --- a/drivers/scsi/megaraid/megaraid_mbox.h 2005-02-08 17:16:27 -06:00 +++ b/drivers/scsi/megaraid/megaraid_mbox.h 2005-02-08 17:16:27 -06:00 @@ -21,8 +21,8 @@ #include "megaraid_ioctl.h" -#define MEGARAID_VERSION "2.20.4.5" -#define MEGARAID_EXT_VERSION "(Release Date: Thu Feb 03 12:27:22 EST 2005)" +#define MEGARAID_VERSION "2.20.4.6" +#define MEGARAID_EXT_VERSION "(Release Date: Tue Feb 08 12:27:22 EST 2005)" /* =================================================================== This BitKeeper patch contains the following changesets: 1.2132.2.3 ## Wrapped with gzip_uu ## M'XL( $M("4( \U9^U/;[EMAIL PROTECTED]:P?>OJ5P,%B7]:U)% VD+U:ME1C M:8P4]/!I) BWWO_]ND>2'\$$ \G5&<>6QC-?=W_=T]VCO($+P9-NY0-+4[L7 MA\+QE#?P2RS2;L7E05!WXA 'AG&, PTO#GDC=.6TQOBF(1SA-P(_RK[4]'JS M1K<U+TZG07:MX*HSECH>W/)$="M:W9B/I/=3WJT,^^\O3HZ&BK*_#\<>BZ[Y MB*>POZ^D<7++ E<<LM0+XJB>)BP2(4\9*3.;3YWIJJKCGZ6U#-5JSK2F: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QJR-=^+OE=.2W% M:+!]=Q?^079!5W[^!!JM(2KS-2K>[EMAIL PROTECTED]&^=$+C$HU1%8"WA)X')E1E;* MNRKY%UE%_1+8&V>3*D;C?[B-([EMAIL PROTECTED]>P5D/DCC:8RQ<&\SV31 _D5\ MEG7]$:^A_KED]*X<V)DKLON6FKL4<RC'ZK6O5B%Q]A>,%]ZF\8)JNBQ8I4O? MI4_D:9\8RE'(!92>)CO2L*V_9UM5V$88*0P]7TS[VSYH2WY.G+?/"PRY(,'> [EMAIL PROTECTED]@A6VY]&Y/8_,;8K*;8K(0F[B? 5^5<"OLN]A5U:XH)2QDI40L5KZ M1F*LQ2ZOI;]7(DH4D; FJM"^LE"]+L#D)BPT6!>]2SAR;[EMAIL PROTECTED]>G:)C M_F4?]7K]WB[IOIGF\PKZ?Z#[L/_A]++0_DIYX_()I<,/_?='PZ-!S_[E='1N [EMAIL PROTECTED]"WDU!]^%*^7XY&@TLGO]R\%QWUZ: 2-[\.EB-)S1]_OA614^ M7IR<5*%8N7#P6BEKNY'J$T& ZF^..:?_4=3YC 7N0V/7'[EMAIL PROTECTED]<-C:4 M<.X6T[ <M:D5')AM W2ELKUR=)%GDO5,;#!U82#!-U%*8<[EMAIL PROTECTED]'+J;? MW)-("[EMAIL PROTECTED]:B;WHZ\K[#Z6C#YWC?X73DK9Z.+'[EMAIL PROTECTED];DZ:CSW.==4--_ MR-GHYRR<[EMAIL PROTECTED]/&[EMAIL PROTECTED],]X*C3$\W,7 'NH6?#_+&97\X&IQ^K&R5SZ:V M'L[I_W:^F+>S_)SLVX_)=K<6_VWJ>-RY$5FXKXW52=,<6\I_ 9(%20&L'0 - To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html