Deleted Added
full compact
if_axe.c (215966) if_axe.c (215968)
1/*-
2 * Copyright (c) 1997, 1998, 1999, 2000-2003
3 * Bill Paul <wpaul@windriver.com>. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30 * THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1997, 1998, 1999, 2000-2003
3 * Bill Paul <wpaul@windriver.com>. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30 * THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#include <sys/cdefs.h>
34__FBSDID("$FreeBSD: head/sys/dev/usb/net/if_axe.c 215966 2010-11-28 01:16:37Z yongari $");
34__FBSDID("$FreeBSD: head/sys/dev/usb/net/if_axe.c 215968 2010-11-28 01:43:28Z yongari $");
35
36/*
37 * ASIX Electronics AX88172/AX88178/AX88778 USB 2.0 ethernet driver.
38 * Used in the LinkSys USB200M and various other adapters.
39 *
40 * Manuals available from:
41 * http://www.asix.com.tw/datasheet/mac/Ax88172.PDF
42 * Note: you need the manual for the AX88170 chip (USB 1.x ethernet

--- 254 unchanged lines hidden (view full) ---

297 if (!locked)
298 AXE_LOCK(sc);
299
300 axe_cmd(sc, AXE_CMD_MII_OPMODE_SW, 0, 0, NULL);
301 axe_cmd(sc, AXE_CMD_MII_READ_REG, reg, phy, &val);
302 axe_cmd(sc, AXE_CMD_MII_OPMODE_HW, 0, 0, NULL);
303
304 val = le16toh(val);
35
36/*
37 * ASIX Electronics AX88172/AX88178/AX88778 USB 2.0 ethernet driver.
38 * Used in the LinkSys USB200M and various other adapters.
39 *
40 * Manuals available from:
41 * http://www.asix.com.tw/datasheet/mac/Ax88172.PDF
42 * Note: you need the manual for the AX88170 chip (USB 1.x ethernet

--- 254 unchanged lines hidden (view full) ---

297 if (!locked)
298 AXE_LOCK(sc);
299
300 axe_cmd(sc, AXE_CMD_MII_OPMODE_SW, 0, 0, NULL);
301 axe_cmd(sc, AXE_CMD_MII_READ_REG, reg, phy, &val);
302 axe_cmd(sc, AXE_CMD_MII_OPMODE_HW, 0, 0, NULL);
303
304 val = le16toh(val);
305 if ((sc->sc_flags & AXE_FLAG_772) != 0 && reg == MII_BMSR) {
305 if (AXE_IS_772(sc) && reg == MII_BMSR) {
306 /*
307 * BMSR of AX88772 indicates that it supports extended
308 * capability but the extended status register is
309 * revered for embedded ethernet PHY. So clear the
310 * extended capability bit of BMSR.
311 */
312 val &= ~BMSR_EXTCAP;
313 }

--- 65 unchanged lines hidden (view full) ---

379
380 /* Lost link, do nothing. */
381 if ((sc->sc_flags & AXE_FLAG_LINK) == 0)
382 goto done;
383
384 val = 0;
385 if ((IFM_OPTIONS(mii->mii_media_active) & IFM_FDX) != 0)
386 val |= AXE_MEDIA_FULL_DUPLEX;
306 /*
307 * BMSR of AX88772 indicates that it supports extended
308 * capability but the extended status register is
309 * revered for embedded ethernet PHY. So clear the
310 * extended capability bit of BMSR.
311 */
312 val &= ~BMSR_EXTCAP;
313 }

--- 65 unchanged lines hidden (view full) ---

