VSF Documented
Data Structures | Macros | Typedefs | Enumerations | Functions
vsf_template_eth.h File Reference
#include "./vsf_template_hal_driver.h"
#include "hal/arch/vsf_arch.h"

Go to the source code of this file.

Data Structures

struct  vsf_eth_isr_t
 ETH interrupt configuration structure. More...
 
struct  vsf_eth_cfg_t
 ETH configuration structure. More...
 
struct  vsf_eth_status_t
 ETH status information structure Contains the current status of ETH operations and FIFO thresholds. More...
 
struct  vsf_eth_capability_t
 Predefined VSF ETH capability that can be reimplemented in specific hal drivers. The vsf_eth_capability_t structure defines the features supported by the ETH hardware. When reimplementing this structure, all existing members must be preserved. More...
 
struct  vsf_eth_buf_desc_t
 
struct  vsf_eth_op_t
 ETH operation function pointer type, used for ETH Multi Class support. More...
 
struct  vsf_eth_t
 ETH instance structure, used for ETH Multi Class support, not needed in non Multi Class mode. More...
 

Macros

#define VSF_ETH_CFG_MULTI_CLASS   ENABLED
 Enable multi-class support by default for maximum availability.
 
#define VSF_ETH_CFG_MULTI_PHY_CLASS   ENABLED
 
#define VSF_ETH_CFG_PREFIX   vsf
 We can redefine ethro VSF_ETH_CFG_PREFIX to specify a prefix to call a specific driver directly in the application code. Example:
 
#define VSF_ETH_CFG_FUNCTION_RENAME   ENABLED
 After define VSF_ETH_CFG_FUNCTION_RENAME to DISABLED, calling any vsf_eth_xxx() function will not be renamed. It has higher priority than VSF_ETH_CFG_PREFIX.
 
#define VSF_ETH_CFG_REIMPLEMENT_TYPE_PHY_MODE   DISABLED
 In specific hardware driver, we can enable ethro VSF_ETH_CFG_REIMPLEMENT_TYPE_PHY_MODE to redefine enum vsf_eth_mode_t.
 
#define VSF_ETH_CFG_REIMPLEMENT_TYPE_MODE   DISABLED
 In specific hardware driver, we can enable ethro VSF_ETH_CFG_REIMPLEMENT_TYPE_MODE to redefine enum vsf_eth_mode_t.
 
#define VSF_ETH_CFG_REIMPLEMENT_TYPE_CFG   DISABLED
 In specific hardware driver, we can enable ethro VSF_ETH_CFG_REIMPLEMENT_TYPE_CFG to redefine struct vsf_eth_cfg_t. For compatibility, members should not be deleted when redefining it.
 
#define VSF_ETH_CFG_REIMPLEMENT_TYPE_STATUS   DISABLED
 In the specific hardware driver, we can enable VSF_ETH_CFG_REIMPLEMENT_TYPE_STATUS to redefine struct vsf_eth_status_t.
 
#define VSF_ETH_CFG_REIMPLEMENT_TYPE_CAPABILITY   DISABLED
 In specific hardware driver, we can enable ethro VSF_ETH_CFG_REIMPLEMENT_TYPE_CAPABILITY to redefine struct vsf_eth_capability_t. For compatibility, members should not be deleted when redefining it.
 
#define VSF_ETH_CFG_REIMPLEMENT_TYPE_BUF_MODE   DISABLED
 In specific hardware driver, we can enable ethro VSF_ETH_CFG_REIMPLEMENT_TYPE_BUF_MODE to redefine struct vsf_eth_buf_mode_t.
 
#define VSF_ETH_CFG_REIMPLEMENT_TYPE_BUF_DESC   DISABLED
 
#define VSF_ETH_CFG_REIMPLEMENT_TYPE_SEND_BUF_DESC   DISABLED
 
#define VSF_ETH_CFG_REIMPLEMENT_TYPE_RECV_BUF_DESC   DISABLED
 
#define VSF_ETH_CFG_REIMPLEMENT_TYPE_SG_BUF_DESC   DISABLED
 In specific hardware driver, we can enable ethro VSF_ETH_CFG_REIMPLEMENT_TYPE_SG_BUF_DESC to redefine struct vsf_eth_buf_desc_t.
 
#define VSF_ETH_CFG_REIMPLEMENT_TYPE_IRQ_MASK   DISABLED
 In specific hardware driver, we can enable ethro VSF_ETH_CFG_REIMPLEMENT_TYPE_IRQ_MASK to redefine struct vsf_eth_irq_mask_t.
 
#define VSF_ETH_CFG_INHERIT_HAL_CAPABILITY   ENABLED
 In specific hardware driver, we can enable ethro VSF_ETH_CFG_INHERIT_HAL_CAPABILITY to inherit the structure vsf_peripheral_capability_t.
 
#define VSF_ETH_APIS(__prefix)
 ETH API template, used to generate ETH type, specific prefix function declarations, etc.
 

Typedefs

typedef enum vsf_eth_phy_mode_t vsf_eth_phy_mode_t
 Predefined VSF ETH modes that can be reimplemented in specific HAL drivers.The following modes must be retained even if not supported by hardware. If hardware supports more modes, we can implement them in the hardware driver:
 
typedef enum vsf_eth_mode_t vsf_eth_mode_t
 Predefined VSF ETH modes that can be reimplemented in specific HAL drivers.The following modes must be retained even if not supported by hardware. If hardware supports more modes, we can implement them in the hardware driver:
 
typedef enum vsf_eth_irq_mask_t vsf_eth_irq_mask_t
 
typedef struct vsf_eth_t vsf_eth_t
 ETH forward declaration.
 
typedef 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.
 
typedef struct vsf_eth_isr_t vsf_eth_isr_t
 ETH interrupt configuration structure.
 
typedef struct vsf_eth_cfg_t vsf_eth_cfg_t
 ETH configuration structure.
 
typedef struct vsf_eth_status_t vsf_eth_status_t
 ETH status information structure Contains the current status of ETH operations and FIFO thresholds.
 
typedef struct vsf_eth_capability_t vsf_eth_capability_t
 Predefined VSF ETH capability that can be reimplemented in specific hal drivers. The vsf_eth_capability_t structure defines the features supported by the ETH hardware. When reimplementing this structure, all existing members must be preserved.
 
typedef enum vsf_eth_buf_mode_t vsf_eth_buf_mode_t
 
typedef struct vsf_eth_buf_desc_t vsf_eth_buf_desc_t
 
typedef vsf_eth_buf_desc_t vsf_eth_send_buf_desc_t
 
typedef vsf_eth_buf_desc_t vsf_eth_recv_buf_desc_t
 
typedef vsf_eth_buf_desc_t vsf_eth_send_sg_buf_desc_t
 
typedef vsf_eth_buf_desc_t vsf_eth_recv_sg_buf_desc_t
 
typedef enum vsf_eth_ctrl_t vsf_eth_ctrl_t
 
typedef struct vsf_eth_op_t vsf_eth_op_t
 ETH operation function pointer type, used for ETH Multi Class support.
 

Enumerations

enum  vsf_eth_phy_mode_t {
  VSF_ETH_PHY_MODE_SPEED_10M = 1 << 0 ,
  VSF_ETH_PHY_MODE_SPEED_100M = 1 << 1 ,
  VSF_ETH_PHY_MODE_SPEED_1000M = 1 << 2 ,
  VSF_ETH_PHY_MODE_DUPLEX_HALF = 1 << 3 ,
  VSF_ETH_PHY_MODE_DUPLEX_FULL = 1 << 4 ,
  VSF_ETH_PHY_MODE_LINK_UP = 1 << 5
}
 Predefined VSF ETH modes that can be reimplemented in specific HAL drivers.The following modes must be retained even if not supported by hardware. If hardware supports more modes, we can implement them in the hardware driver: More...
 
enum  {
  VSF_ETH_PHY_MODE_SPEED_MASK = VSF_ETH_PHY_MODE_SPEED_10M | VSF_ETH_PHY_MODE_SPEED_100M | VSF_ETH_PHY_MODE_SPEED_1000M ,
  VSF_ETH_PHY_MODE_DUPLEX_MASK = VSF_ETH_PHY_MODE_DUPLEX_HALF | VSF_ETH_PHY_MODE_DUPLEX_FULL ,
  VSF_ETH_PHY_MODE_ALL_BITS_MASK = VSF_ETH_PHY_MODE_SPEED_MASK | VSF_ETH_PHY_MODE_DUPLEX_MASK
}
 ETH PHY mode completion, used to simplify the definition of ETH mode. More...
 
enum  vsf_eth_mode_t {
  VSF_ETH_MODE_TX_CHECKSUM_OFFLOAD = 1 << 5 ,
  VSF_ETH_MODE_RX_CHECKSUM_OFFLOAD = 1 << 6
}
 Predefined VSF ETH modes that can be reimplemented in specific HAL drivers.The following modes must be retained even if not supported by hardware. If hardware supports more modes, we can implement them in the hardware driver: More...
 
enum  {
  VSF_ETH_MODE_OFFLOAD_MASK = VSF_ETH_MODE_RX_CHECKSUM_OFFLOAD | VSF_ETH_MODE_TX_CHECKSUM_OFFLOAD ,
  VSF_ETH_MODE_ALL_BITS_MASK = VSF_ETH_MODE_OFFLOAD_MASK
}
 ETH mode completion, used to simplify the definition of ETH mode. More...
 
