?? am930llc.c
字號(hào):
/* am930llc.c: Handles the Linux network interface* --------------------------------------------------------------------** Linux WLAN ** The contents of this file are subject to the Mozilla Public* License Version 1.0 (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 specific language governing* rights and limitations under the License.** The initial developer of the original code is Mark S. Mathews* <mark@absoval.com>. Portions created by Mark S. Mathews* are Copyright (C) 1998 AbsoluteValue Software, Inc. All Rights Reserved.* * --------------------------------------------------------------------** The author may be reached as mark@absoval.com, or C/O AbsoluteValue* Software Inc., P.O. Box 941149, Maitland, FL, 32794-1149** Thanks to David Hinds, Donald Becker, and the rest of the Linux* developers worldwide for making all of this possible.** --------------------------------------------------------------------** Seperate file isolating the functions that handle the Linux network* interface. LLC may not be the appropriate name, but this code _does_* sit on top of the MAC...**//* The following prevents "kernel_version" from being set in this file. */#define __NO_VERSION__/* PCMCIA headers generated during PCMCIA package installation */#include <pcmcia/config.h>#include <pcmcia/k_compat.h>/* Module related headers, non-module drivers should not include */#include <linux/version.h>/* Standard driver includes */#include <assert.h>#include <linux/delay.h>#include <linux/kernel.h>#include <linux/types.h>#include <linux/fcntl.h>#include <linux/interrupt.h>#include <linux/ptrace.h>#include <linux/ioport.h>#include <linux/in.h>#include <linux/malloc.h>#include <linux/string.h>#include <linux/timer.h>#include <asm/system.h>#include <asm/bitops.h>#include <asm/io.h>#include <linux/errno.h>/* Ethernet and network includes */#include <linux/if_ether.h>#include <linux/netdevice.h>#include <linux/etherdevice.h>#include <linux/skbuff.h>#include <linux/if_arp.h>#include <linux/ioport.h>/* Card and Driver services includes */#include <pcmcia/version.h>#include <pcmcia/cs_types.h>#include <pcmcia/cs.h>#include <pcmcia/cistpl.h>#include <pcmcia/ds.h>#include <pcmcia/cisreg.h>/* Local Includes */#include <wlan/version.h>#include <wlan/am930const.h>#include <wlan/am930mib.h>#include <wlan/p80211.h>#include <wlan/wlan_ioctl.h>#include "am930debug.h"#include "am930mac.h"#include "am930hw.h"#include "am930mgr.h"#include "am930llc.h"/*================================================================*//* Local Macros */#define FILEBIT DBLLC/*================================================================*//* Local Types */typedef struct enet_statistics enet_stats_t;typedef struct devpriv{ enet_stats_t stats; am930llc_t* llc;} devpriv_t;typedef int (*do_ioctl_t)(struct device *dev, struct ifreq *ifr, int cmd);/*================================================================*//* Local Functions */static int am930llc_devinit(device_t *dev);static int am930llc_devopen(device_t *dev);static int am930llc_devstop(device_t *dev);static int am930llc_devhard_start_xmit( struct sk_buff *skb, device_t *dev);static enet_stats_t* am930llc_devgetstats(device_t *dev);static void am930llc_devset_multicast_list(device_t *dev);int am930llc_devdo_ioctl(device_t *dev, wlan_req_t *req, int cmd);void am930llc_dbprt_frame( UINT8* frm, UINT32 len, int isrx );/*================================================================*//* Static variables *//*================================================================*//*----------------------------------------------------------------* am930llc_construct** returns: addr. of the lnd object if successful, NULL otherwise----------------------------------------------------------------*/am930llc_t *am930llc_construct(am930mac_t *mac, am930mgr_t *mgr){ am930llc_t *llc; DBFENTER; llc = kmalloc( sizeof(am930llc_t), GFP_KERNEL); if ( llc != NULL ) { llc->mac = mac; llc->mgr = mgr; /* lets begin the initialization of the linux device */ llc->dev = kmalloc( sizeof(device_t), GFP_KERNEL); memset( llc->dev, 0, sizeof(device_t)); llc->dev->priv = kmalloc( sizeof(devpriv_t), GFP_KERNEL); memset( llc->dev->priv, 0, sizeof(devpriv_t)); /* the dev name field will point to the same memory used by the node_t field of the pcmcia di object */ llc->dev->name = llc->mac->di->dev->dev_name; /* set the private data to point back at the llc */ V2P(llc->dev->priv)->llc = llc; /* set the hardware address */ am930mgr_mibgetitem( llc->mgr, ADDR_MAC_ADDR, llc->dev->dev_addr, 6); /* set the method pointers */ llc->dev->init = am930llc_devinit; llc->dev->open = am930llc_devopen; llc->dev->stop = am930llc_devstop; llc->dev->hard_start_xmit = am930llc_devhard_start_xmit; llc->dev->get_stats = am930llc_devgetstats; llc->dev->set_multicast_list = am930llc_devset_multicast_list; llc->dev->do_ioctl = (do_ioctl_t)am930llc_devdo_ioctl; ether_setup( llc->dev ); if ( register_netdev(llc->dev) != 0 ) { DBPRT( DBINIT, "register_netdev failed!\n"); kfree( llc->dev ); llc->dev = NULL; am930llc_destruct( llc ); llc = NULL; } DBPRT( DBINIT, "Device %s registered\n", llc->dev->name); } DBFEXIT return llc;} /*----------------------------------------------------------------* am930llc_destruct** returns: nothing----------------------------------------------------------------*/void am930llc_destruct( am930llc_t *llc){ DBFENTER; if ( llc->dev != NULL ) { llc->dev->start = 0; unregister_netdev( llc->dev ); kfree(llc->dev); llc->dev = NULL; } kfree_s( llc, sizeof(am930llc_t)); DBFEXIT; return;}/*----------------------------------------------------------------* am930llc_devinit* init method for the linux net device. Called by * register_netdevice. For this driver, it doesn't have to do* anything.** returns: zero----------------------------------------------------------------*/int am930llc_devinit(device_t *dev){ int result = 0; DBFENTER; DBFEXIT; return result;}/*----------------------------------------------------------------* am930llc_devopen* open method for the linux net device. Called when ifconfig* is used to set up the interface.** returns: zero----------------------------------------------------------------*/int am930llc_devopen(device_t *dev){ int result = 0; DBFENTER; /* set the flags in the device object */ dev->tbusy = 0; dev->interrupt = 0; dev->start = 1; MOD_INC_USE_COUNT; DBFEXIT; return result;}/*----------------------------------------------------------------* am930llc_devstop* stop method for the linux net device. Called when ifconfig* is used to shut down an interface.** returns: zero----------------------------------------------------------------*/int am930llc_devstop(device_t *dev){ int result = 0; DBFENTER; /* set the flags in the device object */ dev->start = 0; dev->tbusy = 1; MOD_DEC_USE_COUNT; DBFEXIT; return result;}/*----------------------------------------------------------------* am930llc_devhard_start_xmit* hard_start_xmint method for the linux net device. Called by * the higher level protocol code when it has a packet to xmit.** returns: zero----------------------------------------------------------------*/int am930llc_devhard_start_xmit( struct sk_buff *skb, device_t *dev){ int result = 0; DBFENTER; if ( dev->start == 1 ) { /* If some higher layer thinks we've missed a tx-done, we are passed NULL. Caution: dev_tint handles the cli/sti .. */#if (LINUX_VERSION_CODE < VERSION(2,1,25)) if ( skb == NULL ) { dev->tbusy = 0; dev_tint(dev); return 0; }#endif if ( dev->tbusy ) /* shouldn't ever happen */ { /* printk(KERN_DEBUG"xmit called when tbusy set!\n"); */ /* need to add a reset capability here. see skeleton.c */ result = -EBUSY; } else {#ifdef DEBUG_TXHDR_ETHam930llc_dbprt_frame( skb->data, skb->len, 0 );#endif dev->trans_start = jiffies; result = am930mac_txdata( V2P(dev->priv)->llc->mac, skb->data, skb->data + 6, skb->data, skb->len); if ( result ) { dev->tbusy = 1; } } if ( !result )#if (LINUX_VERSION_CODE < VERSION(2,2,0)) dev_kfree_skb( skb, FREE_WRITE);#else dev_kfree_skb( skb );#endif } DBFEXIT; return result;}/*----------------------------------------------------------------* am930llc_rxframe* Event method called from mac when a frame has been received.** returns: zero----------------------------------------------------------------*/
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -