emad.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. * drivers/net/ethernet/mellanox/mlxsw/emad.h
  3. * Copyright (c) 2015 Mellanox Technologies. All rights reserved.
  4. * Copyright (c) 2015 Ido Schimmel <idosch@mellanox.com>
  5. * Copyright (c) 2015 Jiri Pirko <jiri@mellanox.com>
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions are met:
  9. *
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. Neither the names of the copyright holders nor the names of its
  16. * contributors may be used to endorse or promote products derived from
  17. * this software without specific prior written permission.
  18. *
  19. * Alternatively, this software may be distributed under the terms of the
  20. * GNU General Public License ("GPL") version 2 as published by the Free
  21. * Software Foundation.
  22. *
  23. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  24. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  25. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  26. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  27. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  28. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  29. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  30. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  31. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  32. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  33. * POSSIBILITY OF SUCH DAMAGE.
  34. */
  35. #ifndef _MLXSW_EMAD_H
  36. #define _MLXSW_EMAD_H
  37. #define MLXSW_EMAD_MAX_FRAME_LEN 1518 /* Length in u8 */
  38. #define MLXSW_EMAD_MAX_RETRY 5
  39. /* EMAD Ethernet header */
  40. #define MLXSW_EMAD_ETH_HDR_LEN 0x10 /* Length in u8 */
  41. #define MLXSW_EMAD_EH_DMAC "\x01\x02\xc9\x00\x00\x01"
  42. #define MLXSW_EMAD_EH_SMAC "\x00\x02\xc9\x01\x02\x03"
  43. #define MLXSW_EMAD_EH_ETHERTYPE 0x8932
  44. #define MLXSW_EMAD_EH_MLX_PROTO 0
  45. #define MLXSW_EMAD_EH_PROTO_VERSION 0
  46. /* EMAD TLV Types */
  47. enum {
  48. MLXSW_EMAD_TLV_TYPE_END,
  49. MLXSW_EMAD_TLV_TYPE_OP,
  50. MLXSW_EMAD_TLV_TYPE_DR,
  51. MLXSW_EMAD_TLV_TYPE_REG,
  52. MLXSW_EMAD_TLV_TYPE_USERDATA,
  53. MLXSW_EMAD_TLV_TYPE_OOBETH,
  54. };
  55. /* OP TLV */
  56. #define MLXSW_EMAD_OP_TLV_LEN 4 /* Length in u32 */
  57. enum {
  58. MLXSW_EMAD_OP_TLV_CLASS_REG_ACCESS = 1,
  59. MLXSW_EMAD_OP_TLV_CLASS_IPC = 2,
  60. };
  61. enum mlxsw_emad_op_tlv_status {
  62. MLXSW_EMAD_OP_TLV_STATUS_SUCCESS,
  63. MLXSW_EMAD_OP_TLV_STATUS_BUSY,
  64. MLXSW_EMAD_OP_TLV_STATUS_VERSION_NOT_SUPPORTED,
  65. MLXSW_EMAD_OP_TLV_STATUS_UNKNOWN_TLV,
  66. MLXSW_EMAD_OP_TLV_STATUS_REGISTER_NOT_SUPPORTED,
  67. MLXSW_EMAD_OP_TLV_STATUS_CLASS_NOT_SUPPORTED,
  68. MLXSW_EMAD_OP_TLV_STATUS_METHOD_NOT_SUPPORTED,
  69. MLXSW_EMAD_OP_TLV_STATUS_BAD_PARAMETER,
  70. MLXSW_EMAD_OP_TLV_STATUS_RESOURCE_NOT_AVAILABLE,
  71. MLXSW_EMAD_OP_TLV_STATUS_MESSAGE_RECEIPT_ACK,
  72. MLXSW_EMAD_OP_TLV_STATUS_INTERNAL_ERROR = 0x70,
  73. };
  74. static inline char *mlxsw_emad_op_tlv_status_str(u8 status)
  75. {
  76. switch (status) {
  77. case MLXSW_EMAD_OP_TLV_STATUS_SUCCESS:
  78. return "operation performed";
  79. case MLXSW_EMAD_OP_TLV_STATUS_BUSY:
  80. return "device is busy";
  81. case MLXSW_EMAD_OP_TLV_STATUS_VERSION_NOT_SUPPORTED:
  82. return "version not supported";
  83. case MLXSW_EMAD_OP_TLV_STATUS_UNKNOWN_TLV:
  84. return "unknown TLV";
  85. case MLXSW_EMAD_OP_TLV_STATUS_REGISTER_NOT_SUPPORTED:
  86. return "register not supported";
  87. case MLXSW_EMAD_OP_TLV_STATUS_CLASS_NOT_SUPPORTED:
  88. return "class not supported";
  89. case MLXSW_EMAD_OP_TLV_STATUS_METHOD_NOT_SUPPORTED:
  90. return "method not supported";
  91. case MLXSW_EMAD_OP_TLV_STATUS_BAD_PARAMETER:
  92. return "bad parameter";
  93. case MLXSW_EMAD_OP_TLV_STATUS_RESOURCE_NOT_AVAILABLE:
  94. return "resource not available";
  95. case MLXSW_EMAD_OP_TLV_STATUS_MESSAGE_RECEIPT_ACK:
  96. return "acknowledged. retransmit";
  97. case MLXSW_EMAD_OP_TLV_STATUS_INTERNAL_ERROR:
  98. return "internal error";
  99. default:
  100. return "*UNKNOWN*";
  101. }
  102. }
  103. enum {
  104. MLXSW_EMAD_OP_TLV_REQUEST,
  105. MLXSW_EMAD_OP_TLV_RESPONSE
  106. };
  107. enum {
  108. MLXSW_EMAD_OP_TLV_METHOD_QUERY = 1,
  109. MLXSW_EMAD_OP_TLV_METHOD_WRITE = 2,
  110. MLXSW_EMAD_OP_TLV_METHOD_SEND = 3,
  111. MLXSW_EMAD_OP_TLV_METHOD_EVENT = 5,
  112. };
  113. /* END TLV */
  114. #define MLXSW_EMAD_END_TLV_LEN 1 /* Length in u32 */
  115. #endif