The csum_start/csum_offset members aren't actually required for the checksum offload pipeline. Maintaining them wastes processing and memory. Remove them.
Reported-at: https://issues.redhat.com/browse/FDP-1193 Signed-off-by: Mike Pattrick <m...@redhat.com> --- lib/dp-packet.c | 3 -- lib/dp-packet.h | 22 ----------- lib/dpif-netdev-extract-avx512.c | 2 - lib/flow.c | 3 -- lib/netdev-linux.c | 67 -------------------------------- lib/netdev-native-tnl.c | 6 +-- 6 files changed, 1 insertion(+), 102 deletions(-) diff --git a/lib/dp-packet.c b/lib/dp-packet.c index dad0d7be3..6a9bfd63b 100644 --- a/lib/dp-packet.c +++ b/lib/dp-packet.c @@ -39,9 +39,6 @@ dp_packet_init__(struct dp_packet *b, size_t allocated, enum dp_packet_source so dp_packet_init_specific(b); /* By default assume the packet type to be Ethernet. */ b->packet_type = htonl(PT_ETH); - /* Reset csum start and offset. */ - b->csum_start = 0; - b->csum_offset = 0; } static void diff --git a/lib/dp-packet.h b/lib/dp-packet.h index 182cb4429..05429f4b2 100644 --- a/lib/dp-packet.h +++ b/lib/dp-packet.h @@ -1534,34 +1534,12 @@ dp_packet_ol_reset_l4_csum_good(struct dp_packet *p) } } -/* Marks packet 'p' with good integrity if checksum offload locations - * were provided. In the case of encapsulated packets, these values may - * be deeper into the packet than OVS might expect. But the packet - * should still be considered to have good integrity. - * The 'csum_start' is the offset from the begin of the packet headers. - * The 'csum_offset' is the offset from start to place the checksum. - * The csum_start and csum_offset fields are set from the virtio_net_hdr - * struct that may be provided by a netdev on packet ingress. */ -static inline void -dp_packet_ol_l4_csum_check_partial(struct dp_packet *p) -{ - if (p->csum_start && p->csum_offset) { - dp_packet_ol_set_l4_csum_partial(p); - } -} - static inline void dp_packet_reset_packet(struct dp_packet *b, int off) { dp_packet_set_size(b, dp_packet_size(b) - off); dp_packet_set_data(b, ((unsigned char *) dp_packet_data(b) + off)); dp_packet_reset_offsets(b); - - if (b->csum_start >= off && b->csum_offset) { - /* Adjust values for decapsulation. */ - b->csum_start -= off; - dp_packet_ol_set_l4_csum_partial(b); - } } static inline uint32_t ALWAYS_INLINE diff --git a/lib/dpif-netdev-extract-avx512.c b/lib/dpif-netdev-extract-avx512.c index 57ca4c71b..3ae850c2d 100644 --- a/lib/dpif-netdev-extract-avx512.c +++ b/lib/dpif-netdev-extract-avx512.c @@ -776,7 +776,6 @@ mfex_ipv6_set_hwol(struct dp_packet *pkt) static void mfex_tcp_set_hwol(struct dp_packet *pkt) { - dp_packet_ol_l4_csum_check_partial(pkt); if (dp_packet_l4_checksum_good(pkt) || dp_packet_ol_l4_csum_partial(pkt)) { dp_packet_hwol_set_csum_tcp(pkt); @@ -786,7 +785,6 @@ mfex_tcp_set_hwol(struct dp_packet *pkt) static void mfex_udp_set_hwol(struct dp_packet *pkt) { - dp_packet_ol_l4_csum_check_partial(pkt); if (dp_packet_l4_checksum_good(pkt) || dp_packet_ol_l4_csum_partial(pkt)) { dp_packet_hwol_set_csum_udp(pkt); diff --git a/lib/flow.c b/lib/flow.c index ef719471c..9778e8a03 100644 --- a/lib/flow.c +++ b/lib/flow.c @@ -1079,7 +1079,6 @@ miniflow_extract(struct dp_packet *packet, struct miniflow *dst) } else if (dl_type == htons(ETH_TYPE_IPV6)) { dp_packet_update_rss_hash_ipv6_tcp_udp(packet); } - dp_packet_ol_l4_csum_check_partial(packet); if (dp_packet_l4_checksum_good(packet) || dp_packet_ol_l4_csum_partial(packet)) { dp_packet_hwol_set_csum_tcp(packet); @@ -1099,7 +1098,6 @@ miniflow_extract(struct dp_packet *packet, struct miniflow *dst) } else if (dl_type == htons(ETH_TYPE_IPV6)) { dp_packet_update_rss_hash_ipv6_tcp_udp(packet); } - dp_packet_ol_l4_csum_check_partial(packet); if (dp_packet_l4_checksum_good(packet) || dp_packet_ol_l4_csum_partial(packet)) { if (tunneling) { @@ -1117,7 +1115,6 @@ miniflow_extract(struct dp_packet *packet, struct miniflow *dst) miniflow_push_be16(mf, tp_dst, sctp->sctp_dst); miniflow_push_be16(mf, ct_tp_src, ct_tp_src); miniflow_push_be16(mf, ct_tp_dst, ct_tp_dst); - dp_packet_ol_l4_csum_check_partial(packet); if (dp_packet_l4_checksum_good(packet) || dp_packet_ol_l4_csum_partial(packet)) { dp_packet_hwol_set_csum_sctp(packet); diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c index 5b4950b14..0b5378620 100644 --- a/lib/netdev-linux.c +++ b/lib/netdev-linux.c @@ -7038,55 +7038,6 @@ af_packet_sock(void) return sock; } -static int -netdev_linux_parse_l2(struct dp_packet *b, uint16_t *l4proto) -{ - struct eth_header *eth_hdr; - ovs_be16 eth_type; - int l2_len; - - eth_hdr = dp_packet_at(b, 0, ETH_HEADER_LEN); - if (!eth_hdr) { - return -EINVAL; - } - - l2_len = ETH_HEADER_LEN; - eth_type = eth_hdr->eth_type; - if (eth_type_vlan(eth_type)) { - struct vlan_header *vlan = dp_packet_at(b, l2_len, VLAN_HEADER_LEN); - - if (!vlan) { - return -EINVAL; - } - - eth_type = vlan->vlan_next_type; - l2_len += VLAN_HEADER_LEN; - } - - if (eth_type == htons(ETH_TYPE_IP)) { - struct ip_header *ip_hdr = dp_packet_at(b, l2_len, IP_HEADER_LEN); - - if (!ip_hdr) { - return -EINVAL; - } - - *l4proto = ip_hdr->ip_proto; - dp_packet_hwol_set_tx_ipv4(b); - } else if (eth_type == htons(ETH_TYPE_IPV6)) { - struct ovs_16aligned_ip6_hdr *nh6; - - nh6 = dp_packet_at(b, l2_len, IPV6_HEADER_LEN); - if (!nh6) { - return -EINVAL; - } - - *l4proto = nh6->ip6_ctlun.ip6_un1.ip6_un1_nxt; - dp_packet_hwol_set_tx_ipv6(b); - } - - return 0; -} - /* Initializes packet 'b' with features enabled in the prepended * struct virtio_net_hdr. Returns 0 if successful, otherwise a * positive errno value. */ @@ -7104,26 +7055,8 @@ netdev_linux_parse_vnet_hdr(struct dp_packet *b) } if (vnet->flags == VIRTIO_NET_HDR_F_NEEDS_CSUM) { - uint16_t l4proto = 0; - - if (netdev_linux_parse_l2(b, &l4proto)) { - return EINVAL; - } - - if (l4proto == IPPROTO_UDP) { - dp_packet_hwol_set_csum_udp(b); - } - /* The packet has offloaded checksum. However, there is no - * additional information like the protocol used, so it would - * require to parse the packet here. The checksum starting point - * and offset are going to be verified when the packet headers - * are parsed during miniflow extraction. */ - b->csum_start = (OVS_FORCE uint16_t) vnet->csum_start; - b->csum_offset = (OVS_FORCE uint16_t) vnet->csum_offset; dp_packet_ol_set_l4_csum_partial(b); } else { - b->csum_start = 0; - b->csum_offset = 0; dp_packet_ol_set_l4_csum_good(b); } diff --git a/lib/netdev-native-tnl.c b/lib/netdev-native-tnl.c index 62e1a0c87..86acd62fa 100644 --- a/lib/netdev-native-tnl.c +++ b/lib/netdev-native-tnl.c @@ -322,11 +322,7 @@ netdev_tnl_push_udp_header(const struct netdev *netdev OVS_UNUSED, } else { dp_packet_hwol_set_csum_udp(packet); } - } - - if (packet->csum_start && packet->csum_offset) { - dp_packet_ol_set_l4_csum_partial(packet); - } else if (!udp->udp_csum) { + } else { dp_packet_ol_set_l4_csum_good(packet); } -- 2.48.1 _______________________________________________ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev