cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * CDDL HEADER START
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * The contents of this file are subject to the terms of the
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * Common Development and Distribution License (the "License").
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * You may not use this file except in compliance with the License.
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * or http://www.opensolaris.org/os/licensing.
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * See the License for the specific language governing permissions
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * and limitations under the License.
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * When distributing Covered Code, include this CDDL HEADER in each
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * If applicable, add the following below this CDDL HEADER, with the
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * fields enclosed by brackets "[]" replaced with your own identifying
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * information: Portions Copyright [yyyy] [name of copyright owner]
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * CDDL HEADER END
bbb1277b6ec1b0daad4e3ed1a2b891d3e2ece2ebGarrett D'Amore * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * Use is subject to license terms.
2c6a6ad1e812de6043502f2f52d21711033ab43eIlya Yanok * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * rtls -- REALTEK 8139-serials PCI Fast Ethernet Driver.
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * This product is covered by one or more of the following patents:
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * US5,307,459, US5,434,872, US5,732,094, US6,570,884, US6,115,776, and
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * US6,327,625.
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * Currently supports:
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore/* Debug flags */
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * Driver support device
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore#define RTLS_SUPPORT_DEVICE_1 ((RT_VENDOR_ID << 16) | RT_DEVICE_8139)
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore /* bind vendor and device id together */
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore#define RTLS_SUPPORT_DEVICE_2 ((RTLS_VENDOR_ID_2 << 16) | RTLS_DEVICE_ID_2)
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore#define RTLS_SUPPORT_DEVICE_3 ((RTLS_VENDOR_ID_3 << 16) | RTLS_DEVICE_ID_3)
bbb1277b6ec1b0daad4e3ed1a2b891d3e2ece2ebGarrett D'Amore#define RTLS_SUPPORT_DEVICE_4 ((RTLS_VENDOR_ID_4 << 16) | RTLS_DEVICE_ID_4)
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * Driver tx/rx parameters
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore#define RTLS_RX_BUF_SIZE (RTLS_RX_BUF_RING + 2*1024)
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore#define RTLS_MCAST_BUF_SIZE 64 /* multicast hash table size in bits */
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * RTL8139 CRC poly
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore#define RTLS_HASH_POLY 0x04C11DB7 /* 0x04C11DB6 */
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * STREAMS parameters
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore#define RTLS_HIWAT (RTLS_MAX_TX_DESC * ETHERMAX)
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore /* driver flow control high water */
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore#define RTLS_LOWAT 1 /* driver flow control low water */
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore#define RTLS_IDNUM 0 /* RTL Id; zero works */
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * Helpful defines for register access
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore#define REG32(reg, off) ((uint32_t *)((uintptr_t)(reg) + off))
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore#define REG16(reg, off) ((uint16_t *)((uintptr_t)(reg) + off))
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore#define REG8(reg, off) ((uint8_t *)((uintptr_t)(reg) + off))
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amoretypedef struct {
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore ddi_acc_handle_t acc_hdl; /* handle for memory */
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore ddi_dma_cookie_t cookie; /* associated cookie */
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore uint64_t brdcst_rcv; /* ifInBroadcastPkts */
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore uint32_t no_carrier; /* dot3StatsCarrierSenseErrors */
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore uint32_t xmt_latecoll; /* dot3StatsLateCollisions */
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore uint32_t defer; /* dot3StatsDeferredTransmissions */
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore uint32_t frame_err; /* dot3StatsAlignErrors */
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore caddr_t io_reg; /* mapped chip register address */
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore /* io handle & iblock */
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore ddi_acc_handle_t io_handle; /* ddi I/O handle */
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore /* dma buffer alloc used */
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore dma_area_t dma_area_rx; /* receive dma area */
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore /* transmit dma area */
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore uint8_t netaddr[ETHERADDRL]; /* mac address */
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore /* used for multicast set */
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore /* used for send */
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore uint16_t tx_current_desc; /* Current Tx page */
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore /* used for recv */
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore /* send reschedule used */
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore /* current MAC state */
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore /* rtls statistics */
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore#define RTLS_TX_WAIT_TIMEOUT (void) (drv_usectohz(100 * 1000)) /* 100ms */
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore#define RTLS_RESET_WAIT_INTERVAL (void) (drv_usecwait(100))
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore#define RTLS_RX_ADDR_ALIGNED(addr) (((addr + 3) & ~3) % RTLS_RX_BUF_RING)
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore /* 4-bytes aligned, also with RTLS_RX_BUF_RING boundary */
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore/* parameter definition in rtls.conf file */
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore#define FORCE_AUTO_NEGO 5 /* auto negotioation mode */
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore#define FORCE_100_FDX 4 /* 100 full_duplex mode */
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore#define FORCE_100_HDX 3 /* 100 half_duplex mode */
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore#define FORCE_10_FDX 2 /* 10 full_duplex mode */
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore#define FORCE_10_HDX 1 /* 10 half_duplex mode */
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * RealTek 8129/8139 register offsets definition
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * MAC address register, initial value isautoloaded from the
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * EEPROM EthernetID field
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * Multicast register
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * Transmit status register
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore#define TX_STATUS_CS_LOST 0x80000000 /* Carrier Sense Lost */
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore#define TX_STATUS_TX_ABORT 0x40000000 /* Transmit Abort */
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore#define TX_STATUS_OWC 0x20000000 /* Out of Window Collision */
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore#define TX_STATUS_CDH 0x10000000 /* CD Heart Beat */
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore#define TX_STATUS_NCC 0x0f000000 /* Number of Collision Count */
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore#define TX_STATUS_TX_THRESHOLD 0x003f0000 /* Early Tx Threshold */
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore#define TX_STATUS_TX_THRESHOLD_MAX 0x3f /* 0x3f * 32 Bytes */
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore#define TX_STATUS_TX_OK 0x00008000 /* Transmit OK */
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore#define TX_STATUS_TX_UNDERRUN 0x00004000 /* Transmit FIFO Underrun */
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore#define TX_STATUS_OWN 0x00002000 /* RTL8139 Own bit */
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore /* The total size in bytes of the data in this descriptor */
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * The read-only bits (CRS, TABT, OWC, CDH, NCC3-0, TOK, TUN) will be cleared
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * by the RTL8139 when the Transmit Byte Count (bit12-0) in the corresponding
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * Tx descriptor is written. If h/w transmit finish, at least some of these
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * bits are none zero.
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore#define TX_COMPLETE_FLAG (TX_STATUS_TX_ABORT | TX_STATUS_TX_OK | \
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore#define TX_ERR_FLAG (TX_STATUS_TX_ABORT | TX_STATUS_TX_UNDERRUN | \
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * Transmit start address of descriptors
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * Receive buffer start address
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * Early receive byte count register
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * Commond register
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * Rx current read address register
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * Value in RX_CURRENT_READ_ADDR_REG is 16 less than
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * the actual rx read address
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * Interrupt register
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore#define RTLS_RX_INT (RX_OK_INT | RX_ERR_INT | \
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore#define RX_OVERFLOW_INT (RX_BUF_OVERFLOW_INT | RX_FIFO_OVERFLOW_INT)
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore#define RTLS_INT_MASK (LINK_CHANGE_INT | TX_ERR_INT | TX_OK_INT | \
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore RX_BUF_OVERFLOW_INT | RX_FIFO_OVERFLOW_INT | \
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * Transmit configuration register
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore /* re-transmit count (16 + 1 * 16) = 32 times before aborting */
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore#define TX_CONFIG_DEFAULT (TX_INTERFRAME_GAP_802_3 | \
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * Receive configuration register
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore#define RX_ACCEPT_BROADCAST_PACKET 0x000000008
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore#define RX_ACCEPT_MULTICAST_PACKET 0x000000004
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore#define RX_ACCEPT_MAC_MATCH_PACKET 0x000000002
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore#define RX_CONFIG_DEFAULT (RX_FIFO_THRESHOLD_NONE | \
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * Missed packet counter: indicates the number of packets
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * discarded due to rx FIFO overflow
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * 93c46(93c56) commond register:
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * Configuration registers
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * Media status register
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * Multiple interrupt select register
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * Transmit status of all descriptor registers register
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * Basic mode control register
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * Basic mode status register
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore#define BASIC_MODE_STATUS_AUTONEGO_DONE 0x0020
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore#define BASIC_MODE_STATUS_REMOTE_FAULT 0x0010
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * Auto-negotiation advertisement register
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * Auto-negotiation link partner ability register
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * Auto-negotiation expansion register
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore * Receive status in rx packet header
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore#define RX_ERR_FLAGS (RX_HEADER_STATUS_ISE | RX_HEADER_STATUS_RUNT | \
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore RX_HEADER_STATUS_FAE | RX_HEADER_STATUS_CRC)
cde2885fdf538266ee2a3b08dee2d5075ce8fa2bGarrett D'Amore#endif /* _SYS_RTLS_H */