if_kuereg.h revision 184610
1184610Salfred/*- 2184610Salfred * Copyright (c) 1997, 1998, 1999, 2000 3184610Salfred * Bill Paul <wpaul@ee.columbia.edu>. All rights reserved. 4184610Salfred * 5184610Salfred * Redistribution and use in source and binary forms, with or without 6184610Salfred * modification, are permitted provided that the following conditions 7184610Salfred * are met: 8184610Salfred * 1. Redistributions of source code must retain the above copyright 9184610Salfred * notice, this list of conditions and the following disclaimer. 10184610Salfred * 2. Redistributions in binary form must reproduce the above copyright 11184610Salfred * notice, this list of conditions and the following disclaimer in the 12184610Salfred * documentation and/or other materials provided with the distribution. 13184610Salfred * 3. All advertising materials mentioning features or use of this software 14184610Salfred * must display the following acknowledgement: 15184610Salfred * This product includes software developed by Bill Paul. 16184610Salfred * 4. Neither the name of the author nor the names of any co-contributors 17184610Salfred * may be used to endorse or promote products derived from this software 18184610Salfred * without specific prior written permission. 19184610Salfred * 20184610Salfred * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND 21184610Salfred * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22184610Salfred * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23184610Salfred * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD 24184610Salfred * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25184610Salfred * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26184610Salfred * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27184610Salfred * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28184610Salfred * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29184610Salfred * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 30184610Salfred * THE POSSIBILITY OF SUCH DAMAGE. 31184610Salfred * 32184610Salfred * $FreeBSD: head/sys/dev/usb2/ethernet/if_kue2_reg.h 184610 2008-11-04 02:31:03Z alfred $ 33184610Salfred */ 34184610Salfred 35184610Salfred/* 36184610Salfred * Definitions for the KLSI KL5KUSB101B USB to ethernet controller. 37184610Salfred * The KLSI part is controlled via vendor control requests, the structure 38184610Salfred * of which depend a bit on the firmware running on the internal 39184610Salfred * microcontroller. The one exception is the 'send scan data' command, 40184610Salfred * which is used to load the firmware. 41184610Salfred */ 42184610Salfred 43184610Salfred#define KUE_CMD_GET_ETHER_DESCRIPTOR 0x00 44184610Salfred#define KUE_CMD_SET_MCAST_FILTERS 0x01 45184610Salfred#define KUE_CMD_SET_PKT_FILTER 0x02 46184610Salfred#define KUE_CMD_GET_ETHERSTATS 0x03 47184610Salfred#define KUE_CMD_GET_GPIO 0x04 48184610Salfred#define KUE_CMD_SET_GPIO 0x05 49184610Salfred#define KUE_CMD_SET_MAC 0x06 50184610Salfred#define KUE_CMD_GET_MAC 0x07 51184610Salfred#define KUE_CMD_SET_URB_SIZE 0x08 52184610Salfred#define KUE_CMD_SET_SOFS 0x09 53184610Salfred#define KUE_CMD_SET_EVEN_PKTS 0x0A 54184610Salfred#define KUE_CMD_SEND_SCAN 0xFF 55184610Salfred 56184610Salfredstruct kue_ether_desc { 57184610Salfred uint8_t kue_len; 58184610Salfred uint8_t kue_rsvd0; 59184610Salfred uint8_t kue_rsvd1; 60184610Salfred uint8_t kue_macaddr[ETHER_ADDR_LEN]; 61184610Salfred uint8_t kue_etherstats[4]; 62184610Salfred uint8_t kue_maxseg[2]; 63184610Salfred uint8_t kue_mcastfilt[2]; 64184610Salfred uint8_t kue_rsvd2; 65184610Salfred} __packed; 66184610Salfred 67184610Salfred#define KUE_ETHERSTATS(x) UGETDW((x)->sc_desc.kue_etherstats) 68184610Salfred#define KUE_MAXSEG(x) UGETW((x)->sc_desc.kue_maxseg) 69184610Salfred#define KUE_MCFILTCNT(x) (UGETW((x)->sc_desc.kue_mcastfilt) & 0x7FFF) 70184610Salfred#define KUE_MCFILT_MAX (USB_ETHER_HASH_MAX / ETHER_ADDR_LEN) 71184610Salfred 72184610Salfred#define KUE_STAT_TX_OK 0x00000001 73184610Salfred#define KUE_STAT_RX_OK 0x00000002 74184610Salfred#define KUE_STAT_TX_ERR 0x00000004 75184610Salfred#define KUE_STAT_RX_ERR 0x00000008 76184610Salfred#define KUE_STAT_RX_NOBUF 0x00000010 77184610Salfred#define KUE_STAT_TX_UCAST_BYTES 0x00000020 78184610Salfred#define KUE_STAT_TX_UCAST_FRAMES 0x00000040 79184610Salfred#define KUE_STAT_TX_MCAST_BYTES 0x00000080 80184610Salfred#define KUE_STAT_TX_MCAST_FRAMES 0x00000100 81184610Salfred#define KUE_STAT_TX_BCAST_BYTES 0x00000200 82184610Salfred#define KUE_STAT_TX_BCAST_FRAMES 0x00000400 83184610Salfred#define KUE_STAT_RX_UCAST_BYTES 0x00000800 84184610Salfred#define KUE_STAT_RX_UCAST_FRAMES 0x00001000 85184610Salfred#define KUE_STAT_RX_MCAST_BYTES 0x00002000 86184610Salfred#define KUE_STAT_RX_MCAST_FRAMES 0x00004000 87184610Salfred#define KUE_STAT_RX_BCAST_BYTES 0x00008000 88184610Salfred#define KUE_STAT_RX_BCAST_FRAMES 0x00010000 89184610Salfred#define KUE_STAT_RX_CRCERR 0x00020000 90184610Salfred#define KUE_STAT_TX_QUEUE_LENGTH 0x00040000 91184610Salfred#define KUE_STAT_RX_ALIGNERR 0x00080000 92184610Salfred#define KUE_STAT_TX_SINGLECOLL 0x00100000 93184610Salfred#define KUE_STAT_TX_MULTICOLL 0x00200000 94184610Salfred#define KUE_STAT_TX_DEFERRED 0x00400000 95184610Salfred#define KUE_STAT_TX_MAXCOLLS 0x00800000 96184610Salfred#define KUE_STAT_RX_OVERRUN 0x01000000 97184610Salfred#define KUE_STAT_TX_UNDERRUN 0x02000000 98184610Salfred#define KUE_STAT_TX_SQE_ERR 0x04000000 99184610Salfred#define KUE_STAT_TX_CARRLOSS 0x08000000 100184610Salfred#define KUE_STAT_RX_LATECOLL 0x10000000 101184610Salfred 102184610Salfred#define KUE_RXFILT_PROMISC 0x0001 103184610Salfred#define KUE_RXFILT_ALLMULTI 0x0002 104184610Salfred#define KUE_RXFILT_UNICAST 0x0004 105184610Salfred#define KUE_RXFILT_BROADCAST 0x0008 106184610Salfred#define KUE_RXFILT_MULTICAST 0x0010 107184610Salfred 108184610Salfred#define KUE_TIMEOUT 1000 109184610Salfred#define KUE_MIN_FRAMELEN 60 110184610Salfred 111184610Salfred#define KUE_CTL_READ 0x01 112184610Salfred#define KUE_CTL_WRITE 0x02 113184610Salfred 114184610Salfred#define KUE_CONFIG_IDX 0 /* config number 1 */ 115184610Salfred#define KUE_IFACE_IDX 0 116184610Salfred 117184610Salfred/* The interrupt endpoint is currently unused by the KLSI part. */ 118184610Salfred#define KUE_ENDPT_MAX 4 119184610Salfred 120184610Salfredstruct kue_softc { 121184610Salfred void *sc_evilhack; /* XXX this pointer must be first */ 122184610Salfred 123184610Salfred struct usb2_config_td sc_config_td; 124184610Salfred struct usb2_callout sc_watchdog; 125184610Salfred struct mtx sc_mtx; 126184610Salfred struct kue_ether_desc sc_desc; 127184610Salfred 128184610Salfred struct ifnet *sc_ifp; 129184610Salfred device_t sc_dev; 130184610Salfred struct usb2_device *sc_udev; 131184610Salfred struct usb2_xfer *sc_xfer[KUE_ENDPT_MAX]; 132184610Salfred 133184610Salfred uint32_t sc_unit; 134184610Salfred 135184610Salfred uint16_t sc_mcfilt_max; 136184610Salfred uint16_t sc_flags; 137184610Salfred#define KUE_FLAG_READ_STALL 0x0010 /* wait for clearing of stall */ 138184610Salfred#define KUE_FLAG_WRITE_STALL 0x0020 /* wait for clearing of stall */ 139184610Salfred#define KUE_FLAG_LL_READY 0x0040 /* Lower Layer Ready */ 140184610Salfred#define KUE_FLAG_HL_READY 0x0080 /* Higher Layer Ready */ 141184610Salfred#define KUE_FLAG_INTR_STALL 0x0100 /* wait for clearing of stall */ 142184610Salfred}; 143