octeon_config.h 14 KB

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