octeon_config.h 15 KB

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