On Fri, 23 Oct 2026 at 15:00, Marcelo Manzo <[email protected]> wrote:
>
> From: Sergey Kambalin <[email protected]>
>
> Implement the receive DMA ring handling: qemu_can_receive()/
> receive() callbacks for the NIC's netdev peer, copying incoming
> frame data into descriptor buffers on the active RX ring,
> classifying broadcast/multicast, and raising the RXDMA_MBDONE
> interrupt as descriptors complete.
>
> Part of Sergey Kambalin's original Raspberry Pi 4B PCIe/GENET
> networking series (patchwork series 829638, posted to qemu-devel in
> 2024, never merged). Carried forward and completed by Marcelo Manzo.
>
> While carrying this forward, make these changes to the original code:
>
>  - Report no hardware-computed RX checksum (rx_csum = 0). The original
>    stored the IPv4 header checksum in host byte order, but the guest's
>    CHECKSUM_COMPLETE path expects a running checksum over the L4
>    payload, which made the guest reject otherwise-valid inbound
>    packets ("hw csum failure" in bcmgenet_rx_poll()) and broke
>    DHCP/connectivity intermittently. With 0 the guest verifies
>    checksums in software instead.
>  - Fill in the per-packet status block with stl_le_p() rather than by
>    casting the packet buffer to a C struct, which is undefined
>    behaviour for a misaligned buffer and wrong on big-endian hosts.
>  - Refresh the link state once a BMCR autonegotiation restart has been
>    handled by the MDIO code (moved here from the MDIO patch, where the
>    function it calls does not exist yet).
>  - Validate the guest-programmed descriptor indexes against the size
>    of the descriptor array, and limit the DMA write to the size of our
>    packet buffer, so that a guest-controlled register can't make us
>    access memory outside them.
>
> Signed-off-by: Sergey Kambalin <[email protected]>
> Signed-off-by: Marcelo Manzo <[email protected]>
> ---

>  static NetClientInfo bcm2838_genet_client_info = {
>      .type = NET_CLIENT_DRIVER_NIC,
> -    .size = sizeof(NICState)
> +    .size = sizeof(NICState),
> +    .receive = bcm2838_genet_receive,
> +    .link_status_changed = bcm2838_genet_set_link,

A very tiny nit -- if the earlier patch had the trailing
',' on the .size initializer line here, we wouldn't need
to edit that line in this patch. (This is why we prefer
trailing comma even on the last initializer in a list, as
a general rule.)

But anyway
Reviewed-by: Peter Maydell <[email protected]>

thanks
-- PMM

Reply via email to