1 /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
3 * SCSI Transport Netlink Interface
4 * Used for the posting of outbound SCSI transport events
6 * Copyright (C) 2006 James Smart, Emulex Corporation
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #ifndef SCSI_NETLINK_H
24 #define SCSI_NETLINK_H
26 #include <linux/netlink.h>
27 #include <linux/types.h>
30 * This file intended to be included by both kernel and user space
33 /* Single Netlink Message type to send all SCSI Transport messages */
34 #define SCSI_TRANSPORT_MSG NLMSG_MIN_TYPE + 1
36 /* SCSI Transport Broadcast Groups */
37 /* leaving groups 0 and 1 unassigned */
38 #define SCSI_NL_GRP_FC_EVENTS (1<<2) /* Group 2 */
39 #define SCSI_NL_GRP_CNT 3
42 /* SCSI_TRANSPORT_MSG event message header */
49 } __attribute__((aligned(sizeof(uint64_t))));
51 /* scsi_nl_hdr->version value */
52 #define SCSI_NL_VERSION 1
54 /* scsi_nl_hdr->magic value */
55 #define SCSI_NL_MAGIC 0xA1B2
57 /* scsi_nl_hdr->transport value */
58 #define SCSI_NL_TRANSPORT 0
59 #define SCSI_NL_TRANSPORT_FC 1
60 #define SCSI_NL_MAX_TRANSPORTS 2
62 /* Transport-based scsi_nl_hdr->msgtype values are defined in each transport */
65 * GENERIC SCSI scsi_nl_hdr->msgtype Values
68 #define SCSI_NL_SHOST_VENDOR 0x0001
70 /* SCSI_NL_SHOST_VENDOR msgtype is kernel->user and user->kernel */
74 * Message Structures :
77 /* macro to round up message lengths to 8byte boundary */
78 #define SCSI_NL_MSGALIGN(len) (((len) + 7) & ~7)
82 * SCSI HOST Vendor Unique messages :
83 * SCSI_NL_SHOST_VENDOR
85 * Note: The Vendor Unique message payload will begin directly after
86 * this structure, with the length of the payload per vmsg_datalen.
88 * Note: When specifying vendor_id, be sure to read the Vendor Type and ID
89 * formatting requirements specified below
91 struct scsi_nl_host_vendor_msg
{
92 struct scsi_nl_hdr snlh
; /* must be 1st element ! */
95 uint16_t vmsg_datalen
;
96 } __attribute__((aligned(sizeof(uint64_t))));
101 * If transports post vendor-unique events, they must pass a well-known
102 * 32-bit vendor identifier. This identifier consists of 8 bits indicating
103 * the "type" of identifier contained, and 24 bits of id data.
105 * Identifiers for each type:
106 * PCI : ID data is the 16 bit PCI Registered Vendor ID
108 #define SCSI_NL_VID_TYPE_SHIFT 56
109 #define SCSI_NL_VID_TYPE_MASK ((__u64)0xFF << SCSI_NL_VID_TYPE_SHIFT)
110 #define SCSI_NL_VID_TYPE_PCI ((__u64)0x01 << SCSI_NL_VID_TYPE_SHIFT)
111 #define SCSI_NL_VID_ID_MASK (~ SCSI_NL_VID_TYPE_MASK)
114 #define INIT_SCSI_NL_HDR(hdr, t, mtype, mlen) \
116 (hdr)->version = SCSI_NL_VERSION; \
117 (hdr)->transport = t; \
118 (hdr)->magic = SCSI_NL_MAGIC; \
119 (hdr)->msgtype = mtype; \
120 (hdr)->msglen = mlen; \
123 #endif /* SCSI_NETLINK_H */