File nut/arch/avr/dev/wlandrv.c

* This file is part of the WLAN-Ethernut device driver.
* Copyright (c) 2004 by Michael Fischer. 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 its contributors may * be used to endorse or promote products derived from this software * without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT OWNER 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.
**************************************************************************** * Portions Copyright:
* Copyright (c) 2002 * M Warner Losh <imp@freebsd.org>. All rights reserved. * Copyright (c) 1997, 1998, 1999 * Bill Paul <wpaul@ctr.columbia.edu>. 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 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.
**************************************************************************** * History:
* 28.02.04 mifi First Version * If you like to see the original source. Take a look * in if_wi.c from FreeBSD. * 01.03.04 mifi Now we use a timeout in our Thread, and check if we lost * the card. In this case we try to Init it again. * 02.03.04 mifi Remove QuickHack for Networkname and WEP. * 03.03.04 mifi Use struct to config WLAN (WLAN_IOCTL_SET_CONFIG) * 04.03.04 mifi Add function to get WLAN_STATUS (WLAN_IOCTL_GET_STATUS) * 06.03.04 mifi Remove all @@MF later for monitor mode. * It does not work with my card, and I think we need a * special firmware for it.


Included Files


Preprocessor definitions

#define __WLANDRV_C__

#define Debug( _x )

#define Debug2( _x )

#define panic

#define WI_LOCK( sc )

#define WI_UNLOCK( sc )

#define ieee80211_new_state( _a, _b, _c )

#define isset( _a, _b )

#define CSR_WRITE_2( _a, _b, _c )

#define CSR_READ_2( _a, _b )

#define WLAN_MIN_ETHERNET_FRAME_LEN 60

#define WLAN_MAX_ETHERNET_FRAME_LEN 1514

#define WLAN_ETHERNET_HEADER_LEN 14

#define WI_INTRS


Type struct wi_card_ident

struct wi_card_ident
struct wi_card_ident  
   {  
      u_int16_t card_id;  
      char* card_name;  
      u_int8_t firm_type;  
   }  

Type struct ieee80211_frame_addr4

struct ieee80211_frame_addr4
struct ieee80211_frame_addr4  
   {  
      u_int8_t i_fc[2];  
      u_int8_t i_dur[2];  
      u_int8_t i_addr1[6];  
      u_int8_t i_addr2[6];  
      u_int8_t i_addr3[6];  
      u_int8_t i_seq[2];  
      u_int8_t i_addr4[6];  
   }  

Type struct wi_frame

struct wi_frame
struct wi_frame  
   {  
      u_int16_t wi_status;  
      u_int16_t wi_rx_tstamp1;  
      u_int16_t wi_rx_tstamp0;  
      u_int8_t wi_rx_silence;  
      u_int8_t wi_rx_signal;  
      u_int8_t wi_rx_rate;  
      u_int8_t wi_rx_flow;  
      u_int8_t wi_tx_rtry;  
      u_int8_t wi_tx_rate;  
      u_int16_t wi_tx_ctl;  
      struct ieee80211_frame_addr4 wi_whdr;  
      u_int16_t wi_dat_len;  
      struct ether_header wi_ehdr;  
   }  

Type struct wi_ssid

struct wi_ssid
struct wi_ssid  
   {  
      u_int16_t wi_len;  
      u_int8_t wi_ssid[32];  
   }  

Typedef LLCS_SNAP_HEADER

typedef struct {...} LLCS_SNAP_HEADER
struct  
   {  
      u_int16_t DSAPSSAP;  
      u_int16_t Control;  
      u_int16_t MustZero;  
      u_int16_t Type;  
   }  

Global Variable wi_card_ident

struct wi_card_ident wi_card_ident[]
Visible in:   nut/arch/avr/dev/wlandrv.c
Used in: wi_read_nicid() nut/arch/avr/dev/wlandrv.c

Local Variables

hDeviceSemaphore
static HANDLE hDeviceSemaphore
Used in: RxThread()  
  wlandrv_Attach()  
  wlandrv_IOCTL()  
  wlandrv_Init()  
  wlandrv_PutPacket()  

bDebugState
static BYTE bDebugState

Used in: DumpWlanData()  
  wlandrv_Attach()  

Global Function DumpWlanData()

void DumpWlanData ( BYTE* pBuffer, WORD wBufferSize )
References Variables: bDebugState nut/arch/avr/dev/wlandrv.c

Global Function RxThread()

