2012-02-02 23:42:57 +04:00
|
|
|
/* $NetBSD: elinkxlvar.h,v 1.24 2012/02/02 19:43:03 tls Exp $ */
|
1998-11-04 03:29:28 +03:00
|
|
|
|
|
|
|
/*-
|
|
|
|
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
* by Frank van der Linden.
|
|
|
|
*
|
|
|
|
* 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, 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/rnd.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Ethernet software status per interface.
|
|
|
|
*/
|
|
|
|
struct ex_softc {
|
2008-04-15 00:03:13 +04:00
|
|
|
device_t sc_dev;
|
2010-03-22 20:11:19 +03:00
|
|
|
device_suspensor_t sc_suspensor;
|
|
|
|
pmf_qual_t sc_qual;
|
1998-11-04 03:29:28 +03:00
|
|
|
void *sc_ih;
|
|
|
|
|
|
|
|
struct ethercom sc_ethercom; /* Ethernet common part */
|
|
|
|
bus_space_tag_t sc_iot; /* bus cookie */
|
|
|
|
bus_space_handle_t sc_ioh; /* bus i/o handle */
|
|
|
|
bus_dma_tag_t sc_dmat; /* bus dma tag */
|
|
|
|
bus_dmamap_t sc_dpd_dmamap;
|
|
|
|
bus_dmamap_t sc_upd_dmamap;
|
|
|
|
#define sc_upddma sc_upd_dmamap->dm_segs[0].ds_addr
|
|
|
|
#define sc_dpddma sc_dpd_dmamap->dm_segs[0].ds_addr
|
|
|
|
struct ex_upd *sc_upd;
|
|
|
|
struct ex_dpd *sc_dpd;
|
|
|
|
bus_dmamap_t sc_tx_dmamaps[EX_NDPD]; /* DMA maps for DPDs */
|
|
|
|
bus_dmamap_t sc_rx_dmamaps[EX_NUPD]; /* DMA maps for UPDs */
|
|
|
|
struct ex_rxdesc sc_rxdescs[EX_NUPD];
|
|
|
|
struct ex_txdesc sc_txdescs[EX_NDPD];
|
|
|
|
|
|
|
|
struct ex_rxdesc *rx_head;
|
|
|
|
struct ex_rxdesc *rx_tail;
|
|
|
|
|
|
|
|
struct ex_txdesc *tx_head;
|
|
|
|
struct ex_txdesc *tx_tail;
|
|
|
|
struct ex_txdesc *tx_free;
|
|
|
|
struct ex_txdesc *tx_ftail;
|
|
|
|
|
|
|
|
int tx_start_thresh; /* Current TX_start_thresh. */
|
|
|
|
int tx_succ_ok; /* # packets sent in sequence */
|
|
|
|
|
|
|
|
u_int ex_connectors; /* Connectors on this card. */
|
|
|
|
mii_data_t ex_mii; /* mii bus data */
|
2000-03-23 10:01:25 +03:00
|
|
|
struct callout ex_mii_callout; /* mii callout */
|
1998-11-04 03:29:28 +03:00
|
|
|
u_int ex_conf; /* config flags */
|
|
|
|
|
|
|
|
#define EX_CONF_MII 0x0001 /* has MII bus */
|
|
|
|
#define EX_CONF_INTPHY 0x0002 /* has internal PHY */
|
|
|
|
#define EX_CONF_90XB 0x0004 /* is 90xB */
|
2000-09-19 05:15:06 +04:00
|
|
|
#define EX_CONF_INV_LED_POLARITY 0x0010 /* CardBus & MiniPCI: LED polarity */
|
|
|
|
#define EX_CONF_PHY_POWER 0x0020 /* CardBus & MiniPCI: PHY power */
|
|
|
|
#define EX_CONF_EEPROM_OFF 0x0040 /* EEPROM is offset by 0x30 */
|
|
|
|
#define EX_CONF_EEPROM_8BIT 0x0080 /* 8 bit EEPROM */
|
|
|
|
#define EX_CONF_PCI_FUNCREG 0x0100 /* Has PCI function registers */
|
|
|
|
#define EX_CONF_RESETHACK 0x0200 /* Hack to make reset work on 556B */
|
2003-06-06 02:11:21 +04:00
|
|
|
#define EX_CONF_NO_XCVR_PWR 0x0400 /* Hack to enable later 556B xcvr */
|
|
|
|
|
|
|
|
#define EX_XCVR_PWR_MAGICBITS 0x0900 /* NO_XCVR_PWR magic value */
|
1998-11-04 03:29:28 +03:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX code duplication from elink3var.h
|
|
|
|
*/
|
|
|
|
u_int ex_flags; /* capabilities flag (from EEPROM) */
|
|
|
|
#define EX_FLAGS_PNP 0x0001
|
|
|
|
#define EX_FLAGS_FULLDUPLEX 0x0002
|
|
|
|
#define EX_FLAGS_LARGEPKT 0x0004 /* 4k packet support */
|
|
|
|
#define EX_FLAGS_SLAVEDMA 0x0008
|
|
|
|
#define EX_FLAGS_SECONDDMA 0x0010
|
|
|
|
#define EX_FLAGS_FULLDMA 0x0020
|
|
|
|
#define EX_FLAGS_FRAGMENTDMA 0x0040
|
|
|
|
#define EX_FLAGS_CRC_PASSTHRU 0x0080
|
|
|
|
#define EX_FLAGS_TXDONE 0x0100
|
|
|
|
#define EX_FLAGS_NO_TXLENGTH 0x0200
|
|
|
|
#define EX_FLAGS_RXREPEAT 0x0400
|
|
|
|
#define EX_FLAGS_SNOOPING 0x0800
|
|
|
|
#define EX_FLAGS_100MBIT 0x1000
|
|
|
|
#define EX_FLAGS_POWERMGMT 0x2000
|
2000-05-29 21:37:12 +04:00
|
|
|
#define EX_FLAGS_ATTACHED 0x4000 /* attach has succeeded */
|
1998-11-04 03:29:28 +03:00
|
|
|
|
First step of random number subsystem rework described in
<20111022023242.BA26F14A158@mail.netbsd.org>. This change includes
the following:
An initial cleanup and minor reorganization of the entropy pool
code in sys/dev/rnd.c and sys/dev/rndpool.c. Several bugs are
fixed. Some effort is made to accumulate entropy more quickly at
boot time.
A generic interface, "rndsink", is added, for stream generators to
request that they be re-keyed with good quality entropy from the pool
as soon as it is available.
The arc4random()/arc4randbytes() implementation in libkern is
adjusted to use the rndsink interface for rekeying, which helps
address the problem of low-quality keys at boot time.
An implementation of the FIPS 140-2 statistical tests for random
number generator quality is provided (libkern/rngtest.c). This
is based on Greg Rose's implementation from Qualcomm.
A new random stream generator, nist_ctr_drbg, is provided. It is
based on an implementation of the NIST SP800-90 CTR_DRBG by
Henric Jungheim. This generator users AES in a modified counter
mode to generate a backtracking-resistant random stream.
An abstraction layer, "cprng", is provided for in-kernel consumers
of randomness. The arc4random/arc4randbytes API is deprecated for
in-kernel use. It is replaced by "cprng_strong". The current
cprng_fast implementation wraps the existing arc4random
implementation. The current cprng_strong implementation wraps the
new CTR_DRBG implementation. Both interfaces are rekeyed from
the entropy pool automatically at intervals justifiable from best
current cryptographic practice.
In some quick tests, cprng_fast() is about the same speed as
the old arc4randbytes(), and cprng_strong() is about 20% faster
than rnd_extract_data(). Performance is expected to improve.
The AES code in src/crypto/rijndael is no longer an optional
kernel component, as it is required by cprng_strong, which is
not an optional kernel component.
The entropy pool output is subjected to the rngtest tests at
startup time; if it fails, the system will reboot. There is
approximately a 3/10000 chance of a false positive from these
tests. Entropy pool _input_ from hardware random numbers is
subjected to the rngtest tests at attach time, as well as the
FIPS continuous-output test, to detect bad or stuck hardware
RNGs; if any are detected, they are detached, but the system
continues to run.
A problem with rndctl(8) is fixed -- datastructures with
pointers in arrays are no longer passed to userspace (this
was not a security problem, but rather a major issue for
compat32). A new kernel will require a new rndctl.
The sysctl kern.arandom() and kern.urandom() nodes are hooked
up to the new generators, but the /dev/*random pseudodevices
are not, yet.
Manual pages for the new kernel interfaces are forthcoming.
2011-11-20 02:51:18 +04:00
|
|
|
krndsource_t rnd_source;
|
1998-11-04 03:29:28 +03:00
|
|
|
|
|
|
|
/* power management hooks */
|
2005-02-04 05:10:35 +03:00
|
|
|
int (*enable)(struct ex_softc *);
|
|
|
|
void (*disable)(struct ex_softc *);
|
1998-11-04 03:29:28 +03:00
|
|
|
int enabled;
|
2001-01-30 22:27:39 +03:00
|
|
|
|
1999-10-15 10:07:17 +04:00
|
|
|
/* interrupt acknowledge hook */
|
2005-02-04 05:10:35 +03:00
|
|
|
void (*intr_ack)(struct ex_softc *);
|
2000-02-05 21:11:55 +03:00
|
|
|
|
|
|
|
bus_dma_segment_t sc_useg, sc_dseg;
|
|
|
|
int sc_urseg, sc_drseg;
|
2005-02-06 06:15:14 +03:00
|
|
|
|
|
|
|
short sc_if_flags;
|
1998-11-04 03:29:28 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#define ex_waitcmd(sc) \
|
2001-10-25 14:02:12 +04:00
|
|
|
do { \
|
|
|
|
int stat; \
|
|
|
|
do { \
|
|
|
|
stat = bus_space_read_2((sc)->sc_iot, (sc)->sc_ioh, \
|
|
|
|
ELINK_STATUS); \
|
2001-12-28 23:35:46 +03:00
|
|
|
} while ((stat & COMMAND_IN_PROGRESS) && (stat != 0xffff)); \
|
2001-10-25 14:02:12 +04:00
|
|
|
} while (0)\
|
1998-11-04 03:29:28 +03:00
|
|
|
|
2005-02-04 05:10:35 +03:00
|
|
|
u_int16_t exreadeeprom(bus_space_tag_t, bus_space_handle_t, int);
|
|
|
|
void ex_config(struct ex_softc *);
|
1998-11-04 03:29:28 +03:00
|
|
|
|
2005-02-04 05:10:35 +03:00
|
|
|
int ex_intr(void *);
|
|
|
|
void ex_stop(struct ifnet *, int);
|
|
|
|
void ex_watchdog(struct ifnet *);
|
2007-03-04 08:59:00 +03:00
|
|
|
int ex_ioctl(struct ifnet *ifp, u_long, void *);
|
2008-04-15 00:03:13 +04:00
|
|
|
int ex_activate(device_t, enum devact);
|
2005-02-04 05:10:35 +03:00
|
|
|
int ex_detach(struct ex_softc *);
|
2002-06-21 03:47:25 +04:00
|
|
|
|
2005-02-04 05:10:35 +03:00
|
|
|
int ex_enable(struct ex_softc *);
|
|
|
|
void ex_disable(struct ex_softc *);
|