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