Source-Changes-HG archive

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

[src/trunk]: src usbnet(9): New usbnet_ispromisc(un).



details:   https://anonhg.NetBSD.org/src/rev/77ccd3446a2e
branches:  trunk
changeset: 369506:77ccd3446a2e
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sat Aug 20 14:08:59 2022 +0000

description:
usbnet(9): New usbnet_ispromisc(un).

Replaces ifp->if_flags & IFF_PROMISC in multicast filter updates.

diffstat:

 share/man/man9/usbnet.9 |  18 +++++++++++++++++-
 sys/dev/usb/if_aue.c    |   8 ++++----
 sys/dev/usb/if_axe.c    |   6 +++---
 sys/dev/usb/if_axen.c   |   6 +++---
 sys/dev/usb/if_cue.c    |  12 ++++++------
 sys/dev/usb/if_kue.c    |   8 ++++----
 sys/dev/usb/if_mos.c    |   6 +++---
 sys/dev/usb/if_mue.c    |   8 ++++----
 sys/dev/usb/if_smsc.c   |   6 +++---
 sys/dev/usb/if_udav.c   |   8 ++++----
 sys/dev/usb/if_ure.c    |   6 +++---
 sys/dev/usb/if_url.c    |   6 +++---
 sys/dev/usb/usbnet.c    |  32 +++++++++++++++++++++++++++++---
 sys/dev/usb/usbnet.h    |   3 ++-
 14 files changed, 88 insertions(+), 45 deletions(-)

diffs (truncated from 457 to 300 lines):

diff -r 04cfe1cca5ec -r 77ccd3446a2e share/man/man9/usbnet.9
--- a/share/man/man9/usbnet.9   Sat Aug 20 14:08:47 2022 +0000
+++ b/share/man/man9/usbnet.9   Sat Aug 20 14:08:59 2022 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: usbnet.9,v 1.18 2022/08/12 15:30:41 riastradh Exp $
+.\"    $NetBSD: usbnet.9,v 1.19 2022/08/20 14:08:59 riastradh Exp $
 .\"
 .\" Copyright (c) 2019 Matthew R. Green
 .\" All rights reserved.
@@ -47,6 +47,8 @@
 .Fn usbnet_softc "struct usbnet *un"
 .Ft bool
 .Fn usbnet_havelink "struct usbnet *un"
+.Ft int
+.Fn usbnet_ispromisc "struct usbnet *un"
 .Ft bool
 .Fn usbnet_isdying "struct usbnet *un"
 .Ft void
@@ -243,6 +245,20 @@
 device softc.
 .It Fn usbnet_havelink un
 Returns true if link is active.
+.It Fn usbnet_ispromisc un
+True if
+.Dv IFF_PROMISC
+is enabled, false if not.
+.Pp
+May be used only in
+.Dq uno_init
+and
+.Dq uno_mcast .
+.Pp
+Drivers must use this in
+.Dq uno_mcast
+instead of reading
+.Li ifp->if_flags .
 .It Fn usbnet_isdying un
 Returns true if device is dying (has been pulled or deactivated,
 pending detach).
diff -r 04cfe1cca5ec -r 77ccd3446a2e sys/dev/usb/if_aue.c
--- a/sys/dev/usb/if_aue.c      Sat Aug 20 14:08:47 2022 +0000
+++ b/sys/dev/usb/if_aue.c      Sat Aug 20 14:08:59 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_aue.c,v 1.190 2022/03/03 05:56:28 riastradh Exp $   */
+/*     $NetBSD: if_aue.c,v 1.191 2022/08/20 14:08:59 riastradh Exp $   */
 
 /*
  * Copyright (c) 1997, 1998, 1999, 2000
@@ -76,7 +76,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_aue.c,v 1.190 2022/03/03 05:56:28 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_aue.c,v 1.191 2022/08/20 14:08:59 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -619,7 +619,7 @@
        AUEHIST_FUNC();
        AUEHIST_CALLARGSN(5, "aue%jd: enter", device_unit(un->un_dev), 0, 0, 0);
 
-       if (ifp->if_flags & IFF_PROMISC) {
+       if (usbnet_ispromisc(un)) {
                ETHER_LOCK(ec);
 allmulti:
                ec->ec_flags |= ETHER_F_ALLMULTI;
@@ -962,7 +962,7 @@
                aue_csr_write_1(sc, AUE_PAR0 + i, eaddr[i]);
 
         /* If we want promiscuous mode, set the allframes bit. */
-       if (ifp->if_flags & IFF_PROMISC)
+       if (usbnet_ispromisc(un))
                AUE_SETBIT(sc, AUE_CTL2, AUE_CTL2_RX_PROMISC);
        else
                AUE_CLRBIT(sc, AUE_CTL2, AUE_CTL2_RX_PROMISC);
