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_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 // Unsuccessful, 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 strlcpy(info
->driver
, DRIVER_NAME
, sizeof(info
->driver
));
461 strlcpy(info
->version
, DRV_VERSION_STR
, sizeof(info
->version
));
462 // strlcpy(info.fw_version, priv->fw_name,
463 // sizeof(info.fw_version));
465 if (dev
->dev
.parent
) {
466 dev_set_name(dev
->dev
.parent
, "%s", info
->bus_info
);
467 //strlcpy(info->bus_info, dev->dev.parent->bus_id,
468 // sizeof(info->bus_info));
470 snprintf(info
->bus_info
, sizeof(info
->bus_info
),
472 // "PCMCIA 0x%lx", priv->hw.iobase);
476 static struct ethtool_ops wl_ethtool_ops
= {
477 .get_drvinfo
= wl_get_drvinfo
,
478 .get_link
= ethtool_op_get_link
,
482 /*******************************************************************************
484 *******************************************************************************
488 * The IOCTL handler for the device.
492 * dev - a pointer to the device's net_device struct.
493 * rq - a pointer to the IOCTL request buffer.
494 * cmd - the IOCTL command code.
499 * errno value otherwise
501 ******************************************************************************/
502 int wl_ioctl( struct net_device
*dev
, struct ifreq
*rq
, int cmd
)
504 struct wl_private
*lp
= wl_priv(dev
);
507 /*------------------------------------------------------------------------*/
509 DBG_FUNC( "wl_ioctl" );
511 DBG_PARAM(DbgInfo
, "dev", "%s (0x%p)", dev
->name
, dev
);
512 DBG_PARAM(DbgInfo
, "rq", "0x%p", rq
);
513 DBG_PARAM(DbgInfo
, "cmd", "0x%04x", cmd
);
515 wl_lock( lp
, &flags
);
517 wl_act_int_off( lp
);
520 if( lp
->useRTS
== 1 ) {
521 /* Handle any RTS IOCTL here */
522 if( cmd
== WL_IOCTL_RTS
) {
523 DBG_TRACE( DbgInfo
, "IOCTL: WL_IOCTL_RTS\n" );
524 ret
= wvlan_rts( (struct rtsreq
*)rq
, dev
->base_addr
);
526 DBG_TRACE( DbgInfo
, "IOCTL not supported in RTS mode: 0x%X\n", cmd
);
530 goto out_act_int_on_unlock
;
534 /* Only handle UIL IOCTL requests when the UIL has the system blocked. */
535 if( !(( lp
->flags
& WVLAN2_UIL_BUSY
) && ( cmd
!= WVLAN2_IOCTL_UIL
))) {
537 struct uilreq
*urq
= (struct uilreq
*)rq
;
541 // ================== Private IOCTLs (up to 16) ==================
543 case WVLAN2_IOCTL_UIL
:
544 DBG_TRACE( DbgInfo
, "IOCTL: WVLAN2_IOCTL_UIL\n" );
545 ret
= wvlan_uil( urq
, lp
);
550 DBG_TRACE(DbgInfo
, "IOCTL CODE NOT SUPPORTED: 0x%X\n", cmd
);
555 DBG_WARNING( DbgInfo
, "DEVICE IS BUSY, CANNOT PROCESS REQUEST\n" );
560 out_act_int_on_unlock
:
564 wl_unlock( lp
, &flags
);
566 DBG_LEAVE( DbgInfo
);
569 /*============================================================================*/
571 #ifdef CONFIG_NET_POLL_CONTROLLER
572 void wl_poll(struct net_device
*dev
)
574 struct wl_private
*lp
= wl_priv(dev
);
578 wl_lock( lp
, &flags
);
579 wl_isr(dev
->irq
, dev
, ®s
);
580 wl_unlock( lp
, &flags
);
584 /*******************************************************************************
586 *******************************************************************************
590 * The handler called when, for some reason, a Tx request is not completed.
594 * dev - a pointer to the device's net_device struct.
600 ******************************************************************************/
601 void wl_tx_timeout( struct net_device
*dev
)
607 struct wl_private
*lp
= wl_priv(dev
);
608 struct net_device_stats
*pStats
= NULL
;
609 /*------------------------------------------------------------------------*/
611 DBG_FUNC( "wl_tx_timeout" );
612 DBG_ENTER( DbgInfo
);
614 DBG_WARNING( DbgInfo
, "%s: Transmit timeout.\n", dev
->name
);
616 wl_lock( lp
, &flags
);
619 if( lp
->useRTS
== 1 ) {
620 DBG_TRACE( DbgInfo
, "Skipping tx_timeout handler, in RTS mode\n" );
621 wl_unlock( lp
, &flags
);
623 DBG_LEAVE( DbgInfo
);
628 /* Figure out which device (the "root" device or WDS port) this timeout
632 for( count
= 0; count
< NUM_WDS_PORTS
; count
++ ) {
633 if( dev
== lp
->wds_port
[count
].dev
) {
634 pStats
= &( lp
->wds_port
[count
].stats
);
636 /* Break the loop so that we can use the counter to access WDS
637 information in the private structure */
644 /* If pStats is still NULL, then the device is not a WDS port */
645 if( pStats
== NULL
) {
646 pStats
= &( lp
->stats
);
649 /* Accumulate the timeout error */
652 wl_unlock( lp
, &flags
);
654 DBG_LEAVE( DbgInfo
);
656 /*============================================================================*/
658 /*******************************************************************************
660 *******************************************************************************
664 * The routine which performs data transmits.
668 * lp - a pointer to the device's wl_private struct.
675 ******************************************************************************/
676 int wl_send( struct wl_private
*lp
)
681 WVLAN_LFRAME
*txF
= NULL
;
682 struct list_head
*element
;
684 /*------------------------------------------------------------------------*/
686 DBG_FUNC( "wl_send" );
689 DBG_ERROR( DbgInfo
, "Private adapter struct is NULL\n" );
692 if( lp
->dev
== NULL
) {
693 DBG_ERROR( DbgInfo
, "net_device struct in wl_private is NULL\n" );
697 /* Check for the availability of FIDs; if none are available, don't take any
698 frames off the txQ */
699 if( lp
->hcfCtx
.IFB_RscInd
== 0 ) {
703 /* Reclaim the TxQ Elements and place them back on the free queue */
704 if( !list_empty( &( lp
->txQ
[0] ))) {
705 element
= lp
->txQ
[0].next
;
707 txF
= (WVLAN_LFRAME
* )list_entry( element
, WVLAN_LFRAME
, node
);
709 lp
->txF
.skb
= txF
->frame
.skb
;
710 lp
->txF
.port
= txF
->frame
.port
;
712 txF
->frame
.skb
= NULL
;
715 list_del( &( txF
->node
));
716 list_add( element
, &( lp
->txFree
));
720 if( lp
->txQ_count
< TX_Q_LOW_WATER_MARK
) {
721 if( lp
->netif_queue_on
== FALSE
) {
722 DBG_TX( DbgInfo
, "Kickstarting Q: %d\n", lp
->txQ_count
);
723 netif_wake_queue( lp
->dev
);
724 WL_WDS_NETIF_WAKE_QUEUE( lp
);
725 lp
->netif_queue_on
= TRUE
;
731 if( lp
->txF
.skb
== NULL
) {
735 /* If the device has resources (FIDs) available, then Tx the packet */
736 /* Format the TxRequest and send it to the adapter */
737 len
= lp
->txF
.skb
->len
< ETH_ZLEN
? ETH_ZLEN
: lp
->txF
.skb
->len
;
739 desc
= &( lp
->desc_tx
);
740 desc
->buf_addr
= lp
->txF
.skb
->data
;
742 desc
->next_desc_addr
= NULL
;
744 status
= hcf_send_msg( &( lp
->hcfCtx
), desc
, lp
->txF
.port
);
746 if( status
== HCF_SUCCESS
) {
747 lp
->dev
->trans_start
= jiffies
;
749 DBG_TX( DbgInfo
, "Transmit...\n" );
751 if( lp
->txF
.port
== HCF_PORT_0
) {
752 lp
->stats
.tx_packets
++;
753 lp
->stats
.tx_bytes
+= lp
->txF
.skb
->len
;
759 lp
->wds_port
[(( lp
->txF
.port
>> 8 ) - 1)].stats
.tx_packets
++;
760 lp
->wds_port
[(( lp
->txF
.port
>> 8 ) - 1)].stats
.tx_bytes
+= lp
->txF
.skb
->len
;
765 /* Free the skb and perform queue cleanup, as the buffer was
766 transmitted successfully */
767 dev_kfree_skb( lp
->txF
.skb
);
775 /*============================================================================*/
777 /*******************************************************************************
779 *******************************************************************************
783 * The Tx handler function for the network layer.
787 * skb - a pointer to the sk_buff structure containing the data to transfer.
788 * dev - a pointer to the device's net_device structure.
795 ******************************************************************************/
796 int wl_tx( struct sk_buff
*skb
, struct net_device
*dev
, int port
)
799 struct wl_private
*lp
= wl_priv(dev
);
800 WVLAN_LFRAME
*txF
= NULL
;
801 struct list_head
*element
;
802 /*------------------------------------------------------------------------*/
806 /* Grab the spinlock */
807 wl_lock( lp
, &flags
);
809 if( lp
->flags
& WVLAN2_UIL_BUSY
) {
810 DBG_WARNING( DbgInfo
, "UIL has device blocked\n" );
811 /* Start dropping packets here??? */
812 wl_unlock( lp
, &flags
);
817 if( lp
->useRTS
== 1 ) {
818 DBG_PRINT( "RTS: we're getting a Tx...\n" );
819 wl_unlock( lp
, &flags
);
825 /* Get an element from the queue */
826 element
= lp
->txFree
.next
;
827 txF
= (WVLAN_LFRAME
*)list_entry( element
, WVLAN_LFRAME
, node
);
829 DBG_ERROR( DbgInfo
, "Problem with list_entry\n" );
830 wl_unlock( lp
, &flags
);
833 /* Fill out the frame */
834 txF
->frame
.skb
= skb
;
835 txF
->frame
.port
= port
;
836 /* Move the frame to the txQ */
837 /* NOTE: Here's where we would do priority queueing */
838 list_move(&(txF
->node
), &(lp
->txQ
[0]));
841 if( lp
->txQ_count
>= DEFAULT_NUM_TX_FRAMES
) {
842 DBG_TX( DbgInfo
, "Q Full: %d\n", lp
->txQ_count
);
843 if( lp
->netif_queue_on
== TRUE
) {
844 netif_stop_queue( lp
->dev
);
845 WL_WDS_NETIF_STOP_QUEUE( lp
);
846 lp
->netif_queue_on
= FALSE
;
850 wl_act_int_off( lp
); /* Disable Interrupts */
852 /* Send the data to the hardware using the appropriate method */
855 wl_send_dma( lp
, skb
, port
);
862 /* Re-enable Interrupts, release the spinlock and return */
864 wl_unlock( lp
, &flags
);
867 /*============================================================================*/
869 /*******************************************************************************
871 *******************************************************************************
875 * The routine which performs data reception.
879 * dev - a pointer to the device's net_device structure.
886 ******************************************************************************/
887 int wl_rx(struct net_device
*dev
)
891 struct wl_private
*lp
= wl_priv(dev
);
896 /*------------------------------------------------------------------------*/
899 DBG_PARAM(DbgInfo
, "dev", "%s (0x%p)", dev
->name
, dev
);
901 if(!( lp
->flags
& WVLAN2_UIL_BUSY
)) {
904 if( lp
->useRTS
== 1 ) {
905 DBG_PRINT( "RTS: We're getting an Rx...\n" );
910 /* Read the HFS_STAT register from the lookahead buffer */
911 hfs_stat
= (hcf_16
)(( lp
->lookAheadBuf
[HFS_STAT
] ) |
912 ( lp
->lookAheadBuf
[HFS_STAT
+ 1] << 8 ));
914 /* Make sure the frame isn't bad */
915 if(( hfs_stat
& HFS_STAT_ERR
) != HCF_SUCCESS
) {
916 DBG_WARNING( DbgInfo
, "HFS_STAT_ERROR (0x%x) in Rx Packet\n",
917 lp
->lookAheadBuf
[HFS_STAT
] );
921 /* Determine what port this packet is for */
922 port
= ( hfs_stat
>> 8 ) & 0x0007;
923 DBG_RX( DbgInfo
, "Rx frame for port %d\n", port
);
925 pktlen
= lp
->hcfCtx
.IFB_RxLen
;
927 skb
= ALLOC_SKB(pktlen
);
929 /* Set the netdev based on the port */
938 skb
->dev
= lp
->wds_port
[port
-1].dev
;
948 desc
= &( lp
->desc_rx
);
950 desc
->next_desc_addr
= NULL
;
953 #define BLOCK_INPUT(buf, len) \
954 desc->buf_addr = buf; \
955 desc->BUF_SIZE = len; \
956 status = hcf_rcv_msg(&(lp->hcfCtx), desc, 0)
959 GET_PACKET( skb
->dev
, skb
, pktlen
);
961 if( status
== HCF_SUCCESS
) {
965 lp
->stats
.rx_packets
++;
966 lp
->stats
.rx_bytes
+= pktlen
;
971 lp
->wds_port
[port
-1].stats
.rx_packets
++;
972 lp
->wds_port
[port
-1].stats
.rx_bytes
+= pktlen
;
976 dev
->last_rx
= jiffies
;
980 if( lp
->spydata
.spy_number
> 0 ) {
981 char *srcaddr
= skb
->mac
.raw
+ MAC_ADDR_SIZE
;
983 wl_spy_gather( dev
, srcaddr
);
985 #endif /* WIRELESS_SPY */
986 #endif /* WIRELESS_EXT */
988 DBG_ERROR( DbgInfo
, "Rx request to card FAILED\n" );
991 lp
->stats
.rx_dropped
++;
996 lp
->wds_port
[port
-1].stats
.rx_dropped
++;
1000 dev_kfree_skb( skb
);
1003 DBG_ERROR( DbgInfo
, "Could not alloc skb\n" );
1006 lp
->stats
.rx_dropped
++;
1011 lp
->wds_port
[port
-1].stats
.rx_dropped
++;
1013 #endif /* USE_WDS */
1020 /*============================================================================*/
1022 /*******************************************************************************
1024 *******************************************************************************
1028 * Function to handle multicast packets
1032 * dev - a pointer to the device's net_device structure.
1038 ******************************************************************************/
1039 #ifdef NEW_MULTICAST
1041 void wl_multicast( struct net_device
*dev
)
1043 #if 1 //;? (HCF_TYPE) & HCF_TYPE_STA //;?should we return an error status in AP mode
1044 //;?seems reasonable that even an AP-only driver could afford this small additional footprint
1047 struct netdev_hw_addr
*ha
;
1048 struct wl_private
*lp
= wl_priv(dev
);
1049 unsigned long flags
;
1050 /*------------------------------------------------------------------------*/
1052 DBG_FUNC( "wl_multicast" );
1053 DBG_ENTER( DbgInfo
);
1054 DBG_PARAM( DbgInfo
, "dev", "%s (0x%p)", dev
->name
, dev
);
1056 if( !wl_adapter_is_open( dev
)) {
1057 DBG_LEAVE( DbgInfo
);
1062 if( DBG_FLAGS( DbgInfo
) & DBG_PARAM_ON
) {
1063 DBG_PRINT(" flags: %s%s%s\n",
1064 ( dev
->flags
& IFF_PROMISC
) ? "Promiscuous " : "",
1065 ( dev
->flags
& IFF_MULTICAST
) ? "Multicast " : "",
1066 ( dev
->flags
& IFF_ALLMULTI
) ? "All-Multicast" : "" );
1068 DBG_PRINT( " mc_count: %d\n", netdev_mc_count(dev
));
1070 netdev_for_each_mc_addr(ha
, dev
)
1071 DBG_PRINT(" %pM (%d)\n", ha
->addr
, dev
->addr_len
);
1075 if(!( lp
->flags
& WVLAN2_UIL_BUSY
)) {
1078 if( lp
->useRTS
== 1 ) {
1079 DBG_TRACE( DbgInfo
, "Skipping multicast, in RTS mode\n" );
1081 DBG_LEAVE( DbgInfo
);
1084 #endif /* USE_RTS */
1086 wl_lock( lp
, &flags
);
1087 wl_act_int_off( lp
);
1089 if ( CNV_INT_TO_LITTLE( lp
->hcfCtx
.IFB_FWIdentity
.comp_id
) == COMP_ID_FW_STA
) {
1090 if( dev
->flags
& IFF_PROMISC
) {
1091 /* Enable promiscuous mode */
1092 lp
->ltvRecord
.len
= 2;
1093 lp
->ltvRecord
.typ
= CFG_PROMISCUOUS_MODE
;
1094 lp
->ltvRecord
.u
.u16
[0] = CNV_INT_TO_LITTLE( 1 );
1095 DBG_PRINT( "Enabling Promiscuous mode (IFF_PROMISC)\n" );
1096 hcf_put_info( &( lp
->hcfCtx
), (LTVP
)&( lp
->ltvRecord
));
1098 else if ((netdev_mc_count(dev
) > HCF_MAX_MULTICAST
) ||
1099 ( dev
->flags
& IFF_ALLMULTI
)) {
1100 /* Shutting off this filter will enable all multicast frames to
1101 be sent up from the device; however, this is a static RID, so
1102 a call to wl_apply() is needed */
1103 lp
->ltvRecord
.len
= 2;
1104 lp
->ltvRecord
.typ
= CFG_CNF_RX_ALL_GROUP_ADDR
;
1105 lp
->ltvRecord
.u
.u16
[0] = CNV_INT_TO_LITTLE( 0 );
1106 DBG_PRINT( "Enabling all multicast mode (IFF_ALLMULTI)\n" );
1107 hcf_put_info( &( lp
->hcfCtx
), (LTVP
)&( lp
->ltvRecord
));
1110 else if (!netdev_mc_empty(dev
)) {
1111 /* Set the multicast addresses */
1112 lp
->ltvRecord
.len
= ( netdev_mc_count(dev
) * 3 ) + 1;
1113 lp
->ltvRecord
.typ
= CFG_GROUP_ADDR
;
1116 netdev_for_each_mc_addr(ha
, dev
)
1117 memcpy(&(lp
->ltvRecord
.u
.u8
[x
++ * ETH_ALEN
]),
1118 ha
->addr
, ETH_ALEN
);
1119 DBG_PRINT( "Setting multicast list\n" );
1120 hcf_put_info( &( lp
->hcfCtx
), (LTVP
)&( lp
->ltvRecord
));
1122 /* Disable promiscuous mode */
1123 lp
->ltvRecord
.len
= 2;
1124 lp
->ltvRecord
.typ
= CFG_PROMISCUOUS_MODE
;
1125 lp
->ltvRecord
.u
.u16
[0] = CNV_INT_TO_LITTLE( 0 );
1126 DBG_PRINT( "Disabling Promiscuous mode\n" );
1127 hcf_put_info( &( lp
->hcfCtx
), (LTVP
)&( lp
->ltvRecord
));
1129 /* Disable multicast mode */
1130 lp
->ltvRecord
.len
= 2;
1131 lp
->ltvRecord
.typ
= CFG_GROUP_ADDR
;
1132 DBG_PRINT( "Disabling Multicast mode\n" );
1133 hcf_put_info( &( lp
->hcfCtx
), (LTVP
)&( lp
->ltvRecord
));
1135 /* Turning on this filter will prevent all multicast frames from
1136 being sent up from the device; however, this is a static RID,
1137 so a call to wl_apply() is needed */
1138 lp
->ltvRecord
.len
= 2;
1139 lp
->ltvRecord
.typ
= CFG_CNF_RX_ALL_GROUP_ADDR
;
1140 lp
->ltvRecord
.u
.u16
[0] = CNV_INT_TO_LITTLE( 1 );
1141 DBG_PRINT( "Disabling all multicast mode (IFF_ALLMULTI)\n" );
1142 hcf_put_info( &( lp
->hcfCtx
), (LTVP
)&( lp
->ltvRecord
));
1146 wl_act_int_on( lp
);
1147 wl_unlock( lp
, &flags
);
1149 DBG_LEAVE( DbgInfo
);
1150 #endif /* HCF_STA */
1152 /*============================================================================*/
1154 #else /* NEW_MULTICAST */
1156 void wl_multicast( struct net_device
*dev
, int num_addrs
, void *addrs
)
1158 DBG_FUNC( "wl_multicast");
1161 DBG_PARAM( DbgInfo
, "dev", "%s (0x%p)", dev
->name
, dev
);
1162 DBG_PARAM( DbgInfo
, "num_addrs", "%d", num_addrs
);
1163 DBG_PARAM( DbgInfo
, "addrs", "0x%p", addrs
);
1165 #error Obsolete set multicast interface!
1167 DBG_LEAVE( DbgInfo
);
1169 /*============================================================================*/
1171 #endif /* NEW_MULTICAST */
1173 static const struct net_device_ops wl_netdev_ops
=
1175 .ndo_start_xmit
= &wl_tx_port0
,
1177 .ndo_set_config
= &wl_config
,
1178 .ndo_get_stats
= &wl_stats
,
1179 .ndo_set_rx_mode
= &wl_multicast
,
1181 .ndo_init
= &wl_insert
,
1182 .ndo_open
= &wl_adapter_open
,
1183 .ndo_stop
= &wl_adapter_close
,
1184 .ndo_do_ioctl
= &wl_ioctl
,
1186 .ndo_tx_timeout
= &wl_tx_timeout
,
1188 #ifdef CONFIG_NET_POLL_CONTROLLER
1189 .ndo_poll_controller
= wl_poll
,
1193 /*******************************************************************************
1195 *******************************************************************************
1199 * Create instances of net_device and wl_private for the new adapter
1200 * and register the device's entry points in the net_device structure.
1208 * a pointer to an allocated and initialized net_device struct for this
1211 ******************************************************************************/
1212 struct net_device
* wl_device_alloc( void )
1214 struct net_device
*dev
= NULL
;
1215 struct wl_private
*lp
= NULL
;
1216 /*------------------------------------------------------------------------*/
1218 DBG_FUNC( "wl_device_alloc" );
1219 DBG_ENTER( DbgInfo
);
1221 /* Alloc a net_device struct */
1222 dev
= alloc_etherdev(sizeof(struct wl_private
));
1226 /* Initialize the 'next' pointer in the struct. Currently only used for PCI,
1227 but do it here just in case it's used for other buses in the future */
1232 if( dev
->mtu
> MTU_MAX
)
1234 DBG_WARNING( DbgInfo
, "%s: MTU set too high, limiting to %d.\n",
1235 dev
->name
, MTU_MAX
);
1239 /* Setup the function table in the device structure. */
1241 dev
->wireless_handlers
= (struct iw_handler_def
*)&wl_iw_handler_def
;
1242 lp
->wireless_data
.spy_data
= &lp
->spy_data
;
1243 dev
->wireless_data
= &lp
->wireless_data
;
1245 dev
->netdev_ops
= &wl_netdev_ops
;
1247 dev
->watchdog_timeo
= TX_TIMEOUT
;
1249 dev
->ethtool_ops
= &wl_ethtool_ops
;
1251 netif_stop_queue( dev
);
1253 /* Allocate virtual devices for WDS support if needed */
1254 WL_WDS_DEVICE_ALLOC( lp
);
1256 DBG_LEAVE( DbgInfo
);
1258 } // wl_device_alloc
1259 /*============================================================================*/
1261 /*******************************************************************************
1262 * wl_device_dealloc()
1263 *******************************************************************************
1267 * Free instances of net_device and wl_private strcutres for an adapter
1268 * and perform basic cleanup.
1272 * dev - a pointer to the device's net_device structure.
1278 ******************************************************************************/
1279 void wl_device_dealloc( struct net_device
*dev
)
1281 // struct wl_private *lp = wl_priv(dev);
1282 /*------------------------------------------------------------------------*/
1284 DBG_FUNC( "wl_device_dealloc" );
1285 DBG_ENTER( DbgInfo
);
1287 /* Dealloc the WDS ports */
1288 WL_WDS_DEVICE_DEALLOC( lp
);
1292 DBG_LEAVE( DbgInfo
);
1293 } // wl_device_dealloc
1294 /*============================================================================*/
1296 /*******************************************************************************
1298 *******************************************************************************
1302 * The handler routine for Tx over HCF_PORT_0.
1306 * skb - a pointer to the sk_buff to transmit.
1307 * dev - a pointer to a net_device structure representing HCF_PORT_0.
1313 ******************************************************************************/
1314 int wl_tx_port0( struct sk_buff
*skb
, struct net_device
*dev
)
1316 DBG_TX( DbgInfo
, "Tx on Port 0\n" );
1318 return wl_tx( skb
, dev
, HCF_PORT_0
);
1320 return wl_tx_dma( skb
, dev
, HCF_PORT_0
);
1323 /*============================================================================*/
1327 /*******************************************************************************
1329 *******************************************************************************
1333 * The handler routine for Tx over HCF_PORT_1.
1337 * skb - a pointer to the sk_buff to transmit.
1338 * dev - a pointer to a net_device structure representing HCF_PORT_1.
1344 ******************************************************************************/
1345 int wl_tx_port1( struct sk_buff
*skb
, struct net_device
*dev
)
1347 DBG_TX( DbgInfo
, "Tx on Port 1\n" );
1348 return wl_tx( skb
, dev
, HCF_PORT_1
);
1350 /*============================================================================*/
1352 /*******************************************************************************
1354 *******************************************************************************
1358 * The handler routine for Tx over HCF_PORT_2.
1362 * skb - a pointer to the sk_buff to transmit.
1363 * dev - a pointer to a net_device structure representing HCF_PORT_2.
1369 ******************************************************************************/
1370 int wl_tx_port2( struct sk_buff
*skb
, struct net_device
*dev
)
1372 DBG_TX( DbgInfo
, "Tx on Port 2\n" );
1373 return wl_tx( skb
, dev
, HCF_PORT_2
);
1375 /*============================================================================*/
1377 /*******************************************************************************
1379 *******************************************************************************
1383 * The handler routine for Tx over HCF_PORT_3.
1387 * skb - a pointer to the sk_buff to transmit.
1388 * dev - a pointer to a net_device structure representing HCF_PORT_3.
1394 ******************************************************************************/
1395 int wl_tx_port3( struct sk_buff
*skb
, struct net_device
*dev
)
1397 DBG_TX( DbgInfo
, "Tx on Port 3\n" );
1398 return wl_tx( skb
, dev
, HCF_PORT_3
);
1400 /*============================================================================*/
1402 /*******************************************************************************
1404 *******************************************************************************
1408 * The handler routine for Tx over HCF_PORT_4.
1412 * skb - a pointer to the sk_buff to transmit.
1413 * dev - a pointer to a net_device structure representing HCF_PORT_4.
1419 ******************************************************************************/
1420 int wl_tx_port4( struct sk_buff
*skb
, struct net_device
*dev
)
1422 DBG_TX( DbgInfo
, "Tx on Port 4\n" );
1423 return wl_tx( skb
, dev
, HCF_PORT_4
);
1425 /*============================================================================*/
1427 /*******************************************************************************
1429 *******************************************************************************
1433 * The handler routine for Tx over HCF_PORT_5.
1437 * skb - a pointer to the sk_buff to transmit.
1438 * dev - a pointer to a net_device structure representing HCF_PORT_5.
1444 ******************************************************************************/
1445 int wl_tx_port5( struct sk_buff
*skb
, struct net_device
*dev
)
1447 DBG_TX( DbgInfo
, "Tx on Port 5\n" );
1448 return wl_tx( skb
, dev
, HCF_PORT_5
);
1450 /*============================================================================*/
1452 /*******************************************************************************
1454 *******************************************************************************
1458 * The handler routine for Tx over HCF_PORT_6.
1462 * skb - a pointer to the sk_buff to transmit.
1463 * dev - a pointer to a net_device structure representing HCF_PORT_6.
1469 ******************************************************************************/
1470 int wl_tx_port6( struct sk_buff
*skb
, struct net_device
*dev
)
1472 DBG_TX( DbgInfo
, "Tx on Port 6\n" );
1473 return wl_tx( skb
, dev
, HCF_PORT_6
);
1475 /*============================================================================*/
1477 /*******************************************************************************
1478 * wl_wds_device_alloc()
1479 *******************************************************************************
1483 * Create instances of net_device to represent the WDS ports, and register
1484 * the device's entry points in the net_device structure.
1488 * lp - a pointer to the device's private adapter structure
1492 * N/A, but will place pointers to the allocated and initialized net_device
1493 * structs in the private adapter structure.
1495 ******************************************************************************/
1496 void wl_wds_device_alloc( struct wl_private
*lp
)
1499 /*------------------------------------------------------------------------*/
1501 DBG_FUNC( "wl_wds_device_alloc" );
1502 DBG_ENTER( DbgInfo
);
1504 /* WDS support requires additional net_device structs to be allocated,
1505 so that user space apps can use these virtual devices to specify the
1506 port on which to Tx/Rx */
1507 for( count
= 0; count
< NUM_WDS_PORTS
; count
++ ) {
1508 struct net_device
*dev_wds
= NULL
;
1510 dev_wds
= kzalloc(sizeof(struct net_device
), GFP_KERNEL
);
1516 ether_setup( dev_wds
);
1518 lp
->wds_port
[count
].dev
= dev_wds
;
1520 /* Re-use wl_init for all the devices, as it currently does nothing, but
1521 is required. Re-use the stats/tx_timeout handler for all as well; the
1522 WDS port which is requesting these operations can be determined by
1523 the net_device pointer. Set the private member of all devices to point
1524 to the same net_device struct; that way, all information gets
1525 funnelled through the one "real" net_device. Name the WDS ports
1527 lp
->wds_port
[count
].dev
->init
= &wl_init
;
1528 lp
->wds_port
[count
].dev
->get_stats
= &wl_stats
;
1529 lp
->wds_port
[count
].dev
->tx_timeout
= &wl_tx_timeout
;
1530 lp
->wds_port
[count
].dev
->watchdog_timeo
= TX_TIMEOUT
;
1531 lp
->wds_port
[count
].dev
->priv
= lp
;
1533 sprintf( lp
->wds_port
[count
].dev
->name
, "wds%d", count
);
1536 /* Register the Tx handlers */
1537 lp
->wds_port
[0].dev
->hard_start_xmit
= &wl_tx_port1
;
1538 lp
->wds_port
[1].dev
->hard_start_xmit
= &wl_tx_port2
;
1539 lp
->wds_port
[2].dev
->hard_start_xmit
= &wl_tx_port3
;
1540 lp
->wds_port
[3].dev
->hard_start_xmit
= &wl_tx_port4
;
1541 lp
->wds_port
[4].dev
->hard_start_xmit
= &wl_tx_port5
;
1542 lp
->wds_port
[5].dev
->hard_start_xmit
= &wl_tx_port6
;
1544 WL_WDS_NETIF_STOP_QUEUE( lp
);
1546 DBG_LEAVE( DbgInfo
);
1547 } // wl_wds_device_alloc
1548 /*============================================================================*/
1550 /*******************************************************************************
1551 * wl_wds_device_dealloc()
1552 *******************************************************************************
1556 * Free instances of net_device structures used to support WDS.
1560 * lp - a pointer to the device's private adapter structure
1566 ******************************************************************************/
1567 void wl_wds_device_dealloc( struct wl_private
*lp
)
1570 /*------------------------------------------------------------------------*/
1572 DBG_FUNC( "wl_wds_device_dealloc" );
1573 DBG_ENTER( DbgInfo
);
1575 for( count
= 0; count
< NUM_WDS_PORTS
; count
++ ) {
1576 struct net_device
*dev_wds
= NULL
;
1578 dev_wds
= lp
->wds_port
[count
].dev
;
1580 if( dev_wds
!= NULL
) {
1581 if( dev_wds
->flags
& IFF_UP
) {
1582 dev_close( dev_wds
);
1583 dev_wds
->flags
&= ~( IFF_UP
| IFF_RUNNING
);
1586 free_netdev(dev_wds
);
1587 lp
->wds_port
[count
].dev
= NULL
;
1591 DBG_LEAVE( DbgInfo
);
1592 } // wl_wds_device_dealloc
1593 /*============================================================================*/
1595 /*******************************************************************************
1596 * wl_wds_netif_start_queue()
1597 *******************************************************************************
1601 * Used to start the netif queues of all the "virtual" network devices
1602 * which represent the WDS ports.
1606 * lp - a pointer to the device's private adapter structure
1612 ******************************************************************************/
1613 void wl_wds_netif_start_queue( struct wl_private
*lp
)
1616 /*------------------------------------------------------------------------*/
1619 for( count
= 0; count
< NUM_WDS_PORTS
; count
++ ) {
1620 if( lp
->wds_port
[count
].is_registered
&&
1621 lp
->wds_port
[count
].netif_queue_on
== FALSE
) {
1622 netif_start_queue( lp
->wds_port
[count
].dev
);
1623 lp
->wds_port
[count
].netif_queue_on
= TRUE
;
1627 } // wl_wds_netif_start_queue
1628 /*============================================================================*/
1630 /*******************************************************************************
1631 * wl_wds_netif_stop_queue()
1632 *******************************************************************************
1636 * Used to stop the netif queues of all the "virtual" network devices
1637 * which represent the WDS ports.
1641 * lp - a pointer to the device's private adapter structure
1647 ******************************************************************************/
1648 void wl_wds_netif_stop_queue( struct wl_private
*lp
)
1651 /*------------------------------------------------------------------------*/
1654 for( count
= 0; count
< NUM_WDS_PORTS
; count
++ ) {
1655 if( lp
->wds_port
[count
].is_registered
&&
1656 lp
->wds_port
[count
].netif_queue_on
== TRUE
) {
1657 netif_stop_queue( lp
->wds_port
[count
].dev
);
1658 lp
->wds_port
[count
].netif_queue_on
= FALSE
;
1662 } // wl_wds_netif_stop_queue
1663 /*============================================================================*/
1665 /*******************************************************************************
1666 * wl_wds_netif_wake_queue()
1667 *******************************************************************************
1671 * Used to wake the netif queues of all the "virtual" network devices
1672 * which represent the WDS ports.
1676 * lp - a pointer to the device's private adapter structure
1682 ******************************************************************************/
1683 void wl_wds_netif_wake_queue( struct wl_private
*lp
)
1686 /*------------------------------------------------------------------------*/
1689 for( count
= 0; count
< NUM_WDS_PORTS
; count
++ ) {
1690 if( lp
->wds_port
[count
].is_registered
&&
1691 lp
->wds_port
[count
].netif_queue_on
== FALSE
) {
1692 netif_wake_queue( lp
->wds_port
[count
].dev
);
1693 lp
->wds_port
[count
].netif_queue_on
= TRUE
;
1697 } // wl_wds_netif_wake_queue
1698 /*============================================================================*/
1700 /*******************************************************************************
1701 * wl_wds_netif_carrier_on()
1702 *******************************************************************************
1706 * Used to signal the network layer that carrier is present on all of the
1707 * "virtual" network devices which represent the WDS ports.
1711 * lp - a pointer to the device's private adapter structure
1717 ******************************************************************************/
1718 void wl_wds_netif_carrier_on( struct wl_private
*lp
)
1721 /*------------------------------------------------------------------------*/
1724 for( count
= 0; count
< NUM_WDS_PORTS
; count
++ ) {
1725 if( lp
->wds_port
[count
].is_registered
) {
1726 netif_carrier_on( lp
->wds_port
[count
].dev
);
1730 } // wl_wds_netif_carrier_on
1731 /*============================================================================*/
1733 /*******************************************************************************
1734 * wl_wds_netif_carrier_off()
1735 *******************************************************************************
1739 * Used to signal the network layer that carrier is NOT present on all of
1740 * the "virtual" network devices which represent the WDS ports.
1744 * lp - a pointer to the device's private adapter structure
1750 ******************************************************************************/
1751 void wl_wds_netif_carrier_off( struct wl_private
*lp
)
1756 for(count
= 0; count
< NUM_WDS_PORTS
; count
++) {
1757 if(lp
->wds_port
[count
].is_registered
)
1758 netif_carrier_off(lp
->wds_port
[count
].dev
);
1762 } // wl_wds_netif_carrier_off
1763 /*============================================================================*/
1765 #endif /* USE_WDS */
1768 /*******************************************************************************
1770 *******************************************************************************
1774 * The routine which performs data transmits when using busmaster DMA.
1778 * lp - a pointer to the device's wl_private struct.
1779 * skb - a pointer to the network layer's data buffer.
1780 * port - the Hermes port on which to transmit.
1787 ******************************************************************************/
1788 int wl_send_dma( struct wl_private
*lp
, struct sk_buff
*skb
, int port
)
1791 DESC_STRCT
*desc
= NULL
;
1792 DESC_STRCT
*desc_next
= NULL
;
1793 /*------------------------------------------------------------------------*/
1795 DBG_FUNC( "wl_send_dma" );
1798 DBG_ERROR( DbgInfo
, "Private adapter struct is NULL\n" );
1802 if( lp
->dev
== NULL
) {
1803 DBG_ERROR( DbgInfo
, "net_device struct in wl_private is NULL\n" );
1807 /* AGAIN, ALL THE QUEUEING DONE HERE IN I/O MODE IS NOT PERFORMED */
1810 DBG_WARNING (DbgInfo
, "Nothing to send.\n");
1816 /* Get a free descriptor */
1817 desc
= wl_pci_dma_get_tx_packet( lp
);
1819 if( desc
== NULL
) {
1820 if( lp
->netif_queue_on
== TRUE
) {
1821 netif_stop_queue( lp
->dev
);
1822 WL_WDS_NETIF_STOP_QUEUE( lp
);
1823 lp
->netif_queue_on
= FALSE
;
1825 dev_kfree_skb( skb
);
1830 SET_BUF_CNT( desc
, /*HCF_DMA_FD_CNT*/HFS_ADDR_DEST
);
1831 SET_BUF_SIZE( desc
, HCF_DMA_TX_BUF1_SIZE
);
1833 desc_next
= desc
->next_desc_addr
;
1835 if( desc_next
->buf_addr
== NULL
) {
1836 DBG_ERROR( DbgInfo
, "DMA descriptor buf_addr is NULL\n" );
1840 /* Copy the payload into the DMA packet */
1841 memcpy( desc_next
->buf_addr
, skb
->data
, len
);
1843 SET_BUF_CNT( desc_next
, len
);
1844 SET_BUF_SIZE( desc_next
, HCF_MAX_PACKET_SIZE
);
1846 hcf_dma_tx_put( &( lp
->hcfCtx
), desc
, 0 );
1848 /* Free the skb and perform queue cleanup, as the buffer was
1849 transmitted successfully */
1850 dev_kfree_skb( skb
);
1854 /*============================================================================*/
1856 /*******************************************************************************
1858 *******************************************************************************
1862 * The routine which performs data reception when using busmaster DMA.
1866 * dev - a pointer to the device's net_device structure.
1873 ******************************************************************************/
1874 int wl_rx_dma( struct net_device
*dev
)
1879 struct sk_buff
*skb
;
1880 struct wl_private
*lp
= NULL
;
1881 DESC_STRCT
*desc
, *desc_next
;
1882 //CFG_MB_INFO_RANGE2_STRCT x;
1883 /*------------------------------------------------------------------------*/
1886 DBG_PARAM(DbgInfo
, "dev", "%s (0x%p)", dev
->name
, dev
);
1888 if((( lp
= dev
->priv
) != NULL
) &&
1889 !( lp
->flags
& WVLAN2_UIL_BUSY
)) {
1892 if( lp
->useRTS
== 1 ) {
1893 DBG_PRINT( "RTS: We're getting an Rx...\n" );
1896 #endif /* USE_RTS */
1898 //if( lp->dma.status == 0 )
1900 desc
= hcf_dma_rx_get( &( lp
->hcfCtx
));
1904 /* Check and see if we rcvd. a WMP frame */
1906 if((( *(hcf_8 *)&desc->buf_addr[HFS_STAT] ) &
1907 ( HFS_STAT_MSG_TYPE | HFS_STAT_ERR )) == HFS_STAT_WMP_MSG )
1909 DBG_TRACE( DbgInfo, "Got a WMP frame\n" );
1911 x.len = sizeof( CFG_MB_INFO_RANGE2_STRCT ) / sizeof( hcf_16 );
1912 x.typ = CFG_MB_INFO;
1913 x.base_typ = CFG_WMP;
1915 x.frag_buf[0].frag_len = GET_BUF_CNT( descp ) / sizeof( hcf_16 );
1916 x.frag_buf[0].frag_addr = (hcf_8 *) descp->buf_addr ;
1917 x.frag_buf[1].frag_len = ( GET_BUF_CNT( descp->next_desc_addr ) + 1 ) / sizeof( hcf_16 );
1918 x.frag_buf[1].frag_addr = (hcf_8 *) descp->next_desc_addr->buf_addr ;
1920 hcf_put_info( &( lp->hcfCtx ), (LTVP)&x );
1924 desc_next
= desc
->next_desc_addr
;
1926 /* Make sure the buffer isn't empty */
1927 if( GET_BUF_CNT( desc
) == 0 ) {
1928 DBG_WARNING( DbgInfo
, "Buffer is empty!\n" );
1930 /* Give the descriptor back to the HCF */
1931 hcf_dma_rx_put( &( lp
->hcfCtx
), desc
);
1935 /* Read the HFS_STAT register from the lookahead buffer */
1936 hfs_stat
= (hcf_16
)( desc
->buf_addr
[HFS_STAT
/2] );
1938 /* Make sure the frame isn't bad */
1939 if(( hfs_stat
& HFS_STAT_ERR
) != HCF_SUCCESS
)
1941 DBG_WARNING( DbgInfo
, "HFS_STAT_ERROR (0x%x) in Rx Packet\n",
1942 desc
->buf_addr
[HFS_STAT
/2] );
1944 /* Give the descriptor back to the HCF */
1945 hcf_dma_rx_put( &( lp
->hcfCtx
), desc
);
1949 /* Determine what port this packet is for */
1950 port
= ( hfs_stat
>> 8 ) & 0x0007;
1951 DBG_RX( DbgInfo
, "Rx frame for port %d\n", port
);
1953 pktlen
= GET_BUF_CNT(desc_next
);
1955 skb
= ALLOC_SKB(pktlen
);
1965 skb
->dev
= lp
->wds_port
[port
-1].dev
;
1967 #endif /* USE_WDS */
1975 GET_PACKET_DMA( skb
->dev
, skb
, pktlen
);
1977 /* Give the descriptor back to the HCF */
1978 hcf_dma_rx_put( &( lp
->hcfCtx
), desc
);
1983 lp
->stats
.rx_packets
++;
1984 lp
->stats
.rx_bytes
+= pktlen
;
1989 lp
->wds_port
[port
-1].stats
.rx_packets
++;
1990 lp
->wds_port
[port
-1].stats
.rx_bytes
+= pktlen
;
1992 #endif /* USE_WDS */
1994 dev
->last_rx
= jiffies
;
1997 DBG_ERROR( DbgInfo
, "Could not alloc skb\n" );
2001 lp
->stats
.rx_dropped
++;
2006 lp
->wds_port
[port
-1].stats
.rx_dropped
++;
2008 #endif /* USE_WDS */
2017 /*============================================================================*/
2018 #endif // ENABLE_DMA