HPM SDK
HPMicro Software Development Kit
hpm_tsw_drv.h File Reference
#include "hpm_common.h"
#include "hpm_soc_feature.h"
#include "hpm_tsw_regs.h"

Go to the source code of this file.

Data Structures

struct  tx_hdr_desc_t
 
struct  tsw_frame_t
 
struct  tsw_dma_config_t
 
struct  tsw_shap_tas_listlen_t
 
struct  tsw_tas_controllist_entry_t
 
struct  tsw_tas_config_t
 
struct  tsw_cbs_config_t
 
struct  tsw_tsf_t
 
struct  tsw_fpe_mms_status_t
 
struct  tsw_fpe_config_t
 
struct  tsw_cb_stmid_lookup_mac_t
 
struct  tsw_cb_stmid_active_mac_t
 
struct  tsw_cb_stmid_entry_t
 
struct  tsw_cb_frer_xrfunc_config_t
 
struct  tsw_cb_frer_sid_func_config_t
 
struct  tsw_cb_frer_latent_error_dectecton_config_t
 
struct  tsw_cb_frer_recovery_func_config_t
 
struct  tsw_psfer_gate_control_list_entry_t
 
struct  tsw_psfer_gate_control_list_config_t
 
struct  tsw_cb_frer_frame_count_egress_t
 
struct  tsw_psfp_gate_static_mode_config_t
 
struct  tsw_psfp_gate_dynamic_mode_config_t
 
struct  tsw_psfp_flow_meter_xir_config_t
 
struct  tsw_psfp_flow_meter_config_t
 
struct  tsw_psfp_filter_config_t
 

Macros

#define MAC_LO(mac)   (uint32_t)(mac[0] | (mac[1] << 8) | (mac[2] << 16) | (mac[3] << 24))
 
#define MAC_HI(mac)   (uint32_t)(mac[4] | (mac[5] << 8))
 
#define MAC_MDIO_CTRL_OP_WR   (0x01)
 
#define MAC_MDIO_CTRL_OP_RD   (0x02)
 
#define TSW_SEND_DESC_COUNT   (16U)
 
#define TSW_RECV_DESC_COUNT   (16U)
 
#define TSW_SEND_BUFF_LEN   (1536U)
 
#define TSW_RECV_BUFF_LEN   (1536U)
 
#define TSW_NS_IN_ONE_SEC   (1000000000UL)
 
#define TSW_BUS_FREQ   (100000000UL)
 
#define TSW_FPE_MMS_MIN_VTIME_MIN   (1U) /* 1ms */
 
#define TSW_FPE_MMS_MAX_VTIME_MAX   (128U) /* 128ms */
 

Enumerations

enum  tsw_port_speed_t { tsw_port_speed_10mbps = 2 , tsw_port_speed_100mbps = 3 , tsw_port_speed_1000mbps = 0 }
 
enum  tsw_port_phy_itf_t { tsw_port_phy_itf_mii = 0 , tsw_port_phy_itf_rmii = 4 , tsw_port_phy_itf_rgmii = 1 }
 
enum  tsw_dst_t {
  tsw_dst_port_null = 0 , tsw_dst_port_cpu = 1 << 0 , tsw_dst_port_1 = 1 << 1 , tsw_dst_port_2 = 1 << 2 ,
  tsw_dst_port_3 = 1 << 3
}
 
enum  tsw_cpu_send_to_port_t {
  tsw_cpu_send_to_lookup = 0x00 , tsw_cpu_send_to_port_1 = 0x01 , tsw_cpu_send_to_port_2 = 0x02 , tsw_cpu_send_to_port_3 = 0x03 ,
  tsw_cpu_send_to_all_ports = 0x80
}
 
enum  tsw_mac_mode_t { tsw_mac_mode_mii = 0 , tsw_mac_mode_gmii }
 
enum  tsw_pps_ctrl_t {
  tsw_pps_ctrl_pps = 0 , tsw_pps_ctrl_bin_2hz_digital_1hz , tsw_pps_ctrl_bin_4hz_digital_2hz , tsw_pps_ctrl_bin_8hz_digital_4hz ,
  tsw_pps_ctrl_bin_16hz_digital_8hz , tsw_pps_ctrl_bin_32hz_digital_16hz , tsw_pps_ctrl_bin_64hz_digital_32hz , tsw_pps_ctrl_bin_128hz_digital_64hz ,
  tsw_pps_ctrl_bin_256hz_digital_128hz , tsw_pps_ctrl_bin_512hz_digital_256hz , tsw_pps_ctrl_bin_1024hz_digital_512hz , tsw_pps_ctrl_bin_2048hz_digital_1024hz ,
  tsw_pps_ctrl_bin_4096hz_digital_2048hz , tsw_pps_ctrl_bin_8192hz_digital_4096hz , tsw_pps_ctrl_bin_16384hz_digital_8192hz , tsw_pps_ctrl_bin_32768hz_digital_16384hz
}
 
enum  tsw_shap_tas_alist_op_t { tsw_shap_tas_aclist_op_set_gate_states = 0 , tsw_shap_tas_aclist_op_set_and_hold_mac , tsw_shap_tas_aclist_op_set_and_release_mac }
 
