Initial changes to support the 2.3.x/2.4.x kernel.

This commit is contained in:
mark 2000-06-14 15:04:53 +00:00
parent 57022341f7
commit 32d0452194
13 changed files with 139 additions and 78 deletions

View File

@ -141,7 +141,7 @@ typedef struct wlandevice
UINT32 request_pending; /* flag, access atomically */
p80211msg_t *curr_msg;
struct timer_list reqtimer;
struct wait_queue *reqwq;
wait_queue_head_t reqwq;
/* Indication i/f state */
/* netlink socket */

View File

@ -66,7 +66,7 @@ $(OBJ_DIR)/%.o : %.c
# Compiler Options
ifndef CFLAGS
CFLAGS = -g -O2 -Wall -Wstrict-prototypes -Winline -pipe
CFLAGS = -g -O2 -Wall -Wstrict-prototypes -pipe
endif
# Preprocessor Options (we have some arch/distro dependencies)

View File

@ -55,7 +55,7 @@ OBJDUMP =$(CROSS_OBJDUMP)
MAKE =make
ifndef CFLAGS
CFLAGS = -O2 -Wall -Wstrict-prototypes -Winline -pipe
CFLAGS = -O2 -Wall -Wstrict-prototypes -pipe
endif
# Preprocessor Options (we have some arch/distro dependencies)

View File

@ -90,7 +90,7 @@ $(OBJ_DIR)/%.o : %.c
# Compiler Options
ifndef CFLAGS
CFLAGS = -O2 -Wall -Wstrict-prototypes -Winline -fomit-frame-pointer -pipe
CFLAGS = -O2 -Wall -Wstrict-prototypes -fomit-frame-pointer -pipe
endif
# Preprocessor Options

View File

