octeon_config.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  1. /**********************************************************************
  2. * Author: Cavium, Inc.
  3. *
  4. * Contact: support@cavium.com
  5. * Please include "LiquidIO" in the subject.
  6. *
  7. * Copyright (c) 2003-2016 Cavium, Inc.
  8. *
  9. * This file is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License, Version 2, as
  11. * published by the Free Software Foundation.
  12. *
  13. * This file is distributed in the hope that it will be useful, but
  14. * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
  15. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
  16. * NONINFRINGEMENT. See the GNU General Public License for more details.
  17. ***********************************************************************/
  18. /*! \file octeon_config.h
  19. * \brief Host Driver: Configuration data structures for the host driver.
  20. */
  21. #ifndef __OCTEON_CONFIG_H__
  22. #define __OCTEON_CONFIG_H__
  23. /*--------------------------CONFIG VALUES------------------------*/
  24. /* The following macros affect the way the driver data structures
  25. * are generated for Octeon devices.
  26. * They can be modified.
  27. */
  28. /* Maximum octeon devices defined as MAX_OCTEON_NICIF to support
  29. * multiple(<= MAX_OCTEON_NICIF) Miniports
  30. */
  31. #define MAX_OCTEON_NICIF 128
  32. #define MAX_OCTEON_DEVICES MAX_OCTEON_NICIF
  33. #define MAX_OCTEON_LINKS MAX_OCTEON_NICIF
  34. #define MAX_OCTEON_MULTICAST_ADDR 32
  35. /* CN6xxx IQ configuration macros */
  36. #define CN6XXX_MAX_INPUT_QUEUES 32
  37. #define CN6XXX_MAX_IQ_DESCRIPTORS 2048
  38. #define CN6XXX_DB_MIN 1
  39. #define CN6XXX_DB_MAX 8
  40. #define CN6XXX_DB_TIMEOUT 1
  41. /* CN6xxx OQ configuration macros */
  42. #define CN6XXX_MAX_OUTPUT_QUEUES 32
  43. #define CN6XXX_MAX_OQ_DESCRIPTORS 2048
  44. #define CN6XXX_OQ_BUF_SIZE 1664
  45. #define CN6XXX_OQ_PKTSPER_INTR ((CN6XXX_MAX_OQ_DESCRIPTORS < 512) ? \
  46. (CN6XXX_MAX_OQ_DESCRIPTORS / 4) : 128)
  47. #define CN6XXX_OQ_REFIL_THRESHOLD ((CN6XXX_MAX_OQ_DESCRIPTORS < 512) ? \
  48. (CN6XXX_MAX_OQ_DESCRIPTORS / 4) : 128)
  49. #define CN6XXX_OQ_INTR_PKT 64
  50. #define CN6XXX_OQ_INTR_TIME 100
  51. #define DEFAULT_NUM_NIC_PORTS_66XX 2
  52. #define DEFAULT_NUM_NIC_PORTS_68XX 4
  53. #define DEFAULT_NUM_NIC_PORTS_68XX_210NV 2
  54. /* CN23xx IQ configuration macros */
  55. #define CN23XX_MAX_VFS_PER_PF_PASS_1_0 8
  56. #define CN23XX_MAX_VFS_PER_PF_PASS_1_1 31
  57. #define CN23XX_MAX_VFS_PER_PF 63
  58. #define CN23XX_MAX_RINGS_PER_VF 8
  59. #define CN23XX_MAX_RINGS_PER_PF_PASS_1_0 12
  60. #define CN23XX_MAX_RINGS_PER_PF_PASS_1_1 32
  61. #define CN23XX_MAX_RINGS_PER_PF 64
  62. #define CN23XX_MAX_RINGS_PER_VF 8
  63. #define CN23XX_MAX_INPUT_QUEUES CN23XX_MAX_RINGS_PER_PF
  64. #define CN23XX_MAX_IQ_DESCRIPTORS 2048
  65. #define CN23XX_DEFAULT_IQ_DESCRIPTORS 512
  66. #define CN23XX_MIN_IQ_DESCRIPTORS 128
  67. #define CN23XX_DB_MIN 1
  68. #define CN23XX_DB_MAX 8
  69. #define CN23XX_DB_TIMEOUT 1
  70. #define CN23XX_MAX_OUTPUT_QUEUES CN23XX_MAX_RINGS_PER_PF
  71. #define CN23XX_MAX_OQ_DESCRIPTORS 2048
  72. #define CN23XX_DEFAULT_OQ_DESCRIPTORS 512
  73. #define CN23XX_MIN_OQ_DESCRIPTORS 128
  74. #define CN23XX_OQ_BUF_SIZE 1664
  75. #define CN23XX_OQ_PKTSPER_INTR 128
  76. /*#define CAVIUM_ONLY_CN23XX_RX_PERF*/
  77. #define CN23XX_OQ_REFIL_THRESHOLD 16
  78. #define CN23XX_OQ_INTR_PKT 64
  79. #define CN23XX_OQ_INTR_TIME 100
  80. #define DEFAULT_NUM_NIC_PORTS_23XX 1
  81. #define CN23XX_CFG_IO_QUEUES CN23XX_MAX_RINGS_PER_PF
  82. /* PEMs count */
  83. #define CN23XX_MAX_MACS 4
  84. #define CN23XX_DEF_IQ_INTR_THRESHOLD 32
  85. #define CN23XX_DEF_IQ_INTR_BYTE_THRESHOLD (64 * 1024)
  86. /* common OCTEON configuration macros */
  87. #define CN6XXX_CFG_IO_QUEUES 32
  88. #define OCTEON_32BYTE_INSTR 32
  89. #define OCTEON_64BYTE_INSTR 64
  90. #define OCTEON_MAX_BASE_IOQ 4
  91. #define OCTEON_DMA_INTR_PKT 64
  92. #define OCTEON_DMA_INTR_TIME 1000
  93. #define MAX_TXQS_PER_INTF 8
  94. #define MAX_RXQS_PER_INTF 8
  95. #define DEF_TXQS_PER_INTF 4
  96. #define DEF_RXQS_PER_INTF 4
  97. #define INVALID_IOQ_NO 0xff
  98. #define DEFAULT_POW_GRP 0
  99. /* Macros to get octeon config params */
  100. #define CFG_GET_IQ_CFG(cfg) ((cfg)->iq)
  101. #define CFG_GET_IQ_MAX_Q(cfg) ((cfg)->iq.max_iqs)
  102. #define CFG_GET_IQ_PENDING_LIST_SIZE(cfg) ((cfg)->iq.pending_list_size)
  103. #define CFG_GET_IQ_INSTR_TYPE(cfg) ((cfg)->iq.instr_type)
  104. #define CFG_GET_IQ_DB_MIN(cfg) ((cfg)->iq.db_min)
  105. #define CFG_GET_IQ_DB_TIMEOUT(cfg) ((cfg)->iq.db_timeout)
  106. #define CFG_GET_IQ_INTR_PKT(cfg) ((cfg)->iq.iq_intr_pkt)
  107. #define CFG_SET_IQ_INTR_PKT(cfg, val) (cfg)->iq.iq_intr_pkt = val
  108. #define CFG_GET_OQ_MAX_Q(cfg) ((cfg)->oq.max_oqs)
  109. #define CFG_GET_OQ_PKTS_PER_INTR(cfg) ((cfg)->oq.pkts_per_intr)
  110. #define CFG_GET_OQ_REFILL_THRESHOLD(cfg) ((cfg)->oq.refill_threshold)
  111. #define CFG_GET_OQ_INTR_PKT(cfg) ((cfg)->oq.oq_intr_pkt)
  112. #define CFG_GET_OQ_INTR_TIME(cfg) ((cfg)->oq.oq_intr_time)
  113. #define CFG_SET_OQ_INTR_PKT(cfg, val) (cfg)->oq.oq_intr_pkt = val
  114. #define CFG_SET_OQ_INTR_TIME(cfg, val) (cfg)->oq.oq_intr_time = val
  115. #define CFG_GET_DMA_INTR_PKT(cfg) ((cfg)->dma.dma_intr_pkt)
  116. #define CFG_GET_DMA_INTR_TIME(cfg) ((cfg)->dma.dma_intr_time)
  117. #define CFG_GET_NUM_NIC_PORTS(cfg) ((cfg)->num_nic_ports)
  118. #define CFG_GET_NUM_DEF_TX_DESCS(cfg) ((cfg)->num_def_tx_descs)
  119. #define CFG_GET_NUM_DEF_RX_DESCS(cfg) ((cfg)->num_def_rx_descs)
  120. #define CFG_GET_DEF_RX_BUF_SIZE(cfg) ((cfg)->def_rx_buf_size)
  121. #define CFG_GET_MAX_TXQS_NIC_IF(cfg, idx) \
  122. ((cfg)->nic_if_cfg[idx].max_txqs)
  123. #define CFG_GET_NUM_TXQS_NIC_IF(cfg, idx) \
  124. ((cfg)->nic_if_cfg[idx].num_txqs)
  125. #define CFG_GET_MAX_RXQS_NIC_IF(cfg, idx) \
  126. ((cfg)->nic_if_cfg[idx].max_rxqs)
  127. #define CFG_GET_NUM_RXQS_NIC_IF(cfg, idx) \
  128. ((cfg)->nic_if_cfg[idx].num_rxqs)
  129. #define CFG_GET_NUM_RX_DESCS_NIC_IF(cfg, idx) \
  130. ((cfg)->nic_if_cfg[idx].num_rx_descs)
  131. #define CFG_GET_NUM_TX_DESCS_NIC_IF(cfg, idx) \
  132. ((cfg)->nic_if_cfg[idx].num_tx_descs)
  133. #define CFG_GET_NUM_RX_BUF_SIZE_NIC_IF(cfg, idx) \
  134. ((cfg)->nic_if_cfg[idx].rx_buf_size)
  135. #define CFG_GET_BASE_QUE_NIC_IF(cfg, idx) \
  136. ((cfg)->nic_if_cfg[idx].base_queue)
  137. #define CFG_GET_GMXID_NIC_IF(cfg, idx) \
  138. ((cfg)->nic_if_cfg[idx].gmx_port_id)
  139. #define CFG_GET_CTRL_Q_GRP(cfg) ((cfg)->misc.ctrlq_grp)
  140. #define CFG_GET_HOST_LINK_QUERY_INTERVAL(cfg) \
  141. ((cfg)->misc.host_link_query_interval)
  142. #define CFG_GET_OCT_LINK_QUERY_INTERVAL(cfg) \
  143. ((cfg)->misc.oct_link_query_interval)
  144. #define CFG_GET_IS_SLI_BP_ON(cfg) ((cfg)->misc.enable_sli_oq_bp)
  145. #define CFG_SET_NUM_RX_DESCS_NIC_IF(cfg, idx, value) \
  146. ((cfg)->nic_if_cfg[idx].num_rx_descs = value)
  147. #define CFG_SET_NUM_TX_DESCS_NIC_IF(cfg, idx, value) \
  148. ((cfg)->nic_if_cfg[idx].num_tx_descs = value)
  149. /* Max IOQs per OCTEON Link */
  150. #define MAX_IOQS_PER_NICIF 64
  151. enum lio_card_type {
  152. LIO_210SV = 0, /* Two port, 66xx */
  153. LIO_210NV, /* Two port, 68xx */
  154. LIO_410NV, /* Four port, 68xx */
  155. LIO_23XX /* 23xx */
  156. };
  157. #define LIO_210SV_NAME "210sv"
  158. #define LIO_210NV_NAME "210nv"
  159. #define LIO_410NV_NAME "410nv"
  160. #define LIO_23XX_NAME "23xx"
  161. /** Structure to define the configuration attributes for each Input queue.
  162. * Applicable to all Octeon processors
  163. **/
  164. struct octeon_iq_config {
  165. #ifdef __BIG_ENDIAN_BITFIELD
  166. u64 reserved:16;
  167. /** Tx interrupt packets. Applicable to 23xx only */
  168. u64 iq_intr_pkt:16;
  169. /** Minimum ticks to wait before checking for pending instructions. */
  170. u64 db_timeout:16;
  171. /** Minimum number of commands pending to be posted to Octeon
  172. * before driver hits the Input queue doorbell.
  173. */
  174. u64 db_min:8;
  175. /** Command size - 32 or 64 bytes */
  176. u64 instr_type:32;
  177. /** Pending list size (usually set to the sum of the size of all Input
  178. * queues)
  179. */
  180. u64 pending_list_size:32;
  181. /* Max number of IQs available */
  182. u64 max_iqs:8;
  183. #else
  184. /* Max number of IQs available */
  185. u64 max_iqs:8;
  186. /** Pending list size (usually set to the sum of the size of all Input
  187. * queues)
  188. */
  189. u64 pending_list_size:32;
  190. /** Command size - 32 or 64 bytes */
  191. u64 instr_type:32;
  192. /** Minimum number of commands pending to be posted to Octeon
  193. * before driver hits the Input queue doorbell.
  194. */
  195. u64 db_min:8;
  196. /** Minimum ticks to wait before checking for pending instructions. */
  197. u64 db_timeout:16;
  198. /** Tx interrupt packets. Applicable to 23xx only */
  199. u64 iq_intr_pkt:16;
  200. u64 reserved:16;
  201. #endif
  202. };
  203. /** Structure to define the configuration attributes for each Output queue.
  204. * Applicable to all Octeon processors
  205. **/
  206. struct octeon_oq_config {
  207. #ifdef __BIG_ENDIAN_BITFIELD
  208. u64 reserved:16;
  209. u64 pkts_per_intr:16;
  210. /** Interrupt Coalescing (Time Interval). Octeon will interrupt the
  211. * host if atleast one packet was sent in the time interval specified
  212. * by this field. The driver uses time interval interrupt coalescing
  213. * by default. The time is specified in microseconds.
  214. */
  215. u64 oq_intr_time:16;
  216. /** Interrupt Coalescing (Packet Count). Octeon will interrupt the host
  217. * only if it sent as many packets as specified by this field.
  218. * The driver
  219. * usually does not use packet count interrupt coalescing.
  220. */
  221. u64 oq_intr_pkt:16;
  222. /** The number of buffers that were consumed during packet processing by
  223. * the driver on this Output queue before the driver attempts to
  224. * replenish
  225. * the descriptor ring with new buffers.
  226. */
  227. u64 refill_threshold:16;
  228. /* Max number of OQs available */
  229. u64 max_oqs:8;
  230. #else
  231. /* Max number of OQs available */
  232. u64 max_oqs:8;
  233. /** The number of buffers that were consumed during packet processing by
  234. * the driver on this Output queue before the driver attempts to
  235. * replenish
  236. * the descriptor ring with new buffers.
  237. */
  238. u64 refill_threshold:16;
  239. /** Interrupt Coalescing (Packet Count). Octeon will interrupt the host
  240. * only if it sent as many packets as specified by this field.
  241. * The driver
  242. * usually does not use packet count interrupt coalescing.
  243. */
  244. u64 oq_intr_pkt:16;
  245. /** Interrupt Coalescing (Time Interval). Octeon will interrupt the
  246. * host if atleast one packet was sent in the time interval specified
  247. * by this field. The driver uses time interval interrupt coalescing
  248. * by default. The time is specified in microseconds.
  249. */
  250. u64 oq_intr_time:16;
  251. u64 pkts_per_intr:16;
  252. u64 reserved:16;
  253. #endif
  254. };
  255. /** This structure conatins the NIC link configuration attributes,
  256. * common for all the OCTEON Modles.
  257. */
  258. struct octeon_nic_if_config {
  259. #ifdef __BIG_ENDIAN_BITFIELD
  260. u64 reserved:56;
  261. u64 base_queue:16;
  262. u64 gmx_port_id:8;
  263. /* SKB size, We need not change buf size even for Jumbo frames.
  264. * Octeon can send jumbo frames in 4 consecutive descriptors,
  265. */
  266. u64 rx_buf_size:16;
  267. /* Num of desc for tx rings */
  268. u64 num_tx_descs:16;
  269. /* Num of desc for rx rings */
  270. u64 num_rx_descs:16;
  271. /* Actual configured value. Range could be: 1...max_rxqs */
  272. u64 num_rxqs:16;
  273. /* Max Rxqs: Half for each of the two ports :max_oq/2 */
  274. u64 max_rxqs:16;
  275. /* Actual configured value. Range could be: 1...max_txqs */
  276. u64 num_txqs:16;
  277. /* Max Txqs: Half for each of the two ports :max_iq/2 */
  278. u64 max_txqs:16;
  279. #else
  280. /* Max Txqs: Half for each of the two ports :max_iq/2 */
  281. u64 max_txqs:16;
  282. /* Actual configured value. Range could be: 1...max_txqs */
  283. u64 num_txqs:16;
  284. /* Max Rxqs: Half for each of the two ports :max_oq/2 */
  285. u64 max_rxqs:16;
  286. /* Actual configured value. Range could be: 1...max_rxqs */
  287. u64 num_rxqs:16;
  288. /* Num of desc for rx rings */
  289. u64 num_rx_descs:16;
  290. /* Num of desc for tx rings */
  291. u64 num_tx_descs:16;
  292. /* SKB size, We need not change buf size even for Jumbo frames.
  293. * Octeon can send jumbo frames in 4 consecutive descriptors,
  294. */
  295. u64 rx_buf_size:16;
  296. u64 gmx_port_id:8;
  297. u64 base_queue:16;
  298. u64 reserved:56;
  299. #endif
  300. };
  301. /** Structure to define the configuration attributes for meta data.
  302. * Applicable to all Octeon processors.
  303. */
  304. struct octeon_misc_config {
  305. #ifdef __BIG_ENDIAN_BITFIELD
  306. /** Host link status polling period */
  307. u64 host_link_query_interval:32;
  308. /** Oct link status polling period */
  309. u64 oct_link_query_interval:32;
  310. u64 enable_sli_oq_bp:1;
  311. /** Control IQ Group */
  312. u64 ctrlq_grp:4;
  313. #else
  314. /** Control IQ Group */
  315. u64 ctrlq_grp:4;
  316. /** BP for SLI OQ */
  317. u64 enable_sli_oq_bp:1;
  318. /** Host link status polling period */
  319. u64 oct_link_query_interval:32;
  320. /** Oct link status polling period */
  321. u64 host_link_query_interval:32;
  322. #endif
  323. };
  324. /** Structure to define the configuration for all OCTEON processors. */
  325. struct octeon_config {
  326. u16 card_type;
  327. char *card_name;
  328. /** Input Queue attributes. */
  329. struct octeon_iq_config iq;
  330. /** Output Queue attributes. */
  331. struct octeon_oq_config oq;
  332. /** NIC Port Configuration */
  333. struct octeon_nic_if_config nic_if_cfg[MAX_OCTEON_NICIF];
  334. /** Miscellaneous attributes */
  335. struct octeon_misc_config misc;
  336. int num_nic_ports;
  337. int num_def_tx_descs;
  338. /* Num of desc for rx rings */
  339. int num_def_rx_descs;
  340. int def_rx_buf_size;
  341. };
  342. /* The following config values are fixed and should not be modified. */
  343. #define BAR1_INDEX_DYNAMIC_MAP 2
  344. #define BAR1_INDEX_STATIC_MAP 15
  345. #define OCTEON_BAR1_ENTRY_SIZE (4 * 1024 * 1024)
  346. #define MAX_BAR1_IOREMAP_SIZE (16 * OCTEON_BAR1_ENTRY_SIZE)
  347. /* Response lists - 1 ordered, 1 unordered-blocking, 1 unordered-nonblocking
  348. * NoResponse Lists are now maintained with each IQ. (Dec' 2007).
  349. */
  350. #define MAX_RESPONSE_LISTS 4
  351. /* Opcode hash bits. The opcode is hashed on the lower 6-bits to lookup the
  352. * dispatch table.
  353. */
  354. #define OPCODE_MASK_BITS 6
  355. /* Mask for the 6-bit lookup hash */
  356. #define OCTEON_OPCODE_MASK 0x3f
  357. /* Size of the dispatch table. The 6-bit hash can index into 2^6 entries */
  358. #define DISPATCH_LIST_SIZE BIT(OPCODE_MASK_BITS)
  359. /* Maximum number of Octeon Instruction (command) queues */
  360. #define MAX_OCTEON_INSTR_QUEUES(oct) \
  361. (OCTEON_CN23XX_PF(oct) ? CN23XX_MAX_INPUT_QUEUES : \
  362. CN6XXX_MAX_INPUT_QUEUES)
  363. /* Maximum number of Octeon Instruction (command) queues */
  364. #define MAX_OCTEON_OUTPUT_QUEUES(oct) \
  365. (OCTEON_CN23XX_PF(oct) ? CN23XX_MAX_OUTPUT_QUEUES : \
  366. CN6XXX_MAX_OUTPUT_QUEUES)
  367. #define MAX_POSSIBLE_OCTEON_INSTR_QUEUES CN23XX_MAX_INPUT_QUEUES
  368. #define MAX_POSSIBLE_OCTEON_OUTPUT_QUEUES CN23XX_MAX_OUTPUT_QUEUES
  369. #define MAX_POSSIBLE_VFS 64
  370. #endif /* __OCTEON_CONFIG_H__ */