Home | History | Annotate | Line # | Download | only in ixgbe
      1 /* $NetBSD: ixgbe_netbsd.h,v 1.17 2022/09/16 03:05:51 knakahara Exp $ */
      2 /*
      3  * Copyright (c) 2011 The NetBSD Foundation, Inc.
      4  * All rights reserved.
      5  *
      6  * This code is derived from software contributed to The NetBSD Foundation
      7  * by Coyote Point Systems, Inc.
      8  *
      9  * Redistribution and use in source and binary forms, with or without
     10  * modification, are permitted provided that the following conditions
     11  * are met:
     12  * 1. Redistributions of source code must retain the above copyright
     13  *    notice, this list of conditions and the following disclaimer.
     14  * 2. Redistributions in binary form must reproduce the above copyright
     15  *    notice, this list of conditions and the following disclaimer in the
     16  *    documentation and/or other materials provided with the distribution.
     17  *
     18  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     19  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     20  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     21  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     22  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     23  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     24  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     26  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     28  * POSSIBILITY OF SUCH DAMAGE.
     29  */
     30 
     31 #ifndef _IXGBE_NETBSD_H
     32 #define _IXGBE_NETBSD_H
     33 
     34 #ifdef _KERNEL_OPT
     35 #include "opt_if_ixg.h"
     36 #endif
     37 
     38 #if 0 /* Enable this if you don't want to use TX multiqueue function */
     39 #define	IXGBE_LEGACY_TX	1
     40 #endif
     41 
     42 #define	ETHERCAP_VLAN_HWCSUM	0
     43 #define	MJUM9BYTES	(9 * 1024)
     44 #define	MJUM16BYTES	(16 * 1024)
     45 #define	MJUMPAGESIZE	PAGE_SIZE
     46 
     47 #define IFCAP_RXCSUM	\
     48 	(IFCAP_CSUM_IPv4_Rx|IFCAP_CSUM_TCPv4_Rx|IFCAP_CSUM_UDPv4_Rx|\
     49 	IFCAP_CSUM_TCPv6_Rx|IFCAP_CSUM_UDPv6_Rx)
     50 
     51 #define IFCAP_TXCSUM	\
     52 	(IFCAP_CSUM_IPv4_Tx|IFCAP_CSUM_TCPv4_Tx|IFCAP_CSUM_UDPv4_Tx|\
     53 	IFCAP_CSUM_TCPv6_Tx|IFCAP_CSUM_UDPv6_Tx)
     54 
     55 #define IFCAP_HWCSUM	(IFCAP_RXCSUM|IFCAP_TXCSUM)
     56 
     57 
     58 /* Helper macros for evcnt(9) .*/
     59 #ifdef __HAVE_ATOMIC64_LOADSTORE
     60 #define IXGBE_EVC_LOAD(evp)				\
     61 	atomic_load_relaxed(&((evp)->ev_count))
     62 #define IXGBE_EVC_STORE(evp, val)			\
     63 	atomic_store_relaxed(&((evp)->ev_count), (val))
     64 #define IXGBE_EVC_ADD(evp, val)					\
     65 	atomic_store_relaxed(&((evp)->ev_count),		\
     66 	    atomic_load_relaxed(&((evp)->ev_count)) + (val))
     67 #else
     68 #define IXGBE_EVC_LOAD(evp)		((evp)->ev_count))
     69 #define IXGBE_EVC_STORE(evp, val)	((evp)->ev_count = (val))
     70 #define IXGBE_EVC_ADD(evp, val)		((evp)->ev_count += (val))
     71 #endif
     72 
     73 #define IXGBE_EVC_REGADD(hw, stats, regname, evname)			\
     74 	IXGBE_EVC_ADD(&(stats)->evname, IXGBE_READ_REG((hw), (regname)))
     75 
     76 /*
     77  * Copy a register value to variable "evname" for later use.
     78  * "evname" is also the name of the evcnt.
     79  */
     80 #define IXGBE_EVC_REGADD2(hw, stats, regname, evname)		\
     81 	do {							\
     82 		(evname) = IXGBE_READ_REG((hw), (regname));	\
     83 		IXGBE_EVC_ADD(&(stats)->evname, (evname));	\
     84 	} while (/*CONSTCOND*/0)
     85 
     86 struct ixgbe_dma_tag {
     87 	bus_dma_tag_t	dt_dmat;
     88 	bus_size_t	dt_alignment;
     89 	bus_size_t	dt_boundary;
     90 	bus_size_t	dt_maxsize;
     91 	int		dt_nsegments;
     92 	bus_size_t	dt_maxsegsize;
     93 	int		dt_flags;
     94 };
     95 
     96 typedef struct ixgbe_dma_tag ixgbe_dma_tag_t;
     97 
     98 int ixgbe_dma_tag_create(bus_dma_tag_t, bus_size_t, bus_size_t, bus_size_t,
     99     int, bus_size_t, int, ixgbe_dma_tag_t **);
    100 void ixgbe_dma_tag_destroy(ixgbe_dma_tag_t *);
    101 int ixgbe_dmamap_create(ixgbe_dma_tag_t *, int, bus_dmamap_t *);
    102 void ixgbe_dmamap_destroy(ixgbe_dma_tag_t *, bus_dmamap_t);
    103 void ixgbe_dmamap_sync(ixgbe_dma_tag_t *, bus_dmamap_t, int);
    104 void ixgbe_dmamap_unload(ixgbe_dma_tag_t *, bus_dmamap_t);
    105 
    106 struct mbuf *ixgbe_getcl(void);
    107 void ixgbe_pci_enable_busmaster(pci_chipset_tag_t, pcitag_t);
    108 
    109 u_int atomic_load_acq_uint(volatile u_int *);
    110 
    111 #endif /* _IXGBE_NETBSD_H */
    112