1f9f848faSopenharmony_ci/*- 2f9f848faSopenharmony_ci * SPDX-License-Identifier: BSD-4-Clause 3f9f848faSopenharmony_ci * 4f9f848faSopenharmony_ci * Copyright (c) 1997, 1998, 1999, 2000-2003 5f9f848faSopenharmony_ci * Bill Paul <wpaul@windriver.com>. All rights reserved. 6f9f848faSopenharmony_ci * 7f9f848faSopenharmony_ci * Redistribution and use in source and binary forms, with or without 8f9f848faSopenharmony_ci * modification, are permitted provided that the following conditions 9f9f848faSopenharmony_ci * are met: 10f9f848faSopenharmony_ci * 1. Redistributions of source code must retain the above copyright 11f9f848faSopenharmony_ci * notice, this list of conditions and the following disclaimer. 12f9f848faSopenharmony_ci * 2. Redistributions in binary form must reproduce the above copyright 13f9f848faSopenharmony_ci * notice, this list of conditions and the following disclaimer in the 14f9f848faSopenharmony_ci * documentation and/or other materials provided with the distribution. 15f9f848faSopenharmony_ci * 3. All advertising materials mentioning features or use of this software 16f9f848faSopenharmony_ci * must display the following acknowledgement: 17f9f848faSopenharmony_ci * This product includes software developed by Bill Paul. 18f9f848faSopenharmony_ci * 4. Neither the name of the author nor the names of any co-contributors 19f9f848faSopenharmony_ci * may be used to endorse or promote products derived from this software 20f9f848faSopenharmony_ci * without specific prior written permission. 21f9f848faSopenharmony_ci * 22f9f848faSopenharmony_ci * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND 23f9f848faSopenharmony_ci * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24f9f848faSopenharmony_ci * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25f9f848faSopenharmony_ci * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD 26f9f848faSopenharmony_ci * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27f9f848faSopenharmony_ci * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28f9f848faSopenharmony_ci * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29f9f848faSopenharmony_ci * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30f9f848faSopenharmony_ci * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31f9f848faSopenharmony_ci * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 32f9f848faSopenharmony_ci * THE POSSIBILITY OF SUCH DAMAGE. 33f9f848faSopenharmony_ci */ 34f9f848faSopenharmony_ci 35f9f848faSopenharmony_ci/* 36f9f848faSopenharmony_ci * Definitions for the ASIX Electronics AX88172, AX88178 37f9f848faSopenharmony_ci * and AX88772 to ethernet controllers. 38f9f848faSopenharmony_ci */ 39f9f848faSopenharmony_ci 40f9f848faSopenharmony_ci/* 41f9f848faSopenharmony_ci * Vendor specific commands. ASIX conveniently doesn't document the 'set 42f9f848faSopenharmony_ci * NODEID' command in their datasheet (thanks a lot guys). 43f9f848faSopenharmony_ci * To make handling these commands easier, I added some extra data which is 44f9f848faSopenharmony_ci * decided by the axe_cmd() routine. Commands are encoded in 16 bits, with 45f9f848faSopenharmony_ci * the format: LDCC. L and D are both nibbles in the high byte. L represents 46f9f848faSopenharmony_ci * the data length (0 to 15) and D represents the direction (0 for vendor read, 47f9f848faSopenharmony_ci * 1 for vendor write). CC is the command byte, as specified in the manual. 48f9f848faSopenharmony_ci */ 49f9f848faSopenharmony_ci 50f9f848faSopenharmony_ci#ifndef LITEOS_USB_AXE_H 51f9f848faSopenharmony_ci#define LITEOS_USB_AXE_H 52f9f848faSopenharmony_ci 53f9f848faSopenharmony_ci#define USB_AXE_MAX_FRAMES 16 54f9f848faSopenharmony_ci#ifndef MCLSHIFT 55f9f848faSopenharmony_ci#define MCLSHIFT 11 /* convert bytes to mbuf clusters */ 56f9f848faSopenharmony_ci#endif /* MCLSHIFT */ 57f9f848faSopenharmony_ci 58f9f848faSopenharmony_ci#ifndef MCLBYTES 59f9f848faSopenharmony_ci#define MCLBYTES (1 << MCLSHIFT) /* size of an mbuf cluster */ 60f9f848faSopenharmony_ci#endif 61f9f848faSopenharmony_ci#define ETHER_TYPE_LEN 2 /* length of the Ethernet type field */ 62f9f848faSopenharmony_ci 63f9f848faSopenharmony_ci#define ETHER_HDR_LEN (NETIF_MAX_HWADDR_LEN*2 + ETHER_TYPE_LEN) 64f9f848faSopenharmony_ci 65f9f848faSopenharmony_ci#define ETHER_ALIGN 2 /* driver adjust for IP hdr alignment */ 66f9f848faSopenharmony_ci 67f9f848faSopenharmony_ci#define AXE_LINK_MASK 0x20 68f9f848faSopenharmony_ci 69f9f848faSopenharmony_ci#define AXE_CMD_IS_WRITE(x) (((x) & 0x0F00) >> 8) 70f9f848faSopenharmony_ci#define AXE_CMD_LEN(x) (((x) & 0xF000) >> 12) 71f9f848faSopenharmony_ci#define AXE_CMD_CMD(x) ((x) & 0x00FF) 72f9f848faSopenharmony_ci 73f9f848faSopenharmony_ci#define AXE_172_CMD_READ_RXTX_SRAM 0x2002 74f9f848faSopenharmony_ci#define AXE_182_CMD_READ_RXTX_SRAM 0x8002 75f9f848faSopenharmony_ci#define AXE_172_CMD_WRITE_RX_SRAM 0x0103 76f9f848faSopenharmony_ci#define AXE_182_CMD_WRITE_RXTX_SRAM 0x8103 77f9f848faSopenharmony_ci#define AXE_172_CMD_WRITE_TX_SRAM 0x0104 78f9f848faSopenharmony_ci#define AXE_CMD_MII_OPMODE_SW 0x0106 79f9f848faSopenharmony_ci#define AXE_CMD_MII_READ_REG 0x2007 80f9f848faSopenharmony_ci#define AXE_CMD_MII_WRITE_REG 0x2108 81f9f848faSopenharmony_ci#define AXE_CMD_MII_READ_OPMODE 0x1009 82f9f848faSopenharmony_ci#define AXE_CMD_MII_OPMODE_HW 0x010A 83f9f848faSopenharmony_ci#define AXE_CMD_SROM_READ 0x200B 84f9f848faSopenharmony_ci#define AXE_CMD_SROM_WRITE 0x010C 85f9f848faSopenharmony_ci#define AXE_CMD_SROM_WR_ENABLE 0x010D 86f9f848faSopenharmony_ci#define AXE_CMD_SROM_WR_DISABLE 0x010E 87f9f848faSopenharmony_ci#define AXE_CMD_RXCTL_READ 0x200F 88f9f848faSopenharmony_ci#define AXE_CMD_RXCTL_WRITE 0x0110 89f9f848faSopenharmony_ci#define AXE_CMD_READ_IPG012 0x3011 90f9f848faSopenharmony_ci#define AXE_172_CMD_WRITE_IPG0 0x0112 91f9f848faSopenharmony_ci#define AXE_178_CMD_WRITE_IPG012 0x0112 92f9f848faSopenharmony_ci#define AXE_172_CMD_WRITE_IPG1 0x0113 93f9f848faSopenharmony_ci#define AXE_178_CMD_READ_NODEID 0x6013 94f9f848faSopenharmony_ci#define AXE_172_CMD_WRITE_IPG2 0x0114 95f9f848faSopenharmony_ci#define AXE_178_CMD_WRITE_NODEID 0x6114 96f9f848faSopenharmony_ci#define AXE_CMD_READ_MCAST 0x8015 97f9f848faSopenharmony_ci#define AXE_CMD_WRITE_MCAST 0x8116 98f9f848faSopenharmony_ci#define AXE_172_CMD_READ_NODEID 0x6017 99f9f848faSopenharmony_ci#define AXE_172_CMD_WRITE_NODEID 0x6118 100f9f848faSopenharmony_ci 101f9f848faSopenharmony_ci#define AXE_CMD_READ_PHYID 0x2019 102f9f848faSopenharmony_ci#define AXE_172_CMD_READ_MEDIA 0x101A 103f9f848faSopenharmony_ci#define AXE_178_CMD_READ_MEDIA 0x201A 104f9f848faSopenharmony_ci#define AXE_CMD_WRITE_MEDIA 0x011B 105f9f848faSopenharmony_ci#define AXE_CMD_READ_MONITOR_MODE 0x101C 106f9f848faSopenharmony_ci#define AXE_CMD_WRITE_MONITOR_MODE 0x011D 107f9f848faSopenharmony_ci#define AXE_CMD_READ_GPIO 0x101E 108f9f848faSopenharmony_ci#define AXE_CMD_WRITE_GPIO 0x011F 109f9f848faSopenharmony_ci 110f9f848faSopenharmony_ci#define AXE_CMD_SW_RESET_REG 0x0120 111f9f848faSopenharmony_ci#define AXE_CMD_SW_PHY_STATUS 0x0021 112f9f848faSopenharmony_ci#define AXE_CMD_SW_PHY_SELECT 0x0122 113f9f848faSopenharmony_ci 114f9f848faSopenharmony_ci/* AX88772A and AX88772B only. */ 115f9f848faSopenharmony_ci#define AXE_CMD_READ_VLAN_CTRL 0x4027 116f9f848faSopenharmony_ci#define AXE_CMD_WRITE_VLAN_CTRL 0x4028 117f9f848faSopenharmony_ci 118f9f848faSopenharmony_ci#define AXE_772B_CMD_RXCTL_WRITE_CFG 0x012A 119f9f848faSopenharmony_ci#define AXE_772B_CMD_READ_RXCSUM 0x002B 120f9f848faSopenharmony_ci#define AXE_772B_CMD_WRITE_RXCSUM 0x012C 121f9f848faSopenharmony_ci#define AXE_772B_CMD_READ_TXCSUM 0x002D 122f9f848faSopenharmony_ci#define AXE_772B_CMD_WRITE_TXCSUM 0x012E 123f9f848faSopenharmony_ci 124f9f848faSopenharmony_ci#define AXE_SW_RESET_CLEAR 0x00 125f9f848faSopenharmony_ci#define AXE_SW_RESET_RR 0x01 126f9f848faSopenharmony_ci#define AXE_SW_RESET_RT 0x02 127f9f848faSopenharmony_ci#define AXE_SW_RESET_PRTE 0x04 128f9f848faSopenharmony_ci#define AXE_SW_RESET_PRL 0x08 129f9f848faSopenharmony_ci#define AXE_SW_RESET_BZ 0x10 130f9f848faSopenharmony_ci#define AXE_SW_RESET_IPRL 0x20 131f9f848faSopenharmony_ci#define AXE_SW_RESET_IPPD 0x40 132f9f848faSopenharmony_ci 133f9f848faSopenharmony_ci/* AX88178 documentation says to always write this bit... */ 134f9f848faSopenharmony_ci#define AXE_178_RESET_MAGIC 0x40 135f9f848faSopenharmony_ci 136f9f848faSopenharmony_ci#define AXE_178_MEDIA_GMII 0x0001 137f9f848faSopenharmony_ci#define AXE_MEDIA_FULL_DUPLEX 0x0002 138f9f848faSopenharmony_ci#define AXE_172_MEDIA_TX_ABORT_ALLOW 0x0004 139f9f848faSopenharmony_ci 140f9f848faSopenharmony_ci/* AX88178/88772 documentation says to always write 1 to bit 2 */ 141f9f848faSopenharmony_ci#define AXE_178_MEDIA_MAGIC 0x0004 142f9f848faSopenharmony_ci/* AX88772 documentation says to always write 0 to bit 3 */ 143f9f848faSopenharmony_ci#define AXE_178_MEDIA_ENCK 0x0008 144f9f848faSopenharmony_ci#define AXE_172_MEDIA_FLOW_CONTROL_EN 0x0010 145f9f848faSopenharmony_ci#define AXE_178_MEDIA_RXFLOW_CONTROL_EN 0x0010 146f9f848faSopenharmony_ci#define AXE_178_MEDIA_TXFLOW_CONTROL_EN 0x0020 147f9f848faSopenharmony_ci#define AXE_178_MEDIA_JUMBO_EN 0x0040 148f9f848faSopenharmony_ci#define AXE_178_MEDIA_LTPF_ONLY 0x0080 149f9f848faSopenharmony_ci#define AXE_178_MEDIA_RX_EN 0x0100 150f9f848faSopenharmony_ci#define AXE_178_MEDIA_100TX 0x0200 151f9f848faSopenharmony_ci#define AXE_178_MEDIA_SBP 0x0800 152f9f848faSopenharmony_ci#define AXE_178_MEDIA_SUPERMAC 0x1000 153f9f848faSopenharmony_ci 154f9f848faSopenharmony_ci#define AXE_RXCMD_PROMISC 0x0001 155f9f848faSopenharmony_ci#define AXE_RXCMD_ALLMULTI 0x0002 156f9f848faSopenharmony_ci#define AXE_172_RXCMD_UNICAST 0x0004 157f9f848faSopenharmony_ci#define AXE_178_RXCMD_KEEP_INVALID_CRC 0x0004 158f9f848faSopenharmony_ci#define AXE_RXCMD_BROADCAST 0x0008 159f9f848faSopenharmony_ci#define AXE_RXCMD_MULTICAST 0x0010 160f9f848faSopenharmony_ci#define AXE_RXCMD_ACCEPT_RUNT 0x0040 /* AX88772B */ 161f9f848faSopenharmony_ci#define AXE_RXCMD_ENABLE 0x0080 162f9f848faSopenharmony_ci#define AXE_178_RXCMD_MFB_MASK 0x0300 163f9f848faSopenharmony_ci#define AXE_178_RXCMD_MFB_2048 0x0000 164f9f848faSopenharmony_ci#define AXE_178_RXCMD_MFB_4096 0x0100 165f9f848faSopenharmony_ci#define AXE_178_RXCMD_MFB_8192 0x0200 166f9f848faSopenharmony_ci#define AXE_178_RXCMD_MFB_16384 0x0300 167f9f848faSopenharmony_ci#define AXE_772B_RXCMD_HDR_TYPE_0 0x0000 168f9f848faSopenharmony_ci#define AXE_772B_RXCMD_HDR_TYPE_1 0x0100 169f9f848faSopenharmony_ci#define AXE_772B_RXCMD_IPHDR_ALIGN 0x0200 170f9f848faSopenharmony_ci#define AXE_772B_RXCMD_ADD_CHKSUM 0x0400 171f9f848faSopenharmony_ci#define AXE_RXCMD_LOOPBACK 0x1000 /* AX88772A/AX88772B */ 172f9f848faSopenharmony_ci 173f9f848faSopenharmony_ci#define AXE_PHY_SEL_PRI 1 174f9f848faSopenharmony_ci#define AXE_PHY_SEL_SEC 0 175f9f848faSopenharmony_ci#define AXE_PHY_TYPE_MASK 0xE0 176f9f848faSopenharmony_ci#define AXE_PHY_TYPE_SHIFT 5 177f9f848faSopenharmony_ci#define AXE_PHY_TYPE(x) \ 178f9f848faSopenharmony_ci (((x) & AXE_PHY_TYPE_MASK) >> AXE_PHY_TYPE_SHIFT) 179f9f848faSopenharmony_ci 180f9f848faSopenharmony_ci#define PHY_TYPE_100_HOME 0 /* 10/100 or 1M HOME PHY */ 181f9f848faSopenharmony_ci#define PHY_TYPE_GIG 1 /* Gigabit PHY */ 182f9f848faSopenharmony_ci#define PHY_TYPE_SPECIAL 4 /* Special case */ 183f9f848faSopenharmony_ci#define PHY_TYPE_RSVD 5 /* Reserved */ 184f9f848faSopenharmony_ci#define PHY_TYPE_NON_SUP 7 /* Non-supported PHY */ 185f9f848faSopenharmony_ci 186f9f848faSopenharmony_ci#define AXE_PHY_NO_MASK 0x1F 187f9f848faSopenharmony_ci#define AXE_PHY_NO(x) ((x) & AXE_PHY_NO_MASK) 188f9f848faSopenharmony_ci 189f9f848faSopenharmony_ci#define AXE_772_PHY_NO_EPHY 0x10 /* Embedded 10/100 PHY of AX88772 */ 190f9f848faSopenharmony_ci 191f9f848faSopenharmony_ci#define AXE_GPIO0_EN 0x01 192f9f848faSopenharmony_ci#define AXE_GPIO0 0x02 193f9f848faSopenharmony_ci#define AXE_GPIO1_EN 0x04 194f9f848faSopenharmony_ci#define AXE_GPIO1 0x08 195f9f848faSopenharmony_ci#define AXE_GPIO2_EN 0x10 196f9f848faSopenharmony_ci#define AXE_GPIO2 0x20 197f9f848faSopenharmony_ci#define AXE_GPIO_RELOAD_EEPROM 0x80 198f9f848faSopenharmony_ci 199f9f848faSopenharmony_ci#define AXE_PHY_MODE_MARVELL 0x00 200f9f848faSopenharmony_ci#define AXE_PHY_MODE_CICADA 0x01 201f9f848faSopenharmony_ci#define AXE_PHY_MODE_AGERE 0x02 202f9f848faSopenharmony_ci#define AXE_PHY_MODE_CICADA_V2 0x05 203f9f848faSopenharmony_ci#define AXE_PHY_MODE_AGERE_GMII 0x06 204f9f848faSopenharmony_ci#define AXE_PHY_MODE_CICADA_V2_ASIX 0x09 205f9f848faSopenharmony_ci#define AXE_PHY_MODE_REALTEK_8211CL 0x0C 206f9f848faSopenharmony_ci#define AXE_PHY_MODE_REALTEK_8211BN 0x0D 207f9f848faSopenharmony_ci#define AXE_PHY_MODE_REALTEK_8251CL 0x0E 208f9f848faSopenharmony_ci#define AXE_PHY_MODE_ATTANSIC 0x40 209f9f848faSopenharmony_ci 210f9f848faSopenharmony_ci/* AX88772A/AX88772B only. */ 211f9f848faSopenharmony_ci#define AXE_SW_PHY_SELECT_EXT 0x0000 212f9f848faSopenharmony_ci#define AXE_SW_PHY_SELECT_EMBEDDED 0x0001 213f9f848faSopenharmony_ci#define AXE_SW_PHY_SELECT_AUTO 0x0002 214f9f848faSopenharmony_ci#define AXE_SW_PHY_SELECT_SS_MII 0x0004 215f9f848faSopenharmony_ci#define AXE_SW_PHY_SELECT_SS_RVRS_MII 0x0008 216f9f848faSopenharmony_ci#define AXE_SW_PHY_SELECT_SS_RVRS_RMII 0x000C 217f9f848faSopenharmony_ci#define AXE_SW_PHY_SELECT_SS_ENB 0x0010 218f9f848faSopenharmony_ci 219f9f848faSopenharmony_ci/* AX88772A/AX88772B VLAN control. */ 220f9f848faSopenharmony_ci#define AXE_VLAN_CTRL_ENB 0x00001000 221f9f848faSopenharmony_ci#define AXE_VLAN_CTRL_STRIP 0x00002000 222f9f848faSopenharmony_ci#define AXE_VLAN_CTRL_VID1_MASK 0x00000FFF 223f9f848faSopenharmony_ci#define AXE_VLAN_CTRL_VID2_MASK 0x0FFF0000 224f9f848faSopenharmony_ci 225f9f848faSopenharmony_ci#define AXE_RXCSUM_IP 0x0001 226f9f848faSopenharmony_ci#define AXE_RXCSUM_IPVE 0x0002 227f9f848faSopenharmony_ci#define AXE_RXCSUM_IPV6E 0x0004 228f9f848faSopenharmony_ci#define AXE_RXCSUM_TCP 0x0008 229f9f848faSopenharmony_ci#define AXE_RXCSUM_UDP 0x0010 230f9f848faSopenharmony_ci#define AXE_RXCSUM_ICMP 0x0020 231f9f848faSopenharmony_ci#define AXE_RXCSUM_IGMP 0x0040 232f9f848faSopenharmony_ci#define AXE_RXCSUM_ICMP6 0x0080 233f9f848faSopenharmony_ci#define AXE_RXCSUM_TCPV6 0x0100 234f9f848faSopenharmony_ci#define AXE_RXCSUM_UDPV6 0x0200 235f9f848faSopenharmony_ci#define AXE_RXCSUM_ICMPV6 0x0400 236f9f848faSopenharmony_ci#define AXE_RXCSUM_IGMPV6 0x0800 237f9f848faSopenharmony_ci#define AXE_RXCSUM_ICMP6V6 0x1000 238f9f848faSopenharmony_ci#define AXE_RXCSUM_FOPC 0x8000 239f9f848faSopenharmony_ci 240f9f848faSopenharmony_ci#define AXE_RXCSUM_64TE 0x0100 241f9f848faSopenharmony_ci#define AXE_RXCSUM_PPPOE 0x0200 242f9f848faSopenharmony_ci#define AXE_RXCSUM_RPCE 0x8000 243f9f848faSopenharmony_ci 244f9f848faSopenharmony_ci#define AXE_TXCSUM_IP 0x0001 245f9f848faSopenharmony_ci#define AXE_TXCSUM_TCP 0x0002 246f9f848faSopenharmony_ci#define AXE_TXCSUM_UDP 0x0004 247f9f848faSopenharmony_ci#define AXE_TXCSUM_ICMP 0x0008 248f9f848faSopenharmony_ci#define AXE_TXCSUM_IGMP 0x0010 249f9f848faSopenharmony_ci#define AXE_TXCSUM_ICMP6 0x0020 250f9f848faSopenharmony_ci#define AXE_TXCSUM_TCPV6 0x0100 251f9f848faSopenharmony_ci#define AXE_TXCSUM_UDPV6 0x0200 252f9f848faSopenharmony_ci#define AXE_TXCSUM_ICMPV6 0x0400 253f9f848faSopenharmony_ci#define AXE_TXCSUM_IGMPV6 0x0800 254f9f848faSopenharmony_ci#define AXE_TXCSUM_ICMP6V6 0x1000 255f9f848faSopenharmony_ci 256f9f848faSopenharmony_ci#define AXE_TXCSUM_64TE 0x0001 257f9f848faSopenharmony_ci#define AXE_TXCSUM_PPPOE 0x0002 258f9f848faSopenharmony_ci 259f9f848faSopenharmony_ci#define AXE_BULK_BUF_SIZE 16384 /* bytes */ 260f9f848faSopenharmony_ci 261f9f848faSopenharmony_ci#define AXE_CTL_READ 0x01 262f9f848faSopenharmony_ci#define AXE_CTL_WRITE 0x02 263f9f848faSopenharmony_ci 264f9f848faSopenharmony_ci#define AXE_CONFIG_IDX 0 /* config number 1 */ 265f9f848faSopenharmony_ci#define AXE_IFACE_IDX 0 266f9f848faSopenharmony_ci 267f9f848faSopenharmony_ci/* EEPROM Map. */ 268f9f848faSopenharmony_ci#define AXE_EEPROM_772B_NODE_ID 0x04 269f9f848faSopenharmony_ci#define AXE_EEPROM_772B_PHY_PWRCFG 0x18 270f9f848faSopenharmony_ci 271f9f848faSopenharmony_cistruct ax88772b_mfb { 272f9f848faSopenharmony_ci int byte_cnt; 273f9f848faSopenharmony_ci int threshold; 274f9f848faSopenharmony_ci int size; 275f9f848faSopenharmony_ci}; 276f9f848faSopenharmony_ci#define AX88772B_MFB_2K 0 277f9f848faSopenharmony_ci#define AX88772B_MFB_4K 1 278f9f848faSopenharmony_ci#define AX88772B_MFB_6K 2 279f9f848faSopenharmony_ci#define AX88772B_MFB_8K 3 280f9f848faSopenharmony_ci#define AX88772B_MFB_16K 4 281f9f848faSopenharmony_ci#define AX88772B_MFB_20K 5 282f9f848faSopenharmony_ci#define AX88772B_MFB_24K 6 283f9f848faSopenharmony_ci#define AX88772B_MFB_32K 7 284f9f848faSopenharmony_ci 285f9f848faSopenharmony_cistruct axe_sframe_hdr { 286f9f848faSopenharmony_ci uint16_t len; 287f9f848faSopenharmony_ci#define AXE_HDR_LEN_MASK 0xFFFF 288f9f848faSopenharmony_ci uint16_t ilen; 289f9f848faSopenharmony_ci} __packed; 290f9f848faSopenharmony_ci 291f9f848faSopenharmony_ci#define AXE_TX_CSUM_PSEUDO_HDR 0x4000 292f9f848faSopenharmony_ci#define AXE_TX_CSUM_DIS 0x8000 293f9f848faSopenharmony_ci 294f9f848faSopenharmony_ci/* 295f9f848faSopenharmony_ci * When RX checksum offloading is enabled, AX88772B uses new RX header 296f9f848faSopenharmony_ci * format and it's not compatible with previous RX header format. In 297f9f848faSopenharmony_ci * addition, IP header align option should be enabled to get correct 298f9f848faSopenharmony_ci * frame size including RX header. Total transferred size including 299f9f848faSopenharmony_ci * the RX header is multiple of 4 and controller will pad necessary 300f9f848faSopenharmony_ci * bytes if the length is not multiple of 4. 301f9f848faSopenharmony_ci * This driver does not enable partial checksum feature which will 302f9f848faSopenharmony_ci * compute 16bit checksum from 14th byte to the end of the frame. If 303f9f848faSopenharmony_ci * this feature is enabled, computed checksum value is embedded into 304f9f848faSopenharmony_ci * RX header which in turn means it uses different RX header format. 305f9f848faSopenharmony_ci */ 306f9f848faSopenharmony_cistruct axe_csum_hdr { 307f9f848faSopenharmony_ci uint16_t len; 308f9f848faSopenharmony_ci#define AXE_CSUM_HDR_LEN_MASK 0x07FF 309f9f848faSopenharmony_ci#define AXE_CSUM_HDR_CRC_ERR 0x1000 310f9f848faSopenharmony_ci#define AXE_CSUM_HDR_MII_ERR 0x2000 311f9f848faSopenharmony_ci#define AXE_CSUM_HDR_RUNT 0x4000 312f9f848faSopenharmony_ci#define AXE_CSUM_HDR_BMCAST 0x8000 313f9f848faSopenharmony_ci uint16_t ilen; 314f9f848faSopenharmony_ci uint16_t cstatus; 315f9f848faSopenharmony_ci#define AXE_CSUM_HDR_VLAN_MASK 0x0007 316f9f848faSopenharmony_ci#define AXE_CSUM_HDR_VLAN_STRIP 0x0008 317f9f848faSopenharmony_ci#define AXE_CSUM_HDR_VLAN_PRI_MASK 0x0070 318f9f848faSopenharmony_ci#define AXE_CSUM_HDR_L4_CSUM_ERR 0x0100 319f9f848faSopenharmony_ci#define AXE_CSUM_HDR_L3_CSUM_ERR 0x0200 320f9f848faSopenharmony_ci#define AXE_CSUM_HDR_L4_TYPE_UDP 0x0400 321f9f848faSopenharmony_ci#define AXE_CSUM_HDR_L4_TYPE_ICMP 0x0800 322f9f848faSopenharmony_ci#define AXE_CSUM_HDR_L4_TYPE_IGMP 0x0C00 323f9f848faSopenharmony_ci#define AXE_CSUM_HDR_L4_TYPE_TCP 0x1000 324f9f848faSopenharmony_ci#define AXE_CSUM_HDR_L4_TYPE_TCPV6 0x1400 325f9f848faSopenharmony_ci#define AXE_CSUM_HDR_L4_TYPE_MASK 0x1C00 326f9f848faSopenharmony_ci#define AXE_CSUM_HDR_L3_TYPE_IPV4 0x2000 327f9f848faSopenharmony_ci#define AXE_CSUM_HDR_L3_TYPE_IPV6 0x4000 328f9f848faSopenharmony_ci 329f9f848faSopenharmony_ci#ifdef AXE_APPEND_PARTIAL_CSUM 330f9f848faSopenharmony_ci /* 331f9f848faSopenharmony_ci * These members present only when partial checksum 332f9f848faSopenharmony_ci * offloading is enabled. The checksum value is simple 333f9f848faSopenharmony_ci * 16bit sum of received frame starting at offset 14 of 334f9f848faSopenharmony_ci * the frame to the end of the frame excluding FCS bytes. 335f9f848faSopenharmony_ci */ 336f9f848faSopenharmony_ci uint16_t csum_value; 337f9f848faSopenharmony_ci uint16_t dummy; 338f9f848faSopenharmony_ci#endif 339f9f848faSopenharmony_ci} __packed; 340f9f848faSopenharmony_ci 341f9f848faSopenharmony_ci#define AXE_CSUM_RXBYTES(x) ((x) & AXE_CSUM_HDR_LEN_MASK) 342f9f848faSopenharmony_ci 343f9f848faSopenharmony_ci#define GET_MII(sc) uether_getmii(&(sc)->sc_ue) 344f9f848faSopenharmony_ci 345f9f848faSopenharmony_ci/* The interrupt endpoint is currently unused by the ASIX part. */ 346f9f848faSopenharmony_cienum { 347f9f848faSopenharmony_ci AXE_BULK_DT_WR, 348f9f848faSopenharmony_ci AXE_BULK_DT_RD, 349f9f848faSopenharmony_ci AXE_N_TRANSFER, 350f9f848faSopenharmony_ci}; 351f9f848faSopenharmony_ci 352f9f848faSopenharmony_cistruct axe_softc { 353f9f848faSopenharmony_ci struct usb_ether sc_ue; 354f9f848faSopenharmony_ci struct mtx sc_mtx; 355f9f848faSopenharmony_ci struct usb_xfer *sc_xfer[AXE_N_TRANSFER]; 356f9f848faSopenharmony_ci int sc_phyno; 357f9f848faSopenharmony_ci 358f9f848faSopenharmony_ci unsigned int sc_flags; 359f9f848faSopenharmony_ci uint16_t sc_link_status; 360f9f848faSopenharmony_ci#define AXE_FLAG_LINK 0x0001 361f9f848faSopenharmony_ci#define AXE_FLAG_STD_FRAME 0x0010 362f9f848faSopenharmony_ci#define AXE_FLAG_CSUM_FRAME 0x0020 363f9f848faSopenharmony_ci#define AXE_FLAG_772 0x1000 /* AX88772 */ 364f9f848faSopenharmony_ci#define AXE_FLAG_772A 0x2000 /* AX88772A */ 365f9f848faSopenharmony_ci#define AXE_FLAG_772B 0x4000 /* AX88772B */ 366f9f848faSopenharmony_ci#define AXE_FLAG_178 0x8000 /* AX88178 */ 367f9f848faSopenharmony_ci 368f9f848faSopenharmony_ci uint8_t sc_ipgs[3]; 369f9f848faSopenharmony_ci uint8_t sc_phyaddrs[2]; 370f9f848faSopenharmony_ci uint16_t sc_pwrcfg; 371f9f848faSopenharmony_ci uint16_t sc_lenmask; 372f9f848faSopenharmony_ci uint8_t rx_chklink_cnt; 373f9f848faSopenharmony_ci#define EVENT_LINK 0x00000001 374f9f848faSopenharmony_ci}; 375f9f848faSopenharmony_ci 376f9f848faSopenharmony_ci#define AXE_IS_178_FAMILY(sc) \ 377f9f848faSopenharmony_ci ((sc)->sc_flags & (AXE_FLAG_772 | AXE_FLAG_772A | AXE_FLAG_772B | \ 378f9f848faSopenharmony_ci AXE_FLAG_178)) 379f9f848faSopenharmony_ci 380f9f848faSopenharmony_ci#define AXE_IS_772(sc) \ 381f9f848faSopenharmony_ci ((sc)->sc_flags & (AXE_FLAG_772 | AXE_FLAG_772A | AXE_FLAG_772B)) 382f9f848faSopenharmony_ci 383f9f848faSopenharmony_ci#define AXE_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx) 384f9f848faSopenharmony_ci#define AXE_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_mtx) 385f9f848faSopenharmony_ci#define AXE_LOCK_ASSERT(_sc, t) mtx_assert(&(_sc)->sc_mtx, t) 386f9f848faSopenharmony_ci#endif 387