xref: /linux/include/uapi/scsi/scsi_netlink.h (revision 976e3645923bdd2fe7893aae33fd7a21098bfb28)
1 /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
2 /*
3  *  SCSI Transport Netlink Interface
4  *    Used for the posting of outbound SCSI transport events
5  *
6  *  Copyright (C) 2006   James Smart, Emulex Corporation
7  */
8 #ifndef SCSI_NETLINK_H
9 #define SCSI_NETLINK_H
10 
11 #include <linux/netlink.h>
12 #include <linux/types.h>
13 
14 /*
15  * This file intended to be included by both kernel and user space
16  */
17 
18 /* Single Netlink Message type to send all SCSI Transport messages */
19 #define SCSI_TRANSPORT_MSG		NLMSG_MIN_TYPE + 1
20 
21 /* SCSI Transport Broadcast Groups */
22 	/* leaving groups 0 and 1 unassigned */
23 #define SCSI_NL_GRP_FC_EVENTS		(1<<2)		/* Group 2 */
24 #define SCSI_NL_GRP_CNT			3
25 
26 
27 /* SCSI_TRANSPORT_MSG event message header */
28 struct scsi_nl_hdr {
29 	__u8 version;
30 	__u8 transport;
31 	__u16 magic;
32 	__u16 msgtype;
33 	__u16 msglen;
34 } __attribute__((aligned(sizeof(__u64))));
35 
36 /* scsi_nl_hdr->version value */
37 #define SCSI_NL_VERSION				1
38 
39 /* scsi_nl_hdr->magic value */
40 #define SCSI_NL_MAGIC				0xA1B2
41 
42 /* scsi_nl_hdr->transport value */
43 #define SCSI_NL_TRANSPORT			0
44 #define SCSI_NL_TRANSPORT_FC			1
45 #define SCSI_NL_MAX_TRANSPORTS			2
46 
47 /* Transport-based scsi_nl_hdr->msgtype values are defined in each transport */
48 
49 /*
50  * GENERIC SCSI scsi_nl_hdr->msgtype Values
51  */
52 	/* kernel -> user */
53 #define SCSI_NL_SHOST_VENDOR			0x0001
54 	/* user -> kernel */
55 /* SCSI_NL_SHOST_VENDOR msgtype is kernel->user and user->kernel */
56 
57 
58 /*
59  * Message Structures :
60  */
61 
62 /* macro to round up message lengths to 8byte boundary */
63 #define SCSI_NL_MSGALIGN(len)		(((len) + 7) & ~7)
64 
65 
66 /*
67  * SCSI HOST Vendor Unique messages :
68  *   SCSI_NL_SHOST_VENDOR
69  *
70  * Note: The Vendor Unique message payload will begin directly after
71  * 	 this structure, with the length of the payload per vmsg_datalen.
72  *
73  * Note: When specifying vendor_id, be sure to read the Vendor Type and ID
74  *   formatting requirements specified below
75  */
76 struct scsi_nl_host_vendor_msg {
77 	struct scsi_nl_hdr snlh;		/* must be 1st element ! */
78 	__u64 vendor_id;
79 	__u16 host_no;
80 	__u16 vmsg_datalen;
81 } __attribute__((aligned(sizeof(__u64))));
82 
83 
84 /*
85  * Vendor ID:
86  *   If transports post vendor-unique events, they must pass a well-known
87  *   32-bit vendor identifier. This identifier consists of 8 bits indicating
88  *   the "type" of identifier contained, and 24 bits of id data.
89  *
90  *   Identifiers for each type:
91  *    PCI :  ID data is the 16 bit PCI Registered Vendor ID
92  */
93 #define SCSI_NL_VID_TYPE_SHIFT		56
94 #define SCSI_NL_VID_TYPE_MASK		((__u64)0xFF << SCSI_NL_VID_TYPE_SHIFT)
95 #define SCSI_NL_VID_TYPE_PCI		((__u64)0x01 << SCSI_NL_VID_TYPE_SHIFT)
96 #define SCSI_NL_VID_ID_MASK		(~ SCSI_NL_VID_TYPE_MASK)
97 
98 
99 #define INIT_SCSI_NL_HDR(hdr, t, mtype, mlen)			\
100 	{							\
101 	(hdr)->version = SCSI_NL_VERSION;			\
102 	(hdr)->transport = t;					\
103 	(hdr)->magic = SCSI_NL_MAGIC;				\
104 	(hdr)->msgtype = mtype;					\
105 	(hdr)->msglen = mlen;					\
106 	}
107 
108 #endif /* SCSI_NETLINK_H */
109 
110