Deleted Added
full compact
if_ep.c (55864) if_ep.c (56017)
1/*
2 * Copyright (c) 1994 Herb Peyerl <hpeyerl@novatel.ca>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 24 unchanged lines hidden (view full) ---

33/*
34 * Modified from the FreeBSD 1.1.5.1 version by:
35 * Andres Vega Garcia
36 * INRIA - Sophia Antipolis, France
37 * avega@sophia.inria.fr
38 */
39
40/*
1/*
2 * Copyright (c) 1994 Herb Peyerl <hpeyerl@novatel.ca>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 24 unchanged lines hidden (view full) ---

33/*
34 * Modified from the FreeBSD 1.1.5.1 version by:
35 * Andres Vega Garcia
36 * INRIA - Sophia Antipolis, France
37 * avega@sophia.inria.fr
38 */
39
40/*
41 * $FreeBSD: head/sys/dev/ep/if_ep.c 55864 2000-01-12 17:51:01Z mdodd $
41 * $FreeBSD: head/sys/dev/ep/if_ep.c 56017 2000-01-15 05:21:43Z mdodd $
42 *
43 * Promiscuous mode added and interrupt logic slightly changed
44 * to reduce the number of adapter failures. Transceiver select
45 * logic changed to use value from EEPROM. Autoconfiguration
46 * features added.
47 * Done by:
48 * Serge Babkin
49 * Chelindbank (Chelyabinsk, Russia)

--- 57 unchanged lines hidden (view full) ---

107static int ep_if_ioctl __P((struct ifnet *, u_long, caddr_t));
108static void ep_if_start __P((struct ifnet *));
109static void ep_if_watchdog __P((struct ifnet *));
110
111/* if_media functions */
112static int ep_ifmedia_upd __P((struct ifnet *));
113static void ep_ifmedia_sts __P((struct ifnet *, struct ifmediareq *));
114
42 *
43 * Promiscuous mode added and interrupt logic slightly changed
44 * to reduce the number of adapter failures. Transceiver select
45 * logic changed to use value from EEPROM. Autoconfiguration
46 * features added.
47 * Done by:
48 * Serge Babkin
49 * Chelindbank (Chelyabinsk, Russia)

--- 57 unchanged lines hidden (view full) ---

107static int ep_if_ioctl __P((struct ifnet *, u_long, caddr_t));
108static void ep_if_start __P((struct ifnet *));
109static void ep_if_watchdog __P((struct ifnet *));
110
111/* if_media functions */
112static int ep_ifmedia_upd __P((struct ifnet *));
113static void ep_ifmedia_sts __P((struct ifnet *, struct ifmediareq *));
114
115static void ep_get_macaddr __P((struct ep_softc *, u_char *));
116static void epstop __P((struct ep_softc *));
117static void epread __P((struct ep_softc *));
118static int eeprom_rdy __P((struct ep_softc *));
119
120#define EP_FTST(sc, f) (sc->stat & (f))
121#define EP_FSET(sc, f) (sc->stat |= (f))
122#define EP_FRST(sc, f) (sc->stat &= ~(f))
123
124static int
125eeprom_rdy(sc)
126 struct ep_softc *sc;
127{
128 int i;
129
115static void epstop __P((struct ep_softc *));
116static void epread __P((struct ep_softc *));
117static int eeprom_rdy __P((struct ep_softc *));
118
119#define EP_FTST(sc, f) (sc->stat & (f))
120#define EP_FSET(sc, f) (sc->stat |= (f))
121#define EP_FRST(sc, f) (sc->stat &= ~(f))
122
123static int
124eeprom_rdy(sc)
125 struct ep_softc *sc;
126{
127 int i;
128
130 for (i = 0; is_eeprom_busy(BASE) && i < MAX_EEPROMBUSY; i++)
131 continue;
129 for (i = 0; is_eeprom_busy(BASE) && i < MAX_EEPROMBUSY; i++) {
130 DELAY(100);
131 }
132 if (i >= MAX_EEPROMBUSY) {
133 printf("ep%d: eeprom failed to come ready.\n", sc->unit);
134 return (0);
135 }
136 return (1);
137}
138
139/*
140 * get_e: gets a 16 bits word from the EEPROM. we must have set the window
141 * before
142 */
143u_int16_t
144get_e(sc, offset)
145 struct ep_softc *sc;
132 if (i >= MAX_EEPROMBUSY) {
133 printf("ep%d: eeprom failed to come ready.\n", sc->unit);
134 return (0);
135 }
136 return (1);
137}
138
139/*
140 * get_e: gets a 16 bits word from the EEPROM. we must have set the window
141 * before
142 */
143u_int16_t
144get_e(sc, offset)
145 struct ep_softc *sc;
146 int offset;
146 u_int16_t offset;
147{
148 if (!eeprom_rdy(sc))
147{
148 if (!eeprom_rdy(sc))
149 return (0xffff);
149 return (0);
150 outw(BASE + EP_W0_EEPROM_COMMAND, (EEPROM_CMD_RD << sc->epb.cmd_off) | offset);
151 if (!eeprom_rdy(sc))
150 outw(BASE + EP_W0_EEPROM_COMMAND, (EEPROM_CMD_RD << sc->epb.cmd_off) | offset);
151 if (!eeprom_rdy(sc))
152 return (0xffff);
152 return (0);
153 return (inw(BASE + EP_W0_EEPROM_DATA));
154}
155
153 return (inw(BASE + EP_W0_EEPROM_DATA));
154}
155
156static void
156void
157ep_get_macaddr(sc, addr)
158 struct ep_softc * sc;
159 u_char * addr;
160{
161 int i;
162 u_int16_t * macaddr = (u_int16_t *)addr;
163
164 GO_WINDOW(0);

--- 36 unchanged lines hidden (view full) ---

201 sc->ep_io_addr = rman_get_start(sc->iobase);
202
203 sc->ep_btag = rman_get_bustag(sc->iobase);
204 sc->ep_bhandle = rman_get_bushandle(sc->iobase);
205
206 sc->ep_connectors = 0;
207 sc->ep_connector = 0;
208
157ep_get_macaddr(sc, addr)
158 struct ep_softc * sc;
159 u_char * addr;
160{
161 int i;
162 u_int16_t * macaddr = (u_int16_t *)addr;
163
164 GO_WINDOW(0);

--- 36 unchanged lines hidden (view full) ---

201 sc->ep_io_addr = rman_get_start(sc->iobase);
202
203 sc->ep_btag = rman_get_bustag(sc->iobase);
204 sc->ep_bhandle = rman_get_bushandle(sc->iobase);
205
206 sc->ep_connectors = 0;
207 sc->ep_connector = 0;
208
209 GO_WINDOW(0);
209 sc->epb.cmd_off = 0;
210 sc->epb.prod_id = get_e(sc, EEPROM_PROD_ID);
211 sc->epb.res_cfg = get_e(sc, EEPROM_RESOURCE_CFG);
212
213bad:
214 return (error);
215}
216

--- 175 unchanged lines hidden (view full) ---

392
393 if (ifp->if_flags & IFF_PROMISC)
394 outw(BASE + EP_COMMAND, SET_RX_FILTER | FIL_INDIVIDUAL |
395 FIL_GROUP | FIL_BRDCST | FIL_ALL);
396 else
397 outw(BASE + EP_COMMAND, SET_RX_FILTER | FIL_INDIVIDUAL |
398 FIL_GROUP | FIL_BRDCST);
399
210 sc->epb.cmd_off = 0;
211 sc->epb.prod_id = get_e(sc, EEPROM_PROD_ID);
212 sc->epb.res_cfg = get_e(sc, EEPROM_RESOURCE_CFG);
213
214bad:
215 return (error);
216}
217