enum  vsf_eth_irq_mask_t {
  VSF_ETH_IRQ_MASK_RX_AVAILABLE = (1 << 0) ,
  VSF_ETH_IRQ_MASK_TX_COMPLETE = (1 << 1) ,
  VSF_ETH_IRQ_MASK_SG_RX_AVAILABLE = (1 << 2) ,
  VSF_ETH_IRQ_MASK_SG_TX_COMPLETE = (1 << 3) ,
  VSF_ETH_IRQ_MASK_PHY_LINK_CHANGE = (1 << 4) ,
  VSF_ETH_IRQ_MASK_ERROR = (1 << 5)
}
 
enum  { VSF_ETH_IRQ_MASK_ALL }
 
enum  vsf_eth_buf_mode_t {
  VSF_ETH_BUF_MODE_TX_CHECKSUM_OFFLOAD = 1 << 0 ,
  VSF_ETH_BUF_MODE_RX_CHECKSUM_OFFLOAD = 1 << 1
}
 
enum  vsf_eth_ctrl_t { VSF_ETH_CTRL_GET_MAC_ADDRESS }
 

Functions

vsf_err_t vsf_eth_init (vsf_eth_t *eth_ptr, vsf_eth_cfg_t *cfg_ptr)
 Initialize a ETH instance.
 
void vsf_eth_fini (vsf_eth_t *eth_ptr)
 Finalize a ETH instance.
 
fsm_rt_t vsf_eth_enable (vsf_eth_t *eth_ptr)
 Enable a ETH instance.
 
fsm_rt_t vsf_eth_disable (vsf_eth_t *eth_ptr)
 Disable a ETH instance.
 
void vsf_eth_isr_enable (vsf_eth_t *eth_ptr, vsf_eth_irq_mask_t isr_mask)
 Enable ETH instance interrupt.
 
void vsf_eth_isr_disable (vsf_eth_t *eth_ptr, vsf_eth_irq_mask_t isr_mask)
 Disable ETH instance interrupt.
 
vsf_eth_status_t vsf_eth_status (vsf_eth_t *eth_ptr)
 Get the status of ETH instance.
 
vsf_eth_capability_t vsf_eth_capability (vsf_eth_t *eth_ptr)
 Get the capability of ETH instance.
 
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.
 
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.
 
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.
 
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.
 
vsf_err_t vsf_eth_ctrl (vsf_eth_t *eth_ptr, vsf_eth_ctrl_t ctrl, void *param)
 Control ETH instance.
 
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_write_reg (vsf_eth_t *eth_ptr, uint16_t reg_addr, uint32_t value)
 Write a value to a PHY register.
 
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_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.
 

Macro Definition Documentation

◆ VSF_ETH_CFG_MULTI_CLASS

#define VSF_ETH_CFG_MULTI_CLASS   ENABLED

Enable multi-class support by default for maximum availability.

◆ VSF_ETH_CFG_MULTI_PHY_CLASS

#define VSF_ETH_CFG_MULTI_PHY_CLASS   ENABLED

◆ VSF_ETH_CFG_PREFIX

#define VSF_ETH_CFG_PREFIX   vsf

We can redefine ethro VSF_ETH_CFG_PREFIX to specify a prefix to call a specific driver directly in the application code. Example:

#define VSF_ETH_CFG_PREFIX my_device // Use my device hardware ETH driver
vsf_eth_init() // Will be expanded to my_device_eth_init()
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
Note
This ethro is only valid when VSF_ETH_CFG_FUNCTION_RENAME is ENABLED.

◆ VSF_ETH_CFG_FUNCTION_RENAME

#define VSF_ETH_CFG_FUNCTION_RENAME   ENABLED

After define VSF_ETH_CFG_FUNCTION_RENAME to DISABLED, calling any vsf_eth_xxx() function will not be renamed. It has higher priority than VSF_ETH_CFG_PREFIX.

◆ VSF_ETH_CFG_REIMPLEMENT_TYPE_PHY_MODE

#define VSF_ETH_CFG_REIMPLEMENT_TYPE_PHY_MODE   DISABLED

In specific hardware driver, we can enable ethro VSF_ETH_CFG_REIMPLEMENT_TYPE_PHY_MODE to redefine enum vsf_eth_mode_t.

◆ VSF_ETH_CFG_REIMPLEMENT_TYPE_MODE

#define VSF_ETH_CFG_REIMPLEMENT_TYPE_MODE   DISABLED

In specific hardware driver, we can enable ethro VSF_ETH_CFG_REIMPLEMENT_TYPE_MODE to redefine enum vsf_eth_mode_t.

