Root/
1 | /* |
2 | * SCSI Transport Netlink Interface |
3 | * Used for the posting of outbound SCSI transport events |
4 | * |
5 | * Copyright (C) 2006 James Smart, Emulex Corporation |
6 | * |
7 | * This program is free software; you can redistribute it and/or modify |
8 | * it under the terms of the GNU General Public License as published by |
9 | * the Free Software Foundation; either version 2 of the License, or |
10 | * (at your option) any later version. |
11 | * |
12 | * This program is distributed in the hope that it will be useful, |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * GNU General Public License for more details. |
16 | * |
17 | * You should have received a copy of the GNU General Public License |
18 | * along with this program; if not, write to the Free Software |
19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
20 | * |
21 | */ |
22 | #ifndef SCSI_NETLINK_H |
23 | #define SCSI_NETLINK_H |
24 | |
25 | #include <linux/netlink.h> |
26 | |
27 | |
28 | /* |
29 | * This file intended to be included by both kernel and user space |
30 | */ |
31 | |
32 | /* Single Netlink Message type to send all SCSI Transport messages */ |
33 | #define SCSI_TRANSPORT_MSG NLMSG_MIN_TYPE + 1 |
34 | |
35 | /* SCSI Transport Broadcast Groups */ |
36 | /* leaving groups 0 and 1 unassigned */ |
37 | #define SCSI_NL_GRP_FC_EVENTS (1<<2) /* Group 2 */ |
38 | #define SCSI_NL_GRP_CNT 3 |
39 | |
40 | |
41 | /* SCSI_TRANSPORT_MSG event message header */ |
42 | struct scsi_nl_hdr { |
43 | uint8_t version; |
44 | uint8_t transport; |
45 | uint16_t magic; |
46 | uint16_t msgtype; |
47 | uint16_t msglen; |
48 | } __attribute__((aligned(sizeof(uint64_t)))); |
49 | |
50 | /* scsi_nl_hdr->version value */ |
51 | #define SCSI_NL_VERSION 1 |
52 | |
53 | /* scsi_nl_hdr->magic value */ |
54 | #define SCSI_NL_MAGIC 0xA1B2 |
55 | |
56 | /* scsi_nl_hdr->transport value */ |
57 | #define SCSI_NL_TRANSPORT 0 |
58 | #define SCSI_NL_TRANSPORT_FC 1 |
59 | #define SCSI_NL_MAX_TRANSPORTS 2 |
60 | |
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 | */ |
90 | struct 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)))); |
96 | |
97 | |
98 | /* |
99 | * Vendor ID: |
100 | * If transports post vendor-unique events, they must pass a well-known |
101 | * 32-bit vendor identifier. This identifier consists of 8 bits indicating |
102 | * the "type" of identifier contained, and 24 bits of id data. |
103 | * |
104 | * Identifiers for each type: |
105 | * PCI : ID data is the 16 bit PCI Registered Vendor ID |
106 | */ |
107 | #define SCSI_NL_VID_TYPE_SHIFT 56 |
108 | #define SCSI_NL_VID_TYPE_MASK ((u64)0xFF << SCSI_NL_VID_TYPE_SHIFT) |
109 | #define SCSI_NL_VID_TYPE_PCI ((u64)0x01 << SCSI_NL_VID_TYPE_SHIFT) |
110 | #define SCSI_NL_VID_ID_MASK (~ SCSI_NL_VID_TYPE_MASK) |
111 | |
112 | |
113 | #define INIT_SCSI_NL_HDR(hdr, t, mtype, mlen) \ |
114 | { \ |
115 | (hdr)->version = SCSI_NL_VERSION; \ |
116 | (hdr)->transport = t; \ |
117 | (hdr)->magic = SCSI_NL_MAGIC; \ |
118 | (hdr)->msgtype = mtype; \ |
119 | (hdr)->msglen = mlen; \ |
120 | } |
121 | |
122 | |
123 | #ifdef __KERNEL__ |
124 | |
125 | #include <scsi/scsi_host.h> |
126 | |
127 | /* Exported Kernel Interfaces */ |
128 | int scsi_nl_add_transport(u8 tport, |
129 | int (*msg_handler)(struct sk_buff *), |
130 | void (*event_handler)(struct notifier_block *, unsigned long, void *)); |
131 | void scsi_nl_remove_transport(u8 tport); |
132 | |
133 | int 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)); |
138 | void scsi_nl_remove_driver(u64 vendor_id); |
139 | |
140 | void scsi_nl_send_transport_msg(u32 pid, struct scsi_nl_hdr *hdr); |
141 | int 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 | |
146 | #endif /* SCSI_NETLINK_H */ |
147 | |
148 |
Branches:
ben-wpan
ben-wpan-stefan
javiroman/ks7010
jz-2.6.34
jz-2.6.34-rc5
jz-2.6.34-rc6
jz-2.6.34-rc7
jz-2.6.35
jz-2.6.36
jz-2.6.37
jz-2.6.38
jz-2.6.39
jz-3.0
jz-3.1
jz-3.11
jz-3.12
jz-3.13
jz-3.15
jz-3.16
jz-3.18-dt
jz-3.2
jz-3.3
jz-3.4
jz-3.5
jz-3.6
jz-3.6-rc2-pwm
jz-3.9
jz-3.9-clk
jz-3.9-rc8
jz47xx
jz47xx-2.6.38
master
Tags:
od-2011-09-04
od-2011-09-18
v2.6.34-rc5
v2.6.34-rc6
v2.6.34-rc7
v3.9