Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/sys couple more changes to usbnet(9):



details:   https://anonhg.NetBSD.org/src/rev/16a15a19f010
branches:  trunk
changeset: 964857:16a15a19f010
user:      mrg <mrg%NetBSD.org@localhost>
date:      Tue Aug 20 06:37:06 2019 +0000

description:
couple more changes to usbnet(9):

- MII read/write reg return int instead of usbd_status (requested by skrll)
- usbnet_attach_ifp(9) changes arg, two mii-specific flags are placed by a
  pointer to new struct usbnet_mii.  if not NULL, then attach an MII to this
  interface like previous have_mii parameter.  use this to allow ure(4) to
  properly pass PHY location to mii_attach().

welcome netbsd 9.99.10.

diffstat:

 sys/dev/usb/if_axe.c    |  30 +++++++++++++++++-------------
 sys/dev/usb/if_axen.c   |  39 ++++++++++++++++++++++-----------------
 sys/dev/usb/if_cdce.c   |   8 ++++----
 sys/dev/usb/if_cue.c    |   8 ++++----
 sys/dev/usb/if_kue.c    |   8 ++++----
 sys/dev/usb/if_mue.c    |  33 +++++++++++++++++----------------
 sys/dev/usb/if_smsc.c   |  33 +++++++++++++++++----------------
 sys/dev/usb/if_udav.c   |  35 ++++++++++++++++++++---------------
 sys/dev/usb/if_upl.c    |   8 ++++----
 sys/dev/usb/if_ure.c    |  26 ++++++++++++++------------
 sys/dev/usb/if_url.c    |  37 +++++++++++++++----------------------
 sys/dev/usb/if_urndis.c |   8 ++++----
 sys/dev/usb/usbnet.c    |  25 ++++++++++++-------------
 sys/dev/usb/usbnet.h    |  34 ++++++++++++++++++++++++++++------
 sys/sys/param.h         |   4 ++--
 15 files changed, 184 insertions(+), 152 deletions(-)

diffs (truncated from 1105 to 300 lines):

