📄 cb20_cb.h
字号:
/* The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specificlanguage governing rights and limitations under the License. The Original Code is a driver for Aironet CB20A card. The Initial Developer of the Original Code is Benjamin Reed <breed@almaden.ibm.com>. Portions created by Benjamin Reed are Copyright (C) 1999 Benjamin Reed. All Rights Reserved. Contributor(s): Cisco Systems, Inc. Portions created by Cisco Systems, Inc. are Copyright (C) 2003, 2004 Cisco Systems, Inc. All Rights Reserved. */#ifndef __KERNEL__#define __KERNEL__#endif/* #define DEBUG_MIC 1 */#define V_CNFCTRL 0x7c /* Reset config control port */#define BB_HANDSHAKE_0 0xa505 /* bootblock sanity check constants */#define BB_HANDSHAKE_1 0xbb10#define CB_INTENABLE 0x84 /* write */#define CB_PENDING 0x88 /* read */#define CB_CLEARINT 0x80 /* write */#define CB_FLAGBIT 0x8000 /* Magic bit for cardbus int control */#define READLINE_DEL 0x10 /* Read cache line hack */#define AIRONET 0x14b9#define MAXTXQ 32#define TXTIME 4 #define TXSTALL 200 /* Tx timeout */#define PRODNAME "cb20"#define KOALA_TYPE 7 /* Card this driver is for */#define VERSION_CODE(vers,rel,seq) ( ((vers)<<16) | ((rel)<<8) | (seq) )/* * Events */#define EV_CMD 0x10#define EV_CLEARCOMMANDBUSY 0x4000#define EV_RX 0x01#define EV_TX 0x02#define EV_TXEXC 0x04#define EV_ALLOC 0x08#define EV_XMIT 0x08#define EV_LINK 0x80#define EV_AWAKE 0x100#define EV_TXCPY 0x400#define EV_TXQCMPL 0x800#define EV_SLEEPING 0x2000#define EV_MIC 0x1000#define STATUS_INTS (EV_TXCPY|EV_CMD|EV_LINK|EV_TX|EV_RX|EV_MIC )/* * I have been told that cb20 io ports are 32 bit aligned * addresses */#define V_COMMAND 00#define V_PARAM0 4#define V_PARAM1 8#define V_PARAM2 12#define V_STATUS 16#define V_RESP0 20#define V_RESP1 24#define V_RESP2 28#define V_LINKSTAT 32#define V_SELECT0 36#define V_OFFSET0 40#define V_RXFID 44#define V_TXALLOCFID 48#define V_SWS0 80#define V_SWS1 84#define V_SWS2 88#define V_SWS3 92#define V_EVSTAT 96#define V_EVINTEN 100#define V_EVACK 104#define ETHERNET_ADDRESS_LENGTH 6#define ETHERNET_HEADER_SIZE 14 // Size of the ethernet header#define MAXIMUM_ETHERNET_PACKET_SIZE 1514#define MIC_PACKET_LENGTH 18 // Size increase of ethernet packet to do Mic#define MAXIMUM_RX_PACKET_SIZE MAXIMUM_ETHERNET_PACKET_SIZE + MIC_PACKET_LENGTH#define MAXIMUM_TX_PACKET_SIZE MAXIMUM_ETHERNET_PACKET_SIZE + MIC_PACKET_LENGTH#define MIC_MSGLEN_MAX 2000#define EMMH32_MSGLEN_MAX MIC_MSGLEN_MAX#define CFG_OPMODE_MIC 0x8000#define EXT_SOFT_CAPS_MIC 0x0001#define FW_LOAD_OFFSET 0x20000 /* Where firmware image needs to go */#define MAXTXDTRY 1000typedef struct FIRMWARE_HEADER { unsigned char text[128]; unsigned char file_format; unsigned char device_type; unsigned char bootdload_vers[2]; unsigned char oper_vers[2]; unsigned short bootdload_size; unsigned short oper_size; unsigned short img_chksum; unsigned char _filler[114]; unsigned short hdr_chksum;} FIRMWARE_IMAGE_FILE_HEADER __attribute__ ((packed)) ;typedef struct { unsigned long coeff[((EMMH32_MSGLEN_MAX)+3)>>2]; unsigned long long accum; /* accumulated mic, reduced to u32 in final() */ int position; /* current position (byte offset) in message */ union { unsigned char d8[4]; unsigned long d32; } part; /* saves partial message word across update() calls */} emmh32_context;/* * Mic support * */typedef struct _ETH_HEADER_STRUC { u8 Destination[ETHERNET_ADDRESS_LENGTH]__attribute__ ((packed)); u8 Source[ETHERNET_ADDRESS_LENGTH] __attribute__ ((packed)); u16 TypeLength __attribute__ ((packed));} ETH_HEADER_STRUC __attribute__ ((packed)) ;#define UNALIGN32 0#define MIC_ACCUM(v) \ context->accum += (u64)val * context->coeff[coeff_position++];#define SWAPU32(d) ( ((d)<<24) | ( ((d)&0xFF00)<<8) | (((d)>>8)&0xFF00) | ((d)>>24) )#define ISBIGENDIAN ( (*(u8*)(&endian_ref)) == 0x12 )#define BIGEND32(d) ( ISBIGENDIAN ? (d) : SWAPU32(d))#ifndef UNALIGN32#error UNALIGN32 must be defined.#elif UNALIGN32/* unaligned accesses are allowed -- fetch u32 and swap endian */#define GETBIG32(p) BIGEND32(*(u32*)(p))#else/* unaligned accesses are disallowed ... slow GET32() */#define GB(p,i,s) ( ((u32) *((u8*)(p)+i) ) << (s) )#define GETBIG32(p) GB(p,0,24)|GB(p,1,16)|GB(p,2,8)|GB(p,3,0)#endiftypedef struct _MIC_BUFFER_STRUCT { u8 DA[ETHERNET_ADDRESS_LENGTH]; u8 SA[ETHERNET_ADDRESS_LENGTH]; u16 TypeLength __attribute__ ((packed)); union { u8 snap[8]; struct { u8 dsap; u8 ssap; u8 control; u8 orgCode[3]; u8 fieldType[2]; } llc; }u __attribute__ ((packed)); u32 MIC __attribute__ ((packed)); u32 SEQ __attribute__ ((packed)); u8 payload __attribute__ ((packed)); } MIC_BUFFER_STRUCT __attribute__ ((packed));typedef struct _MIC_CNTX { emmh32_context seed __attribute__ ((packed)); //Context - "the seed" u32 rx __attribute__ ((packed)) ; //Received sequence numbers u32 window __attribute__ ((packed)); //start of window u32 tx __attribute__ ((packed)) ; //Tx sequence number u8 multicast __attribute__ ((packed)); // Flag to say if it is mulitcast or not u8 valid __attribute__ ((packed)); // Flag to say if context is valid or not u8 key[16] __attribute__ ((packed)) ; } MICCNTX __attribute__ ((packed));typedef struct _MIC_MODULE { MICCNTX mCtx; //Multicast context MICCNTX uCtx; //Unicast context} MICMODULE __attribute__ ((packed));#define NUM_MODULES 2/* expand the key to fill the MMH coefficient array */void emmh32_setseed(emmh32_context *context, unsigned char *pkey, int keylen);/* prepare for calculation of a new mic */void emmh32_init(emmh32_context *context);/* add some bytes to the mic calculation */void emmh32_update(emmh32_context *context, unsigned char *pOctets, int len);/* calculate the mic */void emmh32_final(emmh32_context *context, unsigned char digest[4]);/* * This vector conains all the cb20 * PCI id's ending with a null for the * last one. Things change so be ready */unsigned cb20_ids [ ] = { 0x5000, /* Rev G radio */ 0x5050, /* Nova */ 0xa504, /* Rev I radio */ 0 /* Who knows */};#define NOVA_SUBDEV 0x5050#define MPI350_SUBDEV 0x5000#define KOALA_SUBDEV 0x6000struct proc_data { int release_buffer; int readlen; char *rbuffer; int writelen; int maxwritelen; char *wbuffer; void (*on_close) (struct inode *, struct file *);};#if (LINUX_VERSION_CODE < 0x20315)#define in_irq in_interrupt#define net_device device#define dev_kfree_skb_irq(a) dev_kfree_skb(a)#ifdef _LINUX_NETDEVICE_H /* only if netdevice.h was included */#define netif_start_queue(dev) clear_bit(0, (void *) &(dev)->tbusy);#define netif_stop_queue(dev) set_bit(0, (void *) &(dev)->tbusy);#define check_mem_region(a,b) 0 #define release_mem_region(a,b) #define request_mem_region(a,b,c) 1#ifndef set_current_state#define set_current_state(a)#endifstatic inline int netif_device_present(struct device *dev){ if(dev == NULL) return 0; else return 1;} static inline void netif_wake_queue(struct device *dev){ clear_bit(0, (void *) &(dev)->tbusy); mark_bh(NET_BH);}/* Pure 2^n version of get_order taken from 2.4 sources */#if LINUX_VERSION_CODE < VERSION_CODE(2,2,19)extern __inline__ int get_order(unsigned long size){ int order; size = (size-1) >> (PAGE_SHIFT-1); order = -1; do { size >>= 1; order++; } while (size); return order;}static inline void netif_device_attach(struct device *dev){ }static inline void netif_device_detach(struct device *dev){ }#endifstatic inline void netif_carrier_on(struct device *dev){ }static inline void netif_carrier_off(struct device *dev){ }#if LINUX_VERSION_CODE < VERSION_CODE(2,2,19) typedef unsigned dma_addr_t;#endif#endif #endif typedef struct { u16 cmd; u16 parm0; u16 parm1; u16 parm2;} Cmd;typedef struct { u16 status; u16 rsp0; u16 rsp1; u16 rsp2;} Resp;/* * Offset into card memory of descriptors. */#define CARD_DISCRAMOFF 0x800 /* * 1 tx 1 rx and a host frame buffer section (1832 ) * for each descriptor + 2k for the rid desc. ~3664 * bytes per MAX_DESC count * SHAREDMEMSIZE = (MAX_DESC * (HOSTBUFSIZ*2) ) + 2048 */#define MAX_DESC 1#define HOSTBUFSIZ 2048#define DISCDLY 20#define VADDR(Type,HOSTP) (Type *)(HOSTP.VirtualHostAddress)#define CDISCP(Type,CARDP) (Type *)(p.CardRamOff)/* * Flag bits for cb20_info->flags */ #define TXBUSY 1#define INSPAC 2#define ASSOC 4#define MIC_CAPABLE 8 /* Can do mic */#define MIC_ENABLED 16 /* Mic turned on */#define ADHOC 32 /* In addhoc */#define FLASHING 64 /* Flashing */ #define REAP 128 /* Unregister netdev at earliest convenience. */#define DEVREGISTERED 256 /* Device registered */#define NOCARD 512#define INT_DISABLE 1024#define FWBAD 2048 /* Something is wrong with the firmware cant start */#define SUCCESS 0#define ERROR -1#define COMMAND_BUSY 0x8000#define SHAREDMEMSIZE (MAX_DESC * (2 * HOSTBUFSIZ ) ) + 2048 /*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -