[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 14:30:09 -07:00
|
|
|
/*
|
|
|
|
* scsi_netlink.c - SCSI Transport Netlink Interface
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 James Smart, Emulex Corporation
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
#include <linux/time.h>
|
|
|
|
#include <linux/jiffies.h>
|
|
|
|
#include <linux/security.h>
|
2008-08-07 23:14:18 -07:00
|
|
|
#include <linux/delay.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 01:04:11 -07:00
|
|
|
#include <linux/slab.h>
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 14:30:09 -07:00
|
|
|
#include <net/sock.h>
|
|
|
|
#include <net/netlink.h>
|
|
|
|
|
|
|
|
#include <scsi/scsi_netlink.h>
|
|
|
|
#include "scsi_priv.h"
|
|
|
|
|
|
|
|
struct sock *scsi_nl_sock = NULL;
|
|
|
|
EXPORT_SYMBOL_GPL(scsi_nl_sock);
|
|
|
|
|
2008-08-07 23:14:18 -07:00
|
|
|
static DEFINE_SPINLOCK(scsi_nl_lock);
|
|
|
|
static struct list_head scsi_nl_drivers;
|
|
|
|
|
|
|
|
static u32 scsi_nl_state;
|
|
|
|
#define STATE_EHANDLER_BSY 0x00000001
|
|
|
|
|
|
|
|
struct scsi_nl_transport {
|
|
|
|
int (*msg_handler)(struct sk_buff *);
|
|
|
|
void (*event_handler)(struct notifier_block *, unsigned long, void *);
|
|
|
|
unsigned int refcnt;
|
|
|
|
int flags;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* flags values (bit flags) */
|
|
|
|
#define HANDLER_DELETING 0x1
|
|
|
|
|
|
|
|
static struct scsi_nl_transport transports[SCSI_NL_MAX_TRANSPORTS] =
|
|
|
|
{ {NULL, }, };
|
|
|
|
|
|
|
|
|
|
|
|
struct scsi_nl_drvr {
|
|
|
|
struct list_head next;
|
|
|
|
int (*dmsg_handler)(struct Scsi_Host *shost, void *payload,
|
|
|
|
u32 len, u32 pid);
|
|
|
|
void (*devt_handler)(struct notifier_block *nb,
|
|
|
|
unsigned long event, void *notify_ptr);
|
|
|
|
struct scsi_host_template *hostt;
|
|
|
|
u64 vendor_id;
|
|
|
|
unsigned int refcnt;
|
|
|
|
int flags;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 14:30:09 -07:00
|
|
|
|
|
|
|
/**
|
2007-11-03 11:30:39 -07:00
|
|
|
* scsi_nl_rcv_msg - Receive message handler.
|
|
|
|
* @skb: socket receive buffer
|
|
|
|
*
|
|
|
|
* Description: Extracts message from a receive buffer.
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 14:30:09 -07:00
|
|
|
* Validates message header and calls appropriate transport message handler
|
|
|
|
*
|
|
|
|
*
|
|
|
|
**/
|
|
|
|
static void
|
|
|
|
scsi_nl_rcv_msg(struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
struct nlmsghdr *nlh;
|
|
|
|
struct scsi_nl_hdr *hdr;
|
2008-08-07 23:14:18 -07:00
|
|
|
unsigned long flags;
|
|
|
|
u32 rlen;
|
|
|
|
int err, tport;
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 14:30:09 -07:00
|
|
|
|
|
|
|
while (skb->len >= NLMSG_SPACE(0)) {
|
|
|
|
err = 0;
|
|
|
|
|
2007-04-25 19:08:35 -07:00
|
|
|
nlh = nlmsg_hdr(skb);
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 14:30:09 -07:00
|
|
|
if ((nlh->nlmsg_len < (sizeof(*nlh) + sizeof(*hdr))) ||
|
|
|
|
(skb->len < nlh->nlmsg_len)) {
|
|
|
|
printk(KERN_WARNING "%s: discarding partial skb\n",
|
2008-07-03 23:47:27 -07:00
|
|
|
__func__);
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 14:30:09 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
rlen = NLMSG_ALIGN(nlh->nlmsg_len);
|
|
|
|
if (rlen > skb->len)
|
|
|
|
rlen = skb->len;
|
|
|
|
|
|
|
|
if (nlh->nlmsg_type != SCSI_TRANSPORT_MSG) {
|
|
|
|
err = -EBADMSG;
|
2008-08-07 23:14:18 -07:00
|
|
|
goto next_msg;
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 14:30:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
hdr = NLMSG_DATA(nlh);
|
|
|
|
if ((hdr->version != SCSI_NL_VERSION) ||
|
|
|
|
(hdr->magic != SCSI_NL_MAGIC)) {
|
|
|
|
err = -EPROTOTYPE;
|
|
|
|
goto next_msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (security_netlink_recv(skb, CAP_SYS_ADMIN)) {
|
|
|
|
err = -EPERM;
|
|
|
|
goto next_msg;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nlh->nlmsg_len < (sizeof(*nlh) + hdr->msglen)) {
|
|
|
|
printk(KERN_WARNING "%s: discarding partial message\n",
|
2008-07-03 23:47:27 -07:00
|
|
|
__func__);
|
2008-08-07 23:14:18 -07:00
|
|
|
goto next_msg;
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 14:30:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2008-08-07 23:14:18 -07:00
|
|
|
* Deliver message to the appropriate transport
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 14:30:09 -07:00
|
|
|
*/
|
2008-08-07 23:14:18 -07:00
|
|
|
spin_lock_irqsave(&scsi_nl_lock, flags);
|
|
|
|
|
|
|
|
tport = hdr->transport;
|
|
|
|
if ((tport < SCSI_NL_MAX_TRANSPORTS) &&
|
|
|
|
!(transports[tport].flags & HANDLER_DELETING) &&
|
|
|
|
(transports[tport].msg_handler)) {
|
|
|
|
transports[tport].refcnt++;
|
|
|
|
spin_unlock_irqrestore(&scsi_nl_lock, flags);
|
|
|
|
err = transports[tport].msg_handler(skb);
|
|
|
|
spin_lock_irqsave(&scsi_nl_lock, flags);
|
|
|
|
transports[tport].refcnt--;
|
|
|
|
} else
|
|
|
|
err = -ENOENT;
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&scsi_nl_lock, flags);
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 14:30:09 -07:00
|
|
|
|
|
|
|
next_msg:
|
|
|
|
if ((err) || (nlh->nlmsg_flags & NLM_F_ACK))
|
|
|
|
netlink_ack(skb, nlh, err);
|
|
|
|
|
|
|
|
skb_pull(skb, rlen);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2007-11-03 11:30:39 -07:00
|
|
|
* scsi_nl_rcv_event - Event handler for a netlink socket.
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 14:30:09 -07:00
|
|
|
* @this: event notifier block
|
|
|
|
* @event: event type
|
|
|
|
* @ptr: event payload
|
|
|
|
*
|
|
|
|
**/
|
|
|
|
static int
|
|
|
|
scsi_nl_rcv_event(struct notifier_block *this, unsigned long event, void *ptr)
|
|
|
|
{
|
|
|
|
struct netlink_notify *n = ptr;
|
2008-08-07 23:14:18 -07:00
|
|
|
struct scsi_nl_drvr *driver;
|
|
|
|
unsigned long flags;
|
|
|
|
int tport;
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 14:30:09 -07:00
|
|
|
|
|
|
|
if (n->protocol != NETLINK_SCSITRANSPORT)
|
|
|
|
return NOTIFY_DONE;
|
|
|
|
|
2008-08-07 23:14:18 -07:00
|
|
|
spin_lock_irqsave(&scsi_nl_lock, flags);
|
|
|
|
scsi_nl_state |= STATE_EHANDLER_BSY;
|
|
|
|
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 14:30:09 -07:00
|
|
|
/*
|
2008-08-07 23:14:18 -07:00
|
|
|
* Pass event on to any transports that may be listening
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 14:30:09 -07:00
|
|
|
*/
|
2008-08-07 23:14:18 -07:00
|
|
|
for (tport = 0; tport < SCSI_NL_MAX_TRANSPORTS; tport++) {
|
|
|
|
if (!(transports[tport].flags & HANDLER_DELETING) &&
|
|
|
|
(transports[tport].event_handler)) {
|
|
|
|
spin_unlock_irqrestore(&scsi_nl_lock, flags);
|
|
|
|
transports[tport].event_handler(this, event, ptr);
|
|
|
|
spin_lock_irqsave(&scsi_nl_lock, flags);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Pass event on to any drivers that may be listening
|
|
|
|
*/
|
|
|
|
list_for_each_entry(driver, &scsi_nl_drivers, next) {
|
|
|
|
if (!(driver->flags & HANDLER_DELETING) &&
|
|
|
|
(driver->devt_handler)) {
|
|
|
|
spin_unlock_irqrestore(&scsi_nl_lock, flags);
|
|
|
|
driver->devt_handler(this, event, ptr);
|
|
|
|
spin_lock_irqsave(&scsi_nl_lock, flags);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
scsi_nl_state &= ~STATE_EHANDLER_BSY;
|
|
|
|
spin_unlock_irqrestore(&scsi_nl_lock, flags);
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 14:30:09 -07:00
|
|
|
|
|
|
|
return NOTIFY_DONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct notifier_block scsi_netlink_notifier = {
|
|
|
|
.notifier_call = scsi_nl_rcv_event,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-10-13 09:15:09 -07:00
|
|
|
/*
|
2008-08-07 23:14:18 -07:00
|
|
|
* GENERIC SCSI transport receive and event handlers
|
2008-10-13 09:15:09 -07:00
|
|
|
*/
|
2008-08-07 23:14:18 -07:00
|
|
|
|
|
|
|
/**
|
2008-10-13 09:15:09 -07:00
|
|
|
* scsi_generic_msg_handler - receive message handler for GENERIC transport messages
|
2008-08-07 23:14:18 -07:00
|
|
|
* @skb: socket receive buffer
|
|
|
|
**/
|
|
|
|
static int
|
|
|
|
scsi_generic_msg_handler(struct sk_buff *skb)
|
|
|
|
{
|
|
|
|
struct nlmsghdr *nlh = nlmsg_hdr(skb);
|
|
|
|
struct scsi_nl_hdr *snlh = NLMSG_DATA(nlh);
|
|
|
|
struct scsi_nl_drvr *driver;
|
|
|
|
struct Scsi_Host *shost;
|
|
|
|
unsigned long flags;
|
|
|
|
int err = 0, match, pid;
|
|
|
|
|
|
|
|
pid = NETLINK_CREDS(skb)->pid;
|
|
|
|
|
|
|
|
switch (snlh->msgtype) {
|
|
|
|
case SCSI_NL_SHOST_VENDOR:
|
|
|
|
{
|
|
|
|
struct scsi_nl_host_vendor_msg *msg = NLMSG_DATA(nlh);
|
|
|
|
|
|
|
|
/* Locate the driver that corresponds to the message */
|
|
|
|
spin_lock_irqsave(&scsi_nl_lock, flags);
|
|
|
|
match = 0;
|
|
|
|
list_for_each_entry(driver, &scsi_nl_drivers, next) {
|
|
|
|
if (driver->vendor_id == msg->vendor_id) {
|
|
|
|
match = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((!match) || (!driver->dmsg_handler)) {
|
|
|
|
spin_unlock_irqrestore(&scsi_nl_lock, flags);
|
|
|
|
err = -ESRCH;
|
|
|
|
goto rcv_exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (driver->flags & HANDLER_DELETING) {
|
|
|
|
spin_unlock_irqrestore(&scsi_nl_lock, flags);
|
|
|
|
err = -ESHUTDOWN;
|
|
|
|
goto rcv_exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
driver->refcnt++;
|
|
|
|
spin_unlock_irqrestore(&scsi_nl_lock, flags);
|
|
|
|
|
|
|
|
|
|
|
|
/* if successful, scsi_host_lookup takes a shost reference */
|
|
|
|
shost = scsi_host_lookup(msg->host_no);
|
|
|
|
if (!shost) {
|
|
|
|
err = -ENODEV;
|
|
|
|
goto driver_exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* is this host owned by the vendor ? */
|
|
|
|
if (shost->hostt != driver->hostt) {
|
|
|
|
err = -EINVAL;
|
|
|
|
goto vendormsg_put;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* pass message on to the driver */
|
|
|
|
err = driver->dmsg_handler(shost, (void *)&msg[1],
|
|
|
|
msg->vmsg_datalen, pid);
|
|
|
|
|
|
|
|
vendormsg_put:
|
|
|
|
/* release reference by scsi_host_lookup */
|
|
|
|
scsi_host_put(shost);
|
|
|
|
|
|
|
|
driver_exit:
|
|
|
|
/* release our own reference on the registration object */
|
|
|
|
spin_lock_irqsave(&scsi_nl_lock, flags);
|
|
|
|
driver->refcnt--;
|
|
|
|
spin_unlock_irqrestore(&scsi_nl_lock, flags);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
err = -EBADR;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
rcv_exit:
|
|
|
|
if (err)
|
|
|
|
printk(KERN_WARNING "%s: Msgtype %d failed - err %d\n",
|
|
|
|
__func__, snlh->msgtype, err);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* scsi_nl_add_transport -
|
|
|
|
* Registers message and event handlers for a transport. Enables
|
|
|
|
* receipt of netlink messages and events to a transport.
|
|
|
|
*
|
|
|
|
* @tport: transport registering handlers
|
|
|
|
* @msg_handler: receive message handler callback
|
|
|
|
* @event_handler: receive event handler callback
|
|
|
|
**/
|
|
|
|
int
|
|
|
|
scsi_nl_add_transport(u8 tport,
|
|
|
|
int (*msg_handler)(struct sk_buff *),
|
|
|
|
void (*event_handler)(struct notifier_block *, unsigned long, void *))
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
int err = 0;
|
|
|
|
|
|
|
|
if (tport >= SCSI_NL_MAX_TRANSPORTS)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&scsi_nl_lock, flags);
|
|
|
|
|
|
|
|
if (scsi_nl_state & STATE_EHANDLER_BSY) {
|
|
|
|
spin_unlock_irqrestore(&scsi_nl_lock, flags);
|
|
|
|
msleep(1);
|
|
|
|
spin_lock_irqsave(&scsi_nl_lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (transports[tport].msg_handler || transports[tport].event_handler) {
|
|
|
|
err = -EALREADY;
|
|
|
|
goto register_out;
|
|
|
|
}
|
|
|
|
|
|
|
|
transports[tport].msg_handler = msg_handler;
|
|
|
|
transports[tport].event_handler = event_handler;
|
|
|
|
transports[tport].flags = 0;
|
|
|
|
transports[tport].refcnt = 0;
|
|
|
|
|
|
|
|
register_out:
|
|
|
|
spin_unlock_irqrestore(&scsi_nl_lock, flags);
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(scsi_nl_add_transport);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* scsi_nl_remove_transport -
|
|
|
|
* Disable transport receiption of messages and events
|
|
|
|
*
|
|
|
|
* @tport: transport deregistering handlers
|
|
|
|
*
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
scsi_nl_remove_transport(u8 tport)
|
|
|
|
{
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&scsi_nl_lock, flags);
|
|
|
|
if (scsi_nl_state & STATE_EHANDLER_BSY) {
|
|
|
|
spin_unlock_irqrestore(&scsi_nl_lock, flags);
|
|
|
|
msleep(1);
|
|
|
|
spin_lock_irqsave(&scsi_nl_lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tport < SCSI_NL_MAX_TRANSPORTS) {
|
|
|
|
transports[tport].flags |= HANDLER_DELETING;
|
|
|
|
|
|
|
|
while (transports[tport].refcnt != 0) {
|
|
|
|
spin_unlock_irqrestore(&scsi_nl_lock, flags);
|
|
|
|
schedule_timeout_uninterruptible(HZ/4);
|
|
|
|
spin_lock_irqsave(&scsi_nl_lock, flags);
|
|
|
|
}
|
|
|
|
transports[tport].msg_handler = NULL;
|
|
|
|
transports[tport].event_handler = NULL;
|
|
|
|
transports[tport].flags = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&scsi_nl_lock, flags);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(scsi_nl_remove_transport);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* scsi_nl_add_driver -
|
|
|
|
* A driver is registering its interfaces for SCSI netlink messages
|
|
|
|
*
|
|
|
|
* @vendor_id: A unique identification value for the driver.
|
|
|
|
* @hostt: address of the driver's host template. Used
|
|
|
|
* to verify an shost is bound to the driver
|
|
|
|
* @nlmsg_handler: receive message handler callback
|
|
|
|
* @nlevt_handler: receive event handler callback
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* 0 on Success
|
|
|
|
* error result otherwise
|
|
|
|
**/
|
|
|
|
int
|
|
|
|
scsi_nl_add_driver(u64 vendor_id, struct scsi_host_template *hostt,
|
|
|
|
int (*nlmsg_handler)(struct Scsi_Host *shost, void *payload,
|
|
|
|
u32 len, u32 pid),
|
|
|
|
void (*nlevt_handler)(struct notifier_block *nb,
|
|
|
|
unsigned long event, void *notify_ptr))
|
|
|
|
{
|
|
|
|
struct scsi_nl_drvr *driver;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
driver = kzalloc(sizeof(*driver), GFP_KERNEL);
|
|
|
|
if (unlikely(!driver)) {
|
|
|
|
printk(KERN_ERR "%s: allocation failure\n", __func__);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
driver->dmsg_handler = nlmsg_handler;
|
|
|
|
driver->devt_handler = nlevt_handler;
|
|
|
|
driver->hostt = hostt;
|
|
|
|
driver->vendor_id = vendor_id;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&scsi_nl_lock, flags);
|
|
|
|
if (scsi_nl_state & STATE_EHANDLER_BSY) {
|
|
|
|
spin_unlock_irqrestore(&scsi_nl_lock, flags);
|
|
|
|
msleep(1);
|
|
|
|
spin_lock_irqsave(&scsi_nl_lock, flags);
|
|
|
|
}
|
|
|
|
list_add_tail(&driver->next, &scsi_nl_drivers);
|
|
|
|
spin_unlock_irqrestore(&scsi_nl_lock, flags);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(scsi_nl_add_driver);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* scsi_nl_remove_driver -
|
|
|
|
* An driver is unregistering with the SCSI netlink messages
|
|
|
|
*
|
|
|
|
* @vendor_id: The unique identification value for the driver.
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
scsi_nl_remove_driver(u64 vendor_id)
|
|
|
|
{
|
|
|
|
struct scsi_nl_drvr *driver;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
spin_lock_irqsave(&scsi_nl_lock, flags);
|
|
|
|
if (scsi_nl_state & STATE_EHANDLER_BSY) {
|
|
|
|
spin_unlock_irqrestore(&scsi_nl_lock, flags);
|
|
|
|
msleep(1);
|
|
|
|
spin_lock_irqsave(&scsi_nl_lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
list_for_each_entry(driver, &scsi_nl_drivers, next) {
|
|
|
|
if (driver->vendor_id == vendor_id) {
|
|
|
|
driver->flags |= HANDLER_DELETING;
|
|
|
|
while (driver->refcnt != 0) {
|
|
|
|
spin_unlock_irqrestore(&scsi_nl_lock, flags);
|
|
|
|
schedule_timeout_uninterruptible(HZ/4);
|
|
|
|
spin_lock_irqsave(&scsi_nl_lock, flags);
|
|
|
|
}
|
|
|
|
list_del(&driver->next);
|
|
|
|
kfree(driver);
|
|
|
|
spin_unlock_irqrestore(&scsi_nl_lock, flags);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
spin_unlock_irqrestore(&scsi_nl_lock, flags);
|
|
|
|
|
|
|
|
printk(KERN_ERR "%s: removal of driver failed - vendor_id 0x%llx\n",
|
|
|
|
__func__, (unsigned long long)vendor_id);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(scsi_nl_remove_driver);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
tree-wide: fix comment/printk typos
"gadget", "through", "command", "maintain", "maintain", "controller", "address",
"between", "initiali[zs]e", "instead", "function", "select", "already",
"equal", "access", "management", "hierarchy", "registration", "interest",
"relative", "memory", "offset", "already",
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2010-11-01 12:38:34 -07:00
|
|
|
* scsi_netlink_init - Called by SCSI subsystem to initialize
|
2008-08-07 23:14:18 -07:00
|
|
|
* the SCSI transport netlink interface
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 14:30:09 -07:00
|
|
|
*
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
scsi_netlink_init(void)
|
|
|
|
{
|
|
|
|
int error;
|
|
|
|
|
2008-08-07 23:14:18 -07:00
|
|
|
INIT_LIST_HEAD(&scsi_nl_drivers);
|
|
|
|
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 14:30:09 -07:00
|
|
|
error = netlink_register_notifier(&scsi_netlink_notifier);
|
|
|
|
if (error) {
|
|
|
|
printk(KERN_ERR "%s: register of event handler failed - %d\n",
|
2008-07-03 23:47:27 -07:00
|
|
|
__func__, error);
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 14:30:09 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-09-12 04:05:38 -07:00
|
|
|
scsi_nl_sock = netlink_kernel_create(&init_net, NETLINK_SCSITRANSPORT,
|
2007-10-10 21:15:29 -07:00
|
|
|
SCSI_NL_GRP_CNT, scsi_nl_rcv_msg, NULL,
|
2007-04-20 14:14:21 -07:00
|
|
|
THIS_MODULE);
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 14:30:09 -07:00
|
|
|
if (!scsi_nl_sock) {
|
2011-03-30 18:57:33 -07:00
|
|
|
printk(KERN_ERR "%s: register of receive handler failed\n",
|
2008-07-03 23:47:27 -07:00
|
|
|
__func__);
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 14:30:09 -07:00
|
|
|
netlink_unregister_notifier(&scsi_netlink_notifier);
|
2008-08-07 23:14:18 -07:00
|
|
|
return;
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 14:30:09 -07:00
|
|
|
}
|
|
|
|
|
2008-08-07 23:14:18 -07:00
|
|
|
/* Register the entry points for the generic SCSI transport */
|
|
|
|
error = scsi_nl_add_transport(SCSI_NL_TRANSPORT,
|
|
|
|
scsi_generic_msg_handler, NULL);
|
|
|
|
if (error)
|
|
|
|
printk(KERN_ERR "%s: register of GENERIC transport handler"
|
|
|
|
" failed - %d\n", __func__, error);
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 14:30:09 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2007-11-03 11:30:39 -07:00
|
|
|
* scsi_netlink_exit - Called by SCSI subsystem to disable the SCSI transport netlink interface
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 14:30:09 -07:00
|
|
|
*
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
scsi_netlink_exit(void)
|
|
|
|
{
|
2008-08-07 23:14:18 -07:00
|
|
|
scsi_nl_remove_transport(SCSI_NL_TRANSPORT);
|
|
|
|
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 14:30:09 -07:00
|
|
|
if (scsi_nl_sock) {
|
2008-01-28 15:41:19 -07:00
|
|
|
netlink_kernel_release(scsi_nl_sock);
|
[SCSI] SCSI and FC Transport: add netlink support for posting of transport events
This patch formally adds support for the posting of FC events via netlink.
It is a followup to the original RFC at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=114530667923464&w=2
and the initial posting at:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115507374832500&w=2
The patch has been updated to optimize the send path, per the discussions
in the initial posting.
Per discussions at the Storage Summit and at OLS, we are to use netlink for
async events from transports. Also per discussions, to avoid a netlink
protocol per transport, I've create a single NETLINK_SCSITRANSPORT protocol,
which can then be used by all transports.
This patch:
- Creates new files scsi_netlink.c and scsi_netlink.h, which contains the
single and shared definitions for the SCSI Transport. It is tied into the
base SCSI subsystem intialization.
Contains a single interface routine, scsi_send_transport_event(), for a
transport to send an event (via multicast to a protocol specific group).
- Creates a new scsi_netlink_fc.h file, which contains the FC netlink event
messages
- Adds 3 new routines to the fc transport:
fc_get_event_number() - to get a FC event #
fc_host_post_event() - to send a simple FC event (32 bits of data)
fc_host_post_vendor_event() - to send a Vendor unique event, with
arbitrary amounts of data.
Note: the separation of event number allows for a LLD to send a standard
event, followed by vendor-specific data for the event.
Note: This patch assumes 2 prior fc transport patches have been installed:
http://marc.theaimsgroup.com/?l=linux-scsi&m=115555807316329&w=2
http://marc.theaimsgroup.com/?l=linux-scsi&m=115581614930261&w=2
Sorry - next time I'll do something like making these individual
patches of the same posting when I know they'll be posted closely
together.
Signed-off-by: James Smart <James.Smart@emulex.com>
Tidy up configuration not to make SCSI always select NET
Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
2006-08-18 14:30:09 -07:00
|
|
|
netlink_unregister_notifier(&scsi_netlink_notifier);
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-08-07 23:14:18 -07:00
|
|
|
/*
|
|
|
|
* Exported Interfaces
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* scsi_nl_send_transport_msg -
|
|
|
|
* Generic function to send a single message from a SCSI transport to
|
|
|
|
* a single process
|
|
|
|
*
|
|
|
|
* @pid: receiving pid
|
|
|
|
* @hdr: message payload
|
|
|
|
*
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
scsi_nl_send_transport_msg(u32 pid, struct scsi_nl_hdr *hdr)
|
|
|
|
{
|
|
|
|
struct sk_buff *skb;
|
|
|
|
struct nlmsghdr *nlh;
|
|
|
|
const char *fn;
|
|
|
|
char *datab;
|
|
|
|
u32 len, skblen;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if (!scsi_nl_sock) {
|
|
|
|
err = -ENOENT;
|
|
|
|
fn = "netlink socket";
|
|
|
|
goto msg_fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
len = NLMSG_SPACE(hdr->msglen);
|
|
|
|
skblen = NLMSG_SPACE(len);
|
|
|
|
|
|
|
|
skb = alloc_skb(skblen, GFP_KERNEL);
|
|
|
|
if (!skb) {
|
|
|
|
err = -ENOBUFS;
|
|
|
|
fn = "alloc_skb";
|
|
|
|
goto msg_fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
nlh = nlmsg_put(skb, pid, 0, SCSI_TRANSPORT_MSG, len - sizeof(*nlh), 0);
|
|
|
|
if (!nlh) {
|
|
|
|
err = -ENOBUFS;
|
|
|
|
fn = "nlmsg_put";
|
|
|
|
goto msg_fail_skb;
|
|
|
|
}
|
|
|
|
datab = NLMSG_DATA(nlh);
|
|
|
|
memcpy(datab, hdr, hdr->msglen);
|
|
|
|
|
|
|
|
err = nlmsg_unicast(scsi_nl_sock, skb, pid);
|
|
|
|
if (err < 0) {
|
|
|
|
fn = "nlmsg_unicast";
|
|
|
|
/* nlmsg_unicast already kfree_skb'd */
|
|
|
|
goto msg_fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
msg_fail_skb:
|
|
|
|
kfree_skb(skb);
|
|
|
|
msg_fail:
|
|
|
|
printk(KERN_WARNING
|
|
|
|
"%s: Dropped Message : pid %d Transport %d, msgtype x%x, "
|
|
|
|
"msglen %d: %s : err %d\n",
|
|
|
|
__func__, pid, hdr->transport, hdr->msgtype, hdr->msglen,
|
|
|
|
fn, err);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(scsi_nl_send_transport_msg);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* scsi_nl_send_vendor_msg - called to send a shost vendor unique message
|
|
|
|
* to a specific process id.
|
|
|
|
*
|
|
|
|
* @pid: process id of the receiver
|
|
|
|
* @host_no: host # sending the message
|
|
|
|
* @vendor_id: unique identifier for the driver's vendor
|
|
|
|
* @data_len: amount, in bytes, of vendor unique payload data
|
|
|
|
* @data_buf: pointer to vendor unique data buffer
|
|
|
|
*
|
|
|
|
* Returns:
|
tree-wide: fix assorted typos all over the place
That is "success", "unknown", "through", "performance", "[re|un]mapping"
, "access", "default", "reasonable", "[con]currently", "temperature"
, "channel", "[un]used", "application", "example","hierarchy", "therefore"
, "[over|under]flow", "contiguous", "threshold", "enough" and others.
Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2009-11-14 08:09:05 -07:00
|
|
|
* 0 on successful return
|
2008-08-07 23:14:18 -07:00
|
|
|
* otherwise, failing error code
|
|
|
|
*
|
|
|
|
* Notes:
|
|
|
|
* This routine assumes no locks are held on entry.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
scsi_nl_send_vendor_msg(u32 pid, unsigned short host_no, u64 vendor_id,
|
|
|
|
char *data_buf, u32 data_len)
|
|
|
|
{
|
|
|
|
struct sk_buff *skb;
|
|
|
|
struct nlmsghdr *nlh;
|
|
|
|
struct scsi_nl_host_vendor_msg *msg;
|
|
|
|
u32 len, skblen;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
if (!scsi_nl_sock) {
|
|
|
|
err = -ENOENT;
|
|
|
|
goto send_vendor_fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
len = SCSI_NL_MSGALIGN(sizeof(*msg) + data_len);
|
|
|
|
skblen = NLMSG_SPACE(len);
|
|
|
|
|
|
|
|
skb = alloc_skb(skblen, GFP_KERNEL);
|
|
|
|
if (!skb) {
|
|
|
|
err = -ENOBUFS;
|
|
|
|
goto send_vendor_fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
nlh = nlmsg_put(skb, 0, 0, SCSI_TRANSPORT_MSG,
|
|
|
|
skblen - sizeof(*nlh), 0);
|
|
|
|
if (!nlh) {
|
|
|
|
err = -ENOBUFS;
|
|
|
|
goto send_vendor_fail_skb;
|
|
|
|
}
|
|
|
|
msg = NLMSG_DATA(nlh);
|
|
|
|
|
|
|
|
INIT_SCSI_NL_HDR(&msg->snlh, SCSI_NL_TRANSPORT,
|
|
|
|
SCSI_NL_SHOST_VENDOR, len);
|
|
|
|
msg->vendor_id = vendor_id;
|
|
|
|
msg->host_no = host_no;
|
|
|
|
msg->vmsg_datalen = data_len; /* bytes */
|
|
|
|
memcpy(&msg[1], data_buf, data_len);
|
|
|
|
|
|
|
|
err = nlmsg_unicast(scsi_nl_sock, skb, pid);
|
|
|
|
if (err)
|
|
|
|
/* nlmsg_multicast already kfree_skb'd */
|
|
|
|
goto send_vendor_fail;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
send_vendor_fail_skb:
|
|
|
|
kfree_skb(skb);
|
|
|
|
send_vendor_fail:
|
|
|
|
printk(KERN_WARNING
|
|
|
|
"%s: Dropped SCSI Msg : host %d vendor_unique - err %d\n",
|
|
|
|
__func__, host_no, err);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(scsi_nl_send_vendor_msg);
|
|
|
|
|
|
|
|
|