[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] hw/net: ftgmac100: copy eth_hdr for alignment
From: |
Philippe Mathieu-Daudé |
Subject: |
Re: [PATCH] hw/net: ftgmac100: copy eth_hdr for alignment |
Date: |
Mon, 3 Mar 2025 12:17:32 +0100 |
User-agent: |
Mozilla Thunderbird |
Hi Patrick,
On 27/2/25 16:42, Patrick Venture wrote:
eth_hdr requires 2 byte alignment
Signed-off-by: Patrick Venture <venture@google.com>
---
hw/net/ftgmac100.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
@@ -1028,6 +1032,7 @@ static ssize_t ftgmac100_receive(NetClientState *nc,
const uint8_t *buf,
{
FTGMAC100State *s = FTGMAC100(qemu_get_nic_opaque(nc));
FTGMAC100Desc bd;
+ struct eth_header eth_hdr = {};
uint32_t flags = 0;
uint64_t addr;
uint32_t crc;
@@ -1036,7 +1041,11 @@ static ssize_t ftgmac100_receive(NetClientState *nc,
const uint8_t *buf,
uint32_t buf_len;
size_t size = len;
uint32_t first = FTGMAC100_RXDES0_FRS;
- uint16_t proto = be16_to_cpu(PKT_GET_ETH_HDR(buf)->h_proto);
The LD/ST API deals with unaligned fields, would that help?
uint16_t proto = lduw_be_p(&PKT_GET_ETH_HDR(buf)->h_proto);
+ uint16_t proto;
+
+ memcpy(ð_hdr, PKT_GET_ETH_HDR(buf),
+ (sizeof(eth_hdr) > len) ? len : sizeof(eth_hdr));
+ proto = be16_to_cpu(eth_hdr.h_proto);
int max_frame_size = ftgmac100_max_frame_size(s, proto);
- Re: [PATCH] hw/net: ftgmac100: copy eth_hdr for alignment,
Philippe Mathieu-Daudé <=