diff -r 4e91d6c6f28a -r 16a15a19f010 sys/dev/usb/if_axe.c
--- a/sys/dev/usb/if_axe.c      Tue Aug 20 06:18:54 2019 +0000
+++ b/sys/dev/usb/if_axe.c      Tue Aug 20 06:37:06 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_axe.c,v 1.117 2019/08/19 07:33:37 mrg Exp $ */
+/*     $NetBSD: if_axe.c,v 1.118 2019/08/20 06:37:06 mrg Exp $ */
 /*     $OpenBSD: if_axe.c,v 1.137 2016/04/13 11:03:37 mpi Exp $ */
 
 /*
@@ -87,7 +87,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.117 2019/08/19 07:33:37 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.118 2019/08/20 06:37:06 mrg Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -259,8 +259,8 @@
 static void    axe_stop(struct ifnet *, int);
 static int     axe_ioctl(struct ifnet *, u_long, void *);
 static int     axe_init(struct ifnet *);
-static usbd_status axe_mii_read_reg(struct usbnet *, int, int, uint16_t *);
-static usbd_status axe_mii_write_reg(struct usbnet *, int, int, uint16_t);
+static int     axe_mii_read_reg(struct usbnet *, int, int, uint16_t *);
+static int     axe_mii_write_reg(struct usbnet *, int, int, uint16_t);
 static void    axe_mii_statchg(struct ifnet *);
 static void    axe_rx_loop(struct usbnet *, struct usbnet_chain *, uint32_t);
 static unsigned axe_tx_prepare(struct usbnet *, struct mbuf *,
@@ -313,7 +313,7 @@
        return err;
 }
 
-static usbd_status
+static int
 axe_mii_read_reg(struct usbnet *un, int phy, int reg, uint16_t *val)
 {
        AXEHIST_FUNC(); AXEHIST_CALLED();
@@ -324,7 +324,7 @@
        DPRINTFN(30, "phy 0x%jx reg 0x%jx\n", phy, reg, 0, 0);
 
        if (un->un_phyno != phy)
-               return USBD_INVAL;
+               return EINVAL;
 
        axe_cmd(sc, AXE_CMD_MII_OPMODE_SW, 0, 0, NULL);
 
@@ -333,7 +333,7 @@
 
        if (err) {
                aprint_error_dev(un->un_dev, "read PHY failed\n");
-               return err;
+               return EIO;
        }
 
        *val = le16toh(data);
@@ -349,10 +349,10 @@
 
        DPRINTFN(30, "phy 0x%jx reg 0x%jx val %#jx", phy, reg, *val, 0);
 
-       return USBD_NORMAL_COMPLETION;
+       return 0;
 }
 
-static usbd_status
+static int
 axe_mii_write_reg(struct usbnet *un, int phy, int reg, uint16_t val)
 {
        struct axe_softc * const sc = usbnet_softc(un);
@@ -360,7 +360,7 @@
        uint16_t aval;
 
        if (un->un_phyno != phy)
-               return USBD_INVAL;
+               return EINVAL;
 
        aval = htole16(val);
 
@@ -368,7 +368,9 @@
        err = axe_cmd(sc, AXE_CMD_MII_WRITE_REG, reg, phy, &aval);
        axe_cmd(sc, AXE_CMD_MII_OPMODE_HW, 0, 0, NULL);
 
-       return err;
+       if (err)
+               return EIO;
+       return 0;
 }
 
 static void
@@ -861,6 +863,7 @@
 axe_attach(device_t parent, device_t self, void *aux)
 {
        AXEHIST_FUNC(); AXEHIST_CALLED();
+       UBSNET_MII_DECL_DEFAULT(unm);
        struct axe_softc *sc = device_private(self);
        struct usbnet * const un = &sc->axe_un;
        struct usb_attach_arg *uaa = aux;
@@ -1009,8 +1012,9 @@
                adv_pause = 0;
        adv_pause = 0;
 
-       usbnet_attach_ifp(un, true, IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST,
-           0, adv_pause);
+       unm.un_mii_flags = adv_pause;
+       usbnet_attach_ifp(un, IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST,
+           0, &unm);
 }
 
 static void
diff -r 4e91d6c6f28a -r 16a15a19f010 sys/dev/usb/if_axen.c
--- a/sys/dev/usb/if_axen.c     Tue Aug 20 06:18:54 2019 +0000
+++ b/sys/dev/usb/if_axen.c     Tue Aug 20 06:37:06 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_axen.c,v 1.65 2019/08/19 07:33:37 mrg Exp $ */
+/*     $NetBSD: if_axen.c,v 1.66 2019/08/20 06:37:06 mrg Exp $ */
 /*     $OpenBSD: if_axen.c,v 1.3 2013/10/21 10:10:22 yuo Exp $ */
 
 /*
@@ -23,7 +23,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.65 2019/08/19 07:33:37 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.66 2019/08/20 06:37:06 mrg Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -80,8 +80,8 @@
 
 static void    axen_stop_cb(struct ifnet *, int);
 static int     axen_ioctl_cb(struct ifnet *, u_long, void *);
-static usbd_status axen_mii_read_reg(struct usbnet *, int, int, uint16_t *);
-static usbd_status axen_mii_write_reg(struct usbnet *, int, int, uint16_t);
+static int     axen_mii_read_reg(struct usbnet *, int, int, uint16_t *);
+static int     axen_mii_write_reg(struct usbnet *, int, int, uint16_t);
 static void    axen_mii_statchg(struct ifnet *);
 static void    axen_rx_loop(struct usbnet *, struct usbnet_chain *, uint32_t);
 static unsigned        axen_tx_prepare(struct usbnet *, struct mbuf *,
@@ -131,34 +131,38 @@
        return 0;
 }
 
-static usbd_status
+static int
 axen_mii_read_reg(struct usbnet *un, int phy, int reg, uint16_t *val)
 {
        uint16_t data;
 
        if (un->un_phyno != phy)
-               return USBD_INVAL;
+               return EINVAL;
 
        usbd_status err = axen_cmd(un, AXEN_CMD_MII_READ_REG, reg, phy, &data);
-       if (!err) {
-               *val = le16toh(data);
+       if (err)
+               return EIO;
 
-               if (reg == MII_BMSR)
-                       *val &= ~BMSR_EXTCAP;
-       }
+       *val = le16toh(data);
+       if (reg == MII_BMSR)
+               *val &= ~BMSR_EXTCAP;
 
-       return err;
+       return 0;
 }
 
-static usbd_status
+static int
 axen_mii_write_reg(struct usbnet *un, int phy, int reg, uint16_t val)
 {
        uint16_t uval = htole16(val);
 
        if (un->un_phyno != phy)
-               return USBD_INVAL;
+               return EINVAL;
 
-       return axen_cmd(un, AXEN_CMD_MII_WRITE_REG, reg, phy, &uval);
+       usbd_status err = axen_cmd(un, AXEN_CMD_MII_WRITE_REG, reg, phy, &uval);
+       if (err)
+               return EIO;
+
+       return 0;
 }
 
 static void
@@ -595,6 +599,7 @@
 static void
 axen_attach(device_t parent, device_t self, void *aux)
 {
+       UBSNET_MII_DECL_DEFAULT(unm);
        struct usbnet * const un = device_private(self);
        struct usb_attach_arg *uaa = aux;
        struct usbd_device *dev = uaa->uaa_device;
@@ -709,8 +714,8 @@
            IFCAP_CSUM_TCPv6_Rx | IFCAP_CSUM_TCPv6_Tx |
            IFCAP_CSUM_UDPv6_Rx | IFCAP_CSUM_UDPv6_Tx;
 
-       usbnet_attach_ifp(un, true, IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST,
-           0, 0);
+       usbnet_attach_ifp(un, IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST,
+           0, &unm);
 }
 
 static int
diff -r 4e91d6c6f28a -r 16a15a19f010 sys/dev/usb/if_cdce.c
--- a/sys/dev/usb/if_cdce.c     Tue Aug 20 06:18:54 2019 +0000
+++ b/sys/dev/usb/if_cdce.c     Tue Aug 20 06:37:06 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_cdce.c,v 1.66 2019/08/15 05:52:23 mrg Exp $ */
+/*     $NetBSD: if_cdce.c,v 1.67 2019/08/20 06:37:06 mrg Exp $ */
 
 /*
  * Copyright (c) 1997, 1998, 1999, 2000-2003 Bill Paul <wpaul%windriver.com@localhost>
@@ -40,7 +40,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_cdce.c,v 1.66 2019/08/15 05:52:23 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cdce.c,v 1.67 2019/08/20 06:37:06 mrg Exp $");
 
 #include <sys/param.h>
 
@@ -247,8 +247,8 @@
        }
 
        usbnet_attach(un, "cdcedet");
-       usbnet_attach_ifp(un, false, IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST,
-            0, 0);
+       usbnet_attach_ifp(un, IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST,
+            0, NULL);
 }
 
 static int
diff -r 4e91d6c6f28a -r 16a15a19f010 sys/dev/usb/if_cue.c
--- a/sys/dev/usb/if_cue.c      Tue Aug 20 06:18:54 2019 +0000
+++ b/sys/dev/usb/if_cue.c      Tue Aug 20 06:37:06 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_cue.c,v 1.85 2019/08/15 08:02:32 mrg Exp $  */
+/*     $NetBSD: if_cue.c,v 1.86 2019/08/20 06:37:06 mrg Exp $  */
 
 /*
  * Copyright (c) 1997, 1998, 1999, 2000
@@ -57,7 +57,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_cue.c,v 1.85 2019/08/15 08:02:32 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cue.c,v 1.86 2019/08/20 06:37:06 mrg Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -536,8 +536,8 @@
         */
        cue_getmac(un);
 
