i.MX RT 1170 Ethernet 2 QOS reference error

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

i.MX RT 1170 Ethernet 2 QOS reference error

319 Views
mjbcswitzerland
Specialist V

Hi All

I believe there is an issue with the QOS reference "evkmimxrt1170_lwip_ping_enet_qos_bm_cm7" (and probably other variations of it).

The bus root clock is 240MHz and the QOS 1us timer needs to be set up accordingly, meaning that MAC_ONEUS_TIC_COUNTER needs to be set to 239 (0x000000ef).

The reference project sets it to 0x00000fff, which gives about 17us instead of 1us.
The reason for this is that config->csrClock_Hz is 0 so the calculation results in 0xffffffff (and then masked to maximum when written):

config->csrClock_Hz / ENET_QOS_MICRSECS_ONESECOND - 1U;


Higher in the call stack this routine is called:

status = ENET_QOS_Init(ethernetif->base, &config, netif->hwaddr, 1U, ethernetifConfig->srcClockHz);


where ethernetifConfig->srcClockHz is correctly 240000000, however it is not used by the calculation in question as that uses a value in the config struct, which never gets set to anything other than its cleared value of 0.

To correct this I have added

config.csrClock_Hz = ethernetifConfig->srcClockHz;

before the

ENET_QOS_Init()

call so that the correct value (and correct us interval) is then used.

Regards

Mark




0 Kudos
Reply
3 Replies

268 Views
Sam_Gao
NXP Employee
NXP Employee

@mjbcswitzerland 

Would you please tell us which SDK version are you using? and which code line for this issue with more detailed code snippets and patch submissions to us?

Thanks.

0 Kudos
Reply

254 Views
mjbcswitzerland
Specialist V

Hi Sam

The SDK version is the latest as for a few days ago: 2.16.000

I will explain again:
1. There is a config struct which is initialised with default values:

ENET_QOS_GetDefaultConfig(&config);

 

/*!

* brief Gets the ENET default configuration structure.

*

* The purpose of this API is to get the default ENET configure

* structure for ENET_QOS_Init(). User may use the initialized

* structure unchanged in ENET_QOS_Init(), or modify some fields of the

* structure before calling ENET_QOS_Init().

* Example:

code

enet_qos_config_t config;

ENET_QOS_GetDefaultConfig(&config);

endcode

* param config The ENET mac controller configuration structure pointer.

*/

void ENET_QOS_GetDefaultConfig(enet_qos_config_t *config)

{

/* Checks input parameter. */

assert(config != NULL);

 

/* Initializes the configure structure to zero. */

(void)memset(config, 0, sizeof(*config));

 

/* Sets RGMII mode, full duplex, 1000Mbps for MAC and PHY data interface. */

config->miiMode = kENET_QOS_RgmiiMode;

config->miiSpeed = kENET_QOS_MiiSpeed1000M;

config->miiDuplex = kENET_QOS_MiiFullDuplex;

 

/* Sets default configuration for other options. */

config->specialControl = 0;

config->multiqueueCfg = NULL;

config->pauseDuration = 0;

 

config->ptpConfig = NULL;

}

The struct has a member

uint32_t csrClock_Hz; /*!< CSR clock frequency in HZ. */


which is initialised there ((void)memset(config, 0, sizeof(*config));) to 0.


2. Nowhere in the code is this value changed/initailised with something else.


3. During the configuration of the HW in

ENET_QOS_SetMacControl


the 1us timer is configured by [line 463 in fsl_enet_qos.c]

/* Set the 1us ticket. */

reg = config->csrClock_Hz / ENET_QOS_MICRSECS_ONESECOND - 1U;

base->MAC_ONEUS_TIC_COUNTER = ENET_QOS_MAC_ONEUS_TIC_COUNTER_TIC_1US_CNTR(reg);



This is using the (uninitialised 0) value for its calculation and so it doesn't set the correct 1us value but instead sets (by chance) about 17u.

The result is that all timing of off by this factor.



4: It can be fixed by adding

config.csrClock_Hz = ethernetifConfig->srcClockHz;

to any code with access to the two structs 'before'

ENET_QOS_Init() is called.

For example, adding it at line 476 in enet_ethernetif_qos.c will fix it:




ENET_QOS_GetDefaultConfig(&config);

config.csrClock_Hz = ethernetifConfig->srcClockHz; // initialse the member that will be used to define the us timer value


Regards

Mark

 

 

 

 

0 Kudos
Reply

96 Views
Sam_Gao
NXP Employee
NXP Employee

Thanks @mjbcswitzerland 

Agreed, it is a bug about srcClockHz configuration, we have created internal JIRA(MCUX-81039) to follow-up, it will be fixed in next release (e.g. 25.09).

Thanks for your contribution!

0 Kudos
Reply
An error has occurred when reading existing sub-variable "Language_PG_Configuration"; see cause exception! The type of the containing value was: extended_hash+string (lithium.coreapi.webui.template.models.NamedValueByNameTemplateModel wrapped into f.e.b.StringModel) ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign redirect_lingo_page_url = web... [in template "language_macro_header.ftl" at line 173, column 1] - Reached through: #include "language_macro_header.ftl" [in template "Language_translator_Dashboard" at line 3, column 1] ----