1 /*******************************************************************************
3 * Wireless device driver for Linux (wlags49).
5 * Copyright (c) 1998-2003 Agere Systems Inc.
9 * Initially developed by TriplePoint, Inc.
10 * http://www.triplepoint.com
12 *------------------------------------------------------------------------------
14 * This file contains handler functions registered with the net_device
17 *------------------------------------------------------------------------------
21 * This software is provided subject to the following terms and conditions,
22 * which you should read carefully before using the software. Using this
23 * software indicates your acceptance of these terms and conditions. If you do
24 * not agree with these terms and conditions, do not use the software.
26 * Copyright © 2003 Agere Systems Inc.
27 * All rights reserved.
29 * Redistribution and use in source or binary forms, with or without
30 * modifications, are permitted provided that the following conditions are met:
32 * . Redistributions of source code must retain the above copyright notice, this
33 * list of conditions and the following Disclaimer as comments in the code as
34 * well as in the documentation and/or other materials provided with the
37 * . Redistributions in binary form must reproduce the above copyright notice,
38 * this list of conditions and the following Disclaimer in the documentation
39 * and/or other materials provided with the distribution.
41 * . Neither the name of Agere Systems Inc. nor the names of the contributors
42 * may be used to endorse or promote products derived from this software
43 * without specific prior written permission.
47 * THIS SOFTWARE IS PROVIDED
\93AS IS
\94 AND ANY EXPRESS OR IMPLIED WARRANTIES,
48 * INCLUDING, BUT NOT LIMITED TO, INFRINGEMENT AND THE IMPLIED WARRANTIES OF
49 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ANY
50 * USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE IS SOLELY AT THE USERS OWN
51 * RISK. IN NO EVENT SHALL AGERE SYSTEMS INC. OR CONTRIBUTORS BE LIABLE FOR ANY
52 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
53 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
54 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
55 * ON ANY THEORY OF LIABILITY, INCLUDING, BUT NOT LIMITED TO, CONTRACT, STRICT
56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
57 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
60 ******************************************************************************/
64 /*******************************************************************************
65 * VERSION CONTROL INFORMATION
66 *******************************************************************************
69 * $Date: 2004/08/03 13:33:44 $
71 * $Source: /usr/local/cvs/wl_lkm/wireless/wl_netdev.c,v $
73 ******************************************************************************/
77 /*******************************************************************************
79 ******************************************************************************/
80 #include <wl_version.h>
82 #include <linux/module.h>
83 #include <linux/types.h>
84 #include <linux/kernel.h>
85 // #include <linux/sched.h>
86 // #include <linux/ptrace.h>
87 // #include <linux/slab.h>
88 // #include <linux/ctype.h>
89 // #include <linux/string.h>
90 //#include <linux/timer.h>
91 // #include <linux/interrupt.h>
92 // #include <linux/in.h>
93 // #include <linux/delay.h>
94 // #include <linux/skbuff.h>
95 // #include <asm/io.h>
96 // #include <asm/system.h>
97 // #include <asm/bitops.h>
99 #include <linux/netdevice.h>
100 #include <linux/ethtool.h>
101 #include <linux/etherdevice.h>
102 // #include <linux/skbuff.h>
103 // #include <linux/if_arp.h>
104 // #include <linux/ioport.h>
110 // #include <hcfdef.h>
113 #include <wl_internal.h>
117 #include <wl_netdev.h>
121 #include <wl_profile.h>
122 #endif /* USE_PROFILE */
126 #endif /* BUS_PCMCIA */
133 /*******************************************************************************
135 ******************************************************************************/
137 extern dbg_info_t *DbgInfo;
142 #define MTU_MAX (HCF_MAX_MSG - ETH_HLEN - 8)
144 #define MTU_MAX (HCF_MAX_MSG - ETH_HLEN)
147 //static int mtu = MTU_MAX;
148 //MODULE_PARM(mtu, "i");
149 //MODULE_PARM_DESC(mtu, "MTU");
151 /*******************************************************************************
153 ******************************************************************************/
154 #define BLOCK_INPUT(buf, len) \
155 desc->buf_addr = buf; \
156 desc->BUF_SIZE = len; \
157 status = hcf_rcv_msg(&(lp->hcfCtx), desc, 0)
159 #define BLOCK_INPUT_DMA(buf, len) memcpy( buf, desc_next->buf_addr, pktlen )
161 /*******************************************************************************
162 * function prototypes
163 ******************************************************************************/
165 /*******************************************************************************
167 *******************************************************************************
171 * We never need to do anything when a "Wireless" device is "initialized"
172 * by the net software, because we only register already-found cards.
176 * dev - a pointer to the device's net_device structure
181 * errno value otherwise
183 ******************************************************************************/
184 int wl_init( struct net_device *dev )
186 // unsigned long flags;
187 // struct wl_private *lp = wl_priv(dev);
188 /*------------------------------------------------------------------------*/
190 DBG_FUNC( "wl_init" );
191 DBG_ENTER( DbgInfo );
193 DBG_PARAM( DbgInfo, "dev", "%s (0x%p)", dev->name, dev );
195 /* Nothing to do, but grab the spinlock anyway just in case we ever need
197 // wl_lock( lp, &flags );
198 // wl_unlock( lp, &flags );
200 DBG_LEAVE( DbgInfo );
203 /*============================================================================*/
205 /*******************************************************************************
207 *******************************************************************************
211 * Implement the SIOCSIFMAP interface.
215 * dev - a pointer to the device's net_device structure
216 * map - a pointer to the device's ifmap structure
223 ******************************************************************************/
224 int wl_config( struct net_device *dev, struct ifmap *map )
226 DBG_FUNC( "wl_config" );
227 DBG_ENTER( DbgInfo );
229 DBG_PARAM( DbgInfo, "dev", "%s (0x%p)", dev->name, dev );
230 DBG_PARAM( DbgInfo, "map", "0x%p", map );
232 /* The only thing we care about here is a port change. Since this not needed,
233 ignore the request. */
234 DBG_TRACE( DbgInfo, "%s: %s called.\n", dev->name, __FUNC__ );
236 DBG_LEAVE( DbgInfo );
239 /*============================================================================*/
241 /*******************************************************************************
243 *******************************************************************************
247 * Return the current device statistics.
251 * dev - a pointer to the device's net_device structure
255 * a pointer to a net_device_stats structure containing the network
258 ******************************************************************************/
259 struct net_device_stats *wl_stats( struct net_device *dev )
265 struct net_device_stats *pStats;
266 struct wl_private *lp = wl_priv(dev);
267 /*------------------------------------------------------------------------*/
269 //DBG_FUNC( "wl_stats" );
270 //DBG_ENTER( DbgInfo );
271 //DBG_PARAM( DbgInfo, "dev", "%s (0x%p)", dev->name, dev );
275 wl_lock( lp, &flags );
278 if( lp->useRTS == 1 ) {
279 wl_unlock( lp, &flags );
281 //DBG_LEAVE( DbgInfo );
286 /* Return the statistics for the appropriate device */
289 for( count = 0; count < NUM_WDS_PORTS; count++ ) {
290 if( dev == lp->wds_port[count].dev ) {
291 pStats = &( lp->wds_port[count].stats );
297 /* If pStats is still NULL, then the device is not a WDS port */
298 if( pStats == NULL ) {
299 pStats = &( lp->stats );
302 wl_unlock( lp, &flags );
304 //DBG_LEAVE( DbgInfo );
308 /*============================================================================*/
310 /*******************************************************************************
312 *******************************************************************************
320 * dev - a pointer to the device's net_device structure
327 ******************************************************************************/
328 int wl_open(struct net_device *dev)
330 int status = HCF_SUCCESS;
331 struct wl_private *lp = wl_priv(dev);
333 /*------------------------------------------------------------------------*/
335 DBG_FUNC( "wl_open" );
336 DBG_ENTER( DbgInfo );
338 wl_lock( lp, &flags );
341 if( lp->useRTS == 1 ) {
342 DBG_TRACE( DbgInfo, "Skipping device open, in RTS mode\n" );
343 wl_unlock( lp, &flags );
344 DBG_LEAVE( DbgInfo );
353 if( lp->portState == WVLAN_PORT_STATE_DISABLED ) {
354 DBG_TRACE( DbgInfo, "Enabling Port 0\n" );
355 status = wl_enable( lp );
357 if( status != HCF_SUCCESS ) {
358 DBG_TRACE( DbgInfo, "Enable port 0 failed: 0x%x\n", status );
362 // Holding the lock too long, make a gap to allow other processes
363 wl_unlock(lp, &flags);
364 wl_lock( lp, &flags );
366 if ( strlen( lp->fw_image_filename ) ) {
367 DBG_TRACE( DbgInfo, ";???? Kludgy way to force a download\n" );
368 status = wl_go( lp );
370 status = wl_apply( lp );
373 // Holding the lock too long, make a gap to allow other processes
374 wl_unlock(lp, &flags);
375 wl_lock( lp, &flags );
377 if( status != HCF_SUCCESS ) {
378 // Unsuccesfull, try reset of the card to recover
379 status = wl_reset( dev );
382 // Holding the lock too long, make a gap to allow other processes
383 wl_unlock(lp, &flags);
384 wl_lock( lp, &flags );
386 if( status == HCF_SUCCESS ) {
387 netif_carrier_on( dev );
388 WL_WDS_NETIF_CARRIER_ON( lp );
390 lp->is_handling_int = WL_HANDLING_INT; // Start handling interrupts
393 netif_start_queue( dev );
394 WL_WDS_NETIF_START_QUEUE( lp );
396 wl_hcf_error( dev, status ); /* Report the error */
397 netif_device_detach( dev ); /* Stop the device and queue */
400 wl_unlock( lp, &flags );
402 DBG_LEAVE( DbgInfo );
405 /*============================================================================*/
407 /*******************************************************************************
409 *******************************************************************************
417 * dev - a pointer to the device's net_device structure
424 ******************************************************************************/
425 int wl_close( struct net_device *dev )
427 struct wl_private *lp = wl_priv(dev);
429 /*------------------------------------------------------------------------*/
431 DBG_FUNC("wl_close");
433 DBG_PARAM(DbgInfo, "dev", "%s (0x%p)", dev->name, dev);
435 /* Mark the adapter as busy */
436 netif_stop_queue( dev );
437 WL_WDS_NETIF_STOP_QUEUE( lp );
439 netif_carrier_off( dev );
440 WL_WDS_NETIF_CARRIER_OFF( lp );
442 /* Shutdown the adapter:
443 Disable adapter interrupts
449 wl_lock( lp, &flags );
451 wl_act_int_off( lp );
452 lp->is_handling_int = WL_NOT_HANDLING_INT; // Stop handling interrupts
455 if( lp->useRTS == 1 ) {
456 DBG_TRACE( DbgInfo, "Skipping device close, in RTS mode\n" );
457 wl_unlock( lp, &flags );
458 DBG_LEAVE( DbgInfo );
463 /* Disable the ports */
466 wl_unlock( lp, &flags );
468 DBG_LEAVE( DbgInfo );
471 /*============================================================================*/
473 static void wl_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
475 strncpy(info->driver, DRIVER_NAME, sizeof(info->driver) - 1);
476 strncpy(info->version, DRV_VERSION_STR, sizeof(info->version) - 1);
477 // strncpy(info.fw_version, priv->fw_name,
478 // sizeof(info.fw_version) - 1);
480 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,20))
481 if (dev->dev.parent) {
482 dev_set_name(dev->dev.parent, "%s", info->bus_info);
483 //strncpy(info->bus_info, dev->dev.parent->bus_id,
484 // sizeof(info->bus_info) - 1);
486 if (dev->class_dev.parent) {
487 sizeof(info->bus_info) - 1);
490 snprintf(info->bus_info, sizeof(info->bus_info) - 1,
492 // "PCMCIA 0x%lx", priv->hw.iobase);
496 static struct ethtool_ops wl_ethtool_ops = {
497 .get_drvinfo = wl_get_drvinfo,
498 .get_link = ethtool_op_get_link,
502 /*******************************************************************************
504 *******************************************************************************
508 * The IOCTL handler for the device.
512 * dev - a pointer to the device's net_device struct.
513 * rq - a pointer to the IOCTL request buffer.
514 * cmd - the IOCTL command code.
519 * errno value otherwise
521 ******************************************************************************/
522 int wl_ioctl( struct net_device *dev, struct ifreq *rq, int cmd )
524 struct wl_private *lp = wl_priv(dev);
527 /*------------------------------------------------------------------------*/
529 DBG_FUNC( "wl_ioctl" );
531 DBG_PARAM(DbgInfo, "dev", "%s (0x%p)", dev->name, dev);
532 DBG_PARAM(DbgInfo, "rq", "0x%p", rq);
533 DBG_PARAM(DbgInfo, "cmd", "0x%04x", cmd);
535 wl_lock( lp, &flags );
537 wl_act_int_off( lp );
540 if( lp->useRTS == 1 ) {
541 /* Handle any RTS IOCTL here */
542 if( cmd == WL_IOCTL_RTS ) {
543 DBG_TRACE( DbgInfo, "IOCTL: WL_IOCTL_RTS\n" );
544 ret = wvlan_rts( (struct rtsreq *)rq, dev->base_addr );
546 DBG_TRACE( DbgInfo, "IOCTL not supported in RTS mode: 0x%X\n", cmd );
550 goto out_act_int_on_unlock;
554 /* Only handle UIL IOCTL requests when the UIL has the system blocked. */
555 if( !(( lp->flags & WVLAN2_UIL_BUSY ) && ( cmd != WVLAN2_IOCTL_UIL ))) {
557 struct uilreq *urq = (struct uilreq *)rq;
561 // ================== Private IOCTLs (up to 16) ==================
563 case WVLAN2_IOCTL_UIL:
564 DBG_TRACE( DbgInfo, "IOCTL: WVLAN2_IOCTL_UIL\n" );
565 ret = wvlan_uil( urq, lp );
570 DBG_TRACE(DbgInfo, "IOCTL CODE NOT SUPPORTED: 0x%X\n", cmd );
575 DBG_WARNING( DbgInfo, "DEVICE IS BUSY, CANNOT PROCESS REQUEST\n" );
580 out_act_int_on_unlock:
584 wl_unlock( lp, &flags );
586 DBG_LEAVE( DbgInfo );
589 /*============================================================================*/
591 #ifdef CONFIG_NET_POLL_CONTROLLER
592 void wl_poll(struct net_device *dev)
594 struct wl_private *lp = wl_priv(dev);
598 wl_lock( lp, &flags );
599 wl_isr(dev->irq, dev, ®s);
600 wl_unlock( lp, &flags );
604 /*******************************************************************************
606 *******************************************************************************
610 * The handler called when, for some reason, a Tx request is not completed.
614 * dev - a pointer to the device's net_device struct.
620 ******************************************************************************/
621 void wl_tx_timeout( struct net_device *dev )
627 struct wl_private *lp = wl_priv(dev);
628 struct net_device_stats *pStats = NULL;
629 /*------------------------------------------------------------------------*/
631 DBG_FUNC( "wl_tx_timeout" );
632 DBG_ENTER( DbgInfo );
634 DBG_WARNING( DbgInfo, "%s: Transmit timeout.\n", dev->name );
636 wl_lock( lp, &flags );
639 if( lp->useRTS == 1 ) {
640 DBG_TRACE( DbgInfo, "Skipping tx_timeout handler, in RTS mode\n" );
641 wl_unlock( lp, &flags );
643 DBG_LEAVE( DbgInfo );
648 /* Figure out which device (the "root" device or WDS port) this timeout
652 for( count = 0; count < NUM_WDS_PORTS; count++ ) {
653 if( dev == lp->wds_port[count].dev ) {
654 pStats = &( lp->wds_port[count].stats );
656 /* Break the loop so that we can use the counter to access WDS
657 information in the private structure */
664 /* If pStats is still NULL, then the device is not a WDS port */
665 if( pStats == NULL ) {
666 pStats = &( lp->stats );
669 /* Accumulate the timeout error */
672 wl_unlock( lp, &flags );
674 DBG_LEAVE( DbgInfo );
677 /*============================================================================*/
679 /*******************************************************************************
681 *******************************************************************************
685 * The routine which performs data transmits.
689 * lp - a pointer to the device's wl_private struct.
696 ******************************************************************************/
697 int wl_send( struct wl_private *lp )
702 WVLAN_LFRAME *txF = NULL;
703 struct list_head *element;
705 /*------------------------------------------------------------------------*/
707 DBG_FUNC( "wl_send" );
710 DBG_ERROR( DbgInfo, "Private adapter struct is NULL\n" );
713 if( lp->dev == NULL ) {
714 DBG_ERROR( DbgInfo, "net_device struct in wl_private is NULL\n" );
718 /* Check for the availability of FIDs; if none are available, don't take any
719 frames off the txQ */
720 if( lp->hcfCtx.IFB_RscInd == 0 ) {
724 /* Reclaim the TxQ Elements and place them back on the free queue */
725 if( !list_empty( &( lp->txQ[0] ))) {
726 element = lp->txQ[0].next;
728 txF = (WVLAN_LFRAME * )list_entry( element, WVLAN_LFRAME, node );
730 lp->txF.skb = txF->frame.skb;
731 lp->txF.port = txF->frame.port;
733 txF->frame.skb = NULL;
736 list_del( &( txF->node ));
737 list_add( element, &( lp->txFree ));
741 if( lp->txQ_count < TX_Q_LOW_WATER_MARK ) {
742 if( lp->netif_queue_on == FALSE ) {
743 DBG_TX( DbgInfo, "Kickstarting Q: %d\n", lp->txQ_count );
744 netif_wake_queue( lp->dev );
745 WL_WDS_NETIF_WAKE_QUEUE( lp );
746 lp->netif_queue_on = TRUE;
752 if( lp->txF.skb == NULL ) {
756 /* If the device has resources (FIDs) available, then Tx the packet */
757 /* Format the TxRequest and send it to the adapter */
758 len = lp->txF.skb->len < ETH_ZLEN ? ETH_ZLEN : lp->txF.skb->len;
760 desc = &( lp->desc_tx );
761 desc->buf_addr = lp->txF.skb->data;
763 desc->next_desc_addr = NULL;
765 status = hcf_send_msg( &( lp->hcfCtx ), desc, lp->txF.port );
767 if( status == HCF_SUCCESS ) {
768 lp->dev->trans_start = jiffies;
770 DBG_TX( DbgInfo, "Transmit...\n" );
772 if( lp->txF.port == HCF_PORT_0 ) {
773 lp->stats.tx_packets++;
774 lp->stats.tx_bytes += lp->txF.skb->len;
780 lp->wds_port[(( lp->txF.port >> 8 ) - 1)].stats.tx_packets++;
781 lp->wds_port[(( lp->txF.port >> 8 ) - 1)].stats.tx_bytes += lp->txF.skb->len;
786 /* Free the skb and perform queue cleanup, as the buffer was
787 transmitted successfully */
788 dev_kfree_skb( lp->txF.skb );
796 /*============================================================================*/
798 /*******************************************************************************
800 *******************************************************************************
804 * The Tx handler function for the network layer.
808 * skb - a pointer to the sk_buff structure containing the data to transfer.
809 * dev - a pointer to the device's net_device structure.
816 ******************************************************************************/
817 int wl_tx( struct sk_buff *skb, struct net_device *dev, int port )
820 struct wl_private *lp = wl_priv(dev);
821 WVLAN_LFRAME *txF = NULL;
822 struct list_head *element;
823 /*------------------------------------------------------------------------*/
827 /* Grab the spinlock */
828 wl_lock( lp, &flags );
830 if( lp->flags & WVLAN2_UIL_BUSY ) {
831 DBG_WARNING( DbgInfo, "UIL has device blocked\n" );
832 /* Start dropping packets here??? */
833 wl_unlock( lp, &flags );
838 if( lp->useRTS == 1 ) {
839 DBG_PRINT( "RTS: we're getting a Tx...\n" );
840 wl_unlock( lp, &flags );
846 /* Get an element from the queue */
847 element = lp->txFree.next;
848 txF = (WVLAN_LFRAME *)list_entry( element, WVLAN_LFRAME, node );
850 DBG_ERROR( DbgInfo, "Problem with list_entry\n" );
851 wl_unlock( lp, &flags );
854 /* Fill out the frame */
855 txF->frame.skb = skb;
856 txF->frame.port = port;
857 /* Move the frame to the txQ */
858 /* NOTE: Here's where we would do priority queueing */
859 list_del( &( txF->node ));
860 list_add( &( txF->node ), &( lp->txQ[0] ));
863 if( lp->txQ_count >= DEFAULT_NUM_TX_FRAMES ) {
864 DBG_TX( DbgInfo, "Q Full: %d\n", lp->txQ_count );
865 if( lp->netif_queue_on == TRUE ) {
866 netif_stop_queue( lp->dev );
867 WL_WDS_NETIF_STOP_QUEUE( lp );
868 lp->netif_queue_on = FALSE;
872 wl_act_int_off( lp ); /* Disable Interrupts */
874 /* Send the data to the hardware using the appropriate method */
877 wl_send_dma( lp, skb, port );
884 /* Re-enable Interrupts, release the spinlock and return */
886 wl_unlock( lp, &flags );
889 /*============================================================================*/
891 /*******************************************************************************
893 *******************************************************************************
897 * The routine which performs data reception.
901 * dev - a pointer to the device's net_device structure.
908 ******************************************************************************/
909 int wl_rx(struct net_device *dev)
913 struct wl_private *lp = wl_priv(dev);
918 /*------------------------------------------------------------------------*/
921 DBG_PARAM(DbgInfo, "dev", "%s (0x%p)", dev->name, dev);
923 if(!( lp->flags & WVLAN2_UIL_BUSY )) {
926 if( lp->useRTS == 1 ) {
927 DBG_PRINT( "RTS: We're getting an Rx...\n" );
932 /* Read the HFS_STAT register from the lookahead buffer */
933 hfs_stat = (hcf_16)(( lp->lookAheadBuf[HFS_STAT] ) |
934 ( lp->lookAheadBuf[HFS_STAT + 1] << 8 ));
936 /* Make sure the frame isn't bad */
937 if(( hfs_stat & HFS_STAT_ERR ) != HCF_SUCCESS ) {
938 DBG_WARNING( DbgInfo, "HFS_STAT_ERROR (0x%x) in Rx Packet\n",
939 lp->lookAheadBuf[HFS_STAT] );
943 /* Determine what port this packet is for */
944 port = ( hfs_stat >> 8 ) & 0x0007;
945 DBG_RX( DbgInfo, "Rx frame for port %d\n", port );
947 if(( pktlen = lp->hcfCtx.IFB_RxLen ) != 0 ) {
948 if(( skb = ALLOC_SKB( pktlen )) != NULL ) {
949 /* Set the netdev based on the port */
958 skb->dev = lp->wds_port[port-1].dev;
968 desc = &( lp->desc_rx );
970 desc->next_desc_addr = NULL;
973 #define BLOCK_INPUT(buf, len) \
974 desc->buf_addr = buf; \
975 desc->BUF_SIZE = len; \
976 status = hcf_rcv_msg(&(lp->hcfCtx), desc, 0)
979 GET_PACKET( skb->dev, skb, pktlen );
981 if( status == HCF_SUCCESS ) {
985 lp->stats.rx_packets++;
986 lp->stats.rx_bytes += pktlen;
991 lp->wds_port[port-1].stats.rx_packets++;
992 lp->wds_port[port-1].stats.rx_bytes += pktlen;
996 dev->last_rx = jiffies;
1000 if( lp->spydata.spy_number > 0 ) {
1001 char *srcaddr = skb->mac.raw + MAC_ADDR_SIZE;
1003 wl_spy_gather( dev, srcaddr );
1005 #endif /* WIRELESS_SPY */
1006 #endif /* WIRELESS_EXT */
1008 DBG_ERROR( DbgInfo, "Rx request to card FAILED\n" );
1011 lp->stats.rx_dropped++;
1016 lp->wds_port[port-1].stats.rx_dropped++;
1018 #endif /* USE_WDS */
1020 dev_kfree_skb( skb );
1023 DBG_ERROR( DbgInfo, "Could not alloc skb\n" );
1026 lp->stats.rx_dropped++;
1031 lp->wds_port[port-1].stats.rx_dropped++;
1033 #endif /* USE_WDS */
1040 /*============================================================================*/
1042 /*******************************************************************************
1044 *******************************************************************************
1048 * Function to handle multicast packets
1052 * dev - a pointer to the device's net_device structure.
1058 ******************************************************************************/
1059 #ifdef NEW_MULTICAST
1061 void wl_multicast( struct net_device *dev )
1063 #if 1 //;? (HCF_TYPE) & HCF_TYPE_STA //;?should we return an error status in AP mode
1064 //;?seems reasonable that even an AP-only driver could afford this small additional footprint
1067 struct dev_mc_list *mclist;
1068 struct wl_private *lp = wl_priv(dev);
1069 unsigned long flags;
1070 /*------------------------------------------------------------------------*/
1072 DBG_FUNC( "wl_multicast" );
1073 DBG_ENTER( DbgInfo );
1074 DBG_PARAM( DbgInfo, "dev", "%s (0x%p)", dev->name, dev );
1076 if( !wl_adapter_is_open( dev )) {
1077 DBG_LEAVE( DbgInfo );
1082 if( DBG_FLAGS( DbgInfo ) & DBG_PARAM_ON ) {
1083 DBG_PRINT(" flags: %s%s%s\n",
1084 ( dev->flags & IFF_PROMISC ) ? "Promiscous " : "",
1085 ( dev->flags & IFF_MULTICAST ) ? "Multicast " : "",
1086 ( dev->flags & IFF_ALLMULTI ) ? "All-Multicast" : "" );
1088 DBG_PRINT( " mc_count: %d\n", dev->mc_count );
1090 for( x = 0, mclist = dev->mc_list; mclist && x < dev->mc_count;
1091 x++, mclist = mclist->next ) {
1092 DBG_PRINT( " %s (%d)\n", DbgHwAddr(mclist->dmi_addr),
1093 mclist->dmi_addrlen );
1098 if(!( lp->flags & WVLAN2_UIL_BUSY )) {
1101 if( lp->useRTS == 1 ) {
1102 DBG_TRACE( DbgInfo, "Skipping multicast, in RTS mode\n" );
1104 DBG_LEAVE( DbgInfo );
1107 #endif /* USE_RTS */
1109 wl_lock( lp, &flags );
1110 wl_act_int_off( lp );
1112 if ( CNV_INT_TO_LITTLE( lp->hcfCtx.IFB_FWIdentity.comp_id ) == COMP_ID_FW_STA ) {
1113 if( dev->flags & IFF_PROMISC ) {
1114 /* Enable promiscuous mode */
1115 lp->ltvRecord.len = 2;
1116 lp->ltvRecord.typ = CFG_PROMISCUOUS_MODE;
1117 lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE( 1 );
1118 DBG_PRINT( "Enabling Promiscuous mode (IFF_PROMISC)\n" );
1119 hcf_put_info( &( lp->hcfCtx ), (LTVP)&( lp->ltvRecord ));
1121 else if(( dev->mc_count > HCF_MAX_MULTICAST ) ||
1122 ( dev->flags & IFF_ALLMULTI )) {
1123 /* Shutting off this filter will enable all multicast frames to
1124 be sent up from the device; however, this is a static RID, so
1125 a call to wl_apply() is needed */
1126 lp->ltvRecord.len = 2;
1127 lp->ltvRecord.typ = CFG_CNF_RX_ALL_GROUP_ADDR;
1128 lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE( 0 );
1129 DBG_PRINT( "Enabling all multicast mode (IFF_ALLMULTI)\n" );
1130 hcf_put_info( &( lp->hcfCtx ), (LTVP)&( lp->ltvRecord ));
1133 else if( dev->mc_count != 0 ) {
1134 /* Set the multicast addresses */
1135 lp->ltvRecord.len = ( dev->mc_count * 3 ) + 1;
1136 lp->ltvRecord.typ = CFG_GROUP_ADDR;
1138 for( x = 0, mclist = dev->mc_list;
1139 ( x < dev->mc_count ) && ( mclist != NULL );
1140 x++, mclist = mclist->next ) {
1141 memcpy( &( lp->ltvRecord.u.u8[x * ETH_ALEN] ),
1142 mclist->dmi_addr, ETH_ALEN );
1144 DBG_PRINT( "Setting multicast list\n" );
1145 hcf_put_info( &( lp->hcfCtx ), (LTVP)&( lp->ltvRecord ));
1147 /* Disable promiscuous mode */
1148 lp->ltvRecord.len = 2;
1149 lp->ltvRecord.typ = CFG_PROMISCUOUS_MODE;
1150 lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE( 0 );
1151 DBG_PRINT( "Disabling Promiscuous mode\n" );
1152 hcf_put_info( &( lp->hcfCtx ), (LTVP)&( lp->ltvRecord ));
1154 /* Disable multicast mode */
1155 lp->ltvRecord.len = 2;
1156 lp->ltvRecord.typ = CFG_GROUP_ADDR;
1157 DBG_PRINT( "Disabling Multicast mode\n" );
1158 hcf_put_info( &( lp->hcfCtx ), (LTVP)&( lp->ltvRecord ));
1160 /* Turning on this filter will prevent all multicast frames from
1161 being sent up from the device; however, this is a static RID,
1162 so a call to wl_apply() is needed */
1163 lp->ltvRecord.len = 2;
1164 lp->ltvRecord.typ = CFG_CNF_RX_ALL_GROUP_ADDR;
1165 lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE( 1 );
1166 DBG_PRINT( "Disabling all multicast mode (IFF_ALLMULTI)\n" );
1167 hcf_put_info( &( lp->hcfCtx ), (LTVP)&( lp->ltvRecord ));
1171 wl_act_int_on( lp );
1172 wl_unlock( lp, &flags );
1174 DBG_LEAVE( DbgInfo );
1175 #endif /* HCF_STA */
1177 /*============================================================================*/
1179 #else /* NEW_MULTICAST */
1181 void wl_multicast( struct net_device *dev, int num_addrs, void *addrs )
1183 DBG_FUNC( "wl_multicast");
1186 DBG_PARAM( DbgInfo, "dev", "%s (0x%p)", dev->name, dev );
1187 DBG_PARAM( DbgInfo, "num_addrs", "%d", num_addrs );
1188 DBG_PARAM( DbgInfo, "addrs", "0x%p", addrs );
1190 #error Obsolete set multicast interface!
1192 DBG_LEAVE( DbgInfo );
1194 /*============================================================================*/
1196 #endif /* NEW_MULTICAST */
1198 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,30))
1199 static const struct net_device_ops wl_netdev_ops =
1201 .ndo_start_xmit = &wl_tx_port0,
1203 .ndo_set_config = &wl_config,
1204 .ndo_get_stats = &wl_stats,
1205 .ndo_set_multicast_list = &wl_multicast,
1207 .ndo_init = &wl_insert,
1208 .ndo_open = &wl_adapter_open,
1209 .ndo_stop = &wl_adapter_close,
1210 .ndo_do_ioctl = &wl_ioctl,
1212 #ifdef HAVE_TX_TIMEOUT
1213 .ndo_tx_timeout = &wl_tx_timeout,
1216 #ifdef CONFIG_NET_POLL_CONTROLLER
1217 .ndo_poll_controller = wl_poll,
1220 #endif // (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,30))
1222 /*******************************************************************************
1224 *******************************************************************************
1228 * Create instances of net_device and wl_private for the new adapter
1229 * and register the device's entry points in the net_device structure.
1237 * a pointer to an allocated and initialized net_device struct for this
1240 ******************************************************************************/
1241 struct net_device * wl_device_alloc( void )
1243 struct net_device *dev = NULL;
1244 struct wl_private *lp = NULL;
1245 /*------------------------------------------------------------------------*/
1247 DBG_FUNC( "wl_device_alloc" );
1248 DBG_ENTER( DbgInfo );
1250 /* Alloc a net_device struct */
1251 dev = alloc_etherdev(sizeof(struct wl_private));
1255 /* Initialize the 'next' pointer in the struct. Currently only used for PCI,
1256 but do it here just in case it's used for other buses in the future */
1261 if( dev->mtu > MTU_MAX )
1263 DBG_WARNING( DbgInfo, "%s: MTU set too high, limiting to %d.\n",
1264 dev->name, MTU_MAX );
1268 /* Setup the function table in the device structure. */
1270 dev->wireless_handlers = (struct iw_handler_def *)&wl_iw_handler_def;
1271 lp->wireless_data.spy_data = &lp->spy_data;
1272 dev->wireless_data = &lp->wireless_data;
1274 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,30))
1275 dev->netdev_ops = &wl_netdev_ops;
1277 dev->hard_start_xmit = &wl_tx_port0;
1279 dev->set_config = &wl_config;
1280 dev->get_stats = &wl_stats;
1281 dev->set_multicast_list = &wl_multicast;
1283 dev->init = &wl_insert;
1284 dev->open = &wl_adapter_open;
1285 dev->stop = &wl_adapter_close;
1286 dev->do_ioctl = &wl_ioctl;
1288 #ifdef HAVE_TX_TIMEOUT
1289 dev->tx_timeout = &wl_tx_timeout;
1292 #ifdef CONFIG_NET_POLL_CONTROLLER
1293 dev->poll_controller = wl_poll;
1296 #endif // (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,30))
1298 #ifdef HAVE_TX_TIMEOUT
1299 dev->watchdog_timeo = TX_TIMEOUT;
1302 dev->ethtool_ops = &wl_ethtool_ops;
1304 netif_stop_queue( dev );
1306 /* Allocate virutal devices for WDS support if needed */
1307 WL_WDS_DEVICE_ALLOC( lp );
1309 DBG_LEAVE( DbgInfo );
1311 } // wl_device_alloc
1312 /*============================================================================*/
1314 /*******************************************************************************
1315 * wl_device_dealloc()
1316 *******************************************************************************
1320 * Free instances of net_device and wl_private strcutres for an adapter
1321 * and perform basic cleanup.
1325 * dev - a pointer to the device's net_device structure.
1331 ******************************************************************************/
1332 void wl_device_dealloc( struct net_device *dev )
1334 // struct wl_private *lp = wl_priv(dev);
1335 /*------------------------------------------------------------------------*/
1337 DBG_FUNC( "wl_device_dealloc" );
1338 DBG_ENTER( DbgInfo );
1340 /* Dealloc the WDS ports */
1341 WL_WDS_DEVICE_DEALLOC( lp );
1345 DBG_LEAVE( DbgInfo );
1347 } // wl_device_dealloc
1348 /*============================================================================*/
1350 /*******************************************************************************
1352 *******************************************************************************
1356 * The handler routine for Tx over HCF_PORT_0.
1360 * skb - a pointer to the sk_buff to transmit.
1361 * dev - a pointer to a net_device structure representing HCF_PORT_0.
1367 ******************************************************************************/
1368 int wl_tx_port0( struct sk_buff *skb, struct net_device *dev )
1370 DBG_TX( DbgInfo, "Tx on Port 0\n" );
1372 return wl_tx( skb, dev, HCF_PORT_0 );
1374 return wl_tx_dma( skb, dev, HCF_PORT_0 );
1377 /*============================================================================*/
1381 /*******************************************************************************
1383 *******************************************************************************
1387 * The handler routine for Tx over HCF_PORT_1.
1391 * skb - a pointer to the sk_buff to transmit.
1392 * dev - a pointer to a net_device structure representing HCF_PORT_1.
1398 ******************************************************************************/
1399 int wl_tx_port1( struct sk_buff *skb, struct net_device *dev )
1401 DBG_TX( DbgInfo, "Tx on Port 1\n" );
1402 return wl_tx( skb, dev, HCF_PORT_1 );
1404 /*============================================================================*/
1406 /*******************************************************************************
1408 *******************************************************************************
1412 * The handler routine for Tx over HCF_PORT_2.
1416 * skb - a pointer to the sk_buff to transmit.
1417 * dev - a pointer to a net_device structure representing HCF_PORT_2.
1423 ******************************************************************************/
1424 int wl_tx_port2( struct sk_buff *skb, struct net_device *dev )
1426 DBG_TX( DbgInfo, "Tx on Port 2\n" );
1427 return wl_tx( skb, dev, HCF_PORT_2 );
1429 /*============================================================================*/
1431 /*******************************************************************************
1433 *******************************************************************************
1437 * The handler routine for Tx over HCF_PORT_3.
1441 * skb - a pointer to the sk_buff to transmit.
1442 * dev - a pointer to a net_device structure representing HCF_PORT_3.
1448 ******************************************************************************/
1449 int wl_tx_port3( struct sk_buff *skb, struct net_device *dev )
1451 DBG_TX( DbgInfo, "Tx on Port 3\n" );
1452 return wl_tx( skb, dev, HCF_PORT_3 );
1454 /*============================================================================*/
1456 /*******************************************************************************
1458 *******************************************************************************
1462 * The handler routine for Tx over HCF_PORT_4.
1466 * skb - a pointer to the sk_buff to transmit.
1467 * dev - a pointer to a net_device structure representing HCF_PORT_4.
1473 ******************************************************************************/
1474 int wl_tx_port4( struct sk_buff *skb, struct net_device *dev )
1476 DBG_TX( DbgInfo, "Tx on Port 4\n" );
1477 return wl_tx( skb, dev, HCF_PORT_4 );
1479 /*============================================================================*/
1481 /*******************************************************************************
1483 *******************************************************************************
1487 * The handler routine for Tx over HCF_PORT_5.
1491 * skb - a pointer to the sk_buff to transmit.
1492 * dev - a pointer to a net_device structure representing HCF_PORT_5.
1498 ******************************************************************************/
1499 int wl_tx_port5( struct sk_buff *skb, struct net_device *dev )
1501 DBG_TX( DbgInfo, "Tx on Port 5\n" );
1502 return wl_tx( skb, dev, HCF_PORT_5 );
1504 /*============================================================================*/
1506 /*******************************************************************************
1508 *******************************************************************************
1512 * The handler routine for Tx over HCF_PORT_6.
1516 * skb - a pointer to the sk_buff to transmit.
1517 * dev - a pointer to a net_device structure representing HCF_PORT_6.
1523 ******************************************************************************/
1524 int wl_tx_port6( struct sk_buff *skb, struct net_device *dev )
1526 DBG_TX( DbgInfo, "Tx on Port 6\n" );
1527 return wl_tx( skb, dev, HCF_PORT_6 );
1529 /*============================================================================*/
1531 /*******************************************************************************
1532 * wl_wds_device_alloc()
1533 *******************************************************************************
1537 * Create instances of net_device to represent the WDS ports, and register
1538 * the device's entry points in the net_device structure.
1542 * lp - a pointer to the device's private adapter structure
1546 * N/A, but will place pointers to the allocated and initialized net_device
1547 * structs in the private adapter structure.
1549 ******************************************************************************/
1550 void wl_wds_device_alloc( struct wl_private *lp )
1553 /*------------------------------------------------------------------------*/
1555 DBG_FUNC( "wl_wds_device_alloc" );
1556 DBG_ENTER( DbgInfo );
1558 /* WDS support requires additional net_device structs to be allocated,
1559 so that user space apps can use these virtual devices to specify the
1560 port on which to Tx/Rx */
1561 for( count = 0; count < NUM_WDS_PORTS; count++ ) {
1562 struct net_device *dev_wds = NULL;
1564 dev_wds = kmalloc( sizeof( struct net_device ), GFP_KERNEL );
1565 memset( dev_wds, 0, sizeof( struct net_device ));
1567 ether_setup( dev_wds );
1569 lp->wds_port[count].dev = dev_wds;
1571 /* Re-use wl_init for all the devices, as it currently does nothing, but
1572 is required. Re-use the stats/tx_timeout handler for all as well; the
1573 WDS port which is requesting these operations can be determined by
1574 the net_device pointer. Set the private member of all devices to point
1575 to the same net_device struct; that way, all information gets
1576 funnelled through the one "real" net_device. Name the WDS ports
1578 lp->wds_port[count].dev->init = &wl_init;
1579 lp->wds_port[count].dev->get_stats = &wl_stats;
1580 lp->wds_port[count].dev->tx_timeout = &wl_tx_timeout;
1581 lp->wds_port[count].dev->watchdog_timeo = TX_TIMEOUT;
1582 lp->wds_port[count].dev->priv = lp;
1584 sprintf( lp->wds_port[count].dev->name, "wds%d", count );
1587 /* Register the Tx handlers */
1588 lp->wds_port[0].dev->hard_start_xmit = &wl_tx_port1;
1589 lp->wds_port[1].dev->hard_start_xmit = &wl_tx_port2;
1590 lp->wds_port[2].dev->hard_start_xmit = &wl_tx_port3;
1591 lp->wds_port[3].dev->hard_start_xmit = &wl_tx_port4;
1592 lp->wds_port[4].dev->hard_start_xmit = &wl_tx_port5;
1593 lp->wds_port[5].dev->hard_start_xmit = &wl_tx_port6;
1595 WL_WDS_NETIF_STOP_QUEUE( lp );
1597 DBG_LEAVE( DbgInfo );
1599 } // wl_wds_device_alloc
1600 /*============================================================================*/
1602 /*******************************************************************************
1603 * wl_wds_device_dealloc()
1604 *******************************************************************************
1608 * Free instances of net_device structures used to support WDS.
1612 * lp - a pointer to the device's private adapter structure
1618 ******************************************************************************/
1619 void wl_wds_device_dealloc( struct wl_private *lp )
1622 /*------------------------------------------------------------------------*/
1624 DBG_FUNC( "wl_wds_device_dealloc" );
1625 DBG_ENTER( DbgInfo );
1627 for( count = 0; count < NUM_WDS_PORTS; count++ ) {
1628 struct net_device *dev_wds = NULL;
1630 dev_wds = lp->wds_port[count].dev;
1632 if( dev_wds != NULL ) {
1633 if( dev_wds->flags & IFF_UP ) {
1634 dev_close( dev_wds );
1635 dev_wds->flags &= ~( IFF_UP | IFF_RUNNING );
1639 lp->wds_port[count].dev = NULL;
1643 DBG_LEAVE( DbgInfo );
1645 } // wl_wds_device_dealloc
1646 /*============================================================================*/
1648 /*******************************************************************************
1649 * wl_wds_netif_start_queue()
1650 *******************************************************************************
1654 * Used to start the netif queues of all the "virtual" network devices
1655 * which repesent the WDS ports.
1659 * lp - a pointer to the device's private adapter structure
1665 ******************************************************************************/
1666 void wl_wds_netif_start_queue( struct wl_private *lp )
1669 /*------------------------------------------------------------------------*/
1672 for( count = 0; count < NUM_WDS_PORTS; count++ ) {
1673 if( lp->wds_port[count].is_registered &&
1674 lp->wds_port[count].netif_queue_on == FALSE ) {
1675 netif_start_queue( lp->wds_port[count].dev );
1676 lp->wds_port[count].netif_queue_on = TRUE;
1682 } // wl_wds_netif_start_queue
1683 /*============================================================================*/
1685 /*******************************************************************************
1686 * wl_wds_netif_stop_queue()
1687 *******************************************************************************
1691 * Used to stop the netif queues of all the "virtual" network devices
1692 * which repesent the WDS ports.
1696 * lp - a pointer to the device's private adapter structure
1702 ******************************************************************************/
1703 void wl_wds_netif_stop_queue( struct wl_private *lp )
1706 /*------------------------------------------------------------------------*/
1709 for( count = 0; count < NUM_WDS_PORTS; count++ ) {
1710 if( lp->wds_port[count].is_registered &&
1711 lp->wds_port[count].netif_queue_on == TRUE ) {
1712 netif_stop_queue( lp->wds_port[count].dev );
1713 lp->wds_port[count].netif_queue_on = FALSE;
1719 } // wl_wds_netif_stop_queue
1720 /*============================================================================*/
1722 /*******************************************************************************
1723 * wl_wds_netif_wake_queue()
1724 *******************************************************************************
1728 * Used to wake the netif queues of all the "virtual" network devices
1729 * which repesent the WDS ports.
1733 * lp - a pointer to the device's private adapter structure
1739 ******************************************************************************/
1740 void wl_wds_netif_wake_queue( struct wl_private *lp )
1743 /*------------------------------------------------------------------------*/
1746 for( count = 0; count < NUM_WDS_PORTS; count++ ) {
1747 if( lp->wds_port[count].is_registered &&
1748 lp->wds_port[count].netif_queue_on == FALSE ) {
1749 netif_wake_queue( lp->wds_port[count].dev );
1750 lp->wds_port[count].netif_queue_on = TRUE;
1756 } // wl_wds_netif_wake_queue
1757 /*============================================================================*/
1759 /*******************************************************************************
1760 * wl_wds_netif_carrier_on()
1761 *******************************************************************************
1765 * Used to signal the network layer that carrier is present on all of the
1766 * "virtual" network devices which repesent the WDS ports.
1770 * lp - a pointer to the device's private adapter structure
1776 ******************************************************************************/
1777 void wl_wds_netif_carrier_on( struct wl_private *lp )
1780 /*------------------------------------------------------------------------*/
1783 for( count = 0; count < NUM_WDS_PORTS; count++ ) {
1784 if( lp->wds_port[count].is_registered ) {
1785 netif_carrier_on( lp->wds_port[count].dev );
1791 } // wl_wds_netif_carrier_on
1792 /*============================================================================*/
1794 /*******************************************************************************
1795 * wl_wds_netif_carrier_off()
1796 *******************************************************************************
1800 * Used to signal the network layer that carrier is NOT present on all of
1801 * the "virtual" network devices which repesent the WDS ports.
1805 * lp - a pointer to the device's private adapter structure
1811 ******************************************************************************/
1812 void wl_wds_netif_carrier_off( struct wl_private *lp )
1815 /*------------------------------------------------------------------------*/
1818 for( count = 0; count < NUM_WDS_PORTS; count++ ) {
1819 if( lp->wds_port[count].is_registered ) {
1820 netif_carrier_off( lp->wds_port[count].dev );
1826 } // wl_wds_netif_carrier_off
1827 /*============================================================================*/
1829 #endif /* USE_WDS */
1832 /*******************************************************************************
1834 *******************************************************************************
1838 * The routine which performs data transmits when using busmaster DMA.
1842 * lp - a pointer to the device's wl_private struct.
1843 * skb - a pointer to the network layer's data buffer.
1844 * port - the Hermes port on which to transmit.
1851 ******************************************************************************/
1852 int wl_send_dma( struct wl_private *lp, struct sk_buff *skb, int port )
1855 DESC_STRCT *desc = NULL;
1856 DESC_STRCT *desc_next = NULL;
1857 /*------------------------------------------------------------------------*/
1859 DBG_FUNC( "wl_send_dma" );
1863 DBG_ERROR( DbgInfo, "Private adapter struct is NULL\n" );
1867 if( lp->dev == NULL )
1869 DBG_ERROR( DbgInfo, "net_device struct in wl_private is NULL\n" );
1873 /* AGAIN, ALL THE QUEUEING DONE HERE IN I/O MODE IS NOT PERFORMED */
1877 DBG_WARNING (DbgInfo, "Nothing to send.\n");
1883 /* Get a free descriptor */
1884 desc = wl_pci_dma_get_tx_packet( lp );
1888 if( lp->netif_queue_on == TRUE ) {
1889 netif_stop_queue( lp->dev );
1890 WL_WDS_NETIF_STOP_QUEUE( lp );
1891 lp->netif_queue_on = FALSE;
1893 dev_kfree_skb( skb );
1898 SET_BUF_CNT( desc, /*HCF_DMA_FD_CNT*/HFS_ADDR_DEST );
1899 SET_BUF_SIZE( desc, HCF_DMA_TX_BUF1_SIZE );
1901 desc_next = desc->next_desc_addr;
1903 if( desc_next->buf_addr == NULL )
1905 DBG_ERROR( DbgInfo, "DMA descriptor buf_addr is NULL\n" );
1909 /* Copy the payload into the DMA packet */
1910 memcpy( desc_next->buf_addr, skb->data, len );
1912 SET_BUF_CNT( desc_next, len );
1913 SET_BUF_SIZE( desc_next, HCF_MAX_PACKET_SIZE );
1915 hcf_dma_tx_put( &( lp->hcfCtx ), desc, 0 );
1917 /* Free the skb and perform queue cleanup, as the buffer was
1918 transmitted successfully */
1919 dev_kfree_skb( skb );
1923 /*============================================================================*/
1925 /*******************************************************************************
1927 *******************************************************************************
1931 * The routine which performs data reception when using busmaster DMA.
1935 * dev - a pointer to the device's net_device structure.
1942 ******************************************************************************/
1943 int wl_rx_dma( struct net_device *dev )
1948 struct sk_buff *skb;
1949 struct wl_private *lp = NULL;
1950 DESC_STRCT *desc, *desc_next;
1951 //CFG_MB_INFO_RANGE2_STRCT x;
1952 /*------------------------------------------------------------------------*/
1955 DBG_PARAM(DbgInfo, "dev", "%s (0x%p)", dev->name, dev);
1957 if((( lp = (struct wl_private *)dev->priv ) != NULL ) &&
1958 !( lp->flags & WVLAN2_UIL_BUSY )) {
1961 if( lp->useRTS == 1 ) {
1962 DBG_PRINT( "RTS: We're getting an Rx...\n" );
1965 #endif /* USE_RTS */
1967 //if( lp->dma.status == 0 )
1969 desc = hcf_dma_rx_get( &( lp->hcfCtx ));
1973 /* Check and see if we rcvd. a WMP frame */
1975 if((( *(hcf_8 *)&desc->buf_addr[HFS_STAT] ) &
1976 ( HFS_STAT_MSG_TYPE | HFS_STAT_ERR )) == HFS_STAT_WMP_MSG )
1978 DBG_TRACE( DbgInfo, "Got a WMP frame\n" );
1980 x.len = sizeof( CFG_MB_INFO_RANGE2_STRCT ) / sizeof( hcf_16 );
1981 x.typ = CFG_MB_INFO;
1982 x.base_typ = CFG_WMP;
1984 x.frag_buf[0].frag_len = GET_BUF_CNT( descp ) / sizeof( hcf_16 );
1985 x.frag_buf[0].frag_addr = (hcf_8 *) descp->buf_addr ;
1986 x.frag_buf[1].frag_len = ( GET_BUF_CNT( descp->next_desc_addr ) + 1 ) / sizeof( hcf_16 );
1987 x.frag_buf[1].frag_addr = (hcf_8 *) descp->next_desc_addr->buf_addr ;
1989 hcf_put_info( &( lp->hcfCtx ), (LTVP)&x );
1993 desc_next = desc->next_desc_addr;
1995 /* Make sure the buffer isn't empty */
1996 if( GET_BUF_CNT( desc ) == 0 ) {
1997 DBG_WARNING( DbgInfo, "Buffer is empty!\n" );
1999 /* Give the descriptor back to the HCF */
2000 hcf_dma_rx_put( &( lp->hcfCtx ), desc );
2004 /* Read the HFS_STAT register from the lookahead buffer */
2005 hfs_stat = (hcf_16)( desc->buf_addr[HFS_STAT/2] );
2007 /* Make sure the frame isn't bad */
2008 if(( hfs_stat & HFS_STAT_ERR ) != HCF_SUCCESS )
2010 DBG_WARNING( DbgInfo, "HFS_STAT_ERROR (0x%x) in Rx Packet\n",
2011 desc->buf_addr[HFS_STAT/2] );
2013 /* Give the descriptor back to the HCF */
2014 hcf_dma_rx_put( &( lp->hcfCtx ), desc );
2018 /* Determine what port this packet is for */
2019 port = ( hfs_stat >> 8 ) & 0x0007;
2020 DBG_RX( DbgInfo, "Rx frame for port %d\n", port );
2022 if(( pktlen = GET_BUF_CNT( desc_next )) != 0 ) {
2023 if(( skb = ALLOC_SKB( pktlen )) != NULL ) {
2032 skb->dev = lp->wds_port[port-1].dev;
2034 #endif /* USE_WDS */
2042 GET_PACKET_DMA( skb->dev, skb, pktlen );
2044 /* Give the descriptor back to the HCF */
2045 hcf_dma_rx_put( &( lp->hcfCtx ), desc );
2050 lp->stats.rx_packets++;
2051 lp->stats.rx_bytes += pktlen;
2056 lp->wds_port[port-1].stats.rx_packets++;
2057 lp->wds_port[port-1].stats.rx_bytes += pktlen;
2059 #endif /* USE_WDS */
2061 dev->last_rx = jiffies;
2064 DBG_ERROR( DbgInfo, "Could not alloc skb\n" );
2068 lp->stats.rx_dropped++;
2073 lp->wds_port[port-1].stats.rx_dropped++;
2075 #endif /* USE_WDS */
2084 /*============================================================================*/
2085 #endif // ENABLE_DMA