2 * Copyright (c) 2002-2007 Neterion, Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 #define XGE_PCI_VENDOR_ID 0x17D5
33 #define XGE_PCI_DEVICE_ID_XENA_1 0x5731
34 #define XGE_PCI_DEVICE_ID_XENA_2 0x5831
35 #define XGE_PCI_DEVICE_ID_HERC_1 0x5732
36 #define XGE_PCI_DEVICE_ID_HERC_2 0x5832
37 #define XGE_PCI_DEVICE_ID_TITAN_1 0x5733
38 #define XGE_PCI_DEVICE_ID_TITAN_2 0x5833
40 #define XGE_DRIVER_NAME "Xge driver"
41 #define XGE_DRIVER_VENDOR "Neterion, Inc"
42 #define XGE_CHIP_FAMILY "Xframe"
43 #define XGE_SUPPORTED_MEDIA_0 "Fiber"
45 #include <dev/nxge/include/version.h>
47 #if defined(__cplusplus)
48 #define __EXTERN_BEGIN_DECLS extern "C" {
49 #define __EXTERN_END_DECLS }
51 #define __EXTERN_BEGIN_DECLS
52 #define __EXTERN_END_DECLS
57 /*---------------------------- DMA attributes ------------------------------*/
58 /* Used in xge_os_dma_malloc() and xge_os_dma_map() */
59 /*---------------------------- DMA attributes ------------------------------*/
61 /* XGE_OS_DMA_REQUIRES_SYNC - should be defined or
62 NOT defined in the Makefile */
63 #define XGE_OS_DMA_CACHELINE_ALIGNED 0x1
64 /* Either STREAMING or CONSISTENT should be used.
65 The combination of both or none is invalid */
66 #define XGE_OS_DMA_STREAMING 0x2
67 #define XGE_OS_DMA_CONSISTENT 0x4
68 #define XGE_OS_SPRINTF_STRLEN 64
70 /*---------------------------- common stuffs -------------------------------*/
72 #define XGE_OS_LLXFMT "%llx"
73 #define XGE_OS_NEWLINE "\n"
74 #ifdef XGE_OS_MEMORY_CHECK
82 #define XGE_OS_MALLOC_CNT_MAX 64*1024
83 extern xge_os_malloc_t g_malloc_arr[XGE_OS_MALLOC_CNT_MAX];
84 extern int g_malloc_cnt;
86 #define XGE_OS_MEMORY_CHECK_MALLOC(_vaddr, _size, _file, _line) { \
89 for (index_mem_chk=0; index_mem_chk < g_malloc_cnt; index_mem_chk++) { \
90 if (g_malloc_arr[index_mem_chk].ptr == NULL) { \
94 if (index_mem_chk == g_malloc_cnt) { \
96 if (g_malloc_cnt >= XGE_OS_MALLOC_CNT_MAX) { \
97 xge_os_bug("g_malloc_cnt exceed %d", \
98 XGE_OS_MALLOC_CNT_MAX); \
101 g_malloc_arr[index_mem_chk].ptr = _vaddr; \
102 g_malloc_arr[index_mem_chk].size = _size; \
103 g_malloc_arr[index_mem_chk].file = _file; \
104 g_malloc_arr[index_mem_chk].line = _line; \
105 for (index_mem_chk=0; index_mem_chk<_size; index_mem_chk++) { \
106 *((char *)_vaddr+index_mem_chk) = 0x5a; \
111 #define XGE_OS_MEMORY_CHECK_FREE(_vaddr, _check_size) { \
113 for (index_mem_chk=0; index_mem_chk < XGE_OS_MALLOC_CNT_MAX; index_mem_chk++) { \
114 if (g_malloc_arr[index_mem_chk].ptr == _vaddr) { \
115 g_malloc_arr[index_mem_chk].ptr = NULL; \
116 if(_check_size && g_malloc_arr[index_mem_chk].size!=_check_size) { \
117 xge_os_printf("OSPAL: freeing with wrong " \
118 "size %d! allocated at %s:%d:"XGE_OS_LLXFMT":%d", \
120 g_malloc_arr[index_mem_chk].file, \
121 g_malloc_arr[index_mem_chk].line, \
122 (unsigned long long)(ulong_t) \
123 g_malloc_arr[index_mem_chk].ptr, \
124 g_malloc_arr[index_mem_chk].size); \
129 if (index_mem_chk == XGE_OS_MALLOC_CNT_MAX) { \
130 xge_os_printf("OSPAL: ptr "XGE_OS_LLXFMT" not found!", \
131 (unsigned long long)(ulong_t)_vaddr); \
135 #define XGE_OS_MEMORY_CHECK_MALLOC(ptr, size, file, line)
136 #define XGE_OS_MEMORY_CHECK_FREE(vaddr, check_size)
141 #endif /* XGE_DEFS_H */