@ -218,10 +218,14 @@ int p80211knetdev_open( netdevice_t *netdev )
if ( wlandev->open != NULL) {
result = (*(wlandev->open))(wlandev);
if ( result == 0 ) {
#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,3,43) )
/* set the device flags */
netdev->tbusy = 0;
netdev->interrupt = 0;
netdev->start = 1;
#else
netif_start_queue(netdev);
#endif
}
} else {
result = -EAGAIN;
@ -255,10 +259,14 @@ int p80211knetdev_stop( netdevice_t *netdev )
result = (*(wlandev->close))(wlandev);
}
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,38) )
/* To make sure noone tries to send us something, just force */
/* tbusy to true */
netdev->tbusy = 1;
netdev->start = 0;
#else
netif_stop_queue(netdev);
#endif
DBFEXIT;
return result;
@ -287,10 +295,15 @@ void p80211netdev_rx(wlandevice_t *wlandev, wlan_pb_t *pb)
DBFENTER;
dev->interrupt = 1;
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,38) )
if (dev->start) {
#else
if (dev->flags & IFF_UP ) {
#endif
if ( pb->p80211_payloadlen == 0 ) {
/* Do nothing, converting and passing up zero len frame is pointless */
/* Do nothing, converting and passing up zero
length frame is pointless
*/
} else if ( p80211pb_p80211_to_ether(wlandev, wlandev->ethconv, pb) == 0 ) {
/* Mark last reception */
dev->last_rx = jiffies;
@ -307,8 +320,6 @@ void p80211netdev_rx(wlandevice_t *wlandev, wlan_pb_t *pb)
}
}
dev->interrupt = 0;
p80211pb_free(pb);
DBFEXIT;
@ -343,79 +354,105 @@ int p80211knetdev_hard_start_xmit( struct sk_buff *skb, netdevice_t *netdev)
DBFENTER;
if ( netdev->start == 0 ) {
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,38) )
if (netdev->start == 0) {
#else
if ((netdev->flags & IFF_UP) == 0 ) {
#endif
return 1;
}
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,38) )
if ( test_and_set_bit(0, (void*)&(netdev->tbusy)) != 0 ) {
/* We've been called w/ tbusy set, has the tx */
/* path stalled? */
WLAN_LOG_DEBUG0(1, "called when tbusy set\n");
return 1;
}
#else
netif_stop_queue(netdev);
/* No timeout handling here, 2.3.38+ kernels call the
timeout function directly.
*/
#endif
/* particularly handy in the above case */
netdev->trans_start = jiffies;
/* OK, now we setup the ether to 802.11 conversion */
pb = p80211pb_alloc();
if ( pb == NULL ) {
return 1;
}
pb->ethhostbuf = skb;
pb->ethfree = p80211pb_freeskb;
pb->ethbuf = skb->data;
pb->ethbuflen = skb->len > 1514 ? 1514 : skb->len;
pb->ethfrmlen = pb->ethbuflen;
pb->eth_hdr = (wlan_ethhdr_t*)pb->ethbuf;
if ( p80211pb_ether_to_p80211(wlandev, wlandev->ethconv, pb) != 0 ) {
/* convert failed */
WLAN_LOG_DEBUG1(1,
"ether_to_80211(%d) failed.\n",
wlandev->ethconv);
/* Free the pb, but not the skb */
pb->ethhostbuf = NULL;
p80211pb_free(pb);
result = 1;
} else {
/* particularly handy in the above case */
netdev->trans_start = jiffies;
/* OK, now we setup the ether to 802.11 conversion */
pb = p80211pb_alloc();
if ( pb == NULL ) {
if ( wlandev->txframe == NULL ) {
return 1;
}
wlandev->linux_stats.tx_packets++;
pb->ethhostbuf = skb;
pb->ethfree = p80211pb_freeskb;
pb->ethbuf = skb->data;
pb->ethbuflen = skb->len > 1514 ? 1514 : skb->len;
pb->ethfrmlen = pb->ethbuflen;
pb->eth_hdr = (wlan_ethhdr_t*)pb->ethbuf;
txresult = (*(wlandev->txframe))(wlandev, pb);
if ( p80211pb_ether_to_p80211(wlandev, wlandev->ethconv, pb) != 0 ) {
/* convert failed */
WLAN_LOG_DEBUG1(1,
"ether_to_80211(%d) failed.\n",
wlandev->ethconv);
if ( txresult == 0) {
/* success and more buf */
/* avail, re: hw_txdata */
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,38) )
netdev->tbusy = 0;
#else
netif_wake_queue(netdev);
#endif
result = 0;
} else if ( txresult == 1 ) {
/* success, no more avail */
WLAN_LOG_DEBUG0(3, "txframe success, no more bufs\n");
/* netdev->tbusy = 1; don't set here, irqhdlr */
/* may have already cleared it */
result = 0;
} else if ( txresult == 2 ) {
/* alloc failure, drop frame */
WLAN_LOG_DEBUG0(3, "txframe returned alloc_fail\n");
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,38) )
netdev->tbusy = 0;
#else
netif_wake_queue(netdev);
#endif
/* Free the pb, but not the skb */
pb->ethhostbuf = NULL;
p80211pb_free(pb);
result = 1;
} else {
/* buffer full or queue busy */
WLAN_LOG_DEBUG0(3, "txframe returned full or busy\n");
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,38) )
netdev->tbusy = 0;
#else
netif_wake_queue(netdev);
#endif
/* Free the pb, but not the skb */
pb->ethhostbuf = NULL;
p80211pb_free(pb);
result = 1;
} else {
if ( wlandev->txframe == NULL ) {
return 1;
}
wlandev->linux_stats.tx_packets++;
txresult = (*(wlandev->txframe))(wlandev, pb);
if ( txresult == 0) {
/* success and more buf */
/* avail, re: hw_txdata */
netdev->tbusy = 0;
result = 0;
} else if ( txresult == 1 ) {
/* success, no more avail */
WLAN_LOG_DEBUG0(3, "txframe success, no more bufs\n");
/* netdev->tbusy = 1; don't set here, irqhdlr */
/* may have already cleared it */
result = 0;
} else if ( txresult == 2 ) {
/* alloc failure, drop frame */
WLAN_LOG_DEBUG0(3, "txframe returned alloc_fail\n");
netdev->tbusy = 0;
/* Free the pb, but not the skb */
pb->ethhostbuf = NULL;
p80211pb_free(pb);
result = 1;
} else {
/* buffer full or queue busy */
WLAN_LOG_DEBUG0(3, "txframe returned full or busy\n");
netdev->tbusy = 0;
/* Free the pb, but not the skb */
pb->ethhostbuf = NULL;
p80211pb_free(pb);
result = 1;
}
}
}
DBFEXIT;
return result;
}
@ -555,6 +592,8 @@ int wlan_setup(wlandevice_t *wlandev)
wlandev->ethconv = WLAN_ETHCONV_RFC1042;
wlandev->macmode = WLAN_MACMODE_NONE;
init_waitqueue_head(&wlandev->reqwq);
/* Allocate and initialize the struct device */
dev = kmalloc(sizeof(netdevice_t), GFP_ATOMIC);
if ( dev == NULL ) {
@ -572,9 +611,12 @@ int wlan_setup(wlandevice_t *wlandev)
dev->open = &p80211knetdev_open;
dev->stop = &p80211knetdev_stop;
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,38) )
dev->tbusy = 1;
#endif
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,99) )
dev->name = wlandev->name;
#endif
ether_setup(dev);
}
}
@ -656,6 +698,10 @@ int register_wlandev(wlandevice_t *wlandev)
i = wlandev_get_index(wlandev);
}
#if ( LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,99) )
strcpy(dev->name, wlandev->name);
#endif
if (register_netdevice(dev)) {
if ( i >= 0 ) {
wlandev_clear_index(wlandev);

View File

@ -166,9 +166,6 @@ int p80211req_dorequest( wlandevice_t *wlandev, UINT8 *msgbuf)
/* cmdtimerfunc (timeout), or p80211req_confirm */
interruptible_sleep_on(&(wlandev->reqwq));
/* after return, clear the wq as a flag we're not asleep */
wlandev->reqwq = NULL;
/* If sleep return is via signal */
if ( signal_pending(current) ) {
WLAN_LOG_DEBUG0(2,"req unblocked via signal\n");
@ -179,7 +176,8 @@ int p80211req_dorequest( wlandevice_t *wlandev, UINT8 *msgbuf)
/* If timeout */
if ( wlandev->reqtimer.expires == 0 )
{
WLAN_LOG_DEBUG0(2,"req unblocked via timeout\n");
WLAN_LOG_DEBUG0(2,
"req unblocked via timeout\n");
/* stop request, clean up request */
result = -ETIME;
} else {
@ -190,7 +188,7 @@ int p80211req_dorequest( wlandevice_t *wlandev, UINT8 *msgbuf)
}
}
} else {
result = -retval; /* retval should be a positive errno */
result = -retval; /* retval shld be a positive errno */
}
}
@ -218,7 +216,7 @@ int p80211req_dorequest( wlandevice_t *wlandev, UINT8 *msgbuf)
void p80211req_timerfunc(wlandevice_t *wlandev)
{
wlandev->reqtimer.expires = 0;
if (wlandev->reqwq != NULL) {
if (wlandev->request_pending != 0) {
wake_up_interruptible(&(wlandev->reqwq));
}
}
@ -267,7 +265,7 @@ void p80211req_confirm(wlandevice_t *wlandev)
{
DBFENTER;
if ( wlandev->reqwq != NULL ){
if ( wlandev->request_pending != 0 ){
wake_up_interruptible(&(wlandev->reqwq));
}

View File

@ -55,7 +55,7 @@ OBJDUMP =$(CROSS_OBJDUMP)
MAKE =make
ifndef CFLAGS
CFLAGS = -g -O2 -Wall -Wstrict-prototypes -Winline -pipe
CFLAGS = -g -O2 -Wall -Wstrict-prototypes -pipe
endif
# Preprocessor Options (we have some arch/distro dependencies)

View File

@ -103,7 +103,7 @@ $(AP_CS_OBJ_DIR)/%.o : %.c
# Compiler Options
ifndef CFLAGS
CFLAGS = -O2 -Wall -Wstrict-prototypes -Winline -fomit-frame-pointer -pipe
CFLAGS = -O2 -Wall -Wstrict-prototypes -fomit-frame-pointer -pipe
endif
# Preprocessor Options

View File

@ -367,10 +367,10 @@ int prism2sta_close(wlandevice_t *wlandev)
/* We don't currently have to do anything else. */
/* Higher layers know we're not ready from dev->start==0 and */
/* dev->tbusy==1. Our rx path knows to pass up received */
/* dev->tbusy==1. Our rx path knows to not pass up received */
/* frames because of dev->flags&IFF_UP is false. */
/* We leave the port enabled in case someone needs to receive */
/* Info frames or send Notify frames. All rx frames after this */
/* Info frames or send Notify frames. All rx data frames after this */
/* will be dropped. */
DBFEXIT;
@ -2004,8 +2004,13 @@ void prism2sta_int_alloc(wlandevice_t *wlandev)
/* collect the FID and push it onto the stack */
txfid_push(priv, wlan_inw_le16_to_cpu(HFA384x_ALLOCFID(hw->iobase)));
/* clear tbusy (if set) */
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,38) )
wlandev->netdev->tbusy = 0;
mark_bh(NET_BH);
#else
netif_wake_queue(wlandev->netdev);
#endif
DBFEXIT;
return;
@ -2552,8 +2557,12 @@ static int prism2sta_event (event_t event, int priority, event_callback_args_t *
link->state &= ~DEV_PRESENT;
if (link->state & DEV_CONFIG)
{
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,38) )
wlandev->netdev->tbusy = 1;
wlandev->netdev->start = 0;
#else
netif_stop_queue(wlandev->netdev);
#endif
link->release.expires = RUN_AT(HZ/20);
add_timer(&link->release);
}
@ -2579,8 +2588,12 @@ static int prism2sta_event (event_t event, int priority, event_callback_args_t *
link->state |= DEV_SUSPEND;
if (link->state & DEV_CONFIG)
{
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,38) )
wlandev->netdev->tbusy = 1;
wlandev->netdev->start = 0;
#else
netif_stop_queue(wlandev->netdev);
#endif
CardServices(ReleaseConfiguration, link->handle);
}
break;
@ -2598,8 +2611,12 @@ static int prism2sta_event (event_t event, int priority, event_callback_args_t *
WLAN_LOG_ERROR0("MAC Initialization failed.\n");
result = 1;
} else {
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,38) )
wlandev->netdev->tbusy = 0;
wlandev->netdev->start = 1;
#else
netif_start_queue(wlandev->netdev);
#endif
}
}
break;

