linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* RE: How to add/drop SCSI drives from within the driver?
@ 2005-01-25 23:37 Mukker, Atul
  2005-01-26 14:48 ` Brian King
  0 siblings, 1 reply; 59+ messages in thread
From: Mukker, Atul @ 2005-01-25 23:37 UTC (permalink / raw)
  To: 'Patrick Mansfield', Mukker, Atul
  Cc: 'James Bottomley', 'Linux Kernel',
	'SCSI Mailing List'

Thanks for the suggestion. After more exploration, looks like different
distribution have different implementations for /sbin/hotplug. This may
aggravate the issue for applications. For now, we will stick with a wait and
watch after bus scan :-(

Will probe the linux-hotplug-devel@lists.sourceforge.net list for more
pointers

Thanks

===========================
Atul Mukker
Architect, Drivers and BIOS
LSI Logic Corporation


> -----Original Message-----
> From: Patrick Mansfield [mailto:patmans@us.ibm.com] 
> Sent: Tuesday, January 25, 2005 11:52 AM
> To: Mukker, Atul
> Cc: 'James Bottomley'; Linux Kernel; SCSI Mailing List
> Subject: Re: How to add/drop SCSI drives from within the driver?
> 
> Atul -
> 
> On Tue, Jan 25, 2005 at 11:27:36AM -0500, Mukker, Atul wrote:
> > After writing the "- - -" to the scan attribute, the management 
> > applications assume the udev has created the relevant 
> entries in the 
> > /dev directly and try to use the devices _immediately_ and 
> fail to see 
> > the devices
> > 
> > Is there a hotplug event which would tell the management 
> applications 
> > that the device nodes have actually been created now and 
> ready to be used?
> 
> Read the udev man page section, the part right before 
> "FILES". Try putting a script under /etc/dev.d/default/*.dev. 
> Then you can get more specific with an /etc/dev.d/scsi/*.dev 
> script or something else.
> 
> I just tried something simple but did not get it working.
> 
> Try linux-hotplug-devel@lists.sourceforge.net list for help.
> 
> -- Patrick Mansfield
> 

^ permalink raw reply	[flat|nested] 59+ messages in thread
* RE: How to add/drop SCSI drives from within the driver?
@ 2005-01-26 23:23 Mukker, Atul
  2005-01-27  7:05 ` 'Patrick Mansfield'
  0 siblings, 1 reply; 59+ messages in thread
From: Mukker, Atul @ 2005-01-26 23:23 UTC (permalink / raw)
  To: 'Greg KH'
  Cc: 'Patrick Mansfield', 'James Bottomley',
	'Linux Kernel', 'SCSI Mailing List'

> 
> And what do you mean "different implementations for /sbin/hotplug"?
> What distros do not use the standard "linux-hotplug" type 
> scripts, or if not the scripts, the same functionality?

You are right, even though distributions (I checked Red Hat and SuSE) have
different /sbin/hotplug scripts (e.g., SuSE 9.2 will not execute files from
/etc/hotplug.d whereas Red Hat does) udev will be invoked in all cases,
which will take care of creating device nodes.

But our concern is that how would the applications get the cue that udev has
actually created the nodes for the new devices? 

Make sure an agent is called after the, e.g., scsi agents are executed from
/etc/hotplug directory (which happen to be scsi.agent, scsi_device.agent,
scsi_host.agent in one and only scsi.agent in other distribution), by
writing an rc like script?

Or more likely, by placing our agent in /etc/dev.d directory. Unfortunately,
there seems be not a consensus here as well. On system has "default" and
"net" directories and other has "block", "input", "net", "tty"?


Thanks

--------------------------------
Atul Mukker
Architect, RAID Drivers and BIOS
LSI Logic Corporation

^ permalink raw reply	[flat|nested] 59+ messages in thread
* RE: How to add/drop SCSI drives from within the driver?
@ 2005-01-26 16:48 Greg KH
  0 siblings, 0 replies; 59+ messages in thread
From: Greg KH @ 2005-01-26 16:48 UTC (permalink / raw)
  Cc: 'Patrick Mansfield', Mukker, Atul,
	'James Bottomley', 'Linux Kernel',
	'SCSI Mailing List'

> Thanks for the suggestion. After more exploration, looks like different
> distribution have different implementations for /sbin/hotplug. This may
> aggravate the issue for applications. For now, we will stick with a wait and
> watch after bus scan :-(

What do you mean?  Just use the /etc/dev.d notification stuff that all
distros that use udev have.

And what do you mean "different implementations for /sbin/hotplug"?
What distros do not use the standard "linux-hotplug" type scripts, or if
not the scripts, the same functionality?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 59+ messages in thread
* RE: How to add/drop SCSI drives from within the driver?
@ 2005-01-25 16:27 Mukker, Atul
  2005-01-25 16:52 ` Patrick Mansfield
  0 siblings, 1 reply; 59+ messages in thread
From: Mukker, Atul @ 2005-01-25 16:27 UTC (permalink / raw)
  To: 'James Bottomley'; +Cc: Linux Kernel, SCSI Mailing List

> 
> > After the new logical drives are created with "- - -" written to the
> > scsi_host scan attribute, there is a highly noticeable delay before
> device
> > names (e.g., sda) appears in the /dev directory. If the management
> > application tried to access the device immediately after creating new,
> the
> > access fails. Putting a 1 second delay helped, but of course this is not
> a
> > deterministic solution.
> >
> > What are the other possibilities?
> 
> Well, how about hotplug.  The device addition actually triggers a hot
> plug event already (there's no need to add anything, it's done by the
> mid-layer), so if you just listen for that, you'll know when the scan
> has detected a device.


After writing the "- - -" to the scan attribute, the management applications
assume the udev has created the relevant entries in the /dev directly and
try to use the devices _immediately_ and fail to see the devices

Is there a hotplug event which would tell the management applications that
the device nodes have actually been created now and ready to be used?

I tried this simple script to re-create the failure. Assume there is one
scsi disk, which is the installation disk. Now load the megaraid driver,
with a few logical drive already created.

# insmod megaraid_mm.ko; insmod megaraid_mbox.ko; ls -l /dev/sd*
<driver loads>
<not all scsi devices are available>

<try again after a brief delay>
# ls -l /dev/sd*	# all devices show up now

Thanks
-Atul

^ permalink raw reply	[flat|nested] 59+ messages in thread
* RE: How to add/drop SCSI drives from within the driver?
@ 2005-01-21 22:11 Mukker, Atul
  2005-01-21 23:58 ` James Bottomley
  0 siblings, 1 reply; 59+ messages in thread
From: Mukker, Atul @ 2005-01-21 22:11 UTC (permalink / raw)
  To: 'James Bottomley', 'Matt Domsch'
  Cc: 'Salyzyn, Mark', Bagalkote, Sreenivas,
	'brking@us.ibm.com', 'Linux Kernel',
	'SCSI Mailing List', 'bunk@fs.tum.de',
	'Andrew Morton', Ju, Seokmann, Doelfel, Hardy,
	Mukker, Atul

All right! The implementation is complete for this and the driver has
thoroughly gone through testing. Everything looks good except for a minor
glitch.

After the new logical drives are created with "- - -" written to the
scsi_host scan attribute, there is a highly noticeable delay before device
names (e.g., sda) appears in the /dev directory. If the management
application tried to access the device immediately after creating new, the
access fails. Putting a 1 second delay helped, but of course this is not a
deterministic solution.

What are the other possibilities?

Thanks
-Atul Mukker
LSI Logic

> -----Original Message-----
> From: James Bottomley [mailto:James.Bottomley@SteelEye.com] 
> Sent: Wednesday, December 15, 2004 1:49 PM
> To: Matt Domsch
> Cc: Salyzyn, Mark; Bagalkote, Sreenivas; brking@us.ibm.com; 
> Linux Kernel; SCSI Mailing List; bunk@fs.tum.de; Andrew 
> Morton; Ju, Seokmann; Doelfel, Hardy; Mukker, Atul
> Subject: Re: How to add/drop SCSI drives from within the driver?
> 
> On Wed, 2004-12-15 at 01:24 -0600, Matt Domsch wrote:
> > James, I've been thinking about this a little more, and you 
> may be on 
> > to something here. Let each driver add files as such:
> > 
> > /sys/class/scsi_host
> >  |-- host0
> >  |   |-- add_logical_drive
> >  |   |-- remove_logical_drive
> >  |   `-- rescan_logical_drive
> > 
> > Then we can go 2 ways with this.
> > 1) driver functions directly call scsi_add_device(), 
> > scsi_remove_device(), and something for rescan (option 2 
> handles this 
> > one cleanly for us).  ATM, megaraid_mbox doesn't implement a rescan 
> > function, so this point may be moot.
> > 
> > 2) driver functions call a midlayer library function, which invokes
> >    /sbin/hotplug with appropriate data, and add a new /etc/hotplug.d
> >    helper app which would then write to these files:
> > 
> > /sys/class/scsi_host
> > |-- host0
> > |   |-- scan
> > /sys/devices/pci0000:0x/0000:0x:0x.0/host0
> > |-- 0:0:0:0
> > |   |-- delete
> > |   |-- rescan
> > 
> > to do likewise.
> 
> I'll buy this (option 2).. it seems like a good way to export 
> the megaraid specific information and at the same time 
> integrate it more fully into the evolving hotplug infrastructure.
> 
> James
> 
> 
> -
> To unsubscribe from this list: send the line "unsubscribe 
> linux-kernel" in the body of a message to 
> majordomo@vger.kernel.org More majordomo info at  
> http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
> 

^ permalink raw reply	[flat|nested] 59+ messages in thread
* RE: How to add/drop SCSI drives from within the driver?
@ 2005-01-06 14:20 Mukker, Atul
  2005-01-06 14:42 ` James Bottomley
  0 siblings, 1 reply; 59+ messages in thread
From: Mukker, Atul @ 2005-01-06 14:20 UTC (permalink / raw)
  To: 'James Bottomley', Bagalkote, Sreenivas
  Cc: 'Matt Domsch', 'Salyzyn, Mark',
	'brking@us.ibm.com', 'Linux Kernel',
	'SCSI Mailing List', 'bunk@fs.tum.de',
	'Andrew Morton', Ju, Seokmann, Doelfel, Hardy,
	Mukker, Atul

> > the management app, there is no getting around knowing HCTL 
> mapping. 
> > The app must know the HCTL quad of a logical drive.
> 
> Actually, if that's all you're trying to do, what about
> 
> echo '- - -' > /sys/class/scsi_host/host<n>/scan
> 
> That'll trigger a rescan of the entire card and the device 
> will be found and added?
For this to happen, the applications must at lease know 'n' in host<n>,
otherwise it will have to trigger a rescan on all controllers. Which would
be an overkill. How about publishing the adapter class attribute as well?
This would allow applications to correlate the adapter handle with the class
attribute.

> 
> Then, if you simply publish your LD number as an extra 
> parameter of the device, you can look through /sys to find it.
Taken

Apologize for the late post, we were evaluating your feedback. It looks
good, thanks!


--------
Atul Mukker
Architect, Drivers and BIOS
LSI Logic Corporation

^ permalink raw reply	[flat|nested] 59+ messages in thread
* RE: How to add/drop SCSI drives from within the driver?
@ 2005-01-04 17:25 Bagalkote, Sreenivas
  2005-01-04 17:42 ` James Bottomley
  0 siblings, 1 reply; 59+ messages in thread
From: Bagalkote, Sreenivas @ 2005-01-04 17:25 UTC (permalink / raw)
  To: 'James Bottomley', Bagalkote, Sreenivas
  Cc: Matt Domsch, Salyzyn, Mark, brking, Linux Kernel,
	SCSI Mailing List, bunk, Andrew Morton, Ju, Seokmann,
	Doelfel, Hardy, Mukker, Atul

>
>On Mon, 2005-01-03 at 18:02 -0500, Bagalkote, Sreenivas wrote:
>> o    Everybody understands that as long as the SCSI 
>scan/rescan is triggered
>> by 
>> the management app, there is no getting around knowing HCTL 
>mapping. The app
>> must know the HCTL quad of a logical drive.
>
>Actually, if that's all you're trying to do, what about
>
>echo '- - -' > /sys/class/scsi_host/host<n>/scan
>
>That'll trigger a rescan of the entire card and the device 
>will be found
>and added?
>

A minor point is that an application should ideally force scan only those
drives
that it has added. But more importantly, this will not help an application
to delete
the drives. Correct?

Sreenivas

^ permalink raw reply	[flat|nested] 59+ messages in thread
* RE: How to add/drop SCSI drives from within the driver?
@ 2005-01-03 23:02 Bagalkote, Sreenivas
  2005-01-03 23:40 ` James Bottomley
  0 siblings, 1 reply; 59+ messages in thread
From: Bagalkote, Sreenivas @ 2005-01-03 23:02 UTC (permalink / raw)
  To: 'Matt Domsch', James Bottomley
  Cc: Salyzyn, Mark, Bagalkote, Sreenivas, brking, linux-kernel,
	SCSI Mailing List, bunk, Andrew Morton, Ju, Seokmann,
	Doelfel, Hardy, Mukker, Atul

Hello All,

I am trying to stoke this thread once more. Please review the brief summary
of all discussion and a new sysfs based proposal.

o    The more ideal and long-term way to handle addition and removal of
devices is through hotplug mechanism. Currently it is not fully developed.
Moreover, the megaraid SCSI driver doesn't get any event notification from
the FW that the configuration has been changed.

o    Management App that communicates to FW via driver private ioctls is the
one that creates/modifies the configuration. This is transparent to the
driver.

o    Logical drives being "logical", the driver exports the logical drives
on virtual
SCSI addresses. The management app that knows about LD0, LD1 .. LDn, does
not know the LDn to HCTL mapping (Host:Channel:Target:Lun)

o    Everybody understands that as long as the SCSI scan/rescan is triggered
by 
the management app, there is no getting around knowing HCTL mapping. The app
must know the HCTL quad of a logical drive.

o    Our original solution was that the driver returns HCTL of a LD via
ioctl. This
has been squarely rejected because kernel cannot add any more private
ioctls.

Considering that the app has to somehow _know_ the HCTL given a logical
drive
(that it has deleted or will be adding), please provide your feedback on the
following
proposal. I know that it is not radically different.

The driver would create nodes for all possible logical drives.

/sys/modules
 |-- megaraid_mbox
 |   |-- LD0
 |   |-- LD1
 |   |-- LD2
 |   |-- LD(i)
 |   |-- LD40

One of the attributes of a LD node would be HCTL information. A management
app
can then scan, delete the LDs using corresponding HCTL address.

Y'all have a great new year!

Sreenivas
LSI Logic

^ permalink raw reply	[flat|nested] 59+ messages in thread
* RE: How to add/drop SCSI drives from within the driver?
@ 2004-12-16 16:51 Salyzyn, Mark
  0 siblings, 0 replies; 59+ messages in thread
From: Salyzyn, Mark @ 2004-12-16 16:51 UTC (permalink / raw)
  To: Alan Cox, Arjan van de Ven
  Cc: Matt Domsch, James Bottomley, Bagalkote, Sreenivas, brking,
	Linux Kernel Mailing List, SCSI Mailing List, bunk, Andrew Morton,
	Ju, Seokmann, Doelfel, Hardy, Mukker, Atul

Alan Cox writes:
 
>On Iau, 2004-12-16 at 09:54, Arjan van de Ven wrote:
>> I'm strongly against adding this. The reason for that is that once an
>> ioctl is added, it realistically will and can never go away.
>> LSI is free to have their own fork and give that to dell; but they
>> should and could have known that it wasn't going to fly. (same I
guess
>> for adaptec ioctls). The companies who then commit to some schedule
>> realize they take a huge risk, but that is no reason to foul up the
>> kernel more. 
>
>I agree. I'd like to see an agreed standard interface for dropping and
>managing physical volumes and drives, as well as a standard interface
>for dropping/managing logical volumes.