--- 175 unchanged lines hidden (view full) ---

393
394 if (ifp->if_flags & IFF_PROMISC)
395 outw(BASE + EP_COMMAND, SET_RX_FILTER | FIL_INDIVIDUAL |
396 FIL_GROUP | FIL_BRDCST | FIL_ALL);
397 else
398 outw(BASE + EP_COMMAND, SET_RX_FILTER | FIL_INDIVIDUAL |
399 FIL_GROUP | FIL_BRDCST);
400
400 ep_ifmedia_upd(ifp);
401 if (!sc->epb.mii_trans) {
402 ep_ifmedia_upd(ifp);
403 }
401
402 outw(BASE + EP_COMMAND, RX_ENABLE);
403 outw(BASE + EP_COMMAND, TX_ENABLE);
404
405 ifp->if_flags |= IFF_RUNNING;
406 ifp->if_flags &= ~IFF_OACTIVE; /* just in case */
407
408#ifdef EP_LOCAL_STATS

--- 511 unchanged lines hidden (view full) ---

920 * promiscuous to multicast, since we're always a
921 * member of the ALL-SYSTEMS group, so there's no
922 * need to process SIOC*MULTI requests.
923 */
924 error = 0;
925 break;
926 case SIOCSIFMEDIA:
927 case SIOCGIFMEDIA:
404
405 outw(BASE + EP_COMMAND, RX_ENABLE);
406 outw(BASE + EP_COMMAND, TX_ENABLE);
407
408 ifp->if_flags |= IFF_RUNNING;
409 ifp->if_flags &= ~IFF_OACTIVE; /* just in case */
410
411#ifdef EP_LOCAL_STATS

--- 511 unchanged lines hidden (view full) ---

923 * promiscuous to multicast, since we're always a
924 * member of the ALL-SYSTEMS group, so there's no
925 * need to process SIOC*MULTI requests.
926 */
927 error = 0;
928 break;
929 case SIOCSIFMEDIA:
930 case SIOCGIFMEDIA:
928 error = ifmedia_ioctl(ifp, ifr, &sc->ifmedia, cmd);
931 if (!sc->epb.mii_trans) {
932 error = ifmedia_ioctl(ifp, ifr, &sc->ifmedia, cmd);
933 } else {
934 error = EINVAL;
935 }
929 break;
930 default:
931 error = EINVAL;
932 break;
933 }
934
935 (void)splx(s);
936

--- 46 unchanged lines hidden ---
936 break;
937 default:
938 error = EINVAL;
939 break;
940 }
941
942 (void)splx(s);
943

--- 46 unchanged lines hidden ---