enum  tsw_shap_tas_aclist_state_open_queue_t {
  tsw_shap_tas_aclist_state_open_queueu_0 = 1 << 0 , tsw_shap_tas_aclist_state_open_queueu_1 = 1 << 1 , tsw_shap_tas_aclist_state_open_queueu_2 = 1 << 2 , tsw_shap_tas_aclist_state_open_queueu_3 = 1 << 3 ,
  tsw_shap_tas_aclist_state_open_queueu_4 = 1 << 4 , tsw_shap_tas_aclist_state_open_queueu_5 = 1 << 5 , tsw_shap_tas_aclist_state_open_queueu_6 = 1 << 6 , tsw_shap_tas_aclist_state_open_queueu_7 = 1 << 7 ,
  tsw_shap_tas_aclist_state_open_queueu_all = 0xff
}
 
enum  tsw_traffic_queue_t {
  tsw_traffic_queue_0 = 0 , tsw_traffic_queue_1 , tsw_traffic_queue_2 , tsw_traffic_queue_3 ,
  tsw_traffic_queue_4 , tsw_traffic_queue_5 , tsw_traffic_queue_6 , tsw_traffic_queue_7
}
 
enum  tsw_fpe_mms_statistics_counter_t {
  tsw_fpe_mms_frame_reassembly_error_counter = 0 , tsw_fpe_mms_frame_rejected_due_to_wrong_smd , tsw_fpe_mms_frame_assembly_ok_counter , tsw_fpe_mms_fragment_rx_counter ,
  tsw_fpe_mms_fragment_tx_counter , tsw_fpe_mms_hold_request_counter
}
 
enum  tsw_fpe_mms_fragment_size_t { tsw_fpe_mms_fragment_size_60_octets = 0 , tsw_fpe_mms_fragment_size_124_octets , tsw_fpe_mms_fragment_size_188_octets , tsw_fpe_mms_fragment_size_252_octets }
 
enum  tsw_stmid_lookup_mode_t { tsw_stmid_lookup_mode_priority = 1 , tsw_stmid_lookup_mode_tagged = 2 , tsw_stmid_lookup_mode_all }
 
enum  tsw_stmid_active_dest_mac_control_t { tsw_stmid_actctl_disabled = 0 , tsw_stmid_actctl_use_amac_with_removed_vlan_tag = 1 , tsw_stmid_actctl_use_amac_with_replaced_or_inserted_vlan_tag = 3 }
 
enum  tsw_stmid_control_lookup_mode_t { tsw_stmid_control_lookup_by_dest_mac = 0 , tsw_stmid_control_lookup_by_src_mac }
 
enum  tsw_cb_frer_algo_t { tsw_cb_frer_algo_vector_recovery = 0 , tsw_cb_frer_algo_match_recovery }
 
enum  tsw_cb_frer_xfunc_recovery_t { tsw_cb_frer_xfunc_recovery_sequence = 0 , tsw_cb_frer_xfunc_recovery_individual }
 
enum  tsw_cb_frer_frame_ount_egress_t {
  presented_frames = 0 , discarded_frames , tagless_frames , rougue_frames ,
  out_of_oder_frames , lost_frames , recover_func_resets , latent_err_dectection_resets
}
 
enum  tsw_psfp_gate_mode_t { tsw_psfp_gate_mode_static = 0 , tsw_psfp_gate_mode_dynamic , tsw_psfp_gate_mode_unknown }
 
enum  tsw_psfp_gate_t { tsw_psfp_gate_closed = 0 , tsw_psfp_gate_open }
 

Functions

void tsw_get_default_dma_config (tsw_dma_config_t *config)
 Get default DMA configuration. More...
 
void tsw_init_send (TSW_Type *ptr, tsw_dma_config_t *config)
 Initialize TSW send DMA. More...
 
void tsw_init_recv (TSW_Type *ptr, tsw_dma_config_t *config)
 Initialize TSW receive 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_commit_recv_desc (TSW_Type *ptr, uint8_t *buffer, uint16_t length, uint8_t id)
 Commit a receive DMA descriptor. More...
 
hpm_stat_t tsw_recv_frame (TSW_Type *ptr, tsw_frame_t *frame)
 Receive a frame from CPU port. 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...
 
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, uint8_t mac_type)
 Enable MAC Controller. More...
 
hpm_stat_t tsw_ep_disable_mac_ctrl (TSW_Type *ptr, uint8_t port, uint8_t mac_type)
 Disable MAC Controller. More...
 
hpm_stat_t tsw_ep_enable_all_mac_ctrl (TSW_Type *ptr, uint8_t mac_type)
 Enable All MAC Controllers. More...
 
hpm_stat_t tsw_ep_disable_all_mac_ctrl (TSW_Type *ptr, uint8_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. 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_speed (TSW_Type *ptr, uint8_t port, uint8_t speed)
 Set TSW port speed. 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_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_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_set_lookup_table (TSW_Type *ptr, uint16_t entry_num, uint8_t dest_port, uint64_t dest_mac)
 Set Lookup Table. 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_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_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_set_pps_tod_output (TSW_Type *ptr)
 Set pps tod output. 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_set_tas_listlen (TSW_Type *ptr, uint8_t port, uint32_t listlen)
 Set TAS list length. 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_tas_change_config (TSW_Type *ptr, uint8_t port)
 Trigger to change TAS config. 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_set_tas (TSW_Type *ptr, uint8_t port, tsw_tas_config_t *config)
 Set TAS config. More...
 
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_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_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_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_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_set_entry (TSW_Type *ptr, tsw_cb_stmid_entry_t *entry)
 Set STMID entry for ingress. 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_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...