◆ VSF_ETH_CFG_REIMPLEMENT_TYPE_CFG

#define VSF_ETH_CFG_REIMPLEMENT_TYPE_CFG   DISABLED

In specific hardware driver, we can enable ethro VSF_ETH_CFG_REIMPLEMENT_TYPE_CFG to redefine struct vsf_eth_cfg_t. For compatibility, members should not be deleted when redefining it.

◆ VSF_ETH_CFG_REIMPLEMENT_TYPE_STATUS

#define VSF_ETH_CFG_REIMPLEMENT_TYPE_STATUS   DISABLED

In the specific hardware driver, we can enable VSF_ETH_CFG_REIMPLEMENT_TYPE_STATUS to redefine struct vsf_eth_status_t.

◆ VSF_ETH_CFG_REIMPLEMENT_TYPE_CAPABILITY

#define VSF_ETH_CFG_REIMPLEMENT_TYPE_CAPABILITY   DISABLED

In specific hardware driver, we can enable ethro VSF_ETH_CFG_REIMPLEMENT_TYPE_CAPABILITY to redefine struct vsf_eth_capability_t. For compatibility, members should not be deleted when redefining it.

◆ VSF_ETH_CFG_REIMPLEMENT_TYPE_BUF_MODE

#define VSF_ETH_CFG_REIMPLEMENT_TYPE_BUF_MODE   DISABLED

In specific hardware driver, we can enable ethro VSF_ETH_CFG_REIMPLEMENT_TYPE_BUF_MODE to redefine struct vsf_eth_buf_mode_t.

◆ VSF_ETH_CFG_REIMPLEMENT_TYPE_BUF_DESC

#define VSF_ETH_CFG_REIMPLEMENT_TYPE_BUF_DESC   DISABLED

◆ VSF_ETH_CFG_REIMPLEMENT_TYPE_SEND_BUF_DESC

#define VSF_ETH_CFG_REIMPLEMENT_TYPE_SEND_BUF_DESC   DISABLED

◆ VSF_ETH_CFG_REIMPLEMENT_TYPE_RECV_BUF_DESC

#define VSF_ETH_CFG_REIMPLEMENT_TYPE_RECV_BUF_DESC   DISABLED

◆ VSF_ETH_CFG_REIMPLEMENT_TYPE_SG_BUF_DESC

#define VSF_ETH_CFG_REIMPLEMENT_TYPE_SG_BUF_DESC   DISABLED

In specific hardware driver, we can enable ethro VSF_ETH_CFG_REIMPLEMENT_TYPE_SG_BUF_DESC to redefine struct vsf_eth_buf_desc_t.

◆ VSF_ETH_CFG_REIMPLEMENT_TYPE_IRQ_MASK

#define VSF_ETH_CFG_REIMPLEMENT_TYPE_IRQ_MASK   DISABLED

In specific hardware driver, we can enable ethro VSF_ETH_CFG_REIMPLEMENT_TYPE_IRQ_MASK to redefine struct vsf_eth_irq_mask_t.

◆ VSF_ETH_CFG_INHERIT_HAL_CAPABILITY

#define VSF_ETH_CFG_INHERIT_HAL_CAPABILITY   ENABLED

In specific hardware driver, we can enable ethro VSF_ETH_CFG_INHERIT_HAL_CAPABILITY to inherit the structure vsf_peripheral_capability_t.

◆ VSF_ETH_APIS

