Skip to content

drivers/network: add ixgbe driver#682

Open
terryzbai wants to merge 2 commits into
mainfrom
ixgbe_driver_cleanup
Open

drivers/network: add ixgbe driver#682
terryzbai wants to merge 2 commits into
mainfrom
ixgbe_driver_cleanup

Conversation

@terryzbai

Copy link
Copy Markdown
Contributor

This driver is for Intel X540/X550 NICs and works with IO-APIC and MSI/MSI-X interrupts.

Before a proper PCI driver (#622) gets implemented, this experimental driver needs the access to PCI configuration space and set things up by itself. Interrupt types need to be manually switched by (un)commenting code snippets in meta.py and ethernet.c.

This driver is for Intel X540/X550 NICs and works
with IO-APIC and MSI/MSI-X interrupts.

Signed-off-by: Terry Bai <tianyi.bai@unsw.edu.au>
Signed-off-by: Terry Bai <tianyi.bai@unsw.edu.au>

@midnightveil midnightveil left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Brief skim.

Comment thread drivers/network/ixgbe/ethernet.c Outdated
Comment thread drivers/network/ixgbe/ethernet.c
Comment thread drivers/network/ixgbe/ethernet.c
Comment thread drivers/network/ixgbe/ethernet.c Outdated
Comment thread drivers/network/ixgbe/ethernet.c
Comment thread drivers/network/ixgbe/ethernet.c
Comment thread drivers/network/ixgbe/ethernet.c
config.virt_tx.active_queue.vaddr,
config.virt_tx.num_buffers);

// Disable Interrupts, see Section 4.6.3.1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can we link the manual we are referncing somewhere for these sections to make sense?

Comment on lines +336 to +356
// Enable MSI. see PCI Express Technology 3.0 Chapter 17 for more details.
/* set_flags16(PCI_COMMAND_16, BIT(10)); */
/* set_flags16(PCI_MSI_MESSAGE_CONTROL_16, BIT(0)); */
/* clear_flags16(PCI_MSI_MESSAGE_CONTROL_16, BIT(4) | BIT(5) | BIT(6)); */
/* set_reg(PCI_MSI_MESSAGE_ADDRESS_LOW, 0xFEEu << 20); */
/* set_reg(PCI_MSI_MESSAGE_ADDRESS_HIGH, 0); */
/* set_reg16(PCI_MSI_MESSAGE_DATA_16, 0x31); */
/* clear_flags16(PCI_MSI_MASK, BIT(0)); */

// Enable MSI-X, see PCI Express Technology 3.0 Chapter 17 for more details.
/* // Disable legacy interrupts. TODO: this should be done by PCI driver. */
/* set_flags16(PCI_COMMAND_16, BIT(10)); */
/* // Set vector message address to Local APIC of CPU0 */
/* set_reg(DEVICE_MSIX_TABLE + 0x0, 0xFEEu << 20); */
/* set_reg(DEVICE_MSIX_TABLE + 0x4, 0); */
/* // Set vector data to Interrupt Vector */
/* set_reg(DEVICE_MSIX_TABLE + 0x8, 0x32); */
/* // Unmask vector 0 to enable interrupts through it */
/* set_reg(DEVICE_MSIX_TABLE + 0xC, 0xFFFFFFFE); */
/* // Enable MSI-X. TODO: this should be set by PCI driver. */
/* set_flags(PCI_MSIX_CTRL, BIT(31)); */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Either these are needed or not; there's no need for commented out code.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

As described in this PR, these are for manually switch which type of IRQs to use before a PCI driver is ready.

Comment thread drivers/network/ixgbe/ethernet.h

@KurtWu10 KurtWu10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I've only checked the provide/return functions of Rx/Tx. I need to read the intel manual further to understand its concurrency model. I don't see the need of using inline assembly for get_reg*/set_reg* either.

Comment thread drivers/network/ixgbe/ethernet.c
Comment thread drivers/network/ixgbe/ethernet.c
Comment thread drivers/network/ixgbe/ethernet.c
Comment thread drivers/network/ixgbe/ethernet.c
Comment thread drivers/network/ixgbe/ethernet.c
Comment thread drivers/network/ixgbe/ethernet.c
Comment thread drivers/network/ixgbe/ethernet.c
while (!hw_tx_ring_empty()) {
/* Ensure that this buffer has been sent by the device */
ixgbe_adv_tx_desc_wb_t hw_desc = device.tx_ring[device.tx_head].wb;
if ((hw_desc.status & IXGBE_ADVTXD_STAT_DD) == 0)

@KurtWu10 KurtWu10 Mar 31, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

TODO: it is unclear to me whether we should use the head pointer to detect completion of Tx descriptor write back. According to section 7.2.3.5.2 of the X550 datasheet (rev. 2.7),

In legacy hardware, transmit requests are completed by writing the DD bit to the transmit descriptor ring. This causes cache trash since both the driver and hardware are writing to the descriptor ring in host memory. Instead of writing the DD bits to signal that a transmit request is complete, hardware can write the contents of the descriptor queue head to host memory. The driver reads that memory location to determine which transmit requests are complete.

@omeh-a

omeh-a commented Jun 4, 2026

Copy link
Copy Markdown
Member

@terryzbai What's the current state on this PR? Is this just waiting on having a PCIe driver to be merged?

@terryzbai

Copy link
Copy Markdown
Contributor Author

@terryzbai What's the current state on this PR? Is this just waiting on having a PCIe driver to be merged?

That's one of the reasons. Another reason is that I haven't got time to look at the event logics, which seem different from other ethernet drivers that we have. Btw, it would be great for development if we have a machine with less booting time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants