/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */1/*2* SCSI Transport Netlink Interface3* Used for the posting of outbound SCSI transport events4*5* Copyright (C) 2006 James Smart, Emulex Corporation6*/7#ifndef SCSI_NETLINK_H8#define SCSI_NETLINK_H910#include <linux/netlink.h>11#include <linux/types.h>1213/*14* This file intended to be included by both kernel and user space15*/1617/* Single Netlink Message type to send all SCSI Transport messages */18#define SCSI_TRANSPORT_MSG NLMSG_MIN_TYPE + 11920/* SCSI Transport Broadcast Groups */21/* leaving groups 0 and 1 unassigned */22#define SCSI_NL_GRP_FC_EVENTS (1<<2) /* Group 2 */23#define SCSI_NL_GRP_CNT 3242526/* SCSI_TRANSPORT_MSG event message header */27struct scsi_nl_hdr {28__u8 version;29__u8 transport;30__u16 magic;31__u16 msgtype;32__u16 msglen;33} __attribute__((aligned(sizeof(__u64))));3435/* scsi_nl_hdr->version value */36#define SCSI_NL_VERSION 13738/* scsi_nl_hdr->magic value */39#define SCSI_NL_MAGIC 0xA1B24041/* scsi_nl_hdr->transport value */42#define SCSI_NL_TRANSPORT 043#define SCSI_NL_TRANSPORT_FC 144#define SCSI_NL_MAX_TRANSPORTS 24546/* Transport-based scsi_nl_hdr->msgtype values are defined in each transport */4748/*49* GENERIC SCSI scsi_nl_hdr->msgtype Values50*/51/* kernel -> user */52#define SCSI_NL_SHOST_VENDOR 0x000153/* user -> kernel */54/* SCSI_NL_SHOST_VENDOR msgtype is kernel->user and user->kernel */555657/*58* Message Structures :59*/6061/* macro to round up message lengths to 8byte boundary */62#define SCSI_NL_MSGALIGN(len) (((len) + 7) & ~7)636465/*66* SCSI HOST Vendor Unique messages :67* SCSI_NL_SHOST_VENDOR68*69* Note: The Vendor Unique message payload will begin directly after70* this structure, with the length of the payload per vmsg_datalen.71*72* Note: When specifying vendor_id, be sure to read the Vendor Type and ID73* formatting requirements specified below74*/75struct scsi_nl_host_vendor_msg {76struct scsi_nl_hdr snlh; /* must be 1st element ! */77__u64 vendor_id;78__u16 host_no;79__u16 vmsg_datalen;80} __attribute__((aligned(sizeof(__u64))));818283/*84* Vendor ID:85* If transports post vendor-unique events, they must pass a well-known86* 32-bit vendor identifier. This identifier consists of 8 bits indicating87* the "type" of identifier contained, and 24 bits of id data.88*89* Identifiers for each type:90* PCI : ID data is the 16 bit PCI Registered Vendor ID91*/92#define SCSI_NL_VID_TYPE_SHIFT 5693#define SCSI_NL_VID_TYPE_MASK ((__u64)0xFF << SCSI_NL_VID_TYPE_SHIFT)94#define SCSI_NL_VID_TYPE_PCI ((__u64)0x01 << SCSI_NL_VID_TYPE_SHIFT)95#define SCSI_NL_VID_ID_MASK (~ SCSI_NL_VID_TYPE_MASK)969798#define INIT_SCSI_NL_HDR(hdr, t, mtype, mlen) \99{ \100(hdr)->version = SCSI_NL_VERSION; \101(hdr)->transport = t; \102(hdr)->magic = SCSI_NL_MAGIC; \103(hdr)->msgtype = mtype; \104(hdr)->msglen = mlen; \105}106107#endif /* SCSI_NETLINK_H */108109110111