1 /*-
2 * Copyright (c) 2002-2007 Neterion, Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
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.
13 *
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
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: src/sys/dev/nxge/include/xge-defs.h,v 1.2 2007/10/29 14:19:31 rwatson Exp $
27 */
28
29 #ifndef XGE_DEFS_H
30 #define XGE_DEFS_H
31
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
39
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"
44
45 #include <dev/nxge/include/version.h>
46
47 #if defined(__cplusplus)
48 #define __EXTERN_BEGIN_DECLS extern "C" {
49 #define __EXTERN_END_DECLS }
50 #else
51 #define __EXTERN_BEGIN_DECLS
52 #define __EXTERN_END_DECLS
53 #endif
54
55 __EXTERN_BEGIN_DECLS
56
57 /*---------------------------- DMA attributes ------------------------------*/
58 /* Used in xge_os_dma_malloc() and xge_os_dma_map() */
59 /*---------------------------- DMA attributes ------------------------------*/
60
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
69
70 /*---------------------------- common stuffs -------------------------------*/
71
72 #define XGE_OS_LLXFMT "%llx"
73 #define XGE_OS_NEWLINE "\n"
74 #ifdef XGE_OS_MEMORY_CHECK
75 typedef struct {
76 void *ptr;
77 int size;
78 char *file;
79 int line;
80 } xge_os_malloc_t;
81
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;
85
86 #define XGE_OS_MEMORY_CHECK_MALLOC(_vaddr, _size, _file, _line) { \
87 if (_vaddr) { \
88 int index_mem_chk; \
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) { \
91 break; \
92 } \
93 } \
94 if (index_mem_chk == g_malloc_cnt) { \
95 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); \
99 } \
100 } \
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; \
107 } \
108 } \
109 }
110
111 #define XGE_OS_MEMORY_CHECK_FREE(_vaddr, _check_size) { \
112 int index_mem_chk; \
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", \
119 (int)_check_size, \
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); \
125 } \
126 break; \
127 } \
128 } \
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); \
132 } \
133 }
134 #else
135 #define XGE_OS_MEMORY_CHECK_MALLOC(ptr, size, file, line)
136 #define XGE_OS_MEMORY_CHECK_FREE(vaddr, check_size)
137 #endif
138
139 __EXTERN_END_DECLS
140
141 #endif /* XGE_DEFS_H */
142
|