HPM SDK
HPMicro Software Development Kit
hpm_tsw_drv.c File Reference
#include "hpm_tsw_drv.h"
#include "hpm_swap.h"
#include <stdint.h>

Functions

static uint32_t tsw_ns_to_systicks (uint32_t nanoseconds, uint32_t busfreq)
 
static hpm_stat_t tsw_send_frame_setup (TSW_Type *ptr, uint8_t *buffer, uint16_t length, uint8_t id)
 
void tsw_get_default_dma_config (tsw_dma_config_t *config)
 Get default DMA configuration. More...
 
hpm_stat_t tsw_ep_set_mdio_config (TSW_Type *ptr, uint8_t port, uint8_t clk_div)
 MDIO Interface Config. More...
 
hpm_stat_t tsw_ep_mdio_read (TSW_Type *ptr, uint8_t port, uint32_t phy_addr, uint32_t reg_addr, uint16_t *data)
 MDIO Read. More...
 
hpm_stat_t tsw_ep_mdio_write (TSW_Type *ptr, uint8_t port, uint32_t phy_addr, uint32_t reg_addr, uint16_t data)
 MDIO Write. More...
 
hpm_stat_t tsw_ep_enable_mac_ctrl (TSW_Type *ptr, uint8_t port, tsw_mac_type_t mac_type)
 Enable MAC Controller. More...
 
hpm_stat_t tsw_ep_disable_mac_ctrl (TSW_Type *ptr, uint8_t port, tsw_mac_type_t mac_type)
 Disable MAC Controller. More...
 
hpm_stat_t tsw_ep_enable_all_mac_ctrl (TSW_Type *ptr, tsw_mac_type_t mac_type)
 Enable All MAC Controllers. More...
 
hpm_stat_t tsw_ep_disable_all_mac_ctrl (TSW_Type *ptr, tsw_mac_type_t mac_type)
 Disable All MAC Controllers. More...
 
hpm_stat_t tsw_ep_set_mac_addr (TSW_Type *ptr, uint8_t port, uint8_t *mac_addr, bool promisc)
 Set MAC Address. More...
 
hpm_stat_t tsw_ep_set_mac_mode (TSW_Type *ptr, uint8_t port, uint8_t gmii)
 Set MAC Mode @Note This API will be deprecated from V2.0.0. More...
 
hpm_stat_t tsw_ep_set_xmac_mode (TSW_Type *ptr, uint8_t port, uint8_t gmii, tsw_mac_type_t mac_type)
 Set MAC Mode For Specified MAC. More...
 
void tsw_init_send (TSW_Type *ptr, tsw_dma_config_t *config)
 Initialize TSW send DMA. More...
 
hpm_stat_t tsw_send_frame (TSW_Type *ptr, uint8_t *buffer, uint16_t length, uint8_t id)
 Send a frame to CPU port. More...
 
hpm_stat_t tsw_send_frame_check_response (TSW_Type *ptr, uint8_t *buffer, uint16_t length, uint8_t id)
 Send a frame to CPU port and check response. More...
 
void tsw_init_recv (TSW_Type *ptr, tsw_dma_config_t *config)
 Initialize TSW receive DMA. More...
 
hpm_stat_t tsw_recv_frame (TSW_Type *ptr, tsw_frame_t *frame)
 Receive a frame from CPU port. More...
 
hpm_stat_t tsw_commit_recv_desc (TSW_Type *ptr, uint8_t *buffer, uint16_t length, uint8_t id)
 Commit a receive DMA descriptor. More...
 
void tsw_mac_lookup_bypass (TSW_Type *ptr, uint8_t dst_port)
 Lookup Bypass Setting. More...
 
void tsw_set_cam_vlan_port (TSW_Type *ptr)
 CAM VLAN Setting. More...
 
void tsw_port_gpr (TSW_Type *ptr, uint8_t port, uint8_t speed, uint8_t itf, uint8_t tx_dly, uint8_t rx_dly)
 Set Port GPR. More...
 
void tsw_set_port_clock_delay (TSW_Type *ptr, uint8_t port, uint8_t tx_dly, uint8_t rx_dly)
 Set TSW port clock delay. More...
 
void tsw_set_port_interface (TSW_Type *ptr, uint8_t port, uint8_t itf)
 Set TSW port interface type. More...
 
void tsw_set_port_speed (TSW_Type *ptr, uint8_t port, uint8_t speed)
 Set TSW port speed. More...
 