void RxThread ( void* arg )
Prototyped in: nut/arch/avr/dev/wlandrv.c
Calls: NutEventPost() nut/os/event.c
  NutEventWait() nut/os/event.c
  pcmcia_WriteReg() nut/arch/avr/dev/pcmcia.c
  wi_info_intr() nut/arch/avr/dev/wlandrv.c
  wi_rx_intr() nut/arch/avr/dev/wlandrv.c
  wi_tx_intr() nut/arch/avr/dev/wlandrv.c
  wlandrv_Init() nut/arch/avr/dev/wlandrv.c
Used in: wlandrv_Init() nut/arch/avr/dev/wlandrv.c
References Variables: hDeviceSemaphore nut/arch/avr/dev/wlandrv.c

Global Function wi_stop()

void wi_stop ( struct wi_softc* sc, int disable )
Calls: DELAY() nut/arch/avr/dev/wlandrv.c
  pcmcia_WriteReg() nut/arch/avr/dev/pcmcia.c
  wi_cmd() nut/arch/avr/dev/wlandrv.c
Called by: wlandrv_IOCTL() nut/arch/avr/dev/wlandrv.c
  wlandrv_Init() nut/arch/avr/dev/wlandrv.c

Global Function wlandrv_Attach()

int wlandrv_Attach ( NUTDEVICE* dev )
Prototyped in: nut/include/dev/wlandrv.h
Calls: NutEventPost() nut/os/event.c
  wi_read_nicid() nut/arch/avr/dev/wlandrv.c
  wi_read_rid() nut/arch/avr/dev/wlandrv.c
  wi_reset() nut/arch/avr/dev/wlandrv.c
Called by: WlanInit() nut/arch/avr/dev/wlan.c
References Variables: bDebugState nut/arch/avr/dev/wlandrv.c
  hDeviceSemaphore nut/arch/avr/dev/wlandrv.c

Global Function wlandrv_IOCTL()

int wlandrv_IOCTL ( NUTDEVICE* dev, int req, void* conf )
Prototyped in: nut/include/dev/wlandrv.h
Calls: NutEventPost() nut/os/event.c
  NutEventWait() nut/os/event.c
  wi_read_rid() nut/arch/avr/dev/wlandrv.c
  wi_stop() nut/arch/avr/dev/wlandrv.c
  wlandrv_Init() nut/arch/avr/dev/wlandrv.c
  memcpy(), memset(), strlen()
Called by: WlanIOCtl() nut/arch/avr/dev/wlan.c
References Variables: hDeviceSemaphore nut/arch/avr/dev/wlandrv.c

Global Function wlandrv_Init()

void wlandrv_Init ( NUTDEVICE* dev )
Prototyped in: nut/include/dev/wlandrv.h
Calls: NutEventPost() nut/os/event.c
  NutEventWait() nut/os/event.c
  NutRegisterIrqHandler() nut/dev/ihndlr.c
  NutThreadCreate() nut/arch/avr/os/context_gcc.c
  pcmcia_WriteReg() nut/arch/avr/dev/pcmcia.c
  wi_alloc_fid() nut/arch/avr/dev/wlandrv.c
  wi_cmd() nut/arch/avr/dev/wlandrv.c
  wi_reset() nut/arch/avr/dev/wlandrv.c
  wi_stop() nut/arch/avr/dev/wlandrv.c
  wi_write_rid() nut/arch/avr/dev/wlandrv.c
  wi_write_ssid() nut/arch/avr/dev/wlandrv.c
  wi_write_txrate() nut/arch/avr/dev/wlandrv.c
  wi_write_val() nut/arch/avr/dev/wlandrv.c
  wi_write_wep() nut/arch/avr/dev/wlandrv.c
Called by: RxThread() nut/arch/avr/dev/wlandrv.c
  WlanInit() nut/arch/avr/dev/wlan.c
  wlandrv_IOCTL() nut/arch/avr/dev/wlandrv.c
References Functions: RxThread() nut/arch/avr/dev/wlandrv.c
  WLANInterrupt() nut/arch/avr/dev/wlandrv.c
References Variables: hDeviceSemaphore nut/arch/avr/dev/wlandrv.c

Global Function wlandrv_ProbeDevice()

int wlandrv_ProbeDevice ( void )
Prototyped in: nut/include/dev/wlandrv.h
Calls: NutSleep() nut/os/timer.c
  pcmcia_ReadReg() nut/arch/avr/dev/pcmcia.c
  pcmcia_WriteMem() nut/arch/avr/dev/pcmcia.c
  pcmcia_WriteReg() nut/arch/avr/dev/pcmcia.c
Called by: WlanInit() nut/arch/avr/dev/wlan.c

Global Function wlandrv_PutPacket()

