AM263Px MCU+ SDK: cpsw_macport.h Source File

| AM263Px MCU+ SDK 26.00.00 |

cpsw_macport.h
Go to the documentation of this file.
1 /*
2 * Copyright (c) Texas Instruments Incorporated 2020
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the
14 * distribution.
15 *
16 * Neither the name of Texas Instruments Incorporated nor the names of
17 * its contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
62 #ifndef CPSW_MACPORT_H_
63 #define CPSW_MACPORT_H_
64
65 /* ========================================================================== */
66 /* Include Files */
67 /* ========================================================================== */
68
69 #include <include/core/enet_mod_macport.h>
70
71 #ifdef __cplusplus
72 extern "C" {
73 #endif
74
75 /* ========================================================================== */
76 /* Macros */
77 /* ========================================================================== */
78
80 #define CPSW_MACPORT_PUBLIC_IOCTL(x) (ENET_IOCTL_TYPE_PUBLIC | \
81 ENET_IOCTL_MACPORT_BASE | \
82 ENET_IOCTL_PER_CPSW | \
83 ENET_IOCTL_MIN(x))
84
88 #define CPSW_MACPORT_EST_TIME_INTERVAL_MIN (0x010U)
89
91 #define CPSW_MACPORT_EST_TIME_INTERVAL_MAX (0x3FFFU)
92
94 #define CPSW_MACPORT_EST_TIME_STEP_1G (8U)
95
97 #define CPSW_MACPORT_EST_TIME_STEP_100M (40U)
98
100 #define CPSW_MACPORT_EST_TIME_STEP_10M (400U)
101
103 #define CPSW_MACPORT_EST_TIME_MIN(speed) (CPSW_MACPORT_EST_TIME_STEP_##speed * CPSW_MACPORT_EST_TIME_INTERVAL_MIN)
104
106 #define CPSW_MACPORT_EST_TIME_MAX(speed) (CPSW_MACPORT_EST_TIME_STEP_##speed * CPSW_MACPORT_EST_TIME_INTERVAL_MAX)
107
109 #define CPSW_MACPORT_EST_ALLOWCNT_FACTOR_1G (1U)
110
112 #define CPSW_MACPORT_EST_ALLOWCNT_FACTOR_100M (2U)
113
115 #define CPSW_MACPORT_EST_ALLOWCNT_FACTOR_10M (2U)
116
119 #define CPSW_MACPORT_EST_GUARD_BAND(maxPktSize, speed) (((((maxPktSize) + 4U) * \
120 CPSW_MACPORT_EST_ALLOWCNT_FACTOR_##speed) + 292U) * \
121 CPSW_MACPORT_EST_TIME_STEP_##speed)
122
124 #define CPSW_MACPORT_GIGABIT_IET_VERIFY_TIMEOUT_NS (10*1000*1000)
125
127 #define CPSW_MACPORT_RX_MAX_BLKS_IET (7U)
128
130 #define CPSW_MACPORT_TX_MAX_BLKS_IET (13U)
131
133 #define CPSW_MACPORT_RX_MAX_BLKS_DEFAULT (4U)
134
136 #define CPSW_MACPORT_TX_MAX_BLKS_DEFAULT (16U)
137
138 /* ========================================================================== */
139 /* Structures and Enums */
140 /* ========================================================================== */
141
145 typedef enum CpswMacPort_Ioctl_s
146 {
154 CPSW_MACPORT_IOCTL_GET_FIFO_STATS = CPSW_MACPORT_PUBLIC_IOCTL(0U),
155
163 CPSW_MACPORT_IOCTL_ENABLE_CPTS_EVENT = CPSW_MACPORT_PUBLIC_IOCTL(1U),
164
172 CPSW_MACPORT_IOCTL_DISABLE_CPTS_EVENT = CPSW_MACPORT_PUBLIC_IOCTL(2U),
173
183 CPSW_MACPORT_IOCTL_EST_ENABLE_TIMESTAMP = CPSW_MACPORT_PUBLIC_IOCTL(3U),
184
192 CPSW_MACPORT_IOCTL_EST_DISABLE_TIMESTAMP = CPSW_MACPORT_PUBLIC_IOCTL(4U),
193 } CpswMacPort_Ioctl;
194
198 typedef struct CpswMacPort_TxShortIpgCfg_s
199 {
203 bool txShortGapEn;
204
215 bool txShortGapLimitEn;
216 } CpswMacPort_TxShortIpgCfg;
217
221 typedef struct CpswMacPort_PortTxShortIpgCfg_s
222 {
224 Enet_MacPort macPort;
225
227 CpswMacPort_TxShortIpgCfg shortIpgCfg;
228 } CpswMacPort_PortTxShortIpgCfg;
229
233 typedef enum CpswMacPort_InterVlanRouteId_e
234 {
236 CPSW_MACPORT_INTERVLAN_ROUTEID_FIRST,
237
239 CPSW_MACPORT_INTERVLAN_ROUTEID_1 = CPSW_MACPORT_INTERVLAN_ROUTEID_FIRST,
240
242 CPSW_MACPORT_INTERVLAN_ROUTEID_2,
243
245 CPSW_MACPORT_INTERVLAN_ROUTEID_3,
246
248 CPSW_MACPORT_INTERVLAN_ROUTEID_4,
249
251 CPSW_MACPORT_INTERVLAN_ROUTEID_LAST = CPSW_MACPORT_INTERVLAN_ROUTEID_4
252 } CpswMacPort_InterVlanRouteId;
253
257 typedef struct CpswMacPort_InterVlanRoutingCfg_s
258 {
260 uint8_t dstAddr[ENET_MAC_ADDR_LEN];
261
263 uint8_t srcAddr[ENET_MAC_ADDR_LEN];
264
266 uint32_t vlanId;
267
270 bool replaceDASA;
271
274 bool forceUntaggedEgress;
275
285 bool decrementTTL;
286 } CpswMacPort_InterVlanRoutingCfg;
287
291 typedef struct CpswMacPort_FifoStats_s
292 {
294 uint32_t rxThroughputRate;
295
298 uint32_t txStartWords;
299
301 uint32_t txMaxBlocks;
302
305 uint32_t rxMaxBlocks;
306
308 uint32_t txBlockCount;
309
311 uint32_t rxExpressBlockCount;
312
314 uint32_t rxPreemptBlockCount;
315
317 bool txActiveFifo[ENET_PRI_NUM];
318 } CpswMacPort_FifoStats;
319
325 typedef struct CpswMacPort_IpTsCfg_s
326 {
328 bool ttlNonzeroEn;
329
331 bool unicastEn;
332
334 bool tsIp129En;
335
337 bool tsIp130En;
338
340 bool tsIp131En;
341
343 bool tsIp132En;
344
346 bool tsIp107En;
347
349 bool tsPort319En;
350
352 bool tsPort320En;
353 } CpswMacPort_IpTsCfg;
354
361 typedef struct CpswMacPort_TsEventCfg_s
362 {
364 bool txAnnexDEn;
365
367 bool rxAnnexDEn;
368
370 bool txAnnexEEn;
371
373 bool rxAnnexEEn;
374
376 bool txAnnexFEn;
377
379 bool rxAnnexFEn;
380
382 bool txHostTsEn;
383
385 EnetMacPort_VlanType txVlanType;
386
388 EnetMacPort_VlanType rxVlanType;
389
392 uint32_t vlanLType1;
393
396 uint32_t vlanLType2;
397
399 CpswMacPort_IpTsCfg commonPortIpCfg;
400
402 uint32_t mcastType;
403
405 uint32_t messageType;
406
408 bool ltype2En;
409
411 uint32_t seqIdOffset;
412
414 uint32_t domainOffset;
415 } CpswMacPort_TsEventCfg;
416
420 typedef struct CpswMacPort_EnableTsEventInArgs_s
421 {
423 Enet_MacPort macPort;
424
426 CpswMacPort_TsEventCfg tsEventCfg;
427 } CpswMacPort_EnableTsEventInArgs;
428
432 typedef enum CpswMacPort_EstTimestampMode_e
433 {
435 CPSW_MACPORT_EST_TIMESTAMP_ALL,
436
438 CPSW_MACPORT_EST_TIMESTAMP_ONEPRI,
439
441 CPSW_MACPORT_EST_TIMESTAMP_FIRST,
442
444 CPSW_MACPORT_EST_TIMESTAMP_FIRST_ONEPRI,
445
446 } CpswMacPort_EstTimestampMode;
447
451 typedef struct CpswMacPort_EstTimestampCfg_s
452 {
454 Enet_MacPort macPort;
455
457 CpswMacPort_EstTimestampMode mode;
458
462 uint8_t priority;
463
466 uint8_t domain;
467 } CpswMacPort_EstTimestampCfg;
468
472 typedef struct CpswMacPort_Cfg_s
473 {
475 bool loopbackEn;
476
478 Enet_CrcType crcType;
479
482 uint32_t rxMtu;
483
486 bool passPriorityTaggedUnchanged;
487
489 EnetPort_VlanCfg vlanCfg;
490
492 EnetPort_EgressPriorityType txPriorityType;
493
495 EnetMac_SgmiiMode sgmiiMode;
496 } CpswMacPort_Cfg;
497
498 /* ========================================================================== */
499 /* Global Variables Declarations */
500 /* ========================================================================== */
501
502 /* None */
503
504 /* ========================================================================== */
505 /* Function Declarations */
506 /* ========================================================================== */
507
513 void CpswMacPort_initCfg(CpswMacPort_Cfg *macPortCfg);
514
515 /* ========================================================================== */
516 /* Deprecated Function Declarations */
517 /* ========================================================================== */
518
519 /* None */
520
521 /* ========================================================================== */
522 /* Static Function Definitions */
523 /* ========================================================================== */
524
525 /* None */
526
527 #ifdef __cplusplus
528 }
529 #endif
530
531 #endif /* CPSW_MACPORT_H_ */
532
CpswMacPort_FifoStats::rxPreemptBlockCount
uint32_t rxPreemptBlockCount
Definition: cpsw_macport.h:314
CpswMacPort_Cfg::passPriorityTaggedUnchanged
bool passPriorityTaggedUnchanged
Definition: cpsw_macport.h:486
CpswMacPort_EstTimestampMode
CpswMacPort_EstTimestampMode
EST timestamping modes.
Definition: cpsw_macport.h:433
CpswMacPort_EnableTsEventInArgs::macPort
Enet_MacPort macPort
Definition: cpsw_macport.h:423
CpswMacPort_FifoStats::txStartWords
uint32_t txStartWords
Definition: cpsw_macport.h:298
CpswMacPort_FifoStats::rxMaxBlocks
uint32_t rxMaxBlocks
Definition: cpsw_macport.h:305
CPSW_MACPORT_INTERVLAN_ROUTEID_2
@ CPSW_MACPORT_INTERVLAN_ROUTEID_2
Definition: cpsw_macport.h:242
CpswMacPort_IpTsCfg::tsPort320En
bool tsPort320En
Definition: cpsw_macport.h:352
CpswMacPort_TxShortIpgCfg::txShortGapEn
bool txShortGapEn
Definition: cpsw_macport.h:203
CpswMacPort_IpTsCfg::tsIp132En
bool tsIp132En
Definition: cpsw_macport.h:343
enet_mod_macport.h
This file contains the type definitions and helper macros for the Enet MAC port module interface.
CpswMacPort_TsEventCfg::txAnnexFEn
bool txAnnexFEn
Definition: cpsw_macport.h:376
CpswMacPort_TsEventCfg::txVlanType
EnetMacPort_VlanType txVlanType
Definition: cpsw_macport.h:385
CpswMacPort_InterVlanRoutingCfg::forceUntaggedEgress
bool forceUntaggedEgress
Definition: cpsw_macport.h:274
CpswMacPort_Ioctl
CpswMacPort_Ioctl
CPSW MAC port IOCTL commands.
Definition: cpsw_macport.h:146
EnetPort_VlanCfg
VLAN configuration parameters.
Definition: enet_mod_port.h:69
CpswMacPort_TsEventCfg::rxVlanType
EnetMacPort_VlanType rxVlanType
Definition: cpsw_macport.h:388
CpswMacPort_FifoStats::txBlockCount
uint32_t txBlockCount
Definition: cpsw_macport.h:308
CpswMacPort_IpTsCfg::tsPort319En
bool tsPort319En
Definition: cpsw_macport.h:349
CPSW_MACPORT_INTERVLAN_ROUTEID_1
@ CPSW_MACPORT_INTERVLAN_ROUTEID_1
Definition: cpsw_macport.h:239
CpswMacPort_IpTsCfg
Port IP configuration for time synchronization events.
Definition: cpsw_macport.h:326
CpswMacPort_TxShortIpgCfg::txShortGapLimitEn
bool txShortGapLimitEn
Definition: cpsw_macport.h:215
CPSW_MACPORT_EST_TIMESTAMP_FIRST_ONEPRI
@ CPSW_MACPORT_EST_TIMESTAMP_FIRST_ONEPRI
Definition: cpsw_macport.h:444
CpswMacPort_TsEventCfg::domainOffset
uint32_t domainOffset
Definition: cpsw_macport.h:414
Enet_MacPort
Enet_MacPort
MAC port.
Definition: enet_types.h:412
CpswMacPort_PortTxShortIpgCfg
MAC port's short gap configuration.
Definition: cpsw_macport.h:222
CPSW_MACPORT_INTERVLAN_ROUTEID_3
@ CPSW_MACPORT_INTERVLAN_ROUTEID_3
Definition: cpsw_macport.h:245
CpswMacPort_IpTsCfg::tsIp130En
bool tsIp130En
Definition: cpsw_macport.h:337
CpswMacPort_InterVlanRoutingCfg::replaceDASA
bool replaceDASA
Definition: cpsw_macport.h:270
CpswMacPort_InterVlanRoutingCfg
Port interVLAN configuration parameters.
Definition: cpsw_macport.h:258
CpswMacPort_Cfg::crcType
Enet_CrcType crcType
Definition: cpsw_macport.h:478
CpswMacPort_TxShortIpgCfg
Configuration of transmit short inter packet gap feature.
Definition: cpsw_macport.h:199
CpswMacPort_Cfg::vlanCfg
EnetPort_VlanCfg vlanCfg
Definition: cpsw_macport.h:489
CpswMacPort_Cfg::loopbackEn
bool loopbackEn
Definition: cpsw_macport.h:475
CpswMacPort_PortTxShortIpgCfg::shortIpgCfg
CpswMacPort_TxShortIpgCfg shortIpgCfg
Definition: cpsw_macport.h:227
CPSW_MACPORT_EST_TIMESTAMP_FIRST
@ CPSW_MACPORT_EST_TIMESTAMP_FIRST
Definition: cpsw_macport.h:441
CpswMacPort_IpTsCfg::tsIp131En
bool tsIp131En
Definition: cpsw_macport.h:340
CpswMacPort_EstTimestampCfg::mode
CpswMacPort_EstTimestampMode mode
Definition: cpsw_macport.h:457
CpswMacPort_initCfg
void CpswMacPort_initCfg(CpswMacPort_Cfg *macPortCfg)
Initialize CPSW MAC port configuration parameters.
CpswMacPort_TsEventCfg
Port configuration for time synchronization.
Definition: cpsw_macport.h:362
CPSW_MACPORT_INTERVLAN_ROUTEID_LAST
@ CPSW_MACPORT_INTERVLAN_ROUTEID_LAST
Definition: cpsw_macport.h:251
EnetMacPort_VlanType
EnetMacPort_VlanType
VLAN usage type.
Definition: enet_mod_macport.h:470
CPSW_MACPORT_IOCTL_ENABLE_CPTS_EVENT
@ CPSW_MACPORT_IOCTL_ENABLE_CPTS_EVENT
Enable Ethernet port CPTS event.
Definition: cpsw_macport.h:163
ENET_PRI_NUM
#define ENET_PRI_NUM
Packet priority.
Definition: enet_types.h:165
CpswMacPort_TsEventCfg::txAnnexEEn
bool txAnnexEEn
Definition: cpsw_macport.h:370
CpswMacPort_Cfg
MAC port module configuration parameters.
Definition: cpsw_macport.h:473
CpswMacPort_TsEventCfg::commonPortIpCfg
CpswMacPort_IpTsCfg commonPortIpCfg
Definition: cpsw_macport.h:399
CPSW_MACPORT_IOCTL_EST_ENABLE_TIMESTAMP
@ CPSW_MACPORT_IOCTL_EST_ENABLE_TIMESTAMP
Enable EST packet timestamping functionality.
Definition: cpsw_macport.h:183
CpswMacPort_IpTsCfg::tsIp107En
bool tsIp107En
Definition: cpsw_macport.h:346
CpswMacPort_IpTsCfg::tsIp129En
bool tsIp129En
Definition: cpsw_macport.h:334
CpswMacPort_EstTimestampCfg::domain
uint8_t domain
Definition: cpsw_macport.h:466
EnetPort_EgressPriorityType
EnetPort_EgressPriorityType
Egress priority type.
Definition: enet_mod_port.h:84
CpswMacPort_FifoStats
FIFO related statistics of a MAC port.
Definition: cpsw_macport.h:292
CpswMacPort_Cfg::sgmiiMode
EnetMac_SgmiiMode sgmiiMode
Definition: cpsw_macport.h:495
CpswMacPort_TsEventCfg::vlanLType2
uint32_t vlanLType2
Definition: cpsw_macport.h:396
CpswMacPort_FifoStats::rxExpressBlockCount
uint32_t rxExpressBlockCount
Definition: cpsw_macport.h:311
CpswMacPort_EnableTsEventInArgs
Input args for CPSW_MACPORT_IOCTL_ENABLE_CPTS_EVENT.
Definition: cpsw_macport.h:421
CpswMacPort_TsEventCfg::vlanLType1
uint32_t vlanLType1
Definition: cpsw_macport.h:392
CPSW_MACPORT_EST_TIMESTAMP_ONEPRI
@ CPSW_MACPORT_EST_TIMESTAMP_ONEPRI
Definition: cpsw_macport.h:438
CpswMacPort_FifoStats::txMaxBlocks
uint32_t txMaxBlocks
Definition: cpsw_macport.h:301
CpswMacPort_TsEventCfg::rxAnnexFEn
bool rxAnnexFEn
Definition: cpsw_macport.h:379
CpswMacPort_TsEventCfg::rxAnnexEEn
bool rxAnnexEEn
Definition: cpsw_macport.h:373
CPSW_MACPORT_IOCTL_DISABLE_CPTS_EVENT
@ CPSW_MACPORT_IOCTL_DISABLE_CPTS_EVENT
Disable Ethernet port CPTS event.
Definition: cpsw_macport.h:172
CpswMacPort_Cfg::txPriorityType
EnetPort_EgressPriorityType txPriorityType
Definition: cpsw_macport.h:492
CPSW_MACPORT_INTERVLAN_ROUTEID_FIRST
@ CPSW_MACPORT_INTERVLAN_ROUTEID_FIRST
Definition: cpsw_macport.h:236
CpswMacPort_TsEventCfg::ltype2En
bool ltype2En
Definition: cpsw_macport.h:408
CpswMacPort_InterVlanRoutingCfg::decrementTTL
bool decrementTTL
Definition: cpsw_macport.h:285
CpswMacPort_Cfg::rxMtu
uint32_t rxMtu
Definition: cpsw_macport.h:482
CpswMacPort_PortTxShortIpgCfg::macPort
Enet_MacPort macPort
Definition: cpsw_macport.h:224
CpswMacPort_TsEventCfg::rxAnnexDEn
bool rxAnnexDEn
Definition: cpsw_macport.h:367
CpswMacPort_TsEventCfg::seqIdOffset
uint32_t seqIdOffset
Definition: cpsw_macport.h:411
CpswMacPort_TsEventCfg::messageType
uint32_t messageType
Definition: cpsw_macport.h:405
CPSW_MACPORT_INTERVLAN_ROUTEID_4
@ CPSW_MACPORT_INTERVLAN_ROUTEID_4
Definition: cpsw_macport.h:248
CPSW_MACPORT_IOCTL_GET_FIFO_STATS
@ CPSW_MACPORT_IOCTL_GET_FIFO_STATS
Get MAC port FIFO statistics.
Definition: cpsw_macport.h:154
CPSW_MACPORT_EST_TIMESTAMP_ALL
@ CPSW_MACPORT_EST_TIMESTAMP_ALL
Definition: cpsw_macport.h:435
CpswMacPort_EnableTsEventInArgs::tsEventCfg
CpswMacPort_TsEventCfg tsEventCfg
Definition: cpsw_macport.h:426
CpswMacPort_TsEventCfg::txAnnexDEn
bool txAnnexDEn
Definition: cpsw_macport.h:364
CpswMacPort_InterVlanRouteId
CpswMacPort_InterVlanRouteId
MAC port interVLAN route identifier.
Definition: cpsw_macport.h:234
CPSW_MACPORT_IOCTL_EST_DISABLE_TIMESTAMP
@ CPSW_MACPORT_IOCTL_EST_DISABLE_TIMESTAMP
Disable EST packet timestamping functionality.
Definition: cpsw_macport.h:192
CPSW_MACPORT_PUBLIC_IOCTL
#define CPSW_MACPORT_PUBLIC_IOCTL(x)
Helper macro to create IOCTL commands for CPSW MAC port module.
Definition: cpsw_macport.h:80
CpswMacPort_IpTsCfg::unicastEn
bool unicastEn
Definition: cpsw_macport.h:331
CpswMacPort_InterVlanRoutingCfg::vlanId
uint32_t vlanId
Definition: cpsw_macport.h:266
CpswMacPort_EstTimestampCfg::macPort
Enet_MacPort macPort
Definition: cpsw_macport.h:454
ENET_MAC_ADDR_LEN
#define ENET_MAC_ADDR_LEN
MAC address length in bytes/octets.
Definition: enet_types.h:153
CpswMacPort_FifoStats::rxThroughputRate
uint32_t rxThroughputRate
Definition: cpsw_macport.h:294
CpswMacPort_EstTimestampCfg::priority
uint8_t priority
Definition: cpsw_macport.h:462
CpswMacPort_TsEventCfg::mcastType
uint32_t mcastType
Definition: cpsw_macport.h:402
Enet_CrcType
Enet_CrcType
CRC type.
Definition: enet_types.h:250
CpswMacPort_EstTimestampCfg
EST timestamping configuration parameters.
Definition: cpsw_macport.h:452
CpswMacPort_TsEventCfg::txHostTsEn
bool txHostTsEn
Definition: cpsw_macport.h:382
CpswMacPort_IpTsCfg::ttlNonzeroEn
bool ttlNonzeroEn
Definition: cpsw_macport.h:328
EnetMac_SgmiiMode
EnetMac_SgmiiMode
SGMII mode.
Definition: enet_mod_macport.h:419