void tsw_set_lookup_table (TSW_Type *ptr, uint16_t entry_num, uint8_t dest_port, uint64_t dest_mac)
 Set Lookup Table. More...
 
void tsw_set_internal_frame_action (TSW_Type *ptr, uint8_t dest_port)
 Set Internal Frame Action. More...
 
void tsw_set_broadcast_frame_action (TSW_Type *ptr, uint8_t dest_port)
 Set Broadcast Frame Action. More...
 
void tsw_set_unknown_frame_action (TSW_Type *ptr, uint8_t dest_port)
 Set Unknow Frame Action. More...
 
void tsw_clear_cam (TSW_Type *ptr)
 Clear CAM. More...
 
void tsw_enable_store_forward_mode (TSW_Type *ptr, uint8_t port)
 Enable RXFIFO to store and forward mode. More...
 
void tsw_disable_store_forward_mode (TSW_Type *ptr, uint8_t port)
 Disable RXFIFO to store and forward mode. More...
 
hpm_stat_t tsw_get_rtc_time_increment (TSW_Type *ptr, uint32_t *increment)
 Get RTC timer increment value. More...
 
hpm_stat_t tsw_set_rtc_time_increment (TSW_Type *ptr, uint32_t increment)
 Set RTC timer increment value. More...
 
hpm_stat_t tsw_get_rtc_current_time (TSW_Type *ptr, uint32_t *sec, uint32_t *nsec)
 Get RTC current time. More...
 
hpm_stat_t tsw_get_rtc_offset (TSW_Type *ptr, int64_t *sec, uint32_t *nsec)
 Get RTC offset. More...
 
hpm_stat_t tsw_set_rtc_offset (TSW_Type *ptr, int64_t sec, uint32_t nsec)
 Set RTC offset. More...
 
hpm_stat_t tsw_set_rtc_offset_change (TSW_Type *ptr, uint32_t change)
 Set RTC offset change. More...
 
hpm_stat_t tsw_set_tsync_timer_hclkdiv (TSW_Type *ptr, uint8_t port, uint32_t host_clkdiv)
 Set TSYNC timer host clock divider. More...
 
hpm_stat_t tsw_tsync_timer_control (TSW_Type *ptr, uint8_t port, uint8_t index, uint32_t period, uint32_t enable)
 TSYNC timer control. More...
 
hpm_stat_t tsw_tsync_timer_interrupt_enable (TSW_Type *ptr, uint8_t port)
 TSYNC timer interrupt enable. More...
 
hpm_stat_t tsw_tsync_update_data (TSW_Type *ptr, uint8_t port, uint32_t bin, uint32_t binofs, uint32_t srcaddr, uint8_t lenbytes)
 TSYNC update data. More...
 
hpm_stat_t tsw_tsync_update_len (TSW_Type *ptr, uint8_t port, uint32_t bin, uint8_t lenbytes, uint8_t tqueue)
 TSYNC update length. More...
 
hpm_stat_t tsw_tsync_trigger_tx (TSW_Type *ptr, uint8_t port, uint32_t bin)
 TSYNC trigger TX. More...
 
hpm_stat_t tsw_tsync_get_txtimestamp (TSW_Type *ptr, uint8_t port, uint32_t bin, uint32_t *timestamplo, uint32_t *timestamphi)
 TSYNC get TX timestamp. More...
 
hpm_stat_t tsw_tsync_get_rxtimestamp (TSW_Type *ptr, uint8_t port, uint32_t *timestamplo, uint32_t *timestamphi)
 TSYNC get RX timestamp. More...
 
hpm_stat_t tsw_tsync_disable_current_events (TSW_Type *ptr, uint8_t port, uint32_t *disabled)
 TSYNC disable current events. More...
 
hpm_stat_t tsw_tsync_get_rxstatus (TSW_Type *ptr, uint8_t port, uint8_t *ov, uint8_t *avnxt, uint8_t *rxsel)
 TSYNC get RX status. More...
 
hpm_stat_t tsw_tsync_next_rxbuffer (TSW_Type *ptr, uint8_t port)
 TSYNC next RX buffer. More...
 
hpm_stat_t tsw_tsync_clear_overflow (TSW_Type *ptr, uint8_t port)
 TSYNC clear overflow status. More...
 
hpm_stat_t tsw_tsync_get_txdone (TSW_Type *ptr, uint8_t port, uint32_t *done)
 TSYNC get tx done status. More...
 