-       usbnet_attach_ifp(un, false, IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST,
-           0, 0);
+       usbnet_attach_ifp(un, IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST,
+           0, NULL);
 }
 
 static void
diff -r 4e91d6c6f28a -r 16a15a19f010 sys/dev/usb/if_kue.c
--- a/sys/dev/usb/if_kue.c      Tue Aug 20 06:18:54 2019 +0000
+++ b/sys/dev/usb/if_kue.c      Tue Aug 20 06:37:06 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_kue.c,v 1.99 2019/08/18 11:46:38 mrg Exp $  */
+/*     $NetBSD: if_kue.c,v 1.100 2019/08/20 06:37:06 mrg Exp $ */
 
 /*
  * Copyright (c) 1997, 1998, 1999, 2000
@@ -71,7 +71,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_kue.c,v 1.99 2019/08/18 11:46:38 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_kue.c,v 1.100 2019/08/20 06:37:06 mrg Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -509,8 +509,8 @@
        sc->kue_mcfilters = kmem_alloc(KUE_MCFILTCNT(sc) * ETHER_ADDR_LEN,
            KM_SLEEP);
 
-       usbnet_attach_ifp(un, false, IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST,
-           0, 0);
+       usbnet_attach_ifp(un, IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST,
+           0, NULL);
 }
 
 int
diff -r 4e91d6c6f28a -r 16a15a19f010 sys/dev/usb/if_mue.c
--- a/sys/dev/usb/if_mue.c      Tue Aug 20 06:18:54 2019 +0000
+++ b/sys/dev/usb/if_mue.c      Tue Aug 20 06:37:06 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_mue.c,v 1.53 2019/08/19 07:33:37 mrg Exp $  */
+/*     $NetBSD: if_mue.c,v 1.54 2019/08/20 06:37:06 mrg Exp $  */



Home | Main Index | Thread Index | Old Index