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", netdev_mc_count(dev));
1075 netdev_for_each_mc_addr(mclist, dev)
1076 DBG_PRINT( " %s (%d)\n", DbgHwAddr(mclist->dmi_addr),
1077 mclist->dmi_addrlen );
1081 if(!( lp->flags & WVLAN2_UIL_BUSY )) {
1084 if( lp->useRTS == 1 ) {
1085 DBG_TRACE( DbgInfo, "Skipping multicast, in RTS mode\n" );
1087 DBG_LEAVE( DbgInfo );
1090 #endif /* USE_RTS */
1092 wl_lock( lp, &flags );
1093 wl_act_int_off( lp );
1095 if ( CNV_INT_TO_LITTLE( lp->hcfCtx.IFB_FWIdentity.comp_id ) == COMP_ID_FW_STA ) {
1096 if( dev->flags & IFF_PROMISC ) {
1097 /* Enable promiscuous mode */
1098 lp->ltvRecord.len = 2;
1099 lp->ltvRecord.typ = CFG_PROMISCUOUS_MODE;
1100 lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE( 1 );
1101 DBG_PRINT( "Enabling Promiscuous mode (IFF_PROMISC)\n" );
1102 hcf_put_info( &( lp->hcfCtx ), (LTVP)&( lp->ltvRecord ));
1104 else if ((netdev_mc_count(dev) > HCF_MAX_MULTICAST) ||
1105 ( dev->flags & IFF_ALLMULTI )) {
1106 /* Shutting off this filter will enable all multicast frames to
1107 be sent up from the device; however, this is a static RID, so
1108 a call to wl_apply() is needed */
1109 lp->ltvRecord.len = 2;
1110 lp->ltvRecord.typ = CFG_CNF_RX_ALL_GROUP_ADDR;
1111 lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE( 0 );
1112 DBG_PRINT( "Enabling all multicast mode (IFF_ALLMULTI)\n" );
1113 hcf_put_info( &( lp->hcfCtx ), (LTVP)&( lp->ltvRecord ));
1116 else if (!netdev_mc_empty(dev)) {
1117 /* Set the multicast addresses */
1118 lp->ltvRecord.len = ( netdev_mc_count(dev) * 3 ) + 1;
1119 lp->ltvRecord.typ = CFG_GROUP_ADDR;
1122 netdev_for_each_mc_addr(mclist, dev)
1123 memcpy(&(lp->ltvRecord.u.u8[x++ * ETH_ALEN]),
1124 mclist->dmi_addr, ETH_ALEN);
1125 DBG_PRINT( "Setting multicast list\n" );
1126 hcf_put_info( &( lp->hcfCtx ), (LTVP)&( lp->ltvRecord ));
1128 /* Disable promiscuous mode */
1129 lp->ltvRecord.len = 2;
1130 lp->ltvRecord.typ = CFG_PROMISCUOUS_MODE;
1131 lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE( 0 );
1132 DBG_PRINT( "Disabling Promiscuous mode\n" );
1133 hcf_put_info( &( lp->hcfCtx ), (LTVP)&( lp->ltvRecord ));
1135 /* Disable multicast mode */
1136 lp->ltvRecord.len = 2;
1137 lp->ltvRecord.typ = CFG_GROUP_ADDR;
1138 DBG_PRINT( "Disabling Multicast mode\n" );
1139 hcf_put_info( &( lp->hcfCtx ), (LTVP)&( lp->ltvRecord ));
1141 /* Turning on this filter will prevent all multicast frames from
1142 being sent up from the device; however, this is a static RID,
1143 so a call to wl_apply() is needed */
1144 lp->ltvRecord.len = 2;
1145 lp->ltvRecord.typ = CFG_CNF_RX_ALL_GROUP_ADDR;
1146 lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE( 1 );
1147 DBG_PRINT( "Disabling all multicast mode (IFF_ALLMULTI)\n" );
1148 hcf_put_info( &( lp->hcfCtx ), (LTVP)&( lp->ltvRecord ));
1152 wl_act_int_on( lp );
1153 wl_unlock( lp, &flags );
1155 DBG_LEAVE( DbgInfo );
1156 #endif /* HCF_STA */
1158 /*============================================================================*/
1160 #else /* NEW_MULTICAST */
1162 void wl_multicast( struct net_device *dev, int num_addrs, void *addrs )
1164 DBG_FUNC( "wl_multicast");
1167 DBG_PARAM( DbgInfo, "dev", "%s (0x%p)", dev->name, dev );
1168 DBG_PARAM( DbgInfo, "num_addrs", "%d", num_addrs );
1169 DBG_PARAM( DbgInfo, "addrs", "0x%p", addrs );
1171 #error Obsolete set multicast interface!
1173 DBG_LEAVE( DbgInfo );
1175 /*============================================================================*/
1177 #endif /* NEW_MULTICAST */
1179 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,30))
1180 static const struct net_device_ops wl_netdev_ops =
1182 .ndo_start_xmit = &wl_tx_port0,
1184 .ndo_set_config = &wl_config,
1185 .ndo_get_stats = &wl_stats,
1186 .ndo_set_multicast_list = &wl_multicast,
1188 .ndo_init = &wl_insert,
1189 .ndo_open = &wl_adapter_open,
1190 .ndo_stop = &wl_adapter_close,
1191 .ndo_do_ioctl = &wl_ioctl,
1193 .ndo_tx_timeout = &wl_tx_timeout,
1195 #ifdef CONFIG_NET_POLL_CONTROLLER
1196 .ndo_poll_controller = wl_poll,
1199 #endif // (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,30))
1201 /*******************************************************************************
1203 *******************************************************************************
1207 * Create instances of net_device and wl_private for the new adapter
1208 * and register the device's entry points in the net_device structure.
1216 * a pointer to an allocated and initialized net_device struct for this
1219 ******************************************************************************/
1220 struct net_device * wl_device_alloc( void )
1222 struct net_device *dev = NULL;
1223 struct wl_private *lp = NULL;
1224 /*------------------------------------------------------------------------*/
1226 DBG_FUNC( "wl_device_alloc" );
1227 DBG_ENTER( DbgInfo );
1229 /* Alloc a net_device struct */
1230 dev = alloc_etherdev(sizeof(struct wl_private));
1234 /* Initialize the 'next' pointer in the struct. Currently only used for PCI,
1235 but do it here just in case it's used for other buses in the future */
1240 if( dev->mtu > MTU_MAX )
1242 DBG_WARNING( DbgInfo, "%s: MTU set too high, limiting to %d.\n",
1243 dev->name, MTU_MAX );
1247 /* Setup the function table in the device structure. */
1249 dev->wireless_handlers = (struct iw_handler_def *)&wl_iw_handler_def;
1250 lp->wireless_data.spy_data = &lp->spy_data;
1251 dev->wireless_data = &lp->wireless_data;
1253 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,30))
1254 dev->netdev_ops = &wl_netdev_ops;
1256 dev->hard_start_xmit = &wl_tx_port0;
1258 dev->set_config = &wl_config;
1259 dev->get_stats = &wl_stats;
1260 dev->set_multicast_list = &wl_multicast;
1262 dev->init = &wl_insert;
1263 dev->open = &wl_adapter_open;
1264 dev->stop = &wl_adapter_close;
1265 dev->do_ioctl = &wl_ioctl;
1267 dev->tx_timeout = &wl_tx_timeout;
1269 #ifdef CONFIG_NET_POLL_CONTROLLER
1270 dev->poll_controller = wl_poll;
1273 #endif // (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,30))
1275 dev->watchdog_timeo = TX_TIMEOUT;
1277 dev->ethtool_ops = &wl_ethtool_ops;
1279 netif_stop_queue( dev );
1281 /* Allocate virutal devices for WDS support if needed */
1282 WL_WDS_DEVICE_ALLOC( lp );
1284 DBG_LEAVE( DbgInfo );
1286 } // wl_device_alloc
1287 /*============================================================================*/
1289 /*******************************************************************************
1290 * wl_device_dealloc()
1291 *******************************************************************************
1295 * Free instances of net_device and wl_private strcutres for an adapter
1296 * and perform basic cleanup.
1300 * dev - a pointer to the device's net_device structure.
1306 ******************************************************************************/
1307 void wl_device_dealloc( struct net_device *dev )
1309 // struct wl_private *lp = wl_priv(dev);
1310 /*------------------------------------------------------------------------*/
1312 DBG_FUNC( "wl_device_dealloc" );
1313 DBG_ENTER( DbgInfo );
1315 /* Dealloc the WDS ports */
1316 WL_WDS_DEVICE_DEALLOC( lp );
1320 DBG_LEAVE( DbgInfo );
1322 } // wl_device_dealloc
1323 /*============================================================================*/
1325 /*******************************************************************************
1327 *******************************************************************************
1331 * The handler routine for Tx over HCF_PORT_0.
1335 * skb - a pointer to the sk_buff to transmit.
1336 * dev - a pointer to a net_device structure representing HCF_PORT_0.
1342 ******************************************************************************/
1343 int wl_tx_port0( struct sk_buff *skb, struct net_device *dev )
1345 DBG_TX( DbgInfo, "Tx on Port 0\n" );
1347 return wl_tx( skb, dev, HCF_PORT_0 );
1349 return wl_tx_dma( skb, dev, HCF_PORT_0 );
1352 /*============================================================================*/
1356 /*******************************************************************************
1358 *******************************************************************************
1362 * The handler routine for Tx over HCF_PORT_1.
1366 * skb - a pointer to the sk_buff to transmit.
1367 * dev - a pointer to a net_device structure representing HCF_PORT_1.
1373 ******************************************************************************/
1374 int wl_tx_port1( struct sk_buff *skb, struct net_device *dev )
1376 DBG_TX( DbgInfo, "Tx on Port 1\n" );
1377 return wl_tx( skb, dev, HCF_PORT_1 );
1379 /*============================================================================*/
1381 /*******************************************************************************
1383 *******************************************************************************
1387 * The handler routine for Tx over HCF_PORT_2.
1391 * skb - a pointer to the sk_buff to transmit.
1392 * dev - a pointer to a net_device structure representing HCF_PORT_2.
1398 ******************************************************************************/
1399 int wl_tx_port2( struct sk_buff *skb, struct net_device *dev )
1401 DBG_TX( DbgInfo, "Tx on Port 2\n" );
1402 return wl_tx( skb, dev, HCF_PORT_2 );
1404 /*============================================================================*/
1406 /*******************************************************************************
1408 *******************************************************************************
1412 * The handler routine for Tx over HCF_PORT_3.
1416 * skb - a pointer to the sk_buff to transmit.
1417 * dev - a pointer to a net_device structure representing HCF_PORT_3.
1423 ******************************************************************************/
1424 int wl_tx_port3( struct sk_buff *skb, struct net_device *dev )
1426 DBG_TX( DbgInfo, "Tx on Port 3\n" );
1427 return wl_tx( skb, dev, HCF_PORT_3 );
1429 /*============================================================================*/
1431 /*******************************************************************************
1433 *******************************************************************************
1437 * The handler routine for Tx over HCF_PORT_4.
1441 * skb - a pointer to the sk_buff to transmit.
1442 * dev - a pointer to a net_device structure representing HCF_PORT_4.
1448 ******************************************************************************/
1449 int wl_tx_port4( struct sk_buff *skb, struct net_device *dev )
1451 DBG_TX( DbgInfo, "Tx on Port 4\n" );
1452 return wl_tx( skb, dev, HCF_PORT_4 );
1454 /*============================================================================*/
1456 /*******************************************************************************
1458 *******************************************************************************
1462 * The handler routine for Tx over HCF_PORT_5.
1466 * skb - a pointer to the sk_buff to transmit.
1467 * dev - a pointer to a net_device structure representing HCF_PORT_5.
1473 ******************************************************************************/
1474 int wl_tx_port5( struct sk_buff *skb, struct net_device *dev )
1476 DBG_TX( DbgInfo, "Tx on Port 5\n" );
1477 return wl_tx( skb, dev, HCF_PORT_5 );
1479 /*============================================================================*/
1481 /*******************************************************************************
1483 *******************************************************************************
1487 * The handler routine for Tx over HCF_PORT_6.
1491 * skb - a pointer to the sk_buff to transmit.
1492 * dev - a pointer to a net_device structure representing HCF_PORT_6.
1498 ******************************************************************************/
1499 int wl_tx_port6( struct sk_buff *skb, struct net_device *dev )
1501 DBG_TX( DbgInfo, "Tx on Port 6\n" );
1502 return wl_tx( skb, dev, HCF_PORT_6 );
1504 /*============================================================================*/
1506 /*******************************************************************************
1507 * wl_wds_device_alloc()
1508 *******************************************************************************
1512 * Create instances of net_device to represent the WDS ports, and register
1513 * the device's entry points in the net_device structure.
1517 * lp - a pointer to the device's private adapter structure
1521 * N/A, but will place pointers to the allocated and initialized net_device
1522 * structs in the private adapter structure.
1524 ******************************************************************************/
1525 void wl_wds_device_alloc( struct wl_private *lp )
1528 /*------------------------------------------------------------------------*/
1530 DBG_FUNC( "wl_wds_device_alloc" );
1531 DBG_ENTER( DbgInfo );
1533 /* WDS support requires additional net_device structs to be allocated,
1534 so that user space apps can use these virtual devices to specify the
1535 port on which to Tx/Rx */
1536 for( count = 0; count < NUM_WDS_PORTS; count++ ) {
1537 struct net_device *dev_wds = NULL;
1539 dev_wds = kmalloc( sizeof( struct net_device ), GFP_KERNEL );
1540 memset( dev_wds, 0, sizeof( struct net_device ));
1542 ether_setup( dev_wds );
1544 lp->wds_port[count].dev = dev_wds;
1546 /* Re-use wl_init for all the devices, as it currently does nothing, but
1547 is required. Re-use the stats/tx_timeout handler for all as well; the
1548 WDS port which is requesting these operations can be determined by
1549 the net_device pointer. Set the private member of all devices to point
1550 to the same net_device struct; that way, all information gets
1551 funnelled through the one "real" net_device. Name the WDS ports
1553 lp->wds_port[count].dev->init = &wl_init;
1554 lp->wds_port[count].dev->get_stats = &wl_stats;
1555 lp->wds_port[count].dev->tx_timeout = &wl_tx_timeout;
1556 lp->wds_port[count].dev->watchdog_timeo = TX_TIMEOUT;
1557 lp->wds_port[count].dev->priv = lp;
1559 sprintf( lp->wds_port[count].dev->name, "wds%d", count );
1562 /* Register the Tx handlers */
1563 lp->wds_port[0].dev->hard_start_xmit = &wl_tx_port1;
1564 lp->wds_port[1].dev->hard_start_xmit = &wl_tx_port2;
1565 lp->wds_port[2].dev->hard_start_xmit = &wl_tx_port3;
1566 lp->wds_port[3].dev->hard_start_xmit = &wl_tx_port4;
1567 lp->wds_port[4].dev->hard_start_xmit = &wl_tx_port5;
1568 lp->wds_port[5].dev->hard_start_xmit = &wl_tx_port6;
1570 WL_WDS_NETIF_STOP_QUEUE( lp );
1572 DBG_LEAVE( DbgInfo );
1574 } // wl_wds_device_alloc
1575 /*============================================================================*/
1577 /*******************************************************************************
1578 * wl_wds_device_dealloc()
1579 *******************************************************************************
1583 * Free instances of net_device structures used to support WDS.
1587 * lp - a pointer to the device's private adapter structure
1593 ******************************************************************************/
1594 void wl_wds_device_dealloc( struct wl_private *lp )
1597 /*------------------------------------------------------------------------*/
1599 DBG_FUNC( "wl_wds_device_dealloc" );
1600 DBG_ENTER( DbgInfo );
1602 for( count = 0; count < NUM_WDS_PORTS; count++ ) {
1603 struct net_device *dev_wds = NULL;
1605 dev_wds = lp->wds_port[count].dev;
1607 if( dev_wds != NULL ) {
1608 if( dev_wds->flags & IFF_UP ) {
1609 dev_close( dev_wds );
1610 dev_wds->flags &= ~( IFF_UP | IFF_RUNNING );
1614 lp->wds_port[count].dev = NULL;
1618 DBG_LEAVE( DbgInfo );
1620 } // wl_wds_device_dealloc
1621 /*============================================================================*/
1623 /*******************************************************************************
1624 * wl_wds_netif_start_queue()
1625 *******************************************************************************
1629 * Used to start the netif queues of all the "virtual" network devices
1630 * which repesent the WDS ports.
1634 * lp - a pointer to the device's private adapter structure
1640 ******************************************************************************/
1641 void wl_wds_netif_start_queue( struct wl_private *lp )
1644 /*------------------------------------------------------------------------*/
1647 for( count = 0; count < NUM_WDS_PORTS; count++ ) {
1648 if( lp->wds_port[count].is_registered &&
1649 lp->wds_port[count].netif_queue_on == FALSE ) {
1650 netif_start_queue( lp->wds_port[count].dev );
1651 lp->wds_port[count].netif_queue_on = TRUE;
1657 } // wl_wds_netif_start_queue
1658 /*============================================================================*/
1660 /*******************************************************************************
1661 * wl_wds_netif_stop_queue()
1662 *******************************************************************************
1666 * Used to stop the netif queues of all the "virtual" network devices
1667 * which repesent the WDS ports.
1671 * lp - a pointer to the device's private adapter structure
1677 ******************************************************************************/
1678 void wl_wds_netif_stop_queue( struct wl_private *lp )
1681 /*------------------------------------------------------------------------*/
1684 for( count = 0; count < NUM_WDS_PORTS; count++ ) {
1685 if( lp->wds_port[count].is_registered &&
1686 lp->wds_port[count].netif_queue_on == TRUE ) {
1687 netif_stop_queue( lp->wds_port[count].dev );
1688 lp->wds_port[count].netif_queue_on = FALSE;
1694 } // wl_wds_netif_stop_queue
1695 /*============================================================================*/
1697 /*******************************************************************************
1698 * wl_wds_netif_wake_queue()
1699 *******************************************************************************
1703 * Used to wake the netif queues of all the "virtual" network devices
1704 * which repesent the WDS ports.
1708 * lp - a pointer to the device's private adapter structure
1714 ******************************************************************************/
1715 void wl_wds_netif_wake_queue( struct wl_private *lp )
1718 /*------------------------------------------------------------------------*/
1721 for( count = 0; count < NUM_WDS_PORTS; count++ ) {
1722 if( lp->wds_port[count].is_registered &&
1723 lp->wds_port[count].netif_queue_on == FALSE ) {
1724 netif_wake_queue( lp->wds_port[count].dev );
1725 lp->wds_port[count].netif_queue_on = TRUE;
1731 } // wl_wds_netif_wake_queue
1732 /*============================================================================*/
1734 /*******************************************************************************
1735 * wl_wds_netif_carrier_on()
1736 *******************************************************************************
1740 * Used to signal the network layer that carrier is present on all of the
1741 * "virtual" network devices which repesent the WDS ports.
1745 * lp - a pointer to the device's private adapter structure
1751 ******************************************************************************/
1752 void wl_wds_netif_carrier_on( struct wl_private *lp )
1755 /*------------------------------------------------------------------------*/
1758 for( count = 0; count < NUM_WDS_PORTS; count++ ) {
1759 if( lp->wds_port[count].is_registered ) {
1760 netif_carrier_on( lp->wds_port[count].dev );
1766 } // wl_wds_netif_carrier_on
1767 /*============================================================================*/
1769 /*******************************************************************************
1770 * wl_wds_netif_carrier_off()
1771 *******************************************************************************
1775 * Used to signal the network layer that carrier is NOT present on all of
1776 * the "virtual" network devices which repesent the WDS ports.
1780 * lp - a pointer to the device's private adapter structure
1786 ******************************************************************************/
1787 void wl_wds_netif_carrier_off( struct wl_private *lp )
1790 /*------------------------------------------------------------------------*/
1793 for( count = 0; count < NUM_WDS_PORTS; count++ ) {
1794 if( lp->wds_port[count].is_registered ) {
1795 netif_carrier_off( lp->wds_port[count].dev );
1801 } // wl_wds_netif_carrier_off
1802 /*============================================================================*/
1804 #endif /* USE_WDS */
1807 /*******************************************************************************
1809 *******************************************************************************
1813 * The routine which performs data transmits when using busmaster DMA.
1817 * lp - a pointer to the device's wl_private struct.
1818 * skb - a pointer to the network layer's data buffer.
1819 * port - the Hermes port on which to transmit.
1826 ******************************************************************************/
1827 int wl_send_dma( struct wl_private *lp, struct sk_buff *skb, int port )
1830 DESC_STRCT *desc = NULL;
1831 DESC_STRCT *desc_next = NULL;
1832 /*------------------------------------------------------------------------*/
1834 DBG_FUNC( "wl_send_dma" );
1838 DBG_ERROR( DbgInfo, "Private adapter struct is NULL\n" );
1842 if( lp->dev == NULL )
1844 DBG_ERROR( DbgInfo, "net_device struct in wl_private is NULL\n" );
1848 /* AGAIN, ALL THE QUEUEING DONE HERE IN I/O MODE IS NOT PERFORMED */
1852 DBG_WARNING (DbgInfo, "Nothing to send.\n");
1858 /* Get a free descriptor */
1859 desc = wl_pci_dma_get_tx_packet( lp );
1863 if( lp->netif_queue_on == TRUE ) {
1864 netif_stop_queue( lp->dev );
1865 WL_WDS_NETIF_STOP_QUEUE( lp );
1866 lp->netif_queue_on = FALSE;
1868 dev_kfree_skb( skb );
1873 SET_BUF_CNT( desc, /*HCF_DMA_FD_CNT*/HFS_ADDR_DEST );
1874 SET_BUF_SIZE( desc, HCF_DMA_TX_BUF1_SIZE );
1876 desc_next = desc->next_desc_addr;
1878 if( desc_next->buf_addr == NULL )
1880 DBG_ERROR( DbgInfo, "DMA descriptor buf_addr is NULL\n" );
1884 /* Copy the payload into the DMA packet */
1885 memcpy( desc_next->buf_addr, skb->data, len );
1887 SET_BUF_CNT( desc_next, len );
1888 SET_BUF_SIZE( desc_next, HCF_MAX_PACKET_SIZE );
1890 hcf_dma_tx_put( &( lp->hcfCtx ), desc, 0 );
1892 /* Free the skb and perform queue cleanup, as the buffer was
1893 transmitted successfully */
1894 dev_kfree_skb( skb );
1898 /*============================================================================*/
1900 /*******************************************************************************
1902 *******************************************************************************
1906 * The routine which performs data reception when using busmaster DMA.
1910 * dev - a pointer to the device's net_device structure.
1917 ******************************************************************************/
1918 int wl_rx_dma( struct net_device *dev )
1923 struct sk_buff *skb;
1924 struct wl_private *lp = NULL;
1925 DESC_STRCT *desc, *desc_next;
1926 //CFG_MB_INFO_RANGE2_STRCT x;
1927 /*------------------------------------------------------------------------*/
1930 DBG_PARAM(DbgInfo, "dev", "%s (0x%p)", dev->name, dev);
1932 if((( lp = (struct wl_private *)dev->priv ) != NULL ) &&
1933 !( lp->flags & WVLAN2_UIL_BUSY )) {
1936 if( lp->useRTS == 1 ) {
1937 DBG_PRINT( "RTS: We're getting an Rx...\n" );
1940 #endif /* USE_RTS */
1942 //if( lp->dma.status == 0 )
1944 desc = hcf_dma_rx_get( &( lp->hcfCtx ));
1948 /* Check and see if we rcvd. a WMP frame */
1950 if((( *(hcf_8 *)&desc->buf_addr[HFS_STAT] ) &
1951 ( HFS_STAT_MSG_TYPE | HFS_STAT_ERR )) == HFS_STAT_WMP_MSG )
1953 DBG_TRACE( DbgInfo, "Got a WMP frame\n" );
1955 x.len = sizeof( CFG_MB_INFO_RANGE2_STRCT ) / sizeof( hcf_16 );
1956 x.typ = CFG_MB_INFO;
1957 x.base_typ = CFG_WMP;
1959 x.frag_buf[0].frag_len = GET_BUF_CNT( descp ) / sizeof( hcf_16 );
1960 x.frag_buf[0].frag_addr = (hcf_8 *) descp->buf_addr ;
1961 x.frag_buf[1].frag_len = ( GET_BUF_CNT( descp->next_desc_addr ) + 1 ) / sizeof( hcf_16 );
1962 x.frag_buf[1].frag_addr = (hcf_8 *) descp->next_desc_addr->buf_addr ;
1964 hcf_put_info( &( lp->hcfCtx ), (LTVP)&x );
1968 desc_next = desc->next_desc_addr;
1970 /* Make sure the buffer isn't empty */
1971 if( GET_BUF_CNT( desc ) == 0 ) {
1972 DBG_WARNING( DbgInfo, "Buffer is empty!\n" );
1974 /* Give the descriptor back to the HCF */
1975 hcf_dma_rx_put( &( lp->hcfCtx ), desc );
1979 /* Read the HFS_STAT register from the lookahead buffer */
1980 hfs_stat = (hcf_16)( desc->buf_addr[HFS_STAT/2] );
1982 /* Make sure the frame isn't bad */
1983 if(( hfs_stat & HFS_STAT_ERR ) != HCF_SUCCESS )
1985 DBG_WARNING( DbgInfo, "HFS_STAT_ERROR (0x%x) in Rx Packet\n",
1986 desc->buf_addr[HFS_STAT/2] );
1988 /* Give the descriptor back to the HCF */
1989 hcf_dma_rx_put( &( lp->hcfCtx ), desc );
1993 /* Determine what port this packet is for */
1994 port = ( hfs_stat >> 8 ) & 0x0007;
1995 DBG_RX( DbgInfo, "Rx frame for port %d\n", port );
1997 if(( pktlen = GET_BUF_CNT( desc_next )) != 0 ) {
1998 if(( skb = ALLOC_SKB( pktlen )) != NULL ) {
2007 skb->dev = lp->wds_port[port-1].dev;
2009 #endif /* USE_WDS */
2017 GET_PACKET_DMA( skb->dev, skb, pktlen );
2019 /* Give the descriptor back to the HCF */
2020 hcf_dma_rx_put( &( lp->hcfCtx ), desc );
2025 lp->stats.rx_packets++;
2026 lp->stats.rx_bytes += pktlen;
2031 lp->wds_port[port-1].stats.rx_packets++;
2032 lp->wds_port[port-1].stats.rx_bytes += pktlen;
2034 #endif /* USE_WDS */
2036 dev->last_rx = jiffies;
2039 DBG_ERROR( DbgInfo, "Could not alloc skb\n" );
2043 lp->stats.rx_dropped++;
2048 lp->wds_port[port-1].stats.rx_dropped++;
2050 #endif /* USE_WDS */
2059 /*============================================================================*/
2060 #endif // ENABLE_DMA