clmac.h (12226B)
1 /* 2 * 3 * 4 * 5 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 6 * 7 * Copyright 2007-2019 Broadcom Inc. All rights reserved. 8 */ 9 10 #ifndef _PORTMOD_CLMAC_H_ 11 #define _PORTMOD_CLMAC_H_ 12 13 #include <soc/portmod/portmod.h> 14 15 #define CLMAC_ENCAP_SET_FLAGS_NO_SOP_FOR_CRC_HG (1) 16 #define CLMAC_ENCAP_SET_FLAGS_EXTENDED_HIGIG2_EN (2) 17 #define CLMAC_ENCAP_SET_FLAGS_SOFT_RESET_DIS (4) 18 #define CLMAC_SPEED_SET_FLAGS_SOFT_RESET_DIS (1) 19 20 #define CLMAC_ENABLE_SET_FLAGS_SOFT_RESET_DIS 0x1 21 #define CLMAC_ENABLE_SET_FLAGS_TX_EN 0x2 22 #define CLMAC_ENABLE_SET_FLAGS_RX_EN 0x4 23 24 #define CLMAC_ENABLE_RX (1) 25 #define CLMAC_ENABLE_TX (2) 26 27 #define CLMAC_INIT_F_RX_STRIP_CRC 0x1 28 #define CLMAC_INIT_F_TX_APPEND_CRC 0x2 29 #define CLMAC_INIT_F_TX_REPLACE_CRC 0x4 30 #define CLMAC_INIT_F_TX_PASS_THROUGH_CRC_MODE 0x8 31 #define CLMAC_INIT_F_IS_HIGIG 0x10 32 #define CLMAC_INIT_F_IPG_CHECK_DISABLE 0x20 33 34 /* MAC Preemption TX status */ 35 /* 36 * if VERIFY_ENABLE = 1, but its status is failed or not initiaded 37 * if VERIFY_ENABLE = 0, preemption is not enabled 38 */ 39 #define CLMAC_PREEMPT_TX_INACTIVE 0x0 40 /* 41 * Preemption is enabled, Verify is enabled and its 42 * operation is in progress. 43 */ 44 #define CLMAC_PREEMPT_TX_VERIFY_IN_PROGRESS 0x1 45 /* 46 * Preemption is enabled and active. 47 * if VERIFY_ENABLE = 1, verify is enabled and succeed 48 * if VERIFY_ENABLE = 0, preemption is enabled 49 */ 50 #define CLMAC_PREEMPT_TX_ACTIVE 0x2 51 52 /* MAC preemption verification state */ 53 #define CLMAC_PREEMPT_VERIFY_DISABLED 0x0 /* disabled */ 54 #define CLMAC_PREEMPT_VERIFY_INITIAL 0x1 /* enabled but not started */ 55 #define CLMAC_PREEMPT_VERIFY_VERIFYING 0x2 /* in progress */ 56 #define CLMAC_PREEMPT_VERIFY_SUCCEED 0x3 /* successful */ 57 #define CLMAC_PREEMPT_VERIFY_FAILED 0x4 /* failed */ 58 59 /* 60 * MAC Preemption Tx status flags 61 * These macros are used as flags to retrieve the preemption status 62 * on the transmit side. 63 * Used by function clmac_preemption_tx_status_get() to get either 64 * TX, Verify operation status or Number of Verify Messages sent 65 * during preemption. 66 */ 67 #define CLMAC_PREEMPTION_TX_STATUS 0x1 68 #define CLMAC_PREEMPTION_VERIFY_STATUS 0x2 69 #define CLMAC_PREEMPTION_VERIFY_CNT_STATUS 0x3 70 71 /* MAC preemption force lost rx EOP flags */ 72 #define CLMAC_PREEMPTION_FORCE_SW_RX_EOP 0x1 73 #define CLMAC_PREEMPTION_FORCE_AUTO_HW_RX_EOP 0x2 74 75 /* MAC timestamp byte adjust flags */ 76 #define CLMAC_TIMESTAMP_BYTE_ADJUST_CLEAR 0x1 77 78 int clmac_init(int unit, soc_port_t port, uint32 init_flags); 79 int clmac_speed_set(int unit, soc_port_t port, int flags, int speed); 80 int clmac_speed_get (int unit, soc_port_t port, int *speed); 81 int clmac_encap_set(int unit, soc_port_t port, int flags, portmod_encap_t encap); 82 int clmac_encap_get(int unit, soc_port_t port, int *flags, portmod_encap_t *encap); 83 int clmac_enable_set(int unit, soc_port_t port, int flags, int enable); 84 int clmac_enable_get(int unit, soc_port_t port, int flags, int *enable); 85 int clmac_duplex_set(int unit, soc_port_t port, int duplex); 86 int clmac_duplex_get(int unit, soc_port_t port, int *duplex); 87 88 int clmac_loopback_set(int unit, soc_port_t port, portmod_loopback_mode_t lb, int enable); 89 int clmac_loopback_get(int unit, soc_port_t port, portmod_loopback_mode_t lb, int *enable); 90 int clmac_discard_set (int unit, soc_port_t port, int discard); 91 int clmac_tx_enable_set (int unit, soc_port_t port, int enable); 92 int clmac_tx_enable_get (int unit, soc_port_t port, int *enable); 93 int clmac_rx_enable_set (int unit, soc_port_t port, int enable); 94 int clmac_rx_enable_get (int unit, soc_port_t port, int *enable); 95 int clmac_tx_mac_sa_set(int unit, soc_port_t port, sal_mac_addr_t mac); 96 int clmac_tx_mac_sa_get(int unit, soc_port_t port, sal_mac_addr_t mac); 97 int clmac_rx_mac_sa_set(int unit, soc_port_t port, sal_mac_addr_t mac); 98 int clmac_rx_mac_sa_get(int unit, soc_port_t port, sal_mac_addr_t mac); 99 int clmac_soft_reset_set (int unit, soc_port_t p, int enable); 100 int clmac_soft_reset_get (int unit, soc_port_t p, int *enable); 101 int clmac_rx_vlan_tag_set(int unit, soc_port_t port, int outer_vlan_tag, int inner_vlan_tag); 102 int clmac_rx_vlan_tag_get(int unit, soc_port_t port, int *outer_vlan_tag, int *inner_vlan_tag); 103 int clmac_rx_max_size_set(int unit, soc_port_t port, int value); 104 int clmac_rx_max_size_get(int unit, soc_port_t port, int *value); 105 int clmac_pad_size_set(int unit, soc_port_t port, int value); 106 int clmac_pad_size_get(int unit, soc_port_t port, int *value); 107 int clmac_tx_average_ipg_set(int unit, soc_port_t port, int val); 108 int clmac_tx_average_ipg_get(int unit, soc_port_t port, int *val); 109 int clmac_runt_threshold_set(int unit, soc_port_t port, int value); 110 int clmac_runt_threshold_get(int unit, soc_port_t port, int *value); 111 int clmac_strict_preamble_set(int unit, soc_port_t port, int value); 112 int clmac_strict_preamble_get(int unit, soc_port_t port, int *value); 113 int clmac_sw_link_status_set (int unit, soc_port_t p, int link); 114 115 int xlmac_tx_preamble_length_set (int unit, soc_port_t p, int length); 116 int xlmac_sw_link_status_select_set (int unit, soc_port_t p, int enable); 117 int xlmac_sw_link_status_select_get (int unit, soc_port_t p, int *enable); 118 119 int clmac_timestamp_delay_set(int unit, soc_port_t port, portmod_port_ts_adjust_t ts_adjust); 120 int clmac_timestamp_delay_get(int unit, soc_port_t port, portmod_port_ts_adjust_t *ts_adjust); 121 int clmac_timestamp_byte_adjust_set(int unit, soc_port_t port, int flags, int speed); 122 123 /******************************************************************************* 124 Remote/local Fault 125 */ 126 int clmac_remote_fault_control_get(int unit, soc_port_t port, portmod_remote_fault_control_t *control); 127 int clmac_remote_fault_control_set(int unit, soc_port_t port, const portmod_remote_fault_control_t *control); 128 int clmac_local_fault_control_get(int unit, soc_port_t port, portmod_local_fault_control_t *control); 129 int clmac_local_fault_control_set(int unit, soc_port_t port, const portmod_local_fault_control_t *control); 130 int clmac_local_fault_status_get (int unit, soc_port_t port, int clear_status, int *status); 131 int clmac_remote_fault_status_get (int unit, soc_port_t port, int clear_status, int *status); 132 int clmac_clear_rx_lss_status_set (int unit, soc_port_t port, int lcl_fault, int rmt_fault); 133 int clmac_clear_rx_lss_status_get (int unit, soc_port_t port, int *lcl_fault, int *rmt_fault); 134 135 /******************************************************************************* 136 Flow Control 137 */ 138 int clmac_pfc_control_set(int unit, soc_port_t port, const portmod_pfc_control_t *control); 139 int clmac_pfc_control_get(int unit, soc_port_t port, portmod_pfc_control_t *control); 140 int clmac_llfc_control_set(int unit, soc_port_t port, const portmod_llfc_control_t *control); 141 int clmac_llfc_control_get(int unit, soc_port_t port, portmod_llfc_control_t *control); 142 int clmac_pause_control_set(int unit, soc_port_t port, const portmod_pause_control_t *control); 143 int clmac_pause_control_get(int unit, soc_port_t port, portmod_pause_control_t *control); 144 145 /***************************************************************************** 146 SDK Support Functions 147 */ 148 int clmac_eee_set(int u, int p, const portmod_eee_t* eee); 149 int clmac_eee_get(int u, int p, portmod_eee_t* eee); 150 151 int clmac_pfc_config_set (int u, int p, const portmod_pfc_config_t* pfc_cfg); 152 int clmac_pfc_config_get (int u, int p, const portmod_pfc_config_t* pfc_cfg); 153 154 int clmac_diag_fifo_status_get (int u, int p, const portmod_fifo_status_t* ts_info); 155 int clmac_timesync_tx_info_get (int unit, int port, portmod_fifo_status_t* tx_info); 156 157 int clmac_frame_spacing_stretch_set (int u, int p, int spacing); 158 int clmac_frame_spacing_stretch_get (int u, int p, int *spacing); 159 160 /***************************************************************************** 161 send CTRL/PAUSE/PFC frame to system side 162 */ 163 int clmac_pass_control_frame_set(int unit, int port, int value); 164 int clmac_pass_pfc_frame_set(int unit, int port, int value); 165 int clmac_pass_pause_frame_set(int unit, int port, int value); 166 int clmac_pass_control_frame_get(int unit, int port, int *value); 167 int clmac_pass_pfc_frame_get(int unit, int port, int *value); 168 int clmac_pass_pause_frame_get(int unit, int port, int *value); 169 170 int clmac_lag_failover_loopback_set(int unit, int port, int val); 171 int clmac_lag_failover_loopback_get(int unit, int port, int *val); 172 173 int clmac_lag_failover_en_get(int unit, int port, int *val); 174 int clmac_lag_failover_en_set(int unit, int port, int val); 175 176 int clmac_reset_fc_timers_on_link_dn_get (int unit, soc_port_t port, int *val); 177 int clmac_reset_fc_timers_on_link_dn_set (int unit, soc_port_t port, int val); 178 179 int clmac_lag_remove_failover_lpbk_get(int unit, int port, int *val); 180 int clmac_lag_remove_failover_lpbk_set(int unit, int port, int val); 181 182 int clmac_lag_failover_disable(int unit, int port); 183 184 int clmac_mac_ctrl_set (int u, int p, uint64 ctrl); 185 int clmac_drain_cell_get (int unit, int port, portmod_drain_cells_t *drain_cells); 186 int clmac_drain_cell_stop (int unit, int port, const portmod_drain_cells_t *drain_cells); 187 int clmac_drain_cell_start(int u, int p); 188 189 int clmac_txfifo_cell_cnt_get (int u, int p, uint32* fval); 190 int clmac_egress_queue_drain_get (int u, int p, uint64 *ctrl, int *rx); 191 192 int clmac_drain_cells_rx_enable (int u, int p, int rx_en); 193 int clmac_egress_queue_drain_rx_en(int u, int p, int rx_en); 194 int clmac_reset_check(int u, int p, int enable, int *reset); 195 196 int clmac_e2ecc_hdr_get (int unit, int port, uint32_t *words); 197 int clmac_e2ecc_hdr_set (int unit, int port, uint32_t *words); 198 199 int clmac_e2e_enable_set(int unit, int port, int enable); 200 int clmac_e2e_enable_get(int unit, int port, int *nable); 201 202 int clmac_sw_link_status_select_set(int unit, soc_port_t port, int enable); 203 int clmac_sw_link_status_select_get(int unit, soc_port_t port, int *enable); 204 205 /***************************************************************************** 206 Interrupt enable and status 207 */ 208 int clmac_interrupt_enable_get(int unit, int port, int intr_type, uint32 *value); 209 int clmac_interrupt_enable_set(int unit, int port, int intr_type, uint32 value); 210 int clmac_interrupt_status_get(int unit, int port, int intr_type, uint32 *value); 211 int clmac_interrupts_status_get(int unit, int port, int arr_max_size, uint32* intr_arr, uint32* size); 212 213 int clmac_preemption_mode_set(int32 unit, soc_port_t port, uint32 enable); 214 int clmac_preemption_mode_get(int32 unit, soc_port_t port, uint32 *enable); 215 216 int clmac_preemption_tx_enable_set(int32 unit, soc_port_t port, uint32 enable); 217 int clmac_preemption_tx_enable_get(int32 unit, soc_port_t port, uint32 *enable); 218 219 int clmac_preemption_verify_enable_set(int32 unit, soc_port_t port, 220 uint32 enable); 221 int clmac_preemption_verify_enable_get(int32 unit, soc_port_t port, 222 uint32 *enable); 223 224 int clmac_preemption_verify_time_set(int32 unit, soc_port_t port, 225 uint32 time_val); 226 int clmac_preemption_verify_time_get(int32 unit, soc_port_t port, 227 uint32 *time_val); 228 229 int clmac_preemption_verify_attempts_set(int32 unit, soc_port_t port, 230 uint32 num_attempts); 231 int clmac_preemption_verify_attempts_get(int32 unit, soc_port_t port, 232 uint32 *num_attempts); 233 234 int clmac_preemption_tx_status_get(int unit, soc_port_t port, 235 int flags, uint32 *value); 236 237 int clmac_preemption_force_rx_lost_eop_set(int unit, soc_port_t port, 238 int flags, uint32 value); 239 int clmac_preemption_force_rx_lost_eop_get(int unit, soc_port_t port, 240 int flags, uint32 *value); 241 242 int clmac_preemption_rx_timeout_info_set(int unit, soc_port_t port, 243 uint32 enable, uint32 timeout_val); 244 int clmac_preemption_rx_timeout_info_get(int unit, soc_port_t port, 245 uint32 *enable, uint32 *timeout_val); 246 247 #endif /*_PORTMOD_CLMAC_H_*/