History

Merge tag 'uapi-20121219' into for-linus

UAPI Disintegration 2012-12-19 This is the remaining SCSI part of the UAPI

James Bottomley committed 13 years ago

Commit c1577502 parents e0eca63 ee7afd75 files · +3 −3Browse files

Showing the changes to include/uapi (4 of 5 files). Show all

Unified · Split

4 files
  1. include/uapi/scsi/Kbuild +3 −0
  2. include/uapi/scsi/scsi_bsg_fc.h +320 −0
  3. include/uapi/scsi/scsi_netlink.h +123 −0
  4. include/uapi/scsi/scsi_netlink_fc.h +71 −0
include/uapi/scsi/Kbuild+3−0
@@ -1,2 +1,5 @@
11 # UAPI Header export list
22 header-y += fc/
3+header-y += scsi_bsg_fc.h
4+header-y += scsi_netlink.h
5+header-y += scsi_netlink_fc.h
include/uapi/scsi/scsi_bsg_fc.h+320−0
@@ -0,0 +1,320 @@
1+/*
2+ * FC Transport BSG Interface
3+ *
4+ * Copyright (C) 2008 James Smart, Emulex Corporation
5+ *
6+ * This program is free software; you can redistribute it and/or modify
7+ * it under the terms of the GNU General Public License as published by
8+ * the Free Software Foundation; either version 2 of the License, or
9+ * (at your option) any later version.
10+ *
11+ * This program is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+ * GNU General Public License for more details.
15+ *
16+ * You should have received a copy of the GNU General Public License
17+ * along with this program; if not, write to the Free Software
18+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19+ *
20+ */
21+
22+#ifndef SCSI_BSG_FC_H
23+#define SCSI_BSG_FC_H
24+
25+/*
26+ * This file intended to be included by both kernel and user space
27+ */
28+
29+/*
30+ * FC Transport SGIO v4 BSG Message Support
31+ */
32+
33+/* Default BSG request timeout (in seconds) */
34+#define FC_DEFAULT_BSG_TIMEOUT (10 * HZ)
35+
36+
37+/*
38+ * Request Message Codes supported by the FC Transport
39+ */
40+
41+/* define the class masks for the message codes */
42+#define FC_BSG_CLS_MASK 0xF0000000 /* find object class */
43+#define FC_BSG_HST_MASK 0x80000000 /* fc host class */
44+#define FC_BSG_RPT_MASK 0x40000000 /* fc rport class */
45+
46+ /* fc_host Message Codes */
47+#define FC_BSG_HST_ADD_RPORT (FC_BSG_HST_MASK | 0x00000001)
48+#define FC_BSG_HST_DEL_RPORT (FC_BSG_HST_MASK | 0x00000002)
49+#define FC_BSG_HST_ELS_NOLOGIN (FC_BSG_HST_MASK | 0x00000003)
50+#define FC_BSG_HST_CT (FC_BSG_HST_MASK | 0x00000004)
51+#define FC_BSG_HST_VENDOR (FC_BSG_HST_MASK | 0x000000FF)
52+
53+ /* fc_rport Message Codes */
54+#define FC_BSG_RPT_ELS (FC_BSG_RPT_MASK | 0x00000001)
55+#define FC_BSG_RPT_CT (FC_BSG_RPT_MASK | 0x00000002)
56+
57+
58+
59+/*
60+ * FC Address Identifiers in Message Structures :
61+ *
62+ * Whenever a command payload contains a FC Address Identifier
63+ * (aka port_id), the value is effectively in big-endian
64+ * order, thus the array elements are decoded as follows:
65+ * element [0] is bits 23:16 of the FC Address Identifier
66+ * element [1] is bits 15:8 of the FC Address Identifier
67+ * element [2] is bits 7:0 of the FC Address Identifier
68+ */
69+
70+
71+/*
72+ * FC Host Messages
73+ */
74+
75+/* FC_BSG_HST_ADDR_PORT : */
76+
77+/* Request:
78+ * This message requests the FC host to login to the remote port
79+ * at the specified N_Port_Id. The remote port is to be enumerated
80+ * with the transport upon completion of the login.
81+ */
82+struct fc_bsg_host_add_rport {
83+ uint8_t reserved;
84+
85+ /* FC Address Identier of the remote port to login to */
86+ uint8_t port_id[3];
87+};
88+
89+/* Response:
90+ * There is no additional response data - fc_bsg_reply->result is sufficient
91+ */
92+
93+
94+/* FC_BSG_HST_DEL_RPORT : */
95+
96+/* Request:
97+ * This message requests the FC host to remove an enumerated
98+ * remote port and to terminate the login to it.
99+ *
100+ * Note: The driver is free to reject this request if it desires to
101+ * remain logged in with the remote port.
102+ */
103+struct fc_bsg_host_del_rport {
104+ uint8_t reserved;
105+
106+ /* FC Address Identier of the remote port to logout of */
107+ uint8_t port_id[3];
108+};
109+
110+/* Response:
111+ * There is no additional response data - fc_bsg_reply->result is sufficient
112+ */
113+
114+
115+/* FC_BSG_HST_ELS_NOLOGIN : */
116+
117+/* Request:
118+ * This message requests the FC_Host to send an ELS to a specific
119+ * N_Port_ID. The host does not need to log into the remote port,
120+ * nor does it need to enumerate the rport for further traffic
121+ * (although, the FC host is free to do so if it desires).
122+ */
123+struct fc_bsg_host_els {
124+ /*
125+ * ELS Command Code being sent (must be the same as byte 0
126+ * of the payload)
127+ */
128+ uint8_t command_code;
129+
130+ /* FC Address Identier of the remote port to send the ELS to */
131+ uint8_t port_id[3];
132+};
133+
134+/* Response:
135+ */
136+/* fc_bsg_ctels_reply->status values */
137+#define FC_CTELS_STATUS_OK 0x00000000
138+#define FC_CTELS_STATUS_REJECT 0x00000001
139+#define FC_CTELS_STATUS_P_RJT 0x00000002
140+#define FC_CTELS_STATUS_F_RJT 0x00000003
141+#define FC_CTELS_STATUS_P_BSY 0x00000004
142+#define FC_CTELS_STATUS_F_BSY 0x00000006
143+struct fc_bsg_ctels_reply {
144+ /*
145+ * Note: An ELS LS_RJT may be reported in 2 ways:
146+ * a) A status of FC_CTELS_STATUS_OK is returned. The caller
147+ * is to look into the ELS receive payload to determine
148+ * LS_ACC or LS_RJT (by contents of word 0). The reject
149+ * data will be in word 1.
150+ * b) A status of FC_CTELS_STATUS_REJECT is returned, The
151+ * rjt_data field will contain valid data.
152+ *
153+ * Note: ELS LS_ACC is determined by an FC_CTELS_STATUS_OK, and
154+ * the receive payload word 0 indicates LS_ACC
155+ * (e.g. value is 0x02xxxxxx).
156+ *
157+ * Note: Similarly, a CT Reject may be reported in 2 ways:
158+ * a) A status of FC_CTELS_STATUS_OK is returned. The caller
159+ * is to look into the CT receive payload to determine
160+ * Accept or Reject (by contents of word 2). The reject
161+ * data will be in word 3.
162+ * b) A status of FC_CTELS_STATUS_REJECT is returned, The
163+ * rjt_data field will contain valid data.
164+ *
165+ * Note: x_RJT/BSY status will indicae that the rjt_data field
166+ * is valid and contains the reason/explanation values.
167+ */
168+ uint32_t status; /* See FC_CTELS_STATUS_xxx */
169+
170+ /* valid if status is not FC_CTELS_STATUS_OK */
171+ struct {
172+ uint8_t action; /* fragment_id for CT REJECT */
173+ uint8_t reason_code;
174+ uint8_t reason_explanation;
175+ uint8_t vendor_unique;
176+ } rjt_data;
177+};
178+
179+
180+/* FC_BSG_HST_CT : */
181+
182+/* Request:
183+ * This message requests that a CT Request be performed with the
184+ * indicated N_Port_ID. The driver is responsible for logging in with
185+ * the fabric and/or N_Port_ID, etc as per FC rules. This request does
186+ * not mandate that the driver must enumerate the destination in the
187+ * transport. The driver is allowed to decide whether to enumerate it,
188+ * and whether to tear it down after the request.
189+ */
190+struct fc_bsg_host_ct {
191+ uint8_t reserved;
192+
193+ /* FC Address Identier of the remote port to send the ELS to */
194+ uint8_t port_id[3];
195+
196+ /*
197+ * We need words 0-2 of the generic preamble for the LLD's
198+ */
199+ uint32_t preamble_word0; /* revision & IN_ID */
200+ uint32_t preamble_word1; /* GS_Type, GS_SubType, Options, Rsvd */
201+ uint32_t preamble_word2; /* Cmd Code, Max Size */
202+
203+};
204+/* Response:
205+ *
206+ * The reply structure is an fc_bsg_ctels_reply structure
207+ */
208+
209+
210+/* FC_BSG_HST_VENDOR : */
211+
212+/* Request:
213+ * Note: When specifying vendor_id, be sure to read the Vendor Type and ID
214+ * formatting requirements specified in scsi_netlink.h
215+ */
216+struct fc_bsg_host_vendor {
217+ /*
218+ * Identifies the vendor that the message is formatted for. This
219+ * should be the recipient of the message.
220+ */
221+ uint64_t vendor_id;
222+
223+ /* start of vendor command area */
224+ uint32_t vendor_cmd[0];
225+};
226+
227+/* Response:
228+ */
229+struct fc_bsg_host_vendor_reply {
230+ /* start of vendor response area */
231+ uint32_t vendor_rsp[0];
232+};
233+
234+
235+
236+/*
237+ * FC Remote Port Messages
238+ */
239+
240+/* FC_BSG_RPT_ELS : */
241+
242+/* Request:
243+ * This message requests that an ELS be performed with the rport.
244+ */
245+struct fc_bsg_rport_els {
246+ /*
247+ * ELS Command Code being sent (must be the same as
248+ * byte 0 of the payload)
249+ */
250+ uint8_t els_code;
251+};
252+
253+/* Response:
254+ *
255+ * The reply structure is an fc_bsg_ctels_reply structure
256+ */
257+
258+
259+/* FC_BSG_RPT_CT : */
260+
261+/* Request:
262+ * This message requests that a CT Request be performed with the rport.
263+ */
264+struct fc_bsg_rport_ct {
265+ /*
266+ * We need words 0-2 of the generic preamble for the LLD's
267+ */
268+ uint32_t preamble_word0; /* revision & IN_ID */
269+ uint32_t preamble_word1; /* GS_Type, GS_SubType, Options, Rsvd */
270+ uint32_t preamble_word2; /* Cmd Code, Max Size */
271+};
272+/* Response:
273+ *
274+ * The reply structure is an fc_bsg_ctels_reply structure
275+ */
276+
277+
278+
279+
280+/* request (CDB) structure of the sg_io_v4 */
281+struct fc_bsg_request {
282+ uint32_t msgcode;
283+ union {
284+ struct fc_bsg_host_add_rport h_addrport;
285+ struct fc_bsg_host_del_rport h_delrport;
286+ struct fc_bsg_host_els h_els;
287+ struct fc_bsg_host_ct h_ct;
288+ struct fc_bsg_host_vendor h_vendor;
289+
290+ struct fc_bsg_rport_els r_els;
291+ struct fc_bsg_rport_ct r_ct;
292+ } rqst_data;
293+} __attribute__((packed));
294+
295+
296+/* response (request sense data) structure of the sg_io_v4 */
297+struct fc_bsg_reply {
298+ /*
299+ * The completion result. Result exists in two forms:
300+ * if negative, it is an -Exxx system errno value. There will
301+ * be no further reply information supplied.
302+ * else, it's the 4-byte scsi error result, with driver, host,
303+ * msg and status fields. The per-msgcode reply structure
304+ * will contain valid data.
305+ */
306+ uint32_t result;
307+
308+ /* If there was reply_payload, how much was recevied ? */
309+ uint32_t reply_payload_rcv_len;
310+
311+ union {
312+ struct fc_bsg_host_vendor_reply vendor_reply;
313+
314+ struct fc_bsg_ctels_reply ctels_reply;
315+ } reply_data;
316+};
317+
318+
319+#endif /* SCSI_BSG_FC_H */
320+
include/uapi/scsi/scsi_netlink.h+123−0
@@ -0,0 +1,123 @@
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+#include <linux/types.h>
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+#endif /* SCSI_NETLINK_H */
123+
include/uapi/scsi/scsi_netlink_fc.h+71−0
@@ -0,0 +1,71 @@
1+/*
2+ * FC Transport Netlink Interface
3+ *
4+ * Copyright (C) 2006 James Smart, Emulex Corporation
5+ *
6+ * This program is free software; you can redistribute it and/or modify
7+ * it under the terms of the GNU General Public License as published by
8+ * the Free Software Foundation; either version 2 of the License, or
9+ * (at your option) any later version.
10+ *
11+ * This program is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+ * GNU General Public License for more details.
15+ *
16+ * You should have received a copy of the GNU General Public License
17+ * along with this program; if not, write to the Free Software
18+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19+ *
20+ */
21+#ifndef SCSI_NETLINK_FC_H
22+#define SCSI_NETLINK_FC_H
23+
24+#include <scsi/scsi_netlink.h>
25+
26+/*
27+ * This file intended to be included by both kernel and user space
28+ */
29+
30+/*
31+ * FC Transport Message Types
32+ */
33+ /* kernel -> user */
34+#define FC_NL_ASYNC_EVENT 0x0100
35+ /* user -> kernel */
36+/* none */
37+
38+
39+/*
40+ * Message Structures :
41+ */
42+
43+/* macro to round up message lengths to 8byte boundary */
44+#define FC_NL_MSGALIGN(len) (((len) + 7) & ~7)
45+
46+
47+/*
48+ * FC Transport Broadcast Event Message :
49+ * FC_NL_ASYNC_EVENT
50+ *
51+ * Note: if Vendor Unique message, &event_data will be start of
52+ * vendor unique payload, and the length of the payload is
53+ * per event_datalen
54+ *
55+ * Note: When specifying vendor_id, be sure to read the Vendor Type and ID
56+ * formatting requirements specified in scsi_netlink.h
57+ */
58+struct fc_nl_event {
59+ struct scsi_nl_hdr snlh; /* must be 1st element ! */
60+ uint64_t seconds;
61+ uint64_t vendor_id;
62+ uint16_t host_no;
63+ uint16_t event_datalen;
64+ uint32_t event_num;
65+ uint32_t event_code;
66+ uint32_t event_data;
67+} __attribute__((aligned(sizeof(uint64_t))));
68+
69+
70+#endif /* SCSI_NETLINK_FC_H */
71+