mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 15:53:54 -06:00
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>
This commit is contained in:
parent
d97f11590a
commit
f574633529
10 changed files with 55 additions and 33 deletions
|
@ -561,22 +561,18 @@ static void imx_enet_do_tx(IMXFECState *s, uint32_t index)
|
|||
ptr += len;
|
||||
frame_size += len;
|
||||
if (bd.flags & ENET_BD_L) {
|
||||
int csum = 0;
|
||||
|
||||
if (bd.option & ENET_BD_PINS) {
|
||||
struct ip_header *ip_hd = PKT_GET_IP_HDR(s->frame);
|
||||
if (IP_HEADER_VERSION(ip_hd) == 4) {
|
||||
net_checksum_calculate(s->frame, frame_size);
|
||||
}
|
||||
csum |= (CSUM_TCP | CSUM_UDP);
|
||||
}
|
||||
if (bd.option & ENET_BD_IINS) {
|
||||
struct ip_header *ip_hd = PKT_GET_IP_HDR(s->frame);
|
||||
/* We compute checksum only for IPv4 frames */
|
||||
if (IP_HEADER_VERSION(ip_hd) == 4) {
|
||||
uint16_t csum;
|
||||
ip_hd->ip_sum = 0;
|
||||
csum = net_raw_checksum((uint8_t *)ip_hd, sizeof(*ip_hd));
|
||||
ip_hd->ip_sum = cpu_to_be16(csum);
|
||||
}
|
||||
csum |= CSUM_IP;
|
||||
}
|
||||
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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue