-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathrt_main_dev.c
866 lines (652 loc) · 21.7 KB
/
rt_main_dev.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
/*
*************************************************************************
* Ralink Tech Inc.
* 5F., No.36, Taiyuan St., Jhubei City,
* Hsinchu County 302,
* Taiwan, R.O.C.
*
* (c) Copyright 2002-2010, Ralink Technology, Inc.
*
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
* *
*************************************************************************/
#define RTMP_MODULE_OS
/*#include "rt_config.h" */
#include "rtmp_comm.h"
#include "rt_os_util.h"
#include "rt_os_net.h"
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
#ifndef SA_SHIRQ
#define SA_SHIRQ IRQF_SHARED
#endif
#endif
// TODO: shiang-6590, remove it when MP
// TODO: End---
#ifdef RTMP_MAC_USB
#ifdef OS_ABL_SUPPORT
MODULE_LICENSE("GPL");
#endif /* OS_ABL_SUPPORT */
#endif /* RTMP_MAC_USB */
#ifdef CONFIG_APSTA_MIXED_SUPPORT
/*UINT32 CW_MAX_IN_BITS;*/
#endif /* CONFIG_APSTA_MIXED_SUPPORT */
/*---------------------------------------------------------------------*/
/* Private Variables Used */
/*---------------------------------------------------------------------*/
PSTRING mac = ""; /* default 00:00:00:00:00:00 */
PSTRING hostname = ""; /* default CMPC */
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,12)
MODULE_PARM (mac, "s");
#else
module_param (mac, charp, 0);
#endif
MODULE_PARM_DESC (mac, "rt28xx: wireless mac addr");
#ifdef OS_ABL_SUPPORT
RTMP_DRV_ABL_OPS RtmpDrvOps, *pRtmpDrvOps = &RtmpDrvOps;
RTMP_NET_ABL_OPS RtmpDrvNetOps, *pRtmpDrvNetOps = &RtmpDrvNetOps;
#endif /* OS_ABL_SUPPORT */
/*---------------------------------------------------------------------*/
/* Prototypes of Functions Used */
/*---------------------------------------------------------------------*/
/* public function prototype */
int rt28xx_close(VOID *net_dev);
int rt28xx_open(VOID *net_dev);
/* private function prototype */
static INT rt28xx_send_packets(IN struct sk_buff *skb_p, IN struct net_device *net_dev);
struct net_device_stats *RT28xx_get_ether_stats(
IN struct net_device *net_dev);
/*
========================================================================
Routine Description:
Close raxx interface.
Arguments:
*net_dev the raxx interface pointer
Return Value:
0 Open OK
otherwise Open Fail
Note:
1. if open fail, kernel will not call the close function.
2. Free memory for
(1) Mlme Memory Handler: MlmeHalt()
(2) TX & RX: RTMPFreeTxRxRingMemory()
(3) BA Reordering: ba_reordering_resource_release()
========================================================================
*/
int MainVirtualIF_close(IN struct net_device *net_dev)
{
VOID *pAd = NULL;
GET_PAD_FROM_NET_DEV(pAd, net_dev);
/* Sanity check for pAd */
if (pAd == NULL)
return 0; /* close ok */
netif_carrier_off(net_dev);
netif_stop_queue(net_dev);
RTMPInfClose(pAd);
#ifdef IFUP_IN_PROBE
;
#else
VIRTUAL_IF_DOWN(pAd);
#endif /* IFUP_IN_PROBE */
RT_MOD_DEC_USE_COUNT();
return 0; /* close ok */
}
/*
========================================================================
Routine Description:
Open raxx interface.
Arguments:
*net_dev the raxx interface pointer
Return Value:
0 Open OK
otherwise Open Fail
Note:
1. if open fail, kernel will not call the close function.
2. Free memory for
(1) Mlme Memory Handler: MlmeHalt()
(2) TX & RX: RTMPFreeTxRxRingMemory()
(3) BA Reordering: ba_reordering_resource_release()
========================================================================
*/
int MainVirtualIF_open(IN struct net_device *net_dev)
{
VOID *pAd = NULL;
GET_PAD_FROM_NET_DEV(pAd, net_dev);
/* Sanity check for pAd */
if (pAd == NULL)
return 0; /* close ok */
#ifdef IFUP_IN_PROBE
while (RTMP_DRIVER_IOCTL_SANITY_CHECK(pAd, NULL) != NDIS_STATUS_SUCCESS)
{
OS_WAIT(10);
DBGPRINT(RT_DEBUG_TRACE, ("Card not ready, NDIS_STATUS_SUCCESS!\n"));
}
#else
if (VIRTUAL_IF_UP(pAd) != 0)
return -1;
#endif /* IFUP_IN_PROBE */
/* increase MODULE use count */
RT_MOD_INC_USE_COUNT();
netif_start_queue(net_dev);
netif_carrier_on(net_dev);
netif_wake_queue(net_dev);
return 0;
}
/*
========================================================================
Routine Description:
Close raxx interface.
Arguments:
*net_dev the raxx interface pointer
Return Value:
0 Open OK
otherwise Open Fail
Note:
1. if open fail, kernel will not call the close function.
2. Free memory for
(1) Mlme Memory Handler: MlmeHalt()
(2) TX & RX: RTMPFreeTxRxRingMemory()
(3) BA Reordering: ba_reordering_resource_release()
========================================================================
*/
int rt28xx_close(VOID *dev)
{
struct net_device * net_dev = (struct net_device *)dev;
VOID *pAd = NULL;
GET_PAD_FROM_NET_DEV(pAd, net_dev);
DBGPRINT(RT_DEBUG_TRACE, ("===> rt28xx_close\n"));
if (pAd == NULL)
return 0; /* close ok */
#ifdef CONFIG_STA_SUPPORT
RTMPDrvSTAClose(pAd, net_dev);
#endif
#ifdef VENDOR_FEATURE2_SUPPORT
printk("Number of Packet Allocated in open = %lu\n", OS_NumOfPktAlloc);
printk("Number of Packet Freed in open = %lu\n", OS_NumOfPktFree);
#endif /* VENDOR_FEATURE2_SUPPORT */
DBGPRINT(RT_DEBUG_TRACE, ("<=== rt28xx_close\n"));
return 0;
}
/*
========================================================================
Routine Description:
Open raxx interface.
Arguments:
*net_dev the raxx interface pointer
Return Value:
0 Open OK
otherwise Open Fail
Note:
========================================================================
*/
int rt28xx_open(VOID *dev)
{
struct net_device * net_dev = (struct net_device *)dev;
VOID *pAd = NULL;
int retval = 0;
ULONG OpMode;
#ifdef CONFIG_STA_SUPPORT
#ifdef CONFIG_PM
#ifdef USB_SUPPORT_SELECTIVE_SUSPEND
struct usb_interface *intf;
struct usb_device *pUsb_Dev;
INT pm_usage_cnt;
#endif /* USB_SUPPORT_SELECTIVE_SUSPEND */
#endif /* CONFIG_PM */
#endif /* CONFIG_STA_SUPPORT */
/* sanity check */
if (sizeof(ra_dma_addr_t) < sizeof(dma_addr_t))
DBGPRINT(RT_DEBUG_ERROR, ("Fatal error for DMA address size!!!\n"));
GET_PAD_FROM_NET_DEV(pAd, net_dev);
/* Sanity check for pAd */
if (pAd == NULL)
{
/* if 1st open fail, pAd will be free;
So the net_dev->priv will be NULL in 2rd open */
return -1;
}
RTMP_DRIVER_MCU_SLEEP_CLEAR(pAd);
RTMP_DRIVER_OP_MODE_GET(pAd, &OpMode);
#ifdef CONFIG_STA_SUPPORT
#ifdef CONFIG_PM
#ifdef USB_SUPPORT_SELECTIVE_SUSPEND
RTMP_DRIVER_USB_DEV_GET(pAd, &pUsb_Dev);
RTMP_DRIVER_USB_INTF_GET(pAd, &intf);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)
pm_usage_cnt = atomic_read(&intf->pm_usage_cnt);
#else
pm_usage_cnt = intf->pm_usage_cnt;
#endif
if (pm_usage_cnt == 0)
{
int res=1;
res = usb_autopm_get_interface(intf);
if (res)
{
DBGPRINT(RT_DEBUG_ERROR, ("rt28xx_open autopm_resume fail ------\n"));
return (-1);
}
}
#endif /* USB_SUPPORT_SELECTIVE_SUSPEND */
#endif /* CONFIG_PM */
#endif /* CONFIG_STA_SUPPORT */
#ifdef CONFIG_APSTA_MIXED_SUPPORT
if (OpMode == OPMODE_AP)
{
/*CW_MAX_IN_BITS = 6; */
RTMP_DRIVER_MAX_IN_BITS_SET(pAd, 6);
}
else if (OpMode == OPMODE_STA)
{
/*CW_MAX_IN_BITS = 10; */
RTMP_DRIVER_MAX_IN_BITS_SET(pAd, 10);
}
#endif /* CONFIG_APSTA_MIXED_SUPPORT */
#if WIRELESS_EXT >= 12
/* if (RT_DEV_PRIV_FLAGS_GET(net_dev) == INT_MAIN) */
if (RTMP_DRIVER_MAIN_INF_CHECK(pAd, RT_DEV_PRIV_FLAGS_GET(net_dev)) == NDIS_STATUS_SUCCESS)
{
#ifdef CONFIG_APSTA_MIXED_SUPPORT
if (OpMode == OPMODE_AP)
net_dev->wireless_handlers = (struct iw_handler_def *) &rt28xx_ap_iw_handler_def;
#endif /* CONFIG_APSTA_MIXED_SUPPORT */
#ifdef CONFIG_STA_SUPPORT
if (OpMode == OPMODE_STA)
net_dev->wireless_handlers = (struct iw_handler_def *) &rt28xx_iw_handler_def;
#endif /* CONFIG_STA_SUPPORT */
}
#endif /* WIRELESS_EXT >= 12 */
/* Request interrupt service routine for PCI device */
/* register the interrupt routine with the os */
/*
AP Channel auto-selection will be run in rt28xx_init(),
so we must reqister IRQ hander here.
*/
RtmpOSIRQRequest(net_dev);
/* Init IRQ parameters stored in pAd */
/* RTMP_IRQ_INIT(pAd); */
RTMP_DRIVER_IRQ_INIT(pAd);
/* Chip & other init */
if (rt28xx_init(pAd, mac, hostname) == FALSE)
goto err;
#ifdef MBSS_SUPPORT
/* the function can not be moved to RT2860_probe() even register_netdev()
is changed as register_netdevice().
Or in some PC, kernel will panic (Fedora 4) */
RT28xx_MBSS_Init(pAd, net_dev);
#endif /* MBSS_SUPPORT */
#ifdef WDS_SUPPORT
RT28xx_WDS_Init(pAd, net_dev);
#endif /* WDS_SUPPORT */
#ifdef APCLI_SUPPORT
RT28xx_ApCli_Init(pAd, net_dev);
#endif /* APCLI_SUPPORT */
#ifdef LINUX
#ifdef RT_CFG80211_SUPPORT
RTMP_DRIVER_CFG80211_START(pAd);
#endif /* RT_CFG80211_SUPPORT */
#endif /* LINUX */
#ifdef CONFIG_STA_SUPPORT
RTMPDrvSTAOpen(pAd);
#endif
return (retval);
err:
RTMP_DRIVER_IRQ_RELEASE(pAd);
return -1;
}
PNET_DEV RtmpPhyNetDevInit(
IN VOID *pAd,
IN RTMP_OS_NETDEV_OP_HOOK *pNetDevHook)
{
struct net_device *net_dev = NULL;
ULONG InfId, OpMode;
RTMP_DRIVER_MAIN_INF_GET(pAd, &InfId);
/* net_dev = RtmpOSNetDevCreate(pAd, INT_MAIN, 0, sizeof(PRTMP_ADAPTER), INF_MAIN_DEV_NAME); */
RTMP_DRIVER_MAIN_INF_CREATE(pAd, &net_dev);
if (net_dev == NULL)
{
printk("RtmpPhyNetDevInit(): creation failed for main physical net device!\n");
return NULL;
}
NdisZeroMemory((unsigned char *)pNetDevHook, sizeof(RTMP_OS_NETDEV_OP_HOOK));
pNetDevHook->open = MainVirtualIF_open;
pNetDevHook->stop = MainVirtualIF_close;
pNetDevHook->xmit = rt28xx_send_packets;
#ifdef IKANOS_VX_1X0
pNetDevHook->xmit = IKANOS_DataFramesTx;
#endif /* IKANOS_VX_1X0 */
pNetDevHook->ioctl = rt28xx_ioctl;
pNetDevHook->priv_flags = InfId; /*INT_MAIN; */
pNetDevHook->get_stats = RT28xx_get_ether_stats;
pNetDevHook->needProtcted = FALSE;
#if (WIRELESS_EXT < 21) && (WIRELESS_EXT >= 12)
pNetDevHook->get_wstats = rt28xx_get_wireless_stats;
#endif
RTMP_DRIVER_OP_MODE_GET(pAd, &OpMode);
#ifdef CONFIG_STA_SUPPORT
#if WIRELESS_EXT >= 12
if (OpMode == OPMODE_STA)
{
pNetDevHook->iw_handler = (void *)&rt28xx_iw_handler_def;
}
#endif /*WIRELESS_EXT >= 12 */
#endif /* CONFIG_STA_SUPPORT */
#ifdef CONFIG_APSTA_MIXED_SUPPORT
#if WIRELESS_EXT >= 12
if (OpMode == OPMODE_AP)
{
pNetDevHook->iw_handler = &rt28xx_ap_iw_handler_def;
}
#endif /*WIRELESS_EXT >= 12 */
#endif /* CONFIG_APSTA_MIXED_SUPPORT */
/* put private data structure */
RTMP_OS_NETDEV_SET_PRIV(net_dev, pAd);
/* double-check if pAd is associated with the net_dev */
if (RTMP_OS_NETDEV_GET_PRIV(net_dev) == NULL)
{
RtmpOSNetDevFree(net_dev);
return NULL;
}
RTMP_DRIVER_NET_DEV_SET(pAd, net_dev);
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
SET_MODULE_OWNER(net_dev);
#endif
return net_dev;
}
VOID *RtmpNetEthConvertDevSearch(
IN VOID *net_dev_,
IN UCHAR *pData)
{
struct net_device *pNetDev;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)
struct net_device *net_dev = (struct net_device *)net_dev_;
struct net *net;
net = dev_net(net_dev);
BUG_ON(!net);
for_each_netdev(net, pNetDev)
#else
struct net *net;
struct net_device *net_dev = (struct net_device *)net_dev_;
BUG_ON(!net_dev->nd_net);
net = net_dev->nd_net;
for_each_netdev(net, pNetDev)
#endif
#else
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
for_each_netdev(pNetDev)
#else
for (pNetDev = dev_base; pNetDev; pNetDev = pNetDev->next)
#endif
#endif
{
if ((pNetDev->type == ARPHRD_ETHER)
&& NdisEqualMemory(pNetDev->dev_addr, &pData[6], pNetDev->addr_len))
break;
}
return (VOID *)pNetDev;
}
/*
========================================================================
Routine Description:
The entry point for Linux kernel sent packet to our driver.
Arguments:
sk_buff *skb the pointer refer to a sk_buffer.
Return Value:
0
Note:
This function is the entry point of Tx Path for Os delivery packet to
our driver. You only can put OS-depened & STA/AP common handle procedures
in here.
========================================================================
*/
int rt28xx_packet_xmit(void *skbsrc)
{
struct sk_buff *skb = (struct sk_buff *)skbsrc;
struct net_device *net_dev = skb->dev;
VOID *pAd = NULL;
PNDIS_PACKET pPacket = (PNDIS_PACKET) skb;
GET_PAD_FROM_NET_DEV(pAd, net_dev);
return RTMPSendPackets((NDIS_HANDLE)pAd, (PPNDIS_PACKET) &pPacket, 1,
skb->len, RtmpNetEthConvertDevSearch);
}
/*
========================================================================
Routine Description:
Send a packet to WLAN.
Arguments:
skb_p points to our adapter
dev_p which WLAN network interface
Return Value:
0: transmit successfully
otherwise: transmit fail
Note:
========================================================================
*/
static int rt28xx_send_packets(
IN struct sk_buff *skb_p,
IN struct net_device *net_dev)
{
if (!(RTMP_OS_NETDEV_STATE_RUNNING(net_dev)))
{
RELEASE_NDIS_PACKET(NULL, (PNDIS_PACKET)skb_p, NDIS_STATUS_FAILURE);
return 0;
}
NdisZeroMemory((PUCHAR)&skb_p->cb[CB_OFF], 15);
RTMP_SET_PACKET_NET_DEVICE_MBSSID(skb_p, MAIN_MBSSID);
MEM_DBG_PKT_ALLOC_INC(skb_p);
return rt28xx_packet_xmit(skb_p);
}
#if WIRELESS_EXT >= 12
/* This function will be called when query /proc */
struct iw_statistics *rt28xx_get_wireless_stats(struct net_device *net_dev)
{
VOID *pAd = NULL;
struct iw_statistics *pStats;
RT_CMD_IW_STATS DrvIwStats, *pDrvIwStats = &DrvIwStats;
GET_PAD_FROM_NET_DEV(pAd, net_dev);
DBGPRINT(RT_DEBUG_TRACE, ("rt28xx_get_wireless_stats --->\n"));
pDrvIwStats->priv_flags = RT_DEV_PRIV_FLAGS_GET(net_dev);
pDrvIwStats->dev_addr = (PUCHAR)net_dev->dev_addr;
if (RTMP_DRIVER_IW_STATS_GET(pAd, pDrvIwStats) != NDIS_STATUS_SUCCESS)
return NULL;
pStats = (struct iw_statistics *)(pDrvIwStats->pStats);
pStats->status = 0; /* Status - device dependent for now */
pStats->qual.updated = 1; /* Flags to know if updated */
#ifdef IW_QUAL_DBM
pStats->qual.updated |= IW_QUAL_DBM; /* Level + Noise are dBm */
#endif /* IW_QUAL_DBM */
pStats->qual.qual = pDrvIwStats->qual;
pStats->qual.level = pDrvIwStats->level;
pStats->qual.noise = pDrvIwStats->noise;
pStats->discard.nwid = 0; /* Rx : Wrong nwid/essid */
pStats->miss.beacon = 0; /* Missed beacons/superframe */
DBGPRINT(RT_DEBUG_TRACE, ("<--- rt28xx_get_wireless_stats\n"));
return pStats;
}
#endif /* WIRELESS_EXT */
INT rt28xx_ioctl(
IN PNET_DEV net_dev,
INOUT struct ifreq *rq,
IN INT cmd)
{
VOID *pAd = NULL;
INT ret = 0;
ULONG OpMode;
GET_PAD_FROM_NET_DEV(pAd, net_dev);
if (pAd == NULL)
{
/* if 1st open fail, pAd will be free;
So the net_dev->priv will be NULL in 2rd open */
return -ENETDOWN;
}
RTMP_DRIVER_OP_MODE_GET(pAd, &OpMode);
#ifdef CONFIG_STA_SUPPORT
/* IF_DEV_CONFIG_OPMODE_ON_STA(pAd) */
RT_CONFIG_IF_OPMODE_ON_STA(OpMode)
{
ret = rt28xx_sta_ioctl(net_dev, rq, cmd);
}
#endif /* CONFIG_STA_SUPPORT */
return ret;
}
/*
========================================================================
Routine Description:
return ethernet statistics counter
Arguments:
net_dev Pointer to net_device
Return Value:
net_device_stats*
Note:
========================================================================
*/
struct net_device_stats *RT28xx_get_ether_stats(
IN struct net_device *net_dev)
{
VOID *pAd = NULL;
struct net_device_stats *pStats;
if (net_dev)
GET_PAD_FROM_NET_DEV(pAd, net_dev);
if (pAd)
{
RT_CMD_STATS DrvStats, *pDrvStats = &DrvStats;
//assign net device for RTMP_DRIVER_INF_STATS_GET()
pDrvStats->pNetDev = net_dev;
RTMP_DRIVER_INF_STATS_GET(pAd, pDrvStats);
pStats = (struct net_device_stats *)(pDrvStats->pStats);
pStats->rx_packets = pDrvStats->rx_packets;
pStats->tx_packets = pDrvStats->tx_packets;
pStats->rx_bytes = pDrvStats->rx_bytes;
pStats->tx_bytes = pDrvStats->tx_bytes;
pStats->rx_errors = pDrvStats->rx_errors;
pStats->tx_errors = pDrvStats->tx_errors;
pStats->rx_dropped = 0;
pStats->tx_dropped = 0;
pStats->multicast = pDrvStats->multicast;
pStats->collisions = pDrvStats->collisions;
pStats->rx_length_errors = 0;
pStats->rx_over_errors = pDrvStats->rx_over_errors;
pStats->rx_crc_errors = 0;/*pAd->WlanCounters.FCSErrorCount; // recved pkt with crc error */
pStats->rx_frame_errors = pDrvStats->rx_frame_errors;
pStats->rx_fifo_errors = pDrvStats->rx_fifo_errors;
pStats->rx_missed_errors = 0; /* receiver missed packet */
/* detailed tx_errors */
pStats->tx_aborted_errors = 0;
pStats->tx_carrier_errors = 0;
pStats->tx_fifo_errors = 0;
pStats->tx_heartbeat_errors = 0;
pStats->tx_window_errors = 0;
/* for cslip etc */
pStats->rx_compressed = 0;
pStats->tx_compressed = 0;
return pStats;
}
else
return NULL;
}
BOOLEAN RtmpPhyNetDevExit(
IN VOID *pAd,
IN PNET_DEV net_dev)
{
#ifdef INF_PPA_SUPPORT
RTMP_DRIVER_INF_PPA_EXIT(pAd);
#endif /* INF_PPA_SUPPORT */
/* Unregister network device */
if (net_dev != NULL)
{
printk("RtmpOSNetDevDetach(): RtmpOSNetDeviceDetach(), dev->name=%s!\n", net_dev->name);
RtmpOSNetDevDetach(net_dev);
}
return TRUE;
}
/*******************************************************************************
Device IRQ related functions.
*******************************************************************************/
int RtmpOSIRQRequest(IN PNET_DEV pNetDev)
{
ULONG infType;
VOID *pAd = NULL;
int retval = 0;
GET_PAD_FROM_NET_DEV(pAd, pNetDev);
ASSERT(pAd);
RTMP_DRIVER_INF_TYPE_GET(pAd, &infType);
return retval;
}
#ifdef WDS_SUPPORT
/*
========================================================================
Routine Description:
return ethernet statistics counter
Arguments:
net_dev Pointer to net_device
Return Value:
net_device_stats*
Note:
========================================================================
*/
struct net_device_stats *RT28xx_get_wds_ether_stats(
IN PNET_DEV net_dev)
{
VOID *pAd = NULL;
/* INT WDS_apidx = 0,index; */
struct net_device_stats *pStats;
RT_CMD_STATS WdsStats, *pWdsStats = &WdsStats;
if (net_dev) {
GET_PAD_FROM_NET_DEV(pAd, net_dev);
}
/* if (RT_DEV_PRIV_FLAGS_GET(net_dev) == INT_WDS) */
{
if (pAd)
{
pWdsStats->pNetDev = net_dev;
if (RTMP_COM_IoctlHandle(pAd, NULL, CMD_RTPRIV_IOCTL_WDS_STATS_GET,
0, pWdsStats, RT_DEV_PRIV_FLAGS_GET(net_dev)) != NDIS_STATUS_SUCCESS)
return NULL;
pStats = (struct net_device_stats *)pWdsStats->pStats; /*pAd->stats; */
pStats->rx_packets = pWdsStats->rx_packets; /*pAd->WdsTab.WdsEntry[WDS_apidx].WdsCounter.ReceivedFragmentCount.QuadPart; */
pStats->tx_packets = pWdsStats->tx_packets; /*pAd->WdsTab.WdsEntry[WDS_apidx].WdsCounter.TransmittedFragmentCount.QuadPart; */
pStats->rx_bytes = pWdsStats->rx_bytes; /*pAd->WdsTab.WdsEntry[WDS_apidx].WdsCounter.ReceivedByteCount; */
pStats->tx_bytes = pWdsStats->tx_bytes; /*pAd->WdsTab.WdsEntry[WDS_apidx].WdsCounter.TransmittedByteCount; */
pStats->rx_errors = pWdsStats->rx_errors; /*pAd->WdsTab.WdsEntry[WDS_apidx].WdsCounter.RxErrors; */
pStats->tx_errors = pWdsStats->tx_errors; /*pAd->WdsTab.WdsEntry[WDS_apidx].WdsCounter.TxErrors; */
pStats->rx_dropped = 0;
pStats->tx_dropped = 0;
pStats->multicast = pWdsStats->multicast; /*pAd->WdsTab.WdsEntry[WDS_apidx].WdsCounter.MulticastReceivedFrameCount.QuadPart; // multicast packets received */
pStats->collisions = pWdsStats->collisions; /*pAd->WdsTab.WdsEntry[WDS_apidx].WdsCounter.OneCollision + pAd->WdsTab.WdsEntry[index].WdsCounter.MoreCollisions; // Collision packets */
pStats->rx_length_errors = 0;
pStats->rx_over_errors = pWdsStats->rx_over_errors; /*pAd->WdsTab.WdsEntry[WDS_apidx].WdsCounter.RxNoBuffer; // receiver ring buff overflow */
pStats->rx_crc_errors = 0;/*pAd->WlanCounters.FCSErrorCount; // recved pkt with crc error */
pStats->rx_frame_errors = pWdsStats->rx_frame_errors; /*pAd->WdsTab.WdsEntry[WDS_apidx].WdsCounter.RcvAlignmentErrors; // recv'd frame alignment error */
pStats->rx_fifo_errors = pWdsStats->rx_fifo_errors; /*pAd->WdsTab.WdsEntry[WDS_apidx].WdsCounter.RxNoBuffer; // recv'r fifo overrun */
pStats->rx_missed_errors = 0; /* receiver missed packet */
/* detailed tx_errors */
pStats->tx_aborted_errors = 0;
pStats->tx_carrier_errors = 0;
pStats->tx_fifo_errors = 0;
pStats->tx_heartbeat_errors = 0;
pStats->tx_window_errors = 0;
/* for cslip etc */
pStats->rx_compressed = 0;
pStats->tx_compressed = 0;
return pStats;
}
else
return NULL;
}
/* else */
/* return NULL; */
}
#endif /* WDS_SUPPORT */