scsi_netlink.h 2.8 KB

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