VSF Documented
vsf_template_eth.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright(C)2009-2022 by VSF Team *
3 * *
4 * Licensed under the Apache License, Version 2.0 (the "License"); *
5 * you may not use this file except in compliance with the License. *
6 * You may obtain a copy of the License at *
7 * *
8 * http://www.apache.org/licenses/LICENSE-2.0 *
9 * *
10 * Unless required by applicable law or agreed to in writing, software *
11 * distributed under the License is distributed on an "AS IS" BASIS, *
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13 * See the License for the specific language governing permissions and *
14 * limitations under the License. *
15 * *
16 ****************************************************************************/
17
18#ifndef __VSF_TEMPLATE_ETH_H__
19#define __VSF_TEMPLATE_ETH_H__
20
21/*============================ INCLUDES ======================================*/
22
24#include "hal/arch/vsf_arch.h"
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30/*============================ ETHROS ========================================*/
31
39#ifndef VSF_ETH_CFG_MULTI_CLASS
40# define VSF_ETH_CFG_MULTI_CLASS ENABLED
41#endif
42#ifndef VSF_ETH_CFG_MULTI_PHY_CLASS
43# define VSF_ETH_CFG_MULTI_PHY_CLASS ENABLED
44#endif
45
46#if defined(VSF_HW_ETH_COUNT) && !defined(VSF_HW_ETH_MASK)
54# define VSF_HW_ETH_MASK VSF_HAL_COUNT_TO_MASK(VSF_HW_ETH_COUNT)
55#endif
56
57#if defined(VSF_HW_ETH_MASK) && !defined(VSF_HW_ETH_COUNT)
65# define VSF_HW_ETH_COUNT VSF_HAL_MASK_TO_COUNT(VSF_HW_ETH_MASK)
66#endif
67
89#ifndef VSF_ETH_CFG_PREFIX
90# if (VSF_ETH_CFG_MULTI_CLASS == DISABLED) && defined(VSF_HW_ETH_COUNT) && (VSF_HW_ETH_COUNT != 0)
91# define VSF_ETH_CFG_PREFIX vsf_hw
92# else
93# define VSF_ETH_CFG_PREFIX vsf
94# endif
95#endif
96
107#ifndef VSF_ETH_CFG_FUNCTION_RENAME
108# define VSF_ETH_CFG_FUNCTION_RENAME ENABLED
109#endif
110
120#ifndef VSF_ETH_CFG_REIMPLEMENT_TYPE_PHY_MODE
121# define VSF_ETH_CFG_REIMPLEMENT_TYPE_PHY_MODE DISABLED
122#endif
123
133#ifndef VSF_ETH_CFG_REIMPLEMENT_TYPE_MODE
134# define VSF_ETH_CFG_REIMPLEMENT_TYPE_MODE DISABLED
135#endif
136
149#if VSF_ETH_CFG_REIMPLEMENT_TYPE_CFG == DISABLED
150# define VSF_ETH_CFG_REIMPLEMENT_TYPE_CFG DISABLED
151#endif
152
161#ifndef VSF_ETH_CFG_REIMPLEMENT_TYPE_STATUS
162# define VSF_ETH_CFG_REIMPLEMENT_TYPE_STATUS DISABLED
163#endif
164
177#if VSF_ETH_CFG_REIMPLEMENT_TYPE_CAPABILITY == DISABLED
178# define VSF_ETH_CFG_REIMPLEMENT_TYPE_CAPABILITY DISABLED
179#endif
180
191#if VSF_ETH_CFG_REIMPLEMENT_TYPE_BUF_MODE == DISABLED
192# define VSF_ETH_CFG_REIMPLEMENT_TYPE_BUF_MODE DISABLED
193#endif
194
195#if VSF_ETH_CFG_REIMPLEMENT_TYPE_BUF_DESC == DISABLED
196# define VSF_ETH_CFG_REIMPLEMENT_TYPE_BUF_DESC DISABLED
197#endif
198
199#if VSF_ETH_CFG_REIMPLEMENT_TYPE_SEND_BUF_DESC == DISABLED
200# define VSF_ETH_CFG_REIMPLEMENT_TYPE_SEND_BUF_DESC DISABLED
201#endif
202
203#if VSF_ETH_CFG_REIMPLEMENT_TYPE_RECV_BUF_DESC == DISABLED
204# define VSF_ETH_CFG_REIMPLEMENT_TYPE_RECV_BUF_DESC DISABLED
205#endif
206
216#ifndef VSF_ETH_CFG_REIMPLEMENT_TYPE_SG_SEND_BUF
217# define VSF_ETH_CFG_REIMPLEMENT_TYPE_SG_SEND_BUF DISABLED
218#endif
219
229#ifndef VSF_ETH_CFG_REIMPLEMENT_TYPE_SG_RECV_BUF
230# define VSF_ETH_CFG_REIMPLEMENT_TYPE_SG_RECV_BUF DISABLED
231#endif
232
242#ifndef VSF_ETH_CFG_REIMPLEMENT_TYPE_IRQ_MASK
243# define VSF_ETH_CFG_REIMPLEMENT_TYPE_IRQ_MASK DISABLED
244#endif
245
255#ifndef VSF_ETH_CFG_REIMPLEMENT_TYPE_CTRL
256# define VSF_ETH_CFG_REIMPLEMENT_TYPE_CTRL DISABLED
257#endif
258
269#ifndef VSF_ETH_CFG_INHERIT_HAL_CAPABILITY
270# define VSF_ETH_CFG_INHERIT_HAL_CAPABILITY ENABLED
271#endif
272
306#ifndef __VSF_ETH_CFG_SUPPORT_STANDARD_OPTIONAL
307# define __VSF_ETH_CFG_SUPPORT_STANDARD_OPTIONAL DISABLED
308#endif
309
310/*============================ ETHROFIED FUNCTIONS ===========================*/
311
321#define VSF_ETH_APIS(__prefix_name) \
322 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, eth, init, VSF_MCONNECT(__prefix_name, _t) *eth_ptr, vsf_eth_cfg_t *cfg_ptr) \
323 __VSF_HAL_TEMPLATE_API(__prefix_name, void, eth, fini, VSF_MCONNECT(__prefix_name, _t) *eth_ptr) \
324 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, eth, get_configuration, VSF_MCONNECT(__prefix_name, _t) *eth_ptr, vsf_eth_cfg_t *cfg_ptr) \
325 __VSF_HAL_TEMPLATE_API(__prefix_name, fsm_rt_t, eth, enable, VSF_MCONNECT(__prefix_name, _t) *eth_ptr) \
326 __VSF_HAL_TEMPLATE_API(__prefix_name, fsm_rt_t, eth, disable, VSF_MCONNECT(__prefix_name, _t) *eth_ptr) \
327 __VSF_HAL_TEMPLATE_API(__prefix_name, void, eth, irq_enable, VSF_MCONNECT(__prefix_name, _t) *eth_ptr, vsf_eth_irq_mask_t irq_mask) \
328 __VSF_HAL_TEMPLATE_API(__prefix_name, void, eth, irq_disable, VSF_MCONNECT(__prefix_name, _t) *eth_ptr, vsf_eth_irq_mask_t irq_mask) \
329 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_eth_irq_mask_t, eth, irq_clear, VSF_MCONNECT(__prefix_name, _t) *eth_ptr, vsf_eth_irq_mask_t irq_mask) \
330 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, eth, send_request, VSF_MCONNECT(__prefix_name, _t) *eth_ptr, vsf_eth_send_buf_desc_t *buf_ptr) \
331 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, eth, recv_request, VSF_MCONNECT(__prefix_name, _t) *eth_ptr, vsf_eth_recv_buf_desc_t *buf_ptr) \
332 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, eth, send_sg_request, VSF_MCONNECT(__prefix_name, _t) *eth_ptr, vsf_eth_send_sg_buf_desc_t *buf_ptr, uint32_t sg_count) \
333 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, eth, recv_sg_request, VSF_MCONNECT(__prefix_name, _t) *eth_ptr, vsf_eth_recv_sg_buf_desc_t *buf_ptr, uint32_t sg_count) \
334 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, eth, ctrl, VSF_MCONNECT(__prefix_name, _t) *eth_ptr, vsf_eth_ctrl_t ctrl, void *param) \
335 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_eth_status_t, eth, status, VSF_MCONNECT(__prefix_name, _t) *eth_ptr) \
336 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_eth_capability_t, eth, capability, VSF_MCONNECT(__prefix_name, _t) *eth_ptr) \
337 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, eth, phy_set_mode, VSF_MCONNECT(__prefix_name, _t) *eth_ptr, vsf_eth_phy_mode_t phy_mode) \
338 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, eth, phy_get_link_status, VSF_MCONNECT(__prefix_name, _t) *eth_ptr, vsf_eth_phy_mode_t *phy_mode_ptr) \
339 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, eth, phy_read_reg, VSF_MCONNECT(__prefix_name, _t) *eth_ptr, uint16_t reg_addr, uint32_t *value_ptr) \
340 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, eth, phy_write_reg, VSF_MCONNECT(__prefix_name, _t) *eth_ptr, uint16_t reg_addr, uint32_t value)
341
342
343/*============================ TYPES =========================================*/
344
345
346
347#if VSF_ETH_CFG_REIMPLEMENT_TYPE_PHY_MODE == DISABLED
383typedef enum vsf_eth_phy_mode_t {
390
393
395
398 //VSF_ETH_PHY_MODE_LINK_DOWN = 1 << 6,
400#endif
401
402
409enum {
410#ifndef VSF_ETH_PHY_MODE_SPEED_MASK
412#endif
413
414#ifndef VSF_ETH_PHY_MODE_DUPLEX_MASK
416#endif
417
418#ifndef VSF_ETH_PHY_MODE_ALL_BITS_MASK
420#endif
421};
422
423#if VSF_ETH_CFG_REIMPLEMENT_TYPE_MODE == DISABLED
462typedef enum vsf_eth_mode_t {
465
466#if __VSF_ETH_CFG_SUPPORT_STANDARD_OPTIONAL
467 /* Address Filtering Options
468 * ------------------------- */
469 // \~english Enable filtering of unicast frames not addressed to this station
470 // \~chinese 启用单播帧过滤,丢弃不是发往本站的单播帧
471 VSF_ETH_MODE_UNICAST_FILTER = 1 << 7,
472# define VSF_ETH_MODE_UNICAST_FILTER VSF_ETH_MODE_UNICAST_FILTER
473
474 // \~english Enable filtering of multicast frames according to a filter table
475 // \~chinese 启用多播帧过滤,根据过滤表过滤多播帧
476 VSF_ETH_MODE_MULTICAST_FILTER = 1 << 8,
477# define VSF_ETH_MODE_MULTICAST_FILTER VSF_ETH_MODE_MULTICAST_FILTER
478
479 // \~english Enable filtering of broadcast frames
480 // \~chinese 启用广播帧过滤,可选择是否接收广播帧
481 VSF_ETH_MODE_BROADCAST_FILTER = 1 << 9,
482# define VSF_ETH_MODE_BROADCAST_FILTER VSF_ETH_MODE_BROADCAST_FILTER
483
484 /* VLAN Support Options
485 * --------------------
486 * VLAN (Virtual LAN) allows network segmentation at Layer 2
487 */
488 // \~english Enable adding VLAN tags to outgoing frames
489 // \~chinese 启用VLAN标签,向外发送的帧添加VLAN标签
490 VSF_ETH_MODE_VLAN_TAGGING = 1 << 10,
491# define VSF_ETH_MODE_VLAN_TAGGING VSF_ETH_MODE_VLAN_TAGGING
492
493 // \~english Enable filtering frames based on VLAN ID
494 // \~chinese 启用VLAN标签过滤,根据VLAN ID过滤接收的帧
495 VSF_ETH_MODE_VLAN_FILTERING = 1 << 11,
496# define VSF_ETH_MODE_VLAN_FILTERING VSF_ETH_MODE_VLAN_FILTERING
497
498 // \~english Remove VLAN tags from received frames before passing to upper layer
499 // \~chinese 启用VLAN标签剥离,在传递给上层前移除接收帧中的VLAN标签
500 VSF_ETH_MODE_VLAN_STRIPPING = 1 << 12,
501# define VSF_ETH_MODE_VLAN_STRIPPING VSF_ETH_MODE_VLAN_STRIPPING
502
503 // \~english Insert VLAN tags into outgoing frames that don't have them
504 // \~chinese 启用VLAN标签插入,向没有VLAN标签的外发帧插入标签
505 VSF_ETH_MODE_VLAN_INSERTION = 1 << 13,
506# define VSF_ETH_MODE_VLAN_INSERTION VSF_ETH_MODE_VLAN_INSERTION
507
508 /* Special Frame Handling
509 * --------------------- */
510 // \~english Support for frames larger than 1518 bytes (up to 9000 bytes typically)
511 // \~chinese 支持巨型帧,允许处理大于1518字节的帧(通常最大可达9000字节)
512 VSF_ETH_MODE_JUMBO_FRAME = 1 << 14,
513# define VSF_ETH_MODE_JUMBO_FRAME VSF_ETH_MODE_JUMBO_FRAME
514
515 // \~english Support IEEE 802.3x flow control mechanism to prevent buffer overflow
516 // \~chinese 支持IEEE 802.3x流控制机制,防止缓冲区溢出
517 VSF_ETH_MODE_FLOW_CONTROL = 1 << 15,
518# define VSF_ETH_MODE_FLOW_CONTROL VSF_ETH_MODE_FLOW_CONTROL
519
520 // \~english Support for pause frames which temporarily pause transmission
521 // \~chinese 支持暂停帧,可临时暂停传输以控制数据流
522 VSF_ETH_MODE_PAUSE_FRAME = 1 << 16,
523# define VSF_ETH_MODE_PAUSE_FRAME VSF_ETH_MODE_PAUSE_FRAME
524
525 /* QoS and Traffic Management
526 * ------------------------- */
527 // \~english Support for multiple priority queues for traffic handling
528 // \~chinese 支持优先级队列,根据优先级处理不同流量
529 VSF_ETH_MODE_PRIORITY_QUEUE = 1 << 17,
530# define VSF_ETH_MODE_PRIORITY_QUEUE VSF_ETH_MODE_PRIORITY_QUEUE
531
532 // \~english Quality of Service support for traffic differentiation
533 // \~chinese 服务质量支持,区分处理不同类型的流量
534 VSF_ETH_MODE_QOS = 1 << 18,
535# define VSF_ETH_MODE_QOS VSF_ETH_MODE_QOS
536
537 /* Time Synchronization
538 * ------------------- */
539 // \~english Support for Precision Time Protocol timestamp for accurate timing
540 // \~chinese 支持精确时间协议时间戳,用于精确计时
541 VSF_ETH_MODE_PTP_TIMESTAMP = 1 << 19,
542# define VSF_ETH_MODE_PTP_TIMESTAMP VSF_ETH_MODE_PTP_TIMESTAMP
543
544 /* Advanced Hardware Acceleration
545 * ----------------------------- */
546 // \~english TCP Segmentation Offload - hardware handles TCP segmentation
547 // \~chinese TCP分段卸载 - 硬件处理TCP分段,减轻CPU负担
548 VSF_ETH_MODE_TCP_SEGMENTATION = 1 << 20,
549# define VSF_ETH_MODE_TCP_SEGMENTATION VSF_ETH_MODE_TCP_SEGMENTATION
550
551 // \~english Large Receive Offload - hardware combines received TCP segments
552 // \~chinese 大型接收卸载 - 硬件合并接收到的TCP分段,减少处理开销
553 VSF_ETH_MODE_LARGE_RECEIVE = 1 << 21,
554# define VSF_ETH_MODE_LARGE_RECEIVE VSF_ETH_MODE_LARGE_RECEIVE
555#endif
557#endif
558
565enum {
566#ifndef VSF_ETH_MODE_OFFLOAD_MASK
568#endif
569
570#ifndef VSF_ETH_MODE_ALL_BITS_MASK
572#endif
573};
574
575
576#if VSF_ETH_CFG_REIMPLEMENT_TYPE_IRQ_MASK == DISABLED
577typedef enum vsf_eth_irq_mask_t {
580
583
585
588#endif
589
590enum {
591#ifndef VSF_ETH_IRQ_MASK_ALL
597#endif
598};
599
600
601#if VSF_ETH_CFG_REIMPLEMENT_TYPE_CFG == DISABLED
606typedef struct vsf_eth_t vsf_eth_t;
607
616typedef void vsf_eth_isr_handler_t(void *target_ptr, vsf_eth_t *eth_ptr,
618
623typedef struct vsf_eth_isr_t {
628
636typedef struct vsf_eth_cfg_t {
642#endif
643
652#if VSF_ETH_CFG_REIMPLEMENT_TYPE_STATUS == DISABLED
653typedef struct vsf_eth_status_t {
654 union {
657 struct {
660 };
661 };
663#endif
664
665#if VSF_ETH_CFG_REIMPLEMENT_TYPE_CAPABILITY == DISABLED
676typedef struct vsf_eth_capability_t {
677#if VSF_ETH_CFG_INHERIT_HAL_CAPABILITY == ENABLED
679#endif
680
681 vsf_eth_mode_t support_modes;
684
685 union {
687 struct {
694
701 };
702 };
704#endif
705
706#if VSF_ETH_CFG_REIMPLEMENT_TYPE_BUF_MODE == DISABLED
707typedef enum vsf_eth_buf_mode_t {
710
711 // TODO: Add more modes as needed
713#endif
714
715#if VSF_ETH_CFG_REIMPLEMENT_TYPE_BUF_DESC == DISABLED
716typedef struct vsf_eth_buf_desc_t {
718 void *payload;
719 size_t len;
721#endif
722
723#if VSF_ETH_CFG_REIMPLEMENT_TYPE_SEND_BUF_DESC == DISABLED
727#endif
728
729#if VSF_ETH_CFG_REIMPLEMENT_TYPE_RECV_BUF_DESC == DISABLED
733#endif
734
735#if VSF_ETH_CFG_REIMPLEMENT_TYPE_SG_SEND_BUF == DISABLED
739#endif
740
741#if VSF_ETH_CFG_REIMPLEMENT_TYPE_SG_RECV_BUF == DISABLED
745#endif
746
747#if VSF_ETH_CFG_REIMPLEMENT_TYPE_CTRL == DISABLED
748typedef enum vsf_eth_ctrl_t {
750
751 /* IEEE 802.3 Clause 45 Configuration Commands */
752 /*
753 VSF_ETH_CTRL_PHY_C45_READ_REG, //!< \~english Read PHY register using Clause 45 access (vsf_eth_phy_c45_reg_access_t *) \~chinese 使用 Clause 45 访问方式读取 PHY 寄存器 (vsf_eth_phy_c45_reg_access_t *)
754 VSF_ETH_CTRL_PHY_C45_WRITE_REG, //!< \~english Write PHY register using Clause 45 access (vsf_eth_phy_c45_reg_access_t *) \~chinese 使用 Clause 45 访问方式写入 PHY 寄存器 (vsf_eth_phy_c45_reg_access_t *)
755 */
756
757 /* PLCA (Physical Layer Collision Avoidance) Configuration Commands - For 10BASE-T1S Ethernet */
758 /*
759 VSF_ETH_CTRL_PHY_PLCA_ENABLE, //!< \~english Enable PLCA operation (bool) \~chinese 启用 PLCA 操作 (bool)
760 VSF_ETH_CTRL_PHY_PLCA_GET_STATUS, //!< \~english Get PLCA status (bool *) \~chinese 获取 PLCA 状态 (bool *)
761 VSF_ETH_CTRL_PHY_PLCA_SET_NODE_ID, //!< \~english Set PLCA node ID (uint8_t) \~chinese 设置 PLCA 节点 ID (uint8_t)
762 VSF_ETH_CTRL_PHY_PLCA_SET_NODE_COUNT, //!< \~english Set PLCA node count (uint8_t) \~chinese 设置 PLCA 节点数量 (uint8_t)
763 VSF_ETH_CTRL_PHY_PLCA_SET_BURST_COUNT, //!< \~english Set PLCA burst count (uint8_t) \~chinese 设置 PLCA 突发计数 (uint8_t)
764 VSF_ETH_CTRL_PHY_PLCA_SET_BURST_TIMER, //!< \~english Set PLCA burst timer (uint8_t) \~chinese 设置 PLCA 突发计时器 (uint8_t)
765 */
766
767 // TODO: Add more control commands as needed
769#endif
770
776typedef struct vsf_eth_op_t {
778#undef __VSF_HAL_TEMPLATE_API
779#define __VSF_HAL_TEMPLATE_API VSF_HAL_TEMPLATE_API_FP
781
782 VSF_ETH_APIS(vsf_eth)
784
785
786#if VSF_ETH_CFG_MULTI_CLASS == ENABLED
791struct vsf_eth_t {
793};
794#endif
795
796/*============================ PROTOTYPES ====================================*/
797
817extern vsf_err_t vsf_eth_init(vsf_eth_t *eth_ptr, vsf_eth_cfg_t *cfg_ptr);
818
830extern void vsf_eth_fini(vsf_eth_t *eth_ptr);
831
850
862extern fsm_rt_t vsf_eth_enable(vsf_eth_t *eth_ptr);
863
875extern fsm_rt_t vsf_eth_disable(vsf_eth_t *eth_ptr);
876
890extern void vsf_eth_irq_enable(vsf_eth_t *eth_ptr, vsf_eth_irq_mask_t isr_mask);
891
905extern void vsf_eth_irq_disable(vsf_eth_t *eth_ptr, vsf_eth_irq_mask_t isr_mask);
906
933
946
959
978
997
998
1019
1038
1056extern vsf_err_t vsf_eth_ctrl(vsf_eth_t *eth_ptr, vsf_eth_ctrl_t ctrl, void *param);
1057
1073extern vsf_err_t vsf_eth_phy_read_reg(vsf_eth_t *eth_ptr, uint16_t reg_addr, uint32_t *value_ptr);
1074
1091
1120
1121/*============================ ETHROFIED FUNCTIONS ===========================*/
1122
1124#if VSF_ETH_CFG_FUNCTION_RENAME == ENABLED
1125# define __vsf_eth_t VSF_MCONNECT(VSF_ETH_CFG_PREFIX, _eth_t)
1126# define vsf_eth_init(__ETH, ...) VSF_MCONNECT(VSF_ETH_CFG_PREFIX, _eth_init)((__vsf_eth_t *)(__ETH), ##__VA_ARGS__)
1127# define vsf_eth_fini(__ETH) VSF_MCONNECT(VSF_ETH_CFG_PREFIX, _eth_fini)((__vsf_eth_t *)(__ETH))
1128# define vsf_eth_get_configuration(__ETH, ...) VSF_MCONNECT(VSF_ETH_CFG_PREFIX, _eth_get_configuration)((__vsf_eth_t *)(__ETH), ##__VA_ARGS__)
1129# define vsf_eth_enable(__ETH) VSF_MCONNECT(VSF_ETH_CFG_PREFIX, _eth_enable)((__vsf_eth_t *)(__ETH))
1130# define vsf_eth_disable(__ETH) VSF_MCONNECT(VSF_ETH_CFG_PREFIX, _eth_disable)((__vsf_eth_t *)(__ETH))
1131# define vsf_eth_irq_enable(__ETH, ...) VSF_MCONNECT(VSF_ETH_CFG_PREFIX, _eth_irq_enable)((__vsf_eth_t *)(__ETH), ##__VA_ARGS__)
1132# define vsf_eth_irq_disable(__ETH, ...) VSF_MCONNECT(VSF_ETH_CFG_PREFIX, _eth_irq_disable)((__vsf_eth_t *)(__ETH), ##__VA_ARGS__)
1133# define vsf_eth_irq_clear(__ETH, ...) VSF_MCONNECT(VSF_ETH_CFG_PREFIX, _eth_irq_clear)((__vsf_eth_t *)(__ETH), ##__VA_ARGS__)
1134# define vsf_eth_status(__ETH) VSF_MCONNECT(VSF_ETH_CFG_PREFIX, _eth_status)((__vsf_eth_t *)(__ETH))
1135# define vsf_eth_capability(__ETH) VSF_MCONNECT(VSF_ETH_CFG_PREFIX, _eth_capability)((__vsf_eth_t *)(__ETH))
1136# define vsf_eth_send_request(__ETH, ...) VSF_MCONNECT(VSF_ETH_CFG_PREFIX, _eth_send_request)((__vsf_eth_t *)(__ETH), ##__VA_ARGS__)
1137# define vsf_eth_send_sg_request(__ETH, ...) VSF_MCONNECT(VSF_ETH_CFG_PREFIX, _eth_send_sg_request)((__vsf_eth_t *)(__ETH), ##__VA_ARGS__)
1138# define vsf_eth_recv_request(__ETH, ...) VSF_MCONNECT(VSF_ETH_CFG_PREFIX, _eth_recv_request)((__vsf_eth_t *)(__ETH), ##__VA_ARGS__)
1139# define vsf_eth_recv_sg_request(__ETH, ...) VSF_MCONNECT(VSF_ETH_CFG_PREFIX, _eth_recv_sg_request)((__vsf_eth_t *)(__ETH), ##__VA_ARGS__)
1140# define vsf_eth_ctrl(__ETH, ...) VSF_MCONNECT(VSF_ETH_CFG_PREFIX, _eth_ctrl)((__vsf_eth_t *)(__ETH), ##__VA_ARGS__)
1141# define vsf_eth_phy_read_reg(__ETH, ...) VSF_MCONNECT(VSF_ETH_CFG_PREFIX, _eth_phy_read_reg)((__vsf_eth_t *)(__ETH), ##__VA_ARGS__)
1142# define vsf_eth_phy_write_reg(__ETH, ...) VSF_MCONNECT(VSF_ETH_CFG_PREFIX, _eth_phy_write_reg)((__vsf_eth_t *)(__ETH), ##__VA_ARGS__)
1143# define vsf_eth_phy_set_mode(__ETH, ...) VSF_MCONNECT(VSF_ETH_CFG_PREFIX, _eth_phy_set_mode)((__vsf_eth_t *)(__ETH), ##__VA_ARGS__)
1144# define vsf_eth_phy_get_link_status(__ETH, ...) VSF_MCONNECT(VSF_ETH_CFG_PREFIX, _eth_phy_get_link_status)((__vsf_eth_t *)(__ETH), ##__VA_ARGS__)
1145#endif
1147
1148#ifdef __cplusplus
1149}
1150#endif
1151
1152#endif /*__VSF_TEMPLATE_ETH_H__*/
vsf_err_t
Definition __type.h:42
vsf_arch_prio_t
Definition cortex_a_generic.h:88
vsf_eth_irq_mask_t
Definition eth.h:153
vsf_eth_buf_mode_t
Definition eth.h:226
vsf_eth_mode_t
Definition eth.h:144
vsf_eth_phy_mode_t
Definition eth.h:129
void vsf_eth_isr_handler_t(void *target_ptr, vsf_eth_t *eth_ptr, vsf_eth_irq_mask_t irq_mask)
Definition eth.h:175
const i_spi_t vsf_spi_irq_mask_t irq_mask
Definition spi_interface.h:38
unsigned short uint16_t
Definition stdint.h:7
unsigned uint32_t
Definition stdint.h:9
unsigned char uint8_t
Definition stdint.h:5
Definition vsf_template_eth.h:716
void * payload
Definition vsf_template_eth.h:718
vsf_eth_buf_mode_t mode
Definition vsf_template_eth.h:717
size_t len
Definition vsf_template_eth.h:719
Predefined VSF ETH capability that can be reimplemented in specific hal drivers. The vsf_eth_capabili...
Definition vsf_template_eth.h:676
uint32_t is_send_buf_releasable_immediately
Definition vsf_template_eth.h:693
uint32_t is_sg_send_buf_releasable_immediately
Definition vsf_template_eth.h:700
inherit(vsf_peripheral_capability_t) vsf_eth_mode_t support_modes
Supported modes, refer to vsf_eth_mode_t.
vsf_eth_phy_mode_t support_phy_modes
Supported PHY modes, refer to vsf_eth_phy_mode_t.
Definition vsf_template_eth.h:682
uint32_t value
Definition vsf_template_eth.h:686
vsf_eth_irq_mask_t support_irq_mask
Supported IRQ masks, refer to vsf_eth_irq_mask_t.
Definition vsf_template_eth.h:683
ETH configuration structure.
Definition vsf_template_eth.h:636
uint8_t mac_address[6]
MAC address, 6 bytes.
Definition vsf_template_eth.h:639
vsf_eth_phy_mode_t phy_mode
PHY mode, refer to vsf_eth_phy_mode_t.
Definition vsf_template_eth.h:638
vsf_eth_isr_t isr
ETH interrupt configuration, refer to vsf_eth_isr_t.
Definition vsf_template_eth.h:640
vsf_eth_mode_t mode
ETH mode, refer to vsf_eth_mode_t.
Definition vsf_template_eth.h:637
ETH interrupt configuration structure.
Definition vsf_template_eth.h:623
vsf_eth_isr_handler_t * handler_fn
Interrupt handler function pointer.
Definition vsf_template_eth.h:624
void * target_ptr
User-defined target pointer.
Definition vsf_template_eth.h:625
vsf_arch_prio_t prio
Interrupt priority.
Definition vsf_template_eth.h:626
ETH operation function pointer type, used for ETH Multi Class support.
Definition vsf_template_eth.h:776
ETH status information structure Contains the current status of ETH operations and FIFO thresholds.
Definition vsf_template_eth.h:653
uint32_t is_tx_ready
TX is ready to accept data.
Definition vsf_template_eth.h:659
uint32_t is_rx_available
RX data is available.
Definition vsf_template_eth.h:658
ETH instance structure, used for ETH Multi Class support, not needed in non Multi Class mode.
Definition vsf_template_eth.h:791
const vsf_eth_op_t * op
Definition vsf_template_eth.h:792
Definition vsf_template_hal_driver.h:204
Definition vsf_template_hal_driver.h:197
vk_av_control_value_t value
Definition vsf_audio.h:171
fsm_rt_t
Definition vsf_fsm.h:315
vsf_err_t vsf_eth_init(vsf_eth_t *eth_ptr, vsf_eth_cfg_t *cfg_ptr)
Initialize a ETH instance.
Definition eth_common.c:38
vsf_err_t vsf_eth_recv_sg_request(vsf_eth_t *eth_ptr, vsf_eth_recv_sg_buf_desc_t *sg_ptr, uint32_t sg_count)
Receive data using scatter-gather buffers from ETH instance.
Definition eth_common.c:129
void vsf_eth_irq_enable(vsf_eth_t *eth_ptr, vsf_eth_irq_mask_t isr_mask)
Enable ETH instance interrupt.
Definition eth_common.c:84
void vsf_eth_fini(vsf_eth_t *eth_ptr)
Finalize a ETH instance.
Definition eth_common.c:47
#define VSF_ETH_APIS(__prefix_name)
ETH API template, used to generate ETH type, specific prefix function declarations,...
Definition vsf_template_eth.h:321
vsf_eth_buf_desc_t vsf_eth_recv_buf_desc_t
Definition vsf_template_eth.h:732
vsf_eth_irq_mask_t
Definition vsf_template_eth.h:577
@ VSF_ETH_IRQ_MASK_ERROR
Error interrupt mask.
Definition vsf_template_eth.h:586
@ VSF_ETH_IRQ_MASK_RX_AVAILABLE
RX data available interrupt mask.
Definition vsf_template_eth.h:578
@ VSF_ETH_IRQ_MASK_PHY_LINK_CHANGE
PHY link change interrupt mask.
Definition vsf_template_eth.h:584
@ VSF_ETH_IRQ_MASK_SG_TX_COMPLETE
Scatter-gather TX complete interrupt mask.
Definition vsf_template_eth.h:582
@ VSF_ETH_IRQ_MASK_SG_RX_AVAILABLE
Scatter-gather RX available interrupt mask.
Definition vsf_template_eth.h:581
@ VSF_ETH_IRQ_MASK_TX_COMPLETE
TX complete interrupt mask.
Definition vsf_template_eth.h:579
struct vsf_eth_cfg_t vsf_eth_cfg_t
ETH configuration structure.
fsm_rt_t vsf_eth_enable(vsf_eth_t *eth_ptr)
Enable a ETH instance.
Definition eth_common.c:66
struct vsf_eth_status_t vsf_eth_status_t
ETH status information structure Contains the current status of ETH operations and FIFO thresholds.
@ VSF_ETH_MODE_OFFLOAD_MASK
Definition vsf_template_eth.h:567
@ VSF_ETH_MODE_ALL_BITS_MASK
Definition vsf_template_eth.h:571
vsf_err_t vsf_eth_send_request(vsf_eth_t *eth_ptr, vsf_eth_send_buf_desc_t *buf_ptr)
Send a buffer over ETH instance.
Definition eth_common.c:102
fsm_rt_t vsf_eth_disable(vsf_eth_t *eth_ptr)
Disable a ETH instance.
Definition eth_common.c:75
vsf_err_t vsf_eth_get_configuration(vsf_eth_t *eth_ptr, vsf_eth_cfg_t *cfg_ptr)
Get current configuration of an ETH instance.
Definition eth_common.c:56
vsf_err_t vsf_eth_ctrl(vsf_eth_t *eth_ptr, vsf_eth_ctrl_t ctrl, void *param)
Control ETH instance.
Definition eth_common.c:138
vsf_eth_ctrl_t
Definition vsf_template_eth.h:748
@ VSF_ETH_CTRL_GET_MAC_ADDRESS
Get MAC address (uint8_t *)
Definition vsf_template_eth.h:749
vsf_eth_buf_mode_t
Definition vsf_template_eth.h:707
@ VSF_ETH_BUF_MODE_TX_CHECKSUM_OFFLOAD
TX checksum offload mode.
Definition vsf_template_eth.h:708
@ VSF_ETH_BUF_MODE_RX_CHECKSUM_OFFLOAD
RX checksum offload mode.
Definition vsf_template_eth.h:709
vsf_err_t vsf_eth_phy_write_reg(vsf_eth_t *eth_ptr, uint16_t reg_addr, uint32_t value)
Write a value to a PHY register.
struct vsf_eth_buf_desc_t vsf_eth_buf_desc_t
vsf_eth_capability_t vsf_eth_capability(vsf_eth_t *eth_ptr)
Get the capability of ETH instance.
Definition eth_common.c:156
vsf_err_t vsf_eth_recv_request(vsf_eth_t *eth_ptr, vsf_eth_recv_buf_desc_t *buf_ptr)
Receive a buffer from ETH instance.
Definition eth_common.c:111
vsf_eth_mode_t
Predefined VSF ETH modes that can be reimplemented in specific HAL drivers.The following modes must b...
Definition vsf_template_eth.h:462
@ VSF_ETH_MODE_TX_CHECKSUM_OFFLOAD
TX checksum offload mode.
Definition vsf_template_eth.h:463
@ VSF_ETH_MODE_RX_CHECKSUM_OFFLOAD
RX checksum offload mode.
Definition vsf_template_eth.h:464
vsf_eth_phy_mode_t
Predefined VSF ETH modes that can be reimplemented in specific HAL drivers.The following modes must b...
Definition vsf_template_eth.h:383
@ VSF_ETH_PHY_MODE_LINK_UP
Link up mode.
Definition vsf_template_eth.h:394
@ VSF_ETH_PHY_MODE_SPEED_1000M
1000M speed mode
Definition vsf_template_eth.h:389
@ VSF_ETH_PHY_MODE_SPEED_100M
100M speed mode
Definition vsf_template_eth.h:388
@ VSF_ETH_PHY_MODE_SPEED_10M
10M speed mode
Definition vsf_template_eth.h:387
@ VSF_ETH_PHY_MODE_DUPLEX_HALF
Half duplex mode.
Definition vsf_template_eth.h:391
@ VSF_ETH_PHY_MODE_DUPLEX_FULL
Full duplex mode.
Definition vsf_template_eth.h:392
vsf_err_t vsf_eth_send_sg_request(vsf_eth_t *eth_ptr, vsf_eth_send_sg_buf_desc_t *sg_ptr, uint32_t sg_count)
Send a scatter-gather buffer over ETH instance.
Definition eth_common.c:120
vsf_err_t vsf_eth_phy_set_mode(vsf_eth_t *eth_ptr, vsf_eth_phy_mode_t mode)
Configure the PHY operating mode.
vsf_eth_buf_desc_t vsf_eth_send_sg_buf_desc_t
Definition vsf_template_eth.h:738
vsf_eth_irq_mask_t vsf_eth_irq_clear(vsf_eth_t *eth_ptr, vsf_eth_irq_mask_t irq_mask)
Clear interrupt flags of ETH instance and return previous state.
vsf_eth_buf_desc_t vsf_eth_send_buf_desc_t
Definition vsf_template_eth.h:726
struct vsf_eth_capability_t vsf_eth_capability_t
Predefined VSF ETH capability that can be reimplemented in specific hal drivers. The vsf_eth_capabili...
vsf_err_t vsf_eth_phy_read_reg(vsf_eth_t *eth_ptr, uint16_t reg_addr, uint32_t *value_ptr)
Read a PHY register.
vsf_err_t vsf_eth_phy_get_link_status(vsf_eth_t *eth_ptr, vsf_eth_phy_mode_t *phy_mode_ptr)
Get the current link status of the PHY.
@ VSF_ETH_PHY_MODE_SPEED_MASK
Definition vsf_template_eth.h:411
@ VSF_ETH_PHY_MODE_ALL_BITS_MASK
Definition vsf_template_eth.h:419
@ VSF_ETH_PHY_MODE_DUPLEX_MASK
Definition vsf_template_eth.h:415
vsf_eth_buf_desc_t vsf_eth_recv_sg_buf_desc_t
Definition vsf_template_eth.h:744
void vsf_eth_isr_handler_t(void *target_ptr, vsf_eth_t *eth_ptr, vsf_eth_irq_mask_t irq_mask)
ETH interrupt handler type declaration.
Definition vsf_template_eth.h:616
@ VSF_ETH_IRQ_MASK_ALL
Definition vsf_template_eth.h:592
struct vsf_eth_isr_t vsf_eth_isr_t
ETH interrupt configuration structure.
void vsf_eth_irq_disable(vsf_eth_t *eth_ptr, vsf_eth_irq_mask_t isr_mask)
Disable ETH instance interrupt.
Definition eth_common.c:93
vsf_eth_status_t vsf_eth_status(vsf_eth_t *eth_ptr)
Get the status of ETH instance.
Definition eth_common.c:147
Generated from commit: vsfteam/vsf@b2e9e8a