platform.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. /*
  2. * Copyright(c) 2015, 2016 Intel Corporation.
  3. *
  4. * This file is provided under a dual BSD/GPLv2 license. When using or
  5. * redistributing this file, you may do so under either license.
  6. *
  7. * GPL LICENSE SUMMARY
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of version 2 of the GNU General Public License as
  11. * published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * BSD LICENSE
  19. *
  20. * Redistribution and use in source and binary forms, with or without
  21. * modification, are permitted provided that the following conditions
  22. * are met:
  23. *
  24. * - Redistributions of source code must retain the above copyright
  25. * notice, this list of conditions and the following disclaimer.
  26. * - Redistributions in binary form must reproduce the above copyright
  27. * notice, this list of conditions and the following disclaimer in
  28. * the documentation and/or other materials provided with the
  29. * distribution.
  30. * - Neither the name of Intel Corporation nor the names of its
  31. * contributors may be used to endorse or promote products derived
  32. * from this software without specific prior written permission.
  33. *
  34. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  35. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  36. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  37. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  38. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  39. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  40. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  41. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  42. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  43. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  44. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  45. *
  46. */
  47. #ifndef __PLATFORM_H
  48. #define __PLATFORM_H
  49. #define METADATA_TABLE_FIELD_START_SHIFT 0
  50. #define METADATA_TABLE_FIELD_START_LEN_BITS 15
  51. #define METADATA_TABLE_FIELD_LEN_SHIFT 16
  52. #define METADATA_TABLE_FIELD_LEN_LEN_BITS 16
  53. /* Header structure */
  54. #define PLATFORM_CONFIG_HEADER_RECORD_IDX_SHIFT 0
  55. #define PLATFORM_CONFIG_HEADER_RECORD_IDX_LEN_BITS 6
  56. #define PLATFORM_CONFIG_HEADER_TABLE_LENGTH_SHIFT 16
  57. #define PLATFORM_CONFIG_HEADER_TABLE_LENGTH_LEN_BITS 12
  58. #define PLATFORM_CONFIG_HEADER_TABLE_TYPE_SHIFT 28
  59. #define PLATFORM_CONFIG_HEADER_TABLE_TYPE_LEN_BITS 4
  60. enum platform_config_table_type_encoding {
  61. PLATFORM_CONFIG_TABLE_RESERVED,
  62. PLATFORM_CONFIG_SYSTEM_TABLE,
  63. PLATFORM_CONFIG_PORT_TABLE,
  64. PLATFORM_CONFIG_RX_PRESET_TABLE,
  65. PLATFORM_CONFIG_TX_PRESET_TABLE,
  66. PLATFORM_CONFIG_QSFP_ATTEN_TABLE,
  67. PLATFORM_CONFIG_VARIABLE_SETTINGS_TABLE,
  68. PLATFORM_CONFIG_TABLE_MAX
  69. };
  70. enum platform_config_system_table_fields {
  71. SYSTEM_TABLE_RESERVED,
  72. SYSTEM_TABLE_NODE_STRING,
  73. SYSTEM_TABLE_SYSTEM_IMAGE_GUID,
  74. SYSTEM_TABLE_NODE_GUID,
  75. SYSTEM_TABLE_REVISION,
  76. SYSTEM_TABLE_VENDOR_OUI,
  77. SYSTEM_TABLE_META_VERSION,
  78. SYSTEM_TABLE_DEVICE_ID,
  79. SYSTEM_TABLE_PARTITION_ENFORCEMENT_CAP,
  80. SYSTEM_TABLE_QSFP_POWER_CLASS_MAX,
  81. SYSTEM_TABLE_QSFP_ATTENUATION_DEFAULT_12G,
  82. SYSTEM_TABLE_QSFP_ATTENUATION_DEFAULT_25G,
  83. SYSTEM_TABLE_VARIABLE_TABLE_ENTRIES_PER_PORT,
  84. SYSTEM_TABLE_MAX
  85. };
  86. enum platform_config_port_table_fields {
  87. PORT_TABLE_RESERVED,
  88. PORT_TABLE_PORT_TYPE,
  89. PORT_TABLE_LOCAL_ATTEN_12G,
  90. PORT_TABLE_LOCAL_ATTEN_25G,
  91. PORT_TABLE_LINK_SPEED_SUPPORTED,
  92. PORT_TABLE_LINK_WIDTH_SUPPORTED,
  93. PORT_TABLE_AUTO_LANE_SHEDDING_ENABLED,
  94. PORT_TABLE_EXTERNAL_LOOPBACK_ALLOWED,
  95. PORT_TABLE_VL_CAP,
  96. PORT_TABLE_MTU_CAP,
  97. PORT_TABLE_TX_LANE_ENABLE_MASK,
  98. PORT_TABLE_LOCAL_MAX_TIMEOUT,
  99. PORT_TABLE_REMOTE_ATTEN_12G,
  100. PORT_TABLE_REMOTE_ATTEN_25G,
  101. PORT_TABLE_TX_PRESET_IDX_ACTIVE_NO_EQ,
  102. PORT_TABLE_TX_PRESET_IDX_ACTIVE_EQ,
  103. PORT_TABLE_RX_PRESET_IDX,
  104. PORT_TABLE_CABLE_REACH_CLASS,
  105. PORT_TABLE_MAX
  106. };
  107. enum platform_config_rx_preset_table_fields {
  108. RX_PRESET_TABLE_RESERVED,
  109. RX_PRESET_TABLE_QSFP_RX_CDR_APPLY,
  110. RX_PRESET_TABLE_QSFP_RX_EMP_APPLY,
  111. RX_PRESET_TABLE_QSFP_RX_AMP_APPLY,
  112. RX_PRESET_TABLE_QSFP_RX_CDR,
  113. RX_PRESET_TABLE_QSFP_RX_EMP,
  114. RX_PRESET_TABLE_QSFP_RX_AMP,
  115. RX_PRESET_TABLE_MAX
  116. };
  117. enum platform_config_tx_preset_table_fields {
  118. TX_PRESET_TABLE_RESERVED,
  119. TX_PRESET_TABLE_PRECUR,
  120. TX_PRESET_TABLE_ATTN,
  121. TX_PRESET_TABLE_POSTCUR,
  122. TX_PRESET_TABLE_QSFP_TX_CDR_APPLY,
  123. TX_PRESET_TABLE_QSFP_TX_EQ_APPLY,
  124. TX_PRESET_TABLE_QSFP_TX_CDR,
  125. TX_PRESET_TABLE_QSFP_TX_EQ,
  126. TX_PRESET_TABLE_MAX
  127. };
  128. enum platform_config_qsfp_attn_table_fields {
  129. QSFP_ATTEN_TABLE_RESERVED,
  130. QSFP_ATTEN_TABLE_TX_PRESET_IDX,
  131. QSFP_ATTEN_TABLE_RX_PRESET_IDX,
  132. QSFP_ATTEN_TABLE_MAX
  133. };
  134. enum platform_config_variable_settings_table_fields {
  135. VARIABLE_SETTINGS_TABLE_RESERVED,
  136. VARIABLE_SETTINGS_TABLE_TX_PRESET_IDX,
  137. VARIABLE_SETTINGS_TABLE_RX_PRESET_IDX,
  138. VARIABLE_SETTINGS_TABLE_MAX
  139. };
  140. struct platform_config {
  141. size_t size;
  142. const u8 *data;
  143. };
  144. struct platform_config_data {
  145. u32 *table;
  146. u32 *table_metadata;
  147. u32 num_table;
  148. };
  149. /*
  150. * This struct acts as a quick reference into the platform_data binary image
  151. * and is populated by parse_platform_config(...) depending on the specific
  152. * META_VERSION
  153. */
  154. struct platform_config_cache {
  155. u8 cache_valid;
  156. struct platform_config_data config_tables[PLATFORM_CONFIG_TABLE_MAX];
  157. };
  158. /* This section defines default values and encodings for the
  159. * fields defined for each table above
  160. */
  161. /*
  162. * =====================================================
  163. * System table encodings
  164. * =====================================================
  165. */
  166. #define PLATFORM_CONFIG_MAGIC_NUM 0x3d4f5041
  167. #define PLATFORM_CONFIG_MAGIC_NUMBER_LEN 4
  168. /*
  169. * These power classes are the same as defined in SFF 8636 spec rev 2.4
  170. * describing byte 129 in table 6-16, except enumerated in a different order
  171. */
  172. enum platform_config_qsfp_power_class_encoding {
  173. QSFP_POWER_CLASS_1 = 1,
  174. QSFP_POWER_CLASS_2,
  175. QSFP_POWER_CLASS_3,
  176. QSFP_POWER_CLASS_4,
  177. QSFP_POWER_CLASS_5,
  178. QSFP_POWER_CLASS_6,
  179. QSFP_POWER_CLASS_7
  180. };
  181. /*
  182. * ====================================================
  183. * Port table encodings
  184. * ====================================================
  185. */
  186. enum platform_config_port_type_encoding {
  187. PORT_TYPE_UNKNOWN,
  188. PORT_TYPE_DISCONNECTED,
  189. PORT_TYPE_FIXED,
  190. PORT_TYPE_VARIABLE,
  191. PORT_TYPE_QSFP,
  192. PORT_TYPE_MAX
  193. };
  194. enum platform_config_link_speed_supported_encoding {
  195. LINK_SPEED_SUPP_12G = 1,
  196. LINK_SPEED_SUPP_25G,
  197. LINK_SPEED_SUPP_12G_25G,
  198. LINK_SPEED_SUPP_MAX
  199. };
  200. /*
  201. * This is a subset (not strict) of the link downgrades
  202. * supported. The link downgrades supported are expected
  203. * to be supplied to the driver by another entity such as
  204. * the fabric manager
  205. */
  206. enum platform_config_link_width_supported_encoding {
  207. LINK_WIDTH_SUPP_1X = 1,
  208. LINK_WIDTH_SUPP_2X,
  209. LINK_WIDTH_SUPP_2X_1X,
  210. LINK_WIDTH_SUPP_3X,
  211. LINK_WIDTH_SUPP_3X_1X,
  212. LINK_WIDTH_SUPP_3X_2X,
  213. LINK_WIDTH_SUPP_3X_2X_1X,
  214. LINK_WIDTH_SUPP_4X,
  215. LINK_WIDTH_SUPP_4X_1X,
  216. LINK_WIDTH_SUPP_4X_2X,
  217. LINK_WIDTH_SUPP_4X_2X_1X,
  218. LINK_WIDTH_SUPP_4X_3X,
  219. LINK_WIDTH_SUPP_4X_3X_1X,
  220. LINK_WIDTH_SUPP_4X_3X_2X,
  221. LINK_WIDTH_SUPP_4X_3X_2X_1X,
  222. LINK_WIDTH_SUPP_MAX
  223. };
  224. enum platform_config_virtual_lane_capability_encoding {
  225. VL_CAP_VL0 = 1,
  226. VL_CAP_VL0_1,
  227. VL_CAP_VL0_2,
  228. VL_CAP_VL0_3,
  229. VL_CAP_VL0_4,
  230. VL_CAP_VL0_5,
  231. VL_CAP_VL0_6,
  232. VL_CAP_VL0_7,
  233. VL_CAP_VL0_8,
  234. VL_CAP_VL0_9,
  235. VL_CAP_VL0_10,
  236. VL_CAP_VL0_11,
  237. VL_CAP_VL0_12,
  238. VL_CAP_VL0_13,
  239. VL_CAP_VL0_14,
  240. VL_CAP_MAX
  241. };
  242. /* Max MTU */
  243. enum platform_config_mtu_capability_encoding {
  244. MTU_CAP_256 = 1,
  245. MTU_CAP_512 = 2,
  246. MTU_CAP_1024 = 3,
  247. MTU_CAP_2048 = 4,
  248. MTU_CAP_4096 = 5,
  249. MTU_CAP_8192 = 6,
  250. MTU_CAP_10240 = 7
  251. };
  252. enum platform_config_local_max_timeout_encoding {
  253. LOCAL_MAX_TIMEOUT_10_MS = 1,
  254. LOCAL_MAX_TIMEOUT_100_MS,
  255. LOCAL_MAX_TIMEOUT_1_S,
  256. LOCAL_MAX_TIMEOUT_10_S,
  257. LOCAL_MAX_TIMEOUT_100_S,
  258. LOCAL_MAX_TIMEOUT_1000_S
  259. };
  260. enum link_tuning_encoding {
  261. OPA_PASSIVE_TUNING,
  262. OPA_ACTIVE_TUNING,
  263. OPA_UNKNOWN_TUNING
  264. };
  265. /*
  266. * Shifts and masks for the link SI tuning values stuffed into the ASIC scratch
  267. * registers for integrated platforms
  268. */
  269. #define PORT0_PORT_TYPE_SHIFT 0
  270. #define PORT0_LOCAL_ATTEN_SHIFT 4
  271. #define PORT0_REMOTE_ATTEN_SHIFT 10
  272. #define PORT0_DEFAULT_ATTEN_SHIFT 32
  273. #define PORT1_PORT_TYPE_SHIFT 16
  274. #define PORT1_LOCAL_ATTEN_SHIFT 20
  275. #define PORT1_REMOTE_ATTEN_SHIFT 26
  276. #define PORT1_DEFAULT_ATTEN_SHIFT 40
  277. #define PORT0_PORT_TYPE_MASK 0xFUL
  278. #define PORT0_LOCAL_ATTEN_MASK 0x3FUL
  279. #define PORT0_REMOTE_ATTEN_MASK 0x3FUL
  280. #define PORT0_DEFAULT_ATTEN_MASK 0xFFUL
  281. #define PORT1_PORT_TYPE_MASK 0xFUL
  282. #define PORT1_LOCAL_ATTEN_MASK 0x3FUL
  283. #define PORT1_REMOTE_ATTEN_MASK 0x3FUL
  284. #define PORT1_DEFAULT_ATTEN_MASK 0xFFUL
  285. #define PORT0_PORT_TYPE_SMASK (PORT0_PORT_TYPE_MASK << \
  286. PORT0_PORT_TYPE_SHIFT)
  287. #define PORT0_LOCAL_ATTEN_SMASK (PORT0_LOCAL_ATTEN_MASK << \
  288. PORT0_LOCAL_ATTEN_SHIFT)
  289. #define PORT0_REMOTE_ATTEN_SMASK (PORT0_REMOTE_ATTEN_MASK << \
  290. PORT0_REMOTE_ATTEN_SHIFT)
  291. #define PORT0_DEFAULT_ATTEN_SMASK (PORT0_DEFAULT_ATTEN_MASK << \
  292. PORT0_DEFAULT_ATTEN_SHIFT)
  293. #define PORT1_PORT_TYPE_SMASK (PORT1_PORT_TYPE_MASK << \
  294. PORT1_PORT_TYPE_SHIFT)
  295. #define PORT1_LOCAL_ATTEN_SMASK (PORT1_LOCAL_ATTEN_MASK << \
  296. PORT1_LOCAL_ATTEN_SHIFT)
  297. #define PORT1_REMOTE_ATTEN_SMASK (PORT1_REMOTE_ATTEN_MASK << \
  298. PORT1_REMOTE_ATTEN_SHIFT)
  299. #define PORT1_DEFAULT_ATTEN_SMASK (PORT1_DEFAULT_ATTEN_MASK << \
  300. PORT1_DEFAULT_ATTEN_SHIFT)
  301. #define QSFP_MAX_POWER_SHIFT 0
  302. #define TX_NO_EQ_SHIFT 4
  303. #define TX_EQ_SHIFT 25
  304. #define RX_SHIFT 46
  305. #define QSFP_MAX_POWER_MASK 0xFUL
  306. #define TX_NO_EQ_MASK 0x1FFFFFUL
  307. #define TX_EQ_MASK 0x1FFFFFUL
  308. #define RX_MASK 0xFFFFUL
  309. #define QSFP_MAX_POWER_SMASK (QSFP_MAX_POWER_MASK << \
  310. QSFP_MAX_POWER_SHIFT)
  311. #define TX_NO_EQ_SMASK (TX_NO_EQ_MASK << TX_NO_EQ_SHIFT)
  312. #define TX_EQ_SMASK (TX_EQ_MASK << TX_EQ_SHIFT)
  313. #define RX_SMASK (RX_MASK << RX_SHIFT)
  314. #define TX_PRECUR_SHIFT 0
  315. #define TX_ATTN_SHIFT 4
  316. #define QSFP_TX_CDR_APPLY_SHIFT 9
  317. #define QSFP_TX_EQ_APPLY_SHIFT 10
  318. #define QSFP_TX_CDR_SHIFT 11
  319. #define QSFP_TX_EQ_SHIFT 12
  320. #define TX_POSTCUR_SHIFT 16
  321. #define TX_PRECUR_MASK 0xFUL
  322. #define TX_ATTN_MASK 0x1FUL
  323. #define QSFP_TX_CDR_APPLY_MASK 0x1UL
  324. #define QSFP_TX_EQ_APPLY_MASK 0x1UL
  325. #define QSFP_TX_CDR_MASK 0x1UL
  326. #define QSFP_TX_EQ_MASK 0xFUL
  327. #define TX_POSTCUR_MASK 0x1FUL
  328. #define TX_PRECUR_SMASK (TX_PRECUR_MASK << TX_PRECUR_SHIFT)
  329. #define TX_ATTN_SMASK (TX_ATTN_MASK << TX_ATTN_SHIFT)
  330. #define QSFP_TX_CDR_APPLY_SMASK (QSFP_TX_CDR_APPLY_MASK << \
  331. QSFP_TX_CDR_APPLY_SHIFT)
  332. #define QSFP_TX_EQ_APPLY_SMASK (QSFP_TX_EQ_APPLY_MASK << \
  333. QSFP_TX_EQ_APPLY_SHIFT)
  334. #define QSFP_TX_CDR_SMASK (QSFP_TX_CDR_MASK << QSFP_TX_CDR_SHIFT)
  335. #define QSFP_TX_EQ_SMASK (QSFP_TX_EQ_MASK << QSFP_TX_EQ_SHIFT)
  336. #define TX_POSTCUR_SMASK (TX_POSTCUR_MASK << TX_POSTCUR_SHIFT)
  337. #define QSFP_RX_CDR_APPLY_SHIFT 0
  338. #define QSFP_RX_EMP_APPLY_SHIFT 1
  339. #define QSFP_RX_AMP_APPLY_SHIFT 2
  340. #define QSFP_RX_CDR_SHIFT 3
  341. #define QSFP_RX_EMP_SHIFT 4
  342. #define QSFP_RX_AMP_SHIFT 8
  343. #define QSFP_RX_CDR_APPLY_MASK 0x1UL
  344. #define QSFP_RX_EMP_APPLY_MASK 0x1UL
  345. #define QSFP_RX_AMP_APPLY_MASK 0x1UL
  346. #define QSFP_RX_CDR_MASK 0x1UL
  347. #define QSFP_RX_EMP_MASK 0xFUL
  348. #define QSFP_RX_AMP_MASK 0x3UL
  349. #define QSFP_RX_CDR_APPLY_SMASK (QSFP_RX_CDR_APPLY_MASK << \
  350. QSFP_RX_CDR_APPLY_SHIFT)
  351. #define QSFP_RX_EMP_APPLY_SMASK (QSFP_RX_EMP_APPLY_MASK << \
  352. QSFP_RX_EMP_APPLY_SHIFT)
  353. #define QSFP_RX_AMP_APPLY_SMASK (QSFP_RX_AMP_APPLY_MASK << \
  354. QSFP_RX_AMP_APPLY_SHIFT)
  355. #define QSFP_RX_CDR_SMASK (QSFP_RX_CDR_MASK << QSFP_RX_CDR_SHIFT)
  356. #define QSFP_RX_EMP_SMASK (QSFP_RX_EMP_MASK << QSFP_RX_EMP_SHIFT)
  357. #define QSFP_RX_AMP_SMASK (QSFP_RX_AMP_MASK << QSFP_RX_AMP_SHIFT)
  358. #define BITMAP_VERSION 1
  359. #define BITMAP_VERSION_SHIFT 44
  360. #define BITMAP_VERSION_MASK 0xFUL
  361. #define BITMAP_VERSION_SMASK (BITMAP_VERSION_MASK << \
  362. BITMAP_VERSION_SHIFT)
  363. #define CHECKSUM_SHIFT 48
  364. #define CHECKSUM_MASK 0xFFFFUL
  365. #define CHECKSUM_SMASK (CHECKSUM_MASK << CHECKSUM_SHIFT)
  366. /* platform.c */
  367. void get_platform_config(struct hfi1_devdata *dd);
  368. void free_platform_config(struct hfi1_devdata *dd);
  369. void get_port_type(struct hfi1_pportdata *ppd);
  370. int set_qsfp_tx(struct hfi1_pportdata *ppd, int on);
  371. void tune_serdes(struct hfi1_pportdata *ppd);
  372. #endif /*__PLATFORM_H*/