blob: 6a81014df597ab4a2371532515b8954c15e67fa5 [file] [log] [blame]
Ramkrishna Vepa40a3a912009-04-01 18:14:40 +00001/******************************************************************************
2 * This software may be used and distributed according to the terms of
3 * the GNU General Public License (GPL), incorporated herein by reference.
4 * Drivers based on or derived from this code fall under the GPL and must
5 * retain the authorship, copyright and license notice. This file is not
6 * a complete program and may only be used when the entire operating
7 * system is licensed under the GPL.
8 * See the file COPYING in this distribution for more information.
9 *
Jon Mason926bd902010-07-15 08:47:26 +000010 * vxge-config.h: Driver for Exar Corp's X3100 Series 10GbE PCIe I/O
Ramkrishna Vepa40a3a912009-04-01 18:14:40 +000011 * Virtualized Server Adapter.
Jon Mason926bd902010-07-15 08:47:26 +000012 * Copyright(c) 2002-2010 Exar Corp.
Ramkrishna Vepa40a3a912009-04-01 18:14:40 +000013 ******************************************************************************/
14#ifndef VXGE_CONFIG_H
15#define VXGE_CONFIG_H
16#include <linux/list.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090017#include <linux/slab.h>
Ramkrishna Vepa40a3a912009-04-01 18:14:40 +000018
19#ifndef VXGE_CACHE_LINE_SIZE
20#define VXGE_CACHE_LINE_SIZE 128
21#endif
22
Ramkrishna Vepa40a3a912009-04-01 18:14:40 +000023#ifndef VXGE_ALIGN
24#define VXGE_ALIGN(adrs, size) \
25 (((size) - (((u64)adrs) & ((size)-1))) & ((size)-1))
26#endif
27
28#define VXGE_HW_MIN_MTU 68
29#define VXGE_HW_MAX_MTU 9600
30#define VXGE_HW_DEFAULT_MTU 1500
31
32#ifdef VXGE_DEBUG_ASSERT
Ramkrishna Vepa40a3a912009-04-01 18:14:40 +000033/**
34 * vxge_assert
35 * @test: C-condition to check
36 * @fmt: printf like format string
37 *
38 * This function implements traditional assert. By default assertions
39 * are enabled. It can be disabled by undefining VXGE_DEBUG_ASSERT macro in
40 * compilation
41 * time.
42 */
Jon Masonddd62722010-11-11 04:25:55 +000043#define vxge_assert(test) BUG_ON(!(test))
Ramkrishna Vepa40a3a912009-04-01 18:14:40 +000044#else
45#define vxge_assert(test)
46#endif /* end of VXGE_DEBUG_ASSERT */
47
48/**
Jon Masonddd62722010-11-11 04:25:55 +000049 * enum vxge_debug_level
Ramkrishna Vepa40a3a912009-04-01 18:14:40 +000050 * @VXGE_NONE: debug disabled
51 * @VXGE_ERR: all errors going to be logged out
52 * @VXGE_TRACE: all errors plus all kind of verbose tracing print outs
53 * going to be logged out. Very noisy.
54 *
55 * This enumeration going to be used to switch between different
56 * debug levels during runtime if DEBUG macro defined during
57 * compilation. If DEBUG macro not defined than code will be
58 * compiled out.
59 */
60enum vxge_debug_level {
61 VXGE_NONE = 0,
62 VXGE_TRACE = 1,
63 VXGE_ERR = 2
64};
65
66#define NULL_VPID 0xFFFFFFFF
67#ifdef CONFIG_VXGE_DEBUG_TRACE_ALL
68#define VXGE_DEBUG_MODULE_MASK 0xffffffff
69#define VXGE_DEBUG_TRACE_MASK 0xffffffff
70#define VXGE_DEBUG_ERR_MASK 0xffffffff
71#define VXGE_DEBUG_MASK 0x000001ff
72#else
73#define VXGE_DEBUG_MODULE_MASK 0x20000000
74#define VXGE_DEBUG_TRACE_MASK 0x20000000
75#define VXGE_DEBUG_ERR_MASK 0x20000000
76#define VXGE_DEBUG_MASK 0x00000001
77#endif
78
79/*
80 * @VXGE_COMPONENT_LL: do debug for vxge link layer module
81 * @VXGE_COMPONENT_ALL: activate debug for all modules with no exceptions
82 *
83 * This enumeration going to be used to distinguish modules
84 * or libraries during compilation and runtime. Makefile must declare
85 * VXGE_DEBUG_MODULE_MASK macro and set it to proper value.
86 */
87#define VXGE_COMPONENT_LL 0x20000000
88#define VXGE_COMPONENT_ALL 0xffffffff
89
90#define VXGE_HW_BASE_INF 100
91#define VXGE_HW_BASE_ERR 200
92#define VXGE_HW_BASE_BADCFG 300
93
94enum vxge_hw_status {
95 VXGE_HW_OK = 0,
96 VXGE_HW_FAIL = 1,
97 VXGE_HW_PENDING = 2,
98 VXGE_HW_COMPLETIONS_REMAIN = 3,
99
100 VXGE_HW_INF_NO_MORE_COMPLETED_DESCRIPTORS = VXGE_HW_BASE_INF + 1,
101 VXGE_HW_INF_OUT_OF_DESCRIPTORS = VXGE_HW_BASE_INF + 2,
102
103 VXGE_HW_ERR_INVALID_HANDLE = VXGE_HW_BASE_ERR + 1,
104 VXGE_HW_ERR_OUT_OF_MEMORY = VXGE_HW_BASE_ERR + 2,
105 VXGE_HW_ERR_VPATH_NOT_AVAILABLE = VXGE_HW_BASE_ERR + 3,
106 VXGE_HW_ERR_VPATH_NOT_OPEN = VXGE_HW_BASE_ERR + 4,
107 VXGE_HW_ERR_WRONG_IRQ = VXGE_HW_BASE_ERR + 5,
108 VXGE_HW_ERR_SWAPPER_CTRL = VXGE_HW_BASE_ERR + 6,
109 VXGE_HW_ERR_INVALID_MTU_SIZE = VXGE_HW_BASE_ERR + 7,
110 VXGE_HW_ERR_INVALID_INDEX = VXGE_HW_BASE_ERR + 8,
111 VXGE_HW_ERR_INVALID_TYPE = VXGE_HW_BASE_ERR + 9,
112 VXGE_HW_ERR_INVALID_OFFSET = VXGE_HW_BASE_ERR + 10,
113 VXGE_HW_ERR_INVALID_DEVICE = VXGE_HW_BASE_ERR + 11,
114 VXGE_HW_ERR_VERSION_CONFLICT = VXGE_HW_BASE_ERR + 12,
115 VXGE_HW_ERR_INVALID_PCI_INFO = VXGE_HW_BASE_ERR + 13,
116 VXGE_HW_ERR_INVALID_TCODE = VXGE_HW_BASE_ERR + 14,
117 VXGE_HW_ERR_INVALID_BLOCK_SIZE = VXGE_HW_BASE_ERR + 15,
118 VXGE_HW_ERR_INVALID_STATE = VXGE_HW_BASE_ERR + 16,
119 VXGE_HW_ERR_PRIVILAGED_OPEARATION = VXGE_HW_BASE_ERR + 17,
120 VXGE_HW_ERR_INVALID_PORT = VXGE_HW_BASE_ERR + 18,
121 VXGE_HW_ERR_FIFO = VXGE_HW_BASE_ERR + 19,
122 VXGE_HW_ERR_VPATH = VXGE_HW_BASE_ERR + 20,
123 VXGE_HW_ERR_CRITICAL = VXGE_HW_BASE_ERR + 21,
124 VXGE_HW_ERR_SLOT_FREEZE = VXGE_HW_BASE_ERR + 22,
125
126 VXGE_HW_BADCFG_RING_INDICATE_MAX_PKTS = VXGE_HW_BASE_BADCFG + 1,
127 VXGE_HW_BADCFG_FIFO_BLOCKS = VXGE_HW_BASE_BADCFG + 2,
128 VXGE_HW_BADCFG_VPATH_MTU = VXGE_HW_BASE_BADCFG + 3,
129 VXGE_HW_BADCFG_VPATH_RPA_STRIP_VLAN_TAG = VXGE_HW_BASE_BADCFG + 4,
130 VXGE_HW_BADCFG_VPATH_MIN_BANDWIDTH = VXGE_HW_BASE_BADCFG + 5,
131 VXGE_HW_BADCFG_INTR_MODE = VXGE_HW_BASE_BADCFG + 6,
132 VXGE_HW_BADCFG_RTS_MAC_EN = VXGE_HW_BASE_BADCFG + 7,
133
134 VXGE_HW_EOF_TRACE_BUF = -1
135};
136
137/**
138 * enum enum vxge_hw_device_link_state - Link state enumeration.
139 * @VXGE_HW_LINK_NONE: Invalid link state.
140 * @VXGE_HW_LINK_DOWN: Link is down.
141 * @VXGE_HW_LINK_UP: Link is up.
142 *
143 */
144enum vxge_hw_device_link_state {
145 VXGE_HW_LINK_NONE,
146 VXGE_HW_LINK_DOWN,
147 VXGE_HW_LINK_UP
148};
149
150/**
151 * struct vxge_hw_device_date - Date Format
152 * @day: Day
153 * @month: Month
154 * @year: Year
155 * @date: Date in string format
156 *
157 * Structure for returning date
158 */
159
160#define VXGE_HW_FW_STRLEN 32
161struct vxge_hw_device_date {
162 u32 day;
163 u32 month;
164 u32 year;
165 char date[VXGE_HW_FW_STRLEN];
166};
167
168struct vxge_hw_device_version {
169 u32 major;
170 u32 minor;
171 u32 build;
172 char version[VXGE_HW_FW_STRLEN];
173};
174
Ramkrishna Vepa40a3a912009-04-01 18:14:40 +0000175/**
176 * struct vxge_hw_fifo_config - Configuration of fifo.
177 * @enable: Is this fifo to be commissioned
178 * @fifo_blocks: Numbers of TxDL (that is, lists of Tx descriptors)
179 * blocks per queue.
180 * @max_frags: Max number of Tx buffers per TxDL (that is, per single
181 * transmit operation).
182 * No more than 256 transmit buffers can be specified.
183 * @memblock_size: Fifo descriptors are allocated in blocks of @mem_block_size
184 * bytes. Setting @memblock_size to page size ensures
185 * by-page allocation of descriptors. 128K bytes is the
186 * maximum supported block size.
187 * @alignment_size: per Tx fragment DMA-able memory used to align transmit data
188 * (e.g., to align on a cache line).
189 * @intr: Boolean. Use 1 to generate interrupt for each completed TxDL.
190 * Use 0 otherwise.
191 * @no_snoop_bits: If non-zero, specifies no-snoop PCI operation,
192 * which generally improves latency of the host bridge operation
193 * (see PCI specification). For valid values please refer
194 * to struct vxge_hw_fifo_config{} in the driver sources.
195 * Configuration of all Titan fifos.
196 * Note: Valid (min, max) range for each attribute is specified in the body of
197 * the struct vxge_hw_fifo_config{} structure.
198 */
199struct vxge_hw_fifo_config {
200 u32 enable;
201#define VXGE_HW_FIFO_ENABLE 1
202#define VXGE_HW_FIFO_DISABLE 0
203
204 u32 fifo_blocks;
205#define VXGE_HW_MIN_FIFO_BLOCKS 2
206#define VXGE_HW_MAX_FIFO_BLOCKS 128
207
208 u32 max_frags;
209#define VXGE_HW_MIN_FIFO_FRAGS 1
210#define VXGE_HW_MAX_FIFO_FRAGS 256
211
212 u32 memblock_size;
213#define VXGE_HW_MIN_FIFO_MEMBLOCK_SIZE VXGE_HW_BLOCK_SIZE
214#define VXGE_HW_MAX_FIFO_MEMBLOCK_SIZE 131072
215#define VXGE_HW_DEF_FIFO_MEMBLOCK_SIZE 8096
216
217 u32 alignment_size;
218#define VXGE_HW_MIN_FIFO_ALIGNMENT_SIZE 0
219#define VXGE_HW_MAX_FIFO_ALIGNMENT_SIZE 65536
220#define VXGE_HW_DEF_FIFO_ALIGNMENT_SIZE VXGE_CACHE_LINE_SIZE
221
222 u32 intr;
223#define VXGE_HW_FIFO_QUEUE_INTR_ENABLE 1
224#define VXGE_HW_FIFO_QUEUE_INTR_DISABLE 0
225#define VXGE_HW_FIFO_QUEUE_INTR_DEFAULT 0
226
227 u32 no_snoop_bits;
228#define VXGE_HW_FIFO_NO_SNOOP_DISABLED 0
229#define VXGE_HW_FIFO_NO_SNOOP_TXD 1
230#define VXGE_HW_FIFO_NO_SNOOP_FRM 2
231#define VXGE_HW_FIFO_NO_SNOOP_ALL 3
232#define VXGE_HW_FIFO_NO_SNOOP_DEFAULT 0
233
234};
235/**
236 * struct vxge_hw_ring_config - Ring configurations.
237 * @enable: Is this ring to be commissioned
238 * @ring_blocks: Numbers of RxD blocks in the ring
239 * @buffer_mode: Receive buffer mode (1, 2, 3, or 5); for details please refer
240 * to Titan User Guide.
241 * @scatter_mode: Titan supports two receive scatter modes: A and B.
242 * For details please refer to Titan User Guide.
243 * @rx_timer_val: The number of 32ns periods that would be counted between two
244 * timer interrupts.
245 * @greedy_return: If Set it forces the device to return absolutely all RxD
246 * that are consumed and still on board when a timer interrupt
247 * triggers. If Clear, then if the device has already returned
248 * RxD before current timer interrupt trigerred and after the
249 * previous timer interrupt triggered, then the device is not
250 * forced to returned the rest of the consumed RxD that it has
251 * on board which account for a byte count less than the one
252 * programmed into PRC_CFG6.RXD_CRXDT field
253 * @rx_timer_ci: TBD
254 * @backoff_interval_us: Time (in microseconds), after which Titan
255 * tries to download RxDs posted by the host.
256 * Note that the "backoff" does not happen if host posts receive
257 * descriptors in the timely fashion.
258 * Ring configuration.
259 */
260struct vxge_hw_ring_config {
261 u32 enable;
262#define VXGE_HW_RING_ENABLE 1
263#define VXGE_HW_RING_DISABLE 0
264#define VXGE_HW_RING_DEFAULT 1
265
266 u32 ring_blocks;
267#define VXGE_HW_MIN_RING_BLOCKS 1
268#define VXGE_HW_MAX_RING_BLOCKS 128
269#define VXGE_HW_DEF_RING_BLOCKS 2
270
271 u32 buffer_mode;
272#define VXGE_HW_RING_RXD_BUFFER_MODE_1 1
273#define VXGE_HW_RING_RXD_BUFFER_MODE_3 3
274#define VXGE_HW_RING_RXD_BUFFER_MODE_5 5
275#define VXGE_HW_RING_RXD_BUFFER_MODE_DEFAULT 1
276
277 u32 scatter_mode;
278#define VXGE_HW_RING_SCATTER_MODE_A 0
279#define VXGE_HW_RING_SCATTER_MODE_B 1
280#define VXGE_HW_RING_SCATTER_MODE_C 2
281#define VXGE_HW_RING_SCATTER_MODE_USE_FLASH_DEFAULT 0xffffffff
282
283 u64 rxds_limit;
284#define VXGE_HW_DEF_RING_RXDS_LIMIT 44
285};
286
287/**
288 * struct vxge_hw_vp_config - Configuration of virtual path
289 * @vp_id: Virtual Path Id
290 * @min_bandwidth: Minimum Guaranteed bandwidth
291 * @ring: See struct vxge_hw_ring_config{}.
292 * @fifo: See struct vxge_hw_fifo_config{}.
293 * @tti: Configuration of interrupt associated with Transmit.
294 * see struct vxge_hw_tim_intr_config();
295 * @rti: Configuration of interrupt associated with Receive.
296 * see struct vxge_hw_tim_intr_config();
297 * @mtu: mtu size used on this port.
298 * @rpa_strip_vlan_tag: Strip VLAN Tag enable/disable. Instructs the device to
299 * remove the VLAN tag from all received tagged frames that are not
300 * replicated at the internal L2 switch.
301 * 0 - Do not strip the VLAN tag.
302 * 1 - Strip the VLAN tag. Regardless of this setting, VLAN tags are
303 * always placed into the RxDMA descriptor.
304 *
305 * This structure is used by the driver to pass the configuration parameters to
306 * configure Virtual Path.
307 */
308struct vxge_hw_vp_config {
309 u32 vp_id;
310
311#define VXGE_HW_VPATH_PRIORITY_MIN 0
312#define VXGE_HW_VPATH_PRIORITY_MAX 16
313#define VXGE_HW_VPATH_PRIORITY_DEFAULT 0
314
315 u32 min_bandwidth;
316#define VXGE_HW_VPATH_BANDWIDTH_MIN 0
317#define VXGE_HW_VPATH_BANDWIDTH_MAX 100
318#define VXGE_HW_VPATH_BANDWIDTH_DEFAULT 0
319
320 struct vxge_hw_ring_config ring;
321 struct vxge_hw_fifo_config fifo;
322 struct vxge_hw_tim_intr_config tti;
323 struct vxge_hw_tim_intr_config rti;
324
325 u32 mtu;
326#define VXGE_HW_VPATH_MIN_INITIAL_MTU VXGE_HW_MIN_MTU
327#define VXGE_HW_VPATH_MAX_INITIAL_MTU VXGE_HW_MAX_MTU
328#define VXGE_HW_VPATH_USE_FLASH_DEFAULT_INITIAL_MTU 0xffffffff
329
330 u32 rpa_strip_vlan_tag;
331#define VXGE_HW_VPATH_RPA_STRIP_VLAN_TAG_ENABLE 1
332#define VXGE_HW_VPATH_RPA_STRIP_VLAN_TAG_DISABLE 0
333#define VXGE_HW_VPATH_RPA_STRIP_VLAN_TAG_USE_FLASH_DEFAULT 0xffffffff
334
335};
336/**
337 * struct vxge_hw_device_config - Device configuration.
338 * @dma_blockpool_initial: Initial size of DMA Pool
339 * @dma_blockpool_max: Maximum blocks in DMA pool
340 * @intr_mode: Line, or MSI-X interrupt.
341 *
342 * @rth_en: Enable Receive Traffic Hashing(RTH) using IT(Indirection Table).
343 * @rth_it_type: RTH IT table programming type
344 * @rts_mac_en: Enable Receive Traffic Steering using MAC destination address
345 * @vp_config: Configuration for virtual paths
346 * @device_poll_millis: Specify the interval (in mulliseconds)
347 * to wait for register reads
348 *
349 * Titan configuration.
350 * Contains per-device configuration parameters, including:
351 * - stats sampling interval, etc.
352 *
353 * In addition, struct vxge_hw_device_config{} includes "subordinate"
354 * configurations, including:
355 * - fifos and rings;
356 * - MAC (done at firmware level).
357 *
358 * See Titan User Guide for more details.
359 * Note: Valid (min, max) range for each attribute is specified in the body of
360 * the struct vxge_hw_device_config{} structure. Please refer to the
361 * corresponding include file.
362 * See also: struct vxge_hw_tim_intr_config{}.
363 */
364struct vxge_hw_device_config {
365 u32 dma_blockpool_initial;
366 u32 dma_blockpool_max;
367#define VXGE_HW_MIN_DMA_BLOCK_POOL_SIZE 0
368#define VXGE_HW_INITIAL_DMA_BLOCK_POOL_SIZE 0
369#define VXGE_HW_INCR_DMA_BLOCK_POOL_SIZE 4
370#define VXGE_HW_MAX_DMA_BLOCK_POOL_SIZE 4096
371
372#define VXGE_HW_MAX_PAYLOAD_SIZE_512 2
373
374 u32 intr_mode;
375#define VXGE_HW_INTR_MODE_IRQLINE 0
376#define VXGE_HW_INTR_MODE_MSIX 1
377#define VXGE_HW_INTR_MODE_MSIX_ONE_SHOT 2
378
379#define VXGE_HW_INTR_MODE_DEF 0
380
381 u32 rth_en;
382#define VXGE_HW_RTH_DISABLE 0
383#define VXGE_HW_RTH_ENABLE 1
384#define VXGE_HW_RTH_DEFAULT 0
385
386 u32 rth_it_type;
387#define VXGE_HW_RTH_IT_TYPE_SOLO_IT 0
388#define VXGE_HW_RTH_IT_TYPE_MULTI_IT 1
389#define VXGE_HW_RTH_IT_TYPE_DEFAULT 0
390
391 u32 rts_mac_en;
392#define VXGE_HW_RTS_MAC_DISABLE 0
393#define VXGE_HW_RTS_MAC_ENABLE 1
394#define VXGE_HW_RTS_MAC_DEFAULT 0
395
396 struct vxge_hw_vp_config vp_config[VXGE_HW_MAX_VIRTUAL_PATHS];
397
398 u32 device_poll_millis;
399#define VXGE_HW_MIN_DEVICE_POLL_MILLIS 1
400#define VXGE_HW_MAX_DEVICE_POLL_MILLIS 100000
401#define VXGE_HW_DEF_DEVICE_POLL_MILLIS 1000
402
403};
404
405/**
406 * function vxge_uld_link_up_f - Link-Up callback provided by driver.
407 * @devh: HW device handle.
408 * Link-up notification callback provided by the driver.
409 * This is one of the per-driver callbacks, see struct vxge_hw_uld_cbs{}.
410 *
411 * See also: struct vxge_hw_uld_cbs{}, vxge_uld_link_down_f{},
412 * vxge_hw_driver_initialize().
413 */
414
415/**
416 * function vxge_uld_link_down_f - Link-Down callback provided by
417 * driver.
418 * @devh: HW device handle.
419 *
420 * Link-Down notification callback provided by the driver.
421 * This is one of the per-driver callbacks, see struct vxge_hw_uld_cbs{}.
422 *
423 * See also: struct vxge_hw_uld_cbs{}, vxge_uld_link_up_f{},
424 * vxge_hw_driver_initialize().
425 */
426
427/**
428 * function vxge_uld_crit_err_f - Critical Error notification callback.
429 * @devh: HW device handle.
430 * (typically - at HW device iinitialization time).
431 * @type: Enumerated hw error, e.g.: double ECC.
432 * @serr_data: Titan status.
433 * @ext_data: Extended data. The contents depends on the @type.
434 *
435 * Link-Down notification callback provided by the driver.
436 * This is one of the per-driver callbacks, see struct vxge_hw_uld_cbs{}.
437 *
438 * See also: struct vxge_hw_uld_cbs{}, enum vxge_hw_event{},
439 * vxge_hw_driver_initialize().
440 */
441
442/**
443 * struct vxge_hw_uld_cbs - driver "slow-path" callbacks.
444 * @link_up: See vxge_uld_link_up_f{}.
445 * @link_down: See vxge_uld_link_down_f{}.
446 * @crit_err: See vxge_uld_crit_err_f{}.
447 *
448 * Driver slow-path (per-driver) callbacks.
449 * Implemented by driver and provided to HW via
450 * vxge_hw_driver_initialize().
451 * Note that these callbacks are not mandatory: HW will not invoke
452 * a callback if NULL is specified.
453 *
454 * See also: vxge_hw_driver_initialize().
455 */
456struct vxge_hw_uld_cbs {
457
458 void (*link_up)(struct __vxge_hw_device *devh);
459 void (*link_down)(struct __vxge_hw_device *devh);
460 void (*crit_err)(struct __vxge_hw_device *devh,
461 enum vxge_hw_event type, u64 ext_data);
462};
463
464/*
465 * struct __vxge_hw_blockpool_entry - Block private data structure
466 * @item: List header used to link.
467 * @length: Length of the block
468 * @memblock: Virtual address block
469 * @dma_addr: DMA Address of the block.
470 * @dma_handle: DMA handle of the block.
471 * @acc_handle: DMA acc handle
472 *
473 * Block is allocated with a header to put the blocks into list.
474 *
475 */
476struct __vxge_hw_blockpool_entry {
477 struct list_head item;
478 u32 length;
479 void *memblock;
480 dma_addr_t dma_addr;
481 struct pci_dev *dma_handle;
482 struct pci_dev *acc_handle;
483};
484
485/*
486 * struct __vxge_hw_blockpool - Block Pool
487 * @hldev: HW device
488 * @block_size: size of each block.
489 * @Pool_size: Number of blocks in the pool
490 * @pool_max: Maximum number of blocks above which to free additional blocks
491 * @req_out: Number of block requests with OS out standing
492 * @free_block_list: List of free blocks
493 *
494 * Block pool contains the DMA blocks preallocated.
495 *
496 */
497struct __vxge_hw_blockpool {
498 struct __vxge_hw_device *hldev;
499 u32 block_size;
500 u32 pool_size;
501 u32 pool_max;
502 u32 req_out;
503 struct list_head free_block_list;
504 struct list_head free_entry_list;
505};
506
507/*
508 * enum enum __vxge_hw_channel_type - Enumerated channel types.
509 * @VXGE_HW_CHANNEL_TYPE_UNKNOWN: Unknown channel.
510 * @VXGE_HW_CHANNEL_TYPE_FIFO: fifo.
511 * @VXGE_HW_CHANNEL_TYPE_RING: ring.
512 * @VXGE_HW_CHANNEL_TYPE_MAX: Maximum number of HW-supported
513 * (and recognized) channel types. Currently: 2.
514 *
515 * Enumerated channel types. Currently there are only two link-layer
516 * channels - Titan fifo and Titan ring. In the future the list will grow.
517 */
518enum __vxge_hw_channel_type {
519 VXGE_HW_CHANNEL_TYPE_UNKNOWN = 0,
520 VXGE_HW_CHANNEL_TYPE_FIFO = 1,
521 VXGE_HW_CHANNEL_TYPE_RING = 2,
522 VXGE_HW_CHANNEL_TYPE_MAX = 3
523};
524
525/*
526 * struct __vxge_hw_channel
527 * @item: List item; used to maintain a list of open channels.
528 * @type: Channel type. See enum vxge_hw_channel_type{}.
529 * @devh: Device handle. HW device object that contains _this_ channel.
530 * @vph: Virtual path handle. Virtual Path Object that contains _this_ channel.
531 * @length: Channel length. Currently allocated number of descriptors.
532 * The channel length "grows" when more descriptors get allocated.
533 * See _hw_mempool_grow.
534 * @reserve_arr: Reserve array. Contains descriptors that can be reserved
535 * by driver for the subsequent send or receive operation.
536 * See vxge_hw_fifo_txdl_reserve(),
537 * vxge_hw_ring_rxd_reserve().
538 * @reserve_ptr: Current pointer in the resrve array
539 * @reserve_top: Reserve top gives the maximum number of dtrs available in
540 * reserve array.
541 * @work_arr: Work array. Contains descriptors posted to the channel.
542 * Note that at any point in time @work_arr contains 3 types of
543 * descriptors:
544 * 1) posted but not yet consumed by Titan device;
545 * 2) consumed but not yet completed;
546 * 3) completed but not yet freed
547 * (via vxge_hw_fifo_txdl_free() or vxge_hw_ring_rxd_free())
548 * @post_index: Post index. At any point in time points on the
549 * position in the channel, which'll contain next to-be-posted
550 * descriptor.
551 * @compl_index: Completion index. At any point in time points on the
552 * position in the channel, which will contain next
553 * to-be-completed descriptor.
554 * @free_arr: Free array. Contains completed descriptors that were freed
555 * (i.e., handed over back to HW) by driver.
556 * See vxge_hw_fifo_txdl_free(), vxge_hw_ring_rxd_free().
557 * @free_ptr: current pointer in free array
558 * @per_dtr_space: Per-descriptor space (in bytes) that channel user can utilize
559 * to store per-operation control information.
560 * @stats: Pointer to common statistics
561 * @userdata: Per-channel opaque (void*) user-defined context, which may be
562 * driver object, ULP connection, etc.
563 * Once channel is open, @userdata is passed back to user via
564 * vxge_hw_channel_callback_f.
565 *
566 * HW channel object.
567 *
568 * See also: enum vxge_hw_channel_type{}, enum vxge_hw_channel_flag
569 */
570struct __vxge_hw_channel {
571 struct list_head item;
572 enum __vxge_hw_channel_type type;
573 struct __vxge_hw_device *devh;
574 struct __vxge_hw_vpath_handle *vph;
575 u32 length;
576 u32 vp_id;
577 void **reserve_arr;
578 u32 reserve_ptr;
579 u32 reserve_top;
580 void **work_arr;
581 u32 post_index ____cacheline_aligned;
582 u32 compl_index ____cacheline_aligned;
583 void **free_arr;
584 u32 free_ptr;
585 void **orig_arr;
586 u32 per_dtr_space;
587 void *userdata;
588 struct vxge_hw_common_reg __iomem *common_reg;
589 u32 first_vp_id;
590 struct vxge_hw_vpath_stats_sw_common_info *stats;
591
592} ____cacheline_aligned;
593
594/*
595 * struct __vxge_hw_virtualpath - Virtual Path
596 *
597 * @vp_id: Virtual path id
598 * @vp_open: This flag specifies if vxge_hw_vp_open is called from LL Driver
599 * @hldev: Hal device
600 * @vp_config: Virtual Path Config
601 * @vp_reg: VPATH Register map address in BAR0
602 * @vpmgmt_reg: VPATH_MGMT register map address
603 * @max_mtu: Max mtu that can be supported
604 * @vsport_number: vsport attached to this vpath
605 * @max_kdfc_db: Maximum kernel mode doorbells
606 * @max_nofl_db: Maximum non offload doorbells
607 * @tx_intr_num: Interrupt Number associated with the TX
608
609 * @ringh: Ring Queue
610 * @fifoh: FIFO Queue
611 * @vpath_handles: Virtual Path handles list
612 * @stats_block: Memory for DMAing stats
613 * @stats: Vpath statistics
614 *
615 * Virtual path structure to encapsulate the data related to a virtual path.
616 * Virtual paths are allocated by the HW upon getting configuration from the
617 * driver and inserted into the list of virtual paths.
618 */
619struct __vxge_hw_virtualpath {
620 u32 vp_id;
621
622 u32 vp_open;
623#define VXGE_HW_VP_NOT_OPEN 0
624#define VXGE_HW_VP_OPEN 1
625
626 struct __vxge_hw_device *hldev;
627 struct vxge_hw_vp_config *vp_config;
628 struct vxge_hw_vpath_reg __iomem *vp_reg;
629 struct vxge_hw_vpmgmt_reg __iomem *vpmgmt_reg;
630 struct __vxge_hw_non_offload_db_wrapper __iomem *nofl_db;
631
632 u32 max_mtu;
633 u32 vsport_number;
634 u32 max_kdfc_db;
635 u32 max_nofl_db;
636
637 struct __vxge_hw_ring *____cacheline_aligned ringh;
638 struct __vxge_hw_fifo *____cacheline_aligned fifoh;
639 struct list_head vpath_handles;
640 struct __vxge_hw_blockpool_entry *stats_block;
641 struct vxge_hw_vpath_stats_hw_info *hw_stats;
642 struct vxge_hw_vpath_stats_hw_info *hw_stats_sav;
643 struct vxge_hw_vpath_stats_sw_info *sw_stats;
Jon Mason8424e002010-11-11 04:25:56 +0000644 spinlock_t lock;
Ramkrishna Vepa40a3a912009-04-01 18:14:40 +0000645};
646
647/*
648 * struct __vxge_hw_vpath_handle - List item to store callback information
649 * @item: List head to keep the item in linked list
650 * @vpath: Virtual path to which this item belongs
651 *
652 * This structure is used to store the callback information.
653 */
654struct __vxge_hw_vpath_handle{
655 struct list_head item;
656 struct __vxge_hw_virtualpath *vpath;
657};
658
659/*
660 * struct __vxge_hw_device
661 *
662 * HW device object.
663 */
664/**
665 * struct __vxge_hw_device - Hal device object
666 * @magic: Magic Number
667 * @device_id: PCI Device Id of the adapter
668 * @major_revision: PCI Device major revision
669 * @minor_revision: PCI Device minor revision
670 * @bar0: BAR0 virtual address.
Ramkrishna Vepa40a3a912009-04-01 18:14:40 +0000671 * @pdev: Physical device handle
672 * @config: Confguration passed by the LL driver at initialization
673 * @link_state: Link state
674 *
675 * HW device object. Represents Titan adapter
676 */
677struct __vxge_hw_device {
678 u32 magic;
679#define VXGE_HW_DEVICE_MAGIC 0x12345678
680#define VXGE_HW_DEVICE_DEAD 0xDEADDEAD
681 u16 device_id;
682 u8 major_revision;
683 u8 minor_revision;
684 void __iomem *bar0;
Ramkrishna Vepa40a3a912009-04-01 18:14:40 +0000685 struct pci_dev *pdev;
686 struct net_device *ndev;
687 struct vxge_hw_device_config config;
688 enum vxge_hw_device_link_state link_state;
689
690 struct vxge_hw_uld_cbs uld_callbacks;
691
692 u32 host_type;
693 u32 func_id;
694 u32 access_rights;
695#define VXGE_HW_DEVICE_ACCESS_RIGHT_VPATH 0x1
696#define VXGE_HW_DEVICE_ACCESS_RIGHT_SRPCIM 0x2
697#define VXGE_HW_DEVICE_ACCESS_RIGHT_MRPCIM 0x4
698 struct vxge_hw_legacy_reg __iomem *legacy_reg;
699 struct vxge_hw_toc_reg __iomem *toc_reg;
700 struct vxge_hw_common_reg __iomem *common_reg;
701 struct vxge_hw_mrpcim_reg __iomem *mrpcim_reg;
702 struct vxge_hw_srpcim_reg __iomem *srpcim_reg \
703 [VXGE_HW_TITAN_SRPCIM_REG_SPACES];
704 struct vxge_hw_vpmgmt_reg __iomem *vpmgmt_reg \
705 [VXGE_HW_TITAN_VPMGMT_REG_SPACES];
706 struct vxge_hw_vpath_reg __iomem *vpath_reg \
707 [VXGE_HW_TITAN_VPATH_REG_SPACES];
708 u8 __iomem *kdfc;
709 u8 __iomem *usdc;
710 struct __vxge_hw_virtualpath virtual_paths \
711 [VXGE_HW_MAX_VIRTUAL_PATHS];
712 u64 vpath_assignments;
713 u64 vpaths_deployed;
714 u32 first_vp_id;
715 u64 tim_int_mask0[4];
716 u32 tim_int_mask1[4];
717
718 struct __vxge_hw_blockpool block_pool;
719 struct vxge_hw_device_stats stats;
720 u32 debug_module_mask;
721 u32 debug_level;
722 u32 level_err;
723 u32 level_trace;
724};
725
726#define VXGE_HW_INFO_LEN 64
727/**
728 * struct vxge_hw_device_hw_info - Device information
729 * @host_type: Host Type
730 * @func_id: Function Id
731 * @vpath_mask: vpath bit mask
732 * @fw_version: Firmware version
733 * @fw_date: Firmware Date
734 * @flash_version: Firmware version
735 * @flash_date: Firmware Date
736 * @mac_addrs: Mac addresses for each vpath
737 * @mac_addr_masks: Mac address masks for each vpath
738 *
739 * Returns the vpath mask that has the bits set for each vpath allocated
740 * for the driver and the first mac address for each vpath
741 */
742struct vxge_hw_device_hw_info {
743 u32 host_type;
744#define VXGE_HW_NO_MR_NO_SR_NORMAL_FUNCTION 0
745#define VXGE_HW_MR_NO_SR_VH0_BASE_FUNCTION 1
746#define VXGE_HW_NO_MR_SR_VH0_FUNCTION0 2
747#define VXGE_HW_NO_MR_SR_VH0_VIRTUAL_FUNCTION 3
748#define VXGE_HW_MR_SR_VH0_INVALID_CONFIG 4
749#define VXGE_HW_SR_VH_FUNCTION0 5
750#define VXGE_HW_SR_VH_VIRTUAL_FUNCTION 6
751#define VXGE_HW_VH_NORMAL_FUNCTION 7
752 u64 function_mode;
Sreenivasa Honnurcb27ec62010-04-08 01:48:57 -0700753#define VXGE_HW_FUNCTION_MODE_SINGLE_FUNCTION 0
754#define VXGE_HW_FUNCTION_MODE_MULTI_FUNCTION 1
Ramkrishna Vepa40a3a912009-04-01 18:14:40 +0000755#define VXGE_HW_FUNCTION_MODE_SRIOV 2
756#define VXGE_HW_FUNCTION_MODE_MRIOV 3
Sreenivasa Honnurcb27ec62010-04-08 01:48:57 -0700757#define VXGE_HW_FUNCTION_MODE_MRIOV_8 4
758#define VXGE_HW_FUNCTION_MODE_MULTI_FUNCTION_17 5
759#define VXGE_HW_FUNCTION_MODE_SRIOV_8 6
760#define VXGE_HW_FUNCTION_MODE_SRIOV_4 7
761#define VXGE_HW_FUNCTION_MODE_MULTI_FUNCTION_2 8
762#define VXGE_HW_FUNCTION_MODE_MULTI_FUNCTION_4 9
763#define VXGE_HW_FUNCTION_MODE_MRIOV_4 10
764
Ramkrishna Vepa40a3a912009-04-01 18:14:40 +0000765 u32 func_id;
766 u64 vpath_mask;
767 struct vxge_hw_device_version fw_version;
768 struct vxge_hw_device_date fw_date;
769 struct vxge_hw_device_version flash_version;
770 struct vxge_hw_device_date flash_date;
771 u8 serial_number[VXGE_HW_INFO_LEN];
772 u8 part_number[VXGE_HW_INFO_LEN];
773 u8 product_desc[VXGE_HW_INFO_LEN];
774 u8 (mac_addrs)[VXGE_HW_MAX_VIRTUAL_PATHS][ETH_ALEN];
775 u8 (mac_addr_masks)[VXGE_HW_MAX_VIRTUAL_PATHS][ETH_ALEN];
776};
777
778/**
779 * struct vxge_hw_device_attr - Device memory spaces.
780 * @bar0: BAR0 virtual address.
Ramkrishna Vepa40a3a912009-04-01 18:14:40 +0000781 * @pdev: PCI device object.
782 *
Sreenivasa Honnur7975d1e2009-07-01 21:12:23 +0000783 * Device memory spaces. Includes configuration, BAR0 etc. per device
Ramkrishna Vepa40a3a912009-04-01 18:14:40 +0000784 * mapped memories. Also, includes a pointer to OS-specific PCI device object.
785 */
786struct vxge_hw_device_attr {
787 void __iomem *bar0;
Ramkrishna Vepa40a3a912009-04-01 18:14:40 +0000788 struct pci_dev *pdev;
789 struct vxge_hw_uld_cbs uld_callbacks;
790};
791
792#define VXGE_HW_DEVICE_LINK_STATE_SET(hldev, ls) (hldev->link_state = ls)
793
794#define VXGE_HW_DEVICE_TIM_INT_MASK_SET(m0, m1, i) { \
795 if (i < 16) { \
796 m0[0] |= vxge_vBIT(0x8, (i*4), 4); \
797 m0[1] |= vxge_vBIT(0x4, (i*4), 4); \
798 } \
799 else { \
800 m1[0] = 0x80000000; \
801 m1[1] = 0x40000000; \
802 } \
803}
804
805#define VXGE_HW_DEVICE_TIM_INT_MASK_RESET(m0, m1, i) { \
806 if (i < 16) { \
807 m0[0] &= ~vxge_vBIT(0x8, (i*4), 4); \
808 m0[1] &= ~vxge_vBIT(0x4, (i*4), 4); \
809 } \
810 else { \
811 m1[0] = 0; \
812 m1[1] = 0; \
813 } \
814}
815
816#define VXGE_HW_DEVICE_STATS_PIO_READ(loc, offset) { \
817 status = vxge_hw_mrpcim_stats_access(hldev, \
818 VXGE_HW_STATS_OP_READ, \
819 loc, \
820 offset, \
821 &val64); \
822 \
823 if (status != VXGE_HW_OK) \
824 return status; \
825}
826
827#define VXGE_HW_VPATH_STATS_PIO_READ(offset) { \
828 status = __vxge_hw_vpath_stats_access(vpath, \
829 VXGE_HW_STATS_OP_READ, \
830 offset, \
831 &val64); \
832 if (status != VXGE_HW_OK) \
833 return status; \
834}
835
836/*
837 * struct __vxge_hw_ring - Ring channel.
838 * @channel: Channel "base" of this ring, the common part of all HW
839 * channels.
840 * @mempool: Memory pool, the pool from which descriptors get allocated.
841 * (See vxge_hw_mm.h).
842 * @config: Ring configuration, part of device configuration
843 * (see struct vxge_hw_device_config{}).
844 * @ring_length: Length of the ring
845 * @buffer_mode: 1, 3, or 5. The value specifies a receive buffer mode,
846 * as per Titan User Guide.
847 * @rxd_size: RxD sizes for 1-, 3- or 5- buffer modes. As per Titan spec,
848 * 1-buffer mode descriptor is 32 byte long, etc.
849 * @rxd_priv_size: Per RxD size reserved (by HW) for driver to keep
850 * per-descriptor data (e.g., DMA handle for Solaris)
851 * @per_rxd_space: Per rxd space requested by driver
852 * @rxds_per_block: Number of descriptors per hardware-defined RxD
853 * block. Depends on the (1-, 3-, 5-) buffer mode.
854 * @rxdblock_priv_size: Reserved at the end of each RxD block. HW internal
855 * usage. Not to confuse with @rxd_priv_size.
856 * @cmpl_cnt: Completion counter. Is reset to zero upon entering the ISR.
857 * @callback: Channel completion callback. HW invokes the callback when there
858 * are new completions on that channel. In many implementations
859 * the @callback executes in the hw interrupt context.
860 * @rxd_init: Channel's descriptor-initialize callback.
861 * See vxge_hw_ring_rxd_init_f{}.
862 * If not NULL, HW invokes the callback when opening
863 * the ring.
864 * @rxd_term: Channel's descriptor-terminate callback. If not NULL,
865 * HW invokes the callback when closing the corresponding channel.
866 * See also vxge_hw_channel_rxd_term_f{}.
867 * @stats: Statistics for ring
868 * Ring channel.
869 *
870 * Note: The structure is cache line aligned to better utilize
871 * CPU cache performance.
872 */
873struct __vxge_hw_ring {
874 struct __vxge_hw_channel channel;
875 struct vxge_hw_mempool *mempool;
876 struct vxge_hw_vpath_reg __iomem *vp_reg;
877 struct vxge_hw_common_reg __iomem *common_reg;
878 u32 ring_length;
879 u32 buffer_mode;
880 u32 rxd_size;
881 u32 rxd_priv_size;
882 u32 per_rxd_space;
883 u32 rxds_per_block;
884 u32 rxdblock_priv_size;
885 u32 cmpl_cnt;
886 u32 vp_id;
887 u32 doorbell_cnt;
888 u32 total_db_cnt;
889 u64 rxds_limit;
890
891 enum vxge_hw_status (*callback)(
892 struct __vxge_hw_ring *ringh,
893 void *rxdh,
894 u8 t_code,
895 void *userdata);
896
897 enum vxge_hw_status (*rxd_init)(
898 void *rxdh,
899 void *userdata);
900
901 void (*rxd_term)(
902 void *rxdh,
903 enum vxge_hw_rxd_state state,
904 void *userdata);
905
906 struct vxge_hw_vpath_stats_sw_ring_info *stats ____cacheline_aligned;
907 struct vxge_hw_ring_config *config;
908} ____cacheline_aligned;
909
910/**
911 * enum enum vxge_hw_txdl_state - Descriptor (TXDL) state.
912 * @VXGE_HW_TXDL_STATE_NONE: Invalid state.
913 * @VXGE_HW_TXDL_STATE_AVAIL: Descriptor is available for reservation.
914 * @VXGE_HW_TXDL_STATE_POSTED: Descriptor is posted for processing by the
915 * device.
916 * @VXGE_HW_TXDL_STATE_FREED: Descriptor is free and can be reused for
917 * filling-in and posting later.
918 *
919 * Titan/HW descriptor states.
920 *
921 */
922enum vxge_hw_txdl_state {
923 VXGE_HW_TXDL_STATE_NONE = 0,
924 VXGE_HW_TXDL_STATE_AVAIL = 1,
925 VXGE_HW_TXDL_STATE_POSTED = 2,
926 VXGE_HW_TXDL_STATE_FREED = 3
927};
928/*
929 * struct __vxge_hw_fifo - Fifo.
930 * @channel: Channel "base" of this fifo, the common part of all HW
931 * channels.
932 * @mempool: Memory pool, from which descriptors get allocated.
933 * @config: Fifo configuration, part of device configuration
934 * (see struct vxge_hw_device_config{}).
935 * @interrupt_type: Interrupt type to be used
936 * @no_snoop_bits: See struct vxge_hw_fifo_config{}.
937 * @txdl_per_memblock: Number of TxDLs (TxD lists) per memblock.
938 * on TxDL please refer to Titan UG.
939 * @txdl_size: Configured TxDL size (i.e., number of TxDs in a list), plus
940 * per-TxDL HW private space (struct __vxge_hw_fifo_txdl_priv).
941 * @priv_size: Per-Tx descriptor space reserved for driver
942 * usage.
943 * @per_txdl_space: Per txdl private space for the driver
944 * @callback: Fifo completion callback. HW invokes the callback when there
945 * are new completions on that fifo. In many implementations
946 * the @callback executes in the hw interrupt context.
947 * @txdl_term: Fifo's descriptor-terminate callback. If not NULL,
948 * HW invokes the callback when closing the corresponding fifo.
949 * See also vxge_hw_fifo_txdl_term_f{}.
950 * @stats: Statistics of this fifo
951 *
952 * Fifo channel.
953 * Note: The structure is cache line aligned.
954 */
955struct __vxge_hw_fifo {
956 struct __vxge_hw_channel channel;
957 struct vxge_hw_mempool *mempool;
958 struct vxge_hw_fifo_config *config;
959 struct vxge_hw_vpath_reg __iomem *vp_reg;
960 struct __vxge_hw_non_offload_db_wrapper __iomem *nofl_db;
961 u64 interrupt_type;
962 u32 no_snoop_bits;
963 u32 txdl_per_memblock;
964 u32 txdl_size;
965 u32 priv_size;
966 u32 per_txdl_space;
967 u32 vp_id;
968 u32 tx_intr_num;
969
970 enum vxge_hw_status (*callback)(
971 struct __vxge_hw_fifo *fifo_handle,
972 void *txdlh,
973 enum vxge_hw_fifo_tcode t_code,
974 void *userdata,
Benjamin LaHaiseff67df52009-08-04 10:21:03 +0000975 struct sk_buff ***skb_ptr,
976 int nr_skb,
977 int *more);
Ramkrishna Vepa40a3a912009-04-01 18:14:40 +0000978
979 void (*txdl_term)(
980 void *txdlh,
981 enum vxge_hw_txdl_state state,
982 void *userdata);
983
984 struct vxge_hw_vpath_stats_sw_fifo_info *stats ____cacheline_aligned;
985} ____cacheline_aligned;
986
987/*
988 * struct __vxge_hw_fifo_txdl_priv - Transmit descriptor HW-private data.
989 * @dma_addr: DMA (mapped) address of _this_ descriptor.
990 * @dma_handle: DMA handle used to map the descriptor onto device.
991 * @dma_offset: Descriptor's offset in the memory block. HW allocates
992 * descriptors in memory blocks (see struct vxge_hw_fifo_config{})
993 * Each memblock is a contiguous block of DMA-able memory.
994 * @frags: Total number of fragments (that is, contiguous data buffers)
995 * carried by this TxDL.
996 * @align_vaddr_start: Aligned virtual address start
997 * @align_vaddr: Virtual address of the per-TxDL area in memory used for
998 * alignement. Used to place one or more mis-aligned fragments
999 * @align_dma_addr: DMA address translated from the @align_vaddr.
1000 * @align_dma_handle: DMA handle that corresponds to @align_dma_addr.
1001 * @align_dma_acch: DMA access handle corresponds to @align_dma_addr.
1002 * @align_dma_offset: The current offset into the @align_vaddr area.
1003 * Grows while filling the descriptor, gets reset.
1004 * @align_used_frags: Number of fragments used.
1005 * @alloc_frags: Total number of fragments allocated.
1006 * @unused: TODO
1007 * @next_txdl_priv: (TODO).
1008 * @first_txdp: (TODO).
1009 * @linked_txdl_priv: Pointer to any linked TxDL for creating contiguous
1010 * TxDL list.
1011 * @txdlh: Corresponding txdlh to this TxDL.
1012 * @memblock: Pointer to the TxDL memory block or memory page.
1013 * on the next send operation.
1014 * @dma_object: DMA address and handle of the memory block that contains
1015 * the descriptor. This member is used only in the "checked"
1016 * version of the HW (to enforce certain assertions);
1017 * otherwise it gets compiled out.
1018 * @allocated: True if the descriptor is reserved, 0 otherwise. Internal usage.
1019 *
1020 * Per-transmit decsriptor HW-private data. HW uses the space to keep DMA
1021 * information associated with the descriptor. Note that driver can ask HW
1022 * to allocate additional per-descriptor space for its own (driver-specific)
1023 * purposes.
1024 *
1025 * See also: struct vxge_hw_ring_rxd_priv{}.
1026 */
1027struct __vxge_hw_fifo_txdl_priv {
1028 dma_addr_t dma_addr;
1029 struct pci_dev *dma_handle;
1030 ptrdiff_t dma_offset;
1031 u32 frags;
1032 u8 *align_vaddr_start;
1033 u8 *align_vaddr;
1034 dma_addr_t align_dma_addr;
1035 struct pci_dev *align_dma_handle;
1036 struct pci_dev *align_dma_acch;
1037 ptrdiff_t align_dma_offset;
1038 u32 align_used_frags;
1039 u32 alloc_frags;
1040 u32 unused;
1041 struct __vxge_hw_fifo_txdl_priv *next_txdl_priv;
1042 struct vxge_hw_fifo_txd *first_txdp;
1043 void *memblock;
1044};
1045
1046/*
1047 * struct __vxge_hw_non_offload_db_wrapper - Non-offload Doorbell Wrapper
1048 * @control_0: Bits 0 to 7 - Doorbell type.
1049 * Bits 8 to 31 - Reserved.
1050 * Bits 32 to 39 - The highest TxD in this TxDL.
1051 * Bits 40 to 47 - Reserved.
1052 * Bits 48 to 55 - Reserved.
1053 * Bits 56 to 63 - No snoop flags.
1054 * @txdl_ptr: The starting location of the TxDL in host memory.
1055 *
1056 * Created by the host and written to the adapter via PIO to a Kernel Doorbell
1057 * FIFO. All non-offload doorbell wrapper fields must be written by the host as
1058 * part of a doorbell write. Consumed by the adapter but is not written by the
1059 * adapter.
1060 */
1061struct __vxge_hw_non_offload_db_wrapper {
1062 u64 control_0;
1063#define VXGE_HW_NODBW_GET_TYPE(ctrl0) vxge_bVALn(ctrl0, 0, 8)
1064#define VXGE_HW_NODBW_TYPE(val) vxge_vBIT(val, 0, 8)
1065#define VXGE_HW_NODBW_TYPE_NODBW 0
1066
1067#define VXGE_HW_NODBW_GET_LAST_TXD_NUMBER(ctrl0) vxge_bVALn(ctrl0, 32, 8)
1068#define VXGE_HW_NODBW_LAST_TXD_NUMBER(val) vxge_vBIT(val, 32, 8)
1069
1070#define VXGE_HW_NODBW_GET_NO_SNOOP(ctrl0) vxge_bVALn(ctrl0, 56, 8)
1071#define VXGE_HW_NODBW_LIST_NO_SNOOP(val) vxge_vBIT(val, 56, 8)
1072#define VXGE_HW_NODBW_LIST_NO_SNOOP_TXD_READ_TXD0_WRITE 0x2
1073#define VXGE_HW_NODBW_LIST_NO_SNOOP_TX_FRAME_DATA_READ 0x1
1074
1075 u64 txdl_ptr;
1076};
1077
1078/*
1079 * TX Descriptor
1080 */
1081
1082/**
1083 * struct vxge_hw_fifo_txd - Transmit Descriptor
1084 * @control_0: Bits 0 to 6 - Reserved.
1085 * Bit 7 - List Ownership. This field should be initialized
1086 * to '1' by the driver before the transmit list pointer is
1087 * written to the adapter. This field will be set to '0' by the
1088 * adapter once it has completed transmitting the frame or frames in
1089 * the list. Note - This field is only valid in TxD0. Additionally,
1090 * for multi-list sequences, the driver should not release any
1091 * buffers until the ownership of the last list in the multi-list
1092 * sequence has been returned to the host.
1093 * Bits 8 to 11 - Reserved
1094 * Bits 12 to 15 - Transfer_Code. This field is only valid in
1095 * TxD0. It is used to describe the status of the transmit data
1096 * buffer transfer. This field is always overwritten by the
1097 * adapter, so this field may be initialized to any value.
1098 * Bits 16 to 17 - Host steering. This field allows the host to
1099 * override the selection of the physical transmit port.
1100 * Attention:
1101 * Normal sounds as if learned from the switch rather than from
1102 * the aggregation algorythms.
1103 * 00: Normal. Use Destination/MAC Address
1104 * lookup to determine the transmit port.
1105 * 01: Send on physical Port1.
1106 * 10: Send on physical Port0.
1107 * 11: Send on both ports.
1108 * Bits 18 to 21 - Reserved
1109 * Bits 22 to 23 - Gather_Code. This field is set by the host and
1110 * is used to describe how individual buffers comprise a frame.
1111 * 10: First descriptor of a frame.
1112 * 00: Middle of a multi-descriptor frame.
1113 * 01: Last descriptor of a frame.
1114 * 11: First and last descriptor of a frame (the entire frame
1115 * resides in a single buffer).
1116 * For multi-descriptor frames, the only valid gather code sequence
1117 * is {10, [00], 01}. In other words, the descriptors must be placed
1118 * in the list in the correct order.
1119 * Bits 24 to 27 - Reserved
1120 * Bits 28 to 29 - LSO_Frm_Encap. LSO Frame Encapsulation
1121 * definition. Only valid in TxD0. This field allows the host to
1122 * indicate the Ethernet encapsulation of an outbound LSO packet.
1123 * 00 - classic mode (best guess)
1124 * 01 - LLC
1125 * 10 - SNAP
1126 * 11 - DIX
1127 * If "classic mode" is selected, the adapter will attempt to
1128 * decode the frame's Ethernet encapsulation by examining the L/T
1129 * field as follows:
1130 * <= 0x05DC LLC/SNAP encoding; must examine DSAP/SSAP to determine
1131 * if packet is IPv4 or IPv6.
1132 * 0x8870 Jumbo-SNAP encoding.
1133 * 0x0800 IPv4 DIX encoding
1134 * 0x86DD IPv6 DIX encoding
1135 * others illegal encapsulation
1136 * Bits 30 - LSO_ Flag. Large Send Offload (LSO) flag.
1137 * Set to 1 to perform segmentation offload for TCP/UDP.
1138 * This field is valid only in TxD0.
1139 * Bits 31 to 33 - Reserved.
1140 * Bits 34 to 47 - LSO_MSS. TCP/UDP LSO Maximum Segment Size
1141 * This field is meaningful only when LSO_Control is non-zero.
1142 * When LSO_Control is set to TCP_LSO, the single (possibly large)
1143 * TCP segment described by this TxDL will be sent as a series of
1144 * TCP segments each of which contains no more than LSO_MSS
1145 * payload bytes.
1146 * When LSO_Control is set to UDP_LSO, the single (possibly large)
1147 * UDP datagram described by this TxDL will be sent as a series of
1148 * UDP datagrams each of which contains no more than LSO_MSS
1149 * payload bytes.
1150 * All outgoing frames from this TxDL will have LSO_MSS bytes of UDP
1151 * or TCP payload, with the exception of the last, which will have
1152 * <= LSO_MSS bytes of payload.
1153 * Bits 48 to 63 - Buffer_Size. Number of valid bytes in the
1154 * buffer to be read by the adapter. This field is written by the
1155 * host. A value of 0 is illegal.
1156 * Bits 32 to 63 - This value is written by the adapter upon
1157 * completion of a UDP or TCP LSO operation and indicates the number
1158 * of UDP or TCP payload bytes that were transmitted. 0x0000 will be
1159 * returned for any non-LSO operation.
1160 * @control_1: Bits 0 to 4 - Reserved.
1161 * Bit 5 - Tx_CKO_IPv4 Set to a '1' to enable IPv4 header checksum
1162 * offload. This field is only valid in the first TxD of a frame.
1163 * Bit 6 - Tx_CKO_TCP Set to a '1' to enable TCP checksum offload.
1164 * This field is only valid in the first TxD of a frame (the TxD's
1165 * gather code must be 10 or 11). The driver should only set this
1166 * bit if it can guarantee that TCP is present.
1167 * Bit 7 - Tx_CKO_UDP Set to a '1' to enable UDP checksum offload.
1168 * This field is only valid in the first TxD of a frame (the TxD's
1169 * gather code must be 10 or 11). The driver should only set this
1170 * bit if it can guarantee that UDP is present.
1171 * Bits 8 to 14 - Reserved.
1172 * Bit 15 - Tx_VLAN_Enable VLAN tag insertion flag. Set to a '1' to
1173 * instruct the adapter to insert the VLAN tag specified by the
1174 * Tx_VLAN_Tag field. This field is only valid in the first TxD of
1175 * a frame.
1176 * Bits 16 to 31 - Tx_VLAN_Tag. Variable portion of the VLAN tag
1177 * to be inserted into the frame by the adapter (the first two bytes
1178 * of a VLAN tag are always 0x8100). This field is only valid if the
1179 * Tx_VLAN_Enable field is set to '1'.
1180 * Bits 32 to 33 - Reserved.
1181 * Bits 34 to 39 - Tx_Int_Number. Indicates which Tx interrupt
1182 * number the frame associated with. This field is written by the
1183 * host. It is only valid in the first TxD of a frame.
1184 * Bits 40 to 42 - Reserved.
1185 * Bit 43 - Set to 1 to exclude the frame from bandwidth metering
1186 * functions. This field is valid only in the first TxD
1187 * of a frame.
1188 * Bits 44 to 45 - Reserved.
1189 * Bit 46 - Tx_Int_Per_List Set to a '1' to instruct the adapter to
1190 * generate an interrupt as soon as all of the frames in the list
1191 * have been transmitted. In order to have per-frame interrupts,
1192 * the driver should place a maximum of one frame per list. This
1193 * field is only valid in the first TxD of a frame.
1194 * Bit 47 - Tx_Int_Utilization Set to a '1' to instruct the adapter
1195 * to count the frame toward the utilization interrupt specified in
1196 * the Tx_Int_Number field. This field is only valid in the first
1197 * TxD of a frame.
1198 * Bits 48 to 63 - Reserved.
1199 * @buffer_pointer: Buffer start address.
1200 * @host_control: Host_Control.Opaque 64bit data stored by driver inside the
1201 * Titan descriptor prior to posting the latter on the fifo
1202 * via vxge_hw_fifo_txdl_post().The %host_control is returned as is
1203 * to the driver with each completed descriptor.
1204 *
1205 * Transmit descriptor (TxD).Fifo descriptor contains configured number
1206 * (list) of TxDs. * For more details please refer to Titan User Guide,
1207 * Section 5.4.2 "Transmit Descriptor (TxD) Format".
1208 */
1209struct vxge_hw_fifo_txd {
1210 u64 control_0;
1211#define VXGE_HW_FIFO_TXD_LIST_OWN_ADAPTER vxge_mBIT(7)
1212
1213#define VXGE_HW_FIFO_TXD_T_CODE_GET(ctrl0) vxge_bVALn(ctrl0, 12, 4)
1214#define VXGE_HW_FIFO_TXD_T_CODE(val) vxge_vBIT(val, 12, 4)
1215#define VXGE_HW_FIFO_TXD_T_CODE_UNUSED VXGE_HW_FIFO_T_CODE_UNUSED
1216
1217
1218#define VXGE_HW_FIFO_TXD_GATHER_CODE(val) vxge_vBIT(val, 22, 2)
1219#define VXGE_HW_FIFO_TXD_GATHER_CODE_FIRST VXGE_HW_FIFO_GATHER_CODE_FIRST
1220#define VXGE_HW_FIFO_TXD_GATHER_CODE_LAST VXGE_HW_FIFO_GATHER_CODE_LAST
1221
1222
1223#define VXGE_HW_FIFO_TXD_LSO_EN vxge_mBIT(30)
1224
1225#define VXGE_HW_FIFO_TXD_LSO_MSS(val) vxge_vBIT(val, 34, 14)
1226
1227#define VXGE_HW_FIFO_TXD_BUFFER_SIZE(val) vxge_vBIT(val, 48, 16)
1228
1229 u64 control_1;
1230#define VXGE_HW_FIFO_TXD_TX_CKO_IPV4_EN vxge_mBIT(5)
1231#define VXGE_HW_FIFO_TXD_TX_CKO_TCP_EN vxge_mBIT(6)
1232#define VXGE_HW_FIFO_TXD_TX_CKO_UDP_EN vxge_mBIT(7)
1233#define VXGE_HW_FIFO_TXD_VLAN_ENABLE vxge_mBIT(15)
1234
1235#define VXGE_HW_FIFO_TXD_VLAN_TAG(val) vxge_vBIT(val, 16, 16)
1236
1237#define VXGE_HW_FIFO_TXD_INT_NUMBER(val) vxge_vBIT(val, 34, 6)
1238
1239#define VXGE_HW_FIFO_TXD_INT_TYPE_PER_LIST vxge_mBIT(46)
1240#define VXGE_HW_FIFO_TXD_INT_TYPE_UTILZ vxge_mBIT(47)
1241
1242 u64 buffer_pointer;
1243
1244 u64 host_control;
1245};
1246
1247/**
1248 * struct vxge_hw_ring_rxd_1 - One buffer mode RxD for ring
1249 * @host_control: This field is exclusively for host use and is "readonly"
1250 * from the adapter's perspective.
1251 * @control_0:Bits 0 to 6 - RTH_Bucket get
1252 * Bit 7 - Own Descriptor ownership bit. This bit is set to 1
1253 * by the host, and is set to 0 by the adapter.
1254 * 0 - Host owns RxD and buffer.
1255 * 1 - The adapter owns RxD and buffer.
1256 * Bit 8 - Fast_Path_Eligible When set, indicates that the
1257 * received frame meets all of the criteria for fast path processing.
1258 * The required criteria are as follows:
1259 * !SYN &
1260 * (Transfer_Code == "Transfer OK") &
1261 * (!Is_IP_Fragment) &
1262 * ((Is_IPv4 & computed_L3_checksum == 0xFFFF) |
1263 * (Is_IPv6)) &
1264 * ((Is_TCP & computed_L4_checksum == 0xFFFF) |
1265 * (Is_UDP & (computed_L4_checksum == 0xFFFF |
1266 * computed _L4_checksum == 0x0000)))
1267 * (same meaning for all RxD buffer modes)
1268 * Bit 9 - L3 Checksum Correct
1269 * Bit 10 - L4 Checksum Correct
1270 * Bit 11 - Reserved
1271 * Bit 12 to 15 - This field is written by the adapter. It is
1272 * used to report the status of the frame transfer to the host.
1273 * 0x0 - Transfer OK
1274 * 0x4 - RDA Failure During Transfer
1275 * 0x5 - Unparseable Packet, such as unknown IPv6 header.
1276 * 0x6 - Frame integrity error (FCS or ECC).
1277 * 0x7 - Buffer Size Error. The provided buffer(s) were not
1278 * appropriately sized and data loss occurred.
1279 * 0x8 - Internal ECC Error. RxD corrupted.
1280 * 0x9 - IPv4 Checksum error
1281 * 0xA - TCP/UDP Checksum error
1282 * 0xF - Unknown Error or Multiple Error. Indicates an
1283 * unknown problem or that more than one of transfer codes is set.
1284 * Bit 16 - SYN The adapter sets this field to indicate that
1285 * the incoming frame contained a TCP segment with its SYN bit
1286 * set and its ACK bit NOT set. (same meaning for all RxD buffer
1287 * modes)
1288 * Bit 17 - Is ICMP
1289 * Bit 18 - RTH_SPDM_HIT Set to 1 if there was a match in the
1290 * Socket Pair Direct Match Table and the frame was steered based
1291 * on SPDM.
1292 * Bit 19 - RTH_IT_HIT Set to 1 if there was a match in the
1293 * Indirection Table and the frame was steered based on hash
1294 * indirection.
1295 * Bit 20 to 23 - RTH_HASH_TYPE Indicates the function (hash
1296 * type) that was used to calculate the hash.
1297 * Bit 19 - IS_VLAN Set to '1' if the frame was/is VLAN
1298 * tagged.
1299 * Bit 25 to 26 - ETHER_ENCAP Reflects the Ethernet encapsulation
1300 * of the received frame.
1301 * 0x0 - Ethernet DIX
1302 * 0x1 - LLC
1303 * 0x2 - SNAP (includes Jumbo-SNAP)
1304 * 0x3 - IPX
1305 * Bit 27 - IS_IPV4 Set to '1' if the frame contains an IPv4 packet.
1306 * Bit 28 - IS_IPV6 Set to '1' if the frame contains an IPv6 packet.
1307 * Bit 29 - IS_IP_FRAG Set to '1' if the frame contains a fragmented
1308 * IP packet.
1309 * Bit 30 - IS_TCP Set to '1' if the frame contains a TCP segment.
1310 * Bit 31 - IS_UDP Set to '1' if the frame contains a UDP message.
1311 * Bit 32 to 47 - L3_Checksum[0:15] The IPv4 checksum value that
1312 * arrived with the frame. If the resulting computed IPv4 header
1313 * checksum for the frame did not produce the expected 0xFFFF value,
1314 * then the transfer code would be set to 0x9.
1315 * Bit 48 to 63 - L4_Checksum[0:15] The TCP/UDP checksum value that
1316 * arrived with the frame. If the resulting computed TCP/UDP checksum
1317 * for the frame did not produce the expected 0xFFFF value, then the
1318 * transfer code would be set to 0xA.
1319 * @control_1:Bits 0 to 1 - Reserved
1320 * Bits 2 to 15 - Buffer0_Size.This field is set by the host and
1321 * eventually overwritten by the adapter. The host writes the
1322 * available buffer size in bytes when it passes the descriptor to
1323 * the adapter. When a frame is delivered the host, the adapter
1324 * populates this field with the number of bytes written into the
1325 * buffer. The largest supported buffer is 16, 383 bytes.
1326 * Bit 16 to 47 - RTH Hash Value 32-bit RTH hash value. Only valid if
1327 * RTH_HASH_TYPE (Control_0, bits 20:23) is nonzero.
1328 * Bit 48 to 63 - VLAN_Tag[0:15] The contents of the variable portion
1329 * of the VLAN tag, if one was detected by the adapter. This field is
1330 * populated even if VLAN-tag stripping is enabled.
1331 * @buffer0_ptr: Pointer to buffer. This field is populated by the driver.
1332 *
1333 * One buffer mode RxD for ring structure
1334 */
1335struct vxge_hw_ring_rxd_1 {
1336 u64 host_control;
1337 u64 control_0;
1338#define VXGE_HW_RING_RXD_RTH_BUCKET_GET(ctrl0) vxge_bVALn(ctrl0, 0, 7)
1339
1340#define VXGE_HW_RING_RXD_LIST_OWN_ADAPTER vxge_mBIT(7)
1341
1342#define VXGE_HW_RING_RXD_FAST_PATH_ELIGIBLE_GET(ctrl0) vxge_bVALn(ctrl0, 8, 1)
1343
1344#define VXGE_HW_RING_RXD_L3_CKSUM_CORRECT_GET(ctrl0) vxge_bVALn(ctrl0, 9, 1)
1345
1346#define VXGE_HW_RING_RXD_L4_CKSUM_CORRECT_GET(ctrl0) vxge_bVALn(ctrl0, 10, 1)
1347
1348#define VXGE_HW_RING_RXD_T_CODE_GET(ctrl0) vxge_bVALn(ctrl0, 12, 4)
1349#define VXGE_HW_RING_RXD_T_CODE(val) vxge_vBIT(val, 12, 4)
1350
1351#define VXGE_HW_RING_RXD_T_CODE_UNUSED VXGE_HW_RING_T_CODE_UNUSED
1352
1353#define VXGE_HW_RING_RXD_SYN_GET(ctrl0) vxge_bVALn(ctrl0, 16, 1)
1354
1355#define VXGE_HW_RING_RXD_IS_ICMP_GET(ctrl0) vxge_bVALn(ctrl0, 17, 1)
1356
1357#define VXGE_HW_RING_RXD_RTH_SPDM_HIT_GET(ctrl0) vxge_bVALn(ctrl0, 18, 1)
1358
1359#define VXGE_HW_RING_RXD_RTH_IT_HIT_GET(ctrl0) vxge_bVALn(ctrl0, 19, 1)
1360
1361#define VXGE_HW_RING_RXD_RTH_HASH_TYPE_GET(ctrl0) vxge_bVALn(ctrl0, 20, 4)
1362
1363#define VXGE_HW_RING_RXD_IS_VLAN_GET(ctrl0) vxge_bVALn(ctrl0, 24, 1)
1364
1365#define VXGE_HW_RING_RXD_ETHER_ENCAP_GET(ctrl0) vxge_bVALn(ctrl0, 25, 2)
1366
1367#define VXGE_HW_RING_RXD_FRAME_PROTO_GET(ctrl0) vxge_bVALn(ctrl0, 27, 5)
1368
1369#define VXGE_HW_RING_RXD_L3_CKSUM_GET(ctrl0) vxge_bVALn(ctrl0, 32, 16)
1370
1371#define VXGE_HW_RING_RXD_L4_CKSUM_GET(ctrl0) vxge_bVALn(ctrl0, 48, 16)
1372
1373 u64 control_1;
1374
1375#define VXGE_HW_RING_RXD_1_BUFFER0_SIZE_GET(ctrl1) vxge_bVALn(ctrl1, 2, 14)
1376#define VXGE_HW_RING_RXD_1_BUFFER0_SIZE(val) vxge_vBIT(val, 2, 14)
1377#define VXGE_HW_RING_RXD_1_BUFFER0_SIZE_MASK vxge_vBIT(0x3FFF, 2, 14)
1378
1379#define VXGE_HW_RING_RXD_1_RTH_HASH_VAL_GET(ctrl1) vxge_bVALn(ctrl1, 16, 32)
1380
1381#define VXGE_HW_RING_RXD_VLAN_TAG_GET(ctrl1) vxge_bVALn(ctrl1, 48, 16)
1382
1383 u64 buffer0_ptr;
1384};
1385
1386enum vxge_hw_rth_algoritms {
1387 RTH_ALG_JENKINS = 0,
1388 RTH_ALG_MS_RSS = 1,
1389 RTH_ALG_CRC32C = 2
1390};
1391
1392/**
1393 * struct vxge_hw_rth_hash_types - RTH hash types.
1394 * @hash_type_tcpipv4_en: Enables RTH field type HashTypeTcpIPv4
1395 * @hash_type_ipv4_en: Enables RTH field type HashTypeIPv4
1396 * @hash_type_tcpipv6_en: Enables RTH field type HashTypeTcpIPv6
1397 * @hash_type_ipv6_en: Enables RTH field type HashTypeIPv6
1398 * @hash_type_tcpipv6ex_en: Enables RTH field type HashTypeTcpIPv6Ex
1399 * @hash_type_ipv6ex_en: Enables RTH field type HashTypeIPv6Ex
1400 *
1401 * Used to pass RTH hash types to rts_rts_set.
1402 *
1403 * See also: vxge_hw_vpath_rts_rth_set(), vxge_hw_vpath_rts_rth_get().
1404 */
1405struct vxge_hw_rth_hash_types {
Jon Mason47f01db2010-11-11 04:25:53 +00001406 u8 hash_type_tcpipv4_en:1,
1407 hash_type_ipv4_en:1,
1408 hash_type_tcpipv6_en:1,
1409 hash_type_ipv6_en:1,
1410 hash_type_tcpipv6ex_en:1,
1411 hash_type_ipv6ex_en:1;
Ramkrishna Vepa40a3a912009-04-01 18:14:40 +00001412};
1413
Ramkrishna Vepa40a3a912009-04-01 18:14:40 +00001414void vxge_hw_device_debug_set(
1415 struct __vxge_hw_device *devh,
1416 enum vxge_debug_level level,
1417 u32 mask);
1418
1419u32
1420vxge_hw_device_error_level_get(struct __vxge_hw_device *devh);
1421
1422u32
1423vxge_hw_device_trace_level_get(struct __vxge_hw_device *devh);
1424
Ramkrishna Vepa40a3a912009-04-01 18:14:40 +00001425/**
1426 * vxge_hw_ring_rxd_size_get - Get the size of ring descriptor.
1427 * @buf_mode: Buffer mode (1, 3 or 5)
1428 *
1429 * This function returns the size of RxD for given buffer mode
1430 */
1431static inline u32 vxge_hw_ring_rxd_size_get(u32 buf_mode)
1432{
1433 return sizeof(struct vxge_hw_ring_rxd_1);
1434}
1435
1436/**
1437 * vxge_hw_ring_rxds_per_block_get - Get the number of rxds per block.
1438 * @buf_mode: Buffer mode (1 buffer mode only)
1439 *
1440 * This function returns the number of RxD for RxD block for given buffer mode
1441 */
1442static inline u32 vxge_hw_ring_rxds_per_block_get(u32 buf_mode)
1443{
1444 return (u32)((VXGE_HW_BLOCK_SIZE-16) /
1445 sizeof(struct vxge_hw_ring_rxd_1));
1446}
1447
1448/**
1449 * vxge_hw_ring_rxd_1b_set - Prepare 1-buffer-mode descriptor.
1450 * @rxdh: Descriptor handle.
1451 * @dma_pointer: DMA address of a single receive buffer this descriptor
1452 * should carry. Note that by the time vxge_hw_ring_rxd_1b_set is called,
1453 * the receive buffer should be already mapped to the device
1454 * @size: Size of the receive @dma_pointer buffer.
1455 *
1456 * Prepare 1-buffer-mode Rx descriptor for posting
1457 * (via vxge_hw_ring_rxd_post()).
1458 *
1459 * This inline helper-function does not return any parameters and always
1460 * succeeds.
1461 *
1462 */
1463static inline
1464void vxge_hw_ring_rxd_1b_set(
1465 void *rxdh,
1466 dma_addr_t dma_pointer,
1467 u32 size)
1468{
1469 struct vxge_hw_ring_rxd_1 *rxdp = (struct vxge_hw_ring_rxd_1 *)rxdh;
1470 rxdp->buffer0_ptr = dma_pointer;
1471 rxdp->control_1 &= ~VXGE_HW_RING_RXD_1_BUFFER0_SIZE_MASK;
1472 rxdp->control_1 |= VXGE_HW_RING_RXD_1_BUFFER0_SIZE(size);
1473}
1474
1475/**
1476 * vxge_hw_ring_rxd_1b_get - Get data from the completed 1-buf
1477 * descriptor.
1478 * @vpath_handle: Virtual Path handle.
1479 * @rxdh: Descriptor handle.
1480 * @dma_pointer: DMA address of a single receive buffer this descriptor
1481 * carries. Returned by HW.
1482 * @pkt_length: Length (in bytes) of the data in the buffer pointed by
1483 *
1484 * Retrieve protocol data from the completed 1-buffer-mode Rx descriptor.
1485 * This inline helper-function uses completed descriptor to populate receive
1486 * buffer pointer and other "out" parameters. The function always succeeds.
1487 *
1488 */
1489static inline
1490void vxge_hw_ring_rxd_1b_get(
1491 struct __vxge_hw_ring *ring_handle,
1492 void *rxdh,
1493 u32 *pkt_length)
1494{
1495 struct vxge_hw_ring_rxd_1 *rxdp = (struct vxge_hw_ring_rxd_1 *)rxdh;
1496
1497 *pkt_length =
1498 (u32)VXGE_HW_RING_RXD_1_BUFFER0_SIZE_GET(rxdp->control_1);
1499}
1500
1501/**
1502 * vxge_hw_ring_rxd_1b_info_get - Get extended information associated with
1503 * a completed receive descriptor for 1b mode.
1504 * @vpath_handle: Virtual Path handle.
1505 * @rxdh: Descriptor handle.
1506 * @rxd_info: Descriptor information
1507 *
1508 * Retrieve extended information associated with a completed receive descriptor.
1509 *
1510 */
1511static inline
1512void vxge_hw_ring_rxd_1b_info_get(
1513 struct __vxge_hw_ring *ring_handle,
1514 void *rxdh,
1515 struct vxge_hw_ring_rxd_info *rxd_info)
1516{
1517
1518 struct vxge_hw_ring_rxd_1 *rxdp = (struct vxge_hw_ring_rxd_1 *)rxdh;
1519 rxd_info->syn_flag =
1520 (u32)VXGE_HW_RING_RXD_SYN_GET(rxdp->control_0);
1521 rxd_info->is_icmp =
1522 (u32)VXGE_HW_RING_RXD_IS_ICMP_GET(rxdp->control_0);
1523 rxd_info->fast_path_eligible =
1524 (u32)VXGE_HW_RING_RXD_FAST_PATH_ELIGIBLE_GET(rxdp->control_0);
1525 rxd_info->l3_cksum_valid =
1526 (u32)VXGE_HW_RING_RXD_L3_CKSUM_CORRECT_GET(rxdp->control_0);
1527 rxd_info->l3_cksum =
1528 (u32)VXGE_HW_RING_RXD_L3_CKSUM_GET(rxdp->control_0);
1529 rxd_info->l4_cksum_valid =
1530 (u32)VXGE_HW_RING_RXD_L4_CKSUM_CORRECT_GET(rxdp->control_0);
1531 rxd_info->l4_cksum =
Joe Perchesa419aef2009-08-18 11:18:35 -07001532 (u32)VXGE_HW_RING_RXD_L4_CKSUM_GET(rxdp->control_0);
Ramkrishna Vepa40a3a912009-04-01 18:14:40 +00001533 rxd_info->frame =
1534 (u32)VXGE_HW_RING_RXD_ETHER_ENCAP_GET(rxdp->control_0);
1535 rxd_info->proto =
1536 (u32)VXGE_HW_RING_RXD_FRAME_PROTO_GET(rxdp->control_0);
1537 rxd_info->is_vlan =
1538 (u32)VXGE_HW_RING_RXD_IS_VLAN_GET(rxdp->control_0);
1539 rxd_info->vlan =
1540 (u32)VXGE_HW_RING_RXD_VLAN_TAG_GET(rxdp->control_1);
1541 rxd_info->rth_bucket =
1542 (u32)VXGE_HW_RING_RXD_RTH_BUCKET_GET(rxdp->control_0);
1543 rxd_info->rth_it_hit =
1544 (u32)VXGE_HW_RING_RXD_RTH_IT_HIT_GET(rxdp->control_0);
1545 rxd_info->rth_spdm_hit =
1546 (u32)VXGE_HW_RING_RXD_RTH_SPDM_HIT_GET(rxdp->control_0);
1547 rxd_info->rth_hash_type =
1548 (u32)VXGE_HW_RING_RXD_RTH_HASH_TYPE_GET(rxdp->control_0);
1549 rxd_info->rth_value =
1550 (u32)VXGE_HW_RING_RXD_1_RTH_HASH_VAL_GET(rxdp->control_1);
1551}
1552
1553/**
1554 * vxge_hw_ring_rxd_private_get - Get driver private per-descriptor data
1555 * of 1b mode 3b mode ring.
1556 * @rxdh: Descriptor handle.
1557 *
1558 * Returns: private driver info associated with the descriptor.
1559 * driver requests per-descriptor space via vxge_hw_ring_attr.
1560 *
1561 */
1562static inline void *vxge_hw_ring_rxd_private_get(void *rxdh)
1563{
1564 struct vxge_hw_ring_rxd_1 *rxdp = (struct vxge_hw_ring_rxd_1 *)rxdh;
1565 return (void *)(size_t)rxdp->host_control;
1566}
1567
1568/**
1569 * vxge_hw_fifo_txdl_cksum_set_bits - Offload checksum.
1570 * @txdlh: Descriptor handle.
1571 * @cksum_bits: Specifies which checksums are to be offloaded: IPv4,
1572 * and/or TCP and/or UDP.
1573 *
1574 * Ask Titan to calculate IPv4 & transport checksums for _this_ transmit
1575 * descriptor.
1576 * This API is part of the preparation of the transmit descriptor for posting
1577 * (via vxge_hw_fifo_txdl_post()). The related "preparation" APIs include
1578 * vxge_hw_fifo_txdl_mss_set(), vxge_hw_fifo_txdl_buffer_set_aligned(),
1579 * and vxge_hw_fifo_txdl_buffer_set().
1580 * All these APIs fill in the fields of the fifo descriptor,
1581 * in accordance with the Titan specification.
1582 *
1583 */
1584static inline void vxge_hw_fifo_txdl_cksum_set_bits(void *txdlh, u64 cksum_bits)
1585{
1586 struct vxge_hw_fifo_txd *txdp = (struct vxge_hw_fifo_txd *)txdlh;
1587 txdp->control_1 |= cksum_bits;
1588}
1589
1590/**
1591 * vxge_hw_fifo_txdl_mss_set - Set MSS.
1592 * @txdlh: Descriptor handle.
1593 * @mss: MSS size for _this_ TCP connection. Passed by TCP stack down to the
1594 * driver, which in turn inserts the MSS into the @txdlh.
1595 *
1596 * This API is part of the preparation of the transmit descriptor for posting
1597 * (via vxge_hw_fifo_txdl_post()). The related "preparation" APIs include
1598 * vxge_hw_fifo_txdl_buffer_set(), vxge_hw_fifo_txdl_buffer_set_aligned(),
1599 * and vxge_hw_fifo_txdl_cksum_set_bits().
1600 * All these APIs fill in the fields of the fifo descriptor,
1601 * in accordance with the Titan specification.
1602 *
1603 */
1604static inline void vxge_hw_fifo_txdl_mss_set(void *txdlh, int mss)
1605{
1606 struct vxge_hw_fifo_txd *txdp = (struct vxge_hw_fifo_txd *)txdlh;
1607
1608 txdp->control_0 |= VXGE_HW_FIFO_TXD_LSO_EN;
1609 txdp->control_0 |= VXGE_HW_FIFO_TXD_LSO_MSS(mss);
1610}
1611
1612/**
1613 * vxge_hw_fifo_txdl_vlan_set - Set VLAN tag.
1614 * @txdlh: Descriptor handle.
1615 * @vlan_tag: 16bit VLAN tag.
1616 *
1617 * Insert VLAN tag into specified transmit descriptor.
1618 * The actual insertion of the tag into outgoing frame is done by the hardware.
1619 */
1620static inline void vxge_hw_fifo_txdl_vlan_set(void *txdlh, u16 vlan_tag)
1621{
1622 struct vxge_hw_fifo_txd *txdp = (struct vxge_hw_fifo_txd *)txdlh;
1623
1624 txdp->control_1 |= VXGE_HW_FIFO_TXD_VLAN_ENABLE;
1625 txdp->control_1 |= VXGE_HW_FIFO_TXD_VLAN_TAG(vlan_tag);
1626}
1627
1628/**
1629 * vxge_hw_fifo_txdl_private_get - Retrieve per-descriptor private data.
1630 * @txdlh: Descriptor handle.
1631 *
1632 * Retrieve per-descriptor private data.
1633 * Note that driver requests per-descriptor space via
1634 * struct vxge_hw_fifo_attr passed to
1635 * vxge_hw_vpath_open().
1636 *
1637 * Returns: private driver data associated with the descriptor.
1638 */
1639static inline void *vxge_hw_fifo_txdl_private_get(void *txdlh)
1640{
1641 struct vxge_hw_fifo_txd *txdp = (struct vxge_hw_fifo_txd *)txdlh;
1642
1643 return (void *)(size_t)txdp->host_control;
1644}
1645
1646/**
1647 * struct vxge_hw_ring_attr - Ring open "template".
1648 * @callback: Ring completion callback. HW invokes the callback when there
1649 * are new completions on that ring. In many implementations
1650 * the @callback executes in the hw interrupt context.
1651 * @rxd_init: Ring's descriptor-initialize callback.
1652 * See vxge_hw_ring_rxd_init_f{}.
1653 * If not NULL, HW invokes the callback when opening
1654 * the ring.
1655 * @rxd_term: Ring's descriptor-terminate callback. If not NULL,
1656 * HW invokes the callback when closing the corresponding ring.
1657 * See also vxge_hw_ring_rxd_term_f{}.
1658 * @userdata: User-defined "context" of _that_ ring. Passed back to the
1659 * user as one of the @callback, @rxd_init, and @rxd_term arguments.
1660 * @per_rxd_space: If specified (i.e., greater than zero): extra space
1661 * reserved by HW per each receive descriptor.
1662 * Can be used to store
1663 * and retrieve on completion, information specific
1664 * to the driver.
1665 *
1666 * Ring open "template". User fills the structure with ring
1667 * attributes and passes it to vxge_hw_vpath_open().
1668 */
1669struct vxge_hw_ring_attr {
1670 enum vxge_hw_status (*callback)(
1671 struct __vxge_hw_ring *ringh,
1672 void *rxdh,
1673 u8 t_code,
1674 void *userdata);
1675
1676 enum vxge_hw_status (*rxd_init)(
1677 void *rxdh,
1678 void *userdata);
1679
1680 void (*rxd_term)(
1681 void *rxdh,
1682 enum vxge_hw_rxd_state state,
1683 void *userdata);
1684
1685 void *userdata;
1686 u32 per_rxd_space;
1687};
1688
1689/**
1690 * function vxge_hw_fifo_callback_f - FIFO callback.
1691 * @vpath_handle: Virtual path whose Fifo "containing" 1 or more completed
1692 * descriptors.
1693 * @txdlh: First completed descriptor.
1694 * @txdl_priv: Pointer to per txdl space allocated
1695 * @t_code: Transfer code, as per Titan User Guide.
1696 * Returned by HW.
1697 * @host_control: Opaque 64bit data stored by driver inside the Titan
1698 * descriptor prior to posting the latter on the fifo
1699 * via vxge_hw_fifo_txdl_post(). The @host_control is returned
1700 * as is to the driver with each completed descriptor.
1701 * @userdata: Opaque per-fifo data specified at fifo open
1702 * time, via vxge_hw_vpath_open().
1703 *
1704 * Fifo completion callback (type declaration). A single per-fifo
1705 * callback is specified at fifo open time, via
1706 * vxge_hw_vpath_open(). Typically gets called as part of the processing
1707 * of the Interrupt Service Routine.
1708 *
1709 * Fifo callback gets called by HW if, and only if, there is at least
1710 * one new completion on a given fifo. Upon processing the first @txdlh driver
1711 * is _supposed_ to continue consuming completions using:
1712 * - vxge_hw_fifo_txdl_next_completed()
1713 *
1714 * Note that failure to process new completions in a timely fashion
1715 * leads to VXGE_HW_INF_OUT_OF_DESCRIPTORS condition.
1716 *
1717 * Non-zero @t_code means failure to process transmit descriptor.
1718 *
1719 * In the "transmit" case the failure could happen, for instance, when the
1720 * link is down, in which case Titan completes the descriptor because it
1721 * is not able to send the data out.
1722 *
1723 * For details please refer to Titan User Guide.
1724 *
1725 * See also: vxge_hw_fifo_txdl_next_completed(), vxge_hw_fifo_txdl_term_f{}.
1726 */
1727/**
1728 * function vxge_hw_fifo_txdl_term_f - Terminate descriptor callback.
1729 * @txdlh: First completed descriptor.
1730 * @txdl_priv: Pointer to per txdl space allocated
1731 * @state: One of the enum vxge_hw_txdl_state{} enumerated states.
1732 * @userdata: Per-fifo user data (a.k.a. context) specified at
1733 * fifo open time, via vxge_hw_vpath_open().
1734 *
1735 * Terminate descriptor callback. Unless NULL is specified in the
1736 * struct vxge_hw_fifo_attr{} structure passed to vxge_hw_vpath_open()),
1737 * HW invokes the callback as part of closing fifo, prior to
1738 * de-allocating the ring and associated data structures
1739 * (including descriptors).
1740 * driver should utilize the callback to (for instance) unmap
1741 * and free DMA data buffers associated with the posted (state =
1742 * VXGE_HW_TXDL_STATE_POSTED) descriptors,
1743 * as well as other relevant cleanup functions.
1744 *
1745 * See also: struct vxge_hw_fifo_attr{}
1746 */
1747/**
1748 * struct vxge_hw_fifo_attr - Fifo open "template".
1749 * @callback: Fifo completion callback. HW invokes the callback when there
1750 * are new completions on that fifo. In many implementations
1751 * the @callback executes in the hw interrupt context.
1752 * @txdl_term: Fifo's descriptor-terminate callback. If not NULL,
1753 * HW invokes the callback when closing the corresponding fifo.
1754 * See also vxge_hw_fifo_txdl_term_f{}.
1755 * @userdata: User-defined "context" of _that_ fifo. Passed back to the
1756 * user as one of the @callback, and @txdl_term arguments.
1757 * @per_txdl_space: If specified (i.e., greater than zero): extra space
1758 * reserved by HW per each transmit descriptor. Can be used to
1759 * store, and retrieve on completion, information specific
1760 * to the driver.
1761 *
1762 * Fifo open "template". User fills the structure with fifo
1763 * attributes and passes it to vxge_hw_vpath_open().
1764 */
1765struct vxge_hw_fifo_attr {
1766
1767 enum vxge_hw_status (*callback)(
1768 struct __vxge_hw_fifo *fifo_handle,
1769 void *txdlh,
1770 enum vxge_hw_fifo_tcode t_code,
1771 void *userdata,
Benjamin LaHaiseff67df52009-08-04 10:21:03 +00001772 struct sk_buff ***skb_ptr,
1773 int nr_skb, int *more);
Ramkrishna Vepa40a3a912009-04-01 18:14:40 +00001774
1775 void (*txdl_term)(
1776 void *txdlh,
1777 enum vxge_hw_txdl_state state,
1778 void *userdata);
1779
1780 void *userdata;
1781 u32 per_txdl_space;
1782};
1783
1784/**
1785 * struct vxge_hw_vpath_attr - Attributes of virtual path
1786 * @vp_id: Identifier of Virtual Path
1787 * @ring_attr: Attributes of ring for non-offload receive
1788 * @fifo_attr: Attributes of fifo for non-offload transmit
1789 *
1790 * Attributes of virtual path. This structure is passed as parameter
1791 * to the vxge_hw_vpath_open() routine to set the attributes of ring and fifo.
1792 */
1793struct vxge_hw_vpath_attr {
1794 u32 vp_id;
1795 struct vxge_hw_ring_attr ring_attr;
1796 struct vxge_hw_fifo_attr fifo_attr;
1797};
1798
Ramkrishna Vepa40a3a912009-04-01 18:14:40 +00001799enum vxge_hw_status __devinit vxge_hw_device_hw_info_get(
1800 void __iomem *bar0,
1801 struct vxge_hw_device_hw_info *hw_info);
1802
Ramkrishna Vepa40a3a912009-04-01 18:14:40 +00001803enum vxge_hw_status __devinit vxge_hw_device_config_default_get(
1804 struct vxge_hw_device_config *device_config);
1805
1806/**
1807 * vxge_hw_device_link_state_get - Get link state.
1808 * @devh: HW device handle.
1809 *
1810 * Get link state.
1811 * Returns: link state.
1812 */
1813static inline
1814enum vxge_hw_device_link_state vxge_hw_device_link_state_get(
1815 struct __vxge_hw_device *devh)
1816{
1817 return devh->link_state;
1818}
1819
1820void vxge_hw_device_terminate(struct __vxge_hw_device *devh);
1821
1822const u8 *
1823vxge_hw_device_serial_number_get(struct __vxge_hw_device *devh);
1824
1825u16 vxge_hw_device_link_width_get(struct __vxge_hw_device *devh);
1826
1827const u8 *
1828vxge_hw_device_product_name_get(struct __vxge_hw_device *devh);
1829
1830enum vxge_hw_status __devinit vxge_hw_device_initialize(
1831 struct __vxge_hw_device **devh,
1832 struct vxge_hw_device_attr *attr,
1833 struct vxge_hw_device_config *device_config);
1834
1835enum vxge_hw_status vxge_hw_device_getpause_data(
1836 struct __vxge_hw_device *devh,
1837 u32 port,
1838 u32 *tx,
1839 u32 *rx);
1840
1841enum vxge_hw_status vxge_hw_device_setpause_data(
1842 struct __vxge_hw_device *devh,
1843 u32 port,
1844 u32 tx,
1845 u32 rx);
1846
1847static inline void *vxge_os_dma_malloc(struct pci_dev *pdev,
1848 unsigned long size,
1849 struct pci_dev **p_dmah,
1850 struct pci_dev **p_dma_acch)
1851{
1852 gfp_t flags;
1853 void *vaddr;
1854 unsigned long misaligned = 0;
Sreenivasa Honnur47231f72010-03-28 22:09:47 +00001855 int realloc_flag = 0;
Ramkrishna Vepa40a3a912009-04-01 18:14:40 +00001856 *p_dma_acch = *p_dmah = NULL;
1857
1858 if (in_interrupt())
1859 flags = GFP_ATOMIC | GFP_DMA;
1860 else
1861 flags = GFP_KERNEL | GFP_DMA;
Sreenivasa Honnur47231f72010-03-28 22:09:47 +00001862realloc:
Ramkrishna Vepa40a3a912009-04-01 18:14:40 +00001863 vaddr = kmalloc((size), flags);
1864 if (vaddr == NULL)
1865 return vaddr;
Sreenivasa Honnur47231f72010-03-28 22:09:47 +00001866 misaligned = (unsigned long)VXGE_ALIGN((unsigned long)vaddr,
Ramkrishna Vepa40a3a912009-04-01 18:14:40 +00001867 VXGE_CACHE_LINE_SIZE);
Sreenivasa Honnur47231f72010-03-28 22:09:47 +00001868 if (realloc_flag)
1869 goto out;
1870
1871 if (misaligned) {
1872 /* misaligned, free current one and try allocating
1873 * size + VXGE_CACHE_LINE_SIZE memory
1874 */
1875 kfree((void *) vaddr);
1876 size += VXGE_CACHE_LINE_SIZE;
1877 realloc_flag = 1;
1878 goto realloc;
1879 }
1880out:
Ramkrishna Vepa40a3a912009-04-01 18:14:40 +00001881 *(unsigned long *)p_dma_acch = misaligned;
1882 vaddr = (void *)((u8 *)vaddr + misaligned);
1883 return vaddr;
1884}
1885
Ramkrishna Vepa40a3a912009-04-01 18:14:40 +00001886/*
1887 * __vxge_hw_mempool_item_priv - will return pointer on per item private space
1888 */
1889static inline void*
1890__vxge_hw_mempool_item_priv(
1891 struct vxge_hw_mempool *mempool,
1892 u32 memblock_idx,
1893 void *item,
1894 u32 *memblock_item_idx)
1895{
1896 ptrdiff_t offset;
1897 void *memblock = mempool->memblocks_arr[memblock_idx];
1898
1899
1900 offset = (u32)((u8 *)item - (u8 *)memblock);
1901 vxge_assert(offset >= 0 && (u32)offset < mempool->memblock_size);
1902
1903 (*memblock_item_idx) = (u32) offset / mempool->item_size;
1904 vxge_assert((*memblock_item_idx) < mempool->items_per_memblock);
1905
1906 return (u8 *)mempool->memblocks_priv_arr[memblock_idx] +
1907 (*memblock_item_idx) * mempool->items_priv_size;
1908}
1909
Ramkrishna Vepa40a3a912009-04-01 18:14:40 +00001910/*
1911 * __vxge_hw_fifo_txdl_priv - Return the max fragments allocated
1912 * for the fifo.
1913 * @fifo: Fifo
1914 * @txdp: Poniter to a TxD
1915 */
1916static inline struct __vxge_hw_fifo_txdl_priv *
1917__vxge_hw_fifo_txdl_priv(
1918 struct __vxge_hw_fifo *fifo,
1919 struct vxge_hw_fifo_txd *txdp)
1920{
1921 return (struct __vxge_hw_fifo_txdl_priv *)
1922 (((char *)((ulong)txdp->host_control)) +
1923 fifo->per_txdl_space);
1924}
1925
1926enum vxge_hw_status vxge_hw_vpath_open(
1927 struct __vxge_hw_device *devh,
1928 struct vxge_hw_vpath_attr *attr,
1929 struct __vxge_hw_vpath_handle **vpath_handle);
1930
Ramkrishna Vepa40a3a912009-04-01 18:14:40 +00001931enum vxge_hw_status vxge_hw_vpath_close(
1932 struct __vxge_hw_vpath_handle *vpath_handle);
1933
1934enum vxge_hw_status
1935vxge_hw_vpath_reset(
1936 struct __vxge_hw_vpath_handle *vpath_handle);
1937
1938enum vxge_hw_status
1939vxge_hw_vpath_recover_from_reset(
1940 struct __vxge_hw_vpath_handle *vpath_handle);
1941
1942void
1943vxge_hw_vpath_enable(struct __vxge_hw_vpath_handle *vp);
1944
1945enum vxge_hw_status
1946vxge_hw_vpath_check_leak(struct __vxge_hw_ring *ringh);
1947
1948enum vxge_hw_status vxge_hw_vpath_mtu_set(
1949 struct __vxge_hw_vpath_handle *vpath_handle,
1950 u32 new_mtu);
1951
Ramkrishna Vepa40a3a912009-04-01 18:14:40 +00001952void
1953vxge_hw_vpath_rx_doorbell_init(struct __vxge_hw_vpath_handle *vp);
1954
Ramkrishna Vepa40a3a912009-04-01 18:14:40 +00001955
1956#ifndef readq
1957static inline u64 readq(void __iomem *addr)
1958{
1959 u64 ret = 0;
1960 ret = readl(addr + 4);
1961 ret <<= 32;
1962 ret |= readl(addr);
1963
1964 return ret;
1965}
1966#endif
1967
1968#ifndef writeq
1969static inline void writeq(u64 val, void __iomem *addr)
1970{
1971 writel((u32) (val), addr);
1972 writel((u32) (val >> 32), (addr + 4));
1973}
1974#endif
1975
1976static inline void __vxge_hw_pio_mem_write32_upper(u32 val, void __iomem *addr)
1977{
1978 writel(val, addr + 4);
1979}
1980
1981static inline void __vxge_hw_pio_mem_write32_lower(u32 val, void __iomem *addr)
1982{
1983 writel(val, addr);
1984}
1985
Ramkrishna Vepa40a3a912009-04-01 18:14:40 +00001986enum vxge_hw_status
1987vxge_hw_device_flick_link_led(struct __vxge_hw_device *devh, u64 on_off);
1988
1989enum vxge_hw_status
Sreenivasa Honnurfa41fd12009-10-05 01:56:35 +00001990vxge_hw_vpath_strip_fcs_check(struct __vxge_hw_device *hldev, u64 vpath_mask);
stephen hemminger42821a52010-10-21 07:50:53 +00001991
Ramkrishna Vepa40a3a912009-04-01 18:14:40 +00001992/**
Jon Masonddd62722010-11-11 04:25:55 +00001993 * vxge_debug_ll
Ramkrishna Vepa40a3a912009-04-01 18:14:40 +00001994 * @level: level of debug verbosity.
1995 * @mask: mask for the debug
1996 * @buf: Circular buffer for tracing
1997 * @fmt: printf like format string
1998 *
1999 * Provides logging facilities. Can be customized on per-module
2000 * basis or/and with debug levels. Input parameters, except
2001 * module and level, are the same as posix printf. This function
2002 * may be compiled out if DEBUG macro was never defined.
2003 * See also: enum vxge_debug_level{}.
2004 */
Ramkrishna Vepa40a3a912009-04-01 18:14:40 +00002005#if (VXGE_COMPONENT_LL & VXGE_DEBUG_MODULE_MASK)
Jon Masonddd62722010-11-11 04:25:55 +00002006#define vxge_debug_ll(level, mask, fmt, ...) do { \
2007 if ((level >= VXGE_ERR && VXGE_COMPONENT_LL & VXGE_DEBUG_ERR_MASK) || \
2008 (level >= VXGE_TRACE && VXGE_COMPONENT_LL & VXGE_DEBUG_TRACE_MASK))\
2009 if ((mask & VXGE_DEBUG_MASK) == mask) \
2010 printk(fmt "\n", __VA_ARGS__); \
2011} while (0)
Ramkrishna Vepa40a3a912009-04-01 18:14:40 +00002012#else
2013#define vxge_debug_ll(level, mask, fmt, ...)
2014#endif
2015
2016enum vxge_hw_status vxge_hw_vpath_rts_rth_itable_set(
2017 struct __vxge_hw_vpath_handle **vpath_handles,
2018 u32 vpath_count,
2019 u8 *mtable,
2020 u8 *itable,
2021 u32 itable_size);
2022
2023enum vxge_hw_status vxge_hw_vpath_rts_rth_set(
2024 struct __vxge_hw_vpath_handle *vpath_handle,
2025 enum vxge_hw_rth_algoritms algorithm,
2026 struct vxge_hw_rth_hash_types *hash_type,
2027 u16 bucket_size);
2028
Sreenivasa Honnurcb27ec62010-04-08 01:48:57 -07002029enum vxge_hw_status
2030__vxge_hw_device_is_privilaged(u32 host_type, u32 func_id);
Jon Mason4d2a5b42010-11-11 04:25:54 +00002031
2032#define VXGE_HW_MIN_SUCCESSIVE_IDLE_COUNT 5
2033#define VXGE_HW_MAX_POLLING_COUNT 100
2034
2035int vxge_hw_vpath_wait_receive_idle(struct __vxge_hw_device *hldev, u32 vp_id);
2036
2037void vxge_hw_device_wait_receive_idle(struct __vxge_hw_device *hldev);
Ramkrishna Vepa40a3a912009-04-01 18:14:40 +00002038#endif