[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 3/3] net: checksum: Introduce fine control over checksum type
From: |
Cédric Le Goater |
Subject: |
Re: [PATCH 3/3] net: checksum: Introduce fine control over checksum type |
Date: |
Wed, 9 Dec 2020 09:33:35 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 |
Hello !
> diff --git a/hw/net/ftgmac100.c b/hw/net/ftgmac100.c
> index 782ff19..fbae1f1 100644
> --- a/hw/net/ftgmac100.c
> +++ b/hw/net/ftgmac100.c
> @@ -573,7 +573,15 @@ static void ftgmac100_do_tx(FTGMAC100State *s, uint32_t
> tx_ring,
> }
>
> if (flags & FTGMAC100_TXDES1_IP_CHKSUM) {
> - net_checksum_calculate(s->frame, frame_size);
> + /*
> + * TODO:
> + * FTGMAC100_TXDES1_IP_CHKSUM seems to be only for IP
> checksum,
> + * however previous net_checksum_calculate() did not
> calculate
> + * IP checksum at all. Passing CSUM_ALL for now until someone
> + * who is familar with this MAC to figure out what should be
> + * properly added for TCP/UDP checksum offload.
> + */
> + net_checksum_calculate(s->frame, frame_size, CSUM_ALL);
> }
> /* Last buffer in frame. */
> qemu_send_packet(qemu_get_queue(s->nic), s->frame, frame_size);
You can test your changes using the HOWTO Joel provided here :
https://github.com/openbmc/qemu/wiki/Usage
Please also check the Linux driver :
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/net/ethernet/faraday/ftgmac100.c#n685
That said, something like the change below should be more appropriate.
Thanks,
C.
+static int ftgmac100_convert_csum_flag(uint32_t flags)
+{
+ int csum = 0;
+
+ if (flags & FTGMAC100_TXDES1_IP_CHKSUM) {
+ csum |= CSUM_IP;
+ }
+ if (flags & FTGMAC100_TXDES1_TCP_CHKSUM) {
+ csum |= CSUM_TCP;
+ }
+ if (flags & FTGMAC100_TXDES1_UDP_CHKSUM) {
+ csum |= CSUM_UDP;
+ }
+ return csum;
+}
+
static void ftgmac100_do_tx(FTGMAC100State *s, uint32_t tx_ring,
uint32_t tx_descriptor)
{
@@ -602,6 +618,7 @@ static void ftgmac100_do_tx(FTGMAC100Sta
ptr += len;
frame_size += len;
if (bd.des0 & FTGMAC100_TXDES0_LTS) {
+ int csum = ftgmac100_convert_csum_flag(flags);
/* Check for VLAN */
if (flags & FTGMAC100_TXDES1_INS_VLANTAG &&
@@ -610,16 +627,8 @@ static void ftgmac100_do_tx(FTGMAC100Sta
FTGMAC100_TXDES1_VLANTAG_CI(flags));
}
- if (flags & FTGMAC100_TXDES1_IP_CHKSUM) {
- /*
- * TODO:
- * FTGMAC100_TXDES1_IP_CHKSUM seems to be only for IP checksum,
- * however previous net_checksum_calculate() did not calculate
- * IP checksum at all. Passing CSUM_ALL for now until someone
- * who is familar with this MAC to figure out what should be
- * properly added for TCP/UDP checksum offload.
- */
- net_checksum_calculate(s->frame, frame_size, CSUM_ALL);
+ if (csum) {
+ net_checksum_calculate(s->frame, frame_size, csum);
}
/* Last buffer in frame. */
qemu_send_packet(qemu_get_queue(s->nic), s->frame, frame_size);