/* * Copyright (c) 2017-2018 Cavium, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * */ /* * File: qlnx_os.h * Author : David C Somayajulu, Cavium, Inc., San Jose, CA 95131. */ #ifndef _QLNX_OS_H_ #define _QLNX_OS_H_ #include #include #include #include #include #include #include #include #include #include #include #include #include #if __FreeBSD_version < 1000000 #error FreeBSD Version not supported - use version >= 1000000 #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef CONFIG_ECORE_SRIOV #include #include #include #endif /* #ifdef CONFIG_ECORE_SRIOV */ static __inline int qlnx_ms_to_hz(int ms) { int qlnx_hz; struct timeval t; t.tv_sec = ms / 1000; t.tv_usec = (ms % 1000) * 1000; qlnx_hz = tvtohz(&t); if (qlnx_hz < 0) qlnx_hz = 0x7fffffff; if (!qlnx_hz) qlnx_hz = 1; return (qlnx_hz); } static __inline int qlnx_sec_to_hz(int sec) { struct timeval t; t.tv_sec = sec; t.tv_usec = 0; return (tvtohz(&t)); } MALLOC_DECLARE(M_QLNXBUF); #define qlnx_mdelay(fn, msecs) \ {\ if (cold) \ DELAY((msecs * 1000)); \ else \ pause(fn, qlnx_ms_to_hz(msecs)); \ } /* * Locks */ #define QLNX_LOCK(ha) sx_xlock(&ha->hw_lock) #define QLNX_UNLOCK(ha) sx_xunlock(&ha->hw_lock) /* * structure encapsulating a DMA buffer */ struct qlnx_dma { bus_size_t alignment; uint32_t size; void *dma_b; bus_addr_t dma_addr; bus_dmamap_t dma_map; bus_dma_tag_t dma_tag; }; typedef struct qlnx_dma qlnx_dma_t; #endif /* #ifndef _QLNX_OS_H_ */