The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/dev/iavf/iavf_osdep.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /* SPDX-License-Identifier: BSD-3-Clause */
    2 /*  Copyright (c) 2021, Intel Corporation
    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 are met:
    7  *
    8  *   1. Redistributions of source code must retain the above copyright notice,
    9  *      this list of conditions and the following disclaimer.
   10  *
   11  *   2. Redistributions in binary form must reproduce the above copyright
   12  *      notice, this list of conditions and the following disclaimer in the
   13  *      documentation and/or other materials provided with the distribution.
   14  *
   15  *   3. Neither the name of the Intel Corporation nor the names of its
   16  *      contributors may be used to endorse or promote products derived from
   17  *      this software without specific prior written permission.
   18  *
   19  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
   20  *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   21  *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   22  *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
   23  *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   24  *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   25  *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   26  *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   27  *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   28  *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   29  *  POSSIBILITY OF SUCH DAMAGE.
   30  */
   31 /*$FreeBSD$*/
   32 
   33 /**
   34  * @file iavf_osdep.h
   35  * @brief OS compatibility layer definitions
   36  *
   37  * Contains macros and definitions used to implement an OS compatibility layer
   38  * used by some of the hardware files.
   39  */
   40 #ifndef _IAVF_OSDEP_H_
   41 #define _IAVF_OSDEP_H_
   42 
   43 #include <sys/types.h>
   44 #include <sys/param.h>
   45 #include <sys/systm.h>
   46 #include <sys/endian.h>
   47 #include <sys/mbuf.h>
   48 #include <sys/protosw.h>
   49 #include <sys/socket.h>
   50 #include <sys/malloc.h>
   51 #include <sys/kernel.h>
   52 #include <sys/bus.h>
   53 #include <machine/bus.h>
   54 #include <sys/rman.h>
   55 #include <machine/resource.h>
   56 #include <vm/vm.h>
   57 #include <vm/pmap.h>
   58 #include <machine/clock.h>
   59 #include <dev/pci/pcivar.h>
   60 #include <dev/pci/pcireg.h>
   61 
   62 #include "iavf_status.h"
   63 #include "iavf_debug.h"
   64 
   65 #define iavf_usec_delay(x) DELAY(x)
   66 #define iavf_msec_delay(x) DELAY(1000 * (x))
   67 
   68 #define DBG 0
   69 #define DEBUGFUNC(F)        DEBUGOUT(F);
   70 #if DBG
   71         #define DEBUGOUT(S)         printf(S "\n")
   72         #define DEBUGOUT1(S,A)      printf(S "\n",A)
   73         #define DEBUGOUT2(S,A,B)    printf(S "\n",A,B)
   74         #define DEBUGOUT3(S,A,B,C)  printf(S "\n",A,B,C)
   75         #define DEBUGOUT7(S,A,B,C,D,E,F,G)  printf(S "\n",A,B,C,D,E,F,G)
   76 #else
   77         #define DEBUGOUT(S)
   78         #define DEBUGOUT1(S,A)
   79         #define DEBUGOUT2(S,A,B)
   80         #define DEBUGOUT3(S,A,B,C)
   81         #define DEBUGOUT6(S,A,B,C,D,E,F)
   82         #define DEBUGOUT7(S,A,B,C,D,E,F,G)
   83 #endif
   84 
   85 #define UNREFERENCED_PARAMETER(_p) _p = _p
   86 #define UNREFERENCED_1PARAMETER(_p) do {                        \
   87         UNREFERENCED_PARAMETER(_p);                             \
   88 } while (0)
   89 #define UNREFERENCED_2PARAMETER(_p, _q) do {                    \
   90         UNREFERENCED_PARAMETER(_p);                             \
   91         UNREFERENCED_PARAMETER(_q);                             \
   92 } while (0)
   93 #define UNREFERENCED_3PARAMETER(_p, _q, _r) do {                \
   94         UNREFERENCED_PARAMETER(_p);                             \
   95         UNREFERENCED_PARAMETER(_q);                             \
   96         UNREFERENCED_PARAMETER(_r);                             \
   97 } while (0)
   98 #define UNREFERENCED_4PARAMETER(_p, _q, _r, _s) do {            \
   99         UNREFERENCED_PARAMETER(_p);                             \
  100         UNREFERENCED_PARAMETER(_q);                             \
  101         UNREFERENCED_PARAMETER(_r);                             \
  102         UNREFERENCED_PARAMETER(_s);                             \
  103 } while (0)
  104 #define UNREFERENCED_5PARAMETER(_p, _q, _r, _s, _t) do {        \
  105         UNREFERENCED_PARAMETER(_p);                             \
  106         UNREFERENCED_PARAMETER(_q);                             \
  107         UNREFERENCED_PARAMETER(_r);                             \
  108         UNREFERENCED_PARAMETER(_s);                             \
  109         UNREFERENCED_PARAMETER(_t);                             \
  110 } while (0)
  111 
  112 #define STATIC  static
  113 #define INLINE  inline
  114 
  115 #define iavf_memset(a, b, c, d)  memset((a), (b), (c))
  116 #define iavf_memcpy(a, b, c, d)  memcpy((a), (b), (c))
  117 
  118 #define CPU_TO_LE16(o)  htole16(o)
  119 #define CPU_TO_LE32(s)  htole32(s)
  120 #define CPU_TO_LE64(h)  htole64(h)
  121 #define LE16_TO_CPU(a)  le16toh(a)
  122 #define LE32_TO_CPU(c)  le32toh(c)
  123 #define LE64_TO_CPU(k)  le64toh(k)
  124 
  125 /**
  126  * @typedef u8
  127  * @brief compatibility typedef for uint8_t
  128  */
  129 typedef uint8_t         u8;
  130 
  131 /**
  132  * @typedef s8
  133  * @brief compatibility typedef for int8_t
  134  */
  135 typedef int8_t          s8;
  136 
  137 /**
  138  * @typedef u16
  139  * @brief compatibility typedef for uint16_t
  140  */
  141 typedef uint16_t        u16;
  142 
  143 /**
  144  * @typedef s16
  145  * @brief compatibility typedef for int16_t
  146  */
  147 typedef int16_t         s16;
  148 
  149 /**
  150  * @typedef u32
  151  * @brief compatibility typedef for uint32_t
  152  */
  153 typedef uint32_t        u32;
  154 
  155 /**
  156  * @typedef s32
  157  * @brief compatibility typedef for int32_t
  158  */
  159 typedef int32_t         s32;
  160 
  161 /**
  162  * @typedef u64
  163  * @brief compatibility typedef for uint64_t
  164  */
  165 typedef uint64_t        u64;
  166 
  167 #define __le16  u16
  168 #define __le32  u32
  169 #define __le64  u64
  170 #define __be16  u16
  171 #define __be32  u32
  172 #define __be64  u64
  173 
  174 /**
  175  * @struct iavf_spinlock
  176  * @brief OS wrapper for a non-sleeping lock
  177  *
  178  * Wrapper used to provide an implementation of a non-sleeping lock.
  179  */
  180 struct iavf_spinlock {
  181         struct mtx mutex;
  182 };
  183 
  184 /**
  185  * @struct iavf_osdep
  186  * @brief Storage for data used by the osdep interface
  187  *
  188  * Contains data used by the osdep layer. Accessed via the hw->back pointer.
  189  */
  190 struct iavf_osdep {
  191         bus_space_tag_t         mem_bus_space_tag;
  192         bus_space_handle_t      mem_bus_space_handle;
  193         bus_size_t              mem_bus_space_size;
  194         uint32_t                flush_reg;
  195         int                     i2c_intfc_num;
  196         device_t                dev;
  197 };
  198 
  199 /**
  200  * @struct iavf_dma_mem
  201  * @brief DMA memory map
  202  *
  203  * Structure representing a DMA memory mapping.
  204  */
  205 struct iavf_dma_mem {
  206         void                    *va;
  207         u64                     pa;
  208         bus_dma_tag_t           tag;
  209         bus_dmamap_t            map;
  210         bus_dma_segment_t       seg;
  211         bus_size_t              size;
  212         int                     nseg;
  213         int                     flags;
  214 };
  215 
  216 /**
  217  * @struct iavf_virt_mem
  218  * @brief Virtual memory
  219  *
  220  * Structure representing some virtual memory.
  221  */
  222 struct iavf_virt_mem {
  223         void *va;
  224         u32 size;
  225 };
  226 
  227 struct iavf_hw; /* forward decl */
  228 u16     iavf_read_pci_cfg(struct iavf_hw *, u32);
  229 void    iavf_write_pci_cfg(struct iavf_hw *, u32, u16);
  230 
  231 /*
  232 ** iavf_debug - OS dependent version of shared code debug printing
  233 */
  234 #define iavf_debug(h, m, s, ...)  iavf_debug_shared(h, m, s, ##__VA_ARGS__)
  235 void iavf_debug_shared(struct iavf_hw *hw, uint64_t mask,
  236     char *fmt_str, ...) __printflike(3, 4);
  237 
  238 /*
  239 ** This hardware supports either 16 or 32 byte rx descriptors;
  240 ** the driver only uses the 32 byte kind.
  241 */
  242 #define iavf_rx_desc iavf_32byte_rx_desc
  243 
  244 uint32_t iavf_rd32(struct iavf_hw *hw, uint32_t reg);
  245 void iavf_wr32(struct iavf_hw *hw, uint32_t reg, uint32_t val);
  246 void iavf_flush(struct iavf_hw *hw);
  247 #define rd32(hw, reg)           iavf_rd32(hw, reg)
  248 #define wr32(hw, reg, val)      iavf_wr32(hw, reg, val)
  249 
  250 #endif /* _IAVF_OSDEP_H_ */

Cache object: 486f231718ac219eeb03340633c408dd


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.