2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders/*
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders * CDDL HEADER START
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders *
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders * The contents of this file are subject to the terms of the
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders * Common Development and Distribution License (the "License").
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders * You may not use this file except in compliance with the License.
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders *
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders * or http://www.opensolaris.org/os/licensing.
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders * See the License for the specific language governing permissions
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders * and limitations under the License.
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders *
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders * When distributing Covered Code, include this CDDL HEADER in each
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders * If applicable, add the following below this CDDL HEADER, with the
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders * fields enclosed by brackets "[]" replaced with your own identifying
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders * information: Portions Copyright [yyyy] [name of copyright owner]
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders *
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders * CDDL HEADER END
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders */
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders/*
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders * Use is subject to license terms.
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders */
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#ifndef _VR_H
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define _VR_H
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#ifdef __cplusplus
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders extern "C" {
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#endif
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders/*
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders * Number of descriptor entries for each ring. The no. of descriptors is bound
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders * to 4K per ring (256 entries a 16 bytes).
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders */
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_TX_N_DESC 128
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_RX_N_DESC 256
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders/*
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders * The number of TX interrupts to "schedule" on the ring.
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders */
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_TX_INTRS_RING 3
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders/*
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders * The the periodic check interval of 2 seconds, in nano seconds
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders */
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_CHECK_INTERVAL (2000 * 1000 * 1000)
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders/*
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders * The number of TX checks that must pass without progress before we decide
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders * to reset the adapter.
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders */
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_MAXTXCHECKS 12
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders/*
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders * All possible interrupts with the unwanted commented.
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders */
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_ICR0_CFG (VR_ICR0_RX_DONE | \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_ICR0_TX_DONE | \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_ICR0_RX_ERR | \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_ICR0_TX_ERR | \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_ICR0_TX_BUF_UFLOW| \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_ICR0_RX_LINKERR | \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_ICR0_BUSERR | \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders /* VR_ICR0_STATSMAX | */ \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders /* VR_ICR0_RX_EARLY | */ \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_ICR0_TX_FIFO_UFLOW | \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_ICR0_RX_FIFO_OFLOW | \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_ICR0_RX_DROPPED | \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_ICR0_RX_NOBUF | \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_ICR0_TX_ABORT | \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_ICR0_LINKSTATUS | \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_ICR0_GENERAL)
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_ICR1_CFG (/* VR_ICR1_TIMER0 | */ \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders /* VR_ICR1_TIMER1 | */ \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders /* VR_ICR1_PHYEVENT | */ \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders /* VR_ICR1_TDERR | */ \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders /* VR_ICR1_SSRCI | */ \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders /* VR_ICR1_UINTR_SET| */ \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders /* VR_ICR1_UINTR_CLR| */ \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders /* VR_ICR1_PWEI */)
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders/*
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders * Our definitions of RX and TX errors.
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders */
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_ISR_TX_ERR_BITS (VR_ICR0_TX_ERR | \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_ICR0_TX_BUF_UFLOW | \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_ICR0_TX_FIFO_UFLOW | \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_ICR0_TX_ABORT)
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_ISR_RX_ERR_BITS (VR_ICR0_RX_ERR | \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_ICR0_RX_LINKERR | \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_ICR0_RX_FIFO_OFLOW | \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_ICR0_RX_DROPPED | \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_ICR0_RX_NOBUF)
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_ISR_SYS_ERR_BITS (VR_ICR0_BUSERR)
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_ISR_ERR_BITS (VR_ISR_TX_ERR_BITS | \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_ISR_RX_ERR_BITS | \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_ISR_SYS_ERR_BITS)
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_TX_MAX_INTR_DISTANCE \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders (VR_TX_N_DESC / VR_TX_INTRS_RING)
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define MODULENAME "vr" /* Our name */
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_SLOPSZ 2
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_MAX_PKTSZ (ETHERMAX + ETHERFCSL + VLAN_TAGSZ + VR_SLOPSZ)
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_DMABUFSZ (VR_MAX_PKTSZ)
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_MMI_WAITINCR (10)
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_MMI_WAITMAX (10000)
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_CAM_SZ (32)
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders/*
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders * PCI identification for the Rhine's.
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders */
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_PCI_VIA_VENID 0x1106
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_PCI_DEVID_RHINE 0x3043
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_PCI_DEVID_RHINE_IIIM 0x3053
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_PCI_DEVID_RHINE_II2 0x3065
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_PCI_DEVID_RHINE_III 0x3106
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_PCI_DEVID_RHINE_II 0x6100
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_PCI_REVID_VT86C100A_E 0x04
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_PCI_REVID_VT6102_A 0x40
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_PCI_REVID_VT6102_C 0x42
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_PCI_REVID_VT6105_A0 0x80
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_PCI_REVID_VT6105_B0 0x83
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_PCI_REVID_VT6105_LOM 0x8A
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_PCI_REVID_VT6107_A0 0x8C
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_PCI_REVID_VT6107_A1 0x8D
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_PCI_REVID_VT6105M_A0 0x90
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_PCI_REVID_VT6105M_B1 0x94
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders/*
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders * Feature bits for the different cards.
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders */
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_FEATURE_NONE (0)
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_FEATURE_RX_PAUSE_CAP (1 << 0) /* can receive pauses */
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_FEATURE_TX_PAUSE_CAP (1 << 1) /* can transmit pauses */
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_FEATURE_MRDLNMULTIPLE (1 << 2) /* can read mult cache lines */
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_FEATURE_TXCHKSUM (1 << 3) /* can do TX TCP checksum */
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_FEATURE_RXCHKSUM (1 << 4) /* can do RX TCP checksum */
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_FEATURE_CAMSUPPORT (1 << 5) /* has a CAM filter */
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_FEATURE_VLANTAGGING (1 << 6) /* can do VLAN tagging */
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_FEATURE_MIBCOUNTER (1 << 7) /* has a MIB counter */
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders/*
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders * Bug bits for the different cards.
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders */
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_BUG_NONE (0)
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_BUG_TXALIGN (1 << 0) /* needs aligned TX */
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_BUG_NEEDMODE10T (1 << 1) /* chip needs mode10t secret */
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_BUG_NEEDMIION (1 << 2) /* chip needs miion secret */
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_BUG_NEEDMODE2PCEROPT (1 << 3) /* chip needs pceropt */
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_BUG_NO_TXQUEUEING (1 << 4) /* chip cannot queue tx */
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_BUG_NO_MEMIO (1 << 5) /* chip cannot memory space */
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_BUG_MIIPOLLSTOP (1 << 6) /* special to stop polling */
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_GET8(acc, p) \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders ddi_get8((acc)->hdl, \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders (uint8_t *)((void *)((acc)->addr + (p))))
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_GET16(acc, p) \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders ddi_get16((acc)->hdl, \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders (uint16_t *)((void *)((acc)->addr + (p))))
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_GET32(acc, p) \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders ddi_get32((acc)->hdl, \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders (uint32_t *)((void *)((acc)->addr + (p))))
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_PUT8(acc, p, v) \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders ddi_put8((acc)->hdl, \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders (uint8_t *)((void *)((acc)->addr + (p))), v)
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_PUT16(acc, p, v) \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders ddi_put16((acc)->hdl, \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders (uint16_t *)((void *)((acc)->addr + (p))), v)
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_PUT32(acc, p, v) \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders ddi_put32((acc)->hdl, \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders (uint32_t *)((void *)((acc)->addr + (p))), v)
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders/*
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders * Clear bit b in register r.
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders */
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_CLRBIT8(acc, r, b) \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_PUT8(acc, r, VR_GET8(acc, r) & ~(b))
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_CLRBIT16(acc, r, b) \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_PUT16(acc, r, VR_GET16(acc, r) & ~(b))
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_CLRBIT32(acc, r, b) \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_PUT32(acc, r, VR_GET32(acc, r) & ~(b))
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders/*
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders * Set bit b in register r.
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders */
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_SETBIT8(acc, r, b) \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_PUT8(acc, r, (VR_GET8(acc, r) | (b)))
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_SETBIT16(acc, r, b) \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_PUT16(acc, r, (VR_GET16(acc, r) | (b)))
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_SETBIT32(acc, r, b) \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_PUT32(acc, r, (VR_GET32(acc, r) | (b)))
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders/*
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders * Set bits b in register r to value v.
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders */
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_SETBITS8(acc, r, b, v) \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_PUT8(acc, r, (VR_GET8(acc, r) & ~(b)) | (v))
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_SETBITS16(acc, r, b, v) \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_PUT16(acc, r, (VR_GET16(acc, r) & ~(b)) | (v))
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#define VR_SETBITS32(acc, r, b, v) \
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_PUT32(acc, r, (VR_GET32(acc, r) & ~(b)) | (v))
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders/*
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders * The descriptor as used by the MAC.
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders */
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulderstypedef struct {
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint32_t stat0;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint32_t stat1;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint32_t data;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint32_t next;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders} vr_chip_desc_t;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders/*
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders * A structure describing an DMA object.
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders */
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulderstypedef struct data_dma {
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders ddi_dma_handle_t handle;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders ddi_acc_handle_t acchdl;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint32_t paddr;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders char *buf;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders size_t bufsz;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders} vr_data_dma_t;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders/*
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders * A descriptor as used by the host.
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders */
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulderstypedef struct vr_desc {
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders vr_chip_desc_t *cdesc;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint32_t paddr; /* paddr of cdesc */
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint32_t offset; /* offset to paddr */
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders struct vr_desc *next;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders vr_data_dma_t dmabuf;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders} vr_desc_t;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulderstypedef struct vr_ring {
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders vr_desc_t *desc;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders vr_chip_desc_t *cdesc;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint32_t cdesc_paddr;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders ddi_dma_handle_t handle;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders ddi_acc_handle_t acchdl;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders} vr_ring_t;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulderstypedef struct {
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders kmutex_t lock;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint32_t ndesc;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint32_t nfree;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint32_t stallticks;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint32_t resched;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint32_t intr_distance;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders vr_desc_t *ring;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders vr_desc_t *wp; /* write pointer */
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders vr_desc_t *cp; /* claim pointer */
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders} vr_tx_t;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulderstypedef struct {
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint32_t ndesc;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders vr_desc_t *ring;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders vr_desc_t *rp; /* read pointer */
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders} vr_rx_t;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulderstypedef enum {
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_LINK_STATE_UNKNOWN = LINK_STATE_UNKNOWN,
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_LINK_STATE_DOWN = LINK_STATE_DOWN,
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_LINK_STATE_UP = LINK_STATE_UP
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders} vr_link_state_t;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulderstypedef enum {
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_LINK_SPEED_UNKNOWN,
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_LINK_SPEED_10MBS,
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_LINK_SPEED_100MBS
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders} vr_link_speed_t;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulderstypedef enum {
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_LINK_DUPLEX_UNKNOWN = LINK_DUPLEX_UNKNOWN,
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_LINK_DUPLEX_FULL = LINK_DUPLEX_FULL,
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_LINK_DUPLEX_HALF = LINK_DUPLEX_HALF
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders} vr_link_duplex_t;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulderstypedef enum {
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_LINK_AUTONEG_UNKNOWN,
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_LINK_AUTONEG_OFF,
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_LINK_AUTONEG_ON
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders} vr_link_autoneg_t;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders/*
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders * Pause variations.
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders */
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulderstypedef enum {
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_PAUSE_UNKNOWN,
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_PAUSE_NONE = LINK_FLOWCTRL_NONE,
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_PAUSE_TRANSMIT = LINK_FLOWCTRL_TX,
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_PAUSE_RECEIVE = LINK_FLOWCTRL_RX,
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_PAUSE_BIDIRECTIONAL = LINK_FLOWCTRL_BI
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders} vr_link_flowctrl_t;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders/*
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders * Type of medium attachement unit.
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders */
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulderstypedef enum {
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_MAU_UNKNOWN = XCVR_UNDEFINED,
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_MAU_NONE = XCVR_NONE,
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_MAU_10 = XCVR_10,
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_MAU_100T4 = XCVR_100T4,
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_MAU_100X = XCVR_100X,
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_MAU_100T2 = XCVR_100T2,
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_MAU_1000X = XCVR_1000X,
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_MAU_1000T = XCVR_1000T
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders} vr_mau_t;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulderstypedef struct {
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders vr_link_state_t state;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders vr_link_speed_t speed;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders vr_link_duplex_t duplex;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders vr_link_flowctrl_t flowctrl;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders vr_mau_t mau;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders} vr_link_t;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulderstypedef enum {
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders CHIPSTATE_UNKNOWN,
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders CHIPSTATE_INITIALIZED,
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders CHIPSTATE_RUNNING,
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders CHIPSTATE_STOPPED,
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders CHIPSTATE_SLEEPING,
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders CHIPSTATE_SUSPENDED,
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders CHIPSTATE_SUSPENDED_RUNNING,
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders CHIPSTATE_ERROR
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders} vr_chip_state_t;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulderstypedef struct {
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint16_t control;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint16_t status;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint16_t identh;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint16_t identl;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint16_t anadv;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint16_t lpable;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint16_t anexp;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders} mii_t;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders/*
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders * A structure defining the various types of cards and their habits.
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders */
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulderstypedef struct {
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint8_t revmin;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint8_t revmax;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders char name[128];
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint32_t bugs;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint32_t features;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders} chip_info_t;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders/*
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders * A structure describing the card.
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders */
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulderstypedef struct {
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint16_t vendor;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint16_t device;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint8_t revision;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders vr_chip_state_t state;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders mii_t mii;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders vr_link_t link;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders chip_info_t info;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint32_t phyaddr;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders} vr_chip_t;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders/*
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders * Operational parameters.
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders */
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulderstypedef struct {
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint16_t anadv_en;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint16_t an_phymask;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint16_t an_macmask;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders vr_link_autoneg_t an_en;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint32_t mtu;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders} vr_param_t;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulderstypedef enum {
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_SUCCESS = 0,
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders VR_FAILURE = 1
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders} vr_result_t;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulderstypedef struct {
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint64_t ether_stat_align_errors;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint64_t ether_stat_carrier_errors;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint64_t ether_stat_ex_collisions;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint64_t ether_stat_fcs_errors;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint64_t ether_stat_first_collisions;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint64_t ether_stat_macrcv_errors;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint64_t ether_stat_macxmt_errors;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint64_t ether_stat_multi_collisions;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint64_t ether_stat_toolong_errors;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint64_t ether_stat_tooshort_errors;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint64_t ether_stat_tx_late_collisions;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint64_t ether_stat_defer_xmts;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint64_t mac_stat_brdcstrcv;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint64_t mac_stat_brdcstxmt;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint64_t mac_stat_multixmt;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint64_t mac_stat_collisions;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint64_t mac_stat_ierrors;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint64_t mac_stat_ipackets;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint64_t mac_stat_multircv;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint64_t mac_stat_norcvbuf;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint64_t mac_stat_noxmtbuf;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint64_t mac_stat_obytes;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint64_t mac_stat_opackets;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint64_t mac_stat_rbytes;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint64_t mac_stat_underflows;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint64_t mac_stat_overflows;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint64_t cyclics;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint64_t txchecks;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint64_t intr_claimed;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint64_t intr_unclaimed;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint64_t linkchanges;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint64_t txcpybytes;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint64_t txmapbytes;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint64_t rxcpybytes;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint64_t rxmapbytes;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint64_t txreclaim0;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint64_t txreclaims;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint32_t txstalls;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint32_t resets;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint32_t allocbfail;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders} vr_stats_t;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders/*
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders * Access attributes for the card.
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders */
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulderstypedef struct {
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders ddi_acc_handle_t hdl;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders caddr_t addr;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders pci_regspec_t reg;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders} vr_acc_t;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders/*
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders * Instance state structure.
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders */
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulderstypedef struct {
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders kmutex_t oplock;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders dev_info_t *devinfo;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint8_t vendor_ether_addr [ETHERADDRL];
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders char ifname[12];
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders mac_handle_t machdl;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders ddi_intr_handle_t intr_hdl;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint_t intr_pri;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders kmutex_t intrlock;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders vr_chip_t chip;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders vr_ring_t txring;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders vr_ring_t rxring;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders vr_rx_t rx;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders vr_tx_t tx;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders ddi_periodic_t periodic_id;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders int nsets;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders vr_acc_t *regset;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders vr_acc_t *acc_mem;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders vr_acc_t *acc_io;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders vr_acc_t *acc_cfg;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders vr_acc_t *acc_reg;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders vr_param_t param;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders vr_stats_t stats;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders struct kstat *ksp;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders vr_param_t defaults;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint32_t promisc;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint32_t mhash0;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint32_t mhash1;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint32_t mcount;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint32_t reset;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders} vr_t;
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders/*
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders * Function prototypes.
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders */
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Muldersint vr_mac_getstat(void *arg, uint_t stat, uint64_t *val);
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Muldersint vr_mac_start(void *vrp);
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Muldersvoid vr_mac_stop(void *vrp);
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Muldersint vr_mac_set_promisc(void *vrp, boolean_t promiscflag);
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Muldersint vr_mac_set_multicast(void *vrp, boolean_t add,
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders const uint8_t *mca);
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Muldersint vr_mac_set_ether_addr(void *vrp,
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders const uint8_t *macaddr);
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Muldersmblk_t *vr_mac_tx_enqueue_list(void *p, mblk_t *mp);
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Muldersint vr_mac_getprop(void *arg, const char *pr_name,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer mac_prop_id_t pr_num, uint_t pr_valsize,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer void *pr_val);
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Muldersint vr_mac_setprop(void *arg, const char *pr_name,
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders mac_prop_id_t pr_num,
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders uint_t pr_valsize, const void *pr_val);
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyervoid vr_mac_propinfo(void *arg, const char *pr_name,
0dc2366f7b9f9f36e10909b1e95edbf2a261c2acVenugopal Iyer mac_prop_id_t pr_num, mac_prop_info_handle_t prh);
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Muldersuint_t vr_intr(caddr_t arg1, caddr_t arg2);
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#ifdef __cplusplus
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders}
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#endif
2ca5b6595b95478e6568b0e77c6c83c8a870867aJoost Mulders#endif /* _VR_H */