Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Josh Hilke" <jrhilke@google.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH v8 1/6] vfio: selftests: igb: Add driver for Intel 82576 device
Date: Wed, 29 Jul 2026 22:45:53 +0000	[thread overview]
Message-ID: <20260729224554.0C22C1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260729-igb_v3_b4-v8-1-3ed236272b4e@google.com>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Medium] Hardware Testing Failure / Invalid Loopback Configuration
- [Medium] Hardware Configuration / Frame Padding failure for short packets
- [Low] Misleading comment about interrupt delivery during memcpy
--

--- Patch [1]: [PATCH v8 1/6] vfio: selftests: igb: Add driver for Intel 82576 device ---
commit e83f78e00ae490d2604290c3e38f2458c48dd9d4
Author: Josh Hilke <jrhilke@google.com>

vfio: selftests: igb: Add driver for Intel 82576 device

This commit adds a VFIO selftest driver for the Intel 82576 Gigabit Ethernet
controller. It uses advanced descriptors and programs MSI-X routing to test
DMA loopback via QEMU's igb emulation and physical hardware.

> diff --git a/tools/testing/selftests/vfio/lib/drivers/igb/igb.c b/tools/testing/selftests/vfio/lib/drivers/igb/igb.c
> new file mode 100644
> index 0000000000000..6fc6e7c0e7235
> --- /dev/null
> +++ b/tools/testing/selftests/vfio/lib/drivers/igb/igb.c

[ ... ]

> +static void igb_phy_setup_autoneg(struct igb *igb)
> +{
> +	int timeout_ms = 1000;
> +	bool success = false;
> +	u16 phy_status;
> +	int ret;
> +	int i;
> +
> +	/* Trigger auto-negotiation */
> +	ret = igb_write_phy(igb, MII_BMCR,
> +			    BMCR_ANENABLE | BMCR_ANRESTART);

[Severity: Medium]
Will this auto-negotiation time out and fail the test via VFIO_ASSERT_TRUE
when running on physical 82576 hardware without an active external link
partner?

> +	VFIO_ASSERT_EQ(ret, 0, "Failed to write PHY control register");
> +
> +	for (i = 0; i < timeout_ms; i++) {
> +		if (igb_read_phy(igb, MII_BMSR, &phy_status) == 0) {
> +			success = !!(phy_status & BMSR_ANEGCOMPLETE);
> +			if (success)
> +				break;
> +		}
> +		usleep(1000);
> +	}
> +
> +	VFIO_ASSERT_TRUE(success, "Auto-negotiation did not complete in time");
> +}

[ ... ]

> +static void igb_init(struct vfio_pci_device *device)
> +{

[ ... ]

> +	/* Enable Receiver and Transmitter */
> +	rctl = E1000_RCTL_EN |       /* Receiver Enable */
> +	       E1000_RCTL_UPE |      /* Unicast Promiscuous (for dummy MAC) */
> +	       E1000_RCTL_MPE |      /* Multicast Promiscuous */
> +	       E1000_RCTL_BAM |      /* Broadcast Accept Mode */
> +	       E1000_RCTL_LBM_MAC |  /* MAC Loopback Mode */

[Severity: Medium]
Does real 82576 hardware support MAC loopback? It appears this might cause DMA
loopback to fail on physical hardware even if auto-negotiation completes.

> +	       E1000_RCTL_SECRC;     /* Strip CRC (needed for memcmp) */
> +	igb_write32(igb, E1000_RCTL, rctl);
> +	igb_write32(igb, E1000_TCTL, E1000_TCTL_EN);

[Severity: Medium]
Is the Pad Short Packets bit (E1000_TCTL_PSP) missing from the TCTL
configuration here?

If vfio_pci_driver_memcpy() is called with a size smaller than 60 bytes,
would the hardware send a runt frame that the receiver drops (because Store
Bad Packets is disabled), causing igb_memcpy_wait() to time out with
-ETIMEDOUT?

> +
> +	/* Enable MSI-X with 1 vector for the test */
> +	vfio_pci_msix_enable(device, MSIX_VECTOR, 1);
> +
> +	/*
> +	 * Program MSI-X interrupt routing per 82576 datasheet:
> +	 *
> +	 * GPIE (section 7.3.2.11, Table 7-47): set Multiple_MSIX (bit 4) to
> +	 * route interrupt causes through IVAR mapping, and EIAME (bit 30)
> +	 * to apply EIAM on MSI-X assertion (without EIAME, EIAM only
> +	 * applies on EICR read/write).
> +	 *
> +	 * EIAC (section 8.8.5): enable auto-clear of EICR for vector 0.
> +	 * Without auto-clear the cause stays set after delivery and the
> +	 * test can see spurious interrupts on the next memcpy batch.
> +	 *
> +	 * EIAM (section 8.8.6): enable auto-mask of EIMS for vector 0 on
> +	 * MSI-X assertion (effective because EIAME is set), so a single
> +	 * interrupt is delivered per memcpy batch even if the cause
> +	 * re-asserts before software re-enables the mask.

[Severity: Low]
This isn't a bug, but is this comment accurate about delivering a single
interrupt per memcpy batch?

Looking at igb_memcpy_start(), it explicitly disables interrupts before the
batch:

    igb_irq_disable(igb);

and igb_memcpy_wait() polls the descriptor writeback before clearing the
cause and re-enabling interrupts:

    igb_irq_clear(igb);
    igb_irq_enable(igb);

It appears interrupts are prevented entirely during the polling loop.

> +	 *
> +	 * IVAR (section 7.3.1.2, register definition in 8.8.13): map RX
> +	 * cause 0 to MSI-X vector 0 and mark the entry valid.
> +	 */

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260729-igb_v3_b4-v8-0-3ed236272b4e@google.com?part=1

  reply	other threads:[~2026-07-29 22:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-29 22:26 [PATCH v8 0/6] vfio: selftests: Add driver for Intel Ethernet Gigabit Controller (IGB) Josh Hilke
2026-07-29 22:26 ` [PATCH v8 1/6] vfio: selftests: igb: Add driver for Intel 82576 device Josh Hilke
2026-07-29 22:45   ` sashiko-bot [this message]
2026-07-29 22:26 ` [PATCH v8 2/6] vfio: selftests: igb: Use PHY internal loopback on 82576 Josh Hilke
2026-07-29 22:26 ` [PATCH v8 3/6] vfio: selftests: Add helpers to re-enable interrupts Josh Hilke
2026-07-29 22:26 ` [PATCH v8 4/6] vfio: selftests: igb: Factor hardware programming into igb_hw_init() Josh Hilke
2026-07-29 22:27 ` [PATCH v8 5/6] vfio: selftests: Retry on EAGAIN during device reset Josh Hilke
2026-07-29 22:27 ` [PATCH v8 6/6] vfio: selftests: igb: Recover after DMA-read faults Josh Hilke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260729224554.0C22C1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=jrhilke@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox