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/slab.h>
69 #include <linux/types.h>
70 #include <linux/kernel.h>
71 // #include <linux/sched.h>
72 // #include <linux/ptrace.h>
73 // #include <linux/slab.h>
74 // #include <linux/ctype.h>
75 // #include <linux/string.h>
76 //#include <linux/timer.h>
77 // #include <linux/interrupt.h>
78 // #include <linux/in.h>
79 // #include <linux/delay.h>
80 // #include <linux/skbuff.h>
81 // #include <asm/io.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_ENTER( DbgInfo );
177 DBG_PARAM( DbgInfo, "dev", "%s (0x%p)", dev->name, dev );
179 /* Nothing to do, but grab the spinlock anyway just in case we ever need
181 // wl_lock( lp, &flags );
182 // wl_unlock( lp, &flags );
184 DBG_LEAVE( DbgInfo );
187 /*============================================================================*/
189 /*******************************************************************************
191 *******************************************************************************
195 * Implement the SIOCSIFMAP interface.
199 * dev - a pointer to the device's net_device structure
200 * map - a pointer to the device's ifmap structure
207 ******************************************************************************/
208 int wl_config( struct net_device *dev, struct ifmap *map )
210 DBG_ENTER( DbgInfo );
212 DBG_PARAM( DbgInfo, "dev", "%s (0x%p)", dev->name, dev );
213 DBG_PARAM( DbgInfo, "map", "0x%p", map );
215 /* The only thing we care about here is a port change. Since this not needed,
216 ignore the request. */
217 DBG_TRACE(DbgInfo, "%s: %s called.\n", dev->name, __func__);
219 DBG_LEAVE( DbgInfo );
222 /*============================================================================*/
224 /*******************************************************************************
226 *******************************************************************************
230 * Return the current device statistics.
234 * dev - a pointer to the device's net_device structure
238 * a pointer to a net_device_stats structure containing the network
241 ******************************************************************************/
242 struct net_device_stats *wl_stats( struct net_device *dev )
248 struct net_device_stats *pStats;
249 struct wl_private *lp = wl_priv(dev);
250 /*------------------------------------------------------------------------*/
252 //DBG_ENTER( DbgInfo );
253 //DBG_PARAM( DbgInfo, "dev", "%s (0x%p)", dev->name, dev );
257 wl_lock( lp, &flags );
260 if( lp->useRTS == 1 ) {
261 wl_unlock( lp, &flags );
263 //DBG_LEAVE( DbgInfo );
268 /* Return the statistics for the appropriate device */
271 for( count = 0; count < NUM_WDS_PORTS; count++ ) {
272 if( dev == lp->wds_port[count].dev ) {
273 pStats = &( lp->wds_port[count].stats );
279 /* If pStats is still NULL, then the device is not a WDS port */
280 if( pStats == NULL ) {
281 pStats = &( lp->stats );
284 wl_unlock( lp, &flags );
286 //DBG_LEAVE( DbgInfo );
290 /*============================================================================*/
292 /*******************************************************************************
294 *******************************************************************************
302 * dev - a pointer to the device's net_device structure
309 ******************************************************************************/
310 int wl_open(struct net_device *dev)
312 int status = HCF_SUCCESS;
313 struct wl_private *lp = wl_priv(dev);
315 /*------------------------------------------------------------------------*/
317 DBG_ENTER( DbgInfo );
319 wl_lock( lp, &flags );
322 if( lp->useRTS == 1 ) {
323 DBG_TRACE( DbgInfo, "Skipping device open, in RTS mode\n" );
324 wl_unlock( lp, &flags );
325 DBG_LEAVE( DbgInfo );
334 if( lp->portState == WVLAN_PORT_STATE_DISABLED ) {
335 DBG_TRACE( DbgInfo, "Enabling Port 0\n" );
336 status = wl_enable( lp );
338 if( status != HCF_SUCCESS ) {
339 DBG_TRACE( DbgInfo, "Enable port 0 failed: 0x%x\n", status );
343 // Holding the lock too long, make a gap to allow other processes
344 wl_unlock(lp, &flags);
345 wl_lock( lp, &flags );
347 if ( strlen( lp->fw_image_filename ) ) {
348 DBG_TRACE( DbgInfo, ";???? Kludgy way to force a download\n" );
349 status = wl_go( lp );
351 status = wl_apply( lp );
354 // Holding the lock too long, make a gap to allow other processes
355 wl_unlock(lp, &flags);
356 wl_lock( lp, &flags );
358 if( status != HCF_SUCCESS ) {
359 // Unsuccessful, try reset of the card to recover
360 status = wl_reset( dev );
363 // Holding the lock too long, make a gap to allow other processes
364 wl_unlock(lp, &flags);
365 wl_lock( lp, &flags );
367 if( status == HCF_SUCCESS ) {
368 netif_carrier_on( dev );
369 WL_WDS_NETIF_CARRIER_ON( lp );
371 lp->is_handling_int = WL_HANDLING_INT; // Start handling interrupts
374 netif_start_queue( dev );
375 WL_WDS_NETIF_START_QUEUE( lp );
377 wl_hcf_error( dev, status ); /* Report the error */
378 netif_device_detach( dev ); /* Stop the device and queue */
381 wl_unlock( lp, &flags );
383 DBG_LEAVE( DbgInfo );
386 /*============================================================================*/
388 /*******************************************************************************
390 *******************************************************************************
398 * dev - a pointer to the device's net_device structure
405 ******************************************************************************/
406 int wl_close( struct net_device *dev )
408 struct wl_private *lp = wl_priv(dev);
410 /*------------------------------------------------------------------------*/
413 DBG_PARAM(DbgInfo, "dev", "%s (0x%p)", dev->name, dev);
415 /* Mark the adapter as busy */
416 netif_stop_queue( dev );
417 WL_WDS_NETIF_STOP_QUEUE( lp );
419 netif_carrier_off( dev );
420 WL_WDS_NETIF_CARRIER_OFF( lp );
422 /* Shutdown the adapter:
423 Disable adapter interrupts
429 wl_lock( lp, &flags );
431 wl_act_int_off( lp );
432 lp->is_handling_int = WL_NOT_HANDLING_INT; // Stop handling interrupts
435 if( lp->useRTS == 1 ) {
436 DBG_TRACE( DbgInfo, "Skipping device close, in RTS mode\n" );
437 wl_unlock( lp, &flags );
438 DBG_LEAVE( DbgInfo );
443 /* Disable the ports */
446 wl_unlock( lp, &flags );
448 DBG_LEAVE( DbgInfo );
451 /*============================================================================*/
453 static void wl_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
455 strlcpy(info->driver, DRIVER_NAME, sizeof(info->driver));
456 strlcpy(info->version, DRV_VERSION_STR, sizeof(info->version));
457 // strlcpy(info.fw_version, priv->fw_name,
458 // sizeof(info.fw_version));
460 if (dev->dev.parent) {
461 dev_set_name(dev->dev.parent, "%s", info->bus_info);
462 //strlcpy(info->bus_info, dev->dev.parent->bus_id,
463 // sizeof(info->bus_info));
465 snprintf(info->bus_info, sizeof(info->bus_info),
467 // "PCMCIA 0x%lx", priv->hw.iobase);
471 static struct ethtool_ops wl_ethtool_ops = {
472 .get_drvinfo = wl_get_drvinfo,
473 .get_link = ethtool_op_get_link,
477 /*******************************************************************************
479 *******************************************************************************
483 * The IOCTL handler for the device.
487 * dev - a pointer to the device's net_device struct.
488 * rq - a pointer to the IOCTL request buffer.
489 * cmd - the IOCTL command code.
494 * errno value otherwise
496 ******************************************************************************/
497 int wl_ioctl( struct net_device *dev, struct ifreq *rq, int cmd )
499 struct wl_private *lp = wl_priv(dev);
502 /*------------------------------------------------------------------------*/
505 DBG_PARAM(DbgInfo, "dev", "%s (0x%p)", dev->name, dev);
506 DBG_PARAM(DbgInfo, "rq", "0x%p", rq);
507 DBG_PARAM(DbgInfo, "cmd", "0x%04x", cmd);
509 wl_lock( lp, &flags );
511 wl_act_int_off( lp );
514 if( lp->useRTS == 1 ) {
515 /* Handle any RTS IOCTL here */
516 if( cmd == WL_IOCTL_RTS ) {
517 DBG_TRACE( DbgInfo, "IOCTL: WL_IOCTL_RTS\n" );
518 ret = wvlan_rts( (struct rtsreq *)rq, dev->base_addr );
520 DBG_TRACE( DbgInfo, "IOCTL not supported in RTS mode: 0x%X\n", cmd );
524 goto out_act_int_on_unlock;
528 /* Only handle UIL IOCTL requests when the UIL has the system blocked. */
529 if( !(( lp->flags & WVLAN2_UIL_BUSY ) && ( cmd != WVLAN2_IOCTL_UIL ))) {
531 struct uilreq *urq = (struct uilreq *)rq;
535 // ================== Private IOCTLs (up to 16) ==================
537 case WVLAN2_IOCTL_UIL:
538 DBG_TRACE( DbgInfo, "IOCTL: WVLAN2_IOCTL_UIL\n" );
539 ret = wvlan_uil( urq, lp );
544 DBG_TRACE(DbgInfo, "IOCTL CODE NOT SUPPORTED: 0x%X\n", cmd );
549 DBG_WARNING( DbgInfo, "DEVICE IS BUSY, CANNOT PROCESS REQUEST\n" );
554 out_act_int_on_unlock:
558 wl_unlock( lp, &flags );
560 DBG_LEAVE( DbgInfo );
563 /*============================================================================*/
565 #ifdef CONFIG_NET_POLL_CONTROLLER
566 void wl_poll(struct net_device *dev)
568 struct wl_private *lp = wl_priv(dev);
572 wl_lock( lp, &flags );
573 wl_isr(dev->irq, dev, ®s);
574 wl_unlock( lp, &flags );
578 /*******************************************************************************
580 *******************************************************************************
584 * The handler called when, for some reason, a Tx request is not completed.
588 * dev - a pointer to the device's net_device struct.
594 ******************************************************************************/
595 void wl_tx_timeout( struct net_device *dev )
601 struct wl_private *lp = wl_priv(dev);
602 struct net_device_stats *pStats = NULL;
603 /*------------------------------------------------------------------------*/
605 DBG_ENTER( DbgInfo );
607 DBG_WARNING( DbgInfo, "%s: Transmit timeout.\n", dev->name );
609 wl_lock( lp, &flags );
612 if( lp->useRTS == 1 ) {
613 DBG_TRACE( DbgInfo, "Skipping tx_timeout handler, in RTS mode\n" );
614 wl_unlock( lp, &flags );
616 DBG_LEAVE( DbgInfo );
621 /* Figure out which device (the "root" device or WDS port) this timeout
625 for( count = 0; count < NUM_WDS_PORTS; count++ ) {
626 if( dev == lp->wds_port[count].dev ) {
627 pStats = &( lp->wds_port[count].stats );
629 /* Break the loop so that we can use the counter to access WDS
630 information in the private structure */
637 /* If pStats is still NULL, then the device is not a WDS port */
638 if( pStats == NULL ) {
639 pStats = &( lp->stats );
642 /* Accumulate the timeout error */
645 wl_unlock( lp, &flags );
647 DBG_LEAVE( DbgInfo );
649 /*============================================================================*/
651 /*******************************************************************************
653 *******************************************************************************
657 * The routine which performs data transmits.
661 * lp - a pointer to the device's wl_private struct.
668 ******************************************************************************/
669 int wl_send( struct wl_private *lp )
674 WVLAN_LFRAME *txF = NULL;
675 struct list_head *element;
677 /*------------------------------------------------------------------------*/
680 DBG_ERROR( DbgInfo, "Private adapter struct is NULL\n" );
683 if( lp->dev == NULL ) {
684 DBG_ERROR( DbgInfo, "net_device struct in wl_private is NULL\n" );
688 /* Check for the availability of FIDs; if none are available, don't take any
689 frames off the txQ */
690 if( lp->hcfCtx.IFB_RscInd == 0 ) {
694 /* Reclaim the TxQ Elements and place them back on the free queue */
695 if( !list_empty( &( lp->txQ[0] ))) {
696 element = lp->txQ[0].next;
698 txF = (WVLAN_LFRAME * )list_entry( element, WVLAN_LFRAME, node );
700 lp->txF.skb = txF->frame.skb;
701 lp->txF.port = txF->frame.port;
703 txF->frame.skb = NULL;
706 list_del( &( txF->node ));
707 list_add( element, &( lp->txFree ));
711 if( lp->txQ_count < TX_Q_LOW_WATER_MARK ) {
712 if( lp->netif_queue_on == FALSE ) {
713 DBG_TX( DbgInfo, "Kickstarting Q: %d\n", lp->txQ_count );
714 netif_wake_queue( lp->dev );
715 WL_WDS_NETIF_WAKE_QUEUE( lp );
716 lp->netif_queue_on = TRUE;
722 if( lp->txF.skb == NULL ) {
726 /* If the device has resources (FIDs) available, then Tx the packet */
727 /* Format the TxRequest and send it to the adapter */
728 len = lp->txF.skb->len < ETH_ZLEN ? ETH_ZLEN : lp->txF.skb->len;
730 desc = &( lp->desc_tx );
731 desc->buf_addr = lp->txF.skb->data;
733 desc->next_desc_addr = NULL;
735 status = hcf_send_msg( &( lp->hcfCtx ), desc, lp->txF.port );
737 if( status == HCF_SUCCESS ) {
738 lp->dev->trans_start = jiffies;
740 DBG_TX( DbgInfo, "Transmit...\n" );
742 if( lp->txF.port == HCF_PORT_0 ) {
743 lp->stats.tx_packets++;
744 lp->stats.tx_bytes += lp->txF.skb->len;
750 lp->wds_port[(( lp->txF.port >> 8 ) - 1)].stats.tx_packets++;
751 lp->wds_port[(( lp->txF.port >> 8 ) - 1)].stats.tx_bytes += lp->txF.skb->len;
756 /* Free the skb and perform queue cleanup, as the buffer was
757 transmitted successfully */
758 dev_kfree_skb( lp->txF.skb );
766 /*============================================================================*/
768 /*******************************************************************************
770 *******************************************************************************
774 * The Tx handler function for the network layer.
778 * skb - a pointer to the sk_buff structure containing the data to transfer.
779 * dev - a pointer to the device's net_device structure.
786 ******************************************************************************/
787 int wl_tx( struct sk_buff *skb, struct net_device *dev, int port )
790 struct wl_private *lp = wl_priv(dev);
791 WVLAN_LFRAME *txF = NULL;
792 struct list_head *element;
793 /*------------------------------------------------------------------------*/
795 /* Grab the spinlock */
796 wl_lock( lp, &flags );
798 if( lp->flags & WVLAN2_UIL_BUSY ) {
799 DBG_WARNING( DbgInfo, "UIL has device blocked\n" );
800 /* Start dropping packets here??? */
801 wl_unlock( lp, &flags );
806 if( lp->useRTS == 1 ) {
807 DBG_PRINT( "RTS: we're getting a Tx...\n" );
808 wl_unlock( lp, &flags );
814 /* Get an element from the queue */
815 element = lp->txFree.next;
816 txF = (WVLAN_LFRAME *)list_entry( element, WVLAN_LFRAME, node );
818 DBG_ERROR( DbgInfo, "Problem with list_entry\n" );
819 wl_unlock( lp, &flags );
822 /* Fill out the frame */
823 txF->frame.skb = skb;
824 txF->frame.port = port;
825 /* Move the frame to the txQ */
826 /* NOTE: Here's where we would do priority queueing */
827 list_move(&(txF->node), &(lp->txQ[0]));
830 if( lp->txQ_count >= DEFAULT_NUM_TX_FRAMES ) {
831 DBG_TX( DbgInfo, "Q Full: %d\n", lp->txQ_count );
832 if( lp->netif_queue_on == TRUE ) {
833 netif_stop_queue( lp->dev );
834 WL_WDS_NETIF_STOP_QUEUE( lp );
835 lp->netif_queue_on = FALSE;
839 wl_act_int_off( lp ); /* Disable Interrupts */
841 /* Send the data to the hardware using the appropriate method */
844 wl_send_dma( lp, skb, port );
851 /* Re-enable Interrupts, release the spinlock and return */
853 wl_unlock( lp, &flags );
856 /*============================================================================*/
858 /*******************************************************************************
860 *******************************************************************************
864 * The routine which performs data reception.
868 * dev - a pointer to the device's net_device structure.
875 ******************************************************************************/
876 int wl_rx(struct net_device *dev)
880 struct wl_private *lp = wl_priv(dev);
885 /*------------------------------------------------------------------------*/
887 DBG_PARAM(DbgInfo, "dev", "%s (0x%p)", dev->name, dev);
889 if(!( lp->flags & WVLAN2_UIL_BUSY )) {
892 if( lp->useRTS == 1 ) {
893 DBG_PRINT( "RTS: We're getting an Rx...\n" );
898 /* Read the HFS_STAT register from the lookahead buffer */
899 hfs_stat = (hcf_16)(( lp->lookAheadBuf[HFS_STAT] ) |
900 ( lp->lookAheadBuf[HFS_STAT + 1] << 8 ));
902 /* Make sure the frame isn't bad */
903 if(( hfs_stat & HFS_STAT_ERR ) != HCF_SUCCESS ) {
904 DBG_WARNING( DbgInfo, "HFS_STAT_ERROR (0x%x) in Rx Packet\n",
905 lp->lookAheadBuf[HFS_STAT] );
909 /* Determine what port this packet is for */
910 port = ( hfs_stat >> 8 ) & 0x0007;
911 DBG_RX( DbgInfo, "Rx frame for port %d\n", port );
913 pktlen = lp->hcfCtx.IFB_RxLen;
915 skb = ALLOC_SKB(pktlen);
917 /* Set the netdev based on the port */
926 skb->dev = lp->wds_port[port-1].dev;
936 desc = &( lp->desc_rx );
938 desc->next_desc_addr = NULL;
941 #define BLOCK_INPUT(buf, len) \
942 desc->buf_addr = buf; \
943 desc->BUF_SIZE = len; \
944 status = hcf_rcv_msg(&(lp->hcfCtx), desc, 0)
947 GET_PACKET( skb->dev, skb, pktlen );
949 if( status == HCF_SUCCESS ) {
953 lp->stats.rx_packets++;
954 lp->stats.rx_bytes += pktlen;
959 lp->wds_port[port-1].stats.rx_packets++;
960 lp->wds_port[port-1].stats.rx_bytes += pktlen;
964 dev->last_rx = jiffies;
968 if( lp->spydata.spy_number > 0 ) {
969 char *srcaddr = skb->mac.raw + MAC_ADDR_SIZE;
971 wl_spy_gather( dev, srcaddr );
973 #endif /* WIRELESS_SPY */
974 #endif /* WIRELESS_EXT */
976 DBG_ERROR( DbgInfo, "Rx request to card FAILED\n" );
979 lp->stats.rx_dropped++;
984 lp->wds_port[port-1].stats.rx_dropped++;
988 dev_kfree_skb( skb );
991 DBG_ERROR( DbgInfo, "Could not alloc skb\n" );
994 lp->stats.rx_dropped++;
999 lp->wds_port[port-1].stats.rx_dropped++;
1001 #endif /* USE_WDS */
1008 /*============================================================================*/
1010 /*******************************************************************************
1012 *******************************************************************************
1016 * Function to handle multicast packets
1020 * dev - a pointer to the device's net_device structure.
1026 ******************************************************************************/
1027 #ifdef NEW_MULTICAST
1029 void wl_multicast( struct net_device *dev )
1031 #if 1 //;? (HCF_TYPE) & HCF_TYPE_STA //;?should we return an error status in AP mode
1032 //;?seems reasonable that even an AP-only driver could afford this small additional footprint
1035 struct netdev_hw_addr *ha;
1036 struct wl_private *lp = wl_priv(dev);
1037 unsigned long flags;
1038 /*------------------------------------------------------------------------*/
1040 DBG_ENTER( DbgInfo );
1041 DBG_PARAM( DbgInfo, "dev", "%s (0x%p)", dev->name, dev );
1043 if( !wl_adapter_is_open( dev )) {
1044 DBG_LEAVE( DbgInfo );
1049 if( DBG_FLAGS( DbgInfo ) & DBG_PARAM_ON ) {
1050 DBG_PRINT(" flags: %s%s%s\n",
1051 ( dev->flags & IFF_PROMISC ) ? "Promiscuous " : "",
1052 ( dev->flags & IFF_MULTICAST ) ? "Multicast " : "",
1053 ( dev->flags & IFF_ALLMULTI ) ? "All-Multicast" : "" );
1055 DBG_PRINT( " mc_count: %d\n", netdev_mc_count(dev));
1057 netdev_for_each_mc_addr(ha, dev)
1058 DBG_PRINT(" %pM (%d)\n", ha->addr, dev->addr_len);
1062 if(!( lp->flags & WVLAN2_UIL_BUSY )) {
1065 if( lp->useRTS == 1 ) {
1066 DBG_TRACE( DbgInfo, "Skipping multicast, in RTS mode\n" );
1068 DBG_LEAVE( DbgInfo );
1071 #endif /* USE_RTS */
1073 wl_lock( lp, &flags );
1074 wl_act_int_off( lp );
1076 if ( CNV_INT_TO_LITTLE( lp->hcfCtx.IFB_FWIdentity.comp_id ) == COMP_ID_FW_STA ) {
1077 if( dev->flags & IFF_PROMISC ) {
1078 /* Enable promiscuous mode */
1079 lp->ltvRecord.len = 2;
1080 lp->ltvRecord.typ = CFG_PROMISCUOUS_MODE;
1081 lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE( 1 );
1082 DBG_PRINT( "Enabling Promiscuous mode (IFF_PROMISC)\n" );
1083 hcf_put_info( &( lp->hcfCtx ), (LTVP)&( lp->ltvRecord ));
1085 else if ((netdev_mc_count(dev) > HCF_MAX_MULTICAST) ||
1086 ( dev->flags & IFF_ALLMULTI )) {
1087 /* Shutting off this filter will enable all multicast frames to
1088 be sent up from the device; however, this is a static RID, so
1089 a call to wl_apply() is needed */
1090 lp->ltvRecord.len = 2;
1091 lp->ltvRecord.typ = CFG_CNF_RX_ALL_GROUP_ADDR;
1092 lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE( 0 );
1093 DBG_PRINT( "Enabling all multicast mode (IFF_ALLMULTI)\n" );
1094 hcf_put_info( &( lp->hcfCtx ), (LTVP)&( lp->ltvRecord ));
1097 else if (!netdev_mc_empty(dev)) {
1098 /* Set the multicast addresses */
1099 lp->ltvRecord.len = ( netdev_mc_count(dev) * 3 ) + 1;
1100 lp->ltvRecord.typ = CFG_GROUP_ADDR;
1103 netdev_for_each_mc_addr(ha, dev)
1104 memcpy(&(lp->ltvRecord.u.u8[x++ * ETH_ALEN]),
1105 ha->addr, ETH_ALEN);
1106 DBG_PRINT( "Setting multicast list\n" );
1107 hcf_put_info( &( lp->hcfCtx ), (LTVP)&( lp->ltvRecord ));
1109 /* Disable promiscuous mode */
1110 lp->ltvRecord.len = 2;
1111 lp->ltvRecord.typ = CFG_PROMISCUOUS_MODE;
1112 lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE( 0 );
1113 DBG_PRINT( "Disabling Promiscuous mode\n" );
1114 hcf_put_info( &( lp->hcfCtx ), (LTVP)&( lp->ltvRecord ));
1116 /* Disable multicast mode */
1117 lp->ltvRecord.len = 2;
1118 lp->ltvRecord.typ = CFG_GROUP_ADDR;
1119 DBG_PRINT( "Disabling Multicast mode\n" );
1120 hcf_put_info( &( lp->hcfCtx ), (LTVP)&( lp->ltvRecord ));
1122 /* Turning on this filter will prevent all multicast frames from
1123 being sent up from the device; however, this is a static RID,
1124 so a call to wl_apply() is needed */
1125 lp->ltvRecord.len = 2;
1126 lp->ltvRecord.typ = CFG_CNF_RX_ALL_GROUP_ADDR;
1127 lp->ltvRecord.u.u16[0] = CNV_INT_TO_LITTLE( 1 );
1128 DBG_PRINT( "Disabling all multicast mode (IFF_ALLMULTI)\n" );
1129 hcf_put_info( &( lp->hcfCtx ), (LTVP)&( lp->ltvRecord ));
1133 wl_act_int_on( lp );
1134 wl_unlock( lp, &flags );
1136 DBG_LEAVE( DbgInfo );
1137 #endif /* HCF_STA */
1139 /*============================================================================*/
1141 #else /* NEW_MULTICAST */
1143 void wl_multicast( struct net_device *dev, int num_addrs, void *addrs )
1147 DBG_PARAM( DbgInfo, "dev", "%s (0x%p)", dev->name, dev );
1148 DBG_PARAM( DbgInfo, "num_addrs", "%d", num_addrs );
1149 DBG_PARAM( DbgInfo, "addrs", "0x%p", addrs );
1151 #error Obsolete set multicast interface!
1153 DBG_LEAVE( DbgInfo );
1155 /*============================================================================*/
1157 #endif /* NEW_MULTICAST */
1159 static const struct net_device_ops wl_netdev_ops =
1161 .ndo_start_xmit = &wl_tx_port0,
1163 .ndo_set_config = &wl_config,
1164 .ndo_get_stats = &wl_stats,
1165 .ndo_set_rx_mode = &wl_multicast,
1167 .ndo_init = &wl_insert,
1168 .ndo_open = &wl_adapter_open,
1169 .ndo_stop = &wl_adapter_close,
1170 .ndo_do_ioctl = &wl_ioctl,
1172 .ndo_tx_timeout = &wl_tx_timeout,
1174 #ifdef CONFIG_NET_POLL_CONTROLLER
1175 .ndo_poll_controller = wl_poll,
1179 /*******************************************************************************
1181 *******************************************************************************
1185 * Create instances of net_device and wl_private for the new adapter
1186 * and register the device's entry points in the net_device structure.
1194 * a pointer to an allocated and initialized net_device struct for this
1197 ******************************************************************************/
1198 struct net_device * wl_device_alloc( void )
1200 struct net_device *dev = NULL;
1201 struct wl_private *lp = NULL;
1202 /*------------------------------------------------------------------------*/
1204 DBG_ENTER( DbgInfo );
1206 /* Alloc a net_device struct */
1207 dev = alloc_etherdev(sizeof(struct wl_private));
1211 /* Initialize the 'next' pointer in the struct. Currently only used for PCI,
1212 but do it here just in case it's used for other buses in the future */
1217 if( dev->mtu > MTU_MAX )
1219 DBG_WARNING( DbgInfo, "%s: MTU set too high, limiting to %d.\n",
1220 dev->name, MTU_MAX );
1224 /* Setup the function table in the device structure. */
1226 dev->wireless_handlers = (struct iw_handler_def *)&wl_iw_handler_def;
1227 lp->wireless_data.spy_data = &lp->spy_data;
1228 dev->wireless_data = &lp->wireless_data;
1230 dev->netdev_ops = &wl_netdev_ops;
1232 dev->watchdog_timeo = TX_TIMEOUT;
1234 dev->ethtool_ops = &wl_ethtool_ops;
1236 netif_stop_queue( dev );
1238 /* Allocate virtual devices for WDS support if needed */
1239 WL_WDS_DEVICE_ALLOC( lp );
1241 DBG_LEAVE( DbgInfo );
1243 } // wl_device_alloc
1244 /*============================================================================*/
1246 /*******************************************************************************
1247 * wl_device_dealloc()
1248 *******************************************************************************
1252 * Free instances of net_device and wl_private strcutres for an adapter
1253 * and perform basic cleanup.
1257 * dev - a pointer to the device's net_device structure.
1263 ******************************************************************************/
1264 void wl_device_dealloc( struct net_device *dev )
1266 // struct wl_private *lp = wl_priv(dev);
1267 /*------------------------------------------------------------------------*/
1269 DBG_ENTER( DbgInfo );
1271 /* Dealloc the WDS ports */
1272 WL_WDS_DEVICE_DEALLOC( lp );
1276 DBG_LEAVE( DbgInfo );
1277 } // wl_device_dealloc
1278 /*============================================================================*/
1280 /*******************************************************************************
1282 *******************************************************************************
1286 * The handler routine for Tx over HCF_PORT_0.
1290 * skb - a pointer to the sk_buff to transmit.
1291 * dev - a pointer to a net_device structure representing HCF_PORT_0.
1297 ******************************************************************************/
1298 int wl_tx_port0( struct sk_buff *skb, struct net_device *dev )
1300 DBG_TX( DbgInfo, "Tx on Port 0\n" );
1302 return wl_tx( skb, dev, HCF_PORT_0 );
1304 return wl_tx_dma( skb, dev, HCF_PORT_0 );
1307 /*============================================================================*/
1311 /*******************************************************************************
1313 *******************************************************************************
1317 * The handler routine for Tx over HCF_PORT_1.
1321 * skb - a pointer to the sk_buff to transmit.
1322 * dev - a pointer to a net_device structure representing HCF_PORT_1.
1328 ******************************************************************************/
1329 int wl_tx_port1( struct sk_buff *skb, struct net_device *dev )
1331 DBG_TX( DbgInfo, "Tx on Port 1\n" );
1332 return wl_tx( skb, dev, HCF_PORT_1 );
1334 /*============================================================================*/
1336 /*******************************************************************************
1338 *******************************************************************************
1342 * The handler routine for Tx over HCF_PORT_2.
1346 * skb - a pointer to the sk_buff to transmit.
1347 * dev - a pointer to a net_device structure representing HCF_PORT_2.
1353 ******************************************************************************/
1354 int wl_tx_port2( struct sk_buff *skb, struct net_device *dev )
1356 DBG_TX( DbgInfo, "Tx on Port 2\n" );
1357 return wl_tx( skb, dev, HCF_PORT_2 );
1359 /*============================================================================*/
1361 /*******************************************************************************
1363 *******************************************************************************
1367 * The handler routine for Tx over HCF_PORT_3.
1371 * skb - a pointer to the sk_buff to transmit.
1372 * dev - a pointer to a net_device structure representing HCF_PORT_3.
1378 ******************************************************************************/
1379 int wl_tx_port3( struct sk_buff *skb, struct net_device *dev )
1381 DBG_TX( DbgInfo, "Tx on Port 3\n" );
1382 return wl_tx( skb, dev, HCF_PORT_3 );
1384 /*============================================================================*/
1386 /*******************************************************************************
1388 *******************************************************************************
1392 * The handler routine for Tx over HCF_PORT_4.
1396 * skb - a pointer to the sk_buff to transmit.
1397 * dev - a pointer to a net_device structure representing HCF_PORT_4.
1403 ******************************************************************************/
1404 int wl_tx_port4( struct sk_buff *skb, struct net_device *dev )
1406 DBG_TX( DbgInfo, "Tx on Port 4\n" );
1407 return wl_tx( skb, dev, HCF_PORT_4 );
1409 /*============================================================================*/
1411 /*******************************************************************************
1413 *******************************************************************************
1417 * The handler routine for Tx over HCF_PORT_5.
1421 * skb - a pointer to the sk_buff to transmit.
1422 * dev - a pointer to a net_device structure representing HCF_PORT_5.
1428 ******************************************************************************/
1429 int wl_tx_port5( struct sk_buff *skb, struct net_device *dev )
1431 DBG_TX( DbgInfo, "Tx on Port 5\n" );
1432 return wl_tx( skb, dev, HCF_PORT_5 );
1434 /*============================================================================*/
1436 /*******************************************************************************
1438 *******************************************************************************
1442 * The handler routine for Tx over HCF_PORT_6.
1446 * skb - a pointer to the sk_buff to transmit.
1447 * dev - a pointer to a net_device structure representing HCF_PORT_6.
1453 ******************************************************************************/
1454 int wl_tx_port6( struct sk_buff *skb, struct net_device *dev )
1456 DBG_TX( DbgInfo, "Tx on Port 6\n" );
1457 return wl_tx( skb, dev, HCF_PORT_6 );
1459 /*============================================================================*/
1461 /*******************************************************************************
1462 * wl_wds_device_alloc()
1463 *******************************************************************************
1467 * Create instances of net_device to represent the WDS ports, and register
1468 * the device's entry points in the net_device structure.
1472 * lp - a pointer to the device's private adapter structure
1476 * N/A, but will place pointers to the allocated and initialized net_device
1477 * structs in the private adapter structure.
1479 ******************************************************************************/
1480 void wl_wds_device_alloc( struct wl_private *lp )
1483 /*------------------------------------------------------------------------*/
1485 DBG_ENTER( DbgInfo );
1487 /* WDS support requires additional net_device structs to be allocated,
1488 so that user space apps can use these virtual devices to specify the
1489 port on which to Tx/Rx */
1490 for( count = 0; count < NUM_WDS_PORTS; count++ ) {
1491 struct net_device *dev_wds = NULL;
1493 dev_wds = kzalloc(sizeof(struct net_device), GFP_KERNEL);
1499 ether_setup( dev_wds );
1501 lp->wds_port[count].dev = dev_wds;
1503 /* Re-use wl_init for all the devices, as it currently does nothing, but
1504 is required. Re-use the stats/tx_timeout handler for all as well; the
1505 WDS port which is requesting these operations can be determined by
1506 the net_device pointer. Set the private member of all devices to point
1507 to the same net_device struct; that way, all information gets
1508 funnelled through the one "real" net_device. Name the WDS ports
1510 lp->wds_port[count].dev->init = &wl_init;
1511 lp->wds_port[count].dev->get_stats = &wl_stats;
1512 lp->wds_port[count].dev->tx_timeout = &wl_tx_timeout;
1513 lp->wds_port[count].dev->watchdog_timeo = TX_TIMEOUT;
1514 lp->wds_port[count].dev->priv = lp;
1516 sprintf( lp->wds_port[count].dev->name, "wds%d", count );
1519 /* Register the Tx handlers */
1520 lp->wds_port[0].dev->hard_start_xmit = &wl_tx_port1;
1521 lp->wds_port[1].dev->hard_start_xmit = &wl_tx_port2;
1522 lp->wds_port[2].dev->hard_start_xmit = &wl_tx_port3;
1523 lp->wds_port[3].dev->hard_start_xmit = &wl_tx_port4;
1524 lp->wds_port[4].dev->hard_start_xmit = &wl_tx_port5;
1525 lp->wds_port[5].dev->hard_start_xmit = &wl_tx_port6;
1527 WL_WDS_NETIF_STOP_QUEUE( lp );
1529 DBG_LEAVE( DbgInfo );
1530 } // wl_wds_device_alloc
1531 /*============================================================================*/
1533 /*******************************************************************************
1534 * wl_wds_device_dealloc()
1535 *******************************************************************************
1539 * Free instances of net_device structures used to support WDS.
1543 * lp - a pointer to the device's private adapter structure
1549 ******************************************************************************/
1550 void wl_wds_device_dealloc( struct wl_private *lp )
1553 /*------------------------------------------------------------------------*/
1555 DBG_ENTER( DbgInfo );
1557 for( count = 0; count < NUM_WDS_PORTS; count++ ) {
1558 struct net_device *dev_wds = NULL;
1560 dev_wds = lp->wds_port[count].dev;
1562 if( dev_wds != NULL ) {
1563 if( dev_wds->flags & IFF_UP ) {
1564 dev_close( dev_wds );
1565 dev_wds->flags &= ~( IFF_UP | IFF_RUNNING );
1568 free_netdev(dev_wds);
1569 lp->wds_port[count].dev = NULL;
1573 DBG_LEAVE( DbgInfo );
1574 } // wl_wds_device_dealloc
1575 /*============================================================================*/
1577 /*******************************************************************************
1578 * wl_wds_netif_start_queue()
1579 *******************************************************************************
1583 * Used to start the netif queues of all the "virtual" network devices
1584 * which represent the WDS ports.
1588 * lp - a pointer to the device's private adapter structure
1594 ******************************************************************************/
1595 void wl_wds_netif_start_queue( struct wl_private *lp )
1598 /*------------------------------------------------------------------------*/
1601 for( count = 0; count < NUM_WDS_PORTS; count++ ) {
1602 if( lp->wds_port[count].is_registered &&
1603 lp->wds_port[count].netif_queue_on == FALSE ) {
1604 netif_start_queue( lp->wds_port[count].dev );
1605 lp->wds_port[count].netif_queue_on = TRUE;
1609 } // wl_wds_netif_start_queue
1610 /*============================================================================*/
1612 /*******************************************************************************
1613 * wl_wds_netif_stop_queue()
1614 *******************************************************************************
1618 * Used to stop the netif queues of all the "virtual" network devices
1619 * which represent the WDS ports.
1623 * lp - a pointer to the device's private adapter structure
1629 ******************************************************************************/
1630 void wl_wds_netif_stop_queue( struct wl_private *lp )
1633 /*------------------------------------------------------------------------*/
1636 for( count = 0; count < NUM_WDS_PORTS; count++ ) {
1637 if( lp->wds_port[count].is_registered &&
1638 lp->wds_port[count].netif_queue_on == TRUE ) {
1639 netif_stop_queue( lp->wds_port[count].dev );
1640 lp->wds_port[count].netif_queue_on = FALSE;
1644 } // wl_wds_netif_stop_queue
1645 /*============================================================================*/
1647 /*******************************************************************************
1648 * wl_wds_netif_wake_queue()
1649 *******************************************************************************
1653 * Used to wake the netif queues of all the "virtual" network devices
1654 * which represent the WDS ports.
1658 * lp - a pointer to the device's private adapter structure
1664 ******************************************************************************/
1665 void wl_wds_netif_wake_queue( struct wl_private *lp )
1668 /*------------------------------------------------------------------------*/
1671 for( count = 0; count < NUM_WDS_PORTS; count++ ) {
1672 if( lp->wds_port[count].is_registered &&
1673 lp->wds_port[count].netif_queue_on == FALSE ) {
1674 netif_wake_queue( lp->wds_port[count].dev );
1675 lp->wds_port[count].netif_queue_on = TRUE;
1679 } // wl_wds_netif_wake_queue
1680 /*============================================================================*/
1682 /*******************************************************************************
1683 * wl_wds_netif_carrier_on()
1684 *******************************************************************************
1688 * Used to signal the network layer that carrier is present on all of the
1689 * "virtual" network devices which represent the WDS ports.
1693 * lp - a pointer to the device's private adapter structure
1699 ******************************************************************************/
1700 void wl_wds_netif_carrier_on( struct wl_private *lp )
1703 /*------------------------------------------------------------------------*/
1706 for( count = 0; count < NUM_WDS_PORTS; count++ ) {
1707 if( lp->wds_port[count].is_registered ) {
1708 netif_carrier_on( lp->wds_port[count].dev );
1712 } // wl_wds_netif_carrier_on
1713 /*============================================================================*/
1715 /*******************************************************************************
1716 * wl_wds_netif_carrier_off()
1717 *******************************************************************************
1721 * Used to signal the network layer that carrier is NOT present on all of
1722 * the "virtual" network devices which represent the WDS ports.
1726 * lp - a pointer to the device's private adapter structure
1732 ******************************************************************************/
1733 void wl_wds_netif_carrier_off( struct wl_private *lp )
1738 for(count = 0; count < NUM_WDS_PORTS; count++) {
1739 if(lp->wds_port[count].is_registered)
1740 netif_carrier_off(lp->wds_port[count].dev);
1744 } // wl_wds_netif_carrier_off
1745 /*============================================================================*/
1747 #endif /* USE_WDS */
1750 /*******************************************************************************
1752 *******************************************************************************
1756 * The routine which performs data transmits when using busmaster DMA.
1760 * lp - a pointer to the device's wl_private struct.
1761 * skb - a pointer to the network layer's data buffer.
1762 * port - the Hermes port on which to transmit.
1769 ******************************************************************************/
1770 int wl_send_dma( struct wl_private *lp, struct sk_buff *skb, int port )
1773 DESC_STRCT *desc = NULL;
1774 DESC_STRCT *desc_next = NULL;
1775 /*------------------------------------------------------------------------*/
1778 DBG_ERROR( DbgInfo, "Private adapter struct is NULL\n" );
1782 if( lp->dev == NULL ) {
1783 DBG_ERROR( DbgInfo, "net_device struct in wl_private is NULL\n" );
1787 /* AGAIN, ALL THE QUEUEING DONE HERE IN I/O MODE IS NOT PERFORMED */
1790 DBG_WARNING (DbgInfo, "Nothing to send.\n");
1796 /* Get a free descriptor */
1797 desc = wl_pci_dma_get_tx_packet( lp );
1799 if( desc == NULL ) {
1800 if( lp->netif_queue_on == TRUE ) {
1801 netif_stop_queue( lp->dev );
1802 WL_WDS_NETIF_STOP_QUEUE( lp );
1803 lp->netif_queue_on = FALSE;
1805 dev_kfree_skb( skb );
1810 SET_BUF_CNT( desc, /*HCF_DMA_FD_CNT*/HFS_ADDR_DEST );
1811 SET_BUF_SIZE( desc, HCF_DMA_TX_BUF1_SIZE );
1813 desc_next = desc->next_desc_addr;
1815 if( desc_next->buf_addr == NULL ) {
1816 DBG_ERROR( DbgInfo, "DMA descriptor buf_addr is NULL\n" );
1820 /* Copy the payload into the DMA packet */
1821 memcpy( desc_next->buf_addr, skb->data, len );
1823 SET_BUF_CNT( desc_next, len );
1824 SET_BUF_SIZE( desc_next, HCF_MAX_PACKET_SIZE );
1826 hcf_dma_tx_put( &( lp->hcfCtx ), desc, 0 );
1828 /* Free the skb and perform queue cleanup, as the buffer was
1829 transmitted successfully */
1830 dev_kfree_skb( skb );
1834 /*============================================================================*/
1836 /*******************************************************************************
1838 *******************************************************************************
1842 * The routine which performs data reception when using busmaster DMA.
1846 * dev - a pointer to the device's net_device structure.
1853 ******************************************************************************/
1854 int wl_rx_dma( struct net_device *dev )
1859 struct sk_buff *skb;
1860 struct wl_private *lp = NULL;
1861 DESC_STRCT *desc, *desc_next;
1862 //CFG_MB_INFO_RANGE2_STRCT x;
1863 /*------------------------------------------------------------------------*/
1865 DBG_PARAM(DbgInfo, "dev", "%s (0x%p)", dev->name, dev);
1867 if((( lp = dev->priv ) != NULL ) &&
1868 !( lp->flags & WVLAN2_UIL_BUSY )) {
1871 if( lp->useRTS == 1 ) {
1872 DBG_PRINT( "RTS: We're getting an Rx...\n" );
1875 #endif /* USE_RTS */
1877 //if( lp->dma.status == 0 )
1879 desc = hcf_dma_rx_get( &( lp->hcfCtx ));
1883 /* Check and see if we rcvd. a WMP frame */
1885 if((( *(hcf_8 *)&desc->buf_addr[HFS_STAT] ) &
1886 ( HFS_STAT_MSG_TYPE | HFS_STAT_ERR )) == HFS_STAT_WMP_MSG )
1888 DBG_TRACE( DbgInfo, "Got a WMP frame\n" );
1890 x.len = sizeof( CFG_MB_INFO_RANGE2_STRCT ) / sizeof( hcf_16 );
1891 x.typ = CFG_MB_INFO;
1892 x.base_typ = CFG_WMP;
1894 x.frag_buf[0].frag_len = GET_BUF_CNT( descp ) / sizeof( hcf_16 );
1895 x.frag_buf[0].frag_addr = (hcf_8 *) descp->buf_addr ;
1896 x.frag_buf[1].frag_len = ( GET_BUF_CNT( descp->next_desc_addr ) + 1 ) / sizeof( hcf_16 );
1897 x.frag_buf[1].frag_addr = (hcf_8 *) descp->next_desc_addr->buf_addr ;
1899 hcf_put_info( &( lp->hcfCtx ), (LTVP)&x );
1903 desc_next = desc->next_desc_addr;
1905 /* Make sure the buffer isn't empty */
1906 if( GET_BUF_CNT( desc ) == 0 ) {
1907 DBG_WARNING( DbgInfo, "Buffer is empty!\n" );
1909 /* Give the descriptor back to the HCF */
1910 hcf_dma_rx_put( &( lp->hcfCtx ), desc );
1914 /* Read the HFS_STAT register from the lookahead buffer */
1915 hfs_stat = (hcf_16)( desc->buf_addr[HFS_STAT/2] );
1917 /* Make sure the frame isn't bad */
1918 if(( hfs_stat & HFS_STAT_ERR ) != HCF_SUCCESS )
1920 DBG_WARNING( DbgInfo, "HFS_STAT_ERROR (0x%x) in Rx Packet\n",
1921 desc->buf_addr[HFS_STAT/2] );
1923 /* Give the descriptor back to the HCF */
1924 hcf_dma_rx_put( &( lp->hcfCtx ), desc );
1928 /* Determine what port this packet is for */
1929 port = ( hfs_stat >> 8 ) & 0x0007;
1930 DBG_RX( DbgInfo, "Rx frame for port %d\n", port );
1932 pktlen = GET_BUF_CNT(desc_next);
1934 skb = ALLOC_SKB(pktlen);
1944 skb->dev = lp->wds_port[port-1].dev;
1946 #endif /* USE_WDS */
1954 GET_PACKET_DMA( skb->dev, skb, pktlen );
1956 /* Give the descriptor back to the HCF */
1957 hcf_dma_rx_put( &( lp->hcfCtx ), desc );
1962 lp->stats.rx_packets++;
1963 lp->stats.rx_bytes += pktlen;
1968 lp->wds_port[port-1].stats.rx_packets++;
1969 lp->wds_port[port-1].stats.rx_bytes += pktlen;
1971 #endif /* USE_WDS */
1973 dev->last_rx = jiffies;
1976 DBG_ERROR( DbgInfo, "Could not alloc skb\n" );
1980 lp->stats.rx_dropped++;
1985 lp->wds_port[port-1].stats.rx_dropped++;
1987 #endif /* USE_WDS */
1996 /*============================================================================*/
1997 #endif // ENABLE_DMA