hpm_stat_t tsw_tsync_clear_txdone (TSW_Type *ptr, uint8_t port, uint32_t done)
 TSYNC clear tx done status. More...
 
hpm_stat_t tsw_tsync_get_tmrdone (TSW_Type *ptr, uint8_t port, uint32_t *done)
 TSYNC get tmr done status. More...
 
hpm_stat_t tsw_shap_set_tas_listlen (TSW_Type *ptr, uint8_t port, uint32_t listlen)
 Set TAS list length. More...
 
hpm_stat_t tsw_shap_get_tas_listlen (TSW_Type *ptr, uint8_t port, tsw_shap_tas_listlen_t *listlen)
 TSW get shap tas listlen. More...
 
hpm_stat_t tsw_shap_set_tas_cycletime (TSW_Type *ptr, uint8_t port, uint32_t cycle_time)
 SHAP set tas cycle. More...
 
hpm_stat_t tsw_shap_set_tas_basetime (TSW_Type *ptr, uint8_t port, uint32_t basetime_sec, uint32_t basetime_ns)
 Set TAS base time. More...
 
hpm_stat_t tsw_shap_set_tas_controllist (TSW_Type *ptr, uint8_t port, uint32_t index, tsw_tas_controllist_entry_t *entry)
 SHAP set tas controllist. More...
 
hpm_stat_t tsw_shap_get_tas_controllist (TSW_Type *ptr, uint8_t port, uint32_t index, tsw_tas_controllist_entry_t *entry)
 SHAP get tas controllist. More...
 
hpm_stat_t tsw_shap_set_tas_max_sdu_ticks (TSW_Type *ptr, uint8_t port, uint8_t index, uint32_t ticks)
 Set tas maximum SDU ticks. More...
 
hpm_stat_t tsw_shap_get_tas_max_sdu_ticks (TSW_Type *ptr, uint8_t port, uint8_t index, uint32_t *ticks)
 Get tas maximum SDU ticks. More...
 
hpm_stat_t tsw_shap_get_tas_crsr (TSW_Type *ptr, uint8_t port, uint32_t *crsr)
 Get TAS cycle time. More...
 
hpm_stat_t tsw_shap_enable_tas (TSW_Type *ptr, uint8_t port)
 Enable TAS. More...
 
hpm_stat_t tsw_shap_disable_tas (TSW_Type *ptr, uint8_t port)
 Disable TAS. More...
 
hpm_stat_t tsw_shap_tas_change_config (TSW_Type *ptr, uint8_t port)
 Trigger to change TAS config. More...
 
hpm_stat_t tsw_set_pps_tod_output (TSW_Type *ptr)
 Set pps tod output. More...
 
hpm_stat_t tsw_shap_set_tas (TSW_Type *ptr, uint8_t port, tsw_tas_config_t *config)
 Set TAS config. More...
 
hpm_stat_t tsw_shap_get_tas_txov (TSW_Type *ptr, uint8_t port, uint8_t index, uint32_t *txov)
 
hpm_stat_t tsw_shap_set_cbs (TSW_Type *ptr, uint8_t port, uint8_t index, tsw_cbs_config_t *config)
 Set CBS config. More...
 
hpm_stat_t tsw_shap_set_cbs_max_sdu_size (TSW_Type *ptr, uint8_t port, uint8_t index, uint32_t size)
 
hpm_stat_t tsw_shap_get_cbs_max_sdu_size (TSW_Type *ptr, uint8_t port, uint8_t index, uint32_t *size)
 
hpm_stat_t tsw_get_txtimestampfifo_used (TSW_Type *ptr, uint8_t port, uint32_t *count)
 Get used countsed count from the TX-Timestamp FIFO. More...
 
hpm_stat_t tsw_get_txtimestampfifo_entry (TSW_Type *ptr, uint8_t port, tsw_tsf_t *entry)
 Get TX-Timestamp FIFO entry. More...
 
hpm_stat_t tsw_fpe_get_mms_status (TSW_Type *ptr, uint8_t port, tsw_fpe_mms_status_t *status)
 
hpm_stat_t tsw_fpe_enable_mms (TSW_Type *ptr, uint8_t port)
 Enable MMS. More...
 
hpm_stat_t tsw_fpe_disable_mms (TSW_Type *ptr, uint8_t port)
 Disable MMS. More...
 
hpm_stat_t tsw_fpe_get_default_mms_ctrl_config (TSW_Type *ptr, uint8_t port, tsw_fpe_config_t *config)
 Get default MMS config. More...
 
hpm_stat_t tsw_fpe_set_mms_ctrl (TSW_Type *ptr, uint8_t port, tsw_fpe_config_t *config)
 Set MMS config. More...
 
hpm_stat_t tsw_fpe_reset_mms_statistics_counter (TSW_Type *ptr, uint8_t port, tsw_fpe_mms_statistics_counter_t counter)
 Reset MMS statistics counter. More...
 
hpm_stat_t tsw_fpe_get_mms_statistics_counter (TSW_Type *ptr, uint8_t port, tsw_fpe_mms_statistics_counter_t counter, uint32_t *value)
 Get MMS statistics counter. More...
 
hpm_stat_t tsw_cb_stmid_ingress_get_entry (TSW_Type *ptr, tsw_cb_stmid_entry_t *entry)
 Get STMID entry for ingress. More...
 
hpm_stat_t tsw_cb_stmid_ingress_set_entry (TSW_Type *ptr, tsw_cb_stmid_entry_t *entry)
 Set STMID entry for ingress. More...
 
hpm_stat_t tsw_cb_stmid_egress_set_entry (TSW_Type *ptr, tsw_cb_stmid_entry_t *entry)
 Set STMID entry for egress. More...
 
hpm_stat_t tsw_cb_frer_ingress_enable_rtag (TSW_Type *ptr)
 Enable RTAG with CB frer for ingress. More...
 
hpm_stat_t tsw_cb_frer_egress_set_sid_func (TSW_Type *ptr, tsw_cb_frer_sid_func_config_t *config)
 specify recovery functions for stream for egress More...
 
hpm_stat_t tsw_cb_frer_egress_set_recovery_func (TSW_Type *ptr, tsw_cb_frer_recovery_func_config_t *config)
 Set up recovery functions for stream with CB frer for egress. More...
 
hpm_stat_t tsw_cb_frer_egress_clear_latten_error_flag (TSW_Type *ptr)
 Clear latten error flag. More...
 
hpm_stat_t tsw_cb_frer_egress_get_count (TSW_Type *ptr, tsw_cb_frer_frame_count_egress_t *count)
 Get count of latten error. More...
 
hpm_stat_t tsw_psfp_set_filter (TSW_Type *ptr, tsw_psfp_filter_config_t *config)
 Set PSFP filter. More...
 
hpm_stat_t tsw_psfp_set_gate_static_mode (TSW_Type *ptr, tsw_psfp_gate_static_mode_config_t *config)
 Set PSFP gate with static mode. More...
 
hpm_stat_t tsw_psfp_set_gate_dynamic_mode (TSW_Type *ptr, tsw_psfp_gate_dynamic_mode_config_t *config)
 Set PSFP gate with dynamic mode. More...
 
hpm_stat_t tsw_psfp_set_flow_meter (TSW_Type *ptr, tsw_psfp_flow_meter_config_t *config)
 Set PSFP flow meter. More...
 

Function Documentation

◆ tsw_fpe_get_mms_status()

hpm_stat_t tsw_fpe_get_mms_status ( TSW_Type ptr,
uint8_t  port,
tsw_fpe_mms_status_t status 
)

◆ tsw_ns_to_systicks()

static uint32_t tsw_ns_to_systicks ( uint32_t  nanoseconds,
uint32_t  busfreq 
)
static

◆ tsw_send_frame_setup()

static hpm_stat_t tsw_send_frame_setup ( TSW_Type ptr,
uint8_t *  buffer,
uint16_t  length,
uint8_t  id 
)
static

◆ tsw_shap_get_cbs_max_sdu_size()

hpm_stat_t tsw_shap_get_cbs_max_sdu_size ( TSW_Type ptr,
uint8_t  port,
uint8_t  index,
uint32_t *  size 
)

◆ tsw_shap_get_tas_txov()

hpm_stat_t tsw_shap_get_tas_txov ( TSW_Type ptr,
uint8_t  port,
uint8_t  index,
uint32_t *  txov 
)

◆ tsw_shap_set_cbs_max_sdu_size()

hpm_stat_t tsw_shap_set_cbs_max_sdu_size ( TSW_Type ptr,
uint8_t  port,
uint8_t  index,
uint32_t  size 
)