diff -r 04cfe1cca5ec -r 77ccd3446a2e sys/dev/usb/if_axe.c
--- a/sys/dev/usb/if_axe.c      Sat Aug 20 14:08:47 2022 +0000
+++ b/sys/dev/usb/if_axe.c      Sat Aug 20 14:08:59 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_axe.c,v 1.150 2022/03/03 05:56:28 riastradh Exp $   */
+/*     $NetBSD: if_axe.c,v 1.151 2022/08/20 14:08:59 riastradh 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.150 2022/03/03 05:56:28 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.151 2022/08/20 14:08:59 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -452,7 +452,7 @@
            ~(AXE_RXCMD_ALLMULTI | AXE_RXCMD_PROMISC | AXE_RXCMD_MULTICAST);
 
        ETHER_LOCK(ec);
-       if (ifp->if_flags & IFF_PROMISC) {
+       if (usbnet_ispromisc(un)) {
                ec->ec_flags |= ETHER_F_ALLMULTI;
                ETHER_UNLOCK(ec);
                /* run promisc. mode */
diff -r 04cfe1cca5ec -r 77ccd3446a2e sys/dev/usb/if_axen.c
--- a/sys/dev/usb/if_axen.c     Sat Aug 20 14:08:47 2022 +0000
+++ b/sys/dev/usb/if_axen.c     Sat Aug 20 14:08:59 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_axen.c,v 1.93 2022/03/03 05:56:28 riastradh Exp $   */
+/*     $NetBSD: if_axen.c,v 1.94 2022/08/20 14:08:59 riastradh 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.93 2022/03/03 05:56:28 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.94 2022/08/20 14:08:59 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -249,7 +249,7 @@
        rxmode &= ~(AXEN_RXCTL_ACPT_ALL_MCAST | AXEN_RXCTL_PROMISC |
            AXEN_RXCTL_ACPT_MCAST);
 
-       if (ifp->if_flags & IFF_PROMISC) {
+       if (usbnet_ispromisc(un)) {
                DPRINTF(("%s: promisc\n", device_xname(un->un_dev)));
                rxmode |= AXEN_RXCTL_PROMISC;
 allmulti:
diff -r 04cfe1cca5ec -r 77ccd3446a2e sys/dev/usb/if_cue.c
--- a/sys/dev/usb/if_cue.c      Sat Aug 20 14:08:47 2022 +0000
+++ b/sys/dev/usb/if_cue.c      Sat Aug 20 14:08:59 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_cue.c,v 1.106 2022/03/03 05:56:28 riastradh Exp $   */
+/*     $NetBSD: if_cue.c,v 1.107 2022/08/20 14:08:59 riastradh Exp $   */
 
 /*
  * Copyright (c) 1997, 1998, 1999, 2000
@@ -57,7 +57,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_cue.c,v 1.106 2022/03/03 05:56:28 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cue.c,v 1.107 2022/08/20 14:08:59 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -366,10 +366,10 @@
        struct ether_multistep  step;
        uint32_t                h, i;
 
-       DPRINTFN(2,("%s: cue_setiff if_flags=%#x\n",
-           device_xname(un->un_dev), ifp->if_flags));
+       DPRINTFN(2,("%s: cue_setiff promisc=%d\n",
+           device_xname(un->un_dev), usbnet_ispromisc(un)));
 
-       if (ifp->if_flags & IFF_PROMISC) {
+       if (usbnet_ispromisc(un)) {
                ETHER_LOCK(ec);
 allmulti:
                ec->ec_flags |= ETHER_F_ALLMULTI;
@@ -636,7 +636,7 @@
 
        /* Enable RX logic. */
        ctl = CUE_ETHCTL_RX_ON | CUE_ETHCTL_MCAST_ON;
-       if (ifp->if_flags & IFF_PROMISC)
+       if (usbnet_ispromisc(un))
                ctl |= CUE_ETHCTL_PROMISC;
        cue_csr_write_1(un, CUE_ETHCTL, ctl);
 
diff -r 04cfe1cca5ec -r 77ccd3446a2e sys/dev/usb/if_kue.c
--- a/sys/dev/usb/if_kue.c      Sat Aug 20 14:08:47 2022 +0000
+++ b/sys/dev/usb/if_kue.c      Sat Aug 20 14:08:59 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_kue.c,v 1.118 2022/03/03 05:56:28 riastradh Exp $   */
+/*     $NetBSD: if_kue.c,v 1.119 2022/08/20 14:08:59 riastradh Exp $   */
 
 /*
  * Copyright (c) 1997, 1998, 1999, 2000
@@ -71,7 +71,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_kue.c,v 1.118 2022/03/03 05:56:28 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_kue.c,v 1.119 2022/08/20 14:08:59 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -330,12 +330,12 @@
        DPRINTFN(5,("%s: %s: enter\n", device_xname(un->un_dev), __func__));
 
         /* If we want promiscuous mode, set the allframes bit. */
-       if (ifp->if_flags & IFF_PROMISC)
+       if (usbnet_ispromisc(un))
                sc->kue_rxfilt |= KUE_RXFILT_PROMISC;
        else
                sc->kue_rxfilt &= ~KUE_RXFILT_PROMISC;
 
