2001-03-12 21:30:52 +00:00
|
|
|
/*-
|
1995-11-28 23:55:26 +00:00
|
|
|
* Copyright (c) 1995, David Greenman
|
2001-03-14 19:50:35 +00:00
|
|
|
* Copyright (c) 2001 Jonathan Lemon <jlemon@freebsd.org>
|
1995-11-28 23:55:26 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice unmodified, this list of conditions, and the following
|
|
|
|
* disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2003-08-24 17:55:58 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
1995-11-28 23:55:26 +00:00
|
|
|
/*
|
1996-01-15 10:12:41 +00:00
|
|
|
* Intel EtherExpress Pro/100B PCI Fast Ethernet driver
|
1995-11-28 23:55:26 +00:00
|
|
|
*/
|
|
|
|
|
2005-10-05 10:09:17 +00:00
|
|
|
#ifdef HAVE_KERNEL_OPTION_HEADERS
|
|
|
|
#include "opt_device_polling.h"
|
|
|
|
#endif
|
|
|
|
|
1995-11-28 23:55:26 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
2008-11-25 00:59:11 +00:00
|
|
|
#include <sys/bus.h>
|
2003-04-06 01:04:17 +00:00
|
|
|
#include <sys/endian.h>
|
1995-11-28 23:55:26 +00:00
|
|
|
#include <sys/kernel.h>
|
2008-11-25 00:59:11 +00:00
|
|
|
#include <sys/mbuf.h>
|
2008-12-08 03:48:03 +00:00
|
|
|
#include <sys/lock.h>
|
2004-05-30 20:08:47 +00:00
|
|
|
#include <sys/module.h>
|
2008-12-08 03:48:03 +00:00
|
|
|
#include <sys/mutex.h>
|
2008-11-25 00:59:11 +00:00
|
|
|
#include <sys/rman.h>
|
1996-10-12 19:49:43 +00:00
|
|
|
#include <sys/socket.h>
|
2008-11-25 00:59:11 +00:00
|
|
|
#include <sys/sockio.h>
|
2001-10-25 05:32:01 +00:00
|
|
|
#include <sys/sysctl.h>
|
1995-11-28 23:55:26 +00:00
|
|
|
|
2008-11-25 00:59:11 +00:00
|
|
|
#include <net/bpf.h>
|
|
|
|
#include <net/ethernet.h>
|
1995-11-28 23:55:26 +00:00
|
|
|
#include <net/if.h>
|
2008-11-25 00:59:11 +00:00
|
|
|
#include <net/if_arp.h>
|
1997-09-29 11:27:43 +00:00
|
|
|
#include <net/if_dl.h>
|
1997-09-05 10:23:58 +00:00
|
|
|
#include <net/if_media.h>
|
2008-11-25 00:59:11 +00:00
|
|
|
#include <net/if_types.h>
|
|
|
|
#include <net/if_vlan_var.h>
|
1995-11-28 23:55:26 +00:00
|
|
|
|
2003-02-26 22:12:04 +00:00
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <netinet/in_systm.h>
|
|
|
|
#include <netinet/ip.h>
|
2008-11-26 06:36:53 +00:00
|
|
|
#include <netinet/tcp.h>
|
|
|
|
#include <netinet/udp.h>
|
|
|
|
|
|
|
|
#include <machine/bus.h>
|
2003-02-26 22:12:04 +00:00
|
|
|
#include <machine/in_cksum.h>
|
2008-11-26 06:36:53 +00:00
|
|
|
#include <machine/resource.h>
|
2003-02-26 22:12:04 +00:00
|
|
|
|
2003-08-22 05:54:52 +00:00
|
|
|
#include <dev/pci/pcivar.h>
|
|
|
|
#include <dev/pci/pcireg.h> /* for PCIM_CMD_xxx */
|
1995-11-28 23:55:26 +00:00
|
|
|
|
2001-03-12 21:30:52 +00:00
|
|
|
#include <dev/mii/mii.h>
|
|
|
|
#include <dev/mii/miivar.h>
|
|
|
|
|
|
|
|
#include <dev/fxp/if_fxpreg.h>
|
|
|
|
#include <dev/fxp/if_fxpvar.h>
|
2001-10-25 05:32:01 +00:00
|
|
|
#include <dev/fxp/rcvbundl.h>
|
2001-03-12 21:30:52 +00:00
|
|
|
|
2003-04-15 06:37:30 +00:00
|
|
|
MODULE_DEPEND(fxp, pci, 1, 1, 1);
|
|
|
|
MODULE_DEPEND(fxp, ether, 1, 1, 1);
|
2001-03-12 21:30:52 +00:00
|
|
|
MODULE_DEPEND(fxp, miibus, 1, 1, 1);
|
|
|
|
#include "miibus_if.h"
|
1999-09-30 19:03:12 +00:00
|
|
|
|
1997-09-05 10:23:58 +00:00
|
|
|
/*
|
2011-02-26 17:28:09 +00:00
|
|
|
* NOTE! On !x86 we typically have an alignment constraint. The
|
1997-09-05 10:23:58 +00:00
|
|
|
* card DMAs the packet immediately following the RFA. However,
|
|
|
|
* the first thing in the packet is a 14-byte Ethernet header.
|
|
|
|
* This means that the packet is misaligned. To compensate,
|
|
|
|
* we actually offset the RFA 2 bytes into the cluster. This
|
|
|
|
* alignes the packet after the Ethernet header at a 32-bit
|
|
|
|
* boundary. HOWEVER! This means that the RFA is misaligned!
|
|
|
|
*/
|
|
|
|
#define RFA_ALIGNMENT_FUDGE 2
|
|
|
|
|
|
|
|
/*
|
2001-03-12 21:30:52 +00:00
|
|
|
* Set initial transmit threshold at 64 (512 bytes). This is
|
|
|
|
* increased by 64 (512 bytes) at a time, to maximum of 192
|
|
|
|
* (1536 bytes), if an underrun occurs.
|
1997-09-05 10:23:58 +00:00
|
|
|
*/
|
2001-03-12 21:30:52 +00:00
|
|
|
static int tx_threshold = 64;
|
1995-11-28 23:55:26 +00:00
|
|
|
|
|
|
|
/*
|
2001-03-12 21:30:52 +00:00
|
|
|
* The configuration byte map has several undefined fields which
|
2010-05-07 18:03:35 +00:00
|
|
|
* must be one or must be zero. Set up a template for these bits.
|
2010-11-23 21:09:42 +00:00
|
|
|
* The actual configuration is performed in fxp_init_body.
|
2001-03-12 21:30:52 +00:00
|
|
|
*
|
1995-11-28 23:55:26 +00:00
|
|
|
* See struct fxp_cb_config for the bit definitions.
|
|
|
|
*/
|
2012-11-05 19:16:27 +00:00
|
|
|
static const u_char fxp_cb_config_template[] = {
|
1995-11-28 23:55:26 +00:00
|
|
|
0x0, 0x0, /* cb_status */
|
2001-03-12 21:30:52 +00:00
|
|
|
0x0, 0x0, /* cb_command */
|
|
|
|
0x0, 0x0, 0x0, 0x0, /* link_addr */
|
|
|
|
0x0, /* 0 */
|
|
|
|
0x0, /* 1 */
|
1995-11-28 23:55:26 +00:00
|
|
|
0x0, /* 2 */
|
|
|
|
0x0, /* 3 */
|
|
|
|
0x0, /* 4 */
|
2001-03-12 21:30:52 +00:00
|
|
|
0x0, /* 5 */
|
|
|
|
0x32, /* 6 */
|
|
|
|
0x0, /* 7 */
|
|
|
|
0x0, /* 8 */
|
1995-11-28 23:55:26 +00:00
|
|
|
0x0, /* 9 */
|
2001-03-12 21:30:52 +00:00
|
|
|
0x6, /* 10 */
|
1995-11-28 23:55:26 +00:00
|
|
|
0x0, /* 11 */
|
2001-03-12 21:30:52 +00:00
|
|
|
0x0, /* 12 */
|
1995-11-28 23:55:26 +00:00
|
|
|
0x0, /* 13 */
|
|
|
|
0xf2, /* 14 */
|
|
|
|
0x48, /* 15 */
|
|
|
|
0x0, /* 16 */
|
|
|
|
0x40, /* 17 */
|
2001-03-12 21:30:52 +00:00
|
|
|
0xf0, /* 18 */
|
1995-11-28 23:55:26 +00:00
|
|
|
0x0, /* 19 */
|
|
|
|
0x3f, /* 20 */
|
2010-05-07 18:03:35 +00:00
|
|
|
0x5, /* 21 */
|
|
|
|
0x0, /* 22 */
|
|
|
|
0x0, /* 23 */
|
|
|
|
0x0, /* 24 */
|
|
|
|
0x0, /* 25 */
|
|
|
|
0x0, /* 26 */
|
|
|
|
0x0, /* 27 */
|
|
|
|
0x0, /* 28 */
|
|
|
|
0x0, /* 29 */
|
|
|
|
0x0, /* 30 */
|
|
|
|
0x0 /* 31 */
|
1995-11-28 23:55:26 +00:00
|
|
|
};
|
|
|
|
|
2001-03-12 21:30:52 +00:00
|
|
|
/*
|
|
|
|
* Claim various Intel PCI device identifiers for this driver. The
|
|
|
|
* sub-vendor and sub-device field are extensively used to identify
|
|
|
|
* particular variants, but we don't currently differentiate between
|
|
|
|
* them.
|
|
|
|
*/
|
2012-11-05 19:16:27 +00:00
|
|
|
static const struct fxp_ident fxp_ident_table[] = {
|
2009-06-21 07:34:12 +00:00
|
|
|
{ 0x1029, -1, 0, "Intel 82559 PCI/CardBus Pro/100" },
|
|
|
|
{ 0x1030, -1, 0, "Intel 82559 Pro/100 Ethernet" },
|
|
|
|
{ 0x1031, -1, 3, "Intel 82801CAM (ICH3) Pro/100 VE Ethernet" },
|
|
|
|
{ 0x1032, -1, 3, "Intel 82801CAM (ICH3) Pro/100 VE Ethernet" },
|
|
|
|
{ 0x1033, -1, 3, "Intel 82801CAM (ICH3) Pro/100 VM Ethernet" },
|
|
|
|
{ 0x1034, -1, 3, "Intel 82801CAM (ICH3) Pro/100 VM Ethernet" },
|
|
|
|
{ 0x1035, -1, 3, "Intel 82801CAM (ICH3) Pro/100 Ethernet" },
|
|
|
|
{ 0x1036, -1, 3, "Intel 82801CAM (ICH3) Pro/100 Ethernet" },
|
|
|
|
{ 0x1037, -1, 3, "Intel 82801CAM (ICH3) Pro/100 Ethernet" },
|
|
|
|
{ 0x1038, -1, 3, "Intel 82801CAM (ICH3) Pro/100 VM Ethernet" },
|
|
|
|
{ 0x1039, -1, 4, "Intel 82801DB (ICH4) Pro/100 VE Ethernet" },
|
|
|
|
{ 0x103A, -1, 4, "Intel 82801DB (ICH4) Pro/100 Ethernet" },
|
|
|
|
{ 0x103B, -1, 4, "Intel 82801DB (ICH4) Pro/100 VM Ethernet" },
|
|
|
|
{ 0x103C, -1, 4, "Intel 82801DB (ICH4) Pro/100 Ethernet" },
|
|
|
|
{ 0x103D, -1, 4, "Intel 82801DB (ICH4) Pro/100 VE Ethernet" },
|
|
|
|
{ 0x103E, -1, 4, "Intel 82801DB (ICH4) Pro/100 VM Ethernet" },
|
|
|
|
{ 0x1050, -1, 5, "Intel 82801BA (D865) Pro/100 VE Ethernet" },
|
|
|
|
{ 0x1051, -1, 5, "Intel 82562ET (ICH5/ICH5R) Pro/100 VE Ethernet" },
|
|
|
|
{ 0x1059, -1, 0, "Intel 82551QM Pro/100 M Mobile Connection" },
|
|
|
|
{ 0x1064, -1, 6, "Intel 82562EZ (ICH6)" },
|
|
|
|
{ 0x1065, -1, 6, "Intel 82562ET/EZ/GT/GZ PRO/100 VE Ethernet" },
|
|
|
|
{ 0x1068, -1, 6, "Intel 82801FBM (ICH6-M) Pro/100 VE Ethernet" },
|
|
|
|
{ 0x1069, -1, 6, "Intel 82562EM/EX/GX Pro/100 Ethernet" },
|
|
|
|
{ 0x1091, -1, 7, "Intel 82562GX Pro/100 Ethernet" },
|
|
|
|
{ 0x1092, -1, 7, "Intel Pro/100 VE Network Connection" },
|
|
|
|
{ 0x1093, -1, 7, "Intel Pro/100 VM Network Connection" },
|
|
|
|
{ 0x1094, -1, 7, "Intel Pro/100 946GZ (ICH7) Network Connection" },
|
|
|
|
{ 0x1209, -1, 0, "Intel 82559ER Embedded 10/100 Ethernet" },
|
|
|
|
{ 0x1229, 0x01, 0, "Intel 82557 Pro/100 Ethernet" },
|
|
|
|
{ 0x1229, 0x02, 0, "Intel 82557 Pro/100 Ethernet" },
|
|
|
|
{ 0x1229, 0x03, 0, "Intel 82557 Pro/100 Ethernet" },
|
|
|
|
{ 0x1229, 0x04, 0, "Intel 82558 Pro/100 Ethernet" },
|
|
|
|
{ 0x1229, 0x05, 0, "Intel 82558 Pro/100 Ethernet" },
|
|
|
|
{ 0x1229, 0x06, 0, "Intel 82559 Pro/100 Ethernet" },
|
|
|
|
{ 0x1229, 0x07, 0, "Intel 82559 Pro/100 Ethernet" },
|
|
|
|
{ 0x1229, 0x08, 0, "Intel 82559 Pro/100 Ethernet" },
|
|
|
|
{ 0x1229, 0x09, 0, "Intel 82559ER Pro/100 Ethernet" },
|
|
|
|
{ 0x1229, 0x0c, 0, "Intel 82550 Pro/100 Ethernet" },
|
2012-03-28 01:08:55 +00:00
|
|
|
{ 0x1229, 0x0d, 0, "Intel 82550C Pro/100 Ethernet" },
|
2009-06-21 07:34:12 +00:00
|
|
|
{ 0x1229, 0x0e, 0, "Intel 82550 Pro/100 Ethernet" },
|
|
|
|
{ 0x1229, 0x0f, 0, "Intel 82551 Pro/100 Ethernet" },
|
|
|
|
{ 0x1229, 0x10, 0, "Intel 82551 Pro/100 Ethernet" },
|
|
|
|
{ 0x1229, -1, 0, "Intel 82557/8/9 Pro/100 Ethernet" },
|
|
|
|
{ 0x2449, -1, 2, "Intel 82801BA/CAM (ICH2/3) Pro/100 Ethernet" },
|
|
|
|
{ 0x27dc, -1, 7, "Intel 82801GB (ICH7) 10/100 Ethernet" },
|
|
|
|
{ 0, -1, 0, NULL },
|
1997-09-05 10:23:58 +00:00
|
|
|
};
|
|
|
|
|
2003-02-26 22:12:04 +00:00
|
|
|
#ifdef FXP_IP_CSUM_WAR
|
|
|
|
#define FXP_CSUM_FEATURES (CSUM_IP | CSUM_TCP | CSUM_UDP)
|
|
|
|
#else
|
|
|
|
#define FXP_CSUM_FEATURES (CSUM_TCP | CSUM_UDP)
|
|
|
|
#endif
|
|
|
|
|
2001-03-12 21:30:52 +00:00
|
|
|
static int fxp_probe(device_t dev);
|
|
|
|
static int fxp_attach(device_t dev);
|
|
|
|
static int fxp_detach(device_t dev);
|
|
|
|
static int fxp_shutdown(device_t dev);
|
|
|
|
static int fxp_suspend(device_t dev);
|
|
|
|
static int fxp_resume(device_t dev);
|
|
|
|
|
2010-11-23 21:09:42 +00:00
|
|
|
static const struct fxp_ident *fxp_find_ident(device_t dev);
|
2001-03-12 21:30:52 +00:00
|
|
|
static void fxp_intr(void *xsc);
|
2008-11-26 06:36:53 +00:00
|
|
|
static void fxp_rxcsum(struct fxp_softc *sc, struct ifnet *ifp,
|
|
|
|
struct mbuf *m, uint16_t status, int pos);
|
2009-05-30 15:14:44 +00:00
|
|
|
static int fxp_intr_body(struct fxp_softc *sc, struct ifnet *ifp,
|
2005-03-06 05:07:26 +00:00
|
|
|
uint8_t statack, int count);
|
2001-03-12 21:30:52 +00:00
|
|
|
static void fxp_init(void *xsc);
|
2010-11-26 21:52:33 +00:00
|
|
|
static void fxp_init_body(struct fxp_softc *sc, int);
|
2001-03-12 21:30:52 +00:00
|
|
|
static void fxp_tick(void *xsc);
|
|
|
|
static void fxp_start(struct ifnet *ifp);
|
Make fxp(4) INTR_MPSAFE (but do not enable MPSAFE just yet):
- Add fxp_start_body() and change fxp_start() to just acquire locks and
then call fxp_start_body(). Places that would call fxp_start() with
locks held (mutex recursion) now call fxp_start_body() directly.
Remove MTX_RECURSE flag from sc_mtx. [gallatin]
- Change fxp_attach() to work without the softc lock, saving interrupt
hooking until the head of fxp_attach().
- Call ether_ifattach() before overriding ifp parameters. This reverts
part of 1.155.
- Remove multiple error paths in fxp_attach().
- Teardown interrupt in fxp_detach() before unlocking the softc.
- Make sure mutex is not held in fxp_release()
- Delete the miibus instance and/or self in fxp_release(), not in
fxp_detach(). This can happen if attach fails partway through.
- Move ifmedia_removeall to fxp_release() since attach may fail after
media have been allocated.
- Add locking to fxp_suspend, fxp_resume, fxp_start, fxp_intr,
fxp_poll, fxp_tick, fxp_ioctl, fxp_watchdog.
- Pass in ifp to fxp_intr_body since its callers sometimes already use
it.
- Add compatibility define for INTR_MPSAFE for 4.x. [gallatin]
- You don't need to bzero softc.
Ideas from: gallatin, mux
Tested by: >400M packets of dd/ssh, NFS, ping on i386 UP
2003-04-25 09:01:54 +00:00
|
|
|
static void fxp_start_body(struct ifnet *ifp);
|
2008-11-25 04:16:16 +00:00
|
|
|
static int fxp_encap(struct fxp_softc *sc, struct mbuf **m_head);
|
|
|
|
static void fxp_txeof(struct fxp_softc *sc);
|
2001-03-12 21:30:52 +00:00
|
|
|
static void fxp_stop(struct fxp_softc *sc);
|
|
|
|
static void fxp_release(struct fxp_softc *sc);
|
|
|
|
static int fxp_ioctl(struct ifnet *ifp, u_long command,
|
|
|
|
caddr_t data);
|
2006-11-30 14:58:01 +00:00
|
|
|
static void fxp_watchdog(struct fxp_softc *sc);
|
2008-11-26 05:51:49 +00:00
|
|
|
static void fxp_add_rfabuf(struct fxp_softc *sc,
|
2012-03-14 00:54:37 +00:00
|
|
|
struct fxp_rx *rxp);
|
2008-11-26 05:51:49 +00:00
|
|
|
static void fxp_discard_rfabuf(struct fxp_softc *sc,
|
2012-03-14 00:54:37 +00:00
|
|
|
struct fxp_rx *rxp);
|
2008-11-26 05:51:49 +00:00
|
|
|
static int fxp_new_rfabuf(struct fxp_softc *sc,
|
2012-03-14 00:54:37 +00:00
|
|
|
struct fxp_rx *rxp);
|
2002-01-07 15:08:54 +00:00
|
|
|
static int fxp_mc_addrs(struct fxp_softc *sc);
|
2001-03-12 21:30:52 +00:00
|
|
|
static void fxp_mc_setup(struct fxp_softc *sc);
|
2005-03-06 05:07:26 +00:00
|
|
|
static uint16_t fxp_eeprom_getword(struct fxp_softc *sc, int offset,
|
2001-03-12 21:30:52 +00:00
|
|
|
int autosize);
|
2001-08-27 16:07:12 +00:00
|
|
|
static void fxp_eeprom_putword(struct fxp_softc *sc, int offset,
|
2005-03-06 05:07:26 +00:00
|
|
|
uint16_t data);
|
2001-03-12 21:30:52 +00:00
|
|
|
static void fxp_autosize_eeprom(struct fxp_softc *sc);
|
2012-03-28 01:27:27 +00:00
|
|
|
static void fxp_load_eeprom(struct fxp_softc *sc);
|
2001-03-12 21:30:52 +00:00
|
|
|
static void fxp_read_eeprom(struct fxp_softc *sc, u_short *data,
|
|
|
|
int offset, int words);
|
2001-08-27 16:07:12 +00:00
|
|
|
static void fxp_write_eeprom(struct fxp_softc *sc, u_short *data,
|
|
|
|
int offset, int words);
|
2001-03-12 21:30:52 +00:00
|
|
|
static int fxp_ifmedia_upd(struct ifnet *ifp);
|
|
|
|
static void fxp_ifmedia_sts(struct ifnet *ifp,
|
|
|
|
struct ifmediareq *ifmr);
|
|
|
|
static int fxp_serial_ifmedia_upd(struct ifnet *ifp);
|
|
|
|
static void fxp_serial_ifmedia_sts(struct ifnet *ifp,
|
|
|
|
struct ifmediareq *ifmr);
|
2007-05-30 03:46:04 +00:00
|
|
|
static int fxp_miibus_readreg(device_t dev, int phy, int reg);
|
2009-02-05 19:33:35 +00:00
|
|
|
static int fxp_miibus_writereg(device_t dev, int phy, int reg,
|
2001-03-12 21:30:52 +00:00
|
|
|
int value);
|
2010-11-26 21:52:33 +00:00
|
|
|
static void fxp_miibus_statchg(device_t dev);
|
2001-10-25 05:32:01 +00:00
|
|
|
static void fxp_load_ucode(struct fxp_softc *sc);
|
2010-05-09 22:16:15 +00:00
|
|
|
static void fxp_update_stats(struct fxp_softc *sc);
|
|
|
|
static void fxp_sysctl_node(struct fxp_softc *sc);
|
2001-10-25 05:32:01 +00:00
|
|
|
static int sysctl_int_range(SYSCTL_HANDLER_ARGS,
|
|
|
|
int low, int high);
|
|
|
|
static int sysctl_hw_fxp_bundle_max(SYSCTL_HANDLER_ARGS);
|
|
|
|
static int sysctl_hw_fxp_int_delay(SYSCTL_HANDLER_ARGS);
|
2003-07-22 15:50:54 +00:00
|
|
|
static void fxp_scb_wait(struct fxp_softc *sc);
|
|
|
|
static void fxp_scb_cmd(struct fxp_softc *sc, int cmd);
|
|
|
|
static void fxp_dma_wait(struct fxp_softc *sc,
|
2012-03-14 00:54:37 +00:00
|
|
|
volatile uint16_t *status, bus_dma_tag_t dmat,
|
2003-04-08 18:56:45 +00:00
|
|
|
bus_dmamap_t map);
|
1995-11-28 23:55:26 +00:00
|
|
|
|
2001-03-12 21:30:52 +00:00
|
|
|
static device_method_t fxp_methods[] = {
|
|
|
|
/* Device interface */
|
|
|
|
DEVMETHOD(device_probe, fxp_probe),
|
|
|
|
DEVMETHOD(device_attach, fxp_attach),
|
|
|
|
DEVMETHOD(device_detach, fxp_detach),
|
|
|
|
DEVMETHOD(device_shutdown, fxp_shutdown),
|
|
|
|
DEVMETHOD(device_suspend, fxp_suspend),
|
|
|
|
DEVMETHOD(device_resume, fxp_resume),
|
1996-09-19 09:15:20 +00:00
|
|
|
|
2001-03-12 21:30:52 +00:00
|
|
|
/* MII interface */
|
|
|
|
DEVMETHOD(miibus_readreg, fxp_miibus_readreg),
|
|
|
|
DEVMETHOD(miibus_writereg, fxp_miibus_writereg),
|
2010-11-26 21:52:33 +00:00
|
|
|
DEVMETHOD(miibus_statchg, fxp_miibus_statchg),
|
1995-11-28 23:55:26 +00:00
|
|
|
|
2012-05-11 02:40:40 +00:00
|
|
|
DEVMETHOD_END
|
2001-03-12 21:30:52 +00:00
|
|
|
};
|
1998-08-04 08:53:12 +00:00
|
|
|
|
2001-03-12 21:30:52 +00:00
|
|
|
static driver_t fxp_driver = {
|
|
|
|
"fxp",
|
|
|
|
fxp_methods,
|
|
|
|
sizeof(struct fxp_softc),
|
|
|
|
};
|
1995-11-28 23:55:26 +00:00
|
|
|
|
2001-03-12 21:30:52 +00:00
|
|
|
static devclass_t fxp_devclass;
|
|
|
|
|
2012-05-11 02:40:40 +00:00
|
|
|
DRIVER_MODULE_ORDERED(fxp, pci, fxp_driver, fxp_devclass, NULL, NULL,
|
|
|
|
SI_ORDER_ANY);
|
|
|
|
DRIVER_MODULE(miibus, fxp, miibus_driver, miibus_devclass, NULL, NULL);
|
1995-11-28 23:55:26 +00:00
|
|
|
|
2005-09-27 09:01:11 +00:00
|
|
|
static struct resource_spec fxp_res_spec_mem[] = {
|
|
|
|
{ SYS_RES_MEMORY, FXP_PCI_MMBA, RF_ACTIVE },
|
|
|
|
{ SYS_RES_IRQ, 0, RF_ACTIVE | RF_SHAREABLE },
|
|
|
|
{ -1, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct resource_spec fxp_res_spec_io[] = {
|
|
|
|
{ SYS_RES_IOPORT, FXP_PCI_IOBA, RF_ACTIVE },
|
|
|
|
{ SYS_RES_IRQ, 0, RF_ACTIVE | RF_SHAREABLE },
|
|
|
|
{ -1, 0 }
|
|
|
|
};
|
|
|
|
|
1995-12-01 22:41:56 +00:00
|
|
|
/*
|
|
|
|
* Wait for the previous command to be accepted (but not necessarily
|
|
|
|
* completed).
|
|
|
|
*/
|
2003-07-22 15:50:54 +00:00
|
|
|
static void
|
2001-03-12 21:30:52 +00:00
|
|
|
fxp_scb_wait(struct fxp_softc *sc)
|
1995-11-28 23:55:26 +00:00
|
|
|
{
|
2005-09-21 04:36:40 +00:00
|
|
|
union {
|
|
|
|
uint16_t w;
|
|
|
|
uint8_t b[2];
|
|
|
|
} flowctl;
|
1995-11-28 23:55:26 +00:00
|
|
|
int i = 10000;
|
|
|
|
|
2000-09-17 22:12:12 +00:00
|
|
|
while (CSR_READ_1(sc, FXP_CSR_SCB_COMMAND) && --i)
|
|
|
|
DELAY(2);
|
2005-09-21 04:36:40 +00:00
|
|
|
if (i == 0) {
|
2010-11-26 21:52:33 +00:00
|
|
|
flowctl.b[0] = CSR_READ_1(sc, FXP_CSR_FC_THRESH);
|
|
|
|
flowctl.b[1] = CSR_READ_1(sc, FXP_CSR_FC_STATUS);
|
2001-08-27 16:07:12 +00:00
|
|
|
device_printf(sc->dev, "SCB timeout: 0x%x 0x%x 0x%x 0x%x\n",
|
2001-05-13 00:03:39 +00:00
|
|
|
CSR_READ_1(sc, FXP_CSR_SCB_COMMAND),
|
|
|
|
CSR_READ_1(sc, FXP_CSR_SCB_STATACK),
|
2005-09-21 04:36:40 +00:00
|
|
|
CSR_READ_1(sc, FXP_CSR_SCB_RUSCUS), flowctl.w);
|
|
|
|
}
|
2000-09-17 22:12:12 +00:00
|
|
|
}
|
|
|
|
|
2003-07-22 15:50:54 +00:00
|
|
|
static void
|
2001-05-17 23:50:24 +00:00
|
|
|
fxp_scb_cmd(struct fxp_softc *sc, int cmd)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (cmd == FXP_SCB_COMMAND_CU_RESUME && sc->cu_resume_bug) {
|
|
|
|
CSR_WRITE_1(sc, FXP_CSR_SCB_COMMAND, FXP_CB_COMMAND_NOP);
|
|
|
|
fxp_scb_wait(sc);
|
|
|
|
}
|
|
|
|
CSR_WRITE_1(sc, FXP_CSR_SCB_COMMAND, cmd);
|
|
|
|
}
|
|
|
|
|
2003-07-22 15:50:54 +00:00
|
|
|
static void
|
2005-03-06 05:07:26 +00:00
|
|
|
fxp_dma_wait(struct fxp_softc *sc, volatile uint16_t *status,
|
2003-04-08 18:56:45 +00:00
|
|
|
bus_dma_tag_t dmat, bus_dmamap_t map)
|
2000-09-17 22:12:12 +00:00
|
|
|
{
|
2009-06-10 01:15:30 +00:00
|
|
|
int i;
|
2000-09-17 22:12:12 +00:00
|
|
|
|
2009-06-10 01:15:30 +00:00
|
|
|
for (i = 10000; i > 0; i--) {
|
2000-09-17 22:12:12 +00:00
|
|
|
DELAY(2);
|
2009-06-10 01:15:30 +00:00
|
|
|
bus_dmamap_sync(dmat, map,
|
|
|
|
BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
|
|
|
|
if ((le16toh(*status) & FXP_CB_STATUS_C) != 0)
|
|
|
|
break;
|
2003-04-08 18:56:45 +00:00
|
|
|
}
|
2000-09-17 22:12:12 +00:00
|
|
|
if (i == 0)
|
2001-03-12 21:30:52 +00:00
|
|
|
device_printf(sc->dev, "DMA timeout\n");
|
1997-09-05 10:23:58 +00:00
|
|
|
}
|
|
|
|
|
2010-11-23 21:09:42 +00:00
|
|
|
static const struct fxp_ident *
|
2009-06-21 07:34:12 +00:00
|
|
|
fxp_find_ident(device_t dev)
|
1995-11-28 23:55:26 +00:00
|
|
|
{
|
2005-03-06 05:07:26 +00:00
|
|
|
uint16_t devid;
|
|
|
|
uint8_t revid;
|
2010-11-23 21:09:42 +00:00
|
|
|
const struct fxp_ident *ident;
|
2001-03-12 21:30:52 +00:00
|
|
|
|
2000-06-18 10:26:09 +00:00
|
|
|
if (pci_get_vendor(dev) == FXP_VENDORID_INTEL) {
|
2001-03-12 21:30:52 +00:00
|
|
|
devid = pci_get_device(dev);
|
2003-08-04 00:17:16 +00:00
|
|
|
revid = pci_get_revid(dev);
|
2001-03-12 21:30:52 +00:00
|
|
|
for (ident = fxp_ident_table; ident->name != NULL; ident++) {
|
2003-08-04 00:17:16 +00:00
|
|
|
if (ident->devid == devid &&
|
|
|
|
(ident->revid == revid || ident->revid == -1)) {
|
2009-06-21 07:34:12 +00:00
|
|
|
return (ident);
|
2001-03-12 21:30:52 +00:00
|
|
|
}
|
2000-06-18 10:26:09 +00:00
|
|
|
}
|
1999-09-06 06:15:18 +00:00
|
|
|
}
|
2009-06-21 07:34:12 +00:00
|
|
|
return (NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return identification string if this device is ours.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
fxp_probe(device_t dev)
|
|
|
|
{
|
2010-11-23 21:09:42 +00:00
|
|
|
const struct fxp_ident *ident;
|
2009-06-21 07:34:12 +00:00
|
|
|
|
|
|
|
ident = fxp_find_ident(dev);
|
|
|
|
if (ident != NULL) {
|
|
|
|
device_set_desc(dev, ident->name);
|
|
|
|
return (BUS_PROBE_DEFAULT);
|
|
|
|
}
|
2001-03-12 21:30:52 +00:00
|
|
|
return (ENXIO);
|
1995-11-28 23:55:26 +00:00
|
|
|
}
|
|
|
|
|
2003-04-02 16:47:16 +00:00
|
|
|
static void
|
|
|
|
fxp_dma_map_addr(void *arg, bus_dma_segment_t *segs, int nseg, int error)
|
|
|
|
{
|
2005-03-06 05:07:26 +00:00
|
|
|
uint32_t *addr;
|
2003-04-02 16:47:16 +00:00
|
|
|
|
|
|
|
if (error)
|
|
|
|
return;
|
|
|
|
|
|
|
|
KASSERT(nseg == 1, ("too many DMA segments, %d should be 1", nseg));
|
|
|
|
addr = arg;
|
|
|
|
*addr = segs->ds_addr;
|
|
|
|
}
|
|
|
|
|
1999-04-16 21:22:55 +00:00
|
|
|
static int
|
|
|
|
fxp_attach(device_t dev)
|
1995-11-28 23:55:26 +00:00
|
|
|
{
|
2005-03-03 00:22:59 +00:00
|
|
|
struct fxp_softc *sc;
|
|
|
|
struct fxp_cb_tx *tcbp;
|
|
|
|
struct fxp_tx *txp;
|
2003-04-02 16:47:16 +00:00
|
|
|
struct fxp_rx *rxp;
|
2005-03-03 00:22:59 +00:00
|
|
|
struct ifnet *ifp;
|
2005-03-06 05:07:26 +00:00
|
|
|
uint32_t val;
|
2012-03-28 01:27:27 +00:00
|
|
|
uint16_t data;
|
2005-06-10 16:49:24 +00:00
|
|
|
u_char eaddr[ETHER_ADDR_LEN];
|
2010-11-26 21:52:33 +00:00
|
|
|
int error, flags, i, pmc, prefer_iomap;
|
1995-11-28 23:55:26 +00:00
|
|
|
|
2005-03-03 00:22:59 +00:00
|
|
|
error = 0;
|
|
|
|
sc = device_get_softc(dev);
|
2001-03-12 21:30:52 +00:00
|
|
|
sc->dev = dev;
|
2002-04-04 21:03:38 +00:00
|
|
|
mtx_init(&sc->sc_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
|
Make fxp(4) INTR_MPSAFE (but do not enable MPSAFE just yet):
- Add fxp_start_body() and change fxp_start() to just acquire locks and
then call fxp_start_body(). Places that would call fxp_start() with
locks held (mutex recursion) now call fxp_start_body() directly.
Remove MTX_RECURSE flag from sc_mtx. [gallatin]
- Change fxp_attach() to work without the softc lock, saving interrupt
hooking until the head of fxp_attach().
- Call ether_ifattach() before overriding ifp parameters. This reverts
part of 1.155.
- Remove multiple error paths in fxp_attach().
- Teardown interrupt in fxp_detach() before unlocking the softc.
- Make sure mutex is not held in fxp_release()
- Delete the miibus instance and/or self in fxp_release(), not in
fxp_detach(). This can happen if attach fails partway through.
- Move ifmedia_removeall to fxp_release() since attach may fail after
media have been allocated.
- Add locking to fxp_suspend, fxp_resume, fxp_start, fxp_intr,
fxp_poll, fxp_tick, fxp_ioctl, fxp_watchdog.
- Pass in ifp to fxp_intr_body since its callers sometimes already use
it.
- Add compatibility define for INTR_MPSAFE for 4.x. [gallatin]
- You don't need to bzero softc.
Ideas from: gallatin, mux
Tested by: >400M packets of dd/ssh, NFS, ping on i386 UP
2003-04-25 09:01:54 +00:00
|
|
|
MTX_DEF);
|
2005-08-08 21:03:54 +00:00
|
|
|
callout_init_mtx(&sc->stat_ch, &sc->sc_mtx, 0);
|
Make fxp(4) INTR_MPSAFE (but do not enable MPSAFE just yet):
- Add fxp_start_body() and change fxp_start() to just acquire locks and
then call fxp_start_body(). Places that would call fxp_start() with
locks held (mutex recursion) now call fxp_start_body() directly.
Remove MTX_RECURSE flag from sc_mtx. [gallatin]
- Change fxp_attach() to work without the softc lock, saving interrupt
hooking until the head of fxp_attach().
- Call ether_ifattach() before overriding ifp parameters. This reverts
part of 1.155.
- Remove multiple error paths in fxp_attach().
- Teardown interrupt in fxp_detach() before unlocking the softc.
- Make sure mutex is not held in fxp_release()
- Delete the miibus instance and/or self in fxp_release(), not in
fxp_detach(). This can happen if attach fails partway through.
- Move ifmedia_removeall to fxp_release() since attach may fail after
media have been allocated.
- Add locking to fxp_suspend, fxp_resume, fxp_start, fxp_intr,
fxp_poll, fxp_tick, fxp_ioctl, fxp_watchdog.
- Pass in ifp to fxp_intr_body since its callers sometimes already use
it.
- Add compatibility define for INTR_MPSAFE for 4.x. [gallatin]
- You don't need to bzero softc.
Ideas from: gallatin, mux
Tested by: >400M packets of dd/ssh, NFS, ping on i386 UP
2003-04-25 09:01:54 +00:00
|
|
|
ifmedia_init(&sc->sc_media, 0, fxp_serial_ifmedia_upd,
|
|
|
|
fxp_serial_ifmedia_sts);
|
1995-11-28 23:55:26 +00:00
|
|
|
|
2005-06-11 00:47:34 +00:00
|
|
|
ifp = sc->ifp = if_alloc(IFT_ETHER);
|
|
|
|
if (ifp == NULL) {
|
|
|
|
device_printf(dev, "can not if_alloc()\n");
|
|
|
|
error = ENOSPC;
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
1999-03-20 04:51:25 +00:00
|
|
|
/*
|
2003-04-16 09:16:55 +00:00
|
|
|
* Enable bus mastering.
|
1999-03-20 04:51:25 +00:00
|
|
|
*/
|
2003-04-14 15:50:04 +00:00
|
|
|
pci_enable_busmaster(dev);
|
2004-06-28 20:26:21 +00:00
|
|
|
|
1995-12-01 22:41:56 +00:00
|
|
|
/*
|
2001-01-23 23:22:17 +00:00
|
|
|
* Figure out which we should try first - memory mapping or i/o mapping?
|
|
|
|
* We default to memory mapping. Then we accept an override from the
|
|
|
|
* command line. Then we check to see which one is enabled.
|
1995-12-01 22:41:56 +00:00
|
|
|
*/
|
2001-02-27 22:57:32 +00:00
|
|
|
prefer_iomap = 0;
|
2005-09-27 09:01:11 +00:00
|
|
|
resource_int_value(device_get_name(dev), device_get_unit(dev),
|
|
|
|
"prefer_iomap", &prefer_iomap);
|
|
|
|
if (prefer_iomap)
|
|
|
|
sc->fxp_spec = fxp_res_spec_io;
|
|
|
|
else
|
|
|
|
sc->fxp_spec = fxp_res_spec_mem;
|
2001-01-23 23:22:17 +00:00
|
|
|
|
2005-09-27 09:01:11 +00:00
|
|
|
error = bus_alloc_resources(dev, sc->fxp_spec, sc->fxp_res);
|
|
|
|
if (error) {
|
|
|
|
if (sc->fxp_spec == fxp_res_spec_mem)
|
|
|
|
sc->fxp_spec = fxp_res_spec_io;
|
|
|
|
else
|
|
|
|
sc->fxp_spec = fxp_res_spec_mem;
|
|
|
|
error = bus_alloc_resources(dev, sc->fxp_spec, sc->fxp_res);
|
2001-01-23 23:22:17 +00:00
|
|
|
}
|
2005-09-27 09:01:11 +00:00
|
|
|
if (error) {
|
|
|
|
device_printf(dev, "could not allocate resources\n");
|
1999-04-16 21:22:55 +00:00
|
|
|
error = ENXIO;
|
1995-11-28 23:55:26 +00:00
|
|
|
goto fail;
|
2001-01-23 23:22:17 +00:00
|
|
|
}
|
1999-09-30 19:03:12 +00:00
|
|
|
|
2005-09-27 09:01:11 +00:00
|
|
|
if (bootverbose) {
|
|
|
|
device_printf(dev, "using %s space register mapping\n",
|
|
|
|
sc->fxp_spec == fxp_res_spec_mem ? "memory" : "I/O");
|
1999-04-16 21:22:55 +00:00
|
|
|
}
|
|
|
|
|
2001-03-12 21:30:52 +00:00
|
|
|
/*
|
2009-06-21 06:18:19 +00:00
|
|
|
* Put CU/RU idle state and prepare full reset.
|
2001-03-12 21:30:52 +00:00
|
|
|
*/
|
|
|
|
CSR_WRITE_4(sc, FXP_CSR_PORT, FXP_PORT_SELECTIVE_RESET);
|
|
|
|
DELAY(10);
|
2009-06-21 06:18:19 +00:00
|
|
|
/* Full reset and disable interrupts. */
|
|
|
|
CSR_WRITE_4(sc, FXP_CSR_PORT, FXP_PORT_SOFTWARE_RESET);
|
|
|
|
DELAY(10);
|
|
|
|
CSR_WRITE_1(sc, FXP_CSR_SCB_INTRCNTL, FXP_SCB_INTR_DISABLE);
|
2001-03-12 21:30:52 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Find out how large of an SEEPROM we have.
|
|
|
|
*/
|
|
|
|
fxp_autosize_eeprom(sc);
|
2012-03-28 01:27:27 +00:00
|
|
|
fxp_load_eeprom(sc);
|
2001-03-12 21:30:52 +00:00
|
|
|
|
2005-02-27 15:12:50 +00:00
|
|
|
/*
|
|
|
|
* Find out the chip revision; lump all 82557 revs together.
|
|
|
|
*/
|
2009-06-21 07:34:12 +00:00
|
|
|
sc->ident = fxp_find_ident(dev);
|
|
|
|
if (sc->ident->ich > 0) {
|
|
|
|
/* Assume ICH controllers are 82559. */
|
|
|
|
sc->revision = FXP_REV_82559_A0;
|
|
|
|
} else {
|
2012-03-28 01:27:27 +00:00
|
|
|
data = sc->eeprom[FXP_EEPROM_MAP_CNTR];
|
2009-06-21 07:34:12 +00:00
|
|
|
if ((data >> 8) == 1)
|
|
|
|
sc->revision = FXP_REV_82557;
|
|
|
|
else
|
|
|
|
sc->revision = pci_get_revid(dev);
|
|
|
|
}
|
2005-02-27 15:12:50 +00:00
|
|
|
|
2008-11-27 01:57:23 +00:00
|
|
|
/*
|
|
|
|
* Check availability of WOL. 82559ER does not support WOL.
|
|
|
|
*/
|
|
|
|
if (sc->revision >= FXP_REV_82558_A4 &&
|
|
|
|
sc->revision != FXP_REV_82559S_A) {
|
2012-03-28 01:27:27 +00:00
|
|
|
data = sc->eeprom[FXP_EEPROM_MAP_ID];
|
2008-11-27 01:57:23 +00:00
|
|
|
if ((data & 0x20) != 0 &&
|
2011-03-23 13:10:15 +00:00
|
|
|
pci_find_cap(sc->dev, PCIY_PMG, &pmc) == 0)
|
2008-11-27 01:57:23 +00:00
|
|
|
sc->flags |= FXP_FLAG_WOLCAP;
|
|
|
|
}
|
|
|
|
|
2012-03-28 01:08:55 +00:00
|
|
|
if (sc->revision == FXP_REV_82550_C) {
|
|
|
|
/*
|
|
|
|
* 82550C with server extension requires microcode to
|
|
|
|
* receive fragmented UDP datagrams. However if the
|
|
|
|
* microcode is used for client-only featured 82550C
|
|
|
|
* it locks up controller.
|
|
|
|
*/
|
2012-03-28 01:27:27 +00:00
|
|
|
data = sc->eeprom[FXP_EEPROM_MAP_COMPAT];
|
2012-03-28 01:08:55 +00:00
|
|
|
if ((data & 0x0400) == 0)
|
|
|
|
sc->flags |= FXP_FLAG_NO_UCODE;
|
|
|
|
}
|
|
|
|
|
2009-06-21 06:27:35 +00:00
|
|
|
/* Receiver lock-up workaround detection. */
|
2010-12-02 03:53:29 +00:00
|
|
|
if (sc->revision < FXP_REV_82558_A4) {
|
2012-03-28 01:27:27 +00:00
|
|
|
data = sc->eeprom[FXP_EEPROM_MAP_COMPAT];
|
2010-12-02 03:53:29 +00:00
|
|
|
if ((data & 0x03) != 0x03) {
|
|
|
|
sc->flags |= FXP_FLAG_RXBUG;
|
|
|
|
device_printf(dev, "Enabling Rx lock-up workaround\n");
|
|
|
|
}
|
2009-06-21 06:27:35 +00:00
|
|
|
}
|
|
|
|
|
2001-03-12 21:30:52 +00:00
|
|
|
/*
|
2001-03-14 19:50:35 +00:00
|
|
|
* Determine whether we must use the 503 serial interface.
|
2001-03-12 21:30:52 +00:00
|
|
|
*/
|
2012-03-28 01:27:27 +00:00
|
|
|
data = sc->eeprom[FXP_EEPROM_MAP_PRI_PHY];
|
2005-02-27 15:12:50 +00:00
|
|
|
if (sc->revision == FXP_REV_82557 && (data & FXP_PHY_DEVICE_MASK) != 0
|
2004-12-20 10:18:21 +00:00
|
|
|
&& (data & FXP_PHY_SERIAL_ONLY))
|
2001-05-15 18:52:40 +00:00
|
|
|
sc->flags |= FXP_FLAG_SERIAL_MEDIA;
|
2001-03-12 21:30:52 +00:00
|
|
|
|
2010-05-09 22:16:15 +00:00
|
|
|
fxp_sysctl_node(sc);
|
2001-05-17 23:50:24 +00:00
|
|
|
/*
|
|
|
|
* Enable workarounds for certain chip revision deficiencies.
|
2001-08-27 16:07:12 +00:00
|
|
|
*
|
2001-10-25 05:32:01 +00:00
|
|
|
* Systems based on the ICH2/ICH2-M chip from Intel, and possibly
|
|
|
|
* some systems based a normal 82559 design, have a defect where
|
|
|
|
* the chip can cause a PCI protocol violation if it receives
|
2008-11-25 00:48:05 +00:00
|
|
|
* a CU_RESUME command when it is entering the IDLE state. The
|
2001-08-27 16:07:12 +00:00
|
|
|
* workaround is to disable Dynamic Standby Mode, so the chip never
|
|
|
|
* deasserts CLKRUN#, and always remains in an active state.
|
|
|
|
*
|
|
|
|
* See Intel 82801BA/82801BAM Specification Update, Errata #30.
|
2001-05-17 23:50:24 +00:00
|
|
|
*/
|
2009-06-21 07:34:12 +00:00
|
|
|
if ((sc->ident->ich >= 2 && sc->ident->ich <= 3) ||
|
|
|
|
(sc->ident->ich == 0 && sc->revision >= FXP_REV_82559_A0)) {
|
2012-03-28 01:27:27 +00:00
|
|
|
data = sc->eeprom[FXP_EEPROM_MAP_ID];
|
2001-08-27 16:07:12 +00:00
|
|
|
if (data & 0x02) { /* STB enable */
|
2005-03-06 05:07:26 +00:00
|
|
|
uint16_t cksum;
|
2001-08-27 16:07:12 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
device_printf(dev,
|
2001-12-13 16:13:31 +00:00
|
|
|
"Disabling dynamic standby mode in EEPROM\n");
|
2001-08-27 16:07:12 +00:00
|
|
|
data &= ~0x02;
|
2012-03-28 01:27:27 +00:00
|
|
|
sc->eeprom[FXP_EEPROM_MAP_ID] = data;
|
|
|
|
fxp_write_eeprom(sc, &data, FXP_EEPROM_MAP_ID, 1);
|
2001-08-27 16:07:12 +00:00
|
|
|
device_printf(dev, "New EEPROM ID: 0x%x\n", data);
|
|
|
|
cksum = 0;
|
2012-03-28 01:27:27 +00:00
|
|
|
for (i = 0; i < (1 << sc->eeprom_size) - 1; i++)
|
|
|
|
cksum += sc->eeprom[i];
|
2001-08-27 16:07:12 +00:00
|
|
|
i = (1 << sc->eeprom_size) - 1;
|
|
|
|
cksum = 0xBABA - cksum;
|
|
|
|
fxp_write_eeprom(sc, &cksum, i, 1);
|
|
|
|
device_printf(dev,
|
|
|
|
"EEPROM checksum @ 0x%x: 0x%x -> 0x%x\n",
|
2012-03-28 01:27:27 +00:00
|
|
|
i, sc->eeprom[i], cksum);
|
|
|
|
sc->eeprom[i] = cksum;
|
2001-08-27 16:07:12 +00:00
|
|
|
/*
|
|
|
|
* If the user elects to continue, try the software
|
|
|
|
* workaround, as it is better than nothing.
|
|
|
|
*/
|
|
|
|
sc->flags |= FXP_FLAG_CU_RESUME_BUG;
|
|
|
|
}
|
|
|
|
}
|
2001-05-17 23:50:24 +00:00
|
|
|
|
2001-03-14 19:50:35 +00:00
|
|
|
/*
|
|
|
|
* If we are not a 82557 chip, we can enable extended features.
|
|
|
|
*/
|
2001-10-25 05:32:01 +00:00
|
|
|
if (sc->revision != FXP_REV_82557) {
|
2001-03-14 19:50:35 +00:00
|
|
|
/*
|
2001-07-19 15:48:00 +00:00
|
|
|
* If MWI is enabled in the PCI configuration, and there
|
|
|
|
* is a valid cacheline size (8 or 16 dwords), then tell
|
|
|
|
* the board to turn on MWI.
|
2001-03-14 19:50:35 +00:00
|
|
|
*/
|
2013-08-12 23:30:01 +00:00
|
|
|
val = pci_read_config(dev, PCIR_COMMAND, 2);
|
2001-07-19 15:48:00 +00:00
|
|
|
if (val & PCIM_CMD_MWRICEN &&
|
|
|
|
pci_read_config(dev, PCIR_CACHELNSZ, 1) != 0)
|
2001-03-14 19:50:35 +00:00
|
|
|
sc->flags |= FXP_FLAG_MWI_ENABLE;
|
|
|
|
|
|
|
|
/* turn on the extended TxCB feature */
|
|
|
|
sc->flags |= FXP_FLAG_EXT_TXCB;
|
2004-05-27 14:36:58 +00:00
|
|
|
|
|
|
|
/* enable reception of long frames for VLAN */
|
|
|
|
sc->flags |= FXP_FLAG_LONG_PKT_EN;
|
|
|
|
} else {
|
|
|
|
/* a hack to get long VLAN frames on a 82557 */
|
|
|
|
sc->flags |= FXP_FLAG_SAVE_BAD;
|
2001-03-14 19:50:35 +00:00
|
|
|
}
|
|
|
|
|
2008-11-26 06:36:53 +00:00
|
|
|
/* For 82559 or later chips, Rx checksum offload is supported. */
|
2009-09-28 19:40:16 +00:00
|
|
|
if (sc->revision >= FXP_REV_82559_A0) {
|
|
|
|
/* 82559ER does not support Rx checksum offloading. */
|
|
|
|
if (sc->ident->devid != 0x1209)
|
|
|
|
sc->flags |= FXP_FLAG_82559_RXCSUM;
|
|
|
|
}
|
2003-02-26 22:12:04 +00:00
|
|
|
/*
|
|
|
|
* Enable use of extended RFDs and TCBs for 82550
|
|
|
|
* and later chips. Note: we need extended TXCB support
|
|
|
|
* too, but that's already enabled by the code above.
|
|
|
|
* Be careful to do this only on the right devices.
|
|
|
|
*/
|
2005-04-22 13:05:53 +00:00
|
|
|
if (sc->revision == FXP_REV_82550 || sc->revision == FXP_REV_82550_C ||
|
|
|
|
sc->revision == FXP_REV_82551_E || sc->revision == FXP_REV_82551_F
|
|
|
|
|| sc->revision == FXP_REV_82551_10) {
|
2003-02-26 22:12:04 +00:00
|
|
|
sc->rfa_size = sizeof (struct fxp_rfa);
|
|
|
|
sc->tx_cmd = FXP_CB_COMMAND_IPCBXMIT;
|
|
|
|
sc->flags |= FXP_FLAG_EXT_RFA;
|
2008-11-26 06:36:53 +00:00
|
|
|
/* Use extended RFA instead of 82559 checksum mode. */
|
|
|
|
sc->flags &= ~FXP_FLAG_82559_RXCSUM;
|
2003-02-26 22:12:04 +00:00
|
|
|
} else {
|
|
|
|
sc->rfa_size = sizeof (struct fxp_rfa) - FXP_RFAX_LEN;
|
|
|
|
sc->tx_cmd = FXP_CB_COMMAND_XMIT;
|
|
|
|
}
|
|
|
|
|
2003-04-02 16:47:16 +00:00
|
|
|
/*
|
|
|
|
* Allocate DMA tags and DMA safe memory.
|
|
|
|
*/
|
2005-03-07 13:20:49 +00:00
|
|
|
sc->maxtxseg = FXP_NTXSEG;
|
2008-11-26 07:36:17 +00:00
|
|
|
sc->maxsegsize = MCLBYTES;
|
|
|
|
if (sc->flags & FXP_FLAG_EXT_RFA) {
|
2005-03-07 13:20:49 +00:00
|
|
|
sc->maxtxseg--;
|
2008-11-26 07:36:17 +00:00
|
|
|
sc->maxsegsize = FXP_TSO_SEGSIZE;
|
|
|
|
}
|
2007-01-21 19:32:51 +00:00
|
|
|
error = bus_dma_tag_create(bus_get_dma_tag(dev), 2, 0,
|
|
|
|
BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
|
2008-11-26 07:36:17 +00:00
|
|
|
sc->maxsegsize * sc->maxtxseg + sizeof(struct ether_vlan_header),
|
|
|
|
sc->maxtxseg, sc->maxsegsize, 0,
|
2009-06-21 06:06:43 +00:00
|
|
|
busdma_lock_mutex, &Giant, &sc->fxp_txmtag);
|
2003-04-02 16:47:16 +00:00
|
|
|
if (error) {
|
2009-06-21 06:06:43 +00:00
|
|
|
device_printf(dev, "could not create TX DMA tag\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = bus_dma_tag_create(bus_get_dma_tag(dev), 2, 0,
|
|
|
|
BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
|
|
|
|
MCLBYTES, 1, MCLBYTES, 0,
|
|
|
|
busdma_lock_mutex, &Giant, &sc->fxp_rxmtag);
|
|
|
|
if (error) {
|
|
|
|
device_printf(dev, "could not create RX DMA tag\n");
|
2003-04-02 16:47:16 +00:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2007-01-21 19:32:51 +00:00
|
|
|
error = bus_dma_tag_create(bus_get_dma_tag(dev), 4, 0,
|
|
|
|
BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
|
|
|
|
sizeof(struct fxp_stats), 1, sizeof(struct fxp_stats), 0,
|
|
|
|
busdma_lock_mutex, &Giant, &sc->fxp_stag);
|
2003-04-02 16:47:16 +00:00
|
|
|
if (error) {
|
2009-06-21 06:06:43 +00:00
|
|
|
device_printf(dev, "could not create stats DMA tag\n");
|
2003-04-02 16:47:16 +00:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = bus_dmamem_alloc(sc->fxp_stag, (void **)&sc->fxp_stats,
|
2011-02-26 17:28:09 +00:00
|
|
|
BUS_DMA_NOWAIT | BUS_DMA_COHERENT | BUS_DMA_ZERO, &sc->fxp_smap);
|
2009-06-21 06:06:43 +00:00
|
|
|
if (error) {
|
|
|
|
device_printf(dev, "could not allocate stats DMA memory\n");
|
Make fxp(4) INTR_MPSAFE (but do not enable MPSAFE just yet):
- Add fxp_start_body() and change fxp_start() to just acquire locks and
then call fxp_start_body(). Places that would call fxp_start() with
locks held (mutex recursion) now call fxp_start_body() directly.
Remove MTX_RECURSE flag from sc_mtx. [gallatin]
- Change fxp_attach() to work without the softc lock, saving interrupt
hooking until the head of fxp_attach().
- Call ether_ifattach() before overriding ifp parameters. This reverts
part of 1.155.
- Remove multiple error paths in fxp_attach().
- Teardown interrupt in fxp_detach() before unlocking the softc.
- Make sure mutex is not held in fxp_release()
- Delete the miibus instance and/or self in fxp_release(), not in
fxp_detach(). This can happen if attach fails partway through.
- Move ifmedia_removeall to fxp_release() since attach may fail after
media have been allocated.
- Add locking to fxp_suspend, fxp_resume, fxp_start, fxp_intr,
fxp_poll, fxp_tick, fxp_ioctl, fxp_watchdog.
- Pass in ifp to fxp_intr_body since its callers sometimes already use
it.
- Add compatibility define for INTR_MPSAFE for 4.x. [gallatin]
- You don't need to bzero softc.
Ideas from: gallatin, mux
Tested by: >400M packets of dd/ssh, NFS, ping on i386 UP
2003-04-25 09:01:54 +00:00
|
|
|
goto fail;
|
2009-06-21 06:06:43 +00:00
|
|
|
}
|
2003-04-02 16:47:16 +00:00
|
|
|
error = bus_dmamap_load(sc->fxp_stag, sc->fxp_smap, sc->fxp_stats,
|
2012-03-14 00:26:36 +00:00
|
|
|
sizeof(struct fxp_stats), fxp_dma_map_addr, &sc->stats_addr,
|
|
|
|
BUS_DMA_NOWAIT);
|
2003-04-02 16:47:16 +00:00
|
|
|
if (error) {
|
2009-06-21 06:06:43 +00:00
|
|
|
device_printf(dev, "could not load the stats DMA buffer\n");
|
2003-04-02 16:47:16 +00:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2007-01-21 19:32:51 +00:00
|
|
|
error = bus_dma_tag_create(bus_get_dma_tag(dev), 4, 0,
|
|
|
|
BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
|
|
|
|
FXP_TXCB_SZ, 1, FXP_TXCB_SZ, 0,
|
|
|
|
busdma_lock_mutex, &Giant, &sc->cbl_tag);
|
2003-04-02 16:47:16 +00:00
|
|
|
if (error) {
|
2009-06-21 06:06:43 +00:00
|
|
|
device_printf(dev, "could not create TxCB DMA tag\n");
|
2003-04-02 16:47:16 +00:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = bus_dmamem_alloc(sc->cbl_tag, (void **)&sc->fxp_desc.cbl_list,
|
2011-02-26 17:28:09 +00:00
|
|
|
BUS_DMA_NOWAIT | BUS_DMA_COHERENT | BUS_DMA_ZERO, &sc->cbl_map);
|
2009-06-21 06:06:43 +00:00
|
|
|
if (error) {
|
|
|
|
device_printf(dev, "could not allocate TxCB DMA memory\n");
|
Make fxp(4) INTR_MPSAFE (but do not enable MPSAFE just yet):
- Add fxp_start_body() and change fxp_start() to just acquire locks and
then call fxp_start_body(). Places that would call fxp_start() with
locks held (mutex recursion) now call fxp_start_body() directly.
Remove MTX_RECURSE flag from sc_mtx. [gallatin]
- Change fxp_attach() to work without the softc lock, saving interrupt
hooking until the head of fxp_attach().
- Call ether_ifattach() before overriding ifp parameters. This reverts
part of 1.155.
- Remove multiple error paths in fxp_attach().
- Teardown interrupt in fxp_detach() before unlocking the softc.
- Make sure mutex is not held in fxp_release()
- Delete the miibus instance and/or self in fxp_release(), not in
fxp_detach(). This can happen if attach fails partway through.
- Move ifmedia_removeall to fxp_release() since attach may fail after
media have been allocated.
- Add locking to fxp_suspend, fxp_resume, fxp_start, fxp_intr,
fxp_poll, fxp_tick, fxp_ioctl, fxp_watchdog.
- Pass in ifp to fxp_intr_body since its callers sometimes already use
it.
- Add compatibility define for INTR_MPSAFE for 4.x. [gallatin]
- You don't need to bzero softc.
Ideas from: gallatin, mux
Tested by: >400M packets of dd/ssh, NFS, ping on i386 UP
2003-04-25 09:01:54 +00:00
|
|
|
goto fail;
|
2009-06-21 06:06:43 +00:00
|
|
|
}
|
2003-04-02 16:47:16 +00:00
|
|
|
|
|
|
|
error = bus_dmamap_load(sc->cbl_tag, sc->cbl_map,
|
|
|
|
sc->fxp_desc.cbl_list, FXP_TXCB_SZ, fxp_dma_map_addr,
|
2012-03-14 00:26:36 +00:00
|
|
|
&sc->fxp_desc.cbl_addr, BUS_DMA_NOWAIT);
|
2003-04-02 16:47:16 +00:00
|
|
|
if (error) {
|
2009-06-21 06:06:43 +00:00
|
|
|
device_printf(dev, "could not load TxCB DMA buffer\n");
|
2003-04-02 16:47:16 +00:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2007-01-21 19:32:51 +00:00
|
|
|
error = bus_dma_tag_create(bus_get_dma_tag(dev), 4, 0,
|
|
|
|
BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
|
|
|
|
sizeof(struct fxp_cb_mcs), 1, sizeof(struct fxp_cb_mcs), 0,
|
|
|
|
busdma_lock_mutex, &Giant, &sc->mcs_tag);
|
2003-04-02 16:47:16 +00:00
|
|
|
if (error) {
|
2009-06-21 06:06:43 +00:00
|
|
|
device_printf(dev,
|
|
|
|
"could not create multicast setup DMA tag\n");
|
2003-04-02 16:47:16 +00:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = bus_dmamem_alloc(sc->mcs_tag, (void **)&sc->mcsp,
|
2011-02-26 17:28:09 +00:00
|
|
|
BUS_DMA_NOWAIT | BUS_DMA_COHERENT | BUS_DMA_ZERO, &sc->mcs_map);
|
2009-06-21 06:06:43 +00:00
|
|
|
if (error) {
|
|
|
|
device_printf(dev,
|
|
|
|
"could not allocate multicast setup DMA memory\n");
|
Make fxp(4) INTR_MPSAFE (but do not enable MPSAFE just yet):
- Add fxp_start_body() and change fxp_start() to just acquire locks and
then call fxp_start_body(). Places that would call fxp_start() with
locks held (mutex recursion) now call fxp_start_body() directly.
Remove MTX_RECURSE flag from sc_mtx. [gallatin]
- Change fxp_attach() to work without the softc lock, saving interrupt
hooking until the head of fxp_attach().
- Call ether_ifattach() before overriding ifp parameters. This reverts
part of 1.155.
- Remove multiple error paths in fxp_attach().
- Teardown interrupt in fxp_detach() before unlocking the softc.
- Make sure mutex is not held in fxp_release()
- Delete the miibus instance and/or self in fxp_release(), not in
fxp_detach(). This can happen if attach fails partway through.
- Move ifmedia_removeall to fxp_release() since attach may fail after
media have been allocated.
- Add locking to fxp_suspend, fxp_resume, fxp_start, fxp_intr,
fxp_poll, fxp_tick, fxp_ioctl, fxp_watchdog.
- Pass in ifp to fxp_intr_body since its callers sometimes already use
it.
- Add compatibility define for INTR_MPSAFE for 4.x. [gallatin]
- You don't need to bzero softc.
Ideas from: gallatin, mux
Tested by: >400M packets of dd/ssh, NFS, ping on i386 UP
2003-04-25 09:01:54 +00:00
|
|
|
goto fail;
|
2009-06-21 06:06:43 +00:00
|
|
|
}
|
2003-04-02 16:47:16 +00:00
|
|
|
error = bus_dmamap_load(sc->mcs_tag, sc->mcs_map, sc->mcsp,
|
2012-03-14 00:26:36 +00:00
|
|
|
sizeof(struct fxp_cb_mcs), fxp_dma_map_addr, &sc->mcs_addr,
|
|
|
|
BUS_DMA_NOWAIT);
|
2003-04-02 16:47:16 +00:00
|
|
|
if (error) {
|
2009-06-21 06:06:43 +00:00
|
|
|
device_printf(dev,
|
|
|
|
"can't load the multicast setup DMA buffer\n");
|
2003-04-02 16:47:16 +00:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2005-03-03 00:22:59 +00:00
|
|
|
* Pre-allocate the TX DMA maps and setup the pointers to
|
|
|
|
* the TX command blocks.
|
2003-04-02 16:47:16 +00:00
|
|
|
*/
|
2005-03-03 00:22:59 +00:00
|
|
|
txp = sc->fxp_desc.tx_list;
|
|
|
|
tcbp = sc->fxp_desc.cbl_list;
|
2003-04-05 12:43:21 +00:00
|
|
|
for (i = 0; i < FXP_NTXCB; i++) {
|
2005-03-03 00:22:59 +00:00
|
|
|
txp[i].tx_cb = tcbp + i;
|
2009-06-21 06:06:43 +00:00
|
|
|
error = bus_dmamap_create(sc->fxp_txmtag, 0, &txp[i].tx_map);
|
2003-04-02 16:47:16 +00:00
|
|
|
if (error) {
|
|
|
|
device_printf(dev, "can't create DMA map for TX\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
}
|
2009-06-21 06:06:43 +00:00
|
|
|
error = bus_dmamap_create(sc->fxp_rxmtag, 0, &sc->spare_map);
|
2003-04-02 16:47:16 +00:00
|
|
|
if (error) {
|
|
|
|
device_printf(dev, "can't create spare DMA map\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Pre-allocate our receive buffers.
|
|
|
|
*/
|
|
|
|
sc->fxp_desc.rx_head = sc->fxp_desc.rx_tail = NULL;
|
|
|
|
for (i = 0; i < FXP_NRFABUFS; i++) {
|
|
|
|
rxp = &sc->fxp_desc.rx_list[i];
|
2009-06-21 06:06:43 +00:00
|
|
|
error = bus_dmamap_create(sc->fxp_rxmtag, 0, &rxp->rx_map);
|
2003-04-02 16:47:16 +00:00
|
|
|
if (error) {
|
|
|
|
device_printf(dev, "can't create DMA map for RX\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
2008-11-26 05:51:49 +00:00
|
|
|
if (fxp_new_rfabuf(sc, rxp) != 0) {
|
Make fxp(4) INTR_MPSAFE (but do not enable MPSAFE just yet):
- Add fxp_start_body() and change fxp_start() to just acquire locks and
then call fxp_start_body(). Places that would call fxp_start() with
locks held (mutex recursion) now call fxp_start_body() directly.
Remove MTX_RECURSE flag from sc_mtx. [gallatin]
- Change fxp_attach() to work without the softc lock, saving interrupt
hooking until the head of fxp_attach().
- Call ether_ifattach() before overriding ifp parameters. This reverts
part of 1.155.
- Remove multiple error paths in fxp_attach().
- Teardown interrupt in fxp_detach() before unlocking the softc.
- Make sure mutex is not held in fxp_release()
- Delete the miibus instance and/or self in fxp_release(), not in
fxp_detach(). This can happen if attach fails partway through.
- Move ifmedia_removeall to fxp_release() since attach may fail after
media have been allocated.
- Add locking to fxp_suspend, fxp_resume, fxp_start, fxp_intr,
fxp_poll, fxp_tick, fxp_ioctl, fxp_watchdog.
- Pass in ifp to fxp_intr_body since its callers sometimes already use
it.
- Add compatibility define for INTR_MPSAFE for 4.x. [gallatin]
- You don't need to bzero softc.
Ideas from: gallatin, mux
Tested by: >400M packets of dd/ssh, NFS, ping on i386 UP
2003-04-25 09:01:54 +00:00
|
|
|
error = ENOMEM;
|
|
|
|
goto fail;
|
|
|
|
}
|
2008-11-26 05:51:49 +00:00
|
|
|
fxp_add_rfabuf(sc, rxp);
|
2003-04-02 16:47:16 +00:00
|
|
|
}
|
|
|
|
|
2001-03-12 21:30:52 +00:00
|
|
|
/*
|
|
|
|
* Read MAC address.
|
|
|
|
*/
|
2012-03-28 01:27:27 +00:00
|
|
|
eaddr[0] = sc->eeprom[FXP_EEPROM_MAP_IA0] & 0xff;
|
|
|
|
eaddr[1] = sc->eeprom[FXP_EEPROM_MAP_IA0] >> 8;
|
|
|
|
eaddr[2] = sc->eeprom[FXP_EEPROM_MAP_IA1] & 0xff;
|
|
|
|
eaddr[3] = sc->eeprom[FXP_EEPROM_MAP_IA1] >> 8;
|
|
|
|
eaddr[4] = sc->eeprom[FXP_EEPROM_MAP_IA2] & 0xff;
|
|
|
|
eaddr[5] = sc->eeprom[FXP_EEPROM_MAP_IA2] >> 8;
|
2001-03-12 21:30:52 +00:00
|
|
|
if (bootverbose) {
|
2001-05-17 23:50:24 +00:00
|
|
|
device_printf(dev, "PCI IDs: %04x %04x %04x %04x %04x\n",
|
2001-03-12 21:30:52 +00:00
|
|
|
pci_get_vendor(dev), pci_get_device(dev),
|
2001-05-17 23:50:24 +00:00
|
|
|
pci_get_subvendor(dev), pci_get_subdevice(dev),
|
|
|
|
pci_get_revid(dev));
|
2001-10-25 05:32:01 +00:00
|
|
|
device_printf(dev, "Dynamic Standby mode is %s\n",
|
2012-03-28 01:27:27 +00:00
|
|
|
sc->eeprom[FXP_EEPROM_MAP_ID] & 0x02 ? "enabled" :
|
|
|
|
"disabled");
|
2001-03-12 21:30:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If this is only a 10Mbps device, then there is no MII, and
|
|
|
|
* the PHY will use a serial interface instead.
|
|
|
|
*
|
|
|
|
* The Seeq 80c24 AutoDUPLEX(tm) Ethernet Interface Adapter
|
|
|
|
* doesn't have a programming interface of any sort. The
|
|
|
|
* media is sensed automatically based on how the link partner
|
|
|
|
* is configured. This is, in essence, manual configuration.
|
|
|
|
*/
|
|
|
|
if (sc->flags & FXP_FLAG_SERIAL_MEDIA) {
|
|
|
|
ifmedia_add(&sc->sc_media, IFM_ETHER|IFM_MANUAL, 0, NULL);
|
|
|
|
ifmedia_set(&sc->sc_media, IFM_ETHER|IFM_MANUAL);
|
|
|
|
} else {
|
2010-10-15 14:52:11 +00:00
|
|
|
/*
|
|
|
|
* i82557 wedge when isolating all of their PHYs.
|
|
|
|
*/
|
2010-11-26 21:52:33 +00:00
|
|
|
flags = MIIF_NOISOLATE;
|
|
|
|
if (sc->revision >= FXP_REV_82558_A4)
|
|
|
|
flags |= MIIF_DOPAUSE;
|
2010-10-15 14:52:11 +00:00
|
|
|
error = mii_attach(dev, &sc->miibus, ifp, fxp_ifmedia_upd,
|
|
|
|
fxp_ifmedia_sts, BMSR_DEFCAPMASK, MII_PHY_ANY,
|
2010-11-26 21:52:33 +00:00
|
|
|
MII_OFFSET_ANY, flags);
|
2010-10-15 14:52:11 +00:00
|
|
|
if (error != 0) {
|
2010-11-26 21:52:33 +00:00
|
|
|
device_printf(dev, "attaching PHYs failed\n");
|
2001-03-12 21:30:52 +00:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
}
|
1997-09-05 10:23:58 +00:00
|
|
|
|
2003-10-31 18:32:15 +00:00
|
|
|
if_initname(ifp, device_get_name(dev), device_get_unit(dev));
|
1997-09-05 10:23:58 +00:00
|
|
|
ifp->if_init = fxp_init;
|
|
|
|
ifp->if_softc = sc;
|
|
|
|
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
|
|
|
|
ifp->if_ioctl = fxp_ioctl;
|
|
|
|
ifp->if_start = fxp_start;
|
|
|
|
|
2004-05-21 20:34:04 +00:00
|
|
|
ifp->if_capabilities = ifp->if_capenable = 0;
|
|
|
|
|
2008-11-26 07:36:17 +00:00
|
|
|
/* Enable checksum offload/TSO for 82550 or better chips */
|
2003-02-26 22:12:04 +00:00
|
|
|
if (sc->flags & FXP_FLAG_EXT_RFA) {
|
2008-11-26 07:36:17 +00:00
|
|
|
ifp->if_hwassist = FXP_CSUM_FEATURES | CSUM_TSO;
|
|
|
|
ifp->if_capabilities |= IFCAP_HWCSUM | IFCAP_TSO4;
|
|
|
|
ifp->if_capenable |= IFCAP_HWCSUM | IFCAP_TSO4;
|
2003-02-26 22:12:04 +00:00
|
|
|
}
|
|
|
|
|
2008-11-26 06:36:53 +00:00
|
|
|
if (sc->flags & FXP_FLAG_82559_RXCSUM) {
|
|
|
|
ifp->if_capabilities |= IFCAP_RXCSUM;
|
|
|
|
ifp->if_capenable |= IFCAP_RXCSUM;
|
|
|
|
}
|
|
|
|
|
2008-11-27 01:57:23 +00:00
|
|
|
if (sc->flags & FXP_FLAG_WOLCAP) {
|
|
|
|
ifp->if_capabilities |= IFCAP_WOL_MAGIC;
|
|
|
|
ifp->if_capenable |= IFCAP_WOL_MAGIC;
|
|
|
|
}
|
|
|
|
|
2004-04-11 15:35:49 +00:00
|
|
|
#ifdef DEVICE_POLLING
|
|
|
|
/* Inform the world we support polling. */
|
|
|
|
ifp->if_capabilities |= IFCAP_POLLING;
|
|
|
|
#endif
|
|
|
|
|
Make fxp(4) INTR_MPSAFE (but do not enable MPSAFE just yet):
- Add fxp_start_body() and change fxp_start() to just acquire locks and
then call fxp_start_body(). Places that would call fxp_start() with
locks held (mutex recursion) now call fxp_start_body() directly.
Remove MTX_RECURSE flag from sc_mtx. [gallatin]
- Change fxp_attach() to work without the softc lock, saving interrupt
hooking until the head of fxp_attach().
- Call ether_ifattach() before overriding ifp parameters. This reverts
part of 1.155.
- Remove multiple error paths in fxp_attach().
- Teardown interrupt in fxp_detach() before unlocking the softc.
- Make sure mutex is not held in fxp_release()
- Delete the miibus instance and/or self in fxp_release(), not in
fxp_detach(). This can happen if attach fails partway through.
- Move ifmedia_removeall to fxp_release() since attach may fail after
media have been allocated.
- Add locking to fxp_suspend, fxp_resume, fxp_start, fxp_intr,
fxp_poll, fxp_tick, fxp_ioctl, fxp_watchdog.
- Pass in ifp to fxp_intr_body since its callers sometimes already use
it.
- Add compatibility define for INTR_MPSAFE for 4.x. [gallatin]
- You don't need to bzero softc.
Ideas from: gallatin, mux
Tested by: >400M packets of dd/ssh, NFS, ping on i386 UP
2003-04-25 09:01:54 +00:00
|
|
|
/*
|
|
|
|
* Attach the interface.
|
|
|
|
*/
|
2005-06-10 16:49:24 +00:00
|
|
|
ether_ifattach(ifp, eaddr);
|
Make fxp(4) INTR_MPSAFE (but do not enable MPSAFE just yet):
- Add fxp_start_body() and change fxp_start() to just acquire locks and
then call fxp_start_body(). Places that would call fxp_start() with
locks held (mutex recursion) now call fxp_start_body() directly.
Remove MTX_RECURSE flag from sc_mtx. [gallatin]
- Change fxp_attach() to work without the softc lock, saving interrupt
hooking until the head of fxp_attach().
- Call ether_ifattach() before overriding ifp parameters. This reverts
part of 1.155.
- Remove multiple error paths in fxp_attach().
- Teardown interrupt in fxp_detach() before unlocking the softc.
- Make sure mutex is not held in fxp_release()
- Delete the miibus instance and/or self in fxp_release(), not in
fxp_detach(). This can happen if attach fails partway through.
- Move ifmedia_removeall to fxp_release() since attach may fail after
media have been allocated.
- Add locking to fxp_suspend, fxp_resume, fxp_start, fxp_intr,
fxp_poll, fxp_tick, fxp_ioctl, fxp_watchdog.
- Pass in ifp to fxp_intr_body since its callers sometimes already use
it.
- Add compatibility define for INTR_MPSAFE for 4.x. [gallatin]
- You don't need to bzero softc.
Ideas from: gallatin, mux
Tested by: >400M packets of dd/ssh, NFS, ping on i386 UP
2003-04-25 09:01:54 +00:00
|
|
|
|
2001-05-13 00:03:39 +00:00
|
|
|
/*
|
|
|
|
* Tell the upper layer(s) we support long frames.
|
2004-05-21 20:34:04 +00:00
|
|
|
* Must appear after the call to ether_ifattach() because
|
|
|
|
* ether_ifattach() sets ifi_hdrlen to the default value.
|
2001-05-13 00:03:39 +00:00
|
|
|
*/
|
|
|
|
ifp->if_data.ifi_hdrlen = sizeof(struct ether_vlan_header);
|
2002-11-14 23:54:55 +00:00
|
|
|
ifp->if_capabilities |= IFCAP_VLAN_MTU;
|
2004-05-27 14:36:58 +00:00
|
|
|
ifp->if_capenable |= IFCAP_VLAN_MTU; /* the hw bits already set */
|
2008-12-02 02:30:12 +00:00
|
|
|
if ((sc->flags & FXP_FLAG_EXT_RFA) != 0) {
|
|
|
|
ifp->if_capabilities |= IFCAP_VLAN_HWTAGGING |
|
2010-10-24 21:59:51 +00:00
|
|
|
IFCAP_VLAN_HWCSUM | IFCAP_VLAN_HWTSO;
|
2008-12-02 02:30:12 +00:00
|
|
|
ifp->if_capenable |= IFCAP_VLAN_HWTAGGING |
|
2010-10-24 21:59:51 +00:00
|
|
|
IFCAP_VLAN_HWCSUM | IFCAP_VLAN_HWTSO;
|
2008-12-02 02:30:12 +00:00
|
|
|
}
|
2001-05-13 00:03:39 +00:00
|
|
|
|
1997-10-23 01:45:15 +00:00
|
|
|
/*
|
1998-08-04 08:53:12 +00:00
|
|
|
* Let the system queue as many packets as we have available
|
|
|
|
* TX descriptors.
|
1997-10-23 01:45:15 +00:00
|
|
|
*/
|
2004-07-02 12:16:02 +00:00
|
|
|
IFQ_SET_MAXLEN(&ifp->if_snd, FXP_NTXCB - 1);
|
|
|
|
ifp->if_snd.ifq_drv_maxlen = FXP_NTXCB - 1;
|
|
|
|
IFQ_SET_READY(&ifp->if_snd);
|
1997-09-05 10:23:58 +00:00
|
|
|
|
2008-11-25 00:48:05 +00:00
|
|
|
/*
|
Make fxp(4) INTR_MPSAFE (but do not enable MPSAFE just yet):
- Add fxp_start_body() and change fxp_start() to just acquire locks and
then call fxp_start_body(). Places that would call fxp_start() with
locks held (mutex recursion) now call fxp_start_body() directly.
Remove MTX_RECURSE flag from sc_mtx. [gallatin]
- Change fxp_attach() to work without the softc lock, saving interrupt
hooking until the head of fxp_attach().
- Call ether_ifattach() before overriding ifp parameters. This reverts
part of 1.155.
- Remove multiple error paths in fxp_attach().
- Teardown interrupt in fxp_detach() before unlocking the softc.
- Make sure mutex is not held in fxp_release()
- Delete the miibus instance and/or self in fxp_release(), not in
fxp_detach(). This can happen if attach fails partway through.
- Move ifmedia_removeall to fxp_release() since attach may fail after
media have been allocated.
- Add locking to fxp_suspend, fxp_resume, fxp_start, fxp_intr,
fxp_poll, fxp_tick, fxp_ioctl, fxp_watchdog.
- Pass in ifp to fxp_intr_body since its callers sometimes already use
it.
- Add compatibility define for INTR_MPSAFE for 4.x. [gallatin]
- You don't need to bzero softc.
Ideas from: gallatin, mux
Tested by: >400M packets of dd/ssh, NFS, ping on i386 UP
2003-04-25 09:01:54 +00:00
|
|
|
* Hook our interrupt after all initialization is complete.
|
2003-04-05 01:27:17 +00:00
|
|
|
*/
|
2005-09-27 09:01:11 +00:00
|
|
|
error = bus_setup_intr(dev, sc->fxp_res[1], INTR_TYPE_NET | INTR_MPSAFE,
|
2007-02-23 12:19:07 +00:00
|
|
|
NULL, fxp_intr, sc, &sc->ih);
|
2003-04-05 01:27:17 +00:00
|
|
|
if (error) {
|
|
|
|
device_printf(dev, "could not setup irq\n");
|
2005-06-10 16:49:24 +00:00
|
|
|
ether_ifdetach(sc->ifp);
|
2003-04-05 01:27:17 +00:00
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
2008-11-27 01:57:23 +00:00
|
|
|
/*
|
|
|
|
* Configure hardware to reject magic frames otherwise
|
|
|
|
* system will hang on recipt of magic frames.
|
|
|
|
*/
|
|
|
|
if ((sc->flags & FXP_FLAG_WOLCAP) != 0) {
|
|
|
|
FXP_LOCK(sc);
|
|
|
|
/* Clear wakeup events. */
|
2008-12-02 02:12:34 +00:00
|
|
|
CSR_WRITE_1(sc, FXP_CSR_PMDR, CSR_READ_1(sc, FXP_CSR_PMDR));
|
2012-03-19 02:10:40 +00:00
|
|
|
fxp_init_body(sc, 0);
|
2008-11-27 01:57:23 +00:00
|
|
|
fxp_stop(sc);
|
|
|
|
FXP_UNLOCK(sc);
|
|
|
|
}
|
|
|
|
|
2001-03-12 21:30:52 +00:00
|
|
|
fail:
|
2005-06-10 20:42:02 +00:00
|
|
|
if (error)
|
Make fxp(4) INTR_MPSAFE (but do not enable MPSAFE just yet):
- Add fxp_start_body() and change fxp_start() to just acquire locks and
then call fxp_start_body(). Places that would call fxp_start() with
locks held (mutex recursion) now call fxp_start_body() directly.
Remove MTX_RECURSE flag from sc_mtx. [gallatin]
- Change fxp_attach() to work without the softc lock, saving interrupt
hooking until the head of fxp_attach().
- Call ether_ifattach() before overriding ifp parameters. This reverts
part of 1.155.
- Remove multiple error paths in fxp_attach().
- Teardown interrupt in fxp_detach() before unlocking the softc.
- Make sure mutex is not held in fxp_release()
- Delete the miibus instance and/or self in fxp_release(), not in
fxp_detach(). This can happen if attach fails partway through.
- Move ifmedia_removeall to fxp_release() since attach may fail after
media have been allocated.
- Add locking to fxp_suspend, fxp_resume, fxp_start, fxp_intr,
fxp_poll, fxp_tick, fxp_ioctl, fxp_watchdog.
- Pass in ifp to fxp_intr_body since its callers sometimes already use
it.
- Add compatibility define for INTR_MPSAFE for 4.x. [gallatin]
- You don't need to bzero softc.
Ideas from: gallatin, mux
Tested by: >400M packets of dd/ssh, NFS, ping on i386 UP
2003-04-25 09:01:54 +00:00
|
|
|
fxp_release(sc);
|
2001-03-12 21:30:52 +00:00
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
Make fxp(4) INTR_MPSAFE (but do not enable MPSAFE just yet):
- Add fxp_start_body() and change fxp_start() to just acquire locks and
then call fxp_start_body(). Places that would call fxp_start() with
locks held (mutex recursion) now call fxp_start_body() directly.
Remove MTX_RECURSE flag from sc_mtx. [gallatin]
- Change fxp_attach() to work without the softc lock, saving interrupt
hooking until the head of fxp_attach().
- Call ether_ifattach() before overriding ifp parameters. This reverts
part of 1.155.
- Remove multiple error paths in fxp_attach().
- Teardown interrupt in fxp_detach() before unlocking the softc.
- Make sure mutex is not held in fxp_release()
- Delete the miibus instance and/or self in fxp_release(), not in
fxp_detach(). This can happen if attach fails partway through.
- Move ifmedia_removeall to fxp_release() since attach may fail after
media have been allocated.
- Add locking to fxp_suspend, fxp_resume, fxp_start, fxp_intr,
fxp_poll, fxp_tick, fxp_ioctl, fxp_watchdog.
- Pass in ifp to fxp_intr_body since its callers sometimes already use
it.
- Add compatibility define for INTR_MPSAFE for 4.x. [gallatin]
- You don't need to bzero softc.
Ideas from: gallatin, mux
Tested by: >400M packets of dd/ssh, NFS, ping on i386 UP
2003-04-25 09:01:54 +00:00
|
|
|
* Release all resources. The softc lock should not be held and the
|
|
|
|
* interrupt should already be torn down.
|
2001-03-12 21:30:52 +00:00
|
|
|
*/
|
|
|
|
static void
|
|
|
|
fxp_release(struct fxp_softc *sc)
|
|
|
|
{
|
2003-04-02 16:47:16 +00:00
|
|
|
struct fxp_rx *rxp;
|
|
|
|
struct fxp_tx *txp;
|
|
|
|
int i;
|
|
|
|
|
2004-06-02 22:59:57 +00:00
|
|
|
FXP_LOCK_ASSERT(sc, MA_NOTOWNED);
|
2004-05-24 18:31:56 +00:00
|
|
|
KASSERT(sc->ih == NULL,
|
|
|
|
("fxp_release() called with intr handle still active"));
|
Make fxp(4) INTR_MPSAFE (but do not enable MPSAFE just yet):
- Add fxp_start_body() and change fxp_start() to just acquire locks and
then call fxp_start_body(). Places that would call fxp_start() with
locks held (mutex recursion) now call fxp_start_body() directly.
Remove MTX_RECURSE flag from sc_mtx. [gallatin]
- Change fxp_attach() to work without the softc lock, saving interrupt
hooking until the head of fxp_attach().
- Call ether_ifattach() before overriding ifp parameters. This reverts
part of 1.155.
- Remove multiple error paths in fxp_attach().
- Teardown interrupt in fxp_detach() before unlocking the softc.
- Make sure mutex is not held in fxp_release()
- Delete the miibus instance and/or self in fxp_release(), not in
fxp_detach(). This can happen if attach fails partway through.
- Move ifmedia_removeall to fxp_release() since attach may fail after
media have been allocated.
- Add locking to fxp_suspend, fxp_resume, fxp_start, fxp_intr,
fxp_poll, fxp_tick, fxp_ioctl, fxp_watchdog.
- Pass in ifp to fxp_intr_body since its callers sometimes already use
it.
- Add compatibility define for INTR_MPSAFE for 4.x. [gallatin]
- You don't need to bzero softc.
Ideas from: gallatin, mux
Tested by: >400M packets of dd/ssh, NFS, ping on i386 UP
2003-04-25 09:01:54 +00:00
|
|
|
if (sc->miibus)
|
|
|
|
device_delete_child(sc->dev, sc->miibus);
|
|
|
|
bus_generic_detach(sc->dev);
|
|
|
|
ifmedia_removeall(&sc->sc_media);
|
2003-04-02 16:47:16 +00:00
|
|
|
if (sc->fxp_desc.cbl_list) {
|
|
|
|
bus_dmamap_unload(sc->cbl_tag, sc->cbl_map);
|
|
|
|
bus_dmamem_free(sc->cbl_tag, sc->fxp_desc.cbl_list,
|
|
|
|
sc->cbl_map);
|
|
|
|
}
|
|
|
|
if (sc->fxp_stats) {
|
|
|
|
bus_dmamap_unload(sc->fxp_stag, sc->fxp_smap);
|
|
|
|
bus_dmamem_free(sc->fxp_stag, sc->fxp_stats, sc->fxp_smap);
|
|
|
|
}
|
|
|
|
if (sc->mcsp) {
|
|
|
|
bus_dmamap_unload(sc->mcs_tag, sc->mcs_map);
|
|
|
|
bus_dmamem_free(sc->mcs_tag, sc->mcsp, sc->mcs_map);
|
|
|
|
}
|
2005-09-27 09:01:11 +00:00
|
|
|
bus_release_resources(sc->dev, sc->fxp_spec, sc->fxp_res);
|
2009-06-21 06:06:43 +00:00
|
|
|
if (sc->fxp_rxmtag) {
|
2003-04-10 23:15:12 +00:00
|
|
|
for (i = 0; i < FXP_NRFABUFS; i++) {
|
|
|
|
rxp = &sc->fxp_desc.rx_list[i];
|
|
|
|
if (rxp->rx_mbuf != NULL) {
|
2009-06-21 06:06:43 +00:00
|
|
|
bus_dmamap_sync(sc->fxp_rxmtag, rxp->rx_map,
|
2003-04-10 23:15:12 +00:00
|
|
|
BUS_DMASYNC_POSTREAD);
|
2009-06-21 06:06:43 +00:00
|
|
|
bus_dmamap_unload(sc->fxp_rxmtag, rxp->rx_map);
|
2003-04-10 23:15:12 +00:00
|
|
|
m_freem(rxp->rx_mbuf);
|
|
|
|
}
|
2009-06-21 06:06:43 +00:00
|
|
|
bus_dmamap_destroy(sc->fxp_rxmtag, rxp->rx_map);
|
2003-04-10 23:15:12 +00:00
|
|
|
}
|
2009-06-21 06:06:43 +00:00
|
|
|
bus_dmamap_destroy(sc->fxp_rxmtag, sc->spare_map);
|
|
|
|
bus_dma_tag_destroy(sc->fxp_rxmtag);
|
|
|
|
}
|
|
|
|
if (sc->fxp_txmtag) {
|
2003-04-10 23:15:12 +00:00
|
|
|
for (i = 0; i < FXP_NTXCB; i++) {
|
|
|
|
txp = &sc->fxp_desc.tx_list[i];
|
|
|
|
if (txp->tx_mbuf != NULL) {
|
2009-06-21 06:06:43 +00:00
|
|
|
bus_dmamap_sync(sc->fxp_txmtag, txp->tx_map,
|
2003-04-10 23:15:12 +00:00
|
|
|
BUS_DMASYNC_POSTWRITE);
|
2009-06-21 06:06:43 +00:00
|
|
|
bus_dmamap_unload(sc->fxp_txmtag, txp->tx_map);
|
2003-04-10 23:15:12 +00:00
|
|
|
m_freem(txp->tx_mbuf);
|
|
|
|
}
|
2009-06-21 06:06:43 +00:00
|
|
|
bus_dmamap_destroy(sc->fxp_txmtag, txp->tx_map);
|
2003-04-10 23:15:12 +00:00
|
|
|
}
|
2009-06-21 06:06:43 +00:00
|
|
|
bus_dma_tag_destroy(sc->fxp_txmtag);
|
2003-04-10 23:15:12 +00:00
|
|
|
}
|
2005-03-16 16:39:04 +00:00
|
|
|
if (sc->fxp_stag)
|
|
|
|
bus_dma_tag_destroy(sc->fxp_stag);
|
2003-04-02 16:47:16 +00:00
|
|
|
if (sc->cbl_tag)
|
|
|
|
bus_dma_tag_destroy(sc->cbl_tag);
|
|
|
|
if (sc->mcs_tag)
|
|
|
|
bus_dma_tag_destroy(sc->mcs_tag);
|
2005-06-10 16:49:24 +00:00
|
|
|
if (sc->ifp)
|
|
|
|
if_free(sc->ifp);
|
2001-10-25 05:32:01 +00:00
|
|
|
|
2000-09-17 13:26:25 +00:00
|
|
|
mtx_destroy(&sc->sc_mtx);
|
1999-04-16 21:22:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Detach interface.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
fxp_detach(device_t dev)
|
|
|
|
{
|
|
|
|
struct fxp_softc *sc = device_get_softc(dev);
|
|
|
|
|
Big polling(4) cleanup.
o Axe poll in trap.
o Axe IFF_POLLING flag from if_flags.
o Rework revision 1.21 (Giant removal), in such a way that
poll_mtx is not dropped during call to polling handler.
This fixes problem with idle polling.
o Make registration and deregistration from polling in a
functional way, insted of next tick/interrupt.
o Obsolete kern.polling.enable. Polling is turned on/off
with ifconfig.
Detailed kern_poll.c changes:
- Remove polling handler flags, introduced in 1.21. The are not
needed now.
- Forget and do not check if_flags, if_capenable and if_drv_flags.
- Call all registered polling handlers unconditionally.
- Do not drop poll_mtx, when entering polling handlers.
- In ether_poll() NET_LOCK_GIANT prior to locking poll_mtx.
- In netisr_poll() axe the block, where polling code asks drivers
to unregister.
- In netisr_poll() and ether_poll() do polling always, if any
handlers are present.
- In ether_poll_[de]register() remove a lot of error hiding code. Assert
that arguments are correct, instead.
- In ether_poll_[de]register() use standard return values in case of
error or success.
- Introduce poll_switch() that is a sysctl handler for kern.polling.enable.
poll_switch() goes through interface list and enabled/disables polling.
A message that kern.polling.enable is deprecated is printed.
Detailed driver changes:
- On attach driver announces IFCAP_POLLING in if_capabilities, but
not in if_capenable.
- On detach driver calls ether_poll_deregister() if polling is enabled.
- In polling handler driver obtains its lock and checks IFF_DRV_RUNNING
flag. If there is no, then unlocks and returns.
- In ioctl handler driver checks for IFCAP_POLLING flag requested to
be set or cleared. Driver first calls ether_poll_[de]register(), then
obtains driver lock and [dis/en]ables interrupts.
- In interrupt handler driver checks IFCAP_POLLING flag in if_capenable.
If present, then returns.This is important to protect from spurious
interrupts.
Reviewed by: ru, sam, jhb
2005-10-01 18:56:19 +00:00
|
|
|
#ifdef DEVICE_POLLING
|
2008-11-25 00:48:05 +00:00
|
|
|
if (sc->ifp->if_capenable & IFCAP_POLLING)
|
Big polling(4) cleanup.
o Axe poll in trap.
o Axe IFF_POLLING flag from if_flags.
o Rework revision 1.21 (Giant removal), in such a way that
poll_mtx is not dropped during call to polling handler.
This fixes problem with idle polling.
o Make registration and deregistration from polling in a
functional way, insted of next tick/interrupt.
o Obsolete kern.polling.enable. Polling is turned on/off
with ifconfig.
Detailed kern_poll.c changes:
- Remove polling handler flags, introduced in 1.21. The are not
needed now.
- Forget and do not check if_flags, if_capenable and if_drv_flags.
- Call all registered polling handlers unconditionally.
- Do not drop poll_mtx, when entering polling handlers.
- In ether_poll() NET_LOCK_GIANT prior to locking poll_mtx.
- In netisr_poll() axe the block, where polling code asks drivers
to unregister.
- In netisr_poll() and ether_poll() do polling always, if any
handlers are present.
- In ether_poll_[de]register() remove a lot of error hiding code. Assert
that arguments are correct, instead.
- In ether_poll_[de]register() use standard return values in case of
error or success.
- Introduce poll_switch() that is a sysctl handler for kern.polling.enable.
poll_switch() goes through interface list and enabled/disables polling.
A message that kern.polling.enable is deprecated is printed.
Detailed driver changes:
- On attach driver announces IFCAP_POLLING in if_capabilities, but
not in if_capenable.
- On detach driver calls ether_poll_deregister() if polling is enabled.
- In polling handler driver obtains its lock and checks IFF_DRV_RUNNING
flag. If there is no, then unlocks and returns.
- In ioctl handler driver checks for IFCAP_POLLING flag requested to
be set or cleared. Driver first calls ether_poll_[de]register(), then
obtains driver lock and [dis/en]ables interrupts.
- In interrupt handler driver checks IFCAP_POLLING flag in if_capenable.
If present, then returns.This is important to protect from spurious
interrupts.
Reviewed by: ru, sam, jhb
2005-10-01 18:56:19 +00:00
|
|
|
ether_poll_deregister(sc->ifp);
|
|
|
|
#endif
|
|
|
|
|
Make fxp(4) INTR_MPSAFE (but do not enable MPSAFE just yet):
- Add fxp_start_body() and change fxp_start() to just acquire locks and
then call fxp_start_body(). Places that would call fxp_start() with
locks held (mutex recursion) now call fxp_start_body() directly.
Remove MTX_RECURSE flag from sc_mtx. [gallatin]
- Change fxp_attach() to work without the softc lock, saving interrupt
hooking until the head of fxp_attach().
- Call ether_ifattach() before overriding ifp parameters. This reverts
part of 1.155.
- Remove multiple error paths in fxp_attach().
- Teardown interrupt in fxp_detach() before unlocking the softc.
- Make sure mutex is not held in fxp_release()
- Delete the miibus instance and/or self in fxp_release(), not in
fxp_detach(). This can happen if attach fails partway through.
- Move ifmedia_removeall to fxp_release() since attach may fail after
media have been allocated.
- Add locking to fxp_suspend, fxp_resume, fxp_start, fxp_intr,
fxp_poll, fxp_tick, fxp_ioctl, fxp_watchdog.
- Pass in ifp to fxp_intr_body since its callers sometimes already use
it.
- Add compatibility define for INTR_MPSAFE for 4.x. [gallatin]
- You don't need to bzero softc.
Ideas from: gallatin, mux
Tested by: >400M packets of dd/ssh, NFS, ping on i386 UP
2003-04-25 09:01:54 +00:00
|
|
|
FXP_LOCK(sc);
|
2003-04-11 12:52:52 +00:00
|
|
|
/*
|
2003-04-29 05:45:09 +00:00
|
|
|
* Stop DMA and drop transmit queue, but disable interrupts first.
|
2003-04-11 12:52:52 +00:00
|
|
|
*/
|
2003-04-29 05:45:09 +00:00
|
|
|
CSR_WRITE_1(sc, FXP_CSR_SCB_INTRCNTL, FXP_SCB_INTR_DISABLE);
|
|
|
|
fxp_stop(sc);
|
|
|
|
FXP_UNLOCK(sc);
|
2005-08-17 17:44:32 +00:00
|
|
|
callout_drain(&sc->stat_ch);
|
1999-04-16 21:22:55 +00:00
|
|
|
|
2005-08-08 21:03:54 +00:00
|
|
|
/*
|
|
|
|
* Close down routes etc.
|
|
|
|
*/
|
|
|
|
ether_ifdetach(sc->ifp);
|
|
|
|
|
2003-04-11 12:52:52 +00:00
|
|
|
/*
|
Make fxp(4) INTR_MPSAFE (but do not enable MPSAFE just yet):
- Add fxp_start_body() and change fxp_start() to just acquire locks and
then call fxp_start_body(). Places that would call fxp_start() with
locks held (mutex recursion) now call fxp_start_body() directly.
Remove MTX_RECURSE flag from sc_mtx. [gallatin]
- Change fxp_attach() to work without the softc lock, saving interrupt
hooking until the head of fxp_attach().
- Call ether_ifattach() before overriding ifp parameters. This reverts
part of 1.155.
- Remove multiple error paths in fxp_attach().
- Teardown interrupt in fxp_detach() before unlocking the softc.
- Make sure mutex is not held in fxp_release()
- Delete the miibus instance and/or self in fxp_release(), not in
fxp_detach(). This can happen if attach fails partway through.
- Move ifmedia_removeall to fxp_release() since attach may fail after
media have been allocated.
- Add locking to fxp_suspend, fxp_resume, fxp_start, fxp_intr,
fxp_poll, fxp_tick, fxp_ioctl, fxp_watchdog.
- Pass in ifp to fxp_intr_body since its callers sometimes already use
it.
- Add compatibility define for INTR_MPSAFE for 4.x. [gallatin]
- You don't need to bzero softc.
Ideas from: gallatin, mux
Tested by: >400M packets of dd/ssh, NFS, ping on i386 UP
2003-04-25 09:01:54 +00:00
|
|
|
* Unhook interrupt before dropping lock. This is to prevent
|
|
|
|
* races with fxp_intr().
|
2003-04-11 12:52:52 +00:00
|
|
|
*/
|
2005-09-27 09:01:11 +00:00
|
|
|
bus_teardown_intr(sc->dev, sc->fxp_res[1], sc->ih);
|
Make fxp(4) INTR_MPSAFE (but do not enable MPSAFE just yet):
- Add fxp_start_body() and change fxp_start() to just acquire locks and
then call fxp_start_body(). Places that would call fxp_start() with
locks held (mutex recursion) now call fxp_start_body() directly.
Remove MTX_RECURSE flag from sc_mtx. [gallatin]
- Change fxp_attach() to work without the softc lock, saving interrupt
hooking until the head of fxp_attach().
- Call ether_ifattach() before overriding ifp parameters. This reverts
part of 1.155.
- Remove multiple error paths in fxp_attach().
- Teardown interrupt in fxp_detach() before unlocking the softc.
- Make sure mutex is not held in fxp_release()
- Delete the miibus instance and/or self in fxp_release(), not in
fxp_detach(). This can happen if attach fails partway through.
- Move ifmedia_removeall to fxp_release() since attach may fail after
media have been allocated.
- Add locking to fxp_suspend, fxp_resume, fxp_start, fxp_intr,
fxp_poll, fxp_tick, fxp_ioctl, fxp_watchdog.
- Pass in ifp to fxp_intr_body since its callers sometimes already use
it.
- Add compatibility define for INTR_MPSAFE for 4.x. [gallatin]
- You don't need to bzero softc.
Ideas from: gallatin, mux
Tested by: >400M packets of dd/ssh, NFS, ping on i386 UP
2003-04-25 09:01:54 +00:00
|
|
|
sc->ih = NULL;
|
2003-04-11 12:52:52 +00:00
|
|
|
|
2001-03-12 21:30:52 +00:00
|
|
|
/* Release our allocated resources. */
|
|
|
|
fxp_release(sc);
|
|
|
|
return (0);
|
1997-09-05 10:23:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Device shutdown routine. Called at system shutdown after sync. The
|
|
|
|
* main purpose of this routine is to shut off receiver DMA so that
|
|
|
|
* kernel memory doesn't get clobbered during warmboot.
|
|
|
|
*/
|
1999-04-16 21:22:55 +00:00
|
|
|
static int
|
|
|
|
fxp_shutdown(device_t dev)
|
1997-09-05 10:23:58 +00:00
|
|
|
{
|
2005-08-08 21:03:54 +00:00
|
|
|
|
1999-04-16 21:22:55 +00:00
|
|
|
/*
|
|
|
|
* Make sure that DMA is disabled prior to reboot. Not doing
|
|
|
|
* do could allow DMA to corrupt kernel memory during the
|
|
|
|
* reboot before the driver initializes.
|
|
|
|
*/
|
2008-11-27 01:57:23 +00:00
|
|
|
return (fxp_suspend(dev));
|
1997-09-05 10:23:58 +00:00
|
|
|
}
|
|
|
|
|
2000-09-17 22:12:12 +00:00
|
|
|
/*
|
|
|
|
* Device suspend routine. Stop the interface and save some PCI
|
|
|
|
* settings in case the BIOS doesn't restore them properly on
|
|
|
|
* resume.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
fxp_suspend(device_t dev)
|
|
|
|
{
|
|
|
|
struct fxp_softc *sc = device_get_softc(dev);
|
2008-11-27 01:57:23 +00:00
|
|
|
struct ifnet *ifp;
|
|
|
|
int pmc;
|
|
|
|
uint16_t pmstat;
|
2000-09-17 22:12:12 +00:00
|
|
|
|
Make fxp(4) INTR_MPSAFE (but do not enable MPSAFE just yet):
- Add fxp_start_body() and change fxp_start() to just acquire locks and
then call fxp_start_body(). Places that would call fxp_start() with
locks held (mutex recursion) now call fxp_start_body() directly.
Remove MTX_RECURSE flag from sc_mtx. [gallatin]
- Change fxp_attach() to work without the softc lock, saving interrupt
hooking until the head of fxp_attach().
- Call ether_ifattach() before overriding ifp parameters. This reverts
part of 1.155.
- Remove multiple error paths in fxp_attach().
- Teardown interrupt in fxp_detach() before unlocking the softc.
- Make sure mutex is not held in fxp_release()
- Delete the miibus instance and/or self in fxp_release(), not in
fxp_detach(). This can happen if attach fails partway through.
- Move ifmedia_removeall to fxp_release() since attach may fail after
media have been allocated.
- Add locking to fxp_suspend, fxp_resume, fxp_start, fxp_intr,
fxp_poll, fxp_tick, fxp_ioctl, fxp_watchdog.
- Pass in ifp to fxp_intr_body since its callers sometimes already use
it.
- Add compatibility define for INTR_MPSAFE for 4.x. [gallatin]
- You don't need to bzero softc.
Ideas from: gallatin, mux
Tested by: >400M packets of dd/ssh, NFS, ping on i386 UP
2003-04-25 09:01:54 +00:00
|
|
|
FXP_LOCK(sc);
|
2000-09-17 22:12:12 +00:00
|
|
|
|
2008-11-27 01:57:23 +00:00
|
|
|
ifp = sc->ifp;
|
2011-03-23 13:10:15 +00:00
|
|
|
if (pci_find_cap(sc->dev, PCIY_PMG, &pmc) == 0) {
|
2008-11-27 01:57:23 +00:00
|
|
|
pmstat = pci_read_config(sc->dev, pmc + PCIR_POWER_STATUS, 2);
|
|
|
|
pmstat &= ~(PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE);
|
|
|
|
if ((ifp->if_capenable & IFCAP_WOL_MAGIC) != 0) {
|
|
|
|
/* Request PME. */
|
|
|
|
pmstat |= PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE;
|
|
|
|
sc->flags |= FXP_FLAG_WOL;
|
|
|
|
/* Reconfigure hardware to accept magic frames. */
|
2013-06-10 07:31:49 +00:00
|
|
|
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
|
|
|
|
fxp_init_body(sc, 0);
|
2008-11-27 01:57:23 +00:00
|
|
|
}
|
|
|
|
pci_write_config(sc->dev, pmc + PCIR_POWER_STATUS, pmstat, 2);
|
|
|
|
}
|
2000-09-17 22:12:12 +00:00
|
|
|
fxp_stop(sc);
|
2008-11-25 00:48:05 +00:00
|
|
|
|
2000-09-17 22:12:12 +00:00
|
|
|
sc->suspended = 1;
|
|
|
|
|
Make fxp(4) INTR_MPSAFE (but do not enable MPSAFE just yet):
- Add fxp_start_body() and change fxp_start() to just acquire locks and
then call fxp_start_body(). Places that would call fxp_start() with
locks held (mutex recursion) now call fxp_start_body() directly.
Remove MTX_RECURSE flag from sc_mtx. [gallatin]
- Change fxp_attach() to work without the softc lock, saving interrupt
hooking until the head of fxp_attach().
- Call ether_ifattach() before overriding ifp parameters. This reverts
part of 1.155.
- Remove multiple error paths in fxp_attach().
- Teardown interrupt in fxp_detach() before unlocking the softc.
- Make sure mutex is not held in fxp_release()
- Delete the miibus instance and/or self in fxp_release(), not in
fxp_detach(). This can happen if attach fails partway through.
- Move ifmedia_removeall to fxp_release() since attach may fail after
media have been allocated.
- Add locking to fxp_suspend, fxp_resume, fxp_start, fxp_intr,
fxp_poll, fxp_tick, fxp_ioctl, fxp_watchdog.
- Pass in ifp to fxp_intr_body since its callers sometimes already use
it.
- Add compatibility define for INTR_MPSAFE for 4.x. [gallatin]
- You don't need to bzero softc.
Ideas from: gallatin, mux
Tested by: >400M packets of dd/ssh, NFS, ping on i386 UP
2003-04-25 09:01:54 +00:00
|
|
|
FXP_UNLOCK(sc);
|
2001-03-12 21:30:52 +00:00
|
|
|
return (0);
|
2000-09-17 22:12:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2005-06-06 03:22:51 +00:00
|
|
|
* Device resume routine. re-enable busmastering, and restart the interface if
|
2000-09-17 22:12:12 +00:00
|
|
|
* appropriate.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
fxp_resume(device_t dev)
|
|
|
|
{
|
|
|
|
struct fxp_softc *sc = device_get_softc(dev);
|
2005-06-10 16:49:24 +00:00
|
|
|
struct ifnet *ifp = sc->ifp;
|
2008-11-27 01:57:23 +00:00
|
|
|
int pmc;
|
|
|
|
uint16_t pmstat;
|
2000-09-17 22:12:12 +00:00
|
|
|
|
Make fxp(4) INTR_MPSAFE (but do not enable MPSAFE just yet):
- Add fxp_start_body() and change fxp_start() to just acquire locks and
then call fxp_start_body(). Places that would call fxp_start() with
locks held (mutex recursion) now call fxp_start_body() directly.
Remove MTX_RECURSE flag from sc_mtx. [gallatin]
- Change fxp_attach() to work without the softc lock, saving interrupt
hooking until the head of fxp_attach().
- Call ether_ifattach() before overriding ifp parameters. This reverts
part of 1.155.
- Remove multiple error paths in fxp_attach().
- Teardown interrupt in fxp_detach() before unlocking the softc.
- Make sure mutex is not held in fxp_release()
- Delete the miibus instance and/or self in fxp_release(), not in
fxp_detach(). This can happen if attach fails partway through.
- Move ifmedia_removeall to fxp_release() since attach may fail after
media have been allocated.
- Add locking to fxp_suspend, fxp_resume, fxp_start, fxp_intr,
fxp_poll, fxp_tick, fxp_ioctl, fxp_watchdog.
- Pass in ifp to fxp_intr_body since its callers sometimes already use
it.
- Add compatibility define for INTR_MPSAFE for 4.x. [gallatin]
- You don't need to bzero softc.
Ideas from: gallatin, mux
Tested by: >400M packets of dd/ssh, NFS, ping on i386 UP
2003-04-25 09:01:54 +00:00
|
|
|
FXP_LOCK(sc);
|
2000-09-17 22:12:12 +00:00
|
|
|
|
2011-03-23 13:10:15 +00:00
|
|
|
if (pci_find_cap(sc->dev, PCIY_PMG, &pmc) == 0) {
|
2008-11-27 01:57:23 +00:00
|
|
|
sc->flags &= ~FXP_FLAG_WOL;
|
|
|
|
pmstat = pci_read_config(sc->dev, pmc + PCIR_POWER_STATUS, 2);
|
|
|
|
/* Disable PME and clear PME status. */
|
|
|
|
pmstat &= ~PCIM_PSTAT_PMEENABLE;
|
|
|
|
pci_write_config(sc->dev, pmc + PCIR_POWER_STATUS, pmstat, 2);
|
2008-12-02 02:12:34 +00:00
|
|
|
if ((sc->flags & FXP_FLAG_WOLCAP) != 0)
|
|
|
|
CSR_WRITE_1(sc, FXP_CSR_PMDR,
|
|
|
|
CSR_READ_1(sc, FXP_CSR_PMDR));
|
2008-11-27 01:57:23 +00:00
|
|
|
}
|
|
|
|
|
2000-09-17 22:12:12 +00:00
|
|
|
CSR_WRITE_4(sc, FXP_CSR_PORT, FXP_PORT_SELECTIVE_RESET);
|
|
|
|
DELAY(10);
|
|
|
|
|
|
|
|
/* reinitialize interface if necessary */
|
|
|
|
if (ifp->if_flags & IFF_UP)
|
2010-11-26 21:52:33 +00:00
|
|
|
fxp_init_body(sc, 1);
|
2000-09-17 22:12:12 +00:00
|
|
|
|
|
|
|
sc->suspended = 0;
|
|
|
|
|
Make fxp(4) INTR_MPSAFE (but do not enable MPSAFE just yet):
- Add fxp_start_body() and change fxp_start() to just acquire locks and
then call fxp_start_body(). Places that would call fxp_start() with
locks held (mutex recursion) now call fxp_start_body() directly.
Remove MTX_RECURSE flag from sc_mtx. [gallatin]
- Change fxp_attach() to work without the softc lock, saving interrupt
hooking until the head of fxp_attach().
- Call ether_ifattach() before overriding ifp parameters. This reverts
part of 1.155.
- Remove multiple error paths in fxp_attach().
- Teardown interrupt in fxp_detach() before unlocking the softc.
- Make sure mutex is not held in fxp_release()
- Delete the miibus instance and/or self in fxp_release(), not in
fxp_detach(). This can happen if attach fails partway through.
- Move ifmedia_removeall to fxp_release() since attach may fail after
media have been allocated.
- Add locking to fxp_suspend, fxp_resume, fxp_start, fxp_intr,
fxp_poll, fxp_tick, fxp_ioctl, fxp_watchdog.
- Pass in ifp to fxp_intr_body since its callers sometimes already use
it.
- Add compatibility define for INTR_MPSAFE for 4.x. [gallatin]
- You don't need to bzero softc.
Ideas from: gallatin, mux
Tested by: >400M packets of dd/ssh, NFS, ping on i386 UP
2003-04-25 09:01:54 +00:00
|
|
|
FXP_UNLOCK(sc);
|
2001-03-12 21:30:52 +00:00
|
|
|
return (0);
|
2000-09-17 22:12:12 +00:00
|
|
|
}
|
|
|
|
|
2008-11-25 00:48:05 +00:00
|
|
|
static void
|
2001-08-27 16:07:12 +00:00
|
|
|
fxp_eeprom_shiftin(struct fxp_softc *sc, int data, int length)
|
|
|
|
{
|
2005-03-06 05:07:26 +00:00
|
|
|
uint16_t reg;
|
2001-08-27 16:07:12 +00:00
|
|
|
int x;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Shift in data.
|
|
|
|
*/
|
|
|
|
for (x = 1 << (length - 1); x; x >>= 1) {
|
|
|
|
if (data & x)
|
|
|
|
reg = FXP_EEPROM_EECS | FXP_EEPROM_EEDI;
|
|
|
|
else
|
|
|
|
reg = FXP_EEPROM_EECS;
|
|
|
|
CSR_WRITE_2(sc, FXP_CSR_EEPROMCONTROL, reg);
|
|
|
|
DELAY(1);
|
|
|
|
CSR_WRITE_2(sc, FXP_CSR_EEPROMCONTROL, reg | FXP_EEPROM_EESK);
|
|
|
|
DELAY(1);
|
|
|
|
CSR_WRITE_2(sc, FXP_CSR_EEPROMCONTROL, reg);
|
|
|
|
DELAY(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1997-09-05 10:23:58 +00:00
|
|
|
/*
|
2001-03-12 21:30:52 +00:00
|
|
|
* Read from the serial EEPROM. Basically, you manually shift in
|
|
|
|
* the read opcode (one bit at a time) and then shift in the address,
|
|
|
|
* and then you shift out the data (all of this one bit at a time).
|
|
|
|
* The word size is 16 bits, so you have to provide the address for
|
|
|
|
* every 16 bits of data.
|
1997-09-05 10:23:58 +00:00
|
|
|
*/
|
2005-03-06 05:07:26 +00:00
|
|
|
static uint16_t
|
2001-03-12 21:30:52 +00:00
|
|
|
fxp_eeprom_getword(struct fxp_softc *sc, int offset, int autosize)
|
1997-09-05 10:23:58 +00:00
|
|
|
{
|
2005-03-06 05:07:26 +00:00
|
|
|
uint16_t reg, data;
|
2001-03-12 21:30:52 +00:00
|
|
|
int x;
|
1997-09-05 10:23:58 +00:00
|
|
|
|
2001-03-12 21:30:52 +00:00
|
|
|
CSR_WRITE_2(sc, FXP_CSR_EEPROMCONTROL, FXP_EEPROM_EECS);
|
1997-09-05 10:23:58 +00:00
|
|
|
/*
|
2001-03-12 21:30:52 +00:00
|
|
|
* Shift in read opcode.
|
1997-09-05 10:23:58 +00:00
|
|
|
*/
|
2001-08-27 16:07:12 +00:00
|
|
|
fxp_eeprom_shiftin(sc, FXP_EEPROM_OPC_READ, 3);
|
1995-12-01 22:41:56 +00:00
|
|
|
/*
|
2001-03-12 21:30:52 +00:00
|
|
|
* Shift in address.
|
1995-12-01 22:41:56 +00:00
|
|
|
*/
|
2001-03-12 21:30:52 +00:00
|
|
|
data = 0;
|
|
|
|
for (x = 1 << (sc->eeprom_size - 1); x; x >>= 1) {
|
|
|
|
if (offset & x)
|
|
|
|
reg = FXP_EEPROM_EECS | FXP_EEPROM_EEDI;
|
|
|
|
else
|
|
|
|
reg = FXP_EEPROM_EECS;
|
|
|
|
CSR_WRITE_2(sc, FXP_CSR_EEPROMCONTROL, reg);
|
|
|
|
DELAY(1);
|
|
|
|
CSR_WRITE_2(sc, FXP_CSR_EEPROMCONTROL, reg | FXP_EEPROM_EESK);
|
|
|
|
DELAY(1);
|
|
|
|
CSR_WRITE_2(sc, FXP_CSR_EEPROMCONTROL, reg);
|
|
|
|
DELAY(1);
|
|
|
|
reg = CSR_READ_2(sc, FXP_CSR_EEPROMCONTROL) & FXP_EEPROM_EEDO;
|
|
|
|
data++;
|
|
|
|
if (autosize && reg == 0) {
|
|
|
|
sc->eeprom_size = data;
|
|
|
|
break;
|
1995-11-28 23:55:26 +00:00
|
|
|
}
|
|
|
|
}
|
1997-03-17 11:08:16 +00:00
|
|
|
/*
|
2001-03-12 21:30:52 +00:00
|
|
|
* Shift out data.
|
1997-03-17 11:08:16 +00:00
|
|
|
*/
|
2001-03-12 21:30:52 +00:00
|
|
|
data = 0;
|
|
|
|
reg = FXP_EEPROM_EECS;
|
|
|
|
for (x = 1 << 15; x; x >>= 1) {
|
|
|
|
CSR_WRITE_2(sc, FXP_CSR_EEPROMCONTROL, reg | FXP_EEPROM_EESK);
|
|
|
|
DELAY(1);
|
|
|
|
if (CSR_READ_2(sc, FXP_CSR_EEPROMCONTROL) & FXP_EEPROM_EEDO)
|
|
|
|
data |= x;
|
|
|
|
CSR_WRITE_2(sc, FXP_CSR_EEPROMCONTROL, reg);
|
|
|
|
DELAY(1);
|
1997-09-05 10:23:58 +00:00
|
|
|
}
|
2001-03-12 21:30:52 +00:00
|
|
|
CSR_WRITE_2(sc, FXP_CSR_EEPROMCONTROL, 0);
|
|
|
|
DELAY(1);
|
1997-09-05 10:23:58 +00:00
|
|
|
|
2001-03-12 21:30:52 +00:00
|
|
|
return (data);
|
1995-11-28 23:55:26 +00:00
|
|
|
}
|
|
|
|
|
2001-08-27 16:07:12 +00:00
|
|
|
static void
|
2005-03-06 05:07:26 +00:00
|
|
|
fxp_eeprom_putword(struct fxp_softc *sc, int offset, uint16_t data)
|
2001-08-27 16:07:12 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Erase/write enable.
|
|
|
|
*/
|
|
|
|
CSR_WRITE_2(sc, FXP_CSR_EEPROMCONTROL, FXP_EEPROM_EECS);
|
|
|
|
fxp_eeprom_shiftin(sc, 0x4, 3);
|
|
|
|
fxp_eeprom_shiftin(sc, 0x03 << (sc->eeprom_size - 2), sc->eeprom_size);
|
|
|
|
CSR_WRITE_2(sc, FXP_CSR_EEPROMCONTROL, 0);
|
|
|
|
DELAY(1);
|
|
|
|
/*
|
|
|
|
* Shift in write opcode, address, data.
|
|
|
|
*/
|
|
|
|
CSR_WRITE_2(sc, FXP_CSR_EEPROMCONTROL, FXP_EEPROM_EECS);
|
|
|
|
fxp_eeprom_shiftin(sc, FXP_EEPROM_OPC_WRITE, 3);
|
|
|
|
fxp_eeprom_shiftin(sc, offset, sc->eeprom_size);
|
|
|
|
fxp_eeprom_shiftin(sc, data, 16);
|
|
|
|
CSR_WRITE_2(sc, FXP_CSR_EEPROMCONTROL, 0);
|
|
|
|
DELAY(1);
|
|
|
|
/*
|
|
|
|
* Wait for EEPROM to finish up.
|
|
|
|
*/
|
|
|
|
CSR_WRITE_2(sc, FXP_CSR_EEPROMCONTROL, FXP_EEPROM_EECS);
|
|
|
|
DELAY(1);
|
|
|
|
for (i = 0; i < 1000; i++) {
|
|
|
|
if (CSR_READ_2(sc, FXP_CSR_EEPROMCONTROL) & FXP_EEPROM_EEDO)
|
|
|
|
break;
|
|
|
|
DELAY(50);
|
|
|
|
}
|
|
|
|
CSR_WRITE_2(sc, FXP_CSR_EEPROMCONTROL, 0);
|
|
|
|
DELAY(1);
|
|
|
|
/*
|
|
|
|
* Erase/write disable.
|
|
|
|
*/
|
|
|
|
CSR_WRITE_2(sc, FXP_CSR_EEPROMCONTROL, FXP_EEPROM_EECS);
|
|
|
|
fxp_eeprom_shiftin(sc, 0x4, 3);
|
|
|
|
fxp_eeprom_shiftin(sc, 0, sc->eeprom_size);
|
|
|
|
CSR_WRITE_2(sc, FXP_CSR_EEPROMCONTROL, 0);
|
|
|
|
DELAY(1);
|
|
|
|
}
|
|
|
|
|
2000-03-28 04:41:42 +00:00
|
|
|
/*
|
|
|
|
* From NetBSD:
|
|
|
|
*
|
|
|
|
* Figure out EEPROM size.
|
|
|
|
*
|
|
|
|
* 559's can have either 64-word or 256-word EEPROMs, the 558
|
|
|
|
* datasheet only talks about 64-word EEPROMs, and the 557 datasheet
|
|
|
|
* talks about the existance of 16 to 256 word EEPROMs.
|
|
|
|
*
|
|
|
|
* The only known sizes are 64 and 256, where the 256 version is used
|
|
|
|
* by CardBus cards to store CIS information.
|
|
|
|
*
|
|
|
|
* The address is shifted in msb-to-lsb, and after the last
|
|
|
|
* address-bit the EEPROM is supposed to output a `dummy zero' bit,
|
|
|
|
* after which follows the actual data. We try to detect this zero, by
|
|
|
|
* probing the data-out bit in the EEPROM control register just after
|
|
|
|
* having shifted in a bit. If the bit is zero, we assume we've
|
|
|
|
* shifted enough address bits. The data-out should be tri-state,
|
|
|
|
* before this, which should translate to a logical one.
|
|
|
|
*/
|
|
|
|
static void
|
2001-03-12 21:30:52 +00:00
|
|
|
fxp_autosize_eeprom(struct fxp_softc *sc)
|
2000-03-28 04:41:42 +00:00
|
|
|
{
|
|
|
|
|
2001-03-12 21:30:52 +00:00
|
|
|
/* guess maximum size of 256 words */
|
|
|
|
sc->eeprom_size = 8;
|
|
|
|
|
|
|
|
/* autosize */
|
|
|
|
(void) fxp_eeprom_getword(sc, 0, 1);
|
2000-03-28 04:41:42 +00:00
|
|
|
}
|
2001-03-12 21:30:52 +00:00
|
|
|
|
1995-11-28 23:55:26 +00:00
|
|
|
static void
|
2001-03-12 21:30:52 +00:00
|
|
|
fxp_read_eeprom(struct fxp_softc *sc, u_short *data, int offset, int words)
|
1997-03-17 11:08:16 +00:00
|
|
|
{
|
2001-03-12 21:30:52 +00:00
|
|
|
int i;
|
1995-11-28 23:55:26 +00:00
|
|
|
|
2001-03-12 21:30:52 +00:00
|
|
|
for (i = 0; i < words; i++)
|
|
|
|
data[i] = fxp_eeprom_getword(sc, offset + i, 0);
|
1995-11-28 23:55:26 +00:00
|
|
|
}
|
|
|
|
|
2001-08-27 16:07:12 +00:00
|
|
|
static void
|
|
|
|
fxp_write_eeprom(struct fxp_softc *sc, u_short *data, int offset, int words)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < words; i++)
|
|
|
|
fxp_eeprom_putword(sc, offset + i, data[i]);
|
|
|
|
}
|
|
|
|
|
2012-03-28 01:27:27 +00:00
|
|
|
static void
|
|
|
|
fxp_load_eeprom(struct fxp_softc *sc)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
uint16_t cksum;
|
|
|
|
|
|
|
|
fxp_read_eeprom(sc, sc->eeprom, 0, 1 << sc->eeprom_size);
|
|
|
|
cksum = 0;
|
|
|
|
for (i = 0; i < (1 << sc->eeprom_size) - 1; i++)
|
|
|
|
cksum += sc->eeprom[i];
|
|
|
|
cksum = 0xBABA - cksum;
|
|
|
|
if (cksum != sc->eeprom[(1 << sc->eeprom_size) - 1])
|
|
|
|
device_printf(sc->dev,
|
|
|
|
"EEPROM checksum mismatch! (0x%04x -> 0x%04x)\n",
|
|
|
|
cksum, sc->eeprom[(1 << sc->eeprom_size) - 1]);
|
|
|
|
}
|
|
|
|
|
1995-11-28 23:55:26 +00:00
|
|
|
/*
|
Make fxp(4) INTR_MPSAFE (but do not enable MPSAFE just yet):
- Add fxp_start_body() and change fxp_start() to just acquire locks and
then call fxp_start_body(). Places that would call fxp_start() with
locks held (mutex recursion) now call fxp_start_body() directly.
Remove MTX_RECURSE flag from sc_mtx. [gallatin]
- Change fxp_attach() to work without the softc lock, saving interrupt
hooking until the head of fxp_attach().
- Call ether_ifattach() before overriding ifp parameters. This reverts
part of 1.155.
- Remove multiple error paths in fxp_attach().
- Teardown interrupt in fxp_detach() before unlocking the softc.
- Make sure mutex is not held in fxp_release()
- Delete the miibus instance and/or self in fxp_release(), not in
fxp_detach(). This can happen if attach fails partway through.
- Move ifmedia_removeall to fxp_release() since attach may fail after
media have been allocated.
- Add locking to fxp_suspend, fxp_resume, fxp_start, fxp_intr,
fxp_poll, fxp_tick, fxp_ioctl, fxp_watchdog.
- Pass in ifp to fxp_intr_body since its callers sometimes already use
it.
- Add compatibility define for INTR_MPSAFE for 4.x. [gallatin]
- You don't need to bzero softc.
Ideas from: gallatin, mux
Tested by: >400M packets of dd/ssh, NFS, ping on i386 UP
2003-04-25 09:01:54 +00:00
|
|
|
* Grab the softc lock and call the real fxp_start_body() routine
|
1995-11-28 23:55:26 +00:00
|
|
|
*/
|
|
|
|
static void
|
2001-03-12 21:30:52 +00:00
|
|
|
fxp_start(struct ifnet *ifp)
|
Make fxp(4) INTR_MPSAFE (but do not enable MPSAFE just yet):
- Add fxp_start_body() and change fxp_start() to just acquire locks and
then call fxp_start_body(). Places that would call fxp_start() with
locks held (mutex recursion) now call fxp_start_body() directly.
Remove MTX_RECURSE flag from sc_mtx. [gallatin]
- Change fxp_attach() to work without the softc lock, saving interrupt
hooking until the head of fxp_attach().
- Call ether_ifattach() before overriding ifp parameters. This reverts
part of 1.155.
- Remove multiple error paths in fxp_attach().
- Teardown interrupt in fxp_detach() before unlocking the softc.
- Make sure mutex is not held in fxp_release()
- Delete the miibus instance and/or self in fxp_release(), not in
fxp_detach(). This can happen if attach fails partway through.
- Move ifmedia_removeall to fxp_release() since attach may fail after
media have been allocated.
- Add locking to fxp_suspend, fxp_resume, fxp_start, fxp_intr,
fxp_poll, fxp_tick, fxp_ioctl, fxp_watchdog.
- Pass in ifp to fxp_intr_body since its callers sometimes already use
it.
- Add compatibility define for INTR_MPSAFE for 4.x. [gallatin]
- You don't need to bzero softc.
Ideas from: gallatin, mux
Tested by: >400M packets of dd/ssh, NFS, ping on i386 UP
2003-04-25 09:01:54 +00:00
|
|
|
{
|
|
|
|
struct fxp_softc *sc = ifp->if_softc;
|
|
|
|
|
|
|
|
FXP_LOCK(sc);
|
|
|
|
fxp_start_body(ifp);
|
|
|
|
FXP_UNLOCK(sc);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2008-11-25 00:48:05 +00:00
|
|
|
* Start packet transmission on the interface.
|
Make fxp(4) INTR_MPSAFE (but do not enable MPSAFE just yet):
- Add fxp_start_body() and change fxp_start() to just acquire locks and
then call fxp_start_body(). Places that would call fxp_start() with
locks held (mutex recursion) now call fxp_start_body() directly.
Remove MTX_RECURSE flag from sc_mtx. [gallatin]
- Change fxp_attach() to work without the softc lock, saving interrupt
hooking until the head of fxp_attach().
- Call ether_ifattach() before overriding ifp parameters. This reverts
part of 1.155.
- Remove multiple error paths in fxp_attach().
- Teardown interrupt in fxp_detach() before unlocking the softc.
- Make sure mutex is not held in fxp_release()
- Delete the miibus instance and/or self in fxp_release(), not in
fxp_detach(). This can happen if attach fails partway through.
- Move ifmedia_removeall to fxp_release() since attach may fail after
media have been allocated.
- Add locking to fxp_suspend, fxp_resume, fxp_start, fxp_intr,
fxp_poll, fxp_tick, fxp_ioctl, fxp_watchdog.
- Pass in ifp to fxp_intr_body since its callers sometimes already use
it.
- Add compatibility define for INTR_MPSAFE for 4.x. [gallatin]
- You don't need to bzero softc.
Ideas from: gallatin, mux
Tested by: >400M packets of dd/ssh, NFS, ping on i386 UP
2003-04-25 09:01:54 +00:00
|
|
|
* This routine must be called with the softc lock held, and is an
|
|
|
|
* internal entry point only.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
fxp_start_body(struct ifnet *ifp)
|
1995-11-28 23:55:26 +00:00
|
|
|
{
|
1996-02-06 18:51:28 +00:00
|
|
|
struct fxp_softc *sc = ifp->if_softc;
|
2003-04-02 16:47:16 +00:00
|
|
|
struct mbuf *mb_head;
|
2008-11-25 04:16:16 +00:00
|
|
|
int txqueued;
|
1995-11-28 23:55:26 +00:00
|
|
|
|
2004-06-02 22:59:57 +00:00
|
|
|
FXP_LOCK_ASSERT(sc, MA_OWNED);
|
2005-03-07 13:20:49 +00:00
|
|
|
|
2009-06-21 06:46:32 +00:00
|
|
|
if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) !=
|
|
|
|
IFF_DRV_RUNNING)
|
|
|
|
return;
|
|
|
|
|
2008-11-25 04:16:16 +00:00
|
|
|
if (sc->tx_queued > FXP_NTXCB_HIWAT)
|
|
|
|
fxp_txeof(sc);
|
1995-12-01 22:41:56 +00:00
|
|
|
/*
|
1997-10-23 01:45:15 +00:00
|
|
|
* We're finished if there is nothing more to add to the list or if
|
|
|
|
* we're all filled up with buffers to transmit.
|
1998-08-04 08:53:12 +00:00
|
|
|
* NOTE: One TxCB is reserved to guarantee that fxp_mc_setup() can add
|
|
|
|
* a NOP command when needed.
|
1995-12-01 22:41:56 +00:00
|
|
|
*/
|
2005-03-07 13:20:49 +00:00
|
|
|
txqueued = 0;
|
2004-07-02 12:16:02 +00:00
|
|
|
while (!IFQ_DRV_IS_EMPTY(&ifp->if_snd) &&
|
|
|
|
sc->tx_queued < FXP_NTXCB - 1) {
|
1997-10-23 01:45:15 +00:00
|
|
|
|
1995-11-28 23:55:26 +00:00
|
|
|
/*
|
1997-10-23 01:45:15 +00:00
|
|
|
* Grab a packet to transmit.
|
1995-11-28 23:55:26 +00:00
|
|
|
*/
|
2004-07-02 12:16:02 +00:00
|
|
|
IFQ_DRV_DEQUEUE(&ifp->if_snd, mb_head);
|
|
|
|
if (mb_head == NULL)
|
|
|
|
break;
|
1995-11-28 23:55:26 +00:00
|
|
|
|
2008-11-25 04:16:16 +00:00
|
|
|
if (fxp_encap(sc, &mb_head)) {
|
|
|
|
if (mb_head == NULL)
|
|
|
|
break;
|
|
|
|
IFQ_DRV_PREPEND(&ifp->if_snd, mb_head);
|
|
|
|
ifp->if_drv_flags |= IFF_DRV_OACTIVE;
|
|
|
|
}
|
|
|
|
txqueued++;
|
|
|
|
/*
|
|
|
|
* Pass packet to bpf if there is a listener.
|
|
|
|
*/
|
|
|
|
BPF_MTAP(ifp, mb_head);
|
2005-03-07 13:20:49 +00:00
|
|
|
}
|
2003-02-26 22:12:04 +00:00
|
|
|
|
2005-03-07 13:20:49 +00:00
|
|
|
/*
|
|
|
|
* We're finished. If we added to the list, issue a RESUME to get DMA
|
|
|
|
* going again if suspended.
|
|
|
|
*/
|
2008-11-25 04:16:16 +00:00
|
|
|
if (txqueued > 0) {
|
2009-06-21 06:06:43 +00:00
|
|
|
bus_dmamap_sync(sc->cbl_tag, sc->cbl_map,
|
|
|
|
BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
|
2005-03-07 13:20:49 +00:00
|
|
|
fxp_scb_wait(sc);
|
|
|
|
fxp_scb_cmd(sc, FXP_SCB_COMMAND_CU_RESUME);
|
2008-11-25 04:16:16 +00:00
|
|
|
/*
|
|
|
|
* Set a 5 second timer just in case we don't hear
|
|
|
|
* from the card again.
|
|
|
|
*/
|
|
|
|
sc->watchdog_timer = 5;
|
2005-03-07 13:20:49 +00:00
|
|
|
}
|
|
|
|
}
|
2003-05-25 05:04:26 +00:00
|
|
|
|
2005-03-07 13:20:49 +00:00
|
|
|
static int
|
2008-11-25 04:16:16 +00:00
|
|
|
fxp_encap(struct fxp_softc *sc, struct mbuf **m_head)
|
2005-03-07 13:20:49 +00:00
|
|
|
{
|
|
|
|
struct ifnet *ifp;
|
|
|
|
struct mbuf *m;
|
|
|
|
struct fxp_tx *txp;
|
|
|
|
struct fxp_cb_tx *cbp;
|
2008-11-26 07:36:17 +00:00
|
|
|
struct tcphdr *tcp;
|
2005-03-07 13:20:49 +00:00
|
|
|
bus_dma_segment_t segs[FXP_NTXSEG];
|
2008-11-26 07:36:17 +00:00
|
|
|
int error, i, nseg, tcp_payload;
|
2005-03-07 13:20:49 +00:00
|
|
|
|
|
|
|
FXP_LOCK_ASSERT(sc, MA_OWNED);
|
2005-06-10 16:49:24 +00:00
|
|
|
ifp = sc->ifp;
|
2005-03-07 13:20:49 +00:00
|
|
|
|
2008-11-26 07:36:17 +00:00
|
|
|
tcp_payload = 0;
|
|
|
|
tcp = NULL;
|
2005-03-07 13:20:49 +00:00
|
|
|
/*
|
|
|
|
* Get pointer to next available tx desc.
|
|
|
|
*/
|
|
|
|
txp = sc->fxp_desc.tx_last->tx_next;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* A note in Appendix B of the Intel 8255x 10/100 Mbps
|
|
|
|
* Ethernet Controller Family Open Source Software
|
|
|
|
* Developer Manual says:
|
|
|
|
* Using software parsing is only allowed with legal
|
|
|
|
* TCP/IP or UDP/IP packets.
|
|
|
|
* ...
|
|
|
|
* For all other datagrams, hardware parsing must
|
|
|
|
* be used.
|
|
|
|
* Software parsing appears to truncate ICMP and
|
|
|
|
* fragmented UDP packets that contain one to three
|
|
|
|
* bytes in the second (and final) mbuf of the packet.
|
|
|
|
*/
|
|
|
|
if (sc->flags & FXP_FLAG_EXT_RFA)
|
|
|
|
txp->tx_cb->ipcb_ip_activation_high =
|
|
|
|
FXP_IPCB_HARDWAREPARSING_ENABLE;
|
|
|
|
|
2008-11-25 04:16:16 +00:00
|
|
|
m = *m_head;
|
2008-11-26 07:36:17 +00:00
|
|
|
if (m->m_pkthdr.csum_flags & CSUM_TSO) {
|
|
|
|
/*
|
|
|
|
* 82550/82551 requires ethernet/IP/TCP headers must be
|
|
|
|
* contained in the first active transmit buffer.
|
|
|
|
*/
|
|
|
|
struct ether_header *eh;
|
|
|
|
struct ip *ip;
|
|
|
|
uint32_t ip_off, poff;
|
|
|
|
|
|
|
|
if (M_WRITABLE(*m_head) == 0) {
|
|
|
|
/* Get a writable copy. */
|
2012-12-04 09:32:43 +00:00
|
|
|
m = m_dup(*m_head, M_NOWAIT);
|
2008-11-26 07:36:17 +00:00
|
|
|
m_freem(*m_head);
|
|
|
|
if (m == NULL) {
|
|
|
|
*m_head = NULL;
|
|
|
|
return (ENOBUFS);
|
|
|
|
}
|
|
|
|
*m_head = m;
|
|
|
|
}
|
|
|
|
ip_off = sizeof(struct ether_header);
|
|
|
|
m = m_pullup(*m_head, ip_off);
|
|
|
|
if (m == NULL) {
|
|
|
|
*m_head = NULL;
|
|
|
|
return (ENOBUFS);
|
|
|
|
}
|
|
|
|
eh = mtod(m, struct ether_header *);
|
|
|
|
/* Check the existence of VLAN tag. */
|
|
|
|
if (eh->ether_type == htons(ETHERTYPE_VLAN)) {
|
|
|
|
ip_off = sizeof(struct ether_vlan_header);
|
|
|
|
m = m_pullup(m, ip_off);
|
|
|
|
if (m == NULL) {
|
|
|
|
*m_head = NULL;
|
|
|
|
return (ENOBUFS);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m = m_pullup(m, ip_off + sizeof(struct ip));
|
|
|
|
if (m == NULL) {
|
|
|
|
*m_head = NULL;
|
|
|
|
return (ENOBUFS);
|
|
|
|
}
|
|
|
|
ip = (struct ip *)(mtod(m, char *) + ip_off);
|
|
|
|
poff = ip_off + (ip->ip_hl << 2);
|
|
|
|
m = m_pullup(m, poff + sizeof(struct tcphdr));
|
|
|
|
if (m == NULL) {
|
|
|
|
*m_head = NULL;
|
|
|
|
return (ENOBUFS);
|
|
|
|
}
|
|
|
|
tcp = (struct tcphdr *)(mtod(m, char *) + poff);
|
2011-12-19 19:00:34 +00:00
|
|
|
m = m_pullup(m, poff + (tcp->th_off << 2));
|
2008-11-26 07:36:17 +00:00
|
|
|
if (m == NULL) {
|
|
|
|
*m_head = NULL;
|
|
|
|
return (ENOBUFS);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Since 82550/82551 doesn't modify IP length and pseudo
|
|
|
|
* checksum in the first frame driver should compute it.
|
|
|
|
*/
|
2010-10-14 18:31:40 +00:00
|
|
|
ip = (struct ip *)(mtod(m, char *) + ip_off);
|
|
|
|
tcp = (struct tcphdr *)(mtod(m, char *) + poff);
|
2008-11-26 07:36:17 +00:00
|
|
|
ip->ip_sum = 0;
|
2009-04-13 00:32:34 +00:00
|
|
|
ip->ip_len = htons(m->m_pkthdr.tso_segsz + (ip->ip_hl << 2) +
|
|
|
|
(tcp->th_off << 2));
|
2008-11-26 07:36:17 +00:00
|
|
|
tcp->th_sum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr,
|
|
|
|
htons(IPPROTO_TCP + (tcp->th_off << 2) +
|
|
|
|
m->m_pkthdr.tso_segsz));
|
|
|
|
/* Compute total TCP payload. */
|
|
|
|
tcp_payload = m->m_pkthdr.len - ip_off - (ip->ip_hl << 2);
|
|
|
|
tcp_payload -= tcp->th_off << 2;
|
|
|
|
*m_head = m;
|
2010-04-19 22:10:40 +00:00
|
|
|
} else if (m->m_pkthdr.csum_flags & FXP_CSUM_FEATURES) {
|
|
|
|
/*
|
|
|
|
* Deal with TCP/IP checksum offload. Note that
|
|
|
|
* in order for TCP checksum offload to work,
|
|
|
|
* the pseudo header checksum must have already
|
|
|
|
* been computed and stored in the checksum field
|
|
|
|
* in the TCP header. The stack should have
|
|
|
|
* already done this for us.
|
|
|
|
*/
|
|
|
|
txp->tx_cb->ipcb_ip_schedule = FXP_IPCB_TCPUDP_CHECKSUM_ENABLE;
|
|
|
|
if (m->m_pkthdr.csum_flags & CSUM_TCP)
|
|
|
|
txp->tx_cb->ipcb_ip_schedule |= FXP_IPCB_TCP_PACKET;
|
|
|
|
|
|
|
|
#ifdef FXP_IP_CSUM_WAR
|
|
|
|
/*
|
|
|
|
* XXX The 82550 chip appears to have trouble
|
|
|
|
* dealing with IP header checksums in very small
|
|
|
|
* datagrams, namely fragments from 1 to 3 bytes
|
|
|
|
* in size. For example, say you want to transmit
|
|
|
|
* a UDP packet of 1473 bytes. The packet will be
|
|
|
|
* fragmented over two IP datagrams, the latter
|
|
|
|
* containing only one byte of data. The 82550 will
|
|
|
|
* botch the header checksum on the 1-byte fragment.
|
|
|
|
* As long as the datagram contains 4 or more bytes
|
|
|
|
* of data, you're ok.
|
|
|
|
*
|
|
|
|
* The following code attempts to work around this
|
|
|
|
* problem: if the datagram is less than 38 bytes
|
|
|
|
* in size (14 bytes ether header, 20 bytes IP header,
|
|
|
|
* plus 4 bytes of data), we punt and compute the IP
|
|
|
|
* header checksum by hand. This workaround doesn't
|
|
|
|
* work very well, however, since it can be fooled
|
|
|
|
* by things like VLAN tags and IP options that make
|
|
|
|
* the header sizes/offsets vary.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (m->m_pkthdr.csum_flags & CSUM_IP) {
|
|
|
|
if (m->m_pkthdr.len < 38) {
|
|
|
|
struct ip *ip;
|
|
|
|
m->m_data += ETHER_HDR_LEN;
|
|
|
|
ip = mtod(m, struct ip *);
|
|
|
|
ip->ip_sum = in_cksum(m, ip->ip_hl << 2);
|
|
|
|
m->m_data -= ETHER_HDR_LEN;
|
|
|
|
m->m_pkthdr.csum_flags &= ~CSUM_IP;
|
|
|
|
} else {
|
|
|
|
txp->tx_cb->ipcb_ip_activation_high =
|
|
|
|
FXP_IPCB_HARDWAREPARSING_ENABLE;
|
|
|
|
txp->tx_cb->ipcb_ip_schedule |=
|
|
|
|
FXP_IPCB_IP_CHECKSUM_ENABLE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2008-11-26 07:36:17 +00:00
|
|
|
}
|
|
|
|
|
2009-06-21 06:06:43 +00:00
|
|
|
error = bus_dmamap_load_mbuf_sg(sc->fxp_txmtag, txp->tx_map, *m_head,
|
2008-11-25 04:16:16 +00:00
|
|
|
segs, &nseg, 0);
|
|
|
|
if (error == EFBIG) {
|
2012-12-04 09:32:43 +00:00
|
|
|
m = m_collapse(*m_head, M_NOWAIT, sc->maxtxseg);
|
2008-11-25 04:16:16 +00:00
|
|
|
if (m == NULL) {
|
|
|
|
m_freem(*m_head);
|
|
|
|
*m_head = NULL;
|
|
|
|
return (ENOMEM);
|
1995-12-05 11:49:55 +00:00
|
|
|
}
|
2008-11-25 04:16:16 +00:00
|
|
|
*m_head = m;
|
2009-06-21 06:06:43 +00:00
|
|
|
error = bus_dmamap_load_mbuf_sg(sc->fxp_txmtag, txp->tx_map,
|
2012-03-14 00:54:37 +00:00
|
|
|
*m_head, segs, &nseg, 0);
|
2008-11-25 04:16:16 +00:00
|
|
|
if (error != 0) {
|
|
|
|
m_freem(*m_head);
|
|
|
|
*m_head = NULL;
|
|
|
|
return (ENOMEM);
|
|
|
|
}
|
|
|
|
} else if (error != 0)
|
|
|
|
return (error);
|
|
|
|
if (nseg == 0) {
|
|
|
|
m_freem(*m_head);
|
|
|
|
*m_head = NULL;
|
|
|
|
return (EIO);
|
2005-03-07 13:20:49 +00:00
|
|
|
}
|
1995-12-05 11:49:55 +00:00
|
|
|
|
2005-03-07 13:20:49 +00:00
|
|
|
KASSERT(nseg <= sc->maxtxseg, ("too many DMA segments"));
|
2009-06-21 06:06:43 +00:00
|
|
|
bus_dmamap_sync(sc->fxp_txmtag, txp->tx_map, BUS_DMASYNC_PREWRITE);
|
2003-04-02 16:47:16 +00:00
|
|
|
|
2005-03-07 13:20:49 +00:00
|
|
|
cbp = txp->tx_cb;
|
|
|
|
for (i = 0; i < nseg; i++) {
|
|
|
|
/*
|
|
|
|
* If this is an 82550/82551, then we're using extended
|
|
|
|
* TxCBs _and_ we're using checksum offload. This means
|
|
|
|
* that the TxCB is really an IPCB. One major difference
|
|
|
|
* between the two is that with plain extended TxCBs,
|
|
|
|
* the bottom half of the TxCB contains two entries from
|
|
|
|
* the TBD array, whereas IPCBs contain just one entry:
|
|
|
|
* one entry (8 bytes) has been sacrificed for the TCP/IP
|
|
|
|
* checksum offload control bits. So to make things work
|
|
|
|
* right, we have to start filling in the TBD array
|
|
|
|
* starting from a different place depending on whether
|
|
|
|
* the chip is an 82550/82551 or not.
|
|
|
|
*/
|
|
|
|
if (sc->flags & FXP_FLAG_EXT_RFA) {
|
2008-12-18 01:36:46 +00:00
|
|
|
cbp->tbd[i + 1].tb_addr = htole32(segs[i].ds_addr);
|
|
|
|
cbp->tbd[i + 1].tb_size = htole32(segs[i].ds_len);
|
1998-08-04 08:53:12 +00:00
|
|
|
} else {
|
2005-03-07 13:20:49 +00:00
|
|
|
cbp->tbd[i].tb_addr = htole32(segs[i].ds_addr);
|
|
|
|
cbp->tbd[i].tb_size = htole32(segs[i].ds_len);
|
1998-08-04 08:53:12 +00:00
|
|
|
}
|
2005-03-07 13:20:49 +00:00
|
|
|
}
|
2008-11-26 07:36:17 +00:00
|
|
|
if (sc->flags & FXP_FLAG_EXT_RFA) {
|
|
|
|
/* Configure dynamic TBD for 82550/82551. */
|
|
|
|
cbp->tbd_number = 0xFF;
|
2008-12-18 01:36:46 +00:00
|
|
|
cbp->tbd[nseg].tb_size |= htole32(0x8000);
|
2008-11-26 07:36:17 +00:00
|
|
|
} else
|
|
|
|
cbp->tbd_number = nseg;
|
|
|
|
/* Configure TSO. */
|
|
|
|
if (m->m_pkthdr.csum_flags & CSUM_TSO) {
|
|
|
|
cbp->tbd[-1].tb_size = htole32(m->m_pkthdr.tso_segsz << 16);
|
2008-12-18 01:36:46 +00:00
|
|
|
cbp->tbd[1].tb_size |= htole32(tcp_payload << 16);
|
2008-11-26 07:36:17 +00:00
|
|
|
cbp->ipcb_ip_schedule |= FXP_IPCB_LARGESEND_ENABLE |
|
|
|
|
FXP_IPCB_IP_CHECKSUM_ENABLE |
|
|
|
|
FXP_IPCB_TCP_PACKET |
|
|
|
|
FXP_IPCB_TCPUDP_CHECKSUM_ENABLE;
|
|
|
|
}
|
2008-12-02 02:30:12 +00:00
|
|
|
/* Configure VLAN hardware tag insertion. */
|
|
|
|
if ((m->m_flags & M_VLANTAG) != 0) {
|
|
|
|
cbp->ipcb_vlan_id = htons(m->m_pkthdr.ether_vtag);
|
|
|
|
txp->tx_cb->ipcb_ip_activation_high |=
|
|
|
|
FXP_IPCB_INSERTVLAN_ENABLE;
|
|
|
|
}
|
2005-03-07 13:20:49 +00:00
|
|
|
|
2008-11-25 04:16:16 +00:00
|
|
|
txp->tx_mbuf = m;
|
2005-03-07 13:20:49 +00:00
|
|
|
txp->tx_cb->cb_status = 0;
|
|
|
|
txp->tx_cb->byte_count = 0;
|
2008-11-25 04:16:16 +00:00
|
|
|
if (sc->tx_queued != FXP_CXINT_THRESH - 1)
|
2005-03-07 13:20:49 +00:00
|
|
|
txp->tx_cb->cb_command =
|
|
|
|
htole16(sc->tx_cmd | FXP_CB_COMMAND_SF |
|
|
|
|
FXP_CB_COMMAND_S);
|
2008-11-25 04:16:16 +00:00
|
|
|
else
|
2005-03-07 13:20:49 +00:00
|
|
|
txp->tx_cb->cb_command =
|
|
|
|
htole16(sc->tx_cmd | FXP_CB_COMMAND_SF |
|
|
|
|
FXP_CB_COMMAND_S | FXP_CB_COMMAND_I);
|
2008-11-26 07:36:17 +00:00
|
|
|
if ((m->m_pkthdr.csum_flags & CSUM_TSO) == 0)
|
|
|
|
txp->tx_cb->tx_threshold = tx_threshold;
|
2005-03-07 13:20:49 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Advance the end of list forward.
|
|
|
|
*/
|
|
|
|
sc->fxp_desc.tx_last->tx_cb->cb_command &= htole16(~FXP_CB_COMMAND_S);
|
|
|
|
sc->fxp_desc.tx_last = txp;
|
1996-01-03 05:22:32 +00:00
|
|
|
|
2005-03-07 13:20:49 +00:00
|
|
|
/*
|
|
|
|
* Advance the beginning of the list forward if there are
|
|
|
|
* no other packets queued (when nothing is queued, tx_first
|
|
|
|
* sits on the last TxCB that was sent out).
|
|
|
|
*/
|
|
|
|
if (sc->tx_queued == 0)
|
|
|
|
sc->fxp_desc.tx_first = txp;
|
1996-09-29 10:20:45 +00:00
|
|
|
|
2005-03-07 13:20:49 +00:00
|
|
|
sc->tx_queued++;
|
1997-10-23 01:45:15 +00:00
|
|
|
|
2005-03-07 13:20:49 +00:00
|
|
|
return (0);
|
1995-11-28 23:55:26 +00:00
|
|
|
}
|
|
|
|
|
Device Polling code for -current.
Non-SMP, i386-only, no polling in the idle loop at the moment.
To use this code you must compile a kernel with
options DEVICE_POLLING
and at runtime enable polling with
sysctl kern.polling.enable=1
The percentage of CPU reserved to userland can be set with
sysctl kern.polling.user_frac=NN (default is 50)
while the remainder is used by polling device drivers and netisr's.
These are the only two variables that you should need to touch. There
are a few more parameters in kern.polling but the default values
are adequate for all purposes. See the code in kern_poll.c for
more details on them.
Polling in the idle loop will be implemented shortly by introducing
a kernel thread which does the job. Until then, the amount of CPU
dedicated to polling will never exceed (100-user_frac).
The equivalent (actually, better) code for -stable is at
http://info.iet.unipi.it/~luigi/polling/
and also supports polling in the idle loop.
NOTE to Alpha developers:
There is really nothing in this code that is i386-specific.
If you move the 2 lines supporting the new option from
sys/conf/{files,options}.i386 to sys/conf/{files,options} I am
pretty sure that this should work on the Alpha as well, just that
I do not have a suitable test box to try it. If someone feels like
trying it, I would appreciate it.
NOTE to other developers:
sure some things could be done better, and as always I am open to
constructive criticism, which a few of you have already given and
I greatly appreciated.
However, before proposing radical architectural changes, please
take some time to possibly try out this code, or at the very least
read the comments in kern_poll.c, especially re. the reason why I
am using a soft netisr and cannot (I believe) replace it with a
simple timeout.
Quick description of files touched by this commit:
sys/conf/files.i386
new file kern/kern_poll.c
sys/conf/options.i386
new option
sys/i386/i386/trap.c
poll in trap (disabled by default)
sys/kern/kern_clock.c
initialization and hardclock hooks.
sys/kern/kern_intr.c
minor swi_net changes
sys/kern/kern_poll.c
the bulk of the code.
sys/net/if.h
new flag
sys/net/if_var.h
declaration for functions used in device drivers.
sys/net/netisr.h
NETISR_POLL
sys/dev/fxp/if_fxp.c
sys/dev/fxp/if_fxpvar.h
sys/pci/if_dc.c
sys/pci/if_dcreg.h
sys/pci/if_sis.c
sys/pci/if_sisreg.h
device driver modifications
2001-12-14 17:56:12 +00:00
|
|
|
#ifdef DEVICE_POLLING
|
|
|
|
static poll_handler_t fxp_poll;
|
|
|
|
|
2009-05-30 15:14:44 +00:00
|
|
|
static int
|
2001-12-15 02:41:52 +00:00
|
|
|
fxp_poll(struct ifnet *ifp, enum poll_cmd cmd, int count)
|
Device Polling code for -current.
Non-SMP, i386-only, no polling in the idle loop at the moment.
To use this code you must compile a kernel with
options DEVICE_POLLING
and at runtime enable polling with
sysctl kern.polling.enable=1
The percentage of CPU reserved to userland can be set with
sysctl kern.polling.user_frac=NN (default is 50)
while the remainder is used by polling device drivers and netisr's.
These are the only two variables that you should need to touch. There
are a few more parameters in kern.polling but the default values
are adequate for all purposes. See the code in kern_poll.c for
more details on them.
Polling in the idle loop will be implemented shortly by introducing
a kernel thread which does the job. Until then, the amount of CPU
dedicated to polling will never exceed (100-user_frac).
The equivalent (actually, better) code for -stable is at
http://info.iet.unipi.it/~luigi/polling/
and also supports polling in the idle loop.
NOTE to Alpha developers:
There is really nothing in this code that is i386-specific.
If you move the 2 lines supporting the new option from
sys/conf/{files,options}.i386 to sys/conf/{files,options} I am
pretty sure that this should work on the Alpha as well, just that
I do not have a suitable test box to try it. If someone feels like
trying it, I would appreciate it.
NOTE to other developers:
sure some things could be done better, and as always I am open to
constructive criticism, which a few of you have already given and
I greatly appreciated.
However, before proposing radical architectural changes, please
take some time to possibly try out this code, or at the very least
read the comments in kern_poll.c, especially re. the reason why I
am using a soft netisr and cannot (I believe) replace it with a
simple timeout.
Quick description of files touched by this commit:
sys/conf/files.i386
new file kern/kern_poll.c
sys/conf/options.i386
new option
sys/i386/i386/trap.c
poll in trap (disabled by default)
sys/kern/kern_clock.c
initialization and hardclock hooks.
sys/kern/kern_intr.c
minor swi_net changes
sys/kern/kern_poll.c
the bulk of the code.
sys/net/if.h
new flag
sys/net/if_var.h
declaration for functions used in device drivers.
sys/net/netisr.h
NETISR_POLL
sys/dev/fxp/if_fxp.c
sys/dev/fxp/if_fxpvar.h
sys/pci/if_dc.c
sys/pci/if_dcreg.h
sys/pci/if_sis.c
sys/pci/if_sisreg.h
device driver modifications
2001-12-14 17:56:12 +00:00
|
|
|
{
|
|
|
|
struct fxp_softc *sc = ifp->if_softc;
|
2005-03-06 05:07:26 +00:00
|
|
|
uint8_t statack;
|
2009-05-30 15:14:44 +00:00
|
|
|
int rx_npkts = 0;
|
Device Polling code for -current.
Non-SMP, i386-only, no polling in the idle loop at the moment.
To use this code you must compile a kernel with
options DEVICE_POLLING
and at runtime enable polling with
sysctl kern.polling.enable=1
The percentage of CPU reserved to userland can be set with
sysctl kern.polling.user_frac=NN (default is 50)
while the remainder is used by polling device drivers and netisr's.
These are the only two variables that you should need to touch. There
are a few more parameters in kern.polling but the default values
are adequate for all purposes. See the code in kern_poll.c for
more details on them.
Polling in the idle loop will be implemented shortly by introducing
a kernel thread which does the job. Until then, the amount of CPU
dedicated to polling will never exceed (100-user_frac).
The equivalent (actually, better) code for -stable is at
http://info.iet.unipi.it/~luigi/polling/
and also supports polling in the idle loop.
NOTE to Alpha developers:
There is really nothing in this code that is i386-specific.
If you move the 2 lines supporting the new option from
sys/conf/{files,options}.i386 to sys/conf/{files,options} I am
pretty sure that this should work on the Alpha as well, just that
I do not have a suitable test box to try it. If someone feels like
trying it, I would appreciate it.
NOTE to other developers:
sure some things could be done better, and as always I am open to
constructive criticism, which a few of you have already given and
I greatly appreciated.
However, before proposing radical architectural changes, please
take some time to possibly try out this code, or at the very least
read the comments in kern_poll.c, especially re. the reason why I
am using a soft netisr and cannot (I believe) replace it with a
simple timeout.
Quick description of files touched by this commit:
sys/conf/files.i386
new file kern/kern_poll.c
sys/conf/options.i386
new option
sys/i386/i386/trap.c
poll in trap (disabled by default)
sys/kern/kern_clock.c
initialization and hardclock hooks.
sys/kern/kern_intr.c
minor swi_net changes
sys/kern/kern_poll.c
the bulk of the code.
sys/net/if.h
new flag
sys/net/if_var.h
declaration for functions used in device drivers.
sys/net/netisr.h
NETISR_POLL
sys/dev/fxp/if_fxp.c
sys/dev/fxp/if_fxpvar.h
sys/pci/if_dc.c
sys/pci/if_dcreg.h
sys/pci/if_sis.c
sys/pci/if_sisreg.h
device driver modifications
2001-12-14 17:56:12 +00:00
|
|
|
|
Make fxp(4) INTR_MPSAFE (but do not enable MPSAFE just yet):
- Add fxp_start_body() and change fxp_start() to just acquire locks and
then call fxp_start_body(). Places that would call fxp_start() with
locks held (mutex recursion) now call fxp_start_body() directly.
Remove MTX_RECURSE flag from sc_mtx. [gallatin]
- Change fxp_attach() to work without the softc lock, saving interrupt
hooking until the head of fxp_attach().
- Call ether_ifattach() before overriding ifp parameters. This reverts
part of 1.155.
- Remove multiple error paths in fxp_attach().
- Teardown interrupt in fxp_detach() before unlocking the softc.
- Make sure mutex is not held in fxp_release()
- Delete the miibus instance and/or self in fxp_release(), not in
fxp_detach(). This can happen if attach fails partway through.
- Move ifmedia_removeall to fxp_release() since attach may fail after
media have been allocated.
- Add locking to fxp_suspend, fxp_resume, fxp_start, fxp_intr,
fxp_poll, fxp_tick, fxp_ioctl, fxp_watchdog.
- Pass in ifp to fxp_intr_body since its callers sometimes already use
it.
- Add compatibility define for INTR_MPSAFE for 4.x. [gallatin]
- You don't need to bzero softc.
Ideas from: gallatin, mux
Tested by: >400M packets of dd/ssh, NFS, ping on i386 UP
2003-04-25 09:01:54 +00:00
|
|
|
FXP_LOCK(sc);
|
Big polling(4) cleanup.
o Axe poll in trap.
o Axe IFF_POLLING flag from if_flags.
o Rework revision 1.21 (Giant removal), in such a way that
poll_mtx is not dropped during call to polling handler.
This fixes problem with idle polling.
o Make registration and deregistration from polling in a
functional way, insted of next tick/interrupt.
o Obsolete kern.polling.enable. Polling is turned on/off
with ifconfig.
Detailed kern_poll.c changes:
- Remove polling handler flags, introduced in 1.21. The are not
needed now.
- Forget and do not check if_flags, if_capenable and if_drv_flags.
- Call all registered polling handlers unconditionally.
- Do not drop poll_mtx, when entering polling handlers.
- In ether_poll() NET_LOCK_GIANT prior to locking poll_mtx.
- In netisr_poll() axe the block, where polling code asks drivers
to unregister.
- In netisr_poll() and ether_poll() do polling always, if any
handlers are present.
- In ether_poll_[de]register() remove a lot of error hiding code. Assert
that arguments are correct, instead.
- In ether_poll_[de]register() use standard return values in case of
error or success.
- Introduce poll_switch() that is a sysctl handler for kern.polling.enable.
poll_switch() goes through interface list and enabled/disables polling.
A message that kern.polling.enable is deprecated is printed.
Detailed driver changes:
- On attach driver announces IFCAP_POLLING in if_capabilities, but
not in if_capenable.
- On detach driver calls ether_poll_deregister() if polling is enabled.
- In polling handler driver obtains its lock and checks IFF_DRV_RUNNING
flag. If there is no, then unlocks and returns.
- In ioctl handler driver checks for IFCAP_POLLING flag requested to
be set or cleared. Driver first calls ether_poll_[de]register(), then
obtains driver lock and [dis/en]ables interrupts.
- In interrupt handler driver checks IFCAP_POLLING flag in if_capenable.
If present, then returns.This is important to protect from spurious
interrupts.
Reviewed by: ru, sam, jhb
2005-10-01 18:56:19 +00:00
|
|
|
if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) {
|
Make fxp(4) INTR_MPSAFE (but do not enable MPSAFE just yet):
- Add fxp_start_body() and change fxp_start() to just acquire locks and
then call fxp_start_body(). Places that would call fxp_start() with
locks held (mutex recursion) now call fxp_start_body() directly.
Remove MTX_RECURSE flag from sc_mtx. [gallatin]
- Change fxp_attach() to work without the softc lock, saving interrupt
hooking until the head of fxp_attach().
- Call ether_ifattach() before overriding ifp parameters. This reverts
part of 1.155.
- Remove multiple error paths in fxp_attach().
- Teardown interrupt in fxp_detach() before unlocking the softc.
- Make sure mutex is not held in fxp_release()
- Delete the miibus instance and/or self in fxp_release(), not in
fxp_detach(). This can happen if attach fails partway through.
- Move ifmedia_removeall to fxp_release() since attach may fail after
media have been allocated.
- Add locking to fxp_suspend, fxp_resume, fxp_start, fxp_intr,
fxp_poll, fxp_tick, fxp_ioctl, fxp_watchdog.
- Pass in ifp to fxp_intr_body since its callers sometimes already use
it.
- Add compatibility define for INTR_MPSAFE for 4.x. [gallatin]
- You don't need to bzero softc.
Ideas from: gallatin, mux
Tested by: >400M packets of dd/ssh, NFS, ping on i386 UP
2003-04-25 09:01:54 +00:00
|
|
|
FXP_UNLOCK(sc);
|
2009-05-30 15:14:44 +00:00
|
|
|
return (rx_npkts);
|
Device Polling code for -current.
Non-SMP, i386-only, no polling in the idle loop at the moment.
To use this code you must compile a kernel with
options DEVICE_POLLING
and at runtime enable polling with
sysctl kern.polling.enable=1
The percentage of CPU reserved to userland can be set with
sysctl kern.polling.user_frac=NN (default is 50)
while the remainder is used by polling device drivers and netisr's.
These are the only two variables that you should need to touch. There
are a few more parameters in kern.polling but the default values
are adequate for all purposes. See the code in kern_poll.c for
more details on them.
Polling in the idle loop will be implemented shortly by introducing
a kernel thread which does the job. Until then, the amount of CPU
dedicated to polling will never exceed (100-user_frac).
The equivalent (actually, better) code for -stable is at
http://info.iet.unipi.it/~luigi/polling/
and also supports polling in the idle loop.
NOTE to Alpha developers:
There is really nothing in this code that is i386-specific.
If you move the 2 lines supporting the new option from
sys/conf/{files,options}.i386 to sys/conf/{files,options} I am
pretty sure that this should work on the Alpha as well, just that
I do not have a suitable test box to try it. If someone feels like
trying it, I would appreciate it.
NOTE to other developers:
sure some things could be done better, and as always I am open to
constructive criticism, which a few of you have already given and
I greatly appreciated.
However, before proposing radical architectural changes, please
take some time to possibly try out this code, or at the very least
read the comments in kern_poll.c, especially re. the reason why I
am using a soft netisr and cannot (I believe) replace it with a
simple timeout.
Quick description of files touched by this commit:
sys/conf/files.i386
new file kern/kern_poll.c
sys/conf/options.i386
new option
sys/i386/i386/trap.c
poll in trap (disabled by default)
sys/kern/kern_clock.c
initialization and hardclock hooks.
sys/kern/kern_intr.c
minor swi_net changes
sys/kern/kern_poll.c
the bulk of the code.
sys/net/if.h
new flag
sys/net/if_var.h
declaration for functions used in device drivers.
sys/net/netisr.h
NETISR_POLL
sys/dev/fxp/if_fxp.c
sys/dev/fxp/if_fxpvar.h
sys/pci/if_dc.c
sys/pci/if_dcreg.h
sys/pci/if_sis.c
sys/pci/if_sisreg.h
device driver modifications
2001-12-14 17:56:12 +00:00
|
|
|
}
|
Big polling(4) cleanup.
o Axe poll in trap.
o Axe IFF_POLLING flag from if_flags.
o Rework revision 1.21 (Giant removal), in such a way that
poll_mtx is not dropped during call to polling handler.
This fixes problem with idle polling.
o Make registration and deregistration from polling in a
functional way, insted of next tick/interrupt.
o Obsolete kern.polling.enable. Polling is turned on/off
with ifconfig.
Detailed kern_poll.c changes:
- Remove polling handler flags, introduced in 1.21. The are not
needed now.
- Forget and do not check if_flags, if_capenable and if_drv_flags.
- Call all registered polling handlers unconditionally.
- Do not drop poll_mtx, when entering polling handlers.
- In ether_poll() NET_LOCK_GIANT prior to locking poll_mtx.
- In netisr_poll() axe the block, where polling code asks drivers
to unregister.
- In netisr_poll() and ether_poll() do polling always, if any
handlers are present.
- In ether_poll_[de]register() remove a lot of error hiding code. Assert
that arguments are correct, instead.
- In ether_poll_[de]register() use standard return values in case of
error or success.
- Introduce poll_switch() that is a sysctl handler for kern.polling.enable.
poll_switch() goes through interface list and enabled/disables polling.
A message that kern.polling.enable is deprecated is printed.
Detailed driver changes:
- On attach driver announces IFCAP_POLLING in if_capabilities, but
not in if_capenable.
- On detach driver calls ether_poll_deregister() if polling is enabled.
- In polling handler driver obtains its lock and checks IFF_DRV_RUNNING
flag. If there is no, then unlocks and returns.
- In ioctl handler driver checks for IFCAP_POLLING flag requested to
be set or cleared. Driver first calls ether_poll_[de]register(), then
obtains driver lock and [dis/en]ables interrupts.
- In interrupt handler driver checks IFCAP_POLLING flag in if_capenable.
If present, then returns.This is important to protect from spurious
interrupts.
Reviewed by: ru, sam, jhb
2005-10-01 18:56:19 +00:00
|
|
|
|
Device Polling code for -current.
Non-SMP, i386-only, no polling in the idle loop at the moment.
To use this code you must compile a kernel with
options DEVICE_POLLING
and at runtime enable polling with
sysctl kern.polling.enable=1
The percentage of CPU reserved to userland can be set with
sysctl kern.polling.user_frac=NN (default is 50)
while the remainder is used by polling device drivers and netisr's.
These are the only two variables that you should need to touch. There
are a few more parameters in kern.polling but the default values
are adequate for all purposes. See the code in kern_poll.c for
more details on them.
Polling in the idle loop will be implemented shortly by introducing
a kernel thread which does the job. Until then, the amount of CPU
dedicated to polling will never exceed (100-user_frac).
The equivalent (actually, better) code for -stable is at
http://info.iet.unipi.it/~luigi/polling/
and also supports polling in the idle loop.
NOTE to Alpha developers:
There is really nothing in this code that is i386-specific.
If you move the 2 lines supporting the new option from
sys/conf/{files,options}.i386 to sys/conf/{files,options} I am
pretty sure that this should work on the Alpha as well, just that
I do not have a suitable test box to try it. If someone feels like
trying it, I would appreciate it.
NOTE to other developers:
sure some things could be done better, and as always I am open to
constructive criticism, which a few of you have already given and
I greatly appreciated.
However, before proposing radical architectural changes, please
take some time to possibly try out this code, or at the very least
read the comments in kern_poll.c, especially re. the reason why I
am using a soft netisr and cannot (I believe) replace it with a
simple timeout.
Quick description of files touched by this commit:
sys/conf/files.i386
new file kern/kern_poll.c
sys/conf/options.i386
new option
sys/i386/i386/trap.c
poll in trap (disabled by default)
sys/kern/kern_clock.c
initialization and hardclock hooks.
sys/kern/kern_intr.c
minor swi_net changes
sys/kern/kern_poll.c
the bulk of the code.
sys/net/if.h
new flag
sys/net/if_var.h
declaration for functions used in device drivers.
sys/net/netisr.h
NETISR_POLL
sys/dev/fxp/if_fxp.c
sys/dev/fxp/if_fxpvar.h
sys/pci/if_dc.c
sys/pci/if_dcreg.h
sys/pci/if_sis.c
sys/pci/if_sisreg.h
device driver modifications
2001-12-14 17:56:12 +00:00
|
|
|
statack = FXP_SCB_STATACK_CXTNO | FXP_SCB_STATACK_CNA |
|
2001-12-15 02:41:52 +00:00
|
|
|
FXP_SCB_STATACK_FR;
|
Device Polling code for -current.
Non-SMP, i386-only, no polling in the idle loop at the moment.
To use this code you must compile a kernel with
options DEVICE_POLLING
and at runtime enable polling with
sysctl kern.polling.enable=1
The percentage of CPU reserved to userland can be set with
sysctl kern.polling.user_frac=NN (default is 50)
while the remainder is used by polling device drivers and netisr's.
These are the only two variables that you should need to touch. There
are a few more parameters in kern.polling but the default values
are adequate for all purposes. See the code in kern_poll.c for
more details on them.
Polling in the idle loop will be implemented shortly by introducing
a kernel thread which does the job. Until then, the amount of CPU
dedicated to polling will never exceed (100-user_frac).
The equivalent (actually, better) code for -stable is at
http://info.iet.unipi.it/~luigi/polling/
and also supports polling in the idle loop.
NOTE to Alpha developers:
There is really nothing in this code that is i386-specific.
If you move the 2 lines supporting the new option from
sys/conf/{files,options}.i386 to sys/conf/{files,options} I am
pretty sure that this should work on the Alpha as well, just that
I do not have a suitable test box to try it. If someone feels like
trying it, I would appreciate it.
NOTE to other developers:
sure some things could be done better, and as always I am open to
constructive criticism, which a few of you have already given and
I greatly appreciated.
However, before proposing radical architectural changes, please
take some time to possibly try out this code, or at the very least
read the comments in kern_poll.c, especially re. the reason why I
am using a soft netisr and cannot (I believe) replace it with a
simple timeout.
Quick description of files touched by this commit:
sys/conf/files.i386
new file kern/kern_poll.c
sys/conf/options.i386
new option
sys/i386/i386/trap.c
poll in trap (disabled by default)
sys/kern/kern_clock.c
initialization and hardclock hooks.
sys/kern/kern_intr.c
minor swi_net changes
sys/kern/kern_poll.c
the bulk of the code.
sys/net/if.h
new flag
sys/net/if_var.h
declaration for functions used in device drivers.
sys/net/netisr.h
NETISR_POLL
sys/dev/fxp/if_fxp.c
sys/dev/fxp/if_fxpvar.h
sys/pci/if_dc.c
sys/pci/if_dcreg.h
sys/pci/if_sis.c
sys/pci/if_sisreg.h
device driver modifications
2001-12-14 17:56:12 +00:00
|
|
|
if (cmd == POLL_AND_CHECK_STATUS) {
|
2005-03-06 05:07:26 +00:00
|
|
|
uint8_t tmp;
|
2001-12-15 02:41:52 +00:00
|
|
|
|
Device Polling code for -current.
Non-SMP, i386-only, no polling in the idle loop at the moment.
To use this code you must compile a kernel with
options DEVICE_POLLING
and at runtime enable polling with
sysctl kern.polling.enable=1
The percentage of CPU reserved to userland can be set with
sysctl kern.polling.user_frac=NN (default is 50)
while the remainder is used by polling device drivers and netisr's.
These are the only two variables that you should need to touch. There
are a few more parameters in kern.polling but the default values
are adequate for all purposes. See the code in kern_poll.c for
more details on them.
Polling in the idle loop will be implemented shortly by introducing
a kernel thread which does the job. Until then, the amount of CPU
dedicated to polling will never exceed (100-user_frac).
The equivalent (actually, better) code for -stable is at
http://info.iet.unipi.it/~luigi/polling/
and also supports polling in the idle loop.
NOTE to Alpha developers:
There is really nothing in this code that is i386-specific.
If you move the 2 lines supporting the new option from
sys/conf/{files,options}.i386 to sys/conf/{files,options} I am
pretty sure that this should work on the Alpha as well, just that
I do not have a suitable test box to try it. If someone feels like
trying it, I would appreciate it.
NOTE to other developers:
sure some things could be done better, and as always I am open to
constructive criticism, which a few of you have already given and
I greatly appreciated.
However, before proposing radical architectural changes, please
take some time to possibly try out this code, or at the very least
read the comments in kern_poll.c, especially re. the reason why I
am using a soft netisr and cannot (I believe) replace it with a
simple timeout.
Quick description of files touched by this commit:
sys/conf/files.i386
new file kern/kern_poll.c
sys/conf/options.i386
new option
sys/i386/i386/trap.c
poll in trap (disabled by default)
sys/kern/kern_clock.c
initialization and hardclock hooks.
sys/kern/kern_intr.c
minor swi_net changes
sys/kern/kern_poll.c
the bulk of the code.
sys/net/if.h
new flag
sys/net/if_var.h
declaration for functions used in device drivers.
sys/net/netisr.h
NETISR_POLL
sys/dev/fxp/if_fxp.c
sys/dev/fxp/if_fxpvar.h
sys/pci/if_dc.c
sys/pci/if_dcreg.h
sys/pci/if_sis.c
sys/pci/if_sisreg.h
device driver modifications
2001-12-14 17:56:12 +00:00
|
|
|
tmp = CSR_READ_1(sc, FXP_CSR_SCB_STATACK);
|
Make fxp(4) INTR_MPSAFE (but do not enable MPSAFE just yet):
- Add fxp_start_body() and change fxp_start() to just acquire locks and
then call fxp_start_body(). Places that would call fxp_start() with
locks held (mutex recursion) now call fxp_start_body() directly.
Remove MTX_RECURSE flag from sc_mtx. [gallatin]
- Change fxp_attach() to work without the softc lock, saving interrupt
hooking until the head of fxp_attach().
- Call ether_ifattach() before overriding ifp parameters. This reverts
part of 1.155.
- Remove multiple error paths in fxp_attach().
- Teardown interrupt in fxp_detach() before unlocking the softc.
- Make sure mutex is not held in fxp_release()
- Delete the miibus instance and/or self in fxp_release(), not in
fxp_detach(). This can happen if attach fails partway through.
- Move ifmedia_removeall to fxp_release() since attach may fail after
media have been allocated.
- Add locking to fxp_suspend, fxp_resume, fxp_start, fxp_intr,
fxp_poll, fxp_tick, fxp_ioctl, fxp_watchdog.
- Pass in ifp to fxp_intr_body since its callers sometimes already use
it.
- Add compatibility define for INTR_MPSAFE for 4.x. [gallatin]
- You don't need to bzero softc.
Ideas from: gallatin, mux
Tested by: >400M packets of dd/ssh, NFS, ping on i386 UP
2003-04-25 09:01:54 +00:00
|
|
|
if (tmp == 0xff || tmp == 0) {
|
|
|
|
FXP_UNLOCK(sc);
|
2009-05-30 15:14:44 +00:00
|
|
|
return (rx_npkts); /* nothing to do */
|
Make fxp(4) INTR_MPSAFE (but do not enable MPSAFE just yet):
- Add fxp_start_body() and change fxp_start() to just acquire locks and
then call fxp_start_body(). Places that would call fxp_start() with
locks held (mutex recursion) now call fxp_start_body() directly.
Remove MTX_RECURSE flag from sc_mtx. [gallatin]
- Change fxp_attach() to work without the softc lock, saving interrupt
hooking until the head of fxp_attach().
- Call ether_ifattach() before overriding ifp parameters. This reverts
part of 1.155.
- Remove multiple error paths in fxp_attach().
- Teardown interrupt in fxp_detach() before unlocking the softc.
- Make sure mutex is not held in fxp_release()
- Delete the miibus instance and/or self in fxp_release(), not in
fxp_detach(). This can happen if attach fails partway through.
- Move ifmedia_removeall to fxp_release() since attach may fail after
media have been allocated.
- Add locking to fxp_suspend, fxp_resume, fxp_start, fxp_intr,
fxp_poll, fxp_tick, fxp_ioctl, fxp_watchdog.
- Pass in ifp to fxp_intr_body since its callers sometimes already use
it.
- Add compatibility define for INTR_MPSAFE for 4.x. [gallatin]
- You don't need to bzero softc.
Ideas from: gallatin, mux
Tested by: >400M packets of dd/ssh, NFS, ping on i386 UP
2003-04-25 09:01:54 +00:00
|
|
|
}
|
2001-12-15 02:41:52 +00:00
|
|
|
tmp &= ~statack;
|
Device Polling code for -current.
Non-SMP, i386-only, no polling in the idle loop at the moment.
To use this code you must compile a kernel with
options DEVICE_POLLING
and at runtime enable polling with
sysctl kern.polling.enable=1
The percentage of CPU reserved to userland can be set with
sysctl kern.polling.user_frac=NN (default is 50)
while the remainder is used by polling device drivers and netisr's.
These are the only two variables that you should need to touch. There
are a few more parameters in kern.polling but the default values
are adequate for all purposes. See the code in kern_poll.c for
more details on them.
Polling in the idle loop will be implemented shortly by introducing
a kernel thread which does the job. Until then, the amount of CPU
dedicated to polling will never exceed (100-user_frac).
The equivalent (actually, better) code for -stable is at
http://info.iet.unipi.it/~luigi/polling/
and also supports polling in the idle loop.
NOTE to Alpha developers:
There is really nothing in this code that is i386-specific.
If you move the 2 lines supporting the new option from
sys/conf/{files,options}.i386 to sys/conf/{files,options} I am
pretty sure that this should work on the Alpha as well, just that
I do not have a suitable test box to try it. If someone feels like
trying it, I would appreciate it.
NOTE to other developers:
sure some things could be done better, and as always I am open to
constructive criticism, which a few of you have already given and
I greatly appreciated.
However, before proposing radical architectural changes, please
take some time to possibly try out this code, or at the very least
read the comments in kern_poll.c, especially re. the reason why I
am using a soft netisr and cannot (I believe) replace it with a
simple timeout.
Quick description of files touched by this commit:
sys/conf/files.i386
new file kern/kern_poll.c
sys/conf/options.i386
new option
sys/i386/i386/trap.c
poll in trap (disabled by default)
sys/kern/kern_clock.c
initialization and hardclock hooks.
sys/kern/kern_intr.c
minor swi_net changes
sys/kern/kern_poll.c
the bulk of the code.
sys/net/if.h
new flag
sys/net/if_var.h
declaration for functions used in device drivers.
sys/net/netisr.h
NETISR_POLL
sys/dev/fxp/if_fxp.c
sys/dev/fxp/if_fxpvar.h
sys/pci/if_dc.c
sys/pci/if_dcreg.h
sys/pci/if_sis.c
sys/pci/if_sisreg.h
device driver modifications
2001-12-14 17:56:12 +00:00
|
|
|
/* ack what we can */
|
|
|
|
if (tmp != 0)
|
|
|
|
CSR_WRITE_1(sc, FXP_CSR_SCB_STATACK, tmp);
|
2001-12-15 02:41:52 +00:00
|
|
|
statack |= tmp;
|
Device Polling code for -current.
Non-SMP, i386-only, no polling in the idle loop at the moment.
To use this code you must compile a kernel with
options DEVICE_POLLING
and at runtime enable polling with
sysctl kern.polling.enable=1
The percentage of CPU reserved to userland can be set with
sysctl kern.polling.user_frac=NN (default is 50)
while the remainder is used by polling device drivers and netisr's.
These are the only two variables that you should need to touch. There
are a few more parameters in kern.polling but the default values
are adequate for all purposes. See the code in kern_poll.c for
more details on them.
Polling in the idle loop will be implemented shortly by introducing
a kernel thread which does the job. Until then, the amount of CPU
dedicated to polling will never exceed (100-user_frac).
The equivalent (actually, better) code for -stable is at
http://info.iet.unipi.it/~luigi/polling/
and also supports polling in the idle loop.
NOTE to Alpha developers:
There is really nothing in this code that is i386-specific.
If you move the 2 lines supporting the new option from
sys/conf/{files,options}.i386 to sys/conf/{files,options} I am
pretty sure that this should work on the Alpha as well, just that
I do not have a suitable test box to try it. If someone feels like
trying it, I would appreciate it.
NOTE to other developers:
sure some things could be done better, and as always I am open to
constructive criticism, which a few of you have already given and
I greatly appreciated.
However, before proposing radical architectural changes, please
take some time to possibly try out this code, or at the very least
read the comments in kern_poll.c, especially re. the reason why I
am using a soft netisr and cannot (I believe) replace it with a
simple timeout.
Quick description of files touched by this commit:
sys/conf/files.i386
new file kern/kern_poll.c
sys/conf/options.i386
new option
sys/i386/i386/trap.c
poll in trap (disabled by default)
sys/kern/kern_clock.c
initialization and hardclock hooks.
sys/kern/kern_intr.c
minor swi_net changes
sys/kern/kern_poll.c
the bulk of the code.
sys/net/if.h
new flag
sys/net/if_var.h
declaration for functions used in device drivers.
sys/net/netisr.h
NETISR_POLL
sys/dev/fxp/if_fxp.c
sys/dev/fxp/if_fxpvar.h
sys/pci/if_dc.c
sys/pci/if_dcreg.h
sys/pci/if_sis.c
sys/pci/if_sisreg.h
device driver modifications
2001-12-14 17:56:12 +00:00
|
|
|
}
|
2009-05-30 15:14:44 +00:00
|
|
|
rx_npkts = fxp_intr_body(sc, ifp, statack, count);
|
Make fxp(4) INTR_MPSAFE (but do not enable MPSAFE just yet):
- Add fxp_start_body() and change fxp_start() to just acquire locks and
then call fxp_start_body(). Places that would call fxp_start() with
locks held (mutex recursion) now call fxp_start_body() directly.
Remove MTX_RECURSE flag from sc_mtx. [gallatin]
- Change fxp_attach() to work without the softc lock, saving interrupt
hooking until the head of fxp_attach().
- Call ether_ifattach() before overriding ifp parameters. This reverts
part of 1.155.
- Remove multiple error paths in fxp_attach().
- Teardown interrupt in fxp_detach() before unlocking the softc.
- Make sure mutex is not held in fxp_release()
- Delete the miibus instance and/or self in fxp_release(), not in
fxp_detach(). This can happen if attach fails partway through.
- Move ifmedia_removeall to fxp_release() since attach may fail after
media have been allocated.
- Add locking to fxp_suspend, fxp_resume, fxp_start, fxp_intr,
fxp_poll, fxp_tick, fxp_ioctl, fxp_watchdog.
- Pass in ifp to fxp_intr_body since its callers sometimes already use
it.
- Add compatibility define for INTR_MPSAFE for 4.x. [gallatin]
- You don't need to bzero softc.
Ideas from: gallatin, mux
Tested by: >400M packets of dd/ssh, NFS, ping on i386 UP
2003-04-25 09:01:54 +00:00
|
|
|
FXP_UNLOCK(sc);
|
2009-05-30 15:14:44 +00:00
|
|
|
return (rx_npkts);
|
Device Polling code for -current.
Non-SMP, i386-only, no polling in the idle loop at the moment.
To use this code you must compile a kernel with
options DEVICE_POLLING
and at runtime enable polling with
sysctl kern.polling.enable=1
The percentage of CPU reserved to userland can be set with
sysctl kern.polling.user_frac=NN (default is 50)
while the remainder is used by polling device drivers and netisr's.
These are the only two variables that you should need to touch. There
are a few more parameters in kern.polling but the default values
are adequate for all purposes. See the code in kern_poll.c for
more details on them.
Polling in the idle loop will be implemented shortly by introducing
a kernel thread which does the job. Until then, the amount of CPU
dedicated to polling will never exceed (100-user_frac).
The equivalent (actually, better) code for -stable is at
http://info.iet.unipi.it/~luigi/polling/
and also supports polling in the idle loop.
NOTE to Alpha developers:
There is really nothing in this code that is i386-specific.
If you move the 2 lines supporting the new option from
sys/conf/{files,options}.i386 to sys/conf/{files,options} I am
pretty sure that this should work on the Alpha as well, just that
I do not have a suitable test box to try it. If someone feels like
trying it, I would appreciate it.
NOTE to other developers:
sure some things could be done better, and as always I am open to
constructive criticism, which a few of you have already given and
I greatly appreciated.
However, before proposing radical architectural changes, please
take some time to possibly try out this code, or at the very least
read the comments in kern_poll.c, especially re. the reason why I
am using a soft netisr and cannot (I believe) replace it with a
simple timeout.
Quick description of files touched by this commit:
sys/conf/files.i386
new file kern/kern_poll.c
sys/conf/options.i386
new option
sys/i386/i386/trap.c
poll in trap (disabled by default)
sys/kern/kern_clock.c
initialization and hardclock hooks.
sys/kern/kern_intr.c
minor swi_net changes
sys/kern/kern_poll.c
the bulk of the code.
sys/net/if.h
new flag
sys/net/if_var.h
declaration for functions used in device drivers.
sys/net/netisr.h
NETISR_POLL
sys/dev/fxp/if_fxp.c
sys/dev/fxp/if_fxpvar.h
sys/pci/if_dc.c
sys/pci/if_dcreg.h
sys/pci/if_sis.c
sys/pci/if_sisreg.h
device driver modifications
2001-12-14 17:56:12 +00:00
|
|
|
}
|
|
|
|
#endif /* DEVICE_POLLING */
|
|
|
|
|
1995-11-28 23:55:26 +00:00
|
|
|
/*
|
1996-11-18 02:45:46 +00:00
|
|
|
* Process interface interrupts.
|
1995-11-28 23:55:26 +00:00
|
|
|
*/
|
2000-09-18 21:12:19 +00:00
|
|
|
static void
|
2001-03-12 21:30:52 +00:00
|
|
|
fxp_intr(void *xsc)
|
1995-11-28 23:55:26 +00:00
|
|
|
{
|
2001-03-12 21:30:52 +00:00
|
|
|
struct fxp_softc *sc = xsc;
|
2005-06-10 16:49:24 +00:00
|
|
|
struct ifnet *ifp = sc->ifp;
|
2005-03-06 05:07:26 +00:00
|
|
|
uint8_t statack;
|
2000-09-17 13:26:25 +00:00
|
|
|
|
2003-04-30 01:54:38 +00:00
|
|
|
FXP_LOCK(sc);
|
|
|
|
if (sc->suspended) {
|
|
|
|
FXP_UNLOCK(sc);
|
2003-04-29 05:47:14 +00:00
|
|
|
return;
|
2003-04-30 01:54:38 +00:00
|
|
|
}
|
2003-04-29 05:47:14 +00:00
|
|
|
|
Device Polling code for -current.
Non-SMP, i386-only, no polling in the idle loop at the moment.
To use this code you must compile a kernel with
options DEVICE_POLLING
and at runtime enable polling with
sysctl kern.polling.enable=1
The percentage of CPU reserved to userland can be set with
sysctl kern.polling.user_frac=NN (default is 50)
while the remainder is used by polling device drivers and netisr's.
These are the only two variables that you should need to touch. There
are a few more parameters in kern.polling but the default values
are adequate for all purposes. See the code in kern_poll.c for
more details on them.
Polling in the idle loop will be implemented shortly by introducing
a kernel thread which does the job. Until then, the amount of CPU
dedicated to polling will never exceed (100-user_frac).
The equivalent (actually, better) code for -stable is at
http://info.iet.unipi.it/~luigi/polling/
and also supports polling in the idle loop.
NOTE to Alpha developers:
There is really nothing in this code that is i386-specific.
If you move the 2 lines supporting the new option from
sys/conf/{files,options}.i386 to sys/conf/{files,options} I am
pretty sure that this should work on the Alpha as well, just that
I do not have a suitable test box to try it. If someone feels like
trying it, I would appreciate it.
NOTE to other developers:
sure some things could be done better, and as always I am open to
constructive criticism, which a few of you have already given and
I greatly appreciated.
However, before proposing radical architectural changes, please
take some time to possibly try out this code, or at the very least
read the comments in kern_poll.c, especially re. the reason why I
am using a soft netisr and cannot (I believe) replace it with a
simple timeout.
Quick description of files touched by this commit:
sys/conf/files.i386
new file kern/kern_poll.c
sys/conf/options.i386
new option
sys/i386/i386/trap.c
poll in trap (disabled by default)
sys/kern/kern_clock.c
initialization and hardclock hooks.
sys/kern/kern_intr.c
minor swi_net changes
sys/kern/kern_poll.c
the bulk of the code.
sys/net/if.h
new flag
sys/net/if_var.h
declaration for functions used in device drivers.
sys/net/netisr.h
NETISR_POLL
sys/dev/fxp/if_fxp.c
sys/dev/fxp/if_fxpvar.h
sys/pci/if_dc.c
sys/pci/if_dcreg.h
sys/pci/if_sis.c
sys/pci/if_sisreg.h
device driver modifications
2001-12-14 17:56:12 +00:00
|
|
|
#ifdef DEVICE_POLLING
|
Big polling(4) cleanup.
o Axe poll in trap.
o Axe IFF_POLLING flag from if_flags.
o Rework revision 1.21 (Giant removal), in such a way that
poll_mtx is not dropped during call to polling handler.
This fixes problem with idle polling.
o Make registration and deregistration from polling in a
functional way, insted of next tick/interrupt.
o Obsolete kern.polling.enable. Polling is turned on/off
with ifconfig.
Detailed kern_poll.c changes:
- Remove polling handler flags, introduced in 1.21. The are not
needed now.
- Forget and do not check if_flags, if_capenable and if_drv_flags.
- Call all registered polling handlers unconditionally.
- Do not drop poll_mtx, when entering polling handlers.
- In ether_poll() NET_LOCK_GIANT prior to locking poll_mtx.
- In netisr_poll() axe the block, where polling code asks drivers
to unregister.
- In netisr_poll() and ether_poll() do polling always, if any
handlers are present.
- In ether_poll_[de]register() remove a lot of error hiding code. Assert
that arguments are correct, instead.
- In ether_poll_[de]register() use standard return values in case of
error or success.
- Introduce poll_switch() that is a sysctl handler for kern.polling.enable.
poll_switch() goes through interface list and enabled/disables polling.
A message that kern.polling.enable is deprecated is printed.
Detailed driver changes:
- On attach driver announces IFCAP_POLLING in if_capabilities, but
not in if_capenable.
- On detach driver calls ether_poll_deregister() if polling is enabled.
- In polling handler driver obtains its lock and checks IFF_DRV_RUNNING
flag. If there is no, then unlocks and returns.
- In ioctl handler driver checks for IFCAP_POLLING flag requested to
be set or cleared. Driver first calls ether_poll_[de]register(), then
obtains driver lock and [dis/en]ables interrupts.
- In interrupt handler driver checks IFCAP_POLLING flag in if_capenable.
If present, then returns.This is important to protect from spurious
interrupts.
Reviewed by: ru, sam, jhb
2005-10-01 18:56:19 +00:00
|
|
|
if (ifp->if_capenable & IFCAP_POLLING) {
|
Make fxp(4) INTR_MPSAFE (but do not enable MPSAFE just yet):
- Add fxp_start_body() and change fxp_start() to just acquire locks and
then call fxp_start_body(). Places that would call fxp_start() with
locks held (mutex recursion) now call fxp_start_body() directly.
Remove MTX_RECURSE flag from sc_mtx. [gallatin]
- Change fxp_attach() to work without the softc lock, saving interrupt
hooking until the head of fxp_attach().
- Call ether_ifattach() before overriding ifp parameters. This reverts
part of 1.155.
- Remove multiple error paths in fxp_attach().
- Teardown interrupt in fxp_detach() before unlocking the softc.
- Make sure mutex is not held in fxp_release()
- Delete the miibus instance and/or self in fxp_release(), not in
fxp_detach(). This can happen if attach fails partway through.
- Move ifmedia_removeall to fxp_release() since attach may fail after
media have been allocated.
- Add locking to fxp_suspend, fxp_resume, fxp_start, fxp_intr,
fxp_poll, fxp_tick, fxp_ioctl, fxp_watchdog.
- Pass in ifp to fxp_intr_body since its callers sometimes already use
it.
- Add compatibility define for INTR_MPSAFE for 4.x. [gallatin]
- You don't need to bzero softc.
Ideas from: gallatin, mux
Tested by: >400M packets of dd/ssh, NFS, ping on i386 UP
2003-04-25 09:01:54 +00:00
|
|
|
FXP_UNLOCK(sc);
|
2001-12-15 02:41:52 +00:00
|
|
|
return;
|
Make fxp(4) INTR_MPSAFE (but do not enable MPSAFE just yet):
- Add fxp_start_body() and change fxp_start() to just acquire locks and
then call fxp_start_body(). Places that would call fxp_start() with
locks held (mutex recursion) now call fxp_start_body() directly.
Remove MTX_RECURSE flag from sc_mtx. [gallatin]
- Change fxp_attach() to work without the softc lock, saving interrupt
hooking until the head of fxp_attach().
- Call ether_ifattach() before overriding ifp parameters. This reverts
part of 1.155.
- Remove multiple error paths in fxp_attach().
- Teardown interrupt in fxp_detach() before unlocking the softc.
- Make sure mutex is not held in fxp_release()
- Delete the miibus instance and/or self in fxp_release(), not in
fxp_detach(). This can happen if attach fails partway through.
- Move ifmedia_removeall to fxp_release() since attach may fail after
media have been allocated.
- Add locking to fxp_suspend, fxp_resume, fxp_start, fxp_intr,
fxp_poll, fxp_tick, fxp_ioctl, fxp_watchdog.
- Pass in ifp to fxp_intr_body since its callers sometimes already use
it.
- Add compatibility define for INTR_MPSAFE for 4.x. [gallatin]
- You don't need to bzero softc.
Ideas from: gallatin, mux
Tested by: >400M packets of dd/ssh, NFS, ping on i386 UP
2003-04-25 09:01:54 +00:00
|
|
|
}
|
Device Polling code for -current.
Non-SMP, i386-only, no polling in the idle loop at the moment.
To use this code you must compile a kernel with
options DEVICE_POLLING
and at runtime enable polling with
sysctl kern.polling.enable=1
The percentage of CPU reserved to userland can be set with
sysctl kern.polling.user_frac=NN (default is 50)
while the remainder is used by polling device drivers and netisr's.
These are the only two variables that you should need to touch. There
are a few more parameters in kern.polling but the default values
are adequate for all purposes. See the code in kern_poll.c for
more details on them.
Polling in the idle loop will be implemented shortly by introducing
a kernel thread which does the job. Until then, the amount of CPU
dedicated to polling will never exceed (100-user_frac).
The equivalent (actually, better) code for -stable is at
http://info.iet.unipi.it/~luigi/polling/
and also supports polling in the idle loop.
NOTE to Alpha developers:
There is really nothing in this code that is i386-specific.
If you move the 2 lines supporting the new option from
sys/conf/{files,options}.i386 to sys/conf/{files,options} I am
pretty sure that this should work on the Alpha as well, just that
I do not have a suitable test box to try it. If someone feels like
trying it, I would appreciate it.
NOTE to other developers:
sure some things could be done better, and as always I am open to
constructive criticism, which a few of you have already given and
I greatly appreciated.
However, before proposing radical architectural changes, please
take some time to possibly try out this code, or at the very least
read the comments in kern_poll.c, especially re. the reason why I
am using a soft netisr and cannot (I believe) replace it with a
simple timeout.
Quick description of files touched by this commit:
sys/conf/files.i386
new file kern/kern_poll.c
sys/conf/options.i386
new option
sys/i386/i386/trap.c
poll in trap (disabled by default)
sys/kern/kern_clock.c
initialization and hardclock hooks.
sys/kern/kern_intr.c
minor swi_net changes
sys/kern/kern_poll.c
the bulk of the code.
sys/net/if.h
new flag
sys/net/if_var.h
declaration for functions used in device drivers.
sys/net/netisr.h
NETISR_POLL
sys/dev/fxp/if_fxp.c
sys/dev/fxp/if_fxpvar.h
sys/pci/if_dc.c
sys/pci/if_dcreg.h
sys/pci/if_sis.c
sys/pci/if_sisreg.h
device driver modifications
2001-12-14 17:56:12 +00:00
|
|
|
#endif
|
2000-09-17 23:04:57 +00:00
|
|
|
while ((statack = CSR_READ_1(sc, FXP_CSR_SCB_STATACK)) != 0) {
|
2001-06-04 22:01:44 +00:00
|
|
|
/*
|
|
|
|
* It should not be possible to have all bits set; the
|
2008-11-25 00:48:05 +00:00
|
|
|
* FXP_SCB_INTR_SWI bit always returns 0 on a read. If
|
2001-06-04 22:01:44 +00:00
|
|
|
* all bits are set, this may indicate that the card has
|
|
|
|
* been physically ejected, so ignore it.
|
2008-11-25 00:48:05 +00:00
|
|
|
*/
|
Make fxp(4) INTR_MPSAFE (but do not enable MPSAFE just yet):
- Add fxp_start_body() and change fxp_start() to just acquire locks and
then call fxp_start_body(). Places that would call fxp_start() with
locks held (mutex recursion) now call fxp_start_body() directly.
Remove MTX_RECURSE flag from sc_mtx. [gallatin]
- Change fxp_attach() to work without the softc lock, saving interrupt
hooking until the head of fxp_attach().
- Call ether_ifattach() before overriding ifp parameters. This reverts
part of 1.155.
- Remove multiple error paths in fxp_attach().
- Teardown interrupt in fxp_detach() before unlocking the softc.
- Make sure mutex is not held in fxp_release()
- Delete the miibus instance and/or self in fxp_release(), not in
fxp_detach(). This can happen if attach fails partway through.
- Move ifmedia_removeall to fxp_release() since attach may fail after
media have been allocated.
- Add locking to fxp_suspend, fxp_resume, fxp_start, fxp_intr,
fxp_poll, fxp_tick, fxp_ioctl, fxp_watchdog.
- Pass in ifp to fxp_intr_body since its callers sometimes already use
it.
- Add compatibility define for INTR_MPSAFE for 4.x. [gallatin]
- You don't need to bzero softc.
Ideas from: gallatin, mux
Tested by: >400M packets of dd/ssh, NFS, ping on i386 UP
2003-04-25 09:01:54 +00:00
|
|
|
if (statack == 0xff) {
|
|
|
|
FXP_UNLOCK(sc);
|
2001-06-04 22:01:44 +00:00
|
|
|
return;
|
Make fxp(4) INTR_MPSAFE (but do not enable MPSAFE just yet):
- Add fxp_start_body() and change fxp_start() to just acquire locks and
then call fxp_start_body(). Places that would call fxp_start() with
locks held (mutex recursion) now call fxp_start_body() directly.
Remove MTX_RECURSE flag from sc_mtx. [gallatin]
- Change fxp_attach() to work without the softc lock, saving interrupt
hooking until the head of fxp_attach().
- Call ether_ifattach() before overriding ifp parameters. This reverts
part of 1.155.
- Remove multiple error paths in fxp_attach().
- Teardown interrupt in fxp_detach() before unlocking the softc.
- Make sure mutex is not held in fxp_release()
- Delete the miibus instance and/or self in fxp_release(), not in
fxp_detach(). This can happen if attach fails partway through.
- Move ifmedia_removeall to fxp_release() since attach may fail after
media have been allocated.
- Add locking to fxp_suspend, fxp_resume, fxp_start, fxp_intr,
fxp_poll, fxp_tick, fxp_ioctl, fxp_watchdog.
- Pass in ifp to fxp_intr_body since its callers sometimes already use
it.
- Add compatibility define for INTR_MPSAFE for 4.x. [gallatin]
- You don't need to bzero softc.
Ideas from: gallatin, mux
Tested by: >400M packets of dd/ssh, NFS, ping on i386 UP
2003-04-25 09:01:54 +00:00
|
|
|
}
|
2001-06-04 22:01:44 +00:00
|
|
|
|
1995-11-28 23:55:26 +00:00
|
|
|
/*
|
|
|
|
* First ACK all the interrupts in this pass.
|
|
|
|
*/
|
1997-09-05 10:23:58 +00:00
|
|
|
CSR_WRITE_1(sc, FXP_CSR_SCB_STATACK, statack);
|
2009-06-21 06:46:32 +00:00
|
|
|
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0)
|
|
|
|
fxp_intr_body(sc, ifp, statack, -1);
|
Device Polling code for -current.
Non-SMP, i386-only, no polling in the idle loop at the moment.
To use this code you must compile a kernel with
options DEVICE_POLLING
and at runtime enable polling with
sysctl kern.polling.enable=1
The percentage of CPU reserved to userland can be set with
sysctl kern.polling.user_frac=NN (default is 50)
while the remainder is used by polling device drivers and netisr's.
These are the only two variables that you should need to touch. There
are a few more parameters in kern.polling but the default values
are adequate for all purposes. See the code in kern_poll.c for
more details on them.
Polling in the idle loop will be implemented shortly by introducing
a kernel thread which does the job. Until then, the amount of CPU
dedicated to polling will never exceed (100-user_frac).
The equivalent (actually, better) code for -stable is at
http://info.iet.unipi.it/~luigi/polling/
and also supports polling in the idle loop.
NOTE to Alpha developers:
There is really nothing in this code that is i386-specific.
If you move the 2 lines supporting the new option from
sys/conf/{files,options}.i386 to sys/conf/{files,options} I am
pretty sure that this should work on the Alpha as well, just that
I do not have a suitable test box to try it. If someone feels like
trying it, I would appreciate it.
NOTE to other developers:
sure some things could be done better, and as always I am open to
constructive criticism, which a few of you have already given and
I greatly appreciated.
However, before proposing radical architectural changes, please
take some time to possibly try out this code, or at the very least
read the comments in kern_poll.c, especially re. the reason why I
am using a soft netisr and cannot (I believe) replace it with a
simple timeout.
Quick description of files touched by this commit:
sys/conf/files.i386
new file kern/kern_poll.c
sys/conf/options.i386
new option
sys/i386/i386/trap.c
poll in trap (disabled by default)
sys/kern/kern_clock.c
initialization and hardclock hooks.
sys/kern/kern_intr.c
minor swi_net changes
sys/kern/kern_poll.c
the bulk of the code.
sys/net/if.h
new flag
sys/net/if_var.h
declaration for functions used in device drivers.
sys/net/netisr.h
NETISR_POLL
sys/dev/fxp/if_fxp.c
sys/dev/fxp/if_fxpvar.h
sys/pci/if_dc.c
sys/pci/if_dcreg.h
sys/pci/if_sis.c
sys/pci/if_sisreg.h
device driver modifications
2001-12-14 17:56:12 +00:00
|
|
|
}
|
Make fxp(4) INTR_MPSAFE (but do not enable MPSAFE just yet):
- Add fxp_start_body() and change fxp_start() to just acquire locks and
then call fxp_start_body(). Places that would call fxp_start() with
locks held (mutex recursion) now call fxp_start_body() directly.
Remove MTX_RECURSE flag from sc_mtx. [gallatin]
- Change fxp_attach() to work without the softc lock, saving interrupt
hooking until the head of fxp_attach().
- Call ether_ifattach() before overriding ifp parameters. This reverts
part of 1.155.
- Remove multiple error paths in fxp_attach().
- Teardown interrupt in fxp_detach() before unlocking the softc.
- Make sure mutex is not held in fxp_release()
- Delete the miibus instance and/or self in fxp_release(), not in
fxp_detach(). This can happen if attach fails partway through.
- Move ifmedia_removeall to fxp_release() since attach may fail after
media have been allocated.
- Add locking to fxp_suspend, fxp_resume, fxp_start, fxp_intr,
fxp_poll, fxp_tick, fxp_ioctl, fxp_watchdog.
- Pass in ifp to fxp_intr_body since its callers sometimes already use
it.
- Add compatibility define for INTR_MPSAFE for 4.x. [gallatin]
- You don't need to bzero softc.
Ideas from: gallatin, mux
Tested by: >400M packets of dd/ssh, NFS, ping on i386 UP
2003-04-25 09:01:54 +00:00
|
|
|
FXP_UNLOCK(sc);
|
Device Polling code for -current.
Non-SMP, i386-only, no polling in the idle loop at the moment.
To use this code you must compile a kernel with
options DEVICE_POLLING
and at runtime enable polling with
sysctl kern.polling.enable=1
The percentage of CPU reserved to userland can be set with
sysctl kern.polling.user_frac=NN (default is 50)
while the remainder is used by polling device drivers and netisr's.
These are the only two variables that you should need to touch. There
are a few more parameters in kern.polling but the default values
are adequate for all purposes. See the code in kern_poll.c for
more details on them.
Polling in the idle loop will be implemented shortly by introducing
a kernel thread which does the job. Until then, the amount of CPU
dedicated to polling will never exceed (100-user_frac).
The equivalent (actually, better) code for -stable is at
http://info.iet.unipi.it/~luigi/polling/
and also supports polling in the idle loop.
NOTE to Alpha developers:
There is really nothing in this code that is i386-specific.
If you move the 2 lines supporting the new option from
sys/conf/{files,options}.i386 to sys/conf/{files,options} I am
pretty sure that this should work on the Alpha as well, just that
I do not have a suitable test box to try it. If someone feels like
trying it, I would appreciate it.
NOTE to other developers:
sure some things could be done better, and as always I am open to
constructive criticism, which a few of you have already given and
I greatly appreciated.
However, before proposing radical architectural changes, please
take some time to possibly try out this code, or at the very least
read the comments in kern_poll.c, especially re. the reason why I
am using a soft netisr and cannot (I believe) replace it with a
simple timeout.
Quick description of files touched by this commit:
sys/conf/files.i386
new file kern/kern_poll.c
sys/conf/options.i386
new option
sys/i386/i386/trap.c
poll in trap (disabled by default)
sys/kern/kern_clock.c
initialization and hardclock hooks.
sys/kern/kern_intr.c
minor swi_net changes
sys/kern/kern_poll.c
the bulk of the code.
sys/net/if.h
new flag
sys/net/if_var.h
declaration for functions used in device drivers.
sys/net/netisr.h
NETISR_POLL
sys/dev/fxp/if_fxp.c
sys/dev/fxp/if_fxpvar.h
sys/pci/if_dc.c
sys/pci/if_dcreg.h
sys/pci/if_sis.c
sys/pci/if_sisreg.h
device driver modifications
2001-12-14 17:56:12 +00:00
|
|
|
}
|
|
|
|
|
2003-04-02 16:47:16 +00:00
|
|
|
static void
|
|
|
|
fxp_txeof(struct fxp_softc *sc)
|
|
|
|
{
|
2008-11-25 04:16:16 +00:00
|
|
|
struct ifnet *ifp;
|
2003-04-02 16:47:16 +00:00
|
|
|
struct fxp_tx *txp;
|
|
|
|
|
2008-11-25 04:16:16 +00:00
|
|
|
ifp = sc->ifp;
|
2009-06-21 06:06:43 +00:00
|
|
|
bus_dmamap_sync(sc->cbl_tag, sc->cbl_map,
|
|
|
|
BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
|
2003-04-02 16:47:16 +00:00
|
|
|
for (txp = sc->fxp_desc.tx_first; sc->tx_queued &&
|
2003-04-06 01:04:17 +00:00
|
|
|
(le16toh(txp->tx_cb->cb_status) & FXP_CB_STATUS_C) != 0;
|
2003-04-02 16:47:16 +00:00
|
|
|
txp = txp->tx_next) {
|
|
|
|
if (txp->tx_mbuf != NULL) {
|
2009-06-21 06:06:43 +00:00
|
|
|
bus_dmamap_sync(sc->fxp_txmtag, txp->tx_map,
|
2003-04-02 16:47:16 +00:00
|
|
|
BUS_DMASYNC_POSTWRITE);
|
2009-06-21 06:06:43 +00:00
|
|
|
bus_dmamap_unload(sc->fxp_txmtag, txp->tx_map);
|
2003-04-02 16:47:16 +00:00
|
|
|
m_freem(txp->tx_mbuf);
|
|
|
|
txp->tx_mbuf = NULL;
|
|
|
|
/* clear this to reset csum offload bits */
|
|
|
|
txp->tx_cb->tbd[0].tb_addr = 0;
|
|
|
|
}
|
|
|
|
sc->tx_queued--;
|
2008-11-25 04:16:16 +00:00
|
|
|
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
|
2003-04-02 16:47:16 +00:00
|
|
|
}
|
|
|
|
sc->fxp_desc.tx_first = txp;
|
2009-06-21 06:06:43 +00:00
|
|
|
bus_dmamap_sync(sc->cbl_tag, sc->cbl_map,
|
|
|
|
BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
|
2009-06-21 07:17:49 +00:00
|
|
|
if (sc->tx_queued == 0)
|
2008-11-25 02:05:01 +00:00
|
|
|
sc->watchdog_timer = 0;
|
2003-04-02 16:47:16 +00:00
|
|
|
}
|
|
|
|
|
2008-11-26 06:36:53 +00:00
|
|
|
static void
|
|
|
|
fxp_rxcsum(struct fxp_softc *sc, struct ifnet *ifp, struct mbuf *m,
|
|
|
|
uint16_t status, int pos)
|
|
|
|
{
|
|
|
|
struct ether_header *eh;
|
|
|
|
struct ip *ip;
|
|
|
|
struct udphdr *uh;
|
|
|
|
int32_t hlen, len, pktlen, temp32;
|
|
|
|
uint16_t csum, *opts;
|
|
|
|
|
|
|
|
if ((sc->flags & FXP_FLAG_82559_RXCSUM) == 0) {
|
|
|
|
if ((status & FXP_RFA_STATUS_PARSE) != 0) {
|
|
|
|
if (status & FXP_RFDX_CS_IP_CSUM_BIT_VALID)
|
|
|
|
m->m_pkthdr.csum_flags |= CSUM_IP_CHECKED;
|
|
|
|
if (status & FXP_RFDX_CS_IP_CSUM_VALID)
|
|
|
|
m->m_pkthdr.csum_flags |= CSUM_IP_VALID;
|
|
|
|
if ((status & FXP_RFDX_CS_TCPUDP_CSUM_BIT_VALID) &&
|
|
|
|
(status & FXP_RFDX_CS_TCPUDP_CSUM_VALID)) {
|
|
|
|
m->m_pkthdr.csum_flags |= CSUM_DATA_VALID |
|
|
|
|
CSUM_PSEUDO_HDR;
|
|
|
|
m->m_pkthdr.csum_data = 0xffff;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
pktlen = m->m_pkthdr.len;
|
|
|
|
if (pktlen < sizeof(struct ether_header) + sizeof(struct ip))
|
|
|
|
return;
|
|
|
|
eh = mtod(m, struct ether_header *);
|
|
|
|
if (eh->ether_type != htons(ETHERTYPE_IP))
|
|
|
|
return;
|
|
|
|
ip = (struct ip *)(eh + 1);
|
|
|
|
if (ip->ip_v != IPVERSION)
|
|
|
|
return;
|
|
|
|
|
|
|
|
hlen = ip->ip_hl << 2;
|
|
|
|
pktlen -= sizeof(struct ether_header);
|
|
|
|
if (hlen < sizeof(struct ip))
|
|
|
|
return;
|
|
|
|
if (ntohs(ip->ip_len) < hlen)
|
|
|
|
return;
|
|
|
|
if (ntohs(ip->ip_len) != pktlen)
|
|
|
|
return;
|
|
|
|
if (ip->ip_off & htons(IP_MF | IP_OFFMASK))
|
|
|
|
return; /* can't handle fragmented packet */
|
|
|
|
|
|
|
|
switch (ip->ip_p) {
|
|
|
|
case IPPROTO_TCP:
|
|
|
|
if (pktlen < (hlen + sizeof(struct tcphdr)))
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
case IPPROTO_UDP:
|
|
|
|
if (pktlen < (hlen + sizeof(struct udphdr)))
|
|
|
|
return;
|
|
|
|
uh = (struct udphdr *)((caddr_t)ip + hlen);
|
|
|
|
if (uh->uh_sum == 0)
|
|
|
|
return; /* no checksum */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* Extract computed checksum. */
|
|
|
|
csum = be16dec(mtod(m, char *) + pos);
|
|
|
|
/* checksum fixup for IP options */
|
|
|
|
len = hlen - sizeof(struct ip);
|
|
|
|
if (len > 0) {
|
|
|
|
opts = (uint16_t *)(ip + 1);
|
|
|
|
for (; len > 0; len -= sizeof(uint16_t), opts++) {
|
|
|
|
temp32 = csum - *opts;
|
|
|
|
temp32 = (temp32 >> 16) + (temp32 & 65535);
|
|
|
|
csum = temp32 & 65535;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m->m_pkthdr.csum_flags |= CSUM_DATA_VALID;
|
|
|
|
m->m_pkthdr.csum_data = csum;
|
|
|
|
}
|
|
|
|
|
2009-05-30 15:14:44 +00:00
|
|
|
static int
|
2005-03-06 05:07:26 +00:00
|
|
|
fxp_intr_body(struct fxp_softc *sc, struct ifnet *ifp, uint8_t statack,
|
Make fxp(4) INTR_MPSAFE (but do not enable MPSAFE just yet):
- Add fxp_start_body() and change fxp_start() to just acquire locks and
then call fxp_start_body(). Places that would call fxp_start() with
locks held (mutex recursion) now call fxp_start_body() directly.
Remove MTX_RECURSE flag from sc_mtx. [gallatin]
- Change fxp_attach() to work without the softc lock, saving interrupt
hooking until the head of fxp_attach().
- Call ether_ifattach() before overriding ifp parameters. This reverts
part of 1.155.
- Remove multiple error paths in fxp_attach().
- Teardown interrupt in fxp_detach() before unlocking the softc.
- Make sure mutex is not held in fxp_release()
- Delete the miibus instance and/or self in fxp_release(), not in
fxp_detach(). This can happen if attach fails partway through.
- Move ifmedia_removeall to fxp_release() since attach may fail after
media have been allocated.
- Add locking to fxp_suspend, fxp_resume, fxp_start, fxp_intr,
fxp_poll, fxp_tick, fxp_ioctl, fxp_watchdog.
- Pass in ifp to fxp_intr_body since its callers sometimes already use
it.
- Add compatibility define for INTR_MPSAFE for 4.x. [gallatin]
- You don't need to bzero softc.
Ideas from: gallatin, mux
Tested by: >400M packets of dd/ssh, NFS, ping on i386 UP
2003-04-25 09:01:54 +00:00
|
|
|
int count)
|
Device Polling code for -current.
Non-SMP, i386-only, no polling in the idle loop at the moment.
To use this code you must compile a kernel with
options DEVICE_POLLING
and at runtime enable polling with
sysctl kern.polling.enable=1
The percentage of CPU reserved to userland can be set with
sysctl kern.polling.user_frac=NN (default is 50)
while the remainder is used by polling device drivers and netisr's.
These are the only two variables that you should need to touch. There
are a few more parameters in kern.polling but the default values
are adequate for all purposes. See the code in kern_poll.c for
more details on them.
Polling in the idle loop will be implemented shortly by introducing
a kernel thread which does the job. Until then, the amount of CPU
dedicated to polling will never exceed (100-user_frac).
The equivalent (actually, better) code for -stable is at
http://info.iet.unipi.it/~luigi/polling/
and also supports polling in the idle loop.
NOTE to Alpha developers:
There is really nothing in this code that is i386-specific.
If you move the 2 lines supporting the new option from
sys/conf/{files,options}.i386 to sys/conf/{files,options} I am
pretty sure that this should work on the Alpha as well, just that
I do not have a suitable test box to try it. If someone feels like
trying it, I would appreciate it.
NOTE to other developers:
sure some things could be done better, and as always I am open to
constructive criticism, which a few of you have already given and
I greatly appreciated.
However, before proposing radical architectural changes, please
take some time to possibly try out this code, or at the very least
read the comments in kern_poll.c, especially re. the reason why I
am using a soft netisr and cannot (I believe) replace it with a
simple timeout.
Quick description of files touched by this commit:
sys/conf/files.i386
new file kern/kern_poll.c
sys/conf/options.i386
new option
sys/i386/i386/trap.c
poll in trap (disabled by default)
sys/kern/kern_clock.c
initialization and hardclock hooks.
sys/kern/kern_intr.c
minor swi_net changes
sys/kern/kern_poll.c
the bulk of the code.
sys/net/if.h
new flag
sys/net/if_var.h
declaration for functions used in device drivers.
sys/net/netisr.h
NETISR_POLL
sys/dev/fxp/if_fxp.c
sys/dev/fxp/if_fxpvar.h
sys/pci/if_dc.c
sys/pci/if_dcreg.h
sys/pci/if_sis.c
sys/pci/if_sisreg.h
device driver modifications
2001-12-14 17:56:12 +00:00
|
|
|
{
|
2002-08-04 22:33:28 +00:00
|
|
|
struct mbuf *m;
|
2003-04-02 16:47:16 +00:00
|
|
|
struct fxp_rx *rxp;
|
2002-08-04 22:33:28 +00:00
|
|
|
struct fxp_rfa *rfa;
|
|
|
|
int rnr = (statack & FXP_SCB_STATACK_RNR) ? 1 : 0;
|
2009-05-30 15:14:44 +00:00
|
|
|
int rx_npkts;
|
2008-11-25 01:33:16 +00:00
|
|
|
uint16_t status;
|
2002-08-04 22:33:28 +00:00
|
|
|
|
2009-05-30 15:14:44 +00:00
|
|
|
rx_npkts = 0;
|
2004-06-02 22:59:57 +00:00
|
|
|
FXP_LOCK_ASSERT(sc, MA_OWNED);
|
2009-05-30 15:14:44 +00:00
|
|
|
|
2002-08-04 22:33:28 +00:00
|
|
|
if (rnr)
|
2004-06-02 22:52:18 +00:00
|
|
|
sc->rnr++;
|
2002-11-07 16:04:07 +00:00
|
|
|
#ifdef DEVICE_POLLING
|
|
|
|
/* Pick up a deferred RNR condition if `count' ran out last time. */
|
|
|
|
if (sc->flags & FXP_FLAG_DEFERRED_RNR) {
|
|
|
|
sc->flags &= ~FXP_FLAG_DEFERRED_RNR;
|
|
|
|
rnr = 1;
|
|
|
|
}
|
|
|
|
#endif
|
1995-11-28 23:55:26 +00:00
|
|
|
|
2002-07-29 02:48:09 +00:00
|
|
|
/*
|
|
|
|
* Free any finished transmit mbuf chains.
|
|
|
|
*
|
|
|
|
* Handle the CNA event likt a CXTNO event. It used to
|
|
|
|
* be that this event (control unit not ready) was not
|
|
|
|
* encountered, but it is now with the SMPng modifications.
|
|
|
|
* The exact sequence of events that occur when the interface
|
|
|
|
* is brought up are different now, and if this event
|
|
|
|
* goes unhandled, the configuration/rxfilter setup sequence
|
|
|
|
* can stall for several seconds. The result is that no
|
|
|
|
* packets go out onto the wire for about 5 to 10 seconds
|
|
|
|
* after the interface is ifconfig'ed for the first time.
|
|
|
|
*/
|
2008-11-25 04:16:16 +00:00
|
|
|
if (statack & (FXP_SCB_STATACK_CXTNO | FXP_SCB_STATACK_CNA))
|
2003-04-02 16:47:16 +00:00
|
|
|
fxp_txeof(sc);
|
|
|
|
|
2008-11-25 04:16:16 +00:00
|
|
|
/*
|
|
|
|
* Try to start more packets transmitting.
|
|
|
|
*/
|
|
|
|
if (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
|
|
|
|
fxp_start_body(ifp);
|
2002-08-04 22:33:28 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Just return if nothing happened on the receive side.
|
|
|
|
*/
|
2002-11-07 16:04:07 +00:00
|
|
|
if (!rnr && (statack & FXP_SCB_STATACK_FR) == 0)
|
2009-05-30 15:14:44 +00:00
|
|
|
return (rx_npkts);
|
2002-08-04 22:33:28 +00:00
|
|
|
|
2002-07-29 02:48:09 +00:00
|
|
|
/*
|
|
|
|
* Process receiver interrupts. If a no-resource (RNR)
|
|
|
|
* condition exists, get whatever packets we can and
|
|
|
|
* re-start the receiver.
|
2002-11-07 16:04:07 +00:00
|
|
|
*
|
2002-08-04 22:33:28 +00:00
|
|
|
* When using polling, we do not process the list to completion,
|
|
|
|
* so when we get an RNR interrupt we must defer the restart
|
|
|
|
* until we hit the last buffer with the C bit set.
|
|
|
|
* If we run out of cycles and rfa_headm has the C bit set,
|
2002-11-07 16:04:07 +00:00
|
|
|
* record the pending RNR in the FXP_FLAG_DEFERRED_RNR flag so
|
|
|
|
* that the info will be used in the subsequent polling cycle.
|
2002-07-29 02:48:09 +00:00
|
|
|
*/
|
2002-08-04 22:33:28 +00:00
|
|
|
for (;;) {
|
2003-04-02 16:47:16 +00:00
|
|
|
rxp = sc->fxp_desc.rx_head;
|
|
|
|
m = rxp->rx_mbuf;
|
2002-07-29 02:48:09 +00:00
|
|
|
rfa = (struct fxp_rfa *)(m->m_ext.ext_buf +
|
|
|
|
RFA_ALIGNMENT_FUDGE);
|
2009-06-21 06:06:43 +00:00
|
|
|
bus_dmamap_sync(sc->fxp_rxmtag, rxp->rx_map,
|
2010-05-14 16:55:13 +00:00
|
|
|
BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
|
1995-11-28 23:55:26 +00:00
|
|
|
|
Device Polling code for -current.
Non-SMP, i386-only, no polling in the idle loop at the moment.
To use this code you must compile a kernel with
options DEVICE_POLLING
and at runtime enable polling with
sysctl kern.polling.enable=1
The percentage of CPU reserved to userland can be set with
sysctl kern.polling.user_frac=NN (default is 50)
while the remainder is used by polling device drivers and netisr's.
These are the only two variables that you should need to touch. There
are a few more parameters in kern.polling but the default values
are adequate for all purposes. See the code in kern_poll.c for
more details on them.
Polling in the idle loop will be implemented shortly by introducing
a kernel thread which does the job. Until then, the amount of CPU
dedicated to polling will never exceed (100-user_frac).
The equivalent (actually, better) code for -stable is at
http://info.iet.unipi.it/~luigi/polling/
and also supports polling in the idle loop.
NOTE to Alpha developers:
There is really nothing in this code that is i386-specific.
If you move the 2 lines supporting the new option from
sys/conf/{files,options}.i386 to sys/conf/{files,options} I am
pretty sure that this should work on the Alpha as well, just that
I do not have a suitable test box to try it. If someone feels like
trying it, I would appreciate it.
NOTE to other developers:
sure some things could be done better, and as always I am open to
constructive criticism, which a few of you have already given and
I greatly appreciated.
However, before proposing radical architectural changes, please
take some time to possibly try out this code, or at the very least
read the comments in kern_poll.c, especially re. the reason why I
am using a soft netisr and cannot (I believe) replace it with a
simple timeout.
Quick description of files touched by this commit:
sys/conf/files.i386
new file kern/kern_poll.c
sys/conf/options.i386
new option
sys/i386/i386/trap.c
poll in trap (disabled by default)
sys/kern/kern_clock.c
initialization and hardclock hooks.
sys/kern/kern_intr.c
minor swi_net changes
sys/kern/kern_poll.c
the bulk of the code.
sys/net/if.h
new flag
sys/net/if_var.h
declaration for functions used in device drivers.
sys/net/netisr.h
NETISR_POLL
sys/dev/fxp/if_fxp.c
sys/dev/fxp/if_fxpvar.h
sys/pci/if_dc.c
sys/pci/if_dcreg.h
sys/pci/if_sis.c
sys/pci/if_sisreg.h
device driver modifications
2001-12-14 17:56:12 +00:00
|
|
|
#ifdef DEVICE_POLLING /* loop at most count times if count >=0 */
|
2002-11-07 16:04:07 +00:00
|
|
|
if (count >= 0 && count-- == 0) {
|
|
|
|
if (rnr) {
|
|
|
|
/* Defer RNR processing until the next time. */
|
|
|
|
sc->flags |= FXP_FLAG_DEFERRED_RNR;
|
|
|
|
rnr = 0;
|
|
|
|
}
|
2002-08-04 22:33:28 +00:00
|
|
|
break;
|
2002-11-07 16:04:07 +00:00
|
|
|
}
|
2002-08-04 22:33:28 +00:00
|
|
|
#endif /* DEVICE_POLLING */
|
2002-07-29 02:48:09 +00:00
|
|
|
|
2008-11-25 01:33:16 +00:00
|
|
|
status = le16toh(rfa->rfa_status);
|
|
|
|
if ((status & FXP_RFA_STATUS_C) == 0)
|
2002-08-04 22:33:28 +00:00
|
|
|
break;
|
1995-11-28 23:55:26 +00:00
|
|
|
|
2010-05-14 17:39:28 +00:00
|
|
|
if ((status & FXP_RFA_STATUS_RNR) != 0)
|
|
|
|
rnr++;
|
2002-08-04 22:33:28 +00:00
|
|
|
/*
|
2003-04-02 16:47:16 +00:00
|
|
|
* Advance head forward.
|
2002-08-04 22:33:28 +00:00
|
|
|
*/
|
2003-04-02 16:47:16 +00:00
|
|
|
sc->fxp_desc.rx_head = rxp->rx_next;
|
2002-07-29 02:48:09 +00:00
|
|
|
|
2002-08-04 22:33:28 +00:00
|
|
|
/*
|
|
|
|
* Add a new buffer to the receive chain.
|
|
|
|
* If this fails, the old buffer is recycled
|
|
|
|
* instead.
|
|
|
|
*/
|
2008-11-26 05:51:49 +00:00
|
|
|
if (fxp_new_rfabuf(sc, rxp) == 0) {
|
2002-08-04 22:33:28 +00:00
|
|
|
int total_len;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Fetch packet length (the top 2 bits of
|
|
|
|
* actual_size are flags set by the controller
|
|
|
|
* upon completion), and drop the packet in case
|
|
|
|
* of bogus length or CRC errors.
|
|
|
|
*/
|
2003-04-08 17:21:15 +00:00
|
|
|
total_len = le16toh(rfa->actual_size) & 0x3fff;
|
2008-11-26 06:36:53 +00:00
|
|
|
if ((sc->flags & FXP_FLAG_82559_RXCSUM) != 0 &&
|
|
|
|
(ifp->if_capenable & IFCAP_RXCSUM) != 0) {
|
|
|
|
/* Adjust for appended checksum bytes. */
|
|
|
|
total_len -= 2;
|
|
|
|
}
|
2011-03-28 16:58:48 +00:00
|
|
|
if (total_len < (int)sizeof(struct ether_header) ||
|
2010-05-14 17:39:28 +00:00
|
|
|
total_len > (MCLBYTES - RFA_ALIGNMENT_FUDGE -
|
|
|
|
sc->rfa_size) ||
|
|
|
|
status & (FXP_RFA_STATUS_CRC |
|
2011-03-28 16:58:48 +00:00
|
|
|
FXP_RFA_STATUS_ALIGN | FXP_RFA_STATUS_OVERRUN)) {
|
2002-08-04 22:33:28 +00:00
|
|
|
m_freem(m);
|
2010-05-14 17:39:28 +00:00
|
|
|
fxp_add_rfabuf(sc, rxp);
|
2002-08-04 22:33:28 +00:00
|
|
|
continue;
|
1995-11-28 23:55:26 +00:00
|
|
|
}
|
2002-08-04 22:33:28 +00:00
|
|
|
|
|
|
|
m->m_pkthdr.len = m->m_len = total_len;
|
2002-11-14 23:54:55 +00:00
|
|
|
m->m_pkthdr.rcvif = ifp;
|
|
|
|
|
2008-11-26 06:36:53 +00:00
|
|
|
/* Do IP checksum checking. */
|
|
|
|
if ((ifp->if_capenable & IFCAP_RXCSUM) != 0)
|
|
|
|
fxp_rxcsum(sc, ifp, m, status, total_len);
|
2008-12-02 02:30:12 +00:00
|
|
|
if ((ifp->if_capenable & IFCAP_VLAN_HWTAGGING) != 0 &&
|
|
|
|
(status & FXP_RFA_STATUS_VLAN) != 0) {
|
|
|
|
m->m_pkthdr.ether_vtag =
|
|
|
|
ntohs(rfa->rfax_vlan_id);
|
|
|
|
m->m_flags |= M_VLANTAG;
|
|
|
|
}
|
2003-06-23 23:23:49 +00:00
|
|
|
/*
|
|
|
|
* Drop locks before calling if_input() since it
|
|
|
|
* may re-enter fxp_start() in the netisr case.
|
|
|
|
* This would result in a lock reversal. Better
|
|
|
|
* performance might be obtained by chaining all
|
|
|
|
* packets received, dropping the lock, and then
|
|
|
|
* calling if_input() on each one.
|
|
|
|
*/
|
|
|
|
FXP_UNLOCK(sc);
|
2002-11-14 23:54:55 +00:00
|
|
|
(*ifp->if_input)(ifp, m);
|
2003-06-23 23:23:49 +00:00
|
|
|
FXP_LOCK(sc);
|
2009-05-30 15:14:44 +00:00
|
|
|
rx_npkts++;
|
2009-06-21 06:46:32 +00:00
|
|
|
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
|
|
|
|
return (rx_npkts);
|
2008-11-26 05:51:49 +00:00
|
|
|
} else {
|
|
|
|
/* Reuse RFA and loaded DMA map. */
|
|
|
|
ifp->if_iqdrops++;
|
|
|
|
fxp_discard_rfabuf(sc, rxp);
|
2002-07-29 02:48:09 +00:00
|
|
|
}
|
2008-11-26 05:51:49 +00:00
|
|
|
fxp_add_rfabuf(sc, rxp);
|
2002-08-04 22:33:28 +00:00
|
|
|
}
|
|
|
|
if (rnr) {
|
2002-11-07 16:04:07 +00:00
|
|
|
fxp_scb_wait(sc);
|
|
|
|
CSR_WRITE_4(sc, FXP_CSR_SCB_GENERAL,
|
2003-04-02 16:47:16 +00:00
|
|
|
sc->fxp_desc.rx_head->rx_addr);
|
2002-11-07 16:04:07 +00:00
|
|
|
fxp_scb_cmd(sc, FXP_SCB_COMMAND_RU_START);
|
2002-07-29 02:48:09 +00:00
|
|
|
}
|
2009-05-30 15:14:44 +00:00
|
|
|
return (rx_npkts);
|
1995-11-28 23:55:26 +00:00
|
|
|
}
|
|
|
|
|
2010-05-09 22:16:15 +00:00
|
|
|
static void
|
|
|
|
fxp_update_stats(struct fxp_softc *sc)
|
|
|
|
{
|
|
|
|
struct ifnet *ifp = sc->ifp;
|
|
|
|
struct fxp_stats *sp = sc->fxp_stats;
|
|
|
|
struct fxp_hwstats *hsp;
|
|
|
|
uint32_t *status;
|
|
|
|
|
|
|
|
FXP_LOCK_ASSERT(sc, MA_OWNED);
|
|
|
|
|
|
|
|
bus_dmamap_sync(sc->fxp_stag, sc->fxp_smap,
|
|
|
|
BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
|
|
|
|
/* Update statistical counters. */
|
|
|
|
if (sc->revision >= FXP_REV_82559_A0)
|
|
|
|
status = &sp->completion_status;
|
|
|
|
else if (sc->revision >= FXP_REV_82558_A4)
|
|
|
|
status = (uint32_t *)&sp->tx_tco;
|
|
|
|
else
|
|
|
|
status = &sp->tx_pause;
|
|
|
|
if (*status == htole32(FXP_STATS_DR_COMPLETE)) {
|
|
|
|
hsp = &sc->fxp_hwstats;
|
|
|
|
hsp->tx_good += le32toh(sp->tx_good);
|
|
|
|
hsp->tx_maxcols += le32toh(sp->tx_maxcols);
|
|
|
|
hsp->tx_latecols += le32toh(sp->tx_latecols);
|
|
|
|
hsp->tx_underruns += le32toh(sp->tx_underruns);
|
|
|
|
hsp->tx_lostcrs += le32toh(sp->tx_lostcrs);
|
|
|
|
hsp->tx_deffered += le32toh(sp->tx_deffered);
|
|
|
|
hsp->tx_single_collisions += le32toh(sp->tx_single_collisions);
|
|
|
|
hsp->tx_multiple_collisions +=
|
|
|
|
le32toh(sp->tx_multiple_collisions);
|
|
|
|
hsp->tx_total_collisions += le32toh(sp->tx_total_collisions);
|
|
|
|
hsp->rx_good += le32toh(sp->rx_good);
|
|
|
|
hsp->rx_crc_errors += le32toh(sp->rx_crc_errors);
|
|
|
|
hsp->rx_alignment_errors += le32toh(sp->rx_alignment_errors);
|
|
|
|
hsp->rx_rnr_errors += le32toh(sp->rx_rnr_errors);
|
|
|
|
hsp->rx_overrun_errors += le32toh(sp->rx_overrun_errors);
|
|
|
|
hsp->rx_cdt_errors += le32toh(sp->rx_cdt_errors);
|
|
|
|
hsp->rx_shortframes += le32toh(sp->rx_shortframes);
|
|
|
|
hsp->tx_pause += le32toh(sp->tx_pause);
|
|
|
|
hsp->rx_pause += le32toh(sp->rx_pause);
|
|
|
|
hsp->rx_controls += le32toh(sp->rx_controls);
|
|
|
|
hsp->tx_tco += le16toh(sp->tx_tco);
|
|
|
|
hsp->rx_tco += le16toh(sp->rx_tco);
|
|
|
|
|
|
|
|
ifp->if_opackets += le32toh(sp->tx_good);
|
|
|
|
ifp->if_collisions += le32toh(sp->tx_total_collisions);
|
|
|
|
if (sp->rx_good) {
|
|
|
|
ifp->if_ipackets += le32toh(sp->rx_good);
|
|
|
|
sc->rx_idle_secs = 0;
|
|
|
|
} else if (sc->flags & FXP_FLAG_RXBUG) {
|
|
|
|
/*
|
|
|
|
* Receiver's been idle for another second.
|
|
|
|
*/
|
|
|
|
sc->rx_idle_secs++;
|
|
|
|
}
|
2012-03-14 00:54:37 +00:00
|
|
|
ifp->if_ierrors +=
|
2010-05-09 22:16:15 +00:00
|
|
|
le32toh(sp->rx_crc_errors) +
|
|
|
|
le32toh(sp->rx_alignment_errors) +
|
|
|
|
le32toh(sp->rx_rnr_errors) +
|
|
|
|
le32toh(sp->rx_overrun_errors);
|
|
|
|
/*
|
|
|
|
* If any transmit underruns occured, bump up the transmit
|
|
|
|
* threshold by another 512 bytes (64 * 8).
|
|
|
|
*/
|
|
|
|
if (sp->tx_underruns) {
|
|
|
|
ifp->if_oerrors += le32toh(sp->tx_underruns);
|
|
|
|
if (tx_threshold < 192)
|
|
|
|
tx_threshold += 64;
|
|
|
|
}
|
|
|
|
*status = 0;
|
|
|
|
bus_dmamap_sync(sc->fxp_stag, sc->fxp_smap,
|
|
|
|
BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1995-12-01 22:41:56 +00:00
|
|
|
/*
|
|
|
|
* Update packet in/out/collision statistics. The i82557 doesn't
|
|
|
|
* allow you to access these counters without doing a fairly
|
|
|
|
* expensive DMA to get _all_ of the statistics it maintains, so
|
|
|
|
* we do this operation here only once per second. The statistics
|
|
|
|
* counters in the kernel are updated from the previous dump-stats
|
|
|
|
* DMA and then a new dump-stats DMA is started. The on-chip
|
|
|
|
* counters are zeroed when the DMA completes. If we can't start
|
|
|
|
* the DMA immediately, we don't wait - we just prepare to read
|
|
|
|
* them again next time.
|
|
|
|
*/
|
1998-02-09 06:11:36 +00:00
|
|
|
static void
|
2001-03-12 21:30:52 +00:00
|
|
|
fxp_tick(void *xsc)
|
1995-11-28 23:55:26 +00:00
|
|
|
{
|
2001-03-12 21:30:52 +00:00
|
|
|
struct fxp_softc *sc = xsc;
|
2005-06-10 16:49:24 +00:00
|
|
|
struct ifnet *ifp = sc->ifp;
|
1995-11-28 23:55:26 +00:00
|
|
|
|
2005-08-08 21:03:54 +00:00
|
|
|
FXP_LOCK_ASSERT(sc, MA_OWNED);
|
2010-05-09 22:16:15 +00:00
|
|
|
|
|
|
|
/* Update statistical counters. */
|
|
|
|
fxp_update_stats(sc);
|
Make fxp(4) INTR_MPSAFE (but do not enable MPSAFE just yet):
- Add fxp_start_body() and change fxp_start() to just acquire locks and
then call fxp_start_body(). Places that would call fxp_start() with
locks held (mutex recursion) now call fxp_start_body() directly.
Remove MTX_RECURSE flag from sc_mtx. [gallatin]
- Change fxp_attach() to work without the softc lock, saving interrupt
hooking until the head of fxp_attach().
- Call ether_ifattach() before overriding ifp parameters. This reverts
part of 1.155.
- Remove multiple error paths in fxp_attach().
- Teardown interrupt in fxp_detach() before unlocking the softc.
- Make sure mutex is not held in fxp_release()
- Delete the miibus instance and/or self in fxp_release(), not in
fxp_detach(). This can happen if attach fails partway through.
- Move ifmedia_removeall to fxp_release() since attach may fail after
media have been allocated.
- Add locking to fxp_suspend, fxp_resume, fxp_start, fxp_intr,
fxp_poll, fxp_tick, fxp_ioctl, fxp_watchdog.
- Pass in ifp to fxp_intr_body since its callers sometimes already use
it.
- Add compatibility define for INTR_MPSAFE for 4.x. [gallatin]
- You don't need to bzero softc.
Ideas from: gallatin, mux
Tested by: >400M packets of dd/ssh, NFS, ping on i386 UP
2003-04-25 09:01:54 +00:00
|
|
|
|
1998-10-22 02:00:49 +00:00
|
|
|
/*
|
|
|
|
* Release any xmit buffers that have completed DMA. This isn't
|
|
|
|
* strictly necessary to do here, but it's advantagous for mbufs
|
|
|
|
* with external storage to be released in a timely manner rather
|
|
|
|
* than being defered for a potentially long time. This limits
|
|
|
|
* the delay to a maximum of one second.
|
2008-11-25 00:48:05 +00:00
|
|
|
*/
|
2003-04-02 16:47:16 +00:00
|
|
|
fxp_txeof(sc);
|
|
|
|
|
1997-09-29 11:27:43 +00:00
|
|
|
/*
|
|
|
|
* If we haven't received any packets in FXP_MAC_RX_IDLE seconds,
|
|
|
|
* then assume the receiver has locked up and attempt to clear
|
|
|
|
* the condition by reprogramming the multicast filter. This is
|
|
|
|
* a work-around for a bug in the 82557 where the receiver locks
|
|
|
|
* up if it gets certain types of garbage in the syncronization
|
|
|
|
* bits prior to the packet header. This bug is supposed to only
|
|
|
|
* occur in 10Mbps mode, but has been seen to occur in 100Mbps
|
|
|
|
* mode as well (perhaps due to a 10/100 speed transition).
|
|
|
|
*/
|
|
|
|
if (sc->rx_idle_secs > FXP_MAX_RX_IDLE) {
|
|
|
|
sc->rx_idle_secs = 0;
|
2013-06-10 07:31:49 +00:00
|
|
|
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) {
|
|
|
|
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
|
2010-11-26 21:52:33 +00:00
|
|
|
fxp_init_body(sc, 1);
|
2013-06-10 07:31:49 +00:00
|
|
|
}
|
2009-06-21 07:17:49 +00:00
|
|
|
return;
|
1997-09-29 11:27:43 +00:00
|
|
|
}
|
1995-11-28 23:55:26 +00:00
|
|
|
/*
|
1996-01-03 05:22:32 +00:00
|
|
|
* If there is no pending command, start another stats
|
|
|
|
* dump. Otherwise punt for now.
|
1995-11-28 23:55:26 +00:00
|
|
|
*/
|
1997-09-29 11:27:43 +00:00
|
|
|
if (CSR_READ_1(sc, FXP_CSR_SCB_COMMAND) == 0) {
|
1995-12-01 22:41:56 +00:00
|
|
|
/*
|
1997-09-29 11:27:43 +00:00
|
|
|
* Start another stats dump.
|
1995-12-01 22:41:56 +00:00
|
|
|
*/
|
2001-05-17 23:50:24 +00:00
|
|
|
fxp_scb_cmd(sc, FXP_SCB_COMMAND_CU_DUMPRESET);
|
1995-11-28 23:55:26 +00:00
|
|
|
}
|
2001-03-12 21:30:52 +00:00
|
|
|
if (sc->miibus != NULL)
|
|
|
|
mii_tick(device_get_softc(sc->miibus));
|
Make fxp(4) INTR_MPSAFE (but do not enable MPSAFE just yet):
- Add fxp_start_body() and change fxp_start() to just acquire locks and
then call fxp_start_body(). Places that would call fxp_start() with
locks held (mutex recursion) now call fxp_start_body() directly.
Remove MTX_RECURSE flag from sc_mtx. [gallatin]
- Change fxp_attach() to work without the softc lock, saving interrupt
hooking until the head of fxp_attach().
- Call ether_ifattach() before overriding ifp parameters. This reverts
part of 1.155.
- Remove multiple error paths in fxp_attach().
- Teardown interrupt in fxp_detach() before unlocking the softc.
- Make sure mutex is not held in fxp_release()
- Delete the miibus instance and/or self in fxp_release(), not in
fxp_detach(). This can happen if attach fails partway through.
- Move ifmedia_removeall to fxp_release() since attach may fail after
media have been allocated.
- Add locking to fxp_suspend, fxp_resume, fxp_start, fxp_intr,
fxp_poll, fxp_tick, fxp_ioctl, fxp_watchdog.
- Pass in ifp to fxp_intr_body since its callers sometimes already use
it.
- Add compatibility define for INTR_MPSAFE for 4.x. [gallatin]
- You don't need to bzero softc.
Ideas from: gallatin, mux
Tested by: >400M packets of dd/ssh, NFS, ping on i386 UP
2003-04-25 09:01:54 +00:00
|
|
|
|
2006-11-30 14:58:01 +00:00
|
|
|
/*
|
2006-12-01 13:07:52 +00:00
|
|
|
* Check that chip hasn't hung.
|
2006-11-30 14:58:01 +00:00
|
|
|
*/
|
|
|
|
fxp_watchdog(sc);
|
|
|
|
|
1995-11-28 23:55:26 +00:00
|
|
|
/*
|
|
|
|
* Schedule another timeout one second from now.
|
|
|
|
*/
|
2003-09-05 22:37:31 +00:00
|
|
|
callout_reset(&sc->stat_ch, hz, fxp_tick, sc);
|
1995-11-28 23:55:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Stop the interface. Cancels the statistics updater and resets
|
|
|
|
* the interface.
|
|
|
|
*/
|
|
|
|
static void
|
2001-03-12 21:30:52 +00:00
|
|
|
fxp_stop(struct fxp_softc *sc)
|
1995-11-28 23:55:26 +00:00
|
|
|
{
|
2005-06-10 16:49:24 +00:00
|
|
|
struct ifnet *ifp = sc->ifp;
|
2003-04-02 16:47:16 +00:00
|
|
|
struct fxp_tx *txp;
|
1996-01-03 05:22:32 +00:00
|
|
|
int i;
|
1995-11-28 23:55:26 +00:00
|
|
|
|
2005-08-09 10:20:02 +00:00
|
|
|
ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE);
|
2006-11-30 14:58:01 +00:00
|
|
|
sc->watchdog_timer = 0;
|
2000-09-17 22:12:12 +00:00
|
|
|
|
1995-11-28 23:55:26 +00:00
|
|
|
/*
|
|
|
|
* Cancel stats updater.
|
|
|
|
*/
|
2003-09-05 22:37:31 +00:00
|
|
|
callout_stop(&sc->stat_ch);
|
1996-01-03 05:22:32 +00:00
|
|
|
|
|
|
|
/*
|
2008-11-27 01:57:23 +00:00
|
|
|
* Preserve PCI configuration, configure, IA/multicast
|
|
|
|
* setup and put RU and CU into idle state.
|
1996-01-03 05:22:32 +00:00
|
|
|
*/
|
2008-11-27 01:57:23 +00:00
|
|
|
CSR_WRITE_4(sc, FXP_CSR_PORT, FXP_PORT_SELECTIVE_RESET);
|
2001-10-25 05:32:01 +00:00
|
|
|
DELAY(50);
|
2008-11-27 01:57:23 +00:00
|
|
|
/* Disable interrupts. */
|
|
|
|
CSR_WRITE_1(sc, FXP_CSR_SCB_INTRCNTL, FXP_SCB_INTR_DISABLE);
|
1995-11-28 23:55:26 +00:00
|
|
|
|
2010-05-09 22:16:15 +00:00
|
|
|
fxp_update_stats(sc);
|
|
|
|
|
1996-01-03 05:22:32 +00:00
|
|
|
/*
|
|
|
|
* Release any xmit buffers.
|
|
|
|
*/
|
2003-04-02 16:47:16 +00:00
|
|
|
txp = sc->fxp_desc.tx_list;
|
1998-10-10 19:26:40 +00:00
|
|
|
if (txp != NULL) {
|
|
|
|
for (i = 0; i < FXP_NTXCB; i++) {
|
2012-03-14 00:54:37 +00:00
|
|
|
if (txp[i].tx_mbuf != NULL) {
|
2009-06-21 06:06:43 +00:00
|
|
|
bus_dmamap_sync(sc->fxp_txmtag, txp[i].tx_map,
|
2003-04-02 16:47:16 +00:00
|
|
|
BUS_DMASYNC_POSTWRITE);
|
2009-06-21 06:06:43 +00:00
|
|
|
bus_dmamap_unload(sc->fxp_txmtag,
|
|
|
|
txp[i].tx_map);
|
2003-04-02 16:47:16 +00:00
|
|
|
m_freem(txp[i].tx_mbuf);
|
|
|
|
txp[i].tx_mbuf = NULL;
|
2003-02-26 22:12:04 +00:00
|
|
|
/* clear this to reset csum offload bits */
|
2003-04-02 16:47:16 +00:00
|
|
|
txp[i].tx_cb->tbd[0].tb_addr = 0;
|
1998-10-10 19:26:40 +00:00
|
|
|
}
|
|
|
|
}
|
1996-01-03 05:22:32 +00:00
|
|
|
}
|
2009-06-21 06:06:43 +00:00
|
|
|
bus_dmamap_sync(sc->cbl_tag, sc->cbl_map,
|
|
|
|
BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
|
1996-01-03 05:22:32 +00:00
|
|
|
sc->tx_queued = 0;
|
1995-11-28 23:55:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Watchdog/transmission transmit timeout handler. Called when a
|
|
|
|
* transmission is started on the interface, but no interrupt is
|
|
|
|
* received before the timeout. This usually indicates that the
|
|
|
|
* card has wedged for some reason.
|
|
|
|
*/
|
|
|
|
static void
|
2006-11-30 14:58:01 +00:00
|
|
|
fxp_watchdog(struct fxp_softc *sc)
|
1995-11-28 23:55:26 +00:00
|
|
|
{
|
1997-09-05 10:23:58 +00:00
|
|
|
|
2006-11-30 14:58:01 +00:00
|
|
|
FXP_LOCK_ASSERT(sc, MA_OWNED);
|
|
|
|
|
|
|
|
if (sc->watchdog_timer == 0 || --sc->watchdog_timer)
|
|
|
|
return;
|
|
|
|
|
2001-03-12 21:30:52 +00:00
|
|
|
device_printf(sc->dev, "device timeout\n");
|
2006-11-30 14:58:01 +00:00
|
|
|
sc->ifp->if_oerrors++;
|
1995-11-28 23:55:26 +00:00
|
|
|
|
2013-06-10 07:31:49 +00:00
|
|
|
sc->ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
|
2010-11-26 21:52:33 +00:00
|
|
|
fxp_init_body(sc, 1);
|
1995-11-28 23:55:26 +00:00
|
|
|
}
|
|
|
|
|
Make fxp(4) INTR_MPSAFE (but do not enable MPSAFE just yet):
- Add fxp_start_body() and change fxp_start() to just acquire locks and
then call fxp_start_body(). Places that would call fxp_start() with
locks held (mutex recursion) now call fxp_start_body() directly.
Remove MTX_RECURSE flag from sc_mtx. [gallatin]
- Change fxp_attach() to work without the softc lock, saving interrupt
hooking until the head of fxp_attach().
- Call ether_ifattach() before overriding ifp parameters. This reverts
part of 1.155.
- Remove multiple error paths in fxp_attach().
- Teardown interrupt in fxp_detach() before unlocking the softc.
- Make sure mutex is not held in fxp_release()
- Delete the miibus instance and/or self in fxp_release(), not in
fxp_detach(). This can happen if attach fails partway through.
- Move ifmedia_removeall to fxp_release() since attach may fail after
media have been allocated.
- Add locking to fxp_suspend, fxp_resume, fxp_start, fxp_intr,
fxp_poll, fxp_tick, fxp_ioctl, fxp_watchdog.
- Pass in ifp to fxp_intr_body since its callers sometimes already use
it.
- Add compatibility define for INTR_MPSAFE for 4.x. [gallatin]
- You don't need to bzero softc.
Ideas from: gallatin, mux
Tested by: >400M packets of dd/ssh, NFS, ping on i386 UP
2003-04-25 09:01:54 +00:00
|
|
|
/*
|
|
|
|
* Acquire locks and then call the real initialization function. This
|
|
|
|
* is necessary because ether_ioctl() calls if_init() and this would
|
|
|
|
* result in mutex recursion if the mutex was held.
|
|
|
|
*/
|
1995-11-28 23:55:26 +00:00
|
|
|
static void
|
2001-03-12 21:30:52 +00:00
|
|
|
fxp_init(void *xsc)
|
1995-11-28 23:55:26 +00:00
|
|
|
{
|
1996-12-10 07:29:50 +00:00
|
|
|
struct fxp_softc *sc = xsc;
|
Make fxp(4) INTR_MPSAFE (but do not enable MPSAFE just yet):
- Add fxp_start_body() and change fxp_start() to just acquire locks and
then call fxp_start_body(). Places that would call fxp_start() with
locks held (mutex recursion) now call fxp_start_body() directly.
Remove MTX_RECURSE flag from sc_mtx. [gallatin]
- Change fxp_attach() to work without the softc lock, saving interrupt
hooking until the head of fxp_attach().
- Call ether_ifattach() before overriding ifp parameters. This reverts
part of 1.155.
- Remove multiple error paths in fxp_attach().
- Teardown interrupt in fxp_detach() before unlocking the softc.
- Make sure mutex is not held in fxp_release()
- Delete the miibus instance and/or self in fxp_release(), not in
fxp_detach(). This can happen if attach fails partway through.
- Move ifmedia_removeall to fxp_release() since attach may fail after
media have been allocated.
- Add locking to fxp_suspend, fxp_resume, fxp_start, fxp_intr,
fxp_poll, fxp_tick, fxp_ioctl, fxp_watchdog.
- Pass in ifp to fxp_intr_body since its callers sometimes already use
it.
- Add compatibility define for INTR_MPSAFE for 4.x. [gallatin]
- You don't need to bzero softc.
Ideas from: gallatin, mux
Tested by: >400M packets of dd/ssh, NFS, ping on i386 UP
2003-04-25 09:01:54 +00:00
|
|
|
|
|
|
|
FXP_LOCK(sc);
|
2010-11-26 21:52:33 +00:00
|
|
|
fxp_init_body(sc, 1);
|
Make fxp(4) INTR_MPSAFE (but do not enable MPSAFE just yet):
- Add fxp_start_body() and change fxp_start() to just acquire locks and
then call fxp_start_body(). Places that would call fxp_start() with
locks held (mutex recursion) now call fxp_start_body() directly.
Remove MTX_RECURSE flag from sc_mtx. [gallatin]
- Change fxp_attach() to work without the softc lock, saving interrupt
hooking until the head of fxp_attach().
- Call ether_ifattach() before overriding ifp parameters. This reverts
part of 1.155.
- Remove multiple error paths in fxp_attach().
- Teardown interrupt in fxp_detach() before unlocking the softc.
- Make sure mutex is not held in fxp_release()
- Delete the miibus instance and/or self in fxp_release(), not in
fxp_detach(). This can happen if attach fails partway through.
- Move ifmedia_removeall to fxp_release() since attach may fail after
media have been allocated.
- Add locking to fxp_suspend, fxp_resume, fxp_start, fxp_intr,
fxp_poll, fxp_tick, fxp_ioctl, fxp_watchdog.
- Pass in ifp to fxp_intr_body since its callers sometimes already use
it.
- Add compatibility define for INTR_MPSAFE for 4.x. [gallatin]
- You don't need to bzero softc.
Ideas from: gallatin, mux
Tested by: >400M packets of dd/ssh, NFS, ping on i386 UP
2003-04-25 09:01:54 +00:00
|
|
|
FXP_UNLOCK(sc);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Perform device initialization. This routine must be called with the
|
|
|
|
* softc lock held.
|
|
|
|
*/
|
|
|
|
static void
|
2010-11-26 21:52:33 +00:00
|
|
|
fxp_init_body(struct fxp_softc *sc, int setmedia)
|
Make fxp(4) INTR_MPSAFE (but do not enable MPSAFE just yet):
- Add fxp_start_body() and change fxp_start() to just acquire locks and
then call fxp_start_body(). Places that would call fxp_start() with
locks held (mutex recursion) now call fxp_start_body() directly.
Remove MTX_RECURSE flag from sc_mtx. [gallatin]
- Change fxp_attach() to work without the softc lock, saving interrupt
hooking until the head of fxp_attach().
- Call ether_ifattach() before overriding ifp parameters. This reverts
part of 1.155.
- Remove multiple error paths in fxp_attach().
- Teardown interrupt in fxp_detach() before unlocking the softc.
- Make sure mutex is not held in fxp_release()
- Delete the miibus instance and/or self in fxp_release(), not in
fxp_detach(). This can happen if attach fails partway through.
- Move ifmedia_removeall to fxp_release() since attach may fail after
media have been allocated.
- Add locking to fxp_suspend, fxp_resume, fxp_start, fxp_intr,
fxp_poll, fxp_tick, fxp_ioctl, fxp_watchdog.
- Pass in ifp to fxp_intr_body since its callers sometimes already use
it.
- Add compatibility define for INTR_MPSAFE for 4.x. [gallatin]
- You don't need to bzero softc.
Ideas from: gallatin, mux
Tested by: >400M packets of dd/ssh, NFS, ping on i386 UP
2003-04-25 09:01:54 +00:00
|
|
|
{
|
2005-06-10 16:49:24 +00:00
|
|
|
struct ifnet *ifp = sc->ifp;
|
2010-11-26 21:52:33 +00:00
|
|
|
struct mii_data *mii;
|
1995-11-28 23:55:26 +00:00
|
|
|
struct fxp_cb_config *cbp;
|
|
|
|
struct fxp_cb_ias *cb_ias;
|
2003-04-02 16:47:16 +00:00
|
|
|
struct fxp_cb_tx *tcbp;
|
|
|
|
struct fxp_tx *txp;
|
2005-08-08 21:03:54 +00:00
|
|
|
int i, prm;
|
1995-11-28 23:55:26 +00:00
|
|
|
|
2004-06-02 22:59:57 +00:00
|
|
|
FXP_LOCK_ASSERT(sc, MA_OWNED);
|
2013-06-10 07:31:49 +00:00
|
|
|
|
|
|
|
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0)
|
|
|
|
return;
|
|
|
|
|
1995-11-28 23:55:26 +00:00
|
|
|
/*
|
1996-01-03 05:22:32 +00:00
|
|
|
* Cancel any pending I/O
|
1995-11-28 23:55:26 +00:00
|
|
|
*/
|
1996-01-03 05:22:32 +00:00
|
|
|
fxp_stop(sc);
|
1995-11-28 23:55:26 +00:00
|
|
|
|
2008-11-27 01:57:23 +00:00
|
|
|
/*
|
|
|
|
* Issue software reset, which also unloads the microcode.
|
|
|
|
*/
|
|
|
|
sc->flags &= ~FXP_FLAG_UCODE;
|
|
|
|
CSR_WRITE_4(sc, FXP_CSR_PORT, FXP_PORT_SOFTWARE_RESET);
|
|
|
|
DELAY(50);
|
|
|
|
|
1995-11-28 23:55:26 +00:00
|
|
|
prm = (ifp->if_flags & IFF_PROMISC) ? 1 : 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize base of CBL and RFA memory. Loading with zero
|
|
|
|
* sets it up for regular linear addressing.
|
|
|
|
*/
|
1997-09-05 10:23:58 +00:00
|
|
|
CSR_WRITE_4(sc, FXP_CSR_SCB_GENERAL, 0);
|
2001-05-17 23:50:24 +00:00
|
|
|
fxp_scb_cmd(sc, FXP_SCB_COMMAND_CU_BASE);
|
1995-11-28 23:55:26 +00:00
|
|
|
|
1997-09-05 10:23:58 +00:00
|
|
|
fxp_scb_wait(sc);
|
2001-05-17 23:50:24 +00:00
|
|
|
fxp_scb_cmd(sc, FXP_SCB_COMMAND_RU_BASE);
|
1995-11-28 23:55:26 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize base of dump-stats buffer.
|
|
|
|
*/
|
1997-09-05 10:23:58 +00:00
|
|
|
fxp_scb_wait(sc);
|
2010-05-09 22:16:15 +00:00
|
|
|
bzero(sc->fxp_stats, sizeof(struct fxp_stats));
|
|
|
|
bus_dmamap_sync(sc->fxp_stag, sc->fxp_smap,
|
|
|
|
BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
|
2003-04-02 16:47:16 +00:00
|
|
|
CSR_WRITE_4(sc, FXP_CSR_SCB_GENERAL, sc->stats_addr);
|
2001-05-17 23:50:24 +00:00
|
|
|
fxp_scb_cmd(sc, FXP_SCB_COMMAND_CU_DUMP_ADR);
|
1995-11-28 23:55:26 +00:00
|
|
|
|
2001-10-25 05:32:01 +00:00
|
|
|
/*
|
|
|
|
* Attempt to load microcode if requested.
|
2009-06-21 07:34:12 +00:00
|
|
|
* For ICH based controllers do not load microcode.
|
2001-10-25 05:32:01 +00:00
|
|
|
*/
|
2009-06-21 07:34:12 +00:00
|
|
|
if (sc->ident->ich == 0) {
|
|
|
|
if (ifp->if_flags & IFF_LINK0 &&
|
|
|
|
(sc->flags & FXP_FLAG_UCODE) == 0)
|
|
|
|
fxp_load_ucode(sc);
|
|
|
|
}
|
2001-10-25 05:32:01 +00:00
|
|
|
|
2002-01-07 15:08:54 +00:00
|
|
|
/*
|
2009-06-21 07:17:49 +00:00
|
|
|
* Set IFF_ALLMULTI status. It's needed in configure action
|
|
|
|
* command.
|
2002-01-07 15:08:54 +00:00
|
|
|
*/
|
2009-06-21 07:17:49 +00:00
|
|
|
fxp_mc_addrs(sc);
|
2002-01-07 15:08:54 +00:00
|
|
|
|
1995-11-28 23:55:26 +00:00
|
|
|
/*
|
|
|
|
* We temporarily use memory that contains the TxCB list to
|
|
|
|
* construct the config CB. The TxCB list memory is rebuilt
|
|
|
|
* later.
|
|
|
|
*/
|
2003-04-02 16:47:16 +00:00
|
|
|
cbp = (struct fxp_cb_config *)sc->fxp_desc.cbl_list;
|
1995-11-28 23:55:26 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* This bcopy is kind of disgusting, but there are a bunch of must be
|
|
|
|
* zero and must be one bits in this structure and this is the easiest
|
|
|
|
* way to initialize them all to proper values.
|
|
|
|
*/
|
2003-04-02 16:47:16 +00:00
|
|
|
bcopy(fxp_cb_config_template, cbp, sizeof(fxp_cb_config_template));
|
1995-11-28 23:55:26 +00:00
|
|
|
|
|
|
|
cbp->cb_status = 0;
|
2003-04-06 01:04:17 +00:00
|
|
|
cbp->cb_command = htole16(FXP_CB_COMMAND_CONFIG |
|
|
|
|
FXP_CB_COMMAND_EL);
|
|
|
|
cbp->link_addr = 0xffffffff; /* (no) next command */
|
2003-04-07 14:53:30 +00:00
|
|
|
cbp->byte_count = sc->flags & FXP_FLAG_EXT_RFA ? 32 : 22;
|
1997-02-04 11:44:15 +00:00
|
|
|
cbp->rx_fifo_limit = 8; /* rx fifo threshold (32 bytes) */
|
|
|
|
cbp->tx_fifo_limit = 0; /* tx fifo threshold (0 bytes) */
|
1995-11-28 23:55:26 +00:00
|
|
|
cbp->adaptive_ifs = 0; /* (no) adaptive interframe spacing */
|
2001-03-12 21:30:52 +00:00
|
|
|
cbp->mwi_enable = sc->flags & FXP_FLAG_MWI_ENABLE ? 1 : 0;
|
|
|
|
cbp->type_enable = 0; /* actually reserved */
|
|
|
|
cbp->read_align_en = sc->flags & FXP_FLAG_READ_ALIGN ? 1 : 0;
|
|
|
|
cbp->end_wr_on_cl = sc->flags & FXP_FLAG_WRITE_ALIGN ? 1 : 0;
|
1997-02-04 11:44:15 +00:00
|
|
|
cbp->rx_dma_bytecount = 0; /* (no) rx DMA max */
|
|
|
|
cbp->tx_dma_bytecount = 0; /* (no) tx DMA max */
|
2001-03-12 21:30:52 +00:00
|
|
|
cbp->dma_mbce = 0; /* (disable) dma max counters */
|
1995-11-28 23:55:26 +00:00
|
|
|
cbp->late_scb = 0; /* (don't) defer SCB update */
|
2001-03-12 21:30:52 +00:00
|
|
|
cbp->direct_dma_dis = 1; /* disable direct rcv dma mode */
|
|
|
|
cbp->tno_int_or_tco_en =0; /* (disable) tx not okay interrupt */
|
1998-08-04 08:53:12 +00:00
|
|
|
cbp->ci_int = 1; /* interrupt on CU idle */
|
2001-03-12 21:30:52 +00:00
|
|
|
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 */
|
2004-05-25 14:49:46 +00:00
|
|
|
cbp->save_bf = sc->flags & FXP_FLAG_SAVE_BAD ? 1 : prm;
|
1995-11-28 23:55:26 +00:00
|
|
|
cbp->disc_short_rx = !prm; /* discard short packets */
|
2001-03-12 21:30:52 +00:00
|
|
|
cbp->underrun_retry = 1; /* retry mode (once) on DMA underrun */
|
|
|
|
cbp->two_frames = 0; /* do not limit FIFO to 2 frames */
|
2008-11-26 07:36:17 +00:00
|
|
|
cbp->dyn_tbd = sc->flags & FXP_FLAG_EXT_RFA ? 1 : 0;
|
2003-02-26 22:12:04 +00:00
|
|
|
cbp->ext_rfa = sc->flags & FXP_FLAG_EXT_RFA ? 1 : 0;
|
2001-03-12 21:30:52 +00:00
|
|
|
cbp->mediatype = sc->flags & FXP_FLAG_SERIAL_MEDIA ? 0 : 1;
|
|
|
|
cbp->csma_dis = 0; /* (don't) disable link */
|
2008-11-26 06:36:53 +00:00
|
|
|
cbp->tcp_udp_cksum = ((sc->flags & FXP_FLAG_82559_RXCSUM) != 0 &&
|
|
|
|
(ifp->if_capenable & IFCAP_RXCSUM) != 0) ? 1 : 0;
|
2001-03-12 21:30:52 +00:00
|
|
|
cbp->vlan_tco = 0; /* (don't) enable vlan wakeup */
|
|
|
|
cbp->link_wake_en = 0; /* (don't) assert PME# on link change */
|
|
|
|
cbp->arp_wake_en = 0; /* (don't) assert PME# on arp */
|
|
|
|
cbp->mc_wake_en = 0; /* (don't) enable PME# on mcmatch */
|
1995-11-28 23:55:26 +00:00
|
|
|
cbp->nsai = 1; /* (don't) disable source addr insert */
|
|
|
|
cbp->preamble_length = 2; /* (7 byte) preamble */
|
|
|
|
cbp->loopback = 0; /* (don't) loopback */
|
|
|
|
cbp->linear_priority = 0; /* (normal CSMA/CD operation) */
|
|
|
|
cbp->linear_pri_mode = 0; /* (wait after xmit only) */
|
|
|
|
cbp->interfrm_spacing = 6; /* (96 bits of) interframe spacing */
|
|
|
|
cbp->promiscuous = prm; /* promiscuous mode */
|
|
|
|
cbp->bcast_disable = 0; /* (don't) disable broadcasts */
|
2001-03-12 21:30:52 +00:00
|
|
|
cbp->wait_after_win = 0; /* (don't) enable modified backoff alg*/
|
|
|
|
cbp->ignore_ul = 0; /* consider U/L bit in IA matching */
|
|
|
|
cbp->crc16_en = 0; /* (don't) enable crc-16 algorithm */
|
|
|
|
cbp->crscdt = sc->flags & FXP_FLAG_SERIAL_MEDIA ? 1 : 0;
|
|
|
|
|
1995-11-28 23:55:26 +00:00
|
|
|
cbp->stripping = !prm; /* truncate rx packet to byte count */
|
|
|
|
cbp->padding = 1; /* (do) pad short tx packets */
|
|
|
|
cbp->rcv_crc_xfer = 0; /* (don't) xfer CRC to host */
|
2001-03-12 21:30:52 +00:00
|
|
|
cbp->long_rx_en = sc->flags & FXP_FLAG_LONG_PKT_EN ? 1 : 0;
|
|
|
|
cbp->ia_wake_en = 0; /* (don't) wake up on address match */
|
2008-11-27 01:57:23 +00:00
|
|
|
cbp->magic_pkt_dis = sc->flags & FXP_FLAG_WOL ? 0 : 1;
|
1995-11-28 23:55:26 +00:00
|
|
|
cbp->force_fdx = 0; /* (don't) force full duplex */
|
1996-01-03 05:22:32 +00:00
|
|
|
cbp->fdx_pin_en = 1; /* (enable) FDX# pin */
|
1995-11-28 23:55:26 +00:00
|
|
|
cbp->multi_ia = 0; /* (don't) accept multiple IAs */
|
2010-05-07 16:43:00 +00:00
|
|
|
cbp->mc_all = ifp->if_flags & IFF_ALLMULTI ? 1 : prm;
|
2003-02-26 22:12:04 +00:00
|
|
|
cbp->gamla_rx = sc->flags & FXP_FLAG_EXT_RFA ? 1 : 0;
|
2008-12-02 02:30:12 +00:00
|
|
|
cbp->vlan_strip_en = ((sc->flags & FXP_FLAG_EXT_RFA) != 0 &&
|
|
|
|
(ifp->if_capenable & IFCAP_VLAN_HWTAGGING) != 0) ? 1 : 0;
|
1995-11-28 23:55:26 +00:00
|
|
|
|
2010-11-26 21:52:33 +00:00
|
|
|
if (sc->revision == FXP_REV_82557) {
|
2001-03-14 19:50:35 +00:00
|
|
|
/*
|
|
|
|
* The 82557 has no hardware flow control, the values
|
|
|
|
* below are the defaults for the chip.
|
|
|
|
*/
|
|
|
|
cbp->fc_delay_lsb = 0;
|
|
|
|
cbp->fc_delay_msb = 0x40;
|
|
|
|
cbp->pri_fc_thresh = 3;
|
|
|
|
cbp->tx_fc_dis = 0;
|
|
|
|
cbp->rx_fc_restop = 0;
|
|
|
|
cbp->rx_fc_restart = 0;
|
|
|
|
cbp->fc_filter = 0;
|
|
|
|
cbp->pri_fc_loc = 1;
|
|
|
|
} else {
|
2010-11-26 21:52:33 +00:00
|
|
|
/* Set pause RX FIFO threshold to 1KB. */
|
|
|
|
CSR_WRITE_1(sc, FXP_CSR_FC_THRESH, 1);
|
|
|
|
/* Set pause time. */
|
|
|
|
cbp->fc_delay_lsb = 0xff;
|
|
|
|
cbp->fc_delay_msb = 0xff;
|
2001-03-14 19:50:35 +00:00
|
|
|
cbp->pri_fc_thresh = 3;
|
2010-11-26 21:52:33 +00:00
|
|
|
mii = device_get_softc(sc->miibus);
|
|
|
|
if ((IFM_OPTIONS(mii->mii_media_active) &
|
|
|
|
IFM_ETH_TXPAUSE) != 0)
|
|
|
|
/* enable transmit FC */
|
|
|
|
cbp->tx_fc_dis = 0;
|
|
|
|
else
|
|
|
|
/* disable transmit FC */
|
|
|
|
cbp->tx_fc_dis = 1;
|
|
|
|
if ((IFM_OPTIONS(mii->mii_media_active) &
|
|
|
|
IFM_ETH_RXPAUSE) != 0) {
|
|
|
|
/* enable FC restart/restop frames */
|
|
|
|
cbp->rx_fc_restart = 1;
|
|
|
|
cbp->rx_fc_restop = 1;
|
|
|
|
} else {
|
|
|
|
/* disable FC restart/restop frames */
|
|
|
|
cbp->rx_fc_restart = 0;
|
|
|
|
cbp->rx_fc_restop = 0;
|
|
|
|
}
|
2001-03-14 19:50:35 +00:00
|
|
|
cbp->fc_filter = !prm; /* drop FC frames to host */
|
|
|
|
cbp->pri_fc_loc = 1; /* FC pri location (byte31) */
|
|
|
|
}
|
|
|
|
|
2010-05-09 22:16:15 +00:00
|
|
|
/* Enable 82558 and 82559 extended statistics functionality. */
|
|
|
|
if (sc->revision >= FXP_REV_82558_A4) {
|
|
|
|
if (sc->revision >= FXP_REV_82559_A0) {
|
|
|
|
/*
|
|
|
|
* Extend configuration table size to 32
|
|
|
|
* to include TCO configuration.
|
|
|
|
*/
|
|
|
|
cbp->byte_count = 32;
|
|
|
|
cbp->ext_stats_dis = 1;
|
|
|
|
/* Enable TCO stats. */
|
|
|
|
cbp->tno_int_or_tco_en = 1;
|
|
|
|
cbp->gamla_rx = 1;
|
|
|
|
} else
|
|
|
|
cbp->ext_stats_dis = 0;
|
|
|
|
}
|
|
|
|
|
1995-11-28 23:55:26 +00:00
|
|
|
/*
|
|
|
|
* Start the config command/DMA.
|
|
|
|
*/
|
1997-09-05 10:23:58 +00:00
|
|
|
fxp_scb_wait(sc);
|
2009-06-10 01:15:30 +00:00
|
|
|
bus_dmamap_sync(sc->cbl_tag, sc->cbl_map,
|
|
|
|
BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
|
2003-04-02 16:47:16 +00:00
|
|
|
CSR_WRITE_4(sc, FXP_CSR_SCB_GENERAL, sc->fxp_desc.cbl_addr);
|
2001-05-17 23:50:24 +00:00
|
|
|
fxp_scb_cmd(sc, FXP_SCB_COMMAND_CU_START);
|
1995-11-28 23:55:26 +00:00
|
|
|
/* ...and wait for it to complete. */
|
2003-04-08 18:56:45 +00:00
|
|
|
fxp_dma_wait(sc, &cbp->cb_status, sc->cbl_tag, sc->cbl_map);
|
1995-11-28 23:55:26 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Now initialize the station address. Temporarily use the TxCB
|
|
|
|
* memory area like we did above for the config CB.
|
|
|
|
*/
|
2003-04-02 16:47:16 +00:00
|
|
|
cb_ias = (struct fxp_cb_ias *)sc->fxp_desc.cbl_list;
|
1995-11-28 23:55:26 +00:00
|
|
|
cb_ias->cb_status = 0;
|
2003-04-06 01:04:17 +00:00
|
|
|
cb_ias->cb_command = htole16(FXP_CB_COMMAND_IAS | FXP_CB_COMMAND_EL);
|
|
|
|
cb_ias->link_addr = 0xffffffff;
|
2005-11-11 16:04:59 +00:00
|
|
|
bcopy(IF_LLADDR(sc->ifp), cb_ias->macaddr, ETHER_ADDR_LEN);
|
1995-11-28 23:55:26 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Start the IAS (Individual Address Setup) command/DMA.
|
|
|
|
*/
|
1997-09-05 10:23:58 +00:00
|
|
|
fxp_scb_wait(sc);
|
2009-06-10 01:15:30 +00:00
|
|
|
bus_dmamap_sync(sc->cbl_tag, sc->cbl_map,
|
|
|
|
BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
|
2009-06-21 07:17:49 +00:00
|
|
|
CSR_WRITE_4(sc, FXP_CSR_SCB_GENERAL, sc->fxp_desc.cbl_addr);
|
2001-05-17 23:50:24 +00:00
|
|
|
fxp_scb_cmd(sc, FXP_SCB_COMMAND_CU_START);
|
1995-11-28 23:55:26 +00:00
|
|
|
/* ...and wait for it to complete. */
|
2003-04-08 18:56:45 +00:00
|
|
|
fxp_dma_wait(sc, &cb_ias->cb_status, sc->cbl_tag, sc->cbl_map);
|
1995-11-28 23:55:26 +00:00
|
|
|
|
2009-06-21 07:17:49 +00:00
|
|
|
/*
|
|
|
|
* Initialize the multicast address list.
|
|
|
|
*/
|
|
|
|
fxp_mc_setup(sc);
|
|
|
|
|
1995-11-28 23:55:26 +00:00
|
|
|
/*
|
|
|
|
* Initialize transmit control block (TxCB) list.
|
|
|
|
*/
|
2003-04-02 16:47:16 +00:00
|
|
|
txp = sc->fxp_desc.tx_list;
|
|
|
|
tcbp = sc->fxp_desc.cbl_list;
|
|
|
|
bzero(tcbp, FXP_TXCB_SZ);
|
1995-11-28 23:55:26 +00:00
|
|
|
for (i = 0; i < FXP_NTXCB; i++) {
|
2003-04-02 16:47:16 +00:00
|
|
|
txp[i].tx_mbuf = NULL;
|
2003-04-06 01:04:17 +00:00
|
|
|
tcbp[i].cb_status = htole16(FXP_CB_STATUS_C | FXP_CB_STATUS_OK);
|
|
|
|
tcbp[i].cb_command = htole16(FXP_CB_COMMAND_NOP);
|
|
|
|
tcbp[i].link_addr = htole32(sc->fxp_desc.cbl_addr +
|
|
|
|
(((i + 1) & FXP_TXCB_MASK) * sizeof(struct fxp_cb_tx)));
|
2001-03-14 19:50:35 +00:00
|
|
|
if (sc->flags & FXP_FLAG_EXT_TXCB)
|
2003-04-02 16:47:16 +00:00
|
|
|
tcbp[i].tbd_array_addr =
|
2003-04-06 01:04:17 +00:00
|
|
|
htole32(FXP_TXCB_DMA_ADDR(sc, &tcbp[i].tbd[2]));
|
2001-03-14 19:50:35 +00:00
|
|
|
else
|
2003-04-02 16:47:16 +00:00
|
|
|
tcbp[i].tbd_array_addr =
|
2003-04-06 01:04:17 +00:00
|
|
|
htole32(FXP_TXCB_DMA_ADDR(sc, &tcbp[i].tbd[0]));
|
2003-04-02 16:47:16 +00:00
|
|
|
txp[i].tx_next = &txp[(i + 1) & FXP_TXCB_MASK];
|
1995-11-28 23:55:26 +00:00
|
|
|
}
|
|
|
|
/*
|
1997-09-29 11:27:43 +00:00
|
|
|
* Set the suspend flag on the first TxCB and start the control
|
1995-11-28 23:55:26 +00:00
|
|
|
* unit. It will execute the NOP and then suspend.
|
|
|
|
*/
|
2003-04-06 01:04:17 +00:00
|
|
|
tcbp->cb_command = htole16(FXP_CB_COMMAND_NOP | FXP_CB_COMMAND_S);
|
2009-06-21 06:06:43 +00:00
|
|
|
bus_dmamap_sync(sc->cbl_tag, sc->cbl_map,
|
|
|
|
BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
|
2003-04-02 16:47:16 +00:00
|
|
|
sc->fxp_desc.tx_first = sc->fxp_desc.tx_last = txp;
|
1997-09-29 11:27:43 +00:00
|
|
|
sc->tx_queued = 1;
|
1995-11-28 23:55:26 +00:00
|
|
|
|
1997-09-05 10:23:58 +00:00
|
|
|
fxp_scb_wait(sc);
|
2009-06-21 07:17:49 +00:00
|
|
|
CSR_WRITE_4(sc, FXP_CSR_SCB_GENERAL, sc->fxp_desc.cbl_addr);
|
2001-05-17 23:50:24 +00:00
|
|
|
fxp_scb_cmd(sc, FXP_SCB_COMMAND_CU_START);
|
1995-11-28 23:55:26 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize receiver buffer area - RFA.
|
|
|
|
*/
|
1997-09-05 10:23:58 +00:00
|
|
|
fxp_scb_wait(sc);
|
2003-04-02 16:47:16 +00:00
|
|
|
CSR_WRITE_4(sc, FXP_CSR_SCB_GENERAL, sc->fxp_desc.rx_head->rx_addr);
|
2001-05-17 23:50:24 +00:00
|
|
|
fxp_scb_cmd(sc, FXP_SCB_COMMAND_RU_START);
|
1995-11-28 23:55:26 +00:00
|
|
|
|
2010-11-26 21:52:33 +00:00
|
|
|
if (sc->miibus != NULL && setmedia != 0)
|
2001-03-12 21:30:52 +00:00
|
|
|
mii_mediachg(device_get_softc(sc->miibus));
|
1997-09-05 10:23:58 +00:00
|
|
|
|
2005-08-09 10:20:02 +00:00
|
|
|
ifp->if_drv_flags |= IFF_DRV_RUNNING;
|
|
|
|
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
|
2001-05-13 00:03:39 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Enable interrupts.
|
|
|
|
*/
|
2002-08-04 22:33:28 +00:00
|
|
|
#ifdef DEVICE_POLLING
|
|
|
|
/*
|
|
|
|
* ... but only do that if we are not polling. And because (presumably)
|
|
|
|
* the default is interrupts on, we need to disable them explicitly!
|
|
|
|
*/
|
Big polling(4) cleanup.
o Axe poll in trap.
o Axe IFF_POLLING flag from if_flags.
o Rework revision 1.21 (Giant removal), in such a way that
poll_mtx is not dropped during call to polling handler.
This fixes problem with idle polling.
o Make registration and deregistration from polling in a
functional way, insted of next tick/interrupt.
o Obsolete kern.polling.enable. Polling is turned on/off
with ifconfig.
Detailed kern_poll.c changes:
- Remove polling handler flags, introduced in 1.21. The are not
needed now.
- Forget and do not check if_flags, if_capenable and if_drv_flags.
- Call all registered polling handlers unconditionally.
- Do not drop poll_mtx, when entering polling handlers.
- In ether_poll() NET_LOCK_GIANT prior to locking poll_mtx.
- In netisr_poll() axe the block, where polling code asks drivers
to unregister.
- In netisr_poll() and ether_poll() do polling always, if any
handlers are present.
- In ether_poll_[de]register() remove a lot of error hiding code. Assert
that arguments are correct, instead.
- In ether_poll_[de]register() use standard return values in case of
error or success.
- Introduce poll_switch() that is a sysctl handler for kern.polling.enable.
poll_switch() goes through interface list and enabled/disables polling.
A message that kern.polling.enable is deprecated is printed.
Detailed driver changes:
- On attach driver announces IFCAP_POLLING in if_capabilities, but
not in if_capenable.
- On detach driver calls ether_poll_deregister() if polling is enabled.
- In polling handler driver obtains its lock and checks IFF_DRV_RUNNING
flag. If there is no, then unlocks and returns.
- In ioctl handler driver checks for IFCAP_POLLING flag requested to
be set or cleared. Driver first calls ether_poll_[de]register(), then
obtains driver lock and [dis/en]ables interrupts.
- In interrupt handler driver checks IFCAP_POLLING flag in if_capenable.
If present, then returns.This is important to protect from spurious
interrupts.
Reviewed by: ru, sam, jhb
2005-10-01 18:56:19 +00:00
|
|
|
if (ifp->if_capenable & IFCAP_POLLING )
|
2002-08-04 22:33:28 +00:00
|
|
|
CSR_WRITE_1(sc, FXP_CSR_SCB_INTRCNTL, FXP_SCB_INTR_DISABLE);
|
|
|
|
else
|
|
|
|
#endif /* DEVICE_POLLING */
|
2001-05-13 00:03:39 +00:00
|
|
|
CSR_WRITE_1(sc, FXP_CSR_SCB_INTRCNTL, 0);
|
1997-09-05 10:23:58 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Start stats updater.
|
|
|
|
*/
|
2003-09-05 22:37:31 +00:00
|
|
|
callout_reset(&sc->stat_ch, hz, fxp_tick, sc);
|
2001-03-12 21:30:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
fxp_serial_ifmedia_upd(struct ifnet *ifp)
|
|
|
|
{
|
|
|
|
|
|
|
|
return (0);
|
1997-09-05 10:23:58 +00:00
|
|
|
}
|
|
|
|
|
1998-02-09 06:11:36 +00:00
|
|
|
static void
|
2001-03-12 21:30:52 +00:00
|
|
|
fxp_serial_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
|
1997-09-05 10:23:58 +00:00
|
|
|
{
|
|
|
|
|
2001-03-12 21:30:52 +00:00
|
|
|
ifmr->ifm_active = IFM_ETHER|IFM_MANUAL;
|
1997-09-05 10:23:58 +00:00
|
|
|
}
|
1997-03-17 11:08:16 +00:00
|
|
|
|
1997-09-05 10:23:58 +00:00
|
|
|
/*
|
|
|
|
* Change media according to request.
|
|
|
|
*/
|
2001-03-12 21:30:52 +00:00
|
|
|
static int
|
|
|
|
fxp_ifmedia_upd(struct ifnet *ifp)
|
1997-09-05 10:23:58 +00:00
|
|
|
{
|
|
|
|
struct fxp_softc *sc = ifp->if_softc;
|
2001-03-12 21:30:52 +00:00
|
|
|
struct mii_data *mii;
|
2012-01-25 04:48:27 +00:00
|
|
|
struct mii_softc *miisc;
|
1997-09-05 10:23:58 +00:00
|
|
|
|
2001-03-12 21:30:52 +00:00
|
|
|
mii = device_get_softc(sc->miibus);
|
2005-08-08 21:03:54 +00:00
|
|
|
FXP_LOCK(sc);
|
- Remove attempts to implement setting of BMCR_LOOP/MIIF_NOLOOP
(reporting IFM_LOOP based on BMCR_LOOP is left in place though as
it might provide useful for debugging). For most mii(4) drivers it
was unclear whether the PHYs driven by them actually support
loopback or not. Moreover, typically loopback mode also needs to
be activated on the MAC, which none of the Ethernet drivers using
mii(4) implements. Given that loopback media has no real use (and
obviously hardly had a chance to actually work) besides for driver
development (which just loopback mode should be sufficient for
though, i.e one doesn't necessary need support for loopback media)
support for it is just dropped as both NetBSD and OpenBSD already
did quite some time ago.
- Let mii_phy_add_media() also announce the support of IFM_NONE.
- Restructure the PHY entry points to use a structure of entry points
instead of discrete function pointers, and extend this to include
a "reset" entry point. Make sure any PHY-specific reset routine is
always used, and provide one for lxtphy(4) which disables MII
interrupts (as is done for a few other PHYs we have drivers for).
This includes changing NIC drivers which previously just called the
generic mii_phy_reset() to now actually call the PHY-specific reset
routine, which might be crucial in some cases. While at it, the
redundant checks in these NIC drivers for mii->mii_instance not being
zero before calling the reset routines were removed because as soon
as one PHY driver attaches mii->mii_instance is incremented and we
hardly can end up in their media change callbacks etc if no PHY driver
has attached as mii_attach() would have failed in that case and not
attach a miibus(4) instance.
Consequently, NIC drivers now no longer should call mii_phy_reset()
directly, so it was removed from EXPORT_SYMS.
- Add a mii_phy_dev_attach() as a companion helper to mii_phy_dev_probe().
The purpose of that function is to perform the common steps to attach
a PHY driver instance and to hook it up to the miibus(4) instance and to
optionally also handle the probing, addition and initialization of the
supported media. So all a PHY driver without any special requirements
has to do in its bus attach method is to call mii_phy_dev_attach()
along with PHY-specific MIIF_* flags, a pointer to its PHY functions
and the add_media set to one. All PHY drivers were updated to take
advantage of mii_phy_dev_attach() as appropriate. Along with these
changes the capability mask was added to the mii_softc structure so
PHY drivers taking advantage of mii_phy_dev_attach() but still
handling media on their own do not need to fiddle with the MII attach
arguments anyway.
- Keep track of the PHY offset in the mii_softc structure. This is done
for compatibility with NetBSD/OpenBSD.
- Keep track of the PHY's OUI, model and revision in the mii_softc
structure. Several PHY drivers require this information also after
attaching and previously had to wrap their own softc around mii_softc.
NetBSD/OpenBSD also keep track of the model and revision on their
mii_softc structure. All PHY drivers were updated to take advantage
as appropriate.
- Convert the mebers of the MII data structure to unsigned where
appropriate. This is partly inspired by NetBSD/OpenBSD.
- According to IEEE 802.3-2002 the bits actually have to be reversed
when mapping an OUI to the MII ID registers. All PHY drivers and
miidevs where changed as necessary. Actually this now again allows to
largely share miidevs with NetBSD, which fixed this problem already
9 years ago. Consequently miidevs was synced as far as possible.
- Add MIIF_NOMANPAUSE and mii_phy_flowstatus() calls to drivers that
weren't explicitly converted to support flow control before. It's
unclear whether flow control actually works with these but typically
it should and their net behavior should be more correct with these
changes in place than without if the MAC driver sets MIIF_DOPAUSE.
Obtained from: NetBSD (partially)
Reviewed by: yongari (earlier version), silence on arch@ and net@
2011-05-03 19:51:29 +00:00
|
|
|
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
|
|
|
|
PHY_RESET(miisc);
|
2001-03-12 21:30:52 +00:00
|
|
|
mii_mediachg(mii);
|
2005-08-08 21:03:54 +00:00
|
|
|
FXP_UNLOCK(sc);
|
1997-09-05 10:23:58 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Notify the world which media we're using.
|
|
|
|
*/
|
2001-03-12 21:30:52 +00:00
|
|
|
static void
|
|
|
|
fxp_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
|
1997-09-05 10:23:58 +00:00
|
|
|
{
|
|
|
|
struct fxp_softc *sc = ifp->if_softc;
|
2001-03-12 21:30:52 +00:00
|
|
|
struct mii_data *mii;
|
1997-09-05 10:23:58 +00:00
|
|
|
|
2001-03-12 21:30:52 +00:00
|
|
|
mii = device_get_softc(sc->miibus);
|
2005-08-08 21:03:54 +00:00
|
|
|
FXP_LOCK(sc);
|
2001-03-12 21:30:52 +00:00
|
|
|
mii_pollstat(mii);
|
|
|
|
ifmr->ifm_active = mii->mii_media_active;
|
|
|
|
ifmr->ifm_status = mii->mii_media_status;
|
2005-08-08 21:03:54 +00:00
|
|
|
FXP_UNLOCK(sc);
|
1995-11-28 23:55:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Add a buffer to the end of the RFA buffer list.
|
|
|
|
* Return 0 if successful, 1 for failure. A failure results in
|
2008-11-26 05:51:49 +00:00
|
|
|
* reusing the RFA buffer.
|
1995-11-28 23:55:26 +00:00
|
|
|
* The RFA struct is stuck at the beginning of mbuf cluster and the
|
|
|
|
* data pointer is fixed up to point just past it.
|
|
|
|
*/
|
|
|
|
static int
|
2008-11-26 05:51:49 +00:00
|
|
|
fxp_new_rfabuf(struct fxp_softc *sc, struct fxp_rx *rxp)
|
1995-11-28 23:55:26 +00:00
|
|
|
{
|
|
|
|
struct mbuf *m;
|
2008-11-26 05:51:49 +00:00
|
|
|
struct fxp_rfa *rfa;
|
2003-04-02 16:47:16 +00:00
|
|
|
bus_dmamap_t tmp_map;
|
2008-11-26 05:51:49 +00:00
|
|
|
int error;
|
1995-11-28 23:55:26 +00:00
|
|
|
|
2012-12-04 09:32:43 +00:00
|
|
|
m = m_getcl(M_NOWAIT, MT_DATA, M_PKTHDR);
|
2008-11-26 05:51:49 +00:00
|
|
|
if (m == NULL)
|
|
|
|
return (ENOBUFS);
|
1997-09-05 10:23:58 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Move the data pointer up so that the incoming data packet
|
|
|
|
* will be 32-bit aligned.
|
|
|
|
*/
|
|
|
|
m->m_data += RFA_ALIGNMENT_FUDGE;
|
|
|
|
|
1996-09-20 11:05:39 +00:00
|
|
|
/*
|
|
|
|
* Get a pointer to the base of the mbuf cluster and move
|
|
|
|
* data start past it.
|
|
|
|
*/
|
1995-11-28 23:55:26 +00:00
|
|
|
rfa = mtod(m, struct fxp_rfa *);
|
2003-02-26 22:12:04 +00:00
|
|
|
m->m_data += sc->rfa_size;
|
2003-04-06 01:04:17 +00:00
|
|
|
rfa->size = htole16(MCLBYTES - sc->rfa_size - RFA_ALIGNMENT_FUDGE);
|
1996-09-20 11:05:39 +00:00
|
|
|
|
1995-11-28 23:55:26 +00:00
|
|
|
rfa->rfa_status = 0;
|
2003-04-06 01:04:17 +00:00
|
|
|
rfa->rfa_control = htole16(FXP_RFA_CONTROL_EL);
|
1995-11-28 23:55:26 +00:00
|
|
|
rfa->actual_size = 0;
|
2008-11-26 05:51:49 +00:00
|
|
|
m->m_len = m->m_pkthdr.len = MCLBYTES - RFA_ALIGNMENT_FUDGE -
|
|
|
|
sc->rfa_size;
|
1997-09-05 10:23:58 +00:00
|
|
|
|
2003-07-22 15:50:54 +00:00
|
|
|
/*
|
|
|
|
* Initialize the rest of the RFA. Note that since the RFA
|
|
|
|
* is misaligned, we cannot store values directly. We're thus
|
|
|
|
* using the le32enc() function which handles endianness and
|
|
|
|
* is also alignment-safe.
|
|
|
|
*/
|
2003-04-06 01:04:17 +00:00
|
|
|
le32enc(&rfa->link_addr, 0xffffffff);
|
|
|
|
le32enc(&rfa->rbd_addr, 0xffffffff);
|
1997-09-05 10:23:58 +00:00
|
|
|
|
2003-04-02 16:47:16 +00:00
|
|
|
/* Map the RFA into DMA memory. */
|
2009-06-21 06:06:43 +00:00
|
|
|
error = bus_dmamap_load(sc->fxp_rxmtag, sc->spare_map, rfa,
|
2003-04-02 16:47:16 +00:00
|
|
|
MCLBYTES - RFA_ALIGNMENT_FUDGE, fxp_dma_map_addr,
|
2010-05-14 16:58:37 +00:00
|
|
|
&rxp->rx_addr, BUS_DMA_NOWAIT);
|
2003-04-02 16:47:16 +00:00
|
|
|
if (error) {
|
|
|
|
m_freem(m);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
2009-01-08 04:26:44 +00:00
|
|
|
if (rxp->rx_mbuf != NULL)
|
2009-06-21 06:06:43 +00:00
|
|
|
bus_dmamap_unload(sc->fxp_rxmtag, rxp->rx_map);
|
2003-04-02 16:47:16 +00:00
|
|
|
tmp_map = sc->spare_map;
|
|
|
|
sc->spare_map = rxp->rx_map;
|
|
|
|
rxp->rx_map = tmp_map;
|
|
|
|
rxp->rx_mbuf = m;
|
|
|
|
|
2009-06-21 06:06:43 +00:00
|
|
|
bus_dmamap_sync(sc->fxp_rxmtag, rxp->rx_map,
|
2003-04-10 23:15:12 +00:00
|
|
|
BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
|
2008-11-26 05:51:49 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
fxp_add_rfabuf(struct fxp_softc *sc, struct fxp_rx *rxp)
|
|
|
|
{
|
|
|
|
struct fxp_rfa *p_rfa;
|
|
|
|
struct fxp_rx *p_rx;
|
2003-04-02 16:47:16 +00:00
|
|
|
|
1995-12-01 22:41:56 +00:00
|
|
|
/*
|
|
|
|
* If there are other buffers already on the list, attach this
|
|
|
|
* one to the end by fixing up the tail to point to this one.
|
|
|
|
*/
|
2003-04-02 16:47:16 +00:00
|
|
|
if (sc->fxp_desc.rx_head != NULL) {
|
|
|
|
p_rx = sc->fxp_desc.rx_tail;
|
|
|
|
p_rfa = (struct fxp_rfa *)
|
|
|
|
(p_rx->rx_mbuf->m_ext.ext_buf + RFA_ALIGNMENT_FUDGE);
|
|
|
|
p_rx->rx_next = rxp;
|
2003-04-06 01:04:17 +00:00
|
|
|
le32enc(&p_rfa->link_addr, rxp->rx_addr);
|
2000-06-19 00:58:34 +00:00
|
|
|
p_rfa->rfa_control = 0;
|
2009-06-21 06:06:43 +00:00
|
|
|
bus_dmamap_sync(sc->fxp_rxmtag, p_rx->rx_map,
|
2010-05-14 16:55:13 +00:00
|
|
|
BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
|
1995-11-28 23:55:26 +00:00
|
|
|
} else {
|
2003-04-02 16:47:16 +00:00
|
|
|
rxp->rx_next = NULL;
|
|
|
|
sc->fxp_desc.rx_head = rxp;
|
1995-11-28 23:55:26 +00:00
|
|
|
}
|
2003-04-02 16:47:16 +00:00
|
|
|
sc->fxp_desc.rx_tail = rxp;
|
2008-11-26 05:51:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
fxp_discard_rfabuf(struct fxp_softc *sc, struct fxp_rx *rxp)
|
|
|
|
{
|
|
|
|
struct mbuf *m;
|
|
|
|
struct fxp_rfa *rfa;
|
|
|
|
|
|
|
|
m = rxp->rx_mbuf;
|
|
|
|
m->m_data = m->m_ext.ext_buf;
|
|
|
|
/*
|
|
|
|
* Move the data pointer up so that the incoming data packet
|
|
|
|
* will be 32-bit aligned.
|
|
|
|
*/
|
|
|
|
m->m_data += RFA_ALIGNMENT_FUDGE;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get a pointer to the base of the mbuf cluster and move
|
|
|
|
* data start past it.
|
|
|
|
*/
|
|
|
|
rfa = mtod(m, struct fxp_rfa *);
|
|
|
|
m->m_data += sc->rfa_size;
|
|
|
|
rfa->size = htole16(MCLBYTES - sc->rfa_size - RFA_ALIGNMENT_FUDGE);
|
|
|
|
|
|
|
|
rfa->rfa_status = 0;
|
|
|
|
rfa->rfa_control = htole16(FXP_RFA_CONTROL_EL);
|
|
|
|
rfa->actual_size = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize the rest of the RFA. Note that since the RFA
|
|
|
|
* is misaligned, we cannot store values directly. We're thus
|
|
|
|
* using the le32enc() function which handles endianness and
|
|
|
|
* is also alignment-safe.
|
|
|
|
*/
|
|
|
|
le32enc(&rfa->link_addr, 0xffffffff);
|
|
|
|
le32enc(&rfa->rbd_addr, 0xffffffff);
|
|
|
|
|
2009-06-21 06:06:43 +00:00
|
|
|
bus_dmamap_sync(sc->fxp_rxmtag, rxp->rx_map,
|
2008-11-26 05:51:49 +00:00
|
|
|
BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
|
1995-11-28 23:55:26 +00:00
|
|
|
}
|
|
|
|
|
2007-05-30 03:46:04 +00:00
|
|
|
static int
|
2001-03-12 21:30:52 +00:00
|
|
|
fxp_miibus_readreg(device_t dev, int phy, int reg)
|
1997-03-17 11:08:16 +00:00
|
|
|
{
|
2001-03-12 21:30:52 +00:00
|
|
|
struct fxp_softc *sc = device_get_softc(dev);
|
1997-03-17 11:08:16 +00:00
|
|
|
int count = 10000;
|
1997-03-21 08:00:13 +00:00
|
|
|
int value;
|
1997-03-17 11:08:16 +00:00
|
|
|
|
1997-09-05 10:23:58 +00:00
|
|
|
CSR_WRITE_4(sc, FXP_CSR_MDICONTROL,
|
|
|
|
(FXP_MDI_READ << 26) | (reg << 16) | (phy << 21));
|
1997-03-17 11:08:16 +00:00
|
|
|
|
1997-09-05 10:23:58 +00:00
|
|
|
while (((value = CSR_READ_4(sc, FXP_CSR_MDICONTROL)) & 0x10000000) == 0
|
|
|
|
&& count--)
|
1997-03-21 08:00:13 +00:00
|
|
|
DELAY(10);
|
1997-03-17 11:08:16 +00:00
|
|
|
|
|
|
|
if (count <= 0)
|
2001-03-12 21:30:52 +00:00
|
|
|
device_printf(dev, "fxp_miibus_readreg: timed out\n");
|
1997-03-17 11:08:16 +00:00
|
|
|
|
1997-03-21 08:00:13 +00:00
|
|
|
return (value & 0xffff);
|
1997-03-17 11:08:16 +00:00
|
|
|
}
|
|
|
|
|
2009-02-05 19:33:35 +00:00
|
|
|
static int
|
2001-03-12 21:30:52 +00:00
|
|
|
fxp_miibus_writereg(device_t dev, int phy, int reg, int value)
|
1997-03-17 11:08:16 +00:00
|
|
|
{
|
2001-03-12 21:30:52 +00:00
|
|
|
struct fxp_softc *sc = device_get_softc(dev);
|
1997-03-17 11:08:16 +00:00
|
|
|
int count = 10000;
|
|
|
|
|
1997-09-05 10:23:58 +00:00
|
|
|
CSR_WRITE_4(sc, FXP_CSR_MDICONTROL,
|
|
|
|
(FXP_MDI_WRITE << 26) | (reg << 16) | (phy << 21) |
|
|
|
|
(value & 0xffff));
|
1997-03-17 11:08:16 +00:00
|
|
|
|
2001-03-12 21:30:52 +00:00
|
|
|
while ((CSR_READ_4(sc, FXP_CSR_MDICONTROL) & 0x10000000) == 0 &&
|
1997-09-05 10:23:58 +00:00
|
|
|
count--)
|
1997-03-21 08:00:13 +00:00
|
|
|
DELAY(10);
|
1997-03-17 11:08:16 +00:00
|
|
|
|
|
|
|
if (count <= 0)
|
2001-03-12 21:30:52 +00:00
|
|
|
device_printf(dev, "fxp_miibus_writereg: timed out\n");
|
2009-02-05 19:33:35 +00:00
|
|
|
return (0);
|
1997-03-17 11:08:16 +00:00
|
|
|
}
|
|
|
|
|
2010-11-26 21:52:33 +00:00
|
|
|
static void
|
|
|
|
fxp_miibus_statchg(device_t dev)
|
|
|
|
{
|
|
|
|
struct fxp_softc *sc;
|
|
|
|
struct mii_data *mii;
|
|
|
|
struct ifnet *ifp;
|
|
|
|
|
|
|
|
sc = device_get_softc(dev);
|
|
|
|
mii = device_get_softc(sc->miibus);
|
|
|
|
ifp = sc->ifp;
|
|
|
|
if (mii == NULL || ifp == NULL ||
|
|
|
|
(ifp->if_drv_flags & IFF_DRV_RUNNING) == 0 ||
|
|
|
|
(mii->mii_media_status & (IFM_AVALID | IFM_ACTIVE)) !=
|
|
|
|
(IFM_AVALID | IFM_ACTIVE))
|
|
|
|
return;
|
|
|
|
|
2012-03-28 01:52:38 +00:00
|
|
|
if (IFM_SUBTYPE(mii->mii_media_active) == IFM_10_T &&
|
|
|
|
sc->flags & FXP_FLAG_CU_RESUME_BUG)
|
|
|
|
sc->cu_resume_bug = 1;
|
|
|
|
else
|
|
|
|
sc->cu_resume_bug = 0;
|
2010-11-26 21:52:33 +00:00
|
|
|
/*
|
|
|
|
* Call fxp_init_body in order to adjust the flow control settings.
|
|
|
|
* Note that the 82557 doesn't support hardware flow control.
|
|
|
|
*/
|
|
|
|
if (sc->revision == FXP_REV_82557)
|
|
|
|
return;
|
2013-06-10 07:31:49 +00:00
|
|
|
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
|
2010-11-26 21:52:33 +00:00
|
|
|
fxp_init_body(sc, 0);
|
|
|
|
}
|
|
|
|
|
1995-11-28 23:55:26 +00:00
|
|
|
static int
|
2001-03-12 21:30:52 +00:00
|
|
|
fxp_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
|
1995-11-28 23:55:26 +00:00
|
|
|
{
|
1996-02-06 18:51:28 +00:00
|
|
|
struct fxp_softc *sc = ifp->if_softc;
|
1997-09-05 10:23:58 +00:00
|
|
|
struct ifreq *ifr = (struct ifreq *)data;
|
2001-03-12 21:42:45 +00:00
|
|
|
struct mii_data *mii;
|
2008-11-25 01:33:16 +00:00
|
|
|
int flag, mask, error = 0, reinit;
|
1995-11-28 23:55:26 +00:00
|
|
|
|
|
|
|
switch (command) {
|
|
|
|
case SIOCSIFFLAGS:
|
2005-08-08 21:03:54 +00:00
|
|
|
FXP_LOCK(sc);
|
1995-11-28 23:55:26 +00:00
|
|
|
/*
|
|
|
|
* If interface is marked up and not running, then start it.
|
|
|
|
* If it is marked down and running, stop it.
|
|
|
|
* XXX If it's up then re-initialize it. This is so flags
|
|
|
|
* such as IFF_PROMISC are handled.
|
|
|
|
*/
|
|
|
|
if (ifp->if_flags & IFF_UP) {
|
2009-06-21 07:17:49 +00:00
|
|
|
if (((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) &&
|
|
|
|
((ifp->if_flags ^ sc->if_flags) &
|
2013-06-10 07:31:49 +00:00
|
|
|
(IFF_PROMISC | IFF_ALLMULTI | IFF_LINK0)) != 0) {
|
|
|
|
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
|
2012-03-19 02:10:40 +00:00
|
|
|
fxp_init_body(sc, 0);
|
2013-06-10 07:31:49 +00:00
|
|
|
} else if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
|
2010-11-26 21:52:33 +00:00
|
|
|
fxp_init_body(sc, 1);
|
1995-11-28 23:55:26 +00:00
|
|
|
} else {
|
2009-06-21 07:17:49 +00:00
|
|
|
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0)
|
1995-12-05 02:01:59 +00:00
|
|
|
fxp_stop(sc);
|
1995-11-28 23:55:26 +00:00
|
|
|
}
|
2009-06-21 07:17:49 +00:00
|
|
|
sc->if_flags = ifp->if_flags;
|
2005-08-08 21:03:54 +00:00
|
|
|
FXP_UNLOCK(sc);
|
1995-11-28 23:55:26 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SIOCADDMULTI:
|
|
|
|
case SIOCDELMULTI:
|
2011-02-15 18:16:04 +00:00
|
|
|
FXP_LOCK(sc);
|
2013-06-10 07:31:49 +00:00
|
|
|
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) {
|
|
|
|
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
|
2011-02-15 18:16:04 +00:00
|
|
|
fxp_init_body(sc, 0);
|
2013-06-10 07:31:49 +00:00
|
|
|
}
|
2011-02-15 18:16:04 +00:00
|
|
|
FXP_UNLOCK(sc);
|
1997-09-05 10:23:58 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case SIOCSIFMEDIA:
|
|
|
|
case SIOCGIFMEDIA:
|
2001-03-12 21:30:52 +00:00
|
|
|
if (sc->miibus != NULL) {
|
|
|
|
mii = device_get_softc(sc->miibus);
|
|
|
|
error = ifmedia_ioctl(ifp, ifr,
|
|
|
|
&mii->mii_media, command);
|
|
|
|
} else {
|
|
|
|
error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, command);
|
|
|
|
}
|
1995-11-28 23:55:26 +00:00
|
|
|
break;
|
|
|
|
|
2004-04-11 15:35:49 +00:00
|
|
|
case SIOCSIFCAP:
|
2008-11-25 01:33:16 +00:00
|
|
|
reinit = 0;
|
2004-05-25 14:49:46 +00:00
|
|
|
mask = ifp->if_capenable ^ ifr->ifr_reqcap;
|
Big polling(4) cleanup.
o Axe poll in trap.
o Axe IFF_POLLING flag from if_flags.
o Rework revision 1.21 (Giant removal), in such a way that
poll_mtx is not dropped during call to polling handler.
This fixes problem with idle polling.
o Make registration and deregistration from polling in a
functional way, insted of next tick/interrupt.
o Obsolete kern.polling.enable. Polling is turned on/off
with ifconfig.
Detailed kern_poll.c changes:
- Remove polling handler flags, introduced in 1.21. The are not
needed now.
- Forget and do not check if_flags, if_capenable and if_drv_flags.
- Call all registered polling handlers unconditionally.
- Do not drop poll_mtx, when entering polling handlers.
- In ether_poll() NET_LOCK_GIANT prior to locking poll_mtx.
- In netisr_poll() axe the block, where polling code asks drivers
to unregister.
- In netisr_poll() and ether_poll() do polling always, if any
handlers are present.
- In ether_poll_[de]register() remove a lot of error hiding code. Assert
that arguments are correct, instead.
- In ether_poll_[de]register() use standard return values in case of
error or success.
- Introduce poll_switch() that is a sysctl handler for kern.polling.enable.
poll_switch() goes through interface list and enabled/disables polling.
A message that kern.polling.enable is deprecated is printed.
Detailed driver changes:
- On attach driver announces IFCAP_POLLING in if_capabilities, but
not in if_capenable.
- On detach driver calls ether_poll_deregister() if polling is enabled.
- In polling handler driver obtains its lock and checks IFF_DRV_RUNNING
flag. If there is no, then unlocks and returns.
- In ioctl handler driver checks for IFCAP_POLLING flag requested to
be set or cleared. Driver first calls ether_poll_[de]register(), then
obtains driver lock and [dis/en]ables interrupts.
- In interrupt handler driver checks IFCAP_POLLING flag in if_capenable.
If present, then returns.This is important to protect from spurious
interrupts.
Reviewed by: ru, sam, jhb
2005-10-01 18:56:19 +00:00
|
|
|
#ifdef DEVICE_POLLING
|
|
|
|
if (mask & IFCAP_POLLING) {
|
|
|
|
if (ifr->ifr_reqcap & IFCAP_POLLING) {
|
|
|
|
error = ether_poll_register(fxp_poll, ifp);
|
|
|
|
if (error)
|
|
|
|
return(error);
|
|
|
|
FXP_LOCK(sc);
|
|
|
|
CSR_WRITE_1(sc, FXP_CSR_SCB_INTRCNTL,
|
|
|
|
FXP_SCB_INTR_DISABLE);
|
|
|
|
ifp->if_capenable |= IFCAP_POLLING;
|
|
|
|
FXP_UNLOCK(sc);
|
|
|
|
} else {
|
|
|
|
error = ether_poll_deregister(ifp);
|
|
|
|
/* Enable interrupts in any case */
|
|
|
|
FXP_LOCK(sc);
|
|
|
|
CSR_WRITE_1(sc, FXP_CSR_SCB_INTRCNTL, 0);
|
|
|
|
ifp->if_capenable &= ~IFCAP_POLLING;
|
|
|
|
FXP_UNLOCK(sc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2008-11-25 01:33:16 +00:00
|
|
|
FXP_LOCK(sc);
|
|
|
|
if ((mask & IFCAP_TXCSUM) != 0 &&
|
|
|
|
(ifp->if_capabilities & IFCAP_TXCSUM) != 0) {
|
|
|
|
ifp->if_capenable ^= IFCAP_TXCSUM;
|
|
|
|
if ((ifp->if_capenable & IFCAP_TXCSUM) != 0)
|
|
|
|
ifp->if_hwassist |= FXP_CSUM_FEATURES;
|
|
|
|
else
|
|
|
|
ifp->if_hwassist &= ~FXP_CSUM_FEATURES;
|
|
|
|
}
|
|
|
|
if ((mask & IFCAP_RXCSUM) != 0 &&
|
2008-11-26 06:36:53 +00:00
|
|
|
(ifp->if_capabilities & IFCAP_RXCSUM) != 0) {
|
2008-11-25 01:33:16 +00:00
|
|
|
ifp->if_capenable ^= IFCAP_RXCSUM;
|
2008-11-26 06:36:53 +00:00
|
|
|
if ((sc->flags & FXP_FLAG_82559_RXCSUM) != 0)
|
|
|
|
reinit++;
|
|
|
|
}
|
2008-11-26 07:36:17 +00:00
|
|
|
if ((mask & IFCAP_TSO4) != 0 &&
|
|
|
|
(ifp->if_capabilities & IFCAP_TSO4) != 0) {
|
|
|
|
ifp->if_capenable ^= IFCAP_TSO4;
|
|
|
|
if ((ifp->if_capenable & IFCAP_TSO4) != 0)
|
|
|
|
ifp->if_hwassist |= CSUM_TSO;
|
|
|
|
else
|
|
|
|
ifp->if_hwassist &= ~CSUM_TSO;
|
|
|
|
}
|
2008-11-27 01:57:23 +00:00
|
|
|
if ((mask & IFCAP_WOL_MAGIC) != 0 &&
|
|
|
|
(ifp->if_capabilities & IFCAP_WOL_MAGIC) != 0)
|
|
|
|
ifp->if_capenable ^= IFCAP_WOL_MAGIC;
|
2008-11-25 01:33:16 +00:00
|
|
|
if ((mask & IFCAP_VLAN_MTU) != 0 &&
|
|
|
|
(ifp->if_capabilities & IFCAP_VLAN_MTU) != 0) {
|
2004-05-25 14:49:46 +00:00
|
|
|
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)
|
2008-11-25 01:33:16 +00:00
|
|
|
reinit++;
|
2004-05-25 14:49:46 +00:00
|
|
|
}
|
2010-10-24 21:59:51 +00:00
|
|
|
if ((mask & IFCAP_VLAN_HWCSUM) != 0 &&
|
|
|
|
(ifp->if_capabilities & IFCAP_VLAN_HWCSUM) != 0)
|
|
|
|
ifp->if_capenable ^= IFCAP_VLAN_HWCSUM;
|
|
|
|
if ((mask & IFCAP_VLAN_HWTSO) != 0 &&
|
|
|
|
(ifp->if_capabilities & IFCAP_VLAN_HWTSO) != 0)
|
|
|
|
ifp->if_capenable ^= IFCAP_VLAN_HWTSO;
|
2008-12-02 02:30:12 +00:00
|
|
|
if ((mask & IFCAP_VLAN_HWTAGGING) != 0 &&
|
|
|
|
(ifp->if_capabilities & IFCAP_VLAN_HWTAGGING) != 0) {
|
|
|
|
ifp->if_capenable ^= IFCAP_VLAN_HWTAGGING;
|
2010-10-24 21:59:51 +00:00
|
|
|
if ((ifp->if_capenable & IFCAP_VLAN_HWTAGGING) == 0)
|
|
|
|
ifp->if_capenable &=
|
|
|
|
~(IFCAP_VLAN_HWTSO | IFCAP_VLAN_HWCSUM);
|
|
|
|
reinit++;
|
2008-12-02 02:30:12 +00:00
|
|
|
}
|
2013-06-10 07:31:49 +00:00
|
|
|
if (reinit > 0 && (ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) {
|
|
|
|
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
|
2012-03-19 02:10:40 +00:00
|
|
|
fxp_init_body(sc, 0);
|
2013-06-10 07:31:49 +00:00
|
|
|
}
|
2008-11-25 01:33:16 +00:00
|
|
|
FXP_UNLOCK(sc);
|
2008-12-02 02:30:12 +00:00
|
|
|
VLAN_CAPABILITIES(ifp);
|
2004-04-11 15:35:49 +00:00
|
|
|
break;
|
|
|
|
|
1995-11-28 23:55:26 +00:00
|
|
|
default:
|
2002-11-14 23:54:55 +00:00
|
|
|
error = ether_ioctl(ifp, command, data);
|
1995-11-28 23:55:26 +00:00
|
|
|
}
|
|
|
|
return (error);
|
|
|
|
}
|
1997-09-29 11:27:43 +00:00
|
|
|
|
2002-01-07 15:08:54 +00:00
|
|
|
/*
|
|
|
|
* Fill in the multicast address list and return number of entries.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
fxp_mc_addrs(struct fxp_softc *sc)
|
|
|
|
{
|
|
|
|
struct fxp_cb_mcs *mcsp = sc->mcsp;
|
2005-06-10 16:49:24 +00:00
|
|
|
struct ifnet *ifp = sc->ifp;
|
2002-01-07 15:08:54 +00:00
|
|
|
struct ifmultiaddr *ifma;
|
|
|
|
int nmcasts;
|
|
|
|
|
|
|
|
nmcasts = 0;
|
2009-06-21 07:17:49 +00:00
|
|
|
if ((ifp->if_flags & IFF_ALLMULTI) == 0) {
|
2009-06-26 11:45:06 +00:00
|
|
|
if_maddr_rlock(ifp);
|
2002-01-07 15:08:54 +00:00
|
|
|
TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
|
|
|
|
if (ifma->ifma_addr->sa_family != AF_LINK)
|
|
|
|
continue;
|
|
|
|
if (nmcasts >= MAXMCADDR) {
|
2009-06-21 07:17:49 +00:00
|
|
|
ifp->if_flags |= IFF_ALLMULTI;
|
2002-01-07 15:08:54 +00:00
|
|
|
nmcasts = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
bcopy(LLADDR((struct sockaddr_dl *)ifma->ifma_addr),
|
2003-04-08 17:21:15 +00:00
|
|
|
&sc->mcsp->mc_addr[nmcasts][0], ETHER_ADDR_LEN);
|
2002-01-07 15:08:54 +00:00
|
|
|
nmcasts++;
|
|
|
|
}
|
2009-06-26 11:45:06 +00:00
|
|
|
if_maddr_runlock(ifp);
|
2002-01-07 15:08:54 +00:00
|
|
|
}
|
2003-04-08 17:21:15 +00:00
|
|
|
mcsp->mc_cnt = htole16(nmcasts * ETHER_ADDR_LEN);
|
2002-01-07 15:08:54 +00:00
|
|
|
return (nmcasts);
|
|
|
|
}
|
|
|
|
|
1997-09-29 11:27:43 +00:00
|
|
|
/*
|
|
|
|
* Program the multicast filter.
|
|
|
|
*
|
|
|
|
* We have an artificial restriction that the multicast setup command
|
|
|
|
* must be the first command in the chain, so we take steps to ensure
|
1998-08-04 08:53:12 +00:00
|
|
|
* this. By requiring this, it allows us to keep up the performance of
|
1997-09-29 11:27:43 +00:00
|
|
|
* the pre-initialized command ring (esp. link pointers) by not actually
|
1998-04-17 22:37:19 +00:00
|
|
|
* inserting the mcsetup command in the ring - i.e. its link pointer
|
1997-09-29 11:27:43 +00:00
|
|
|
* points to the TxCB ring, but the mcsetup descriptor itself is not part
|
|
|
|
* of it. We then can do 'CU_START' on the mcsetup descriptor and have it
|
|
|
|
* lead into the regular TxCB ring when it completes.
|
|
|
|
*/
|
|
|
|
static void
|
2001-03-12 21:30:52 +00:00
|
|
|
fxp_mc_setup(struct fxp_softc *sc)
|
1997-09-29 11:27:43 +00:00
|
|
|
{
|
2009-06-21 07:17:49 +00:00
|
|
|
struct fxp_cb_mcs *mcsp;
|
2000-09-17 22:12:12 +00:00
|
|
|
int count;
|
1997-09-29 11:27:43 +00:00
|
|
|
|
2004-06-02 22:59:57 +00:00
|
|
|
FXP_LOCK_ASSERT(sc, MA_OWNED);
|
1997-09-29 11:27:43 +00:00
|
|
|
|
2009-06-21 07:17:49 +00:00
|
|
|
mcsp = sc->mcsp;
|
1997-09-29 11:27:43 +00:00
|
|
|
mcsp->cb_status = 0;
|
2009-06-21 07:17:49 +00:00
|
|
|
mcsp->cb_command = htole16(FXP_CB_COMMAND_MCAS | FXP_CB_COMMAND_EL);
|
|
|
|
mcsp->link_addr = 0xffffffff;
|
|
|
|
fxp_mc_addrs(sc);
|
1997-09-29 11:27:43 +00:00
|
|
|
|
|
|
|
/*
|
2009-06-21 07:17:49 +00:00
|
|
|
* Wait until command unit is idle. This should never be the
|
|
|
|
* case when nothing is queued, but make sure anyway.
|
1997-09-29 11:27:43 +00:00
|
|
|
*/
|
2000-09-17 22:12:12 +00:00
|
|
|
count = 100;
|
2009-06-21 07:17:49 +00:00
|
|
|
while ((CSR_READ_1(sc, FXP_CSR_SCB_RUSCUS) >> 6) !=
|
|
|
|
FXP_SCB_CUS_IDLE && --count)
|
2000-09-17 22:12:12 +00:00
|
|
|
DELAY(10);
|
|
|
|
if (count == 0) {
|
2001-03-12 21:30:52 +00:00
|
|
|
device_printf(sc->dev, "command queue timeout\n");
|
2000-09-17 22:12:12 +00:00
|
|
|
return;
|
|
|
|
}
|
1997-09-29 11:27:43 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Start the multicast setup command.
|
|
|
|
*/
|
|
|
|
fxp_scb_wait(sc);
|
2009-06-21 06:06:43 +00:00
|
|
|
bus_dmamap_sync(sc->mcs_tag, sc->mcs_map,
|
|
|
|
BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
|
2003-04-02 16:47:16 +00:00
|
|
|
CSR_WRITE_4(sc, FXP_CSR_SCB_GENERAL, sc->mcs_addr);
|
2001-05-17 23:50:24 +00:00
|
|
|
fxp_scb_cmd(sc, FXP_SCB_COMMAND_CU_START);
|
2009-06-21 07:17:49 +00:00
|
|
|
/* ...and wait for it to complete. */
|
|
|
|
fxp_dma_wait(sc, &mcsp->cb_status, sc->mcs_tag, sc->mcs_map);
|
1997-09-29 11:27:43 +00:00
|
|
|
}
|
2001-10-25 05:32:01 +00:00
|
|
|
|
2005-03-06 05:07:26 +00:00
|
|
|
static uint32_t fxp_ucode_d101a[] = D101_A_RCVBUNDLE_UCODE;
|
|
|
|
static uint32_t fxp_ucode_d101b0[] = D101_B0_RCVBUNDLE_UCODE;
|
|
|
|
static uint32_t fxp_ucode_d101ma[] = D101M_B_RCVBUNDLE_UCODE;
|
|
|
|
static uint32_t fxp_ucode_d101s[] = D101S_RCVBUNDLE_UCODE;
|
|
|
|
static uint32_t fxp_ucode_d102[] = D102_B_RCVBUNDLE_UCODE;
|
|
|
|
static uint32_t fxp_ucode_d102c[] = D102_C_RCVBUNDLE_UCODE;
|
2005-04-21 19:34:57 +00:00
|
|
|
static uint32_t fxp_ucode_d102e[] = D102_E_RCVBUNDLE_UCODE;
|
2001-10-25 05:32:01 +00:00
|
|
|
|
2005-03-06 05:07:26 +00:00
|
|
|
#define UCODE(x) x, sizeof(x)/sizeof(uint32_t)
|
2001-10-25 05:32:01 +00:00
|
|
|
|
2010-11-23 21:09:42 +00:00
|
|
|
static const struct ucode {
|
2005-03-06 05:07:26 +00:00
|
|
|
uint32_t revision;
|
|
|
|
uint32_t *ucode;
|
2001-10-25 05:32:01 +00:00
|
|
|
int length;
|
|
|
|
u_short int_delay_offset;
|
|
|
|
u_short bundle_max_offset;
|
2012-11-05 19:16:27 +00:00
|
|
|
} ucode_table[] = {
|
2001-10-25 05:32:01 +00:00
|
|
|
{ FXP_REV_82558_A4, UCODE(fxp_ucode_d101a), D101_CPUSAVER_DWORD, 0 },
|
|
|
|
{ FXP_REV_82558_B0, UCODE(fxp_ucode_d101b0), D101_CPUSAVER_DWORD, 0 },
|
|
|
|
{ FXP_REV_82559_A0, UCODE(fxp_ucode_d101ma),
|
|
|
|
D101M_CPUSAVER_DWORD, D101M_CPUSAVER_BUNDLE_MAX_DWORD },
|
|
|
|
{ FXP_REV_82559S_A, UCODE(fxp_ucode_d101s),
|
|
|
|
D101S_CPUSAVER_DWORD, D101S_CPUSAVER_BUNDLE_MAX_DWORD },
|
|
|
|
{ FXP_REV_82550, UCODE(fxp_ucode_d102),
|
|
|
|
D102_B_CPUSAVER_DWORD, D102_B_CPUSAVER_BUNDLE_MAX_DWORD },
|
|
|
|
{ FXP_REV_82550_C, UCODE(fxp_ucode_d102c),
|
|
|
|
D102_C_CPUSAVER_DWORD, D102_C_CPUSAVER_BUNDLE_MAX_DWORD },
|
2005-04-22 13:05:53 +00:00
|
|
|
{ FXP_REV_82551_F, UCODE(fxp_ucode_d102e),
|
2005-04-21 19:34:57 +00:00
|
|
|
D102_E_CPUSAVER_DWORD, D102_E_CPUSAVER_BUNDLE_MAX_DWORD },
|
2011-06-27 21:37:38 +00:00
|
|
|
{ FXP_REV_82551_10, UCODE(fxp_ucode_d102e),
|
|
|
|
D102_E_CPUSAVER_DWORD, D102_E_CPUSAVER_BUNDLE_MAX_DWORD },
|
2001-10-25 05:32:01 +00:00
|
|
|
{ 0, NULL, 0, 0, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
fxp_load_ucode(struct fxp_softc *sc)
|
|
|
|
{
|
2010-11-23 21:09:42 +00:00
|
|
|
const struct ucode *uc;
|
2001-10-25 05:32:01 +00:00
|
|
|
struct fxp_cb_ucode *cbp;
|
2004-11-17 04:25:10 +00:00
|
|
|
int i;
|
2001-10-25 05:32:01 +00:00
|
|
|
|
2012-03-28 01:08:55 +00:00
|
|
|
if (sc->flags & FXP_FLAG_NO_UCODE)
|
|
|
|
return;
|
|
|
|
|
2001-10-25 05:32:01 +00:00
|
|
|
for (uc = ucode_table; uc->ucode != NULL; uc++)
|
|
|
|
if (sc->revision == uc->revision)
|
|
|
|
break;
|
|
|
|
if (uc->ucode == NULL)
|
|
|
|
return;
|
2003-04-02 16:47:16 +00:00
|
|
|
cbp = (struct fxp_cb_ucode *)sc->fxp_desc.cbl_list;
|
2001-10-25 05:32:01 +00:00
|
|
|
cbp->cb_status = 0;
|
2003-04-06 01:04:17 +00:00
|
|
|
cbp->cb_command = htole16(FXP_CB_COMMAND_UCODE | FXP_CB_COMMAND_EL);
|
|
|
|
cbp->link_addr = 0xffffffff; /* (no) next command */
|
2004-11-17 04:25:10 +00:00
|
|
|
for (i = 0; i < uc->length; i++)
|
|
|
|
cbp->ucode[i] = htole32(uc->ucode[i]);
|
2001-10-25 05:32:01 +00:00
|
|
|
if (uc->int_delay_offset)
|
2005-03-06 05:07:26 +00:00
|
|
|
*(uint16_t *)&cbp->ucode[uc->int_delay_offset] =
|
2003-04-06 01:04:17 +00:00
|
|
|
htole16(sc->tunable_int_delay + sc->tunable_int_delay / 2);
|
2001-10-25 05:32:01 +00:00
|
|
|
if (uc->bundle_max_offset)
|
2005-03-06 05:07:26 +00:00
|
|
|
*(uint16_t *)&cbp->ucode[uc->bundle_max_offset] =
|
2003-04-06 01:04:17 +00:00
|
|
|
htole16(sc->tunable_bundle_max);
|
2001-10-25 05:32:01 +00:00
|
|
|
/*
|
|
|
|
* Download the ucode to the chip.
|
|
|
|
*/
|
|
|
|
fxp_scb_wait(sc);
|
2009-06-10 01:15:30 +00:00
|
|
|
bus_dmamap_sync(sc->cbl_tag, sc->cbl_map,
|
|
|
|
BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
|
2003-04-02 16:47:16 +00:00
|
|
|
CSR_WRITE_4(sc, FXP_CSR_SCB_GENERAL, sc->fxp_desc.cbl_addr);
|
2001-10-25 05:32:01 +00:00
|
|
|
fxp_scb_cmd(sc, FXP_SCB_COMMAND_CU_START);
|
|
|
|
/* ...and wait for it to complete. */
|
2003-04-08 18:56:45 +00:00
|
|
|
fxp_dma_wait(sc, &cbp->cb_status, sc->cbl_tag, sc->cbl_map);
|
2001-10-25 05:32:01 +00:00
|
|
|
device_printf(sc->dev,
|
|
|
|
"Microcode loaded, int_delay: %d usec bundle_max: %d\n",
|
2008-11-25 00:48:05 +00:00
|
|
|
sc->tunable_int_delay,
|
2001-10-25 05:32:01 +00:00
|
|
|
uc->bundle_max_offset == 0 ? 0 : sc->tunable_bundle_max);
|
|
|
|
sc->flags |= FXP_FLAG_UCODE;
|
2012-03-28 01:08:55 +00:00
|
|
|
bzero(cbp, FXP_TXCB_SZ);
|
2001-10-25 05:32:01 +00:00
|
|
|
}
|
|
|
|
|
2010-05-09 22:16:15 +00:00
|
|
|
#define FXP_SYSCTL_STAT_ADD(c, h, n, p, d) \
|
|
|
|
SYSCTL_ADD_UINT(c, h, OID_AUTO, n, CTLFLAG_RD, p, 0, d)
|
|
|
|
|
|
|
|
static void
|
|
|
|
fxp_sysctl_node(struct fxp_softc *sc)
|
|
|
|
{
|
|
|
|
struct sysctl_ctx_list *ctx;
|
|
|
|
struct sysctl_oid_list *child, *parent;
|
|
|
|
struct sysctl_oid *tree;
|
|
|
|
struct fxp_hwstats *hsp;
|
|
|
|
|
|
|
|
ctx = device_get_sysctl_ctx(sc->dev);
|
|
|
|
child = SYSCTL_CHILDREN(device_get_sysctl_tree(sc->dev));
|
|
|
|
|
|
|
|
SYSCTL_ADD_PROC(ctx, child,
|
|
|
|
OID_AUTO, "int_delay", CTLTYPE_INT | CTLFLAG_RW,
|
|
|
|
&sc->tunable_int_delay, 0, sysctl_hw_fxp_int_delay, "I",
|
|
|
|
"FXP driver receive interrupt microcode bundling delay");
|
|
|
|
SYSCTL_ADD_PROC(ctx, child,
|
|
|
|
OID_AUTO, "bundle_max", CTLTYPE_INT | CTLFLAG_RW,
|
|
|
|
&sc->tunable_bundle_max, 0, sysctl_hw_fxp_bundle_max, "I",
|
|
|
|
"FXP driver receive interrupt microcode bundle size limit");
|
|
|
|
SYSCTL_ADD_INT(ctx, child,OID_AUTO, "rnr", CTLFLAG_RD, &sc->rnr, 0,
|
|
|
|
"FXP RNR events");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Pull in device tunables.
|
|
|
|
*/
|
|
|
|
sc->tunable_int_delay = TUNABLE_INT_DELAY;
|
|
|
|
sc->tunable_bundle_max = TUNABLE_BUNDLE_MAX;
|
|
|
|
(void) resource_int_value(device_get_name(sc->dev),
|
|
|
|
device_get_unit(sc->dev), "int_delay", &sc->tunable_int_delay);
|
|
|
|
(void) resource_int_value(device_get_name(sc->dev),
|
|
|
|
device_get_unit(sc->dev), "bundle_max", &sc->tunable_bundle_max);
|
|
|
|
sc->rnr = 0;
|
|
|
|
|
|
|
|
hsp = &sc->fxp_hwstats;
|
|
|
|
tree = SYSCTL_ADD_NODE(ctx, child, OID_AUTO, "stats", CTLFLAG_RD,
|
|
|
|
NULL, "FXP statistics");
|
|
|
|
parent = SYSCTL_CHILDREN(tree);
|
|
|
|
|
|
|
|
/* Rx MAC statistics. */
|
|
|
|
tree = SYSCTL_ADD_NODE(ctx, parent, OID_AUTO, "rx", CTLFLAG_RD,
|
|
|
|
NULL, "Rx MAC statistics");
|
|
|
|
child = SYSCTL_CHILDREN(tree);
|
|
|
|
FXP_SYSCTL_STAT_ADD(ctx, child, "good_frames",
|
|
|
|
&hsp->rx_good, "Good frames");
|
|
|
|
FXP_SYSCTL_STAT_ADD(ctx, child, "crc_errors",
|
|
|
|
&hsp->rx_crc_errors, "CRC errors");
|
|
|
|
FXP_SYSCTL_STAT_ADD(ctx, child, "alignment_errors",
|
|
|
|
&hsp->rx_alignment_errors, "Alignment errors");
|
|
|
|
FXP_SYSCTL_STAT_ADD(ctx, child, "rnr_errors",
|
|
|
|
&hsp->rx_rnr_errors, "RNR errors");
|
|
|
|
FXP_SYSCTL_STAT_ADD(ctx, child, "overrun_errors",
|
|
|
|
&hsp->rx_overrun_errors, "Overrun errors");
|
|
|
|
FXP_SYSCTL_STAT_ADD(ctx, child, "cdt_errors",
|
|
|
|
&hsp->rx_cdt_errors, "Collision detect errors");
|
|
|
|
FXP_SYSCTL_STAT_ADD(ctx, child, "shortframes",
|
|
|
|
&hsp->rx_shortframes, "Short frame errors");
|
|
|
|
if (sc->revision >= FXP_REV_82558_A4) {
|
|
|
|
FXP_SYSCTL_STAT_ADD(ctx, child, "pause",
|
|
|
|
&hsp->rx_pause, "Pause frames");
|
|
|
|
FXP_SYSCTL_STAT_ADD(ctx, child, "controls",
|
|
|
|
&hsp->rx_controls, "Unsupported control frames");
|
|
|
|
}
|
|
|
|
if (sc->revision >= FXP_REV_82559_A0)
|
|
|
|
FXP_SYSCTL_STAT_ADD(ctx, child, "tco",
|
|
|
|
&hsp->rx_tco, "TCO frames");
|
|
|
|
|
|
|
|
/* Tx MAC statistics. */
|
|
|
|
tree = SYSCTL_ADD_NODE(ctx, parent, OID_AUTO, "tx", CTLFLAG_RD,
|
|
|
|
NULL, "Tx MAC statistics");
|
|
|
|
child = SYSCTL_CHILDREN(tree);
|
|
|
|
FXP_SYSCTL_STAT_ADD(ctx, child, "good_frames",
|
|
|
|
&hsp->tx_good, "Good frames");
|
|
|
|
FXP_SYSCTL_STAT_ADD(ctx, child, "maxcols",
|
|
|
|
&hsp->tx_maxcols, "Maximum collisions errors");
|
|
|
|
FXP_SYSCTL_STAT_ADD(ctx, child, "latecols",
|
|
|
|
&hsp->tx_latecols, "Late collisions errors");
|
|
|
|
FXP_SYSCTL_STAT_ADD(ctx, child, "underruns",
|
|
|
|
&hsp->tx_underruns, "Underrun errors");
|
|
|
|
FXP_SYSCTL_STAT_ADD(ctx, child, "lostcrs",
|
|
|
|
&hsp->tx_lostcrs, "Lost carrier sense");
|
|
|
|
FXP_SYSCTL_STAT_ADD(ctx, child, "deffered",
|
|
|
|
&hsp->tx_deffered, "Deferred");
|
|
|
|
FXP_SYSCTL_STAT_ADD(ctx, child, "single_collisions",
|
|
|
|
&hsp->tx_single_collisions, "Single collisions");
|
|
|
|
FXP_SYSCTL_STAT_ADD(ctx, child, "multiple_collisions",
|
|
|
|
&hsp->tx_multiple_collisions, "Multiple collisions");
|
|
|
|
FXP_SYSCTL_STAT_ADD(ctx, child, "total_collisions",
|
|
|
|
&hsp->tx_total_collisions, "Total collisions");
|
|
|
|
if (sc->revision >= FXP_REV_82558_A4)
|
|
|
|
FXP_SYSCTL_STAT_ADD(ctx, child, "pause",
|
|
|
|
&hsp->tx_pause, "Pause frames");
|
|
|
|
if (sc->revision >= FXP_REV_82559_A0)
|
|
|
|
FXP_SYSCTL_STAT_ADD(ctx, child, "tco",
|
|
|
|
&hsp->tx_tco, "TCO frames");
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef FXP_SYSCTL_STAT_ADD
|
|
|
|
|
2001-10-25 05:32:01 +00:00
|
|
|
static int
|
|
|
|
sysctl_int_range(SYSCTL_HANDLER_ARGS, int low, int high)
|
|
|
|
{
|
|
|
|
int error, value;
|
|
|
|
|
|
|
|
value = *(int *)arg1;
|
|
|
|
error = sysctl_handle_int(oidp, &value, 0, req);
|
|
|
|
if (error || !req->newptr)
|
|
|
|
return (error);
|
|
|
|
if (value < low || value > high)
|
|
|
|
return (EINVAL);
|
|
|
|
*(int *)arg1 = value;
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Interrupt delay is expressed in microseconds, a multiplier is used
|
2008-11-25 00:48:05 +00:00
|
|
|
* to convert this to the appropriate clock ticks before using.
|
2001-10-25 05:32:01 +00:00
|
|
|
*/
|
|
|
|
static int
|
|
|
|
sysctl_hw_fxp_int_delay(SYSCTL_HANDLER_ARGS)
|
|
|
|
{
|
2010-11-23 21:09:42 +00:00
|
|
|
|
2001-10-25 05:32:01 +00:00
|
|
|
return (sysctl_int_range(oidp, arg1, arg2, req, 300, 3000));
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
sysctl_hw_fxp_bundle_max(SYSCTL_HANDLER_ARGS)
|
|
|
|
{
|
2010-11-23 21:09:42 +00:00
|
|
|
|
2001-10-25 05:32:01 +00:00
|
|
|
return (sysctl_int_range(oidp, arg1, arg2, req, 1, 0xffff));
|
|
|
|
}
|