Simple transactions, perhaps, but there are many checks, balances and
complexities associated with a full management application that do not
make sense to reside in the kernel.

Aacraid uses a FIB to communicate a wide variety of RAID management
commands.
Dpt_i2o uses an I2O private frame to communicate the RAID management
commands.

The remaining ioctls pick up driver or OS internal information as has
been discussed thus far. Moving these pieces of information to sysfs
does make some sense.

However, in order to add the ability to manage the arrays, especially if
they follow the complexity of the container arrangement, hotspare
assignments, the multitude of array types and their configuration needs
and various other RAID or Cache policies; one will find the code sucked
into the driver to be a lead weight. Adding a `translation' layer from
FIB, I2O and other frames to a common set is *not* going to be
lightweight and will not be full coverage. The recent efforts by HP to
push CSMI added 30% to the size of the driver (Adaptec Branched
version). Yuck (this is a scientific term) and only added `monitoring'
and 'drive passthrough' capabilities.

Array status monitoring is complicated enough to pull out into an
application (the recent dropping of the firmware print messages and
replacement with the aeventd application).

By all means, let's set a standard for rudimentary array manipulation,
but let's not loose sight of the complicated needs of the consumers of
RAID equipment. Sysfs does not look like it will scale well towards a
full up management interface.

Sincerely -- Mark Salyzyn

^ permalink raw reply	[flat|nested] 59+ messages in thread
* RE: How to add/drop SCSI drives from within the driver?
@ 2004-12-16 14:27 Mukker, Atul
  0 siblings, 0 replies; 59+ messages in thread
From: Mukker, Atul @ 2004-12-16 14:27 UTC (permalink / raw)
  To: 'Arjan van de Ven', 'Matt Domsch'
  Cc: 'James Bottomley', 'Salyzyn, Mark',
	Bagalkote, Sreenivas, 'brking@us.ibm.com',
	'Linux Kernel', 'SCSI Mailing List',
	'bunk@fs.tum.de', 'Andrew Morton', Ju, Seokmann,
	Doelfel, Hardy, Mukker, Atul

> On Wed, 2004-12-15 at 15:30 -0600, Matt Domsch wrote:
> > Do you plan to apply LSI's driver patch which adds the 
> driver-private 
> > ioctl to provide the mapping from logical drive address to 
> HCTL value?
> > Both Dell and LSI have products which are lined up to use this new 
> > ioctl because it's the most expedient thing to do, 
> maintains internal 
> > project schedules, etc, which delaying until this sysfs 
> mechanism hits 
> > will greatly impact those schedules. (I know, many folks on 
> this list 
> > don't care about business-side impacts of choices made on-list.)
> 
> I'm strongly against adding this. The reason for that is that 
> once an ioctl is added, it realistically will and can never go away.

This issue has gone from the utility of the ioctl in question (which has
been discussed in detail on the list) to now outright rejection of the
driver ioctls. If this is the idea, drivers would need to consciously move
the driver only ioctls to sysfs. Which may be good for simple ioctls like
these but might now be elegant for complex transfers. So, IMO, drivers need
both of the interfaces and should make a good judgment call on services
provided by each interface.

>
> that is no reason to foul up the kernel more. 
> 
The ioctl in question has been discussed in detail and was deemed
appropriate ioctl to provide important service to the management
applications for device hot plugging. Schedules are one side of the story,
but we must not overlook the importance of the reason to have this ioctl in
the first place. If there are other preferred ways to implement the similar
functionality, we would be more than happy to consider that.

Thanks
-Atul Mukker

^ permalink raw reply	[flat|nested] 59+ messages in thread
* RE: How to add/drop SCSI drives from within the driver?
@ 2004-12-15 19:42 Mukker, Atul
  2004-12-15 20:22 ` Matt Domsch
  0 siblings, 1 reply; 59+ messages in thread
From: Mukker, Atul @ 2004-12-15 19:42 UTC (permalink / raw)
  To: 'Matt Domsch', 'James Bottomley'
  Cc: 'Salyzyn, Mark', Bagalkote, Sreenivas,
	'brking@us.ibm.com',
	'linux-kernel@vger.kernel.org',
	'SCSI Mailing List', 'bunk@fs.tum.de',
	'Andrew Morton', Ju, Seokmann, Doelfel, Hardy,
	Mukker, Atul

> 
> Your management apps currently issue a private ioctl 
> MEGAIOC_QNADAP which returns the number of 
> megaraid_mm-handled adapters in the system.  How do you map a 
> megaraid adapter number to a struct Scsi_Host device, to be 
> sure you're acting on the controller you think you are?
Megaraid_mm module maintains all the controllers on a list
(mraid_mm_get_adapter), and each of the adapter maintains a pointer to the
host object.

> 
> SCSI LLDDs don't show up in sysfs under /sys/bus/scsi/drivers 
> at present, which is where, I think, you would want to put 
> megaraid_mm with links to show the scsi_host and pci_dev 
> associated with this adapter.  Something like this:
> 
> /sys
> |-- bus
> |   `-- drivers
> |       `-- scsi
> |           `-- megaraid_mm
> |               `-- adapter0
> |                   |-- pci_dev -> 
> ../../../../../devices/pci0000:03/0000:03:06.0
> |                   `-- scsi_host -> 
> |../../../../../class/scsi/scsi_host/host0
> |-- class
> |   `-- scsi
> |       `-- scsi_host
> |           `-- host0
> `-- devices
>     `-- pci0000:03
>         `-- 0000:03:06.0
Megaraid_mm is not a 'scsi' driver but only a conduit to pass the commands
from application to the megaraid_mbox scsi module. 

^ permalink raw reply	[flat|nested] 59+ messages in thread
* RE: How to add/drop SCSI drives from within the driver?
@ 2004-12-10  0:31 Bagalkote, Sreenivas
  0 siblings, 0 replies; 59+ messages in thread
From: Bagalkote, Sreenivas @ 2004-12-10  0:31 UTC (permalink / raw)
  To: 'Matt Domsch'
  Cc: 'brking@us.ibm.com', 'James Bottomley',
	'linux-kernel@vger.kernel.org',
	'linux-scsi@vger.kernel.org', 'bunk@fs.tum.de',
	'Andrew Morton', Ju, Seokmann, Doelfel, Hardy,
	Mukker, Atul

>> +} __attribute__ ((packed));
>
>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

