[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH 4/6] hw/net/vmxnet3: Use the tcp_header structur
From: |
Philippe Mathieu-Daudé |
Subject: |
[Qemu-devel] [RFC PATCH 4/6] hw/net/vmxnet3: Use the tcp_header structure |
Date: |
Thu, 8 Aug 2019 16:34:55 +0200 |
The tcp_header structure comes convenient macros to avoid
manipulating the TCP header flags/offset bits manually.
Replace the tcp_hdr structure by the tcp_header equivalent,
and use the macros.
Since we will remove the duplicated TCP_FLAG_ACK definition
in the next commit, replace its use now.
Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
---
RFC: Verify th_off endianess
hw/net/net_rx_pkt.c | 2 +-
hw/net/net_tx_pkt.c | 7 ++++---
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/hw/net/net_rx_pkt.c b/hw/net/net_rx_pkt.c
index 98a5030ace..7558f0646a 100644
--- a/hw/net/net_rx_pkt.c
+++ b/hw/net/net_rx_pkt.c
@@ -376,7 +376,7 @@ bool net_rx_pkt_is_tcp_ack(struct NetRxPkt *pkt)
assert(pkt);
if (pkt->istcp) {
- return TCP_HEADER_FLAGS(&pkt->l4hdr_info.hdr.tcp) & TCP_FLAG_ACK;
+ return TCP_HEADER_FLAGS(&pkt->l4hdr_info.hdr.tcp) & TH_ACK;
}
return false;
diff --git a/hw/net/net_tx_pkt.c b/hw/net/net_tx_pkt.c
index 162f802dd7..fc4514416c 100644
--- a/hw/net/net_tx_pkt.c
+++ b/hw/net/net_tx_pkt.c
@@ -307,7 +307,7 @@ func_exit:
void net_tx_pkt_build_vheader(struct NetTxPkt *pkt, bool tso_enable,
bool csum_enable, uint32_t gso_size)
{
- struct tcp_hdr l4hdr;
+ struct tcp_header l4hdr;
assert(pkt);
/* csum has to be enabled if tso is. */
@@ -330,7 +330,8 @@ void net_tx_pkt_build_vheader(struct NetTxPkt *pkt, bool
tso_enable,
case VIRTIO_NET_HDR_GSO_TCPV6:
iov_to_buf(&pkt->vec[NET_TX_PKT_PL_START_FRAG], pkt->payload_frags,
0, &l4hdr, sizeof(l4hdr));
- pkt->virt_hdr.hdr_len = pkt->hdr_len + l4hdr.th_off * sizeof(uint32_t);
+ pkt->virt_hdr.hdr_len = pkt->hdr_len
+ + TCP_HEADER_DATA_OFFSET(&l4hdr) *
sizeof(uint32_t);
pkt->virt_hdr.gso_size = gso_size;
break;
@@ -343,7 +344,7 @@ void net_tx_pkt_build_vheader(struct NetTxPkt *pkt, bool
tso_enable,
case IP_PROTO_TCP:
pkt->virt_hdr.flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
pkt->virt_hdr.csum_start = pkt->hdr_len;
- pkt->virt_hdr.csum_offset = offsetof(struct tcp_hdr, th_sum);
+ pkt->virt_hdr.csum_offset = offsetof(struct tcp_header, th_sum);
break;
case IP_PROTO_UDP:
pkt->virt_hdr.flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
--
2.20.1
- [Qemu-devel] [PATCH 0/6] net/eth: Remove duplicated tcp/udp_hdr structures, Philippe Mathieu-Daudé, 2019/08/08
- [Qemu-devel] [RFC PATCH 1/6] hw/net/virtio-net: Use TCP_HEADER_FLAGS/TCP_HEADER_DATA_OFFSET macros, Philippe Mathieu-Daudé, 2019/08/08
- [Qemu-devel] [RFC PATCH 2/6] net/colo-compare: Use the tcp_header structure, Philippe Mathieu-Daudé, 2019/08/08
- [Qemu-devel] [PATCH 3/6] net/filter-rewriter: Use the tcp_header structure, Philippe Mathieu-Daudé, 2019/08/08
- [Qemu-devel] [RFC PATCH 4/6] hw/net/vmxnet3: Use the tcp_header structure,
Philippe Mathieu-Daudé <=
- [Qemu-devel] [PATCH 5/6] net/eth: Remove the unused tcp_hdr structure, Philippe Mathieu-Daudé, 2019/08/08
- [Qemu-devel] [PATCH 6/6] net/eth: Remove the single use of udp_hdr structure, Philippe Mathieu-Daudé, 2019/08/08
- Re: [Qemu-devel] [PATCH 0/6] net/eth: Remove duplicated tcp/udp_hdr structures, Dmitry Fleytman, 2019/08/12
- Re: [Qemu-devel] [PATCH 0/6] net/eth: Remove duplicated tcp/udp_hdr structures, Philippe Mathieu-Daudé, 2019/08/18