-
Notifications
You must be signed in to change notification settings - Fork 7.2k
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
drivers: ethernet: Add Xilinx AXI Enet driver #73986
drivers: ethernet: Add Xilinx AXI Enet driver #73986
Conversation
bce8faf
to
b8dde37
Compare
Note that the Ethernet MAC driver depends on the Ethernet MDIO and the AXI DMA drivers. |
75a28a2
to
e59f91a
Compare
bool "Xilinx AXI Ethernet Driver" | ||
default y | ||
depends on DT_HAS_XLNX_AXI_ETHERNET_7_2_ENABLED || DT_HAS_XLNX_AXI_ETHERNET_1_00_A_ENABLED | ||
depends on DT_HAS_XLNX_ETH_DMA_ENABLED && XILINX_AXI_DMA |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is XILINX_AXI_DMA
supposed to be DMA_XILINX_AXI_DMA
? @WorldofJARcraft
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it seems like I forgot to change this in this pull request.
e59f91a
to
189d3b1
Compare
depends on DT_HAS_XLNX_ETH_DMA_ENABLED && DMA_XILINX_AXI_DMA | ||
help | ||
Enable Xilinx 1G / 2.5G AXI Ethernet driver, | ||
commonly found on FPGAs. Depends on Xilinx AXI DMA. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very minor nit but the dependency should already be visible in the menu, don't think it's needed to clarify in the help string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, removed it.
#define LOG_MODULE_NAME eth_xilinx_axienet | ||
#define LOG_LEVEL CONFIG_ETHERNET_LOG_LEVEL | ||
#include <zephyr/logging/log.h> | ||
LOG_MODULE_REGISTER(LOG_MODULE_NAME); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit but please do the log module register as one line (it can take two arguments for the name and level, dont need to define macros)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
#define XILINX_AXIENET_UNICAST_ADDRESS_WORD_0_OFFSET 0x00000700 | ||
#define XILINX_AXIENET_UNICAST_ADDRESS_WORD_1_OFFSET 0x00000704 | ||
|
||
#define ETH_ALEN 6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NET_ETH_ADDR_LEN macro already exists, please use that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, must have overlooked this.
(void)ethdev; | ||
if (status < 0) { | ||
LOG_ERR("DMA RX error: %d", status); | ||
k_panic(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is a dma error code worth causing a kernel panic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not insist on the panic.
The Xilinx DMA only errors when it was configured incorrectly (e.g., invalid address), so I found this helpful in debugging.
Is there some define I can guard this with?
|
||
if (!pkt) { | ||
LOG_ERR("Could not allocate a packet!"); | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment about the else block
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Panic removed.
LOG_ERR("Could not write RX buffer into packet!"); | ||
k_panic(); | ||
net_pkt_unref(pkt); | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto else block
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guard with ifdef?
if (net_recv_data(data->interface, pkt) < 0) { | ||
LOG_ERR("Coult not receive packet data!"); | ||
net_pkt_unref(pkt); | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto else block
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guard with ifdef?
} else { | ||
if (net_pkt_write(pkt, data->rx_buffer, packet_size)) { | ||
LOG_ERR("Could not write RX buffer into packet!"); | ||
k_panic(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto kernel panic question, and for all other occurrences in the file
struct device *ethdev = (struct device *)user_data; | ||
struct xilinx_axienet_data *data = ethdev->data; | ||
|
||
(void)data; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does this accomplish
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
189d3b1
to
34ea455
Compare
removing change request because the comments mostly addressed, the panic still seems like a bad idea to me but I don't have a stake in this driver so it's up to author
789595f
to
b1c0676
Compare
@WorldofJARcraft Is it on purpose that I'm fairly new to zephyr so forgive if I am missing something. |
f7de377
to
6150685
Compare
@WorldofJARcraft It looks like this branch has some trivial conflicts with the main branch that need resolving. Aside from that, unless you are planning any more changes I think you could remove the Draft status to open this for more review? |
@robhancocksed I will fix the merge conflicts and make this PR ready for review. |
a190bb6
to
7e19e2f
Compare
7e19e2f
to
e67f478
Compare
I have force-pushed an untested commit with the changes suggested by @maass-hamburg. |
e67f478
to
b6189f7
Compare
I have fixed a minor issue with the |
b6189f7
to
4237dca
Compare
dceb394
to
2912c53
Compare
2912c53
to
9953d16
Compare
The Xilinx AXI Ethernet subsystem is commonly found in FPGA designs. This patch adds a driver and device tree bindings for the Ethernet MAC core and its MDIO controller. The driver was tested on a RISC-V softcore in an FPGA design, with an RGMII phy and Ethernet subsystem version 7.2 Rev. 14. Device tree bindings match the device tree generated by Vitis hsi. Note that Vitis generates one of the two included compatible strings depending on version. Signed-off-by: Eric Ackermann <eric.ackermann@cispa.de>
9953d16
to
29e9387
Compare
(data->rx_completed_buffer_index + 1) % CONFIG_ETH_XILINX_AXIENET_BUFFER_NUM_RX; | ||
size_t current_descriptor = data->rx_completed_buffer_index; | ||
|
||
if (!net_if_is_up(data->interface)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably want to do this after updating rx_completed_buffer_index, otherwise the indexes won't be tracked properly across a down/up cycle..
The Xilinx AXI Ethernet subsystem is commonly found in FPGA designs. This patch adds a driver and device tree bindings for the Ethernet MAC core.
The driver was tested on a RISC-V softcore in an FPGA design, with an RGMII phy and Ethernet subsystem version 7.2 Rev. 14. Device tree bindings match the device tree generated by Vitis hsi. Note that Vitis generates one of the two included compatible strings depending on version.
Please not that TX checksum offloading depends on #73985.