1
1
/*
2
- * Copyright 2021-2024 NXP
2
+ * Copyright 2021-2025 NXP
3
3
*
4
4
* SPDX-License-Identifier: BSD-3-Clause
5
5
*/
15
15
16
16
/*! @name Defines some Ethernet parameters. */
17
17
/*@{*/
18
- #define NETC_ENETC_TXFRAME_LEN_MAX (9600U) /*!< The Maximum length of frame length. */
19
- #define NETC_ENETC_TXFRAME_LEN_MIN (16U) /*!< The Minimum length of frame length. */
18
+ #define NETC_ENETC_TXFRAME_LEN_MAX (9600U) /*!< The Maximum length of frame length. */
19
+ #define NETC_ENETC_TXFRAME_LEN_MIN (16U) /*!< The Minimum length of frame length. */
20
20
/*@}*/
21
21
22
22
/*! @brief Mask the cache management code if cache control is disabled. */
@@ -188,12 +188,14 @@ static status_t EP_DescriptorInit(ep_handle_t *handle, const ep_config_t *config
188
188
uint8_t idxStart = 0U ;
189
189
uint8_t ring ;
190
190
191
+ #if !(defined(FSL_FEATURE_NETC_HAS_SWITCH_TAG ) && FSL_FEATURE_NETC_HAS_SWITCH_TAG )
191
192
/* Setup Tx/Rx buffer descriptor rings. */
192
193
if (NETC_EnetcHasManagement (handle -> hw .base ) && (getSiNum (handle -> cfg .si ) == 0U ))
193
194
{
194
195
/* For management ENETC, the SI 0 hardware Tx ring index 0 has been keep for direct switch enqueue feature */
195
196
idxStart = 1 ;
196
197
}
198
+ #endif
197
199
for (ring = 0 ; ring < config -> siConfig .txRingUse ; ring ++ )
198
200
{
199
201
if (NETC_SIConfigTxBDR (handle -> hw .si , ring + idxStart , & bdrConfig -> txBdrConfig [ring ]) != kStatus_Success )
@@ -332,8 +334,9 @@ static status_t EP_MSIXSetEntryTable(ep_handle_t *handle, const ep_config_t *con
332
334
return result ;
333
335
}
334
336
335
- msixNum = (uint8_t )(
336
- ((handle -> hw .si -> SIPCAPR1 & ENETC_SI_SIPCAPR1_NUM_MSIX_MASK ) >> ENETC_SI_SIPCAPR1_NUM_MSIX_SHIFT ) + 1U );
337
+ msixNum =
338
+ (uint8_t )(((handle -> hw .si -> SIPCAPR1 & ENETC_SI_SIPCAPR1_NUM_MSIX_MASK ) >> ENETC_SI_SIPCAPR1_NUM_MSIX_SHIFT ) +
339
+ 1U );
337
340
338
341
/* Entry > 0, enable MSIX. */
339
342
if (config -> entryNum != 0U )
@@ -423,27 +426,28 @@ status_t EP_GetDefaultConfig(ep_config_t *config)
423
426
#if (defined(FSL_FEATURE_NETC_HAS_PORT_FCSEA ) && FSL_FEATURE_NETC_HAS_PORT_FCSEA )
424
427
config -> port .common .stompFcs = true;
425
428
#endif
426
- config -> port .common .rxPpduBco = 20U ;
427
- config -> port .common .txPpduBco = 20U ;
428
- config -> port .common .timeGate .holdSkew = 64 ;
429
- config -> port .common .parser .l2PloadCount = 24 ;
430
- config -> port .common .parser .l3PayloadCount = 24 ;
431
- config -> port .common .parser .enableL3Parser = true;
432
- config -> port .common .parser .l4PayloadCount = 24 ;
433
- config -> port .common .parser .enableL4Parser = true;
434
- config -> port .ethMac .enableRevMii = false;
435
- config -> port .ethMac .preemptMode = kNETC_PreemptDisable ;
436
- config -> port .ethMac .enMergeVerify = false;
437
- config -> port .ethMac .mergeVerifyTime = 10U ;
438
- config -> port .ethMac .txTsSelect = kNETC_SyncTime ;
439
- config -> port .ethMac .enTxPad = true;
440
- config -> port .ethMac .rxMinFrameSize = 64U ;
441
- config -> port .ethMac .rxMaxFrameSize = 0x600U ;
442
- config -> port .ethMac .maxBackPressOn = 3036U ;
443
- config -> port .ethMac .minBackPressOff = 20U ;
444
- config -> port .enPseudoMacTxPad = true;
445
- config -> psfpCfg .isiPortConfig .defaultISEID = 0xFFFFU ;
446
- config -> siConfig .ringPerBdrGroup = 0x1U ;
429
+ config -> port .common .rxPpduBco = 20U ;
430
+ config -> port .common .txPpduBco = 20U ;
431
+ config -> port .common .timeGate .holdSkew = 64 ;
432
+ config -> port .common .parser .l2PloadCount = 24 ;
433
+ config -> port .common .parser .l3PayloadCount = 24 ;
434
+ config -> port .common .parser .enableL3Parser = true;
435
+ config -> port .common .parser .l4PayloadCount = 24 ;
436
+ config -> port .common .parser .enableL4Parser = true;
437
+ config -> port .ethMac .enableRevMii = false;
438
+ config -> port .ethMac .txTsSelect = kNETC_SyncTime ;
439
+ config -> port .ethMac .enTxPad = true;
440
+ config -> port .ethMac .rxMinFrameSize = 64U ;
441
+ config -> port .ethMac .rxMaxFrameSize = 0x600U ;
442
+ config -> port .ethMac .maxBackPressOn = 3036U ;
443
+ config -> port .ethMac .minBackPressOff = 20U ;
444
+ config -> port .ethMac .PreemptionConfig .preemptMode = kNETC_PreemptDisable ;
445
+ config -> port .ethMac .PreemptionConfig .enMergeVerify = false;
446
+ config -> port .ethMac .PreemptionConfig .mergeVerifyTime = 10U ;
447
+ config -> port .ethMac .PreemptionConfig .raf_size = kNETC_RafSize64 ;
448
+ config -> port .enPseudoMacTxPad = true;
449
+ config -> psfpCfg .isiPortConfig .defaultISEID = 0xFFFFU ;
450
+ config -> siConfig .ringPerBdrGroup = 0x1U ;
447
451
for (uint8_t i = 0U ; i < 8U ; i ++ )
448
452
{
449
453
config -> txTcCfg [i ].enTcGate = true;
@@ -668,9 +672,9 @@ status_t EP_Init(ep_handle_t *handle, uint8_t *macAddr, const ep_config_t *confi
668
672
return result ;
669
673
}
670
674
671
- if (siNum == 0U )
675
+ if (siNum == 0U && config -> preinitVsi != NULL )
672
676
{
673
- result = NETC_SocPreInitVsi (& handle -> hw , config -> si );
677
+ result = config -> preinitVsi (& handle -> hw , config -> si );
674
678
}
675
679
return result ;
676
680
}
@@ -718,9 +722,10 @@ status_t EP_Down(ep_handle_t *handle)
718
722
NETC_EnetcEnableSI (handle -> hw .base , getSiNum (handle -> cfg .si ), false);
719
723
NETC_SIEnable (handle -> hw .si , false);
720
724
#if defined(FSL_FEATURE_NETC_HAS_ERRATA_051936 ) && FSL_FEATURE_NETC_HAS_ERRATA_051936
721
- /* ERRATA051936: MAC Tx FIFO status may not report empty after FLR when operating in RGMII half duplex mode. In some cases, the transmitter
722
- may become inoperable and not be able to recover from FLR requiring a full reset instead. The issue can occur when FLR is triggered around
723
- the time MAC Tx has started backing off due to a half duplex collision detection. */
725
+ /* ERRATA051936: MAC Tx FIFO status may not report empty after FLR when operating in RGMII half duplex mode. In some
726
+ cases, the transmitter may become inoperable and not be able to recover from FLR requiring a full reset instead.
727
+ The issue can occur when FLR is triggered around the time MAC Tx has started backing off due to a half duplex
728
+ collision detection. */
724
729
handle -> hw .portGroup .eth -> PM0_IF_MODE &= ~NETC_ETH_LINK_PM0_IF_MODE_HD_MASK ;
725
730
handle -> hw .portGroup .eth -> PM1_IF_MODE &= ~NETC_ETH_LINK_PM0_IF_MODE_HD_MASK ;
726
731
#endif
@@ -759,12 +764,12 @@ status_t EP_SendFrameCommon(ep_handle_t *handle,
759
764
status_t result = kStatus_Success ;
760
765
netc_buffer_struct_t * txBuff = frame -> buffArray ;
761
766
uint32_t totBdNum = frame -> length ;
762
- uint16_t frameLen = 0 ;
767
+ uint32_t frameLen = 0 ;
763
768
bool isExtEnable = (bool )txDesc [0 ].standard .isExtended ;
764
- uint32_t address ;
765
769
netc_tx_bd_t * txDesTemp = NULL ;
770
+ uint32_t address ;
766
771
767
- /* Check the frame length . */
772
+ /* The first descriptor in a chain must not have a BUFF_LEN that is less than 16 bytes . */
768
773
if ((frame -> buffArray [0 ].length < NETC_ENETC_TXFRAME_LEN_MIN ) || (frame -> length == 0U ))
769
774
{
770
775
result = kStatus_NETC_TxFrameOverLen ;
@@ -787,7 +792,7 @@ status_t EP_SendFrameCommon(ep_handle_t *handle,
787
792
}
788
793
789
794
/* Check the frame total length. */
790
- if (( frameLen > NETC_ENETC_TXFRAME_LEN_MAX ) || ( frameLen < NETC_ENETC_TXFRAME_LEN_MIN ) )
795
+ if (frameLen > NETC_ENETC_TXFRAME_LEN_MAX )
791
796
{
792
797
result = kStatus_NETC_TxFrameOverLen ;
793
798
}
@@ -825,6 +830,7 @@ status_t EP_SendFrameCommon(ep_handle_t *handle,
825
830
{
826
831
/* Update latest Tx dirty frame info. */
827
832
txBdRing -> dirtyBase [txBdRing -> producerIndex ].context = context ;
833
+ #if !(defined(FSL_FEATURE_NETC_HAS_SWITCH_TAG ) && FSL_FEATURE_NETC_HAS_SWITCH_TAG )
828
834
if (0U != (txDesc [0 ].standard .flags & NETC_SI_TXDESCRIP_RD_TSR_MASK ))
829
835
{
830
836
txBdRing -> dirtyBase [txBdRing -> producerIndex ].isTxTsIdAvail = true;
@@ -833,6 +839,7 @@ status_t EP_SendFrameCommon(ep_handle_t *handle,
833
839
{
834
840
txBdRing -> dirtyBase [txBdRing -> producerIndex ].isTxTsIdAvail = false;
835
841
}
842
+ #endif
836
843
837
844
if (isExtEnable && (0U != (txDesc [1 ].ext .eFlags & (uint32_t )kNETC_TxExtTwoStepTs )))
838
845
{
@@ -843,10 +850,15 @@ status_t EP_SendFrameCommon(ep_handle_t *handle,
843
850
txBdRing -> dirtyBase [txBdRing -> producerIndex ].isTsAvail = false;
844
851
}
845
852
/* Copy user Tx descriptors to hardware Tx BD. */
846
- txDesTemp -> standard .flags = txDesc [0 ].standard .flags ;
847
- txDesTemp -> standard .addr = address ;
848
- txDesTemp -> standard .bufLen = txBuff -> length ;
849
- txDesTemp -> standard .frameLen = frameLen ;
853
+ txDesTemp -> standard .flags = txDesc [0 ].standard .flags ;
854
+ txDesTemp -> standard .addr = address ;
855
+ txDesTemp -> standard .bufLen = txBuff -> length ;
856
+ #if defined(FSL_FEATURE_NETC_HAS_SWITCH_TAG ) && FSL_FEATURE_NETC_HAS_SWITCH_TAG
857
+ txDesc [1 ].ext .frameLenExt = (frameLen >> 16U ) & 0x7U ;
858
+ txDesTemp -> standard .frameLen = frameLen & 0xFFFFU ;
859
+ #else
860
+ txDesTemp -> standard .frameLen = frameLen ;
861
+ #endif
850
862
txDesTemp -> standard .isExtended = (uint32_t )isExtEnable ;
851
863
txDesTemp -> standard .enableInterrupt =
852
864
(uint32_t )((handle -> hw .si -> BDR [hwRing ].TBIER & ENETC_SI_TBIER_TXFIE_MASK ) != 0U );
@@ -897,12 +909,15 @@ status_t EP_SendFrame(ep_handle_t *handle, uint8_t ring, netc_frame_struct_t *fr
897
909
/* Tx BD ring index is out of range */
898
910
return kStatus_InvalidArgument ;
899
911
}
912
+
913
+ #if !(defined(FSL_FEATURE_NETC_HAS_SWITCH_TAG ) && FSL_FEATURE_NETC_HAS_SWITCH_TAG )
900
914
if (NETC_EnetcHasManagement (handle -> hw .base ) && (getSiNum (handle -> cfg .si ) == 0U ))
901
915
{
902
916
/* Switch management ENETC Tx BD hardware ring 0 can't be used to send regular frame, so the index need increase
903
917
* 1 */
904
918
hwRing = ring + 1U ;
905
919
}
920
+ #endif
906
921
907
922
if (opt != NULL )
908
923
{
@@ -911,6 +926,18 @@ status_t EP_SendFrame(ep_handle_t *handle, uint8_t ring, netc_frame_struct_t *fr
911
926
txDesc [0 ].standard .flags = NETC_SI_TXDESCRIP_RD_FL (0x2U ) | NETC_SI_TXDESCRIP_RD_TSE_MASK |
912
927
NETC_SI_TXDESCRIP_RD_TXSTART (opt -> timestamp );
913
928
}
929
+ #if defined(FSL_FEATURE_NETC_HAS_SWITCH_TAG ) && FSL_FEATURE_NETC_HAS_SWITCH_TAG
930
+ else
931
+ {
932
+ txDesc [0 ].standard .flags =
933
+ NETC_SI_TXDESCRIP_RD_LSO (opt -> offload .lso ) | NETC_SI_TXDESCRIP_RD_L4CS (opt -> offload .l4Checksum ) |
934
+ NETC_SI_TXDESCRIP_RD_L4T (opt -> offload .l4Type ) | NETC_SI_TXDESCRIP_RD_L3T (opt -> offload .l3Type ) |
935
+ NETC_SI_TXDESCRIP_RD_L3HDRSIZE (opt -> offload .l3HeaderSize ) |
936
+ NETC_SI_TXDESCRIP_RD_IPCS (opt -> offload .ipv4Checksum ) |
937
+ NETC_SI_TXDESCRIP_RD_L3START (opt -> offload .l3Start );
938
+ }
939
+ #endif
940
+
914
941
if ((opt -> flags & (uint32_t )kEP_TX_OPT_VLAN_INSERT ) != 0U )
915
942
{
916
943
txDesc [0 ].standard .isExtended = 1U ;
@@ -978,10 +1005,12 @@ netc_tx_frame_info_t *EP_ReclaimTxDescCommon(ep_handle_t *handle,
978
1005
{
979
1006
frameInfo -> timestamp = txDesc -> writeback .timestamp ;
980
1007
}
1008
+ #if !(defined(FSL_FEATURE_NETC_HAS_SWITCH_TAG ) && FSL_FEATURE_NETC_HAS_SWITCH_TAG )
981
1009
if (frameInfo -> isTxTsIdAvail )
982
1010
{
983
1011
frameInfo -> txtsid = (uint16_t )txDesc -> writeback .txtsid ;
984
1012
}
1013
+ #endif
985
1014
frameInfo -> status = (netc_ep_tx_status_t )txDesc -> writeback .status ;
986
1015
}
987
1016
else if (txDesc -> standard .frameLen != 0U )
@@ -1027,13 +1056,14 @@ void EP_ReclaimTxDescriptor(ep_handle_t *handle, uint8_t ring)
1027
1056
netc_tx_frame_info_t * frameInfo ;
1028
1057
uint8_t hwRing = ring ;
1029
1058
1059
+ #if !(defined(FSL_FEATURE_NETC_HAS_SWITCH_TAG ) && FSL_FEATURE_NETC_HAS_SWITCH_TAG )
1030
1060
if (NETC_EnetcHasManagement (handle -> hw .base ) && (getSiNum (handle -> cfg .si ) == 0U ))
1031
1061
{
1032
1062
/* Switch management ENETC Tx BD hardware ring 0 can't be used to send regular frame, so the index need increase
1033
1063
* 1 */
1034
1064
hwRing = ring + 1U ;
1035
1065
}
1036
-
1066
+ #endif
1037
1067
do
1038
1068
{
1039
1069
frameInfo =
@@ -2140,7 +2170,7 @@ status_t EP_TxTGSConfigAdminGcl(ep_handle_t *handle, netc_tb_tgs_gcl_t *config)
2140
2170
uint64_t time , minBaseTime ;
2141
2171
2142
2172
/* Read the previous active Operationa gate control list cycle time*/
2143
- (void )memset (cdbrHandle .buffer , 0 , sizeof (netc_tb_tgs_data_t ));
2173
+ (void )memset (cdbrHandle .buffer , 0 , sizeof (netc_tb_tgs_req_data_t ));
2144
2174
cdbrHandle .buffer -> tgs .request .entryID = config -> entryID ;
2145
2175
cdbrHandle .buffer -> tgs .request .commonHeader .updateActions = 0U ;
2146
2176
cdbrHandle .buffer -> tgs .request .commonHeader .queryActions = 0U ;
0 commit comments