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
30 * FileName : xge-defs.h
32 * Description: global definitions
34 * Created: 13 May 2004
40 #define XGE_PCI_VENDOR_ID 0x17D5
41 #define XGE_PCI_DEVICE_ID_XENA_1 0x5731
42 #define XGE_PCI_DEVICE_ID_XENA_2 0x5831
43 #define XGE_PCI_DEVICE_ID_HERC_1 0x5732
44 #define XGE_PCI_DEVICE_ID_HERC_2 0x5832
45 #define XGE_PCI_DEVICE_ID_TITAN_1 0x5733
46 #define XGE_PCI_DEVICE_ID_TITAN_2 0x5833
48 #define XGE_DRIVER_NAME "Xge driver"
49 #define XGE_DRIVER_VENDOR "Neterion, Inc"
50 #define XGE_CHIP_FAMILY "Xframe"
51 #define XGE_SUPPORTED_MEDIA_0 "Fiber"
53 #include <dev/nxge/include/version.h>
55 #if defined(__cplusplus)
56 #define __EXTERN_BEGIN_DECLS extern "C" {
57 #define __EXTERN_END_DECLS }
59 #define __EXTERN_BEGIN_DECLS
60 #define __EXTERN_END_DECLS
65 /*---------------------------- DMA attributes ------------------------------*/
66 /* Used in xge_os_dma_malloc() and xge_os_dma_map() */
67 /*---------------------------- DMA attributes ------------------------------*/
69 /* XGE_OS_DMA_REQUIRES_SYNC - should be defined or
70 NOT defined in the Makefile */
71 #define XGE_OS_DMA_CACHELINE_ALIGNED 0x1
72 /* Either STREAMING or CONSISTENT should be used.
73 The combination of both or none is invalid */
74 #define XGE_OS_DMA_STREAMING 0x2
75 #define XGE_OS_DMA_CONSISTENT 0x4
76 #define XGE_OS_SPRINTF_STRLEN 64
78 /*---------------------------- common stuffs -------------------------------*/
80 #define XGE_OS_LLXFMT "%llx"
81 #define XGE_OS_NEWLINE "\n"
82 #ifdef XGE_OS_MEMORY_CHECK
90 #define XGE_OS_MALLOC_CNT_MAX 64*1024
91 extern xge_os_malloc_t g_malloc_arr[XGE_OS_MALLOC_CNT_MAX];
92 extern int g_malloc_cnt;
94 #define XGE_OS_MEMORY_CHECK_MALLOC(_vaddr, _size, _file, _line) { \
97 for (i=0; i<g_malloc_cnt; i++) { \
98 if (g_malloc_arr[i].ptr == NULL) { \
102 if (i == g_malloc_cnt) { \
104 if (g_malloc_cnt >= XGE_OS_MALLOC_CNT_MAX) { \
105 xge_os_bug("g_malloc_cnt exceed %d", \
106 XGE_OS_MALLOC_CNT_MAX); \
109 g_malloc_arr[i].ptr = _vaddr; \
110 g_malloc_arr[i].size = _size; \
111 g_malloc_arr[i].file = _file; \
112 g_malloc_arr[i].line = _line; \
113 for (i=0; i<_size; i++) { \
114 *((char *)_vaddr+i) = 0x5a; \
119 #define XGE_OS_MEMORY_CHECK_FREE(_vaddr, _check_size) { \
121 for (i=0; i<XGE_OS_MALLOC_CNT_MAX; i++) { \
122 if (g_malloc_arr[i].ptr == _vaddr) { \
123 g_malloc_arr[i].ptr = NULL; \
124 if(_check_size && g_malloc_arr[i].size!=_check_size) { \
125 xge_os_printf("OSPAL: freeing with wrong " \
126 "size %d! allocated at %s:%d:"XGE_OS_LLXFMT":%d", \
128 g_malloc_arr[i].file, \
129 g_malloc_arr[i].line, \
130 (unsigned long long)(ulong_t) \
131 g_malloc_arr[i].ptr, \
132 g_malloc_arr[i].size); \
137 if (i == XGE_OS_MALLOC_CNT_MAX) { \
138 xge_os_printf("OSPAL: ptr "XGE_OS_LLXFMT" not found!", \
139 (unsigned long long)(ulong_t)_vaddr); \
143 #define XGE_OS_MEMORY_CHECK_MALLOC(ptr, size, file, line)
144 #define XGE_OS_MEMORY_CHECK_FREE(vaddr, check_size)
149 #endif /* XGE_DEFS_H */