Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New NXP ENET driver #62833

Merged
merged 16 commits into from
Nov 28, 2023
Merged

Conversation

decsny
Copy link
Member

@decsny decsny commented Sep 19, 2023

ETH MCUX driver is unmaintainable and cannot support a PHY other than the one on some of the NXP EVKs. Redo, planning to deprecate old driver but keep for a release or two.

New driver selects EXPERIMENTAL until the community has had a chance to try this new driver.

This PR also makes the phy-connection-type property generic to all ethernet controllers

@zephyrbot zephyrbot added manifest manifest-hal_nxp DNM This PR should not be merged (Do Not Merge) labels Sep 19, 2023
@zephyrbot
Copy link
Collaborator

zephyrbot commented Sep 19, 2023

The following west manifest projects have been modified in this Pull Request:

Name Old Revision New Revision Diff

Note: This message is automatically posted and updated by the Manifest GitHub Action.

@decsny decsny requested a review from pdgendt November 22, 2023 17:54
drivers/ethernet/Kconfig.nxp_enet Outdated Show resolved Hide resolved
drivers/ethernet/eth_nxp_enet.c Outdated Show resolved Hide resolved
@decsny
Copy link
Member Author

decsny commented Nov 28, 2023

@manuargue can you check if your block is addressed

Add ENET clock value to the CCM clock decoder
for both RT10XX and RT11XX CCM versions.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
Add a property to the ethernet controller binding
indicating what type of connection the MAC has with
the PHY device.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
Add DT Binding for Microchip KSZ8081 PHY

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
Add Driver for KSZ8081 Ethernet PHY. The Generic MII Driver
is not sufficient to use for this PHY chip which has special
vendor implemented behaviors.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
Add bindings for compatibles related to NXP ENET IP.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
Create an include header to be used by NXP ENET drivers.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
Add driver for NXP ENET MDIO functionalities

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
Add driver for NXP ENET which is a rework of the old
eth_mcux.c driver which had become unmaintainable due to
fundamental problems with the lack of PHY abstraction.

eth_mcux.c and the corresponding compatible nxp,kinetis-ethernet
will be deprecated and this new driver will be supported instead.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
when using either old or new driver for nxp enet,
enable the phy clock

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
Increase the size of the system workqueue stack if using
nxp ethernet driver

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
Add subsys value for ENET PLL / ENET Ref clk to CCM Driver

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
Add binding for NXP ENET PTP Clock device

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
Add ptp clock driver init priority kconfig

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
Add Driver for NXP ENET PTP Clock device

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
Support PTP functionality in NXP ENET MAC driver

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
Add overlay to show how to use new experimental nxp enet driver

Also make any eth_mcux related kconfigs dependent on eth_mcux in the
boards' defconfigs.

Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
manuargue
manuargue previously approved these changes Nov 28, 2023
Copy link
Member

@manuargue manuargue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My comments addressed. Nice job!

Comment on lines +67 to +69



Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: multiple newlines

include: ethernet-phy.yaml

properties:
mc,reset-gpio:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I mean that other drivers that use reset-gpios handles, simply name them as such. Without the mc, prefix.

Copy link
Collaborator

@danieldegrasse danieldegrasse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of nits, but driver looks good to me. Verified it is working on an RT1060 EVK.

drivers/ethernet/phy/phy_microchip_ksz8081.c Show resolved Hide resolved
* Interrupt enable: The driver's relevant interrupt was enabled in NVIC
*/
enum nxp_enet_callback_reason {
nxp_enet_module_reset,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit- the convention is typically to use CAPS for a enum constant in Zephyr, right?

@dleach02 dleach02 merged commit 789addb into zephyrproject-rtos:main Nov 28, 2023
28 checks passed
* ethernet driver has not initiaized, just do a busy wait
*/
k_busy_wait(USEC_PER_MSEC * config->timeout);
if (base->EIR && ENET_EIR_MII_MASK == ENET_EIR_MII_MASK) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and the same below do not seem correct. You probably meant:
(base->EIR & ENET_EIR_MII_MASK) == ENET_EIR_MII_MASK

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was fixed in #65999


extern void nxp_enet_mdio_callback(const struct device *mdio_dev,
enum nxp_enet_callback_reason event);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is already included in one of header you created.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was fixed in #65998

k_mutex_lock(&data->tx_frame_buf_mutex, K_FOREVER);

/* Read network packet from upper layer into frame buffer */
if (net_pkt_read(pkt, data->tx_frame_buf, total_len)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, eth_sam_gmac.c does this with zero-copy (and for receive too), perhaps the same can be done with this driver in the future.

Copy link
Member Author

@decsny decsny Dec 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be desirable, this driver is still experimental because I am planning that it will get a lot of changes such as potentially this, and I don't want it to be considered stable yet so that we can make these changes more quickly

return ret;
}

return ret;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the if (ret) .. is unnecessary above.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my opinion on this is that it is easy to forget to add if another call is in the future added later in the code that affects ret, which can cause a bug that might not immediately appear, and the compiler will optimize this anyways, so I prefer this. I get this nit a lot

struct net_pkt *pkt;

pkt = frameinfo->context;
if (pkt && atomic_get(&pkt->atomic_ref) > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the minimum ref count be actually 2?

If the reference count == 1, then the packet will be freed by net_pkt_unref() on line 235. That means whatever we push into the queue by net_if_add_tx_timestamp() is no longer valid.

drivers/ptp_clock/Kconfig Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Clock Control area: Clocks area: Devicetree Binding PR modifies or adds a Device Tree binding area: Ethernet platform: ESP32 Espressif ESP32 platform: Microchip MEC Microchip MEC Platform platform: Microchip SAM Microchip SAM Platform (formerly Atmel SAM) platform: NXP NXP
Projects
None yet
9 participants