40962a0e6909095b30cdb8330fa16718164b81d9
[openwrt/staging/stintel.git] / target / linux / mediatek / files / drivers / net / phy / rtk / rtl8367c / ptp.c
1 /*
2 * Copyright (C) 2013 Realtek Semiconductor Corp.
3 * All Rights Reserved.
4 *
5 * Unless you and Realtek execute a separate written software license
6 * agreement governing use of this software, this software is licensed
7 * to you under the terms of the GNU General Public License version 2,
8 * available at https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
9 *
10 * $Revision: 39583 $
11 * $Date: 2013-05-20 16:59:23 +0800 (星期一, 20 五月 2013) $
12 *
13 * Purpose : RTK switch high-level API for RTL8367/RTL8367C
14 * Feature : Here is a list of all functions and variables in time module.
15 *
16 */
17
18 #include <rtk_switch.h>
19 #include <rtk_error.h>
20 #include <ptp.h>
21 #include <string.h>
22
23 #include <rtl8367c_asicdrv.h>
24 #include <rtl8367c_asicdrv_eav.h>
25
26 /* Function Name:
27 * rtk_ptp_init
28 * Description:
29 * PTP function initialization.
30 * Input:
31 * None
32 * Output:
33 * None
34 * Return:
35 * RT_ERR_OK - OK
36 * RT_ERR_FAILED - Failed
37 * RT_ERR_SMI - SMI access error
38 * Note:
39 * This API is used to initialize PTP status.
40 */
41 rtk_api_ret_t rtk_ptp_init(void)
42 {
43 /* Check initialization state */
44 RTK_CHK_INIT_STATE();
45
46
47 return RT_ERR_OK;
48 }
49
50 /* Function Name:
51 * rtk_ptp_mac_set
52 * Description:
53 * Configure PTP mac address.
54 * Input:
55 * mac - mac address to parser PTP packets.
56 * Output:
57 * None
58 * Return:
59 * RT_ERR_OK - OK
60 * RT_ERR_FAILED - Failed
61 * RT_ERR_SMI - SMI access error
62 * RT_ERR_INPUT - Invalid input parameter.
63 * Note:
64 * None
65 */
66 rtk_api_ret_t rtk_ptp_mac_set(rtk_mac_t mac)
67 {
68 rtk_api_ret_t retVal;
69 ether_addr_t sw_mac;
70
71 memcpy(sw_mac.octet, mac.octet, ETHER_ADDR_LEN);
72
73 if((retVal=rtl8367c_setAsicEavMacAddress(sw_mac))!=RT_ERR_OK)
74 return retVal;
75
76 return RT_ERR_OK;
77 }
78
79 /* Function Name:
80 * rtk_ptp_mac_get
81 * Description:
82 * Get PTP mac address.
83 * Input:
84 * None
85 * Output:
86 * pMac - mac address to parser PTP packets.
87 * Return:
88 * RT_ERR_OK - OK
89 * RT_ERR_FAILED - Failed
90 * RT_ERR_SMI - SMI access error
91 * RT_ERR_INPUT - Invalid input parameter.
92 * Note:
93 * None
94 */
95 rtk_api_ret_t rtk_ptp_mac_get(rtk_mac_t *pMac)
96 {
97 rtk_api_ret_t retVal;
98 ether_addr_t sw_mac;
99
100 if((retVal=rtl8367c_getAsicEavMacAddress(&sw_mac))!=RT_ERR_OK)
101 return retVal;
102
103 memcpy(pMac->octet, sw_mac.octet, ETHER_ADDR_LEN);
104
105 return RT_ERR_OK;
106 }
107
108 /* Function Name:
109 * rtk_ptp_tpid_set
110 * Description:
111 * Configure PTP accepted outer & inner tag TPID.
112 * Input:
113 * outerId - Ether type of S-tag frame parsing in PTP ports.
114 * innerId - Ether type of C-tag frame parsing in PTP ports.
115 * Output:
116 * None
117 * Return:
118 * RT_ERR_OK - OK
119 * RT_ERR_FAILED - Failed
120 * RT_ERR_SMI - SMI access error
121 * RT_ERR_INPUT - Invalid input parameter.
122 * Note:
123 * None
124 */
125 rtk_api_ret_t rtk_ptp_tpid_set(rtk_ptp_tpid_t outerId, rtk_ptp_tpid_t innerId)
126 {
127 rtk_api_ret_t retVal;
128
129 /* Check initialization state */
130 RTK_CHK_INIT_STATE();
131
132 if ((outerId>RTK_MAX_NUM_OF_TPID) ||(innerId>RTK_MAX_NUM_OF_TPID))
133 return RT_ERR_INPUT;
134
135 if ((retVal = rtl8367c_setAsicEavTpid(outerId, innerId)) != RT_ERR_OK)
136 return retVal;
137
138 return RT_ERR_OK;
139 }
140
141 /* Function Name:
142 * rtk_ptp_tpid_get
143 * Description:
144 * Get PTP accepted outer & inner tag TPID.
145 * Input:
146 * None
147 * Output:
148 * pOuterId - Ether type of S-tag frame parsing in PTP ports.
149 * pInnerId - Ether type of C-tag frame parsing in PTP ports.
150 * Return:
151 * RT_ERR_OK - OK
152 * RT_ERR_FAILED - Failed
153 * RT_ERR_SMI - SMI access error
154 * Note:
155 * None
156 */
157 rtk_api_ret_t rtk_ptp_tpid_get(rtk_ptp_tpid_t *pOuterId, rtk_ptp_tpid_t *pInnerId)
158 {
159 rtk_api_ret_t retVal;
160
161 /* Check initialization state */
162 RTK_CHK_INIT_STATE();
163
164 if ((retVal = rtl8367c_getAsicEavTpid(pOuterId, pInnerId)) != RT_ERR_OK)
165 return retVal;
166
167 return RT_ERR_OK;
168 }
169
170 /* Function Name:
171 * rtk_ptp_refTime_set
172 * Description:
173 * Set the reference time of the specified device.
174 * Input:
175 * timeStamp - reference timestamp value
176 * Output:
177 * None
178 * Return:
179 * RT_ERR_OK
180 * RT_ERR_FAILED
181 * RT_ERR_INPUT - invalid input parameter
182 * Applicable:
183 * 8390, 8380
184 * Note:
185 * None
186 */
187 rtk_api_ret_t rtk_ptp_refTime_set(rtk_ptp_timeStamp_t timeStamp)
188 {
189 rtk_api_ret_t retVal;
190
191 /* Check initialization state */
192 RTK_CHK_INIT_STATE();
193
194 if (timeStamp.nsec > RTK_MAX_NUM_OF_NANO_SECOND)
195 return RT_ERR_INPUT;
196
197 if ((retVal = rtl8367c_setAsicEavSysTime(timeStamp.sec, timeStamp.nsec))!=RT_ERR_OK)
198 return retVal;
199
200 return RT_ERR_OK;
201 }
202
203 /* Function Name:
204 * rtk_ptp_refTime_get
205 * Description:
206 * Get the reference time of the specified device.
207 * Input:
208 * Output:
209 * pTimeStamp - pointer buffer of the reference time
210 * Return:
211 * RT_ERR_OK
212 * RT_ERR_FAILED
213 * RT_ERR_UNIT_ID - invalid unit id
214 * RT_ERR_NOT_INIT - The module is not initial
215 * RT_ERR_NULL_POINTER - input parameter may be null pointer
216 * Applicable:
217 * 8390, 8380
218 * Note:
219 * None
220 */
221 rtk_api_ret_t rtk_ptp_refTime_get(rtk_ptp_timeStamp_t *pTimeStamp)
222 {
223 rtk_api_ret_t retVal;
224
225 /* Check initialization state */
226 RTK_CHK_INIT_STATE();
227
228 if ((retVal = rtl8367c_getAsicEavSysTime(&pTimeStamp->sec, &pTimeStamp->nsec))!=RT_ERR_OK)
229 return retVal;
230
231 return RT_ERR_OK;
232 }
233
234 /* Function Name:
235 * rtk_ptp_refTimeAdjust_set
236 * Description:
237 * Adjust the reference time.
238 * Input:
239 * unit - unit id
240 * sign - significant
241 * timeStamp - reference timestamp value
242 * Output:
243 * None
244 * Return:
245 * RT_ERR_OK
246 * RT_ERR_FAILED
247 * RT_ERR_UNIT_ID - invalid unit id
248 * RT_ERR_NOT_INIT - The module is not initial
249 * RT_ERR_INPUT - invalid input parameter
250 * Note:
251 * sign=0 for positive adjustment, sign=1 for negative adjustment.
252 */
253 rtk_api_ret_t rtk_ptp_refTimeAdjust_set(rtk_ptp_sys_adjust_t sign, rtk_ptp_timeStamp_t timeStamp)
254 {
255 rtk_api_ret_t retVal;
256
257 /* Check initialization state */
258 RTK_CHK_INIT_STATE();
259
260 if (timeStamp.nsec > RTK_MAX_NUM_OF_NANO_SECOND)
261 return RT_ERR_INPUT;
262
263 if ((retVal = rtl8367c_setAsicEavSysTimeAdjust(sign, timeStamp.sec, timeStamp.nsec))!=RT_ERR_OK)
264 return retVal;
265
266
267 return RT_ERR_OK;
268 }
269
270 /* Function Name:
271 * rtk_ptp_refTimeEnable_set
272 * Description:
273 * Set the enable state of reference time of the specified device.
274 * Input:
275 * enable - status
276 * Output:
277 * None
278 * Return:
279 * RT_ERR_OK
280 * RT_ERR_FAILED
281 * RT_ERR_INPUT - invalid input parameter
282 * Note:
283 * None
284 */
285 rtk_api_ret_t rtk_ptp_refTimeEnable_set(rtk_enable_t enable)
286 {
287 rtk_api_ret_t retVal;
288
289 /* Check initialization state */
290 RTK_CHK_INIT_STATE();
291
292 if (enable >= RTK_ENABLE_END)
293 return RT_ERR_ENABLE;
294
295 if ((retVal = rtl8367c_setAsicEavSysTimeCtrl(enable))!=RT_ERR_OK)
296 return retVal;
297
298 return RT_ERR_OK;
299 }
300
301 /* Function Name:
302 * rtk_ptp_refTimeEnable_get
303 * Description:
304 * Get the enable state of reference time of the specified device.
305 * Input:
306 * Output:
307 * pEnable - status
308 * Return:
309 * RT_ERR_OK
310 * RT_ERR_FAILED
311 * RT_ERR_UNIT_ID - invalid unit id
312 * RT_ERR_NOT_INIT - The module is not initial
313 * RT_ERR_NULL_POINTER - input parameter may be null pointer
314 * Applicable:
315 * 8390, 8380
316 * Note:
317 * None
318 */
319 rtk_api_ret_t rtk_ptp_refTimeEnable_get(rtk_enable_t *pEnable)
320 {
321 rtk_api_ret_t retVal;
322
323 /* Check initialization state */
324 RTK_CHK_INIT_STATE();
325
326 if ((retVal = rtl8367c_getAsicEavSysTimeCtrl(pEnable))!=RT_ERR_OK)
327 return retVal;
328
329 return RT_ERR_OK;
330 }
331
332 /* Function Name:
333 * rtk_ptp_portEnable_set
334 * Description:
335 * Set PTP status of the specified port.
336 * Input:
337 * port - port id
338 * enable - status
339 * Output:
340 * None
341 * Return:
342 * RT_ERR_OK
343 * RT_ERR_FAILED
344 * RT_ERR_PORT - invalid port id
345 * RT_ERR_INPUT - invalid input parameter
346 * Note:
347 * None
348 */
349 rtk_api_ret_t rtk_ptp_portEnable_set(rtk_port_t port, rtk_enable_t enable)
350 {
351 rtk_api_ret_t retVal;
352
353 /* Check initialization state */
354 RTK_CHK_INIT_STATE();
355
356 /* Check port is PTP port */
357 RTK_CHK_PORT_IS_PTP(port);
358
359 if (enable>=RTK_ENABLE_END)
360 return RT_ERR_INPUT;
361
362 if ((retVal = rtl8367c_setAsicEavPortEnable(rtk_switch_port_L2P_get(port), enable)) != RT_ERR_OK)
363 return retVal;
364
365 return RT_ERR_OK;
366 }
367
368 /* Function Name:
369 * rtk_ptp_portEnable_get
370 * Description:
371 * Get PTP status of the specified port.
372 * Input:
373 * port - port id
374 * Output:
375 * pEnable - status
376 * Return:
377 * RT_ERR_OK
378 * RT_ERR_FAILED
379 * RT_ERR_PORT - invalid port id
380 * RT_ERR_NULL_POINTER - input parameter may be null pointer
381 * Note:
382 * None
383 */
384 rtk_api_ret_t rtk_ptp_portEnable_get(rtk_port_t port, rtk_enable_t *pEnable)
385 {
386 rtk_api_ret_t retVal;
387
388 /* Check initialization state */
389 RTK_CHK_INIT_STATE();
390
391 /* Check port is PTP port */
392 RTK_CHK_PORT_IS_PTP(port);
393
394 if ((retVal = rtl8367c_getAsicEavPortEnable(rtk_switch_port_L2P_get(port), pEnable)) != RT_ERR_OK)
395 return retVal;
396
397 return RT_ERR_OK;
398 }
399
400
401 /* Function Name:
402 * rtk_ptp_portTimestamp_get
403 * Description:
404 * Get PTP timstamp according to the PTP identifier on the dedicated port from the specified device.
405 * Input:
406 * unit - unit id
407 * port - port id
408 * type - PTP message type
409 * Output:
410 * pInfo - pointer buffer of sequence ID and timestamp
411 * Return:
412 * RT_ERR_OK
413 * RT_ERR_FAILED
414 * RT_ERR_PORT_ID - invalid port id
415 * RT_ERR_INPUT - invalid input parameter
416 * RT_ERR_NULL_POINTER - input parameter may be null pointer
417 * Applicable:
418 * 8390, 8380
419 * Note:
420 * None
421 */
422 rtk_api_ret_t rtk_ptp_portTimestamp_get( rtk_port_t port, rtk_ptp_msgType_t type, rtk_ptp_info_t *pInfo)
423 {
424 rtk_api_ret_t retVal;
425 rtl8367c_ptp_time_stamp_t time;
426
427 /* Check initialization state */
428 RTK_CHK_INIT_STATE();
429
430 /* Check port is PTP port */
431 RTK_CHK_PORT_IS_PTP(port);
432
433 if ((retVal = rtl8367c_getAsicEavPortTimeStamp(rtk_switch_port_L2P_get(port), type, &time)) != RT_ERR_OK)
434 return retVal;
435
436 pInfo->sequenceId = time.sequence_id;
437 pInfo->timeStamp.sec = time.second;
438 pInfo->timeStamp.nsec = time.nano_second;
439
440 return RT_ERR_OK;
441 }
442
443 /* Function Name:
444 * rtk_ptp_intControl_set
445 * Description:
446 * Set PTP interrupt trigger status configuration.
447 * Input:
448 * type - Interrupt type.
449 * enable - Interrupt status.
450 * Output:
451 * None
452 * Return:
453 * RT_ERR_OK - OK
454 * RT_ERR_FAILED - Failed
455 * RT_ERR_SMI - SMI access error
456 * RT_ERR_INPUT - Invalid input parameters.
457 * RT_ERR_ENABLE - Invalid enable input.
458 * Note:
459 * The API can set PTP interrupt status configuration.
460 * The interrupt trigger status is shown in the following:
461 * PTP_INT_TYPE_TX_SYNC = 0,
462 * PTP_INT_TYPE_TX_DELAY_REQ,
463 * PTP_INT_TYPE_TX_PDELAY_REQ,
464 * PTP_INT_TYPE_TX_PDELAY_RESP,
465 * PTP_INT_TYPE_RX_SYNC,
466 * PTP_INT_TYPE_RX_DELAY_REQ,
467 * PTP_INT_TYPE_RX_PDELAY_REQ,
468 * PTP_INT_TYPE_RX_PDELAY_RESP,
469 * PTP_INT_TYPE_ALL,
470 */
471 rtk_api_ret_t rtk_ptp_intControl_set(rtk_ptp_intType_t type, rtk_enable_t enable)
472 {
473 rtk_api_ret_t retVal;
474 rtk_uint32 mask;
475
476 /* Check initialization state */
477 RTK_CHK_INIT_STATE();
478
479 if (type>=PTP_INT_TYPE_END)
480 return RT_ERR_INPUT;
481
482 if (PTP_INT_TYPE_ALL!=type)
483 {
484 if ((retVal = rtl8367c_getAsicEavInterruptMask(&mask)) != RT_ERR_OK)
485 return retVal;
486
487 if (ENABLED == enable)
488 mask = mask | (1<<type);
489 else if (DISABLED == enable)
490 mask = mask & ~(1<<type);
491 else
492 return RT_ERR_INPUT;
493
494 if ((retVal = rtl8367c_setAsicEavInterruptMask(mask)) != RT_ERR_OK)
495 return retVal;
496 }
497 else
498 {
499 if (ENABLED == enable)
500 mask = RTK_PTP_INTR_MASK;
501 else if (DISABLED == enable)
502 mask = 0;
503 else
504 return RT_ERR_INPUT;
505
506 if ((retVal = rtl8367c_setAsicEavInterruptMask(mask)) != RT_ERR_OK)
507 return retVal;
508 }
509
510 return RT_ERR_OK;
511 }
512
513 /* Function Name:
514 * rtk_ptp_intControl_get
515 * Description:
516 * Get PTP interrupt trigger status configuration.
517 * Input:
518 * type - Interrupt type.
519 * Output:
520 * pEnable - Interrupt status.
521 * Return:
522 * RT_ERR_OK - OK
523 * RT_ERR_FAILED - Failed
524 * RT_ERR_SMI - SMI access error
525 * RT_ERR_INPUT - Invalid input parameters.
526 * Note:
527 * The API can get interrupt status configuration.
528 * The interrupt trigger status is shown in the following:
529 * PTP_INT_TYPE_TX_SYNC = 0,
530 * PTP_INT_TYPE_TX_DELAY_REQ,
531 * PTP_INT_TYPE_TX_PDELAY_REQ,
532 * PTP_INT_TYPE_TX_PDELAY_RESP,
533 * PTP_INT_TYPE_RX_SYNC,
534 * PTP_INT_TYPE_RX_DELAY_REQ,
535 * PTP_INT_TYPE_RX_PDELAY_REQ,
536 * PTP_INT_TYPE_RX_PDELAY_RESP,
537 */
538 rtk_api_ret_t rtk_ptp_intControl_get(rtk_ptp_intType_t type, rtk_enable_t *pEnable)
539 {
540 rtk_api_ret_t retVal;
541 rtk_uint32 mask;
542
543 /* Check initialization state */
544 RTK_CHK_INIT_STATE();
545
546 if (type>=PTP_INT_TYPE_ALL)
547 return RT_ERR_INPUT;
548
549 if ((retVal = rtl8367c_getAsicEavInterruptMask(&mask)) != RT_ERR_OK)
550 return retVal;
551
552 if (0 == (mask&(1<<type)))
553 *pEnable=DISABLED;
554 else
555 *pEnable=ENABLED;
556
557 return RT_ERR_OK;
558 }
559
560 /* Function Name:
561 * rtk_ptp_intStatus_get
562 * Description:
563 * Get PTP port interrupt trigger status.
564 * Input:
565 * port - physical port
566 * Output:
567 * pStatusMask - Interrupt status bit mask.
568 * Return:
569 * RT_ERR_OK - OK
570 * RT_ERR_FAILED - Failed
571 * RT_ERR_SMI - SMI access error
572 * RT_ERR_INPUT - Invalid input parameters.
573 * Note:
574 * The API can get interrupt trigger status when interrupt happened.
575 * The interrupt trigger status is shown in the following:
576 * - PORT 0 INT (value[0] (Bit0))
577 * - PORT 1 INT (value[0] (Bit1))
578 * - PORT 2 INT (value[0] (Bit2))
579 * - PORT 3 INT (value[0] (Bit3))
580 * - PORT 4 INT (value[0] (Bit4))
581
582 *
583 */
584 rtk_api_ret_t rtk_ptp_intStatus_get(rtk_ptp_intStatus_t *pStatusMask)
585 {
586 rtk_api_ret_t retVal;
587
588 /* Check initialization state */
589 RTK_CHK_INIT_STATE();
590
591 if(NULL == pStatusMask)
592 return RT_ERR_NULL_POINTER;
593
594 if ((retVal = rtl8367c_getAsicEavInterruptStatus(pStatusMask)) != RT_ERR_OK)
595 return retVal;
596
597 return RT_ERR_OK;
598 }
599
600
601
602 /* Function Name:
603 * rtk_ptp_portIntStatus_set
604 * Description:
605 * Set PTP port interrupt trigger status to clean.
606 * Input:
607 * port - physical port
608 * statusMask - Interrupt status bit mask.
609 * Output:
610 * None
611 * Return:
612 * RT_ERR_OK - OK
613 * RT_ERR_FAILED - Failed
614 * RT_ERR_SMI - SMI access error
615 * RT_ERR_INPUT - Invalid input parameters.
616 * Note:
617 * The API can clean interrupt trigger status when interrupt happened.
618 * The interrupt trigger status is shown in the following:
619 * - PTP_INT_TYPE_TX_SYNC (value[0] (Bit0))
620 * - PTP_INT_TYPE_TX_DELAY_REQ (value[0] (Bit1))
621 * - PTP_INT_TYPE_TX_PDELAY_REQ (value[0] (Bit2))
622 * - PTP_INT_TYPE_TX_PDELAY_RESP (value[0] (Bit3))
623 * - PTP_INT_TYPE_RX_SYNC (value[0] (Bit4))
624 * - PTP_INT_TYPE_RX_DELAY_REQ (value[0] (Bit5))
625 * - PTP_INT_TYPE_RX_PDELAY_REQ (value[0] (Bit6))
626 * - PTP_INT_TYPE_RX_PDELAY_RESP (value[0] (Bit7))
627 * The status will be cleared after execute this API.
628 */
629 rtk_api_ret_t rtk_ptp_portIntStatus_set(rtk_port_t port, rtk_ptp_intStatus_t statusMask)
630 {
631 rtk_api_ret_t retVal;
632
633 /* Check initialization state */
634 RTK_CHK_INIT_STATE();
635
636 /* Check port is PTP port */
637 RTK_CHK_PORT_IS_PTP(port);
638
639 if ((retVal = rtl8367c_setAsicEavPortInterruptStatus(rtk_switch_port_L2P_get(port), statusMask))!=RT_ERR_OK)
640 return retVal;
641
642 return RT_ERR_OK;
643 }
644
645 /* Function Name:
646 * rtk_ptp_portIntStatus_get
647 * Description:
648 * Get PTP port interrupt trigger status.
649 * Input:
650 * port - physical port
651 * Output:
652 * pStatusMask - Interrupt status bit mask.
653 * Return:
654 * RT_ERR_OK - OK
655 * RT_ERR_FAILED - Failed
656 * RT_ERR_SMI - SMI access error
657 * RT_ERR_INPUT - Invalid input parameters.
658 * Note:
659 * The API can get interrupt trigger status when interrupt happened.
660 * The interrupt trigger status is shown in the following:
661 * - PTP_INT_TYPE_TX_SYNC (value[0] (Bit0))
662 * - PTP_INT_TYPE_TX_DELAY_REQ (value[0] (Bit1))
663 * - PTP_INT_TYPE_TX_PDELAY_REQ (value[0] (Bit2))
664 * - PTP_INT_TYPE_TX_PDELAY_RESP (value[0] (Bit3))
665 * - PTP_INT_TYPE_RX_SYNC (value[0] (Bit4))
666 * - PTP_INT_TYPE_RX_DELAY_REQ (value[0] (Bit5))
667 * - PTP_INT_TYPE_RX_PDELAY_REQ (value[0] (Bit6))
668 * - PTP_INT_TYPE_RX_PDELAY_RESP (value[0] (Bit7))
669 *
670 */
671 rtk_api_ret_t rtk_ptp_portIntStatus_get(rtk_port_t port, rtk_ptp_intStatus_t *pStatusMask)
672 {
673 rtk_api_ret_t retVal;
674
675 /* Check initialization state */
676 RTK_CHK_INIT_STATE();
677
678 /* Check port is PTP port */
679 RTK_CHK_PORT_IS_PTP(port);
680
681 if(NULL == pStatusMask)
682 return RT_ERR_NULL_POINTER;
683
684 if ((retVal = rtl8367c_getAsicEavPortInterruptStatus(rtk_switch_port_L2P_get(port), pStatusMask)) != RT_ERR_OK)
685 return retVal;
686
687 return RT_ERR_OK;
688 }
689
690 /* Function Name:
691 * rtk_ptp_portPtpTrap_set
692 * Description:
693 * Set PTP packet trap of the specified port.
694 * Input:
695 * port - port id
696 * enable - status
697 * Output:
698 * None
699 * Return:
700 * RT_ERR_OK
701 * RT_ERR_FAILED
702 * RT_ERR_PORT - invalid port id
703 * RT_ERR_INPUT - invalid input parameter
704 * Note:
705 * None
706 */
707 rtk_api_ret_t rtk_ptp_portTrap_set(rtk_port_t port, rtk_enable_t enable)
708 {
709 rtk_api_ret_t retVal;
710
711 /* Check initialization state */
712 RTK_CHK_INIT_STATE();
713
714 /* Check Port Valid */
715 RTK_CHK_PORT_VALID(port);
716
717 if (enable>=RTK_ENABLE_END)
718 return RT_ERR_INPUT;
719
720 if ((retVal = rtl8367c_setAsicEavTrap(rtk_switch_port_L2P_get(port), enable)) != RT_ERR_OK)
721 return retVal;
722
723 return RT_ERR_OK;
724 }
725
726 /* Function Name:
727 * rtk_ptp_portPtpEnable_get
728 * Description:
729 * Get PTP packet trap of the specified port.
730 * Input:
731 * port - port id
732 * Output:
733 * pEnable - status
734 * Return:
735 * RT_ERR_OK
736 * RT_ERR_FAILED
737 * RT_ERR_PORT - invalid port id
738 * RT_ERR_NULL_POINTER - input parameter may be null pointer
739 * Note:
740 * None
741 */
742 rtk_api_ret_t rtk_ptp_portTrap_get(rtk_port_t port, rtk_enable_t *pEnable)
743 {
744 rtk_api_ret_t retVal;
745
746 /* Check initialization state */
747 RTK_CHK_INIT_STATE();
748
749 /* Check Port Valid */
750 RTK_CHK_PORT_VALID(port);
751
752 if ((retVal = rtl8367c_getAsicEavTrap(rtk_switch_port_L2P_get(port), pEnable)) != RT_ERR_OK)
753 return retVal;
754
755 return RT_ERR_OK;
756 }
757
758
759