opa_smi.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
  2. /*
  3. * Copyright (c) 2014 Intel Corporation. All rights reserved.
  4. */
  5. #ifndef OPA_SMI_H
  6. #define OPA_SMI_H
  7. #include <rdma/ib_mad.h>
  8. #include <rdma/ib_smi.h>
  9. #define OPA_SMP_LID_DATA_SIZE 2016
  10. #define OPA_SMP_DR_DATA_SIZE 1872
  11. #define OPA_SMP_MAX_PATH_HOPS 64
  12. #define OPA_MAX_VLS 32
  13. #define OPA_MAX_SLS 32
  14. #define OPA_MAX_SCS 32
  15. #define OPA_LID_PERMISSIVE cpu_to_be32(0xFFFFFFFF)
  16. struct opa_smp {
  17. u8 base_version;
  18. u8 mgmt_class;
  19. u8 class_version;
  20. u8 method;
  21. __be16 status;
  22. u8 hop_ptr;
  23. u8 hop_cnt;
  24. __be64 tid;
  25. __be16 attr_id;
  26. __be16 resv;
  27. __be32 attr_mod;
  28. __be64 mkey;
  29. union {
  30. struct {
  31. uint8_t data[OPA_SMP_LID_DATA_SIZE];
  32. } lid;
  33. struct {
  34. __be32 dr_slid;
  35. __be32 dr_dlid;
  36. u8 initial_path[OPA_SMP_MAX_PATH_HOPS];
  37. u8 return_path[OPA_SMP_MAX_PATH_HOPS];
  38. u8 reserved[8];
  39. u8 data[OPA_SMP_DR_DATA_SIZE];
  40. } dr;
  41. } route;
  42. } __packed;
  43. /* Subnet management attributes */
  44. /* ... */
  45. #define OPA_ATTRIB_ID_NODE_DESCRIPTION cpu_to_be16(0x0010)
  46. #define OPA_ATTRIB_ID_NODE_INFO cpu_to_be16(0x0011)
  47. #define OPA_ATTRIB_ID_PORT_INFO cpu_to_be16(0x0015)
  48. #define OPA_ATTRIB_ID_PARTITION_TABLE cpu_to_be16(0x0016)
  49. #define OPA_ATTRIB_ID_SL_TO_SC_MAP cpu_to_be16(0x0017)
  50. #define OPA_ATTRIB_ID_VL_ARBITRATION cpu_to_be16(0x0018)
  51. #define OPA_ATTRIB_ID_SM_INFO cpu_to_be16(0x0020)
  52. #define OPA_ATTRIB_ID_CABLE_INFO cpu_to_be16(0x0032)
  53. #define OPA_ATTRIB_ID_AGGREGATE cpu_to_be16(0x0080)
  54. #define OPA_ATTRIB_ID_SC_TO_SL_MAP cpu_to_be16(0x0082)
  55. #define OPA_ATTRIB_ID_SC_TO_VLR_MAP cpu_to_be16(0x0083)
  56. #define OPA_ATTRIB_ID_SC_TO_VLT_MAP cpu_to_be16(0x0084)
  57. #define OPA_ATTRIB_ID_SC_TO_VLNT_MAP cpu_to_be16(0x0085)
  58. /* ... */
  59. #define OPA_ATTRIB_ID_PORT_STATE_INFO cpu_to_be16(0x0087)
  60. /* ... */
  61. #define OPA_ATTRIB_ID_BUFFER_CONTROL_TABLE cpu_to_be16(0x008A)
  62. /* ... */
  63. struct opa_node_description {
  64. u8 data[64];
  65. } __packed;
  66. struct opa_node_info {
  67. u8 base_version;
  68. u8 class_version;
  69. u8 node_type;
  70. u8 num_ports;
  71. __be32 reserved;
  72. __be64 system_image_guid;
  73. __be64 node_guid;
  74. __be64 port_guid;
  75. __be16 partition_cap;
  76. __be16 device_id;
  77. __be32 revision;
  78. u8 local_port_num;
  79. u8 vendor_id[3]; /* network byte order */
  80. } __packed;
  81. #define OPA_PARTITION_TABLE_BLK_SIZE 32
  82. static inline u8
  83. opa_get_smp_direction(struct opa_smp *smp)
  84. {
  85. return ib_get_smp_direction((struct ib_smp *)smp);
  86. }
  87. static inline u8 *opa_get_smp_data(struct opa_smp *smp)
  88. {
  89. if (smp->mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)
  90. return smp->route.dr.data;
  91. return smp->route.lid.data;
  92. }
  93. static inline size_t opa_get_smp_data_size(struct opa_smp *smp)
  94. {
  95. if (smp->mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)
  96. return sizeof(smp->route.dr.data);
  97. return sizeof(smp->route.lid.data);
  98. }
  99. static inline size_t opa_get_smp_header_size(struct opa_smp *smp)
  100. {
  101. if (smp->mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE)
  102. return sizeof(*smp) - sizeof(smp->route.dr.data);
  103. return sizeof(*smp) - sizeof(smp->route.lid.data);
  104. }
  105. #endif /* OPA_SMI_H */