1c869993eSxy150489 /* 2c869993eSxy150489 * CDDL HEADER START 3c869993eSxy150489 * 4c869993eSxy150489 * The contents of this file are subject to the terms of the 5c869993eSxy150489 * Common Development and Distribution License (the "License"). 6c869993eSxy150489 * You may not use this file except in compliance with the License. 7c869993eSxy150489 * 80dc2366fSVenugopal Iyer * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90dc2366fSVenugopal Iyer * or http://www.opensolaris.org/os/licensing. 10c869993eSxy150489 * See the License for the specific language governing permissions 11c869993eSxy150489 * and limitations under the License. 12c869993eSxy150489 * 130dc2366fSVenugopal Iyer * When distributing Covered Code, include this CDDL HEADER in each 140dc2366fSVenugopal Iyer * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15c869993eSxy150489 * If applicable, add the following below this CDDL HEADER, with the 16c869993eSxy150489 * fields enclosed by brackets "[]" replaced with your own identifying 17c869993eSxy150489 * information: Portions Copyright [yyyy] [name of copyright owner] 18c869993eSxy150489 * 19c869993eSxy150489 * CDDL HEADER END 20c869993eSxy150489 */ 21c869993eSxy150489 22c869993eSxy150489 /* 2308a0f9b0Schenlu chen - Sun Microsystems - Beijing China * Copyright(c) 2007-2010 Intel Corporation. All rights reserved. 2408a0f9b0Schenlu chen - Sun Microsystems - Beijing China */ 2508a0f9b0Schenlu chen - Sun Microsystems - Beijing China 2608a0f9b0Schenlu chen - Sun Microsystems - Beijing China /* 2708a0f9b0Schenlu chen - Sun Microsystems - Beijing China * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. 2813485e69SGarrett D'Amore * Copyright 2014 Pluribus Networks Inc. 29*b142f83dSRobert Mustacchi * Copyright (c) 2017, Joyent, Inc. 30c869993eSxy150489 */ 31c869993eSxy150489 32c869993eSxy150489 #ifndef _IGB_SW_H 33c869993eSxy150489 #define _IGB_SW_H 34c869993eSxy150489 35c869993eSxy150489 #ifdef __cplusplus 36c869993eSxy150489 extern "C" { 37c869993eSxy150489 #endif 38c869993eSxy150489 39c869993eSxy150489 #include <sys/types.h> 40c869993eSxy150489 #include <sys/conf.h> 41c869993eSxy150489 #include <sys/debug.h> 42c869993eSxy150489 #include <sys/stropts.h> 43c869993eSxy150489 #include <sys/stream.h> 44c869993eSxy150489 #include <sys/strsun.h> 45c869993eSxy150489 #include <sys/strlog.h> 46c869993eSxy150489 #include <sys/kmem.h> 47c869993eSxy150489 #include <sys/stat.h> 48c869993eSxy150489 #include <sys/kstat.h> 49c869993eSxy150489 #include <sys/modctl.h> 50c869993eSxy150489 #include <sys/errno.h> 51c869993eSxy150489 #include <sys/dlpi.h> 52da14cebeSEric Cheng #include <sys/mac_provider.h> 53c869993eSxy150489 #include <sys/mac_ether.h> 54c869993eSxy150489 #include <sys/vlan.h> 55c869993eSxy150489 #include <sys/ddi.h> 56c869993eSxy150489 #include <sys/sunddi.h> 57c869993eSxy150489 #include <sys/pci.h> 58c869993eSxy150489 #include <sys/pcie.h> 59c869993eSxy150489 #include <sys/sdt.h> 60c869993eSxy150489 #include <sys/ethernet.h> 61c869993eSxy150489 #include <sys/pattr.h> 62c869993eSxy150489 #include <sys/strsubr.h> 63c869993eSxy150489 #include <sys/netlb.h> 64c869993eSxy150489 #include <sys/random.h> 65c869993eSxy150489 #include <inet/common.h> 66d11274aaSPaul Guo #include <inet/tcp.h> 67c869993eSxy150489 #include <inet/ip.h> 68c869993eSxy150489 #include <inet/mi.h> 69c869993eSxy150489 #include <inet/nd.h> 708bb4b220Sgl147354 #include <sys/ddifm.h> 718bb4b220Sgl147354 #include <sys/fm/protocol.h> 728bb4b220Sgl147354 #include <sys/fm/util.h> 738bb4b220Sgl147354 #include <sys/fm/io/ddi.h> 7475eba5b6SRobert Mustacchi #include "e1000_api.h" 7575eba5b6SRobert Mustacchi #include "e1000_82575.h" 76c869993eSxy150489 77c869993eSxy150489 78c869993eSxy150489 #define MODULE_NAME "igb" /* module name */ 79c869993eSxy150489 80c869993eSxy150489 #define IGB_SUCCESS DDI_SUCCESS 81c869993eSxy150489 #define IGB_FAILURE DDI_FAILURE 82c869993eSxy150489 83c869993eSxy150489 #define IGB_UNKNOWN 0x00 84c869993eSxy150489 #define IGB_INITIALIZED 0x01 85c869993eSxy150489 #define IGB_STARTED 0x02 86c869993eSxy150489 #define IGB_SUSPENDED 0x04 873f7e60a6Szhefeng xu - Sun Microsystems - Beijing China #define IGB_STALL 0x08 88cf8dcc9bSzhefeng xu - Sun Microsystems - Beijing China #define IGB_ERROR 0x80 89c869993eSxy150489 90ac7f5757Schenlu chen - Sun Microsystems - Beijing China #define IGB_RX_STOPPED 0x1 91ac7f5757Schenlu chen - Sun Microsystems - Beijing China 92c869993eSxy150489 #define IGB_INTR_NONE 0 93c869993eSxy150489 #define IGB_INTR_MSIX 1 94c869993eSxy150489 #define IGB_INTR_MSI 2 95c869993eSxy150489 #define IGB_INTR_LEGACY 3 96c869993eSxy150489 9780a11ad2Schenlu chen - Sun Microsystems - Beijing China #define IGB_ADAPTER_REGSET 1 /* mapping adapter registers */ 9880a11ad2Schenlu chen - Sun Microsystems - Beijing China #define IGB_ADAPTER_MSIXTAB 4 /* mapping msi-x table */ 9980a11ad2Schenlu chen - Sun Microsystems - Beijing China 100da14cebeSEric Cheng #define IGB_NO_POLL -1 101da14cebeSEric Cheng #define IGB_NO_FREE_SLOT -1 102da14cebeSEric Cheng 103c869993eSxy150489 #define MAX_NUM_UNICAST_ADDRESSES E1000_RAR_ENTRIES 1046ca163a1Svitezslav batrla - Sun Microsystems - Prague Czech Republic #define MCAST_ALLOC_COUNT 256 105d11274aaSPaul Guo #define MAX_COOKIE 18 106c869993eSxy150489 #define MIN_NUM_TX_DESC 2 107c869993eSxy150489 108c869993eSxy150489 /* 10980a11ad2Schenlu chen - Sun Microsystems - Beijing China * Number of settings for interrupt throttle rate (ITR). There is one of 11080a11ad2Schenlu chen - Sun Microsystems - Beijing China * these per msi-x vector and it needs to be the maximum of all silicon 11180a11ad2Schenlu chen - Sun Microsystems - Beijing China * types supported by this driver. 11280a11ad2Schenlu chen - Sun Microsystems - Beijing China */ 11380a11ad2Schenlu chen - Sun Microsystems - Beijing China #define MAX_NUM_EITR 25 11480a11ad2Schenlu chen - Sun Microsystems - Beijing China 11580a11ad2Schenlu chen - Sun Microsystems - Beijing China /* 116c869993eSxy150489 * Maximum values for user configurable parameters 117c869993eSxy150489 */ 118c869993eSxy150489 #define MAX_TX_RING_SIZE 4096 119c869993eSxy150489 #define MAX_RX_RING_SIZE 4096 120da14cebeSEric Cheng #define MAX_RX_GROUP_NUM 4 121c869993eSxy150489 122c869993eSxy150489 #define MAX_MTU 9000 123c869993eSxy150489 #define MAX_RX_LIMIT_PER_INTR 4096 124c869993eSxy150489 125c869993eSxy150489 #define MAX_RX_COPY_THRESHOLD 9216 126c869993eSxy150489 #define MAX_TX_COPY_THRESHOLD 9216 127c869993eSxy150489 #define MAX_TX_RECYCLE_THRESHOLD DEFAULT_TX_RING_SIZE 128c869993eSxy150489 #define MAX_TX_OVERLOAD_THRESHOLD DEFAULT_TX_RING_SIZE 129c869993eSxy150489 #define MAX_TX_RESCHED_THRESHOLD DEFAULT_TX_RING_SIZE 1306ca163a1Svitezslav batrla - Sun Microsystems - Prague Czech Republic #define MAX_MCAST_NUM 8192 131c869993eSxy150489 132c869993eSxy150489 /* 133c869993eSxy150489 * Minimum values for user configurable parameters 134c869993eSxy150489 */ 135c869993eSxy150489 #define MIN_TX_RING_SIZE 64 136c869993eSxy150489 #define MIN_RX_RING_SIZE 64 137da14cebeSEric Cheng #define MIN_RX_GROUP_NUM 1 138c869993eSxy150489 139c869993eSxy150489 #define MIN_MTU ETHERMIN 140c869993eSxy150489 #define MIN_RX_LIMIT_PER_INTR 16 1413f7e60a6Szhefeng xu - Sun Microsystems - Beijing China 142c869993eSxy150489 #define MIN_RX_COPY_THRESHOLD 0 143c869993eSxy150489 #define MIN_TX_COPY_THRESHOLD 0 144c869993eSxy150489 #define MIN_TX_RECYCLE_THRESHOLD MIN_NUM_TX_DESC 145c869993eSxy150489 #define MIN_TX_OVERLOAD_THRESHOLD MIN_NUM_TX_DESC 146c869993eSxy150489 #define MIN_TX_RESCHED_THRESHOLD MIN_NUM_TX_DESC 1476ca163a1Svitezslav batrla - Sun Microsystems - Prague Czech Republic #define MIN_MCAST_NUM 8 148c869993eSxy150489 149c869993eSxy150489 /* 150c869993eSxy150489 * Default values for user configurable parameters 151c869993eSxy150489 */ 152c869993eSxy150489 #define DEFAULT_TX_RING_SIZE 512 153c869993eSxy150489 #define DEFAULT_RX_RING_SIZE 512 154da14cebeSEric Cheng #define DEFAULT_RX_GROUP_NUM 1 155c869993eSxy150489 156c869993eSxy150489 #define DEFAULT_MTU ETHERMTU 157c869993eSxy150489 #define DEFAULT_RX_LIMIT_PER_INTR 256 1583f7e60a6Szhefeng xu - Sun Microsystems - Beijing China 159c869993eSxy150489 #define DEFAULT_RX_COPY_THRESHOLD 128 160c869993eSxy150489 #define DEFAULT_TX_COPY_THRESHOLD 512 161d11274aaSPaul Guo #define DEFAULT_TX_RECYCLE_THRESHOLD (MAX_COOKIE + 1) 162c869993eSxy150489 #define DEFAULT_TX_OVERLOAD_THRESHOLD MIN_NUM_TX_DESC 163c869993eSxy150489 #define DEFAULT_TX_RESCHED_THRESHOLD 128 16469b2d733SGuoqing Zhu #define DEFAULT_TX_RESCHED_THRESHOLD_LOW 32 1656ca163a1Svitezslav batrla - Sun Microsystems - Prague Czech Republic #define DEFAULT_MCAST_NUM 4096 166c869993eSxy150489 167d11274aaSPaul Guo #define IGB_LSO_MAXLEN 65535 168d11274aaSPaul Guo 169c869993eSxy150489 #define TX_DRAIN_TIME 200 170c869993eSxy150489 #define RX_DRAIN_TIME 200 171c869993eSxy150489 172c869993eSxy150489 #define STALL_WATCHDOG_TIMEOUT 8 /* 8 seconds */ 173c869993eSxy150489 174c869993eSxy150489 /* 175c869993eSxy150489 * Defined for IP header alignment. 176c869993eSxy150489 */ 177c869993eSxy150489 #define IPHDR_ALIGN_ROOM 2 178c869993eSxy150489 179c869993eSxy150489 /* 180c869993eSxy150489 * Bit flags for attach_progress 181c869993eSxy150489 */ 182c869993eSxy150489 #define ATTACH_PROGRESS_PCI_CONFIG 0x0001 /* PCI config setup */ 183c869993eSxy150489 #define ATTACH_PROGRESS_REGS_MAP 0x0002 /* Registers mapped */ 184c869993eSxy150489 #define ATTACH_PROGRESS_PROPS 0x0004 /* Properties initialized */ 185c869993eSxy150489 #define ATTACH_PROGRESS_ALLOC_INTR 0x0008 /* Interrupts allocated */ 186c869993eSxy150489 #define ATTACH_PROGRESS_ALLOC_RINGS 0x0010 /* Rings allocated */ 187c869993eSxy150489 #define ATTACH_PROGRESS_ADD_INTR 0x0020 /* Intr handlers added */ 188c869993eSxy150489 #define ATTACH_PROGRESS_LOCKS 0x0040 /* Locks initialized */ 189b8d0a377Schenlu chen - Sun Microsystems - Beijing China #define ATTACH_PROGRESS_INIT_ADAPTER 0x0080 /* Adapter initialized */ 190c869993eSxy150489 #define ATTACH_PROGRESS_STATS 0x0200 /* Kstats created */ 191c869993eSxy150489 #define ATTACH_PROGRESS_MAC 0x0800 /* MAC registered */ 192c869993eSxy150489 #define ATTACH_PROGRESS_ENABLE_INTR 0x1000 /* DDI interrupts enabled */ 1938bb4b220Sgl147354 #define ATTACH_PROGRESS_FMINIT 0x2000 /* FMA initialized */ 194c869993eSxy150489 195c869993eSxy150489 #define PROP_ADV_AUTONEG_CAP "adv_autoneg_cap" 196c869993eSxy150489 #define PROP_ADV_1000FDX_CAP "adv_1000fdx_cap" 197c869993eSxy150489 #define PROP_ADV_1000HDX_CAP "adv_1000hdx_cap" 198c869993eSxy150489 #define PROP_ADV_100FDX_CAP "adv_100fdx_cap" 199c869993eSxy150489 #define PROP_ADV_100HDX_CAP "adv_100hdx_cap" 200c869993eSxy150489 #define PROP_ADV_10FDX_CAP "adv_10fdx_cap" 201c869993eSxy150489 #define PROP_ADV_10HDX_CAP "adv_10hdx_cap" 202c869993eSxy150489 #define PROP_DEFAULT_MTU "default_mtu" 203c869993eSxy150489 #define PROP_FLOW_CONTROL "flow_control" 204c869993eSxy150489 #define PROP_TX_RING_SIZE "tx_ring_size" 205c869993eSxy150489 #define PROP_RX_RING_SIZE "rx_ring_size" 206da14cebeSEric Cheng #define PROP_MR_ENABLE "mr_enable" 207da14cebeSEric Cheng #define PROP_RX_GROUP_NUM "rx_group_number" 208c869993eSxy150489 209c869993eSxy150489 #define PROP_INTR_FORCE "intr_force" 210c869993eSxy150489 #define PROP_TX_HCKSUM_ENABLE "tx_hcksum_enable" 211c869993eSxy150489 #define PROP_RX_HCKSUM_ENABLE "rx_hcksum_enable" 212c869993eSxy150489 #define PROP_LSO_ENABLE "lso_enable" 213c869993eSxy150489 #define PROP_TX_HEAD_WB_ENABLE "tx_head_wb_enable" 214c869993eSxy150489 #define PROP_TX_COPY_THRESHOLD "tx_copy_threshold" 215c869993eSxy150489 #define PROP_TX_RECYCLE_THRESHOLD "tx_recycle_threshold" 216c869993eSxy150489 #define PROP_TX_OVERLOAD_THRESHOLD "tx_overload_threshold" 217c869993eSxy150489 #define PROP_TX_RESCHED_THRESHOLD "tx_resched_threshold" 218c869993eSxy150489 #define PROP_RX_COPY_THRESHOLD "rx_copy_threshold" 219c869993eSxy150489 #define PROP_RX_LIMIT_PER_INTR "rx_limit_per_intr" 220c869993eSxy150489 #define PROP_INTR_THROTTLING "intr_throttling" 2216ca163a1Svitezslav batrla - Sun Microsystems - Prague Czech Republic #define PROP_MCAST_MAX_NUM "mcast_max_num" 222c869993eSxy150489 223c869993eSxy150489 #define IGB_LB_NONE 0 224c869993eSxy150489 #define IGB_LB_EXTERNAL 1 225c869993eSxy150489 #define IGB_LB_INTERNAL_PHY 3 226c869993eSxy150489 #define IGB_LB_INTERNAL_SERDES 4 227c869993eSxy150489 228c869993eSxy150489 enum ioc_reply { 229c869993eSxy150489 IOC_INVAL = -1, /* bad, NAK with EINVAL */ 230c869993eSxy150489 IOC_DONE, /* OK, reply sent */ 231c869993eSxy150489 IOC_ACK, /* OK, just send ACK */ 232c869993eSxy150489 IOC_REPLY /* OK, just send reply */ 233c869993eSxy150489 }; 234c869993eSxy150489 235d11274aaSPaul Guo /* 236d11274aaSPaul Guo * For s/w context extraction from a tx frame 237d11274aaSPaul Guo */ 238d11274aaSPaul Guo #define TX_CXT_SUCCESS 0 239d11274aaSPaul Guo #define TX_CXT_E_LSO_CSUM (-1) 240d11274aaSPaul Guo #define TX_CXT_E_ETHER_TYPE (-2) 241c869993eSxy150489 242c869993eSxy150489 #define DMA_SYNC(area, flag) ((void) ddi_dma_sync((area)->dma_handle, \ 243c869993eSxy150489 0, 0, (flag))) 244c869993eSxy150489 245c869993eSxy150489 /* 246c869993eSxy150489 * Defined for ring index operations 247c869993eSxy150489 * ASSERT(index < limit) 248c869993eSxy150489 * ASSERT(step < limit) 249c869993eSxy150489 * ASSERT(index1 < limit) 250c869993eSxy150489 * ASSERT(index2 < limit) 251c869993eSxy150489 */ 252c869993eSxy150489 #define NEXT_INDEX(index, step, limit) (((index) + (step)) < (limit) ? \ 253c869993eSxy150489 (index) + (step) : (index) + (step) - (limit)) 254c869993eSxy150489 #define PREV_INDEX(index, step, limit) ((index) >= (step) ? \ 255c869993eSxy150489 (index) - (step) : (index) + (limit) - (step)) 256c869993eSxy150489 #define OFFSET(index1, index2, limit) ((index1) <= (index2) ? \ 257c869993eSxy150489 (index2) - (index1) : (index2) + (limit) - (index1)) 258c869993eSxy150489 259c869993eSxy150489 #define LINK_LIST_INIT(_LH) \ 260c869993eSxy150489 (_LH)->head = (_LH)->tail = NULL 261c869993eSxy150489 262c869993eSxy150489 #define LIST_GET_HEAD(_LH) ((single_link_t *)((_LH)->head)) 263c869993eSxy150489 264c869993eSxy150489 #define LIST_POP_HEAD(_LH) \ 265c869993eSxy150489 (single_link_t *)(_LH)->head; \ 266c869993eSxy150489 { \ 267c869993eSxy150489 if ((_LH)->head != NULL) { \ 268c869993eSxy150489 (_LH)->head = (_LH)->head->link; \ 269c869993eSxy150489 if ((_LH)->head == NULL) \ 270c869993eSxy150489 (_LH)->tail = NULL; \ 271c869993eSxy150489 } \ 272c869993eSxy150489 } 273c869993eSxy150489 274c869993eSxy150489 #define LIST_GET_TAIL(_LH) ((single_link_t *)((_LH)->tail)) 275c869993eSxy150489 276c869993eSxy150489 #define LIST_PUSH_TAIL(_LH, _E) \ 277c869993eSxy150489 if ((_LH)->tail != NULL) { \ 278c869993eSxy150489 (_LH)->tail->link = (single_link_t *)(_E); \ 279c869993eSxy150489 (_LH)->tail = (single_link_t *)(_E); \ 280c869993eSxy150489 } else { \ 281c869993eSxy150489 (_LH)->head = (_LH)->tail = (single_link_t *)(_E); \ 282c869993eSxy150489 } \ 283c869993eSxy150489 (_E)->link = NULL; 284c869993eSxy150489 285c869993eSxy150489 #define LIST_GET_NEXT(_LH, _E) \ 286c869993eSxy150489 (((_LH)->tail == (single_link_t *)(_E)) ? \ 287c869993eSxy150489 NULL : ((single_link_t *)(_E))->link) 288c869993eSxy150489 289c869993eSxy150489 290c869993eSxy150489 typedef struct single_link { 291c869993eSxy150489 struct single_link *link; 292c869993eSxy150489 } single_link_t; 293c869993eSxy150489 294c869993eSxy150489 typedef struct link_list { 295c869993eSxy150489 single_link_t *head; 296c869993eSxy150489 single_link_t *tail; 297c869993eSxy150489 } link_list_t; 298c869993eSxy150489 299c869993eSxy150489 /* 300c869993eSxy150489 * Property lookups 301c869993eSxy150489 */ 302c869993eSxy150489 #define IGB_PROP_EXISTS(d, n) ddi_prop_exists(DDI_DEV_T_ANY, (d), \ 303c869993eSxy150489 DDI_PROP_DONTPASS, (n)) 304c869993eSxy150489 #define IGB_PROP_GET_INT(d, n) ddi_prop_get_int(DDI_DEV_T_ANY, (d), \ 305c869993eSxy150489 DDI_PROP_DONTPASS, (n), -1) 306c869993eSxy150489 307c869993eSxy150489 30880a11ad2Schenlu chen - Sun Microsystems - Beijing China /* capability/feature flags */ 30980a11ad2Schenlu chen - Sun Microsystems - Beijing China #define IGB_FLAG_HAS_DCA (1 << 0) /* has Direct Cache Access */ 31080a11ad2Schenlu chen - Sun Microsystems - Beijing China #define IGB_FLAG_VMDQ_POOL (1 << 1) /* has vmdq capability */ 31180a11ad2Schenlu chen - Sun Microsystems - Beijing China #define IGB_FLAG_NEED_CTX_IDX (1 << 2) /* context descriptor needs index */ 31280a11ad2Schenlu chen - Sun Microsystems - Beijing China 31380a11ad2Schenlu chen - Sun Microsystems - Beijing China /* function pointer for nic-specific functions */ 31480a11ad2Schenlu chen - Sun Microsystems - Beijing China typedef void (*igb_nic_func_t)(struct igb *); 31580a11ad2Schenlu chen - Sun Microsystems - Beijing China 31680a11ad2Schenlu chen - Sun Microsystems - Beijing China /* adapter-specific info for each supported device type */ 31780a11ad2Schenlu chen - Sun Microsystems - Beijing China typedef struct adapter_info { 31880a11ad2Schenlu chen - Sun Microsystems - Beijing China /* limits */ 31980a11ad2Schenlu chen - Sun Microsystems - Beijing China uint32_t max_rx_que_num; /* maximum number of rx queues */ 32080a11ad2Schenlu chen - Sun Microsystems - Beijing China uint32_t min_rx_que_num; /* minimum number of rx queues */ 32180a11ad2Schenlu chen - Sun Microsystems - Beijing China uint32_t def_rx_que_num; /* default number of rx queues */ 32280a11ad2Schenlu chen - Sun Microsystems - Beijing China uint32_t max_tx_que_num; /* maximum number of tx queues */ 32380a11ad2Schenlu chen - Sun Microsystems - Beijing China uint32_t min_tx_que_num; /* minimum number of tx queues */ 32480a11ad2Schenlu chen - Sun Microsystems - Beijing China uint32_t def_tx_que_num; /* default number of tx queues */ 32580a11ad2Schenlu chen - Sun Microsystems - Beijing China uint32_t max_intr_throttle; /* maximum interrupt throttle */ 32680a11ad2Schenlu chen - Sun Microsystems - Beijing China uint32_t min_intr_throttle; /* minimum interrupt throttle */ 32780a11ad2Schenlu chen - Sun Microsystems - Beijing China uint32_t def_intr_throttle; /* default interrupt throttle */ 32880a11ad2Schenlu chen - Sun Microsystems - Beijing China /* function pointers */ 32980a11ad2Schenlu chen - Sun Microsystems - Beijing China igb_nic_func_t enable_intr; /* enable adapter interrupts */ 33080a11ad2Schenlu chen - Sun Microsystems - Beijing China igb_nic_func_t setup_msix; /* set up msi-x vectors */ 33180a11ad2Schenlu chen - Sun Microsystems - Beijing China /* capabilities */ 33280a11ad2Schenlu chen - Sun Microsystems - Beijing China uint32_t flags; /* capability flags */ 333b8d0a377Schenlu chen - Sun Microsystems - Beijing China uint32_t rxdctl_mask; /* mask for RXDCTL register */ 33480a11ad2Schenlu chen - Sun Microsystems - Beijing China } adapter_info_t; 33580a11ad2Schenlu chen - Sun Microsystems - Beijing China 336c869993eSxy150489 typedef union igb_ether_addr { 337c869993eSxy150489 struct { 338c869993eSxy150489 uint32_t high; 339c869993eSxy150489 uint32_t low; 340c869993eSxy150489 } reg; 341c869993eSxy150489 struct { 342c869993eSxy150489 uint8_t set; 343da14cebeSEric Cheng uint8_t group_index; 344c869993eSxy150489 uint8_t addr[ETHERADDRL]; 345c869993eSxy150489 } mac; 346c869993eSxy150489 } igb_ether_addr_t; 347c869993eSxy150489 348c869993eSxy150489 typedef enum { 349c869993eSxy150489 USE_NONE, 350c869993eSxy150489 USE_COPY, 351c869993eSxy150489 USE_DMA 352c869993eSxy150489 } tx_type_t; 353c869993eSxy150489 354d11274aaSPaul Guo typedef struct tx_context { 355c869993eSxy150489 uint32_t hcksum_flags; 356c869993eSxy150489 uint32_t ip_hdr_len; 357c869993eSxy150489 uint32_t mac_hdr_len; 358c869993eSxy150489 uint32_t l4_proto; 359d11274aaSPaul Guo uint32_t mss; 360d11274aaSPaul Guo uint32_t l4_hdr_len; 361d11274aaSPaul Guo boolean_t lso_flag; 362d11274aaSPaul Guo } tx_context_t; 363c869993eSxy150489 364c869993eSxy150489 /* Hold address/length of each DMA segment */ 365c869993eSxy150489 typedef struct sw_desc { 366c869993eSxy150489 uint64_t address; 367c869993eSxy150489 size_t length; 368c869993eSxy150489 } sw_desc_t; 369c869993eSxy150489 370c869993eSxy150489 /* Handles and addresses of DMA buffer */ 371c869993eSxy150489 typedef struct dma_buffer { 372c869993eSxy150489 caddr_t address; /* Virtual address */ 373c869993eSxy150489 uint64_t dma_address; /* DMA (Hardware) address */ 374c869993eSxy150489 ddi_acc_handle_t acc_handle; /* Data access handle */ 375c869993eSxy150489 ddi_dma_handle_t dma_handle; /* DMA handle */ 376c869993eSxy150489 size_t size; /* Buffer size */ 377c869993eSxy150489 size_t len; /* Data length in the buffer */ 378c869993eSxy150489 } dma_buffer_t; 379c869993eSxy150489 380c869993eSxy150489 /* 381c869993eSxy150489 * Tx Control Block 382c869993eSxy150489 */ 383c869993eSxy150489 typedef struct tx_control_block { 384c869993eSxy150489 single_link_t link; 38569b2d733SGuoqing Zhu uint32_t last_index; 386c869993eSxy150489 uint32_t frag_num; 387c869993eSxy150489 uint32_t desc_num; 388c869993eSxy150489 mblk_t *mp; 389c869993eSxy150489 tx_type_t tx_type; 390c869993eSxy150489 ddi_dma_handle_t tx_dma_handle; 391c869993eSxy150489 dma_buffer_t tx_buf; 392c869993eSxy150489 sw_desc_t desc[MAX_COOKIE]; 393c869993eSxy150489 } tx_control_block_t; 394c869993eSxy150489 395c869993eSxy150489 /* 396c869993eSxy150489 * RX Control Block 397c869993eSxy150489 */ 398c869993eSxy150489 typedef struct rx_control_block { 399c869993eSxy150489 mblk_t *mp; 400ac7f5757Schenlu chen - Sun Microsystems - Beijing China uint32_t ref_cnt; 401c869993eSxy150489 dma_buffer_t rx_buf; 402c869993eSxy150489 frtn_t free_rtn; 403ac7f5757Schenlu chen - Sun Microsystems - Beijing China struct igb_rx_data *rx_data; 404c869993eSxy150489 } rx_control_block_t; 405c869993eSxy150489 406c869993eSxy150489 /* 407c869993eSxy150489 * Software Data Structure for Tx Ring 408c869993eSxy150489 */ 409c869993eSxy150489 typedef struct igb_tx_ring { 410c869993eSxy150489 uint32_t index; /* Ring index */ 411da14cebeSEric Cheng uint32_t intr_vector; /* Interrupt vector index */ 412c869993eSxy150489 413c869993eSxy150489 /* 414c869993eSxy150489 * Mutexes 415c869993eSxy150489 */ 416c869993eSxy150489 kmutex_t tx_lock; 417c869993eSxy150489 kmutex_t recycle_lock; 418c869993eSxy150489 kmutex_t tcb_head_lock; 419c869993eSxy150489 kmutex_t tcb_tail_lock; 420c869993eSxy150489 421c869993eSxy150489 /* 422c869993eSxy150489 * Tx descriptor ring definitions 423c869993eSxy150489 */ 424c869993eSxy150489 dma_buffer_t tbd_area; 425c869993eSxy150489 union e1000_adv_tx_desc *tbd_ring; 426c869993eSxy150489 uint32_t tbd_head; /* Index of next tbd to recycle */ 427c869993eSxy150489 uint32_t tbd_tail; /* Index of next tbd to transmit */ 428c869993eSxy150489 uint32_t tbd_free; /* Number of free tbd */ 429c869993eSxy150489 430c869993eSxy150489 /* 431c869993eSxy150489 * Tx control block list definitions 432c869993eSxy150489 */ 433c869993eSxy150489 tx_control_block_t *tcb_area; 434c869993eSxy150489 tx_control_block_t **work_list; 435c869993eSxy150489 tx_control_block_t **free_list; 436c869993eSxy150489 uint32_t tcb_head; /* Head index of free list */ 437c869993eSxy150489 uint32_t tcb_tail; /* Tail index of free list */ 438c869993eSxy150489 uint32_t tcb_free; /* Number of free tcb in free list */ 439c869993eSxy150489 440c869993eSxy150489 uint32_t *tbd_head_wb; /* Head write-back */ 441c869993eSxy150489 uint32_t (*tx_recycle)(struct igb_tx_ring *); 442c869993eSxy150489 443c869993eSxy150489 /* 444d11274aaSPaul Guo * s/w context structure for TCP/UDP checksum offload and LSO. 445c869993eSxy150489 */ 446d11274aaSPaul Guo tx_context_t tx_context; 447c869993eSxy150489 448c869993eSxy150489 /* 449c869993eSxy150489 * Tx ring settings and status 450c869993eSxy150489 */ 451c869993eSxy150489 uint32_t ring_size; /* Tx descriptor ring size */ 452c869993eSxy150489 uint32_t free_list_size; /* Tx free list size */ 453c869993eSxy150489 454c869993eSxy150489 boolean_t reschedule; 455c869993eSxy150489 uint32_t recycle_fail; 456c869993eSxy150489 uint32_t stall_watchdog; 457c869993eSxy150489 4580dc2366fSVenugopal Iyer /* 4590dc2366fSVenugopal Iyer * Per-ring statistics 4600dc2366fSVenugopal Iyer */ 4610dc2366fSVenugopal Iyer uint64_t tx_pkts; /* Packets Transmitted Count */ 4620dc2366fSVenugopal Iyer uint64_t tx_bytes; /* Bytes Transmitted Count */ 4630dc2366fSVenugopal Iyer 464c869993eSxy150489 #ifdef IGB_DEBUG 465c869993eSxy150489 /* 466c869993eSxy150489 * Debug statistics 467c869993eSxy150489 */ 468c869993eSxy150489 uint32_t stat_overload; 469c869993eSxy150489 uint32_t stat_fail_no_tbd; 470c869993eSxy150489 uint32_t stat_fail_no_tcb; 471c869993eSxy150489 uint32_t stat_fail_dma_bind; 472c869993eSxy150489 uint32_t stat_reschedule; 473da14cebeSEric Cheng uint32_t stat_pkt_cnt; 474c869993eSxy150489 #endif 475c869993eSxy150489 476c869993eSxy150489 /* 477c869993eSxy150489 * Pointer to the igb struct 478c869993eSxy150489 */ 479c869993eSxy150489 struct igb *igb; 480da14cebeSEric Cheng mac_ring_handle_t ring_handle; /* call back ring handle */ 481c869993eSxy150489 } igb_tx_ring_t; 482c869993eSxy150489 483c869993eSxy150489 /* 484c869993eSxy150489 * Software Receive Ring 485c869993eSxy150489 */ 486ac7f5757Schenlu chen - Sun Microsystems - Beijing China typedef struct igb_rx_data { 487c869993eSxy150489 kmutex_t recycle_lock; /* Recycle lock, for rcb_tail */ 488c869993eSxy150489 489c869993eSxy150489 /* 490c869993eSxy150489 * Rx descriptor ring definitions 491c869993eSxy150489 */ 492c869993eSxy150489 dma_buffer_t rbd_area; /* DMA buffer of rx desc ring */ 493c869993eSxy150489 union e1000_adv_rx_desc *rbd_ring; /* Rx desc ring */ 494c869993eSxy150489 uint32_t rbd_next; /* Index of next rx desc */ 495c869993eSxy150489 496c869993eSxy150489 /* 497c869993eSxy150489 * Rx control block list definitions 498c869993eSxy150489 */ 499c869993eSxy150489 rx_control_block_t *rcb_area; 500c869993eSxy150489 rx_control_block_t **work_list; /* Work list of rcbs */ 501c869993eSxy150489 rx_control_block_t **free_list; /* Free list of rcbs */ 502c869993eSxy150489 uint32_t rcb_head; /* Index of next free rcb */ 503c869993eSxy150489 uint32_t rcb_tail; /* Index to put recycled rcb */ 504c869993eSxy150489 uint32_t rcb_free; /* Number of free rcbs */ 505c869993eSxy150489 506c869993eSxy150489 /* 507ac7f5757Schenlu chen - Sun Microsystems - Beijing China * Rx sw ring settings and status 508c869993eSxy150489 */ 509c869993eSxy150489 uint32_t ring_size; /* Rx descriptor ring size */ 510c869993eSxy150489 uint32_t free_list_size; /* Rx free list size */ 511ac7f5757Schenlu chen - Sun Microsystems - Beijing China 512ac7f5757Schenlu chen - Sun Microsystems - Beijing China uint32_t rcb_pending; 513ac7f5757Schenlu chen - Sun Microsystems - Beijing China uint32_t flag; 514ac7f5757Schenlu chen - Sun Microsystems - Beijing China 515ac7f5757Schenlu chen - Sun Microsystems - Beijing China struct igb_rx_ring *rx_ring; /* Pointer to rx ring */ 516ac7f5757Schenlu chen - Sun Microsystems - Beijing China } igb_rx_data_t; 517ac7f5757Schenlu chen - Sun Microsystems - Beijing China 518ac7f5757Schenlu chen - Sun Microsystems - Beijing China /* 519ac7f5757Schenlu chen - Sun Microsystems - Beijing China * Software Data Structure for Rx Ring 520ac7f5757Schenlu chen - Sun Microsystems - Beijing China */ 521ac7f5757Schenlu chen - Sun Microsystems - Beijing China typedef struct igb_rx_ring { 522ac7f5757Schenlu chen - Sun Microsystems - Beijing China uint32_t index; /* Ring index */ 523ac7f5757Schenlu chen - Sun Microsystems - Beijing China uint32_t intr_vector; /* Interrupt vector index */ 524ac7f5757Schenlu chen - Sun Microsystems - Beijing China 525ac7f5757Schenlu chen - Sun Microsystems - Beijing China igb_rx_data_t *rx_data; /* Rx software ring */ 526ac7f5757Schenlu chen - Sun Microsystems - Beijing China 527ac7f5757Schenlu chen - Sun Microsystems - Beijing China kmutex_t rx_lock; /* Rx access lock */ 528c869993eSxy150489 5290dc2366fSVenugopal Iyer /* 5300dc2366fSVenugopal Iyer * Per-ring statistics 5310dc2366fSVenugopal Iyer */ 5320dc2366fSVenugopal Iyer uint64_t rx_pkts; /* Packets Received Count */ 5330dc2366fSVenugopal Iyer uint64_t rx_bytes; /* Bytes Received Count */ 5340dc2366fSVenugopal Iyer 535c869993eSxy150489 #ifdef IGB_DEBUG 536c869993eSxy150489 /* 537c869993eSxy150489 * Debug statistics 538c869993eSxy150489 */ 539c869993eSxy150489 uint32_t stat_frame_error; 540c869993eSxy150489 uint32_t stat_cksum_error; 541c869993eSxy150489 uint32_t stat_exceed_pkt; 542da14cebeSEric Cheng uint32_t stat_pkt_cnt; 543c869993eSxy150489 #endif 544c869993eSxy150489 545c869993eSxy150489 struct igb *igb; /* Pointer to igb struct */ 546da14cebeSEric Cheng mac_ring_handle_t ring_handle; /* call back ring handle */ 547da14cebeSEric Cheng uint32_t group_index; /* group index */ 548da14cebeSEric Cheng uint64_t ring_gen_num; 549c869993eSxy150489 } igb_rx_ring_t; 550c869993eSxy150489 551da14cebeSEric Cheng /* 552da14cebeSEric Cheng * Software Receive Ring Group 553da14cebeSEric Cheng */ 554da14cebeSEric Cheng typedef struct igb_rx_group { 555da14cebeSEric Cheng uint32_t index; /* Group index */ 556da14cebeSEric Cheng mac_group_handle_t group_handle; /* call back group handle */ 557da14cebeSEric Cheng struct igb *igb; /* Pointer to igb struct */ 558da14cebeSEric Cheng } igb_rx_group_t; 559da14cebeSEric Cheng 560c869993eSxy150489 typedef struct igb { 561c869993eSxy150489 int instance; 562c869993eSxy150489 mac_handle_t mac_hdl; 563c869993eSxy150489 dev_info_t *dip; 564c869993eSxy150489 struct e1000_hw hw; 565c869993eSxy150489 struct igb_osdep osdep; 566c869993eSxy150489 56780a11ad2Schenlu chen - Sun Microsystems - Beijing China adapter_info_t *capab; /* adapter capabilities */ 56880a11ad2Schenlu chen - Sun Microsystems - Beijing China 569c869993eSxy150489 uint32_t igb_state; 570c869993eSxy150489 link_state_t link_state; 571c869993eSxy150489 uint32_t link_speed; 572c869993eSxy150489 uint32_t link_duplex; 573cf8dcc9bSzhefeng xu - Sun Microsystems - Beijing China boolean_t link_complete; 574cf8dcc9bSzhefeng xu - Sun Microsystems - Beijing China timeout_id_t link_tid; 575c869993eSxy150489 576c869993eSxy150489 uint32_t reset_count; 577c869993eSxy150489 uint32_t attach_progress; 578c869993eSxy150489 uint32_t loopback_mode; 579ac7f5757Schenlu chen - Sun Microsystems - Beijing China uint32_t default_mtu; 580c869993eSxy150489 uint32_t max_frame_size; 581b8d0a377Schenlu chen - Sun Microsystems - Beijing China uint32_t dout_sync; 582c869993eSxy150489 583ac7f5757Schenlu chen - Sun Microsystems - Beijing China uint32_t rcb_pending; 584ac7f5757Schenlu chen - Sun Microsystems - Beijing China 585da14cebeSEric Cheng uint32_t mr_enable; /* Enable multiple rings */ 586da14cebeSEric Cheng uint32_t vmdq_mode; /* Mode of VMDq */ 587da14cebeSEric Cheng 588c869993eSxy150489 /* 589da14cebeSEric Cheng * Receive Rings and Groups 590c869993eSxy150489 */ 591c869993eSxy150489 igb_rx_ring_t *rx_rings; /* Array of rx rings */ 592c869993eSxy150489 uint32_t num_rx_rings; /* Number of rx rings in use */ 593c869993eSxy150489 uint32_t rx_ring_size; /* Rx descriptor ring size */ 594c869993eSxy150489 uint32_t rx_buf_size; /* Rx buffer size */ 595da14cebeSEric Cheng igb_rx_group_t *rx_groups; /* Array of rx groups */ 596da14cebeSEric Cheng uint32_t num_rx_groups; /* Number of rx groups in use */ 597c869993eSxy150489 598c869993eSxy150489 /* 599c869993eSxy150489 * Transmit Rings 600c869993eSxy150489 */ 601c869993eSxy150489 igb_tx_ring_t *tx_rings; /* Array of tx rings */ 602c869993eSxy150489 uint32_t num_tx_rings; /* Number of tx rings in use */ 603c869993eSxy150489 uint32_t tx_ring_size; /* Tx descriptor ring size */ 604c869993eSxy150489 uint32_t tx_buf_size; /* Tx buffer size */ 605c869993eSxy150489 606ac7f5757Schenlu chen - Sun Microsystems - Beijing China boolean_t tx_ring_init; 607c869993eSxy150489 boolean_t tx_head_wb_enable; /* Tx head wrtie-back */ 608c869993eSxy150489 boolean_t tx_hcksum_enable; /* Tx h/w cksum offload */ 609c869993eSxy150489 boolean_t lso_enable; /* Large Segment Offload */ 610c869993eSxy150489 uint32_t tx_copy_thresh; /* Tx copy threshold */ 611c869993eSxy150489 uint32_t tx_recycle_thresh; /* Tx recycle threshold */ 612c869993eSxy150489 uint32_t tx_overload_thresh; /* Tx overload threshold */ 613c869993eSxy150489 uint32_t tx_resched_thresh; /* Tx reschedule threshold */ 614c869993eSxy150489 boolean_t rx_hcksum_enable; /* Rx h/w cksum offload */ 615c869993eSxy150489 uint32_t rx_copy_thresh; /* Rx copy threshold */ 616c869993eSxy150489 uint32_t rx_limit_per_intr; /* Rx pkts per interrupt */ 617b8d0a377Schenlu chen - Sun Microsystems - Beijing China 618c869993eSxy150489 uint32_t intr_throttling[MAX_NUM_EITR]; 619c869993eSxy150489 uint32_t intr_force; 620c869993eSxy150489 621c869993eSxy150489 int intr_type; 622c869993eSxy150489 int intr_cnt; 623c869993eSxy150489 int intr_cap; 624c869993eSxy150489 size_t intr_size; 625c869993eSxy150489 uint_t intr_pri; 626c869993eSxy150489 ddi_intr_handle_t *htable; 627c869993eSxy150489 uint32_t eims_mask; 628da14cebeSEric Cheng uint32_t ims_mask; 629c869993eSxy150489 630c869993eSxy150489 kmutex_t gen_lock; /* General lock for device access */ 631c869993eSxy150489 kmutex_t watchdog_lock; 632cf8dcc9bSzhefeng xu - Sun Microsystems - Beijing China kmutex_t link_lock; 633ac7f5757Schenlu chen - Sun Microsystems - Beijing China kmutex_t rx_pending_lock; 634c869993eSxy150489 635c869993eSxy150489 boolean_t watchdog_enable; 636c869993eSxy150489 boolean_t watchdog_start; 637c869993eSxy150489 timeout_id_t watchdog_tid; 638c869993eSxy150489 639c869993eSxy150489 boolean_t unicst_init; 640c869993eSxy150489 uint32_t unicst_avail; 641c869993eSxy150489 uint32_t unicst_total; 642c869993eSxy150489 igb_ether_addr_t unicst_addr[MAX_NUM_UNICAST_ADDRESSES]; 643c869993eSxy150489 uint32_t mcast_count; 6446ca163a1Svitezslav batrla - Sun Microsystems - Prague Czech Republic uint32_t mcast_alloc_count; 6456ca163a1Svitezslav batrla - Sun Microsystems - Prague Czech Republic uint32_t mcast_max_num; 6466ca163a1Svitezslav batrla - Sun Microsystems - Prague Czech Republic struct ether_addr *mcast_table; 647c869993eSxy150489 648c869993eSxy150489 /* 649*b142f83dSRobert Mustacchi * LED related functions 650*b142f83dSRobert Mustacchi */ 651*b142f83dSRobert Mustacchi boolean_t igb_led_setup; 652*b142f83dSRobert Mustacchi 653*b142f83dSRobert Mustacchi /* 654c869993eSxy150489 * Kstat definitions 655c869993eSxy150489 */ 656c869993eSxy150489 kstat_t *igb_ks; 657c869993eSxy150489 65813485e69SGarrett D'Amore /* 65913485e69SGarrett D'Amore * Backing store for MAC stats. These are reported via GLDv3, instead 66013485e69SGarrett D'Amore * of via our private kstat structure. 66113485e69SGarrett D'Amore */ 66213485e69SGarrett D'Amore uint64_t stat_tor; /* rbytes */ 66313485e69SGarrett D'Amore uint64_t stat_tpr; /* rpackets */ 66413485e69SGarrett D'Amore uint64_t stat_tot; /* obytes */ 66513485e69SGarrett D'Amore uint64_t stat_tpt; /* opackets */ 66613485e69SGarrett D'Amore uint64_t stat_colc; /* collisions */ 66713485e69SGarrett D'Amore uint64_t stat_mcc; /* multi colls */ 66813485e69SGarrett D'Amore uint64_t stat_scc; /* single colls */ 66913485e69SGarrett D'Amore uint64_t stat_ecol; /* excessive colls */ 67013485e69SGarrett D'Amore uint64_t stat_latecol; /* late colls */ 67113485e69SGarrett D'Amore uint64_t stat_bptc; /* xmit bcast */ 67213485e69SGarrett D'Amore uint64_t stat_mptc; /* xmit bcast */ 67313485e69SGarrett D'Amore uint64_t stat_bprc; /* recv bcast */ 67413485e69SGarrett D'Amore uint64_t stat_mprc; /* recv mcast */ 67513485e69SGarrett D'Amore uint64_t stat_rnbc; /* recv nobuf */ 67613485e69SGarrett D'Amore uint64_t stat_roc; /* recv toolong */ 67713485e69SGarrett D'Amore uint64_t stat_sec; /* sqe errors */ 67813485e69SGarrett D'Amore uint64_t stat_dc; /* defer */ 67913485e69SGarrett D'Amore uint64_t stat_algnerrc; /* align errors */ 68013485e69SGarrett D'Amore uint64_t stat_crcerrs; /* crc errors */ 68113485e69SGarrett D'Amore uint64_t stat_cexterr; /* carrier extension errors */ 68213485e69SGarrett D'Amore uint64_t stat_ruc; /* recv tooshort */ 68313485e69SGarrett D'Amore uint64_t stat_rjc; /* recv jabber */ 68413485e69SGarrett D'Amore uint64_t stat_rxerrc; /* recv errors */ 68513485e69SGarrett D'Amore 686ac7f5757Schenlu chen - Sun Microsystems - Beijing China uint32_t param_en_1000fdx_cap:1, 687ac7f5757Schenlu chen - Sun Microsystems - Beijing China param_en_1000hdx_cap:1, 688ac7f5757Schenlu chen - Sun Microsystems - Beijing China param_en_100t4_cap:1, 689ac7f5757Schenlu chen - Sun Microsystems - Beijing China param_en_100fdx_cap:1, 690ac7f5757Schenlu chen - Sun Microsystems - Beijing China param_en_100hdx_cap:1, 691ac7f5757Schenlu chen - Sun Microsystems - Beijing China param_en_10fdx_cap:1, 692ac7f5757Schenlu chen - Sun Microsystems - Beijing China param_en_10hdx_cap:1, 693ac7f5757Schenlu chen - Sun Microsystems - Beijing China param_1000fdx_cap:1, 694ac7f5757Schenlu chen - Sun Microsystems - Beijing China param_1000hdx_cap:1, 695ac7f5757Schenlu chen - Sun Microsystems - Beijing China param_100t4_cap:1, 696ac7f5757Schenlu chen - Sun Microsystems - Beijing China param_100fdx_cap:1, 697ac7f5757Schenlu chen - Sun Microsystems - Beijing China param_100hdx_cap:1, 698ac7f5757Schenlu chen - Sun Microsystems - Beijing China param_10fdx_cap:1, 699ac7f5757Schenlu chen - Sun Microsystems - Beijing China param_10hdx_cap:1, 700ac7f5757Schenlu chen - Sun Microsystems - Beijing China param_autoneg_cap:1, 701ac7f5757Schenlu chen - Sun Microsystems - Beijing China param_pause_cap:1, 702ac7f5757Schenlu chen - Sun Microsystems - Beijing China param_asym_pause_cap:1, 703ac7f5757Schenlu chen - Sun Microsystems - Beijing China param_rem_fault:1, 704ac7f5757Schenlu chen - Sun Microsystems - Beijing China param_adv_1000fdx_cap:1, 705ac7f5757Schenlu chen - Sun Microsystems - Beijing China param_adv_1000hdx_cap:1, 706ac7f5757Schenlu chen - Sun Microsystems - Beijing China param_adv_100t4_cap:1, 707ac7f5757Schenlu chen - Sun Microsystems - Beijing China param_adv_100fdx_cap:1, 708ac7f5757Schenlu chen - Sun Microsystems - Beijing China param_adv_100hdx_cap:1, 709ac7f5757Schenlu chen - Sun Microsystems - Beijing China param_adv_10fdx_cap:1, 710ac7f5757Schenlu chen - Sun Microsystems - Beijing China param_adv_10hdx_cap:1, 711ac7f5757Schenlu chen - Sun Microsystems - Beijing China param_adv_autoneg_cap:1, 712ac7f5757Schenlu chen - Sun Microsystems - Beijing China param_adv_pause_cap:1, 713ac7f5757Schenlu chen - Sun Microsystems - Beijing China param_adv_asym_pause_cap:1, 714ac7f5757Schenlu chen - Sun Microsystems - Beijing China param_adv_rem_fault:1, 715ac7f5757Schenlu chen - Sun Microsystems - Beijing China param_lp_1000fdx_cap:1, 716ac7f5757Schenlu chen - Sun Microsystems - Beijing China param_lp_1000hdx_cap:1, 717ac7f5757Schenlu chen - Sun Microsystems - Beijing China param_lp_100t4_cap:1; 718ac7f5757Schenlu chen - Sun Microsystems - Beijing China 719ac7f5757Schenlu chen - Sun Microsystems - Beijing China uint32_t param_lp_100fdx_cap:1, 720ac7f5757Schenlu chen - Sun Microsystems - Beijing China param_lp_100hdx_cap:1, 721ac7f5757Schenlu chen - Sun Microsystems - Beijing China param_lp_10fdx_cap:1, 722ac7f5757Schenlu chen - Sun Microsystems - Beijing China param_lp_10hdx_cap:1, 723ac7f5757Schenlu chen - Sun Microsystems - Beijing China param_lp_autoneg_cap:1, 724ac7f5757Schenlu chen - Sun Microsystems - Beijing China param_lp_pause_cap:1, 725ac7f5757Schenlu chen - Sun Microsystems - Beijing China param_lp_asym_pause_cap:1, 726ac7f5757Schenlu chen - Sun Microsystems - Beijing China param_lp_rem_fault:1, 727ac7f5757Schenlu chen - Sun Microsystems - Beijing China param_pad_to_32:24; 728c869993eSxy150489 7298bb4b220Sgl147354 /* 7308bb4b220Sgl147354 * FMA capabilities 7318bb4b220Sgl147354 */ 7328bb4b220Sgl147354 int fm_capabilities; 7338bb4b220Sgl147354 734d11274aaSPaul Guo ulong_t page_size; 735c869993eSxy150489 } igb_t; 736c869993eSxy150489 737c869993eSxy150489 typedef struct igb_stat { 738c869993eSxy150489 739c869993eSxy150489 kstat_named_t reset_count; /* Reset Count */ 740b8d0a377Schenlu chen - Sun Microsystems - Beijing China kstat_named_t dout_sync; /* DMA out of sync */ 741b8d0a377Schenlu chen - Sun Microsystems - Beijing China #ifdef IGB_DEBUG 742c869993eSxy150489 kstat_named_t rx_frame_error; /* Rx Error in Packet */ 743c869993eSxy150489 kstat_named_t rx_cksum_error; /* Rx Checksum Error */ 744c869993eSxy150489 kstat_named_t rx_exceed_pkt; /* Rx Exceed Max Pkt Count */ 745c869993eSxy150489 746c869993eSxy150489 kstat_named_t tx_overload; /* Tx Desc Ring Overload */ 747c869993eSxy150489 kstat_named_t tx_fail_no_tcb; /* Tx Fail Freelist Empty */ 748c869993eSxy150489 kstat_named_t tx_fail_no_tbd; /* Tx Fail Desc Ring Empty */ 749c869993eSxy150489 kstat_named_t tx_fail_dma_bind; /* Tx Fail DMA bind */ 750c869993eSxy150489 kstat_named_t tx_reschedule; /* Tx Reschedule */ 751c869993eSxy150489 752c869993eSxy150489 kstat_named_t gprc; /* Good Packets Received Count */ 753c869993eSxy150489 kstat_named_t gptc; /* Good Packets Xmitted Count */ 754c869993eSxy150489 kstat_named_t gor; /* Good Octets Received Count */ 755c869993eSxy150489 kstat_named_t got; /* Good Octets Xmitd Count */ 756c869993eSxy150489 kstat_named_t prc64; /* Packets Received - 64b */ 757c869993eSxy150489 kstat_named_t prc127; /* Packets Received - 65-127b */ 758c869993eSxy150489 kstat_named_t prc255; /* Packets Received - 127-255b */ 759c869993eSxy150489 kstat_named_t prc511; /* Packets Received - 256-511b */ 760c869993eSxy150489 kstat_named_t prc1023; /* Packets Received - 511-1023b */ 761c869993eSxy150489 kstat_named_t prc1522; /* Packets Received - 1024-1522b */ 762c869993eSxy150489 kstat_named_t ptc64; /* Packets Xmitted (64b) */ 763c869993eSxy150489 kstat_named_t ptc127; /* Packets Xmitted (64-127b) */ 764c869993eSxy150489 kstat_named_t ptc255; /* Packets Xmitted (128-255b) */ 765c869993eSxy150489 kstat_named_t ptc511; /* Packets Xmitted (255-511b) */ 766c869993eSxy150489 kstat_named_t ptc1023; /* Packets Xmitted (512-1023b) */ 767c869993eSxy150489 kstat_named_t ptc1522; /* Packets Xmitted (1024-1522b */ 768c869993eSxy150489 #endif 769c869993eSxy150489 kstat_named_t symerrs; /* Symbol Error Count */ 770c869993eSxy150489 kstat_named_t mpc; /* Missed Packet Count */ 771c869993eSxy150489 kstat_named_t rlec; /* Receive Length Error Count */ 772c869993eSxy150489 kstat_named_t xonrxc; /* XON Received Count */ 773c869993eSxy150489 kstat_named_t xontxc; /* XON Xmitted Count */ 774c869993eSxy150489 kstat_named_t xoffrxc; /* XOFF Received Count */ 775c869993eSxy150489 kstat_named_t xofftxc; /* Xoff Xmitted Count */ 776c869993eSxy150489 kstat_named_t fcruc; /* Unknown Flow Conrol Packet Rcvd Count */ 777c869993eSxy150489 kstat_named_t rfc; /* Receive Frag Count */ 778c869993eSxy150489 kstat_named_t tncrs; /* Transmit with no CRS */ 779c869993eSxy150489 kstat_named_t tsctc; /* TCP seg contexts xmit count */ 780c869993eSxy150489 kstat_named_t tsctfc; /* TCP seg contexts xmit fail count */ 781c869993eSxy150489 } igb_stat_t; 782c869993eSxy150489 783c869993eSxy150489 /* 784c869993eSxy150489 * Function prototypes in e1000_osdep.c 785c869993eSxy150489 */ 7867d46e7adSzhefeng xu - Sun Microsystems - Beijing China void e1000_write_pci_cfg(struct e1000_hw *, uint32_t, uint16_t *); 7877d46e7adSzhefeng xu - Sun Microsystems - Beijing China void e1000_read_pci_cfg(struct e1000_hw *, uint32_t, uint16_t *); 7887d46e7adSzhefeng xu - Sun Microsystems - Beijing China int32_t e1000_read_pcie_cap_reg(struct e1000_hw *, uint32_t, uint16_t *); 7897d46e7adSzhefeng xu - Sun Microsystems - Beijing China int32_t e1000_write_pcie_cap_reg(struct e1000_hw *, uint32_t, uint16_t *); 7903f7e60a6Szhefeng xu - Sun Microsystems - Beijing China void e1000_rar_clear(struct e1000_hw *, uint32_t); 7913f7e60a6Szhefeng xu - Sun Microsystems - Beijing China void e1000_rar_set_vmdq(struct e1000_hw *, const uint8_t *, uint32_t, 79280a11ad2Schenlu chen - Sun Microsystems - Beijing China uint32_t, uint8_t); 793c869993eSxy150489 794c869993eSxy150489 /* 795c869993eSxy150489 * Function prototypes in igb_buf.c 796c869993eSxy150489 */ 797c869993eSxy150489 int igb_alloc_dma(igb_t *); 798c869993eSxy150489 void igb_free_dma(igb_t *); 799ac7f5757Schenlu chen - Sun Microsystems - Beijing China void igb_free_dma_buffer(dma_buffer_t *); 800ac7f5757Schenlu chen - Sun Microsystems - Beijing China int igb_alloc_rx_ring_data(igb_rx_ring_t *rx_ring); 801ac7f5757Schenlu chen - Sun Microsystems - Beijing China void igb_free_rx_ring_data(igb_rx_data_t *rx_data); 802c869993eSxy150489 803c869993eSxy150489 /* 804c869993eSxy150489 * Function prototypes in igb_main.c 805c869993eSxy150489 */ 806ac7f5757Schenlu chen - Sun Microsystems - Beijing China int igb_start(igb_t *, boolean_t); 807ac7f5757Schenlu chen - Sun Microsystems - Beijing China void igb_stop(igb_t *, boolean_t); 808c869993eSxy150489 int igb_setup_link(igb_t *, boolean_t); 809da14cebeSEric Cheng int igb_unicst_find(igb_t *, const uint8_t *); 810da14cebeSEric Cheng int igb_unicst_set(igb_t *, const uint8_t *, int); 811c869993eSxy150489 int igb_multicst_add(igb_t *, const uint8_t *); 812c869993eSxy150489 int igb_multicst_remove(igb_t *, const uint8_t *); 813c869993eSxy150489 enum ioc_reply igb_loopback_ioctl(igb_t *, struct iocblk *, mblk_t *); 814c869993eSxy150489 void igb_enable_watchdog_timer(igb_t *); 815c869993eSxy150489 void igb_disable_watchdog_timer(igb_t *); 816c869993eSxy150489 int igb_atomic_reserve(uint32_t *, uint32_t); 8178bb4b220Sgl147354 int igb_check_acc_handle(ddi_acc_handle_t); 8188bb4b220Sgl147354 int igb_check_dma_handle(ddi_dma_handle_t); 8198bb4b220Sgl147354 void igb_fm_ereport(igb_t *, char *); 820837c1ac4SStephen Hanson void igb_set_fma_flags(int); 821c869993eSxy150489 822c869993eSxy150489 /* 823c869993eSxy150489 * Function prototypes in igb_gld.c 824c869993eSxy150489 */ 825c869993eSxy150489 int igb_m_start(void *); 826c869993eSxy150489 void igb_m_stop(void *); 827c869993eSxy150489 int igb_m_promisc(void *, boolean_t); 828c869993eSxy150489 int igb_m_multicst(void *, boolean_t, const uint8_t *); 829c869993eSxy150489 int igb_m_unicst(void *, const uint8_t *); 830c869993eSxy150489 int igb_m_stat(void *, uint_t, uint64_t *); 831c869993eSxy150489 void igb_m_resources(void *); 832c869993eSxy150489 void igb_m_ioctl(void *, queue_t *, mblk_t *); 833c869993eSxy150489 boolean_t igb_m_getcapab(void *, mac_capab_t, void *); 834da14cebeSEric Cheng void igb_fill_ring(void *, mac_ring_type_t, const int, const int, 835da14cebeSEric Cheng mac_ring_info_t *, mac_ring_handle_t); 836ac7f5757Schenlu chen - Sun Microsystems - Beijing China int igb_m_setprop(void *, const char *, mac_prop_id_t, uint_t, const void *); 8370dc2366fSVenugopal Iyer int igb_m_getprop(void *, const char *, mac_prop_id_t, uint_t, void *); 8380dc2366fSVenugopal Iyer void igb_m_propinfo(void *, const char *, mac_prop_id_t, 8390dc2366fSVenugopal Iyer mac_prop_info_handle_t); 840ac7f5757Schenlu chen - Sun Microsystems - Beijing China int igb_set_priv_prop(igb_t *, const char *, uint_t, const void *); 8410dc2366fSVenugopal Iyer int igb_get_priv_prop(igb_t *, const char *, uint_t, void *); 8420dc2366fSVenugopal Iyer void igb_priv_prop_info(igb_t *, const char *, mac_prop_info_handle_t); 843ac7f5757Schenlu chen - Sun Microsystems - Beijing China boolean_t igb_param_locked(mac_prop_id_t); 844da14cebeSEric Cheng void igb_fill_group(void *arg, mac_ring_type_t, const int, 845da14cebeSEric Cheng mac_group_info_t *, mac_group_handle_t); 846da14cebeSEric Cheng int igb_rx_ring_intr_enable(mac_intr_handle_t); 847da14cebeSEric Cheng int igb_rx_ring_intr_disable(mac_intr_handle_t); 848ac7f5757Schenlu chen - Sun Microsystems - Beijing China int igb_get_def_val(igb_t *, mac_prop_id_t, uint_t, void *); 849c869993eSxy150489 850c869993eSxy150489 /* 851c869993eSxy150489 * Function prototypes in igb_rx.c 852c869993eSxy150489 */ 853da14cebeSEric Cheng mblk_t *igb_rx(igb_rx_ring_t *, int); 854c869993eSxy150489 void igb_rx_recycle(caddr_t arg); 855c869993eSxy150489 856c869993eSxy150489 /* 857c869993eSxy150489 * Function prototypes in igb_tx.c 858c869993eSxy150489 */ 859c869993eSxy150489 void igb_free_tcb(tx_control_block_t *); 860c869993eSxy150489 void igb_put_free_list(igb_tx_ring_t *, link_list_t *); 861c869993eSxy150489 uint32_t igb_tx_recycle_legacy(igb_tx_ring_t *); 862c869993eSxy150489 uint32_t igb_tx_recycle_head_wb(igb_tx_ring_t *); 863c869993eSxy150489 864c869993eSxy150489 /* 865c869993eSxy150489 * Function prototypes in igb_stat.c 866c869993eSxy150489 */ 867c869993eSxy150489 int igb_init_stats(igb_t *); 868c869993eSxy150489 869da14cebeSEric Cheng mblk_t *igb_rx_ring_poll(void *, int); 870da14cebeSEric Cheng mblk_t *igb_tx_ring_send(void *, mblk_t *); 8710dc2366fSVenugopal Iyer int igb_rx_ring_stat(mac_ring_driver_t, uint_t, uint64_t *); 8720dc2366fSVenugopal Iyer int igb_tx_ring_stat(mac_ring_driver_t, uint_t, uint64_t *); 873c869993eSxy150489 874c869993eSxy150489 #ifdef __cplusplus 875c869993eSxy150489 } 876c869993eSxy150489 #endif 877c869993eSxy150489 878c869993eSxy150489 #endif /* _IGB_SW_H */ 879