From 8ef1f631f63e3652fe7ffc4c560b60a132704477 Mon Sep 17 00:00:00 2001 From: Yaroslav Tykhiy Date: Tue, 25 May 2004 14:49:46 +0000 Subject: [PATCH] Teach fxp(4) to control VLAN_MTU in the hardware. Now reception of extended frames can be toggled through ioctl(SIOCSIFCAP). The card will also receive extended frames when in promiscuous mode. --- sys/dev/fxp/if_fxp.c | 24 ++++++++++++++++-------- sys/dev/fxp/if_fxpvar.h | 1 + 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/sys/dev/fxp/if_fxp.c b/sys/dev/fxp/if_fxp.c index 1f04d3a83b0..17abcb08534 100644 --- a/sys/dev/fxp/if_fxp.c +++ b/sys/dev/fxp/if_fxp.c @@ -595,9 +595,6 @@ fxp_attach(device_t dev) /* turn on the extended TxCB feature */ sc->flags |= FXP_FLAG_EXT_TXCB; - - /* enable reception of long frames for VLAN */ - sc->flags |= FXP_FLAG_LONG_PKT_EN; } /* @@ -823,7 +820,7 @@ fxp_attach(device_t dev) */ ifp->if_data.ifi_hdrlen = sizeof(struct ether_vlan_header); ifp->if_capabilities |= IFCAP_VLAN_MTU; - ifp->if_capenable |= IFCAP_VLAN_MTU; + /* this driver lets vlan(4) control the bit in if_capenable via ioctl */ /* * Let the system queue as many packets as we have available @@ -2086,7 +2083,7 @@ fxp_init_body(struct fxp_softc *sc) cbp->ext_txcb_dis = sc->flags & FXP_FLAG_EXT_TXCB ? 0 : 1; cbp->ext_stats_dis = 1; /* disable extended counters */ cbp->keep_overrun_rx = 0; /* don't pass overrun frames to host */ - cbp->save_bf = sc->revision == FXP_REV_82557 ? 1 : prm; + cbp->save_bf = sc->flags & FXP_FLAG_SAVE_BAD ? 1 : prm; cbp->disc_short_rx = !prm; /* discard short packets */ cbp->underrun_retry = 1; /* retry mode (once) on DMA underrun */ cbp->two_frames = 0; /* do not limit FIFO to 2 frames */ @@ -2430,7 +2427,7 @@ fxp_ioctl(struct ifnet *ifp, u_long command, caddr_t data) struct fxp_softc *sc = ifp->if_softc; struct ifreq *ifr = (struct ifreq *)data; struct mii_data *mii; - int s, error = 0; + int flag, mask, s, error = 0; /* * Detaching causes us to call ioctl with the mutex owned. Preclude @@ -2496,8 +2493,19 @@ fxp_ioctl(struct ifnet *ifp, u_long command, caddr_t data) break; case SIOCSIFCAP: - ifp->if_capenable &= ~IFCAP_POLLING; - ifp->if_capenable |= ifr->ifr_reqcap & IFCAP_POLLING; + mask = ifp->if_capenable ^ ifr->ifr_reqcap; + if (mask & IFCAP_POLLING) + ifp->if_capenable ^= IFCAP_POLLING; + if (mask & IFCAP_VLAN_MTU) { + ifp->if_capenable ^= IFCAP_VLAN_MTU; + if (sc->revision != FXP_REV_82557) + flag = FXP_FLAG_LONG_PKT_EN; + else /* a hack to get long frames on the old chip */ + flag = FXP_FLAG_SAVE_BAD; + sc->flags ^= flag; + if (ifp->if_flags & IFF_UP) + fxp_init_body(sc); + } break; default: diff --git a/sys/dev/fxp/if_fxpvar.h b/sys/dev/fxp/if_fxpvar.h index afe7c48bfd0..7515861e8df 100644 --- a/sys/dev/fxp/if_fxpvar.h +++ b/sys/dev/fxp/if_fxpvar.h @@ -209,6 +209,7 @@ struct fxp_softc { #define FXP_FLAG_UCODE 0x0100 /* ucode is loaded */ #define FXP_FLAG_DEFERRED_RNR 0x0200 /* DEVICE_POLLING deferred RNR */ #define FXP_FLAG_EXT_RFA 0x0400 /* extended RFDs for csum offload */ +#define FXP_FLAG_SAVE_BAD 0x0800 /* save bad pkts: bad size, CRC, etc */ /* Macros to ease CSR access. */ #define CSR_READ_1(sc, reg) \