^ permalink raw reply	[flat|nested] 59+ messages in thread
* RE: How to add/drop SCSI drives from within the driver?
@ 2004-12-09 23:37 Bagalkote, Sreenivas
  2004-12-10  0:03 ` Matt Domsch
  0 siblings, 1 reply; 59+ messages in thread
From: Bagalkote, Sreenivas @ 2004-12-09 23:37 UTC (permalink / raw)
  To: Matt Domsch
  Cc: 'brking@us.ibm.com', 'James Bottomley',
	'linux-kernel@vger.kernel.org',
	'linux-scsi@vger.kernel.org', 'bunk@fs.tum.de',
	'Andrew Morton', Ju, Seokmann, Doelfel, Hardy,
	Mukker, Atul

[-- Attachment #1: Type: text/plain, Size: 8487 bytes --]

All,

I am submitting the final patch that incorporates Matt's suggestions.

Thank you,
Sreenivas


diff -Naur old-rc2/Documentation/scsi/ChangeLog.megaraid
new-rc2/Documentation/scsi/ChangeLog.megaraid
--- old-rc2/Documentation/scsi/ChangeLog.megaraid	2004-12-07
16:40:23.000000000 -0500
+++ new-rc2/Documentation/scsi/ChangeLog.megaraid	2004-12-09
17:38:58.000000000 -0500
@@ -1,3 +1,22 @@
+Release Date	: Thu Dec  9 17:25:27 EST 2004 - Sreenivas Bagalkote
<sreenib@lsil.com>
+
+Current Version	: 2.20.4.2 (scsi module), 2.20.2.3 (cmm module)
+Older Version	: 2.20.4.1 (scsi module), 2.20.2.2 (cmm module)
+
+i.	Fixed a bug in deallocating kioc's dma buffer in megaraid_mm module
+ii.	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@us.ibm.com)
+	
+	"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@dell.com)
+
 Release Date	: Thu Nov  4 18:24:56 EST 2004 - Sreenivas Bagalkote
<sreenib@lsil.com>
 
 Current Version	: 2.20.4.1 (scsi module), 2.20.2.2 (cmm module)
diff -Naur old-rc2/drivers/scsi/megaraid/megaraid_ioctl.h
new-rc2/drivers/scsi/megaraid/megaraid_ioctl.h
--- old-rc2/drivers/scsi/megaraid/megaraid_ioctl.h	2004-12-07
16:40:16.000000000 -0500
+++ new-rc2/drivers/scsi/megaraid/megaraid_ioctl.h	2004-12-09
17:05:18.000000000 -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
@@ -142,7 +144,7 @@
 
 	caddr_t			buf_vaddr;
 	dma_addr_t		buf_paddr;
-	uint8_t			pool_index;
+	int8_t			pool_index;
 	uint8_t			free_buf;
 
 	uint8_t			timedout;
@@ -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];
+} __attribute__ ((packed));
 
 /**
  * mm_dmapool_t	: Represents one dma pool with just one buffer
diff -Naur old-rc2/drivers/scsi/megaraid/megaraid_mbox.c
new-rc2/drivers/scsi/megaraid/megaraid_mbox.c
--- old-rc2/drivers/scsi/megaraid/megaraid_mbox.c	2004-12-07
16:40:16.000000000 -0500
+++ new-rc2/drivers/scsi/megaraid/megaraid_mbox.c	2004-12-09
17:42:33.538473752 -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@lsil.com>
@@ -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 old-rc2/drivers/scsi/megaraid/megaraid_mbox.h
new-rc2/drivers/scsi/megaraid/megaraid_mbox.h
--- old-rc2/drivers/scsi/megaraid/megaraid_mbox.h	2004-12-07
16:40:16.000000000 -0500
+++ new-rc2/drivers/scsi/megaraid/megaraid_mbox.h	2004-12-09
17:41:34.706417584 -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 17:25:27 EST
2004)"
 
 
 /*
diff -Naur old-rc2/drivers/scsi/megaraid/megaraid_mm.c
new-rc2/drivers/scsi/megaraid/megaraid_mm.c
--- old-rc2/drivers/scsi/megaraid/megaraid_mm.c	2004-12-07
16:40:16.000000000 -0500
+++ new-rc2/drivers/scsi/megaraid/megaraid_mm.c	2004-12-09
18:12:16.485424616 -0500
@@ -10,7 +10,7 @@
  *	   2 of the License, or (at your option) any later version.
  *
  * FILE		: megaraid_mm.c
- * Version	: v2.20.2.2 (Nov 04 2004)
+ * Version	: v2.20.2.3 (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"));
@@ -614,23 +628,27 @@
 	mm_dmapool_t	*pool;
 	unsigned long	flags;
 
-	pool = &adp->dma_pool_list[kioc->pool_index];
+	if (kioc->pool_index != -1) {
+		pool = &adp->dma_pool_list[kioc->pool_index];
 
-	/* This routine may be called in non-isr context also */
-	spin_lock_irqsave(&pool->lock, flags);
+		/* This routine may be called in non-isr context also */
+		spin_lock_irqsave(&pool->lock, flags);
 
-	/*
-	 * While attaching the dma buffer, if we didn't get the required
-	 * buffer from the pool, we would have allocated it at the run time
-	 * and set the free_buf flag. We must free that buffer. Otherwise,
-	 * just mark that the buffer is not in use
-	 */
-	if (kioc->free_buf == 1)
-		pci_pool_free(pool->handle, kioc->buf_vaddr,
kioc->buf_paddr);
-	else
-		pool->in_use = 0;
+		/*
+		 * While attaching the dma buffer, if we didn't get the 
+		 * required buffer from the pool, we would have allocated 
+		 * it at the run time and set the free_buf flag. We must 
+		 * free that buffer. Otherwise, just mark that the buffer is

+		 * not in use
+		 */
+		if (kioc->free_buf == 1)
+			pci_pool_free(pool->handle, kioc->buf_vaddr, 
+							kioc->buf_paddr);
+		else
+			pool->in_use = 0;
 
-	spin_unlock_irqrestore(&pool->lock, flags);
+		spin_unlock_irqrestore(&pool->lock, flags);
+	}
 
 	/* Return the kioc to the free pool */
 	spin_lock_irqsave(&adp->kioc_pool_lock, flags);
@@ -809,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 old-rc2/drivers/scsi/megaraid/megaraid_mm.h
new-rc2/drivers/scsi/megaraid/megaraid_mm.h
--- old-rc2/drivers/scsi/megaraid/megaraid_mm.h	2004-12-07
16:40:15.000000000 -0500
+++ new-rc2/drivers/scsi/megaraid/megaraid_mm.h	2004-12-09
18:12:10.336359416 -0500
@@ -29,9 +29,9 @@
 #include "megaraid_ioctl.h"
 
 
-#define LSI_COMMON_MOD_VERSION	"2.20.2.2"
+#define LSI_COMMON_MOD_VERSION	"2.20.2.3"
 #define LSI_COMMON_MOD_EXT_VERSION	\
-		"(Release Date: Thu Nov  4 17:46:29 EST 2004)"
+		"(Release Date: Thu Dec  9 17:25:27 EST 2004)"
 
 
 #define LSI_DBGLVL			dbglevel



[-- Attachment #2: megaraid-hctl.patch --]
[-- Type: application/octet-stream, Size: 8638 bytes --]

diff -Naur old-rc2/Documentation/scsi/ChangeLog.megaraid new-rc2/Documentation/scsi/ChangeLog.megaraid
--- old-rc2/Documentation/scsi/ChangeLog.megaraid	2004-12-07 16:40:23.000000000 -0500
+++ new-rc2/Documentation/scsi/ChangeLog.megaraid	2004-12-09 17:38:58.000000000 -0500
@@ -1,3 +1,22 @@
+Release Date	: Thu Dec  9 17:25:27 EST 2004 - Sreenivas Bagalkote <sreenib@lsil.com>
+
+Current Version	: 2.20.4.2 (scsi module), 2.20.2.3 (cmm module)
+Older Version	: 2.20.4.1 (scsi module), 2.20.2.2 (cmm module)
+
+i.	Fixed a bug in deallocating kioc's dma buffer in megaraid_mm module
+ii.	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@us.ibm.com)
+	
+	"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@dell.com)
+
 Release Date	: Thu Nov  4 18:24:56 EST 2004 - Sreenivas Bagalkote <sreenib@lsil.com>
 
 Current Version	: 2.20.4.1 (scsi module), 2.20.2.2 (cmm module)
diff -Naur old-rc2/drivers/scsi/megaraid/megaraid_ioctl.h new-rc2/drivers/scsi/megaraid/megaraid_ioctl.h
--- old-rc2/drivers/scsi/megaraid/megaraid_ioctl.h	2004-12-07 16:40:16.000000000 -0500
+++ new-rc2/drivers/scsi/megaraid/megaraid_ioctl.h	2004-12-09 17:05:18.000000000 -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
@@ -142,7 +144,7 @@
 
 	caddr_t			buf_vaddr;
 	dma_addr_t		buf_paddr;
-	uint8_t			pool_index;
+	int8_t			pool_index;
 	uint8_t			free_buf;
 
 	uint8_t			timedout;
@@ -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];
+} __attribute__ ((packed));
 
 /**
  * mm_dmapool_t	: Represents one dma pool with just one buffer
diff -Naur old-rc2/drivers/scsi/megaraid/megaraid_mbox.c new-rc2/drivers/scsi/megaraid/megaraid_mbox.c
--- old-rc2/drivers/scsi/megaraid/megaraid_mbox.c	2004-12-07 16:40:16.000000000 -0500
+++ new-rc2/drivers/scsi/megaraid/megaraid_mbox.c	2004-12-09 17:42:33.538473752 -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@lsil.com>
@@ -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 old-rc2/drivers/scsi/megaraid/megaraid_mbox.h new-rc2/drivers/scsi/megaraid/megaraid_mbox.h
--- old-rc2/drivers/scsi/megaraid/megaraid_mbox.h	2004-12-07 16:40:16.000000000 -0500
+++ new-rc2/drivers/scsi/megaraid/megaraid_mbox.h	2004-12-09 17:41:34.706417584 -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 17:25:27 EST 2004)"
 
 
 /*
diff -Naur old-rc2/drivers/scsi/megaraid/megaraid_mm.c new-rc2/drivers/scsi/megaraid/megaraid_mm.c
--- old-rc2/drivers/scsi/megaraid/megaraid_mm.c	2004-12-07 16:40:16.000000000 -0500
+++ new-rc2/drivers/scsi/megaraid/megaraid_mm.c	2004-12-09 18:12:16.485424616 -0500
@@ -10,7 +10,7 @@
  *	   2 of the License, or (at your option) any later version.
  *
  * FILE		: megaraid_mm.c
- * Version	: v2.20.2.2 (Nov 04 2004)
+ * Version	: v2.20.2.3 (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"));
@@ -614,23 +628,27 @@
 	mm_dmapool_t	*pool;
 	unsigned long	flags;
 
-	pool = &adp->dma_pool_list[kioc->pool_index];
+	if (kioc->pool_index != -1) {
+		pool = &adp->dma_pool_list[kioc->pool_index];
 
-	/* This routine may be called in non-isr context also */
-	spin_lock_irqsave(&pool->lock, flags);
+		/* This routine may be called in non-isr context also */
+		spin_lock_irqsave(&pool->lock, flags);
 
-	/*
-	 * While attaching the dma buffer, if we didn't get the required
-	 * buffer from the pool, we would have allocated it at the run time
-	 * and set the free_buf flag. We must free that buffer. Otherwise,
-	 * just mark that the buffer is not in use
-	 */
-	if (kioc->free_buf == 1)
-		pci_pool_free(pool->handle, kioc->buf_vaddr, kioc->buf_paddr);
-	else
-		pool->in_use = 0;
+		/*
+		 * While attaching the dma buffer, if we didn't get the 
+		 * required buffer from the pool, we would have allocated 
+		 * it at the run time and set the free_buf flag. We must 
+		 * free that buffer. Otherwise, just mark that the buffer is 
+		 * not in use
+		 */
+		if (kioc->free_buf == 1)
+			pci_pool_free(pool->handle, kioc->buf_vaddr, 
+							kioc->buf_paddr);
+		else
+			pool->in_use = 0;
 
-	spin_unlock_irqrestore(&pool->lock, flags);
+		spin_unlock_irqrestore(&pool->lock, flags);
+	}
 
 	/* Return the kioc to the free pool */
 	spin_lock_irqsave(&adp->kioc_pool_lock, flags);
@@ -809,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 old-rc2/drivers/scsi/megaraid/megaraid_mm.h new-rc2/drivers/scsi/megaraid/megaraid_mm.h
--- old-rc2/drivers/scsi/megaraid/megaraid_mm.h	2004-12-07 16:40:15.000000000 -0500
+++ new-rc2/drivers/scsi/megaraid/megaraid_mm.h	2004-12-09 18:12:10.336359416 -0500
@@ -29,9 +29,9 @@
 #include "megaraid_ioctl.h"
 
 
-#define LSI_COMMON_MOD_VERSION	"2.20.2.2"
+#define LSI_COMMON_MOD_VERSION	"2.20.2.3"
 #define LSI_COMMON_MOD_EXT_VERSION	\
-		"(Release Date: Thu Nov  4 17:46:29 EST 2004)"
+		"(Release Date: Thu Dec  9 17:25:27 EST 2004)"
 
 
 #define LSI_DBGLVL			dbglevel

^ permalink raw reply	[flat|nested] 59+ messages in thread
* RE: How to add/drop SCSI drives from within the driver?
@ 2004-12-09 17:31 Mukker, Atul
  2004-12-09 18:00 ` 'Patrick Mansfield'
  0 siblings, 1 reply; 59+ messages in thread
From: Mukker, Atul @ 2004-12-09 17:31 UTC (permalink / raw)
  To: 'Patrick Mansfield'
  Cc: 'James Bottomley', Bagalkote, Sreenivas,
	'Matt Domsch', 'brking@us.ibm.com',
	'linux-kernel@vger.kernel.org',
	'SCSI Mailing List', 'bunk@fs.tum.de',
	'Andrew Morton', Ju, Seokmann, Doelfel, Hardy

 
> > 8. So, all driver has to do to assist applications is to 
> provide the 
> > logical drive number to scsi address mapping. Application 
> would say, 
> > hey! I added/removed logical drive number 5, driver 
> reverts, here is 
> > the scsi address for it "host:2, channel:5, target:5 lun:0" :-)
> 
> How does the driver supply the mapping if it does not know 
> about the "change"? Is it reserving or telling user space the 
> hctl that will be used?
This point was thoroughly explained in my previous post item 2. Yes, driver
reserves a virtual bus on which all logical drives would be exported.

