e1000g_sw.h revision 0dc2366f7b9f9f36e10909b1e95edbf2a261c2ac
7e8c1a13e97448db2ec17d05c4917939a12aa9c0Mark Andrews/*
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * This file is provided under a CDDLv1 license. When using or
7e8c1a13e97448db2ec17d05c4917939a12aa9c0Mark Andrews * redistributing this file, you may do so under this license.
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * In redistributing this file this license must be included
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews * and no other modification of this header file is permitted.
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews *
7e8c1a13e97448db2ec17d05c4917939a12aa9c0Mark Andrews * CDDL LICENSE SUMMARY
7e8c1a13e97448db2ec17d05c4917939a12aa9c0Mark Andrews *
c1aef54e14bb92518b1c062ba8c0292a7cb949cbAutomatic Updater * Copyright(c) 1999 - 2009 Intel Corporation. All rights reserved.
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein *
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein * The contents of this file are subject to the terms of Version
7e8c1a13e97448db2ec17d05c4917939a12aa9c0Mark Andrews * 1.0 of the Common Development and Distribution License (the "License").
7e8c1a13e97448db2ec17d05c4917939a12aa9c0Mark Andrews *
7e8c1a13e97448db2ec17d05c4917939a12aa9c0Mark Andrews * You should have received a copy of the License with this software.
7e8c1a13e97448db2ec17d05c4917939a12aa9c0Mark Andrews * You can obtain a copy of the License at
7e8c1a13e97448db2ec17d05c4917939a12aa9c0Mark Andrews * http://www.opensolaris.org/os/licensing.
b1b3495eba72ea2b7270c5cd62b0bb824de74e05Mark Andrews * See the License for the specific language governing permissions
7e8c1a13e97448db2ec17d05c4917939a12aa9c0Mark Andrews * and limitations under the License.
b1b3495eba72ea2b7270c5cd62b0bb824de74e05Mark Andrews */
b1b3495eba72ea2b7270c5cd62b0bb824de74e05Mark Andrews
77b101ced9801cdb226919784bfc1aa0650ace6aMark Andrews/*
77b101ced9801cdb226919784bfc1aa0650ace6aMark Andrews * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
8d0ee7a153381d98f6c1e6e9bfe6b73659433666Brian Wellington * Use is subject to license terms.
7e8c1a13e97448db2ec17d05c4917939a12aa9c0Mark Andrews */
3759f10fc543747668b1ca4b4671f35b0dea8445Francis Dupont
b1b3495eba72ea2b7270c5cd62b0bb824de74e05Mark Andrews#ifndef _E1000G_SW_H
7e8c1a13e97448db2ec17d05c4917939a12aa9c0Mark Andrews#define _E1000G_SW_H
7e8c1a13e97448db2ec17d05c4917939a12aa9c0Mark Andrews
7e8c1a13e97448db2ec17d05c4917939a12aa9c0Mark Andrews#ifdef __cplusplus
669e9657c731176df235832367f61435f7b83ddfAndreas Gustafssonextern "C" {
c2bc56dc65b4b103a5600565680eb5f33fa4c90bMark Andrews#endif
c2bc56dc65b4b103a5600565680eb5f33fa4c90bMark Andrews
7e8c1a13e97448db2ec17d05c4917939a12aa9c0Mark Andrews/*
d999ca28d40337907b55eebc28a255b638702379Evan Hunt * **********************************************************************
77b101ced9801cdb226919784bfc1aa0650ace6aMark Andrews * Module Name: *
92551304a9abff9284de5b79a48e83d781989339Mark Andrews * e1000g_sw.h *
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews * *
d999ca28d40337907b55eebc28a255b638702379Evan Hunt * Abstract: *
fc14ca7a8f340f98884c504b3c4c3f40d7393fa9Mark Andrews * This header file contains Software-related data structures *
d999ca28d40337907b55eebc28a255b638702379Evan Hunt * definitions. *
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews * *
92551304a9abff9284de5b79a48e83d781989339Mark Andrews * **********************************************************************
7e8c1a13e97448db2ec17d05c4917939a12aa9c0Mark Andrews */
7e8c1a13e97448db2ec17d05c4917939a12aa9c0Mark Andrews
0f8c9b5eed7e8714ceb7d6d3675555df9c5f6350Mark Andrews#include <sys/types.h>
0f8c9b5eed7e8714ceb7d6d3675555df9c5f6350Mark Andrews#include <sys/conf.h>
66a38d16933a28a0110079a9920ba359d2aad130Danny Mayer#include <sys/debug.h>
8d0ee7a153381d98f6c1e6e9bfe6b73659433666Brian Wellington#include <sys/stropts.h>
92551304a9abff9284de5b79a48e83d781989339Mark Andrews#include <sys/stream.h>
92551304a9abff9284de5b79a48e83d781989339Mark Andrews#include <sys/strsun.h>
92551304a9abff9284de5b79a48e83d781989339Mark Andrews#include <sys/strlog.h>
92551304a9abff9284de5b79a48e83d781989339Mark Andrews#include <sys/kmem.h>
92551304a9abff9284de5b79a48e83d781989339Mark Andrews#include <sys/stat.h>
92551304a9abff9284de5b79a48e83d781989339Mark Andrews#include <sys/kstat.h>
92551304a9abff9284de5b79a48e83d781989339Mark Andrews#include <sys/modctl.h>
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein#include <sys/errno.h>
debd489a44363870f96f75818e89ec27d3cab736Francis Dupont#include <sys/mac_provider.h>
debd489a44363870f96f75818e89ec27d3cab736Francis Dupont#include <sys/mac_ether.h>
debd489a44363870f96f75818e89ec27d3cab736Francis Dupont#include <sys/vlan.h>
b1b3495eba72ea2b7270c5cd62b0bb824de74e05Mark Andrews#include <sys/ddi.h>
b1b3495eba72ea2b7270c5cd62b0bb824de74e05Mark Andrews#include <sys/sunddi.h>
05d4b5a9fc8220826b2dbde5bcd5d77af9984071Jeremy C. Reed#include <sys/disp.h>
0f8c9b5eed7e8714ceb7d6d3675555df9c5f6350Mark Andrews#include <sys/pci.h>
bf33eb0b522801792a6663b0360bc94b9e9b77c2Automatic Updater#include <sys/sdt.h>
b1b3495eba72ea2b7270c5cd62b0bb824de74e05Mark Andrews#include <sys/ethernet.h>
b1b3495eba72ea2b7270c5cd62b0bb824de74e05Mark Andrews#include <sys/pattr.h>
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein#include <sys/strsubr.h>
7e8c1a13e97448db2ec17d05c4917939a12aa9c0Mark Andrews#include <sys/netlb.h>
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews#include <inet/common.h>
8d0ee7a153381d98f6c1e6e9bfe6b73659433666Brian Wellington#include <inet/ip.h>
4e1d3e67cdc76609bad5f0310ac48de10b442b9fMark Andrews#include <inet/tcp.h>
8d0ee7a153381d98f6c1e6e9bfe6b73659433666Brian Wellington#include <inet/mi.h>
8d0ee7a153381d98f6c1e6e9bfe6b73659433666Brian Wellington#include <inet/nd.h>
8d0ee7a153381d98f6c1e6e9bfe6b73659433666Brian Wellington#include <sys/ddifm.h>
8d0ee7a153381d98f6c1e6e9bfe6b73659433666Brian Wellington#include <sys/fm/protocol.h>
079878277fadf272477129bb8ce99c70ee5af25eBrian Wellington#include <sys/fm/util.h>
8d0ee7a153381d98f6c1e6e9bfe6b73659433666Brian Wellington#include <sys/fm/io/ddi.h>
8d0ee7a153381d98f6c1e6e9bfe6b73659433666Brian Wellington#include "e1000_api.h"
8d0ee7a153381d98f6c1e6e9bfe6b73659433666Brian Wellington
8d0ee7a153381d98f6c1e6e9bfe6b73659433666Brian Wellington/* Driver states */
8d0ee7a153381d98f6c1e6e9bfe6b73659433666Brian Wellington#define E1000G_UNKNOWN 0x00
8d0ee7a153381d98f6c1e6e9bfe6b73659433666Brian Wellington#define E1000G_INITIALIZED 0x01
8d0ee7a153381d98f6c1e6e9bfe6b73659433666Brian Wellington#define E1000G_STARTED 0x02
66a38d16933a28a0110079a9920ba359d2aad130Danny Mayer#define E1000G_SUSPENDED 0x04
fc14ca7a8f340f98884c504b3c4c3f40d7393fa9Mark Andrews#define E1000G_ERROR 0x80
8d0ee7a153381d98f6c1e6e9bfe6b73659433666Brian Wellington
8d0ee7a153381d98f6c1e6e9bfe6b73659433666Brian Wellington#define JUMBO_FRAG_LENGTH 4096
8d0ee7a153381d98f6c1e6e9bfe6b73659433666Brian Wellington
7e8c1a13e97448db2ec17d05c4917939a12aa9c0Mark Andrews#define LAST_RAR_ENTRY (E1000_RAR_ENTRIES - 1)
7e8c1a13e97448db2ec17d05c4917939a12aa9c0Mark Andrews#define MAX_NUM_UNICAST_ADDRESSES E1000_RAR_ENTRIES
7e8c1a13e97448db2ec17d05c4917939a12aa9c0Mark Andrews#define MCAST_ALLOC_SIZE 256
7e8c1a13e97448db2ec17d05c4917939a12aa9c0Mark Andrews
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews/*
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews * MAX_COOKIES = max_LSO_packet_size(65535 + ethernet_header_len)/page_size
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews * + one for cross page split
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews * MAX_TX_DESC_PER_PACKET = MAX_COOKIES + one for the context descriptor +
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews * two for the workaround of the 82546 chip
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews */
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews#define MAX_COOKIES 18
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews#define MAX_TX_DESC_PER_PACKET 21
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews/*
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews * constants used in setting flow control thresholds
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews */
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews#define E1000_PBA_MASK 0xffff
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews#define E1000_PBA_SHIFT 10
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews#define E1000_FC_HIGH_DIFF 0x1638 /* High: 5688 bytes below Rx FIFO size */
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews#define E1000_FC_LOW_DIFF 0x1640 /* Low: 5696 bytes below Rx FIFO size */
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews#define E1000_FC_PAUSE_TIME 0x0680 /* 858 usec */
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews#define MAX_NUM_TX_DESCRIPTOR 4096
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews#define MAX_NUM_RX_DESCRIPTOR 4096
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews#define MAX_NUM_RX_FREELIST 4096
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews#define MAX_NUM_TX_FREELIST 4096
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews#define MAX_RX_LIMIT_ON_INTR 4096
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews#define MAX_RX_INTR_DELAY 65535
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews#define MAX_RX_INTR_ABS_DELAY 65535
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews#define MAX_TX_INTR_DELAY 65535
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews#define MAX_TX_INTR_ABS_DELAY 65535
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews#define MAX_INTR_THROTTLING 65535
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews#define MAX_RX_BCOPY_THRESHOLD E1000_RX_BUFFER_SIZE_2K
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews#define MAX_TX_BCOPY_THRESHOLD E1000_TX_BUFFER_SIZE_2K
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews#define MAX_MCAST_NUM 8192
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews#define MIN_NUM_TX_DESCRIPTOR 80
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews#define MIN_NUM_RX_DESCRIPTOR 80
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews#define MIN_NUM_RX_FREELIST 64
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews#define MIN_NUM_TX_FREELIST 80
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews#define MIN_RX_LIMIT_ON_INTR 16
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews#define MIN_RX_INTR_DELAY 0
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews#define MIN_RX_INTR_ABS_DELAY 0
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews#define MIN_TX_INTR_DELAY 0
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews#define MIN_TX_INTR_ABS_DELAY 0
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews#define MIN_INTR_THROTTLING 0
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews#define MIN_RX_BCOPY_THRESHOLD 0
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews#define MIN_TX_BCOPY_THRESHOLD ETHERMIN
d999ca28d40337907b55eebc28a255b638702379Evan Hunt#define MIN_MCAST_NUM 8
d999ca28d40337907b55eebc28a255b638702379Evan Hunt
d999ca28d40337907b55eebc28a255b638702379Evan Hunt#define DEFAULT_NUM_RX_DESCRIPTOR 2048
d999ca28d40337907b55eebc28a255b638702379Evan Hunt#define DEFAULT_NUM_TX_DESCRIPTOR 2048
d999ca28d40337907b55eebc28a255b638702379Evan Hunt#define DEFAULT_NUM_RX_FREELIST 4096
d999ca28d40337907b55eebc28a255b638702379Evan Hunt#define DEFAULT_NUM_TX_FREELIST 2304
d999ca28d40337907b55eebc28a255b638702379Evan Hunt#define DEFAULT_JUMBO_NUM_RX_DESC 1024
d999ca28d40337907b55eebc28a255b638702379Evan Hunt#define DEFAULT_JUMBO_NUM_TX_DESC 1024
d999ca28d40337907b55eebc28a255b638702379Evan Hunt#define DEFAULT_JUMBO_NUM_RX_BUF 2048
d999ca28d40337907b55eebc28a255b638702379Evan Hunt#define DEFAULT_JUMBO_NUM_TX_BUF 1152
d999ca28d40337907b55eebc28a255b638702379Evan Hunt#define DEFAULT_RX_LIMIT_ON_INTR 128
d999ca28d40337907b55eebc28a255b638702379Evan Hunt
d999ca28d40337907b55eebc28a255b638702379Evan Hunt#ifdef __sparc
d999ca28d40337907b55eebc28a255b638702379Evan Hunt#define MAX_INTR_PER_SEC 7100
d999ca28d40337907b55eebc28a255b638702379Evan Hunt#define MIN_INTR_PER_SEC 3000
d999ca28d40337907b55eebc28a255b638702379Evan Hunt#define DEFAULT_INTR_PACKET_LOW 5
d999ca28d40337907b55eebc28a255b638702379Evan Hunt#define DEFAULT_INTR_PACKET_HIGH 128
d999ca28d40337907b55eebc28a255b638702379Evan Hunt#else
d999ca28d40337907b55eebc28a255b638702379Evan Hunt#define MAX_INTR_PER_SEC 15000
d999ca28d40337907b55eebc28a255b638702379Evan Hunt#define MIN_INTR_PER_SEC 4000
d999ca28d40337907b55eebc28a255b638702379Evan Hunt#define DEFAULT_INTR_PACKET_LOW 10
d999ca28d40337907b55eebc28a255b638702379Evan Hunt#define DEFAULT_INTR_PACKET_HIGH 48
d999ca28d40337907b55eebc28a255b638702379Evan Hunt#endif
d999ca28d40337907b55eebc28a255b638702379Evan Hunt
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein#define DEFAULT_RX_INTR_DELAY 0
92551304a9abff9284de5b79a48e83d781989339Mark Andrews#define DEFAULT_RX_INTR_ABS_DELAY 64
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews#define DEFAULT_TX_INTR_DELAY 64
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews#define DEFAULT_TX_INTR_ABS_DELAY 64
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews#define DEFAULT_INTR_THROTTLING_HIGH 1000000000/(MIN_INTR_PER_SEC*256)
fc14ca7a8f340f98884c504b3c4c3f40d7393fa9Mark Andrews#define DEFAULT_INTR_THROTTLING_LOW 1000000000/(MAX_INTR_PER_SEC*256)
a903095bf4512dae561c7f6fc7854a51bebf334aMark Andrews#define DEFAULT_INTR_THROTTLING DEFAULT_INTR_THROTTLING_LOW
fc14ca7a8f340f98884c504b3c4c3f40d7393fa9Mark Andrews
92551304a9abff9284de5b79a48e83d781989339Mark Andrews#define DEFAULT_RX_BCOPY_THRESHOLD 128
92551304a9abff9284de5b79a48e83d781989339Mark Andrews#define DEFAULT_TX_BCOPY_THRESHOLD 512
d999ca28d40337907b55eebc28a255b638702379Evan Hunt#define DEFAULT_TX_UPDATE_THRESHOLD 256
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews#define DEFAULT_TX_NO_RESOURCE MAX_TX_DESC_PER_PACKET
baad8d9fd8dd054ce1edf350ff0c0f2038a1519eEvan Hunt
075a3d60c23140f05db10d70126ff271ef6469c9Mark Andrews#define DEFAULT_TX_INTR_ENABLE 1
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews#define DEFAULT_FLOW_CONTROL 3
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews#define DEFAULT_MASTER_LATENCY_TIMER 0 /* BIOS should decide */
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews /* which is normally 0x040 */
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews#define DEFAULT_TBI_COMPAT_ENABLE 1 /* Enable SBP workaround */
baad8d9fd8dd054ce1edf350ff0c0f2038a1519eEvan Hunt#define DEFAULT_MSI_ENABLE 1 /* MSI Enable */
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews#define DEFAULT_TX_HCKSUM_ENABLE 1 /* Hardware checksum enable */
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews#define DEFAULT_LSO_ENABLE 1 /* LSO enable */
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews#define DEFAULT_MEM_WORKAROUND_82546 1 /* 82546 memory workaround */
a903095bf4512dae561c7f6fc7854a51bebf334aMark Andrews
35f6a21f5f8114542c050bfcb484b39ce513d4bdEvan Hunt#define TX_DRAIN_TIME (200) /* # milliseconds xmit drain */
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews#define RX_DRAIN_TIME (200) /* # milliseconds recv drain */
2c15fcdeac4c2402258867fbac24d7475ef98259Mark Andrews
92551304a9abff9284de5b79a48e83d781989339Mark Andrews#define TX_STALL_TIME_2S (200) /* in unit of tick */
92551304a9abff9284de5b79a48e83d781989339Mark Andrews#define TX_STALL_TIME_8S (800) /* in unit of tick */
92551304a9abff9284de5b79a48e83d781989339Mark Andrews
bf33eb0b522801792a6663b0360bc94b9e9b77c2Automatic Updater/*
bf33eb0b522801792a6663b0360bc94b9e9b77c2Automatic Updater * The size of the receive/transmite buffers
bf33eb0b522801792a6663b0360bc94b9e9b77c2Automatic Updater */
92551304a9abff9284de5b79a48e83d781989339Mark Andrews#define E1000_RX_BUFFER_SIZE_2K (2048)
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews#define E1000_RX_BUFFER_SIZE_4K (4096)
92551304a9abff9284de5b79a48e83d781989339Mark Andrews#define E1000_RX_BUFFER_SIZE_8K (8192)
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews#define E1000_RX_BUFFER_SIZE_16K (16384)
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews#define E1000_TX_BUFFER_SIZE_2K (2048)
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews#define E1000_TX_BUFFER_SIZE_4K (4096)
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews#define E1000_TX_BUFFER_SIZE_8K (8192)
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews#define E1000_TX_BUFFER_SIZE_16K (16384)
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews#define E1000_TX_BUFFER_OEVRRUN_THRESHOLD (2015)
0874abad14e3e9ecfc3dc1a1a2b9969f2f027724Mark Andrews
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews#define E1000G_RX_NORMAL 0x0
075a3d60c23140f05db10d70126ff271ef6469c9Mark Andrews#define E1000G_RX_STOPPED 0x1
075a3d60c23140f05db10d70126ff271ef6469c9Mark Andrews
075a3d60c23140f05db10d70126ff271ef6469c9Mark Andrews#define E1000G_CHAIN_NO_LIMIT 0
075a3d60c23140f05db10d70126ff271ef6469c9Mark Andrews
92551304a9abff9284de5b79a48e83d781989339Mark Andrews/*
92551304a9abff9284de5b79a48e83d781989339Mark Andrews * definitions for smartspeed workaround
92551304a9abff9284de5b79a48e83d781989339Mark Andrews */
d999ca28d40337907b55eebc28a255b638702379Evan Hunt#define E1000_SMARTSPEED_MAX 30 /* 30 watchdog iterations */
baad8d9fd8dd054ce1edf350ff0c0f2038a1519eEvan Hunt /* or 30 seconds */
baad8d9fd8dd054ce1edf350ff0c0f2038a1519eEvan Hunt#define E1000_SMARTSPEED_DOWNSHIFT 6 /* 6 watchdog iterations */
baad8d9fd8dd054ce1edf350ff0c0f2038a1519eEvan Hunt /* or 6 seconds */
baad8d9fd8dd054ce1edf350ff0c0f2038a1519eEvan Hunt
baad8d9fd8dd054ce1edf350ff0c0f2038a1519eEvan Hunt/*
baad8d9fd8dd054ce1edf350ff0c0f2038a1519eEvan Hunt * Definitions for module_info.
baad8d9fd8dd054ce1edf350ff0c0f2038a1519eEvan Hunt */
baad8d9fd8dd054ce1edf350ff0c0f2038a1519eEvan Hunt#define WSNAME "e1000g" /* module name */
baad8d9fd8dd054ce1edf350ff0c0f2038a1519eEvan Hunt
baad8d9fd8dd054ce1edf350ff0c0f2038a1519eEvan Hunt/*
baad8d9fd8dd054ce1edf350ff0c0f2038a1519eEvan Hunt * Defined for IP header alignment. We also need to preserve space for
baad8d9fd8dd054ce1edf350ff0c0f2038a1519eEvan Hunt * VLAN tag (4 bytes)
baad8d9fd8dd054ce1edf350ff0c0f2038a1519eEvan Hunt */
d999ca28d40337907b55eebc28a255b638702379Evan Hunt#define E1000G_IPALIGNROOM 6
d999ca28d40337907b55eebc28a255b638702379Evan Hunt#define E1000G_IPALIGNPRESERVEROOM 64
d999ca28d40337907b55eebc28a255b638702379Evan Hunt
d999ca28d40337907b55eebc28a255b638702379Evan Hunt/*
d999ca28d40337907b55eebc28a255b638702379Evan Hunt * bit flags for 'attach_progress' which is a member variable in struct e1000g
d999ca28d40337907b55eebc28a255b638702379Evan Hunt */
d999ca28d40337907b55eebc28a255b638702379Evan Hunt#define ATTACH_PROGRESS_PCI_CONFIG 0x0001 /* PCI config setup */
d999ca28d40337907b55eebc28a255b638702379Evan Hunt#define ATTACH_PROGRESS_REGS_MAP 0x0002 /* Registers mapped */
d999ca28d40337907b55eebc28a255b638702379Evan Hunt#define ATTACH_PROGRESS_SETUP 0x0004 /* Setup driver parameters */
d999ca28d40337907b55eebc28a255b638702379Evan Hunt#define ATTACH_PROGRESS_ADD_INTR 0x0008 /* Interrupt added */
d999ca28d40337907b55eebc28a255b638702379Evan Hunt#define ATTACH_PROGRESS_LOCKS 0x0010 /* Locks initialized */
d999ca28d40337907b55eebc28a255b638702379Evan Hunt#define ATTACH_PROGRESS_SOFT_INTR 0x0020 /* Soft interrupt added */
d999ca28d40337907b55eebc28a255b638702379Evan Hunt#define ATTACH_PROGRESS_KSTATS 0x0040 /* Kstats created */
92551304a9abff9284de5b79a48e83d781989339Mark Andrews#define ATTACH_PROGRESS_ALLOC 0x0080 /* DMA resources allocated */
d999ca28d40337907b55eebc28a255b638702379Evan Hunt#define ATTACH_PROGRESS_INIT 0x0100 /* Driver initialization */
baad8d9fd8dd054ce1edf350ff0c0f2038a1519eEvan Hunt/* 0200 used to be PROGRESS_NDD. Now unused */
baad8d9fd8dd054ce1edf350ff0c0f2038a1519eEvan Hunt#define ATTACH_PROGRESS_MAC 0x0400 /* MAC registered */
baad8d9fd8dd054ce1edf350ff0c0f2038a1519eEvan Hunt#define ATTACH_PROGRESS_ENABLE_INTR 0x0800 /* DDI interrupts enabled */
baad8d9fd8dd054ce1edf350ff0c0f2038a1519eEvan Hunt#define ATTACH_PROGRESS_FMINIT 0x1000 /* FMA initiated */
baad8d9fd8dd054ce1edf350ff0c0f2038a1519eEvan Hunt
baad8d9fd8dd054ce1edf350ff0c0f2038a1519eEvan Hunt/*
baad8d9fd8dd054ce1edf350ff0c0f2038a1519eEvan Hunt * Speed and Duplex Settings
baad8d9fd8dd054ce1edf350ff0c0f2038a1519eEvan Hunt */
baad8d9fd8dd054ce1edf350ff0c0f2038a1519eEvan Hunt#define GDIAG_10_HALF 1
d999ca28d40337907b55eebc28a255b638702379Evan Hunt#define GDIAG_10_FULL 2
d999ca28d40337907b55eebc28a255b638702379Evan Hunt#define GDIAG_100_HALF 3
d999ca28d40337907b55eebc28a255b638702379Evan Hunt#define GDIAG_100_FULL 4
3d17a3ba61a303d5c4d9867068d0fbe9f24d2988Mark Andrews#define GDIAG_1000_FULL 6
3d17a3ba61a303d5c4d9867068d0fbe9f24d2988Mark Andrews#define GDIAG_ANY 7
3d17a3ba61a303d5c4d9867068d0fbe9f24d2988Mark Andrews
3d17a3ba61a303d5c4d9867068d0fbe9f24d2988Mark Andrews/*
3d17a3ba61a303d5c4d9867068d0fbe9f24d2988Mark Andrews * Coexist Workaround RP: 07/04/03
3d17a3ba61a303d5c4d9867068d0fbe9f24d2988Mark Andrews * 82544 Workaround : Co-existence
3d17a3ba61a303d5c4d9867068d0fbe9f24d2988Mark Andrews */
3d17a3ba61a303d5c4d9867068d0fbe9f24d2988Mark Andrews#define MAX_TX_BUF_SIZE (8 * 1024)
3d17a3ba61a303d5c4d9867068d0fbe9f24d2988Mark Andrews
3d17a3ba61a303d5c4d9867068d0fbe9f24d2988Mark Andrews/*
3d17a3ba61a303d5c4d9867068d0fbe9f24d2988Mark Andrews * Defines for Jumbo Frame
3d17a3ba61a303d5c4d9867068d0fbe9f24d2988Mark Andrews */
3d17a3ba61a303d5c4d9867068d0fbe9f24d2988Mark Andrews#define FRAME_SIZE_UPTO_2K 2048
3d17a3ba61a303d5c4d9867068d0fbe9f24d2988Mark Andrews#define FRAME_SIZE_UPTO_4K 4096
3d17a3ba61a303d5c4d9867068d0fbe9f24d2988Mark Andrews#define FRAME_SIZE_UPTO_8K 8192
3d17a3ba61a303d5c4d9867068d0fbe9f24d2988Mark Andrews#define FRAME_SIZE_UPTO_16K 16384
3d17a3ba61a303d5c4d9867068d0fbe9f24d2988Mark Andrews#define FRAME_SIZE_UPTO_9K 9234
3d17a3ba61a303d5c4d9867068d0fbe9f24d2988Mark Andrews
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews#define DEFAULT_MTU ETHERMTU
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews#define MAXIMUM_MTU_4K 4096
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews#define MAXIMUM_MTU_9K 9216
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews#define DEFAULT_FRAME_SIZE \
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews (DEFAULT_MTU + sizeof (struct ether_vlan_header) + ETHERFCSL)
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews#define MAXIMUM_FRAME_SIZE \
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews (MAXIMUM_MTU + sizeof (struct ether_vlan_header) + ETHERFCSL)
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews#define E1000_LSO_MAXLEN 65535
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews/* Defines for Tx stall check */
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews#define E1000G_STALL_WATCHDOG_COUNT 8
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews#define MAX_TX_LINK_DOWN_TIMEOUT 8
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews/* Defines for DVMA */
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews#ifdef __sparc
2c15fcdeac4c2402258867fbac24d7475ef98259Mark Andrews#define E1000G_DEFAULT_DVMA_PAGE_NUM 2
2c15fcdeac4c2402258867fbac24d7475ef98259Mark Andrews#endif
2c15fcdeac4c2402258867fbac24d7475ef98259Mark Andrews
2c15fcdeac4c2402258867fbac24d7475ef98259Mark Andrews/*
2c15fcdeac4c2402258867fbac24d7475ef98259Mark Andrews * Loopback definitions
2c15fcdeac4c2402258867fbac24d7475ef98259Mark Andrews */
1f2635d3f7b3f0b3bf0d0310fe880d95e84f09fcMark Andrews#define E1000G_LB_NONE 0
1f2635d3f7b3f0b3bf0d0310fe880d95e84f09fcMark Andrews#define E1000G_LB_EXTERNAL_1000 1
2c15fcdeac4c2402258867fbac24d7475ef98259Mark Andrews#define E1000G_LB_EXTERNAL_100 2
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews#define E1000G_LB_EXTERNAL_10 3
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews#define E1000G_LB_INTERNAL_PHY 4
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews/*
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews * Private dip list definitions
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews */
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews#define E1000G_PRIV_DEVI_ATTACH 0x0
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews#define E1000G_PRIV_DEVI_DETACH 0x1
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews/*
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews * Tx descriptor LENGTH field mask
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews */
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews#define E1000G_TBD_LENGTH_MASK 0x000fffff
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews#define E1000G_IS_VLAN_PACKET(ptr) \
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews ((((struct ether_vlan_header *)(uintptr_t)ptr)->ether_tpid) == \
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews htons(ETHERTYPE_VLAN))
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews/*
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews * QUEUE_INIT_LIST -- Macro which will init ialize a queue to NULL.
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews */
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews#define QUEUE_INIT_LIST(_LH) \
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews (_LH)->Flink = (_LH)->Blink = (PSINGLE_LIST_LINK)0
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews/*
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews * IS_QUEUE_EMPTY -- Macro which checks to see if a queue is empty.
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews */
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews#define IS_QUEUE_EMPTY(_LH) \
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews ((_LH)->Flink == (PSINGLE_LIST_LINK)0)
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews/*
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews * QUEUE_GET_HEAD -- Macro which returns the head of the queue, but does
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews * not remove the head from the queue.
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews */
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews#define QUEUE_GET_HEAD(_LH) ((PSINGLE_LIST_LINK)((_LH)->Flink))
dc6da18ccbb808d21f123cc6bda399b44ad11445Mark Andrews
2c15fcdeac4c2402258867fbac24d7475ef98259Mark Andrews/*
2c15fcdeac4c2402258867fbac24d7475ef98259Mark Andrews * QUEUE_REMOVE_HEAD -- Macro which removes the head of the head of a queue.
2c15fcdeac4c2402258867fbac24d7475ef98259Mark Andrews */
2c15fcdeac4c2402258867fbac24d7475ef98259Mark Andrews#define QUEUE_REMOVE_HEAD(_LH) \
2c15fcdeac4c2402258867fbac24d7475ef98259Mark Andrews{ \
2c15fcdeac4c2402258867fbac24d7475ef98259Mark Andrews PSINGLE_LIST_LINK ListElem; \
2c15fcdeac4c2402258867fbac24d7475ef98259Mark Andrews if (ListElem = (_LH)->Flink) \
2c15fcdeac4c2402258867fbac24d7475ef98259Mark Andrews { \
26bb3b7a67b833f0a18072567de036226890ca1aMark Andrews if (!((_LH)->Flink = ListElem->Flink)) \
26bb3b7a67b833f0a18072567de036226890ca1aMark Andrews (_LH)->Blink = (PSINGLE_LIST_LINK) 0; \
26bb3b7a67b833f0a18072567de036226890ca1aMark Andrews } \
26bb3b7a67b833f0a18072567de036226890ca1aMark Andrews}
26bb3b7a67b833f0a18072567de036226890ca1aMark Andrews
26bb3b7a67b833f0a18072567de036226890ca1aMark Andrews/*
26bb3b7a67b833f0a18072567de036226890ca1aMark Andrews * QUEUE_POP_HEAD -- Macro which will pop the head off of a queue (list),
26bb3b7a67b833f0a18072567de036226890ca1aMark Andrews * and return it (this differs from QUEUE_REMOVE_HEAD only in
26bb3b7a67b833f0a18072567de036226890ca1aMark Andrews * the 1st line).
26bb3b7a67b833f0a18072567de036226890ca1aMark Andrews */
26bb3b7a67b833f0a18072567de036226890ca1aMark Andrews#define QUEUE_POP_HEAD(_LH) \
26bb3b7a67b833f0a18072567de036226890ca1aMark Andrews (PSINGLE_LIST_LINK)(_LH)->Flink; \
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews { \
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews PSINGLE_LIST_LINK ListElem; \
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews ListElem = (_LH)->Flink; \
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews if (ListElem) \
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews { \
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews (_LH)->Flink = ListElem->Flink; \
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews if (!(_LH)->Flink) \
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews (_LH)->Blink = (PSINGLE_LIST_LINK)0; \
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews } \
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews }
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews/*
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews * QUEUE_GET_TAIL -- Macro which returns the tail of the queue, but does not
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews * remove the tail from the queue.
bf33eb0b522801792a6663b0360bc94b9e9b77c2Automatic Updater */
bf33eb0b522801792a6663b0360bc94b9e9b77c2Automatic Updater#define QUEUE_GET_TAIL(_LH) ((PSINGLE_LIST_LINK)((_LH)->Blink))
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews/*
a903095bf4512dae561c7f6fc7854a51bebf334aMark Andrews * QUEUE_PUSH_TAIL -- Macro which puts an element at the tail (end) of the queue
a903095bf4512dae561c7f6fc7854a51bebf334aMark Andrews */
ef9334d745a759b02821950230260c1941d066d3Mukund Sivaraman#define QUEUE_PUSH_TAIL(_LH, _E) \
4e1d3e67cdc76609bad5f0310ac48de10b442b9fMark Andrews if ((_LH)->Blink) \
a903095bf4512dae561c7f6fc7854a51bebf334aMark Andrews { \
a903095bf4512dae561c7f6fc7854a51bebf334aMark Andrews ((PSINGLE_LIST_LINK)(_LH)->Blink)->Flink = \
a903095bf4512dae561c7f6fc7854a51bebf334aMark Andrews (PSINGLE_LIST_LINK)(_E); \
a903095bf4512dae561c7f6fc7854a51bebf334aMark Andrews (_LH)->Blink = (PSINGLE_LIST_LINK)(_E); \
35f6a21f5f8114542c050bfcb484b39ce513d4bdEvan Hunt } else { \
35f6a21f5f8114542c050bfcb484b39ce513d4bdEvan Hunt (_LH)->Flink = \
a903095bf4512dae561c7f6fc7854a51bebf334aMark Andrews (_LH)->Blink = (PSINGLE_LIST_LINK)(_E); \
a903095bf4512dae561c7f6fc7854a51bebf334aMark Andrews } \
a903095bf4512dae561c7f6fc7854a51bebf334aMark Andrews (_E)->Flink = (PSINGLE_LIST_LINK)0;
a903095bf4512dae561c7f6fc7854a51bebf334aMark Andrews
35f6a21f5f8114542c050bfcb484b39ce513d4bdEvan Hunt/*
35f6a21f5f8114542c050bfcb484b39ce513d4bdEvan Hunt * QUEUE_PUSH_HEAD -- Macro which puts an element at the head of the queue.
35f6a21f5f8114542c050bfcb484b39ce513d4bdEvan Hunt */
35f6a21f5f8114542c050bfcb484b39ce513d4bdEvan Hunt#define QUEUE_PUSH_HEAD(_LH, _E) \
35f6a21f5f8114542c050bfcb484b39ce513d4bdEvan Hunt if (!((_E)->Flink = (_LH)->Flink)) \
35f6a21f5f8114542c050bfcb484b39ce513d4bdEvan Hunt { \
35f6a21f5f8114542c050bfcb484b39ce513d4bdEvan Hunt (_LH)->Blink = (PSINGLE_LIST_LINK)(_E); \
35f6a21f5f8114542c050bfcb484b39ce513d4bdEvan Hunt } \
fc14ca7a8f340f98884c504b3c4c3f40d7393fa9Mark Andrews (_LH)->Flink = (PSINGLE_LIST_LINK)(_E);
fc14ca7a8f340f98884c504b3c4c3f40d7393fa9Mark Andrews
fc14ca7a8f340f98884c504b3c4c3f40d7393fa9Mark Andrews/*
d999ca28d40337907b55eebc28a255b638702379Evan Hunt * QUEUE_GET_NEXT -- Macro which returns the next element linked to the
92551304a9abff9284de5b79a48e83d781989339Mark Andrews * current element.
92551304a9abff9284de5b79a48e83d781989339Mark Andrews */
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein#define QUEUE_GET_NEXT(_LH, _E) \
92551304a9abff9284de5b79a48e83d781989339Mark Andrews (PSINGLE_LIST_LINK)((((_LH)->Blink) == (_E)) ? \
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews (0) : ((_E)->Flink))
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews
92551304a9abff9284de5b79a48e83d781989339Mark Andrews/*
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews * QUEUE_APPEND -- Macro which appends a queue to the tail of another queue
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews */
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews#define QUEUE_APPEND(_LH1, _LH2) \
92551304a9abff9284de5b79a48e83d781989339Mark Andrews if ((_LH2)->Flink) { \
b6a4cc6927f45f202826c4dc6bb29cd8aeba90efTatuya JINMEI 神明達哉 if ((_LH1)->Flink) { \
92551304a9abff9284de5b79a48e83d781989339Mark Andrews ((PSINGLE_LIST_LINK)(_LH1)->Blink)->Flink = \
92551304a9abff9284de5b79a48e83d781989339Mark Andrews ((PSINGLE_LIST_LINK)(_LH2)->Flink); \
92551304a9abff9284de5b79a48e83d781989339Mark Andrews } else { \
92551304a9abff9284de5b79a48e83d781989339Mark Andrews (_LH1)->Flink = \
92551304a9abff9284de5b79a48e83d781989339Mark Andrews ((PSINGLE_LIST_LINK)(_LH2)->Flink); \
92551304a9abff9284de5b79a48e83d781989339Mark Andrews } \
92551304a9abff9284de5b79a48e83d781989339Mark Andrews (_LH1)->Blink = ((PSINGLE_LIST_LINK)(_LH2)->Blink); \
92551304a9abff9284de5b79a48e83d781989339Mark Andrews }
92551304a9abff9284de5b79a48e83d781989339Mark Andrews
92551304a9abff9284de5b79a48e83d781989339Mark Andrews
92551304a9abff9284de5b79a48e83d781989339Mark Andrews#define QUEUE_SWITCH(_LH1, _LH2) \
92551304a9abff9284de5b79a48e83d781989339Mark Andrews if ((_LH2)->Flink) { \
92551304a9abff9284de5b79a48e83d781989339Mark Andrews (_LH1)->Flink = (_LH2)->Flink; \
92551304a9abff9284de5b79a48e83d781989339Mark Andrews (_LH1)->Blink = (_LH2)->Blink; \
92551304a9abff9284de5b79a48e83d781989339Mark Andrews (_LH2)->Flink = (_LH2)->Blink = (PSINGLE_LIST_LINK)0; \
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews }
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews/*
b6a4cc6927f45f202826c4dc6bb29cd8aeba90efTatuya JINMEI 神明達哉 * Property lookups
b6a4cc6927f45f202826c4dc6bb29cd8aeba90efTatuya JINMEI 神明達哉 */
92551304a9abff9284de5b79a48e83d781989339Mark Andrews#define E1000G_PROP_EXISTS(d, n) ddi_prop_exists(DDI_DEV_T_ANY, (d), \
92551304a9abff9284de5b79a48e83d781989339Mark Andrews DDI_PROP_DONTPASS, (n))
92551304a9abff9284de5b79a48e83d781989339Mark Andrews#define E1000G_PROP_GET_INT(d, n) ddi_prop_get_int(DDI_DEV_T_ANY, (d), \
92551304a9abff9284de5b79a48e83d781989339Mark Andrews DDI_PROP_DONTPASS, (n), -1)
0c29904b27c9ab3b85ecbde159b22ae1323bdbcdMukund Sivaraman
0c29904b27c9ab3b85ecbde159b22ae1323bdbcdMukund Sivaraman#ifdef E1000G_DEBUG
0c29904b27c9ab3b85ecbde159b22ae1323bdbcdMukund Sivaraman/*
0c29904b27c9ab3b85ecbde159b22ae1323bdbcdMukund Sivaraman * E1000G-specific ioctls ...
0c29904b27c9ab3b85ecbde159b22ae1323bdbcdMukund Sivaraman */
0c29904b27c9ab3b85ecbde159b22ae1323bdbcdMukund Sivaraman#define E1000G_IOC ((((((('E' << 4) + '1') << 4) \
0c29904b27c9ab3b85ecbde159b22ae1323bdbcdMukund Sivaraman + 'K') << 4) + 'G') << 4)
0c29904b27c9ab3b85ecbde159b22ae1323bdbcdMukund Sivaraman
0c29904b27c9ab3b85ecbde159b22ae1323bdbcdMukund Sivaraman/*
0c29904b27c9ab3b85ecbde159b22ae1323bdbcdMukund Sivaraman * These diagnostic IOCTLS are enabled only in DEBUG drivers
0c29904b27c9ab3b85ecbde159b22ae1323bdbcdMukund Sivaraman */
0c29904b27c9ab3b85ecbde159b22ae1323bdbcdMukund Sivaraman#define E1000G_IOC_REG_PEEK (E1000G_IOC | 1)
0c29904b27c9ab3b85ecbde159b22ae1323bdbcdMukund Sivaraman#define E1000G_IOC_REG_POKE (E1000G_IOC | 2)
0c29904b27c9ab3b85ecbde159b22ae1323bdbcdMukund Sivaraman#define E1000G_IOC_CHIP_RESET (E1000G_IOC | 3)
92551304a9abff9284de5b79a48e83d781989339Mark Andrews
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein#define E1000G_PP_SPACE_REG 0 /* PCI memory space */
92551304a9abff9284de5b79a48e83d781989339Mark Andrews#define E1000G_PP_SPACE_E1000G 1 /* driver's soft state */
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrewstypedef struct {
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews uint64_t pp_acc_size; /* It's 1, 2, 4 or 8 */
45e1bd63587102c3bb361eaca42ee7b714fb3542Mark Andrews uint64_t pp_acc_space; /* See #defines below */
92551304a9abff9284de5b79a48e83d781989339Mark Andrews uint64_t pp_acc_offset; /* See regs definition */
b6a4cc6927f45f202826c4dc6bb29cd8aeba90efTatuya JINMEI 神明達哉 uint64_t pp_acc_data; /* output for peek */
92551304a9abff9284de5b79a48e83d781989339Mark Andrews /* input for poke */
92551304a9abff9284de5b79a48e83d781989339Mark Andrews} e1000g_peekpoke_t;
92551304a9abff9284de5b79a48e83d781989339Mark Andrews#endif /* E1000G_DEBUG */
92551304a9abff9284de5b79a48e83d781989339Mark Andrews
92551304a9abff9284de5b79a48e83d781989339Mark Andrews/*
92551304a9abff9284de5b79a48e83d781989339Mark Andrews * (Internal) return values from ioctl subroutines
92551304a9abff9284de5b79a48e83d781989339Mark Andrews */
92551304a9abff9284de5b79a48e83d781989339Mark Andrewsenum ioc_reply {
0c29904b27c9ab3b85ecbde159b22ae1323bdbcdMukund Sivaraman IOC_INVAL = -1, /* bad, NAK with EINVAL */
0c29904b27c9ab3b85ecbde159b22ae1323bdbcdMukund Sivaraman IOC_DONE, /* OK, reply sent */
fc14ca7a8f340f98884c504b3c4c3f40d7393fa9Mark Andrews IOC_ACK, /* OK, just send ACK */
0c29904b27c9ab3b85ecbde159b22ae1323bdbcdMukund Sivaraman IOC_REPLY /* OK, just send reply */
92551304a9abff9284de5b79a48e83d781989339Mark Andrews};
92551304a9abff9284de5b79a48e83d781989339Mark Andrews
0c29904b27c9ab3b85ecbde159b22ae1323bdbcdMukund Sivaraman/*
0c29904b27c9ab3b85ecbde159b22ae1323bdbcdMukund Sivaraman * Named Data (ND) Parameter Management Structure
0c29904b27c9ab3b85ecbde159b22ae1323bdbcdMukund Sivaraman */
0c29904b27c9ab3b85ecbde159b22ae1323bdbcdMukund Sivaramantypedef struct {
0c29904b27c9ab3b85ecbde159b22ae1323bdbcdMukund Sivaraman uint32_t ndp_info;
0c29904b27c9ab3b85ecbde159b22ae1323bdbcdMukund Sivaraman uint32_t ndp_min;
0c29904b27c9ab3b85ecbde159b22ae1323bdbcdMukund Sivaraman uint32_t ndp_max;
0c29904b27c9ab3b85ecbde159b22ae1323bdbcdMukund Sivaraman uint32_t ndp_val;
0c29904b27c9ab3b85ecbde159b22ae1323bdbcdMukund Sivaraman struct e1000g *ndp_instance;
0c29904b27c9ab3b85ecbde159b22ae1323bdbcdMukund Sivaraman char *ndp_name;
fc14ca7a8f340f98884c504b3c4c3f40d7393fa9Mark Andrews} nd_param_t;
0c29904b27c9ab3b85ecbde159b22ae1323bdbcdMukund Sivaraman
b6a4cc6927f45f202826c4dc6bb29cd8aeba90efTatuya JINMEI 神明達哉/*
b6a4cc6927f45f202826c4dc6bb29cd8aeba90efTatuya JINMEI 神明達哉 * The entry of the private dip list
92551304a9abff9284de5b79a48e83d781989339Mark Andrews */
92551304a9abff9284de5b79a48e83d781989339Mark Andrewstypedef struct _private_devi_list {
b6a4cc6927f45f202826c4dc6bb29cd8aeba90efTatuya JINMEI 神明達哉 dev_info_t *priv_dip;
b6a4cc6927f45f202826c4dc6bb29cd8aeba90efTatuya JINMEI 神明達哉 uint32_t flag;
b6a4cc6927f45f202826c4dc6bb29cd8aeba90efTatuya JINMEI 神明達哉 uint32_t pending_rx_count;
b6a4cc6927f45f202826c4dc6bb29cd8aeba90efTatuya JINMEI 神明達哉 struct _private_devi_list *prev;
b6a4cc6927f45f202826c4dc6bb29cd8aeba90efTatuya JINMEI 神明達哉 struct _private_devi_list *next;
0c29904b27c9ab3b85ecbde159b22ae1323bdbcdMukund Sivaraman} private_devi_list_t;
0c29904b27c9ab3b85ecbde159b22ae1323bdbcdMukund Sivaraman
92551304a9abff9284de5b79a48e83d781989339Mark Andrews/*
92551304a9abff9284de5b79a48e83d781989339Mark Andrews * A structure that points to the next entry in the queue.
92551304a9abff9284de5b79a48e83d781989339Mark Andrews */
3bc4221346e5045c5679dd0d84f4f7d888a9da79Mark Andrewstypedef struct _SINGLE_LIST_LINK {
3bc4221346e5045c5679dd0d84f4f7d888a9da79Mark Andrews struct _SINGLE_LIST_LINK *Flink;
3bc4221346e5045c5679dd0d84f4f7d888a9da79Mark Andrews} SINGLE_LIST_LINK, *PSINGLE_LIST_LINK;
3bc4221346e5045c5679dd0d84f4f7d888a9da79Mark Andrews
3bc4221346e5045c5679dd0d84f4f7d888a9da79Mark Andrews/*
3bc4221346e5045c5679dd0d84f4f7d888a9da79Mark Andrews * A "ListHead" structure that points to the head and tail of a queue
3bc4221346e5045c5679dd0d84f4f7d888a9da79Mark Andrews */
3bc4221346e5045c5679dd0d84f4f7d888a9da79Mark Andrewstypedef struct _LIST_DESCRIBER {
3bc4221346e5045c5679dd0d84f4f7d888a9da79Mark Andrews struct _SINGLE_LIST_LINK *volatile Flink;
ab023a65562e62b85a824509d829b6fad87e00b1Rob Austein struct _SINGLE_LIST_LINK *volatile Blink;
7e8c1a13e97448db2ec17d05c4917939a12aa9c0Mark Andrews} LIST_DESCRIBER, *PLIST_DESCRIBER;
6ed87838feb246af313a14179680984ea722a9c4Andreas Gustafsson
b1b3495eba72ea2b7270c5cd62b0bb824de74e05Mark Andrewsenum e1000g_bar_type {
8d0ee7a153381d98f6c1e6e9bfe6b73659433666Brian Wellington E1000G_BAR_CONFIG = 0,
8d0ee7a153381d98f6c1e6e9bfe6b73659433666Brian Wellington E1000G_BAR_IO,
7e8c1a13e97448db2ec17d05c4917939a12aa9c0Mark Andrews E1000G_BAR_MEM32,
7e8c1a13e97448db2ec17d05c4917939a12aa9c0Mark Andrews E1000G_BAR_MEM64
b1b3495eba72ea2b7270c5cd62b0bb824de74e05Mark Andrews};
cda18e781315e9bc4f7ca161eb2ded5a45675bcfAndreas Gustafsson
77b101ced9801cdb226919784bfc1aa0650ace6aMark Andrewstypedef struct {
92551304a9abff9284de5b79a48e83d781989339Mark Andrews enum e1000g_bar_type type;
3bc4221346e5045c5679dd0d84f4f7d888a9da79Mark Andrews int rnumber;
ff6de396a93b9b73a37173059a595f3d295b57cbMark Andrews} bar_info_t;
bf33eb0b522801792a6663b0360bc94b9e9b77c2Automatic Updater
0f8c9b5eed7e8714ceb7d6d3675555df9c5f6350Mark Andrews/*
0f8c9b5eed7e8714ceb7d6d3675555df9c5f6350Mark Andrews * Address-Length pair structure that stores descriptor info
c4abb197160a74f7cd4ad23ebc63fbe0194010abEvan Hunt */
c4abb197160a74f7cd4ad23ebc63fbe0194010abEvan Hunttypedef struct _sw_desc {
c4abb197160a74f7cd4ad23ebc63fbe0194010abEvan Hunt uint64_t address;
c4abb197160a74f7cd4ad23ebc63fbe0194010abEvan Hunt uint32_t length;
c4abb197160a74f7cd4ad23ebc63fbe0194010abEvan Hunt} sw_desc_t, *p_sw_desc_t;
c4abb197160a74f7cd4ad23ebc63fbe0194010abEvan Hunt
c4abb197160a74f7cd4ad23ebc63fbe0194010abEvan Hunttypedef struct _desc_array {
c4abb197160a74f7cd4ad23ebc63fbe0194010abEvan Hunt sw_desc_t descriptor[4];
c4abb197160a74f7cd4ad23ebc63fbe0194010abEvan Hunt uint32_t elements;
c4abb197160a74f7cd4ad23ebc63fbe0194010abEvan Hunt} desc_array_t, *p_desc_array_t;
c4abb197160a74f7cd4ad23ebc63fbe0194010abEvan Hunt
c4abb197160a74f7cd4ad23ebc63fbe0194010abEvan Hunttypedef enum {
c4abb197160a74f7cd4ad23ebc63fbe0194010abEvan Hunt USE_NONE,
c4abb197160a74f7cd4ad23ebc63fbe0194010abEvan Hunt USE_BCOPY,
c4abb197160a74f7cd4ad23ebc63fbe0194010abEvan Hunt USE_DVMA,
c4abb197160a74f7cd4ad23ebc63fbe0194010abEvan Hunt USE_DMA
c4abb197160a74f7cd4ad23ebc63fbe0194010abEvan Hunt} dma_type_t;
c4abb197160a74f7cd4ad23ebc63fbe0194010abEvan Hunt
c4abb197160a74f7cd4ad23ebc63fbe0194010abEvan Hunttypedef struct _dma_buffer {
c4abb197160a74f7cd4ad23ebc63fbe0194010abEvan Hunt caddr_t address;
c4abb197160a74f7cd4ad23ebc63fbe0194010abEvan Hunt uint64_t dma_address;
c4abb197160a74f7cd4ad23ebc63fbe0194010abEvan Hunt ddi_acc_handle_t acc_handle;
c4abb197160a74f7cd4ad23ebc63fbe0194010abEvan Hunt ddi_dma_handle_t dma_handle;
c4abb197160a74f7cd4ad23ebc63fbe0194010abEvan Hunt size_t size;
c4abb197160a74f7cd4ad23ebc63fbe0194010abEvan Hunt size_t len;
c4abb197160a74f7cd4ad23ebc63fbe0194010abEvan Hunt} dma_buffer_t, *p_dma_buffer_t;
c4abb197160a74f7cd4ad23ebc63fbe0194010abEvan Hunt
b1b3495eba72ea2b7270c5cd62b0bb824de74e05Mark Andrews/*
92551304a9abff9284de5b79a48e83d781989339Mark Andrews * Transmit Control Block (TCB), Ndis equiv of SWPacket This
92551304a9abff9284de5b79a48e83d781989339Mark Andrews * structure stores the additional information that is
92551304a9abff9284de5b79a48e83d781989339Mark Andrews * associated with every packet to be transmitted. It stores the
92551304a9abff9284de5b79a48e83d781989339Mark Andrews * message block pointer and the TBD addresses associated with
e9359db5e958bf05f9b9c5fe3c27d533f0f05550Mark Andrews * the m_blk and also the link to the next tcb in the chain
7791dd06ea69d0fb2494788ad4c24d568f40bcdfMark Andrews */
7791dd06ea69d0fb2494788ad4c24d568f40bcdfMark Andrewstypedef struct _tx_sw_packet {
7791dd06ea69d0fb2494788ad4c24d568f40bcdfMark Andrews /* Link to the next tx_sw_packet in the list */
c4abb197160a74f7cd4ad23ebc63fbe0194010abEvan Hunt SINGLE_LIST_LINK Link;
c4abb197160a74f7cd4ad23ebc63fbe0194010abEvan Hunt mblk_t *mp;
c4abb197160a74f7cd4ad23ebc63fbe0194010abEvan Hunt uint32_t num_desc;
b1b3495eba72ea2b7270c5cd62b0bb824de74e05Mark Andrews uint32_t num_mblk_frag;
b1b3495eba72ea2b7270c5cd62b0bb824de74e05Mark Andrews dma_type_t dma_type;
b1b3495eba72ea2b7270c5cd62b0bb824de74e05Mark Andrews dma_type_t data_transfer_type;
b1b3495eba72ea2b7270c5cd62b0bb824de74e05Mark Andrews ddi_dma_handle_t tx_dma_handle;
b1b3495eba72ea2b7270c5cd62b0bb824de74e05Mark Andrews dma_buffer_t tx_buf[1];
b1b3495eba72ea2b7270c5cd62b0bb824de74e05Mark Andrews sw_desc_t desc[MAX_TX_DESC_PER_PACKET];
b1b3495eba72ea2b7270c5cd62b0bb824de74e05Mark Andrews int64_t tickstamp;
b1b3495eba72ea2b7270c5cd62b0bb824de74e05Mark Andrews} tx_sw_packet_t, *p_tx_sw_packet_t;
b1b3495eba72ea2b7270c5cd62b0bb824de74e05Mark Andrews
3bc4221346e5045c5679dd0d84f4f7d888a9da79Mark Andrews/*
3bc4221346e5045c5679dd0d84f4f7d888a9da79Mark Andrews * This structure is similar to the rx_sw_packet structure used
3bc4221346e5045c5679dd0d84f4f7d888a9da79Mark Andrews * for Ndis. This structure stores information about the 2k
3bc4221346e5045c5679dd0d84f4f7d888a9da79Mark Andrews * aligned receive buffer into which the FX1000 DMA's frames.
a26ad011f382d12058478704cb5e90e6f4366d01Andreas Gustafsson * This structure is maintained as a linked list of many
a26ad011f382d12058478704cb5e90e6f4366d01Andreas Gustafsson * receiver buffer pointers.
a26ad011f382d12058478704cb5e90e6f4366d01Andreas Gustafsson */
a26ad011f382d12058478704cb5e90e6f4366d01Andreas Gustafssontypedef struct _rx_sw_packet {
ff6de396a93b9b73a37173059a595f3d295b57cbMark Andrews /* Link to the next rx_sw_packet_t in the list */
ff6de396a93b9b73a37173059a595f3d295b57cbMark Andrews SINGLE_LIST_LINK Link;
ff6de396a93b9b73a37173059a595f3d295b57cbMark Andrews struct _rx_sw_packet *next;
ff6de396a93b9b73a37173059a595f3d295b57cbMark Andrews uint32_t ref_cnt;
92551304a9abff9284de5b79a48e83d781989339Mark Andrews mblk_t *mp;
92551304a9abff9284de5b79a48e83d781989339Mark Andrews caddr_t rx_data;
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews dma_type_t dma_type;
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews frtn_t free_rtn;
c5223c9cb7c22620d5ee6611228673e95b48a270Mark Andrews dma_buffer_t rx_buf[1];
92551304a9abff9284de5b79a48e83d781989339Mark Andrews} rx_sw_packet_t, *p_rx_sw_packet_t;
92551304a9abff9284de5b79a48e83d781989339Mark Andrews
0f8c9b5eed7e8714ceb7d6d3675555df9c5f6350Mark Andrewstypedef struct _mblk_list {
0f8c9b5eed7e8714ceb7d6d3675555df9c5f6350Mark Andrews mblk_t *head;
0f8c9b5eed7e8714ceb7d6d3675555df9c5f6350Mark Andrews mblk_t *tail;
0f8c9b5eed7e8714ceb7d6d3675555df9c5f6350Mark Andrews} mblk_list_t, *p_mblk_list_t;
47c5b8af920a93763c97d9a93ea1fd766961a5b3Evan Hunt
0f8c9b5eed7e8714ceb7d6d3675555df9c5f6350Mark Andrewstypedef struct _context_data {
b1b3495eba72ea2b7270c5cd62b0bb824de74e05Mark Andrews uint32_t ether_header_size;
0f8c9b5eed7e8714ceb7d6d3675555df9c5f6350Mark Andrews uint32_t cksum_flags;
0f8c9b5eed7e8714ceb7d6d3675555df9c5f6350Mark Andrews uint32_t cksum_start;
0f8c9b5eed7e8714ceb7d6d3675555df9c5f6350Mark Andrews uint32_t cksum_stuff;
0f8c9b5eed7e8714ceb7d6d3675555df9c5f6350Mark Andrews uint16_t mss;
0f8c9b5eed7e8714ceb7d6d3675555df9c5f6350Mark Andrews uint8_t hdr_len;
b1b3495eba72ea2b7270c5cd62b0bb824de74e05Mark Andrews uint32_t pay_len;
b1b3495eba72ea2b7270c5cd62b0bb824de74e05Mark Andrews boolean_t lso_flag;
b1b3495eba72ea2b7270c5cd62b0bb824de74e05Mark Andrews} context_data_t;
ff6de396a93b9b73a37173059a595f3d295b57cbMark Andrews
ff6de396a93b9b73a37173059a595f3d295b57cbMark Andrewstypedef union _e1000g_ether_addr {
ff6de396a93b9b73a37173059a595f3d295b57cbMark Andrews struct {
ff6de396a93b9b73a37173059a595f3d295b57cbMark Andrews uint32_t high;
ff6de396a93b9b73a37173059a595f3d295b57cbMark Andrews uint32_t low;
0f8c9b5eed7e8714ceb7d6d3675555df9c5f6350Mark Andrews } reg;
0f8c9b5eed7e8714ceb7d6d3675555df9c5f6350Mark Andrews struct {
b1b3495eba72ea2b7270c5cd62b0bb824de74e05Mark Andrews uint8_t set;
b1b3495eba72ea2b7270c5cd62b0bb824de74e05Mark Andrews uint8_t redundant;
7e8c1a13e97448db2ec17d05c4917939a12aa9c0Mark Andrews uint8_t addr[ETHERADDRL];
321fd0ceb416bf1c3d074ace4480dc938ca91b60Andreas Gustafsson } mac;
7e8c1a13e97448db2ec17d05c4917939a12aa9c0Mark Andrews} e1000g_ether_addr_t;
1b42401954a8770d82a168ae1ac06ce66862fd25Mark Andrews
1b42401954a8770d82a168ae1ac06ce66862fd25Mark Andrewstypedef struct _e1000g_stat {
1b42401954a8770d82a168ae1ac06ce66862fd25Mark Andrews
1b42401954a8770d82a168ae1ac06ce66862fd25Mark Andrews kstat_named_t link_speed; /* Link Speed */
0f8c9b5eed7e8714ceb7d6d3675555df9c5f6350Mark Andrews kstat_named_t reset_count; /* Reset Count */
7e8c1a13e97448db2ec17d05c4917939a12aa9c0Mark Andrews
77b101ced9801cdb226919784bfc1aa0650ace6aMark Andrews kstat_named_t rx_error; /* Rx Error in Packet */
77b101ced9801cdb226919784bfc1aa0650ace6aMark Andrews kstat_named_t rx_allocb_fail; /* Rx Allocb Failure */
77b101ced9801cdb226919784bfc1aa0650ace6aMark Andrews kstat_named_t rx_size_error; /* Rx Size Error */
77b101ced9801cdb226919784bfc1aa0650ace6aMark Andrews
e9472e9f18f1c4f1279be2b3147be13a2bb731d0Mark Andrews kstat_named_t tx_no_desc; /* Tx No Desc */
e9472e9f18f1c4f1279be2b3147be13a2bb731d0Mark Andrews kstat_named_t tx_no_swpkt; /* Tx No Pkt Buffer */
66a38d16933a28a0110079a9920ba359d2aad130Danny Mayer kstat_named_t tx_send_fail; /* Tx SendPkt Failure */
8d0ee7a153381d98f6c1e6e9bfe6b73659433666Brian Wellington kstat_named_t tx_over_size; /* Tx Pkt Too Long */
8d0ee7a153381d98f6c1e6e9bfe6b73659433666Brian Wellington kstat_named_t tx_reschedule; /* Tx Reschedule */
8d0ee7a153381d98f6c1e6e9bfe6b73659433666Brian Wellington
8d0ee7a153381d98f6c1e6e9bfe6b73659433666Brian Wellington#ifdef E1000G_DEBUG
8d0ee7a153381d98f6c1e6e9bfe6b73659433666Brian Wellington kstat_named_t rx_none; /* Rx No Incoming Data */
7e8c1a13e97448db2ec17d05c4917939a12aa9c0Mark Andrews kstat_named_t rx_multi_desc; /* Rx Multi Spanned Pkt */
7e8c1a13e97448db2ec17d05c4917939a12aa9c0Mark Andrews kstat_named_t rx_no_freepkt; /* Rx No Free Pkt */
c2bc56dc65b4b103a5600565680eb5f33fa4c90bMark Andrews kstat_named_t rx_avail_freepkt; /* Rx Freelist Avail Buffers */
cda18e781315e9bc4f7ca161eb2ded5a45675bcfAndreas Gustafsson
cda18e781315e9bc4f7ca161eb2ded5a45675bcfAndreas Gustafsson kstat_named_t tx_under_size; /* Tx Packet Under Size */
8d0ee7a153381d98f6c1e6e9bfe6b73659433666Brian Wellington kstat_named_t tx_empty_frags; /* Tx Empty Frags */
fc14ca7a8f340f98884c504b3c4c3f40d7393fa9Mark Andrews kstat_named_t tx_exceed_frags; /* Tx Exceed Max Frags */
92551304a9abff9284de5b79a48e83d781989339Mark Andrews kstat_named_t tx_recycle; /* Tx Recycle */
92551304a9abff9284de5b79a48e83d781989339Mark Andrews kstat_named_t tx_recycle_intr; /* Tx Recycle in Intr */
92551304a9abff9284de5b79a48e83d781989339Mark Andrews kstat_named_t tx_recycle_retry; /* Tx Recycle Retry */
92551304a9abff9284de5b79a48e83d781989339Mark Andrews kstat_named_t tx_recycle_none; /* Tx No Desc Recycled */
92551304a9abff9284de5b79a48e83d781989339Mark Andrews kstat_named_t tx_copy; /* Tx Send Copy */
3bc4221346e5045c5679dd0d84f4f7d888a9da79Mark Andrews kstat_named_t tx_bind; /* Tx Send Bind */
ff6de396a93b9b73a37173059a595f3d295b57cbMark Andrews kstat_named_t tx_multi_copy; /* Tx Copy Multi Fragments */
8d0ee7a153381d98f6c1e6e9bfe6b73659433666Brian Wellington kstat_named_t tx_multi_cookie; /* Tx Pkt Span Multi Cookies */
8d0ee7a153381d98f6c1e6e9bfe6b73659433666Brian Wellington kstat_named_t tx_lack_desc; /* Tx Lack of Desc */
8d0ee7a153381d98f6c1e6e9bfe6b73659433666Brian Wellington#endif
7e8c1a13e97448db2ec17d05c4917939a12aa9c0Mark Andrews
ed6ca94ad75353d5344e2a456e7a8beb480a351fMark Andrews kstat_named_t Crcerrs; /* CRC Error Count */
ed6ca94ad75353d5344e2a456e7a8beb480a351fMark Andrews kstat_named_t Symerrs; /* Symbol Error Count */
66a38d16933a28a0110079a9920ba359d2aad130Danny Mayer kstat_named_t Mpc; /* Missed Packet Count */
7e8c1a13e97448db2ec17d05c4917939a12aa9c0Mark Andrews kstat_named_t Scc; /* Single Collision Count */
77b101ced9801cdb226919784bfc1aa0650ace6aMark Andrews kstat_named_t Ecol; /* Excessive Collision Count */
77b101ced9801cdb226919784bfc1aa0650ace6aMark Andrews kstat_named_t Mcc; /* Multiple Collision Count */
77b101ced9801cdb226919784bfc1aa0650ace6aMark Andrews kstat_named_t Latecol; /* Late Collision Count */
7e8c1a13e97448db2ec17d05c4917939a12aa9c0Mark Andrews kstat_named_t Colc; /* Collision Count */
7e8c1a13e97448db2ec17d05c4917939a12aa9c0Mark Andrews kstat_named_t Dc; /* Defer Count */
1b42401954a8770d82a168ae1ac06ce66862fd25Mark Andrews kstat_named_t Sec; /* Sequence Error Count */
1b42401954a8770d82a168ae1ac06ce66862fd25Mark Andrews kstat_named_t Rlec; /* Receive Length Error Count */
1b42401954a8770d82a168ae1ac06ce66862fd25Mark Andrews kstat_named_t Xonrxc; /* XON Received Count */
1b42401954a8770d82a168ae1ac06ce66862fd25Mark Andrews kstat_named_t Xontxc; /* XON Xmitted Count */
cda18e781315e9bc4f7ca161eb2ded5a45675bcfAndreas Gustafsson kstat_named_t Xoffrxc; /* XOFF Received Count */
7e8c1a13e97448db2ec17d05c4917939a12aa9c0Mark Andrews kstat_named_t Xofftxc; /* Xoff Xmitted Count */
kstat_named_t Fcruc; /* Unknown Flow Conrol Packet Rcvd Count */
#ifdef E1000G_DEBUG
kstat_named_t Prc64; /* Packets Received - 64b */
kstat_named_t Prc127; /* Packets Received - 65-127b */
kstat_named_t Prc255; /* Packets Received - 127-255b */
kstat_named_t Prc511; /* Packets Received - 256-511b */
kstat_named_t Prc1023; /* Packets Received - 511-1023b */
kstat_named_t Prc1522; /* Packets Received - 1024-1522b */
#endif
kstat_named_t Gprc; /* Good Packets Received Count */
kstat_named_t Bprc; /* Broadcasts Pkts Received Count */
kstat_named_t Mprc; /* Multicast Pkts Received Count */
kstat_named_t Gptc; /* Good Packets Xmitted Count */
kstat_named_t Gorl; /* Good Octets Recvd Lo Count */
kstat_named_t Gorh; /* Good Octets Recvd Hi Count */
kstat_named_t Gotl; /* Good Octets Xmitd Lo Count */
kstat_named_t Goth; /* Good Octets Xmitd Hi Count */
kstat_named_t Rnbc; /* Receive No Buffers Count */
kstat_named_t Ruc; /* Receive Undersize Count */
kstat_named_t Rfc; /* Receive Frag Count */
kstat_named_t Roc; /* Receive Oversize Count */
kstat_named_t Rjc; /* Receive Jabber Count */
kstat_named_t Torl; /* Total Octets Recvd Lo Count */
kstat_named_t Torh; /* Total Octets Recvd Hi Count */
kstat_named_t Totl; /* Total Octets Xmted Lo Count */
kstat_named_t Toth; /* Total Octets Xmted Hi Count */
kstat_named_t Tpr; /* Total Packets Received */
kstat_named_t Tpt; /* Total Packets Xmitted */
#ifdef E1000G_DEBUG
kstat_named_t Ptc64; /* Packets Xmitted (64b) */
kstat_named_t Ptc127; /* Packets Xmitted (64-127b) */
kstat_named_t Ptc255; /* Packets Xmitted (128-255b) */
kstat_named_t Ptc511; /* Packets Xmitted (255-511b) */
kstat_named_t Ptc1023; /* Packets Xmitted (512-1023b) */
kstat_named_t Ptc1522; /* Packets Xmitted (1024-1522b */
#endif
kstat_named_t Mptc; /* Multicast Packets Xmited Count */
kstat_named_t Bptc; /* Broadcast Packets Xmited Count */
kstat_named_t Algnerrc; /* Alignment Error count */
kstat_named_t Tuc; /* Transmit Underrun count */
kstat_named_t Rxerrc; /* Rx Error Count */
kstat_named_t Tncrs; /* Transmit with no CRS */
kstat_named_t Cexterr; /* Carrier Extension Error count */
kstat_named_t Rutec; /* Receive DMA too Early count */
kstat_named_t Tsctc; /* TCP seg contexts xmit count */
kstat_named_t Tsctfc; /* TCP seg contexts xmit fail count */
} e1000g_stat_t, *p_e1000g_stat_t;
typedef struct _e1000g_tx_ring {
kmutex_t tx_lock;
kmutex_t freelist_lock;
kmutex_t usedlist_lock;
/*
* Descriptor queue definitions
*/
ddi_dma_handle_t tbd_dma_handle;
ddi_acc_handle_t tbd_acc_handle;
struct e1000_tx_desc *tbd_area;
uint64_t tbd_dma_addr;
struct e1000_tx_desc *tbd_first;
struct e1000_tx_desc *tbd_last;
struct e1000_tx_desc *tbd_oldest;
struct e1000_tx_desc *tbd_next;
uint32_t tbd_avail;
/*
* Software packet structures definitions
*/
p_tx_sw_packet_t packet_area;
LIST_DESCRIBER used_list;
LIST_DESCRIBER free_list;
/*
* TCP/UDP Context Data Information
*/
context_data_t pre_context;
/*
* Timer definitions for 82547
*/
timeout_id_t timer_id_82547;
boolean_t timer_enable_82547;
/*
* reschedule when tx resource is available
*/
boolean_t resched_needed;
clock_t resched_timestamp;
mblk_list_t mblks;
/*
* Statistics
*/
uint32_t stat_no_swpkt;
uint32_t stat_no_desc;
uint32_t stat_send_fail;
uint32_t stat_reschedule;
uint32_t stat_timer_reschedule;
uint32_t stat_over_size;
#ifdef E1000G_DEBUG
uint32_t stat_under_size;
uint32_t stat_exceed_frags;
uint32_t stat_empty_frags;
uint32_t stat_recycle;
uint32_t stat_recycle_intr;
uint32_t stat_recycle_retry;
uint32_t stat_recycle_none;
uint32_t stat_copy;
uint32_t stat_bind;
uint32_t stat_multi_copy;
uint32_t stat_multi_cookie;
uint32_t stat_lack_desc;
uint32_t stat_lso_header_fail;
#endif
/*
* Pointer to the adapter
*/
struct e1000g *adapter;
} e1000g_tx_ring_t, *pe1000g_tx_ring_t;
typedef struct _e1000g_rx_data {
kmutex_t freelist_lock;
kmutex_t recycle_lock;
/*
* Descriptor queue definitions
*/
ddi_dma_handle_t rbd_dma_handle;
ddi_acc_handle_t rbd_acc_handle;
struct e1000_rx_desc *rbd_area;
uint64_t rbd_dma_addr;
struct e1000_rx_desc *rbd_first;
struct e1000_rx_desc *rbd_last;
struct e1000_rx_desc *rbd_next;
/*
* Software packet structures definitions
*/
p_rx_sw_packet_t packet_area;
LIST_DESCRIBER recv_list;
LIST_DESCRIBER free_list;
LIST_DESCRIBER recycle_list;
uint32_t flag;
uint32_t pending_count;
uint32_t avail_freepkt;
uint32_t recycle_freepkt;
uint32_t rx_mblk_len;
mblk_t *rx_mblk;
mblk_t *rx_mblk_tail;
private_devi_list_t *priv_devi_node;
struct _e1000g_rx_ring *rx_ring;
} e1000g_rx_data_t;
typedef struct _e1000g_rx_ring {
e1000g_rx_data_t *rx_data;
kmutex_t rx_lock;
mac_ring_handle_t mrh;
mac_ring_handle_t mrh_init;
uint64_t ring_gen_num;
boolean_t poll_flag;
/*
* Statistics
*/
uint32_t stat_error;
uint32_t stat_allocb_fail;
uint32_t stat_exceed_pkt;
uint32_t stat_size_error;
#ifdef E1000G_DEBUG
uint32_t stat_none;
uint32_t stat_multi_desc;
uint32_t stat_no_freepkt;
#endif
/*
* Pointer to the adapter
*/
struct e1000g *adapter;
} e1000g_rx_ring_t, *pe1000g_rx_ring_t;
typedef struct e1000g {
int instance;
dev_info_t *dip;
dev_info_t *priv_dip;
private_devi_list_t *priv_devi_node;
mac_handle_t mh;
mac_resource_handle_t mrh;
struct e1000_hw shared;
struct e1000g_osdep osdep;
uint32_t e1000g_state;
boolean_t e1000g_promisc;
boolean_t strip_crc;
boolean_t rx_buffer_setup;
boolean_t esb2_workaround;
link_state_t link_state;
uint32_t link_speed;
uint32_t link_duplex;
uint32_t master_latency_timer;
uint32_t smartspeed; /* smartspeed w/a counter */
uint32_t init_count;
uint32_t reset_count;
boolean_t reset_flag;
uint32_t stall_threshold;
boolean_t stall_flag;
uint32_t attach_progress; /* attach tracking */
uint32_t loopback_mode;
uint32_t pending_rx_count;
uint32_t tx_desc_num;
uint32_t tx_freelist_num;
uint32_t rx_desc_num;
uint32_t rx_freelist_num;
uint32_t tx_buffer_size;
uint32_t rx_buffer_size;
uint32_t tx_link_down_timeout;
uint32_t tx_bcopy_thresh;
uint32_t rx_limit_onintr;
uint32_t rx_bcopy_thresh;
uint32_t rx_buf_align;
uint32_t desc_align;
boolean_t intr_adaptive;
boolean_t tx_intr_enable;
uint32_t tx_intr_delay;
uint32_t tx_intr_abs_delay;
uint32_t rx_intr_delay;
uint32_t rx_intr_abs_delay;
uint32_t intr_throttling_rate;
uint32_t tx_desc_num_flag:1,
rx_desc_num_flag:1,
tx_buf_num_flag:1,
rx_buf_num_flag:1,
pad_to_32:28;
uint32_t default_mtu;
uint32_t max_mtu;
uint32_t max_frame_size;
uint32_t min_frame_size;
boolean_t watchdog_timer_enabled;
boolean_t watchdog_timer_started;
timeout_id_t watchdog_tid;
boolean_t link_complete;
timeout_id_t link_tid;
e1000g_rx_ring_t rx_ring[1];
e1000g_tx_ring_t tx_ring[1];
mac_group_handle_t rx_group;
/*
* Rx and Tx packet count for interrupt adaptive setting
*/
uint32_t rx_pkt_cnt;
uint32_t tx_pkt_cnt;
/*
* The watchdog_lock must be held when updateing the
* timeout fields in struct e1000g, that is,
* watchdog_tid, watchdog_timer_started.
*/
kmutex_t watchdog_lock;
/*
* The link_lock protects the link fields in struct e1000g,
* such as link_state, link_speed, link_duplex, link_complete, and
* link_tid.
*/
kmutex_t link_lock;
/*
* The chip_lock assures that the Rx/Tx process must be
* stopped while other functions change the hardware
* configuration of e1000g card, such as e1000g_reset(),
* e1000g_reset_hw() etc are executed.
*/
krwlock_t chip_lock;
boolean_t unicst_init;
uint32_t unicst_avail;
uint32_t unicst_total;
e1000g_ether_addr_t unicst_addr[MAX_NUM_UNICAST_ADDRESSES];
uint32_t mcast_count;
uint32_t mcast_max_num;
uint32_t mcast_alloc_count;
struct ether_addr *mcast_table;
ulong_t sys_page_sz;
#ifdef __sparc
uint_t dvma_page_num;
#endif
boolean_t msi_enable;
boolean_t tx_hcksum_enable;
boolean_t lso_enable;
boolean_t lso_premature_issue;
boolean_t mem_workaround_82546;
int intr_type;
int intr_cnt;
int intr_cap;
size_t intr_size;
uint_t intr_pri;
ddi_intr_handle_t *htable;
int tx_softint_pri;
ddi_softint_handle_t tx_softint_handle;
kstat_t *e1000g_ksp;
boolean_t poll_mode;
uint16_t phy_ctrl; /* contents of PHY_CTRL */
uint16_t phy_status; /* contents of PHY_STATUS */
uint16_t phy_an_adv; /* contents of PHY_AUTONEG_ADV */
uint16_t phy_an_exp; /* contents of PHY_AUTONEG_EXP */
uint16_t phy_ext_status; /* contents of PHY_EXT_STATUS */
uint16_t phy_1000t_ctrl; /* contents of PHY_1000T_CTRL */
uint16_t phy_1000t_status; /* contents of PHY_1000T_STATUS */
uint16_t phy_lp_able; /* contents of PHY_LP_ABILITY */
/*
* FMA capabilities
*/
int fm_capabilities;
uint32_t param_en_1000fdx:1,
param_en_1000hdx:1,
param_en_100fdx:1,
param_en_100hdx:1,
param_en_10fdx:1,
param_en_10hdx:1,
param_autoneg_cap:1,
param_pause_cap:1,
param_asym_pause_cap:1,
param_1000fdx_cap:1,
param_1000hdx_cap:1,
param_100t4_cap:1,
param_100fdx_cap:1,
param_100hdx_cap:1,
param_10fdx_cap:1,
param_10hdx_cap:1,
param_adv_autoneg:1,
param_adv_pause:1,
param_adv_asym_pause:1,
param_adv_1000fdx:1,
param_adv_1000hdx:1,
param_adv_100t4:1,
param_adv_100fdx:1,
param_adv_100hdx:1,
param_adv_10fdx:1,
param_adv_10hdx:1,
param_lp_autoneg:1,
param_lp_pause:1,
param_lp_asym_pause:1,
param_lp_1000fdx:1,
param_lp_1000hdx:1,
param_lp_100t4:1;
uint32_t param_lp_100fdx:1,
param_lp_100hdx:1,
param_lp_10fdx:1,
param_lp_10hdx:1,
param_pad_to_32:28;
} e1000g_t;
/*
* Function prototypes
*/
void e1000g_free_priv_devi_node(private_devi_list_t *devi_node);
void e1000g_free_rx_pending_buffers(e1000g_rx_data_t *rx_data);
void e1000g_free_rx_data(e1000g_rx_data_t *rx_data);
int e1000g_alloc_dma_resources(struct e1000g *Adapter);
void e1000g_release_dma_resources(struct e1000g *Adapter);
void e1000g_free_rx_sw_packet(p_rx_sw_packet_t packet, boolean_t full_release);
void e1000g_tx_setup(struct e1000g *Adapter);
void e1000g_rx_setup(struct e1000g *Adapter);
int e1000g_recycle(e1000g_tx_ring_t *tx_ring);
void e1000g_free_tx_swpkt(p_tx_sw_packet_t packet);
void e1000g_tx_freemsg(e1000g_tx_ring_t *tx_ring);
uint_t e1000g_tx_softint_worker(caddr_t arg1, caddr_t arg2);
mblk_t *e1000g_m_tx(void *arg, mblk_t *mp);
mblk_t *e1000g_receive(e1000g_rx_ring_t *rx_ring, mblk_t **tail, uint_t sz);
void e1000g_rxfree_func(p_rx_sw_packet_t packet);
int e1000g_m_stat(void *arg, uint_t stat, uint64_t *val);
int e1000g_init_stats(struct e1000g *Adapter);
int e1000g_rx_ring_stat(mac_ring_driver_t, uint_t, uint64_t *);
void e1000_tbi_adjust_stats(struct e1000g *Adapter,
uint32_t frame_len, uint8_t *mac_addr);
void e1000g_clear_interrupt(struct e1000g *Adapter);
void e1000g_mask_interrupt(struct e1000g *Adapter);
void e1000g_clear_all_interrupts(struct e1000g *Adapter);
void e1000g_clear_tx_interrupt(struct e1000g *Adapter);
void e1000g_mask_tx_interrupt(struct e1000g *Adapter);
void phy_spd_state(struct e1000_hw *hw, boolean_t enable);
void e1000_destroy_hw_mutex(struct e1000_hw *hw);
void e1000_enable_pciex_master(struct e1000_hw *hw);
int e1000g_check_acc_handle(ddi_acc_handle_t handle);
int e1000g_check_dma_handle(ddi_dma_handle_t handle);
void e1000g_fm_ereport(struct e1000g *Adapter, char *detail);
void e1000g_set_fma_flags(int dma_flag);
int e1000g_reset_link(struct e1000g *Adapter);
/*
* Global variables
*/
extern boolean_t e1000g_force_detach;
extern uint32_t e1000g_mblks_pending;
extern kmutex_t e1000g_rx_detach_lock;
extern private_devi_list_t *e1000g_private_devi_list;
extern int e1000g_poll_mode;
#ifdef __cplusplus
}
#endif
#endif /* _E1000G_SW_H */