diff options
author | dmlb <dmlb@FreeBSD.org> | 2001-01-17 17:55:00 +0000 |
---|---|---|
committer | dmlb <dmlb@FreeBSD.org> | 2001-01-17 17:55:00 +0000 |
commit | 4356e42b84b663a6d97b41ba9b875a12d2eafac6 (patch) | |
tree | 100a68bc419d0b683e7dac813cbe1785b20a5c8a /sys/dev/ray | |
parent | 64179cca152060f1bfeaa483636788bcc3236b75 (diff) | |
download | FreeBSD-src-4356e42b84b663a6d97b41ba9b875a12d2eafac6.zip FreeBSD-src-4356e42b84b663a6d97b41ba9b875a12d2eafac6.tar.gz |
Take advantage of the fixes to the pcic code that allows multiple
active memory maps. This removes the need to change the memory
map from common to attribute every time a packet is sent/received.
This increases performance and decreases cpu load (ping times on
slow machines improve by about 1.5ms).
Move out the old common memory/attrbiute memory hack functions to a
new header file to tidy up the main code. I want to keep them available
for a while.
Diffstat (limited to 'sys/dev/ray')
-rw-r--r-- | sys/dev/ray/if_ray.c | 131 | ||||
-rw-r--r-- | sys/dev/ray/if_ray_oldcard.h | 136 | ||||
-rw-r--r-- | sys/dev/ray/if_rayvar.h | 25 |
3 files changed, 160 insertions, 132 deletions
diff --git a/sys/dev/ray/if_ray.c b/sys/dev/ray/if_ray.c index 7f35cb2..f00d740 100644 --- a/sys/dev/ray/if_ray.c +++ b/sys/dev/ray/if_ray.c @@ -69,25 +69,23 @@ * This card is unusual in that it uses both common and attribute * memory whilst working. It should use common memory and an IO port. * - * The 3.x branch of FreeBSD has a real problem managing and setting - * up the correct memory maps. However, this driver should reset the - * memory maps correctly - it works around for the brain deadness of - * pccardd (where it reads the CIS for common memory, sets it all up - * and then throws it all away assuming the card is an ed driver...). - * Note that this could be dangerous (because it doesn't interact with - * pccardd) if you use other memory mapped cards at the same time. + * The bus resource allocations need to work around the brain deadness + * of pccardd (where it reads the CIS for common memory, sets it all + * up and then throws it all away assuming the card is an ed + * driver...). Note that this could be dangerous (because it doesn't + * interact with pccardd) if you use other memory mapped cards in the + * same pccard slot as currently old mappings are not cleaned up very well + * by the bus_release_resource methods or pccardd. * * There is no support for running this driver on 4.0. * - * For >4.1 and -cuurent things are a lot better. - * * Ad-hoc and infra-structure modes * ================================ * - * At present only the ad-hoc mode is being worked on. + * At present only the ad-hoc mode is tested. * - * I hope to start work on support for infrastructure when an AP arrives - * from FreeBSD Labs. + * I have received an AP from Raylink and will be working on + * infrastructure mode. * * The Linux driver also seems to have the capability to act as an AP. * I wonder what facilities the "AP" can provide within a driver? We can @@ -227,7 +225,10 @@ /* * XXX build options - move to LINT */ -#define RAY_NEED_CM_REMAPPING 1 /* Needed until pccard maps more than one memory area */ +#define RAY_CM_RID 2 /* pccardd abuses windows 0 and 1 */ +#define RAY_AM_RID 3 /* pccardd abuses windows 0 and 1 */ +#define RAY_NEED_CM_REMAPPING 0 /* Needed until pccard maps more than one memory area */ +#define RAY_NEED_AM_REMAPPING 0 /* Needed until pccard maps more than one memory area */ #define RAY_COM_TIMEOUT (hz/2) /* Timeout for CCS commands */ #define RAY_TX_TIMEOUT (hz/2) /* Timeout for rescheduling TX */ /* @@ -268,6 +269,7 @@ #include <dev/ray/if_raymib.h> #include <dev/ray/if_raydbg.h> #include <dev/ray/if_rayvar.h> +#include <dev/ray/if_ray_oldcard.h> /* * Prototyping @@ -342,12 +344,6 @@ static void ray_com_ecf_check (struct ray_softc *sc, size_t ccs, char *mesg); #if RAY_DEBUG & RAY_DBG_MBUF static void ray_dump_mbuf (struct ray_softc *sc, struct mbuf *m, char *s); #endif /* RAY_DEBUG & RAY_DBG_MBUF */ -#if RAY_NEED_CM_REMAPPING -static void ray_attr_mapam (struct ray_softc *sc); -static void ray_attr_mapcm (struct ray_softc *sc); -static u_int8_t ray_attr_read_1 (struct ray_softc *sc, off_t offset); -static void ray_attr_write_1 (struct ray_softc *sc, off_t offset, u_int8_t byte); -#endif /* RAY_NEED_CM_REMAPPING */ /* * PC-Card (PCMCIA) driver definition @@ -1371,9 +1367,7 @@ ray_tx(struct ifnet *ifp) } eh = mtod(m0, struct ether_header *); - for (pktlen = 0, m = m0; m != NULL; m = m->m_next) { - pktlen += m->m_len; - } + pktlen = m0->m_pkthdr.len; if (pktlen > ETHER_MAX_LEN - ETHER_CRC_LEN) { RAY_RECERR(sc, "mbuf too long %d", pktlen); RAY_CCS_FREE(sc, ccs); @@ -1417,7 +1411,7 @@ ray_tx(struct ifnet *ifp) * */ if (m0->m_len < sizeof(struct ether_header)) - m0 = m_pullup(m, sizeof(struct ether_header)); + m0 = m_pullup(m0, sizeof(struct ether_header)); if (m0 == NULL) { RAY_RECERR(sc, "could not pullup ether"); RAY_CCS_FREE(sc, ccs); @@ -2186,7 +2180,7 @@ ray_intr(void *xsc) struct ifnet *ifp = &sc->arpcom.ac_if; size_t ccs; u_int8_t cmd; - int ccsi, count; + int ccsi; RAY_DPRINTF(sc, RAY_DBG_SUBR, ""); RAY_MAP_CM(sc); @@ -2198,10 +2192,7 @@ ray_intr(void *xsc) * Check that the interrupt was for us, if so get the rcs/ccs * and vector on the command contained within it. */ - if (!RAY_HCS_INTR(sc)) - count = 0; - else { - count = 1; + if (RAY_HCS_INTR(sc)) { ccsi = SRAM_READ_1(sc, RAY_SCB_RCSI); ccs = RAY_CCS_ADDRESS(ccsi); cmd = SRAM_READ_FIELD_1(sc, ccs, ray_cmd, c_cmd); @@ -2211,17 +2202,13 @@ ray_intr(void *xsc) ray_intr_rcs(sc, cmd, ccs); else RAY_RECERR(sc, "bad ccs index 0x%x", ccsi); - } - - if (count) RAY_HCS_CLEAR_INTR(sc); - - RAY_DPRINTF(sc, RAY_DBG_RX, "interrupt %s handled", count?"was":"not"); + RAY_DPRINTF(sc, RAY_DBG_RX, "interrupt was handled"); + } /* Send any packets lying around and update error counters */ if (!(ifp->if_flags & IFF_OACTIVE) && (ifp->if_snd.ifq_head != NULL)) ray_tx(ifp); - if ((++sc->sc_checkcounters % 32) == 0) ray_intr_updt_errcntrs(sc); } @@ -3326,7 +3313,7 @@ ray_res_alloc_am(struct ray_softc *sc) RAY_DPRINTF(sc, RAY_DBG_SUBR | RAY_DBG_CM, ""); - sc->am_rid = 1; /* pccard uses 0 */ + sc->am_rid = RAY_AM_RID; start = bus_get_resource_start(sc->dev, SYS_RES_MEMORY, sc->am_rid); count = bus_get_resource_count(sc->dev, SYS_RES_MEMORY, sc->am_rid); error = CARD_GET_RES_FLAGS(device_get_parent(sc->dev), sc->dev, @@ -3374,7 +3361,7 @@ ray_res_alloc_am(struct ray_softc *sc) } } if (!(flags & 0x10) /* XXX MDF_ATTR */) { - RAY_PRINTF(sc, "fixing up AM flags from 0x%lx to 0x10", + RAY_PRINTF(sc, "fixing up AM flags from 0x%lx to 0x50", flags); error = CARD_SET_RES_FLAGS(device_get_parent(sc->dev), sc->dev, SYS_RES_MEMORY, sc->am_rid, PCCARD_A_MEM_ATTR); @@ -3414,7 +3401,7 @@ ray_res_alloc_cm(struct ray_softc *sc) RAY_DPRINTF(sc, RAY_DBG_SUBR | RAY_DBG_CM, ""); - sc->cm_rid = 0; /* pccard uses 0 */ + sc->cm_rid = RAY_CM_RID; start = bus_get_resource_start(sc->dev, SYS_RES_MEMORY, sc->cm_rid); count = bus_get_resource_count(sc->dev, SYS_RES_MEMORY, sc->cm_rid); error = CARD_GET_RES_FLAGS(device_get_parent(sc->dev), sc->dev, @@ -3548,76 +3535,6 @@ ray_res_release(struct ray_softc *sc) } /* - * Hacks for working around the PCCard layer problems. - * - * For NEWBUS kludge and OLDCARD. - * - * We just call the pccard layer to change and restore the mapping each - * time we use the attribute memory. - * - * XXX These could become marcos around bus_activate_resource, but - * XXX the functions do made hacking them around safer. - * - */ -#if RAY_NEED_CM_REMAPPING -static void -ray_attr_mapam(struct ray_softc *sc) -{ - bus_activate_resource(sc->dev, SYS_RES_MEMORY, sc->am_rid, sc->am_res); -#if RAY_DEBUG & RAY_DBG_CM - { - u_long flags = 0xffff; - CARD_GET_RES_FLAGS(device_get_parent(sc->dev), sc->dev, - sys_res_memory, SC->AM_RID, &FLAGS); - RAY_PRINTF(sc, "attribute memory\n" - ". start 0x%0lx count 0x%0lx flags 0x%0lx", - bus_get_resource_start(sc->dev, SYS_RES_MEMORY, sc->am_rid), - bus_get_resource_count(sc->dev, SYS_RES_MEMORY, sc->am_rid), - flags); - } -#endif /* RAY_DEBUG & RAY_DBG_CM */ -} - -static void -ray_attr_mapcm(struct ray_softc *sc) -{ - bus_activate_resource(sc->dev, SYS_RES_MEMORY, sc->cm_rid, sc->cm_res); -#if RAY_DEBUG & RAY_DBG_CM - { - u_long flags = 0xffff; - CARD_GET_RES_FLAGS(device_get_parent(sc->dev), sc->dev, - SYS_RES_MEMORY, sc->cm_rid, &flags); - RAY_PRINTF(sc, "common memory\n" - ". start 0x%0lx count 0x%0lx flags 0x%0lx", - bus_get_resource_start(sc->dev, SYS_RES_MEMORY, sc->cm_rid), - bus_get_resource_count(sc->dev, SYS_RES_MEMORY, sc->cm_rid), - flags); - } -#endif /* RAY_DEBUG & RAY_DBG_CM */ -} - -static u_int8_t -ray_attr_read_1(struct ray_softc *sc, off_t offset) -{ - u_int8_t byte; - - ray_attr_mapam(sc); - byte = (u_int8_t)bus_space_read_1(sc->am_bst, sc->am_bsh, offset); - ray_attr_mapcm(sc); - - return (byte); -} - -static void -ray_attr_write_1(struct ray_softc *sc, off_t offset, u_int8_t byte) -{ - ray_attr_mapam(sc); - bus_space_write_1(sc->am_bst, sc->am_bsh, offset, byte); - ray_attr_mapcm(sc); -} -#endif /* RAY_NEED_CM_REMAPPING */ - -/* * mbuf dump */ #if RAY_DEBUG & RAY_DBG_MBUF diff --git a/sys/dev/ray/if_ray_oldcard.h b/sys/dev/ray/if_ray_oldcard.h new file mode 100644 index 0000000..826227a --- /dev/null +++ b/sys/dev/ray/if_ray_oldcard.h @@ -0,0 +1,136 @@ +/* + * Copyright (C) 2000 + * Dr. Duncan McLennan Barclay, dmlb@ragnet.demon.co.uk. + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, 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. + * 3. Neither the name of the author nor the names of any co-contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY DUNCAN BARCLAY 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 DUNCAN BARCLAY 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. + * + * $FreeBSD$ + * + */ + +/* + * Hacks for working around the PCCard layer problems in NEWBUS kludge + * and OLDCARD. + * + * Now that /sys/pccard/pcic.c can support multiple memory maps per + * slot correctly this is historical code. It is being left in the tree + * for a short while until interactions between OLDCARD and pccardd + * are ironed out. The common and attribute memory is now always + * mapped in. dmlb 17/1/01 + * + * The driver assumes that the common memory is always mapped in, + * for the moment we ensure this with the following macro at the + * head of each function and by using functions to access attribute + * memory. Hysterical raisins led to the non-"reflexive" approach. + * Roll on NEWCARD and it can all die... + * + * We call the pccard layer to change and restore the mapping each + * time we use the attribute memory. + * + * These could become marcos around bus_activate_resource, but + * the functions do made hacking them around safer. + */ + +#if RAY_NEED_CM_REMAPPING +#define RAY_MAP_CM(sc) ray_attr_mapcm(sc) +#else +#define RAY_MAP_CM(sc) +#endif /* RAY_NEED_CM_REMAPPING */ + +#if RAY_NEED_AM_REMAPPING +static __inline void ray_attr_mapam (struct ray_softc *sc); +static __inline u_int8_t ray_attr_read_1 (struct ray_softc *sc, off_t offset); +static __inline void ray_attr_write_1 (struct ray_softc *sc, off_t offset, u_int8_t byte); +#undef ATTR_READ_1 +#define ATTR_READ_1(sc, off) ray_attr_read_1((sc), (off)) +#undef ATTR_WRITE_1 +#define ATTR_WRITE_1(sc, off, val) ray_attr_write_1((sc), (off), (val)) +#endif /* RAY_NEED_AM_REMAPPING */ + +#if (RAY_NEED_AM_REMAPPING || RAY_NEED_CM_REMAPPING) +static __inline void ray_attr_mapcm (struct ray_softc *sc); +#endif /* (RAY_NEED_AM_REMAPPING || RAY_NEED_CM_REMAPPING) */ + +#if (RAY_NEED_AM_REMAPPING || RAY_NEED_CM_REMAPPING) +static __inline void +ray_attr_mapcm(struct ray_softc *sc) +{ + bus_activate_resource(sc->dev, SYS_RES_MEMORY, sc->cm_rid, sc->cm_res); +#if RAY_DEBUG & RAY_DBG_CM + { + u_long flags = 0xffff; + CARD_GET_RES_FLAGS(device_get_parent(sc->dev), sc->dev, + SYS_RES_MEMORY, sc->cm_rid, &flags); + RAY_PRINTF(sc, "common memory\n" + ". start 0x%0lx count 0x%0lx flags 0x%0lx", + bus_get_resource_start(sc->dev, SYS_RES_MEMORY, sc->cm_rid), + bus_get_resource_count(sc->dev, SYS_RES_MEMORY, sc->cm_rid), + flags); + } +#endif /* RAY_DEBUG & RAY_DBG_CM */ +} +#endif /* (RAY_NEED_AM_REMAPPING || RAY_NEED_CM_REMAPPING) */ + +#if RAY_NEED_AM_REMAPPING +static __inline void +ray_attr_mapam(struct ray_softc *sc) +{ + bus_activate_resource(sc->dev, SYS_RES_MEMORY, sc->am_rid, sc->am_res); +#if RAY_DEBUG & RAY_DBG_CM + { + u_long flags = 0xffff; + CARD_GET_RES_FLAGS(device_get_parent(sc->dev), sc->dev, + SYS_RES_MEMORY, sc->am_rid, &flags); + RAY_PRINTF(sc, "attribute memory\n" + ". start 0x%0lx count 0x%0lx flags 0x%0lx", + bus_get_resource_start(sc->dev, SYS_RES_MEMORY, sc->am_rid), + bus_get_resource_count(sc->dev, SYS_RES_MEMORY, sc->am_rid), + flags); + } +#endif /* RAY_DEBUG & RAY_DBG_CM */ +} + +static __inline u_int8_t +ray_attr_read_1(struct ray_softc *sc, off_t offset) +{ + u_int8_t byte; + + ray_attr_mapam(sc); + byte = (u_int8_t)bus_space_read_1(sc->am_bst, sc->am_bsh, offset); + ray_attr_mapcm(sc); + + return (byte); +} + +static __inline void +ray_attr_write_1(struct ray_softc *sc, off_t offset, u_int8_t byte) +{ + ray_attr_mapam(sc); + bus_space_write_1(sc->am_bst, sc->am_bsh, offset, byte); + ray_attr_mapcm(sc); +} +#endif /* RAY_NEED_AM_REMAPPING */ diff --git a/sys/dev/ray/if_rayvar.h b/sys/dev/ray/if_rayvar.h index d366918..e30491b 100644 --- a/sys/dev/ray/if_rayvar.h +++ b/sys/dev/ray/if_rayvar.h @@ -144,24 +144,12 @@ static int mib_info[RAY_MIB_MAX+1][3] = RAY_MIB_INFO; ((size_t)(&((type *)0)->member)) #endif /* offsetof */ -#if RAY_NEED_CM_REMAPPING - -#define ATTR_READ_1(sc, off) \ - ray_attr_read_1((sc), (off)) - -#define ATTR_WRITE_1(sc, off, val) \ - ray_attr_write_1((sc), (off), (val)) - -#else - #define ATTR_READ_1(sc, off) \ ((u_int8_t)bus_space_read_1((sc)->am_bst, (sc)->am_bsh, (off))) #define ATTR_WRITE_1(sc, off, val) \ bus_space_write_1((sc)->am_bst, (sc)->am_bsh, (off), (val)) -#endif /* RAY_NEED_CM_REMAPPING */ - #define SRAM_READ_1(sc, off) \ ((u_int8_t)bus_space_read_1((sc)->cm_bst, (sc)->cm_bsh, (off))) @@ -295,16 +283,3 @@ static int mib_info[RAY_MIB_MAX+1][3] = RAY_MIB_INFO; __FUNCTION__ , __LINE__ , ##args); \ } } while (0) #endif /* RAY_RECERR */ - -/* - * The driver assumes that the common memory is always mapped in, - * for the moment we ensure this with the following macro at the - * head of each function and by using functions to access attribute - * memory. Hysterical raisins led to the non-"reflexive" approach. - * Roll on NEWCARD and it can all die... - */ -#if RAY_NEED_CM_REMAPPING -#define RAY_MAP_CM(sc) ray_attr_mapcm(sc) -#else -#define RAY_MAP_CM(sc) -#endif /* RAY_NEED_CM_REMAPPING */ |