diff options
author | Yecheng Zhao <zyecheng@google.com> | 2024-03-10 07:33:45 +0000 |
---|---|---|
committer | Yecheng Zhao <zyecheng@google.com> | 2024-03-18 16:11:23 +0000 |
commit | 7386a9ca90e41c44f87c47d4cc1844654c4fa44b (patch) | |
tree | 75acc4c822e028e978ee777c5b8282b9055ba550 | |
parent | 838d1740bcf5a983d31fa070e38dbb222cd0af3b (diff) | |
download | u-boot-7386a9ca90e41c44f87c47d4cc1844654c4fa44b.tar.gz |
Fix EFI net issues
Fixes the following issues found when testing
EFI_SIMPLE_NETWORK_PROTOCOL on cuttlefish:
1. EFI uses the first net device by default. Cuttlefish creates 3
network devices but the first one doesn't have an assigned MAC. This
causes failure when EFI registers network device. The solution is to
call `eth_set_current()` first to scan and select a different one.
2. Virtio net stops receiving when rx ring runs out of buffer. Adding
back buffer is not sufficient to resume it. A notification is
necessary to kick if off again.
TEST: Tested Fastboot over TCP in GBL UEFI app.
Change-Id: I73a59cf188fb45212a4666f46b88fdf55de9d663
-rw-r--r-- | drivers/virtio/virtio_net.c | 9 | ||||
-rw-r--r-- | lib/efi_loader/efi_net.c | 3 |
2 files changed, 12 insertions, 0 deletions
diff --git a/drivers/virtio/virtio_net.c b/drivers/virtio/virtio_net.c index 1794f73a8d..69c7d5abb9 100644 --- a/drivers/virtio/virtio_net.c +++ b/drivers/virtio/virtio_net.c @@ -127,9 +127,18 @@ static int virtio_net_free_pkt(struct udevice *dev, uchar *packet, int length) struct virtio_sg sg = { buf, VIRTIO_NET_RX_BUF_SIZE }; struct virtio_sg *sgs[] = { &sg }; + // virtio_net stops receiving frames once it completely runs out of rx ring + // buffers. Adding back buffers does not resume it. An explicit + // notification is necessary to kick it off again. + bool need_notify = priv->rx_vq->free_head == 0; + /* Put the buffer back to the rx ring */ virtqueue_add(priv->rx_vq, sgs, 0, 1); + if (need_notify) { + virtqueue_kick(priv->rx_vq); + } + return 0; } diff --git a/lib/efi_loader/efi_net.c b/lib/efi_loader/efi_net.c index 96a5bcca27..580ec3d29f 100644 --- a/lib/efi_loader/efi_net.c +++ b/lib/efi_loader/efi_net.c @@ -863,6 +863,9 @@ efi_status_t efi_net_register(void) efi_status_t r; int i; + // Cuttlefish has multiple network devices. Call `eth_set_current()` to + // scan and select a working one. + eth_set_current(); if (!eth_get_dev()) { /* No network device active, don't expose any */ return EFI_SUCCESS; |