From owner-svn-src-all@FreeBSD.ORG Wed May 21 08:09:45 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 3EFE0C28; Wed, 21 May 2014 08:09:45 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2C5EE2A52; Wed, 21 May 2014 08:09:45 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s4L89jdD075921; Wed, 21 May 2014 08:09:45 GMT (envelope-from kevlo@svn.freebsd.org) Received: (from kevlo@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s4L89jXL075920; Wed, 21 May 2014 08:09:45 GMT (envelope-from kevlo@svn.freebsd.org) Message-Id: <201405210809.s4L89jXL075920@svn.freebsd.org> From: Kevin Lo Date: Wed, 21 May 2014 08:09:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r266490 - head/sys/dev/usb/net X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 May 2014 08:09:45 -0000 Author: kevlo Date: Wed May 21 08:09:44 2014 New Revision: 266490 URL: http://svnweb.freebsd.org/changeset/base/266490 Log: - Configure Rx bulk - Announce flow control capability to PHY drivers Modified: head/sys/dev/usb/net/if_axge.c Modified: head/sys/dev/usb/net/if_axge.c ============================================================================== --- head/sys/dev/usb/net/if_axge.c Wed May 21 07:42:42 2014 (r266489) +++ head/sys/dev/usb/net/if_axge.c Wed May 21 08:09:44 2014 (r266490) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2013 Kevin Lo + * Copyright (c) 2013-2014 Kevin Lo * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -71,12 +71,16 @@ static const STRUCT_USB_HOST_ID axge_dev }; static const struct { - unsigned char ctrl, timer_l, timer_h, size, ifg; -} AX88179_BULKIN_SIZE[] = { - {7, 0x4f, 0, 0x12, 0xff}, - {7, 0x20, 3, 0x16, 0xff}, - {7, 0xae, 7, 0x18, 0xff}, - {7, 0xcc, 0x4c, 0x18, 8}, + uint8_t ctrl; + uint8_t timer_l; + uint8_t timer_h; + uint8_t size; + uint8_t ifg; +} axge_bulk_size[] = { + { 7, 0x4f, 0x00, 0x12, 0xff }, + { 7, 0x20, 0x03, 0x16, 0xff }, + { 7, 0xae, 0x07, 0x18, 0xff }, + { 7, 0xcc, 0x4c, 0x18, 0x08 } }; /* prototypes */ @@ -104,6 +108,8 @@ static int axge_read_mem(struct axge_sof uint16_t, void *, int); static void axge_write_mem(struct axge_softc *, uint8_t, uint16_t, uint16_t, void *, int); +static uint8_t axge_read_cmd_1(struct axge_softc *, uint8_t, uint16_t, + uint16_t); static uint16_t axge_read_cmd_2(struct axge_softc *, uint8_t, uint16_t, uint16_t); static void axge_write_cmd_1(struct axge_softc *, uint8_t, uint16_t, @@ -233,6 +239,16 @@ axge_write_mem(struct axge_softc *sc, ui } } +static uint8_t +axge_read_cmd_1(struct axge_softc *sc, uint8_t cmd, uint16_t index, + uint16_t reg) +{ + uint8_t val; + + axge_read_mem(sc, cmd, index, reg, &val, 1); + return (val); +} + static uint16_t axge_read_cmd_2(struct axge_softc *sc, uint8_t cmd, uint16_t index, uint16_t reg) @@ -307,6 +323,7 @@ axge_miibus_statchg(device_t dev) struct axge_softc *sc; struct mii_data *mii; struct ifnet *ifp; + uint8_t link_status, tmp[5]; uint16_t val; int locked; @@ -339,6 +356,8 @@ axge_miibus_statchg(device_t dev) if ((sc->sc_flags & AXGE_FLAG_LINK) == 0) goto done; + link_status = axge_read_cmd_1(sc, AXGE_ACCESS_MAC, 1, AXGE_LINK_STATUS); + val = 0; if ((IFM_OPTIONS(mii->mii_media_active) & IFM_FDX) != 0) { val |= AXGE_MEDIUM_FULL_DUPLEX; @@ -347,18 +366,32 @@ axge_miibus_statchg(device_t dev) if ((IFM_OPTIONS(mii->mii_media_active) & IFM_ETH_RXPAUSE) != 0) val |= AXGE_MEDIUM_RXFLOW_CTRLEN; } - val |= AXGE_MEDIUM_RECEIVE_EN | AXGE_MEDIUM_ALWAYS_ONE; + val |= AXGE_MEDIUM_RECEIVE_EN; switch (IFM_SUBTYPE(mii->mii_media_active)) { case IFM_1000_T: - val |= AXGE_MEDIUM_GIGAMODE; + val |= AXGE_MEDIUM_GIGAMODE | AXGE_MEDIUM_EN_125MHZ; + if (link_status & AXGE_LINK_STATUS_USB_SS) + memcpy(tmp, &axge_bulk_size[0], 5); + else if (link_status & AXGE_LINK_STATUS_USB_HS) + memcpy(tmp, &axge_bulk_size[1], 5); + else + memcpy(tmp, &axge_bulk_size[3], 5); + break; case IFM_100_TX: val |= AXGE_MEDIUM_PS; + if (link_status & + (AXGE_LINK_STATUS_USB_SS | AXGE_LINK_STATUS_USB_HS)) + memcpy(tmp, &axge_bulk_size[2], 5); + else + memcpy(tmp, &axge_bulk_size[3], 5); + break; case IFM_10_T: - /* Doesn't need to be handled. */ + memcpy(tmp, &axge_bulk_size[3], 5); break; } + /* Rx bulk configuration. */ + axge_write_mem(sc, AXGE_ACCESS_MAC, 5, AXGE_RX_BULKIN_QCTRL, tmp, 5); axge_write_cmd_2(sc, AXGE_ACCESS_MAC, 2, AXGE_MEDIUM_STATUS_MODE, val); - done: if (!locked) AXGE_UNLOCK(sc); @@ -401,16 +434,12 @@ static void axge_attach_post(struct usb_ether *ue) { struct axge_softc *sc; - uint8_t tmp[5]; sc = uether_getsc(ue); sc->sc_phyno = 3; /* Initialize controller and get station address. */ axge_chip_init(sc); - - memcpy(tmp, &AX88179_BULKIN_SIZE[0], 5); - axge_read_mem(sc, AXGE_ACCESS_MAC, 5, AXGE_RX_BULKIN_QCTRL, tmp, 5); axge_read_mem(sc, AXGE_ACCESS_MAC, ETHER_ADDR_LEN, AXGE_NODE_ID, ue->ue_eaddr, ETHER_ADDR_LEN); } @@ -439,7 +468,7 @@ axge_attach_post_sub(struct usb_ether *u mtx_lock(&Giant); error = mii_attach(ue->ue_dev, &ue->ue_miibus, ifp, uether_ifmedia_upd, ue->ue_methods->ue_mii_sts, - BMSR_DEFCAPMASK, sc->sc_phyno, MII_OFFSET_ANY, 0); + BMSR_DEFCAPMASK, sc->sc_phyno, MII_OFFSET_ANY, MIIF_DOPAUSE); mtx_unlock(&Giant); return (error);