scsi_netlink.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. * SCSI Transport Netlink Interface
  3. * Used for the posting of outbound SCSI transport events
  4. *
  5. * Copyright (C) 2006 James Smart, Emulex Corporation
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. *
  21. */
  22. #ifndef SCSI_NETLINK_H
  23. #define SCSI_NETLINK_H
  24. #include <linux/netlink.h>
  25. #include <linux/types.h>
  26. /*
  27. * This file intended to be included by both kernel and user space
  28. */
  29. /* Single Netlink Message type to send all SCSI Transport messages */
  30. #define SCSI_TRANSPORT_MSG NLMSG_MIN_TYPE + 1
  31. /* SCSI Transport Broadcast Groups */
  32. /* leaving groups 0 and 1 unassigned */
  33. #define SCSI_NL_GRP_FC_EVENTS (1<<2) /* Group 2 */
  34. #define SCSI_NL_GRP_CNT 3
  35. /* SCSI_TRANSPORT_MSG event message header */
  36. struct scsi_nl_hdr {
  37. uint8_t version;
  38. uint8_t transport;
  39. uint16_t magic;
  40. uint16_t msgtype;
  41. uint16_t msglen;
  42. } __attribute__((aligned(sizeof(uint64_t))));
  43. /* scsi_nl_hdr->version value */
  44. #define SCSI_NL_VERSION 1
  45. /* scsi_nl_hdr->magic value */
  46. #define SCSI_NL_MAGIC 0xA1B2
  47. /* scsi_nl_hdr->transport value */
  48. #define SCSI_NL_TRANSPORT 0
  49. #define SCSI_NL_TRANSPORT_FC 1
  50. #define SCSI_NL_MAX_TRANSPORTS 2
  51. /* Transport-based scsi_nl_hdr->msgtype values are defined in each transport */
  52. /*
  53. * GENERIC SCSI scsi_nl_hdr->msgtype Values
  54. */
  55. /* kernel -> user */
  56. #define SCSI_NL_SHOST_VENDOR 0x0001
  57. /* user -> kernel */
  58. /* SCSI_NL_SHOST_VENDOR msgtype is kernel->user and user->kernel */
  59. /*
  60. * Message Structures :
  61. */
  62. /* macro to round up message lengths to 8byte boundary */
  63. #define SCSI_NL_MSGALIGN(len) (((len) + 7) & ~7)
  64. /*
  65. * SCSI HOST Vendor Unique messages :
  66. * SCSI_NL_SHOST_VENDOR
  67. *
  68. * Note: The Vendor Unique message payload will begin directly after
  69. * this structure, with the length of the payload per vmsg_datalen.
  70. *
  71. * Note: When specifying vendor_id, be sure to read the Vendor Type and ID
  72. * formatting requirements specified below
  73. */
  74. struct scsi_nl_host_vendor_msg {
  75. struct scsi_nl_hdr snlh; /* must be 1st element ! */
  76. uint64_t vendor_id;
  77. uint16_t host_no;
  78. uint16_t vmsg_datalen;
  79. } __attribute__((aligned(sizeof(uint64_t))));
  80. /*
  81. * Vendor ID:
  82. * If transports post vendor-unique events, they must pass a well-known
  83. * 32-bit vendor identifier. This identifier consists of 8 bits indicating
  84. * the "type" of identifier contained, and 24 bits of id data.
  85. *
  86. * Identifiers for each type:
  87. * PCI : ID data is the 16 bit PCI Registered Vendor ID
  88. */
  89. #define SCSI_NL_VID_TYPE_SHIFT 56
  90. #define SCSI_NL_VID_TYPE_MASK ((__u64)0xFF << SCSI_NL_VID_TYPE_SHIFT)
  91. #define SCSI_NL_VID_TYPE_PCI ((__u64)0x01 << SCSI_NL_VID_TYPE_SHIFT)
  92. #define SCSI_NL_VID_ID_MASK (~ SCSI_NL_VID_TYPE_MASK)
  93. #define INIT_SCSI_NL_HDR(hdr, t, mtype, mlen) \
  94. { \
  95. (hdr)->version = SCSI_NL_VERSION; \
  96. (hdr)->transport = t; \
  97. (hdr)->magic = SCSI_NL_MAGIC; \
  98. (hdr)->msgtype = mtype; \
  99. (hdr)->msglen = mlen; \
  100. }
  101. #endif /* SCSI_NETLINK_H */