AM64x MCU+ SDK  08.03.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 
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 
123 /* ========================================================================== */
124 /* Structures and Enums */
125 /* ========================================================================== */
126 
130 typedef enum CpswMacPort_Ioctl_s
131 {
140 
149 
158 
169 
179 
183 typedef struct CpswMacPort_TxShortIpgCfg_s
184 {
189 
202 
206 typedef struct CpswMacPort_PortTxShortIpgCfg_s
207 {
210 
214 
218 typedef enum CpswMacPort_InterVlanRouteId_e
219 {
222 
225 
228 
231 
234 
238 
242 typedef struct CpswMacPort_InterVlanRoutingCfg_s
243 {
245  uint8_t dstAddr[ENET_MAC_ADDR_LEN];
246 
248  uint8_t srcAddr[ENET_MAC_ADDR_LEN];
249 
251  uint32_t vlanId;
252 
256 
260 
272 
276 typedef struct CpswMacPort_FifoStats_s
277 {
280 
283  uint32_t txStartWords;
284 
286  uint32_t txMaxBlocks;
287 
290  uint32_t rxMaxBlocks;
291 
293  uint32_t txBlockCount;
294 
297 
300 
302  bool txActiveFifo[ENET_PRI_NUM];
304 
310 typedef struct CpswMacPort_IpTsCfg_s
311 {
314 
316  bool unicastEn;
317 
319  bool tsIp129En;
320 
322  bool tsIp130En;
323 
325  bool tsIp131En;
326 
328  bool tsIp132En;
329 
331  bool tsIp107En;
332 
335 
339 
346 typedef struct CpswMacPort_TsEventCfg_s
347 {
350 
353 
356 
359 
362 
365 
368 
371 
374 
377  uint32_t vlanLType1;
378 
381  uint32_t vlanLType2;
382 
385 
387  uint32_t mcastType;
388 
390  uint32_t messageType;
391 
393  bool ltype2En;
394 
396  uint32_t seqIdOffset;
397 
399  uint32_t domainOffset;
401 
405 typedef struct CpswMacPort_EnableTsEventInArgs_s
406 {
409 
413 
417 typedef enum CpswMacPort_EstTimestampMode_e
418 {
421 
424 
427 
430 
432 
436 typedef struct CpswMacPort_EstTimestampCfg_s
437 {
440 
443 
447  uint8_t priority;
448 
451  uint8_t domain;
453 
457 typedef struct CpswMacPort_Cfg_s
458 {
461 
464 
467  uint32_t rxMtu;
468 
472 
475 
478 
482 
483 /* ========================================================================== */
484 /* Global Variables Declarations */
485 /* ========================================================================== */
486 
487 /* None */
488 
489 /* ========================================================================== */
490 /* Function Declarations */
491 /* ========================================================================== */
492 
499 
500 /* ========================================================================== */
501 /* Deprecated Function Declarations */
502 /* ========================================================================== */
503 
504 /* None */
505 
506 /* ========================================================================== */
507 /* Static Function Definitions */
508 /* ========================================================================== */
509 
510 /* None */
511 
512 #ifdef __cplusplus
513 }
514 #endif
515 
516 #endif /* CPSW_MACPORT_H_ */
517 
CpswMacPort_FifoStats::rxPreemptBlockCount
uint32_t rxPreemptBlockCount
Definition: cpsw_macport.h:299
CpswMacPort_Cfg::passPriorityTaggedUnchanged
bool passPriorityTaggedUnchanged
Definition: cpsw_macport.h:471
CpswMacPort_EstTimestampMode
CpswMacPort_EstTimestampMode
EST timestamping modes.
Definition: cpsw_macport.h:418
CpswMacPort_EnableTsEventInArgs::macPort
Enet_MacPort macPort
Definition: cpsw_macport.h:408
CpswMacPort_FifoStats::txStartWords
uint32_t txStartWords
Definition: cpsw_macport.h:283
CpswMacPort_FifoStats::rxMaxBlocks
uint32_t rxMaxBlocks
Definition: cpsw_macport.h:290
CPSW_MACPORT_INTERVLAN_ROUTEID_2
@ CPSW_MACPORT_INTERVLAN_ROUTEID_2
Definition: cpsw_macport.h:227
CpswMacPort_IpTsCfg::tsPort320En
bool tsPort320En
Definition: cpsw_macport.h:337
CpswMacPort_TxShortIpgCfg::txShortGapEn
bool txShortGapEn
Definition: cpsw_macport.h:188
CpswMacPort_IpTsCfg::tsIp132En
bool tsIp132En
Definition: cpsw_macport.h:328
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:361
CpswMacPort_TsEventCfg::txVlanType
EnetMacPort_VlanType txVlanType
Definition: cpsw_macport.h:370
CpswMacPort_InterVlanRoutingCfg::forceUntaggedEgress
bool forceUntaggedEgress
Definition: cpsw_macport.h:259
CpswMacPort_Ioctl
CpswMacPort_Ioctl
CPSW MAC port IOCTL commands.
Definition: cpsw_macport.h:131
EnetPort_VlanCfg
VLAN configuration parameters.
Definition: enet_mod_port.h:68
CpswMacPort_TsEventCfg::rxVlanType
EnetMacPort_VlanType rxVlanType
Definition: cpsw_macport.h:373
CpswMacPort_FifoStats::txBlockCount
uint32_t txBlockCount
Definition: cpsw_macport.h:293
CpswMacPort_IpTsCfg::tsPort319En
bool tsPort319En
Definition: cpsw_macport.h:334
CPSW_MACPORT_INTERVLAN_ROUTEID_1
@ CPSW_MACPORT_INTERVLAN_ROUTEID_1
Definition: cpsw_macport.h:224
CpswMacPort_IpTsCfg
Port IP configuration for time synchronization events.
Definition: cpsw_macport.h:311
CpswMacPort_TxShortIpgCfg::txShortGapLimitEn
bool txShortGapLimitEn
Definition: cpsw_macport.h:200
CPSW_MACPORT_EST_TIMESTAMP_FIRST_ONEPRI
@ CPSW_MACPORT_EST_TIMESTAMP_FIRST_ONEPRI
Definition: cpsw_macport.h:429
CpswMacPort_TsEventCfg::domainOffset
uint32_t domainOffset
Definition: cpsw_macport.h:399
Enet_MacPort
Enet_MacPort
MAC port.
Definition: enet_types.h:406
CpswMacPort_PortTxShortIpgCfg
MAC port's short gap configuration.
Definition: cpsw_macport.h:207
CPSW_MACPORT_INTERVLAN_ROUTEID_3
@ CPSW_MACPORT_INTERVLAN_ROUTEID_3
Definition: cpsw_macport.h:230
CpswMacPort_IpTsCfg::tsIp130En
bool tsIp130En
Definition: cpsw_macport.h:322
CpswMacPort_InterVlanRoutingCfg::replaceDASA
bool replaceDASA
Definition: cpsw_macport.h:255
CpswMacPort_InterVlanRoutingCfg
Port interVLAN configuration parameters.
Definition: cpsw_macport.h:243
CpswMacPort_Cfg::crcType
Enet_CrcType crcType
Definition: cpsw_macport.h:463
CpswMacPort_TxShortIpgCfg
Configuration of transmit short inter packet gap feature.
Definition: cpsw_macport.h:184
CpswMacPort_Cfg::vlanCfg
EnetPort_VlanCfg vlanCfg
Definition: cpsw_macport.h:474
CpswMacPort_Cfg::loopbackEn
bool loopbackEn
Definition: cpsw_macport.h:460
CpswMacPort_PortTxShortIpgCfg::shortIpgCfg
CpswMacPort_TxShortIpgCfg shortIpgCfg
Definition: cpsw_macport.h:212
CPSW_MACPORT_EST_TIMESTAMP_FIRST
@ CPSW_MACPORT_EST_TIMESTAMP_FIRST
Definition: cpsw_macport.h:426
CpswMacPort_IpTsCfg::tsIp131En
bool tsIp131En
Definition: cpsw_macport.h:325
CpswMacPort_EstTimestampCfg::mode
CpswMacPort_EstTimestampMode mode
Definition: cpsw_macport.h:442
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:347
CPSW_MACPORT_INTERVLAN_ROUTEID_LAST
@ CPSW_MACPORT_INTERVLAN_ROUTEID_LAST
Definition: cpsw_macport.h:236
EnetMacPort_VlanType
EnetMacPort_VlanType
VLAN usage type.
Definition: enet_mod_macport.h:310
CPSW_MACPORT_IOCTL_ENABLE_CPTS_EVENT
@ CPSW_MACPORT_IOCTL_ENABLE_CPTS_EVENT
Enable Ethernet port CPTS event.
Definition: cpsw_macport.h:148
ENET_PRI_NUM
#define ENET_PRI_NUM
Packet priority.
Definition: enet_types.h:165
CpswMacPort_TsEventCfg::txAnnexEEn
bool txAnnexEEn
Definition: cpsw_macport.h:355
CpswMacPort_Cfg
MAC port module configuration parameters.
Definition: cpsw_macport.h:458
CpswMacPort_TsEventCfg::commonPortIpCfg
CpswMacPort_IpTsCfg commonPortIpCfg
Definition: cpsw_macport.h:384
CPSW_MACPORT_IOCTL_EST_ENABLE_TIMESTAMP
@ CPSW_MACPORT_IOCTL_EST_ENABLE_TIMESTAMP
Enable EST packet timestamping functionality.
Definition: cpsw_macport.h:168
CpswMacPort_IpTsCfg::tsIp107En
bool tsIp107En
Definition: cpsw_macport.h:331
CpswMacPort_IpTsCfg::tsIp129En
bool tsIp129En
Definition: cpsw_macport.h:319
CpswMacPort_EstTimestampCfg::domain
uint8_t domain
Definition: cpsw_macport.h:451
EnetPort_EgressPriorityType
EnetPort_EgressPriorityType
Egress priority type.
Definition: enet_mod_port.h:83
CpswMacPort_FifoStats
FIFO related statistics of a MAC port.
Definition: cpsw_macport.h:277
CpswMacPort_Cfg::sgmiiMode
EnetMac_SgmiiMode sgmiiMode
Definition: cpsw_macport.h:480
CpswMacPort_TsEventCfg::vlanLType2
uint32_t vlanLType2
Definition: cpsw_macport.h:381
CpswMacPort_FifoStats::rxExpressBlockCount
uint32_t rxExpressBlockCount
Definition: cpsw_macport.h:296
CpswMacPort_EnableTsEventInArgs
Input args for CPSW_MACPORT_IOCTL_ENABLE_CPTS_EVENT.
Definition: cpsw_macport.h:406
CpswMacPort_TsEventCfg::vlanLType1
uint32_t vlanLType1
Definition: cpsw_macport.h:377
CPSW_MACPORT_EST_TIMESTAMP_ONEPRI
@ CPSW_MACPORT_EST_TIMESTAMP_ONEPRI
Definition: cpsw_macport.h:423
CpswMacPort_FifoStats::txMaxBlocks
uint32_t txMaxBlocks
Definition: cpsw_macport.h:286
CpswMacPort_TsEventCfg::rxAnnexFEn
bool rxAnnexFEn
Definition: cpsw_macport.h:364
CpswMacPort_TsEventCfg::rxAnnexEEn
bool rxAnnexEEn
Definition: cpsw_macport.h:358
CPSW_MACPORT_IOCTL_DISABLE_CPTS_EVENT
@ CPSW_MACPORT_IOCTL_DISABLE_CPTS_EVENT
Disable Ethernet port CPTS event.
Definition: cpsw_macport.h:157
CpswMacPort_Cfg::txPriorityType
EnetPort_EgressPriorityType txPriorityType
Definition: cpsw_macport.h:477
CPSW_MACPORT_INTERVLAN_ROUTEID_FIRST
@ CPSW_MACPORT_INTERVLAN_ROUTEID_FIRST
Definition: cpsw_macport.h:221
CpswMacPort_TsEventCfg::ltype2En
bool ltype2En
Definition: cpsw_macport.h:393
CpswMacPort_InterVlanRoutingCfg::decrementTTL
bool decrementTTL
Definition: cpsw_macport.h:270
CpswMacPort_Cfg::rxMtu
uint32_t rxMtu
Definition: cpsw_macport.h:467
CpswMacPort_PortTxShortIpgCfg::macPort
Enet_MacPort macPort
Definition: cpsw_macport.h:209
CpswMacPort_TsEventCfg::rxAnnexDEn
bool rxAnnexDEn
Definition: cpsw_macport.h:352
CpswMacPort_TsEventCfg::seqIdOffset
uint32_t seqIdOffset
Definition: cpsw_macport.h:396
CpswMacPort_TsEventCfg::messageType
uint32_t messageType
Definition: cpsw_macport.h:390
CPSW_MACPORT_INTERVLAN_ROUTEID_4
@ CPSW_MACPORT_INTERVLAN_ROUTEID_4
Definition: cpsw_macport.h:233
CPSW_MACPORT_IOCTL_GET_FIFO_STATS
@ CPSW_MACPORT_IOCTL_GET_FIFO_STATS
Get MAC port FIFO statistics.
Definition: cpsw_macport.h:139
CPSW_MACPORT_EST_TIMESTAMP_ALL
@ CPSW_MACPORT_EST_TIMESTAMP_ALL
Definition: cpsw_macport.h:420
CpswMacPort_EnableTsEventInArgs::tsEventCfg
CpswMacPort_TsEventCfg tsEventCfg
Definition: cpsw_macport.h:411
CpswMacPort_TsEventCfg::txAnnexDEn
bool txAnnexDEn
Definition: cpsw_macport.h:349
CpswMacPort_InterVlanRouteId
CpswMacPort_InterVlanRouteId
MAC port interVLAN route identifier.
Definition: cpsw_macport.h:219
CPSW_MACPORT_IOCTL_EST_DISABLE_TIMESTAMP
@ CPSW_MACPORT_IOCTL_EST_DISABLE_TIMESTAMP
Disable EST packet timestamping functionality.
Definition: cpsw_macport.h:177
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:316
CpswMacPort_InterVlanRoutingCfg::vlanId
uint32_t vlanId
Definition: cpsw_macport.h:251
CpswMacPort_EstTimestampCfg::macPort
Enet_MacPort macPort
Definition: cpsw_macport.h:439
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:279
CpswMacPort_EstTimestampCfg::priority
uint8_t priority
Definition: cpsw_macport.h:447
CpswMacPort_TsEventCfg::mcastType
uint32_t mcastType
Definition: cpsw_macport.h:387
Enet_CrcType
Enet_CrcType
CRC type.
Definition: enet_types.h:244
CpswMacPort_EstTimestampCfg
EST timestamping configuration parameters.
Definition: cpsw_macport.h:437
CpswMacPort_TsEventCfg::txHostTsEn
bool txHostTsEn
Definition: cpsw_macport.h:367
CpswMacPort_IpTsCfg::ttlNonzeroEn
bool ttlNonzeroEn
Definition: cpsw_macport.h:313
EnetMac_SgmiiMode
EnetMac_SgmiiMode
SGMII mode.
Definition: enet_mod_macport.h:259