#define VSF_ETH_APIS (   __prefix)
Value:
__VSF_HAL_TEMPLATE_API(__prefix, vsf_err_t, eth, init, VSF_MCONNECT(__prefix, _eth_t) *eth_ptr, vsf_eth_cfg_t *cfg_ptr) \
__VSF_HAL_TEMPLATE_API(__prefix, void, eth, fini, VSF_MCONNECT(__prefix, _eth_t) *eth_ptr) \
__VSF_HAL_TEMPLATE_API(__prefix, fsm_rt_t, eth, enable, VSF_MCONNECT(__prefix, _eth_t) *eth_ptr) \
__VSF_HAL_TEMPLATE_API(__prefix, fsm_rt_t, eth, disable, VSF_MCONNECT(__prefix, _eth_t) *eth_ptr) \
__VSF_HAL_TEMPLATE_API(__prefix, void, eth, irq_enable, VSF_MCONNECT(__prefix, _eth_t) *eth_ptr, vsf_eth_irq_mask_t irq_mask) \
__VSF_HAL_TEMPLATE_API(__prefix, void, eth, irq_disable, VSF_MCONNECT(__prefix, _eth_t) *eth_ptr, vsf_eth_irq_mask_t irq_mask) \
__VSF_HAL_TEMPLATE_API(__prefix, vsf_err_t, eth, send_request, VSF_MCONNECT(__prefix, _eth_t) *eth_ptr, vsf_eth_send_buf_desc_t *buf_ptr) \
__VSF_HAL_TEMPLATE_API(__prefix, vsf_err_t, eth, recv_request, VSF_MCONNECT(__prefix, _eth_t) *eth_ptr, vsf_eth_recv_buf_desc_t *buf_ptr) \
__VSF_HAL_TEMPLATE_API(__prefix, vsf_err_t, eth, send_sg_request, VSF_MCONNECT(__prefix, _eth_t) *eth_ptr, vsf_eth_send_sg_buf_desc_t *buf_ptr, uint32_t sg_count) \
__VSF_HAL_TEMPLATE_API(__prefix, vsf_err_t, eth, recv_sg_request, VSF_MCONNECT(__prefix, _eth_t) *eth_ptr, vsf_eth_recv_sg_buf_desc_t *buf_ptr, uint32_t sg_count) \
__VSF_HAL_TEMPLATE_API(__prefix, vsf_err_t, eth, ctrl, VSF_MCONNECT(__prefix, _eth_t) *eth_ptr, vsf_eth_ctrl_t ctrl, void *param) \
__VSF_HAL_TEMPLATE_API(__prefix, vsf_eth_status_t, eth, status, VSF_MCONNECT(__prefix, _eth_t) *eth_ptr) \
__VSF_HAL_TEMPLATE_API(__prefix, vsf_eth_capability_t, eth, capability, VSF_MCONNECT(__prefix, _eth_t) *eth_ptr) \
__VSF_HAL_TEMPLATE_API(__prefix, vsf_err_t, eth, phy_set_mode, VSF_MCONNECT(__prefix, _eth_t) *eth_ptr, vsf_eth_phy_mode_t phy_mode) \
__VSF_HAL_TEMPLATE_API(__prefix, vsf_err_t, eth, phy_get_link_status, VSF_MCONNECT(__prefix, _eth_t) *eth_ptr, vsf_eth_phy_mode_t *phy_mode_ptr) \
__VSF_HAL_TEMPLATE_API(__prefix, vsf_err_t, eth, phy_read_reg, VSF_MCONNECT(__prefix, _eth_t) *eth_ptr, uint16_t reg_addr, uint32_t *value_ptr) \
__VSF_HAL_TEMPLATE_API(__prefix, vsf_err_t, eth, phy_write_reg, VSF_MCONNECT(__prefix, _eth_t) *eth_ptr, uint16_t reg_addr, uint32_t value)
vsf_err_t
Definition __type.h:42
struct VSF_MCONNECT(VSF_FLASH_CFG_IMP_PREFIX, _flash_t)
Definition flash.c:53
__le16 capability
Definition ieee80211.h:134
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
Definition vsf_template_eth.h:636
Predefined VSF ETH capability that can be reimplemented in specific hal drivers. The vsf_eth_capabili...
Definition vsf_template_eth.h:596
ETH configuration structure.
Definition vsf_template_eth.h:556
ETH status information structure Contains the current status of ETH operations and FIFO thresholds.
Definition vsf_template_eth.h:573
vk_av_control_value_t value
Definition vsf_audio.h:171
fsm_rt_t
Definition vsf_fsm.h:315
vsf_eth_irq_mask_t
Definition vsf_template_eth.h:497
vsf_eth_ctrl_t
Definition vsf_template_eth.h:668
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:319
#define __VSF_HAL_TEMPLATE_API
Definition vsf_template_instance_declaration.h:57
uint8_t status
Definition vsf_tgui.h:144

ETH API template, used to generate ETH type, specific prefix function declarations, etc.

Parameters
[in]__prefixThe prefix used for generating ETH functions.

Typedef Documentation

◆ vsf_eth_phy_mode_t

Predefined VSF ETH modes that can be reimplemented in specific HAL drivers.The following modes must be retained even if not supported by hardware. If hardware supports more modes, we can implement them in the hardware driver:

  • VSF_ETH_PHY_MODE_SPEED_10M
  • VSF_ETH_PHY_MODE_SPEED_100M
  • VSF_ETH_PHY_MODE_SPEED_1000M
  • VSF_ETH_PHY_MODE_DUPLEX_HALF
  • VSF_ETH_PHY_MODE_DUPLEX_FULL

In specific drivers, we can implement optional modes. Optional modes require the driver to provide one or more enumeration options, and provide ethros with the same name (users can determine whether to support the mode at compile time). If these options are N to 1, the corresponding MASK option is also required (users can select different modes at runtime).

◆ vsf_eth_mode_t