int wlandrv_PutPacket ( NUTDEVICE* dev, NETBUF* nb )
Prototyped in: nut/include/dev/wlandrv.h
Calls: NutEventPost() nut/os/event.c
  NutEventWait() nut/os/event.c
  wi_cmd() nut/arch/avr/dev/wlandrv.c
  wi_write_bap() nut/arch/avr/dev/wlandrv.c
  memcpy(), memset()
Called by: WlanOutput() nut/arch/avr/dev/wlan.c
References Variables: hDeviceSemaphore nut/arch/avr/dev/wlandrv.c

Local Function DELAY()

static void DELAY ( u_int32_t delay_us )
Calls: NutSleep() nut/os/timer.c
Called by: wi_alloc_fid() nut/arch/avr/dev/wlandrv.c
  wi_cmd() nut/arch/avr/dev/wlandrv.c
  wi_reset() nut/arch/avr/dev/wlandrv.c
  wi_seek_bap() nut/arch/avr/dev/wlandrv.c
  wi_stop() nut/arch/avr/dev/wlandrv.c

Local Function WLANInterrupt()

static void WLANInterrupt ( void* p )
Calls: pcmcia_ReadReg() nut/arch/avr/dev/pcmcia.c
  pcmcia_WriteReg() nut/arch/avr/dev/pcmcia.c
Used in: wlandrv_Init() nut/arch/avr/dev/wlandrv.c

Local Function wi_alloc_fid()

static int wi_alloc_fid ( struct wi_softc* sc, int len, int* idp )
Calls: DELAY() nut/arch/avr/dev/wlandrv.c
  pcmcia_ReadReg() nut/arch/avr/dev/pcmcia.c
  pcmcia_WriteReg() nut/arch/avr/dev/pcmcia.c
  wi_cmd() nut/arch/avr/dev/wlandrv.c
Called by: wlandrv_Init() nut/arch/avr/dev/wlandrv.c

Local Function wi_cmd()

static int wi_cmd ( struct wi_softc* sc, int cmd, int val0, int val1, int val2 )
Calls: DELAY() nut/arch/avr/dev/wlandrv.c
  pcmcia_ReadReg() nut/arch/avr/dev/pcmcia.c
  pcmcia_WriteReg() nut/arch/avr/dev/pcmcia.c
Called by: wi_alloc_fid() nut/arch/avr/dev/wlandrv.c
  wi_info_intr() nut/arch/avr/dev/wlandrv.c
  wi_read_rid() nut/arch/avr/dev/wlandrv.c
  wi_reset() nut/arch/avr/dev/wlandrv.c
  wi_stop() nut/arch/avr/dev/wlandrv.c
  wi_tx_intr() nut/arch/avr/dev/wlandrv.c
  wi_write_rid() nut/arch/avr/dev/wlandrv.c
  wlandrv_Init() nut/arch/avr/dev/wlandrv.c
  wlandrv_PutPacket() nut/arch/avr/dev/wlandrv.c

Local Function wi_info_intr()

static void wi_info_intr ( struct wi_softc* sc )
Calls: pcmcia_ReadReg() nut/arch/avr/dev/pcmcia.c
  pcmcia_WriteReg() nut/arch/avr/dev/pcmcia.c
  wi_cmd() nut/arch/avr/dev/wlandrv.c
  wi_read_bap() nut/arch/avr/dev/wlandrv.c
Called by: RxThread() nut/arch/avr/dev/wlandrv.c

Local Function wi_read_bap()

static int wi_read_bap ( struct wi_softc* sc, int id, int off, void* buf, int buflen )
Calls: pcmcia_ReadReg() nut/arch/avr/dev/pcmcia.c
  wi_seek_bap() nut/arch/avr/dev/wlandrv.c
Called by: wi_info_intr() nut/arch/avr/dev/wlandrv.c
  wi_read_rid() nut/arch/avr/dev/wlandrv.c
  wi_rx_intr() nut/arch/avr/dev/wlandrv.c

Local Function wi_read_nicid()

static void wi_read_nicid ( struct wi_softc* sc )
Calls: wi_read_rid() nut/arch/avr/dev/wlandrv.c
  memset()
Called by: wlandrv_Attach() nut/arch/avr/dev/wlandrv.c
References Variables: wi_card_ident nut/arch/avr/dev/wlandrv.c

Local Function wi_read_rid()

static int wi_read_rid ( struct wi_softc* sc, int rid, void* buf, int* buflenp )
Calls: wi_cmd() nut/arch/avr/dev/wlandrv.c
  wi_read_bap() nut/arch/avr/dev/wlandrv.c