> 
> If so, why can't the driver call scsi_add_device(h,c,t,l) 
> after the ioctl to create the logical drive completes?
This idea was already turned down, see mails on linux-scsi on 12/3

> 
> Though I am all for using hotplug to initiate scanning from 
> user space.
good

^ permalink raw reply	[flat|nested] 59+ messages in thread
* RE: How to add/drop SCSI drives from within the driver?
@ 2004-12-09 14:11 Mukker, Atul
  2004-12-09 17:04 ` Patrick Mansfield
  0 siblings, 1 reply; 59+ messages in thread
From: Mukker, Atul @ 2004-12-09 14:11 UTC (permalink / raw)
  To: 'James Bottomley', Bagalkote, Sreenivas
  Cc: 'Matt Domsch', 'brking@us.ibm.com',
	'linux-kernel@vger.kernel.org',
	'SCSI Mailing List', 'bunk@fs.tum.de',
	'Andrew Morton', Ju, Seokmann, Doelfel, Hardy,
	Mukker, Atul

 
> > >The real way I'd like to handle this is via hotplug.  The hotplug 
> > >event would transmit the HCTL in the environment.
> > >Whether the drive actually gets incorporated into the system and 
> > >where is user policy, so it's appropriate that it should be in 
> > >userland.
> > 
> > James, it is the application that is adding the drive. So 
> it is not a 
> > hotplug event for the driver.
> 
> Then perhaps I don't understand what the issue is.  If the 
> application is adding the drive, then surely it would know 
> the numbers.  If not, then the driver must communicate this 
> back, and that's what the hotplug would be about.
> 
> James
> 
> 
Let me elaborate it.

1. The management applications decide to created new logical drives or
remove some of the existing ones.

2. How applications would do this, is by sending commands to the megaraid
firmware via driver. Driver does not intercept these commands for a simple
reason that the driver code would become unnecessarily bulky to understanad
all the possible ways applications can change the number of logical devices.

3. Once the change in configuration has happened, someone must notify kernel
about new or removed devices.

4. Since megaraid driver does not know about these changes, it cannot notify
kernel.

5. So this becomes the responsibility of the application which caused the
change in configuration. Application dilemma is, all it know is it created a
few devices and removed some. But there is no way for it to relate the
affected devices with the way how kernel was or would be seeing them, that
is, the affected device's scsi address. Remember, the affected devices are
only logical, there is no physical bus, target, lun associated with them.
Driver creates this mapping on the fly.

6. That's where application seeks help from driver and requests for the scsi
address driver would be using for the affected devices.

7. Once it has the scsi address for the devices in question, depending on
the application and system administrator's preference, application would
either use sysfs to add/remove affected devices or cause a hotplug event
resulting in the configured behavior.

8. So, all driver has to do to assist applications is to provide the logical
drive number to scsi address mapping. Application would say, hey! I
added/removed logical drive number 5, driver reverts, here is the scsi
address for it "host:2, channel:5, target:5 lun:0" :-)

-Atul Mukker

^ permalink raw reply	[flat|nested] 59+ messages in thread
* RE: How to add/drop SCSI drives from within the driver?
@ 2004-12-09 13:27 Salyzyn, Mark
  2004-12-09 14:12 ` Arjan van de Ven
  0 siblings, 1 reply; 59+ messages in thread
From: Salyzyn, Mark @ 2004-12-09 13:27 UTC (permalink / raw)
  To: Bryan Henderson
  Cc: Andrew Morton, Arjan van de Ven, Mukker, Atul, brking, bunk,
	Doelfel, Hardy, James Bottomley, linux-scsi, Matthew Wilcox,
	Matt Domsch, Ju, Seokmann, Bagalkote, Sreenivas

Bryan Henderson writes:
>>can only be good because the applications and
>>driver could be compiled on different archs.
>
>I'm having a hard time imagining where the application and the kernel 
>could reasonably have been compiled for different architectures.
They're 
>running on the same machine, aren't they?

We have management applications that run remote. But we still
standardize on byte ordering as well.

Sincerely -- Mark Salyzyn

^ permalink raw reply	[flat|nested] 59+ messages in thread
* RE: How to add/drop SCSI drives from within the driver?
@ 2004-12-08 20:49 Salyzyn, Mark
  0 siblings, 0 replies; 59+ messages in thread
From: Salyzyn, Mark @ 2004-12-08 20:49 UTC (permalink / raw)
  To: Arjan van de Ven, Bryan Henderson
  Cc: Matthew Wilcox, Andrew Morton, Mukker, Atul, brking, bunk,
	Doelfel, Hardy, James Bottomley, linux-scsi, Matt Domsch,
	Ju, Seokmann, Bagalkote, Sreenivas

>On Wed, 2004-12-08 at 15:08 -0500, Bryan Henderson wrote:
>>>> I would also suggest __attribute__((packed)) since you're sharing
with
>>>That's a bad idea, it forces the compiler to pessimise accesses to
the
>>>struct on most hardware.
>> How?  We're assuming that it won't actually affect the layout of this

>> struct, so what does the compiler pessimize?
>it also makes the compiler assume the struct members aren't aligned to
>the natural alignment and thus it'll emit more expensive access paterns
>on architectures that care about such things.

Time to fix the compiler?

Years of writing in itty bitty living spaces resulting in application
specific coding patterns has convinced me of one fact; it is not worth
it.

We are talking about not using a feature of the compiler for kernel/user
space portability in a rarely used interface because of petty
optimization issues.

Sincerely -- Mark Salyzyn


^ permalink raw reply	[flat|nested] 59+ messages in thread
* RE: How to add/drop SCSI drives from within the driver?
@ 2004-12-08 20:36 Mukker, Atul
  2004-12-08 23:26 ` Bryan Henderson
  0 siblings, 1 reply; 59+ messages in thread
From: Mukker, Atul @ 2004-12-08 20:36 UTC (permalink / raw)
  To: 'Arjan van de Ven', 'Bryan Henderson'
  Cc: 'Matthew Wilcox', 'Andrew Morton', Mukker, Atul,
	'brking@us.ibm.com', 'bunk@fs.tum.de',
	Doelfel, Hardy, 'James Bottomley',
	'linux-scsi@vger.kernel.org', 'Matt Domsch',
	Ju, Seokmann, Bagalkote, Sreenivas

> On Wed, 2004-12-08 at 15:08 -0500, Bryan Henderson wrote:
> > >> I would also suggest __attribute__((packed)) since 
> you're sharing 
> > >> with userspace just to ensure you can never get it grown by the 
> > >> compiler (it shouldn't be, but just to be safe).
> > >
> > >That's a bad idea, it forces the compiler to pessimise accesses to 
> > >the struct on most hardware.
> > 
> > How?  We're assuming that it won't actually affect the 
> layout of this 
> > struct, so what does the compiler pessimize?
> 
> it also makes the compiler assume the struct members aren't 
> aligned to the natural alignment and thus it'll emit more 
> expensive access paterns on architectures that care about such things.

My basics tell me that compiler would align the structure using the
alignment restriction of the biggest member, so this structure would still
be same irrespective of __attribute__((packed)) and result in same
instructions. May be wrong. But the point is, it will be an assumption so
specifying proper attributes can only be good because the applications and
driver could be compiled on different archs.

How much overhead can there be, it's just some data sent by the driver to
application via ioctl?

Thanks
-Atul

^ permalink raw reply	[flat|nested] 59+ messages in thread
* RE: How to add/drop SCSI drives from within the driver?
@ 2004-12-08 19:25 Mukker, Atul
  0 siblings, 0 replies; 59+ messages in thread
From: Mukker, Atul @ 2004-12-08 19:25 UTC (permalink / raw)
  To: 'James Bottomley', Bagalkote, Sreenivas
  Cc: 'Matt Domsch', 'brking@us.ibm.com',
	'linux-kernel@vger.kernel.org',
	'linux-scsi@vger.kernel.org', 'bunk@fs.tum.de',
	'Andrew Morton', Ju, Seokmann, Doelfel, Hardy,
	Mukker, Atul

> The real way I'd like to handle this is via hotplug.  The 
> hotplug event would transmit the HCTL in the environment.  
> Whether the drive actually gets incorporated into the system 
> and where is user policy, so it's appropriate that it should 
> be in userland.
Hmm, is it possible for applications to create hotplug events? If it is,
this could a good idea as matter of system policies. Regardless, our
management applications interfaces with the firmware in terms of logical
drive numbers. Driver converts this number to the scsi host, bus, target etc
during all interactions with kernel. In order for applications to actually
notify kernel about arrival or removal of logical drives (hotplug event or
sysfs), it has to know the corresponding mapping used by driver, while
registering or would be registering, the device in question.

Since the mapping is private to the driver, it only can tell to application,
for a give logical driver *number* the corresponding scsi address

> > Removing a drive:- There is no sane way for the application 
> to map out 
> > drives to /dev/sd<x>. If application has a way of knowing 
> the HCTL of 
> > a deleted drive, then using that HCTL, it can match the 
> corresponding 
> > SCSI device name (/dev/sd<x>) and use sysfs to remove that drive.
> 
> Since The sysfs device name contains H:C:T:L surely you can 
> just do a find on /sys?

Again, there is no way for applications to relate H:C:T:L with a logical
drive number. This information must come from the driver.

Thanks
-Atul Mukker

^ permalink raw reply	[flat|nested] 59+ messages in thread
* RE: How to add/drop SCSI drives from within the driver?
@ 2004-12-08 18:42 Salyzyn, Mark
  2004-12-08 20:01 ` James Bottomley
  0 siblings, 1 reply; 59+ messages in thread
From: Salyzyn, Mark @ 2004-12-08 18:42 UTC (permalink / raw)
  To: James Bottomley, Bagalkote, Sreenivas
  Cc: Matt Domsch, brking, linux-kernel, linux-scsi, bunk,
	Andrew Morton, Ju, Seokmann, Doelfel, Hardy, Mukker, Atul

James Bottomley writes:
> On Wed, 2004-12-08 at 01:16, Bagalkote, Sreenivas wrote:
>> Adding a drive:- For application to use sysfs to scan newly added
drive,
>> it needs to know the HCTL (SCSI address - Host, Channel, Target &
Lun)
>> of the drive. Driver is the only one that knows the mapping between a

>> drive and the corresponding HCTL.
>The real way I'd like to handle this is via hotplug.  The hotplug event
>would transmit the HCTL in the environment.  Whether the drive actually
>gets incorporated into the system and where is user policy, so it's
>appropriate that it should be in userland.

The problem is the aac based cards generate events (AIFs) that are
picked up by the driver. To go all the way to userland to interpret
these events and back to the driver is a waste and a source of failures.
Only the Firmware knows when an array zeroing has completed in order to
bring the device online.

>This same infrastructure could be used by fibre channel login, scsi
>enclosure events etc.

I would need to emulate an SES to propagate array changes?

>We have some of the hotplug infrastructure in SCSI, but not quite
enough
>for this ... you'll need an additional API.

What was wrong with scsi_scan_single_target (add), scsi_rescan_device
(remove/change)?

Sincerely -- Mark Salyzyn

