06794990cb
- In subr_ndis.c:ndis_allocate_sharemem(), create the busdma tags used for shared memory allocations with a lowaddr of 0x3E7FFFFF. This forces the buffers to be mapped to physical/bus addresses within the first 1GB of physical memory. It seems that at least one card (Linksys Instant Wireless PCI V2.7) depends on this behavior. I don't know if this is a hardware restriction, or if the NDIS driver for this card is truncating the addresses itself, but using physical/bus addresses beyong the 1GB limit causes initialization failures. - Create am NDIS_INITIALIZED() macro in if_ndisvar.h and use it in if_ndis.c to test whether the device has been initialized rather than checking for the presence of the IFF_UP flag in if_flags. While debugging the previous problem, I noticed that bringing up the device would always produce failures from ndis_setmulti(). It turns out that the following steps now occur during device initialization: - IFF_UP flag is set in if_flags - ifp->if_ioctl() called with SIOCSIFADDR (which we don't handle) - ifp->if_ioctl() called with SIOCADDMULTI - ifp->if_ioctl() called with SIOCADDMULTI (again) - ifp->if_ioctl() called with SIOCADDMULTI (yet again) - ifp->if_ioctl() called with SIOCSIFFLAGS Setting the receive filter and multicast filters can only be done when the underlying NDIS driver has been initialized, which is done by ifp->if_init(). However, we don't call ifp->if_init() until ifp->if_ioctl() is called with SIOCSIFFLAGS and IFF_UP has been set. It appears that now, the network stack tries to add multicast addresses to interface's filter before those steps occur. Normally, ndis_setmulti() would trap this condition by checking for the IFF_UP flag, but the network code has in fact set this flag already, so ndis_setmulti() is fooled into thinking the interface has been initialized when it really hasn't. It turns out this is usually harmless because the ifp->if_init() routine (in this case ndis_init()) will set up the multicast filter when it initializes the hardware anyway, and the underlying routines (ndis_get_info()/ndis_set_info()) know that the driver/NIC haven't been initialized yet, but you end up spurious error messages on the console all the time. Something tells me this new behavior isn't really correct. I think the intention was to fix it so that ifp->if_init() is only called once when we ifconfig an interface up, but the end result seems a little bogus: the change of the IFF_UP flag should be propagated down to the driver before calling any other ioctl() that might actually require the hardware to be up and running.
136 lines
4.1 KiB
C
136 lines
4.1 KiB
C
/*
|
|
* Copyright (c) 2003
|
|
* Bill Paul <wpaul@windriver.com>. 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. All advertising materials mentioning features or use of this software
|
|
* must display the following acknowledgement:
|
|
* This product includes software developed by Bill Paul.
|
|
* 4. 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 Bill Paul 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 Bill Paul OR THE VOICES IN HIS HEAD
|
|
* 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$
|
|
*/
|
|
|
|
#define NDIS_DEFAULT_NODENAME "FreeBSD NDIS node"
|
|
#define NDIS_NODENAME_LEN 32
|
|
|
|
struct ndis_pci_type {
|
|
uint16_t ndis_vid;
|
|
uint16_t ndis_did;
|
|
uint32_t ndis_subsys;
|
|
char *ndis_name;
|
|
};
|
|
|
|
struct ndis_pccard_type {
|
|
const char *ndis_vid;
|
|
const char *ndis_did;
|
|
char *ndis_name;
|
|
};
|
|
|
|
struct ndis_shmem {
|
|
bus_dma_tag_t ndis_stag;
|
|
bus_dmamap_t ndis_smap;
|
|
void *ndis_saddr;
|
|
struct ndis_shmem *ndis_next;
|
|
};
|
|
|
|
struct ndis_cfglist {
|
|
ndis_cfg ndis_cfg;
|
|
TAILQ_ENTRY(ndis_cfglist) link;
|
|
};
|
|
|
|
TAILQ_HEAD(nch, ndis_cfglist);
|
|
|
|
#define NDIS_INITIALIZED(sc) (sc->ndis_block.nmb_miniportadapterctx != NULL)
|
|
|
|
#define NDIS_INC(x) \
|
|
(x)->ndis_txidx = ((x)->ndis_txidx + 1) % (x)->ndis_maxpkts
|
|
|
|
#define arpcom ic.ic_ac
|
|
|
|
struct ndis_softc {
|
|
struct ieee80211com ic; /* interface info */
|
|
#ifdef notdef
|
|
struct ieee80211com arpcom; /* interface info */
|
|
#endif
|
|
struct ifmedia ifmedia; /* media info */
|
|
u_long ndis_hwassist;
|
|
uint32_t ndis_v4tx;
|
|
uint32_t ndis_v4rx;
|
|
bus_space_handle_t ndis_bhandle;
|
|
bus_space_tag_t ndis_btag;
|
|
void *ndis_intrhand;
|
|
struct resource *ndis_irq;
|
|
struct resource *ndis_res;
|
|
struct resource *ndis_res_io;
|
|
int ndis_io_rid;
|
|
struct resource *ndis_res_mem;
|
|
int ndis_mem_rid;
|
|
struct resource *ndis_res_altmem;
|
|
int ndis_altmem_rid;
|
|
struct resource *ndis_res_am; /* attribute mem (pccard) */
|
|
struct resource *ndis_res_cm; /* common mem (pccard) */
|
|
int ndis_rescnt;
|
|
struct mtx ndis_mtx;
|
|
struct mtx ndis_intrmtx;
|
|
device_t ndis_dev;
|
|
int ndis_unit;
|
|
ndis_miniport_block ndis_block;
|
|
ndis_miniport_characteristics ndis_chars;
|
|
interface_type ndis_type;
|
|
struct callout_handle ndis_stat_ch;
|
|
int ndis_maxpkts;
|
|
ndis_oid *ndis_oids;
|
|
int ndis_oidcnt;
|
|
int ndis_txidx;
|
|
int ndis_txpending;
|
|
ndis_packet **ndis_txarray;
|
|
int ndis_sc;
|
|
ndis_cfg *ndis_regvals;
|
|
struct nch ndis_cfglist_head;
|
|
int ndis_80211;
|
|
int ndis_link;
|
|
uint32_t ndis_filter;
|
|
int ndis_if_flags;
|
|
int ndis_skip;
|
|
|
|
#if __FreeBSD_version < 502113
|
|
struct sysctl_ctx_list ndis_ctx;
|
|
struct sysctl_oid *ndis_tree;
|
|
#endif
|
|
int ndis_devidx;
|
|
interface_type ndis_iftype;
|
|
|
|
bus_dma_tag_t ndis_parent_tag;
|
|
struct ndis_shmem *ndis_shlist;
|
|
bus_dma_tag_t ndis_mtag;
|
|
bus_dma_tag_t ndis_ttag;
|
|
bus_dmamap_t *ndis_mmaps;
|
|
bus_dmamap_t *ndis_tmaps;
|
|
int ndis_mmapcnt;
|
|
};
|
|
|
|
#define NDIS_LOCK(_sc) mtx_lock(&(_sc)->ndis_mtx)
|
|
#define NDIS_UNLOCK(_sc) mtx_unlock(&(_sc)->ndis_mtx)
|