if_em.h revision 103895
1/************************************************************************** 2 3Copyright (c) 2001-2002, Intel Corporation 4All rights reserved. 5 6Redistribution and use in source and binary forms, with or without 7modification, are permitted provided that the following conditions are met: 8 9 1. Redistributions of source code must retain the above copyright notice, 10 this list of conditions and the following disclaimer. 11 12 2. Redistributions in binary form must reproduce the above copyright 13 notice, this list of conditions and the following disclaimer in the 14 documentation and/or other materials provided with the distribution. 15 16 3. Neither the name of the Intel Corporation nor the names of its 17 contributors may be used to endorse or promote products derived from 18 this software without specific prior written permission. 19 20THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 24LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30POSSIBILITY OF SUCH DAMAGE. 31 32***************************************************************************/ 33 34/*$FreeBSD: head/sys/dev/em/if_em.h 103895 2002-09-24 16:27:59Z pdeuskar $*/ 35 36#ifndef _EM_H_DEFINED_ 37#define _EM_H_DEFINED_ 38 39 40#include <sys/param.h> 41#include <sys/systm.h> 42#include <sys/mbuf.h> 43#include <sys/protosw.h> 44#include <sys/socket.h> 45#include <sys/malloc.h> 46#include <sys/kernel.h> 47#include <sys/sockio.h> 48 49#include <net/if.h> 50#include <net/if_arp.h> 51#include <net/ethernet.h> 52#include <net/if_dl.h> 53#include <net/if_media.h> 54 55#include <net/bpf.h> 56#include <net/if_types.h> 57#include <net/if_vlan_var.h> 58 59#include <netinet/in_systm.h> 60#include <netinet/in.h> 61#include <netinet/ip.h> 62#include <netinet/tcp.h> 63#include <netinet/udp.h> 64 65#include <sys/bus.h> 66#include <machine/bus.h> 67#include <sys/rman.h> 68#include <machine/resource.h> 69#include <vm/vm.h> 70#include <vm/pmap.h> 71#include <machine/clock.h> 72#include <pci/pcivar.h> 73#include <pci/pcireg.h> 74#include "opt_bdg.h" 75 76#include <dev/em/if_em_hw.h> 77 78/* Tunables */ 79#define MAX_TXD 256 80#define MAX_RXD 256 81#define TX_CLEANUP_THRESHOLD MAX_TXD / 8 82#define TIDV 128 83#define RIDV 28 84#define DO_AUTO_NEG 1 85#define WAIT_FOR_AUTO_NEG_DEFAULT 1 86#define AUTONEG_ADV_DEFAULT (ADVERTISE_10_HALF | ADVERTISE_10_FULL | \ 87 ADVERTISE_100_HALF | ADVERTISE_100_FULL | \ 88 ADVERTISE_1000_FULL) 89#define EM_REPORT_TX_EARLY 2 90#define EM_CHECKSUM_FEATURES (CSUM_TCP | CSUM_UDP) 91#define EM_MAX_INTR 3 92#define EM_TX_TIMEOUT 5 /* set to 5 seconds */ 93 94 95#define EM_VENDOR_ID 0x8086 96#define EM_MMBA 0x0010 /* Mem base address */ 97#define EM_ROUNDUP(size, unit) (((size) + (unit) - 1) & ~((unit) - 1)) 98#define EM_JUMBO_PBA 0x00000028 99#define EM_DEFAULT_PBA 0x00000030 100 101#define IOCTL_CMD_TYPE u_long 102#define MAX_NUM_MULTICAST_ADDRESSES 128 103#define PCI_ANY_ID (~0U) 104#define ETHER_ALIGN 2 105#define QTAG_TYPE 0x8100 106 107/* Defines for printing debug information */ 108#define DEBUG_INIT 0 109#define DEBUG_IOCTL 0 110#define DEBUG_HW 0 111 112#define INIT_DEBUGOUT(S) if (DEBUG_INIT) printf(S "\n") 113#define INIT_DEBUGOUT1(S, A) if (DEBUG_INIT) printf(S "\n", A) 114#define INIT_DEBUGOUT2(S, A, B) if (DEBUG_INIT) printf(S "\n", A, B) 115#define IOCTL_DEBUGOUT(S) if (DEBUG_IOCTL) printf(S "\n") 116#define IOCTL_DEBUGOUT1(S, A) if (DEBUG_IOCTL) printf(S "\n", A) 117#define IOCTL_DEBUGOUT2(S, A, B) if (DEBUG_IOCTL) printf(S "\n", A, B) 118#define HW_DEBUGOUT(S) if (DEBUG_HW) printf(S "\n") 119#define HW_DEBUGOUT1(S, A) if (DEBUG_HW) printf(S "\n", A) 120#define HW_DEBUGOUT2(S, A, B) if (DEBUG_HW) printf(S "\n", A, B) 121 122 123/* Supported RX Buffer Sizes */ 124#define EM_RXBUFFER_2048 2048 125#define EM_RXBUFFER_4096 4096 126#define EM_RXBUFFER_8192 8192 127#define EM_RXBUFFER_16384 16384 128 129#ifdef __alpha__ 130 #undef vtophys 131 #define vtophys(va) alpha_XXX_dmamap((vm_offset_t)(va)) 132#endif /* __alpha__ */ 133 134/* ****************************************************************************** 135 * vendor_info_array 136 * 137 * This array contains the list of Subvendor/Subdevice IDs on which the driver 138 * should load. 139 * 140 * ******************************************************************************/ 141typedef struct _em_vendor_info_t 142{ 143 unsigned int vendor_id; 144 unsigned int device_id; 145 unsigned int subvendor_id; 146 unsigned int subdevice_id; 147 unsigned int index; 148} em_vendor_info_t; 149 150 151struct em_tx_buffer { 152 STAILQ_ENTRY(em_tx_buffer) em_tx_entry; 153 struct mbuf *m_head; 154 u_int32_t num_tx_desc_used; 155}; 156 157 158/* ****************************************************************************** 159 * This structure stores information about the 2k aligned receive buffer 160 * into which the E1000 DMA's frames. 161 * ******************************************************************************/ 162struct em_rx_buffer { 163 STAILQ_ENTRY(em_rx_buffer) em_rx_entry; 164 struct mbuf *m_head; 165 u_int64_t buffer_addr; 166}; 167 168typedef enum _XSUM_CONTEXT_T { 169 OFFLOAD_NONE, 170 OFFLOAD_TCP_IP, 171 OFFLOAD_UDP_IP 172} XSUM_CONTEXT_T; 173 174/* Our adapter structure */ 175struct adapter { 176 struct arpcom interface_data; 177 struct adapter *next; 178 struct adapter *prev; 179 struct em_hw hw; 180 181 /* FreeBSD operating-system-specific structures */ 182 struct em_osdep osdep; 183 struct device *dev; 184 struct resource *res_memory; 185 struct resource *res_ioport; 186 struct resource *res_interrupt; 187 void *int_handler_tag; 188 struct ifmedia media; 189 struct callout_handle timer_handle; 190 int io_rid; 191 u_int8_t unit; 192 193 /* Info about the board itself */ 194 u_int32_t part_num; 195 u_int8_t link_active; 196 u_int16_t link_speed; 197 u_int16_t link_duplex; 198 u_int32_t tx_int_delay; 199 u_int32_t rx_int_delay; 200 201 XSUM_CONTEXT_T active_checksum_context; 202 203 /* Transmit definitions */ 204 struct em_tx_desc *first_tx_desc; 205 struct em_tx_desc *last_tx_desc; 206 struct em_tx_desc *next_avail_tx_desc; 207 struct em_tx_desc *oldest_used_tx_desc; 208 struct em_tx_desc *tx_desc_base; 209 volatile u_int16_t num_tx_desc_avail; 210 u_int16_t num_tx_desc; 211 u_int32_t txd_cmd; 212 struct em_tx_buffer *tx_buffer_area; 213 STAILQ_HEAD(__em_tx_buffer_free, em_tx_buffer) free_tx_buffer_list; 214 STAILQ_HEAD(__em_tx_buffer_used, em_tx_buffer) used_tx_buffer_list; 215 216 /* Receive definitions */ 217 struct em_rx_desc *first_rx_desc; 218 struct em_rx_desc *last_rx_desc; 219 struct em_rx_desc *next_rx_desc_to_check; 220 struct em_rx_desc *rx_desc_base; 221 u_int16_t num_rx_desc; 222 u_int32_t rx_buffer_len; 223 struct em_rx_buffer *rx_buffer_area; 224 STAILQ_HEAD(__em_rx_buffer, em_rx_buffer) rx_buffer_list; 225 226 /* Jumbo frame */ 227 struct mbuf *fmp; 228 struct mbuf *lmp; 229 230 231 /* Misc stats maintained by the driver */ 232 unsigned long dropped_pkts; 233 unsigned long mbuf_alloc_failed; 234 unsigned long mbuf_cluster_failed; 235 unsigned long xmit_pullup; 236 unsigned long no_tx_desc_avail; 237 unsigned long no_tx_buffer_avail1; 238 unsigned long no_tx_buffer_avail2; 239#ifdef DBG_STATS 240 unsigned long no_pkts_avail; 241 unsigned long clean_tx_interrupts; 242 243#endif 244 245 struct em_hw_stats stats; 246}; 247 248#endif /* _EM_H_DEFINED_ */ 249