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 ******************************************************************************/
62 /*******************************************************************************
64 ******************************************************************************/
65 #include <wl_version.h>
67 #include <linux/module.h>
68 #include <linux/types.h>
69 #include <linux/kernel.h>
70 // #include <linux/sched.h>
71 // #include <linux/ptrace.h>
72 // #include <linux/slab.h>
73 // #include <linux/ctype.h>
74 // #include <linux/string.h>
75 //#include <linux/timer.h>
76 // #include <linux/interrupt.h>
77 // #include <linux/in.h>
78 // #include <linux/delay.h>
79 // #include <linux/skbuff.h>
80 // #include <asm/io.h>
81 // #include <asm/system.h>
82 // #include <asm/bitops.h>
84 #include <linux/netdevice.h>
85 #include <linux/ethtool.h>
86 #include <linux/etherdevice.h>
87 // #include <linux/skbuff.h>
88 // #include <linux/if_arp.h>
89 // #include <linux/ioport.h>
95 // #include <hcfdef.h>
98 #include <wl_internal.h>
102 #include <wl_netdev.h>
106 #include <wl_profile.h>
107 #endif /* USE_PROFILE */
111 #endif /* BUS_PCMCIA */
118 /*******************************************************************************
120 ******************************************************************************/
122 extern dbg_info_t *DbgInfo;
127 #define MTU_MAX (HCF_MAX_MSG - ETH_HLEN - 8)
129 #define MTU_MAX (HCF_MAX_MSG - ETH_HLEN)
132 //static int mtu = MTU_MAX;
133 //MODULE_PARM(mtu, "i");
134 //MODULE_PARM_DESC(mtu, "MTU");
136 /*******************************************************************************
138 ******************************************************************************/
139 #define BLOCK_INPUT(buf, len) \
140 desc->buf_addr = buf; \
141 desc->BUF_SIZE = len; \
142 status = hcf_rcv_msg(&(lp->hcfCtx), desc, 0)
144 #define BLOCK_INPUT_DMA(buf, len) memcpy( buf, desc_next->buf_addr, pktlen )
146 /*******************************************************************************
147 * function prototypes
148 ******************************************************************************/
150 /*******************************************************************************
152 *******************************************************************************
156 * We never need to do anything when a "Wireless" device is "initialized"
157 * by the net software, because we only register already-found cards.
161 * dev - a pointer to the device's net_device structure
166 * errno value otherwise
168 ******************************************************************************/
169 int wl_init( struct net_device *dev )
171 // unsigned long flags;
172 // struct wl_private *lp = wl_priv(dev);
173 /*------------------------------------------------------------------------*/
175 DBG_FUNC( "wl_init" );
176 DBG_ENTER( DbgInfo );
178 DBG_PARAM( DbgInfo, "dev", "%s (0x%p)", dev->name, dev );
180 /* Nothing to do, but grab the spinlock anyway just in case we ever need
182 // wl_lock( lp, &flags );
183 // wl_unlock( lp, &flags );
185 DBG_LEAVE( DbgInfo );
188 /*============================================================================*/
190 /*******************************************************************************
192 *******************************************************************************
196 * Implement the SIOCSIFMAP interface.
200 * dev - a pointer to the device's net_device structure
201 * map - a pointer to the device's ifmap structure
208 ******************************************************************************/
209 int wl_config( struct net_device *dev, struct ifmap *map )
211 DBG_FUNC( "wl_config" );
212 DBG_ENTER( DbgInfo );
214 DBG_PARAM( DbgInfo, "dev", "%s (0x%p)", dev->name, dev );
215 DBG_PARAM( DbgInfo, "map", "0x%p", map );
217 /* The only thing we care about here is a port change. Since this not needed,
218 ignore the request. */
219 DBG_TRACE( DbgInfo, "%s: %s called.\n", dev->name, __FUNC__ );
221 DBG_LEAVE( DbgInfo );
224 /*============================================================================*/
226 /*******************************************************************************
228 *******************************************************************************
232 * Return the current device statistics.
236 * dev - a pointer to the device's net_device structure
240 * a pointer to a net_device_stats structure containing the network
243 ******************************************************************************/
244 struct net_device_stats *wl_stats( struct net_device *dev )
250 struct net_device_stats *pStats;
251 struct wl_private *lp = wl_priv(dev);
252 /*------------------------------------------------------------------------*/
254 //DBG_FUNC( "wl_stats" );
255 //DBG_ENTER( DbgInfo );
256 //DBG_PARAM( DbgInfo, "dev", "%s (0x%p)", dev->name, dev );
260 wl_lock( lp, &flags );
263 if( lp->useRTS == 1 ) {
264 wl_unlock( lp, &flags );
266 //DBG_LEAVE( DbgInfo );
271 /* Return the statistics for the appropriate device */
274 for( count = 0; count < NUM_WDS_PORTS; count++ ) {
275 if( dev == lp->wds_port[count].dev ) {
276 pStats = &( lp->wds_port[count].stats );
282 /* If pStats is still NULL, then the device is not a WDS port */
283 if( pStats == NULL ) {
284 pStats = &( lp->stats );
287 wl_unlock( lp, &flags );
289 //DBG_LEAVE( DbgInfo );
293 /*============================================================================*/
295 /*******************************************************************************
297 *******************************************************************************
305 * dev - a pointer to the device's net_device structure
312 ******************************************************************************/
313 int wl_open(struct net_device *dev)
315 int status = HCF_SUCCESS;
316 struct wl_private *lp = wl_priv(dev);
318 /*------------------------------------------------------------------------*/
320 DBG_FUNC( "wl_open" );
321 DBG_ENTER( DbgInfo );
323 wl_lock( lp, &flags );
326 if( lp->useRTS == 1 ) {
327 DBG_TRACE( DbgInfo, "Skipping device open, in RTS mode\n" );
328 wl_unlock( lp, &flags );
329 DBG_LEAVE( DbgInfo );
338 if( lp->portState == WVLAN_PORT_STATE_DISABLED ) {
339 DBG_TRACE( DbgInfo, "Enabling Port 0\n" );
340 status = wl_enable( lp );
342 if( status != HCF_SUCCESS ) {
343 DBG_TRACE( DbgInfo, "Enable port 0 failed: 0x%x\n", status );
347 // Holding the lock too long, make a gap to allow other processes
348 wl_unlock(lp, &flags);
349 wl_lock( lp, &flags );
351 if ( strlen( lp->fw_image_filename ) ) {
352 DBG_TRACE( DbgInfo, ";???? Kludgy way to force a download\n" );
353 status = wl_go( lp );
355 status = wl_apply( lp );
358 // Holding the lock too long, make a gap to allow other processes
359 wl_unlock(lp, &flags);
360 wl_lock( lp, &flags );
362 if( status != HCF_SUCCESS ) {
363 // Unsuccesfull, try reset of the card to recover
364 status = wl_reset( dev );
367 // Holding the lock too long, make a gap to allow other processes
368 wl_unlock(lp, &flags);
369 wl_lock( lp, &flags );
371 if( status == HCF_SUCCESS ) {
372 netif_carrier_on( dev );
373 WL_WDS_NETIF_CARRIER_ON( lp );
375 lp->is_handling_int = WL_HANDLING_INT; // Start handling interrupts
378 netif_start_queue( dev );
379 WL_WDS_NETIF_START_QUEUE( lp );
381 wl_hcf_error( dev, status ); /* Report the error */
382 netif_device_detach( dev ); /* Stop the device and queue */
385 wl_unlock( lp, &flags );
387 DBG_LEAVE( DbgInfo );
390 /*============================================================================*/
392 /*******************************************************************************
394 *******************************************************************************
402 * dev - a pointer to the device's net_device structure
409 ******************************************************************************/
410 int wl_close( struct net_device *dev )
412 struct wl_private *lp = wl_priv(dev);
414 /*------------------------------------------------------------------------*/
416 DBG_FUNC("wl_close");
418 DBG_PARAM(DbgInfo, "dev", "%s (0x%p)", dev->name, dev);
420 /* Mark the adapter as busy */
421 netif_stop_queue( dev );
422 WL_WDS_NETIF_STOP_QUEUE( lp );
424 netif_carrier_off( dev );
425 WL_WDS_NETIF_CARRIER_OFF( lp );
427 /* Shutdown the adapter:
428 Disable adapter interrupts
434 wl_lock( lp, &flags );
436 wl_act_int_off( lp );
437 lp->is_handling_int = WL_NOT_HANDLING_INT; // Stop handling interrupts
440 if( lp->useRTS == 1 ) {
441 DBG_TRACE( DbgInfo, "Skipping device close, in RTS mode\n" );
442 wl_unlock( lp, &flags );
443 DBG_LEAVE( DbgInfo );
448 /* Disable the ports */
451 wl_unlock( lp, &flags );
453 DBG_LEAVE( DbgInfo );
456 /*============================================================================*/
458 static void wl_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
460 strncpy(info->driver, DRIVER_NAME, sizeof(info->driver) - 1);
461 strncpy(info->version, DRV_VERSION_STR, sizeof(info->version) - 1);
462 // strncpy(info.fw_version, priv->fw_name,
463 // sizeof(info.fw_version) - 1);
465 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,20))
466 if (dev->dev.parent) {
467 dev_set_name(dev->dev.parent, "%s", info->bus_info);
468 //strncpy(info->bus_info, dev->dev.parent->bus_id,
469 // sizeof(info->bus_info) - 1);
471 if (dev->class_dev.parent) {
472 sizeof(info->bus_info) - 1);
475 snprintf(info->bus_info, sizeof(info->bus_info) - 1,
477 // "PCMCIA 0x%lx", priv->hw.iobase);
481 static struct ethtool_ops wl_ethtool_ops = {
482 .get_drvinfo = wl_get_drvinfo,
483 .get_link = ethtool_op_get_link,
487 /*******************************************************************************
489 *******************************************************************************
493 * The IOCTL handler for the device.
497 * dev - a pointer to the device's net_device struct.
498 * rq - a pointer to the IOCTL request buffer.
499 * cmd - the IOCTL command code.
504 * errno value otherwise
506 ******************************************************************************/
507 int wl_ioctl( struct net_device *dev, struct ifreq *rq, int cmd )
509 struct wl_private *lp = wl_priv(dev);
512 /*------------------------------------------------------------------------*/
514 DBG_FUNC( "wl_ioctl" );
516 DBG_PARAM(DbgInfo, "dev", "%s (0x%p)", dev->name, dev);
517 DBG_PARAM(DbgInfo, "rq", "0x%p", rq);
518 DBG_PARAM(DbgInfo, "cmd", "0x%04x", cmd);
520 wl_lock( lp, &flags );
522 wl_act_int_off( lp );
525 if( lp->useRTS == 1 ) {
526 /* Handle any RTS IOCTL here */
527 if( cmd == WL_IOCTL_RTS ) {
528 DBG_TRACE( DbgInfo, "IOCTL: WL_IOCTL_RTS\n" );
529 ret = wvlan_rts( (struct rtsreq *)rq, dev->base_addr );
531 DBG_TRACE( DbgInfo, "IOCTL not supported in RTS mode: 0x%X\n", cmd );
535 goto out_act_int_on_unlock;
539 /* Only handle UIL IOCTL requests when the UIL has the system blocked. */
540 if( !(( lp->flags & WVLAN2_UIL_BUSY ) && ( cmd != WVLAN2_IOCTL_UIL ))) {
542 struct uilreq *urq = (struct uilreq *)rq;
546 // ================== Private IOCTLs (up to 16) ==================
548 case WVLAN2_IOCTL_UIL:
549 DBG_TRACE( DbgInfo, "IOCTL: WVLAN2_IOCTL_UIL\n" );
550 ret = wvlan_uil( urq, lp );
555 DBG_TRACE(DbgInfo, "IOCTL CODE NOT SUPPORTED: 0x%X\n", cmd );
560 DBG_WARNING( DbgInfo, "DEVICE IS BUSY, CANNOT PROCESS REQUEST\n" );
565 out_act_int_on_unlock:
569 wl_unlock( lp, &flags );
571 DBG_LEAVE( DbgInfo );
574 /*============================================================================*/
576 #ifdef CONFIG_NET_POLL_CONTROLLER
577 void wl_poll(struct net_device *dev)
579 struct wl_private *lp = wl_priv(dev);
583 wl_lock( lp, &flags );
584 wl_isr(dev->irq, dev, ®s);
585 wl_unlock( lp, &flags );
589 /*******************************************************************************
591 *******************************************************************************
595 * The handler called when, for some reason, a Tx request is not completed.
599 * dev - a pointer to the device's net_device struct.
605 ******************************************************************************/
606 void wl_tx_timeout( struct net_device *dev )
612 struct wl_private *lp = wl_priv(dev);
613 struct net_device_stats *pStats = NULL;
614 /*------------------------------------------------------------------------*/
616 DBG_FUNC( "wl_tx_timeout" );
617 DBG_ENTER( DbgInfo );
619 DBG_WARNING( DbgInfo, "%s: Transmit timeout.\n", dev->name );
621 wl_lock( lp, &flags );
624 if( lp->useRTS == 1 ) {
625 DBG_TRACE( DbgInfo, "Skipping tx_timeout handler, in RTS mode\n" );
626 wl_unlock( lp, &flags );
628 DBG_LEAVE( DbgInfo );
633 /* Figure out which device (the "root" device or WDS port) this timeout
637 for( count = 0; count < NUM_WDS_PORTS; count++ ) {
638 if( dev == lp->wds_port[count].dev ) {
639 pStats = &( lp->wds_port[count].stats );
641 /* Break the loop so that we can use the counter to access WDS
642 information in the private structure */
649 /* If pStats is still NULL, then the device is not a WDS port */
650 if( pStats == NULL ) {
651 pStats = &( lp->stats );
654 /* Accumulate the timeout error */
657 wl_unlock( lp, &flags );
659 DBG_LEAVE( DbgInfo );
662 /*============================================================================*/
664 /*******************************************************************************
666 *******************************************************************************
670 * The routine which performs data transmits.
674 * lp - a pointer to the device's wl_private struct.
681 ******************************************************************************/
682 int wl_send( struct wl_private *lp )
687 WVLAN_LFRAME *txF = NULL;
688 struct list_head *element;
690 /*------------------------------------------------------------------------*/
692 DBG_FUNC( "wl_send" );
695 DBG_ERROR( DbgInfo, "Private adapter struct is NULL\n" );
698 if( lp->dev == NULL ) {
699 DBG_ERROR( DbgInfo, "net_device struct in wl_private is NULL\n" );
703 /* Check for the availability of FIDs; if none are available, don't take any
704 frames off the txQ */
705 if( lp->hcfCtx.IFB_RscInd == 0 ) {
709 /* Reclaim the TxQ Elements and place them back on the free queue */
710 if( !list_empty( &( lp->txQ[0] ))) {
711 element = lp->txQ[0].next;
713 txF = (WVLAN_LFRAME * )list_entry( element, WVLAN_LFRAME, node );
715 lp->txF.skb = txF->frame.skb;
716 lp->txF.port = txF->frame.port;
718 txF->frame.skb = NULL;
721 list_del( &( txF->node ));
722 list_add( element, &( lp->txFree ));
726 if( lp->txQ_count < TX_Q_LOW_WATER_MARK ) {
727 if( lp->netif_queue_on == FALSE ) {
728 DBG_TX( DbgInfo, "Kickstarting Q: %d\n", lp->txQ_count );
729 netif_wake_queue( lp->dev );
730 WL_WDS_NETIF_WAKE_QUEUE( lp );
731 lp->netif_queue_on = TRUE;
737 if( lp->txF.skb == NULL ) {
741 /* If the device has resources (FIDs) available, then Tx the packet */
742 /* Format the TxRequest and send it to the adapter */
743 len = lp->txF.skb->len < ETH_ZLEN ? ETH_ZLEN : lp->txF.skb->len;
745 desc = &( lp->desc_tx );
746 desc->buf_addr = lp->txF.skb->data;
748 desc->next_desc_addr = NULL;
750 status = hcf_send_msg( &( lp->hcfCtx ), desc, lp->txF.port );
752 if( status == HCF_SUCCESS ) {
753 lp->dev->trans_start = jiffies;
755 DBG_TX( DbgInfo, "Transmit...\n" );
757 if( lp->txF.port == HCF_PORT_0 ) {
758 lp->stats.tx_packets++;
759 lp->stats.tx_bytes += lp->txF.skb->len;
765 lp->wds_port[(( lp->txF.port >> 8 ) - 1)].stats.tx_packets++;
766 lp->wds_port[(( lp->txF.port >> 8 ) - 1)].stats.tx_bytes += lp->txF.skb->len;
771 /* Free the skb and perform queue cleanup, as the buffer was
772 transmitted successfully */
773 dev_kfree_skb( lp->txF.skb );
781 /*============================================================================*/
783 /*******************************************************************************
785 *******************************************************************************
789 * The Tx handler function for the network layer.
793 * skb - a pointer to the sk_buff structure containing the data to transfer.
794 * dev - a pointer to the device's net_device structure.
801 ******************************************************************************/
802 int wl_tx( struct sk_buff *skb, struct net_device *dev, int port )
805 struct wl_private *lp = wl_priv(dev);
806 WVLAN_LFRAME *txF = NULL;
807 struct list_head *element;
808 /*------------------------------------------------------------------------*/
812 /* Grab the spinlock */
813 wl_lock( lp, &flags );
815 if( lp->flags & WVLAN2_UIL_BUSY ) {
816 DBG_WARNING( DbgInfo, "UIL has device blocked\n" );
817 /* Start dropping packets here??? */
818 wl_unlock( lp, &flags );
823 if( lp->useRTS == 1 ) {
824 DBG_PRINT( "RTS: we're getting a Tx...\n" );
825 wl_unlock( lp, &flags );
831 /* Get an element from the queue */
832 element = lp->txFree.next;
833 txF = (WVLAN_LFRAME *)list_entry( element, WVLAN_LFRAME, node );
835 DBG_ERROR( DbgInfo, "Problem with list_entry\n" );
836 wl_unlock( lp, &flags );
839 /* Fill out the frame */
840 txF->frame.skb = skb;
841 txF->frame.port = port;
842 /* Move the frame to the txQ */
843 /* NOTE: Here's where we would do priority queueing */
844 list_del( &( txF->node ));
845 list_add( &( txF->node ), &( lp->txQ[0] ));
848 if( lp->txQ_count >= DEFAULT_NUM_TX_FRAMES ) {
849 DBG_TX( DbgInfo, "Q Full: %d\n", lp->txQ_count );
850 if( lp->netif_queue_on == TRUE ) {
851 netif_stop_queue( lp->dev );
852 WL_WDS_NETIF_STOP_QUEUE( lp );
853 lp->netif_queue_on = FALSE;
857 wl_act_int_off( lp ); /* Disable Interrupts */
859 /* Send the data to the hardware using the appropriate method */
862 wl_send_dma( lp, skb, port );
869 /* Re-enable Interrupts, release the spinlock and return */
871 wl_unlock( lp, &flags );
874 /*============================================================================*/
876 /*******************************************************************************
878 *******************************************************************************
882 * The routine which performs data reception.
886 * dev - a pointer to the device's net_device structure.
893 ******************************************************************************/
894 int wl_rx(struct net_device *dev)
898 struct wl_private *lp = wl_priv(dev);
903 /*------------------------------------------------------------------------*/
906 DBG_PARAM(DbgInfo, "dev", "%s (0x%p)", dev->name, dev);
908 if(!( lp->flags & WVLAN2_UIL_BUSY )) {
911 if( lp->useRTS == 1 ) {
912 DBG_PRINT( "RTS: We're getting an Rx...\n" );
917 /* Read the HFS_STAT register from the lookahead buffer */
918 hfs_stat = (hcf_16)(( lp->lookAheadBuf[HFS_STAT] ) |
919 ( lp->lookAheadBuf[HFS_STAT + 1] << 8 ));
921 /* Make sure the frame isn't bad */
922 if(( hfs_stat & HFS_STAT_ERR ) != HCF_SUCCESS ) {
923 DBG_WARNING( DbgInfo, "HFS_STAT_ERROR (0x%x) in Rx Packet\n",
924 lp->lookAheadBuf[HFS_STAT] );
928 /* Determine what port this packet is for */
929 port = ( hfs_stat >> 8 ) & 0x0007;
930 DBG_RX( DbgInfo, "Rx frame for port %d\n", port );
932 if(( pktlen = lp->hcfCtx.IFB_RxLen ) != 0 ) {
933 if(( skb = ALLOC_SKB( pktlen )) != NULL ) {
934 /* Set the netdev based on the port */
943 skb->dev = lp->wds_port[port-1].dev;
953 desc = &( lp->desc_rx );
955 desc->next_desc_addr = NULL;
958 #define BLOCK_INPUT(buf, len) \
959 desc->buf_addr = buf; \
960 desc->BUF_SIZE = len; \
961 status = hcf_rcv_msg(&(lp->hcfCtx), desc, 0)
964 GET_PACKET( skb->dev, skb, pktlen );
966 if( status == HCF_SUCCESS ) {
970 lp->stats.rx_packets++;
971 lp->stats.rx_bytes += pktlen;
976 lp->wds_port[port-1].stats.rx_packets++;
977 lp->wds_port[port-1].stats.rx_bytes += pktlen;
981 dev->last_rx = jiffies;
985 if( lp->spydata.spy_number > 0 ) {
986 char *srcaddr = skb->mac.raw + MAC_ADDR_SIZE;
988 wl_spy_gather( dev, srcaddr );
990 #endif /* WIRELESS_SPY */
991 #endif /* WIRELESS_EXT */
993 DBG_ERROR( DbgInfo, "Rx request to card FAILED\n" );
996 lp->stats.rx_dropped++;
1001 lp->wds_port[port-1].stats.rx_dropped++;
1003 #endif /* USE_WDS */
1005 dev_kfree_skb( skb );
1008 DBG_ERROR( DbgInfo, "Could not alloc skb\n" );
1011 lp->stats.rx_dropped++;
1016 lp->wds_port[port-1].stats.rx_dropped++;
1018 #endif /* USE_WDS */
1025 /*============================================================================*/
1027 /*******************************************************************************
1029 *******************************************************************************
1033 * Function to handle multicast packets
1037 * dev - a pointer to the device's net_device structure.
1043 ******************************************************************************/
1044 #ifdef NEW_MULTICAST
1046 void wl_multicast( struct net_device *dev )
1048 #if 1 //;? (HCF_TYPE) & HCF_TYPE_STA //;?should we return an error status in AP mode
1049 //;?seems reasonable that even an AP-only driver could afford this small additional footprint
1052 struct dev_mc_list *mclist;
1053 struct wl_private *lp = wl_priv(dev);
1054 unsigned long flags;
1055 /*------------------------------------------------------------------------*/
1057 DBG_FUNC( "wl_multicast" );
1058 DBG_ENTER( DbgInfo );
1059 DBG_PARAM( DbgInfo, "dev", "%s (0x%p)", dev->name, dev );
1061 if( !wl_adapter_is_open( dev )) {
1062 DBG_LEAVE( DbgInfo );
1067 if( DBG_FLAGS( DbgInfo ) & DBG_PARAM_ON ) {
1068 DBG_PRINT(" flags: %s%s%s\n",
1069 ( dev->flags & IFF_PROMISC ) ? "Promiscous " : "",
1070 ( dev->flags & IFF_MULTICAST ) ? "Multicast " : "",
1071 ( dev->flags & IFF_ALLMULTI ) ? "All-Multicast" : "" );
1073 DBG_PRINT( " mc_count: %d\n", dev->mc_count );
1075 for( x = 0, mclist = dev->mc_list; mclist && x < dev->mc_count;
1076 x++, mclist = mclist->next ) {
1077 DBG_PRINT( " %s (%d)\n", DbgHwAddr(mclist->dmi_addr),
1078 mclist->dmi_addrlen );
1083 if(!( lp->flags & WVLAN2_UIL_BUSY )) {
1086 if( lp->useRTS == 1 ) {
1087 DBG_TRACE( DbgInfo, "Skipping multicast, in RTS mode\n" );
1089 DBG_LEAVE( DbgInfo );
1092 #endif /* USE_RTS */
1094 wl_lock( lp, &flags );
1095 wl_act_int_off( lp );
1097 if ( CNV_INT_TO_LITTLE( lp->hcfCtx.IFB_FWIdentity.comp_id ) == COMP_ID_FW_STA ) {
1098 if( dev->flags & IFF_PROMISC ) {
1099 /* Enable promiscuous mode */
1100 lp->ltvRecord.len = 2;
1101 lp->ltvRecord.typ = CFG_PROMISCUOUS_MODE;
1102 lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE( 1 );
1103 DBG_PRINT( "Enabling Promiscuous mode (IFF_PROMISC)\n" );
1104 hcf_put_info( &( lp->hcfCtx ), (LTVP)&( lp->ltvRecord ));
1106 else if(( dev->mc_count > HCF_MAX_MULTICAST ) ||
1107 ( dev->flags & IFF_ALLMULTI )) {
1108 /* Shutting off this filter will enable all multicast frames to
1109 be sent up from the device; however, this is a static RID, so
1110 a call to wl_apply() is needed */
1111 lp->ltvRecord.len = 2;
1112 lp->ltvRecord.typ = CFG_CNF_RX_ALL_GROUP_ADDR;
1113 lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE( 0 );
1114 DBG_PRINT( "Enabling all multicast mode (IFF_ALLMULTI)\n" );
1115 hcf_put_info( &( lp->hcfCtx ), (LTVP)&( lp->ltvRecord ));
1118 else if( dev->mc_count != 0 ) {
1119 /* Set the multicast addresses */
1120 lp->ltvRecord.len = ( dev->mc_count * 3 ) + 1;
1121 lp->ltvRecord.typ = CFG_GROUP_ADDR;
1123 for( x = 0, mclist = dev->mc_list;
1124 ( x < dev->mc_count ) && ( mclist != NULL );
1125 x++, mclist = mclist->next ) {
1126 memcpy( &( lp->ltvRecord.u.u8[x * ETH_ALEN] ),
1127 mclist->dmi_addr, ETH_ALEN );
1129 DBG_PRINT( "Setting multicast list\n" );
1130 hcf_put_info( &( lp->hcfCtx ), (LTVP)&( lp->ltvRecord ));
1132 /* Disable promiscuous mode */
1133 lp->ltvRecord.len = 2;
1134 lp->ltvRecord.typ = CFG_PROMISCUOUS_MODE;
1135 lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE( 0 );
1136 DBG_PRINT( "Disabling Promiscuous mode\n" );
1137 hcf_put_info( &( lp->hcfCtx ), (LTVP)&( lp->ltvRecord ));
1139 /* Disable multicast mode */
1140 lp->ltvRecord.len = 2;
1141 lp->ltvRecord.typ = CFG_GROUP_ADDR;
1142 DBG_PRINT( "Disabling Multicast mode\n" );
1143 hcf_put_info( &( lp->hcfCtx ), (LTVP)&( lp->ltvRecord ));
1145 /* Turning on this filter will prevent all multicast frames from
1146 being sent up from the device; however, this is a static RID,
1147 so a call to wl_apply() is needed */
1148 lp->ltvRecord.len = 2;
1149 lp->ltvRecord.typ = CFG_CNF_RX_ALL_GROUP_ADDR;
1150 lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE( 1 );
1151 DBG_PRINT( "Disabling all multicast mode (IFF_ALLMULTI)\n" );
1152 hcf_put_info( &( lp->hcfCtx ), (LTVP)&( lp->ltvRecord ));
1156 wl_act_int_on( lp );
1157 wl_unlock( lp, &flags );
1159 DBG_LEAVE( DbgInfo );
1160 #endif /* HCF_STA */
1162 /*============================================================================*/
1164 #else /* NEW_MULTICAST */
1166 void wl_multicast( struct net_device *dev, int num_addrs, void *addrs )
1168 DBG_FUNC( "wl_multicast");
1171 DBG_PARAM( DbgInfo, "dev", "%s (0x%p)", dev->name, dev );
1172 DBG_PARAM( DbgInfo, "num_addrs", "%d", num_addrs );
1173 DBG_PARAM( DbgInfo, "addrs", "0x%p", addrs );
1175 #error Obsolete set multicast interface!
1177 DBG_LEAVE( DbgInfo );
1179 /*============================================================================*/
1181 #endif /* NEW_MULTICAST */
1183 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,30))
1184 static const struct net_device_ops wl_netdev_ops =
1186 .ndo_start_xmit = &wl_tx_port0,
1188 .ndo_set_config = &wl_config,
1189 .ndo_get_stats = &wl_stats,
1190 .ndo_set_multicast_list = &wl_multicast,
1192 .ndo_init = &wl_insert,
1193 .ndo_open = &wl_adapter_open,
1194 .ndo_stop = &wl_adapter_close,
1195 .ndo_do_ioctl = &wl_ioctl,
1197 #ifdef HAVE_TX_TIMEOUT
1198 .ndo_tx_timeout = &wl_tx_timeout,
1201 #ifdef CONFIG_NET_POLL_CONTROLLER
1202 .ndo_poll_controller = wl_poll,
1205 #endif // (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,30))
1207 /*******************************************************************************
1209 *******************************************************************************
1213 * Create instances of net_device and wl_private for the new adapter
1214 * and register the device's entry points in the net_device structure.
1222 * a pointer to an allocated and initialized net_device struct for this
1225 ******************************************************************************/
1226 struct net_device * wl_device_alloc( void )
1228 struct net_device *dev = NULL;
1229 struct wl_private *lp = NULL;
1230 /*------------------------------------------------------------------------*/
1232 DBG_FUNC( "wl_device_alloc" );
1233 DBG_ENTER( DbgInfo );
1235 /* Alloc a net_device struct */
1236 dev = alloc_etherdev(sizeof(struct wl_private));
1240 /* Initialize the 'next' pointer in the struct. Currently only used for PCI,
1241 but do it here just in case it's used for other buses in the future */
1246 if( dev->mtu > MTU_MAX )
1248 DBG_WARNING( DbgInfo, "%s: MTU set too high, limiting to %d.\n",
1249 dev->name, MTU_MAX );
1253 /* Setup the function table in the device structure. */
1255 dev->wireless_handlers = (struct iw_handler_def *)&wl_iw_handler_def;
1256 lp->wireless_data.spy_data = &lp->spy_data;
1257 dev->wireless_data = &lp->wireless_data;
1259 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,30))
1260 dev->netdev_ops = &wl_netdev_ops;
1262 dev->hard_start_xmit = &wl_tx_port0;
1264 dev->set_config = &wl_config;
1265 dev->get_stats = &wl_stats;
1266 dev->set_multicast_list = &wl_multicast;
1268 dev->init = &wl_insert;
1269 dev->open = &wl_adapter_open;
1270 dev->stop = &wl_adapter_close;
1271 dev->do_ioctl = &wl_ioctl;
1273 #ifdef HAVE_TX_TIMEOUT
1274 dev->tx_timeout = &wl_tx_timeout;
1277 #ifdef CONFIG_NET_POLL_CONTROLLER
1278 dev->poll_controller = wl_poll;
1281 #endif // (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,30))
1283 #ifdef HAVE_TX_TIMEOUT
1284 dev->watchdog_timeo = TX_TIMEOUT;
1287 dev->ethtool_ops = &wl_ethtool_ops;
1289 netif_stop_queue( dev );
1291 /* Allocate virutal devices for WDS support if needed */
1292 WL_WDS_DEVICE_ALLOC( lp );
1294 DBG_LEAVE( DbgInfo );
1296 } // wl_device_alloc
1297 /*============================================================================*/
1299 /*******************************************************************************
1300 * wl_device_dealloc()
1301 *******************************************************************************
1305 * Free instances of net_device and wl_private strcutres for an adapter
1306 * and perform basic cleanup.
1310 * dev - a pointer to the device's net_device structure.
1316 ******************************************************************************/
1317 void wl_device_dealloc( struct net_device *dev )
1319 // struct wl_private *lp = wl_priv(dev);
1320 /*------------------------------------------------------------------------*/
1322 DBG_FUNC( "wl_device_dealloc" );
1323 DBG_ENTER( DbgInfo );
1325 /* Dealloc the WDS ports */
1326 WL_WDS_DEVICE_DEALLOC( lp );
1330 DBG_LEAVE( DbgInfo );
1332 } // wl_device_dealloc
1333 /*============================================================================*/
1335 /*******************************************************************************
1337 *******************************************************************************
1341 * The handler routine for Tx over HCF_PORT_0.
1345 * skb - a pointer to the sk_buff to transmit.
1346 * dev - a pointer to a net_device structure representing HCF_PORT_0.
1352 ******************************************************************************/
1353 int wl_tx_port0( struct sk_buff *skb, struct net_device *dev )
1355 DBG_TX( DbgInfo, "Tx on Port 0\n" );
1357 return wl_tx( skb, dev, HCF_PORT_0 );
1359 return wl_tx_dma( skb, dev, HCF_PORT_0 );
1362 /*============================================================================*/
1366 /*******************************************************************************
1368 *******************************************************************************
1372 * The handler routine for Tx over HCF_PORT_1.
1376 * skb - a pointer to the sk_buff to transmit.
1377 * dev - a pointer to a net_device structure representing HCF_PORT_1.
1383 ******************************************************************************/
1384 int wl_tx_port1( struct sk_buff *skb, struct net_device *dev )
1386 DBG_TX( DbgInfo, "Tx on Port 1\n" );
1387 return wl_tx( skb, dev, HCF_PORT_1 );
1389 /*============================================================================*/
1391 /*******************************************************************************
1393 *******************************************************************************
1397 * The handler routine for Tx over HCF_PORT_2.
1401 * skb - a pointer to the sk_buff to transmit.
1402 * dev - a pointer to a net_device structure representing HCF_PORT_2.
1408 ******************************************************************************/
1409 int wl_tx_port2( struct sk_buff *skb, struct net_device *dev )
1411 DBG_TX( DbgInfo, "Tx on Port 2\n" );
1412 return wl_tx( skb, dev, HCF_PORT_2 );
1414 /*============================================================================*/
1416 /*******************************************************************************
1418 *******************************************************************************
1422 * The handler routine for Tx over HCF_PORT_3.
1426 * skb - a pointer to the sk_buff to transmit.
1427 * dev - a pointer to a net_device structure representing HCF_PORT_3.
1433 ******************************************************************************/
1434 int wl_tx_port3( struct sk_buff *skb, struct net_device *dev )
1436 DBG_TX( DbgInfo, "Tx on Port 3\n" );
1437 return wl_tx( skb, dev, HCF_PORT_3 );
1439 /*============================================================================*/
1441 /*******************************************************************************
1443 *******************************************************************************
1447 * The handler routine for Tx over HCF_PORT_4.
1451 * skb - a pointer to the sk_buff to transmit.
1452 * dev - a pointer to a net_device structure representing HCF_PORT_4.
1458 ******************************************************************************/
1459 int wl_tx_port4( struct sk_buff *skb, struct net_device *dev )
1461 DBG_TX( DbgInfo, "Tx on Port 4\n" );
1462 return wl_tx( skb, dev, HCF_PORT_4 );
1464 /*============================================================================*/
1466 /*******************************************************************************
1468 *******************************************************************************
1472 * The handler routine for Tx over HCF_PORT_5.
1476 * skb - a pointer to the sk_buff to transmit.
1477 * dev - a pointer to a net_device structure representing HCF_PORT_5.
1483 ******************************************************************************/
1484 int wl_tx_port5( struct sk_buff *skb, struct net_device *dev )
1486 DBG_TX( DbgInfo, "Tx on Port 5\n" );
1487 return wl_tx( skb, dev, HCF_PORT_5 );
1489 /*============================================================================*/
1491 /*******************************************************************************
1493 *******************************************************************************
1497 * The handler routine for Tx over HCF_PORT_6.
1501 * skb - a pointer to the sk_buff to transmit.
1502 * dev - a pointer to a net_device structure representing HCF_PORT_6.
1508 ******************************************************************************/
1509 int wl_tx_port6( struct sk_buff *skb, struct net_device *dev )
1511 DBG_TX( DbgInfo, "Tx on Port 6\n" );
1512 return wl_tx( skb, dev, HCF_PORT_6 );
1514 /*============================================================================*/
1516 /*******************************************************************************
1517 * wl_wds_device_alloc()
1518 *******************************************************************************
1522 * Create instances of net_device to represent the WDS ports, and register
1523 * the device's entry points in the net_device structure.
1527 * lp - a pointer to the device's private adapter structure
1531 * N/A, but will place pointers to the allocated and initialized net_device
1532 * structs in the private adapter structure.
1534 ******************************************************************************/
1535 void wl_wds_device_alloc( struct wl_private *lp )
1538 /*------------------------------------------------------------------------*/
1540 DBG_FUNC( "wl_wds_device_alloc" );
1541 DBG_ENTER( DbgInfo );
1543 /* WDS support requires additional net_device structs to be allocated,
1544 so that user space apps can use these virtual devices to specify the
1545 port on which to Tx/Rx */
1546 for( count = 0; count < NUM_WDS_PORTS; count++ ) {
1547 struct net_device *dev_wds = NULL;
1549 dev_wds = kmalloc( sizeof( struct net_device ), GFP_KERNEL );
1550 memset( dev_wds, 0, sizeof( struct net_device ));
1552 ether_setup( dev_wds );
1554 lp->wds_port[count].dev = dev_wds;
1556 /* Re-use wl_init for all the devices, as it currently does nothing, but
1557 is required. Re-use the stats/tx_timeout handler for all as well; the
1558 WDS port which is requesting these operations can be determined by
1559 the net_device pointer. Set the private member of all devices to point
1560 to the same net_device struct; that way, all information gets
1561 funnelled through the one "real" net_device. Name the WDS ports
1563 lp->wds_port[count].dev->init = &wl_init;
1564 lp->wds_port[count].dev->get_stats = &wl_stats;
1565 lp->wds_port[count].dev->tx_timeout = &wl_tx_timeout;
1566 lp->wds_port[count].dev->watchdog_timeo = TX_TIMEOUT;
1567 lp->wds_port[count].dev->priv = lp;
1569 sprintf( lp->wds_port[count].dev->name, "wds%d", count );
1572 /* Register the Tx handlers */
1573 lp->wds_port[0].dev->hard_start_xmit = &wl_tx_port1;
1574 lp->wds_port[1].dev->hard_start_xmit = &wl_tx_port2;
1575 lp->wds_port[2].dev->hard_start_xmit = &wl_tx_port3;
1576 lp->wds_port[3].dev->hard_start_xmit = &wl_tx_port4;
1577 lp->wds_port[4].dev->hard_start_xmit = &wl_tx_port5;
1578 lp->wds_port[5].dev->hard_start_xmit = &wl_tx_port6;
1580 WL_WDS_NETIF_STOP_QUEUE( lp );
1582 DBG_LEAVE( DbgInfo );
1584 } // wl_wds_device_alloc
1585 /*============================================================================*/
1587 /*******************************************************************************
1588 * wl_wds_device_dealloc()
1589 *******************************************************************************
1593 * Free instances of net_device structures used to support WDS.
1597 * lp - a pointer to the device's private adapter structure
1603 ******************************************************************************/
1604 void wl_wds_device_dealloc( struct wl_private *lp )
1607 /*------------------------------------------------------------------------*/
1609 DBG_FUNC( "wl_wds_device_dealloc" );
1610 DBG_ENTER( DbgInfo );
1612 for( count = 0; count < NUM_WDS_PORTS; count++ ) {
1613 struct net_device *dev_wds = NULL;
1615 dev_wds = lp->wds_port[count].dev;
1617 if( dev_wds != NULL ) {
1618 if( dev_wds->flags & IFF_UP ) {
1619 dev_close( dev_wds );
1620 dev_wds->flags &= ~( IFF_UP | IFF_RUNNING );
1624 lp->wds_port[count].dev = NULL;
1628 DBG_LEAVE( DbgInfo );
1630 } // wl_wds_device_dealloc
1631 /*============================================================================*/
1633 /*******************************************************************************
1634 * wl_wds_netif_start_queue()
1635 *******************************************************************************
1639 * Used to start the netif queues of all the "virtual" network devices
1640 * which repesent the WDS ports.
1644 * lp - a pointer to the device's private adapter structure
1650 ******************************************************************************/
1651 void wl_wds_netif_start_queue( struct wl_private *lp )
1654 /*------------------------------------------------------------------------*/
1657 for( count = 0; count < NUM_WDS_PORTS; count++ ) {
1658 if( lp->wds_port[count].is_registered &&
1659 lp->wds_port[count].netif_queue_on == FALSE ) {
1660 netif_start_queue( lp->wds_port[count].dev );
1661 lp->wds_port[count].netif_queue_on = TRUE;
1667 } // wl_wds_netif_start_queue
1668 /*============================================================================*/
1670 /*******************************************************************************
1671 * wl_wds_netif_stop_queue()
1672 *******************************************************************************
1676 * Used to stop the netif queues of all the "virtual" network devices
1677 * which repesent the WDS ports.
1681 * lp - a pointer to the device's private adapter structure
1687 ******************************************************************************/
1688 void wl_wds_netif_stop_queue( struct wl_private *lp )
1691 /*------------------------------------------------------------------------*/
1694 for( count = 0; count < NUM_WDS_PORTS; count++ ) {
1695 if( lp->wds_port[count].is_registered &&
1696 lp->wds_port[count].netif_queue_on == TRUE ) {
1697 netif_stop_queue( lp->wds_port[count].dev );
1698 lp->wds_port[count].netif_queue_on = FALSE;
1704 } // wl_wds_netif_stop_queue
1705 /*============================================================================*/
1707 /*******************************************************************************
1708 * wl_wds_netif_wake_queue()
1709 *******************************************************************************
1713 * Used to wake the netif queues of all the "virtual" network devices
1714 * which repesent the WDS ports.
1718 * lp - a pointer to the device's private adapter structure
1724 ******************************************************************************/
1725 void wl_wds_netif_wake_queue( struct wl_private *lp )
1728 /*------------------------------------------------------------------------*/
1731 for( count = 0; count < NUM_WDS_PORTS; count++ ) {
1732 if( lp->wds_port[count].is_registered &&
1733 lp->wds_port[count].netif_queue_on == FALSE ) {
1734 netif_wake_queue( lp->wds_port[count].dev );
1735 lp->wds_port[count].netif_queue_on = TRUE;
1741 } // wl_wds_netif_wake_queue
1742 /*============================================================================*/
1744 /*******************************************************************************
1745 * wl_wds_netif_carrier_on()
1746 *******************************************************************************
1750 * Used to signal the network layer that carrier is present on all of the
1751 * "virtual" network devices which repesent the WDS ports.
1755 * lp - a pointer to the device's private adapter structure
1761 ******************************************************************************/
1762 void wl_wds_netif_carrier_on( struct wl_private *lp )
1765 /*------------------------------------------------------------------------*/
1768 for( count = 0; count < NUM_WDS_PORTS; count++ ) {
1769 if( lp->wds_port[count].is_registered ) {
1770 netif_carrier_on( lp->wds_port[count].dev );
1776 } // wl_wds_netif_carrier_on
1777 /*============================================================================*/
1779 /*******************************************************************************
1780 * wl_wds_netif_carrier_off()
1781 *******************************************************************************
1785 * Used to signal the network layer that carrier is NOT present on all of
1786 * the "virtual" network devices which repesent the WDS ports.
1790 * lp - a pointer to the device's private adapter structure
1796 ******************************************************************************/
1797 void wl_wds_netif_carrier_off( struct wl_private *lp )
1800 /*------------------------------------------------------------------------*/
1803 for( count = 0; count < NUM_WDS_PORTS; count++ ) {
1804 if( lp->wds_port[count].is_registered ) {
1805 netif_carrier_off( lp->wds_port[count].dev );
1811 } // wl_wds_netif_carrier_off
1812 /*============================================================================*/
1814 #endif /* USE_WDS */
1817 /*******************************************************************************
1819 *******************************************************************************
1823 * The routine which performs data transmits when using busmaster DMA.
1827 * lp - a pointer to the device's wl_private struct.
1828 * skb - a pointer to the network layer's data buffer.
1829 * port - the Hermes port on which to transmit.
1836 ******************************************************************************/
1837 int wl_send_dma( struct wl_private *lp, struct sk_buff *skb, int port )
1840 DESC_STRCT *desc = NULL;
1841 DESC_STRCT *desc_next = NULL;
1842 /*------------------------------------------------------------------------*/
1844 DBG_FUNC( "wl_send_dma" );
1848 DBG_ERROR( DbgInfo, "Private adapter struct is NULL\n" );
1852 if( lp->dev == NULL )
1854 DBG_ERROR( DbgInfo, "net_device struct in wl_private is NULL\n" );
1858 /* AGAIN, ALL THE QUEUEING DONE HERE IN I/O MODE IS NOT PERFORMED */
1862 DBG_WARNING (DbgInfo, "Nothing to send.\n");
1868 /* Get a free descriptor */
1869 desc = wl_pci_dma_get_tx_packet( lp );
1873 if( lp->netif_queue_on == TRUE ) {
1874 netif_stop_queue( lp->dev );
1875 WL_WDS_NETIF_STOP_QUEUE( lp );
1876 lp->netif_queue_on = FALSE;
1878 dev_kfree_skb( skb );
1883 SET_BUF_CNT( desc, /*HCF_DMA_FD_CNT*/HFS_ADDR_DEST );
1884 SET_BUF_SIZE( desc, HCF_DMA_TX_BUF1_SIZE );
1886 desc_next = desc->next_desc_addr;
1888 if( desc_next->buf_addr == NULL )
1890 DBG_ERROR( DbgInfo, "DMA descriptor buf_addr is NULL\n" );
1894 /* Copy the payload into the DMA packet */
1895 memcpy( desc_next->buf_addr, skb->data, len );
1897 SET_BUF_CNT( desc_next, len );
1898 SET_BUF_SIZE( desc_next, HCF_MAX_PACKET_SIZE );
1900 hcf_dma_tx_put( &( lp->hcfCtx ), desc, 0 );
1902 /* Free the skb and perform queue cleanup, as the buffer was
1903 transmitted successfully */
1904 dev_kfree_skb( skb );
1908 /*============================================================================*/
1910 /*******************************************************************************
1912 *******************************************************************************
1916 * The routine which performs data reception when using busmaster DMA.
1920 * dev - a pointer to the device's net_device structure.
1927 ******************************************************************************/
1928 int wl_rx_dma( struct net_device *dev )
1933 struct sk_buff *skb;
1934 struct wl_private *lp = NULL;
1935 DESC_STRCT *desc, *desc_next;
1936 //CFG_MB_INFO_RANGE2_STRCT x;
1937 /*------------------------------------------------------------------------*/
1940 DBG_PARAM(DbgInfo, "dev", "%s (0x%p)", dev->name, dev);
1942 if((( lp = (struct wl_private *)dev->priv ) != NULL ) &&
1943 !( lp->flags & WVLAN2_UIL_BUSY )) {
1946 if( lp->useRTS == 1 ) {
1947 DBG_PRINT( "RTS: We're getting an Rx...\n" );
1950 #endif /* USE_RTS */
1952 //if( lp->dma.status == 0 )
1954 desc = hcf_dma_rx_get( &( lp->hcfCtx ));
1958 /* Check and see if we rcvd. a WMP frame */
1960 if((( *(hcf_8 *)&desc->buf_addr[HFS_STAT] ) &
1961 ( HFS_STAT_MSG_TYPE | HFS_STAT_ERR )) == HFS_STAT_WMP_MSG )
1963 DBG_TRACE( DbgInfo, "Got a WMP frame\n" );
1965 x.len = sizeof( CFG_MB_INFO_RANGE2_STRCT ) / sizeof( hcf_16 );
1966 x.typ = CFG_MB_INFO;
1967 x.base_typ = CFG_WMP;
1969 x.frag_buf[0].frag_len = GET_BUF_CNT( descp ) / sizeof( hcf_16 );
1970 x.frag_buf[0].frag_addr = (hcf_8 *) descp->buf_addr ;
1971 x.frag_buf[1].frag_len = ( GET_BUF_CNT( descp->next_desc_addr ) + 1 ) / sizeof( hcf_16 );
1972 x.frag_buf[1].frag_addr = (hcf_8 *) descp->next_desc_addr->buf_addr ;
1974 hcf_put_info( &( lp->hcfCtx ), (LTVP)&x );
1978 desc_next = desc->next_desc_addr;
1980 /* Make sure the buffer isn't empty */
1981 if( GET_BUF_CNT( desc ) == 0 ) {
1982 DBG_WARNING( DbgInfo, "Buffer is empty!\n" );
1984 /* Give the descriptor back to the HCF */
1985 hcf_dma_rx_put( &( lp->hcfCtx ), desc );
1989 /* Read the HFS_STAT register from the lookahead buffer */
1990 hfs_stat = (hcf_16)( desc->buf_addr[HFS_STAT/2] );
1992 /* Make sure the frame isn't bad */
1993 if(( hfs_stat & HFS_STAT_ERR ) != HCF_SUCCESS )
1995 DBG_WARNING( DbgInfo, "HFS_STAT_ERROR (0x%x) in Rx Packet\n",
1996 desc->buf_addr[HFS_STAT/2] );
1998 /* Give the descriptor back to the HCF */
1999 hcf_dma_rx_put( &( lp->hcfCtx ), desc );
2003 /* Determine what port this packet is for */
2004 port = ( hfs_stat >> 8 ) & 0x0007;
2005 DBG_RX( DbgInfo, "Rx frame for port %d\n", port );
2007 if(( pktlen = GET_BUF_CNT( desc_next )) != 0 ) {
2008 if(( skb = ALLOC_SKB( pktlen )) != NULL ) {
2017 skb->dev = lp->wds_port[port-1].dev;
2019 #endif /* USE_WDS */
2027 GET_PACKET_DMA( skb->dev, skb, pktlen );
2029 /* Give the descriptor back to the HCF */
2030 hcf_dma_rx_put( &( lp->hcfCtx ), desc );
2035 lp->stats.rx_packets++;
2036 lp->stats.rx_bytes += pktlen;
2041 lp->wds_port[port-1].stats.rx_packets++;
2042 lp->wds_port[port-1].stats.rx_bytes += pktlen;
2044 #endif /* USE_WDS */
2046 dev->last_rx = jiffies;
2049 DBG_ERROR( DbgInfo, "Could not alloc skb\n" );
2053 lp->stats.rx_dropped++;
2058 lp->wds_port[port-1].stats.rx_dropped++;
2060 #endif /* USE_WDS */
2069 /*============================================================================*/
2070 #endif // ENABLE_DMA