1 /* 2 * Intel Hard Processor System 10 Giga bit TSN Ethernet Media Access controller (XGMAC) driver 3 * 4 * Driver private data declarations 5 * 6 * Copyright (c) 2024 Intel Corporation. 7 * SPDX-License-Identifier: Apache-2.0 8 */ 9 10 #ifndef _ZEPHYR_DRIVERS_ETHERNET_ETH_DWC_XGMAC_PRIV_H_ 11 #define _ZEPHYR_DRIVERS_ETHERNET_ETH_DWC_XGMAC_PRIV_H_ 12 13 #include <zephyr/device.h> 14 #include <zephyr/net/ethernet.h> 15 #include <zephyr/net/phy.h> 16 #include "../eth.h" 17 18 #define SET_BIT 1 19 #define RESET_BIT 0 20 21 #define READ_BIT(var, bit) ((var >> bit) & 1u) 22 23 /* Offset addresses of the register sets in XGMAC 24 */ 25 #define XGMAC_CORE_BASE_ADDR_OFFSET (0x0000u) 26 #define XGMAC_MTL_BASE_ADDR_OFFSET (0x1000u) 27 #define XGMAC_MTL_TCQ_BASE_ADDR_OFFSET (0x1100u) 28 #define XGMAC_DMA_BASE_ADDR_OFFSET (0x3000u) 29 #define XGMAC_DMA_CHNL_BASE_ADDR_OFFSET (0x3100u) 30 #define XGMAC_DMA_CHNLx_BASE_ADDR_OFFSET(x) (XGMAC_DMA_CHNL_BASE_ADDR_OFFSET + (x * 0x80u)) 31 #define XGMAC_MTL_TCQx_BASE_ADDR_OFFSET(x) (XGMAC_MTL_TCQ_BASE_ADDR_OFFSET + (x * 0x80u)) 32 #define XGMAC_CORE_ADDRx_HIGH(x) (CORE_MAC_ADDRESS0_HIGH_OFST + (x) * 0x8) 33 #define XGMAC_CORE_ADDRx_LOW(x) (CORE_MAC_ADDRESS0_LOW_OFST + (x) * 0x8) 34 35 #define XGMAC_DESC_OWNED_BY_DMA (1u) 36 37 #define NUM_OF_RxQs_PER_DMA_MAP_REG (4u) 38 #define MTL_RXQ_DMA_MAP_Qx_MSK(q_pos) (~(0xffu << (q_pos * 8u))) 39 #define MTL_RXQ_DMA_MAP_QxDDMACH_SET(q_pos, value) ((value & 0x1u) << (8u * q_pos + 7u)) 40 #define MTL_RXQ_DMA_MAP_QxMDMACH_SET(q_pos, value) ((value & 0x7u) << (8u * q_pos)) 41 42 #define NUM_OF_TCs_PER_TC_PRTY_MAP_REG (4u) 43 #define TC_PRTY_MAP_FEILD_SIZE_IN_BITS (8u) 44 #define MTL_TCx_PRTY_MAP_MSK(TCx_pos) (~(0xff << (TCx_pos * TC_PRTY_MAP_FEILD_SIZE_IN_BITS))) 45 46 #define MTL_TCx_PRTY_MAP_PSTC_SET(TCx_pos, prio) ((prio & 0xff) << (8u * TCx_pos)) 47 48 #define DMA_MODE_OFST (0x0) 49 50 #define DMA_MODE_SWR_SET(value) ((value) & 0x00000001) 51 52 #define DMA_MODE_SWR_SET_MSK (0x00000001) 53 54 #define DMA_MODE_INTM_CLR_MSK (0xffffcfff) 55 56 #define DMA_MODE_INTM_SET(value) (((value) << 12) & 0x00003000) 57 58 #define DMA_SYSBUS_MODE_OFST (0x4) 59 60 #define DMA_SYSBUS_MODE_RD_OSR_LMT_SET(value) (((value) << 16) & 0x001f0000) 61 62 #define DMA_SYSBUS_MODE_WR_OSR_LMT_SET(value) (((value) << 24) & 0x1f000000) 63 64 #define DMA_SYSBUS_MODE_AAL_SET(value) (((value) << 12) & 0x00001000) 65 66 #define DMA_SYSBUS_MODE_EAME_SET(value) (((value) << 11) & 0x00000800) 67 68 #define DMA_SYSBUS_MODE_BLEN4_SET(value) (((value) << 1) & 0x00000002) 69 70 #define DMA_SYSBUS_MODE_BLEN8_SET(value) (((value) << 2) & 0x00000004) 71 72 #define DMA_SYSBUS_MODE_BLEN16_SET(value) (((value) << 3) & 0x00000008) 73 74 #define DMA_SYSBUS_MODE_BLEN32_SET(value) (((value) << 4) & 0x00000010) 75 76 #define DMA_SYSBUS_MODE_BLEN64_SET(value) (((value) << 5) & 0x00000020) 77 78 #define DMA_SYSBUS_MODE_BLEN128_SET(value) (((value) << 6) & 0x00000040) 79 80 #define DMA_SYSBUS_MODE_BLEN256_SET(value) (((value) << 7) & 0x00000080) 81 82 #define DMA_SYSBUS_MODE_UNDEF_SET(value) ((value) & 0x00000001) 83 84 #define DMA_TX_EDMA_CONTROL_OFST (0x40) 85 86 #define DMA_TX_EDMA_CONTROL_TDPS_SET(value) ((value) & 0x00000003) 87 88 #define DMA_RX_EDMA_CONTROL_OFST (0x44) 89 90 #define DMA_RX_EDMA_CONTROL_RDPS_SET(value) ((value) & 0x00000003) 91 92 #define DMA_INTERRUPT_STATUS_OFST (0x8) 93 94 #define DMA_CHx_STATUS_OFST (0x60) 95 96 #define DMA_CHx_STATUS_TI_SET_MSK (0x00000001) 97 98 #define DMA_CHx_STATUS_RI_SET_MSK (0x00000040) 99 100 #define DMA_CHx_STATUS_TPS_SET_MSK (0x00000002) 101 102 #define DMA_CHx_STATUS_TBU_SET_MSK (0x00000004) 103 104 #define DMA_CHx_STATUS_RBU_SET_MSK (0x00000080) 105 106 #define DMA_CHx_STATUS_RPS_SET_MSK (0x00000100) 107 108 #define DMA_CHx_STATUS_DDE_SET_MSK (0x00000200) 109 110 #define DMA_CHx_STATUS_FBE_SET_MSK (0x00001000) 111 112 #define DMA_CHx_STATUS_CDE_SET_MSK (0x00002000) 113 114 #define DMA_CHx_STATUS_AIS_SET_MSK (0x00004000) 115 116 #define DMA_CHx_STATUS_NIS_SET_MSK (0x00008000) 117 118 #define DMA_CHx_CONTROL_OFST (0x0) 119 120 #define DMA_CHx_CONTROL_SPH_SET(value) (((value) << 24) & 0x01000000) 121 122 #define DMA_CHx_CONTROL_PBLX8_SET(value) (((value) << 16) & 0x00010000) 123 124 #define DMA_CHx_CONTROL_MSS_SET(value) ((value) & 0x00003fff) 125 126 #define DMA_CHx_TX_CONTROL_OFST (0x4) 127 128 #define DMA_CHx_TX_CONTROL_TXPBL_SET(value) (((value) << 16) & 0x003f0000) 129 130 #define DMA_CHx_TX_CONTROL_TSE_SET(value) (((value) << 12) & 0x00001000) 131 132 #define DMA_CHx_TX_CONTROL_RESERVED_OSP_SET(value) (((value) << 4) & 0x00000010) 133 134 #define DMA_CHx_TX_CONTROL_ST_CLR_MSK (0xfffffffe) 135 136 #define DMA_CHx_RX_CONTROL_OFST (0x8) 137 138 #define DMA_CHx_RX_CONTROL_RPF_SET(value) (((value) << 31) & 0x80000000) 139 140 #define DMA_CHx_RX_CONTROL_RXPBL_SET(value) (((value) << 16) & 0x003f0000) 141 142 #define DMA_CHx_RX_CONTROL_RBSZ_SET(value) ((value << 1) & 0x00007ff0) 143 144 #define DMA_CHx_RX_CONTROL_SR_CLR_MSK (0xfffffffe) 145 146 #define DMA_CHx_TXDESC_LIST_HADDRESS_OFST (0x10) 147 148 #define DMA_CHx_TXDESC_LIST_HADDRESS_TDESHA_SET(value) ((value) & 0x000000ff) 149 150 #define DMA_CHx_TXDESC_LIST_LADDRESS_OFST (0x14) 151 152 #define DMA_CHx_RXDESC_LIST_HADDRESS_OFST (0x18) 153 154 #define DMA_CHx_RXDESC_LIST_LADDRESS_OFST (0x1c) 155 156 #define DMA_CHx_TXDESC_TAIL_LPOINTER_OFST (0x24) 157 158 #define DMA_CHx_TXDESC_TAIL_LPOINTER_TDT_SET(value) ((value) & 0xfffffff8) 159 160 #define DMA_CHx_RXDESC_TAIL_LPOINTER_OFST (0x2c) 161 162 #define DMA_CHx_RXDESC_TAIL_LPOINTER_RDT_SET(value) ((value) & 0xfffffff8) 163 164 #define DMA_CHx_TX_CONTROL2_OFST (0x30) 165 166 #define DMA_CHx_TX_CONTROL2_TDRL_SET(value) (((value) << 0) & 0x0000ffff) 167 168 #define DMA_CHx_RX_CONTROL2_OFST (0x34) 169 170 #define DMA_CHx_RX_CONTROL2_RDRL_SET(value) (((value) << 0) & 0x0000ffff) 171 172 #define DMA_CHx_TX_CONTROL_ST_SET_MSK (0x00000001) 173 174 #define DMA_CHx_RX_CONTROL_SR_SET_MSK (0x00000001) 175 176 #define DMA_CHx_INTERRUPT_ENABLE_OFST (0x38) 177 178 #define DMA_CHx_INTERRUPT_ENABLE_NIE_SET(value) (((value) << 15) & 0x00008000) 179 180 #define DMA_CHx_INTERRUPT_ENABLE_AIE_SET(value) (((value) << 14) & 0x00004000) 181 182 #define DMA_CHx_INTERRUPT_ENABLE_CDEE_SET(value) (((value) << 13) & 0x00002000) 183 184 #define DMA_CHx_INTERRUPT_ENABLE_FBEE_SET(value) (((value) << 12) & 0x00001000) 185 186 #define DMA_CHx_INTERRUPT_ENABLE_DDEE_SET(value) (((value) << 9) & 0x00000200) 187 188 #define DMA_CHx_INTERRUPT_ENABLE_RSE_SET(value) (((value) << 8) & 0x00000100) 189 190 #define DMA_CHx_INTERRUPT_ENABLE_RBUE_SET(value) (((value) << 7) & 0x00000080) 191 192 #define DMA_CHx_INTERRUPT_ENABLE_RIE_SET(value) (((value) << 6) & 0x00000040) 193 194 #define DMA_CHx_INTERRUPT_ENABLE_TBUE_SET(value) (((value) << 2) & 0x00000004) 195 196 #define DMA_CHx_INTERRUPT_ENABLE_TXSE_SET(value) (((value) << 1) & 0x00000002) 197 198 #define DMA_CHx_INTERRUPT_ENABLE_TIE_SET(value) (((value) << 0) & 0x00000001) 199 200 #define MTL_OPERATION_MODE_OFST (0x0) 201 202 #define MTL_OPERATION_MODE_ETSALG_SET(value) (((value) << 5) & 0x00000060) 203 204 #define MTL_OPERATION_MODE_RAA_SET(value) (((value) << 2) & 0x00000004) 205 206 #define MTL_TC_PRTY_MAP0_OFST (0x40) 207 208 #define MTL_RXQ_DMA_MAP0_OFST (0x30) 209 210 #define MTL_TCQx_MTL_TXQx_OPERATION_MODE_OFST (0x0) 211 212 #define MTL_TCQx_MTL_TXQx_OPERATION_MODE_TQS_SET(value) (((value) << 16) & 0x007f0000) 213 214 #define MTL_TCQx_MTL_TXQx_OPERATION_MODE_Q2TCMAP_SET(value) (((value) << 8) & 0x00000700) 215 216 #define MTL_TCQx_MTL_TXQx_OPERATION_MODE_TTC_SET(value) (((value) << 4) & 0x00000070) 217 218 #define MTL_TCQx_MTL_TXQx_OPERATION_MODE_TXQEN_SET(value) (((value) << 2) & 0x0000000c) 219 220 #define MTL_TCQx_MTL_TXQx_OPERATION_MODE_TSF_SET(value) (((value) << 1) & 0x00000002) 221 222 #define MTL_TCQx_MTC_TCx_ETS_CONTROL_OFST (0x10) 223 224 #define MTL_TCQx_MTC_TCx_ETS_CONTROL_TSA_SET(value) (((value) << 0) & 0x00000003) 225 226 #define MTL_TCQx_MTL_RXQx_OPERATION_MODE_OFST (0x40) 227 228 #define MTL_TCQx_MTL_RXQx_OPERATION_MODE_RQS_SET(value) (((value) << 16) & 0x003f0000) 229 230 #define MTL_TCQx_MTL_RXQx_OPERATION_MODE_EHFC_SET(value) (((value) << 7) & 0x00000080) 231 232 #define MTL_TCQx_MTL_RXQx_OPERATION_MODE_DIS_TCP_EF_SET(value) (((value) << 6) & 0x00000040) 233 234 #define MTL_TCQx_MTL_RXQx_OPERATION_MODE_RSF_SET(value) (((value) << 5) & 0x00000020) 235 236 #define MTL_TCQx_MTL_RXQx_OPERATION_MODE_FEF_SET(value) (((value) << 4) & 0x00000010) 237 238 #define MTL_TCQx_MTL_RXQx_OPERATION_MODE_FUF_SET(value) (((value) << 3) & 0x00000008) 239 240 #define MTL_TCQx_MTL_RXQx_OPERATION_MODE_RTC_SET(value) (((value) << 0) & 0x00000003) 241 242 #define MTL_INTERRUPT_STATUS_OFST (0x20) 243 244 #define CORE_MAC_ADDRESSx_HIGH_SA_SET(value) (((value) << 30) & 0x40000000) 245 246 #define CORE_MAC_ADDRESS1_HIGH_AE_SET_MSK (0x80000000) 247 248 #define CORE_MAC_ADDRESS0_HIGH_OFST (0x300) 249 250 #define CORE_MAC_ADDRESS0_LOW_OFST (0x304) 251 252 #define CORE_MAC_TX_CONFIGURATION_OFST (0x0) 253 254 #define CORE_MAC_TX_CONFIGURATION_SS_CLR_MSK (0x1fffffff) 255 256 #define CORE_MAC_TX_CONFIGURATION_SS_SET(value) (((value) << 29) & 0xe0000000) 257 258 #define CORE_MAC_TX_CONFIGURATION_JD_SET(value) (((value) << 16) & 0x00010000) 259 260 #define CORE_MAC_RXQ_CTRL0_OFST (0xa0) 261 262 #define CORE_MAC_RX_CONFIGURATION_OFST (0x4) 263 264 #define CORE_MAC_RX_CONFIGURATION_GPSLCE_SET(value) (((value) << 6) & 0x00000040) 265 266 #define CORE_MAC_RX_CONFIGURATION_WD_SET(value) (((value) << 7) & 0x00000080) 267 268 #define CORE_MAC_RX_CONFIGURATION_JE_SET(value) (((value) << 8) & 0x00000100) 269 270 #define CORE_MAC_RX_CONFIGURATION_ARPEN_SET(value) (((value) << 31) & 0x80000000) 271 272 #define CORE_MAC_RX_CONFIGURATION_GPSL_SET(value) (((value) << 16) & 0x3fff0000) 273 274 #define CORE_MAC_TX_CONFIGURATION_TE_SET(value) (((value) << 0) & 0x00000001) 275 276 #define CORE_MAC_RX_CONFIGURATION_RE_SET(value) (((value) << 0) & 0x00000001) 277 278 #define CORE_MAC_TX_CONFIGURATION_TE_CLR_MSK (0xfffffffe) 279 280 #define CORE_MAC_TX_CONFIGURATION_SS_10MHZ (0x07) 281 282 #define CORE_MAC_TX_CONFIGURATION_SS_100MHZ (0x04) 283 284 #define CORE_MAC_TX_CONFIGURATION_SS_1000MHZ (0x03) 285 286 #define CORE_MAC_TX_CONFIGURATION_SS_2500MHZ (0x06) 287 288 #define CORE_MAC_RX_CONFIGURATION_RE_CLR_MSK (0xfffffffe) 289 290 #define CORE_MAC_INTERRUPT_STATUS_OFST (0xb0) 291 292 #define CORE_MAC_INTERRUPT_ENABLE_OFST (0xb4) 293 294 #define CORE_MAC_INTERRUPT_ENABLE_LSIE_SET(value) (((value) << 0) & 0x00000001) 295 296 #define CORE_MAC_PACKET_FILTER_OFST (0x8) 297 298 #define CORE_MAC_PACKET_FILTER_IPFE_SET(value) (((value) << 20) & 0x00100000) 299 300 #define CORE_MAC_PACKET_FILTER_HPF_SET(value) (((value) << 10) & 0x00000400) 301 302 #define CORE_MAC_PACKET_FILTER_HMC_SET(value) (((value) << 2) & 0x00000004) 303 304 #define CORE_MAC_PACKET_FILTER_HUC_SET(value) (((value) << 1) & 0x00000002) 305 306 #define CORE_MAC_RX_CONFIGURATION_IPC_SET(value) (((value) << 9) & 0x00000200) 307 308 #define CORE_MAC_ADDRESS1_HIGH_AE_CLR_MSK 0x7fffffff 309 310 #define CORE_MAC_ADDRESS1_LOW_ADDRLO_SET_MSK 0xffffffff 311 312 #define CORE_MAC_PACKET_FILTER_PR_CLR_MSK 0xfffffffe 313 314 #define CORE_MAC_PACKET_FILTER_PR_SET(value) (((value) << 0) & 0x00000001) 315 316 #define CORE_MAC_PACKET_FILTER_RA_SET(value) (((value) << 31) & 0x80000000) 317 318 #define CORE_MAC_PACKET_FILTER_PM_SET(value) (((value) << 4) & 0x00000010) 319 320 /* 0th index mac address is not used for L2 filtering */ 321 #define XGMAC_MAX_MAC_ADDR_COUNT (32u) 322 #define MAC_ADDR_BYTE_5 (5) 323 #define MAC_ADDR_BYTE_4 (4) 324 #define MAC_ADDR_BYTE_3 (3) 325 #define MAC_ADDR_BYTE_2 (2) 326 #define MAC_ADDR_BYTE_1 (1) 327 #define MAC_ADDR_BYTE_0 (0) 328 #define BIT_OFFSET_8 (8) 329 #define BIT_OFFSET_16 (16) 330 #define BIT_OFFSET_24 (24) 331 332 #define XGMAC_RXQxEN_DCB (2u) /* RX queue enabled for Data Center Bridging or Generic */ 333 #define XGMAC_RXQxEN_SIZE_BITS (2u) 334 #define ETH_MAC_ADDRESS_SIZE (6u) /*Ethernet MAC address size 6 bytes */ 335 336 #define XGMAC_TDES2_IOC BIT(31) 337 #define XGMAC_TDES3_OWN BIT(31) 338 #define XGMAC_TDES3_FD BIT(29) 339 #define XGMAC_TDES3_LD BIT(28) 340 #define XGMAC_TDES3_CS_EN_MSK (3u << 16u) 341 342 #define XGMAC_RDES3_OWN BIT(31) 343 #define XGMAC_RDES3_IOC BIT(30) 344 #define XGMAC_RDES3_FD BIT(29) 345 #define XGMAC_RDES3_LD BIT(28) 346 #define XGMAC_RDES3_ES BIT(15) 347 #define XGMAC_RDES3_PL GENMASK(14, 0) 348 349 #define RX_FRAGS_PER_DESC (2u) 350 #define XGMAC_POLLING_MODE (2u) 351 #define RX_FRAG_ONE (0u) 352 #define RX_FRAG_TWO (1u) 353 354 #ifdef CONFIG_ETH_DWC_XGMAC_ARP_OFFLOAD 355 #define ETH_DWC_XGMAC_ARP_OFFLOAD (1u) 356 #else 357 #define ETH_DWC_XGMAC_ARP_OFFLOAD (0u) 358 #endif 359 360 #define XGMAC_INTERRUPT_POLING_TIMEOUT_US (500u) 361 362 #define ETH_DWC_XGMAC_RESET_STATUS_CHECK_RETRY_COUNT \ 363 (100) /* retry up to 100ms (1 x 100ms poll interval) */ 364 #define XGMAC_REG_SIZE_BYTES (4u) /*4 Bytes*/ 365 #define XGMAC_REG_SIZE_BITS (32u) /*4 Bytes*/ 366 367 #define CHLCNT(n) DT_INST_PROP(n, num_dma_ch) 368 #define MAX_TX_RING(n) DT_INST_PROP(n, dma_ch_tdrl) 369 #define MAX_RX_RING(n) DT_INST_PROP(n, dma_ch_rdrl) 370 371 typedef void (*eth_config_irq_t)(const struct device *port); 372 typedef void (*eth_enable_irq_t)(const struct device *port, bool en); 373 374 /** 375 * @brief Transmit descriptor 376 */ 377 struct xgmac_dma_tx_desc { 378 /* First word of descriptor */ 379 uint32_t tdes0; 380 /* Second word of descriptor */ 381 uint32_t tdes1; 382 /* Third word of descriptor */ 383 uint32_t tdes2; 384 /* Fourth word of descriptor */ 385 uint32_t tdes3; 386 }; 387 388 /** 389 * @brief Receive descriptor 390 * 391 */ 392 struct xgmac_dma_rx_desc { 393 /* First word of descriptor */ 394 uint32_t rdes0; 395 /* Second word of descriptor */ 396 uint32_t rdes1; 397 /* Third word of descriptor */ 398 uint32_t rdes2; 399 /* Fourth word of descriptor */ 400 uint32_t rdes3; 401 }; 402 403 /** 404 * @brief TX DMA memory area buffer descriptor ring management structure. 405 * 406 * The DMA memory area buffer descriptor ring management structure 407 * is used to manage either the TX buffer descriptor array. 408 * It contains a pointer to the start of the descriptor array, a 409 * semaphore as a means of preventing concurrent access, a free entry 410 * counter as well as indices used to determine which BD shall be used 411 * or evaluated for the next TX operation. 412 */ 413 struct xgmac_dma_tx_desc_meta { 414 struct k_sem free_tx_descs_sem; 415 /* Concurrent modification protection */ 416 struct k_mutex ring_lock; 417 /* Index of the next BD to be used for TX */ 418 volatile uint16_t next_to_use; 419 /* Address of the first descriptor in the TX descriptor ring. This field will be 420 * updated in TX descriptor initialization and consumed by channel initialization. 421 */ 422 mem_addr_t desc_list_addr; 423 /* Address of the last descriptor in the TX descriptor ring. This field will be 424 * updated in TX descriptor initialization and consumed by channel initialization. 425 */ 426 volatile mem_addr_t desc_tail_addr; 427 }; 428 /** 429 * @brief RX DMA memory area buffer descriptor ring management structure. 430 * 431 * The DMA memory area buffer descriptor ring management structure 432 * is used to manage either the RX buffer descriptor array. 433 * It contains a pointer to the start of the descriptor array, a 434 * semaphore as a means of preventing concurrent access, a free entry 435 * counter as well as indices used to determine which BD shall be used 436 * or evaluated for the next RX operation. 437 */ 438 struct xgmac_dma_rx_desc_meta { 439 /* Index of the next BD to be read for RX */ 440 volatile uint16_t next_to_read; 441 /* Address of the first descriptor in the RX descriptor ring. this field will be 442 * updated in RX descriptor initialization and consumed by channel initialization 443 */ 444 mem_addr_t desc_list_addr; 445 /* Address of the last descriptor in the RX descriptor ring. this field will be 446 * updated in RX descriptor initialization and consumed by channel initialization 447 */ 448 volatile mem_addr_t desc_tail_addr; 449 struct net_pkt *rx_pkt; 450 }; 451 452 struct xgmac_tx_cntxt { 453 int timeout; /*Time out in sleep intervals count*/ 454 /* TX packet queue ID */ 455 uint8_t q_id; 456 struct xgmac_dma_tx_desc_meta *descmeta; 457 struct xgmac_dma_tx_desc *tx_desc; 458 uint16_t pkt_desc_id; 459 }; 460 461 struct xgmac_dma_cfg { 462 /* Software configured maximum number of AXI data writing requests */ 463 uint8_t wr_osr_lmt; 464 /* Software configured maximum number of AXI data reading requests */ 465 uint8_t rd_osr_lmt; 466 /* This field controls the threshold in the Descriptor cache after which 467 * the EDMA starts pre-fetching the TxDMA descriptors 468 */ 469 uint8_t edma_tdps; 470 /* This field controls the threshold in the Descriptor cache after which 471 * the EDMA starts pre-fetching the RxDMA descriptors 472 */ 473 uint8_t edma_rdps; 474 /* Mixed burst: AXI master can perform burst transfers that are equal to or 475 * less than the maximum allowed burst length programmed 476 */ 477 bool ubl; 478 /* burst length 4bytes */ 479 bool blen4; 480 /* burst length 8bytes */ 481 bool blen8; 482 /* burst length 16bytes */ 483 bool blen16; 484 /* burst length 32bytes */ 485 bool blen32; 486 /* burst length 64bytes */ 487 bool blen64; 488 /* burst length 128bytes */ 489 bool blen128; 490 /* burst length 256bytes */ 491 bool blen256; 492 /* Address-Aligned Beats. When this bit is set to 1, the AXI master performs 493 * address-aligned burst transfers on Read and Write channels 494 */ 495 bool aal; 496 /* Enhanced Address Mode Enable: e DMA engine uses either the 40- or 48-bit address, 497 * depending on the configuration. This bit is valid only when Address Width is greater than 498 * 32 499 */ 500 bool eame; 501 }; 502 503 struct xgmac_dma_chnl_config { 504 /* This field specifies the maximum segment size that should be used while 505 * segmenting the Transmit packet. not applicable when TSO is disabled 506 */ 507 uint16_t mss; 508 /* Transmit Descriptor Ring Length. This field sets the maximum number of Tx 509 * descriptors in the circular descriptor ring. The maximum number of descriptors 510 * is limited to 65536 descriptors 511 */ 512 uint16_t tdrl; 513 /* Receive Descriptor Ring Length. This field sets the maximum number of Rx 514 * descriptors in the circular descriptor ring. The maximum number of descriptors 515 * is limited to 65536 descriptors 516 */ 517 uint16_t rdrl; 518 /* Alternate Receive Buffer Size Indicates size for Buffer 1 when ARBS is 519 * programmed to a non-zero value (when split header feature is not enabled). 520 * When split header feature is enabled, ARBS indicates the buffer size for 521 * header data. It is recommended to use this field when split header feature is 522 * enabled. 523 */ 524 uint8_t arbs; 525 /* maximum receive burst length */ 526 uint8_t rxpbl; 527 /* maximum transmit burst length */ 528 uint8_t txpbl; 529 /* When this bit is set, the DMA splits the header and payload in 530 * the Receive path and stores into the buffer1 and buffer 2 respectively 531 */ 532 bool sph; 533 /* When this is set, the PBL value programmed in Tx_control is multiplied 534 * eight times 535 */ 536 bool pblx8; 537 /* TCP Segmentation Enabled.When this bit is set, the DMA performs the TCP 538 * segmentation for packets in Channel. not applicable when TSO is disabled 539 */ 540 bool tse; 541 /* Operate on Second Packet. When this bit is set, it instructs the DMA to process 542 * the second packet of the Transmit data even before closing the descriptor of the 543 * first packet. not applicable when edma is enabled 544 */ 545 bool osp; 546 }; 547 548 struct xgmac_mtl_config { 549 /* Receive Arbitration Algorithm.This field is used to select the arbitration algorithm 550 * for the RX side. 551 * 0: Strict Priority (SP): Queue 0 has the lowest priority and the last queue has the 552 * highest priority. 1: Weighted Strict Priority (WSP) 553 */ 554 bool raa; 555 /* ETS Algorithm. This field selects the type of ETS algorithm to be applied for 556 * traffic classes whose transmission selection algorithm (TSA) is set to ETS: 557 * 0: WRR algorithm 558 * 1: WFQ algorithm 559 * 2: DWRR algorithm 560 */ 561 uint8_t etsalg; 562 }; 563 564 struct xgmac_mac_config { 565 /* Giant Packet Size Limit 566 */ 567 uint32_t gpsl; 568 /* ARP offload is enabled/disabled. 569 */ 570 bool arp_offload_en; 571 /* jumbo packet is enabled/disabled. 572 */ 573 bool je; 574 }; 575 576 struct xgmac_tcq_config { 577 /* Receive queue enabled for dynamic DMA channel selection when set, this bit indicates 578 * that each packet received in receive queue is routed to a DMA channel as decided in 579 * the MAC Receiver based on the DMA channel number programmed in the L3-L4 filter 580 * registers, RSS lookup table, the ethernet DA address registers or VLAN filter registers. 581 * When reset, this bit indicates that all packets received in receive queue are routed to 582 * the DMA Channel programmed in the rx_q_dma_chnl_sel field. 583 */ 584 uint8_t rx_q_ddma_en; 585 /* Receive Queue Mapped to DMA Channel. This field is valid when the rx_q_ddma_en field is 586 * reset 587 */ 588 uint8_t rx_q_dma_chnl_sel[CONFIG_ETH_XGMAC_MAX_QUEUES]; 589 /* Transmit Queue Size. This field indicates the size of the allocated Transmit queues in 590 * blocks of 256 bytes. Range 0 - 63 591 */ 592 uint8_t tx_q_size[CONFIG_ETH_XGMAC_MAX_QUEUES]; 593 /* Queue to Traffic Class Mapping 594 * Range TC0 - TC7 -> 0 to 7 595 */ 596 uint8_t q_to_tc_map[CONFIG_ETH_XGMAC_MAX_QUEUES]; 597 /* Transmit Threshold Control. These bits control the threshold level of the MTL TX Queue. 598 * Transmission starts when the packet size within the MTL TX Queue is larger than the 599 * threshold. In addition, full packets with length less than the threshold are also 600 * transmitted 0: 64 2: 96 3: 128 4: 192 5: 256 6: 384 7: 512 601 */ 602 uint8_t ttc[CONFIG_ETH_XGMAC_MAX_QUEUES]; 603 /* Receive Queue Size. This field indicates the size of the allocated Receive queues in 604 * blocks of 256 bytes Range: 0 - 127 605 */ 606 uint8_t rx_q_size[CONFIG_ETH_XGMAC_MAX_QUEUES]; 607 /* Transmit Store and Forward. When this bit is set, the transmission starts when a full 608 * packet resides in the MTL TX Queue. When this bit is set, the values specified in the TTC 609 * field are ignored 610 */ 611 uint8_t tsf_en; 612 /* Enable Hardware Flow Control. When this bit is set, the flow control signal operation, 613 * based on the fill-level of RX queue, is enabled 614 */ 615 uint8_t hfc_en; 616 /* Disable Dropping of TCP/IP Checksum Error Packets */ 617 uint8_t cs_err_pkt_drop_dis; 618 /* Receive Queue Store and Forward. When this bit is set, DWC_xgmac reads a packet from the 619 * RX queue only after the complete packet has been written to it, ignoring the RTC field of 620 * this register 621 */ 622 uint8_t rsf_en; 623 /* Forward Error Packets. When this bit is set, all packets except the runt error 624 * packets are forwarded to the application or DMA 625 */ 626 uint8_t fep_en; 627 /* Forward Undersized Good Packets. When this bit is set, the RX queue forwards the 628 * undersized good packets 629 */ 630 uint8_t fup_en; 631 /* Receive Queue Threshold Control. These bits control the threshold level of the MTL Rx 632 * queue in bytes 0: 64 2: 96 3: 128 633 */ 634 uint8_t rtc[CONFIG_ETH_XGMAC_MAX_QUEUES]; 635 /* Priorities Mapped to Traffic Class. This field determines if the transmit queues 636 * associated with the traffic class should be blocked from transmitting for the specified 637 * pause time when a PFC packet is received with priorities matching the priorities 638 * programmed in this field 639 */ 640 uint8_t pstc[CONFIG_ETH_XGMAC_MAX_QUEUES]; 641 /* 642 * uint8_t slc; 643 * uint8_t cc; 644 * uint8_t cbs_en; 645 */ 646 647 /* Transmission Selection Algorithm. This field is used to assign a transmission selection 648 * algorithm for this traffic class. 649 * 0: Strict priority 650 * 1: CBS 651 * 2: ETS 652 */ 653 uint8_t tsa[CONFIG_ETH_XGMAC_MAX_QUEUES]; 654 }; 655 656 struct xgmac_irq_cntxt_data { 657 const struct device *dev; 658 /* 659 * DMA interrupt status value 660 */ 661 volatile uint32_t dma_interrupt_sts; 662 /* 663 * Array pointer all dma channel interrupt status registers values 664 */ 665 volatile uint32_t *dma_chnl_interrupt_sts; 666 /* 667 * MTL interrupt status register value 668 */ 669 volatile uint32_t mtl_interrupt_sts; 670 /* 671 * MAC interrupt status register value 672 */ 673 volatile uint32_t mac_interrupt_sts; 674 }; 675 676 /** 677 * @brief Link speed configuration enumeration type. 678 * 679 * Enumeration type for link speed indication, contains 'link down' 680 * plus all link speeds supported by the controller (10/100/1000). 681 */ 682 enum eth_dwc_xgmac_link_speed { 683 /* The values of this enum are consecutively numbered */ 684 LINK_DOWN = 0, 685 LINK_10MBIT = 10, 686 LINK_100MBIT = 100, 687 LINK_1GBIT = 1000 688 }; 689 690 #endif /* _ZEPHYR_DRIVERS_ETHERNET_ETH_DWC_XGMAC_PRIV_H_ */ 691