18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * SCSI Transport Netlink Interface 48c2ecf20Sopenharmony_ci * Used for the posting of outbound SCSI transport events 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * Copyright (C) 2006 James Smart, Emulex Corporation 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci#ifndef SCSI_NETLINK_H 98c2ecf20Sopenharmony_ci#define SCSI_NETLINK_H 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#include <linux/netlink.h> 128c2ecf20Sopenharmony_ci#include <linux/types.h> 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci/* 158c2ecf20Sopenharmony_ci * This file intended to be included by both kernel and user space 168c2ecf20Sopenharmony_ci */ 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci/* Single Netlink Message type to send all SCSI Transport messages */ 198c2ecf20Sopenharmony_ci#define SCSI_TRANSPORT_MSG NLMSG_MIN_TYPE + 1 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci/* SCSI Transport Broadcast Groups */ 228c2ecf20Sopenharmony_ci /* leaving groups 0 and 1 unassigned */ 238c2ecf20Sopenharmony_ci#define SCSI_NL_GRP_FC_EVENTS (1<<2) /* Group 2 */ 248c2ecf20Sopenharmony_ci#define SCSI_NL_GRP_CNT 3 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci/* SCSI_TRANSPORT_MSG event message header */ 288c2ecf20Sopenharmony_cistruct scsi_nl_hdr { 298c2ecf20Sopenharmony_ci __u8 version; 308c2ecf20Sopenharmony_ci __u8 transport; 318c2ecf20Sopenharmony_ci __u16 magic; 328c2ecf20Sopenharmony_ci __u16 msgtype; 338c2ecf20Sopenharmony_ci __u16 msglen; 348c2ecf20Sopenharmony_ci} __attribute__((aligned(sizeof(__u64)))); 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci/* scsi_nl_hdr->version value */ 378c2ecf20Sopenharmony_ci#define SCSI_NL_VERSION 1 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci/* scsi_nl_hdr->magic value */ 408c2ecf20Sopenharmony_ci#define SCSI_NL_MAGIC 0xA1B2 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci/* scsi_nl_hdr->transport value */ 438c2ecf20Sopenharmony_ci#define SCSI_NL_TRANSPORT 0 448c2ecf20Sopenharmony_ci#define SCSI_NL_TRANSPORT_FC 1 458c2ecf20Sopenharmony_ci#define SCSI_NL_MAX_TRANSPORTS 2 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci/* Transport-based scsi_nl_hdr->msgtype values are defined in each transport */ 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ci/* 508c2ecf20Sopenharmony_ci * GENERIC SCSI scsi_nl_hdr->msgtype Values 518c2ecf20Sopenharmony_ci */ 528c2ecf20Sopenharmony_ci /* kernel -> user */ 538c2ecf20Sopenharmony_ci#define SCSI_NL_SHOST_VENDOR 0x0001 548c2ecf20Sopenharmony_ci /* user -> kernel */ 558c2ecf20Sopenharmony_ci/* SCSI_NL_SHOST_VENDOR msgtype is kernel->user and user->kernel */ 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci/* 598c2ecf20Sopenharmony_ci * Message Structures : 608c2ecf20Sopenharmony_ci */ 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci/* macro to round up message lengths to 8byte boundary */ 638c2ecf20Sopenharmony_ci#define SCSI_NL_MSGALIGN(len) (((len) + 7) & ~7) 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci/* 678c2ecf20Sopenharmony_ci * SCSI HOST Vendor Unique messages : 688c2ecf20Sopenharmony_ci * SCSI_NL_SHOST_VENDOR 698c2ecf20Sopenharmony_ci * 708c2ecf20Sopenharmony_ci * Note: The Vendor Unique message payload will begin directly after 718c2ecf20Sopenharmony_ci * this structure, with the length of the payload per vmsg_datalen. 728c2ecf20Sopenharmony_ci * 738c2ecf20Sopenharmony_ci * Note: When specifying vendor_id, be sure to read the Vendor Type and ID 748c2ecf20Sopenharmony_ci * formatting requirements specified below 758c2ecf20Sopenharmony_ci */ 768c2ecf20Sopenharmony_cistruct scsi_nl_host_vendor_msg { 778c2ecf20Sopenharmony_ci struct scsi_nl_hdr snlh; /* must be 1st element ! */ 788c2ecf20Sopenharmony_ci __u64 vendor_id; 798c2ecf20Sopenharmony_ci __u16 host_no; 808c2ecf20Sopenharmony_ci __u16 vmsg_datalen; 818c2ecf20Sopenharmony_ci} __attribute__((aligned(sizeof(__u64)))); 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci/* 858c2ecf20Sopenharmony_ci * Vendor ID: 868c2ecf20Sopenharmony_ci * If transports post vendor-unique events, they must pass a well-known 878c2ecf20Sopenharmony_ci * 32-bit vendor identifier. This identifier consists of 8 bits indicating 888c2ecf20Sopenharmony_ci * the "type" of identifier contained, and 24 bits of id data. 898c2ecf20Sopenharmony_ci * 908c2ecf20Sopenharmony_ci * Identifiers for each type: 918c2ecf20Sopenharmony_ci * PCI : ID data is the 16 bit PCI Registered Vendor ID 928c2ecf20Sopenharmony_ci */ 938c2ecf20Sopenharmony_ci#define SCSI_NL_VID_TYPE_SHIFT 56 948c2ecf20Sopenharmony_ci#define SCSI_NL_VID_TYPE_MASK ((__u64)0xFF << SCSI_NL_VID_TYPE_SHIFT) 958c2ecf20Sopenharmony_ci#define SCSI_NL_VID_TYPE_PCI ((__u64)0x01 << SCSI_NL_VID_TYPE_SHIFT) 968c2ecf20Sopenharmony_ci#define SCSI_NL_VID_ID_MASK (~ SCSI_NL_VID_TYPE_MASK) 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_ci#define INIT_SCSI_NL_HDR(hdr, t, mtype, mlen) \ 1008c2ecf20Sopenharmony_ci { \ 1018c2ecf20Sopenharmony_ci (hdr)->version = SCSI_NL_VERSION; \ 1028c2ecf20Sopenharmony_ci (hdr)->transport = t; \ 1038c2ecf20Sopenharmony_ci (hdr)->magic = SCSI_NL_MAGIC; \ 1048c2ecf20Sopenharmony_ci (hdr)->msgtype = mtype; \ 1058c2ecf20Sopenharmony_ci (hdr)->msglen = mlen; \ 1068c2ecf20Sopenharmony_ci } 1078c2ecf20Sopenharmony_ci 1088c2ecf20Sopenharmony_ci#endif /* SCSI_NETLINK_H */ 1098c2ecf20Sopenharmony_ci 110