summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorBrad Smith <brad@cvs.openbsd.org>2006-08-04 14:25:25 +0000
committerBrad Smith <brad@cvs.openbsd.org>2006-08-04 14:25:25 +0000
commit237f09610d31e6aab8bb7598080f081cad6c2eaa (patch)
treebeb7e5f80cd0371fb73f08025f4f9527e84dd2e6 /sys
parentcb8596e5bd5ef2ea2c011bb81cc32c19dabf58f7 (diff)
- merge em/ixgb_disable_promisc() into em/ixgb_set_promisc().
- rearrange interface flags ioctl handler.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/pci/if_em.c40
-rw-r--r--sys/dev/pci/if_em.h3
-rw-r--r--sys/dev/pci/if_ixgb.c38
-rw-r--r--sys/dev/pci/if_ixgb.h3
4 files changed, 38 insertions, 46 deletions
diff --git a/sys/dev/pci/if_em.c b/sys/dev/pci/if_em.c
index 58a675ab87a..e854f9a0e15 100644
--- a/sys/dev/pci/if_em.c
+++ b/sys/dev/pci/if_em.c
@@ -31,7 +31,7 @@ POSSIBILITY OF SUCH DAMAGE.
***************************************************************************/
-/* $OpenBSD: if_em.c,v 1.140 2006/08/04 02:44:50 brad Exp $ */
+/* $OpenBSD: if_em.c,v 1.141 2006/08/04 14:25:24 brad Exp $ */
/* $FreeBSD: if_em.c,v 1.46 2004/09/29 18:28:28 mlaier Exp $ */
#include <dev/pci/if_em.h>
@@ -158,7 +158,6 @@ void em_receive_checksum(struct em_softc *, struct em_rx_desc *,
void em_transmit_checksum_setup(struct em_softc *, struct mbuf *,
u_int32_t *, u_int32_t *);
void em_set_promisc(struct em_softc *);
-void em_disable_promisc(struct em_softc *);
void em_set_multi(struct em_softc *);
void em_print_hw_stats(struct em_softc *);
void em_update_link_status(struct em_softc *);
@@ -519,15 +518,24 @@ em_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
case SIOCSIFFLAGS:
IOCTL_DEBUGOUT("ioctl rcv'd: SIOCSIFFLAGS (Set Interface Flags)");
if (ifp->if_flags & IFF_UP) {
- if (!(ifp->if_flags & IFF_RUNNING))
- em_init(sc);
-
- em_disable_promisc(sc);
- em_set_promisc(sc);
+ /*
+ * If only the PROMISC or ALLMULTI flag changes, then
+ * don't do a full re-init of the chip, just update
+ * the Rx filter.
+ */
+ if ((ifp->if_flags & IFF_RUNNING) &&
+ ((ifp->if_flags ^ sc->if_flags) &
+ (IFF_ALLMULTI | IFF_PROMISC)) != 0) {
+ em_set_promisc(sc);
+ } else {
+ if (!(ifp->if_flags & IFF_RUNNING))
+ em_init(sc);
+ }
} else {
if (ifp->if_flags & IFF_RUNNING)
em_stop(sc);
}
+ sc->if_flags = ifp->if_flags;
break;
case SIOCADDMULTI:
case SIOCDELMULTI:
@@ -1150,35 +1158,21 @@ void
em_set_promisc(struct em_softc *sc)
{
u_int32_t reg_rctl;
- u_int32_t ctrl;
struct ifnet *ifp = &sc->interface_data.ac_if;
reg_rctl = E1000_READ_REG(&sc->hw, RCTL);
- ctrl = E1000_READ_REG(&sc->hw, CTRL);
if (ifp->if_flags & IFF_PROMISC) {
reg_rctl |= (E1000_RCTL_UPE | E1000_RCTL_MPE);
- E1000_WRITE_REG(&sc->hw, RCTL, reg_rctl);
} else if (ifp->if_flags & IFF_ALLMULTI) {
reg_rctl |= E1000_RCTL_MPE;
reg_rctl &= ~E1000_RCTL_UPE;
- E1000_WRITE_REG(&sc->hw, RCTL, reg_rctl);
+ } else {
+ reg_rctl &= ~(E1000_RCTL_UPE | E1000_RCTL_MPE);
}
-}
-
-void
-em_disable_promisc(struct em_softc *sc)
-{
- u_int32_t reg_rctl;
-
- reg_rctl = E1000_READ_REG(&sc->hw, RCTL);
-
- reg_rctl &= (~E1000_RCTL_UPE);
- reg_rctl &= (~E1000_RCTL_MPE);
E1000_WRITE_REG(&sc->hw, RCTL, reg_rctl);
}
-
/*********************************************************************
* Multicast Update
*
diff --git a/sys/dev/pci/if_em.h b/sys/dev/pci/if_em.h
index af01b8a70c3..de249735763 100644
--- a/sys/dev/pci/if_em.h
+++ b/sys/dev/pci/if_em.h
@@ -32,7 +32,7 @@ POSSIBILITY OF SUCH DAMAGE.
***************************************************************************/
/* $FreeBSD: if_em.h,v 1.26 2004/09/01 23:22:41 pdeuskar Exp $ */
-/* $OpenBSD: if_em.h,v 1.26 2006/07/07 02:56:18 brad Exp $ */
+/* $OpenBSD: if_em.h,v 1.27 2006/08/04 14:25:24 brad Exp $ */
#ifndef _EM_H_DEFINED_
#define _EM_H_DEFINED_
@@ -306,6 +306,7 @@ struct em_softc {
struct timeout em_intr_enable;
struct timeout timer_handle;
struct timeout tx_fifo_timer_handle;
+ int if_flags;
void *sc_powerhook;
void *sc_shutdownhook;
diff --git a/sys/dev/pci/if_ixgb.c b/sys/dev/pci/if_ixgb.c
index 448668c052e..4739046c00f 100644
--- a/sys/dev/pci/if_ixgb.c
+++ b/sys/dev/pci/if_ixgb.c
@@ -31,7 +31,7 @@ POSSIBILITY OF SUCH DAMAGE.
***************************************************************************/
-/* $OpenBSD: if_ixgb.c,v 1.23 2006/08/04 02:44:50 brad Exp $ */
+/* $OpenBSD: if_ixgb.c,v 1.24 2006/08/04 14:25:24 brad Exp $ */
#include <dev/pci/if_ixgb.h>
@@ -100,7 +100,6 @@ ixgb_transmit_checksum_setup(struct ixgb_softc *,
struct mbuf *,
u_int8_t *);
void ixgb_set_promisc(struct ixgb_softc *);
-void ixgb_disable_promisc(struct ixgb_softc *);
void ixgb_set_multi(struct ixgb_softc *);
void ixgb_print_hw_stats(struct ixgb_softc *);
void ixgb_update_link_status(struct ixgb_softc *);
@@ -379,15 +378,24 @@ ixgb_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
case SIOCSIFFLAGS:
IOCTL_DEBUGOUT("ioctl rcv'd: SIOCSIFFLAGS (Set Interface Flags)");
if (ifp->if_flags & IFF_UP) {
- if (!(ifp->if_flags & IFF_RUNNING))
- ixgb_init(sc);
-
- ixgb_disable_promisc(sc);
- ixgb_set_promisc(sc);
+ /*
+ * If only the PROMISC or ALLMULTI flag changes, then
+ * don't do a full re-init of the chip, just update
+ * the Rx filter.
+ */
+ if ((ifp->if_flags & IFF_RUNNING) &&
+ ((ifp->if_flags ^ sc->if_flags) &
+ (IFF_ALLMULTI | IFF_PROMISC)) != 0) {
+ ixgb_set_promisc(sc);
+ } else {
+ if (!(ifp->if_flags & IFF_RUNNING))
+ ixgb_init(sc);
+ }
} else {
if (ifp->if_flags & IFF_RUNNING)
ixgb_stop(sc);
}
+ sc->if_flags = ifp->if_flags;
break;
case SIOCADDMULTI:
case SIOCDELMULTI:
@@ -745,27 +753,15 @@ ixgb_set_promisc(struct ixgb_softc *sc)
if (ifp->if_flags & IFF_PROMISC) {
reg_rctl |= (IXGB_RCTL_UPE | IXGB_RCTL_MPE);
- IXGB_WRITE_REG(&sc->hw, RCTL, reg_rctl);
} else if (ifp->if_flags & IFF_ALLMULTI) {
reg_rctl |= IXGB_RCTL_MPE;
reg_rctl &= ~IXGB_RCTL_UPE;
- IXGB_WRITE_REG(&sc->hw, RCTL, reg_rctl);
+ } else {
+ reg_rctl &= ~(IXGB_RCTL_UPE | IXGB_RCTL_MPE);
}
-}
-
-void
-ixgb_disable_promisc(struct ixgb_softc *sc)
-{
- u_int32_t reg_rctl;
-
- reg_rctl = IXGB_READ_REG(&sc->hw, RCTL);
-
- reg_rctl &= (~IXGB_RCTL_UPE);
- reg_rctl &= (~IXGB_RCTL_MPE);
IXGB_WRITE_REG(&sc->hw, RCTL, reg_rctl);
}
-
/*********************************************************************
* Multicast Update
*
diff --git a/sys/dev/pci/if_ixgb.h b/sys/dev/pci/if_ixgb.h
index 496c1e4e044..14ef828665d 100644
--- a/sys/dev/pci/if_ixgb.h
+++ b/sys/dev/pci/if_ixgb.h
@@ -31,7 +31,7 @@ POSSIBILITY OF SUCH DAMAGE.
***************************************************************************/
-/* $OpenBSD: if_ixgb.h,v 1.7 2006/07/21 01:49:15 brad Exp $ */
+/* $OpenBSD: if_ixgb.h,v 1.8 2006/08/04 14:25:24 brad Exp $ */
#ifndef _IXGB_H_DEFINED_
#define _IXGB_H_DEFINED_
@@ -245,6 +245,7 @@ struct ixgb_softc {
void *sc_intrhand;
struct timeout ixgb_intr_enable;
struct timeout timer_handle;
+ int if_flags;
void *sc_powerhook;
void *sc_shutdownhook;