Called by: wi_read_nicid() nut/arch/avr/dev/wlandrv.c
  wlandrv_Attach() nut/arch/avr/dev/wlandrv.c
  wlandrv_IOCTL() nut/arch/avr/dev/wlandrv.c

Local Function wi_reset()

static int wi_reset ( struct wi_softc* sc )
Calls: DELAY() nut/arch/avr/dev/wlandrv.c
  pcmcia_WriteReg() nut/arch/avr/dev/pcmcia.c
  wi_cmd() nut/arch/avr/dev/wlandrv.c
  wi_write_val() nut/arch/avr/dev/wlandrv.c
Called by: wlandrv_Attach() nut/arch/avr/dev/wlandrv.c
  wlandrv_Init() nut/arch/avr/dev/wlandrv.c

Local Function wi_rx_intr()

static NETBUF* wi_rx_intr ( struct wi_softc* sc )
Calls: NutNetBufAlloc() nut/dev/netbuf.c
  NutNetBufFree() nut/dev/netbuf.c
  pcmcia_ReadReg() nut/arch/avr/dev/pcmcia.c
  pcmcia_WriteReg() nut/arch/avr/dev/pcmcia.c
  wi_read_bap() nut/arch/avr/dev/wlandrv.c
  memcpy()
Called by: RxThread() nut/arch/avr/dev/wlandrv.c

Local Function wi_seek_bap()

static int wi_seek_bap ( struct wi_softc* sc, int id, int off )
Calls: DELAY() nut/arch/avr/dev/wlandrv.c
  pcmcia_ReadReg() nut/arch/avr/dev/pcmcia.c
  pcmcia_WriteReg() nut/arch/avr/dev/pcmcia.c
Called by: wi_read_bap() nut/arch/avr/dev/wlandrv.c
  wi_write_bap() nut/arch/avr/dev/wlandrv.c

Local Function wi_tx_intr()

static void wi_tx_intr ( struct wi_softc* sc )
Calls: pcmcia_ReadReg() nut/arch/avr/dev/pcmcia.c
  pcmcia_WriteReg() nut/arch/avr/dev/pcmcia.c
  wi_cmd() nut/arch/avr/dev/wlandrv.c
Called by: RxThread() nut/arch/avr/dev/wlandrv.c

Local Function wi_write_bap()

static int wi_write_bap ( struct wi_softc* sc, int id, int off, void* buf, int buflen )
Calls: pcmcia_WriteReg() nut/arch/avr/dev/pcmcia.c
  wi_seek_bap() nut/arch/avr/dev/wlandrv.c
Called by: wi_write_rid() nut/arch/avr/dev/wlandrv.c
  wlandrv_PutPacket() nut/arch/avr/dev/wlandrv.c

Local Function wi_write_rid()

static int wi_write_rid ( struct wi_softc* sc, int rid, void* buf, int buflen )
Calls: wi_cmd() nut/arch/avr/dev/wlandrv.c
  wi_write_bap() nut/arch/avr/dev/wlandrv.c
Called by: wi_write_ssid() nut/arch/avr/dev/wlandrv.c
  wi_write_val() nut/arch/avr/dev/wlandrv.c
  wi_write_wep() nut/arch/avr/dev/wlandrv.c
  wlandrv_Init() nut/arch/avr/dev/wlandrv.c

Local Function wi_write_ssid()

static int wi_write_ssid ( struct wi_softc* sc, int rid, u_int8_t* buf, int buflen )
Calls: wi_write_rid() nut/arch/avr/dev/wlandrv.c
  memcpy(), memset()
Called by: wlandrv_Init() nut/arch/avr/dev/wlandrv.c

Local Function wi_write_txrate()

static int wi_write_txrate ( struct wi_softc* sc )
Calls: wi_write_val() nut/arch/avr/dev/wlandrv.c
Called by: wlandrv_Init() nut/arch/avr/dev/wlandrv.c

Local Function wi_write_val()

static int wi_write_val ( struct wi_softc* sc, int rid, u_int16_t val )
Calls: wi_write_rid() nut/arch/avr/dev/wlandrv.c
Called by: wi_reset() nut/arch/avr/dev/wlandrv.c
  wi_write_txrate() nut/arch/avr/dev/wlandrv.c
  wi_write_wep() nut/arch/avr/dev/wlandrv.c
  wlandrv_Init() nut/arch/avr/dev/wlandrv.c

Local Function wi_write_wep()

static int wi_write_wep ( struct wi_softc* sc )
Calls: wi_write_rid() nut/arch/avr/dev/wlandrv.c
  wi_write_val() nut/arch/avr/dev/wlandrv.c
  memcpy(), memset()
Called by: wlandrv_Init() nut/arch/avr/dev/wlandrv.c