Predefined VSF ETH modes that can be reimplemented in specific HAL drivers.The following modes must be retained even if not supported by hardware. If hardware supports more modes, we can implement them in the hardware driver:

  • VSF_ETH_MODE_TX_CHECKSUM_OFFLOAD
  • VSF_ETH_MODE_RX_CHECKSUM_OFFLOAD

◆ vsf_eth_irq_mask_t

◆ vsf_eth_t

typedef struct vsf_eth_t vsf_eth_t

ETH forward declaration.

◆ vsf_eth_isr_handler_t

typedef 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.

Parameters
[in,out]target_ptruser defined target pointer
[in,out]eth_ptrvsf_eth_t watchdog timer structure pointer

◆ vsf_eth_isr_t

typedef struct vsf_eth_isr_t vsf_eth_isr_t

ETH interrupt configuration structure.

◆ vsf_eth_cfg_t

typedef struct vsf_eth_cfg_t vsf_eth_cfg_t

ETH configuration structure.

◆ vsf_eth_status_t

ETH status information structure Contains the current status of ETH operations and FIFO thresholds.

◆ vsf_eth_capability_t

Predefined VSF ETH capability that can be reimplemented in specific hal drivers. The vsf_eth_capability_t structure defines the features supported by the ETH hardware. When reimplementing this structure, all existing members must be preserved.

◆ vsf_eth_buf_mode_t

◆ vsf_eth_buf_desc_t

◆ vsf_eth_send_buf_desc_t

Send buffer type, refer to vsf_eth_send_buf_desc_t

◆ vsf_eth_recv_buf_desc_t

Receive buffer type, refer to vsf_eth_recv_buf_desc_t

◆ vsf_eth_send_sg_buf_desc_t

Scatter-gather send buffer type, refer to vsf_eth_send_sg_buf_desc_t

◆ vsf_eth_recv_sg_buf_desc_t

Scatter-gather receive buffer type, refer to vsf_eth_recv_sg_buf_desc_t

◆ vsf_eth_ctrl_t

◆ vsf_eth_op_t

typedef struct vsf_eth_op_t vsf_eth_op_t

ETH operation function pointer type, used for ETH Multi Class support.

Enumeration Type Documentation

◆ vsf_eth_phy_mode_t

Predefined VSF ETH modes that can be reimplemented in specific HAL drivers.The following modes must be retained even if not supported by hardware. If hardware supports more modes, we can implement them in the hardware driver:

  • VSF_ETH_PHY_MODE_SPEED_10M
  • VSF_ETH_PHY_MODE_SPEED_100M
  • VSF_ETH_PHY_MODE_SPEED_1000M
  • VSF_ETH_PHY_MODE_DUPLEX_HALF
  • VSF_ETH_PHY_MODE_DUPLEX_FULL

In specific drivers, we can implement optional modes. Optional modes require the driver to provide one or more enumeration options, and provide ethros with the same name (users can determine whether to support the mode at compile time). If these options are N to 1, the corresponding MASK option is also required (users can select different modes at runtime).

Enumerator
VSF_ETH_PHY_MODE_SPEED_10M 

10M speed mode

Speed modes that are claimed to be supported. The actual speed mode depends on negotiation results between both hardware devices.

VSF_ETH_PHY_MODE_SPEED_100M 

100M speed mode

VSF_ETH_PHY_MODE_SPEED_1000M 

1000M speed mode

VSF_ETH_PHY_MODE_DUPLEX_HALF 

Half duplex mode.

VSF_ETH_PHY_MODE_DUPLEX_FULL 

Full duplex mode.

VSF_ETH_PHY_MODE_LINK_UP 

Link up mode.

◆ anonymous enum

anonymous enum

ETH PHY mode completion, used to simplify the definition of ETH mode.

Enumerator
VSF_ETH_PHY_MODE_SPEED_MASK 
VSF_ETH_PHY_MODE_DUPLEX_MASK 
VSF_ETH_PHY_MODE_ALL_BITS_MASK 

◆ vsf_eth_mode_t

Predefined VSF ETH modes that can be reimplemented in specific HAL drivers.The following modes must be retained even if not supported by hardware. If hardware supports more modes, we can implement them in the hardware driver:

  • VSF_ETH_MODE_TX_CHECKSUM_OFFLOAD
  • VSF_ETH_MODE_RX_CHECKSUM_OFFLOAD
Enumerator
VSF_ETH_MODE_TX_CHECKSUM_OFFLOAD 

TX checksum offload mode.

VSF_ETH_MODE_RX_CHECKSUM_OFFLOAD 

RX checksum offload mode.

◆ anonymous enum

anonymous enum

ETH mode completion, used to simplify the definition of ETH mode.

Enumerator
VSF_ETH_MODE_OFFLOAD_MASK 
VSF_ETH_MODE_ALL_BITS_MASK 

