aboutsummaryrefslogtreecommitdiff
path: root/hw/net/fsl_etsec
diff options
context:
space:
mode:
authorBin Meng <bin.meng@windriver.com>2020-12-11 17:35:12 +0800
committerJason Wang <jasowang@redhat.com>2021-01-25 17:04:56 +0800
commitf574633529926697ced51b6865e5c50bbb78bf1b (patch)
tree98d77919083dfcbec0247c6980c479d08bc07d3b /hw/net/fsl_etsec
parentd97f11590a0f60cd911ace8bb68180b5a09a068d (diff)
net: checksum: Introduce fine control over checksum type
At present net_checksum_calculate() blindly calculates all types of checksums (IP, TCP, UDP). Some NICs may have a per type setting in their BDs to control what checksum should be offloaded. To support such hardware behavior, introduce a 'csum_flag' parameter to the net_checksum_calculate() API to allow fine control over what type checksum is calculated. Existing users of this API are updated accordingly. Signed-off-by: Bin Meng <bin.meng@windriver.com> Signed-off-by: Jason Wang <jasowang@redhat.com>
Diffstat (limited to 'hw/net/fsl_etsec')
-rw-r--r--hw/net/fsl_etsec/rings.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/hw/net/fsl_etsec/rings.c b/hw/net/fsl_etsec/rings.c
index 628648a9c3..121415abfe 100644
--- a/hw/net/fsl_etsec/rings.c
+++ b/hw/net/fsl_etsec/rings.c
@@ -183,13 +183,11 @@ static void process_tx_fcb(eTSEC *etsec)
uint8_t *l3_header = etsec->tx_buffer + 8 + l3_header_offset;
/* L4 header */
uint8_t *l4_header = l3_header + l4_header_offset;
+ int csum = 0;
/* if packet is IP4 and IP checksum is requested */
if (flags & FCB_TX_IP && flags & FCB_TX_CIP) {
- /* do IP4 checksum (TODO This function does TCP/UDP checksum
- * but not sure if it also does IP4 checksum.) */
- net_checksum_calculate(etsec->tx_buffer + 8,
- etsec->tx_buffer_len - 8);
+ csum |= CSUM_IP;
}
/* TODO Check the correct usage of the PHCS field of the FCB in case the NPH
* flag is on */
@@ -201,9 +199,7 @@ static void process_tx_fcb(eTSEC *etsec)
/* if checksum is requested */
if (flags & FCB_TX_CTU) {
/* do UDP checksum */
-
- net_checksum_calculate(etsec->tx_buffer + 8,
- etsec->tx_buffer_len - 8);
+ csum |= CSUM_UDP;
} else {
/* set checksum field to 0 */
l4_header[6] = 0;
@@ -211,10 +207,14 @@ static void process_tx_fcb(eTSEC *etsec)
}
} else if (flags & FCB_TX_CTU) { /* if TCP and checksum is requested */
/* do TCP checksum */
- net_checksum_calculate(etsec->tx_buffer + 8,
- etsec->tx_buffer_len - 8);
+ csum |= CSUM_TCP;
}
}
+
+ if (csum) {
+ net_checksum_calculate(etsec->tx_buffer + 8,
+ etsec->tx_buffer_len - 8, csum);
+ }
}
static void process_tx_bd(eTSEC *etsec,