Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
0002 /*
0003  *  SCSI Transport Netlink Interface
0004  *    Used for the posting of outbound SCSI transport events
0005  *
0006  *  Copyright (C) 2006   James Smart, Emulex Corporation
0007  */
0008 #ifndef SCSI_NETLINK_H
0009 #define SCSI_NETLINK_H
0010 
0011 #include <linux/netlink.h>
0012 #include <linux/types.h>
0013 
0014 /*
0015  * This file intended to be included by both kernel and user space
0016  */
0017 
0018 /* Single Netlink Message type to send all SCSI Transport messages */
0019 #define SCSI_TRANSPORT_MSG      NLMSG_MIN_TYPE + 1
0020 
0021 /* SCSI Transport Broadcast Groups */
0022     /* leaving groups 0 and 1 unassigned */
0023 #define SCSI_NL_GRP_FC_EVENTS       (1<<2)      /* Group 2 */
0024 #define SCSI_NL_GRP_CNT         3
0025 
0026 
0027 /* SCSI_TRANSPORT_MSG event message header */
0028 struct scsi_nl_hdr {
0029     __u8 version;
0030     __u8 transport;
0031     __u16 magic;
0032     __u16 msgtype;
0033     __u16 msglen;
0034 } __attribute__((aligned(sizeof(__u64))));
0035 
0036 /* scsi_nl_hdr->version value */
0037 #define SCSI_NL_VERSION             1
0038 
0039 /* scsi_nl_hdr->magic value */
0040 #define SCSI_NL_MAGIC               0xA1B2
0041 
0042 /* scsi_nl_hdr->transport value */
0043 #define SCSI_NL_TRANSPORT           0
0044 #define SCSI_NL_TRANSPORT_FC            1
0045 #define SCSI_NL_MAX_TRANSPORTS          2
0046 
0047 /* Transport-based scsi_nl_hdr->msgtype values are defined in each transport */
0048 
0049 /*
0050  * GENERIC SCSI scsi_nl_hdr->msgtype Values
0051  */
0052     /* kernel -> user */
0053 #define SCSI_NL_SHOST_VENDOR            0x0001
0054     /* user -> kernel */
0055 /* SCSI_NL_SHOST_VENDOR msgtype is kernel->user and user->kernel */
0056 
0057 
0058 /*
0059  * Message Structures :
0060  */
0061 
0062 /* macro to round up message lengths to 8byte boundary */
0063 #define SCSI_NL_MSGALIGN(len)       (((len) + 7) & ~7)
0064 
0065 
0066 /*
0067  * SCSI HOST Vendor Unique messages :
0068  *   SCSI_NL_SHOST_VENDOR
0069  *
0070  * Note: The Vendor Unique message payload will begin directly after
0071  *   this structure, with the length of the payload per vmsg_datalen.
0072  *
0073  * Note: When specifying vendor_id, be sure to read the Vendor Type and ID
0074  *   formatting requirements specified below
0075  */
0076 struct scsi_nl_host_vendor_msg {
0077     struct scsi_nl_hdr snlh;        /* must be 1st element ! */
0078     __u64 vendor_id;
0079     __u16 host_no;
0080     __u16 vmsg_datalen;
0081 } __attribute__((aligned(sizeof(__u64))));
0082 
0083 
0084 /*
0085  * Vendor ID:
0086  *   If transports post vendor-unique events, they must pass a well-known
0087  *   32-bit vendor identifier. This identifier consists of 8 bits indicating
0088  *   the "type" of identifier contained, and 24 bits of id data.
0089  *
0090  *   Identifiers for each type:
0091  *    PCI :  ID data is the 16 bit PCI Registered Vendor ID
0092  */
0093 #define SCSI_NL_VID_TYPE_SHIFT      56
0094 #define SCSI_NL_VID_TYPE_MASK       ((__u64)0xFF << SCSI_NL_VID_TYPE_SHIFT)
0095 #define SCSI_NL_VID_TYPE_PCI        ((__u64)0x01 << SCSI_NL_VID_TYPE_SHIFT)
0096 #define SCSI_NL_VID_ID_MASK     (~ SCSI_NL_VID_TYPE_MASK)
0097 
0098 
0099 #define INIT_SCSI_NL_HDR(hdr, t, mtype, mlen)           \
0100     {                           \
0101     (hdr)->version = SCSI_NL_VERSION;           \
0102     (hdr)->transport = t;                   \
0103     (hdr)->magic = SCSI_NL_MAGIC;               \
0104     (hdr)->msgtype = mtype;                 \
0105     (hdr)->msglen = mlen;                   \
0106     }
0107 
0108 #endif /* SCSI_NETLINK_H */
0109