port.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /*
  2. * Copyright (c) 2016, Mellanox Technologies. All rights reserved.
  3. *
  4. * This software is available to you under a choice of one of two
  5. * licenses. You may choose to be licensed under the terms of the GNU
  6. * General Public License (GPL) Version 2, available from the file
  7. * COPYING in the main directory of this source tree, or the
  8. * OpenIB.org BSD license below:
  9. *
  10. * Redistribution and use in source and binary forms, with or
  11. * without modification, are permitted provided that the following
  12. * conditions are met:
  13. *
  14. * - Redistributions of source code must retain the above
  15. * copyright notice, this list of conditions and the following
  16. * disclaimer.
  17. *
  18. * - Redistributions in binary form must reproduce the above
  19. * copyright notice, this list of conditions and the following
  20. * disclaimer in the documentation and/or other materials
  21. * provided with the distribution.
  22. *
  23. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  24. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  26. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  27. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  28. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  29. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  30. * SOFTWARE.
  31. */
  32. #ifndef __MLX5_PORT_H__
  33. #define __MLX5_PORT_H__
  34. #include <linux/mlx5/driver.h>
  35. enum mlx5_beacon_duration {
  36. MLX5_BEACON_DURATION_OFF = 0x0,
  37. MLX5_BEACON_DURATION_INF = 0xffff,
  38. };
  39. enum mlx5_module_id {
  40. MLX5_MODULE_ID_SFP = 0x3,
  41. MLX5_MODULE_ID_QSFP = 0xC,
  42. MLX5_MODULE_ID_QSFP_PLUS = 0xD,
  43. MLX5_MODULE_ID_QSFP28 = 0x11,
  44. };
  45. enum mlx5_an_status {
  46. MLX5_AN_UNAVAILABLE = 0,
  47. MLX5_AN_COMPLETE = 1,
  48. MLX5_AN_FAILED = 2,
  49. MLX5_AN_LINK_UP = 3,
  50. MLX5_AN_LINK_DOWN = 4,
  51. };
  52. #define MLX5_EEPROM_MAX_BYTES 32
  53. #define MLX5_EEPROM_IDENTIFIER_BYTE_MASK 0x000000ff
  54. #define MLX5_I2C_ADDR_LOW 0x50
  55. #define MLX5_I2C_ADDR_HIGH 0x51
  56. #define MLX5_EEPROM_PAGE_LENGTH 256
  57. enum mlx5e_link_mode {
  58. MLX5E_1000BASE_CX_SGMII = 0,
  59. MLX5E_1000BASE_KX = 1,
  60. MLX5E_10GBASE_CX4 = 2,
  61. MLX5E_10GBASE_KX4 = 3,
  62. MLX5E_10GBASE_KR = 4,
  63. MLX5E_20GBASE_KR2 = 5,
  64. MLX5E_40GBASE_CR4 = 6,
  65. MLX5E_40GBASE_KR4 = 7,
  66. MLX5E_56GBASE_R4 = 8,
  67. MLX5E_10GBASE_CR = 12,
  68. MLX5E_10GBASE_SR = 13,
  69. MLX5E_10GBASE_ER = 14,
  70. MLX5E_40GBASE_SR4 = 15,
  71. MLX5E_40GBASE_LR4 = 16,
  72. MLX5E_50GBASE_SR2 = 18,
  73. MLX5E_100GBASE_CR4 = 20,
  74. MLX5E_100GBASE_SR4 = 21,
  75. MLX5E_100GBASE_KR4 = 22,
  76. MLX5E_100GBASE_LR4 = 23,
  77. MLX5E_100BASE_TX = 24,
  78. MLX5E_1000BASE_T = 25,
  79. MLX5E_10GBASE_T = 26,
  80. MLX5E_25GBASE_CR = 27,
  81. MLX5E_25GBASE_KR = 28,
  82. MLX5E_25GBASE_SR = 29,
  83. MLX5E_50GBASE_CR2 = 30,
  84. MLX5E_50GBASE_KR2 = 31,
  85. MLX5E_LINK_MODES_NUMBER,
  86. };
  87. enum mlx5e_connector_type {
  88. MLX5E_PORT_UNKNOWN = 0,
  89. MLX5E_PORT_NONE = 1,
  90. MLX5E_PORT_TP = 2,
  91. MLX5E_PORT_AUI = 3,
  92. MLX5E_PORT_BNC = 4,
  93. MLX5E_PORT_MII = 5,
  94. MLX5E_PORT_FIBRE = 6,
  95. MLX5E_PORT_DA = 7,
  96. MLX5E_PORT_OTHER = 8,
  97. MLX5E_CONNECTOR_TYPE_NUMBER,
  98. };
  99. #define MLX5E_PROT_MASK(link_mode) (1 << link_mode)
  100. #define PORT_MODULE_EVENT_MODULE_STATUS_MASK 0xF
  101. #define PORT_MODULE_EVENT_ERROR_TYPE_MASK 0xF
  102. int mlx5_set_port_caps(struct mlx5_core_dev *dev, u8 port_num, u32 caps);
  103. int mlx5_query_port_ptys(struct mlx5_core_dev *dev, u32 *ptys,
  104. int ptys_size, int proto_mask, u8 local_port);
  105. int mlx5_query_port_proto_cap(struct mlx5_core_dev *dev,
  106. u32 *proto_cap, int proto_mask);
  107. int mlx5_query_port_proto_admin(struct mlx5_core_dev *dev,
  108. u32 *proto_admin, int proto_mask);
  109. int mlx5_query_port_link_width_oper(struct mlx5_core_dev *dev,
  110. u8 *link_width_oper, u8 local_port);
  111. int mlx5_query_port_ib_proto_oper(struct mlx5_core_dev *dev,
  112. u8 *proto_oper, u8 local_port);
  113. int mlx5_query_port_eth_proto_oper(struct mlx5_core_dev *dev,
  114. u32 *proto_oper, u8 local_port);
  115. int mlx5_set_port_ptys(struct mlx5_core_dev *dev, bool an_disable,
  116. u32 proto_admin, int proto_mask);
  117. void mlx5_toggle_port_link(struct mlx5_core_dev *dev);
  118. int mlx5_set_port_admin_status(struct mlx5_core_dev *dev,
  119. enum mlx5_port_status status);
  120. int mlx5_query_port_admin_status(struct mlx5_core_dev *dev,
  121. enum mlx5_port_status *status);
  122. int mlx5_set_port_beacon(struct mlx5_core_dev *dev, u16 beacon_duration);
  123. void mlx5_query_port_autoneg(struct mlx5_core_dev *dev, int proto_mask,
  124. u8 *an_status,
  125. u8 *an_disable_cap, u8 *an_disable_admin);
  126. int mlx5_set_port_mtu(struct mlx5_core_dev *dev, u16 mtu, u8 port);
  127. void mlx5_query_port_max_mtu(struct mlx5_core_dev *dev, u16 *max_mtu, u8 port);
  128. void mlx5_query_port_oper_mtu(struct mlx5_core_dev *dev, u16 *oper_mtu,
  129. u8 port);
  130. int mlx5_query_port_vl_hw_cap(struct mlx5_core_dev *dev,
  131. u8 *vl_hw_cap, u8 local_port);
  132. int mlx5_set_port_pause(struct mlx5_core_dev *dev, u32 rx_pause, u32 tx_pause);
  133. int mlx5_query_port_pause(struct mlx5_core_dev *dev,
  134. u32 *rx_pause, u32 *tx_pause);
  135. int mlx5_set_port_pfc(struct mlx5_core_dev *dev, u8 pfc_en_tx, u8 pfc_en_rx);
  136. int mlx5_query_port_pfc(struct mlx5_core_dev *dev, u8 *pfc_en_tx,
  137. u8 *pfc_en_rx);
  138. int mlx5_max_tc(struct mlx5_core_dev *mdev);
  139. int mlx5_set_port_prio_tc(struct mlx5_core_dev *mdev, u8 *prio_tc);
  140. int mlx5_query_port_prio_tc(struct mlx5_core_dev *mdev,
  141. u8 prio, u8 *tc);
  142. int mlx5_set_port_tc_group(struct mlx5_core_dev *mdev, u8 *tc_group);
  143. int mlx5_set_port_tc_bw_alloc(struct mlx5_core_dev *mdev, u8 *tc_bw);
  144. int mlx5_query_port_tc_bw_alloc(struct mlx5_core_dev *mdev,
  145. u8 tc, u8 *bw_pct);
  146. int mlx5_modify_port_ets_rate_limit(struct mlx5_core_dev *mdev,
  147. u8 *max_bw_value,
  148. u8 *max_bw_unit);
  149. int mlx5_query_port_ets_rate_limit(struct mlx5_core_dev *mdev,
  150. u8 *max_bw_value,
  151. u8 *max_bw_unit);
  152. int mlx5_set_port_wol(struct mlx5_core_dev *mdev, u8 wol_mode);
  153. int mlx5_query_port_wol(struct mlx5_core_dev *mdev, u8 *wol_mode);
  154. int mlx5_set_port_fcs(struct mlx5_core_dev *mdev, u8 enable);
  155. void mlx5_query_port_fcs(struct mlx5_core_dev *mdev, bool *supported,
  156. bool *enabled);
  157. int mlx5_query_module_eeprom(struct mlx5_core_dev *dev,
  158. u16 offset, u16 size, u8 *data);
  159. int mlx5_query_port_dcbx_param(struct mlx5_core_dev *mdev, u32 *out);
  160. int mlx5_set_port_dcbx_param(struct mlx5_core_dev *mdev, u32 *in);
  161. #endif /* __MLX5_PORT_H__ */