1 /**********************************************************************
4 * Contact: support@cavium.com
5 * Please include "LiquidIO" in the subject.
7 * Copyright (c) 2003-2015 Cavium, Inc.
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.
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
19 * This file may also be available under a different license from Cavium.
20 * Contact Cavium, Inc. for more information
21 **********************************************************************/
23 /*! \file octeon_config.h
24 * \brief Host Driver: Configuration data structures for the host driver.
27 #ifndef __OCTEON_CONFIG_H__
28 #define __OCTEON_CONFIG_H__
30 /*--------------------------CONFIG VALUES------------------------*/
32 /* The following macros affect the way the driver data structures
33 * are generated for Octeon devices.
34 * They can be modified.
37 /* Maximum octeon devices defined as MAX_OCTEON_NICIF to support
38 * multiple(<= MAX_OCTEON_NICIF) Miniports
40 #define MAX_OCTEON_NICIF 128
41 #define MAX_OCTEON_DEVICES MAX_OCTEON_NICIF
42 #define MAX_OCTEON_LINKS MAX_OCTEON_NICIF
43 #define MAX_OCTEON_MULTICAST_ADDR 32
45 /* CN6xxx IQ configuration macros */
46 #define CN6XXX_MAX_INPUT_QUEUES 32
47 #define CN6XXX_MAX_IQ_DESCRIPTORS 2048
48 #define CN6XXX_DB_MIN 1
49 #define CN6XXX_DB_MAX 8
50 #define CN6XXX_DB_TIMEOUT 1
52 /* CN6xxx OQ configuration macros */
53 #define CN6XXX_MAX_OUTPUT_QUEUES 32
54 #define CN6XXX_MAX_OQ_DESCRIPTORS 2048
55 #define CN6XXX_OQ_BUF_SIZE 1536
56 #define CN6XXX_OQ_PKTSPER_INTR ((CN6XXX_MAX_OQ_DESCRIPTORS < 512) ? \
57 (CN6XXX_MAX_OQ_DESCRIPTORS / 4) : 128)
58 #define CN6XXX_OQ_REFIL_THRESHOLD ((CN6XXX_MAX_OQ_DESCRIPTORS < 512) ? \
59 (CN6XXX_MAX_OQ_DESCRIPTORS / 4) : 128)
61 #define CN6XXX_OQ_INTR_PKT 64
62 #define CN6XXX_OQ_INTR_TIME 100
63 #define DEFAULT_NUM_NIC_PORTS_66XX 2
64 #define DEFAULT_NUM_NIC_PORTS_68XX 4
65 #define DEFAULT_NUM_NIC_PORTS_68XX_210NV 2
67 /* common OCTEON configuration macros */
68 #define CN6XXX_CFG_IO_QUEUES 32
69 #define OCTEON_32BYTE_INSTR 32
70 #define OCTEON_64BYTE_INSTR 64
71 #define OCTEON_MAX_BASE_IOQ 4
72 #define OCTEON_OQ_BUFPTR_MODE 0
73 #define OCTEON_OQ_INFOPTR_MODE 1
75 #define OCTEON_DMA_INTR_PKT 64
76 #define OCTEON_DMA_INTR_TIME 1000
78 #define MAX_TXQS_PER_INTF 8
79 #define MAX_RXQS_PER_INTF 8
80 #define DEF_TXQS_PER_INTF 4
81 #define DEF_RXQS_PER_INTF 4
83 #define INVALID_IOQ_NO 0xff
85 #define DEFAULT_POW_GRP 0
87 /* Macros to get octeon config params */
88 #define CFG_GET_IQ_CFG(cfg) ((cfg)->iq)
89 #define CFG_GET_IQ_MAX_Q(cfg) ((cfg)->iq.max_iqs)
90 #define CFG_GET_IQ_PENDING_LIST_SIZE(cfg) ((cfg)->iq.pending_list_size)
91 #define CFG_GET_IQ_INSTR_TYPE(cfg) ((cfg)->iq.instr_type)
92 #define CFG_GET_IQ_DB_MIN(cfg) ((cfg)->iq.db_min)
93 #define CFG_GET_IQ_DB_TIMEOUT(cfg) ((cfg)->iq.db_timeout)
95 #define CFG_GET_OQ_MAX_Q(cfg) ((cfg)->oq.max_oqs)
96 #define CFG_GET_OQ_INFO_PTR(cfg) ((cfg)->oq.info_ptr)
97 #define CFG_GET_OQ_PKTS_PER_INTR(cfg) ((cfg)->oq.pkts_per_intr)
98 #define CFG_GET_OQ_REFILL_THRESHOLD(cfg) ((cfg)->oq.refill_threshold)
99 #define CFG_GET_OQ_INTR_PKT(cfg) ((cfg)->oq.oq_intr_pkt)
100 #define CFG_GET_OQ_INTR_TIME(cfg) ((cfg)->oq.oq_intr_time)
101 #define CFG_SET_OQ_INTR_PKT(cfg, val) (cfg)->oq.oq_intr_pkt = val
102 #define CFG_SET_OQ_INTR_TIME(cfg, val) (cfg)->oq.oq_intr_time = val
104 #define CFG_GET_DMA_INTR_PKT(cfg) ((cfg)->dma.dma_intr_pkt)
105 #define CFG_GET_DMA_INTR_TIME(cfg) ((cfg)->dma.dma_intr_time)
106 #define CFG_GET_NUM_NIC_PORTS(cfg) ((cfg)->num_nic_ports)
107 #define CFG_GET_NUM_DEF_TX_DESCS(cfg) ((cfg)->num_def_tx_descs)
108 #define CFG_GET_NUM_DEF_RX_DESCS(cfg) ((cfg)->num_def_rx_descs)
109 #define CFG_GET_DEF_RX_BUF_SIZE(cfg) ((cfg)->def_rx_buf_size)
111 #define CFG_GET_MAX_TXQS_NIC_IF(cfg, idx) \
112 ((cfg)->nic_if_cfg[idx].max_txqs)
113 #define CFG_GET_NUM_TXQS_NIC_IF(cfg, idx) \
114 ((cfg)->nic_if_cfg[idx].num_txqs)
115 #define CFG_GET_MAX_RXQS_NIC_IF(cfg, idx) \
116 ((cfg)->nic_if_cfg[idx].max_rxqs)
117 #define CFG_GET_NUM_RXQS_NIC_IF(cfg, idx) \
118 ((cfg)->nic_if_cfg[idx].num_rxqs)
119 #define CFG_GET_NUM_RX_DESCS_NIC_IF(cfg, idx) \
120 ((cfg)->nic_if_cfg[idx].num_rx_descs)
121 #define CFG_GET_NUM_TX_DESCS_NIC_IF(cfg, idx) \
122 ((cfg)->nic_if_cfg[idx].num_tx_descs)
123 #define CFG_GET_NUM_RX_BUF_SIZE_NIC_IF(cfg, idx) \
124 ((cfg)->nic_if_cfg[idx].rx_buf_size)
125 #define CFG_GET_BASE_QUE_NIC_IF(cfg, idx) \
126 ((cfg)->nic_if_cfg[idx].base_queue)
127 #define CFG_GET_GMXID_NIC_IF(cfg, idx) \
128 ((cfg)->nic_if_cfg[idx].gmx_port_id)
130 #define CFG_GET_CTRL_Q_GRP(cfg) ((cfg)->misc.ctrlq_grp)
131 #define CFG_GET_HOST_LINK_QUERY_INTERVAL(cfg) \
132 ((cfg)->misc.host_link_query_interval)
133 #define CFG_GET_OCT_LINK_QUERY_INTERVAL(cfg) \
134 ((cfg)->misc.oct_link_query_interval)
135 #define CFG_GET_IS_SLI_BP_ON(cfg) ((cfg)->misc.enable_sli_oq_bp)
137 /* Max IOQs per OCTEON Link */
138 #define MAX_IOQS_PER_NICIF 64
141 LIO_210SV
= 0, /* Two port, 66xx */
142 LIO_210NV
, /* Two port, 68xx */
143 LIO_410NV
/* Four port, 68xx */
146 #define LIO_210SV_NAME "210sv"
147 #define LIO_210NV_NAME "210nv"
148 #define LIO_410NV_NAME "410nv"
150 /** Structure to define the configuration attributes for each Input queue.
151 * Applicable to all Octeon processors
153 struct octeon_iq_config
{
154 #ifdef __BIG_ENDIAN_BITFIELD
157 /** Minimum ticks to wait before checking for pending instructions. */
160 /** Minimum number of commands pending to be posted to Octeon
161 * before driver hits the Input queue doorbell.
165 /** Command size - 32 or 64 bytes */
168 /** Pending list size (usually set to the sum of the size of all Input
171 u64 pending_list_size
:32;
173 /* Max number of IQs available */
176 /* Max number of IQs available */
179 /** Pending list size (usually set to the sum of the size of all Input
182 u64 pending_list_size
:32;
184 /** Command size - 32 or 64 bytes */
187 /** Minimum number of commands pending to be posted to Octeon
188 * before driver hits the Input queue doorbell.
192 /** Minimum ticks to wait before checking for pending instructions. */
199 /** Structure to define the configuration attributes for each Output queue.
200 * Applicable to all Octeon processors
202 struct octeon_oq_config
{
203 #ifdef __BIG_ENDIAN_BITFIELD
206 u64 pkts_per_intr
:16;
208 /** Interrupt Coalescing (Time Interval). Octeon will interrupt the
209 * host if atleast one packet was sent in the time interval specified
210 * by this field. The driver uses time interval interrupt coalescing
211 * by default. The time is specified in microseconds.
215 /** Interrupt Coalescing (Packet Count). Octeon will interrupt the host
216 * only if it sent as many packets as specified by this field.
218 * usually does not use packet count interrupt coalescing.
222 /** The number of buffers that were consumed during packet processing by
223 * the driver on this Output queue before the driver attempts to
225 * the descriptor ring with new buffers.
227 u64 refill_threshold
:16;
229 /** If set, the Output queue uses info-pointer mode. (Default: 1) */
232 /* Max number of OQs available */
236 /* Max number of OQs available */
239 /** If set, the Output queue uses info-pointer mode. (Default: 1) */
242 /** The number of buffers that were consumed during packet processing by
243 * the driver on this Output queue before the driver attempts to
245 * the descriptor ring with new buffers.
247 u64 refill_threshold
:16;
249 /** Interrupt Coalescing (Packet Count). Octeon will interrupt the host
250 * only if it sent as many packets as specified by this field.
252 * usually does not use packet count interrupt coalescing.
256 /** Interrupt Coalescing (Time Interval). Octeon will interrupt the
257 * host if atleast one packet was sent in the time interval specified
258 * by this field. The driver uses time interval interrupt coalescing
259 * by default. The time is specified in microseconds.
263 u64 pkts_per_intr
:16;
270 /** This structure conatins the NIC link configuration attributes,
271 * common for all the OCTEON Modles.
273 struct octeon_nic_if_config
{
274 #ifdef __BIG_ENDIAN_BITFIELD
281 /* SKB size, We need not change buf size even for Jumbo frames.
282 * Octeon can send jumbo frames in 4 consecutive descriptors,
286 /* Num of desc for tx rings */
289 /* Num of desc for rx rings */
292 /* Actual configured value. Range could be: 1...max_rxqs */
295 /* Max Rxqs: Half for each of the two ports :max_oq/2 */
298 /* Actual configured value. Range could be: 1...max_txqs */
301 /* Max Txqs: Half for each of the two ports :max_iq/2 */
304 /* Max Txqs: Half for each of the two ports :max_iq/2 */
307 /* Actual configured value. Range could be: 1...max_txqs */
310 /* Max Rxqs: Half for each of the two ports :max_oq/2 */
313 /* Actual configured value. Range could be: 1...max_rxqs */
316 /* Num of desc for rx rings */
319 /* Num of desc for tx rings */
322 /* SKB size, We need not change buf size even for Jumbo frames.
323 * Octeon can send jumbo frames in 4 consecutive descriptors,
336 /** Structure to define the configuration attributes for meta data.
337 * Applicable to all Octeon processors.
340 struct octeon_misc_config
{
341 #ifdef __BIG_ENDIAN_BITFIELD
342 /** Host link status polling period */
343 u64 host_link_query_interval
:32;
344 /** Oct link status polling period */
345 u64 oct_link_query_interval
:32;
347 u64 enable_sli_oq_bp
:1;
348 /** Control IQ Group */
351 /** Control IQ Group */
354 u64 enable_sli_oq_bp
:1;
355 /** Host link status polling period */
356 u64 oct_link_query_interval
:32;
357 /** Oct link status polling period */
358 u64 host_link_query_interval
:32;
362 /** Structure to define the configuration for all OCTEON processors. */
363 struct octeon_config
{
367 /** Input Queue attributes. */
368 struct octeon_iq_config iq
;
370 /** Output Queue attributes. */
371 struct octeon_oq_config oq
;
373 /** NIC Port Configuration */
374 struct octeon_nic_if_config nic_if_cfg
[MAX_OCTEON_NICIF
];
376 /** Miscellaneous attributes */
377 struct octeon_misc_config misc
;
381 int num_def_tx_descs
;
383 /* Num of desc for rx rings */
384 int num_def_rx_descs
;
390 /* The following config values are fixed and should not be modified. */
392 /* Maximum address space to be mapped for Octeon's BAR1 index-based access. */
393 #define MAX_BAR1_MAP_INDEX 2
394 #define OCTEON_BAR1_ENTRY_SIZE (4 * 1024 * 1024)
396 /* BAR1 Index 0 to (MAX_BAR1_MAP_INDEX - 1) for normal mapped memory access.
397 * Bar1 register at MAX_BAR1_MAP_INDEX used by driver for dynamic access.
399 #define MAX_BAR1_IOREMAP_SIZE ((MAX_BAR1_MAP_INDEX + 1) * \
400 OCTEON_BAR1_ENTRY_SIZE)
402 /* Response lists - 1 ordered, 1 unordered-blocking, 1 unordered-nonblocking
403 * NoResponse Lists are now maintained with each IQ. (Dec' 2007).
405 #define MAX_RESPONSE_LISTS 4
407 /* Opcode hash bits. The opcode is hashed on the lower 6-bits to lookup the
410 #define OPCODE_MASK_BITS 6
412 /* Mask for the 6-bit lookup hash */
413 #define OCTEON_OPCODE_MASK 0x3f
415 /* Size of the dispatch table. The 6-bit hash can index into 2^6 entries */
416 #define DISPATCH_LIST_SIZE BIT(OPCODE_MASK_BITS)
418 /* Maximum number of Octeon Instruction (command) queues */
419 #define MAX_OCTEON_INSTR_QUEUES(oct) CN6XXX_MAX_INPUT_QUEUES
420 /* Maximum number of Octeon Output queues */
421 #define MAX_OCTEON_OUTPUT_QUEUES(oct) CN6XXX_MAX_OUTPUT_QUEUES
423 #define MAX_POSSIBLE_OCTEON_INSTR_QUEUES CN6XXX_MAX_INPUT_QUEUES
424 #define MAX_POSSIBLE_OCTEON_OUTPUT_QUEUES CN6XXX_MAX_OUTPUT_QUEUES
426 #endif /* __OCTEON_CONFIG_H__ */