^ permalink raw reply	[flat|nested] 59+ messages in thread
* RE: How to add/drop SCSI drives from within the driver?
@ 2004-12-08 17:56 Bagalkote, Sreenivas
  2004-12-08 19:06 ` James Bottomley
  0 siblings, 1 reply; 59+ messages in thread
From: Bagalkote, Sreenivas @ 2004-12-08 17:56 UTC (permalink / raw)
  To: 'James Bottomley', Bagalkote, Sreenivas
  Cc: Matt Domsch, 'brking@us.ibm.com',
	'linux-kernel@vger.kernel.org',
	'linux-scsi@vger.kernel.org', 'bunk@fs.tum.de',
	'Andrew Morton', Ju, Seokmann, Doelfel, Hardy,
	Mukker, Atul

>
>On Wed, 2004-12-08 at 01:16, Bagalkote, Sreenivas wrote:
>> Adding a drive:- For application to use sysfs to scan newly added 
>> drive, it needs to know the HCTL (SCSI address - Host, 
>Channel, Target 
>> & Lun) of the drive. Driver is the only one that knows the mapping 
>> between a drive and the corresponding HCTL.
>
>The real way I'd like to handle this is via hotplug.  The 
>hotplug event would transmit the HCTL in the environment.  
>Whether the drive actually gets incorporated into the system 
>and where is user policy, so it's appropriate that it should 
>be in userland.

James, it is the application that is adding the drive. So it is not a
hotplug
event for the driver.

>
>This same infrastructure could be used by fibre channel login, 
>scsi enclosure events etc.
>
>We have some of the hotplug infrastructure in SCSI, but not 
>quite enough for this ... you'll need an additional API.
>
>> Removing a drive:- There is no sane way for the application 
>to map out 
>> drives to /dev/sd<x>. If application has a way of knowing 
>the HCTL of 
>> a deleted drive, then using that HCTL, it can match the 
>corresponding 
>> SCSI device name (/dev/sd<x>) and use sysfs to remove that drive.
>
>Since The sysfs device name contains H:C:T:L surely you can 
>just do a find on /sys?
>
>James
>
>

Thank you,
sreenivas

^ permalink raw reply	[flat|nested] 59+ messages in thread
* RE: How to add/drop SCSI drives from within the driver?
@ 2004-12-08 14:55 Mukker, Atul
  0 siblings, 0 replies; 59+ messages in thread
From: Mukker, Atul @ 2004-12-08 14:55 UTC (permalink / raw)
  To: 'Matt Domsch', Bagalkote, Sreenivas
  Cc: 'brking@us.ibm.com', 'James Bottomley',
	'linux-kernel@vger.kernel.org',
	'linux-scsi@vger.kernel.org', 'bunk@fs.tum.de',
	'Andrew Morton', Ju, Seokmann, Doelfel, Hardy,
	Mukker, Atul

 
> devices projected on channels N+1..M.  It now projects them 
> as physical devices on channels 0..N (N=number of physical 
> channels on the controller {1,2,4} so far), and the logical 
> drives all on channel N+1.
It makes more sense to export the devices (non-disk, ROMB) on the physical
channel at their actual address. That the reason virtual driver were pushed
out to virtual channel

> 
> Please don't typedef structs, especially not one that's 32 
> bytes long.   
> 
> > +	uint32_t	host_no;
> 
> __u32 is the preferred type when sharing such with userspace.
Yes, typedefs are evil. Is there are good reason to prefer __u32 since
driver conventionally uses uint32_t. The latter definition is available to
userspace as well, right?

> 
> > +	uint32_t	channel;
> > +	uint32_t	scsi_id;
> > +	uint32_t	lun;
> > +	uint32_t	ld;
> > +	uint32_t	reserved[3];
> 
> Why pad this out?
Not pad, possible future expansion of the definition of this packet.

> 
> > +} ld_device_address_t;
> 
> I would also suggest __attribute__((packed)) since you're 
> sharing with userspace just to ensure you can never get it 
> grown by the compiler (it shouldn't be, but just to be safe).
Yes

> 
> Also, as I believe you intend to add some form of INQUIRY 
> Page 81 unique ID to your firmware sets at some point, 
> perhaps this is the logical place to export such information 
> too.  This would then match SCSI_IOCTL_GET_IDLUN in concept.  

The scsi megaraid stack does not have unique identifiers for the logical
drives, and when it happens for future FW, it may not be 32-bits. But you
are right, we should accommodate for this eventuality.


> >  	adapter_t *adapter;
> > +	ld_device_address_t* lda;
> 
> this will be struct ld_device_address *lda of course.
Yes

> 
> > +		if ((lda->ld < 0) || (lda->ld > 
> MAX_LOGICAL_DRIVES_40LD)) {
> 
> It's a __u32, it can't be < 0 (and the compiler should have 
You are right, only the latter check is valid


> warned at that).  Why MAX_LOGICAL_DRIVES_40LD and not 
> MAX_LOGICAL_DRIVES_64LD (which strangely is defined as 65) 
> which is used elsewhere in the driver for such mapping?
For megaraid_mbox, the max limit is 40LD, 64LD is defined in the
mega_common.h, which will be valid for other stacks. 

> 
> > +		lda->scsi_id	= (lda->ld < adapter->init_id) ? 
> > +						lda->ld : lda->ld + 1;
> 
> Ahh, you project an initiator onto the logical drive channel, 
> at init_id, yes?  That wasn't obvious to me at first, is it 
> necessary to do so?  There's no real SCSI bus contention 
> issue, and you can't address the initiator directly.  (again, 
> the driver does this today, and such a change would need to 
> be reflected in this routine
Unfortunately, the mid-layer does not allow initiator id per bus, for
multi-bus devices like megaraid. Since, we have to reserve initiator id for
physical channels, it carries over to virtual channel as well.

This also explains why MAX_LOGICAL_DRIVES_64LD is defined as (64+1)!, since
we lose one spot for initiator id.

Thanks
-Atul Mukker

^ permalink raw reply	[flat|nested] 59+ messages in thread
* RE: How to add/drop SCSI drives from within the driver?
@ 2004-12-08  7:16 Bagalkote, Sreenivas
  2004-12-08 14:07 ` Matt Domsch
                   ` (2 more replies)
  0 siblings, 3 replies; 59+ messages in thread
From: Bagalkote, Sreenivas @ 2004-12-08  7:16 UTC (permalink / raw)
  To: Matt Domsch
  Cc: 'brking@us.ibm.com', 'James Bottomley',
	'linux-kernel@vger.kernel.org',
	'linux-scsi@vger.kernel.org', 'bunk@fs.tum.de',
	'Andrew Morton', Ju, Seokmann, Doelfel, Hardy,
	Mukker, Atul

[-- Attachment #1: Type: text/plain, Size: 8423 bytes --]

Hello All,

Last week we proposed to add couple of IOCTLs to scan/remove the LDs.
It was suggested on the list that our application go sysfs route instead.
We are taking that route. (Matt Domsh, Christoph, JBG and Brian King - 
thanks for your feedback! It is appreciated.)

Please review our updated proposal. Considering that our application can 
add and remove drives on the fly:

Adding a drive:- For application to use sysfs to scan newly added drive,
it needs to know the HCTL (SCSI address - Host, Channel, Target & Lun)
of the drive. Driver is the only one that knows the mapping between a 
drive and the corresponding HCTL.

Removing a drive:- There is no sane way for the application to map out
drives to /dev/sd<x>. If application has a way of knowing the HCTL of a
deleted drive, then using that HCTL, it can match the corresponding SCSI
device name (/dev/sd<x>) and use sysfs to remove that drive.

To this end, we are requesting to be allowed to add a small IOCTL to the
driver that returns the HCTL for an LD. Our strong case is really the
"Adding
a drive" case. Somebody may suggest that an application can blindly
scan all channels and all targets on a host when it adds one drive. That
would
_not_ be correct thing to do. Application should ideally scan only the
drives that 
it has added.

I am attaching and inlining the patch that implements this logic.

Thank you,
Sreenivas
LSI Logic

diff -Naur old-rc2/drivers/scsi/megaraid/megaraid_ioctl.h
new-rc2/drivers/scsi/megaraid/megaraid_ioctl.h
--- old-rc2/drivers/scsi/megaraid/megaraid_ioctl.h	2004-12-07
16:40:16.000000000 -0500
+++ new-rc2/drivers/scsi/megaraid/megaraid_ioctl.h	2004-12-07
23:57:51.415674008 -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_t	: 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
+ */
+typedef struct {
+	uint32_t	host_no;
+	uint32_t	channel;
+	uint32_t	scsi_id;
+	uint32_t	lun;
+	uint32_t	ld;
+	uint32_t	reserved[3];
+} ld_device_address_t;
 
 /**
  * mm_dmapool_t	: Represents one dma pool with just one buffer
diff -Naur old-rc2/drivers/scsi/megaraid/megaraid_mbox.c
new-rc2/drivers/scsi/megaraid/megaraid_mbox.c
--- old-rc2/drivers/scsi/megaraid/megaraid_mbox.c	2004-12-07
16:40:16.000000000 -0500
+++ new-rc2/drivers/scsi/megaraid/megaraid_mbox.c	2004-12-08
01:29:39.420330024 -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.1+ TEST VERSION
  *
  * Authors:
  * 	Atul Mukker		<Atul.Mukker@lsil.com>
@@ -3642,6 +3642,7 @@
 megaraid_mbox_mm_handler(unsigned long drvr_data, uioc_t *kioc, uint32_t
action)
 {
 	adapter_t *adapter;
+	ld_device_address_t* lda;
 
 	if (action != IOCTL_ISSUE) {
 		con_log(CL_ANN, (KERN_WARNING
@@ -3670,6 +3671,30 @@
 
 		return kioc->status;
 
+	case GET_LD_SADDR:
+		
+		lda = (ld_device_address_t*)(unsigned long)kioc->buf_vaddr;
+
+		if ((lda->ld < 0) || (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 old-rc2/drivers/scsi/megaraid/megaraid_mbox.h
new-rc2/drivers/scsi/megaraid/megaraid_mbox.h
--- old-rc2/drivers/scsi/megaraid/megaraid_mbox.h	2004-12-07
16:40:16.000000000 -0500
+++ new-rc2/drivers/scsi/megaraid/megaraid_mbox.h	2004-12-07
23:53:35.047647872 -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.1+ TEST VERSION"
+#define MEGARAID_EXT_VERSION	"(Release Date: TEST VERSION)"
 
 
 /*
diff -Naur old-rc2/drivers/scsi/megaraid/megaraid_mm.c
new-rc2/drivers/scsi/megaraid/megaraid_mm.c
--- old-rc2/drivers/scsi/megaraid/megaraid_mm.c	2004-12-07
16:40:16.015101592 -0500
+++ new-rc2/drivers/scsi/megaraid/megaraid_mm.c	2004-12-08
01:27:35.171218760 -0500
@@ -10,7 +10,7 @@
  *	   2 of the License, or (at your option) any later version.
  *
  * FILE		: megaraid_mm.c
- * Version	: v2.20.2.2 (Nov 04 2004)
+ * Version	: v2.20.2.2+ TEST VERSION
  *
  * 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(ld_device_address_t);
+
+			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"));
@@ -809,6 +823,15 @@
 
 			return 0;
 
+		case MEGAIOC_GET_SADDR:
+
+			if (copy_to_user(kmimd.data, kioc->buf_vaddr,
+					sizeof(ld_device_address_t))) {
+				return (-EFAULT);
+			}
+			
+			return kioc->status;
+
 		default:
 			return (-EINVAL);
 		}
diff -Naur old-rc2/drivers/scsi/megaraid/megaraid_mm.h
new-rc2/drivers/scsi/megaraid/megaraid_mm.h
--- old-rc2/drivers/scsi/megaraid/megaraid_mm.h	2004-12-07
16:40:15.000000000 -0500
+++ new-rc2/drivers/scsi/megaraid/megaraid_mm.h	2004-12-07
23:52:50.975347880 -0500
@@ -29,9 +29,9 @@
 #include "megaraid_ioctl.h"
 
 
-#define LSI_COMMON_MOD_VERSION	"2.20.2.2"
+#define LSI_COMMON_MOD_VERSION	"2.20.2.2+ TEST VERSION"
 #define LSI_COMMON_MOD_EXT_VERSION	\
-		"(Release Date: Thu Nov  4 17:46:29 EST 2004)"
+		"(Release Date: TEST VERSION)"
 
 
 #define LSI_DBGLVL			dbglevel



>-----Original Message-----
>From: Matt Domsch [mailto:Matt_Domsch@dell.com] 
>Sent: Friday, December 03, 2004 12:11 PM
>To: Bagalkote, Sreenivas
>Cc: 'brking@us.ibm.com'; 'James Bottomley'; 
>'linux-kernel@vger.kernel.org'; 'linux-scsi@vger.kernel.org'; 
>'bunk@fs.tum.de'; 'Andrew Morton'; Ju, Seokmann; Doelfel, 
>Hardy; Mukker, Atul
>Subject: Re: How to add/drop SCSI drives from within the driver?
>
>On Fri, Dec 03, 2004 at 10:29:29AM -0500, Bagalkote, Sreenivas wrote:
>> I agree. The sysfs method would have been the most logical 
>way of doing it.
>> But then application becomes sysfs dependent. We really 
>cannot do that.
>
>Why?  With my efibootmgr (a userspace app like your 
>megalib/megamgr/megamon), it looks for the existance of 
>/sys/whatever/, and then operates with that if it is present.  
>Else it looks for the existance of /proc/whatever (in your case
>/proc/scsi/scsi) and does likewise.  No driver ioctl needed.
> 
>> Given that we have to do it from within the driver, is whatever I am 
>> doing right?
>
>Doing it within the driver means you've got to release a new 
>driver for each affected OS, to avoid having to update the 
>userspace app on each OS.  I claim it's much easier to update 
>a userspace lib/app than it is to update a driver on each 
>installed system.
>
>Thanks,
>Matt
>
>--
>Matt Domsch
>Sr. Software Engineer, Lead Engineer
>Dell Linux Solutions linux.dell.com & www.dell.com/linux Linux 
>on Dell mailing lists @ http://lists.us.dell.com
>


[-- Attachment #2: megaraid_hctl.patch --]
[-- Type: application/octet-stream, Size: 5695 bytes --]

diff -Naur old-rc2/drivers/scsi/megaraid/megaraid_ioctl.h new-rc2/drivers/scsi/megaraid/megaraid_ioctl.h
--- old-rc2/drivers/scsi/megaraid/megaraid_ioctl.h	2004-12-07 16:40:16.000000000 -0500
+++ new-rc2/drivers/scsi/megaraid/megaraid_ioctl.h	2004-12-07 23:57:51.415674008 -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_t	: 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
+ */
+typedef struct {
+	uint32_t	host_no;
+	uint32_t	channel;
+	uint32_t	scsi_id;
+	uint32_t	lun;
+	uint32_t	ld;
+	uint32_t	reserved[3];
+} ld_device_address_t;
 
 /**
  * mm_dmapool_t	: Represents one dma pool with just one buffer
diff -Naur old-rc2/drivers/scsi/megaraid/megaraid_mbox.c new-rc2/drivers/scsi/megaraid/megaraid_mbox.c
--- old-rc2/drivers/scsi/megaraid/megaraid_mbox.c	2004-12-07 16:40:16.000000000 -0500
+++ new-rc2/drivers/scsi/megaraid/megaraid_mbox.c	2004-12-08 01:29:39.420330024 -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.1+ TEST VERSION
  *
  * Authors:
  * 	Atul Mukker		<Atul.Mukker@lsil.com>
@@ -3642,6 +3642,7 @@
 megaraid_mbox_mm_handler(unsigned long drvr_data, uioc_t *kioc, uint32_t action)
 {
 	adapter_t *adapter;
+	ld_device_address_t* lda;
 
 	if (action != IOCTL_ISSUE) {
 		con_log(CL_ANN, (KERN_WARNING
@@ -3670,6 +3671,30 @@
 
 		return kioc->status;
 
+	case GET_LD_SADDR:
+		
+		lda = (ld_device_address_t*)(unsigned long)kioc->buf_vaddr;
+
+		if ((lda->ld < 0) || (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 old-rc2/drivers/scsi/megaraid/megaraid_mbox.h new-rc2/drivers/scsi/megaraid/megaraid_mbox.h
--- old-rc2/drivers/scsi/megaraid/megaraid_mbox.h	2004-12-07 16:40:16.000000000 -0500
+++ new-rc2/drivers/scsi/megaraid/megaraid_mbox.h	2004-12-07 23:53:35.047647872 -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.1+ TEST VERSION"
+#define MEGARAID_EXT_VERSION	"(Release Date: TEST VERSION)"
 
 
 /*
diff -Naur old-rc2/drivers/scsi/megaraid/megaraid_mm.c new-rc2/drivers/scsi/megaraid/megaraid_mm.c
--- old-rc2/drivers/scsi/megaraid/megaraid_mm.c	2004-12-07 16:40:16.015101592 -0500
+++ new-rc2/drivers/scsi/megaraid/megaraid_mm.c	2004-12-08 01:27:35.171218760 -0500
@@ -10,7 +10,7 @@
  *	   2 of the License, or (at your option) any later version.
  *
  * FILE		: megaraid_mm.c
- * Version	: v2.20.2.2 (Nov 04 2004)
+ * Version	: v2.20.2.2+ TEST VERSION
  *
  * 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(ld_device_address_t);
+
+			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"));
@@ -809,6 +823,15 @@
 
 			return 0;
 
+		case MEGAIOC_GET_SADDR:
+
+			if (copy_to_user(kmimd.data, kioc->buf_vaddr,
+					sizeof(ld_device_address_t))) {
+				return (-EFAULT);
+			}
+			
+			return kioc->status;
+
 		default:
 			return (-EINVAL);
 		}
diff -Naur old-rc2/drivers/scsi/megaraid/megaraid_mm.h new-rc2/drivers/scsi/megaraid/megaraid_mm.h
--- old-rc2/drivers/scsi/megaraid/megaraid_mm.h	2004-12-07 16:40:15.000000000 -0500
+++ new-rc2/drivers/scsi/megaraid/megaraid_mm.h	2004-12-07 23:52:50.975347880 -0500
@@ -29,9 +29,9 @@
 #include "megaraid_ioctl.h"
 
 
-#define LSI_COMMON_MOD_VERSION	"2.20.2.2"
+#define LSI_COMMON_MOD_VERSION	"2.20.2.2+ TEST VERSION"
 #define LSI_COMMON_MOD_EXT_VERSION	\
-		"(Release Date: Thu Nov  4 17:46:29 EST 2004)"
+		"(Release Date: TEST VERSION)"
 
 
 #define LSI_DBGLVL			dbglevel

^ permalink raw reply	[flat|nested] 59+ messages in thread
* RE: How to add/drop SCSI drives from within the driver?
@ 2004-12-03 17:18 Bagalkote, Sreenivas
  0 siblings, 0 replies; 59+ messages in thread
From: Bagalkote, Sreenivas @ 2004-12-03 17:18 UTC (permalink / raw)
  To: 'Matt Domsch', Bagalkote, Sreenivas
  Cc: 'brking@us.ibm.com', 'James Bottomley',
	'linux-kernel@vger.kernel.org',
	'linux-scsi@vger.kernel.org', 'bunk@fs.tum.de',
	'Andrew Morton', Ju, Seokmann, Doelfel, Hardy,
	Mukker, Atul

4 Against        0 For

That settles it. Thank you all for your replies.

Sreenivas
LSI Logic 

>-----Original Message-----
>From: Matt Domsch [mailto:Matt_Domsch@dell.com] 
>Sent: Friday, December 03, 2004 12:14 PM
>To: Bagalkote, Sreenivas
>Cc: 'brking@us.ibm.com'; 'James Bottomley'; 
>'linux-kernel@vger.kernel.org'; 'linux-scsi@vger.kernel.org'; 
>'bunk@fs.tum.de'; 'Andrew Morton'; Ju, Seokmann; Doelfel, 
>Hardy; Mukker, Atul
>Subject: Re: How to add/drop SCSI drives from within the driver?
>
>On Fri, Dec 03, 2004 at 11:11:01AM -0600, Matt Domsch wrote:
>> Doing it within the driver means you've got to release a new driver 
>> for each affected OS, to avoid having to update the userspace app on 
>> each OS.  I claim it's much easier to update a userspace 
>lib/app than 
>> it is to update a driver on each installed system.
>
>And, you're going to have to update the userspace lib/app to 
>add the new ioctl()-invocation to it anyhow.  So take the hit 
>*only* there and make it use either /sys or /proc, whichever 
>is available, no kernel changes.  Yes?
>
>--
>Matt Domsch
>Sr. Software Engineer, Lead Engineer
>Dell Linux Solutions linux.dell.com & www.dell.com/linux Linux 
>on Dell mailing lists @ http://lists.us.dell.com
>

^ permalink raw reply	[flat|nested] 59+ messages in thread
* RE: How to add/drop SCSI drives from within the driver?
@ 2004-12-03 15:29 Bagalkote, Sreenivas
  2004-12-03 15:58 ` Jan-Benedict Glaw
                   ` (2 more replies)
  0 siblings, 3 replies; 59+ messages in thread
From: Bagalkote, Sreenivas @ 2004-12-03 15:29 UTC (permalink / raw)
  To: 'brking@us.ibm.com', Bagalkote, Sreenivas
  Cc: 'James Bottomley', 'linux-kernel@vger.kernel.org',
	'linux-scsi@vger.kernel.org', 'bunk@fs.tum.de',
	'Andrew Morton', 'Matt_Domsch@dell.com',
	Ju, Seokmann, Doelfel, Hardy, Mukker, Atul

I agree. The sysfs method would have been the most logical way of doing it.
But then application becomes sysfs dependent. We really cannot do that.

Given that we have to do it from within the driver, is whatever I am doing
right?

Thanks,
Sreenivas

>-----Original Message-----
>From: Brian King [mailto:brking@us.ibm.com] 
>Sent: Friday, December 03, 2004 10:11 AM
>To: Bagalkote, Sreenivas
>Cc: 'James Bottomley'; 'linux-kernel@vger.kernel.org'; 
>'linux-scsi@vger.kernel.org'; 'bunk@fs.tum.de'; 'Andrew 
>Morton'; 'Matt_Domsch@dell.com'; Ju, Seokmann; Doelfel, Hardy; 
>Mukker, Atul
>Subject: Re: How to add/drop SCSI drives from within the driver?
>
>This looks to be adding an LLD specific interface to userspace 
>to add/delete disks. Why can't the existing sysfs interfaces 
>be used to to this? (scan attribute on host and delete 
>attribute on device).
>
>-Brian
>
>Bagalkote, Sreenivas wrote:
>> Hello All,
>> 
>> I am trying to implement a feature in my SCSI driver, where it can 
>> trigger the SCSI mid-layer to scan or remove a particular drive. I 
>> appreciate any help in nudging me in the right direction.
>> 
>> The exported functions -
>> 
>> scsi_add_device( host, channel, target, lun ) scsi_remove_device( 
>> struct scsi_device* )
>> 
>> seem to work well in my limited testing. Are there any 
>caveats in this 
>> method? Does this method work well without exceptions? I am inlining 
>> the full patch for megaraid SCSI driver taken against 
>2.6.10-rc2. I am 
>> also attaching it to this mail.
>> 
>> Thank you,
>> Sreenivas
>> 
>> 
>> ----
>> diff -Naur old-rc3/drivers/scsi/megaraid/mega_common.h
>> new-rc2/drivers/scsi/megaraid/mega_common.h
>> --- old-rc2/drivers/scsi/megaraid/mega_common.h	2004-10-18
>> 17:54:31.000000000 -0400
>> +++ new-rc2/drivers/scsi/megaraid/mega_common.h	2004-12-02
>> 20:23:35.000000000 -0500
>> @@ -242,6 +242,15 @@
>>  					[SCP2TARGET(scp)] & 
>0xFF);	\
>>  	}
>>  
>> +/**
>> + * MRAID_LD_TARGET
>> + * @param adp		- Adapter's soft state
>> + * @param ld		- Logical drive number
>> + *
>> + * Macro to retrieve the SCSI target id of a logical drive  */ 
>> +#define MRAID_LD_TARGET(adp, ld) (((ld) < (adp)->init_id) ? (ld) : 
>> +(ld)+1)
>> 
>> +
>>  /*
>>   * ### Helper routines ###
>>   */
>> diff -Naur old-rc2/drivers/scsi/megaraid/megaraid_ioctl.h
>> new-rc2/drivers/scsi/megaraid/megaraid_ioctl.h
>> --- old-rc2/drivers/scsi/megaraid/megaraid_ioctl.h	2004-12-02
>> 20:20:16.000000000 -0500
>> +++ new-rc2/drivers/scsi/megaraid/megaraid_ioctl.h	2004-12-02
>> 20:23:25.000000000 -0500
>> @@ -51,8 +51,11 @@
>>  #define MEGAIOC_QNADAP		'm'	/* Query # of 
>adapters		*/
>>  #define MEGAIOC_QDRVRVER	'e'	/* Query driver version	
>	*/
>>  #define MEGAIOC_QADAPINFO   	'g'	/* Query 
>adapter information	*/
>> +#define MEGAIOC_ADD_LD		'a'
>> +#define MEGAIOC_DEL_LD		'r'
>>  
>>  #define USCSICMD		0x80
>> +#define UIOC_NONE		0x00000
>>  #define UIOC_RD			0x00001
>>  #define UIOC_WR			0x00002
>>  
>> @@ -62,6 +65,8 @@
>>  #define GET_ADAP_INFO		0x30000
>>  #define GET_CAP			0x40000
>>  #define GET_STATS		0x50000
>> +#define	ADD_LD			0x60000
>> +#define DEL_LD			0x70000
>>  #define GET_IOCTL_VERSION	0x01
>>  
>>  #define EXT_IOCTL_SIGN_SZ	16
>> diff -Naur old-rc2/drivers/scsi/megaraid/megaraid_mbox.c
>> new-rc2/drivers/scsi/megaraid/megaraid_mbox.c
>> --- old-rc2/drivers/scsi/megaraid/megaraid_mbox.c	2004-12-02
>> 20:20:16.000000000 -0500
>> +++ new-rc2/drivers/scsi/megaraid/megaraid_mbox.c	2004-12-02
>> 20:32:33.408278216 -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.1+ TEST VERSION
>>   *
>>   * Authors:
>>   * 	Atul Mukker		<Atul.Mukker@lsil.com>
>> @@ -3642,6 +3642,10 @@
>>  megaraid_mbox_mm_handler(unsigned long drvr_data, uioc_t *kioc, 
>> uint32_t
>> action)
>>  {
>>  	adapter_t *adapter;
>> +	uint32_t ld;
>> +	struct scsi_device* sdev;
>> +	int ch;
>> +	int tg;
>>  
>>  	if (action != IOCTL_ISSUE) {
>>  		con_log(CL_ANN, (KERN_WARNING
>> @@ -3670,6 +3674,31 @@
>>  
>>  		return kioc->status;
>>  
>> +	case ADD_LD:
>> +		ld = *(uint32_t*) kioc->buf_vaddr;
>> +		ch = adapter->max_channel;
>> +		tg = MRAID_LD_TARGET( adapter, ld );
>> +		scsi_add_device(adapter->host, ch, tg, 0);
>> +
>> +		kioc->status = 0;
>> +		kioc->done(kioc);
>> +		return kioc->status;
>> +
>> +	case DEL_LD:
>> +		ld = *(uint32_t*) kioc->buf_vaddr;
>> +		ch = adapter->max_channel;
>> +		tg = MRAID_LD_TARGET( adapter, ld );
>> +		sdev = scsi_device_lookup( adapter->host, ch, tg, 0);
>> +		
>> +		if( sdev ) {
>> +			scsi_remove_device( sdev );
>> +			scsi_device_put( sdev );
>> +		}
>> +
>> +		kioc->status = 0;
>> +		kioc->done(kioc);
>> +		return kioc->status;
>> +
>>  	case MBOX_CMD:
>>  
>>  		return megaraid_mbox_mm_command(adapter, kioc); 
>diff -Naur 
>> old-rc2/drivers/scsi/megaraid/megaraid_mbox.h
>> new-rc2/drivers/scsi/megaraid/megaraid_mbox.h
>> --- old-rc2/drivers/scsi/megaraid/megaraid_mbox.h	2004-12-02
>> 20:20:16.000000000 -0500
>> +++ new-rc2/drivers/scsi/megaraid/megaraid_mbox.h	2004-12-02
>> 20:32:09.737876664 -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.1+ TEST VERSION"
>> +#define MEGARAID_EXT_VERSION	"(Release Date: TEST VERSION)"
>>  
>>  
>>  /*
>> diff -Naur old-rc2/drivers/scsi/megaraid/megaraid_mm.c
>> new-rc2/drivers/scsi/megaraid/megaraid_mm.c
>> --- old-rc2/drivers/scsi/megaraid/megaraid_mm.c	2004-12-02
>> 20:20:16.000000000 -0500
>> +++ new-rc2/drivers/scsi/megaraid/megaraid_mm.c	2004-12-02
>> 20:22:57.000000000 -0500
>> @@ -373,6 +373,34 @@
>>  			if (mraid_mm_attach_buf(adp, kioc, 
>kioc->xferlen))
>>  				return (-ENOMEM);
>>  		}
>> +		else if (subopcode == MEGAIOC_ADD_LD) {
>> +
>> +			kioc->opcode	= ADD_LD;
>> +			kioc->data_dir	= UIOC_NONE;
>> +			kioc->xferlen	= sizeof(uint32_t);
>> +
>> +			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 if (subopcode == MEGAIOC_DEL_LD) {
>> +
>> +			kioc->opcode	= DEL_LD;
>> +			kioc->data_dir	= UIOC_NONE;
>> +			kioc->xferlen	= sizeof(uint32_t);
>> +
>> +			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")); @@ -809,6 +837,9 @@
>>  
>>  			return 0;
>>  
>> +		case MEGAIOC_ADD_LD:
>> +		case MEGAIOC_DEL_LD:
>> +			return 0;
>>  		default:
>>  			return (-EINVAL);
>>  		}
>> diff -Naur old-rc2/drivers/scsi/megaraid/megaraid_mm.h
>> new-rc2/drivers/scsi/megaraid/megaraid_mm.h
>> --- old-rc2/drivers/scsi/megaraid/megaraid_mm.h	2004-12-02
>> 20:20:16.000000000 -0500
>> +++ new-rc2/drivers/scsi/megaraid/megaraid_mm.h	2004-12-02
>> 20:33:00.709127856 -0500
>> @@ -29,9 +29,9 @@
>>  #include "megaraid_ioctl.h"
>>  
>>  
>> -#define LSI_COMMON_MOD_VERSION	"2.20.2.2"
>> +#define LSI_COMMON_MOD_VERSION	"2.20.2.2+ TEST VERSION"
>>  #define LSI_COMMON_MOD_EXT_VERSION	\
>> -		"(Release Date: Thu Nov  4 17:46:29 EST 2004)"
>> +		"(Release Date: TEST VERSION)"
>>  
>>  
>>  #define LSI_DBGLVL			dbglevel
>> ----
>> 
>
>--
>Brian King
>eServer Storage I/O
>IBM Linux Technology Center
>

^ permalink raw reply	[flat|nested] 59+ messages in thread
* How to add/drop SCSI drives from within the driver?
@ 2004-12-03  2:04 Bagalkote, Sreenivas
  2004-12-03 15:10 ` Brian King
  0 siblings, 1 reply; 59+ messages in thread
