AM261x MCU+ SDK  11.00.00
cpsw.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Texas Instruments Incorporated 2020-23
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_H_
63 #define CPSW_H_
64 
65 /* ========================================================================== */
66 /* Include Files */
67 /* ========================================================================== */
68 
69 #include <stdint.h>
70 #include <include/mod/cpsw_ale.h>
71 #include <include/mod/cpsw_cpts.h>
74 #include <include/mod/mdio.h>
75 #include <include/mod/cpsw_stats.h>
77 #include <include/core/enet_rm.h>
78 #include <include/core/enet_dma.h>
79 
80 #ifdef __cplusplus
81 extern "C" {
82 #endif
83 
84 /* ========================================================================== */
85 /* Macros */
86 /* ========================================================================== */
87 
89 #define CPSW_COMMON_TX_MTU_DEFAULT (2024U)
90 
99 #define CPSW_ESC_PRI_LD_VAL (2U)
100 
102 #define CPSW_PER_PUBLIC_IOCTL(x) (ENET_IOCTL_TYPE_PUBLIC | \
103  ENET_IOCTL_PER_BASE | \
104  ENET_IOCTL_PER_CPSW | \
105  ENET_IOCTL_MIN(x))
106 
108 #if defined(SOC_AM273X) || defined(SOC_AWR294X) || defined (SOC_AWR2544)
109 #define CPSW_MAC_PORT_NUM (1U)
110 #else
111 #define CPSW_MAC_PORT_NUM (8U)
112 #endif
113 
124 #define CPSW_INTERVLAN_INGRESSPKT_MATCH_PORT (CPSW_ALE_POLICER_MATCH_PORT)
125 
127 #define CPSW_INTERVLAN_INGRESSPKT_MATCH_MACSRC (CPSW_ALE_POLICER_MATCH_MACSRC)
128 
130 #define CPSW_INTERVLAN_INGRESSPKT_MATCH_MACDST (CPSW_ALE_POLICER_MATCH_MACDST)
131 
133 #define CPSW_INTERVLAN_INGRESSPKT_MATCH_ETHERTYPE (CPSW_ALE_POLICER_MATCH_ETHERTYPE)
134 
136 #define CPSW_INTERVLAN_INGRESSPKT_MATCH_IPSRC (CPSW_ALE_POLICER_MATCH_IPSRC)
137 
139 #define CPSW_INTERVLAN_INGRESSPKT_MATCH_IPDST (CPSW_ALE_POLICER_MATCH_IPDST)
140 
144 #define CPSW_INTR_STATS_PEND0 (1U)
145 
147 #define CPSW_INTR_MDIO_PEND (2U)
148 
150 #define CPSW_INTR_EVNT_PEND (3U)
151 
152 /* ========================================================================== */
153 /* Structures and Enums */
154 /* ========================================================================== */
155 
159 typedef enum Cpsw_Ioctl_e
160 {
169 
178 
187 
196 
205 
215 } Cpsw_Ioctl;
216 
220 typedef struct Cpsw_InterVlanRouteIngressPktMatchCfg_s
221 {
225 
230 
235 
240 
245 
247  uint32_t vlanId;
248 
253 
258 
262  uint16_t etherType;
264 
268 typedef struct Cpsw_InterVlanEgressPortCfg_s
269 {
272 
278 
282 typedef struct Cpsw_SetInterVlanRouteUniEgressInArgs_s
283 {
288 
292 
296 typedef struct Cpsw_SetInterVlanRouteUniEgressOutArgs_s
297 {
300 
304 
308 typedef struct Cpsw_ClearInterVlanRouteUniEgressInArgs_s
309 {
314 
317 
321  uint32_t delAleEntryMask;
323 
327 typedef struct Cpsw_SetInterVlanRouteMultiEgressInArgs_s
328 {
330  uint32_t numEgressPorts;
331 
336 
342 
346 typedef struct Cpsw_SetInterVlanRouteMultiEgressOutArgs_s
347 {
350 
354 
358 typedef struct Cpsw_ClearInterVlanRouteMultiEgressInArgs_s
359 {
361  uint32_t numEgressPorts;
362 
367 
372 
376  uint32_t delAleEntryMask;
378 
382 typedef struct Cpsw_SetTxShortIpgCfgInArgs_s
383 {
388 
392 
394  uint32_t numMacPorts;
395 
400 
406 typedef struct Cpsw_TxShortIpgCfg_s
407 {
411 
413  uint32_t numMacPorts;
414 
419 
423 typedef struct Cpsw_VlanCfg_s
424 {
426  bool vlanAware;
427 
430 
432  uint16_t outerVlan;
433 
435  uint16_t innerVlan;
436 } Cpsw_VlanCfg;
437 
441 typedef struct Cpsw_MdioLinkStateChangeInfo_s
442 {
444  uint32_t phyAddr;
445 
449 
452  bool isAlive;
453 
456 
458  bool isLinked;
459 
461 
469  void *appArg);
470 
479  bool isLinkUp,
480  void *appArg);
481 
487 typedef struct Cpsw_Cfg_s
488 {
491 
494 
497 
501  uint32_t txMtu[ENET_PRI_NUM];
502 
505 
508 
511 
514 
517 
519  uint32_t intrPriority;
520 
523 
526 
530 
533 
539 
542 
553 } Cpsw_Cfg;
554 
555 
556 /* ========================================================================== */
557 /* Global Variables Declarations */
558 /* ========================================================================== */
559 
560 /* None */
561 
562 /* ========================================================================== */
563 /* Function Declarations */
564 /* ========================================================================== */
565 
566 /* None */
567 
568 /* ========================================================================== */
569 /* Deprecated Function Declarations */
570 /* ========================================================================== */
571 
572 /* None */
573 
574 /* ========================================================================== */
575 /* Static Function Definitions */
576 /* ========================================================================== */
577 
578 /* None */
579 
580 #ifdef __cplusplus
581 }
582 #endif
583 
584 #endif /* CPSW_H_ */
585 
Cpsw_InterVlanRouteIngressPktMatchCfg::dstIpInfo
CpswAle_IpAddrClassifierInfo dstIpInfo
Definition: cpsw.h:257
Cpsw_ClearInterVlanRouteMultiEgressInArgs::inPktMatchCfg
Cpsw_InterVlanRouteIngressPktMatchCfg inPktMatchCfg
Definition: cpsw.h:371
CpswAle_IpAddrClassifierInfo
ALE IP address classifier info.
Definition: cpsw_ale.h:1421
CPSW_MAC_PORT_NUM
#define CPSW_MAC_PORT_NUM
Definition: cpsw.h:111
Cpsw_Cfg::cptsCfg
CpswCpts_Cfg cptsCfg
Definition: cpsw.h:510
CPSW_ALE_NUM_MAC_PORTS
#define CPSW_ALE_NUM_MAC_PORTS
Number of external ports in the subsystem.
Definition: cpsw_ale.h:96
enet_dma.h
This file contains the type definitions and helper macros for the Enet Data Path (DMA) interface.
Cpsw_VlanCfg
CPSW-level VLAN configuration.
Definition: cpsw.h:424
Cpsw_Cfg::enableQsgmii1RDC
bool enableQsgmii1RDC
Definition: cpsw.h:541
cpsw_ale.h
This file contains the type definitions and helper macros for the CPSW Address Lookup Engine (ALE) mo...
Enet_VlanTagType
Enet_VlanTagType
Double tagging VLAN type.
Definition: enet_types.h:379
Cpsw_SetInterVlanRouteMultiEgressOutArgs::ingressPacketClassifierInfo
CpswAle_PolicerEntryOutArgs ingressPacketClassifierInfo
Definition: cpsw.h:352
EnetDma_Cfg
Config structure for Enet CPDMA.
Definition: enet_cpdma.h:433
cpsw_stats.h
This file contains the type definitions and helper macros for the CPSW Statistics module interface.
mdio.h
This file contains the type definitions and helper macros for the MDIO module interface.
Cpsw_SetInterVlanRouteUniEgressOutArgs::ingressPacketClassifierInfo
CpswAle_PolicerEntryOutArgs ingressPacketClassifierInfo
Definition: cpsw.h:302
Cpsw_Ioctl
Cpsw_Ioctl
CPSW peripheral IOCTL commands.
Definition: cpsw.h:160
CpswAle_Cfg
ALE configuration.
Definition: cpsw_ale.h:2090
Cpsw_MdioLinkStateChangeInfo::phyAddr
uint32_t phyAddr
Definition: cpsw.h:444
Cpsw_MdioLinkStateChangeInfo::linkChanged
bool linkChanged
Definition: cpsw.h:455
Cpsw_TxShortIpgCfg
Short IPG configuration for CPSW IP.
Definition: cpsw.h:407
Cpsw_Cfg::mdioLinkStateChangeCbArg
void * mdioLinkStateChangeCbArg
Definition: cpsw.h:525
Cpsw_MdioLinkStateChangeInfo
PHY link status change event information.
Definition: cpsw.h:442
Cpsw_MdioLinkStateChangeCb
void(* Cpsw_MdioLinkStateChangeCb)(Cpsw_MdioLinkStateChangeInfo *info, void *appArg)
CPSW PHY link state change callback function.
Definition: cpsw.h:468
Cpsw_MdioLinkStateChangeInfo::aliveChanged
bool aliveChanged
Definition: cpsw.h:448
Enet_MacPort
Enet_MacPort
MAC port.
Definition: enet_types.h:412
Cpsw_InterVlanEgressPortCfg::egressPort
Enet_MacPort egressPort
Definition: cpsw.h:271
Cpsw_InterVlanRouteIngressPktMatchCfg::srcMacAddrInfo
CpswAle_MacAddrClassifierInfo srcMacAddrInfo
Definition: cpsw.h:239
Cpsw_SetTxShortIpgCfgInArgs::configureGapThresh
bool configureGapThresh
Definition: cpsw.h:387
Cpsw_VlanCfg::vlanSwitch
Enet_VlanTagType vlanSwitch
Definition: cpsw.h:429
CpswMacPort_PortTxShortIpgCfg
MAC port's short gap configuration.
Definition: cpsw_macport.h:222
CPSW_PER_IOCTL_GET_SHORT_IPG_CFG
@ CPSW_PER_IOCTL_GET_SHORT_IPG_CFG
Get the current short inter-packet gap (IPG) configuration for all open MAC ports.
Definition: cpsw.h:214
enet_mod_phy.h
This file contains the type definitions and helper macros for the Ethernet PHY interface.
Cpsw_SetInterVlanRouteUniEgressInArgs::inPktMatchCfg
Cpsw_InterVlanRouteIngressPktMatchCfg inPktMatchCfg
Definition: cpsw.h:287
Cpsw_SetTxShortIpgCfgInArgs::ipgTriggerThreshBlkCnt
uint32_t ipgTriggerThreshBlkCnt
Definition: cpsw.h:391
EnetRm_ResCfg
Resource manager configuration parameters.
Definition: enet_rm.h:402
Cpsw_InterVlanRouteIngressPktMatchCfg::packetMatchEnMask
uint32_t packetMatchEnMask
Definition: cpsw.h:224
Cpsw_Cfg::mdioCfg
Mdio_Cfg mdioCfg
Definition: cpsw.h:513
CpswMacPort_InterVlanRoutingCfg
Port interVLAN configuration parameters.
Definition: cpsw_macport.h:258
Cpsw_SetInterVlanRouteUniEgressOutArgs::egressPortRouteId
CpswMacPort_InterVlanRouteId egressPortRouteId
Definition: cpsw.h:299
cpsw_cpts.h
This file contains private type definitions and helper macros for the CPSW CPTS module.
Cpsw_ClearInterVlanRouteUniEgressInArgs
Input args for CPSW_PER_IOCTL_CLEAR_INTERVLAN_ROUTE_UNI_EGRESS command.
Definition: cpsw.h:309
CPSW_PER_IOCTL_CLEAR_INTERVLAN_ROUTE_UNI_EGRESS
@ CPSW_PER_IOCTL_CLEAR_INTERVLAN_ROUTE_UNI_EGRESS
Setup interVLAN route for a single egress port.
Definition: cpsw.h:177
CPSW_PER_IOCTL_SET_SHORT_IPG_CFG
@ CPSW_PER_IOCTL_SET_SHORT_IPG_CFG
Configure short inter-packet gap (IPG) for specific MAC ports.
Definition: cpsw.h:204
Cpsw_Cfg::dmaCfg
const EnetDma_Cfg * dmaCfg
Definition: cpsw.h:493
Cpsw_Cfg
CPSW configuration.
Definition: cpsw.h:488
Cpsw_VlanCfg::innerVlan
uint16_t innerVlan
Definition: cpsw.h:435
CpswCpts_Cfg
CPTS configuration.
Definition: cpsw_cpts.h:591
Cpsw_ClearInterVlanRouteUniEgressInArgs::inPktMatchCfg
Cpsw_InterVlanRouteIngressPktMatchCfg inPktMatchCfg
Definition: cpsw.h:313
Cpsw_InterVlanRouteIngressPktMatchCfg::dstMacAddrInfo
CpswAle_MacAddrClassifierInfo dstMacAddrInfo
Definition: cpsw.h:244
Cpsw_Cfg::intrPriority
uint32_t intrPriority
Definition: cpsw.h:519
Cpsw_VlanCfg::vlanAware
bool vlanAware
Definition: cpsw.h:426
Cpsw_SetInterVlanRouteUniEgressOutArgs
Output args for CPSW_PER_IOCTL_SET_INTERVLAN_ROUTE_UNI_EGRESS command.
Definition: cpsw.h:297
Cpsw_InterVlanRouteIngressPktMatchCfg::vlanId
uint32_t vlanId
Definition: cpsw.h:247
Mdio_Cfg
MDIO module configuration.
Definition: networking/enet/core/include/mod/mdio.h:108
ENET_PRI_NUM
#define ENET_PRI_NUM
Packet priority.
Definition: enet_types.h:165
Cpsw_SetInterVlanRouteMultiEgressInArgs::numEgressPorts
uint32_t numEgressPorts
Definition: cpsw.h:330
Cpsw_Cfg::portLinkStatusChangeCb
Cpsw_PortLinkStatusChangeCb portLinkStatusChangeCb
Definition: cpsw.h:529
Cpsw_TxShortIpgCfg::ipgTriggerThreshBlkCnt
uint32_t ipgTriggerThreshBlkCnt
Definition: cpsw.h:410
Cpsw_Cfg::escalatePriorityLoadVal
uint32_t escalatePriorityLoadVal
Definition: cpsw.h:490
Cpsw_SetTxShortIpgCfgInArgs
Input args for CPSW_PER_IOCTL_SET_SHORT_IPG_CFG.
Definition: cpsw.h:383
Cpsw_SetInterVlanRouteMultiEgressInArgs
Input args for CPSW_PER_IOCTL_SET_INTERVLAN_ROUTE_MULTI_EGRESS command.
Definition: cpsw.h:328
Cpsw_SetInterVlanRouteUniEgressInArgs
Input args for CPSW_PER_IOCTL_SET_INTERVLAN_ROUTE_UNI_EGRESS command.
Definition: cpsw.h:283
Cpsw_ClearInterVlanRouteMultiEgressInArgs
Input args for CPSW_PER_IOCTL_CLEAR_INTERVLAN_ROUTE_MULTI_EGRESS command.
Definition: cpsw.h:359
Cpsw_Cfg::hostPortCfg
CpswHostPort_Cfg hostPortCfg
Definition: cpsw.h:504
Cpsw_InterVlanEgressPortCfg
InterVLAN egress port configuration.
Definition: cpsw.h:269
Cpsw_Cfg::enableQsgmii0RDC
bool enableQsgmii0RDC
Definition: cpsw.h:538
CPSW_PER_IOCTL_SET_INTERVLAN_ROUTE_MULTI_EGRESS
@ CPSW_PER_IOCTL_SET_INTERVLAN_ROUTE_MULTI_EGRESS
Setup interVLAN route for a multiple egress port.
Definition: cpsw.h:186
Cpsw_Cfg::portLinkStatusChangeCbArg
void * portLinkStatusChangeCbArg
Definition: cpsw.h:532
cpsw_macport.h
This file contains the type definitions and helper macros for the CPSW MAC port module interface.
Cpsw_ClearInterVlanRouteMultiEgressInArgs::delAleEntryMask
uint32_t delAleEntryMask
Definition: cpsw.h:376
Cpsw_SetInterVlanRouteMultiEgressOutArgs
Output args for CPSW_PER_IOCTL_SET_INTERVLAN_ROUTE_MULTI_EGRESS command.
Definition: cpsw.h:347
enet_rm.h
This file contains the type definitions and helper macros for the Enet Resource Manager module.
Cpsw_SetInterVlanRouteMultiEgressInArgs::inPktMatchCfg
Cpsw_InterVlanRouteIngressPktMatchCfg inPktMatchCfg
Definition: cpsw.h:340
Cpsw_InterVlanRouteIngressPktMatchCfg
InterVLAN route ingress packet match criteria configuration.
Definition: cpsw.h:221
Cpsw_Cfg::disablePhyDriver
bool disablePhyDriver
Definition: cpsw.h:552
cpsw_hostport.h
This file contains the type definitions and helper macros for the CPSW host port module.
Cpsw_TxShortIpgCfg::numMacPorts
uint32_t numMacPorts
Definition: cpsw.h:413
CpswAle_PolicerEntryOutArgs
Output args for CPSW_ALE_IOCTL_GET_POLICER, CPSW_ALE_IOCTL_SET_POLICER_THREADCFG, CPSW_ALE_IOCTL_BLOC...
Definition: cpsw_ale.h:1596
CPSW_PER_PUBLIC_IOCTL
#define CPSW_PER_PUBLIC_IOCTL(x)
Helper macro to create CPSW IOCTL commands.
Definition: cpsw.h:102
Cpsw_PortLinkStatusChangeCb
void(* Cpsw_PortLinkStatusChangeCb)(Enet_MacPort macPort, bool isLinkUp, void *appArg)
CPSW port link status change callback function.
Definition: cpsw.h:478
Cpsw_InterVlanRouteIngressPktMatchCfg::etherType
uint16_t etherType
Definition: cpsw.h:262
Cpsw_VlanCfg::outerVlan
uint16_t outerVlan
Definition: cpsw.h:432
Cpsw_InterVlanRouteIngressPktMatchCfg::ingressPort
Enet_MacPort ingressPort
Definition: cpsw.h:234
Cpsw_SetInterVlanRouteMultiEgressOutArgs::egressPortRouteId
CpswMacPort_InterVlanRouteId egressPortRouteId
Definition: cpsw.h:349
CPSW_PER_IOCTL_SET_INTERVLAN_ROUTE_UNI_EGRESS
@ CPSW_PER_IOCTL_SET_INTERVLAN_ROUTE_UNI_EGRESS
Setup interVLAN route for a single egress port.
Definition: cpsw.h:168
CpswAle_MacAddrClassifierInfo
ALE classifier/policer match parameters for source or destination MAC address.
Definition: cpsw_ale.h:1221
Cpsw_SetTxShortIpgCfgInArgs::numMacPorts
uint32_t numMacPorts
Definition: cpsw.h:394
CpswHostPort_Cfg
Host port module configuration parameters.
Definition: cpsw_hostport.h:138
CpswMacPort_InterVlanRouteId
CpswMacPort_InterVlanRouteId
MAC port interVLAN route identifier.
Definition: cpsw_macport.h:234
Cpsw_Cfg::vlanCfg
Cpsw_VlanCfg vlanCfg
Definition: cpsw.h:496
Cpsw_ClearInterVlanRouteUniEgressInArgs::delAleEntryMask
uint32_t delAleEntryMask
Definition: cpsw.h:321
Cpsw_MdioLinkStateChangeInfo::isAlive
bool isAlive
Definition: cpsw.h:452
Cpsw_InterVlanRouteIngressPktMatchCfg::srcIpInfo
CpswAle_IpAddrClassifierInfo srcIpInfo
Definition: cpsw.h:252
Cpsw_InterVlanRouteIngressPktMatchCfg::ttlCheckEn
bool ttlCheckEn
Definition: cpsw.h:229
Cpsw_InterVlanEgressPortCfg::outPktModCfg
CpswMacPort_InterVlanRoutingCfg outPktModCfg
Definition: cpsw.h:276
Cpsw_Cfg::mdioLinkStateChangeCb
Cpsw_MdioLinkStateChangeCb mdioLinkStateChangeCb
Definition: cpsw.h:522
Cpsw_Cfg::resCfg
EnetRm_ResCfg resCfg
Definition: cpsw.h:516
Cpsw_SetInterVlanRouteUniEgressInArgs::egressCfg
Cpsw_InterVlanEgressPortCfg egressCfg
Definition: cpsw.h:290
Cpsw_ClearInterVlanRouteUniEgressInArgs::egressCfg
Cpsw_InterVlanEgressPortCfg egressCfg
Definition: cpsw.h:316
Cpsw_Cfg::aleCfg
CpswAle_Cfg aleCfg
Definition: cpsw.h:507
CPSW_PER_IOCTL_CLEAR_INTERVLAN_ROUTE_MULTI_EGRESS
@ CPSW_PER_IOCTL_CLEAR_INTERVLAN_ROUTE_MULTI_EGRESS
Clear interVLAN route for a multiple egress port route.
Definition: cpsw.h:195
Cpsw_ClearInterVlanRouteMultiEgressInArgs::numEgressPorts
uint32_t numEgressPorts
Definition: cpsw.h:361
Cpsw_MdioLinkStateChangeInfo::isLinked
bool isLinked
Definition: cpsw.h:458