scsi_netlink.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. /*
  25. * This file intended to be included by both kernel and user space
  26. */
  27. /* Single Netlink Message type to send all SCSI Transport messages */
  28. #define SCSI_TRANSPORT_MSG NLMSG_MIN_TYPE + 1
  29. /* SCSI Transport Broadcast Groups */
  30. /* leaving groups 0 and 1 unassigned */
  31. #define SCSI_NL_GRP_FC_EVENTS (1<<2) /* Group 2 */
  32. #define SCSI_NL_GRP_CNT 3
  33. /* SCSI_TRANSPORT_MSG event message header */
  34. struct scsi_nl_hdr {
  35. uint8_t version;
  36. uint8_t transport;
  37. uint16_t magic;
  38. uint16_t msgtype;
  39. uint16_t msglen;
  40. } __attribute__((aligned(sizeof(uint64_t))));
  41. /* scsi_nl_hdr->version value */
  42. #define SCSI_NL_VERSION 1
  43. /* scsi_nl_hdr->magic value */
  44. #define SCSI_NL_MAGIC 0xA1B2
  45. /* scsi_nl_hdr->transport value */
  46. #define SCSI_NL_TRANSPORT 0
  47. #define SCSI_NL_TRANSPORT_FC 1
  48. #define SCSI_NL_MAX_TRANSPORTS 2
  49. /* scsi_nl_hdr->msgtype values are defined in each transport */
  50. /*
  51. * Vendor ID:
  52. * If transports post vendor-unique events, they must pass a well-known
  53. * 32-bit vendor identifier. This identifier consists of 8 bits indicating
  54. * the "type" of identifier contained, and 24 bits of id data.
  55. *
  56. * Identifiers for each type:
  57. * PCI : ID data is the 16 bit PCI Registered Vendor ID
  58. */
  59. #define SCSI_NL_VID_TYPE_SHIFT 56
  60. #define SCSI_NL_VID_TYPE_MASK ((u64)0xFF << SCSI_NL_VID_TYPE_SHIFT)
  61. #define SCSI_NL_VID_TYPE_PCI ((u64)0x01 << SCSI_NL_VID_TYPE_SHIFT)
  62. #define SCSI_NL_VID_ID_MASK (~ SCSI_NL_VID_TYPE_MASK)
  63. #define INIT_SCSI_NL_HDR(hdr, t, mtype, mlen) \
  64. { \
  65. (hdr)->version = SCSI_NL_VERSION; \
  66. (hdr)->transport = t; \
  67. (hdr)->magic = SCSI_NL_MAGIC; \
  68. (hdr)->msgtype = mtype; \
  69. (hdr)->msglen = mlen; \
  70. }
  71. #endif /* SCSI_NETLINK_H */