◆ vsf_eth_irq_mask_t

Enumerator
VSF_ETH_IRQ_MASK_RX_AVAILABLE 

RX data available interrupt mask.

VSF_ETH_IRQ_MASK_TX_COMPLETE 

TX complete interrupt mask.

VSF_ETH_IRQ_MASK_SG_RX_AVAILABLE 

Scatter-gather RX available interrupt mask.

VSF_ETH_IRQ_MASK_SG_TX_COMPLETE 

Scatter-gather TX complete interrupt mask.

VSF_ETH_IRQ_MASK_PHY_LINK_CHANGE 

PHY link change interrupt mask.

VSF_ETH_IRQ_MASK_ERROR 

Error interrupt mask.

◆ anonymous enum

anonymous enum
Enumerator
VSF_ETH_IRQ_MASK_ALL 

◆ vsf_eth_buf_mode_t

Enumerator
VSF_ETH_BUF_MODE_TX_CHECKSUM_OFFLOAD 

TX checksum offload mode.

VSF_ETH_BUF_MODE_RX_CHECKSUM_OFFLOAD 

RX checksum offload mode.

◆ vsf_eth_ctrl_t

Enumerator
VSF_ETH_CTRL_GET_MAC_ADDRESS 

Get MAC address (uint8_t *)

Function Documentation

◆ vsf_eth_init()

vsf_err_t vsf_eth_init ( vsf_eth_t eth_ptr,
vsf_eth_cfg_t cfg_ptr 
)
extern

Initialize a ETH instance.

Parameters
[in]eth_ptra pointer to structure vsf_eth_t
[in]cfg_ptra pointer to structure vsf_eth_cfg_t
Returns
vsf_err_t: VSF_ERR_NONE if ETH was initialized, or a negative error code
Note
It is not necessary to call vsf_eth_fini() for deinitialization. vsf_eth_init() should be called before any other ETH API except vsf_eth_capability().

◆ vsf_eth_fini()

void vsf_eth_fini ( vsf_eth_t eth_ptr)
extern

Finalize a ETH instance.

Parameters
[in]eth_ptra pointer to structure vsf_eth_t
Returns
none

◆ vsf_eth_enable()

fsm_rt_t vsf_eth_enable ( vsf_eth_t eth_ptr)
extern

Enable a ETH instance.

Parameters
[in]eth_ptra pointer to structure vsf_eth_t
Returns
fsm_rt_t: FSM_RT_CPL if ETH was enabled, fsm_rt_on_going if ETH is still enabling

◆ vsf_eth_disable()

fsm_rt_t vsf_eth_disable ( vsf_eth_t eth_ptr)
extern

Disable a ETH instance.

Parameters
[in]eth_ptra pointer to structure vsf_eth_t
Returns
fsm_rt_t: FSM_RT_CPL if ETH was disabled, fsm_rt_on_going if ETH is still disabling

◆ vsf_eth_isr_enable()

void vsf_eth_isr_enable ( vsf_eth_t eth_ptr,
vsf_eth_irq_mask_t  isr_mask 
)
extern

Enable ETH instance interrupt.

Parameters
[in]eth_ptra pointer to structure vsf_eth_t
[in]isr_maskinterrupt mask, refer to vsf_eth_irq_mask_t
Note
This function should be called after vsf_eth_init() and before vsf_eth_enable()

◆ vsf_eth_isr_disable()

void vsf_eth_isr_disable ( vsf_eth_t eth_ptr,
vsf_eth_irq_mask_t  isr_mask 
)
extern

Disable ETH instance interrupt.

Parameters
[in]eth_ptra pointer to structure vsf_eth_t
[in]isr_maskinterrupt mask, refer to vsf_eth_irq_mask_t
Note
This function should be called after vsf_eth_init() and before vsf_eth_enable()

◆ vsf_eth_status()

vsf_eth_status_t vsf_eth_status ( vsf_eth_t eth_ptr)
extern

Get the status of ETH instance.

Parameters
[in]eth_ptra pointer to structure vsf_eth_t
Returns
vsf_eth_status_t: return all status of current ETH

◆ vsf_eth_capability()

vsf_eth_capability_t vsf_eth_capability ( vsf_eth_t eth_ptr)
extern

Get the capability of ETH instance.

Parameters
[in]eth_ptra pointer to structure vsf_eth_t
Returns
vsf_eth_capability_t: all capability of current ETH vsf_eth_capability_t

◆ vsf_eth_send_request()

vsf_err_t vsf_eth_send_request ( vsf_eth_t eth_ptr,
vsf_eth_send_buf_desc_t buf_ptr 
)
extern

Send a buffer over ETH instance.