-       if (ifp->if_flags & IFF_PROMISC) {
+       if (usbnet_ispromisc(un)) {
                ETHER_LOCK(ec);
 allmulti:
                ec->ec_flags |= ETHER_F_ALLMULTI;
diff -r 04cfe1cca5ec -r 77ccd3446a2e sys/dev/usb/if_mos.c
--- a/sys/dev/usb/if_mos.c      Sat Aug 20 14:08:47 2022 +0000
+++ b/sys/dev/usb/if_mos.c      Sat Aug 20 14:08:59 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_mos.c,v 1.22 2022/03/03 05:56:28 riastradh Exp $    */
+/*     $NetBSD: if_mos.c,v 1.23 2022/08/20 14:08:59 riastradh Exp $    */
 /*     $OpenBSD: if_mos.c,v 1.40 2019/07/07 06:40:10 kevlo Exp $       */
 
 /*
@@ -72,7 +72,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_mos.c,v 1.22 2022/03/03 05:56:28 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_mos.c,v 1.23 2022/08/20 14:08:59 riastradh Exp $");
 
 #include <sys/param.h>
 
@@ -477,7 +477,7 @@
        rxmode &= ~(MOS_CTL_ALLMULTI | MOS_CTL_RX_PROMISC);
 
        ETHER_LOCK(ec);
-       if (ifp->if_flags & IFF_PROMISC) {
+       if (usbnet_ispromisc(un)) {
                ec->ec_flags |= ETHER_F_ALLMULTI;
                ETHER_UNLOCK(ec);
                /* run promisc. mode */
diff -r 04cfe1cca5ec -r 77ccd3446a2e sys/dev/usb/if_mue.c
--- a/sys/dev/usb/if_mue.c      Sat Aug 20 14:08:47 2022 +0000
+++ b/sys/dev/usb/if_mue.c      Sat Aug 20 14:08:59 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_mue.c,v 1.81 2022/03/03 05:56:28 riastradh Exp $    */
+/*     $NetBSD: if_mue.c,v 1.82 2022/08/20 14:08:59 riastradh Exp $    */
 /*     $OpenBSD: if_mue.c,v 1.3 2018/08/04 16:42:46 jsg Exp $  */
 
 /*
@@ -20,7 +20,7 @@
 /* Driver for Microchip LAN7500/LAN7800 chipsets. */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_mue.c,v 1.81 2022/03/03 05:56:28 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_mue.c,v 1.82 2022/08/20 14:08:59 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -1028,11 +1028,11 @@
        rxfilt |= MUE_RFE_CTL_BROADCAST;
 
        ETHER_LOCK(ec);
-       if (ifp->if_flags & IFF_PROMISC) {
+       if (usbnet_ispromisc(un)) {
                rxfilt |= MUE_RFE_CTL_UNICAST;
 allmulti:      rxfilt |= MUE_RFE_CTL_MULTICAST;
                ec->ec_flags |= ETHER_F_ALLMULTI;
-               if (ifp->if_flags & IFF_PROMISC)
+               if (usbnet_ispromisc(un))
                        DPRINTF(un, "promisc\n");
                else
                        DPRINTF(un, "allmulti\n");
diff -r 04cfe1cca5ec -r 77ccd3446a2e sys/dev/usb/if_smsc.c
--- a/sys/dev/usb/if_smsc.c     Sat Aug 20 14:08:47 2022 +0000
+++ b/sys/dev/usb/if_smsc.c     Sat Aug 20 14:08:59 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_smsc.c,v 1.92 2022/03/03 05:56:28 riastradh Exp $   */
+/*     $NetBSD: if_smsc.c,v 1.93 2022/08/20 14:08:59 riastradh Exp $   */
 
 /*     $OpenBSD: if_smsc.c,v 1.4 2012/09/27 12:38:11 jsg Exp $ */
 /*     $FreeBSD: src/sys/dev/usb/net/if_smsc.c,v 1.1 2012/08/15 04:03:55 gonzo Exp $ */
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_smsc.c,v 1.92 2022/03/03 05:56:28 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_smsc.c,v 1.93 2022/08/20 14:08:59 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -425,7 +425,7 @@
        if (usbnet_isdying(un))
                return;
 
-       if (ifp->if_flags & IFF_PROMISC) {
+       if (usbnet_ispromisc(un)) {
                ETHER_LOCK(ec);
 allmulti:
                ec->ec_flags |= ETHER_F_ALLMULTI;
diff -r 04cfe1cca5ec -r 77ccd3446a2e sys/dev/usb/if_udav.c
--- a/sys/dev/usb/if_udav.c     Sat Aug 20 14:08:47 2022 +0000
+++ b/sys/dev/usb/if_udav.c     Sat Aug 20 14:08:59 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_udav.c,v 1.97 2022/03/03 05:56:28 riastradh Exp $   */
+/*     $NetBSD: if_udav.c,v 1.98 2022/08/20 14:08:59 riastradh Exp $   */
 /*     $nabe: if_udav.c,v 1.3 2003/08/21 16:57:19 nabe Exp $   */
 
 /*
@@ -45,7 +45,7 @@
  */



Home | Main Index | Thread Index | Old Index