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