diff mbox series

[ovs-dev,[PATCH,RFC] 09/17] dp-packet: Rename dp_packet_ol l4 functions.

Message ID 20211207165156.705727-10-fbl@sysclose.org
State RFC
Headers show
Series [ovs-dev,[PATCH,RFC] 09/17] dp-packet: Rename dp_packet_ol l4 functions. | expand

Commit Message

Flavio Leitner Dec. 7, 2021, 4:51 p.m. UTC
Rename to better represent their flags.

Signed-off-by: Flavio Leitner <fbl@sysclose.org>
---
 lib/dp-packet.h    | 21 +++++++--------------
 lib/netdev-linux.c | 14 +++++++-------
 lib/netdev.c       | 18 ++++++++----------
 3 files changed, 22 insertions(+), 31 deletions(-)
diff mbox series

Patch

diff --git a/lib/dp-packet.h b/lib/dp-packet.h
index dfa25e095..acb236a7d 100644
--- a/lib/dp-packet.h
+++ b/lib/dp-packet.h
@@ -956,18 +956,11 @@  dp_packet_set_flow_mark(struct dp_packet *p, uint32_t mark)
     *dp_packet_ol_flags_ptr(p) |= DP_PACKET_OL_FLOW_MARK;
 }
 
-/* Returns the L4 cksum offload bitmask. */
-static inline uint64_t
-dp_packet_ol_l4_mask(const struct dp_packet *p)
-{
-    return *dp_packet_ol_flags_ptr(p) & DP_PACKET_OL_TX_L4_MASK;
-}
-
 /* Return true if the packet 'p' requested L4 checksum offload. */
 static inline bool
 dp_packet_ol_tx_l4_csum(const struct dp_packet *p)
 {
-    return !!dp_packet_ol_l4_mask(p);
+    return !!(*dp_packet_ol_flags_ptr(p) & DP_PACKET_OL_TX_L4_MASK);
 }
 
 /* Returns 'true' if packet 'p' is marked for TCP segmentation offloading. */
@@ -986,7 +979,7 @@  dp_packet_ol_tx_ipv4(const struct dp_packet *p)
 
 /* Returns 'true' if packet 'p' is marked for TCP checksum offloading. */
 static inline bool