Parameters
[in]eth_ptra pointer to structure vsf_eth_t
[in]buf_ptrpointer to the buffer to be sent, refer to vsf_eth_send_buf_desc_t
Returns
vsf_err_t: VSF_ERR_NONE if buffer was sent successfully, or a negative error code
Note
If the capability is_send_buf_releasable_immediately is false, the buffer should remain valid until the transmission complete interrupt is received

◆ vsf_eth_send_sg_request()

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 
)
extern

Send a scatter-gather buffer over ETH instance.

Parameters
[in]eth_ptra pointer to structure vsf_eth_t
[in]sg_ptrpointer to the scatter-gather buffer array to be sent
[in]sg_countnumber of scatter-gather buffer elements in the array
Returns
vsf_err_t: VSF_ERR_NONE if buffer was sent successfully, or a negative error code
Note
The buffers should remain valid until the transmission complete interrupt is received

◆ vsf_eth_recv_request()

vsf_err_t vsf_eth_recv_request ( vsf_eth_t eth_ptr,
vsf_eth_recv_buf_desc_t buf_ptr 
)
extern

Receive a buffer from ETH instance.

Parameters
[in]eth_ptra pointer to structure vsf_eth_t
[out]buf_ptrpointer to the buffer to store received data, refer to vsf_eth_recv_buf_desc_t
Returns
vsf_err_t: VSF_ERR_NONE if buffer was received successfully, or a negative error code
Note
The buffer must be pre-allocated with sufficient size to hold received data

◆ vsf_eth_recv_sg_request()

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 
)
extern

Receive data using scatter-gather buffers from ETH instance.

Parameters
[in]eth_ptra pointer to structure vsf_eth_t
[out]sg_ptrpointer to the scatter-gather buffer array to store received data
[in]sg_countnumber of scatter-gather buffer elements in the array
Returns
vsf_err_t: VSF_ERR_NONE if data was received successfully, or a negative error code
Note
The buffers must be pre-allocated with sufficient size to hold received data

◆ vsf_eth_ctrl()

vsf_err_t vsf_eth_ctrl ( vsf_eth_t eth_ptr,
vsf_eth_ctrl_t  ctrl,
void *  param 
)
extern

Control ETH instance.

Parameters
[in]eth_ptra pointer to structure vsf_eth_t
[in]ctrl_ptrpointer to the control command, refer to vsf_eth_ctrl_t
[in]paramcontrol command parameter, the specific type depends on the control command For example, VSF_ETH_CTRL_SET_MAC_ADDRESS requires a uint8_t* type parameter
Returns
vsf_err_t: VSF_ERR_NONE if control command was executed successfully, or a negative error code

◆ vsf_eth_phy_read_reg()

vsf_err_t vsf_eth_phy_read_reg ( vsf_eth_t eth_ptr,
uint16_t  reg_addr,
uint32_t value_ptr 
)
extern

Read a PHY register.

Parameters
[in]eth_ptra pointer to structure vsf_eth_t
[in]reg_addrthe address of the PHY register to read
[out]value_ptrpointer to store the read value
Returns
vsf_err_t: VSF_ERR_NONE if read was successful, or a negative error code

◆ vsf_eth_phy_write_reg()

vsf_err_t vsf_eth_phy_write_reg ( vsf_eth_t eth_ptr,
uint16_t  reg_addr,
uint32_t  value 
)
extern

Write a value to a PHY register.

Parameters
[in]eth_ptra pointer to structure vsf_eth_t
[in]reg_addrthe address of the PHY register to write
[in]valuethe value to write to the PHY register
Returns
vsf_err_t: VSF_ERR_NONE if write was successful, or a negative error code

◆ vsf_eth_phy_set_mode()

vsf_err_t vsf_eth_phy_set_mode ( vsf_eth_t eth_ptr,
vsf_eth_phy_mode_t  mode 
)
extern

Configure the PHY operating mode.

Parameters
[in]eth_ptra pointer to structure vsf_eth_t
[in]modethe desired PHY configuration including speed and duplex mode, refer to vsf_eth_phy_mode_t
Returns
vsf_err_t: VSF_ERR_NONE if PHY mode was configured successfully, or a negative error code

◆ vsf_eth_phy_get_link_status()

vsf_err_t vsf_eth_phy_get_link_status ( vsf_eth_t eth_ptr,
vsf_eth_phy_mode_t phy_mode_ptr 
)
extern

Get the current link status of the PHY.

Parameters
[in]eth_ptra pointer to structure vsf_eth_t
[out]phy_mode_ptrpointer to store the current PHY mode and link status, refer to vsf_eth_phy_mode_t
Returns
vsf_err_t: VSF_ERR_NONE if link status was retrieved successfully, or a negative error code
Generated from commit: vsfteam/vsf@e0b5993