View File

@ -66,7 +66,7 @@ $(OBJ_DIR)/%.o : %.c
# Compiler Options
ifndef CFLAGS
CFLAGS = -g -O2 -Wall -Wstrict-prototypes -Winline -pipe
CFLAGS = -g -O2 -Wall -Wstrict-prototypes -pipe
endif
# Preprocessor Options

View File

@ -82,7 +82,7 @@ $(OBJ_DIR)/%.o : %.c
# Compiler Options
ifndef CFLAGS
CFLAGS = -O2 -Wall -Wstrict-prototypes -Winline -fomit-frame-pointer -pipe
CFLAGS = -O2 -Wall -Wstrict-prototypes -fomit-frame-pointer -pipe
endif
# Preprocessor Options

View File

@ -58,7 +58,7 @@ OBJDUMP =$(CROSS_OBJDUMP)
MAKE =make
ifndef CFLAGS
CFLAGS = -O2 -Wall -Wstrict-prototypes -Winline -pipe
CFLAGS = -O2 -Wall -Wstrict-prototypes -pipe
endif
# Preprocessor Options (we have some arch/distro dependencies)

View File

@ -58,7 +58,7 @@ OBJDUMP =$(CROSS_OBJDUMP)
MAKE =make
ifndef CFLAGS
CFLAGS = -O2 -Wall -Wstrict-prototypes -Winline -pipe
CFLAGS = -O2 -Wall -Wstrict-prototypes -pipe
endif
# Preprocessor Options (we have some arch/distro dependencies)