2008-12-17 18:41:24 +03:00
|
|
|
/* $NetBSD: if_iy.c,v 1.83 2008/12/17 15:41:24 cegger Exp $ */
|
1996-05-07 01:36:51 +04:00
|
|
|
/* #define IYDEBUG */
|
|
|
|
/* #define IYMEMDEBUG */
|
1999-02-17 01:46:55 +03:00
|
|
|
|
1996-05-07 01:36:51 +04:00
|
|
|
/*-
|
2001-03-23 16:15:27 +03:00
|
|
|
* Copyright (c) 1996,2001 The NetBSD Foundation, Inc.
|
1996-05-07 01:36:51 +04:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
1999-02-17 01:46:55 +03:00
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
* by Ignatios Souvatzis.
|
|
|
|
*
|
1996-05-07 01:36:51 +04:00
|
|
|
* 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.
|
|
|
|
*
|
1999-02-17 01:46:55 +03:00
|
|
|
* 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.
|
1996-05-07 01:36:51 +04:00
|
|
|
*/
|
|
|
|
|
1998-07-31 01:28:15 +04:00
|
|
|
/*
|
|
|
|
* Supported hardware:
|
|
|
|
*
|
|
|
|
* - Intel EtherExpress Pro/10.
|
|
|
|
* - possibly other boards using the i82595 chip and no special tweaks.
|
|
|
|
*/
|
|
|
|
|
2001-11-13 11:01:09 +03:00
|
|
|
#include <sys/cdefs.h>
|
2008-12-17 18:41:24 +03:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: if_iy.c,v 1.83 2008/12/17 15:41:24 cegger Exp $");
|
2001-11-13 11:01:09 +03:00
|
|
|
|
1998-07-05 04:51:04 +04:00
|
|
|
#include "opt_inet.h"
|
1996-05-07 01:36:51 +04:00
|
|
|
#include "bpfilter.h"
|
1997-10-15 09:55:13 +04:00
|
|
|
#include "rnd.h"
|
1996-05-07 01:36:51 +04:00
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/mbuf.h>
|
|
|
|
#include <sys/buf.h>
|
|
|
|
#include <sys/protosw.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <sys/errno.h>
|
|
|
|
#include <sys/syslog.h>
|
|
|
|
#include <sys/device.h>
|
2000-07-21 17:54:38 +04:00
|
|
|
#include <sys/endian.h>
|
1997-10-15 09:55:13 +04:00
|
|
|
#if NRND > 0
|
|
|
|
#include <sys/rnd.h>
|
|
|
|
#endif
|
1996-05-07 01:36:51 +04:00
|
|
|
|
|
|
|
#include <net/if.h>
|
|
|
|
#include <net/if_types.h>
|
|
|
|
#include <net/if_dl.h>
|
1997-03-15 21:09:08 +03:00
|
|
|
|
|
|
|
#include <net/if_ether.h>
|
1996-05-07 01:36:51 +04:00
|
|
|
|
|
|
|
#if NBPFILTER > 0
|
|
|
|
#include <net/bpf.h>
|
|
|
|
#include <net/bpfdesc.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef INET
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <netinet/in_systm.h>
|
|
|
|
#include <netinet/in_var.h>
|
|
|
|
#include <netinet/ip.h>
|
1997-03-15 21:09:08 +03:00
|
|
|
#include <netinet/if_inarp.h>
|
1996-05-07 01:36:51 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
1997-12-02 12:34:03 +03:00
|
|
|
#if defined(SIOCSIFMEDIA)
|
|
|
|
#include <net/if_media.h>
|
|
|
|
#endif
|
|
|
|
|
2007-10-19 15:59:34 +04:00
|
|
|
#include <sys/cpu.h>
|
|
|
|
#include <sys/bus.h>
|
|
|
|
#include <sys/intr.h>
|
1996-05-07 01:36:51 +04:00
|
|
|
|
|
|
|
#include <dev/isa/isareg.h>
|
|
|
|
#include <dev/isa/isavar.h>
|
|
|
|
#include <dev/ic/i82595reg.h>
|
|
|
|
|
2000-07-21 17:54:38 +04:00
|
|
|
/* XXX why isn't this centralized? */
|
|
|
|
#ifndef __BUS_SPACE_HAS_STREAM_METHODS
|
|
|
|
#define bus_space_write_stream_2 bus_space_write_2
|
|
|
|
#define bus_space_write_multi_stream_2 bus_space_write_multi_2
|
|
|
|
#define bus_space_read_stream_2 bus_space_read_2
|
|
|
|
#define bus_space_read_multi_stream_2 bus_space_read_multi_2
|
|
|
|
#endif /* __BUS_SPACE_HAS_STREAM_METHODS */
|
|
|
|
|
1996-05-07 01:36:51 +04:00
|
|
|
/*
|
|
|
|
* Ethernet status, per interface.
|
|
|
|
*/
|
|
|
|
struct iy_softc {
|
|
|
|
struct device sc_dev;
|
|
|
|
void *sc_ih;
|
|
|
|
|
1996-10-22 02:34:38 +04:00
|
|
|
bus_space_tag_t sc_iot;
|
|
|
|
bus_space_handle_t sc_ioh;
|
1996-07-25 22:59:12 +04:00
|
|
|
|
1997-03-15 21:09:08 +03:00
|
|
|
struct ethercom sc_ethercom;
|
1996-05-07 01:36:51 +04:00
|
|
|
|
1997-12-02 12:34:03 +03:00
|
|
|
struct ifmedia iy_ifmedia;
|
|
|
|
int iy_media;
|
|
|
|
|
1996-05-07 01:36:51 +04:00
|
|
|
int mappedirq;
|
|
|
|
|
|
|
|
int hard_vers;
|
|
|
|
|
|
|
|
int promisc;
|
|
|
|
|
|
|
|
int sram, tx_size, rx_size;
|
|
|
|
|
|
|
|
int tx_start, tx_end, tx_last;
|
|
|
|
int rx_start;
|
|
|
|
|
1998-07-30 20:40:19 +04:00
|
|
|
int doing_mc_setup;
|
1996-05-07 01:36:51 +04:00
|
|
|
#ifdef IYDEBUG
|
|
|
|
int sc_debug;
|
|
|
|
#endif
|
1997-10-15 09:55:13 +04:00
|
|
|
|
|
|
|
#if NRND > 0
|
|
|
|
rndsource_element_t rnd_source;
|
|
|
|
#endif
|
1996-05-07 01:36:51 +04:00
|
|
|
};
|
|
|
|
|
2005-02-04 05:10:35 +03:00
|
|
|
void iywatchdog(struct ifnet *);
|
2007-03-04 08:59:00 +03:00
|
|
|
int iyioctl(struct ifnet *, u_long, void *);
|
2005-02-04 05:10:35 +03:00
|
|
|
int iyintr(void *);
|
|
|
|
void iyinit(struct iy_softc *);
|
|
|
|
void iystop(struct iy_softc *);
|
|
|
|
void iystart(struct ifnet *);
|
|
|
|
|
|
|
|
void iy_intr_rx(struct iy_softc *);
|
|
|
|
void iy_intr_tx(struct iy_softc *);
|
|
|
|
|
|
|
|
void iyreset(struct iy_softc *);
|
|
|
|
void iy_readframe(struct iy_softc *, int);
|
|
|
|
void iy_drop_packet_buffer(struct iy_softc *);
|
|
|
|
void iy_find_mem_size(struct iy_softc *);
|
|
|
|
void iyrint(struct iy_softc *);
|
|
|
|
void iytint(struct iy_softc *);
|
|
|
|
void iyxmit(struct iy_softc *);
|
|
|
|
static void iy_mc_setup(struct iy_softc *);
|
|
|
|
static void iy_mc_reset(struct iy_softc *);
|
|
|
|
void iyget(struct iy_softc *, bus_space_tag_t, bus_space_handle_t, int);
|
|
|
|
void iyprobemem(struct iy_softc *);
|
2005-12-24 23:27:29 +03:00
|
|
|
static inline void eepromwritebit(bus_space_tag_t, bus_space_handle_t, int);
|
|
|
|
static inline int eepromreadbit(bus_space_tag_t, bus_space_handle_t);
|
1998-07-30 20:40:19 +04:00
|
|
|
|
1996-05-07 01:36:51 +04:00
|
|
|
#ifdef IYDEBUGX
|
2005-02-04 05:10:35 +03:00
|
|
|
void print_rbd(volatile struct iy_recv_buf_desc *);
|
1996-05-07 01:36:51 +04:00
|
|
|
|
|
|
|
int in_ifrint = 0;
|
|
|
|
int in_iftint = 0;
|
|
|
|
#endif
|
|
|
|
|
2005-02-04 05:10:35 +03:00
|
|
|
int iy_mediachange(struct ifnet *);
|
|
|
|
void iy_mediastatus(struct ifnet *, struct ifmediareq *);
|
1997-12-02 12:34:03 +03:00
|
|
|
|
2005-02-04 05:10:35 +03:00
|
|
|
int iyprobe(struct device *, struct cfdata *, void *);
|
|
|
|
void iyattach(struct device *, struct device *, void *);
|
1996-05-07 01:36:51 +04:00
|
|
|
|
2005-02-04 05:10:35 +03:00
|
|
|
static u_int16_t eepromread(bus_space_tag_t, bus_space_handle_t, int);
|
1997-03-15 21:09:08 +03:00
|
|
|
|
2005-02-04 05:10:35 +03:00
|
|
|
static int eepromreadall(bus_space_tag_t, bus_space_handle_t, u_int16_t *,
|
|
|
|
int);
|
1996-05-07 01:36:51 +04:00
|
|
|
|
2002-10-02 06:00:07 +04:00
|
|
|
CFATTACH_DECL(iy, sizeof(struct iy_softc),
|
2002-10-02 07:10:45 +04:00
|
|
|
iyprobe, iyattach, NULL, NULL);
|
1996-05-07 01:36:51 +04:00
|
|
|
|
|
|
|
static u_int8_t eepro_irqmap[] = EEPP_INTMAP;
|
|
|
|
static u_int8_t eepro_revirqmap[] = EEPP_RINTMAP;
|
|
|
|
|
|
|
|
int
|
2006-11-16 04:32:37 +03:00
|
|
|
iyprobe(struct device *parent, struct cfdata *match,
|
2006-10-12 05:30:41 +04:00
|
|
|
void *aux)
|
1996-05-07 01:36:51 +04:00
|
|
|
{
|
|
|
|
struct isa_attach_args *ia = aux;
|
|
|
|
u_int16_t eaddr[8];
|
1996-10-22 02:34:38 +04:00
|
|
|
bus_space_tag_t iot;
|
|
|
|
bus_space_handle_t ioh;
|
1996-05-07 01:36:51 +04:00
|
|
|
u_int8_t c, d;
|
2002-01-08 00:46:56 +03:00
|
|
|
int irq;
|
|
|
|
|
|
|
|
if (ia->ia_nio < 1)
|
|
|
|
return (0);
|
|
|
|
if (ia->ia_nirq < 1)
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
if (ISA_DIRECT_CONFIG(ia))
|
|
|
|
return (0);
|
1996-05-07 01:36:51 +04:00
|
|
|
|
1996-10-22 02:34:38 +04:00
|
|
|
iot = ia->ia_iot;
|
1997-10-18 18:09:52 +04:00
|
|
|
|
2004-09-15 00:20:46 +04:00
|
|
|
if (ia->ia_io[0].ir_addr == ISA_UNKNOWN_PORT)
|
1997-10-18 18:09:52 +04:00
|
|
|
return 0;
|
|
|
|
|
2002-01-08 00:46:56 +03:00
|
|
|
if (bus_space_map(iot, ia->ia_io[0].ir_addr, 16, 0, &ioh))
|
1997-03-15 21:09:08 +03:00
|
|
|
return 0;
|
1996-05-07 01:36:51 +04:00
|
|
|
|
1996-07-25 22:59:12 +04:00
|
|
|
/* try to find the round robin sig: */
|
1996-05-07 01:36:51 +04:00
|
|
|
|
1996-10-22 02:34:38 +04:00
|
|
|
c = bus_space_read_1(iot, ioh, ID_REG);
|
1997-03-15 21:09:08 +03:00
|
|
|
if ((c & ID_REG_MASK) != ID_REG_SIG)
|
1996-07-25 22:59:12 +04:00
|
|
|
goto out;
|
1996-05-07 01:36:51 +04:00
|
|
|
|
1996-10-22 02:34:38 +04:00
|
|
|
d = bus_space_read_1(iot, ioh, ID_REG);
|
1997-03-15 21:09:08 +03:00
|
|
|
if ((d & ID_REG_MASK) != ID_REG_SIG)
|
1996-07-25 22:59:12 +04:00
|
|
|
goto out;
|
1996-05-07 01:36:51 +04:00
|
|
|
|
|
|
|
if (((d-c) & R_ROBIN_BITS) != 0x40)
|
1996-07-25 22:59:12 +04:00
|
|
|
goto out;
|
2005-02-27 03:26:58 +03:00
|
|
|
|
1996-10-22 02:34:38 +04:00
|
|
|
d = bus_space_read_1(iot, ioh, ID_REG);
|
1997-03-15 21:09:08 +03:00
|
|
|
if ((d & ID_REG_MASK) != ID_REG_SIG)
|
1996-07-25 22:59:12 +04:00
|
|
|
goto out;
|
1996-05-07 01:36:51 +04:00
|
|
|
|
|
|
|
if (((d-c) & R_ROBIN_BITS) != 0x80)
|
1996-07-25 22:59:12 +04:00
|
|
|
goto out;
|
2005-02-27 03:26:58 +03:00
|
|
|
|
1996-10-22 02:34:38 +04:00
|
|
|
d = bus_space_read_1(iot, ioh, ID_REG);
|
1997-03-15 21:09:08 +03:00
|
|
|
if ((d & ID_REG_MASK) != ID_REG_SIG)
|
1996-07-25 22:59:12 +04:00
|
|
|
goto out;
|
1996-05-07 01:36:51 +04:00
|
|
|
|
|
|
|
if (((d-c) & R_ROBIN_BITS) != 0xC0)
|
1996-07-25 22:59:12 +04:00
|
|
|
goto out;
|
2005-02-27 03:26:58 +03:00
|
|
|
|
1996-10-22 02:34:38 +04:00
|
|
|
d = bus_space_read_1(iot, ioh, ID_REG);
|
1997-03-15 21:09:08 +03:00
|
|
|
if ((d & ID_REG_MASK) != ID_REG_SIG)
|
1996-07-25 22:59:12 +04:00
|
|
|
goto out;
|
1996-05-07 01:36:51 +04:00
|
|
|
|
|
|
|
if (((d-c) & R_ROBIN_BITS) != 0x00)
|
1996-07-25 22:59:12 +04:00
|
|
|
goto out;
|
2005-02-27 03:26:58 +03:00
|
|
|
|
1996-05-07 01:36:51 +04:00
|
|
|
#ifdef IYDEBUG
|
1997-03-15 21:09:08 +03:00
|
|
|
printf("iyprobe verified working ID reg.\n");
|
1996-05-07 01:36:51 +04:00
|
|
|
#endif
|
2005-02-27 03:26:58 +03:00
|
|
|
|
1997-03-15 21:09:08 +03:00
|
|
|
if (eepromreadall(iot, ioh, eaddr, 8))
|
|
|
|
goto out;
|
2005-02-27 03:26:58 +03:00
|
|
|
|
2004-09-15 00:20:46 +04:00
|
|
|
if (ia->ia_irq[0].ir_irq == ISA_UNKNOWN_IRQ)
|
2002-01-08 00:46:56 +03:00
|
|
|
irq = eepro_irqmap[eaddr[EEPPW1] & EEPP_Int];
|
|
|
|
else
|
|
|
|
irq = ia->ia_irq[0].ir_irq;
|
1996-05-07 01:36:51 +04:00
|
|
|
|
2002-01-08 00:46:56 +03:00
|
|
|
if (irq >= sizeof(eepro_revirqmap))
|
1996-07-25 22:59:12 +04:00
|
|
|
goto out;
|
1996-05-07 01:36:51 +04:00
|
|
|
|
2002-01-08 00:46:56 +03:00
|
|
|
if (eepro_revirqmap[irq] == 0xff)
|
1996-07-25 22:59:12 +04:00
|
|
|
goto out;
|
1996-05-07 01:36:51 +04:00
|
|
|
|
|
|
|
/* now lets reset the chip */
|
2005-02-27 03:26:58 +03:00
|
|
|
|
1996-10-22 02:34:38 +04:00
|
|
|
bus_space_write_1(iot, ioh, COMMAND_REG, RESET_CMD);
|
1996-05-07 01:36:51 +04:00
|
|
|
delay(200);
|
2005-02-27 03:26:58 +03:00
|
|
|
|
2002-01-08 00:46:56 +03:00
|
|
|
ia->ia_nio = 1;
|
|
|
|
ia->ia_io[0].ir_size = 16;
|
|
|
|
|
|
|
|
ia->ia_nirq = 1;
|
|
|
|
ia->ia_irq[0].ir_irq = irq;
|
|
|
|
|
|
|
|
ia->ia_niomem = 0;
|
|
|
|
ia->ia_ndrq = 0;
|
1996-07-25 22:59:12 +04:00
|
|
|
|
1997-03-15 21:09:08 +03:00
|
|
|
bus_space_unmap(iot, ioh, 16);
|
1996-05-07 01:36:51 +04:00
|
|
|
return 1; /* found */
|
1996-07-25 22:59:12 +04:00
|
|
|
out:
|
1996-10-22 02:34:38 +04:00
|
|
|
bus_space_unmap(iot, ioh, 16);
|
1996-07-25 22:59:12 +04:00
|
|
|
return 0;
|
1996-05-07 01:36:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-11-16 04:32:37 +03:00
|
|
|
iyattach(struct device *parent, struct device *self, void *aux)
|
1996-05-07 01:36:51 +04:00
|
|
|
{
|
|
|
|
struct iy_softc *sc = (void *)self;
|
|
|
|
struct isa_attach_args *ia = aux;
|
1997-03-15 21:09:08 +03:00
|
|
|
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
|
1996-10-22 02:34:38 +04:00
|
|
|
bus_space_tag_t iot;
|
|
|
|
bus_space_handle_t ioh;
|
1997-03-15 21:09:08 +03:00
|
|
|
unsigned temp;
|
|
|
|
u_int16_t eaddr[8];
|
|
|
|
u_int8_t myaddr[ETHER_ADDR_LEN];
|
|
|
|
int eirq;
|
1996-07-25 22:59:12 +04:00
|
|
|
|
1997-03-15 21:09:08 +03:00
|
|
|
iot = ia->ia_iot;
|
2005-02-27 03:26:58 +03:00
|
|
|
|
2002-01-08 00:46:56 +03:00
|
|
|
if (bus_space_map(iot, ia->ia_io[0].ir_addr, 16, 0, &ioh)) {
|
1997-10-20 22:43:03 +04:00
|
|
|
printf(": can't map i/o space\n");
|
|
|
|
return;
|
|
|
|
}
|
1997-03-15 21:09:08 +03:00
|
|
|
|
|
|
|
sc->sc_iot = iot;
|
|
|
|
sc->sc_ioh = ioh;
|
|
|
|
|
2002-01-08 00:46:56 +03:00
|
|
|
sc->mappedirq = eepro_revirqmap[ia->ia_irq[0].ir_irq];
|
1997-03-15 21:09:08 +03:00
|
|
|
|
|
|
|
/* now let's reset the chip */
|
2005-02-27 03:26:58 +03:00
|
|
|
|
1997-03-15 21:09:08 +03:00
|
|
|
bus_space_write_1(iot, ioh, COMMAND_REG, RESET_CMD);
|
|
|
|
delay(200);
|
2005-02-27 03:26:58 +03:00
|
|
|
|
1997-03-15 21:09:08 +03:00
|
|
|
iyprobemem(sc);
|
1996-05-07 01:36:51 +04:00
|
|
|
|
2008-04-09 00:08:49 +04:00
|
|
|
strlcpy(ifp->if_xname, device_xname(&sc->sc_dev), IFNAMSIZ);
|
1996-05-07 05:55:13 +04:00
|
|
|
ifp->if_softc = sc;
|
1996-05-07 01:36:51 +04:00
|
|
|
ifp->if_start = iystart;
|
1998-07-30 20:40:19 +04:00
|
|
|
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_NOTRAILERS
|
|
|
|
| IFF_MULTICAST;
|
|
|
|
|
|
|
|
sc->doing_mc_setup = 0;
|
1996-05-07 01:36:51 +04:00
|
|
|
|
|
|
|
ifp->if_ioctl = iyioctl;
|
|
|
|
ifp->if_watchdog = iywatchdog;
|
|
|
|
|
2000-12-14 09:59:01 +03:00
|
|
|
IFQ_SET_READY(&ifp->if_snd);
|
|
|
|
|
1997-03-15 21:09:08 +03:00
|
|
|
(void)eepromreadall(iot, ioh, eaddr, 8);
|
|
|
|
sc->hard_vers = eaddr[EEPW6] & EEPP_BoardRev;
|
|
|
|
|
|
|
|
#ifdef DIAGNOSTICS
|
2005-02-27 03:26:58 +03:00
|
|
|
if ((eaddr[EEPPEther0] !=
|
1997-03-15 21:09:08 +03:00
|
|
|
eepromread(iot, ioh, EEPPEther0a)) &&
|
2005-02-27 03:26:58 +03:00
|
|
|
(eaddr[EEPPEther1] !=
|
1997-03-15 21:09:08 +03:00
|
|
|
eepromread(iot, ioh, EEPPEther1a)) &&
|
2005-02-27 03:26:58 +03:00
|
|
|
(eaddr[EEPPEther2] !=
|
1997-03-15 21:09:08 +03:00
|
|
|
eepromread(iot, ioh, EEPPEther2a)))
|
|
|
|
|
|
|
|
printf("EEPROM Ethernet address differs from copy\n");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
myaddr[1] = eaddr[EEPPEther0] & 0xFF;
|
|
|
|
myaddr[0] = eaddr[EEPPEther0] >> 8;
|
|
|
|
myaddr[3] = eaddr[EEPPEther1] & 0xFF;
|
|
|
|
myaddr[2] = eaddr[EEPPEther1] >> 8;
|
|
|
|
myaddr[5] = eaddr[EEPPEther2] & 0xFF;
|
|
|
|
myaddr[4] = eaddr[EEPPEther2] >> 8;
|
2005-02-27 03:26:58 +03:00
|
|
|
|
1997-12-02 12:34:03 +03:00
|
|
|
ifmedia_init(&sc->iy_ifmedia, 0, iy_mediachange, iy_mediastatus);
|
|
|
|
ifmedia_add(&sc->iy_ifmedia, IFM_ETHER | IFM_10_2, 0, NULL);
|
|
|
|
ifmedia_add(&sc->iy_ifmedia, IFM_ETHER | IFM_10_5, 0, NULL);
|
|
|
|
ifmedia_add(&sc->iy_ifmedia, IFM_ETHER | IFM_10_T, 0, NULL);
|
|
|
|
ifmedia_add(&sc->iy_ifmedia, IFM_ETHER | IFM_AUTO, 0, NULL);
|
|
|
|
ifmedia_set(&sc->iy_ifmedia, IFM_ETHER | IFM_AUTO);
|
1996-05-07 01:36:51 +04:00
|
|
|
/* Attach the interface. */
|
|
|
|
if_attach(ifp);
|
1997-03-15 21:09:08 +03:00
|
|
|
ether_ifattach(ifp, myaddr);
|
|
|
|
printf(": address %s, rev. %d, %d kB\n",
|
|
|
|
ether_sprintf(myaddr),
|
1996-05-07 01:36:51 +04:00
|
|
|
sc->hard_vers, sc->sram/1024);
|
1997-03-15 21:09:08 +03:00
|
|
|
|
|
|
|
eirq = eepro_irqmap[eaddr[EEPPW1] & EEPP_Int];
|
2002-01-08 00:46:56 +03:00
|
|
|
if (eirq != ia->ia_irq[0].ir_irq)
|
1997-03-15 21:09:08 +03:00
|
|
|
printf("%s: EEPROM irq setting %d ignored\n",
|
2008-04-09 00:08:49 +04:00
|
|
|
device_xname(&sc->sc_dev), eirq);
|
1997-03-15 21:09:08 +03:00
|
|
|
|
2002-01-08 00:46:56 +03:00
|
|
|
sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq[0].ir_irq,
|
|
|
|
IST_EDGE, IPL_NET, iyintr, sc);
|
1997-03-15 21:09:08 +03:00
|
|
|
|
1997-10-15 09:55:13 +04:00
|
|
|
#if NRND > 0
|
2008-04-09 00:08:49 +04:00
|
|
|
rnd_attach_source(&sc->rnd_source, device_xname(&sc->sc_dev),
|
1999-02-28 20:08:05 +03:00
|
|
|
RND_TYPE_NET, 0);
|
1997-10-15 09:55:13 +04:00
|
|
|
#endif
|
|
|
|
|
1997-03-15 21:09:08 +03:00
|
|
|
temp = bus_space_read_1(iot, ioh, INT_NO_REG);
|
|
|
|
bus_space_write_1(iot, ioh, INT_NO_REG, (temp & 0xf8) | sc->mappedirq);
|
1996-05-07 01:36:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
iystop(sc)
|
|
|
|
struct iy_softc *sc;
|
|
|
|
{
|
1996-10-22 02:34:38 +04:00
|
|
|
bus_space_tag_t iot;
|
|
|
|
bus_space_handle_t ioh;
|
1996-05-07 01:36:51 +04:00
|
|
|
#ifdef IYDEBUG
|
|
|
|
u_int p, v;
|
|
|
|
#endif
|
|
|
|
|
1996-10-22 02:34:38 +04:00
|
|
|
iot = sc->sc_iot;
|
1996-07-25 22:59:12 +04:00
|
|
|
ioh = sc->sc_ioh;
|
2005-02-27 03:26:58 +03:00
|
|
|
|
1996-10-22 02:34:38 +04:00
|
|
|
bus_space_write_1(iot, ioh, COMMAND_REG, RCV_DISABLE_CMD);
|
1996-05-07 01:36:51 +04:00
|
|
|
|
1996-10-22 02:34:38 +04:00
|
|
|
bus_space_write_1(iot, ioh, INT_MASK_REG, ALL_INTS);
|
|
|
|
bus_space_write_1(iot, ioh, STATUS_REG, ALL_INTS);
|
1996-05-07 01:36:51 +04:00
|
|
|
|
1996-10-22 02:34:38 +04:00
|
|
|
bus_space_write_1(iot, ioh, COMMAND_REG, RESET_CMD);
|
1996-05-07 01:36:51 +04:00
|
|
|
delay(200);
|
2005-02-27 03:26:58 +03:00
|
|
|
#ifdef IYDEBUG
|
|
|
|
printf("%s: dumping tx chain (st 0x%x end 0x%x last 0x%x)\n",
|
2008-04-09 00:08:49 +04:00
|
|
|
device_xname(&sc->sc_dev), sc->tx_start, sc->tx_end, sc->tx_last);
|
1996-05-07 01:36:51 +04:00
|
|
|
p = sc->tx_last;
|
|
|
|
if (!p)
|
|
|
|
p = sc->tx_start;
|
|
|
|
do {
|
2000-08-09 05:56:33 +04:00
|
|
|
char sbuf[128];
|
|
|
|
|
1996-10-22 02:34:38 +04:00
|
|
|
bus_space_write_2(iot, ioh, HOST_ADDR_REG, p);
|
2000-08-09 05:56:33 +04:00
|
|
|
|
2000-07-21 17:54:38 +04:00
|
|
|
v = le16toh(bus_space_read_stream_2(iot, ioh, MEM_PORT_REG));
|
2008-12-17 01:35:21 +03:00
|
|
|
snprintb(sbuf, sizeof(sbuf), "\020\006Ab\010Dn", v);
|
2000-08-09 05:56:33 +04:00
|
|
|
printf("0x%04x: %s ", p, sbuf);
|
|
|
|
|
2000-07-21 17:54:38 +04:00
|
|
|
v = le16toh(bus_space_read_stream_2(iot, ioh, MEM_PORT_REG));
|
2008-12-17 01:35:21 +03:00
|
|
|
snprintb(sbuf, sizeof(sbuf),
|
|
|
|
"\020\6MAX_COL\7HRT_BEAT\010TX_DEF\011UND_RUN"
|
|
|
|
"\012JERR\013LST_CRS\014LTCOL\016TX_OK\020COLL", v);
|
2000-08-09 05:56:33 +04:00
|
|
|
printf("0x%s", sbuf);
|
|
|
|
|
2000-07-21 17:54:38 +04:00
|
|
|
p = le16toh(bus_space_read_stream_2(iot, ioh, MEM_PORT_REG));
|
1996-10-13 05:37:04 +04:00
|
|
|
printf(" 0x%04x", p);
|
2000-08-09 05:56:33 +04:00
|
|
|
|
2000-07-21 17:54:38 +04:00
|
|
|
v = le16toh(bus_space_read_stream_2(iot, ioh, MEM_PORT_REG));
|
2008-12-17 01:35:21 +03:00
|
|
|
snprintb(sbuf, sizeof(sbuf), "\020\020Ch", v);
|
2000-08-09 05:56:33 +04:00
|
|
|
printf(" 0x%s\n", sbuf);
|
|
|
|
|
1996-05-07 01:36:51 +04:00
|
|
|
} while (v & 0x8000);
|
|
|
|
#endif
|
|
|
|
sc->tx_start = sc->tx_end = sc->rx_size;
|
|
|
|
sc->tx_last = 0;
|
1997-03-15 21:09:08 +03:00
|
|
|
sc->sc_ethercom.ec_if.if_flags &= ~(IFF_RUNNING|IFF_OACTIVE);
|
1996-05-07 01:36:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
iyreset(sc)
|
|
|
|
struct iy_softc *sc;
|
|
|
|
{
|
|
|
|
int s;
|
1998-08-09 03:51:39 +04:00
|
|
|
s = splnet();
|
1996-05-07 01:36:51 +04:00
|
|
|
iystop(sc);
|
|
|
|
iyinit(sc);
|
|
|
|
splx(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
iyinit(sc)
|
|
|
|
struct iy_softc *sc;
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
unsigned temp;
|
|
|
|
struct ifnet *ifp;
|
1996-10-22 02:34:38 +04:00
|
|
|
bus_space_tag_t iot;
|
|
|
|
bus_space_handle_t ioh;
|
1996-07-25 22:59:12 +04:00
|
|
|
|
1996-10-22 02:34:38 +04:00
|
|
|
iot = sc->sc_iot;
|
1996-07-25 22:59:12 +04:00
|
|
|
ioh = sc->sc_ioh;
|
1996-05-07 01:36:51 +04:00
|
|
|
|
1997-03-15 21:09:08 +03:00
|
|
|
ifp = &sc->sc_ethercom.ec_if;
|
1996-05-07 01:36:51 +04:00
|
|
|
#ifdef IYDEBUG
|
1996-10-13 05:37:04 +04:00
|
|
|
printf("ifp is %p\n", ifp);
|
1996-05-07 01:36:51 +04:00
|
|
|
#endif
|
|
|
|
|
1996-10-22 02:34:38 +04:00
|
|
|
bus_space_write_1(iot, ioh, 0, BANK_SEL(2));
|
1996-05-07 01:36:51 +04:00
|
|
|
|
1996-10-22 02:34:38 +04:00
|
|
|
temp = bus_space_read_1(iot, ioh, EEPROM_REG);
|
1996-05-07 01:36:51 +04:00
|
|
|
if (temp & 0x10)
|
1996-10-22 02:34:38 +04:00
|
|
|
bus_space_write_1(iot, ioh, EEPROM_REG, temp & ~0x10);
|
2005-02-27 03:26:58 +03:00
|
|
|
|
1996-05-07 01:36:51 +04:00
|
|
|
for (i=0; i<6; ++i) {
|
2007-08-27 02:45:55 +04:00
|
|
|
bus_space_write_1(iot, ioh, I_ADD(i), CLLADDR(ifp->if_sadl)[i]);
|
1996-05-07 01:36:51 +04:00
|
|
|
}
|
|
|
|
|
1996-10-22 02:34:38 +04:00
|
|
|
temp = bus_space_read_1(iot, ioh, REG1);
|
1997-03-15 21:09:08 +03:00
|
|
|
bus_space_write_1(iot, ioh, REG1,
|
2001-03-16 16:02:51 +03:00
|
|
|
temp | /* XMT_CHAIN_INT | XMT_CHAIN_ERRSTOP | */ RCV_DISCARD_BAD);
|
2005-02-27 03:26:58 +03:00
|
|
|
|
1998-07-28 20:02:34 +04:00
|
|
|
if (ifp->if_flags & (IFF_PROMISC|IFF_ALLMULTI)) {
|
|
|
|
temp = MATCH_ALL;
|
2005-02-27 03:26:58 +03:00
|
|
|
} else
|
2001-03-22 17:30:47 +03:00
|
|
|
temp = MATCH_BRDCST;
|
1998-07-28 20:02:34 +04:00
|
|
|
|
|
|
|
bus_space_write_1(iot, ioh, RECV_MODES_REG, temp);
|
1998-07-30 20:40:19 +04:00
|
|
|
|
1996-05-07 01:36:51 +04:00
|
|
|
#ifdef IYDEBUG
|
2000-08-09 05:56:33 +04:00
|
|
|
{
|
|
|
|
char sbuf[128];
|
|
|
|
|
2008-12-17 01:35:21 +03:00
|
|
|
snprintb(sbuf, sizeof(sbuf),
|
|
|
|
"\020\1PRMSC\2NOBRDST\3SEECRC\4LENGTH\5NOSaIns\6MultiIA",
|
|
|
|
temp);
|
|
|
|
|
2008-04-09 00:08:49 +04:00
|
|
|
printf("%s: RECV_MODES set to %s\n", device_xname(&sc->sc_dev), sbuf);
|
2000-08-09 05:56:33 +04:00
|
|
|
}
|
1996-05-07 01:36:51 +04:00
|
|
|
#endif
|
1998-07-30 20:40:19 +04:00
|
|
|
/* XXX VOODOO */
|
|
|
|
temp = bus_space_read_1(iot, ioh, MEDIA_SELECT);
|
|
|
|
bus_space_write_1(iot, ioh, MEDIA_SELECT, temp);
|
|
|
|
/* XXX END OF VOODOO */
|
1996-05-07 01:36:51 +04:00
|
|
|
|
|
|
|
|
1997-03-15 21:09:08 +03:00
|
|
|
delay(500000); /* for the hardware to test for the connector */
|
1996-05-07 01:36:51 +04:00
|
|
|
|
1996-10-22 02:34:38 +04:00
|
|
|
temp = bus_space_read_1(iot, ioh, MEDIA_SELECT);
|
1996-05-07 01:36:51 +04:00
|
|
|
#ifdef IYDEBUG
|
2000-08-09 05:56:33 +04:00
|
|
|
{
|
|
|
|
char sbuf[128];
|
|
|
|
|
2008-12-17 01:35:21 +03:00
|
|
|
snprintb(sbuf, sizeof(sbuf),
|
2008-12-17 18:41:24 +03:00
|
|
|
"\020\1LnkInDis\2PolCor\3TPE\4JabberDis\5NoAport\6BNC",
|
|
|
|
temp);
|
2008-04-09 00:08:49 +04:00
|
|
|
printf("%s: media select was 0x%s ", device_xname(&sc->sc_dev), sbuf);
|
2000-08-09 05:56:33 +04:00
|
|
|
}
|
1996-05-07 01:36:51 +04:00
|
|
|
#endif
|
1996-05-22 19:39:43 +04:00
|
|
|
temp = (temp & TEST_MODE_MASK);
|
2005-02-27 03:26:58 +03:00
|
|
|
|
1997-12-02 12:34:03 +03:00
|
|
|
switch(IFM_SUBTYPE(sc->iy_ifmedia.ifm_media)) {
|
|
|
|
case IFM_10_5:
|
1996-07-25 22:59:12 +04:00
|
|
|
temp &= ~ (BNC_BIT | TPE_BIT);
|
|
|
|
break;
|
1996-05-22 19:39:43 +04:00
|
|
|
|
1997-12-02 12:34:03 +03:00
|
|
|
case IFM_10_2:
|
1997-03-15 21:09:08 +03:00
|
|
|
temp = (temp & ~TPE_BIT) | BNC_BIT;
|
1996-07-25 22:59:12 +04:00
|
|
|
break;
|
2005-02-27 03:26:58 +03:00
|
|
|
|
1997-12-02 12:34:03 +03:00
|
|
|
case IFM_10_T:
|
1997-03-15 21:09:08 +03:00
|
|
|
temp = (temp & ~BNC_BIT) | TPE_BIT;
|
1996-07-25 22:59:12 +04:00
|
|
|
break;
|
1996-05-22 19:39:43 +04:00
|
|
|
default:
|
2001-05-15 18:57:49 +04:00
|
|
|
;
|
1996-07-25 22:59:12 +04:00
|
|
|
/* nothing; leave as it is */
|
1996-05-22 19:39:43 +04:00
|
|
|
}
|
1997-12-02 12:34:03 +03:00
|
|
|
switch (temp & (BNC_BIT | TPE_BIT)) {
|
|
|
|
case BNC_BIT:
|
|
|
|
sc->iy_media = IFM_ETHER | IFM_10_2;
|
|
|
|
break;
|
|
|
|
case TPE_BIT:
|
|
|
|
sc->iy_media = IFM_ETHER | IFM_10_T;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
sc->iy_media = IFM_ETHER | IFM_10_5;
|
|
|
|
}
|
1996-07-25 22:59:12 +04:00
|
|
|
|
1996-10-22 02:34:38 +04:00
|
|
|
bus_space_write_1(iot, ioh, MEDIA_SELECT, temp);
|
1996-05-07 01:36:51 +04:00
|
|
|
#ifdef IYDEBUG
|
2000-08-09 05:56:33 +04:00
|
|
|
{
|
|
|
|
char sbuf[128];
|
|
|
|
|
2008-12-17 01:35:21 +03:00
|
|
|
snprintb(sbuf, sizeof(sbuf),
|
|
|
|
"\020\1LnkInDis\2PolCor\3TPE\4JabberDis\5NoAport\6BNC",
|
|
|
|
temp);
|
2000-08-09 05:56:33 +04:00
|
|
|
printf("changed to 0x%s\n", sbuf);
|
|
|
|
}
|
1996-05-07 01:36:51 +04:00
|
|
|
#endif
|
|
|
|
|
1997-03-15 21:09:08 +03:00
|
|
|
bus_space_write_1(iot, ioh, 0, BANK_SEL(0));
|
|
|
|
bus_space_write_1(iot, ioh, INT_MASK_REG, ALL_INTS);
|
1996-10-22 02:34:38 +04:00
|
|
|
bus_space_write_1(iot, ioh, 0, BANK_SEL(1));
|
1996-05-07 01:36:51 +04:00
|
|
|
|
1996-10-22 02:34:38 +04:00
|
|
|
temp = bus_space_read_1(iot, ioh, INT_NO_REG);
|
|
|
|
bus_space_write_1(iot, ioh, INT_NO_REG, (temp & 0xf8) | sc->mappedirq);
|
1996-05-07 01:36:51 +04:00
|
|
|
|
|
|
|
#ifdef IYDEBUG
|
2000-08-09 05:56:33 +04:00
|
|
|
{
|
|
|
|
char sbuf[128];
|
|
|
|
|
2008-12-17 01:35:21 +03:00
|
|
|
snprintb(sbuf, sizeof(sbuf),
|
|
|
|
"\020\4bad_irq\010flash/boot present", temp);
|
|
|
|
|
2008-04-09 00:08:49 +04:00
|
|
|
printf("%s: int no was %s\n", device_xname(&sc->sc_dev), sbuf);
|
2000-08-09 05:56:33 +04:00
|
|
|
|
|
|
|
temp = bus_space_read_1(iot, ioh, INT_NO_REG);
|
2008-12-17 01:35:21 +03:00
|
|
|
snprintb(sbuf, sizeof(sbuf),
|
|
|
|
"\020\4bad_irq\010flash/boot present", temp);
|
2008-04-09 00:08:49 +04:00
|
|
|
printf("%s: int no now %s\n", device_xname(&sc->sc_dev), sbuf);
|
2000-08-09 05:56:33 +04:00
|
|
|
}
|
1996-05-07 01:36:51 +04:00
|
|
|
#endif
|
|
|
|
|
1996-10-22 02:34:38 +04:00
|
|
|
bus_space_write_1(iot, ioh, RCV_LOWER_LIMIT_REG, 0);
|
2001-03-16 15:01:30 +03:00
|
|
|
bus_space_write_1(iot, ioh, RCV_UPPER_LIMIT_REG, (sc->rx_size -2) >>8);
|
|
|
|
bus_space_write_1(iot, ioh, XMT_LOWER_LIMIT_REG, sc->rx_size >>8);
|
|
|
|
bus_space_write_1(iot, ioh, XMT_UPPER_LIMIT_REG, (sc->sram - 2) >>8);
|
1996-05-07 01:36:51 +04:00
|
|
|
|
1996-10-22 02:34:38 +04:00
|
|
|
temp = bus_space_read_1(iot, ioh, REG1);
|
1996-05-07 01:36:51 +04:00
|
|
|
#ifdef IYDEBUG
|
2000-08-09 05:56:33 +04:00
|
|
|
{
|
|
|
|
char sbuf[128];
|
|
|
|
|
2008-12-17 01:35:21 +03:00
|
|
|
snprintb(sbuf, sizeof(sbuf), "\020\2WORD_WIDTH\010INT_ENABLE",
|
|
|
|
temp);
|
|
|
|
|
2008-04-09 00:08:49 +04:00
|
|
|
printf("%s: HW access is %s\n", device_xname(&sc->sc_dev), sbuf);
|
2000-08-09 05:56:33 +04:00
|
|
|
}
|
1996-05-07 01:36:51 +04:00
|
|
|
#endif
|
1996-10-22 02:34:38 +04:00
|
|
|
bus_space_write_1(iot, ioh, REG1, temp | INT_ENABLE); /* XXX what about WORD_WIDTH? */
|
1996-05-07 01:36:51 +04:00
|
|
|
|
|
|
|
#ifdef IYDEBUG
|
2000-08-09 05:56:33 +04:00
|
|
|
{
|
|
|
|
char sbuf[128];
|
|
|
|
|
|
|
|
temp = bus_space_read_1(iot, ioh, REG1);
|
2008-12-17 01:35:21 +03:00
|
|
|
snprintb(sbuf, sizeof(sbuf), "\020\2WORD_WIDTH\010INT_ENABLE",
|
|
|
|
temp);
|
2008-04-09 00:08:49 +04:00
|
|
|
printf("%s: HW access is %s\n", device_xname(&sc->sc_dev), sbuf);
|
2000-08-09 05:56:33 +04:00
|
|
|
}
|
1996-05-07 01:36:51 +04:00
|
|
|
#endif
|
|
|
|
|
1996-10-22 02:34:38 +04:00
|
|
|
bus_space_write_1(iot, ioh, 0, BANK_SEL(0));
|
1996-05-07 01:36:51 +04:00
|
|
|
|
1996-10-22 02:34:38 +04:00
|
|
|
bus_space_write_1(iot, ioh, INT_MASK_REG, ALL_INTS & ~(RX_BIT|TX_BIT));
|
|
|
|
bus_space_write_1(iot, ioh, STATUS_REG, ALL_INTS); /* clear ints */
|
1996-05-07 01:36:51 +04:00
|
|
|
|
2001-03-16 16:43:31 +03:00
|
|
|
bus_space_write_1(iot, ioh, RCV_COPY_THRESHOLD, 0);
|
|
|
|
|
1996-10-22 02:34:38 +04:00
|
|
|
bus_space_write_2(iot, ioh, RCV_START_LOW, 0);
|
|
|
|
bus_space_write_2(iot, ioh, RCV_STOP_LOW, sc->rx_size - 2);
|
1996-05-07 01:36:51 +04:00
|
|
|
sc->rx_start = 0;
|
|
|
|
|
1996-10-22 02:34:38 +04:00
|
|
|
bus_space_write_1(iot, ioh, 0, SEL_RESET_CMD);
|
1997-03-15 21:09:08 +03:00
|
|
|
delay(200);
|
1996-05-07 01:36:51 +04:00
|
|
|
|
1996-10-22 02:34:38 +04:00
|
|
|
bus_space_write_2(iot, ioh, XMT_ADDR_REG, sc->rx_size);
|
1996-05-07 01:36:51 +04:00
|
|
|
|
|
|
|
sc->tx_start = sc->tx_end = sc->rx_size;
|
|
|
|
sc->tx_last = 0;
|
|
|
|
|
1996-10-22 02:34:38 +04:00
|
|
|
bus_space_write_1(iot, ioh, 0, RCV_ENABLE_CMD);
|
1996-05-07 01:36:51 +04:00
|
|
|
|
|
|
|
ifp->if_flags |= IFF_RUNNING;
|
|
|
|
ifp->if_flags &= ~IFF_OACTIVE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
iystart(ifp)
|
|
|
|
struct ifnet *ifp;
|
|
|
|
{
|
|
|
|
struct iy_softc *sc;
|
1996-07-25 22:59:12 +04:00
|
|
|
|
1996-05-07 01:36:51 +04:00
|
|
|
|
|
|
|
struct mbuf *m0, *m;
|
|
|
|
u_int len, pad, last, end;
|
|
|
|
u_int llen, residual;
|
|
|
|
int avail;
|
2007-03-04 08:59:00 +03:00
|
|
|
char *data;
|
2001-03-23 16:15:27 +03:00
|
|
|
unsigned temp;
|
1996-05-07 01:36:51 +04:00
|
|
|
u_int16_t resval, stat;
|
1996-10-22 02:34:38 +04:00
|
|
|
bus_space_tag_t iot;
|
|
|
|
bus_space_handle_t ioh;
|
1996-05-07 01:36:51 +04:00
|
|
|
|
|
|
|
#ifdef IYDEBUG
|
1996-10-13 05:37:04 +04:00
|
|
|
printf("iystart called\n");
|
1996-05-07 01:36:51 +04:00
|
|
|
#endif
|
1998-07-30 20:40:19 +04:00
|
|
|
sc = ifp->if_softc;
|
|
|
|
|
1996-05-07 01:36:51 +04:00
|
|
|
if ((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) != IFF_RUNNING)
|
|
|
|
return;
|
|
|
|
|
2001-03-23 16:15:27 +03:00
|
|
|
iy_intr_tx(sc);
|
|
|
|
|
1996-10-22 02:34:38 +04:00
|
|
|
iot = sc->sc_iot;
|
1996-07-25 22:59:12 +04:00
|
|
|
ioh = sc->sc_ioh;
|
1996-05-07 01:36:51 +04:00
|
|
|
|
2000-12-14 09:59:01 +03:00
|
|
|
for (;;) {
|
|
|
|
IFQ_POLL(&ifp->if_snd, m0);
|
|
|
|
if (m0 == NULL)
|
|
|
|
break;
|
1996-05-07 01:36:51 +04:00
|
|
|
#ifdef IYDEBUG
|
1996-10-13 05:37:04 +04:00
|
|
|
printf("%s: trying to write another packet to the hardware\n",
|
2008-04-09 00:08:49 +04:00
|
|
|
device_xname(&sc->sc_dev));
|
1996-05-07 01:36:51 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* We need to use m->m_pkthdr.len, so require the header */
|
|
|
|
if ((m0->m_flags & M_PKTHDR) == 0)
|
|
|
|
panic("iystart: no header mbuf");
|
|
|
|
|
|
|
|
len = m0->m_pkthdr.len;
|
|
|
|
pad = len & 1;
|
|
|
|
|
|
|
|
#ifdef IYDEBUG
|
2008-04-09 00:08:49 +04:00
|
|
|
printf("%s: length is %d.\n", device_xname(&sc->sc_dev), len);
|
1996-05-07 01:36:51 +04:00
|
|
|
#endif
|
1999-08-26 02:41:42 +04:00
|
|
|
if (len < (ETHER_MIN_LEN - ETHER_CRC_LEN)) {
|
|
|
|
pad = ETHER_MIN_LEN - ETHER_CRC_LEN - len;
|
1996-05-07 01:36:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (len + pad > ETHER_MAX_LEN) {
|
|
|
|
/* packet is obviously too large: toss it */
|
|
|
|
++ifp->if_oerrors;
|
2002-03-05 07:12:57 +03:00
|
|
|
IFQ_DEQUEUE(&ifp->if_snd, m0);
|
1996-05-07 01:36:51 +04:00
|
|
|
m_freem(m0);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if NBPFILTER > 0
|
|
|
|
if (ifp->if_bpf)
|
|
|
|
bpf_mtap(ifp->if_bpf, m0);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
avail = sc->tx_start - sc->tx_end;
|
|
|
|
if (avail <= 0)
|
|
|
|
avail += sc->tx_size;
|
|
|
|
|
|
|
|
#ifdef IYDEBUG
|
2008-04-09 00:08:49 +04:00
|
|
|
printf("%s: avail is %d.\n", device_xname(&sc->sc_dev), avail);
|
1996-05-07 01:36:51 +04:00
|
|
|
#endif
|
2005-02-27 03:26:58 +03:00
|
|
|
/*
|
|
|
|
* we MUST RUN at splnet here ---
|
|
|
|
* XXX todo: or even turn off the boards ints ??? hm...
|
1996-05-07 01:36:51 +04:00
|
|
|
*/
|
2005-02-27 03:26:58 +03:00
|
|
|
|
1996-05-07 01:36:51 +04:00
|
|
|
/* See if there is room to put another packet in the buffer. */
|
2005-02-27 03:26:58 +03:00
|
|
|
|
1996-05-07 01:36:51 +04:00
|
|
|
if ((len+pad+2*I595_XMT_HDRLEN) > avail) {
|
1998-02-03 19:22:01 +03:00
|
|
|
#ifdef IYDEBUG
|
1996-10-13 05:37:04 +04:00
|
|
|
printf("%s: len = %d, avail = %d, setting OACTIVE\n",
|
2008-04-09 00:08:49 +04:00
|
|
|
device_xname(&sc->sc_dev), len, avail);
|
1998-02-03 19:22:01 +03:00
|
|
|
#endif
|
2001-03-23 16:15:27 +03:00
|
|
|
/* mark interface as full ... */
|
1996-05-07 01:36:51 +04:00
|
|
|
ifp->if_flags |= IFF_OACTIVE;
|
2001-03-23 16:15:27 +03:00
|
|
|
|
|
|
|
/* and wait for any transmission result */
|
|
|
|
bus_space_write_1(iot, ioh, 0, BANK_SEL(2));
|
|
|
|
|
|
|
|
temp = bus_space_read_1(iot, ioh, REG1);
|
|
|
|
bus_space_write_1(iot, ioh, REG1,
|
|
|
|
temp & ~XMT_CHAIN_INT);
|
|
|
|
|
|
|
|
bus_space_write_1(iot, ioh, 0, BANK_SEL(0));
|
|
|
|
|
1996-05-07 01:36:51 +04:00
|
|
|
return;
|
|
|
|
}
|
2005-02-27 03:26:58 +03:00
|
|
|
|
1996-05-07 01:36:51 +04:00
|
|
|
/* we know it fits in the hardware now, so dequeue it */
|
2000-12-14 09:59:01 +03:00
|
|
|
IFQ_DEQUEUE(&ifp->if_snd, m0);
|
2005-02-27 03:26:58 +03:00
|
|
|
|
1996-05-07 01:36:51 +04:00
|
|
|
last = sc->tx_end;
|
2005-02-27 03:26:58 +03:00
|
|
|
end = last + pad + len + I595_XMT_HDRLEN;
|
|
|
|
|
1996-05-07 01:36:51 +04:00
|
|
|
if (end >= sc->sram) {
|
|
|
|
if ((sc->sram - last) <= I595_XMT_HDRLEN) {
|
|
|
|
/* keep header in one piece */
|
|
|
|
last = sc->rx_size;
|
|
|
|
end = last + pad + len + I595_XMT_HDRLEN;
|
|
|
|
} else
|
|
|
|
end -= sc->tx_size;
|
|
|
|
}
|
|
|
|
|
1996-10-22 02:34:38 +04:00
|
|
|
bus_space_write_2(iot, ioh, HOST_ADDR_REG, last);
|
2000-07-21 17:54:38 +04:00
|
|
|
bus_space_write_stream_2(iot, ioh, MEM_PORT_REG,
|
|
|
|
htole16(XMT_CMD));
|
|
|
|
|
1996-10-22 02:34:38 +04:00
|
|
|
bus_space_write_2(iot, ioh, MEM_PORT_REG, 0);
|
|
|
|
bus_space_write_2(iot, ioh, MEM_PORT_REG, 0);
|
2000-07-21 17:54:38 +04:00
|
|
|
|
2005-02-27 03:26:58 +03:00
|
|
|
bus_space_write_stream_2(iot, ioh, MEM_PORT_REG,
|
2000-07-21 17:54:38 +04:00
|
|
|
htole16(len + pad));
|
1996-05-07 01:36:51 +04:00
|
|
|
|
|
|
|
residual = resval = 0;
|
|
|
|
|
|
|
|
while ((m = m0)!=0) {
|
2007-03-04 08:59:00 +03:00
|
|
|
data = mtod(m, void *);
|
1996-05-07 01:36:51 +04:00
|
|
|
llen = m->m_len;
|
|
|
|
if (residual) {
|
|
|
|
#ifdef IYDEBUG
|
1996-10-13 05:37:04 +04:00
|
|
|
printf("%s: merging residual with next mbuf.\n",
|
2008-04-09 00:08:49 +04:00
|
|
|
device_xname(&sc->sc_dev));
|
1996-05-07 01:36:51 +04:00
|
|
|
#endif
|
|
|
|
resval |= *data << 8;
|
2000-07-21 17:54:38 +04:00
|
|
|
bus_space_write_stream_2(iot, ioh,
|
|
|
|
MEM_PORT_REG, resval);
|
1996-05-07 01:36:51 +04:00
|
|
|
--llen;
|
|
|
|
++data;
|
|
|
|
}
|
2004-10-31 02:33:29 +03:00
|
|
|
/*
|
|
|
|
* XXX ALIGNMENT LOSSAGE HERE.
|
|
|
|
*/
|
1996-05-07 01:36:51 +04:00
|
|
|
if (llen > 1)
|
2000-07-21 17:54:38 +04:00
|
|
|
bus_space_write_multi_stream_2(iot, ioh,
|
2004-10-31 02:33:29 +03:00
|
|
|
MEM_PORT_REG, (u_int16_t *) data,
|
|
|
|
llen>>1);
|
1996-05-07 01:36:51 +04:00
|
|
|
residual = llen & 1;
|
|
|
|
if (residual) {
|
|
|
|
resval = *(data + llen - 1);
|
|
|
|
#ifdef IYDEBUG
|
1996-10-13 05:37:04 +04:00
|
|
|
printf("%s: got odd mbuf to send.\n",
|
2008-04-09 00:08:49 +04:00
|
|
|
device_xname(&sc->sc_dev));
|
1996-05-07 01:36:51 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
MFREE(m, m0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (residual)
|
2000-07-21 17:54:38 +04:00
|
|
|
bus_space_write_stream_2(iot, ioh, MEM_PORT_REG,
|
|
|
|
resval);
|
1996-05-07 01:36:51 +04:00
|
|
|
|
|
|
|
pad >>= 1;
|
|
|
|
while (pad-- > 0)
|
2000-07-21 17:54:38 +04:00
|
|
|
bus_space_write_stream_2(iot, ioh, MEM_PORT_REG, 0);
|
2005-02-27 03:26:58 +03:00
|
|
|
|
1996-05-07 01:36:51 +04:00
|
|
|
#ifdef IYDEBUG
|
1996-10-13 05:37:04 +04:00
|
|
|
printf("%s: new last = 0x%x, end = 0x%x.\n",
|
2008-04-09 00:08:49 +04:00
|
|
|
device_xname(&sc->sc_dev), last, end);
|
1996-10-13 05:37:04 +04:00
|
|
|
printf("%s: old start = 0x%x, end = 0x%x, last = 0x%x\n",
|
2008-04-09 00:08:49 +04:00
|
|
|
device_xname(&sc->sc_dev), sc->tx_start, sc->tx_end, sc->tx_last);
|
1996-05-07 01:36:51 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if (sc->tx_start != sc->tx_end) {
|
2000-07-21 17:54:38 +04:00
|
|
|
bus_space_write_2(iot, ioh, HOST_ADDR_REG,
|
|
|
|
sc->tx_last + XMT_COUNT);
|
1996-05-07 01:36:51 +04:00
|
|
|
|
2000-07-21 17:54:38 +04:00
|
|
|
/*
|
|
|
|
* XXX We keep stat in le order, to potentially save
|
|
|
|
* a byte swap.
|
|
|
|
*/
|
|
|
|
stat = bus_space_read_stream_2(iot, ioh, MEM_PORT_REG);
|
|
|
|
|
|
|
|
bus_space_write_2(iot, ioh, HOST_ADDR_REG,
|
|
|
|
sc->tx_last + XMT_CHAIN);
|
|
|
|
|
|
|
|
bus_space_write_stream_2(iot, ioh, MEM_PORT_REG,
|
|
|
|
htole16(last));
|
|
|
|
|
|
|
|
bus_space_write_stream_2(iot, ioh, MEM_PORT_REG,
|
|
|
|
stat | htole16(CHAIN));
|
1996-05-07 01:36:51 +04:00
|
|
|
#ifdef IYDEBUG
|
1996-10-13 05:37:04 +04:00
|
|
|
printf("%s: setting 0x%x to 0x%x\n",
|
2008-04-09 00:08:49 +04:00
|
|
|
device_xname(&sc->sc_dev), sc->tx_last + XMT_COUNT,
|
2000-07-21 17:54:38 +04:00
|
|
|
le16toh(stat) | CHAIN);
|
1996-05-07 01:36:51 +04:00
|
|
|
#endif
|
|
|
|
}
|
1996-10-22 02:34:38 +04:00
|
|
|
stat = bus_space_read_2(iot, ioh, MEM_PORT_REG); /* dummy read */
|
1996-05-07 01:36:51 +04:00
|
|
|
|
|
|
|
/* XXX todo: enable ints here if disabled */
|
2005-02-27 03:26:58 +03:00
|
|
|
|
1996-05-07 01:36:51 +04:00
|
|
|
++ifp->if_opackets;
|
|
|
|
|
|
|
|
if (sc->tx_start == sc->tx_end) {
|
1996-10-22 02:34:38 +04:00
|
|
|
bus_space_write_2(iot, ioh, XMT_ADDR_REG, last);
|
|
|
|
bus_space_write_1(iot, ioh, 0, XMT_CMD);
|
1996-05-07 01:36:51 +04:00
|
|
|
sc->tx_start = last;
|
|
|
|
#ifdef IYDEBUG
|
1996-10-13 05:37:04 +04:00
|
|
|
printf("%s: writing 0x%x to XAR and giving XCMD\n",
|
2008-04-09 00:08:49 +04:00
|
|
|
device_xname(&sc->sc_dev), last);
|
1996-05-07 01:36:51 +04:00
|
|
|
#endif
|
|
|
|
} else {
|
1996-10-22 02:34:38 +04:00
|
|
|
bus_space_write_1(iot, ioh, 0, RESUME_XMT_CMD);
|
1996-05-07 01:36:51 +04:00
|
|
|
#ifdef IYDEBUG
|
1996-10-13 05:37:04 +04:00
|
|
|
printf("%s: giving RESUME_XCMD\n",
|
2008-04-09 00:08:49 +04:00
|
|
|
device_xname(&sc->sc_dev));
|
1996-05-07 01:36:51 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
sc->tx_last = last;
|
|
|
|
sc->tx_end = end;
|
|
|
|
}
|
2001-03-23 16:15:27 +03:00
|
|
|
/* and wait only for end of transmission chain */
|
|
|
|
bus_space_write_1(iot, ioh, 0, BANK_SEL(2));
|
|
|
|
|
|
|
|
temp = bus_space_read_1(iot, ioh, REG1);
|
|
|
|
bus_space_write_1(iot, ioh, REG1, temp | XMT_CHAIN_INT);
|
|
|
|
|
|
|
|
bus_space_write_1(iot, ioh, 0, BANK_SEL(0));
|
1996-05-07 01:36:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-12-24 23:27:29 +03:00
|
|
|
static inline void
|
2005-02-27 03:26:58 +03:00
|
|
|
eepromwritebit(iot, ioh, what)
|
1996-10-22 02:34:38 +04:00
|
|
|
bus_space_tag_t iot;
|
|
|
|
bus_space_handle_t ioh;
|
1996-07-25 22:59:12 +04:00
|
|
|
int what;
|
1996-05-07 01:36:51 +04:00
|
|
|
{
|
1997-03-15 21:09:08 +03:00
|
|
|
bus_space_write_1(iot, ioh, EEPROM_REG, what);
|
1996-05-07 01:36:51 +04:00
|
|
|
delay(1);
|
1997-03-15 21:09:08 +03:00
|
|
|
bus_space_write_1(iot, ioh, EEPROM_REG, what|EESK);
|
1996-05-07 01:36:51 +04:00
|
|
|
delay(1);
|
1997-03-15 21:09:08 +03:00
|
|
|
bus_space_write_1(iot, ioh, EEPROM_REG, what);
|
1996-05-07 01:36:51 +04:00
|
|
|
delay(1);
|
|
|
|
}
|
|
|
|
|
2005-12-24 23:27:29 +03:00
|
|
|
static inline int
|
2005-02-27 03:26:58 +03:00
|
|
|
eepromreadbit(iot, ioh)
|
1996-10-22 02:34:38 +04:00
|
|
|
bus_space_tag_t iot;
|
|
|
|
bus_space_handle_t ioh;
|
1996-05-07 01:36:51 +04:00
|
|
|
{
|
2005-02-27 03:26:58 +03:00
|
|
|
int b;
|
1996-05-07 01:36:51 +04:00
|
|
|
|
2005-02-27 03:26:58 +03:00
|
|
|
bus_space_write_1(iot, ioh, EEPROM_REG, EECS|EESK);
|
1996-05-07 01:36:51 +04:00
|
|
|
delay(1);
|
1997-03-15 21:09:08 +03:00
|
|
|
b = bus_space_read_1(iot, ioh, EEPROM_REG);
|
|
|
|
bus_space_write_1(iot, ioh, EEPROM_REG, EECS);
|
1996-05-07 01:36:51 +04:00
|
|
|
delay(1);
|
|
|
|
|
|
|
|
return ((b & EEDO) != 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static u_int16_t
|
1997-03-15 21:09:08 +03:00
|
|
|
eepromread(iot, ioh, offset)
|
1996-10-22 02:34:38 +04:00
|
|
|
bus_space_tag_t iot;
|
|
|
|
bus_space_handle_t ioh;
|
1996-07-25 22:59:12 +04:00
|
|
|
int offset;
|
1996-05-07 01:36:51 +04:00
|
|
|
{
|
|
|
|
volatile int i;
|
|
|
|
volatile int j;
|
|
|
|
volatile u_int16_t readval;
|
|
|
|
|
1996-10-22 02:34:38 +04:00
|
|
|
bus_space_write_1(iot, ioh, 0, BANK_SEL(2));
|
1996-05-07 01:36:51 +04:00
|
|
|
delay(1);
|
1997-03-15 21:09:08 +03:00
|
|
|
bus_space_write_1(iot, ioh, EEPROM_REG, EECS); /* XXXX??? */
|
1996-05-07 01:36:51 +04:00
|
|
|
delay(1);
|
2005-02-27 03:26:58 +03:00
|
|
|
|
1997-03-15 21:09:08 +03:00
|
|
|
eepromwritebit(iot, ioh, EECS|EEDI);
|
|
|
|
eepromwritebit(iot, ioh, EECS|EEDI);
|
|
|
|
eepromwritebit(iot, ioh, EECS);
|
2005-02-27 03:26:58 +03:00
|
|
|
|
1996-05-07 01:36:51 +04:00
|
|
|
for (j=5; j>=0; --j) {
|
2005-02-27 03:26:58 +03:00
|
|
|
if ((offset>>j) & 1)
|
1997-03-15 21:09:08 +03:00
|
|
|
eepromwritebit(iot, ioh, EECS|EEDI);
|
1996-05-07 01:36:51 +04:00
|
|
|
else
|
1997-03-15 21:09:08 +03:00
|
|
|
eepromwritebit(iot, ioh, EECS);
|
1996-05-07 01:36:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
for (readval=0, i=0; i<16; ++i) {
|
|
|
|
readval<<=1;
|
1997-03-15 21:09:08 +03:00
|
|
|
readval |= eepromreadbit(iot, ioh);
|
1996-05-07 01:36:51 +04:00
|
|
|
}
|
|
|
|
|
1997-03-15 21:09:08 +03:00
|
|
|
bus_space_write_1(iot, ioh, EEPROM_REG, 0|EESK);
|
1996-05-07 01:36:51 +04:00
|
|
|
delay(1);
|
1997-03-15 21:09:08 +03:00
|
|
|
bus_space_write_1(iot, ioh, EEPROM_REG, 0);
|
1996-05-07 01:36:51 +04:00
|
|
|
|
1997-03-15 21:09:08 +03:00
|
|
|
bus_space_write_1(iot, ioh, COMMAND_REG, BANK_SEL(0));
|
1996-05-07 01:36:51 +04:00
|
|
|
|
|
|
|
return readval;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Device timeout/watchdog routine. Entered if the device neglects to generate
|
|
|
|
* an interrupt after a transmit has been started on it.
|
|
|
|
*/
|
|
|
|
void
|
1996-05-07 05:55:13 +04:00
|
|
|
iywatchdog(ifp)
|
1996-05-08 21:29:40 +04:00
|
|
|
struct ifnet *ifp;
|
1996-05-07 01:36:51 +04:00
|
|
|
{
|
1996-05-07 05:55:13 +04:00
|
|
|
struct iy_softc *sc = ifp->if_softc;
|
1996-05-07 01:36:51 +04:00
|
|
|
|
2008-04-09 00:08:49 +04:00
|
|
|
log(LOG_ERR, "%s: device timeout\n", device_xname(&sc->sc_dev));
|
1997-03-15 21:09:08 +03:00
|
|
|
++sc->sc_ethercom.ec_if.if_oerrors;
|
1996-05-07 01:36:51 +04:00
|
|
|
iyreset(sc);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* What to do upon receipt of an interrupt.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
iyintr(arg)
|
|
|
|
void *arg;
|
|
|
|
{
|
2001-03-23 16:15:27 +03:00
|
|
|
struct iy_softc *sc;
|
|
|
|
struct ifnet *ifp;
|
1996-10-22 02:34:38 +04:00
|
|
|
bus_space_tag_t iot;
|
|
|
|
bus_space_handle_t ioh;
|
1996-07-25 22:59:12 +04:00
|
|
|
|
2000-03-30 16:41:09 +04:00
|
|
|
u_short status;
|
1996-05-07 01:36:51 +04:00
|
|
|
|
2001-03-23 16:15:27 +03:00
|
|
|
sc = arg;
|
1996-10-22 02:34:38 +04:00
|
|
|
iot = sc->sc_iot;
|
1996-07-25 22:59:12 +04:00
|
|
|
ioh = sc->sc_ioh;
|
|
|
|
|
2001-03-23 16:15:27 +03:00
|
|
|
ifp = &sc->sc_ethercom.ec_if;
|
|
|
|
|
1996-10-22 02:34:38 +04:00
|
|
|
status = bus_space_read_1(iot, ioh, STATUS_REG);
|
1996-05-07 01:36:51 +04:00
|
|
|
#ifdef IYDEBUG
|
|
|
|
if (status & ALL_INTS) {
|
2000-08-09 05:56:33 +04:00
|
|
|
char sbuf[128];
|
|
|
|
|
2008-12-17 01:35:21 +03:00
|
|
|
snprintb(sbuf, sizeof(sbuf), "\020\1RX_STP\2RX\3TX\4EXEC",
|
|
|
|
status);
|
2008-04-09 00:08:49 +04:00
|
|
|
printf("%s: got interrupt %s", device_xname(&sc->sc_dev), sbuf);
|
2000-08-09 05:56:33 +04:00
|
|
|
|
|
|
|
if (status & EXEC_INT) {
|
2008-12-17 01:35:21 +03:00
|
|
|
snprintb(sbuf, sizeof(sbuf),
|
|
|
|
"\020\6ABORT", bus_space_read_1(iot, ioh, 0));
|
2000-08-09 05:56:33 +04:00
|
|
|
printf(" event %s\n", sbuf);
|
|
|
|
} else
|
1996-10-13 05:37:04 +04:00
|
|
|
printf("\n");
|
1996-05-07 01:36:51 +04:00
|
|
|
}
|
|
|
|
#endif
|
1998-07-30 20:40:19 +04:00
|
|
|
if ((status & (RX_INT | TX_INT)) == 0)
|
1996-05-07 01:36:51 +04:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (status & RX_INT) {
|
|
|
|
iy_intr_rx(sc);
|
1996-10-22 02:34:38 +04:00
|
|
|
bus_space_write_1(iot, ioh, STATUS_REG, RX_INT);
|
1998-07-30 20:40:19 +04:00
|
|
|
}
|
|
|
|
if (status & TX_INT) {
|
2001-03-23 16:15:27 +03:00
|
|
|
/* Tell feeders we may be able to accept more data... */
|
|
|
|
ifp->if_flags &= ~IFF_OACTIVE;
|
|
|
|
/* and get more data. */
|
|
|
|
iystart(ifp);
|
1996-10-22 02:34:38 +04:00
|
|
|
bus_space_write_1(iot, ioh, STATUS_REG, TX_INT);
|
1996-05-07 01:36:51 +04:00
|
|
|
}
|
1997-10-15 09:55:13 +04:00
|
|
|
|
|
|
|
#if NRND > 0
|
|
|
|
rnd_add_uint32(&sc->rnd_source, status);
|
|
|
|
#endif
|
|
|
|
|
1996-05-07 01:36:51 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1996-10-22 02:34:38 +04:00
|
|
|
iyget(sc, iot, ioh, rxlen)
|
1996-07-25 22:59:12 +04:00
|
|
|
struct iy_softc *sc;
|
1996-10-22 02:34:38 +04:00
|
|
|
bus_space_tag_t iot;
|
|
|
|
bus_space_handle_t ioh;
|
1996-07-25 22:59:12 +04:00
|
|
|
int rxlen;
|
1996-05-07 01:36:51 +04:00
|
|
|
{
|
|
|
|
struct mbuf *m, *top, **mp;
|
|
|
|
struct ifnet *ifp;
|
|
|
|
int len;
|
|
|
|
|
1997-03-15 21:09:08 +03:00
|
|
|
ifp = &sc->sc_ethercom.ec_if;
|
1996-05-07 01:36:51 +04:00
|
|
|
|
1997-04-28 22:30:20 +04:00
|
|
|
MGETHDR(m, M_DONTWAIT, MT_DATA);
|
|
|
|
if (m == 0)
|
|
|
|
goto dropped;
|
1996-05-07 01:36:51 +04:00
|
|
|
m->m_pkthdr.rcvif = ifp;
|
|
|
|
m->m_pkthdr.len = rxlen;
|
|
|
|
len = MHLEN;
|
|
|
|
top = 0;
|
|
|
|
mp = ⊤
|
|
|
|
|
|
|
|
while (rxlen > 0) {
|
|
|
|
if (top) {
|
1997-04-28 22:30:20 +04:00
|
|
|
MGET(m, M_DONTWAIT, MT_DATA);
|
1996-05-07 01:36:51 +04:00
|
|
|
if (m == 0) {
|
1997-04-28 22:30:20 +04:00
|
|
|
m_freem(top);
|
|
|
|
goto dropped;
|
1996-05-07 01:36:51 +04:00
|
|
|
}
|
|
|
|
len = MLEN;
|
|
|
|
}
|
|
|
|
if (rxlen >= MINCLSIZE) {
|
|
|
|
MCLGET(m, M_DONTWAIT);
|
1997-04-24 12:05:13 +04:00
|
|
|
if ((m->m_flags & M_EXT) == 0) {
|
1997-04-28 22:30:20 +04:00
|
|
|
m_free(m);
|
1997-04-24 06:04:33 +04:00
|
|
|
m_freem(top);
|
|
|
|
goto dropped;
|
|
|
|
}
|
|
|
|
len = MCLBYTES;
|
1996-05-07 01:36:51 +04:00
|
|
|
}
|
|
|
|
len = min(rxlen, len);
|
2004-10-31 02:33:29 +03:00
|
|
|
/*
|
|
|
|
* XXX ALIGNMENT LOSSAGE HERE.
|
|
|
|
*/
|
1996-05-07 01:36:51 +04:00
|
|
|
if (len > 1) {
|
|
|
|
len &= ~1;
|
1996-07-25 22:59:12 +04:00
|
|
|
|
2005-02-27 03:26:58 +03:00
|
|
|
bus_space_read_multi_stream_2(iot, ioh, MEM_PORT_REG,
|
2004-10-31 02:33:29 +03:00
|
|
|
mtod(m, u_int16_t *), len/2);
|
1996-05-07 01:36:51 +04:00
|
|
|
} else {
|
|
|
|
#ifdef IYDEBUG
|
2008-04-09 00:08:49 +04:00
|
|
|
printf("%s: received odd mbuf\n", device_xname(&sc->sc_dev));
|
1996-05-07 01:36:51 +04:00
|
|
|
#endif
|
2007-03-04 08:59:00 +03:00
|
|
|
*(mtod(m, char *)) = bus_space_read_stream_2(iot, ioh,
|
1996-07-25 22:59:12 +04:00
|
|
|
MEM_PORT_REG);
|
1996-05-07 01:36:51 +04:00
|
|
|
}
|
|
|
|
m->m_len = len;
|
|
|
|
rxlen -= len;
|
|
|
|
*mp = m;
|
|
|
|
mp = &m->m_next;
|
|
|
|
}
|
2006-04-15 01:49:08 +04:00
|
|
|
|
|
|
|
if (top == NULL)
|
|
|
|
return;
|
|
|
|
|
2005-02-27 03:26:58 +03:00
|
|
|
/* XXX receive the top here */
|
1996-05-07 01:36:51 +04:00
|
|
|
++ifp->if_ipackets;
|
|
|
|
|
2006-04-15 01:49:08 +04:00
|
|
|
|
1996-05-07 01:36:51 +04:00
|
|
|
#if NBPFILTER > 0
|
2000-10-02 03:32:39 +04:00
|
|
|
if (ifp->if_bpf)
|
1996-05-07 01:36:51 +04:00
|
|
|
bpf_mtap(ifp->if_bpf, top);
|
|
|
|
#endif
|
1999-05-19 03:52:51 +04:00
|
|
|
(*ifp->if_input)(ifp, top);
|
1996-05-07 01:36:51 +04:00
|
|
|
return;
|
|
|
|
|
|
|
|
dropped:
|
|
|
|
++ifp->if_ierrors;
|
|
|
|
return;
|
|
|
|
}
|
1998-07-30 20:40:19 +04:00
|
|
|
|
1996-05-07 01:36:51 +04:00
|
|
|
void
|
|
|
|
iy_intr_rx(sc)
|
|
|
|
struct iy_softc *sc;
|
|
|
|
{
|
1996-10-22 02:34:38 +04:00
|
|
|
bus_space_tag_t iot;
|
|
|
|
bus_space_handle_t ioh;
|
1996-07-25 22:59:12 +04:00
|
|
|
|
1996-05-07 01:36:51 +04:00
|
|
|
u_int rxadrs, rxevnt, rxstatus, rxnext, rxlen;
|
|
|
|
|
1996-10-22 02:34:38 +04:00
|
|
|
iot = sc->sc_iot;
|
1996-07-25 22:59:12 +04:00
|
|
|
ioh = sc->sc_ioh;
|
1996-05-07 01:36:51 +04:00
|
|
|
|
|
|
|
rxadrs = sc->rx_start;
|
1996-10-22 02:34:38 +04:00
|
|
|
bus_space_write_2(iot, ioh, HOST_ADDR_REG, rxadrs);
|
2000-07-21 17:54:38 +04:00
|
|
|
rxevnt = le16toh(bus_space_read_stream_2(iot, ioh, MEM_PORT_REG));
|
1996-05-07 01:36:51 +04:00
|
|
|
rxnext = 0;
|
2005-02-27 03:26:58 +03:00
|
|
|
|
1996-05-07 01:36:51 +04:00
|
|
|
while (rxevnt == RCV_DONE) {
|
2000-07-21 17:54:38 +04:00
|
|
|
rxstatus = le16toh(bus_space_read_stream_2(iot, ioh,
|
|
|
|
MEM_PORT_REG));
|
|
|
|
rxnext = le16toh(bus_space_read_stream_2(iot, ioh,
|
|
|
|
MEM_PORT_REG));
|
|
|
|
rxlen = le16toh(bus_space_read_stream_2(iot, ioh,
|
|
|
|
MEM_PORT_REG));
|
1996-05-07 01:36:51 +04:00
|
|
|
#ifdef IYDEBUG
|
2000-08-09 05:56:33 +04:00
|
|
|
{
|
|
|
|
char sbuf[128];
|
|
|
|
|
2008-12-17 01:35:21 +03:00
|
|
|
snprintb(sbuf, sizeof(sbuf),
|
|
|
|
"\020\1RCLD\2IA_MCH\010SHORT\011OVRN\013ALGERR"
|
|
|
|
"\014CRCERR\015LENERR\016RCVOK\020TYP", rxstatus);
|
|
|
|
|
2000-08-09 05:56:33 +04:00
|
|
|
printf("%s: pck at 0x%04x stat %s next 0x%x len 0x%x\n",
|
2008-04-09 00:08:49 +04:00
|
|
|
device_xname(&sc->sc_dev), rxadrs, sbuf, rxnext, rxlen);
|
2000-08-09 05:56:33 +04:00
|
|
|
}
|
1996-05-07 01:36:51 +04:00
|
|
|
#endif
|
1996-10-22 02:34:38 +04:00
|
|
|
iyget(sc, iot, ioh, rxlen);
|
1996-05-07 01:36:51 +04:00
|
|
|
|
|
|
|
/* move stop address */
|
1996-10-22 02:34:38 +04:00
|
|
|
bus_space_write_2(iot, ioh, RCV_STOP_LOW,
|
1996-05-07 01:36:51 +04:00
|
|
|
rxnext == 0 ? sc->rx_size - 2 : rxnext - 2);
|
|
|
|
|
1996-10-22 02:34:38 +04:00
|
|
|
bus_space_write_2(iot, ioh, HOST_ADDR_REG, rxnext);
|
1996-05-07 01:36:51 +04:00
|
|
|
rxadrs = rxnext;
|
2000-07-21 17:54:38 +04:00
|
|
|
rxevnt = le16toh(bus_space_read_stream_2(iot, ioh,
|
|
|
|
MEM_PORT_REG));
|
1996-05-07 01:36:51 +04:00
|
|
|
}
|
|
|
|
sc->rx_start = rxnext;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
iy_intr_tx(sc)
|
|
|
|
struct iy_softc *sc;
|
|
|
|
{
|
1996-10-22 02:34:38 +04:00
|
|
|
bus_space_tag_t iot;
|
|
|
|
bus_space_handle_t ioh;
|
1996-05-07 01:36:51 +04:00
|
|
|
struct ifnet *ifp;
|
|
|
|
u_int txstatus, txstat2, txlen, txnext;
|
|
|
|
|
1997-03-15 21:09:08 +03:00
|
|
|
ifp = &sc->sc_ethercom.ec_if;
|
1996-10-22 02:34:38 +04:00
|
|
|
iot = sc->sc_iot;
|
1996-07-25 22:59:12 +04:00
|
|
|
ioh = sc->sc_ioh;
|
|
|
|
|
1996-05-07 01:36:51 +04:00
|
|
|
while (sc->tx_start != sc->tx_end) {
|
1996-10-22 02:34:38 +04:00
|
|
|
bus_space_write_2(iot, ioh, HOST_ADDR_REG, sc->tx_start);
|
2000-07-21 17:54:38 +04:00
|
|
|
txstatus = le16toh(bus_space_read_stream_2(iot, ioh,
|
|
|
|
MEM_PORT_REG));
|
|
|
|
|
1996-05-07 01:36:51 +04:00
|
|
|
if ((txstatus & (TX_DONE|CMD_MASK)) != (TX_DONE|XMT_CMD))
|
|
|
|
break;
|
|
|
|
|
2000-07-21 17:54:38 +04:00
|
|
|
txstat2 = le16toh(bus_space_read_stream_2(iot, ioh,
|
|
|
|
MEM_PORT_REG));
|
|
|
|
txnext = le16toh(bus_space_read_stream_2(iot, ioh,
|
|
|
|
MEM_PORT_REG));
|
|
|
|
txlen = le16toh(bus_space_read_stream_2(iot, ioh,
|
|
|
|
MEM_PORT_REG));
|
1996-05-07 01:36:51 +04:00
|
|
|
#ifdef IYDEBUG
|
2000-08-09 05:56:33 +04:00
|
|
|
{
|
|
|
|
char sbuf[128];
|
|
|
|
|
2008-12-17 01:35:21 +03:00
|
|
|
snprintb(sbuf, sizeof(sbuf),
|
|
|
|
"\020\6MAX_COL\7HRT_BEAT\010TX_DEF"
|
|
|
|
"\011UND_RUN\012JERR\013LST_CRS"
|
2008-12-17 18:41:24 +03:00
|
|
|
"\014LTCOL\016TX_OK\020COLL", txstat2);
|
2008-12-17 01:35:21 +03:00
|
|
|
|
2000-08-09 05:56:33 +04:00
|
|
|
printf("txstat 0x%x stat2 0x%s next 0x%x len 0x%x\n",
|
|
|
|
txstatus, sbuf, txnext, txlen);
|
|
|
|
}
|
1996-05-07 01:36:51 +04:00
|
|
|
#endif
|
|
|
|
if (txlen & CHAIN)
|
|
|
|
sc->tx_start = txnext;
|
|
|
|
else
|
|
|
|
sc->tx_start = sc->tx_end;
|
|
|
|
ifp->if_flags &= ~IFF_OACTIVE;
|
2005-02-27 03:26:58 +03:00
|
|
|
|
2001-03-15 16:27:31 +03:00
|
|
|
if (txstat2 & 0x0020)
|
|
|
|
ifp->if_collisions += 16;
|
|
|
|
else
|
|
|
|
ifp->if_collisions += txstat2 & 0x000f;
|
|
|
|
|
2001-03-16 16:02:51 +03:00
|
|
|
if ((txstat2 & 0x2000) == 0)
|
1996-05-07 01:36:51 +04:00
|
|
|
++ifp->if_oerrors;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
*** Summary ***
When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.
Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)
Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.
Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.
Return consistent, appropriate error codes from network drivers.
Improve readability. KNF.
*** Details ***
In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.
In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.
Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.
In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.
Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:
switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}
Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,
switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}
unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).
In ipw(4), remove an if_set_sadl() call that is out of place.
In nfe(4), reuse the jumbo MTU logic in ether_ioctl().
Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.
Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.
Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.
Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.
In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.
Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.
In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.
Let ifioctl_common() handle SIOCGIFADDR.
Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.
In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.
bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.
2008-11-07 03:20:01 +03:00
|
|
|
iyioctl(struct ifnet *ifp, u_long cmd, void *data)
|
1996-05-07 01:36:51 +04:00
|
|
|
{
|
|
|
|
struct iy_softc *sc;
|
|
|
|
struct ifaddr *ifa;
|
|
|
|
struct ifreq *ifr;
|
|
|
|
int s, error = 0;
|
|
|
|
|
1996-05-07 05:55:13 +04:00
|
|
|
sc = ifp->if_softc;
|
1996-05-07 01:36:51 +04:00
|
|
|
ifa = (struct ifaddr *)data;
|
|
|
|
ifr = (struct ifreq *)data;
|
|
|
|
|
|
|
|
#ifdef IYDEBUG
|
2005-05-22 19:54:45 +04:00
|
|
|
printf("iyioctl called with ifp %p (%s) cmd 0x%lx data %p\n",
|
1996-05-07 05:55:13 +04:00
|
|
|
ifp, ifp->if_xname, cmd, data);
|
1996-05-07 01:36:51 +04:00
|
|
|
#endif
|
|
|
|
|
1998-08-09 03:51:39 +04:00
|
|
|
s = splnet();
|
1996-05-07 01:36:51 +04:00
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
|
*** Summary ***
When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.
Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)
Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.
Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.
Return consistent, appropriate error codes from network drivers.
Improve readability. KNF.
*** Details ***
In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.
In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.
Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.
In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.
Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:
switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}
Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,
switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}
unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).
In ipw(4), remove an if_set_sadl() call that is out of place.
In nfe(4), reuse the jumbo MTU logic in ether_ioctl().
Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.
Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.
Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.
Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.
In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.
Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.
In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.
Let ifioctl_common() handle SIOCGIFADDR.
Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.
In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.
bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.
2008-11-07 03:20:01 +03:00
|
|
|
case SIOCINITIFADDR:
|
1996-05-07 01:36:51 +04:00
|
|
|
ifp->if_flags |= IFF_UP;
|
|
|
|
|
*** Summary ***
When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.
Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)
Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.
Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.
Return consistent, appropriate error codes from network drivers.
Improve readability. KNF.
*** Details ***
In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.
In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.
Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.
In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.
Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:
switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}
Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,
switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}
unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).
In ipw(4), remove an if_set_sadl() call that is out of place.
In nfe(4), reuse the jumbo MTU logic in ether_ioctl().
Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.
Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.
Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.
Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.
In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.
Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.
In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.
Let ifioctl_common() handle SIOCGIFADDR.
Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.
In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.
bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.
2008-11-07 03:20:01 +03:00
|
|
|
iyinit(sc);
|
1996-05-07 01:36:51 +04:00
|
|
|
switch (ifa->ifa_addr->sa_family) {
|
|
|
|
#ifdef INET
|
|
|
|
case AF_INET:
|
1997-03-15 21:09:08 +03:00
|
|
|
arp_ifinit(ifp, ifa);
|
1996-05-07 01:36:51 +04:00
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SIOCSIFFLAGS:
|
*** Summary ***
When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.
Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)
Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.
Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.
Return consistent, appropriate error codes from network drivers.
Improve readability. KNF.
*** Details ***
In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.
In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.
Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.
In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.
Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:
switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}
Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,
switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}
unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).
In ipw(4), remove an if_set_sadl() call that is out of place.
In nfe(4), reuse the jumbo MTU logic in ether_ioctl().
Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.
Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.
Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.
Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.
In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.
Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.
In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.
Let ifioctl_common() handle SIOCGIFADDR.
Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.
In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.
bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.
2008-11-07 03:20:01 +03:00
|
|
|
if ((error = ifioctl_common(ifp, cmd, data)) != 0)
|
|
|
|
break;
|
1996-05-07 01:36:51 +04:00
|
|
|
sc->promisc = ifp->if_flags & (IFF_PROMISC | IFF_ALLMULTI);
|
*** Summary ***
When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.
Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)
Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.
Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.
Return consistent, appropriate error codes from network drivers.
Improve readability. KNF.
*** Details ***
In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.
In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.
Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.
In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.
Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:
switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}
Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,
switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}
unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).
In ipw(4), remove an if_set_sadl() call that is out of place.
In nfe(4), reuse the jumbo MTU logic in ether_ioctl().
Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.
Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.
Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.
Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.
In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.
Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.
In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.
Let ifioctl_common() handle SIOCGIFADDR.
Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.
In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.
bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.
2008-11-07 03:20:01 +03:00
|
|
|
/* XXX re-use ether_ioctl() */
|
|
|
|
switch (ifp->if_flags & (IFF_UP|IFF_RUNNING)) {
|
|
|
|
case IFF_RUNNING:
|
1996-05-07 01:36:51 +04:00
|
|
|
/*
|
|
|
|
* If interface is marked down and it is running, then
|
|
|
|
* stop it.
|
|
|
|
*/
|
|
|
|
iystop(sc);
|
|
|
|
ifp->if_flags &= ~IFF_RUNNING;
|
*** Summary ***
When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.
Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)
Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.
Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.
Return consistent, appropriate error codes from network drivers.
Improve readability. KNF.
*** Details ***
In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.
In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.
Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.
In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.
Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:
switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}
Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,
switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}
unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).
In ipw(4), remove an if_set_sadl() call that is out of place.
In nfe(4), reuse the jumbo MTU logic in ether_ioctl().
Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.
Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.
Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.
Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.
In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.
Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.
In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.
Let ifioctl_common() handle SIOCGIFADDR.
Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.
In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.
bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.
2008-11-07 03:20:01 +03:00
|
|
|
break;
|
|
|
|
case IFF_UP:
|
1996-05-07 01:36:51 +04:00
|
|
|
/*
|
|
|
|
* If interface is marked up and it is stopped, then
|
|
|
|
* start it.
|
|
|
|
*/
|
|
|
|
iyinit(sc);
|
*** Summary ***
When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.
Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)
Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.
Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.
Return consistent, appropriate error codes from network drivers.
Improve readability. KNF.
*** Details ***
In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.
In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.
Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.
In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.
Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:
switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}
Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,
switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}
unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).
In ipw(4), remove an if_set_sadl() call that is out of place.
In nfe(4), reuse the jumbo MTU logic in ether_ioctl().
Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.
Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.
Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.
Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.
In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.
Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.
In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.
Let ifioctl_common() handle SIOCGIFADDR.
Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.
In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.
bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.
2008-11-07 03:20:01 +03:00
|
|
|
break;
|
|
|
|
default:
|
1996-05-07 01:36:51 +04:00
|
|
|
/*
|
|
|
|
* Reset the interface to pick up changes in any other
|
|
|
|
* flags that affect hardware registers.
|
|
|
|
*/
|
|
|
|
iystop(sc);
|
|
|
|
iyinit(sc);
|
*** Summary ***
When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.
Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)
Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.
Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.
Return consistent, appropriate error codes from network drivers.
Improve readability. KNF.
*** Details ***
In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.
In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.
Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.
In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.
Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:
switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}
Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,
switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}
unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).
In ipw(4), remove an if_set_sadl() call that is out of place.
In nfe(4), reuse the jumbo MTU logic in ether_ioctl().
Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.
Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.
Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.
Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.
In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.
Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.
In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.
Let ifioctl_common() handle SIOCGIFADDR.
Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.
In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.
bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.
2008-11-07 03:20:01 +03:00
|
|
|
break;
|
1996-05-07 01:36:51 +04:00
|
|
|
}
|
|
|
|
#ifdef IYDEBUGX
|
|
|
|
if (ifp->if_flags & IFF_DEBUG)
|
|
|
|
sc->sc_debug = IFY_ALL;
|
|
|
|
else
|
|
|
|
sc->sc_debug = 0;
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SIOCADDMULTI:
|
|
|
|
case SIOCDELMULTI:
|
2007-09-01 11:32:22 +04:00
|
|
|
if ((error = ether_ioctl(ifp, cmd, data)) == ENETRESET) {
|
1996-05-07 01:36:51 +04:00
|
|
|
/*
|
|
|
|
* Multicast list has changed; set the hardware filter
|
|
|
|
* accordingly.
|
|
|
|
*/
|
2004-10-31 02:33:29 +03:00
|
|
|
if (ifp->if_flags & IFF_RUNNING) {
|
|
|
|
/* XXX can't make it work otherwise */
|
|
|
|
iyreset(sc);
|
|
|
|
iy_mc_reset(sc);
|
|
|
|
}
|
1996-05-07 01:36:51 +04:00
|
|
|
error = 0;
|
|
|
|
}
|
|
|
|
break;
|
1998-07-31 05:10:13 +04:00
|
|
|
|
1997-12-02 12:34:03 +03:00
|
|
|
case SIOCSIFMEDIA:
|
|
|
|
case SIOCGIFMEDIA:
|
|
|
|
error = ifmedia_ioctl(ifp, ifr, &sc->iy_ifmedia, cmd);
|
|
|
|
break;
|
1996-05-07 01:36:51 +04:00
|
|
|
default:
|
*** Summary ***
When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.
Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)
Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.
Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.
Return consistent, appropriate error codes from network drivers.
Improve readability. KNF.
*** Details ***
In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.
In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.
Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.
In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.
Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:
switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}
Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,
switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}
unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).
In ipw(4), remove an if_set_sadl() call that is out of place.
In nfe(4), reuse the jumbo MTU logic in ether_ioctl().
Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.
Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.
Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.
Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.
In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.
Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.
In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.
Let ifioctl_common() handle SIOCGIFADDR.
Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.
In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.
bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.
2008-11-07 03:20:01 +03:00
|
|
|
error = ether_ioctl(ifp, cmd, data);
|
1996-05-07 01:36:51 +04:00
|
|
|
}
|
|
|
|
splx(s);
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
1997-12-02 12:34:03 +03:00
|
|
|
int
|
|
|
|
iy_mediachange(ifp)
|
|
|
|
struct ifnet *ifp;
|
|
|
|
{
|
|
|
|
struct iy_softc *sc = ifp->if_softc;
|
|
|
|
|
|
|
|
if (IFM_TYPE(sc->iy_ifmedia.ifm_media) != IFM_ETHER)
|
|
|
|
return EINVAL;
|
|
|
|
switch(IFM_SUBTYPE(sc->iy_ifmedia.ifm_media)) {
|
|
|
|
case IFM_10_5:
|
|
|
|
case IFM_10_2:
|
|
|
|
case IFM_10_T:
|
|
|
|
case IFM_AUTO:
|
|
|
|
iystop(sc);
|
|
|
|
iyinit(sc);
|
|
|
|
return 0;
|
|
|
|
default:
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
iy_mediastatus(ifp, ifmr)
|
|
|
|
struct ifnet *ifp;
|
|
|
|
struct ifmediareq *ifmr;
|
|
|
|
{
|
|
|
|
struct iy_softc *sc = ifp->if_softc;
|
|
|
|
|
|
|
|
ifmr->ifm_active = sc->iy_media;
|
|
|
|
ifmr->ifm_status = IFM_AVALID | IFM_ACTIVE;
|
|
|
|
}
|
|
|
|
|
1998-07-30 20:40:19 +04:00
|
|
|
|
|
|
|
static void
|
|
|
|
iy_mc_setup(sc)
|
|
|
|
struct iy_softc *sc;
|
|
|
|
{
|
|
|
|
struct ether_multi *enm;
|
|
|
|
struct ether_multistep step;
|
|
|
|
struct ethercom *ecp;
|
|
|
|
struct ifnet *ifp;
|
|
|
|
bus_space_tag_t iot;
|
|
|
|
bus_space_handle_t ioh;
|
|
|
|
int avail, last /*, end*/ , len;
|
|
|
|
int timeout;
|
2000-07-14 14:50:50 +04:00
|
|
|
volatile u_int16_t dum;
|
1998-07-30 20:40:19 +04:00
|
|
|
u_int8_t temp;
|
2005-02-27 03:26:58 +03:00
|
|
|
|
1998-07-30 20:40:19 +04:00
|
|
|
|
|
|
|
ecp = &sc->sc_ethercom;
|
|
|
|
ifp = &ecp->ec_if;
|
|
|
|
|
|
|
|
iot = sc->sc_iot;
|
|
|
|
ioh = sc->sc_ioh;
|
|
|
|
|
2001-03-16 16:43:31 +03:00
|
|
|
len = 6 * ecp->ec_multicnt;
|
2005-02-27 03:26:58 +03:00
|
|
|
|
1998-07-30 20:40:19 +04:00
|
|
|
avail = sc->tx_start - sc->tx_end;
|
|
|
|
if (avail <= 0)
|
|
|
|
avail += sc->tx_size;
|
2000-06-23 17:54:50 +04:00
|
|
|
if (ifp->if_flags & IFF_DEBUG)
|
|
|
|
printf("%s: iy_mc_setup called, %d addresses, "
|
2005-02-27 03:26:58 +03:00
|
|
|
"%d/%d bytes needed/avail\n", ifp->if_xname,
|
2000-06-23 17:54:50 +04:00
|
|
|
ecp->ec_multicnt, len + I595_XMT_HDRLEN, avail);
|
1998-07-30 20:40:19 +04:00
|
|
|
|
|
|
|
last = sc->rx_size;
|
|
|
|
|
|
|
|
bus_space_write_1(iot, ioh, 0, BANK_SEL(2));
|
2001-03-22 17:30:47 +03:00
|
|
|
bus_space_write_1(iot, ioh, RECV_MODES_REG, MATCH_BRDCST);
|
1998-07-30 20:40:19 +04:00
|
|
|
/* XXX VOODOO */
|
|
|
|
temp = bus_space_read_1(iot, ioh, MEDIA_SELECT);
|
|
|
|
bus_space_write_1(iot, ioh, MEDIA_SELECT, temp);
|
|
|
|
/* XXX END OF VOODOO */
|
|
|
|
bus_space_write_1(iot, ioh, 0, BANK_SEL(0));
|
|
|
|
bus_space_write_2(iot, ioh, HOST_ADDR_REG, last);
|
2000-07-21 17:54:38 +04:00
|
|
|
bus_space_write_stream_2(iot, ioh, MEM_PORT_REG, htole16(MC_SETUP_CMD));
|
1998-07-30 20:40:19 +04:00
|
|
|
bus_space_write_2(iot, ioh, MEM_PORT_REG, 0);
|
|
|
|
bus_space_write_2(iot, ioh, MEM_PORT_REG, 0);
|
2000-07-21 17:54:38 +04:00
|
|
|
bus_space_write_stream_2(iot, ioh, MEM_PORT_REG, htole16(len));
|
2005-02-27 03:26:58 +03:00
|
|
|
|
1998-07-30 20:40:19 +04:00
|
|
|
ETHER_FIRST_MULTI(step, ecp, enm);
|
|
|
|
while(enm) {
|
2004-10-31 02:33:29 +03:00
|
|
|
/*
|
|
|
|
* XXX ALIGNMENT LOSSAGE HERE?
|
|
|
|
*/
|
2000-07-21 17:54:38 +04:00
|
|
|
bus_space_write_multi_stream_2(iot, ioh, MEM_PORT_REG,
|
2004-10-31 02:33:29 +03:00
|
|
|
(u_int16_t *) enm->enm_addrlo, 3);
|
1998-07-30 20:40:19 +04:00
|
|
|
|
|
|
|
ETHER_NEXT_MULTI(step, enm);
|
|
|
|
}
|
2000-07-14 14:50:50 +04:00
|
|
|
dum = bus_space_read_2(iot, ioh, MEM_PORT_REG); /* dummy read */
|
1998-07-30 20:40:19 +04:00
|
|
|
bus_space_write_2(iot, ioh, XMT_ADDR_REG, last);
|
|
|
|
bus_space_write_1(iot, ioh, 0, MC_SETUP_CMD);
|
2005-02-27 03:26:58 +03:00
|
|
|
|
1998-07-30 20:40:19 +04:00
|
|
|
|
|
|
|
sc->tx_start = sc->rx_size;
|
|
|
|
sc->tx_end = sc->rx_size + I595_XMT_HDRLEN + len;
|
|
|
|
|
|
|
|
for (timeout=0; timeout<100; timeout++) {
|
|
|
|
DELAY(2);
|
|
|
|
if ((bus_space_read_1(iot, ioh, STATUS_REG) & EXEC_INT) == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
temp = bus_space_read_1(iot, ioh, 0);
|
|
|
|
bus_space_write_1(iot, ioh, STATUS_REG, EXEC_INT);
|
|
|
|
#ifdef DIAGNOSTIC
|
|
|
|
if (temp & 0x20) {
|
2008-04-09 00:08:49 +04:00
|
|
|
aprint_error_dev(&sc->sc_dev, "mc setup failed, %d usec\n",
|
|
|
|
timeout * 2);
|
2000-06-23 17:54:50 +04:00
|
|
|
} else if (((temp & 0x0f) == 0x03) &&
|
|
|
|
(ifp->if_flags & IFF_DEBUG)) {
|
1998-07-30 20:40:19 +04:00
|
|
|
printf("%s: mc setup done, %d usec\n",
|
2008-04-09 00:08:49 +04:00
|
|
|
device_xname(&sc->sc_dev), timeout * 2);
|
1998-07-30 20:40:19 +04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
sc->tx_start = sc->tx_end;
|
2000-06-23 18:07:03 +04:00
|
|
|
ifp->if_flags &= ~IFF_OACTIVE;
|
2005-02-27 03:26:58 +03:00
|
|
|
|
1998-07-30 20:40:19 +04:00
|
|
|
}
|
|
|
|
|
1996-05-07 01:36:51 +04:00
|
|
|
static void
|
|
|
|
iy_mc_reset(sc)
|
|
|
|
struct iy_softc *sc;
|
|
|
|
{
|
|
|
|
struct ether_multi *enm;
|
|
|
|
struct ether_multistep step;
|
1998-07-28 20:02:34 +04:00
|
|
|
struct ethercom *ecp;
|
|
|
|
struct ifnet *ifp;
|
1998-07-30 20:40:19 +04:00
|
|
|
bus_space_tag_t iot;
|
|
|
|
bus_space_handle_t ioh;
|
|
|
|
u_int16_t temp;
|
1998-07-28 20:02:34 +04:00
|
|
|
|
|
|
|
ecp = &sc->sc_ethercom;
|
|
|
|
ifp = &ecp->ec_if;
|
1996-05-07 01:36:51 +04:00
|
|
|
|
1998-07-30 20:40:19 +04:00
|
|
|
iot = sc->sc_iot;
|
|
|
|
ioh = sc->sc_ioh;
|
|
|
|
|
1998-07-28 20:02:34 +04:00
|
|
|
if (ecp->ec_multicnt > 63) {
|
1998-07-30 20:40:19 +04:00
|
|
|
ifp->if_flags |= IFF_ALLMULTI;
|
1998-07-28 20:02:34 +04:00
|
|
|
|
1998-07-30 20:40:19 +04:00
|
|
|
} else if (ecp->ec_multicnt > 0) {
|
1998-07-28 20:02:34 +04:00
|
|
|
/*
|
|
|
|
* Step through the list of addresses.
|
|
|
|
*/
|
|
|
|
ETHER_FIRST_MULTI(step, ecp, enm);
|
|
|
|
while(enm) {
|
2001-07-19 00:42:54 +04:00
|
|
|
if (memcmp(enm->enm_addrlo, enm->enm_addrhi, 6) != 0) {
|
1998-07-30 20:40:19 +04:00
|
|
|
ifp->if_flags |= IFF_ALLMULTI;
|
|
|
|
goto setupmulti;
|
1998-07-28 20:02:34 +04:00
|
|
|
}
|
|
|
|
ETHER_NEXT_MULTI(step, enm);
|
2005-02-27 03:26:58 +03:00
|
|
|
}
|
1998-07-28 20:02:34 +04:00
|
|
|
/* OK, we really need to do it now: */
|
1998-07-30 20:40:19 +04:00
|
|
|
#if 0
|
|
|
|
if ((ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE))
|
|
|
|
!= IFF_RUNNING) {
|
|
|
|
ifp->if_flags |= IFF_OACTIVE;
|
|
|
|
sc->want_mc_setup = 1;
|
|
|
|
return;
|
1996-05-07 01:36:51 +04:00
|
|
|
}
|
1998-07-30 20:40:19 +04:00
|
|
|
#endif
|
|
|
|
iy_mc_setup(sc);
|
1998-07-28 20:02:34 +04:00
|
|
|
} else {
|
1998-07-30 20:40:19 +04:00
|
|
|
ifp->if_flags &= ~IFF_ALLMULTI;
|
1996-05-07 01:36:51 +04:00
|
|
|
}
|
1998-07-28 20:02:34 +04:00
|
|
|
|
1998-07-30 20:40:19 +04:00
|
|
|
setupmulti:
|
|
|
|
bus_space_write_1(iot, ioh, 0, BANK_SEL(2));
|
|
|
|
if (ifp->if_flags & (IFF_PROMISC|IFF_ALLMULTI)) {
|
|
|
|
temp = MATCH_ALL;
|
2005-02-27 03:26:58 +03:00
|
|
|
} else
|
2001-03-22 17:30:47 +03:00
|
|
|
temp = MATCH_BRDCST;
|
1998-07-30 20:40:19 +04:00
|
|
|
|
|
|
|
bus_space_write_1(iot, ioh, RECV_MODES_REG, temp);
|
|
|
|
/* XXX VOODOO */
|
|
|
|
temp = bus_space_read_1(iot, ioh, MEDIA_SELECT);
|
|
|
|
bus_space_write_1(iot, ioh, MEDIA_SELECT, temp);
|
|
|
|
/* XXX END OF VOODOO */
|
|
|
|
|
|
|
|
/* XXX TBD: setup hardware for all multicasts */
|
|
|
|
bus_space_write_1(iot, ioh, 0, BANK_SEL(0));
|
1998-07-28 20:02:34 +04:00
|
|
|
return;
|
1996-05-07 01:36:51 +04:00
|
|
|
}
|
|
|
|
|
2000-08-09 05:56:33 +04:00
|
|
|
#ifdef IYDEBUGX
|
1996-05-07 01:36:51 +04:00
|
|
|
void
|
|
|
|
print_rbd(rbd)
|
|
|
|
volatile struct ie_recv_buf_desc *rbd;
|
|
|
|
{
|
1996-10-13 05:37:04 +04:00
|
|
|
printf("RBD at %08lx:\nactual %04x, next %04x, buffer %08x\n"
|
1996-05-07 01:36:51 +04:00
|
|
|
"length %04x, mbz %04x\n", (u_long)rbd, rbd->ie_rbd_actual,
|
|
|
|
rbd->ie_rbd_next, rbd->ie_rbd_buffer, rbd->ie_rbd_length,
|
|
|
|
rbd->mbz);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void
|
|
|
|
iyprobemem(sc)
|
|
|
|
struct iy_softc *sc;
|
|
|
|
{
|
1996-10-22 02:34:38 +04:00
|
|
|
bus_space_tag_t iot;
|
|
|
|
bus_space_handle_t ioh;
|
1996-05-07 01:36:51 +04:00
|
|
|
int testing;
|
|
|
|
|
1996-10-22 02:34:38 +04:00
|
|
|
iot = sc->sc_iot;
|
1996-07-25 22:59:12 +04:00
|
|
|
ioh = sc->sc_ioh;
|
1996-05-07 01:36:51 +04:00
|
|
|
|
1997-03-15 21:09:08 +03:00
|
|
|
bus_space_write_1(iot, ioh, COMMAND_REG, BANK_SEL(0));
|
|
|
|
delay(1);
|
1996-10-22 02:34:38 +04:00
|
|
|
bus_space_write_2(iot, ioh, HOST_ADDR_REG, 4096-2);
|
|
|
|
bus_space_write_2(iot, ioh, MEM_PORT_REG, 0);
|
1996-05-07 01:36:51 +04:00
|
|
|
|
|
|
|
for (testing=65536; testing >= 4096; testing >>= 1) {
|
1996-10-22 02:34:38 +04:00
|
|
|
bus_space_write_2(iot, ioh, HOST_ADDR_REG, testing-2);
|
|
|
|
bus_space_write_2(iot, ioh, MEM_PORT_REG, 0xdead);
|
|
|
|
bus_space_write_2(iot, ioh, HOST_ADDR_REG, testing-2);
|
|
|
|
if (bus_space_read_2(iot, ioh, MEM_PORT_REG) != 0xdead) {
|
1996-05-07 01:36:51 +04:00
|
|
|
#ifdef IYMEMDEBUG
|
1996-10-13 05:37:04 +04:00
|
|
|
printf("%s: Didn't keep 0xdead at 0x%x\n",
|
2008-04-09 00:08:49 +04:00
|
|
|
device_xname(&sc->sc_dev), testing-2);
|
1996-05-07 01:36:51 +04:00
|
|
|
#endif
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
1996-10-22 02:34:38 +04:00
|
|
|
bus_space_write_2(iot, ioh, HOST_ADDR_REG, testing-2);
|
|
|
|
bus_space_write_2(iot, ioh, MEM_PORT_REG, 0xbeef);
|
|
|
|
bus_space_write_2(iot, ioh, HOST_ADDR_REG, testing-2);
|
|
|
|
if (bus_space_read_2(iot, ioh, MEM_PORT_REG) != 0xbeef) {
|
1996-05-07 01:36:51 +04:00
|
|
|
#ifdef IYMEMDEBUG
|
1996-10-13 05:37:04 +04:00
|
|
|
printf("%s: Didn't keep 0xbeef at 0x%x\n",
|
2008-04-09 00:08:49 +04:00
|
|
|
device_xname(&sc->sc_dev), testing-2);
|
1996-05-07 01:36:51 +04:00
|
|
|
#endif
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
1996-10-22 02:34:38 +04:00
|
|
|
bus_space_write_2(iot, ioh, HOST_ADDR_REG, 0);
|
|
|
|
bus_space_write_2(iot, ioh, MEM_PORT_REG, 0);
|
|
|
|
bus_space_write_2(iot, ioh, HOST_ADDR_REG, testing >> 1);
|
|
|
|
bus_space_write_2(iot, ioh, MEM_PORT_REG, testing >> 1);
|
|
|
|
bus_space_write_2(iot, ioh, HOST_ADDR_REG, 0);
|
|
|
|
if (bus_space_read_2(iot, ioh, MEM_PORT_REG) == (testing >> 1)) {
|
1996-05-07 01:36:51 +04:00
|
|
|
#ifdef IYMEMDEBUG
|
1996-10-13 05:37:04 +04:00
|
|
|
printf("%s: 0x%x alias of 0x0\n",
|
2008-04-09 00:08:49 +04:00
|
|
|
device_xname(&sc->sc_dev), testing >> 1);
|
1996-05-07 01:36:51 +04:00
|
|
|
#endif
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
sc->sram = testing;
|
|
|
|
|
|
|
|
switch(testing) {
|
|
|
|
case 65536:
|
|
|
|
/* 4 NFS packets + overhead RX, 2 NFS + overhead TX */
|
|
|
|
sc->rx_size = 44*1024;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 32768:
|
|
|
|
/* 2 NFS packets + overhead RX, 1 NFS + overhead TX */
|
|
|
|
sc->rx_size = 22*1024;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 16384:
|
|
|
|
/* 1 NFS packet + overhead RX, 4 big packets TX */
|
|
|
|
sc->rx_size = 10*1024;
|
|
|
|
break;
|
2005-02-27 03:26:58 +03:00
|
|
|
default:
|
1996-05-07 01:36:51 +04:00
|
|
|
sc->rx_size = testing/2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
sc->tx_size = testing - sc->rx_size;
|
|
|
|
}
|
1997-03-15 21:09:08 +03:00
|
|
|
|
|
|
|
static int
|
|
|
|
eepromreadall(iot, ioh, wordp, maxi)
|
|
|
|
bus_space_tag_t iot;
|
|
|
|
bus_space_handle_t ioh;
|
|
|
|
u_int16_t *wordp;
|
|
|
|
int maxi;
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
u_int16_t checksum, tmp;
|
|
|
|
|
|
|
|
checksum = 0;
|
|
|
|
|
|
|
|
for (i=0; i<EEPP_LENGTH; ++i) {
|
|
|
|
tmp = eepromread(iot, ioh, i);
|
|
|
|
checksum += tmp;
|
|
|
|
if (i<maxi)
|
|
|
|
wordp[i] = tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (checksum != EEPP_CHKSUM) {
|
|
|
|
#ifdef IYDEBUG
|
|
|
|
printf("wrong EEPROM checksum 0x%x should be 0x%x\n",
|
|
|
|
checksum, EEPP_CHKSUM);
|
|
|
|
#endif
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|