13526Sxy150489 /* 23526Sxy150489 * This file is provided under a CDDLv1 license. When using or 33526Sxy150489 * redistributing this file, you may do so under this license. 43526Sxy150489 * In redistributing this file this license must be included 53526Sxy150489 * and no other modification of this header file is permitted. 63526Sxy150489 * 73526Sxy150489 * CDDL LICENSE SUMMARY 83526Sxy150489 * 98479SChenlu.Chen@Sun.COM * Copyright(c) 1999 - 2009 Intel Corporation. All rights reserved. 103526Sxy150489 * 113526Sxy150489 * The contents of this file are subject to the terms of Version 123526Sxy150489 * 1.0 of the Common Development and Distribution License (the "License"). 133526Sxy150489 * 143526Sxy150489 * You should have received a copy of the License with this software. 153526Sxy150489 * You can obtain a copy of the License at 163526Sxy150489 * http://www.opensolaris.org/os/licensing. 173526Sxy150489 * See the License for the specific language governing permissions 183526Sxy150489 * and limitations under the License. 193526Sxy150489 */ 203526Sxy150489 213526Sxy150489 /* 22*12853SChangqing.Li@Sun.COM * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 233526Sxy150489 */ 243526Sxy150489 253526Sxy150489 #ifndef _E1000G_SW_H 263526Sxy150489 #define _E1000G_SW_H 273526Sxy150489 283526Sxy150489 #ifdef __cplusplus 293526Sxy150489 extern "C" { 303526Sxy150489 #endif 313526Sxy150489 323526Sxy150489 /* 333526Sxy150489 * ********************************************************************** 343526Sxy150489 * Module Name: * 353526Sxy150489 * e1000g_sw.h * 363526Sxy150489 * * 373526Sxy150489 * Abstract: * 383526Sxy150489 * This header file contains Software-related data structures * 393526Sxy150489 * definitions. * 403526Sxy150489 * * 413526Sxy150489 * ********************************************************************** 423526Sxy150489 */ 433526Sxy150489 443526Sxy150489 #include <sys/types.h> 453526Sxy150489 #include <sys/conf.h> 463526Sxy150489 #include <sys/debug.h> 473526Sxy150489 #include <sys/stropts.h> 483526Sxy150489 #include <sys/stream.h> 493526Sxy150489 #include <sys/strsun.h> 503526Sxy150489 #include <sys/strlog.h> 513526Sxy150489 #include <sys/kmem.h> 523526Sxy150489 #include <sys/stat.h> 533526Sxy150489 #include <sys/kstat.h> 543526Sxy150489 #include <sys/modctl.h> 553526Sxy150489 #include <sys/errno.h> 568275SEric Cheng #include <sys/mac_provider.h> 573526Sxy150489 #include <sys/mac_ether.h> 583526Sxy150489 #include <sys/vlan.h> 593526Sxy150489 #include <sys/ddi.h> 603526Sxy150489 #include <sys/sunddi.h> 615882Syy150190 #include <sys/disp.h> 623526Sxy150489 #include <sys/pci.h> 633526Sxy150489 #include <sys/sdt.h> 643526Sxy150489 #include <sys/ethernet.h> 653526Sxy150489 #include <sys/pattr.h> 663526Sxy150489 #include <sys/strsubr.h> 673526Sxy150489 #include <sys/netlb.h> 683526Sxy150489 #include <inet/common.h> 693526Sxy150489 #include <inet/ip.h> 706986Smx205022 #include <inet/tcp.h> 713526Sxy150489 #include <inet/mi.h> 723526Sxy150489 #include <inet/nd.h> 735273Sgl147354 #include <sys/ddifm.h> 745273Sgl147354 #include <sys/fm/protocol.h> 755273Sgl147354 #include <sys/fm/util.h> 765273Sgl147354 #include <sys/fm/io/ddi.h> 774919Sxy150489 #include "e1000_api.h" 783526Sxy150489 798479SChenlu.Chen@Sun.COM /* Driver states */ 808479SChenlu.Chen@Sun.COM #define E1000G_UNKNOWN 0x00 818479SChenlu.Chen@Sun.COM #define E1000G_INITIALIZED 0x01 828479SChenlu.Chen@Sun.COM #define E1000G_STARTED 0x02 838479SChenlu.Chen@Sun.COM #define E1000G_SUSPENDED 0x04 848479SChenlu.Chen@Sun.COM #define E1000G_ERROR 0x80 858479SChenlu.Chen@Sun.COM 863526Sxy150489 #define JUMBO_FRAG_LENGTH 4096 873526Sxy150489 883526Sxy150489 #define LAST_RAR_ENTRY (E1000_RAR_ENTRIES - 1) 893526Sxy150489 #define MAX_NUM_UNICAST_ADDRESSES E1000_RAR_ENTRIES 909770SChangqing.Li@Sun.COM #define MCAST_ALLOC_SIZE 256 913526Sxy150489 926986Smx205022 /* 938073SMin.Xu@Sun.COM * MAX_COOKIES = max_LSO_packet_size(65535 + ethernet_header_len)/page_size 948073SMin.Xu@Sun.COM * + one for cross page split 957607STed.You@Sun.COM * MAX_TX_DESC_PER_PACKET = MAX_COOKIES + one for the context descriptor + 967607STed.You@Sun.COM * two for the workaround of the 82546 chip 976986Smx205022 */ 987607STed.You@Sun.COM #define MAX_COOKIES 18 997607STed.You@Sun.COM #define MAX_TX_DESC_PER_PACKET 21 1003526Sxy150489 1013526Sxy150489 /* 1023526Sxy150489 * constants used in setting flow control thresholds 1033526Sxy150489 */ 1043526Sxy150489 #define E1000_PBA_MASK 0xffff 1053526Sxy150489 #define E1000_PBA_SHIFT 10 1063526Sxy150489 #define E1000_FC_HIGH_DIFF 0x1638 /* High: 5688 bytes below Rx FIFO size */ 1073526Sxy150489 #define E1000_FC_LOW_DIFF 0x1640 /* Low: 5696 bytes below Rx FIFO size */ 1083526Sxy150489 #define E1000_FC_PAUSE_TIME 0x0680 /* 858 usec */ 1093526Sxy150489 1104919Sxy150489 #define MAX_NUM_TX_DESCRIPTOR 4096 1114919Sxy150489 #define MAX_NUM_RX_DESCRIPTOR 4096 1124919Sxy150489 #define MAX_NUM_RX_FREELIST 4096 1134919Sxy150489 #define MAX_NUM_TX_FREELIST 4096 1144919Sxy150489 #define MAX_RX_LIMIT_ON_INTR 4096 1154919Sxy150489 #define MAX_RX_INTR_DELAY 65535 1164919Sxy150489 #define MAX_RX_INTR_ABS_DELAY 65535 1174919Sxy150489 #define MAX_TX_INTR_DELAY 65535 1184919Sxy150489 #define MAX_TX_INTR_ABS_DELAY 65535 1194919Sxy150489 #define MAX_INTR_THROTTLING 65535 1204919Sxy150489 #define MAX_RX_BCOPY_THRESHOLD E1000_RX_BUFFER_SIZE_2K 1214919Sxy150489 #define MAX_TX_BCOPY_THRESHOLD E1000_TX_BUFFER_SIZE_2K 1229770SChangqing.Li@Sun.COM #define MAX_MCAST_NUM 8192 1233526Sxy150489 1244919Sxy150489 #define MIN_NUM_TX_DESCRIPTOR 80 1254919Sxy150489 #define MIN_NUM_RX_DESCRIPTOR 80 1264919Sxy150489 #define MIN_NUM_RX_FREELIST 64 1274919Sxy150489 #define MIN_NUM_TX_FREELIST 80 1284919Sxy150489 #define MIN_RX_LIMIT_ON_INTR 16 1294919Sxy150489 #define MIN_RX_INTR_DELAY 0 1304919Sxy150489 #define MIN_RX_INTR_ABS_DELAY 0 1314919Sxy150489 #define MIN_TX_INTR_DELAY 0 1324919Sxy150489 #define MIN_TX_INTR_ABS_DELAY 0 1334919Sxy150489 #define MIN_INTR_THROTTLING 0 1344919Sxy150489 #define MIN_RX_BCOPY_THRESHOLD 0 1356394Scc210113 #define MIN_TX_BCOPY_THRESHOLD ETHERMIN 1369770SChangqing.Li@Sun.COM #define MIN_MCAST_NUM 8 1373526Sxy150489 1384919Sxy150489 #define DEFAULT_NUM_RX_DESCRIPTOR 2048 1394919Sxy150489 #define DEFAULT_NUM_TX_DESCRIPTOR 2048 1404919Sxy150489 #define DEFAULT_NUM_RX_FREELIST 4096 1415882Syy150190 #define DEFAULT_NUM_TX_FREELIST 2304 14211339SGuoqing.Zhu@Sun.COM #define DEFAULT_JUMBO_NUM_RX_DESC 1024 14311339SGuoqing.Zhu@Sun.COM #define DEFAULT_JUMBO_NUM_TX_DESC 1024 14411339SGuoqing.Zhu@Sun.COM #define DEFAULT_JUMBO_NUM_RX_BUF 2048 14511339SGuoqing.Zhu@Sun.COM #define DEFAULT_JUMBO_NUM_TX_BUF 1152 1465882Syy150190 #define DEFAULT_RX_LIMIT_ON_INTR 128 147*12853SChangqing.Li@Sun.COM #define RX_FREELIST_INCREASE_SIZE 512 1485882Syy150190 1495882Syy150190 #ifdef __sparc 1505882Syy150190 #define MAX_INTR_PER_SEC 7100 1515882Syy150190 #define MIN_INTR_PER_SEC 3000 1525882Syy150190 #define DEFAULT_INTR_PACKET_LOW 5 1535882Syy150190 #define DEFAULT_INTR_PACKET_HIGH 128 1545882Syy150190 #else 1555882Syy150190 #define MAX_INTR_PER_SEC 15000 1565882Syy150190 #define MIN_INTR_PER_SEC 4000 1575882Syy150190 #define DEFAULT_INTR_PACKET_LOW 10 1585882Syy150190 #define DEFAULT_INTR_PACKET_HIGH 48 1595882Syy150190 #endif 1605882Syy150190 1614919Sxy150489 #define DEFAULT_RX_INTR_DELAY 0 1625882Syy150190 #define DEFAULT_RX_INTR_ABS_DELAY 64 1635882Syy150190 #define DEFAULT_TX_INTR_DELAY 64 1645882Syy150190 #define DEFAULT_TX_INTR_ABS_DELAY 64 1655882Syy150190 #define DEFAULT_INTR_THROTTLING_HIGH 1000000000/(MIN_INTR_PER_SEC*256) 1665882Syy150190 #define DEFAULT_INTR_THROTTLING_LOW 1000000000/(MAX_INTR_PER_SEC*256) 1675882Syy150190 #define DEFAULT_INTR_THROTTLING DEFAULT_INTR_THROTTLING_LOW 1685882Syy150190 1695882Syy150190 #define DEFAULT_RX_BCOPY_THRESHOLD 128 1704919Sxy150489 #define DEFAULT_TX_BCOPY_THRESHOLD 512 1715882Syy150190 #define DEFAULT_TX_UPDATE_THRESHOLD 256 1726986Smx205022 #define DEFAULT_TX_NO_RESOURCE MAX_TX_DESC_PER_PACKET 1734919Sxy150489 1744919Sxy150489 #define DEFAULT_TX_INTR_ENABLE 1 1754919Sxy150489 #define DEFAULT_FLOW_CONTROL 3 1764919Sxy150489 #define DEFAULT_MASTER_LATENCY_TIMER 0 /* BIOS should decide */ 1773526Sxy150489 /* which is normally 0x040 */ 1784919Sxy150489 #define DEFAULT_TBI_COMPAT_ENABLE 1 /* Enable SBP workaround */ 1794919Sxy150489 #define DEFAULT_MSI_ENABLE 1 /* MSI Enable */ 1806011Ssv141092 #define DEFAULT_TX_HCKSUM_ENABLE 1 /* Hardware checksum enable */ 1816986Smx205022 #define DEFAULT_LSO_ENABLE 1 /* LSO enable */ 1828417SChenlu.Chen@Sun.COM #define DEFAULT_MEM_WORKAROUND_82546 1 /* 82546 memory workaround */ 1833526Sxy150489 1844919Sxy150489 #define TX_DRAIN_TIME (200) /* # milliseconds xmit drain */ 1858850SMin.Xu@Sun.COM #define RX_DRAIN_TIME (200) /* # milliseconds recv drain */ 1868850SMin.Xu@Sun.COM 1878850SMin.Xu@Sun.COM #define TX_STALL_TIME_2S (200) /* in unit of tick */ 1888850SMin.Xu@Sun.COM #define TX_STALL_TIME_8S (800) /* in unit of tick */ 1893526Sxy150489 1903526Sxy150489 /* 1913526Sxy150489 * The size of the receive/transmite buffers 1923526Sxy150489 */ 1933526Sxy150489 #define E1000_RX_BUFFER_SIZE_2K (2048) 1943526Sxy150489 #define E1000_RX_BUFFER_SIZE_4K (4096) 1953526Sxy150489 #define E1000_RX_BUFFER_SIZE_8K (8192) 1963526Sxy150489 #define E1000_RX_BUFFER_SIZE_16K (16384) 1973526Sxy150489 1983526Sxy150489 #define E1000_TX_BUFFER_SIZE_2K (2048) 1993526Sxy150489 #define E1000_TX_BUFFER_SIZE_4K (4096) 2003526Sxy150489 #define E1000_TX_BUFFER_SIZE_8K (8192) 2013526Sxy150489 #define E1000_TX_BUFFER_SIZE_16K (16384) 2023526Sxy150489 2036986Smx205022 #define E1000_TX_BUFFER_OEVRRUN_THRESHOLD (2015) 2043526Sxy150489 2058850SMin.Xu@Sun.COM #define E1000G_RX_NORMAL 0x0 2068850SMin.Xu@Sun.COM #define E1000G_RX_STOPPED 0x1 2073526Sxy150489 2088833SVenu.Iyer@Sun.COM #define E1000G_CHAIN_NO_LIMIT 0 2098833SVenu.Iyer@Sun.COM 2103526Sxy150489 /* 2113526Sxy150489 * definitions for smartspeed workaround 2123526Sxy150489 */ 2133526Sxy150489 #define E1000_SMARTSPEED_MAX 30 /* 30 watchdog iterations */ 2143526Sxy150489 /* or 30 seconds */ 2153526Sxy150489 #define E1000_SMARTSPEED_DOWNSHIFT 6 /* 6 watchdog iterations */ 2163526Sxy150489 /* or 6 seconds */ 2173526Sxy150489 2183526Sxy150489 /* 2193526Sxy150489 * Definitions for module_info. 2203526Sxy150489 */ 2213526Sxy150489 #define WSNAME "e1000g" /* module name */ 2223526Sxy150489 2233526Sxy150489 /* 2243526Sxy150489 * Defined for IP header alignment. We also need to preserve space for 2253526Sxy150489 * VLAN tag (4 bytes) 2263526Sxy150489 */ 227*12853SChangqing.Li@Sun.COM #define E1000G_IPALIGNROOM 2 2283526Sxy150489 2293526Sxy150489 /* 2303526Sxy150489 * bit flags for 'attach_progress' which is a member variable in struct e1000g 2313526Sxy150489 */ 2324919Sxy150489 #define ATTACH_PROGRESS_PCI_CONFIG 0x0001 /* PCI config setup */ 2334919Sxy150489 #define ATTACH_PROGRESS_REGS_MAP 0x0002 /* Registers mapped */ 2344919Sxy150489 #define ATTACH_PROGRESS_SETUP 0x0004 /* Setup driver parameters */ 2354919Sxy150489 #define ATTACH_PROGRESS_ADD_INTR 0x0008 /* Interrupt added */ 2364919Sxy150489 #define ATTACH_PROGRESS_LOCKS 0x0010 /* Locks initialized */ 2374919Sxy150489 #define ATTACH_PROGRESS_SOFT_INTR 0x0020 /* Soft interrupt added */ 2384919Sxy150489 #define ATTACH_PROGRESS_KSTATS 0x0040 /* Kstats created */ 2394919Sxy150489 #define ATTACH_PROGRESS_ALLOC 0x0080 /* DMA resources allocated */ 2404919Sxy150489 #define ATTACH_PROGRESS_INIT 0x0100 /* Driver initialization */ 2416512Ssowmini /* 0200 used to be PROGRESS_NDD. Now unused */ 2424919Sxy150489 #define ATTACH_PROGRESS_MAC 0x0400 /* MAC registered */ 2434919Sxy150489 #define ATTACH_PROGRESS_ENABLE_INTR 0x0800 /* DDI interrupts enabled */ 2445273Sgl147354 #define ATTACH_PROGRESS_FMINIT 0x1000 /* FMA initiated */ 2453526Sxy150489 2463526Sxy150489 /* 2473526Sxy150489 * Speed and Duplex Settings 2483526Sxy150489 */ 2493526Sxy150489 #define GDIAG_10_HALF 1 2503526Sxy150489 #define GDIAG_10_FULL 2 2513526Sxy150489 #define GDIAG_100_HALF 3 2523526Sxy150489 #define GDIAG_100_FULL 4 2533526Sxy150489 #define GDIAG_1000_FULL 6 2543526Sxy150489 #define GDIAG_ANY 7 2553526Sxy150489 2563526Sxy150489 /* 2573526Sxy150489 * Coexist Workaround RP: 07/04/03 2583526Sxy150489 * 82544 Workaround : Co-existence 2593526Sxy150489 */ 2603526Sxy150489 #define MAX_TX_BUF_SIZE (8 * 1024) 2613526Sxy150489 2623526Sxy150489 /* 2633526Sxy150489 * Defines for Jumbo Frame 2643526Sxy150489 */ 2653526Sxy150489 #define FRAME_SIZE_UPTO_2K 2048 2663526Sxy150489 #define FRAME_SIZE_UPTO_4K 4096 2673526Sxy150489 #define FRAME_SIZE_UPTO_8K 8192 2683526Sxy150489 #define FRAME_SIZE_UPTO_16K 16384 2694919Sxy150489 #define FRAME_SIZE_UPTO_9K 9234 2703526Sxy150489 2716394Scc210113 #define DEFAULT_MTU ETHERMTU 27210680SMin.Xu@Sun.COM #define MAXIMUM_MTU_4K 4096 27310680SMin.Xu@Sun.COM #define MAXIMUM_MTU_9K 9216 2746394Scc210113 2756394Scc210113 #define DEFAULT_FRAME_SIZE \ 2766394Scc210113 (DEFAULT_MTU + sizeof (struct ether_vlan_header) + ETHERFCSL) 2776394Scc210113 #define MAXIMUM_FRAME_SIZE \ 2786394Scc210113 (MAXIMUM_MTU + sizeof (struct ether_vlan_header) + ETHERFCSL) 2793526Sxy150489 28012246SChangqing.Li@Sun.COM #define E1000_LSO_MAXLEN 65535 28112246SChangqing.Li@Sun.COM #define E1000_LSO_FIRST_DESC_ALIGNMENT_BOUNDARY_4K 4096 28212246SChangqing.Li@Sun.COM #define E1000_LSO_FIRST_DESC_ALIGNMENT 128 2836986Smx205022 2843526Sxy150489 /* Defines for Tx stall check */ 2853526Sxy150489 #define E1000G_STALL_WATCHDOG_COUNT 8 2863526Sxy150489 2874061Sxy150489 #define MAX_TX_LINK_DOWN_TIMEOUT 8 2884061Sxy150489 2893526Sxy150489 /* Defines for DVMA */ 2903526Sxy150489 #ifdef __sparc 2913526Sxy150489 #define E1000G_DEFAULT_DVMA_PAGE_NUM 2 2923526Sxy150489 #endif 2933526Sxy150489 2943526Sxy150489 /* 2953526Sxy150489 * Loopback definitions 2963526Sxy150489 */ 2973526Sxy150489 #define E1000G_LB_NONE 0 2983526Sxy150489 #define E1000G_LB_EXTERNAL_1000 1 2993526Sxy150489 #define E1000G_LB_EXTERNAL_100 2 3003526Sxy150489 #define E1000G_LB_EXTERNAL_10 3 3013526Sxy150489 #define E1000G_LB_INTERNAL_PHY 4 3023526Sxy150489 3034982Syy150190 /* 3044982Syy150190 * Private dip list definitions 3054982Syy150190 */ 3064982Syy150190 #define E1000G_PRIV_DEVI_ATTACH 0x0 3074982Syy150190 #define E1000G_PRIV_DEVI_DETACH 0x1 3083526Sxy150489 3093526Sxy150489 /* 3106986Smx205022 * Tx descriptor LENGTH field mask 3116986Smx205022 */ 3126986Smx205022 #define E1000G_TBD_LENGTH_MASK 0x000fffff 3136986Smx205022 3148995SMin.Xu@Sun.COM #define E1000G_IS_VLAN_PACKET(ptr) \ 3158995SMin.Xu@Sun.COM ((((struct ether_vlan_header *)(uintptr_t)ptr)->ether_tpid) == \ 3168995SMin.Xu@Sun.COM htons(ETHERTYPE_VLAN)) 3178995SMin.Xu@Sun.COM 3186986Smx205022 /* 3193526Sxy150489 * QUEUE_INIT_LIST -- Macro which will init ialize a queue to NULL. 3203526Sxy150489 */ 3213526Sxy150489 #define QUEUE_INIT_LIST(_LH) \ 3223526Sxy150489 (_LH)->Flink = (_LH)->Blink = (PSINGLE_LIST_LINK)0 3233526Sxy150489 3243526Sxy150489 /* 3253526Sxy150489 * IS_QUEUE_EMPTY -- Macro which checks to see if a queue is empty. 3263526Sxy150489 */ 3273526Sxy150489 #define IS_QUEUE_EMPTY(_LH) \ 3283526Sxy150489 ((_LH)->Flink == (PSINGLE_LIST_LINK)0) 3293526Sxy150489 3303526Sxy150489 /* 3313526Sxy150489 * QUEUE_GET_HEAD -- Macro which returns the head of the queue, but does 3323526Sxy150489 * not remove the head from the queue. 3333526Sxy150489 */ 3343526Sxy150489 #define QUEUE_GET_HEAD(_LH) ((PSINGLE_LIST_LINK)((_LH)->Flink)) 3353526Sxy150489 3363526Sxy150489 /* 3373526Sxy150489 * QUEUE_REMOVE_HEAD -- Macro which removes the head of the head of a queue. 3383526Sxy150489 */ 3393526Sxy150489 #define QUEUE_REMOVE_HEAD(_LH) \ 3403526Sxy150489 { \ 3413526Sxy150489 PSINGLE_LIST_LINK ListElem; \ 3423526Sxy150489 if (ListElem = (_LH)->Flink) \ 3433526Sxy150489 { \ 3443526Sxy150489 if (!((_LH)->Flink = ListElem->Flink)) \ 3453526Sxy150489 (_LH)->Blink = (PSINGLE_LIST_LINK) 0; \ 3463526Sxy150489 } \ 3473526Sxy150489 } 3483526Sxy150489 3493526Sxy150489 /* 3503526Sxy150489 * QUEUE_POP_HEAD -- Macro which will pop the head off of a queue (list), 3513526Sxy150489 * and return it (this differs from QUEUE_REMOVE_HEAD only in 3523526Sxy150489 * the 1st line). 3533526Sxy150489 */ 3543526Sxy150489 #define QUEUE_POP_HEAD(_LH) \ 3553526Sxy150489 (PSINGLE_LIST_LINK)(_LH)->Flink; \ 3563526Sxy150489 { \ 3573526Sxy150489 PSINGLE_LIST_LINK ListElem; \ 3583526Sxy150489 ListElem = (_LH)->Flink; \ 3593526Sxy150489 if (ListElem) \ 3603526Sxy150489 { \ 3613526Sxy150489 (_LH)->Flink = ListElem->Flink; \ 3623526Sxy150489 if (!(_LH)->Flink) \ 3633526Sxy150489 (_LH)->Blink = (PSINGLE_LIST_LINK)0; \ 3643526Sxy150489 } \ 3653526Sxy150489 } 3663526Sxy150489 3673526Sxy150489 /* 3683526Sxy150489 * QUEUE_GET_TAIL -- Macro which returns the tail of the queue, but does not 3693526Sxy150489 * remove the tail from the queue. 3703526Sxy150489 */ 3713526Sxy150489 #define QUEUE_GET_TAIL(_LH) ((PSINGLE_LIST_LINK)((_LH)->Blink)) 3723526Sxy150489 3733526Sxy150489 /* 3743526Sxy150489 * QUEUE_PUSH_TAIL -- Macro which puts an element at the tail (end) of the queue 3753526Sxy150489 */ 3763526Sxy150489 #define QUEUE_PUSH_TAIL(_LH, _E) \ 3773526Sxy150489 if ((_LH)->Blink) \ 3783526Sxy150489 { \ 3793526Sxy150489 ((PSINGLE_LIST_LINK)(_LH)->Blink)->Flink = \ 3803526Sxy150489 (PSINGLE_LIST_LINK)(_E); \ 3813526Sxy150489 (_LH)->Blink = (PSINGLE_LIST_LINK)(_E); \ 3823526Sxy150489 } else { \ 3833526Sxy150489 (_LH)->Flink = \ 3843526Sxy150489 (_LH)->Blink = (PSINGLE_LIST_LINK)(_E); \ 3853526Sxy150489 } \ 3863526Sxy150489 (_E)->Flink = (PSINGLE_LIST_LINK)0; 3873526Sxy150489 3883526Sxy150489 /* 3893526Sxy150489 * QUEUE_PUSH_HEAD -- Macro which puts an element at the head of the queue. 3903526Sxy150489 */ 3913526Sxy150489 #define QUEUE_PUSH_HEAD(_LH, _E) \ 3923526Sxy150489 if (!((_E)->Flink = (_LH)->Flink)) \ 3933526Sxy150489 { \ 3943526Sxy150489 (_LH)->Blink = (PSINGLE_LIST_LINK)(_E); \ 3953526Sxy150489 } \ 3963526Sxy150489 (_LH)->Flink = (PSINGLE_LIST_LINK)(_E); 3973526Sxy150489 3983526Sxy150489 /* 3993526Sxy150489 * QUEUE_GET_NEXT -- Macro which returns the next element linked to the 4003526Sxy150489 * current element. 4013526Sxy150489 */ 4023526Sxy150489 #define QUEUE_GET_NEXT(_LH, _E) \ 4033526Sxy150489 (PSINGLE_LIST_LINK)((((_LH)->Blink) == (_E)) ? \ 4043526Sxy150489 (0) : ((_E)->Flink)) 4053526Sxy150489 4063526Sxy150489 /* 4073526Sxy150489 * QUEUE_APPEND -- Macro which appends a queue to the tail of another queue 4083526Sxy150489 */ 4093526Sxy150489 #define QUEUE_APPEND(_LH1, _LH2) \ 4103526Sxy150489 if ((_LH2)->Flink) { \ 4113526Sxy150489 if ((_LH1)->Flink) { \ 4123526Sxy150489 ((PSINGLE_LIST_LINK)(_LH1)->Blink)->Flink = \ 4133526Sxy150489 ((PSINGLE_LIST_LINK)(_LH2)->Flink); \ 4143526Sxy150489 } else { \ 4153526Sxy150489 (_LH1)->Flink = \ 4163526Sxy150489 ((PSINGLE_LIST_LINK)(_LH2)->Flink); \ 4173526Sxy150489 } \ 4183526Sxy150489 (_LH1)->Blink = ((PSINGLE_LIST_LINK)(_LH2)->Blink); \ 4193526Sxy150489 } 4203526Sxy150489 4218275SEric Cheng 4228275SEric Cheng #define QUEUE_SWITCH(_LH1, _LH2) \ 4238275SEric Cheng if ((_LH2)->Flink) { \ 4248275SEric Cheng (_LH1)->Flink = (_LH2)->Flink; \ 4258275SEric Cheng (_LH1)->Blink = (_LH2)->Blink; \ 4268275SEric Cheng (_LH2)->Flink = (_LH2)->Blink = (PSINGLE_LIST_LINK)0; \ 4278275SEric Cheng } 4288275SEric Cheng 4293526Sxy150489 /* 4303526Sxy150489 * Property lookups 4313526Sxy150489 */ 4323526Sxy150489 #define E1000G_PROP_EXISTS(d, n) ddi_prop_exists(DDI_DEV_T_ANY, (d), \ 4333526Sxy150489 DDI_PROP_DONTPASS, (n)) 4343526Sxy150489 #define E1000G_PROP_GET_INT(d, n) ddi_prop_get_int(DDI_DEV_T_ANY, (d), \ 4353526Sxy150489 DDI_PROP_DONTPASS, (n), -1) 4363526Sxy150489 4374919Sxy150489 #ifdef E1000G_DEBUG 4383526Sxy150489 /* 4393526Sxy150489 * E1000G-specific ioctls ... 4403526Sxy150489 */ 4413526Sxy150489 #define E1000G_IOC ((((((('E' << 4) + '1') << 4) \ 4423526Sxy150489 + 'K') << 4) + 'G') << 4) 4433526Sxy150489 4443526Sxy150489 /* 4453526Sxy150489 * These diagnostic IOCTLS are enabled only in DEBUG drivers 4463526Sxy150489 */ 4473526Sxy150489 #define E1000G_IOC_REG_PEEK (E1000G_IOC | 1) 4483526Sxy150489 #define E1000G_IOC_REG_POKE (E1000G_IOC | 2) 4493526Sxy150489 #define E1000G_IOC_CHIP_RESET (E1000G_IOC | 3) 4503526Sxy150489 4513526Sxy150489 #define E1000G_PP_SPACE_REG 0 /* PCI memory space */ 4523526Sxy150489 #define E1000G_PP_SPACE_E1000G 1 /* driver's soft state */ 4533526Sxy150489 4543526Sxy150489 typedef struct { 4553526Sxy150489 uint64_t pp_acc_size; /* It's 1, 2, 4 or 8 */ 4563526Sxy150489 uint64_t pp_acc_space; /* See #defines below */ 4573526Sxy150489 uint64_t pp_acc_offset; /* See regs definition */ 4583526Sxy150489 uint64_t pp_acc_data; /* output for peek */ 4593526Sxy150489 /* input for poke */ 4603526Sxy150489 } e1000g_peekpoke_t; 4614919Sxy150489 #endif /* E1000G_DEBUG */ 4623526Sxy150489 4633526Sxy150489 /* 4643526Sxy150489 * (Internal) return values from ioctl subroutines 4653526Sxy150489 */ 4663526Sxy150489 enum ioc_reply { 4673526Sxy150489 IOC_INVAL = -1, /* bad, NAK with EINVAL */ 4683526Sxy150489 IOC_DONE, /* OK, reply sent */ 4693526Sxy150489 IOC_ACK, /* OK, just send ACK */ 4703526Sxy150489 IOC_REPLY /* OK, just send reply */ 4713526Sxy150489 }; 4723526Sxy150489 4733526Sxy150489 /* 4743526Sxy150489 * Named Data (ND) Parameter Management Structure 4753526Sxy150489 */ 4763526Sxy150489 typedef struct { 4773526Sxy150489 uint32_t ndp_info; 4783526Sxy150489 uint32_t ndp_min; 4793526Sxy150489 uint32_t ndp_max; 4803526Sxy150489 uint32_t ndp_val; 4813526Sxy150489 struct e1000g *ndp_instance; 4823526Sxy150489 char *ndp_name; 4833526Sxy150489 } nd_param_t; 4843526Sxy150489 4853526Sxy150489 /* 4864982Syy150190 * The entry of the private dip list 4874982Syy150190 */ 4884349Sxy150489 typedef struct _private_devi_list { 4894349Sxy150489 dev_info_t *priv_dip; 4908850SMin.Xu@Sun.COM uint32_t flag; 4918850SMin.Xu@Sun.COM uint32_t pending_rx_count; 4928850SMin.Xu@Sun.COM struct _private_devi_list *prev; 4934349Sxy150489 struct _private_devi_list *next; 4944349Sxy150489 } private_devi_list_t; 4954349Sxy150489 4963526Sxy150489 /* 4973526Sxy150489 * A structure that points to the next entry in the queue. 4983526Sxy150489 */ 4993526Sxy150489 typedef struct _SINGLE_LIST_LINK { 5003526Sxy150489 struct _SINGLE_LIST_LINK *Flink; 5013526Sxy150489 } SINGLE_LIST_LINK, *PSINGLE_LIST_LINK; 5023526Sxy150489 5033526Sxy150489 /* 5043526Sxy150489 * A "ListHead" structure that points to the head and tail of a queue 5053526Sxy150489 */ 5063526Sxy150489 typedef struct _LIST_DESCRIBER { 5073526Sxy150489 struct _SINGLE_LIST_LINK *volatile Flink; 5083526Sxy150489 struct _SINGLE_LIST_LINK *volatile Blink; 5093526Sxy150489 } LIST_DESCRIBER, *PLIST_DESCRIBER; 5103526Sxy150489 51111532SGuoqing.Zhu@Sun.COM enum e1000g_bar_type { 51211532SGuoqing.Zhu@Sun.COM E1000G_BAR_CONFIG = 0, 51311532SGuoqing.Zhu@Sun.COM E1000G_BAR_IO, 51411532SGuoqing.Zhu@Sun.COM E1000G_BAR_MEM32, 51511532SGuoqing.Zhu@Sun.COM E1000G_BAR_MEM64 51611532SGuoqing.Zhu@Sun.COM }; 51711532SGuoqing.Zhu@Sun.COM 51811532SGuoqing.Zhu@Sun.COM typedef struct { 51911532SGuoqing.Zhu@Sun.COM enum e1000g_bar_type type; 52011532SGuoqing.Zhu@Sun.COM int rnumber; 52111532SGuoqing.Zhu@Sun.COM } bar_info_t; 52211532SGuoqing.Zhu@Sun.COM 5233526Sxy150489 /* 5243526Sxy150489 * Address-Length pair structure that stores descriptor info 5253526Sxy150489 */ 5264919Sxy150489 typedef struct _sw_desc { 5274919Sxy150489 uint64_t address; 5284919Sxy150489 uint32_t length; 5294919Sxy150489 } sw_desc_t, *p_sw_desc_t; 5303526Sxy150489 5314919Sxy150489 typedef struct _desc_array { 5324919Sxy150489 sw_desc_t descriptor[4]; 5334919Sxy150489 uint32_t elements; 5344919Sxy150489 } desc_array_t, *p_desc_array_t; 5353526Sxy150489 5363526Sxy150489 typedef enum { 5373526Sxy150489 USE_NONE, 5383526Sxy150489 USE_BCOPY, 5393526Sxy150489 USE_DVMA, 5403526Sxy150489 USE_DMA 5413526Sxy150489 } dma_type_t; 5423526Sxy150489 5433526Sxy150489 typedef struct _dma_buffer { 5443526Sxy150489 caddr_t address; 5453526Sxy150489 uint64_t dma_address; 5463526Sxy150489 ddi_acc_handle_t acc_handle; 5473526Sxy150489 ddi_dma_handle_t dma_handle; 5483526Sxy150489 size_t size; 5493526Sxy150489 size_t len; 5504919Sxy150489 } dma_buffer_t, *p_dma_buffer_t; 5513526Sxy150489 5523526Sxy150489 /* 5533526Sxy150489 * Transmit Control Block (TCB), Ndis equiv of SWPacket This 5543526Sxy150489 * structure stores the additional information that is 5553526Sxy150489 * associated with every packet to be transmitted. It stores the 5563526Sxy150489 * message block pointer and the TBD addresses associated with 5573526Sxy150489 * the m_blk and also the link to the next tcb in the chain 5583526Sxy150489 */ 5594919Sxy150489 typedef struct _tx_sw_packet { 5604919Sxy150489 /* Link to the next tx_sw_packet in the list */ 5613526Sxy150489 SINGLE_LIST_LINK Link; 5623526Sxy150489 mblk_t *mp; 5634919Sxy150489 uint32_t num_desc; 5644919Sxy150489 uint32_t num_mblk_frag; 5653526Sxy150489 dma_type_t dma_type; 5663526Sxy150489 dma_type_t data_transfer_type; 5673526Sxy150489 ddi_dma_handle_t tx_dma_handle; 5683526Sxy150489 dma_buffer_t tx_buf[1]; 5694919Sxy150489 sw_desc_t desc[MAX_TX_DESC_PER_PACKET]; 5708850SMin.Xu@Sun.COM int64_t tickstamp; 5714919Sxy150489 } tx_sw_packet_t, *p_tx_sw_packet_t; 5723526Sxy150489 5733526Sxy150489 /* 5744919Sxy150489 * This structure is similar to the rx_sw_packet structure used 5753526Sxy150489 * for Ndis. This structure stores information about the 2k 5763526Sxy150489 * aligned receive buffer into which the FX1000 DMA's frames. 5773526Sxy150489 * This structure is maintained as a linked list of many 5783526Sxy150489 * receiver buffer pointers. 5793526Sxy150489 */ 5804982Syy150190 typedef struct _rx_sw_packet { 5814919Sxy150489 /* Link to the next rx_sw_packet_t in the list */ 5823526Sxy150489 SINGLE_LIST_LINK Link; 5834982Syy150190 struct _rx_sw_packet *next; 5848850SMin.Xu@Sun.COM uint32_t ref_cnt; 5853526Sxy150489 mblk_t *mp; 5868850SMin.Xu@Sun.COM caddr_t rx_data; 5873526Sxy150489 dma_type_t dma_type; 5883526Sxy150489 frtn_t free_rtn; 5893526Sxy150489 dma_buffer_t rx_buf[1]; 5904919Sxy150489 } rx_sw_packet_t, *p_rx_sw_packet_t; 5913526Sxy150489 5924919Sxy150489 typedef struct _mblk_list { 5933526Sxy150489 mblk_t *head; 5943526Sxy150489 mblk_t *tail; 5954919Sxy150489 } mblk_list_t, *p_mblk_list_t; 5963526Sxy150489 5976986Smx205022 typedef struct _context_data { 5984061Sxy150489 uint32_t ether_header_size; 5994061Sxy150489 uint32_t cksum_flags; 6004061Sxy150489 uint32_t cksum_start; 6014061Sxy150489 uint32_t cksum_stuff; 6026986Smx205022 uint16_t mss; 6036986Smx205022 uint8_t hdr_len; 6046986Smx205022 uint32_t pay_len; 6056986Smx205022 boolean_t lso_flag; 6066986Smx205022 } context_data_t; 6074061Sxy150489 6083526Sxy150489 typedef union _e1000g_ether_addr { 6093526Sxy150489 struct { 6103526Sxy150489 uint32_t high; 6113526Sxy150489 uint32_t low; 6123526Sxy150489 } reg; 6133526Sxy150489 struct { 6143526Sxy150489 uint8_t set; 6153526Sxy150489 uint8_t redundant; 6164919Sxy150489 uint8_t addr[ETHERADDRL]; 6173526Sxy150489 } mac; 6183526Sxy150489 } e1000g_ether_addr_t; 6193526Sxy150489 6204919Sxy150489 typedef struct _e1000g_stat { 6213526Sxy150489 6223526Sxy150489 kstat_named_t link_speed; /* Link Speed */ 6234919Sxy150489 kstat_named_t reset_count; /* Reset Count */ 6244919Sxy150489 6253526Sxy150489 kstat_named_t rx_error; /* Rx Error in Packet */ 6264919Sxy150489 kstat_named_t rx_allocb_fail; /* Rx Allocb Failure */ 6278995SMin.Xu@Sun.COM kstat_named_t rx_size_error; /* Rx Size Error */ 6284919Sxy150489 6294919Sxy150489 kstat_named_t tx_no_desc; /* Tx No Desc */ 6304919Sxy150489 kstat_named_t tx_no_swpkt; /* Tx No Pkt Buffer */ 6314919Sxy150489 kstat_named_t tx_send_fail; /* Tx SendPkt Failure */ 6324919Sxy150489 kstat_named_t tx_over_size; /* Tx Pkt Too Long */ 6334919Sxy150489 kstat_named_t tx_reschedule; /* Tx Reschedule */ 6344919Sxy150489 6354919Sxy150489 #ifdef E1000G_DEBUG 6364919Sxy150489 kstat_named_t rx_none; /* Rx No Incoming Data */ 6373526Sxy150489 kstat_named_t rx_multi_desc; /* Rx Multi Spanned Pkt */ 6383526Sxy150489 kstat_named_t rx_no_freepkt; /* Rx No Free Pkt */ 6393526Sxy150489 kstat_named_t rx_avail_freepkt; /* Rx Freelist Avail Buffers */ 6404919Sxy150489 6414919Sxy150489 kstat_named_t tx_under_size; /* Tx Packet Under Size */ 6423526Sxy150489 kstat_named_t tx_empty_frags; /* Tx Empty Frags */ 6433526Sxy150489 kstat_named_t tx_exceed_frags; /* Tx Exceed Max Frags */ 6443526Sxy150489 kstat_named_t tx_recycle; /* Tx Recycle */ 6454919Sxy150489 kstat_named_t tx_recycle_intr; /* Tx Recycle in Intr */ 6463526Sxy150489 kstat_named_t tx_recycle_retry; /* Tx Recycle Retry */ 6473526Sxy150489 kstat_named_t tx_recycle_none; /* Tx No Desc Recycled */ 6483526Sxy150489 kstat_named_t tx_copy; /* Tx Send Copy */ 6493526Sxy150489 kstat_named_t tx_bind; /* Tx Send Bind */ 6503526Sxy150489 kstat_named_t tx_multi_copy; /* Tx Copy Multi Fragments */ 6514919Sxy150489 kstat_named_t tx_multi_cookie; /* Tx Pkt Span Multi Cookies */ 6524919Sxy150489 kstat_named_t tx_lack_desc; /* Tx Lack of Desc */ 6534919Sxy150489 #endif 6544919Sxy150489 6553526Sxy150489 kstat_named_t Crcerrs; /* CRC Error Count */ 6563526Sxy150489 kstat_named_t Symerrs; /* Symbol Error Count */ 6573526Sxy150489 kstat_named_t Mpc; /* Missed Packet Count */ 6583526Sxy150489 kstat_named_t Scc; /* Single Collision Count */ 6593526Sxy150489 kstat_named_t Ecol; /* Excessive Collision Count */ 6603526Sxy150489 kstat_named_t Mcc; /* Multiple Collision Count */ 6613526Sxy150489 kstat_named_t Latecol; /* Late Collision Count */ 6623526Sxy150489 kstat_named_t Colc; /* Collision Count */ 6633526Sxy150489 kstat_named_t Dc; /* Defer Count */ 6643526Sxy150489 kstat_named_t Sec; /* Sequence Error Count */ 6653526Sxy150489 kstat_named_t Rlec; /* Receive Length Error Count */ 6663526Sxy150489 kstat_named_t Xonrxc; /* XON Received Count */ 6673526Sxy150489 kstat_named_t Xontxc; /* XON Xmitted Count */ 6683526Sxy150489 kstat_named_t Xoffrxc; /* XOFF Received Count */ 6693526Sxy150489 kstat_named_t Xofftxc; /* Xoff Xmitted Count */ 6703526Sxy150489 kstat_named_t Fcruc; /* Unknown Flow Conrol Packet Rcvd Count */ 6715882Syy150190 #ifdef E1000G_DEBUG 6723526Sxy150489 kstat_named_t Prc64; /* Packets Received - 64b */ 6733526Sxy150489 kstat_named_t Prc127; /* Packets Received - 65-127b */ 6743526Sxy150489 kstat_named_t Prc255; /* Packets Received - 127-255b */ 6753526Sxy150489 kstat_named_t Prc511; /* Packets Received - 256-511b */ 6763526Sxy150489 kstat_named_t Prc1023; /* Packets Received - 511-1023b */ 6773526Sxy150489 kstat_named_t Prc1522; /* Packets Received - 1024-1522b */ 6785882Syy150190 #endif 6793526Sxy150489 kstat_named_t Gprc; /* Good Packets Received Count */ 6803526Sxy150489 kstat_named_t Bprc; /* Broadcasts Pkts Received Count */ 6813526Sxy150489 kstat_named_t Mprc; /* Multicast Pkts Received Count */ 6823526Sxy150489 kstat_named_t Gptc; /* Good Packets Xmitted Count */ 6833526Sxy150489 kstat_named_t Gorl; /* Good Octets Recvd Lo Count */ 6843526Sxy150489 kstat_named_t Gorh; /* Good Octets Recvd Hi Count */ 6853526Sxy150489 kstat_named_t Gotl; /* Good Octets Xmitd Lo Count */ 6863526Sxy150489 kstat_named_t Goth; /* Good Octets Xmitd Hi Count */ 6873526Sxy150489 kstat_named_t Rnbc; /* Receive No Buffers Count */ 6883526Sxy150489 kstat_named_t Ruc; /* Receive Undersize Count */ 6893526Sxy150489 kstat_named_t Rfc; /* Receive Frag Count */ 6903526Sxy150489 kstat_named_t Roc; /* Receive Oversize Count */ 6913526Sxy150489 kstat_named_t Rjc; /* Receive Jabber Count */ 6923526Sxy150489 kstat_named_t Torl; /* Total Octets Recvd Lo Count */ 6933526Sxy150489 kstat_named_t Torh; /* Total Octets Recvd Hi Count */ 6943526Sxy150489 kstat_named_t Totl; /* Total Octets Xmted Lo Count */ 6953526Sxy150489 kstat_named_t Toth; /* Total Octets Xmted Hi Count */ 6963526Sxy150489 kstat_named_t Tpr; /* Total Packets Received */ 6973526Sxy150489 kstat_named_t Tpt; /* Total Packets Xmitted */ 6985882Syy150190 #ifdef E1000G_DEBUG 6993526Sxy150489 kstat_named_t Ptc64; /* Packets Xmitted (64b) */ 7003526Sxy150489 kstat_named_t Ptc127; /* Packets Xmitted (64-127b) */ 7013526Sxy150489 kstat_named_t Ptc255; /* Packets Xmitted (128-255b) */ 7023526Sxy150489 kstat_named_t Ptc511; /* Packets Xmitted (255-511b) */ 7033526Sxy150489 kstat_named_t Ptc1023; /* Packets Xmitted (512-1023b) */ 7043526Sxy150489 kstat_named_t Ptc1522; /* Packets Xmitted (1024-1522b */ 7055882Syy150190 #endif 7063526Sxy150489 kstat_named_t Mptc; /* Multicast Packets Xmited Count */ 7073526Sxy150489 kstat_named_t Bptc; /* Broadcast Packets Xmited Count */ 7083526Sxy150489 kstat_named_t Algnerrc; /* Alignment Error count */ 7093526Sxy150489 kstat_named_t Tuc; /* Transmit Underrun count */ 7103526Sxy150489 kstat_named_t Rxerrc; /* Rx Error Count */ 7113526Sxy150489 kstat_named_t Tncrs; /* Transmit with no CRS */ 7123526Sxy150489 kstat_named_t Cexterr; /* Carrier Extension Error count */ 7133526Sxy150489 kstat_named_t Rutec; /* Receive DMA too Early count */ 7143526Sxy150489 kstat_named_t Tsctc; /* TCP seg contexts xmit count */ 7153526Sxy150489 kstat_named_t Tsctfc; /* TCP seg contexts xmit fail count */ 7164919Sxy150489 } e1000g_stat_t, *p_e1000g_stat_t; 7173526Sxy150489 7183526Sxy150489 typedef struct _e1000g_tx_ring { 7193526Sxy150489 kmutex_t tx_lock; 7203526Sxy150489 kmutex_t freelist_lock; 7213526Sxy150489 kmutex_t usedlist_lock; 7223526Sxy150489 /* 7233526Sxy150489 * Descriptor queue definitions 7243526Sxy150489 */ 7253526Sxy150489 ddi_dma_handle_t tbd_dma_handle; 7263526Sxy150489 ddi_acc_handle_t tbd_acc_handle; 7273526Sxy150489 struct e1000_tx_desc *tbd_area; 7283526Sxy150489 uint64_t tbd_dma_addr; 7293526Sxy150489 struct e1000_tx_desc *tbd_first; 7303526Sxy150489 struct e1000_tx_desc *tbd_last; 7313526Sxy150489 struct e1000_tx_desc *tbd_oldest; 7323526Sxy150489 struct e1000_tx_desc *tbd_next; 7334919Sxy150489 uint32_t tbd_avail; 7343526Sxy150489 /* 7353526Sxy150489 * Software packet structures definitions 7363526Sxy150489 */ 7374919Sxy150489 p_tx_sw_packet_t packet_area; 7383526Sxy150489 LIST_DESCRIBER used_list; 7393526Sxy150489 LIST_DESCRIBER free_list; 7403526Sxy150489 /* 7416986Smx205022 * TCP/UDP Context Data Information 7423526Sxy150489 */ 7436986Smx205022 context_data_t pre_context; 7443526Sxy150489 /* 7453526Sxy150489 * Timer definitions for 82547 7463526Sxy150489 */ 7473526Sxy150489 timeout_id_t timer_id_82547; 7483526Sxy150489 boolean_t timer_enable_82547; 7493526Sxy150489 /* 7504919Sxy150489 * reschedule when tx resource is available 7514919Sxy150489 */ 7524919Sxy150489 boolean_t resched_needed; 7538275SEric Cheng clock_t resched_timestamp; 7544919Sxy150489 mblk_list_t mblks; 7554919Sxy150489 /* 7564919Sxy150489 * Statistics 7574919Sxy150489 */ 7584919Sxy150489 uint32_t stat_no_swpkt; 7594919Sxy150489 uint32_t stat_no_desc; 7604919Sxy150489 uint32_t stat_send_fail; 7614919Sxy150489 uint32_t stat_reschedule; 7628275SEric Cheng uint32_t stat_timer_reschedule; 7634919Sxy150489 uint32_t stat_over_size; 7644919Sxy150489 #ifdef E1000G_DEBUG 7654919Sxy150489 uint32_t stat_under_size; 7664919Sxy150489 uint32_t stat_exceed_frags; 7674919Sxy150489 uint32_t stat_empty_frags; 7684919Sxy150489 uint32_t stat_recycle; 7694919Sxy150489 uint32_t stat_recycle_intr; 7704919Sxy150489 uint32_t stat_recycle_retry; 7714919Sxy150489 uint32_t stat_recycle_none; 7724919Sxy150489 uint32_t stat_copy; 7734919Sxy150489 uint32_t stat_bind; 7744919Sxy150489 uint32_t stat_multi_copy; 7754919Sxy150489 uint32_t stat_multi_cookie; 7764919Sxy150489 uint32_t stat_lack_desc; 7778073SMin.Xu@Sun.COM uint32_t stat_lso_header_fail; 7784919Sxy150489 #endif 7794919Sxy150489 /* 7803526Sxy150489 * Pointer to the adapter 7813526Sxy150489 */ 7823526Sxy150489 struct e1000g *adapter; 7833526Sxy150489 } e1000g_tx_ring_t, *pe1000g_tx_ring_t; 7843526Sxy150489 7858850SMin.Xu@Sun.COM typedef struct _e1000g_rx_data { 7863526Sxy150489 kmutex_t freelist_lock; 7878275SEric Cheng kmutex_t recycle_lock; 7883526Sxy150489 /* 7893526Sxy150489 * Descriptor queue definitions 7903526Sxy150489 */ 7913526Sxy150489 ddi_dma_handle_t rbd_dma_handle; 7923526Sxy150489 ddi_acc_handle_t rbd_acc_handle; 7933526Sxy150489 struct e1000_rx_desc *rbd_area; 7943526Sxy150489 uint64_t rbd_dma_addr; 7953526Sxy150489 struct e1000_rx_desc *rbd_first; 7963526Sxy150489 struct e1000_rx_desc *rbd_last; 7973526Sxy150489 struct e1000_rx_desc *rbd_next; 7983526Sxy150489 /* 7993526Sxy150489 * Software packet structures definitions 8003526Sxy150489 */ 8014919Sxy150489 p_rx_sw_packet_t packet_area; 8023526Sxy150489 LIST_DESCRIBER recv_list; 8033526Sxy150489 LIST_DESCRIBER free_list; 8048275SEric Cheng LIST_DESCRIBER recycle_list; 8058850SMin.Xu@Sun.COM uint32_t flag; 8064919Sxy150489 8074919Sxy150489 uint32_t pending_count; 8084919Sxy150489 uint32_t avail_freepkt; 8098275SEric Cheng uint32_t recycle_freepkt; 8104919Sxy150489 uint32_t rx_mblk_len; 8114919Sxy150489 mblk_t *rx_mblk; 8124919Sxy150489 mblk_t *rx_mblk_tail; 8138850SMin.Xu@Sun.COM 8148850SMin.Xu@Sun.COM private_devi_list_t *priv_devi_node; 8158850SMin.Xu@Sun.COM struct _e1000g_rx_ring *rx_ring; 8168850SMin.Xu@Sun.COM } e1000g_rx_data_t; 8178850SMin.Xu@Sun.COM 8188850SMin.Xu@Sun.COM typedef struct _e1000g_rx_ring { 8198850SMin.Xu@Sun.COM e1000g_rx_data_t *rx_data; 8208850SMin.Xu@Sun.COM 8218850SMin.Xu@Sun.COM kmutex_t rx_lock; 8228850SMin.Xu@Sun.COM 8238275SEric Cheng mac_ring_handle_t mrh; 8248275SEric Cheng mac_ring_handle_t mrh_init; 8258275SEric Cheng uint64_t ring_gen_num; 8268275SEric Cheng boolean_t poll_flag; 8278275SEric Cheng 8284919Sxy150489 /* 8294919Sxy150489 * Statistics 8304919Sxy150489 */ 8314919Sxy150489 uint32_t stat_error; 8324919Sxy150489 uint32_t stat_allocb_fail; 8334919Sxy150489 uint32_t stat_exceed_pkt; 8348995SMin.Xu@Sun.COM uint32_t stat_size_error; 835*12853SChangqing.Li@Sun.COM uint32_t stat_crc_only_pkt; 8364919Sxy150489 #ifdef E1000G_DEBUG 8374919Sxy150489 uint32_t stat_none; 8384919Sxy150489 uint32_t stat_multi_desc; 8394919Sxy150489 uint32_t stat_no_freepkt; 8404919Sxy150489 #endif 8413526Sxy150489 /* 8423526Sxy150489 * Pointer to the adapter 8433526Sxy150489 */ 8443526Sxy150489 struct e1000g *adapter; 8453526Sxy150489 } e1000g_rx_ring_t, *pe1000g_rx_ring_t; 8463526Sxy150489 8473526Sxy150489 typedef struct e1000g { 8484919Sxy150489 int instance; 8493526Sxy150489 dev_info_t *dip; 8504349Sxy150489 dev_info_t *priv_dip; 8518850SMin.Xu@Sun.COM private_devi_list_t *priv_devi_node; 8524919Sxy150489 mac_handle_t mh; 8534919Sxy150489 mac_resource_handle_t mrh; 8544919Sxy150489 struct e1000_hw shared; 8553526Sxy150489 struct e1000g_osdep osdep; 8563526Sxy150489 8578479SChenlu.Chen@Sun.COM uint32_t e1000g_state; 8584919Sxy150489 boolean_t e1000g_promisc; 8594919Sxy150489 boolean_t strip_crc; 8604919Sxy150489 boolean_t rx_buffer_setup; 8617133Scc210113 boolean_t esb2_workaround; 8624061Sxy150489 link_state_t link_state; 8634919Sxy150489 uint32_t link_speed; 8644919Sxy150489 uint32_t link_duplex; 8654919Sxy150489 uint32_t master_latency_timer; 8664919Sxy150489 uint32_t smartspeed; /* smartspeed w/a counter */ 8674919Sxy150489 uint32_t init_count; 8684919Sxy150489 uint32_t reset_count; 8698850SMin.Xu@Sun.COM boolean_t reset_flag; 8708850SMin.Xu@Sun.COM uint32_t stall_threshold; 8718850SMin.Xu@Sun.COM boolean_t stall_flag; 8724919Sxy150489 uint32_t attach_progress; /* attach tracking */ 8734919Sxy150489 uint32_t loopback_mode; 8748850SMin.Xu@Sun.COM uint32_t pending_rx_count; 8754919Sxy150489 8764919Sxy150489 uint32_t tx_desc_num; 8774919Sxy150489 uint32_t tx_freelist_num; 8784919Sxy150489 uint32_t rx_desc_num; 8794919Sxy150489 uint32_t rx_freelist_num; 880*12853SChangqing.Li@Sun.COM uint32_t rx_freelist_limit; 8814919Sxy150489 uint32_t tx_buffer_size; 8824919Sxy150489 uint32_t rx_buffer_size; 8834919Sxy150489 8844919Sxy150489 uint32_t tx_link_down_timeout; 8854919Sxy150489 uint32_t tx_bcopy_thresh; 8864919Sxy150489 uint32_t rx_limit_onintr; 8874919Sxy150489 uint32_t rx_bcopy_thresh; 8884919Sxy150489 uint32_t rx_buf_align; 8898178SChenlu.Chen@Sun.COM uint32_t desc_align; 8904919Sxy150489 8913526Sxy150489 boolean_t intr_adaptive; 8924919Sxy150489 boolean_t tx_intr_enable; 8934919Sxy150489 uint32_t tx_intr_delay; 8944919Sxy150489 uint32_t tx_intr_abs_delay; 8954919Sxy150489 uint32_t rx_intr_delay; 8964919Sxy150489 uint32_t rx_intr_abs_delay; 8973526Sxy150489 uint32_t intr_throttling_rate; 8984919Sxy150489 89911339SGuoqing.Zhu@Sun.COM uint32_t tx_desc_num_flag:1, 90011339SGuoqing.Zhu@Sun.COM rx_desc_num_flag:1, 90111339SGuoqing.Zhu@Sun.COM tx_buf_num_flag:1, 90211339SGuoqing.Zhu@Sun.COM rx_buf_num_flag:1, 90311339SGuoqing.Zhu@Sun.COM pad_to_32:28; 90411339SGuoqing.Zhu@Sun.COM 9056394Scc210113 uint32_t default_mtu; 90610680SMin.Xu@Sun.COM uint32_t max_mtu; 9076735Scc210113 uint32_t max_frame_size; 9086735Scc210113 uint32_t min_frame_size; 9096394Scc210113 9104919Sxy150489 boolean_t watchdog_timer_enabled; 9114919Sxy150489 boolean_t watchdog_timer_started; 9124919Sxy150489 timeout_id_t watchdog_tid; 9134919Sxy150489 boolean_t link_complete; 9144061Sxy150489 timeout_id_t link_tid; 9154919Sxy150489 9164919Sxy150489 e1000g_rx_ring_t rx_ring[1]; 9174919Sxy150489 e1000g_tx_ring_t tx_ring[1]; 9188275SEric Cheng mac_group_handle_t rx_group; 9198275SEric Cheng 9203526Sxy150489 /* 9215882Syy150190 * Rx and Tx packet count for interrupt adaptive setting 9225882Syy150190 */ 9235882Syy150190 uint32_t rx_pkt_cnt; 9245882Syy150190 uint32_t tx_pkt_cnt; 9255882Syy150190 9265882Syy150190 /* 9274919Sxy150489 * The watchdog_lock must be held when updateing the 9283526Sxy150489 * timeout fields in struct e1000g, that is, 9294919Sxy150489 * watchdog_tid, watchdog_timer_started. 9303526Sxy150489 */ 9314919Sxy150489 kmutex_t watchdog_lock; 9323526Sxy150489 /* 93312246SChangqing.Li@Sun.COM * The link_lock protects the link_complete and link_tid 93412246SChangqing.Li@Sun.COM * fields in struct e1000g. 9353526Sxy150489 */ 9364919Sxy150489 kmutex_t link_lock; 9373526Sxy150489 /* 9383526Sxy150489 * The chip_lock assures that the Rx/Tx process must be 9393526Sxy150489 * stopped while other functions change the hardware 9403526Sxy150489 * configuration of e1000g card, such as e1000g_reset(), 9413526Sxy150489 * e1000g_reset_hw() etc are executed. 9423526Sxy150489 */ 9433526Sxy150489 krwlock_t chip_lock; 9443526Sxy150489 9455273Sgl147354 boolean_t unicst_init; 9463526Sxy150489 uint32_t unicst_avail; 9473526Sxy150489 uint32_t unicst_total; 9483526Sxy150489 e1000g_ether_addr_t unicst_addr[MAX_NUM_UNICAST_ADDRESSES]; 9493526Sxy150489 9503526Sxy150489 uint32_t mcast_count; 9519770SChangqing.Li@Sun.COM uint32_t mcast_max_num; 9529770SChangqing.Li@Sun.COM uint32_t mcast_alloc_count; 9539770SChangqing.Li@Sun.COM struct ether_addr *mcast_table; 9543526Sxy150489 9558073SMin.Xu@Sun.COM ulong_t sys_page_sz; 9563526Sxy150489 #ifdef __sparc 9573526Sxy150489 uint_t dvma_page_num; 9583526Sxy150489 #endif 9593526Sxy150489 9606986Smx205022 boolean_t msi_enable; 9616986Smx205022 boolean_t tx_hcksum_enable; 9626986Smx205022 boolean_t lso_enable; 9636986Smx205022 boolean_t lso_premature_issue; 9648417SChenlu.Chen@Sun.COM boolean_t mem_workaround_82546; 9653526Sxy150489 int intr_type; 9663526Sxy150489 int intr_cnt; 9673526Sxy150489 int intr_cap; 9683526Sxy150489 size_t intr_size; 9693526Sxy150489 uint_t intr_pri; 9703526Sxy150489 ddi_intr_handle_t *htable; 9713526Sxy150489 9724919Sxy150489 int tx_softint_pri; 9734919Sxy150489 ddi_softint_handle_t tx_softint_handle; 9744919Sxy150489 9754919Sxy150489 kstat_t *e1000g_ksp; 9764919Sxy150489 9778275SEric Cheng boolean_t poll_mode; 9788275SEric Cheng 9795082Syy150190 uint16_t phy_ctrl; /* contents of PHY_CTRL */ 9805082Syy150190 uint16_t phy_status; /* contents of PHY_STATUS */ 9815082Syy150190 uint16_t phy_an_adv; /* contents of PHY_AUTONEG_ADV */ 9825082Syy150190 uint16_t phy_an_exp; /* contents of PHY_AUTONEG_EXP */ 9835082Syy150190 uint16_t phy_ext_status; /* contents of PHY_EXT_STATUS */ 9845082Syy150190 uint16_t phy_1000t_ctrl; /* contents of PHY_1000T_CTRL */ 9855082Syy150190 uint16_t phy_1000t_status; /* contents of PHY_1000T_STATUS */ 9865082Syy150190 uint16_t phy_lp_able; /* contents of PHY_LP_ABILITY */ 9875082Syy150190 9885273Sgl147354 /* 9895273Sgl147354 * FMA capabilities 9905273Sgl147354 */ 9915273Sgl147354 int fm_capabilities; 9926394Scc210113 9936394Scc210113 uint32_t param_en_1000fdx:1, 9946394Scc210113 param_en_1000hdx:1, 9956394Scc210113 param_en_100fdx:1, 9966394Scc210113 param_en_100hdx:1, 9976394Scc210113 param_en_10fdx:1, 9986394Scc210113 param_en_10hdx:1, 9996512Ssowmini param_autoneg_cap:1, 10006512Ssowmini param_pause_cap:1, 10016512Ssowmini param_asym_pause_cap:1, 10026512Ssowmini param_1000fdx_cap:1, 10036512Ssowmini param_1000hdx_cap:1, 10046512Ssowmini param_100t4_cap:1, 10056512Ssowmini param_100fdx_cap:1, 10066512Ssowmini param_100hdx_cap:1, 10076512Ssowmini param_10fdx_cap:1, 10086512Ssowmini param_10hdx_cap:1, 10096512Ssowmini param_adv_autoneg:1, 10106512Ssowmini param_adv_pause:1, 10116512Ssowmini param_adv_asym_pause:1, 10126512Ssowmini param_adv_1000fdx:1, 10136512Ssowmini param_adv_1000hdx:1, 10146512Ssowmini param_adv_100t4:1, 10156512Ssowmini param_adv_100fdx:1, 10166512Ssowmini param_adv_100hdx:1, 10176512Ssowmini param_adv_10fdx:1, 10186512Ssowmini param_adv_10hdx:1, 10196512Ssowmini param_lp_autoneg:1, 10206512Ssowmini param_lp_pause:1, 10216512Ssowmini param_lp_asym_pause:1, 10226512Ssowmini param_lp_1000fdx:1, 10236512Ssowmini param_lp_1000hdx:1, 10246512Ssowmini param_lp_100t4:1; 10256512Ssowmini 10266512Ssowmini uint32_t param_lp_100fdx:1, 10276512Ssowmini param_lp_100hdx:1, 10286512Ssowmini param_lp_10fdx:1, 10296512Ssowmini param_lp_10hdx:1, 10306512Ssowmini param_pad_to_32:28; 10316512Ssowmini 10324919Sxy150489 } e1000g_t; 10333526Sxy150489 10343526Sxy150489 10353526Sxy150489 /* 10363526Sxy150489 * Function prototypes 10373526Sxy150489 */ 10388850SMin.Xu@Sun.COM void e1000g_free_priv_devi_node(private_devi_list_t *devi_node); 10398850SMin.Xu@Sun.COM void e1000g_free_rx_pending_buffers(e1000g_rx_data_t *rx_data); 10408850SMin.Xu@Sun.COM void e1000g_free_rx_data(e1000g_rx_data_t *rx_data); 10413526Sxy150489 int e1000g_alloc_dma_resources(struct e1000g *Adapter); 10423526Sxy150489 void e1000g_release_dma_resources(struct e1000g *Adapter); 10438850SMin.Xu@Sun.COM void e1000g_free_rx_sw_packet(p_rx_sw_packet_t packet, boolean_t full_release); 10444919Sxy150489 void e1000g_tx_setup(struct e1000g *Adapter); 10454919Sxy150489 void e1000g_rx_setup(struct e1000g *Adapter); 1046*12853SChangqing.Li@Sun.COM int e1000g_increase_rx_packets(e1000g_rx_data_t *rx_data); 10473526Sxy150489 10483526Sxy150489 int e1000g_recycle(e1000g_tx_ring_t *tx_ring); 10494919Sxy150489 void e1000g_free_tx_swpkt(p_tx_sw_packet_t packet); 10504919Sxy150489 void e1000g_tx_freemsg(e1000g_tx_ring_t *tx_ring); 10514919Sxy150489 uint_t e1000g_tx_softint_worker(caddr_t arg1, caddr_t arg2); 10523526Sxy150489 mblk_t *e1000g_m_tx(void *arg, mblk_t *mp); 10538833SVenu.Iyer@Sun.COM mblk_t *e1000g_receive(e1000g_rx_ring_t *rx_ring, mblk_t **tail, uint_t sz); 10544919Sxy150489 void e1000g_rxfree_func(p_rx_sw_packet_t packet); 10553526Sxy150489 10563526Sxy150489 int e1000g_m_stat(void *arg, uint_t stat, uint64_t *val); 10574919Sxy150489 int e1000g_init_stats(struct e1000g *Adapter); 105811878SVenu.Iyer@Sun.COM int e1000g_rx_ring_stat(mac_ring_driver_t, uint_t, uint64_t *); 10594919Sxy150489 void e1000_tbi_adjust_stats(struct e1000g *Adapter, 10604919Sxy150489 uint32_t frame_len, uint8_t *mac_addr); 10613526Sxy150489 10624919Sxy150489 void e1000g_clear_interrupt(struct e1000g *Adapter); 10634919Sxy150489 void e1000g_mask_interrupt(struct e1000g *Adapter); 10644919Sxy150489 void e1000g_clear_all_interrupts(struct e1000g *Adapter); 10654919Sxy150489 void e1000g_clear_tx_interrupt(struct e1000g *Adapter); 10664919Sxy150489 void e1000g_mask_tx_interrupt(struct e1000g *Adapter); 10673526Sxy150489 void phy_spd_state(struct e1000_hw *hw, boolean_t enable); 106810680SMin.Xu@Sun.COM void e1000_destroy_hw_mutex(struct e1000_hw *hw); 10693526Sxy150489 void e1000_enable_pciex_master(struct e1000_hw *hw); 10705273Sgl147354 int e1000g_check_acc_handle(ddi_acc_handle_t handle); 10715273Sgl147354 int e1000g_check_dma_handle(ddi_dma_handle_t handle); 10725273Sgl147354 void e1000g_fm_ereport(struct e1000g *Adapter, char *detail); 107311236SStephen.Hanson@Sun.COM void e1000g_set_fma_flags(int dma_flag); 10746394Scc210113 int e1000g_reset_link(struct e1000g *Adapter); 10756394Scc210113 10763526Sxy150489 /* 10773526Sxy150489 * Global variables 10783526Sxy150489 */ 10794349Sxy150489 extern boolean_t e1000g_force_detach; 10803526Sxy150489 extern uint32_t e1000g_mblks_pending; 10818850SMin.Xu@Sun.COM extern kmutex_t e1000g_rx_detach_lock; 10824982Syy150190 extern private_devi_list_t *e1000g_private_devi_list; 10838275SEric Cheng extern int e1000g_poll_mode; 10843526Sxy150489 10853526Sxy150489 #ifdef __cplusplus 10863526Sxy150489 } 10873526Sxy150489 #endif 10883526Sxy150489 10893526Sxy150489 #endif /* _E1000G_SW_H */ 1090