From: Bagalkote, Sreenivas @ 2004-12-03  2:04 UTC (permalink / raw)
  To: 'James Bottomley'
  Cc: 'linux-kernel@vger.kernel.org',
	'linux-scsi@vger.kernel.org', 'bunk@fs.tum.de',
	'Andrew Morton', 'Matt_Domsch@dell.com',
	Ju, Seokmann, Doelfel, Hardy, Mukker, Atul

[-- Attachment #1: Type: text/plain, Size: 5961 bytes --]

Hello All,

I am trying to implement a feature in my SCSI driver, where it can
trigger the SCSI mid-layer to scan or remove a particular drive. I 
appreciate any help in nudging me in the right direction.

The exported functions - 

scsi_add_device( host, channel, target, lun )
scsi_remove_device( struct scsi_device* )

seem to work well in my limited testing. Are there any caveats in this
method? Does this method work well without exceptions? I am inlining
the full patch for megaraid SCSI driver taken against 2.6.10-rc2. I am
also attaching it to this mail.

Thank you,
Sreenivas


----
diff -Naur old-rc3/drivers/scsi/megaraid/mega_common.h
new-rc2/drivers/scsi/megaraid/mega_common.h
--- old-rc2/drivers/scsi/megaraid/mega_common.h	2004-10-18
17:54:31.000000000 -0400
+++ new-rc2/drivers/scsi/megaraid/mega_common.h	2004-12-02
20:23:35.000000000 -0500
@@ -242,6 +242,15 @@
 					[SCP2TARGET(scp)] & 0xFF);	\
 	}
 
