]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/nxge/include/xge-defs.h
This commit was generated by cvs2svn to compensate for changes in r171169,
[FreeBSD/FreeBSD.git] / sys / dev / nxge / include / xge-defs.h
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$
27  */
28
29 /*
30  *  FileName :    xge-defs.h
31  *
32  *  Description:  global definitions
33  *
34  *  Created:      13 May 2004
35  */
36
37 #ifndef XGE_DEFS_H
38 #define XGE_DEFS_H
39
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
47
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"
52
53 #include <dev/nxge/include/version.h>
54
55 #if defined(__cplusplus)
56 #define __EXTERN_BEGIN_DECLS    extern "C" {
57 #define __EXTERN_END_DECLS      }
58 #else
59 #define __EXTERN_BEGIN_DECLS
60 #define __EXTERN_END_DECLS
61 #endif
62
63 __EXTERN_BEGIN_DECLS
64
65 /*---------------------------- DMA attributes ------------------------------*/
66 /*           Used in xge_os_dma_malloc() and xge_os_dma_map() */
67 /*---------------------------- DMA attributes ------------------------------*/
68
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
77
78 /*---------------------------- common stuffs -------------------------------*/
79
80 #define XGE_OS_LLXFMT           "%llx"
81 #define XGE_OS_NEWLINE      "\n"
82 #ifdef XGE_OS_MEMORY_CHECK
83 typedef struct {
84         void *ptr;
85         int size;
86         char *file;
87         int line;
88 } xge_os_malloc_t;
89
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;
93
94 #define XGE_OS_MEMORY_CHECK_MALLOC(_vaddr, _size, _file, _line) { \
95         if (_vaddr) { \
96                 int i; \
97                 for (i=0; i<g_malloc_cnt; i++) { \
98                         if (g_malloc_arr[i].ptr == NULL) { \
99                                 break; \
100                         } \
101                 } \
102                 if (i == g_malloc_cnt) { \
103                         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); \
107                         } \
108                 } \
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; \
115                 } \
116         } \
117 }
118
119 #define XGE_OS_MEMORY_CHECK_FREE(_vaddr, _check_size) { \
120         int i; \
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", \
127                                          (int)_check_size, \
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); \
133                         } \
134                         break; \
135                 } \
136         } \
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); \
140         } \
141 }
142 #else
143 #define XGE_OS_MEMORY_CHECK_MALLOC(ptr, size, file, line)
144 #define XGE_OS_MEMORY_CHECK_FREE(vaddr, check_size)
145 #endif
146
147 __EXTERN_END_DECLS
148
149 #endif /* XGE_DEFS_H */