• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/linux/linux-2.6/drivers/char/rtl8365mb/
1/*
2 * Copyright (C) 2013 Realtek Semiconductor Corp.
3 * All Rights Reserved.
4 *
5 * This program is the proprietary software of Realtek Semiconductor
6 * Corporation and/or its licensors, and only be used, duplicated,
7 * modified or distributed under the authorized license from Realtek.
8 *
9 * ANY USE OF THE SOFTWARE OTHER THAN AS AUTHORIZED UNDER
10 * THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
11 *
12 * $Revision: 49198 $
13 * $Date: 2014-07-14 18:32:30 +0800 (������, 14 ������ 2014) $
14 *
15 * Purpose : RTK switch high-level API for RTL8367/RTL8367C
16 * Feature : Here is a list of all functions and variables in MIB module.
17 *
18 */
19
20#include <rtk_switch.h>
21#include <rtk_error.h>
22#include <stat.h>
23#ifndef __KERNEL__
24#include <string.h>
25#else
26#include <linux/string.h>
27#endif
28
29#include <rtl8367c_asicdrv.h>
30#include <rtl8367c_asicdrv_mib.h>
31
32/* Function Name:
33 *      rtk_stat_global_reset
34 * Description:
35 *      Reset global MIB counter.
36 * Input:
37 *      None
38 * Output:
39 *      None
40 * Return:
41 *      RT_ERR_OK           - OK
42 *      RT_ERR_FAILED       - Failed
43 *      RT_ERR_SMI          - SMI access error
44 * Note:
45 *      Reset MIB counter of ports. API will use global reset while port mask is all-ports.
46 */
47rtk_api_ret_t rtk_stat_global_reset(void)
48{
49    rtk_api_ret_t retVal;
50
51    /* Check initialization state */
52    RTK_CHK_INIT_STATE();
53
54    if ((retVal = rtl8367c_setAsicMIBsCounterReset(TRUE,FALSE, 0)) != RT_ERR_OK)
55        return retVal;
56
57    return RT_ERR_OK;
58}
59
60/* Function Name:
61 *      rtk_stat_port_reset
62 * Description:
63 *      Reset per port MIB counter by port.
64 * Input:
65 *      port - port id.
66 * Output:
67 *      None
68 * Return:
69 *      RT_ERR_OK           - OK
70 *      RT_ERR_FAILED       - Failed
71 *      RT_ERR_SMI          - SMI access error
72 * Note:
73 *
74 */
75rtk_api_ret_t rtk_stat_port_reset(rtk_port_t port)
76{
77    rtk_api_ret_t retVal;
78
79    /* Check initialization state */
80    RTK_CHK_INIT_STATE();
81
82    /* Check port valid */
83    RTK_CHK_PORT_VALID(port);
84
85    if ((retVal = rtl8367c_setAsicMIBsCounterReset(FALSE,FALSE,1 << rtk_switch_port_L2P_get(port))) != RT_ERR_OK)
86        return retVal;
87
88    return RT_ERR_OK;
89}
90
91/* Function Name:
92 *      rtk_stat_queueManage_reset
93 * Description:
94 *      Reset queue manage MIB counter.
95 * Input:
96 *      None
97 * Output:
98 *      None
99 * Return:
100 *      RT_ERR_OK           - OK
101 *      RT_ERR_FAILED       - Failed
102 *      RT_ERR_SMI          - SMI access error
103 * Note:
104 *
105 */
106rtk_api_ret_t rtk_stat_queueManage_reset(void)
107{
108    rtk_api_ret_t retVal;
109
110    /* Check initialization state */
111    RTK_CHK_INIT_STATE();
112
113    if ((retVal = rtl8367c_setAsicMIBsCounterReset(FALSE,TRUE,0)) != RT_ERR_OK)
114        return retVal;
115
116    return RT_ERR_OK;
117}
118
119
120/* Function Name:
121 *      rtk_stat_global_get
122 * Description:
123 *      Get global MIB counter
124 * Input:
125 *      cntr_idx - global counter index.
126 * Output:
127 *      pCntr - global counter value.
128 * Return:
129 *      RT_ERR_OK           - OK
130 *      RT_ERR_FAILED       - Failed
131 *      RT_ERR_SMI          - SMI access error
132 *      RT_ERR_INPUT 		- Invalid input parameters.
133 * Note:
134 *      Get global MIB counter by index definition.
135 */
136rtk_api_ret_t rtk_stat_global_get(rtk_stat_global_type_t cntr_idx, rtk_stat_counter_t *pCntr)
137{
138    rtk_api_ret_t retVal;
139
140    /* Check initialization state */
141    RTK_CHK_INIT_STATE();
142
143    if(NULL == pCntr)
144        return RT_ERR_NULL_POINTER;
145
146    if (cntr_idx!=DOT1D_TP_LEARNED_ENTRY_DISCARDS_INDEX)
147        return RT_ERR_STAT_INVALID_GLOBAL_CNTR;
148
149    if ((retVal = rtl8367c_getAsicMIBsCounter(0, cntr_idx, pCntr)) != RT_ERR_OK)
150        return retVal;
151
152    return RT_ERR_OK;
153}
154
155/* Function Name:
156 *      rtk_stat_global_getAll
157 * Description:
158 *      Get all global MIB counter
159 * Input:
160 *      None
161 * Output:
162 *      pGlobal_cntrs - global counter structure.
163 * Return:
164 *      RT_ERR_OK           - OK
165 *      RT_ERR_FAILED       - Failed
166 *      RT_ERR_SMI          - SMI access error
167 *      RT_ERR_INPUT 		- Invalid input parameters.
168 * Note:
169 *      Get all global MIB counter by index definition.
170 */
171rtk_api_ret_t rtk_stat_global_getAll(rtk_stat_global_cntr_t *pGlobal_cntrs)
172{
173    rtk_api_ret_t retVal;
174
175    /* Check initialization state */
176    RTK_CHK_INIT_STATE();
177
178    if(NULL == pGlobal_cntrs)
179        return RT_ERR_NULL_POINTER;
180
181    if ((retVal = rtl8367c_getAsicMIBsCounter(0,DOT1D_TP_LEARNED_ENTRY_DISCARDS_INDEX, &pGlobal_cntrs->dot1dTpLearnedEntryDiscards)) != RT_ERR_OK)
182        return retVal;
183
184    return RT_ERR_OK;
185}
186
187#define MIB_NOT_SUPPORT     (0xFFFF)
188static rtk_api_ret_t _get_asic_mib_idx(rtk_stat_port_type_t cnt_idx, RTL8367C_MIBCOUNTER *pMib_idx)
189{
190    RTL8367C_MIBCOUNTER mib_asic_idx[STAT_PORT_CNTR_END]=
191    {
192        ifInOctets,                     /* STAT_IfInOctets */
193        dot3StatsFCSErrors,             /* STAT_Dot3StatsFCSErrors */
194        dot3StatsSymbolErrors,          /* STAT_Dot3StatsSymbolErrors */
195        dot3InPauseFrames,              /* STAT_Dot3InPauseFrames */
196        dot3ControlInUnknownOpcodes,    /* STAT_Dot3ControlInUnknownOpcodes */
197        etherStatsFragments,            /* STAT_EtherStatsFragments */
198        etherStatsJabbers,              /* STAT_EtherStatsJabbers */
199        ifInUcastPkts,                  /* STAT_IfInUcastPkts */
200        etherStatsDropEvents,           /* STAT_EtherStatsDropEvents */
201        etherStatsOctets,               /* STAT_EtherStatsOctets */
202        etherStatsUnderSizePkts,        /* STAT_EtherStatsUnderSizePkts */
203        etherOversizeStats,             /* STAT_EtherOversizeStats */
204        etherStatsPkts64Octets,         /* STAT_EtherStatsPkts64Octets */
205        etherStatsPkts65to127Octets,    /* STAT_EtherStatsPkts65to127Octets */
206        etherStatsPkts128to255Octets,   /* STAT_EtherStatsPkts128to255Octets */
207        etherStatsPkts256to511Octets,   /* STAT_EtherStatsPkts256to511Octets */
208        etherStatsPkts512to1023Octets,  /* STAT_EtherStatsPkts512to1023Octets */
209        etherStatsPkts1024to1518Octets, /* STAT_EtherStatsPkts1024to1518Octets */
210        ifInMulticastPkts,              /* STAT_EtherStatsMulticastPkts */
211        ifInBroadcastPkts,              /* STAT_EtherStatsBroadcastPkts */
212        ifOutOctets,                    /* STAT_IfOutOctets */
213        dot3StatsSingleCollisionFrames, /* STAT_Dot3StatsSingleCollisionFrames */
214        dot3StatMultipleCollisionFrames,/* STAT_Dot3StatsMultipleCollisionFrames */
215        dot3sDeferredTransmissions,     /* STAT_Dot3StatsDeferredTransmissions */
216        dot3StatsLateCollisions,        /* STAT_Dot3StatsLateCollisions */
217        etherStatsCollisions,           /* STAT_EtherStatsCollisions */
218        dot3StatsExcessiveCollisions,   /* STAT_Dot3StatsExcessiveCollisions */
219        dot3OutPauseFrames,             /* STAT_Dot3OutPauseFrames */
220        MIB_NOT_SUPPORT,                /* STAT_Dot1dBasePortDelayExceededDiscards */
221        dot1dTpPortInDiscards,          /* STAT_Dot1dTpPortInDiscards */
222        ifOutUcastPkts,                 /* STAT_IfOutUcastPkts */
223        ifOutMulticastPkts,             /* STAT_IfOutMulticastPkts */
224        ifOutBroadcastPkts,             /* STAT_IfOutBroadcastPkts */
225        outOampduPkts,                  /* STAT_OutOampduPkts */
226        inOampduPkts,                   /* STAT_InOampduPkts */
227        MIB_NOT_SUPPORT,                /* STAT_PktgenPkts */
228        inMldChecksumError,             /* STAT_InMldChecksumError */
229        inIgmpChecksumError,            /* STAT_InIgmpChecksumError */
230        inMldSpecificQuery,             /* STAT_InMldSpecificQuery */
231        inMldGeneralQuery,              /* STAT_InMldGeneralQuery */
232        inIgmpSpecificQuery,            /* STAT_InIgmpSpecificQuery */
233        inIgmpGeneralQuery,             /* STAT_InIgmpGeneralQuery */
234        inMldLeaves,                    /* STAT_InMldLeaves */
235        inIgmpLeaves,          			/* STAT_InIgmpInterfaceLeaves */
236        inIgmpJoinsSuccess,             /* STAT_InIgmpJoinsSuccess */
237        inIgmpJoinsFail,                /* STAT_InIgmpJoinsFail */
238        inMldJoinsSuccess,              /* STAT_InMldJoinsSuccess */
239        inMldJoinsFail,                 /* STAT_InMldJoinsFail */
240        inReportSuppressionDrop,        /* STAT_InReportSuppressionDrop */
241        inLeaveSuppressionDrop,         /* STAT_InLeaveSuppressionDrop */
242        outIgmpReports,                 /* STAT_OutIgmpReports */
243        outIgmpLeaves,                  /* STAT_OutIgmpLeaves */
244        outIgmpGeneralQuery,            /* STAT_OutIgmpGeneralQuery */
245        outIgmpSpecificQuery,           /* STAT_OutIgmpSpecificQuery */
246        outMldReports,                  /* STAT_OutMldReports */
247        outMldLeaves,                   /* STAT_OutMldLeaves */
248        outMldGeneralQuery,             /* STAT_OutMldGeneralQuery */
249        outMldSpecificQuery,            /* STAT_OutMldSpecificQuery */
250        inKnownMulticastPkts,           /* STAT_InKnownMulticastPkts */
251        ifInMulticastPkts,              /* STAT_IfInMulticastPkts */
252        ifInBroadcastPkts,              /* STAT_IfInBroadcastPkts */
253        ifOutDiscards                   /* STAT_IfOutDiscards */
254    };
255
256    if(cnt_idx >= STAT_PORT_CNTR_END)
257        return RT_ERR_STAT_INVALID_PORT_CNTR;
258
259    if(mib_asic_idx[cnt_idx] == MIB_NOT_SUPPORT)
260        return RT_ERR_CHIP_NOT_SUPPORTED;
261
262    *pMib_idx = mib_asic_idx[cnt_idx];
263    return RT_ERR_OK;
264}
265
266/* Function Name:
267 *      rtk_stat_port_get
268 * Description:
269 *      Get per port MIB counter by index
270 * Input:
271 *      port        - port id.
272 *      cntr_idx    - port counter index.
273 * Output:
274 *      pCntr - MIB retrived counter.
275 * Return:
276 *      RT_ERR_OK           - OK
277 *      RT_ERR_FAILED       - Failed
278 *      RT_ERR_SMI          - SMI access error
279 * Note:
280 *      Get per port MIB counter by index definition.
281 */
282rtk_api_ret_t rtk_stat_port_get(rtk_port_t port, rtk_stat_port_type_t cntr_idx, rtk_stat_counter_t *pCntr)
283{
284    rtk_api_ret_t       retVal;
285    RTL8367C_MIBCOUNTER mib_idx;
286    rtk_stat_counter_t  second_cnt;
287
288    /* Check initialization state */
289    RTK_CHK_INIT_STATE();
290
291    if(NULL == pCntr)
292        return RT_ERR_NULL_POINTER;
293
294    /* Check port valid */
295    RTK_CHK_PORT_VALID(port);
296
297    if (cntr_idx>=STAT_PORT_CNTR_END)
298        return RT_ERR_STAT_INVALID_PORT_CNTR;
299
300    if((retVal = _get_asic_mib_idx(cntr_idx, &mib_idx)) != RT_ERR_OK)
301        return retVal;
302
303    if(mib_idx == MIB_NOT_SUPPORT)
304        return RT_ERR_CHIP_NOT_SUPPORTED;
305
306    if ((retVal = rtl8367c_getAsicMIBsCounter(rtk_switch_port_L2P_get(port), mib_idx, pCntr)) != RT_ERR_OK)
307        return retVal;
308
309    if(cntr_idx == STAT_EtherStatsMulticastPkts)
310    {
311        if((retVal = _get_asic_mib_idx(STAT_IfOutMulticastPkts, &mib_idx)) != RT_ERR_OK)
312            return retVal;
313
314        if((retVal = rtl8367c_getAsicMIBsCounter(rtk_switch_port_L2P_get(port), mib_idx, &second_cnt)) != RT_ERR_OK)
315            return retVal;
316
317        *pCntr += second_cnt;
318    }
319
320    if(cntr_idx == STAT_EtherStatsBroadcastPkts)
321    {
322        if((retVal = _get_asic_mib_idx(STAT_IfOutBroadcastPkts, &mib_idx)) != RT_ERR_OK)
323            return retVal;
324
325        if((retVal = rtl8367c_getAsicMIBsCounter(rtk_switch_port_L2P_get(port), mib_idx, &second_cnt)) != RT_ERR_OK)
326            return retVal;
327
328        *pCntr += second_cnt;
329    }
330
331    return RT_ERR_OK;
332}
333
334/* Function Name:
335 *      rtk_stat_port_getAll
336 * Description:
337 *      Get all counters of one specified port in the specified device.
338 * Input:
339 *      port - port id.
340 * Output:
341 *      pPort_cntrs - buffer pointer of counter value.
342 * Return:
343 *      RT_ERR_OK           - OK
344 *      RT_ERR_FAILED       - Failed
345 *      RT_ERR_SMI          - SMI access error
346 *      RT_ERR_INPUT 		- Invalid input parameters.
347 * Note:
348 *      Get all MIB counters of one port.
349 */
350rtk_api_ret_t rtk_stat_port_getAll(rtk_port_t port, rtk_stat_port_cntr_t *pPort_cntrs)
351{
352    rtk_api_ret_t retVal;
353    rtk_uint32 mibIndex;
354    rtk_uint64 mibCounter;
355    rtk_uint32 *accessPtr;
356    /* address offset to MIBs counter */
357    CONST_T rtk_uint16 mibLength[STAT_PORT_CNTR_END]= {
358        2,1,1,1,1,1,1,1,1,
359        2,1,1,1,1,1,1,1,1,1,1,
360        2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
361        1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
362
363    /* Check initialization state */
364    RTK_CHK_INIT_STATE();
365
366    if(NULL == pPort_cntrs)
367        return RT_ERR_NULL_POINTER;
368
369    /* Check port valid */
370    RTK_CHK_PORT_VALID(port);
371
372    accessPtr = (rtk_uint32*)pPort_cntrs;
373    for (mibIndex=0;mibIndex<STAT_PORT_CNTR_END;mibIndex++)
374    {
375        if ((retVal = rtk_stat_port_get(port, mibIndex, &mibCounter)) != RT_ERR_OK)
376        {
377            if (retVal == RT_ERR_CHIP_NOT_SUPPORTED)
378                mibCounter = 0;
379            else
380                return retVal;
381        }
382
383        if (2 == mibLength[mibIndex])
384            *(rtk_uint64*)accessPtr = mibCounter;
385        else if (1 == mibLength[mibIndex])
386            *accessPtr = mibCounter;
387        else
388            return RT_ERR_FAILED;
389
390        accessPtr+=mibLength[mibIndex];
391    }
392
393    return RT_ERR_OK;
394}
395
396/* Function Name:
397 *      rtk_stat_logging_counterCfg_set
398 * Description:
399 *      Set the type and mode of Logging Counter
400 * Input:
401 *      idx     - The index of Logging Counter. Should be even number only.(0,2,4,6,8.....30)
402 *      mode    - 32 bits or 64 bits mode
403 *      type    - Packet counter or byte counter
404 * Output:
405 *      None.
406 * Return:
407 *      RT_ERR_OK           - OK
408 *      RT_ERR_OUT_OF_RANGE - Out of range.
409 *      RT_ERR_FAILED       - Failed
410 *      RT_ERR_SMI          - SMI access error
411 *      RT_ERR_INPUT 		- Invalid input parameters.
412 * Note:
413 *      Set the type and mode of Logging Counter.
414 */
415rtk_api_ret_t rtk_stat_logging_counterCfg_set(rtk_uint32 idx, rtk_logging_counter_mode_t mode, rtk_logging_counter_type_t type)
416{
417    rtk_api_ret_t retVal;
418
419    /* Check initialization state */
420    RTK_CHK_INIT_STATE();
421
422    if(idx > RTL8367C_MIB_MAX_LOG_CNT_IDX)
423        return RT_ERR_OUT_OF_RANGE;
424
425    if((idx % 2) == 1)
426        return RT_ERR_INPUT;
427
428    if(mode >= LOGGING_MODE_END)
429        return RT_ERR_OUT_OF_RANGE;
430
431    if(type >= LOGGING_TYPE_END)
432        return RT_ERR_OUT_OF_RANGE;
433
434    if((retVal = rtl8367c_setAsicMIBsLoggingType((idx / 2), (rtk_uint32)type)) != RT_ERR_OK)
435        return retVal;
436
437    if((retVal = rtl8367c_setAsicMIBsLoggingMode((idx / 2), (rtk_uint32)mode)) != RT_ERR_OK)
438        return retVal;
439
440    return RT_ERR_OK;
441}
442
443/* Function Name:
444 *      rtk_stat_logging_counterCfg_get
445 * Description:
446 *      Get the type and mode of Logging Counter
447 * Input:
448 *      idx     - The index of Logging Counter. Should be even number only.(0,2,4,6,8.....30)
449 * Output:
450 *      pMode   - 32 bits or 64 bits mode
451 *      pType   - Packet counter or byte counter
452 * Return:
453 *      RT_ERR_OK           - OK
454 *      RT_ERR_OUT_OF_RANGE - Out of range.
455 *      RT_ERR_FAILED       - Failed
456 *      RT_ERR_NULL_POINTER - NULL Pointer
457 *      RT_ERR_SMI          - SMI access error
458 *      RT_ERR_INPUT 		- Invalid input parameters.
459 * Note:
460 *      Get the type and mode of Logging Counter.
461 */
462rtk_api_ret_t rtk_stat_logging_counterCfg_get(rtk_uint32 idx, rtk_logging_counter_mode_t *pMode, rtk_logging_counter_type_t *pType)
463{
464    rtk_api_ret_t   retVal;
465    rtk_uint32      type, mode;
466
467    /* Check initialization state */
468    RTK_CHK_INIT_STATE();
469
470    if(idx > RTL8367C_MIB_MAX_LOG_CNT_IDX)
471        return RT_ERR_OUT_OF_RANGE;
472
473    if((idx % 2) == 1)
474        return RT_ERR_INPUT;
475
476    if(pMode == NULL)
477        return RT_ERR_NULL_POINTER;
478
479    if(pType == NULL)
480        return RT_ERR_NULL_POINTER;
481
482    if((retVal = rtl8367c_getAsicMIBsLoggingType((idx / 2), &type)) != RT_ERR_OK)
483        return retVal;
484
485    if((retVal = rtl8367c_getAsicMIBsLoggingMode((idx / 2), &mode)) != RT_ERR_OK)
486        return retVal;
487
488    *pMode = (rtk_logging_counter_mode_t)mode;
489    *pType = (rtk_logging_counter_type_t)type;
490
491    return RT_ERR_OK;
492}
493
494
495/* Function Name:
496 *      rtk_stat_logging_counter_reset
497 * Description:
498 *      Reset Logging Counter
499 * Input:
500 *      idx     - The index of Logging Counter. (0~31)
501 * Output:
502 *      None.
503 * Return:
504 *      RT_ERR_OK           - OK
505 *      RT_ERR_OUT_OF_RANGE - Out of range.
506 *      RT_ERR_FAILED       - Failed
507 *      RT_ERR_SMI          - SMI access error
508 * Note:
509 *      Reset Logging Counter.
510 */
511rtk_api_ret_t rtk_stat_logging_counter_reset(rtk_uint32 idx)
512{
513    rtk_api_ret_t   retVal;
514
515    /* Check initialization state */
516    RTK_CHK_INIT_STATE();
517
518    if(idx > RTL8367C_MIB_MAX_LOG_CNT_IDX)
519        return RT_ERR_OUT_OF_RANGE;
520
521    if((retVal = rtl8367c_setAsicMIBsResetLoggingCounter(idx)) != RT_ERR_OK)
522        return retVal;
523
524    return RT_ERR_OK;
525}
526
527/* Function Name:
528 *      rtk_stat_logging_counter_get
529 * Description:
530 *      Get Logging Counter
531 * Input:
532 *      idx     - The index of Logging Counter. (0~31)
533 * Output:
534 *      pCnt    - Logging counter value
535 * Return:
536 *      RT_ERR_OK           - OK
537 *      RT_ERR_OUT_OF_RANGE - Out of range.
538 *      RT_ERR_FAILED       - Failed
539 *      RT_ERR_SMI          - SMI access error
540 * Note:
541 *      Get Logging Counter.
542 */
543rtk_api_ret_t rtk_stat_logging_counter_get(rtk_uint32 idx, rtk_uint32 *pCnt)
544{
545    rtk_api_ret_t   retVal;
546
547    /* Check initialization state */
548    RTK_CHK_INIT_STATE();
549
550    if(NULL == pCnt)
551        return RT_ERR_NULL_POINTER;
552
553    if(idx > RTL8367C_MIB_MAX_LOG_CNT_IDX)
554        return RT_ERR_OUT_OF_RANGE;
555
556    if((retVal = rtl8367c_getAsicMIBsLogCounter(idx, pCnt)) != RT_ERR_OK)
557        return retVal;
558
559    return RT_ERR_OK;
560}
561
562/* Function Name:
563 *      rtk_stat_lengthMode_set
564 * Description:
565 *      Set Legnth mode.
566 * Input:
567 *      txMode     - The length counting mode
568 *      rxMode     - The length counting mode
569 * Output:
570 *      None.
571 * Return:
572 *      RT_ERR_OK           - OK
573 *      RT_ERR_INPUT        - Out of range.
574 *      RT_ERR_FAILED       - Failed
575 *      RT_ERR_SMI          - SMI access error
576 * Note:
577 *
578 */
579rtk_api_ret_t rtk_stat_lengthMode_set(rtk_stat_lengthMode_t txMode, rtk_stat_lengthMode_t rxMode)
580{
581    rtk_api_ret_t   retVal;
582
583    /* Check initialization state */
584    RTK_CHK_INIT_STATE();
585
586    if(txMode >= LENGTH_MODE_END)
587        return RT_ERR_INPUT;
588
589    if(rxMode >= LENGTH_MODE_END)
590        return RT_ERR_INPUT;
591
592    if((retVal = rtl8367c_setAsicMIBsLength((rtk_uint32)txMode, (rtk_uint32)rxMode)) != RT_ERR_OK)
593        return retVal;
594
595    return RT_ERR_OK;
596}
597
598/* Function Name:
599 *      rtk_stat_lengthMode_get
600 * Description:
601 *      Get Legnth mode.
602 * Input:
603 *      None.
604 * Output:
605 *      pTxMode       - The length counting mode
606 *      pRxMode       - The length counting mode
607 * Return:
608 *      RT_ERR_OK           - OK
609 *      RT_ERR_INPUT        - Out of range.
610 *      RT_ERR_FAILED       - Failed
611 *      RT_ERR_SMI          - SMI access error
612 * Note:
613 */
614rtk_api_ret_t rtk_stat_lengthMode_get(rtk_stat_lengthMode_t *pTxMode, rtk_stat_lengthMode_t *pRxMode)
615{
616    rtk_api_ret_t   retVal;
617
618    /* Check initialization state */
619    RTK_CHK_INIT_STATE();
620
621    if(NULL == pTxMode)
622        return RT_ERR_NULL_POINTER;
623
624    if(NULL == pRxMode)
625        return RT_ERR_NULL_POINTER;
626
627    if((retVal = rtl8367c_getAsicMIBsLength((rtk_uint32 *)pTxMode, (rtk_uint32 *)pRxMode)) != RT_ERR_OK)
628        return retVal;
629
630    return RT_ERR_OK;
631}
632
633