+/**
+ * MRAID_LD_TARGET
+ * @param adp		- Adapter's soft state
+ * @param ld		- Logical drive number
+ *
+ * Macro to retrieve the SCSI target id of a logical drive
+ */
+#define MRAID_LD_TARGET(adp, ld) (((ld) < (adp)->init_id) ? (ld) : (ld)+1)

+
 /*
  * ### Helper routines ###
  */
diff -Naur old-rc2/drivers/scsi/megaraid/megaraid_ioctl.h
new-rc2/drivers/scsi/megaraid/megaraid_ioctl.h
--- old-rc2/drivers/scsi/megaraid/megaraid_ioctl.h	2004-12-02
20:20:16.000000000 -0500
+++ new-rc2/drivers/scsi/megaraid/megaraid_ioctl.h	2004-12-02
20:23:25.000000000 -0500
@@ -51,8 +51,11 @@
 #define MEGAIOC_QNADAP		'm'	/* Query # of adapters		*/
 #define MEGAIOC_QDRVRVER	'e'	/* Query driver version		*/
 #define MEGAIOC_QADAPINFO   	'g'	/* Query adapter information	*/
+#define MEGAIOC_ADD_LD		'a'
+#define MEGAIOC_DEL_LD		'r'
 
 #define USCSICMD		0x80
+#define UIOC_NONE		0x00000
 #define UIOC_RD			0x00001
 #define UIOC_WR			0x00002
 
@@ -62,6 +65,8 @@
 #define GET_ADAP_INFO		0x30000
 #define GET_CAP			0x40000
 #define GET_STATS		0x50000
+#define	ADD_LD			0x60000
+#define DEL_LD			0x70000
 #define GET_IOCTL_VERSION	0x01
 
 #define EXT_IOCTL_SIGN_SZ	16
diff -Naur old-rc2/drivers/scsi/megaraid/megaraid_mbox.c
new-rc2/drivers/scsi/megaraid/megaraid_mbox.c
--- old-rc2/drivers/scsi/megaraid/megaraid_mbox.c	2004-12-02
20:20:16.000000000 -0500
+++ new-rc2/drivers/scsi/megaraid/megaraid_mbox.c	2004-12-02
20:32:33.408278216 -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.1+ TEST VERSION
  *
  * Authors:
  * 	Atul Mukker		<Atul.Mukker@lsil.com>