379
380 /* Lost link, do nothing. */
381 if ((sc->sc_flags & AXE_FLAG_LINK) == 0)
382 goto done;
383
384 val = 0;
385 if ((IFM_OPTIONS(mii->mii_media_active) & IFM_FDX) != 0)
386 val |= AXE_MEDIA_FULL_DUPLEX;
387 if (sc->sc_flags & (AXE_FLAG_178 | AXE_FLAG_772)) {
387 if (AXE_IS_178_FAMILY(sc)) {
388 val |= AXE_178_MEDIA_RX_EN | AXE_178_MEDIA_MAGIC;
389 if ((sc->sc_flags & AXE_FLAG_178) != 0)
390 val |= AXE_178_MEDIA_ENCK;
391 switch (IFM_SUBTYPE(mii->mii_media_active)) {
392 case IFM_1000_T:
393 val |= AXE_178_MEDIA_GMII | AXE_178_MEDIA_ENCK;
394 break;
395 case IFM_100_TX:

--- 299 unchanged lines hidden (view full) ---

695 if (sc->sc_phyno == -1)
696 sc->sc_phyno = axe_get_phyno(sc, AXE_PHY_SEL_SEC);
697 if (sc->sc_phyno == -1) {
698 device_printf(sc->sc_ue.ue_dev,
699 "no valid PHY address found, assuming PHY address 0\n");
700 sc->sc_phyno = 0;
701 }
702
388 val |= AXE_178_MEDIA_RX_EN | AXE_178_MEDIA_MAGIC;
389 if ((sc->sc_flags & AXE_FLAG_178) != 0)
390 val |= AXE_178_MEDIA_ENCK;
391 switch (IFM_SUBTYPE(mii->mii_media_active)) {
392 case IFM_1000_T:
393 val |= AXE_178_MEDIA_GMII | AXE_178_MEDIA_ENCK;
394 break;
395 case IFM_100_TX:

--- 299 unchanged lines hidden (view full) ---

695 if (sc->sc_phyno == -1)
696 sc->sc_phyno = axe_get_phyno(sc, AXE_PHY_SEL_SEC);
697 if (sc->sc_phyno == -1) {
698 device_printf(sc->sc_ue.ue_dev,
699 "no valid PHY address found, assuming PHY address 0\n");
700 sc->sc_phyno = 0;
701 }
702
703 if (sc->sc_flags & AXE_FLAG_178)
703 if (sc->sc_flags & AXE_FLAG_178) {
704 axe_ax88178_init(sc);
704 axe_ax88178_init(sc);
705 else if (sc->sc_flags & AXE_FLAG_772)
705 sc->sc_tx_bufsz = 16 * 1024;
706 } else if (sc->sc_flags & AXE_FLAG_772) {
706 axe_ax88772_init(sc);
707 axe_ax88772_init(sc);
708 sc->sc_tx_bufsz = 8 * 1024;
709 }
707
708 /*
709 * Get station address.
710 */
710
711 /*
712 * Get station address.
713 */
711 if (sc->sc_flags & (AXE_FLAG_178 | AXE_FLAG_772))
714 if (AXE_IS_178_FAMILY(sc))
712 axe_cmd(sc, AXE_178_CMD_READ_NODEID, 0, 0, ue->ue_eaddr);
713 else
714 axe_cmd(sc, AXE_172_CMD_READ_NODEID, 0, 0, ue->ue_eaddr);
715
716 /*
717 * Fetch IPG values.
718 */
719 axe_cmd(sc, AXE_CMD_READ_IPG012, 0, 0, sc->sc_ipgs);

--- 94 unchanged lines hidden (view full) ---

814
815 switch (USB_GET_STATE(xfer)) {
816 case USB_ST_TRANSFERRED:
817 pos = 0;
818 len = 0;
819 err = 0;
820
821 pc = usbd_xfer_get_frame(xfer, 0);
715 axe_cmd(sc, AXE_178_CMD_READ_NODEID, 0, 0, ue->ue_eaddr);
716 else
717 axe_cmd(sc, AXE_172_CMD_READ_NODEID, 0, 0, ue->ue_eaddr);
718
719 /*
720 * Fetch IPG values.
721 */
722 axe_cmd(sc, AXE_CMD_READ_IPG012, 0, 0, sc->sc_ipgs);

--- 94 unchanged lines hidden (view full) ---

817
818 switch (USB_GET_STATE(xfer)) {
819 case USB_ST_TRANSFERRED:
820 pos = 0;
821 len = 0;
822 err = 0;
823
824 pc = usbd_xfer_get_frame(xfer, 0);
822 if (sc->sc_flags & (AXE_FLAG_772 | AXE_FLAG_178)) {
825 if (AXE_IS_178_FAMILY(sc)) {
823 while (pos < actlen) {
824 if ((pos + sizeof(hdr)) > actlen) {
825 /* too little data */
826 err = EINVAL;
827 break;
828 }
829 usbd_copy_out(pc, pos, &hdr, sizeof(hdr));
830

--- 80 unchanged lines hidden (view full) ---

911 if (m == NULL) {
912 if (pos > 0)
913 break; /* send out data */
914 return;
915 }
916 if (m->m_pkthdr.len > MCLBYTES) {
917 m->m_pkthdr.len = MCLBYTES;
918 }
826 while (pos < actlen) {
827 if ((pos + sizeof(hdr)) > actlen) {
828 /* too little data */
829 err = EINVAL;
830 break;
831 }
832 usbd_copy_out(pc, pos, &hdr, sizeof(hdr));
833

--- 80 unchanged lines hidden (view full) ---

914 if (m == NULL) {
915 if (pos > 0)
916 break; /* send out data */
917 return;
918 }
919 if (m->m_pkthdr.len > MCLBYTES) {
920 m->m_pkthdr.len = MCLBYTES;
921 }
919 if (sc->sc_flags & (AXE_FLAG_772 | AXE_FLAG_178)) {
922 if (AXE_IS_178_FAMILY(sc)) {
920
921 hdr.len = htole16(m->m_pkthdr.len);
922 hdr.ilen = ~hdr.len;
923
924 usbd_copy_in(pc, pos, &hdr, sizeof(hdr));
925
926 pos += sizeof(hdr);
927

--- 22 unchanged lines hidden (view full) ---

950 /*
951 * if there's a BPF listener, bounce a copy
952 * of this frame to him:
953 */
954 BPF_MTAP(ifp, m);
955
956 m_freem(m);
957
923
924 hdr.len = htole16(m->m_pkthdr.len);
925 hdr.ilen = ~hdr.len;
926
927 usbd_copy_in(pc, pos, &hdr, sizeof(hdr));
928
929 pos += sizeof(hdr);
930

--- 22 unchanged lines hidden (view full) ---

953 /*
954 * if there's a BPF listener, bounce a copy
955 * of this frame to him:
956 */
957 BPF_MTAP(ifp, m);
958
959 m_freem(m);
960
958 if (sc->sc_flags & (AXE_FLAG_772 | AXE_FLAG_178)) {
961 if (AXE_IS_178_FAMILY(sc)) {
959 if (pos > (AXE_BULK_BUF_SIZE - MCLBYTES - sizeof(hdr))) {
960 /* send out frame(s) */
961 break;
962 }
963 } else {
964 /* send out frame */
965 break;
966 }

--- 62 unchanged lines hidden (view full) ---

1029 return;
1030
1031 /* Cancel pending I/O */
1032 axe_stop(ue);
1033
1034 axe_reset(sc);
1035
1036 /* Set MAC address. */
962 if (pos > (AXE_BULK_BUF_SIZE - MCLBYTES - sizeof(hdr))) {
963 /* send out frame(s) */
964 break;
965 }
966 } else {
967 /* send out frame */
968 break;
969 }

--- 62 unchanged lines hidden (view full) ---

1032 return;
1033
1034 /* Cancel pending I/O */
1035 axe_stop(ue);
1036
1037 axe_reset(sc);
1038
1039 /* Set MAC address. */
1037 if (sc->sc_flags & (AXE_FLAG_178 | AXE_FLAG_772))
1040 if (AXE_IS_178_FAMILY(sc))
1038 axe_cmd(sc, AXE_178_CMD_WRITE_NODEID, 0, 0, IF_LLADDR(ifp));
1039 else
1040 axe_cmd(sc, AXE_172_CMD_WRITE_NODEID, 0, 0, IF_LLADDR(ifp));
1041
1042 /* Set transmitter IPG values */
1041 axe_cmd(sc, AXE_178_CMD_WRITE_NODEID, 0, 0, IF_LLADDR(ifp));
1042 else
1043 axe_cmd(sc, AXE_172_CMD_WRITE_NODEID, 0, 0, IF_LLADDR(ifp));
1044
1045 /* Set transmitter IPG values */
1043 if (sc->sc_flags & (AXE_FLAG_178 | AXE_FLAG_772)) {
1046 if (AXE_IS_178_FAMILY(sc))
1044 axe_cmd(sc, AXE_178_CMD_WRITE_IPG012, sc->sc_ipgs[2],
1045 (sc->sc_ipgs[1] << 8) | (sc->sc_ipgs[0]), NULL);
1047 axe_cmd(sc, AXE_178_CMD_WRITE_IPG012, sc->sc_ipgs[2],
1048 (sc->sc_ipgs[1] << 8) | (sc->sc_ipgs[0]), NULL);
1046 } else {
1049 else {
1047 axe_cmd(sc, AXE_172_CMD_WRITE_IPG0, 0, sc->sc_ipgs[0], NULL);
1048 axe_cmd(sc, AXE_172_CMD_WRITE_IPG1, 0, sc->sc_ipgs[1], NULL);
1049 axe_cmd(sc, AXE_172_CMD_WRITE_IPG2, 0, sc->sc_ipgs[2], NULL);
1050 }
1051
1052 /* Enable receiver, set RX mode */
1053 rxmode = (AXE_RXCMD_MULTICAST | AXE_RXCMD_ENABLE);
1050 axe_cmd(sc, AXE_172_CMD_WRITE_IPG0, 0, sc->sc_ipgs[0], NULL);
1051 axe_cmd(sc, AXE_172_CMD_WRITE_IPG1, 0, sc->sc_ipgs[1], NULL);
1052 axe_cmd(sc, AXE_172_CMD_WRITE_IPG2, 0, sc->sc_ipgs[2], NULL);
1053 }
1054
1055 /* Enable receiver, set RX mode */
1056 rxmode = (AXE_RXCMD_MULTICAST | AXE_RXCMD_ENABLE);
1054 if (sc->sc_flags & (AXE_FLAG_178 | AXE_FLAG_772)) {
1057 if (AXE_IS_178_FAMILY(sc)) {
1055#if 0
1056 rxmode |= AXE_178_RXCMD_MFB_2048; /* chip default */
1057#else
1058 /*
1059 * Default Rx buffer size is too small to get
1060 * maximum performance.
1061 */
1062 rxmode |= AXE_178_RXCMD_MFB_16384;

--- 64 unchanged lines hidden ---
1058#if 0
1059 rxmode |= AXE_178_RXCMD_MFB_2048; /* chip default */
1060#else
1061 /*
1062 * Default Rx buffer size is too small to get
1063 * maximum performance.
1064 */
1065 rxmode |= AXE_178_RXCMD_MFB_16384;

--- 64 unchanged lines hidden ---