-dp_packet_ol_l4_is_tcp(const struct dp_packet *p)
+dp_packet_ol_tx_tcp_csum(const struct dp_packet *p)
 {
     return (*dp_packet_ol_flags_ptr(p) & DP_PACKET_OL_TX_L4_MASK) ==
             DP_PACKET_OL_TX_TCP_CSUM;
@@ -994,7 +987,7 @@  dp_packet_ol_l4_is_tcp(const struct dp_packet *p)
 
 /* Returns 'true' if packet 'p' is marked for UDP checksum offloading. */
 static inline bool
-dp_packet_ol_l4_is_udp(struct dp_packet *p)
+dp_packet_ol_tx_udp_csum(struct dp_packet *p)
 {
     return (*dp_packet_ol_flags_ptr(p) & DP_PACKET_OL_TX_L4_MASK) ==
             DP_PACKET_OL_TX_UDP_CSUM;
@@ -1002,7 +995,7 @@  dp_packet_ol_l4_is_udp(struct dp_packet *p)
 
 /* Returns 'true' if packet 'p' is marked for SCTP checksum offloading. */
 static inline bool
-dp_packet_ol_l4_is_sctp(struct dp_packet *p)
+dp_packet_ol_tx_sctp_csum(struct dp_packet *p)
 {
     return (*dp_packet_ol_flags_ptr(p) & DP_PACKET_OL_TX_L4_MASK) ==
             DP_PACKET_OL_TX_SCTP_CSUM;
@@ -1025,7 +1018,7 @@  dp_packet_ol_set_tx_ipv6(struct dp_packet *p)
 /* Mark packet 'p' for TCP checksum offloading.  It implies that either
  * the packet 'p' is marked for IPv4 or IPv6 checksum offloading. */
 static inline void
-dp_packet_ol_set_csum_tcp(struct dp_packet *p)
+dp_packet_ol_set_tx_tcp_csum(struct dp_packet *p)
 {
     *dp_packet_ol_flags_ptr(p) |= DP_PACKET_OL_TX_TCP_CSUM;
 }
@@ -1033,7 +1026,7 @@  dp_packet_ol_set_csum_tcp(struct dp_packet *p)
 /* Mark packet 'p' for UDP checksum offloading.  It implies that either
  * the packet 'p' is marked for IPv4 or IPv6 checksum offloading. */
 static inline void
-dp_packet_ol_set_csum_udp(struct dp_packet *p)
+dp_packet_ol_set_tx_udp_csum(struct dp_packet *p)
 {
     *dp_packet_ol_flags_ptr(p) |= DP_PACKET_OL_TX_UDP_CSUM;
 }
@@ -1041,7 +1034,7 @@  dp_packet_ol_set_csum_udp(struct dp_packet *p)
 /* Mark packet 'p' for SCTP checksum offloading.  It implies that either
  * the packet 'p' is marked for IPv4 or IPv6 checksum offloading. */
 static inline void
-dp_packet_ol_set_csum_sctp(struct dp_packet *p)
+dp_packet_ol_set_tx_sctp_csum(struct dp_packet *p)
 {
     *dp_packet_ol_flags_ptr(p) |= DP_PACKET_OL_TX_SCTP_CSUM;
 }
diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c
index 696a86db2..82f9a0758 100644
--- a/lib/netdev-linux.c
+++ b/lib/netdev-linux.c
@@ -6637,11 +6637,11 @@  netdev_linux_parse_vnet_hdr(struct dp_packet *b)
 
     if (vnet->flags == VIRTIO_NET_HDR_F_NEEDS_CSUM) {
         if (l4proto == IPPROTO_TCP) {
-            dp_packet_ol_set_csum_tcp(b);
+            dp_packet_ol_set_tx_tcp_csum(b);
         } else if (l4proto == IPPROTO_UDP) {
-            dp_packet_ol_set_csum_udp(b);
+            dp_packet_ol_set_tx_udp_csum(b);
         } else if (l4proto == IPPROTO_SCTP) {
-            dp_packet_ol_set_csum_sctp(b);
+            dp_packet_ol_set_tx_sctp_csum(b);
         }
     }
 
@@ -6681,18 +6681,18 @@  netdev_linux_prepend_vnet_hdr(struct dp_packet *b, int mtu)
         vnet->flags = VIRTIO_NET_HDR_GSO_NONE;
     }
 
-    if (dp_packet_ol_l4_mask(b)) {
+    if (dp_packet_ol_tx_l4_csum(b)) {
         vnet->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
         vnet->csum_start = (OVS_FORCE __virtio16)((char *)dp_packet_l4(b)
                                                   - (char *)dp_packet_eth(b));
 
-        if (dp_packet_ol_l4_is_tcp(b)) {
+        if (dp_packet_ol_tx_tcp_csum(b)) {
             vnet->csum_offset = (OVS_FORCE __virtio16) __builtin_offsetof(
                                     struct tcp_header, tcp_csum);
-        } else if (dp_packet_ol_l4_is_udp(b)) {
+        } else if (dp_packet_ol_tx_udp_csum(b)) {
             vnet->csum_offset = (OVS_FORCE __virtio16) __builtin_offsetof(
                                     struct udp_header, udp_csum);
-        } else if (dp_packet_ol_l4_is_sctp(b)) {
+        } else if (dp_packet_ol_tx_sctp_csum(b)) {
             vnet->csum_offset = (OVS_FORCE __virtio16) __builtin_offsetof(
                                     struct sctp_header, sctp_csum);
         } else {
diff --git a/lib/netdev.c b/lib/netdev.c
index fb535ed7c..08f2e4b87 100644
--- a/lib/netdev.c
+++ b/lib/netdev.c
@@ -792,8 +792,6 @@  static bool
 netdev_send_prepare_packet(const uint64_t netdev_flags,
                            struct dp_packet *packet, char **errormsg)
 {
-    uint64_t l4_mask;
-
     if (dp_packet_ol_tcp_seg(packet)
         && !(netdev_flags & NETDEV_OFFLOAD_TX_TCP_TSO)) {
             /* Fall back to GSO in software. */
@@ -801,29 +799,29 @@  netdev_send_prepare_packet(const uint64_t netdev_flags,
             return false;
     }
 
-    l4_mask = dp_packet_ol_l4_mask(packet);
-    if (l4_mask) {
-        if (dp_packet_ol_l4_is_tcp(packet)) {
+    if (dp_packet_ol_tx_l4_csum(packet)) {
+        if (dp_packet_ol_tx_tcp_csum(packet)) {
             if (!(netdev_flags & NETDEV_OFFLOAD_TX_TCP_CSUM)) {
                 /* Fall back to TCP csum in software. */
                 VLOG_ERR_BUF(errormsg, "No TCP checksum support");
                 return false;
             }
-        } else if (dp_packet_ol_l4_is_udp(packet)) {
+        } else if (dp_packet_ol_tx_udp_csum(packet)) {
             if (!(netdev_flags & NETDEV_OFFLOAD_TX_UDP_CSUM)) {
                 /* Fall back to UDP csum in software. */
                 VLOG_ERR_BUF(errormsg, "No UDP checksum support");
                 return false;
             }
-        } else if (dp_packet_ol_l4_is_sctp(packet)) {
+        } else if (dp_packet_ol_tx_sctp_csum(packet)) {
             if (!(netdev_flags & NETDEV_OFFLOAD_TX_SCTP_CSUM)) {
                 /* Fall back to SCTP csum in software. */
                 VLOG_ERR_BUF(errormsg, "No SCTP checksum support");
                 return false;
             }
         } else {
-            VLOG_ERR_BUF(errormsg, "No L4 checksum support: mask: %"PRIu64,
-                         l4_mask);
+            uint64_t ol_flags = *dp_packet_ol_flags_ptr(packet);
+            VLOG_ERR_BUF(errormsg, "No L4 checksum support: "
+                         "offload mask: %"PRIu64, ol_flags);
             return false;
         }
     }
@@ -961,7 +959,7 @@  netdev_push_header(const struct netdev *netdev,
 
     DP_PACKET_BATCH_REFILL_FOR_EACH (i, size, packet, batch) {
         if (OVS_UNLIKELY(dp_packet_ol_tcp_seg(packet)
-                         || dp_packet_ol_l4_mask(packet))) {
+                         || dp_packet_ol_tx_l4_csum(packet))) {
             COVERAGE_INC(netdev_push_header_drops);
             dp_packet_delete(packet);
             VLOG_WARN_RL(&rl, "%s: Tunneling packets with HW offload flags is "