Navigation
Home
bsd
atuwi
0.1
if_atuwireg.h








































if_atuwireg.h
   /*
    * Copyright (c) 2003
    *	Daan Vreeken <Danovitsch @ Vitsch . net>.  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 Daan Vreeken.
    * 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 Daan Vreeken 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 Daan Vreeken 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.
    *
    */
   
   /*
    * Definitions for the Atmel wireless lan controllers
    */
   
   
   
   /*
    * TODO - should make this a reasonable number... :)
    * it's more than 1536 (802.11 & atmel header), but 2000 is too much
    */
   /* #define ATUWI_BUFSZ		1536 */
   #define ATUWI_BUFSZ		2000
   
   #define ATUWI_MIN_FRAMELEN	60
   
   #define ATUWI_RX_LIST_CNT	1
   #define ATUWI_TX_LIST_CNT	1
   
   #define ATUWI_ENDPT_RX		0x0
   #define ATUWI_ENDPT_TX		0x1
   #define ATUWI_ENDPT_MAX		0x2
   
   
   enum atuwi_radio_type {
   	RadioRFMD = 0,
   	RadioIntersil
   };
   
   struct atuwi_type {
   	u_int16_t		atuwi_vid;
   	u_int16_t		atuwi_did;
   	enum atuwi_radio_type	atuwi_radio;
   };
   
   
   struct atuwi_softc;
   
   struct atuwi_chain {
   	struct atuwi_softc	*atuwi_sc;
   	usbd_xfer_handle	atuwi_xfer;
   	char			*atuwi_buf;
   	struct mbuf		*atuwi_mbuf;
   	int			atuwi_idx;
   };
   
   struct atuwi_cdata {
   	struct atuwi_chain	atuwi_tx_chain[ATUWI_TX_LIST_CNT];
   	struct atuwi_chain	atuwi_rx_chain[ATUWI_RX_LIST_CNT];
   	int			atuwi_tx_prod;
   	int			atuwi_tx_cons;
   	int			atuwi_tx_cnt;
   	int			atuwi_rx_prod;
   };
   
   
   #define MAX_SSID_LEN		32
   
   
   struct atuwi_softc {
   	struct arpcom		arpcom;
   	usbd_device_handle	atuwi_udev;
   	usbd_interface_handle	atuwi_iface;
   	int			atuwi_ed[ATUWI_ENDPT_MAX];
   	usbd_pipe_handle	atuwi_ep[ATUWI_ENDPT_MAX];
   	int			atuwi_unit;
   	int			atuwi_if_flags;
   	struct atuwi_cdata	atuwi_cdata;
   	struct mtx		atuwi_mtx;
   	char			atuwi_dying;
   	struct timeval		atuwi_rx_notice;
   	
   	u_int8_t		atuwi_mac_addr[ETHER_ADDR_LEN];
   	u_int8_t		atuwi_bssid[ETHER_ADDR_LEN];
   	enum atuwi_radio_type	atuwi_radio;
   	
   	u_int8_t		atuwi_ssid[MAX_SSID_LEN];
   	u_int8_t		atuwi_ssidlen;
   	u_int8_t		atuwi_channel;
   	u_int8_t		atuwi_mode;
   	u_int8_t		atuwi_radio_on;
   };
   
   
   
   
   
   
   /* Commands for uploading the firmware (standard DFU interface) */
   #define DFU_DNLOAD		UT_WRITE_CLASS_INTERFACE, 0x01
   #define DFU_GETSTATUS		UT_READ_CLASS_INTERFACE, 0x03
   #define DFU_GETSTATE		UT_READ_CLASS_INTERFACE, 0x05
   #define DFU_REMAP		UT_WRITE_VENDOR_INTERFACE, 0x0a
   
   
   /* DFU states */
   #define DFUState_AppIdle	0
   #define DFUState_AppDetach	1
   #define DFUState_DFUIdle	2
   #define DFUState_DnLoadSync	3
   #define DFUState_DnLoadBusy	4
   #define DFUState_DnLoadIdle	5
   #define DFUState_ManifestSync	6
   #define DFUState_Manifest	7
   #define DFUState_ManifestWait	8
   #define DFUState_UploadIdle	9
   #define DFUState_DFUError	10
   
   #define DFU_MaxBlockSize	1024
   
   
   /* AT76c503 operating modes */
   #define MODE_NONE		0x00
   #define MODE_NETCARD		0x01
   #define MODE_CONFIG		0x02
   #define MODE_DFU		0x03
   #define MODE_NOFLASHNETCARD	0x04
   
   
   
   
   /* AT76c503 commands */
   #define CMD_SET_MIB			0x01
   #define CMD_START_IBSS			0x05
   #define CMD_RADIO			0x06
   #define CMD_RADIO_ON			0x06
   #define CMD_RADIO_OFF			0x07
   #define CMD_STARTUP			0x0b
   
   /* AT76c503 status messages */
   /* used in atuwi_wait_completion */
   #define STATUS_IDLE			0x00
   #define STATUS_COMPLETE			0x01
   #define STATUS_UNKNOWN			0x02
   #define STATUS_INVALID_PARAMETER	0x03
   #define STATUS_FUNCTION_NOT_SUPPORTED	0x04
   #define STATUS_TIME_OUT			0x07
   #define STATUS_IN_PROGRESS		0x08
   #define STATUS_HOST_FAILURE		0xff
   #define STATUS_SCAN_FAILED		0xf0
   
   
   
   /* AT76c503 command header */
   struct atuwi_cmd {
   	u_int8_t		Cmd;
   	u_int8_t		Reserved;
   	u_int16_t		Size;
   };
   
   /* CMD_STARTUP command */
   struct atuwi_cmd_card_config {
   	u_int8_t		Cmd;
   	u_int8_t		Reserved;
   	u_int16_t		Size;
   		
   	u_int8_t		ExcludeUnencrypted;
   	u_int8_t		PromiscuousMode;
   	u_int8_t		ShortRetryLimit;
   	u_int8_t		EncryptionType;
   	u_int16_t		RTS_Threshold;
   	u_int16_t		FragThreshold;		/* 256 .. 2346 */
   	u_int8_t		BasicRateSet[4];
   	u_int8_t		AutoRateFallback;
   	u_int8_t		Channel;
   	u_int8_t		PrivacyInvoked;		/* wep */
   	u_int8_t		WEP_DefaultKeyID;	/* 0 .. 3 */
   	u_int8_t		SSID[MAX_SSID_LEN];
   	u_int8_t		WEP_DefaultKey[4][13];
   	u_int8_t		SSID_Len;
   	u_int8_t		ShortPreamble;
   	u_int16_t		BeaconPeriod;
   };
   
   
   /*
    * The At76c503 adapters come with different types of radios on them.
    * At this moment the driver supports adapters with RFMD and Intersil
    * radios.
    */
   
   /* The config structure of an RFMD radio */
   struct atuwi_rfmd_conf {
   	u_int8_t		CR20[14];
   	u_int8_t		CR21[14];
   	u_int8_t		BB_CR[14];
   	u_int8_t		PidVid[4];
   	u_int8_t		MACAddr[6];
   	u_int8_t		RegulatoryDomain;
   	u_int8_t		LowPowerValues[14];
   	u_int8_t		NormalPowerValues[14];
   	u_int8_t		Reserved[3];
   };
   
   /* The config structure of an Intersil radio */
   struct atuwi_intersil_conf {
   	u_int8_t		MACAddr[6];
   	u_int8_t		CR31[14];
   	u_int8_t		CR58[14];
   	u_int8_t		PidVid[4];
   	u_int8_t		RegulatoryDomain;
   	u_int8_t		Reserved[1];
   };
   
   
   /* Firmware information request */
   struct atuwi_fw {
   	u_int8_t		major;
   	u_int8_t		minor;
   	u_int8_t		patch;
   	u_int8_t		build;
   };
           
   
   /* The header the AT76c503 puts in front of RX packets (for both managment & data) */
   struct at76c503_rx_buffer { 
   	u_int16_t		wlength;
   	u_int8_t		rx_rate;
   	u_int8_t		newbss; 
   	u_int8_t		fragmentation;
   	u_int8_t		rssi;
   	u_int8_t		link_quality;
   	u_int8_t		noise_level; 
   	u_int8_t		rx_time[4];  
   };
   
   /* The total packet the AT76c503 spits out looks like this */
   struct atuwi_rxpkt {
   	struct at76c503_rx_buffer	AtHeader;
   	struct wi_80211_hdr		WiHeader;
   	u_int16_t			EthType;
   	/* TODO - change this to a more correct value */
   	u_int8_t			Packet[2000];
   };
   
   /* The header we have to put in front of a TX packet before sending it to the AT76c503 */
   struct at76c503_tx_buffer {
   	u_int16_t			wlength;
   	u_int8_t			tx_rate;
   	u_int8_t			padding;
   	u_int8_t			reserved[4];
   };
   
   /* The total packet we send to the AT76c503 looks like this */
   struct atuwi_txpkt {
   	struct at76c503_tx_buffer	AtHeader;
   	struct wi_80211_hdr		WiHeader;
   	/* TODO - change this to a more correct value */
   	u_int8_t			Packet[2000];
   };
   
   
   
   struct wi_80211_beacon {
   	u_int8_t		timestamp[8];
   	u_int16_t		interval;
   	u_int16_t		flags;
   	u_int8_t		data[1500];
   };
   
   struct tlv {
   	u_int8_t		type;
   	u_int8_t		length;
   	u_int8_t		value[255];
   };
   
   #define TYPE_MASK		0x000c
   
   
   
   
   
   
   #if 0
   #define	ATUWI_LOCK(_sc)		mtx_lock(&(_sc)->atuwi_mtx)
   #define	ATUWI_UNLOCK(_sc)	mtx_unlock(&(_sc)->atuwi_mtx)
   #else
   #define	ATUWI_LOCK(_sc)
   #define	ATUWI_UNLOCK(_sc)
   #endif
   
   
   
   
   

syntax highlighted by Code2HTML, v. 0.9.1


Email me with questions/comments : Daan <Daan @ pa4dan . nl>