1171095Ssam/*- 2171095Ssam * Copyright (c) 2002-2007 Neterion, Inc. 3171095Ssam * All rights reserved. 4171095Ssam * 5171095Ssam * Redistribution and use in source and binary forms, with or without 6171095Ssam * modification, are permitted provided that the following conditions 7171095Ssam * are met: 8171095Ssam * 1. Redistributions of source code must retain the above copyright 9171095Ssam * notice, this list of conditions and the following disclaimer. 10171095Ssam * 2. Redistributions in binary form must reproduce the above copyright 11171095Ssam * notice, this list of conditions and the following disclaimer in the 12171095Ssam * documentation and/or other materials provided with the distribution. 13171095Ssam * 14171095Ssam * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15171095Ssam * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16171095Ssam * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17171095Ssam * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18171095Ssam * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19171095Ssam * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20171095Ssam * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21171095Ssam * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22171095Ssam * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23171095Ssam * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24171095Ssam * SUCH DAMAGE. 25171095Ssam * 26171095Ssam * $FreeBSD$ 27171095Ssam */ 28171095Ssam 29171095Ssam#ifndef XGE_DEFS_H 30171095Ssam#define XGE_DEFS_H 31171095Ssam 32173139Srwatson#define XGE_PCI_VENDOR_ID 0x17D5 33173139Srwatson#define XGE_PCI_DEVICE_ID_XENA_1 0x5731 34173139Srwatson#define XGE_PCI_DEVICE_ID_XENA_2 0x5831 35173139Srwatson#define XGE_PCI_DEVICE_ID_HERC_1 0x5732 36173139Srwatson#define XGE_PCI_DEVICE_ID_HERC_2 0x5832 37173139Srwatson#define XGE_PCI_DEVICE_ID_TITAN_1 0x5733 38173139Srwatson#define XGE_PCI_DEVICE_ID_TITAN_2 0x5833 39171095Ssam 40173139Srwatson#define XGE_DRIVER_NAME "Xge driver" 41173139Srwatson#define XGE_DRIVER_VENDOR "Neterion, Inc" 42173139Srwatson#define XGE_CHIP_FAMILY "Xframe" 43173139Srwatson#define XGE_SUPPORTED_MEDIA_0 "Fiber" 44171095Ssam 45171095Ssam#include <dev/nxge/include/version.h> 46171095Ssam 47171095Ssam#if defined(__cplusplus) 48173139Srwatson#define __EXTERN_BEGIN_DECLS extern "C" { 49173139Srwatson#define __EXTERN_END_DECLS } 50171095Ssam#else 51171095Ssam#define __EXTERN_BEGIN_DECLS 52171095Ssam#define __EXTERN_END_DECLS 53171095Ssam#endif 54171095Ssam 55171095Ssam__EXTERN_BEGIN_DECLS 56171095Ssam 57171095Ssam/*---------------------------- DMA attributes ------------------------------*/ 58171095Ssam/* Used in xge_os_dma_malloc() and xge_os_dma_map() */ 59171095Ssam/*---------------------------- DMA attributes ------------------------------*/ 60171095Ssam 61171095Ssam/* XGE_OS_DMA_REQUIRES_SYNC - should be defined or 62173139Srwatson NOT defined in the Makefile */ 63171095Ssam#define XGE_OS_DMA_CACHELINE_ALIGNED 0x1 64171095Ssam/* Either STREAMING or CONSISTENT should be used. 65171095Ssam The combination of both or none is invalid */ 66171095Ssam#define XGE_OS_DMA_STREAMING 0x2 67171095Ssam#define XGE_OS_DMA_CONSISTENT 0x4 68171095Ssam#define XGE_OS_SPRINTF_STRLEN 64 69171095Ssam 70171095Ssam/*---------------------------- common stuffs -------------------------------*/ 71171095Ssam 72173139Srwatson#define XGE_OS_LLXFMT "%llx" 73171095Ssam#define XGE_OS_NEWLINE "\n" 74171095Ssam#ifdef XGE_OS_MEMORY_CHECK 75171095Ssamtypedef struct { 76171095Ssam void *ptr; 77171095Ssam int size; 78171095Ssam char *file; 79171095Ssam int line; 80171095Ssam} xge_os_malloc_t; 81171095Ssam 82173139Srwatson#define XGE_OS_MALLOC_CNT_MAX 64*1024 83171095Ssamextern xge_os_malloc_t g_malloc_arr[XGE_OS_MALLOC_CNT_MAX]; 84171095Ssamextern int g_malloc_cnt; 85171095Ssam 86171095Ssam#define XGE_OS_MEMORY_CHECK_MALLOC(_vaddr, _size, _file, _line) { \ 87171095Ssam if (_vaddr) { \ 88173139Srwatson int index_mem_chk; \ 89173139Srwatson for (index_mem_chk=0; index_mem_chk < g_malloc_cnt; index_mem_chk++) { \ 90173139Srwatson if (g_malloc_arr[index_mem_chk].ptr == NULL) { \ 91173139Srwatson break; \ 92173139Srwatson } \ 93173139Srwatson } \ 94173139Srwatson if (index_mem_chk == g_malloc_cnt) { \ 95173139Srwatson g_malloc_cnt++; \ 96173139Srwatson if (g_malloc_cnt >= XGE_OS_MALLOC_CNT_MAX) { \ 97173139Srwatson xge_os_bug("g_malloc_cnt exceed %d", \ 98173139Srwatson XGE_OS_MALLOC_CNT_MAX); \ 99173139Srwatson } \ 100173139Srwatson } \ 101173139Srwatson g_malloc_arr[index_mem_chk].ptr = _vaddr; \ 102173139Srwatson g_malloc_arr[index_mem_chk].size = _size; \ 103173139Srwatson g_malloc_arr[index_mem_chk].file = _file; \ 104173139Srwatson g_malloc_arr[index_mem_chk].line = _line; \ 105173139Srwatson for (index_mem_chk=0; index_mem_chk<_size; index_mem_chk++) { \ 106173139Srwatson *((char *)_vaddr+index_mem_chk) = 0x5a; \ 107173139Srwatson } \ 108171095Ssam } \ 109171095Ssam} 110171095Ssam 111171095Ssam#define XGE_OS_MEMORY_CHECK_FREE(_vaddr, _check_size) { \ 112173139Srwatson int index_mem_chk; \ 113173139Srwatson for (index_mem_chk=0; index_mem_chk < XGE_OS_MALLOC_CNT_MAX; index_mem_chk++) { \ 114173139Srwatson if (g_malloc_arr[index_mem_chk].ptr == _vaddr) { \ 115173139Srwatson g_malloc_arr[index_mem_chk].ptr = NULL; \ 116173139Srwatson if(_check_size && g_malloc_arr[index_mem_chk].size!=_check_size) { \ 117173139Srwatson xge_os_printf("OSPAL: freeing with wrong " \ 118173139Srwatson "size %d! allocated at %s:%d:"XGE_OS_LLXFMT":%d", \ 119173139Srwatson (int)_check_size, \ 120173139Srwatson g_malloc_arr[index_mem_chk].file, \ 121173139Srwatson g_malloc_arr[index_mem_chk].line, \ 122173139Srwatson (unsigned long long)(ulong_t) \ 123173139Srwatson g_malloc_arr[index_mem_chk].ptr, \ 124173139Srwatson g_malloc_arr[index_mem_chk].size); \ 125173139Srwatson } \ 126173139Srwatson break; \ 127173139Srwatson } \ 128171095Ssam } \ 129173139Srwatson if (index_mem_chk == XGE_OS_MALLOC_CNT_MAX) { \ 130173139Srwatson xge_os_printf("OSPAL: ptr "XGE_OS_LLXFMT" not found!", \ 131173139Srwatson (unsigned long long)(ulong_t)_vaddr); \ 132171095Ssam } \ 133171095Ssam} 134171095Ssam#else 135171095Ssam#define XGE_OS_MEMORY_CHECK_MALLOC(ptr, size, file, line) 136171095Ssam#define XGE_OS_MEMORY_CHECK_FREE(vaddr, check_size) 137171095Ssam#endif 138171095Ssam 139171095Ssam__EXTERN_END_DECLS 140171095Ssam 141171095Ssam#endif /* XGE_DEFS_H */ 142