AM273x MCU+ SDK  08.06.00
cpsw.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_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 /* ========================================================================== */
88 #define CPSW_PER_PUBLIC_IOCTL(x) (ENET_IOCTL_TYPE_PUBLIC | \
89  ENET_IOCTL_PER_BASE | \
90  ENET_IOCTL_PER_CPSW | \
91  ENET_IOCTL_MIN(x))
92 
94 #if defined(SOC_AM273X) || defined(SOC_AWR294X)
95 #define CPSW_MAC_PORT_NUM (1U)
96 #else
97 #define CPSW_MAC_PORT_NUM (8U)
98 #endif
99 
110 #define CPSW_INTERVLAN_INGRESSPKT_MATCH_PORT (CPSW_ALE_POLICER_MATCH_PORT)
111 
113 #define CPSW_INTERVLAN_INGRESSPKT_MATCH_MACSRC (CPSW_ALE_POLICER_MATCH_MACSRC)
114 
116 #define CPSW_INTERVLAN_INGRESSPKT_MATCH_MACDST (CPSW_ALE_POLICER_MATCH_MACDST)
117 
119 #define CPSW_INTERVLAN_INGRESSPKT_MATCH_ETHERTYPE (CPSW_ALE_POLICER_MATCH_ETHERTYPE)
120 
122 #define CPSW_INTERVLAN_INGRESSPKT_MATCH_IPSRC (CPSW_ALE_POLICER_MATCH_IPSRC)
123 
125 #define CPSW_INTERVLAN_INGRESSPKT_MATCH_IPDST (CPSW_ALE_POLICER_MATCH_IPDST)
126 
130 #define CPSW_INTR_STATS_PEND0 (1U)
131 
133 #define CPSW_INTR_MDIO_PEND (2U)
134 
136 #define CPSW_INTR_EVNT_PEND (3U)
137 
138 /* ========================================================================== */
139 /* Structures and Enums */
140 /* ========================================================================== */
141 
145 typedef enum Cpsw_Ioctl_e
146 {
155 
164 
173 
182 
191 
201 } Cpsw_Ioctl;
202 
206 typedef struct Cpsw_InterVlanRouteIngressPktMatchCfg_s
207 {
211 
216 
221 
226 
231 
233  uint32_t vlanId;
234 
239 
244 
248  uint16_t etherType;
250 
254 typedef struct Cpsw_InterVlanEgressPortCfg_s
255 {
258 
264 
268 typedef struct Cpsw_SetInterVlanRouteUniEgressInArgs_s
269 {
274 
278 
282 typedef struct Cpsw_SetInterVlanRouteUniEgressOutArgs_s
283 {
286 
290 
294 typedef struct Cpsw_ClearInterVlanRouteUniEgressInArgs_s
295 {
300 
303 
307  uint32_t delAleEntryMask;
309 
313 typedef struct Cpsw_SetInterVlanRouteMultiEgressInArgs_s
314 {
316  uint32_t numEgressPorts;
317 
322 
328 
332 typedef struct Cpsw_SetInterVlanRouteMultiEgressOutArgs_s
333 {
336 
340 
344 typedef struct Cpsw_ClearInterVlanRouteMultiEgressInArgs_s
345 {
347  uint32_t numEgressPorts;
348 
353 
358 
362  uint32_t delAleEntryMask;
364 
368 typedef struct Cpsw_SetTxShortIpgCfgInArgs_s
369 {
374 
378 
380  uint32_t numMacPorts;
381 
386 
392 typedef struct Cpsw_TxShortIpgCfg_s
393 {
397 
399  uint32_t numMacPorts;
400 
405 
409 typedef struct Cpsw_VlanCfg_s
410 {
412  bool vlanAware;
413 
416 
418  uint16_t outerVlan;
419 
421  uint16_t innerVlan;
422 } Cpsw_VlanCfg;
423 
427 typedef struct Cpsw_MdioLinkStateChangeInfo_s
428 {
430  uint32_t phyAddr;
431 
435 
438  bool isAlive;
439 
442 
444  bool isLinked;
445 
447 
455  void *appArg);
456 
465  bool isLinkUp,
466  void *appArg);
467 
473 typedef struct Cpsw_Cfg_s
474 {
477 
479  const void *dmaCfg;
480 
483 
487  uint32_t txMtu[ENET_PRI_NUM];
488 
489  // /*! Configuration of the CPSW DMA */
490  // EnetDma_Cfg dmaCfg;
491 
494 
497 
500 
503 
506 
508  uint32_t intrPriority;
509 
512 
515 
519 
522 
528 
531 
542 
543 } Cpsw_Cfg;
544 
545 
546 /* ========================================================================== */
547 /* Global Variables Declarations */
548 /* ========================================================================== */
549 
550 /* None */
551 
552 /* ========================================================================== */
553 /* Function Declarations */
554 /* ========================================================================== */
555 
556 /* None */
557 
558 /* ========================================================================== */
559 /* Deprecated Function Declarations */
560 /* ========================================================================== */
561 
562 /* None */
563 
564 /* ========================================================================== */
565 /* Static Function Definitions */
566 /* ========================================================================== */
567 
568 /* None */
569 
570 #ifdef __cplusplus
571 }
572 #endif
573 
574 #endif /* CPSW_H_ */
575 
Cpsw_InterVlanRouteIngressPktMatchCfg::dstIpInfo
CpswAle_IpAddrClassifierInfo dstIpInfo
Definition: cpsw.h:243
Cpsw_ClearInterVlanRouteMultiEgressInArgs::inPktMatchCfg
Cpsw_InterVlanRouteIngressPktMatchCfg inPktMatchCfg
Definition: cpsw.h:357
CpswAle_IpAddrClassifierInfo
ALE IP address classifier info.
Definition: cpsw_ale.h:1379
CPSW_MAC_PORT_NUM
#define CPSW_MAC_PORT_NUM
Definition: cpsw.h:97
Cpsw_Cfg::cptsCfg
CpswCpts_Cfg cptsCfg
Definition: cpsw.h:499
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:410
Cpsw_Cfg::enableQsgmii1RDC
bool enableQsgmii1RDC
Definition: cpsw.h:530
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:376
Cpsw_SetInterVlanRouteMultiEgressOutArgs::ingressPacketClassifierInfo
CpswAle_PolicerEntryOutArgs ingressPacketClassifierInfo
Definition: cpsw.h:338
cpsw_stats.h
This file contains the type definitions and helper macros for the CPSW Statistics module interface.
Cpsw_SetInterVlanRouteUniEgressOutArgs::ingressPacketClassifierInfo
CpswAle_PolicerEntryOutArgs ingressPacketClassifierInfo
Definition: cpsw.h:288
Cpsw_Ioctl
Cpsw_Ioctl
CPSW peripheral IOCTL commands.
Definition: cpsw.h:146
CpswAle_Cfg
ALE configuration.
Definition: cpsw_ale.h:2024
Cpsw_MdioLinkStateChangeInfo::phyAddr
uint32_t phyAddr
Definition: cpsw.h:430
Cpsw_MdioLinkStateChangeInfo::linkChanged
bool linkChanged
Definition: cpsw.h:441
Cpsw_TxShortIpgCfg
Short IPG configuration for CPSW IP.
Definition: cpsw.h:393
Cpsw_Cfg::mdioLinkStateChangeCbArg
void * mdioLinkStateChangeCbArg
Definition: cpsw.h:514
Cpsw_MdioLinkStateChangeInfo
PHY link status change event information.
Definition: cpsw.h:428
Cpsw_MdioLinkStateChangeCb
void(* Cpsw_MdioLinkStateChangeCb)(Cpsw_MdioLinkStateChangeInfo *info, void *appArg)
CPSW PHY link state change callback function.
Definition: cpsw.h:454
Cpsw_MdioLinkStateChangeInfo::aliveChanged
bool aliveChanged
Definition: cpsw.h:434
Enet_MacPort
Enet_MacPort
MAC port.
Definition: enet_types.h:409
Cpsw_InterVlanEgressPortCfg::egressPort
Enet_MacPort egressPort
Definition: cpsw.h:257
Cpsw_InterVlanRouteIngressPktMatchCfg::srcMacAddrInfo
CpswAle_MacAddrClassifierInfo srcMacAddrInfo
Definition: cpsw.h:225
Cpsw_SetTxShortIpgCfgInArgs::configureGapThresh
bool configureGapThresh
Definition: cpsw.h:373
mdio.h
This file contains the type definitions and helper macros for the MDIO module interface.
Cpsw_Cfg::dmaCfg
const void * dmaCfg
Definition: cpsw.h:479
Cpsw_VlanCfg::vlanSwitch
Enet_VlanTagType vlanSwitch
Definition: cpsw.h:415
CpswMacPort_PortTxShortIpgCfg
MAC port's short gap configuration.
Definition: cpsw_macport.h:207
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:200
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:273
Cpsw_SetTxShortIpgCfgInArgs::ipgTriggerThreshBlkCnt
uint32_t ipgTriggerThreshBlkCnt
Definition: cpsw.h:377
EnetRm_ResCfg
Resource manager configuration parameters.
Definition: enet_rm.h:337
Cpsw_InterVlanRouteIngressPktMatchCfg::packetMatchEnMask
uint32_t packetMatchEnMask
Definition: cpsw.h:210
Cpsw_Cfg::mdioCfg
Mdio_Cfg mdioCfg
Definition: cpsw.h:502
CpswMacPort_InterVlanRoutingCfg
Port interVLAN configuration parameters.
Definition: cpsw_macport.h:243
Cpsw_SetInterVlanRouteUniEgressOutArgs::egressPortRouteId
CpswMacPort_InterVlanRouteId egressPortRouteId
Definition: cpsw.h:285
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:295
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:163
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:190
Cpsw_Cfg
CPSW configuration.
Definition: cpsw.h:474
Cpsw_VlanCfg::innerVlan
uint16_t innerVlan
Definition: cpsw.h:421
CpswCpts_Cfg
CPTS configuration.
Definition: cpsw_cpts.h:579
Cpsw_ClearInterVlanRouteUniEgressInArgs::inPktMatchCfg
Cpsw_InterVlanRouteIngressPktMatchCfg inPktMatchCfg
Definition: cpsw.h:299
Cpsw_InterVlanRouteIngressPktMatchCfg::dstMacAddrInfo
CpswAle_MacAddrClassifierInfo dstMacAddrInfo
Definition: cpsw.h:230
Cpsw_Cfg::intrPriority
uint32_t intrPriority
Definition: cpsw.h:508
Cpsw_VlanCfg::vlanAware
bool vlanAware
Definition: cpsw.h:412
Cpsw_SetInterVlanRouteUniEgressOutArgs
Output args for CPSW_PER_IOCTL_SET_INTERVLAN_ROUTE_UNI_EGRESS command.
Definition: cpsw.h:283
Cpsw_InterVlanRouteIngressPktMatchCfg::vlanId
uint32_t vlanId
Definition: cpsw.h:233
Mdio_Cfg
MDIO module configuration.
Definition: 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:316
Cpsw_Cfg::portLinkStatusChangeCb
Cpsw_PortLinkStatusChangeCb portLinkStatusChangeCb
Definition: cpsw.h:518
Cpsw_TxShortIpgCfg::ipgTriggerThreshBlkCnt
uint32_t ipgTriggerThreshBlkCnt
Definition: cpsw.h:396
Cpsw_Cfg::escalatePriorityLoadVal
uint32_t escalatePriorityLoadVal
Definition: cpsw.h:476
Cpsw_SetTxShortIpgCfgInArgs
Input args for CPSW_PER_IOCTL_SET_SHORT_IPG_CFG.
Definition: cpsw.h:369
Cpsw_SetInterVlanRouteMultiEgressInArgs
Input args for CPSW_PER_IOCTL_SET_INTERVLAN_ROUTE_MULTI_EGRESS command.
Definition: cpsw.h:314
Cpsw_SetInterVlanRouteUniEgressInArgs
Input args for CPSW_PER_IOCTL_SET_INTERVLAN_ROUTE_UNI_EGRESS command.
Definition: cpsw.h:269
Cpsw_ClearInterVlanRouteMultiEgressInArgs
Input args for CPSW_PER_IOCTL_CLEAR_INTERVLAN_ROUTE_MULTI_EGRESS command.
Definition: cpsw.h:345
Cpsw_Cfg::hostPortCfg
CpswHostPort_Cfg hostPortCfg
Definition: cpsw.h:493
Cpsw_InterVlanEgressPortCfg
InterVLAN egress port configuration.
Definition: cpsw.h:255
Cpsw_Cfg::enableQsgmii0RDC
bool enableQsgmii0RDC
Definition: cpsw.h:527
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:172
Cpsw_Cfg::portLinkStatusChangeCbArg
void * portLinkStatusChangeCbArg
Definition: cpsw.h:521
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:362
Cpsw_SetInterVlanRouteMultiEgressOutArgs
Output args for CPSW_PER_IOCTL_SET_INTERVLAN_ROUTE_MULTI_EGRESS command.
Definition: cpsw.h:333
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:326
Cpsw_InterVlanRouteIngressPktMatchCfg
InterVLAN route ingress packet match criteria configuration.
Definition: cpsw.h:207
Cpsw_Cfg::disablePhyDriver
bool disablePhyDriver
Definition: cpsw.h:541
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:399
CpswAle_PolicerEntryOutArgs
Output args for CPSW_ALE_IOCTL_GET_POLICER, CPSW_ALE_IOCTL_SET_POLICER_THREADCFG, CPSW_ALE_IOCTL_BLOC...
Definition: cpsw_ale.h:1530
CPSW_PER_PUBLIC_IOCTL
#define CPSW_PER_PUBLIC_IOCTL(x)
Helper macro to create CPSW IOCTL commands.
Definition: cpsw.h:88
Cpsw_PortLinkStatusChangeCb
void(* Cpsw_PortLinkStatusChangeCb)(Enet_MacPort macPort, bool isLinkUp, void *appArg)
CPSW port link status change callback function.
Definition: cpsw.h:464
Cpsw_InterVlanRouteIngressPktMatchCfg::etherType
uint16_t etherType
Definition: cpsw.h:248
Cpsw_VlanCfg::outerVlan
uint16_t outerVlan
Definition: cpsw.h:418
Cpsw_InterVlanRouteIngressPktMatchCfg::ingressPort
Enet_MacPort ingressPort
Definition: cpsw.h:220
Cpsw_SetInterVlanRouteMultiEgressOutArgs::egressPortRouteId
CpswMacPort_InterVlanRouteId egressPortRouteId
Definition: cpsw.h:335
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:154
CpswAle_MacAddrClassifierInfo
ALE classifier/policer match parameters for source or destination MAC address.
Definition: cpsw_ale.h:1179
Cpsw_SetTxShortIpgCfgInArgs::numMacPorts
uint32_t numMacPorts
Definition: cpsw.h:380
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:219
Cpsw_Cfg::vlanCfg
Cpsw_VlanCfg vlanCfg
Definition: cpsw.h:482
Cpsw_ClearInterVlanRouteUniEgressInArgs::delAleEntryMask
uint32_t delAleEntryMask
Definition: cpsw.h:307
Cpsw_MdioLinkStateChangeInfo::isAlive
bool isAlive
Definition: cpsw.h:438
Cpsw_InterVlanRouteIngressPktMatchCfg::srcIpInfo
CpswAle_IpAddrClassifierInfo srcIpInfo
Definition: cpsw.h:238
Cpsw_InterVlanRouteIngressPktMatchCfg::ttlCheckEn
bool ttlCheckEn
Definition: cpsw.h:215
Cpsw_InterVlanEgressPortCfg::outPktModCfg
CpswMacPort_InterVlanRoutingCfg outPktModCfg
Definition: cpsw.h:262
Cpsw_Cfg::mdioLinkStateChangeCb
Cpsw_MdioLinkStateChangeCb mdioLinkStateChangeCb
Definition: cpsw.h:511
Cpsw_Cfg::resCfg
EnetRm_ResCfg resCfg
Definition: cpsw.h:505
Cpsw_SetInterVlanRouteUniEgressInArgs::egressCfg
Cpsw_InterVlanEgressPortCfg egressCfg
Definition: cpsw.h:276
Cpsw_ClearInterVlanRouteUniEgressInArgs::egressCfg
Cpsw_InterVlanEgressPortCfg egressCfg
Definition: cpsw.h:302
Cpsw_Cfg::aleCfg
CpswAle_Cfg aleCfg
Definition: cpsw.h:496
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:181
Cpsw_ClearInterVlanRouteMultiEgressInArgs::numEgressPorts
uint32_t numEgressPorts
Definition: cpsw.h:347
Cpsw_MdioLinkStateChangeInfo::isLinked
bool isLinked
Definition: cpsw.h:444