1015a6ef6SSaurabh Misra /* 2015a6ef6SSaurabh Misra * CDDL HEADER START 3015a6ef6SSaurabh Misra * 4015a6ef6SSaurabh Misra * The contents of this file are subject to the terms of the 5015a6ef6SSaurabh Misra * Common Development and Distribution License (the "License"). 6015a6ef6SSaurabh Misra * You may not use this file except in compliance with the License. 7015a6ef6SSaurabh Misra * 8015a6ef6SSaurabh Misra * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9015a6ef6SSaurabh Misra * or http://www.opensolaris.org/os/licensing. 10015a6ef6SSaurabh Misra * See the License for the specific language governing permissions 11015a6ef6SSaurabh Misra * and limitations under the License. 12015a6ef6SSaurabh Misra * 13015a6ef6SSaurabh Misra * When distributing Covered Code, include this CDDL HEADER in each 14015a6ef6SSaurabh Misra * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15015a6ef6SSaurabh Misra * If applicable, add the following below this CDDL HEADER, with the 16015a6ef6SSaurabh Misra * fields enclosed by brackets "[]" replaced with your own identifying 17015a6ef6SSaurabh Misra * information: Portions Copyright [yyyy] [name of copyright owner] 18015a6ef6SSaurabh Misra * 19015a6ef6SSaurabh Misra * CDDL HEADER END 20015a6ef6SSaurabh Misra */ 21015a6ef6SSaurabh Misra /* 22*5e8715b9SGary Mills * Copyright (c) 2012 Gary Mills 23*5e8715b9SGary Mills * 240dc2366fSVenugopal Iyer * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 25015a6ef6SSaurabh Misra * Use is subject to license terms. 26015a6ef6SSaurabh Misra */ 27015a6ef6SSaurabh Misra 28015a6ef6SSaurabh Misra #ifndef _ATGE_H 29015a6ef6SSaurabh Misra #define _ATGE_H 30015a6ef6SSaurabh Misra 31015a6ef6SSaurabh Misra #ifdef __cplusplus 32015a6ef6SSaurabh Misra extern "C" { 33015a6ef6SSaurabh Misra #endif 34015a6ef6SSaurabh Misra 350dc2366fSVenugopal Iyer #include <sys/ethernet.h> 36015a6ef6SSaurabh Misra #include <sys/mac_provider.h> 37015a6ef6SSaurabh Misra #include "atge_l1e_reg.h" 38*5e8715b9SGary Mills #include "atge_l1c_reg.h" 39015a6ef6SSaurabh Misra 40015a6ef6SSaurabh Misra #define ATGE_PCI_REG_NUMBER 1 41015a6ef6SSaurabh Misra 42015a6ef6SSaurabh Misra #define ROUNDUP(x, a) (((x) + (a) - 1) & ~((a) - 1)) 43015a6ef6SSaurabh Misra 44015a6ef6SSaurabh Misra /* 45015a6ef6SSaurabh Misra * Flags. 46015a6ef6SSaurabh Misra */ 47015a6ef6SSaurabh Misra #define ATGE_FLAG_PCIE 0x0001 48015a6ef6SSaurabh Misra #define ATGE_FIXED_TYPE 0x0002 49015a6ef6SSaurabh Misra #define ATGE_MSI_TYPE 0x0004 50015a6ef6SSaurabh Misra #define ATGE_MSIX_TYPE 0x0008 51015a6ef6SSaurabh Misra #define ATGE_FLAG_FASTETHER 0x0010 52015a6ef6SSaurabh Misra #define ATGE_FLAG_JUMBO 0x0020 530eb090a7SSaurabh Misra #define ATGE_MII_CHECK 0x0040 54*5e8715b9SGary Mills #define ATGE_FLAG_ASPM_MON 0x0080 55*5e8715b9SGary Mills #define ATGE_FLAG_CMB_BUG 0x0100 56*5e8715b9SGary Mills #define ATGE_FLAG_SMB_BUG 0x0200 57*5e8715b9SGary Mills #define ATGE_FLAG_APS 0x1000 58015a6ef6SSaurabh Misra 59015a6ef6SSaurabh Misra #define ATGE_CHIP_L1_DEV_ID 0x1048 60015a6ef6SSaurabh Misra #define ATGE_CHIP_L2_DEV_ID 0x2048 61015a6ef6SSaurabh Misra #define ATGE_CHIP_L1E_DEV_ID 0x1026 62*5e8715b9SGary Mills #define ATGE_CHIP_L1CG_DEV_ID 0x1063 63*5e8715b9SGary Mills #define ATGE_CHIP_L1CF_DEV_ID 0x1062 64*5e8715b9SGary Mills #define ATGE_CHIP_AR8151V1_DEV_ID 0x1073 65*5e8715b9SGary Mills #define ATGE_CHIP_AR8151V2_DEV_ID 0x1083 66*5e8715b9SGary Mills #define ATGE_CHIP_AR8152V1_DEV_ID 0x2060 67*5e8715b9SGary Mills #define ATGE_CHIP_AR8152V2_DEV_ID 0x2062 68015a6ef6SSaurabh Misra 69015a6ef6SSaurabh Misra #define ATGE_PROMISC 0x001 70015a6ef6SSaurabh Misra #define ATGE_ALL_MULTICST 0x002 71015a6ef6SSaurabh Misra 72015a6ef6SSaurabh Misra /* 73015a6ef6SSaurabh Misra * Timer for one second interval. 74015a6ef6SSaurabh Misra */ 75015a6ef6SSaurabh Misra #define ATGE_TIMER_INTERVAL (1000 * 1000 * 1000) 76015a6ef6SSaurabh Misra 77015a6ef6SSaurabh Misra /* 78015a6ef6SSaurabh Misra * Chip state. 79015a6ef6SSaurabh Misra */ 80015a6ef6SSaurabh Misra #define ATGE_CHIP_INITIALIZED 0x0001 81015a6ef6SSaurabh Misra #define ATGE_CHIP_RUNNING 0x0002 82015a6ef6SSaurabh Misra #define ATGE_CHIP_STOPPED 0x0004 83015a6ef6SSaurabh Misra #define ATGE_CHIP_SUSPENDED 0x0008 84015a6ef6SSaurabh Misra 85015a6ef6SSaurabh Misra #define ETHER_CRC_LEN 0x4 86015a6ef6SSaurabh Misra 87015a6ef6SSaurabh Misra /* 88015a6ef6SSaurabh Misra * Descriptor increment and decrment operation. 89015a6ef6SSaurabh Misra */ 900eb090a7SSaurabh Misra #define ATGE_INC_SLOT(x, y) \ 910eb090a7SSaurabh Misra ((x) = ((x) + 1) % (y)) 920eb090a7SSaurabh Misra 930eb090a7SSaurabh Misra #define ATGE_DEC_SLOT(x, y) \ 940eb090a7SSaurabh Misra (x = ((x + y - 1) % y)) 95015a6ef6SSaurabh Misra 96015a6ef6SSaurabh Misra /* 97015a6ef6SSaurabh Misra * I/O instructions 98015a6ef6SSaurabh Misra */ 99015a6ef6SSaurabh Misra #define OUTB(atge, p, v) \ 100015a6ef6SSaurabh Misra ddi_put8((atge)->atge_io_handle, \ 101015a6ef6SSaurabh Misra (void *)((caddr_t)((atge)->atge_io_regs) + (p)), v) 102015a6ef6SSaurabh Misra 103015a6ef6SSaurabh Misra #define OUTW(atge, p, v) \ 104015a6ef6SSaurabh Misra ddi_put16((atge)->atge_io_handle, \ 105015a6ef6SSaurabh Misra (void *)((caddr_t)((atge)->atge_io_regs) + (p)), v) 106015a6ef6SSaurabh Misra 107015a6ef6SSaurabh Misra #define OUTL(atge, p, v) \ 108015a6ef6SSaurabh Misra ddi_put32((atge)->atge_io_handle, \ 109015a6ef6SSaurabh Misra (void *)((caddr_t)((atge)->atge_io_regs) + (p)), v) 110015a6ef6SSaurabh Misra 111015a6ef6SSaurabh Misra #define INB(atge, p) \ 112015a6ef6SSaurabh Misra ddi_get8((atge)->atge_io_handle, \ 113015a6ef6SSaurabh Misra (void *)(((caddr_t)(atge)->atge_io_regs) + (p))) 114015a6ef6SSaurabh Misra #define INW(atge, p) \ 115015a6ef6SSaurabh Misra ddi_get16((atge)->atge_io_handle, \ 116015a6ef6SSaurabh Misra (void *)(((caddr_t)(atge)->atge_io_regs) + (p))) 117015a6ef6SSaurabh Misra 118015a6ef6SSaurabh Misra #define INL(atge, p) \ 119015a6ef6SSaurabh Misra ddi_get32((atge)->atge_io_handle, \ 120015a6ef6SSaurabh Misra (void *)(((caddr_t)(atge)->atge_io_regs) + (p))) 121015a6ef6SSaurabh Misra 122015a6ef6SSaurabh Misra #define FLUSH(atge, reg) \ 123015a6ef6SSaurabh Misra (void) INL(atge, reg) 124015a6ef6SSaurabh Misra 125015a6ef6SSaurabh Misra #define OUTL_OR(atge, reg, v) \ 126015a6ef6SSaurabh Misra OUTL(atge, reg, (INL(atge, reg) | v)) 127015a6ef6SSaurabh Misra 128015a6ef6SSaurabh Misra #define OUTL_AND(atge, reg, v) \ 129015a6ef6SSaurabh Misra OUTL(atge, reg, (INL(atge, reg) & v)) 130015a6ef6SSaurabh Misra 131015a6ef6SSaurabh Misra /* 132015a6ef6SSaurabh Misra * Descriptor and other endianess aware access. 133015a6ef6SSaurabh Misra */ 134015a6ef6SSaurabh Misra #define ATGE_PUT64(dma, addr, v) \ 135015a6ef6SSaurabh Misra ddi_put64(dma->acchdl, (addr), (v)) 136015a6ef6SSaurabh Misra 137015a6ef6SSaurabh Misra #define ATGE_PUT32(dma, addr, v) \ 138015a6ef6SSaurabh Misra ddi_put32(dma->acchdl, (addr), (v)) 139015a6ef6SSaurabh Misra 140015a6ef6SSaurabh Misra #define ATGE_GET32(dma, addr) \ 141015a6ef6SSaurabh Misra ddi_get32(dma->acchdl, (addr)) 142015a6ef6SSaurabh Misra 143015a6ef6SSaurabh Misra #define ATGE_GET64(dma, addr) \ 144015a6ef6SSaurabh Misra ddi_get64(dma->acchdl, (addr)) 145015a6ef6SSaurabh Misra 146015a6ef6SSaurabh Misra #define DMA_SYNC(dma, s, l, d) \ 147015a6ef6SSaurabh Misra (void) ddi_dma_sync(dma->hdl, (off_t)(s), (l), d) 148015a6ef6SSaurabh Misra 149015a6ef6SSaurabh Misra 150015a6ef6SSaurabh Misra #define ATGE_ADDR_LO(x) ((uint64_t)(x) & 0xFFFFFFFF) 151015a6ef6SSaurabh Misra #define ATGE_ADDR_HI(x) ((uint64_t)(x) >> 32) 152015a6ef6SSaurabh Misra 153015a6ef6SSaurabh Misra 154015a6ef6SSaurabh Misra /* 155015a6ef6SSaurabh Misra * General purpose macros. 156015a6ef6SSaurabh Misra */ 157015a6ef6SSaurabh Misra #define ATGE_MODEL(atgep) atgep->atge_model 158*5e8715b9SGary Mills #define ATGE_VID(atgep) atgep->atge_vid 159*5e8715b9SGary Mills #define ATGE_DID(atgep) atgep->atge_did 160015a6ef6SSaurabh Misra 161015a6ef6SSaurabh Misra /* 162015a6ef6SSaurabh Misra * Different type of chip models. 163015a6ef6SSaurabh Misra */ 164015a6ef6SSaurabh Misra typedef enum { 165015a6ef6SSaurabh Misra ATGE_CHIP_L1 = 1, 166015a6ef6SSaurabh Misra ATGE_CHIP_L2, 167015a6ef6SSaurabh Misra ATGE_CHIP_L1E, 168*5e8715b9SGary Mills ATGE_CHIP_L1C, 169015a6ef6SSaurabh Misra } atge_model_t; 170015a6ef6SSaurabh Misra 171015a6ef6SSaurabh Misra typedef struct atge_cards { 172015a6ef6SSaurabh Misra uint16_t vendor_id; /* PCI vendor id */ 173015a6ef6SSaurabh Misra uint16_t device_id; /* PCI device id */ 174015a6ef6SSaurabh Misra char *cardname; /* Description of the card */ 175015a6ef6SSaurabh Misra atge_model_t model; /* Model of the card */ 176015a6ef6SSaurabh Misra } atge_cards_t; 177015a6ef6SSaurabh Misra 178015a6ef6SSaurabh Misra /* 179015a6ef6SSaurabh Misra * Number of Descriptors for TX and RX Ring. 180015a6ef6SSaurabh Misra */ 181015a6ef6SSaurabh Misra #define ATGE_TX_NUM_DESC 256 182015a6ef6SSaurabh Misra #define ATGE_RX_NUM_DESC 256 183015a6ef6SSaurabh Misra 184015a6ef6SSaurabh Misra /* 185015a6ef6SSaurabh Misra * DMA Handle for all DMA work. 186015a6ef6SSaurabh Misra */ 187015a6ef6SSaurabh Misra typedef struct atge_dma_data { 188015a6ef6SSaurabh Misra ddi_dma_handle_t hdl; 189015a6ef6SSaurabh Misra ddi_acc_handle_t acchdl; 190015a6ef6SSaurabh Misra ddi_dma_cookie_t cookie; 191015a6ef6SSaurabh Misra caddr_t addr; 192015a6ef6SSaurabh Misra size_t len; 193015a6ef6SSaurabh Misra uint_t count; 194015a6ef6SSaurabh Misra } atge_dma_t; 195015a6ef6SSaurabh Misra 196015a6ef6SSaurabh Misra struct atge; 197015a6ef6SSaurabh Misra 198015a6ef6SSaurabh Misra /* 199015a6ef6SSaurabh Misra * Structure for ring data (TX/RX). 200015a6ef6SSaurabh Misra */ 201015a6ef6SSaurabh Misra typedef struct atge_ring { 202015a6ef6SSaurabh Misra struct atge *r_atge; 203015a6ef6SSaurabh Misra atge_dma_t **r_buf_tbl; 204015a6ef6SSaurabh Misra atge_dma_t *r_desc_ring; 205015a6ef6SSaurabh Misra int r_ndesc; 206015a6ef6SSaurabh Misra int r_consumer; 207015a6ef6SSaurabh Misra int r_producer; 208015a6ef6SSaurabh Misra int r_avail_desc; 209015a6ef6SSaurabh Misra } atge_ring_t; 210015a6ef6SSaurabh Misra 211015a6ef6SSaurabh Misra /* 212015a6ef6SSaurabh Misra * L1E specific private data. 213015a6ef6SSaurabh Misra */ 214015a6ef6SSaurabh Misra typedef struct atge_l1e_data { 215015a6ef6SSaurabh Misra atge_dma_t **atge_l1e_rx_page; 216015a6ef6SSaurabh Misra atge_dma_t *atge_l1e_rx_cmb; 217015a6ef6SSaurabh Misra int atge_l1e_pagesize; 218015a6ef6SSaurabh Misra int atge_l1e_rx_curp; 219015a6ef6SSaurabh Misra uint16_t atge_l1e_rx_seqno; 220015a6ef6SSaurabh Misra uint32_t atge_l1e_proc_max; 221015a6ef6SSaurabh Misra uint32_t atge_l1e_rx_page_cons; 222015a6ef6SSaurabh Misra uint32_t atge_l1e_rx_page_prods[L1E_RX_PAGES]; 223015a6ef6SSaurabh Misra } atge_l1e_data_t; 224015a6ef6SSaurabh Misra 225015a6ef6SSaurabh Misra /* 2260eb090a7SSaurabh Misra * L1 specific private data. 2270eb090a7SSaurabh Misra */ 2280eb090a7SSaurabh Misra typedef struct atge_l1_data { 2290eb090a7SSaurabh Misra atge_ring_t *atge_rx_ring; 2300eb090a7SSaurabh Misra atge_dma_t *atge_l1_cmb; 2310eb090a7SSaurabh Misra atge_dma_t *atge_l1_rr; 2320eb090a7SSaurabh Misra atge_dma_t *atge_l1_smb; 2330eb090a7SSaurabh Misra int atge_l1_rr_consumers; 2340eb090a7SSaurabh Misra uint32_t atge_l1_intr_status; 2350eb090a7SSaurabh Misra uint32_t atge_l1_rx_prod_cons; 2360eb090a7SSaurabh Misra uint32_t atge_l1_tx_prod_cons; 2370eb090a7SSaurabh Misra } atge_l1_data_t; 2380eb090a7SSaurabh Misra 2390eb090a7SSaurabh Misra /* 240*5e8715b9SGary Mills * L1C specific private data. 241*5e8715b9SGary Mills */ 242*5e8715b9SGary Mills typedef struct atge_l1c_data { 243*5e8715b9SGary Mills atge_ring_t *atge_rx_ring; 244*5e8715b9SGary Mills atge_dma_t *atge_l1c_cmb; 245*5e8715b9SGary Mills atge_dma_t *atge_l1c_rr; 246*5e8715b9SGary Mills atge_dma_t *atge_l1c_smb; 247*5e8715b9SGary Mills int atge_l1c_rr_consumers; 248*5e8715b9SGary Mills uint32_t atge_l1c_intr_status; 249*5e8715b9SGary Mills uint32_t atge_l1c_rx_prod_cons; 250*5e8715b9SGary Mills uint32_t atge_l1c_tx_prod_cons; 251*5e8715b9SGary Mills } atge_l1c_data_t; 252*5e8715b9SGary Mills 253*5e8715b9SGary Mills /* 2540eb090a7SSaurabh Misra * TX descriptor table is same with L1, L1E and L2E chips. 2550eb090a7SSaurabh Misra */ 2560eb090a7SSaurabh Misra #pragma pack(1) 2570eb090a7SSaurabh Misra typedef struct atge_tx_desc { 2580eb090a7SSaurabh Misra uint64_t addr; 2590eb090a7SSaurabh Misra uint32_t len; 2600eb090a7SSaurabh Misra uint32_t flags; 2610eb090a7SSaurabh Misra } atge_tx_desc_t; 2620eb090a7SSaurabh Misra #pragma pack() 2630eb090a7SSaurabh Misra 2640eb090a7SSaurabh Misra #define ATGE_TX_RING_CNT 256 2650eb090a7SSaurabh Misra #define ATGE_TX_RING_SZ \ 2660eb090a7SSaurabh Misra (sizeof (struct atge_tx_desc) * ATGE_TX_RING_CNT) 2670eb090a7SSaurabh Misra 2680eb090a7SSaurabh Misra /* 269015a6ef6SSaurabh Misra * Private instance data structure (per-instance soft-state). 270015a6ef6SSaurabh Misra */ 271015a6ef6SSaurabh Misra typedef struct atge { 272015a6ef6SSaurabh Misra /* 273015a6ef6SSaurabh Misra * Lock for the TX ring, RX ring and interrupt. In order to align 274015a6ef6SSaurabh Misra * these locks at 8-byte boundary, we have kept it at the beginning 275015a6ef6SSaurabh Misra * of atge_t. 276015a6ef6SSaurabh Misra */ 277015a6ef6SSaurabh Misra kmutex_t atge_tx_lock; 278015a6ef6SSaurabh Misra kmutex_t atge_rx_lock; 279015a6ef6SSaurabh Misra kmutex_t atge_intr_lock; 280015a6ef6SSaurabh Misra kmutex_t atge_mii_lock; 2810eb090a7SSaurabh Misra kmutex_t atge_mbox_lock; 282015a6ef6SSaurabh Misra 283015a6ef6SSaurabh Misra /* 284015a6ef6SSaurabh Misra * Instance number and devinfo pointer. 285015a6ef6SSaurabh Misra */ 286015a6ef6SSaurabh Misra int atge_unit; 287015a6ef6SSaurabh Misra dev_info_t *atge_dip; 288015a6ef6SSaurabh Misra char atge_name[8]; 289015a6ef6SSaurabh Misra atge_model_t atge_model; 290*5e8715b9SGary Mills uint16_t atge_vid; 291*5e8715b9SGary Mills uint16_t atge_did; 292015a6ef6SSaurabh Misra int atge_chip_rev; 293015a6ef6SSaurabh Misra uint8_t atge_revid; 294015a6ef6SSaurabh Misra 295015a6ef6SSaurabh Misra /* 296015a6ef6SSaurabh Misra * Mac handle. 297015a6ef6SSaurabh Misra */ 298015a6ef6SSaurabh Misra mac_handle_t atge_mh; 299015a6ef6SSaurabh Misra 300015a6ef6SSaurabh Misra /* 301015a6ef6SSaurabh Misra * MII layer handle. 302015a6ef6SSaurabh Misra */ 303015a6ef6SSaurabh Misra mii_handle_t atge_mii; 304015a6ef6SSaurabh Misra link_state_t atge_link_state; 305015a6ef6SSaurabh Misra 306015a6ef6SSaurabh Misra /* 307015a6ef6SSaurabh Misra * Config Space Handle. 308015a6ef6SSaurabh Misra */ 309015a6ef6SSaurabh Misra ddi_acc_handle_t atge_conf_handle; 310015a6ef6SSaurabh Misra 311015a6ef6SSaurabh Misra /* 312015a6ef6SSaurabh Misra * IO registers mapped by DDI. 313015a6ef6SSaurabh Misra */ 314015a6ef6SSaurabh Misra ddi_acc_handle_t atge_io_handle; 315015a6ef6SSaurabh Misra caddr_t atge_io_regs; 316015a6ef6SSaurabh Misra uint_t atge_intrs; 317015a6ef6SSaurabh Misra 318015a6ef6SSaurabh Misra /* 319015a6ef6SSaurabh Misra * Interrupt management structures. 320015a6ef6SSaurabh Misra */ 321015a6ef6SSaurabh Misra ddi_intr_handle_t *atge_intr_handle; 322015a6ef6SSaurabh Misra int atge_intr_types; 323015a6ef6SSaurabh Misra int atge_intr_cnt; 324015a6ef6SSaurabh Misra uint_t atge_intr_pri; 325015a6ef6SSaurabh Misra int atge_intr_size; 326015a6ef6SSaurabh Misra int atge_intr_cap; 327015a6ef6SSaurabh Misra 328015a6ef6SSaurabh Misra /* 329015a6ef6SSaurabh Misra * Common structures. 330015a6ef6SSaurabh Misra */ 331015a6ef6SSaurabh Misra atge_ring_t *atge_tx_ring; 332015a6ef6SSaurabh Misra int atge_tx_resched; 333015a6ef6SSaurabh Misra int atge_mtu; 334015a6ef6SSaurabh Misra int atge_int_mod; 335*5e8715b9SGary Mills int atge_int_rx_mod; /* L1C */ 336*5e8715b9SGary Mills int atge_int_tx_mod; /* L1C */ 337015a6ef6SSaurabh Misra int atge_max_frame_size; 338015a6ef6SSaurabh Misra 3390eb090a7SSaurabh Misra 340015a6ef6SSaurabh Misra /* 341015a6ef6SSaurabh Misra * Ethernet addresses. 342015a6ef6SSaurabh Misra */ 343015a6ef6SSaurabh Misra ether_addr_t atge_ether_addr; 344015a6ef6SSaurabh Misra ether_addr_t atge_dev_addr; 345015a6ef6SSaurabh Misra uint64_t atge_mchash; 346015a6ef6SSaurabh Misra uint32_t atge_mchash_ref_cnt[64]; 347015a6ef6SSaurabh Misra 348015a6ef6SSaurabh Misra /* 349015a6ef6SSaurabh Misra * PHY register. 350015a6ef6SSaurabh Misra */ 351015a6ef6SSaurabh Misra int atge_phyaddr; 352015a6ef6SSaurabh Misra 353015a6ef6SSaurabh Misra /* 354015a6ef6SSaurabh Misra * Flags. 355015a6ef6SSaurabh Misra */ 356015a6ef6SSaurabh Misra int atge_flags; 357015a6ef6SSaurabh Misra uint32_t atge_dma_rd_burst; 358015a6ef6SSaurabh Misra uint32_t atge_dma_wr_burst; 359015a6ef6SSaurabh Misra int atge_filter_flags; 360015a6ef6SSaurabh Misra int atge_chip_state; 361015a6ef6SSaurabh Misra 362015a6ef6SSaurabh Misra /* 363015a6ef6SSaurabh Misra * Private data for the chip. 364015a6ef6SSaurabh Misra */ 365015a6ef6SSaurabh Misra void *atge_private_data; 366015a6ef6SSaurabh Misra 367015a6ef6SSaurabh Misra /* 368015a6ef6SSaurabh Misra * Buffer length. 369015a6ef6SSaurabh Misra */ 370015a6ef6SSaurabh Misra int atge_rx_buf_len; 371015a6ef6SSaurabh Misra int atge_tx_buf_len; 372015a6ef6SSaurabh Misra 373015a6ef6SSaurabh Misra /* 374015a6ef6SSaurabh Misra * Common stats. 375015a6ef6SSaurabh Misra */ 376015a6ef6SSaurabh Misra void *atge_hw_stats; 377015a6ef6SSaurabh Misra uint64_t atge_ipackets; 378015a6ef6SSaurabh Misra uint64_t atge_opackets; 379015a6ef6SSaurabh Misra uint64_t atge_rbytes; 380015a6ef6SSaurabh Misra uint64_t atge_obytes; 381015a6ef6SSaurabh Misra uint64_t atge_brdcstxmt; 382015a6ef6SSaurabh Misra uint64_t atge_multixmt; 383015a6ef6SSaurabh Misra uint64_t atge_brdcstrcv; 384015a6ef6SSaurabh Misra uint64_t atge_multircv; 385015a6ef6SSaurabh Misra unsigned atge_norcvbuf; 386015a6ef6SSaurabh Misra unsigned atge_errrcv; 387015a6ef6SSaurabh Misra unsigned atge_errxmt; 388015a6ef6SSaurabh Misra unsigned atge_missed; 389015a6ef6SSaurabh Misra unsigned atge_underflow; 390015a6ef6SSaurabh Misra unsigned atge_overflow; 391015a6ef6SSaurabh Misra unsigned atge_align_errors; 392015a6ef6SSaurabh Misra unsigned atge_fcs_errors; 393015a6ef6SSaurabh Misra unsigned atge_carrier_errors; 394015a6ef6SSaurabh Misra unsigned atge_collisions; 395015a6ef6SSaurabh Misra unsigned atge_ex_collisions; 396015a6ef6SSaurabh Misra unsigned atge_tx_late_collisions; 397015a6ef6SSaurabh Misra unsigned atge_defer_xmts; 398015a6ef6SSaurabh Misra unsigned atge_first_collisions; 399015a6ef6SSaurabh Misra unsigned atge_multi_collisions; 400015a6ef6SSaurabh Misra unsigned atge_sqe_errors; 401015a6ef6SSaurabh Misra unsigned atge_macxmt_errors; 402015a6ef6SSaurabh Misra unsigned atge_macrcv_errors; 403015a6ef6SSaurabh Misra unsigned atge_toolong_errors; 404015a6ef6SSaurabh Misra unsigned atge_runt; 405015a6ef6SSaurabh Misra unsigned atge_jabber; 406015a6ef6SSaurabh Misra unsigned atge_noxmtbuf; 407015a6ef6SSaurabh Misra } atge_t; 408015a6ef6SSaurabh Misra 409015a6ef6SSaurabh Misra /* 410015a6ef6SSaurabh Misra * extern functions. 411015a6ef6SSaurabh Misra */ 412015a6ef6SSaurabh Misra extern void atge_error(dev_info_t *, char *, ...); 413015a6ef6SSaurabh Misra 414015a6ef6SSaurabh Misra /* 415015a6ef6SSaurabh Misra * Debugging Support. 416015a6ef6SSaurabh Misra */ 417015a6ef6SSaurabh Misra #ifdef DEBUG 418015a6ef6SSaurabh Misra #define ATGE_DB(arg) atge_debug_func arg 419015a6ef6SSaurabh Misra #else 420015a6ef6SSaurabh Misra #define ATGE_DB(arg) 421015a6ef6SSaurabh Misra #endif 422015a6ef6SSaurabh Misra 423015a6ef6SSaurabh Misra extern int atge_debug; 424015a6ef6SSaurabh Misra extern void atge_debug_func(char *, ...); 425015a6ef6SSaurabh Misra extern atge_dma_t *atge_alloc_a_dma_blk(atge_t *, ddi_dma_attr_t *, 426015a6ef6SSaurabh Misra int, int); 427015a6ef6SSaurabh Misra extern void atge_free_a_dma_blk(atge_dma_t *); 428015a6ef6SSaurabh Misra extern atge_dma_t *atge_buf_alloc(atge_t *, size_t, int); 429015a6ef6SSaurabh Misra extern void atge_buf_free(atge_dma_t *); 430015a6ef6SSaurabh Misra extern mblk_t *atge_get_mblk(int); 431015a6ef6SSaurabh Misra extern void atge_device_restart(atge_t *); 432015a6ef6SSaurabh Misra extern int atge_alloc_buffers(atge_ring_t *, size_t, size_t, int); 433015a6ef6SSaurabh Misra extern void atge_free_buffers(atge_ring_t *, size_t); 434015a6ef6SSaurabh Misra extern void atge_stop_timer(atge_t *); 435015a6ef6SSaurabh Misra extern void atge_start_timer(atge_t *); 436015a6ef6SSaurabh Misra extern void atge_mii_write(void *, uint8_t, uint8_t, uint16_t); 4370eb090a7SSaurabh Misra extern uint16_t atge_mii_read(void *, uint8_t, uint8_t); 4380eb090a7SSaurabh Misra extern void atge_device_stop(atge_t *); 4390eb090a7SSaurabh Misra extern void atge_tx_reclaim(atge_t *, int); 4400eb090a7SSaurabh Misra 441015a6ef6SSaurabh Misra 442015a6ef6SSaurabh Misra #ifdef __cplusplus 443015a6ef6SSaurabh Misra } 444015a6ef6SSaurabh Misra #endif 445015a6ef6SSaurabh Misra 446015a6ef6SSaurabh Misra #endif /* _ATGE_H */ 447