@@ -3642,6 +3642,10 @@
 megaraid_mbox_mm_handler(unsigned long drvr_data, uioc_t *kioc, uint32_t
action)
 {
 	adapter_t *adapter;
+	uint32_t ld;
+	struct scsi_device* sdev;
+	int ch;
+	int tg;
 
 	if (action != IOCTL_ISSUE) {
 		con_log(CL_ANN, (KERN_WARNING
@@ -3670,6 +3674,31 @@
 
 		return kioc->status;
 
+	case ADD_LD:
+		ld = *(uint32_t*) kioc->buf_vaddr;
+		ch = adapter->max_channel;
+		tg = MRAID_LD_TARGET( adapter, ld );
+		scsi_add_device(adapter->host, ch, tg, 0);
+
+		kioc->status = 0;
+		kioc->done(kioc);
+		return kioc->status;
+
+	case DEL_LD:
+		ld = *(uint32_t*) kioc->buf_vaddr;
+		ch = adapter->max_channel;
+		tg = MRAID_LD_TARGET( adapter, ld );
+		sdev = scsi_device_lookup( adapter->host, ch, tg, 0);
+		
+		if( sdev ) {
+			scsi_remove_device( sdev );
+			scsi_device_put( sdev );
+		}
+
+		kioc->status = 0;
+		kioc->done(kioc);
+		return kioc->status;
+
 	case MBOX_CMD:
 
 		return megaraid_mbox_mm_command(adapter, kioc);
diff -Naur old-rc2/drivers/scsi/megaraid/megaraid_mbox.h
new-rc2/drivers/scsi/megaraid/megaraid_mbox.h
--- old-rc2/drivers/scsi/megaraid/megaraid_mbox.h	2004-12-02
20:20:16.000000000 -0500
+++ new-rc2/drivers/scsi/megaraid/megaraid_mbox.h	2004-12-02
20:32:09.737876664 -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.1+ TEST VERSION"
+#define MEGARAID_EXT_VERSION	"(Release Date: TEST VERSION)"
 
 
 /*
diff -Naur old-rc2/drivers/scsi/megaraid/megaraid_mm.c
new-rc2/drivers/scsi/megaraid/megaraid_mm.c
--- old-rc2/drivers/scsi/megaraid/megaraid_mm.c	2004-12-02
20:20:16.000000000 -0500
+++ new-rc2/drivers/scsi/megaraid/megaraid_mm.c	2004-12-02
20:22:57.000000000 -0500
@@ -373,6 +373,34 @@
 			if (mraid_mm_attach_buf(adp, kioc, kioc->xferlen))
 				return (-ENOMEM);
 		}
+		else if (subopcode == MEGAIOC_ADD_LD) {
+
+			kioc->opcode	= ADD_LD;
+			kioc->data_dir	= UIOC_NONE;
+			kioc->xferlen	= sizeof(uint32_t);
+
+			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 if (subopcode == MEGAIOC_DEL_LD) {
+
+			kioc->opcode	= DEL_LD;
+			kioc->data_dir	= UIOC_NONE;
+			kioc->xferlen	= sizeof(uint32_t);
+
+			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"));
@@ -809,6 +837,9 @@
 
 			return 0;
 
+		case MEGAIOC_ADD_LD:
+		case MEGAIOC_DEL_LD:
+			return 0;
 		default:
 			return (-EINVAL);
 		}
diff -Naur old-rc2/drivers/scsi/megaraid/megaraid_mm.h
new-rc2/drivers/scsi/megaraid/megaraid_mm.h
--- old-rc2/drivers/scsi/megaraid/megaraid_mm.h	2004-12-02
20:20:16.000000000 -0500
+++ new-rc2/drivers/scsi/megaraid/megaraid_mm.h	2004-12-02
20:33:00.709127856 -0500
@@ -29,9 +29,9 @@
 #include "megaraid_ioctl.h"
 
 
-#define LSI_COMMON_MOD_VERSION	"2.20.2.2"
+#define LSI_COMMON_MOD_VERSION	"2.20.2.2+ TEST VERSION"
 #define LSI_COMMON_MOD_EXT_VERSION	\
-		"(Release Date: Thu Nov  4 17:46:29 EST 2004)"
+		"(Release Date: TEST VERSION)"
 
 
 #define LSI_DBGLVL			dbglevel
----


[-- Attachment #2: megaraid-scan.patch --]
[-- Type: application/octet-stream, Size: 5536 bytes --]

diff -Naur old-rc2/drivers/scsi/megaraid/mega_common.h new-rc2/drivers/scsi/megaraid/mega_common.h
--- old-rc2/drivers/scsi/megaraid/mega_common.h	2004-10-18 17:54:31.000000000 -0400
+++ new-rc2/drivers/scsi/megaraid/mega_common.h	2004-12-02 20:23:35.000000000 -0500
@@ -242,6 +242,15 @@
 					[SCP2TARGET(scp)] & 0xFF);	\
 	}
 
+/**
+ * MRAID_LD_TARGET
+ * @param adp		- Adapter's soft state
+ * @param ld		- Logical drive number
+ *
+ * Macro to retrieve the SCSI target id of a logical drive
+ */
+#define MRAID_LD_TARGET(adp, ld) (((ld) < (adp)->init_id) ? (ld) : (ld)+1)	
+
 /*
  * ### Helper routines ###
  */
diff -Naur old-rc2/drivers/scsi/megaraid/megaraid_ioctl.h new-rc2/drivers/scsi/megaraid/megaraid_ioctl.h
--- old-rc2/drivers/scsi/megaraid/megaraid_ioctl.h	2004-12-02 20:20:16.000000000 -0500
+++ new-rc2/drivers/scsi/megaraid/megaraid_ioctl.h	2004-12-02 20:23:25.000000000 -0500
@@ -51,8 +51,11 @@
 #define MEGAIOC_QNADAP		'm'	/* Query # of adapters		*/
 #define MEGAIOC_QDRVRVER	'e'	/* Query driver version		*/
 #define MEGAIOC_QADAPINFO   	'g'	/* Query adapter information	*/
+#define MEGAIOC_ADD_LD		'a'
+#define MEGAIOC_DEL_LD		'r'
 
 #define USCSICMD		0x80
+#define UIOC_NONE		0x00000
 #define UIOC_RD			0x00001
 #define UIOC_WR			0x00002
 
@@ -62,6 +65,8 @@
 #define GET_ADAP_INFO		0x30000
 #define GET_CAP			0x40000
 #define GET_STATS		0x50000
+#define	ADD_LD			0x60000
+#define DEL_LD			0x70000
 #define GET_IOCTL_VERSION	0x01
 
 #define EXT_IOCTL_SIGN_SZ	16
diff -Naur old-rc2/drivers/scsi/megaraid/megaraid_mbox.c new-rc2/drivers/scsi/megaraid/megaraid_mbox.c
--- old-rc2/drivers/scsi/megaraid/megaraid_mbox.c	2004-12-02 20:20:16.000000000 -0500
+++ new-rc2/drivers/scsi/megaraid/megaraid_mbox.c	2004-12-02 20:32:33.408278216 -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.1+ TEST VERSION
  *
  * Authors:
  * 	Atul Mukker		<Atul.Mukker@lsil.com>
@@ -3642,6 +3642,10 @@
 megaraid_mbox_mm_handler(unsigned long drvr_data, uioc_t *kioc, uint32_t action)
 {
 	adapter_t *adapter;
+	uint32_t ld;
+	struct scsi_device* sdev;
+	int ch;
+	int tg;
 
 	if (action != IOCTL_ISSUE) {
 		con_log(CL_ANN, (KERN_WARNING
@@ -3670,6 +3674,31 @@
 
 		return kioc->status;
 
+	case ADD_LD:
+		ld = *(uint32_t*) kioc->buf_vaddr;
+		ch = adapter->max_channel;
+		tg = MRAID_LD_TARGET( adapter, ld );
+		scsi_add_device(adapter->host, ch, tg, 0);
+
+		kioc->status = 0;
+		kioc->done(kioc);
+		return kioc->status;
+
+	case DEL_LD:
+		ld = *(uint32_t*) kioc->buf_vaddr;
+		ch = adapter->max_channel;
+		tg = MRAID_LD_TARGET( adapter, ld );
+		sdev = scsi_device_lookup( adapter->host, ch, tg, 0);
+		
+		if( sdev ) {
+			scsi_remove_device( sdev );
+			scsi_device_put( sdev );
+		}
+
+		kioc->status = 0;
+		kioc->done(kioc);
+		return kioc->status;
+
 	case MBOX_CMD:
 
 		return megaraid_mbox_mm_command(adapter, kioc);
diff -Naur old-rc2/drivers/scsi/megaraid/megaraid_mbox.h new-rc2/drivers/scsi/megaraid/megaraid_mbox.h
--- old-rc2/drivers/scsi/megaraid/megaraid_mbox.h	2004-12-02 20:20:16.000000000 -0500
+++ new-rc2/drivers/scsi/megaraid/megaraid_mbox.h	2004-12-02 20:32:09.737876664 -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.1+ TEST VERSION"
+#define MEGARAID_EXT_VERSION	"(Release Date: TEST VERSION)"
 
 
 /*
diff -Naur old-rc2/drivers/scsi/megaraid/megaraid_mm.c new-rc2/drivers/scsi/megaraid/megaraid_mm.c
--- old-rc2/drivers/scsi/megaraid/megaraid_mm.c	2004-12-02 20:20:16.000000000 -0500
+++ new-rc2/drivers/scsi/megaraid/megaraid_mm.c	2004-12-02 20:22:57.000000000 -0500
@@ -373,6 +373,34 @@
 			if (mraid_mm_attach_buf(adp, kioc, kioc->xferlen))
 				return (-ENOMEM);
 		}
+		else if (subopcode == MEGAIOC_ADD_LD) {
+
+			kioc->opcode	= ADD_LD;
+			kioc->data_dir	= UIOC_NONE;
+			kioc->xferlen	= sizeof(uint32_t);
+
+			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 if (subopcode == MEGAIOC_DEL_LD) {
+
+			kioc->opcode	= DEL_LD;
+			kioc->data_dir	= UIOC_NONE;
+			kioc->xferlen	= sizeof(uint32_t);
+
+			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"));
@@ -809,6 +837,9 @@
 
 			return 0;
 
+		case MEGAIOC_ADD_LD:
+		case MEGAIOC_DEL_LD:
+			return 0;
 		default:
 			return (-EINVAL);
 		}
diff -Naur old-rc2/drivers/scsi/megaraid/megaraid_mm.h new-rc2/drivers/scsi/megaraid/megaraid_mm.h
--- old-rc2/drivers/scsi/megaraid/megaraid_mm.h	2004-12-02 20:20:16.000000000 -0500
+++ new-rc2/drivers/scsi/megaraid/megaraid_mm.h	2004-12-02 20:33:00.709127856 -0500
@@ -29,9 +29,9 @@
 #include "megaraid_ioctl.h"
 
 
-#define LSI_COMMON_MOD_VERSION	"2.20.2.2"
+#define LSI_COMMON_MOD_VERSION	"2.20.2.2+ TEST VERSION"
 #define LSI_COMMON_MOD_EXT_VERSION	\
-		"(Release Date: Thu Nov  4 17:46:29 EST 2004)"
+		"(Release Date: TEST VERSION)"
 
 
 #define LSI_DBGLVL			dbglevel

^ permalink raw reply	[flat|nested] 59+ messages in thread

end of thread, other threads:[~2005-01-27  7:06 UTC | newest]

Thread overview: 59+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-01-25 23:37 How to add/drop SCSI drives from within the driver? Mukker, Atul
2005-01-26 14:48 ` Brian King
  -- strict thread matches above, loose matches on Subject: below --
2005-01-26 23:23 Mukker, Atul
2005-01-27  7:05 ` 'Patrick Mansfield'
2005-01-26 16:48 Greg KH
2005-01-25 16:27 Mukker, Atul
2005-01-25 16:52 ` Patrick Mansfield
2005-01-21 22:11 Mukker, Atul
2005-01-21 23:58 ` James Bottomley
2005-01-06 14:20 Mukker, Atul
2005-01-06 14:42 ` James Bottomley
2005-01-04 17:25 Bagalkote, Sreenivas
2005-01-04 17:42 ` James Bottomley
2005-01-03 23:02 Bagalkote, Sreenivas
2005-01-03 23:40 ` James Bottomley
2004-12-16 16:51 Salyzyn, Mark
2004-12-16 14:27 Mukker, Atul
2004-12-15 19:42 Mukker, Atul
2004-12-15 20:22 ` Matt Domsch
2004-12-10  0:31 Bagalkote, Sreenivas
2004-12-09 23:37 Bagalkote, Sreenivas
2004-12-10  0:03 ` Matt Domsch
2004-12-09 17:31 Mukker, Atul
2004-12-09 18:00 ` 'Patrick Mansfield'
2004-12-09 14:11 Mukker, Atul
2004-12-09 17:04 ` Patrick Mansfield
2004-12-09 13:27 Salyzyn, Mark
2004-12-09 14:12 ` Arjan van de Ven
2004-12-08 20:49 Salyzyn, Mark
2004-12-08 20:36 Mukker, Atul
2004-12-08 23:26 ` Bryan Henderson
2004-12-08 19:25 Mukker, Atul
2004-12-08 18:42 Salyzyn, Mark
2004-12-08 20:01 ` James Bottomley
2004-12-15  7:24   ` Matt Domsch
2004-12-15 16:48     ` Matt Domsch
2004-12-15 18:55       ` James Bottomley
2004-12-15 18:49     ` James Bottomley
2004-12-15 21:30       ` Matt Domsch
2004-12-16  9:54         ` Arjan van de Ven
2004-12-16 14:41           ` Alan Cox
2004-12-08 17:56 Bagalkote, Sreenivas
2004-12-08 19:06 ` James Bottomley
2004-12-08 14:55 Mukker, Atul
2004-12-08  7:16 Bagalkote, Sreenivas
2004-12-08 14:07 ` Matt Domsch
2004-12-08 15:40   ` Matthew Wilcox
2004-12-08 20:08     ` Bryan Henderson
2004-12-08 20:14       ` Arjan van de Ven
2004-12-08 15:59 ` James Bottomley
2004-12-08 23:46 ` Brian King
2004-12-03 17:18 Bagalkote, Sreenivas
2004-12-03 15:29 Bagalkote, Sreenivas
2004-12-03 15:58 ` Jan-Benedict Glaw
2004-12-03 16:22 ` Christoph Hellwig
2004-12-03 17:11 ` Matt Domsch
2004-12-03 17:14   ` Matt Domsch
2004-12-03  2:04 Bagalkote, Sreenivas
2004-12-03 15:10 ` Brian King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).