aboutsummaryrefslogtreecommitdiffstats
path: root/include/scsi/scsi_netlink.h
diff options
context:
space:
mode:
authorJames Smart <James.Smart@Emulex.Com>2008-08-08 02:14:18 -0400
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2008-10-03 12:46:13 -0400
commit22447be7d15aefcfab84e9bec4859a28198b0c62 (patch)
tree7bb58323dfdbfbc85759c668a876b85d2084a3da /include/scsi/scsi_netlink.h
parent557cc476c04146ee610f4bc77bfe20ce1c823d7c (diff)
[SCSI] scsi_netlink: Add transport and LLD recieve and event support
This patch adds scsi netlink recieve and event support for transport and scsi LLDD's. It is a reimplementation of the patch posted last week by David Somayajulu. http://marc.info/?l=linux-scsi&m=121745486221819&w=2 There are a few things done differently: - Transport support is included - Event delivery is included - The vendor message is now its own unique message type, considered part of the generic "SCSI Transport". - LLDD entry points are now registered rather than included in the scsi_host_template. Background: When I started to implement the event handler via template, I had to either: muck up scsi_add_host and scsi_remove_host; or have the event handler search all possible shosts. Neither was acceptable. Moving to a registration solves this, and also limits the scope of the changes to something that could be backported to a distro without breaking an already-released-distro kabi. However, I admit it isn't as elegant, as the passing of the LLDD host template in the registration and the complexity around dynamic add/remove shows. - The receive path was augmented to require a unique identifier for the LLDD before the message was allowed to be handed off to the driver. Given how quickly very fatal errors occur if there's msg mismatches (which I saw in testing my own tools :), I believe this to be a very good thing. The id plays off the vendor id scheme already introduced for the vendor unique event messages used by FC. Additionally, the id use as the basis of the registration/deregistration. - Send assist functions, for both the transport and LLDDs are included. [fujita.tomonori@lab.ntt.co.jp: fix missing cast] Signed-off-by: James Smart <james.smart@emulex.com> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'include/scsi/scsi_netlink.h')
-rw-r--r--include/scsi/scsi_netlink.h62
1 files changed, 61 insertions, 1 deletions
diff --git a/include/scsi/scsi_netlink.h b/include/scsi/scsi_netlink.h
index 8c1470cc8209..536752c40d41 100644
--- a/include/scsi/scsi_netlink.h
+++ b/include/scsi/scsi_netlink.h
@@ -22,6 +22,9 @@
22#ifndef SCSI_NETLINK_H 22#ifndef SCSI_NETLINK_H
23#define SCSI_NETLINK_H 23#define SCSI_NETLINK_H
24 24
25#include <linux/netlink.h>
26
27
25/* 28/*
26 * This file intended to be included by both kernel and user space 29 * This file intended to be included by both kernel and user space
27 */ 30 */
@@ -55,7 +58,41 @@ struct scsi_nl_hdr {
55#define SCSI_NL_TRANSPORT_FC 1 58#define SCSI_NL_TRANSPORT_FC 1
56#define SCSI_NL_MAX_TRANSPORTS 2 59#define SCSI_NL_MAX_TRANSPORTS 2
57 60
58/* scsi_nl_hdr->msgtype values are defined in each transport */ 61/* Transport-based scsi_nl_hdr->msgtype values are defined in each transport */
62
63/*
64 * GENERIC SCSI scsi_nl_hdr->msgtype Values
65 */
66 /* kernel -> user */
67#define SCSI_NL_SHOST_VENDOR 0x0001
68 /* user -> kernel */
69/* SCSI_NL_SHOST_VENDOR msgtype is kernel->user and user->kernel */
70
71
72/*
73 * Message Structures :
74 */
75
76/* macro to round up message lengths to 8byte boundary */
77#define SCSI_NL_MSGALIGN(len) (((len) + 7) & ~7)
78
79
80/*
81 * SCSI HOST Vendor Unique messages :
82 * SCSI_NL_SHOST_VENDOR
83 *
84 * Note: The Vendor Unique message payload will begin directly after
85 * this structure, with the length of the payload per vmsg_datalen.
86 *
87 * Note: When specifying vendor_id, be sure to read the Vendor Type and ID
88 * formatting requirements specified below
89 */
90struct scsi_nl_host_vendor_msg {
91 struct scsi_nl_hdr snlh; /* must be 1st element ! */
92 uint64_t vendor_id;
93 uint16_t host_no;
94 uint16_t vmsg_datalen;
95} __attribute__((aligned(sizeof(uint64_t))));
59 96
60 97
61/* 98/*
@@ -83,5 +120,28 @@ struct scsi_nl_hdr {
83 } 120 }
84 121
85 122
123#ifdef __KERNEL__
124
125#include <scsi/scsi_host.h>
126
127/* Exported Kernel Interfaces */
128int scsi_nl_add_transport(u8 tport,
129 int (*msg_handler)(struct sk_buff *),
130 void (*event_handler)(struct notifier_block *, unsigned long, void *));
131void scsi_nl_remove_transport(u8 tport);
132
133int scsi_nl_add_driver(u64 vendor_id, struct scsi_host_template *hostt,
134 int (*nlmsg_handler)(struct Scsi_Host *shost, void *payload,
135 u32 len, u32 pid),
136 void (*nlevt_handler)(struct notifier_block *nb,
137 unsigned long event, void *notify_ptr));
138void scsi_nl_remove_driver(u64 vendor_id);
139
140void scsi_nl_send_transport_msg(u32 pid, struct scsi_nl_hdr *hdr);
141int scsi_nl_send_vendor_msg(u32 pid, unsigned short host_no, u64 vendor_id,
142 char *data_buf, u32 data_len);
143
144#endif /* __KERNEL__ */
145
86#endif /* SCSI_NETLINK_H */ 146#endif /* SCSI_NETLINK_H */
87 147