Following a rework of dpdk network structures names [1], update the
concerned parts.

Ran Olivier script:
sh prefix-net-rte.sh $(find -name "*dpdk*.c")
sh prefix-net-rte.sh $(find -name "*dpdk*.h")
sh prefix-net-rte.sh $(find -name "*rte*.c")
sh prefix-net-rte.sh $(find -name "*rte*.h")

Plus an extra pass following further changes [2]:
old=RTE_IPv4
new=RTE_IPV4
git grep -lw $old | xargs sed -i -e "s/\<$old\>/$new/g"

old=RTE_ETHER_TYPE_IPv4
new=RTE_ETHER_TYPE_IPV4
git grep -lw $old | xargs sed -i -e "s/\<$old\>/$new/g"

old=RTE_ETHER_TYPE_IPv6
new=RTE_ETHER_TYPE_IPV6
git grep -lw $old | xargs sed -i -e "s/\<$old\>/$new/g"

1: http://mails.dpdk.org/archives/dev/2019-May/132612.html
2: https://git.dpdk.org/dpdk/commit/?id=0c9da7555da8

Signed-off-by: David Marchand <[email protected]>
---

Small note on checkpatch, I left the warnings on rte_ip.h since they
precede this patch.

---
 include/sparse/rte_esp.h  |  2 +-
 include/sparse/rte_flow.h | 18 ++++++------
 include/sparse/rte_icmp.h |  6 ++--
 include/sparse/rte_ip.h   | 70 +++++++++++++++++++++++------------------------
 include/sparse/rte_sctp.h |  2 +-
 include/sparse/rte_tcp.h  |  2 +-
 include/sparse/rte_udp.h  |  2 +-
 lib/netdev-dpdk.c         | 21 +++++++-------
 8 files changed, 62 insertions(+), 61 deletions(-)

diff --git a/include/sparse/rte_esp.h b/include/sparse/rte_esp.h
index d3fc19e..7491074 100644
--- a/include/sparse/rte_esp.h
+++ b/include/sparse/rte_esp.h
@@ -53,7 +53,7 @@ extern "C" {
 /**
  * ESP Header
  */
-struct esp_hdr {
+struct rte_esp_hdr {
        ovs_be32 spi;  /**< Security Parameters Index */
        ovs_be32 seq;  /**< packet sequence number */
 } __attribute__((__packed__));
diff --git a/include/sparse/rte_flow.h b/include/sparse/rte_flow.h
index a36ab45..be26824 100644
--- a/include/sparse/rte_flow.h
+++ b/include/sparse/rte_flow.h
@@ -478,8 +478,8 @@ static const struct rte_flow_item_raw 
rte_flow_item_raw_mask = {
  * Matches an Ethernet header.
  */
 struct rte_flow_item_eth {
-       struct ether_addr dst; /**< Destination MAC. */
-       struct ether_addr src; /**< Source MAC. */
+       struct rte_ether_addr dst; /**< Destination MAC. */
+       struct rte_ether_addr src; /**< Source MAC. */
        rte_be16_t type; /**< EtherType. */
 };
 
@@ -521,7 +521,7 @@ static const struct rte_flow_item_vlan 
rte_flow_item_vlan_mask = {
  * Note: IPv4 options are handled by dedicated pattern items.
  */
 struct rte_flow_item_ipv4 {
-       struct ipv4_hdr hdr; /**< IPv4 header definition. */
+       struct rte_ipv4_hdr hdr; /**< IPv4 header definition. */
 };
 
 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV4. */
@@ -542,7 +542,7 @@ static const struct rte_flow_item_ipv4 
rte_flow_item_ipv4_mask = {
  * Note: IPv6 options are handled by dedicated pattern items.
  */
 struct rte_flow_item_ipv6 {
-       struct ipv6_hdr hdr; /**< IPv6 header definition. */
+       struct rte_ipv6_hdr hdr; /**< IPv6 header definition. */
 };
 
 /** Default mask for RTE_FLOW_ITEM_TYPE_IPV6. */
@@ -565,7 +565,7 @@ static const struct rte_flow_item_ipv6 
rte_flow_item_ipv6_mask = {
  * Matches an ICMP header.
  */
 struct rte_flow_item_icmp {
-       struct icmp_hdr hdr; /**< ICMP header definition. */
+       struct rte_icmp_hdr hdr; /**< ICMP header definition. */
 };
 
 /** Default mask for RTE_FLOW_ITEM_TYPE_ICMP. */
@@ -584,7 +584,7 @@ static const struct rte_flow_item_icmp 
rte_flow_item_icmp_mask = {
  * Matches a UDP header.
  */
 struct rte_flow_item_udp {
-       struct udp_hdr hdr; /**< UDP header definition. */
+       struct rte_udp_hdr hdr; /**< UDP header definition. */
 };
 
 /** Default mask for RTE_FLOW_ITEM_TYPE_UDP. */
@@ -603,7 +603,7 @@ static const struct rte_flow_item_udp 
rte_flow_item_udp_mask = {
  * Matches a TCP header.
  */
 struct rte_flow_item_tcp {
-       struct tcp_hdr hdr; /**< TCP header definition. */
+       struct rte_tcp_hdr hdr; /**< TCP header definition. */
 };
 
 /** Default mask for RTE_FLOW_ITEM_TYPE_TCP. */
@@ -622,7 +622,7 @@ static const struct rte_flow_item_tcp 
rte_flow_item_tcp_mask = {
  * Matches a SCTP header.
  */
 struct rte_flow_item_sctp {
-       struct sctp_hdr hdr; /**< SCTP header definition. */
+       struct rte_sctp_hdr hdr; /**< SCTP header definition. */
 };
 
 /** Default mask for RTE_FLOW_ITEM_TYPE_SCTP. */
@@ -804,7 +804,7 @@ static const struct rte_flow_item_gtp 
rte_flow_item_gtp_mask = {
  * Matches an ESP header.
  */
 struct rte_flow_item_esp {
-       struct esp_hdr hdr; /**< ESP header definition. */
+       struct rte_esp_hdr hdr; /**< ESP header definition. */
 };
 
 /** Default mask for RTE_FLOW_ITEM_TYPE_ESP. */
diff --git a/include/sparse/rte_icmp.h b/include/sparse/rte_icmp.h
index 62e8b04..f4844ed 100644
--- a/include/sparse/rte_icmp.h
+++ b/include/sparse/rte_icmp.h
@@ -87,7 +87,7 @@ extern "C" {
 /**
  * ICMP Header
  */
-struct icmp_hdr {
+struct rte_icmp_hdr {
        uint8_t  icmp_type;   /* ICMP packet type. */
        uint8_t  icmp_code;   /* ICMP packet code. */
        ovs_be16 icmp_cksum;  /* ICMP packet checksum. */
@@ -96,8 +96,8 @@ struct icmp_hdr {
 } __attribute__((__packed__));
 
 /* ICMP packet types */
-#define IP_ICMP_ECHO_REPLY   0
-#define IP_ICMP_ECHO_REQUEST 8
+#define RTE_IP_ICMP_ECHO_REPLY   0
+#define RTE_IP_ICMP_ECHO_REQUEST 8
 
 #ifdef __cplusplus
 }
diff --git a/include/sparse/rte_ip.h b/include/sparse/rte_ip.h
index b171308..024aada 100644
--- a/include/sparse/rte_ip.h
+++ b/include/sparse/rte_ip.h
@@ -90,7 +90,7 @@ extern "C" {
 /**
  * IPv4 Header
  */
-struct ipv4_hdr {
+struct rte_ipv4_hdr {
        uint8_t  version_ihl;           /**< version and header length */
        uint8_t  type_of_service;       /**< type of service */
        ovs_be16 total_length;          /**< length of packet */
@@ -104,52 +104,52 @@ struct ipv4_hdr {
 } __attribute__((__packed__));
 
 /** Create IPv4 address */
-#define IPv4(a,b,c,d) ((uint32_t)(((a) & 0xff) << 24) | \
+#define RTE_IPV4(a,b,c,d) ((uint32_t)(((a) & 0xff) << 24) | \
                                           (((b) & 0xff) << 16) | \
                                           (((c) & 0xff) << 8)  | \
                                           ((d) & 0xff))
 
 /** Maximal IPv4 packet length (including a header) */
-#define IPV4_MAX_PKT_LEN        65535
+#define RTE_IPV4_MAX_PKT_LEN        65535
 
 /** Internet header length mask for version_ihl field */
-#define IPV4_HDR_IHL_MASK      (0x0f)
+#define RTE_IPV4_HDR_IHL_MASK  (0x0f)
 /**
  * Internet header length field multiplier (IHL field specifies overall header
  * length in number of 4-byte words)
  */
-#define IPV4_IHL_MULTIPLIER    (4)
+#define RTE_IPV4_IHL_MULTIPLIER        (4)
 
 /* Fragment Offset * Flags. */
-#define        IPV4_HDR_DF_SHIFT       14
-#define        IPV4_HDR_MF_SHIFT       13
-#define        IPV4_HDR_FO_SHIFT       3
+#define        RTE_IPV4_HDR_DF_SHIFT   14
+#define        RTE_IPV4_HDR_MF_SHIFT   13
+#define        RTE_IPV4_HDR_FO_SHIFT   3
 
-#define        IPV4_HDR_DF_FLAG        (1 << IPV4_HDR_DF_SHIFT)
-#define        IPV4_HDR_MF_FLAG        (1 << IPV4_HDR_MF_SHIFT)
+#define        RTE_IPV4_HDR_DF_FLAG    (1 << RTE_IPV4_HDR_DF_SHIFT)
+#define        RTE_IPV4_HDR_MF_FLAG    (1 << RTE_IPV4_HDR_MF_SHIFT)
 
-#define        IPV4_HDR_OFFSET_MASK    ((1 << IPV4_HDR_MF_SHIFT) - 1)
+#define        RTE_IPV4_HDR_OFFSET_MASK        ((1 << RTE_IPV4_HDR_MF_SHIFT) - 
1)
 
-#define        IPV4_HDR_OFFSET_UNITS   8
+#define        RTE_IPV4_HDR_OFFSET_UNITS       8
 
 /*
  * IPv4 address types
  */
-#define IPV4_ANY              ((uint32_t)0x00000000) /**< 0.0.0.0 */
-#define IPV4_LOOPBACK         ((uint32_t)0x7f000001) /**< 127.0.0.1 */
-#define IPV4_BROADCAST        ((uint32_t)0xe0000000) /**< 224.0.0.0 */
-#define IPV4_ALLHOSTS_GROUP   ((uint32_t)0xe0000001) /**< 224.0.0.1 */
-#define IPV4_ALLRTRS_GROUP    ((uint32_t)0xe0000002) /**< 224.0.0.2 */
-#define IPV4_MAX_LOCAL_GROUP  ((uint32_t)0xe00000ff) /**< 224.0.0.255 */
+#define RTE_IPV4_ANY              ((uint32_t)0x00000000) /**< 0.0.0.0 */
+#define RTE_IPV4_LOOPBACK         ((uint32_t)0x7f000001) /**< 127.0.0.1 */
+#define RTE_IPV4_BROADCAST        ((uint32_t)0xe0000000) /**< 224.0.0.0 */
+#define RTE_IPV4_ALLHOSTS_GROUP   ((uint32_t)0xe0000001) /**< 224.0.0.1 */
+#define RTE_IPV4_ALLRTRS_GROUP    ((uint32_t)0xe0000002) /**< 224.0.0.2 */
+#define RTE_IPV4_MAX_LOCAL_GROUP  ((uint32_t)0xe00000ff) /**< 224.0.0.255 */
 
 /*
  * IPv4 Multicast-related macros
  */
-#define IPV4_MIN_MCAST  IPv4(224, 0, 0, 0)          /**< Minimal 
IPv4-multicast address */
-#define IPV4_MAX_MCAST  IPv4(239, 255, 255, 255)    /**< Maximum IPv4 
multicast address */
+#define RTE_IPV4_MIN_MCAST  RTE_IPV4(224, 0, 0, 0)          /**< Minimal 
IPv4-multicast address */
+#define RTE_IPV4_MAX_MCAST  RTE_IPV4(239, 255, 255, 255)    /**< Maximum IPv4 
multicast address */
 
-#define IS_IPV4_MCAST(x) \
-       ((x) >= IPV4_MIN_MCAST && (x) <= IPV4_MAX_MCAST) /**< check if IPv4 
address is multicast */
+#define RTE_IS_IPV4_MCAST(x) \
+       ((x) >= RTE_IPV4_MIN_MCAST && (x) <= RTE_IPV4_MAX_MCAST) /**< check if 
IPv4 address is multicast */
 
 /**
  * @internal Calculate a sum of all words in the buffer.
@@ -311,10 +311,10 @@ rte_raw_cksum_mbuf(const struct rte_mbuf *m, uint32_t 
off, uint32_t len,
  *   The complemented checksum to set in the IP packet.
  */
 static inline uint16_t
-rte_ipv4_cksum(const struct ipv4_hdr *ipv4_hdr)
+rte_ipv4_cksum(const struct rte_ipv4_hdr *ipv4_hdr)
 {
        uint16_t cksum;
-       cksum = rte_raw_cksum(ipv4_hdr, sizeof(struct ipv4_hdr));
+       cksum = rte_raw_cksum(ipv4_hdr, sizeof(struct rte_ipv4_hdr));
        return (cksum == 0xffff) ? cksum : ~cksum;
 }
 
@@ -337,7 +337,7 @@ rte_ipv4_cksum(const struct ipv4_hdr *ipv4_hdr)
  *   The non-complemented checksum to set in the L4 header.
  */
 static inline uint16_t
-rte_ipv4_phdr_cksum(const struct ipv4_hdr *ipv4_hdr, uint64_t ol_flags)
+rte_ipv4_phdr_cksum(const struct rte_ipv4_hdr *ipv4_hdr, uint64_t ol_flags)
 {
        struct ipv4_psd_header {
                ovs_be32 src_addr; /* IP address of source host. */
@@ -356,7 +356,7 @@ rte_ipv4_phdr_cksum(const struct ipv4_hdr *ipv4_hdr, 
uint64_t ol_flags)
        } else {
                psd_hdr.len = rte_cpu_to_be_16(
                        (uint16_t)(rte_be_to_cpu_16(ipv4_hdr->total_length)
-                               - sizeof(struct ipv4_hdr)));
+                               - sizeof(struct rte_ipv4_hdr)));
        }
        return rte_raw_cksum(&psd_hdr, sizeof(psd_hdr));
 }
@@ -375,13 +375,13 @@ rte_ipv4_phdr_cksum(const struct ipv4_hdr *ipv4_hdr, 
uint64_t ol_flags)
  *   The complemented checksum to set in the IP packet.
  */
 static inline uint16_t
-rte_ipv4_udptcp_cksum(const struct ipv4_hdr *ipv4_hdr, const void *l4_hdr)
+rte_ipv4_udptcp_cksum(const struct rte_ipv4_hdr *ipv4_hdr, const void *l4_hdr)
 {
        uint32_t cksum;
        uint32_t l4_len;
 
        l4_len = rte_be_to_cpu_16(ipv4_hdr->total_length) -
-               sizeof(struct ipv4_hdr);
+               sizeof(struct rte_ipv4_hdr);
 
        cksum = rte_raw_cksum(l4_hdr, l4_len);
        cksum += rte_ipv4_phdr_cksum(ipv4_hdr, 0);
@@ -397,7 +397,7 @@ rte_ipv4_udptcp_cksum(const struct ipv4_hdr *ipv4_hdr, 
const void *l4_hdr)
 /**
  * IPv6 Header
  */
-struct ipv6_hdr {
+struct rte_ipv6_hdr {
        ovs_be32 vtc_flow;     /**< IP version, traffic class & flow label. */
        ovs_be16 payload_len;  /**< IP packet length - includes 
sizeof(ip_header). */
        uint8_t  proto;        /**< Protocol, next header. */
@@ -407,10 +407,10 @@ struct ipv6_hdr {
 } __attribute__((__packed__));
 
 /* IPv6 vtc_flow: IPv / TC / flow_label */
-#define IPV6_HDR_FL_SHIFT 0
-#define IPV6_HDR_TC_SHIFT 20
-#define IPV6_HDR_FL_MASK ((1u << IPV6_HDR_TC_SHIFT) - 1)
-#define IPV6_HDR_TC_MASK (0xf << IPV6_HDR_TC_SHIFT)
+#define RTE_IPV6_HDR_FL_SHIFT 0
+#define RTE_IPV6_HDR_TC_SHIFT 20
+#define RTE_IPV6_HDR_FL_MASK ((1u << RTE_IPV6_HDR_TC_SHIFT) - 1)
+#define RTE_IPV6_HDR_TC_MASK (0xf << RTE_IPV6_HDR_TC_SHIFT)
 
 /**
  * Process the pseudo-header checksum of an IPv6 header.
@@ -429,7 +429,7 @@ struct ipv6_hdr {
  *   The non-complemented checksum to set in the L4 header.
  */
 static inline uint16_t
-rte_ipv6_phdr_cksum(const struct ipv6_hdr *ipv6_hdr, uint64_t ol_flags)
+rte_ipv6_phdr_cksum(const struct rte_ipv6_hdr *ipv6_hdr, uint64_t ol_flags)
 {
        uint32_t sum;
        struct {
@@ -465,7 +465,7 @@ rte_ipv6_phdr_cksum(const struct ipv6_hdr *ipv6_hdr, 
uint64_t ol_flags)
  *   The complemented checksum to set in the IP packet.
  */
 static inline uint16_t
-rte_ipv6_udptcp_cksum(const struct ipv6_hdr *ipv6_hdr, const void *l4_hdr)
+rte_ipv6_udptcp_cksum(const struct rte_ipv6_hdr *ipv6_hdr, const void *l4_hdr)
 {
        uint32_t cksum;
        uint32_t l4_len;
diff --git a/include/sparse/rte_sctp.h b/include/sparse/rte_sctp.h
index 7428790..1cca2fb 100644
--- a/include/sparse/rte_sctp.h
+++ b/include/sparse/rte_sctp.h
@@ -89,7 +89,7 @@ extern "C" {
 /**
  * SCTP Header
  */
-struct sctp_hdr {
+struct rte_sctp_hdr {
        ovs_be16 src_port; /**< Source port. */
        ovs_be16 dst_port; /**< Destin port. */
        ovs_be32 tag;      /**< Validation tag. */
diff --git a/include/sparse/rte_tcp.h b/include/sparse/rte_tcp.h
index 7295296..0d898d4 100644
--- a/include/sparse/rte_tcp.h
+++ b/include/sparse/rte_tcp.h
@@ -89,7 +89,7 @@ extern "C" {
 /**
  * TCP Header
  */
-struct tcp_hdr {
+struct rte_tcp_hdr {
        ovs_be16 src_port;  /**< TCP source port. */
        ovs_be16 dst_port;  /**< TCP destination port. */
        ovs_be32 sent_seq;  /**< TX data sequence number. */
diff --git a/include/sparse/rte_udp.h b/include/sparse/rte_udp.h
index 8694a1d..4155a56 100644
--- a/include/sparse/rte_udp.h
+++ b/include/sparse/rte_udp.h
@@ -89,7 +89,7 @@ extern "C" {
 /**
  * UDP Header
  */
-struct udp_hdr {
+struct rte_udp_hdr {
        ovs_be16 src_port;    /**< UDP source port. */
        ovs_be16 dst_port;    /**< UDP destination port. */
        ovs_be16 dgram_len;   /**< UDP datagram length */
diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index 4d73237..e86d356 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -84,12 +84,13 @@ static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 
20);
  * The minimum mbuf size is limited to avoid scatter behaviour and drop in
  * performance for standard Ethernet MTU.
  */
-#define ETHER_HDR_MAX_LEN           (ETHER_HDR_LEN + ETHER_CRC_LEN \
+#define ETHER_HDR_MAX_LEN           (RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN \
                                      + (2 * VLAN_HEADER_LEN))
-#define MTU_TO_FRAME_LEN(mtu)       ((mtu) + ETHER_HDR_LEN + ETHER_CRC_LEN)
+#define MTU_TO_FRAME_LEN(mtu)       ((mtu) + RTE_ETHER_HDR_LEN + \
+                                     RTE_ETHER_CRC_LEN)
 #define MTU_TO_MAX_FRAME_LEN(mtu)   ((mtu) + ETHER_HDR_MAX_LEN)
 #define FRAME_LEN_TO_MTU(frame_len) ((frame_len)                    \
-                                     - ETHER_HDR_LEN - ETHER_CRC_LEN)
+                                     - RTE_ETHER_HDR_LEN - RTE_ETHER_CRC_LEN)
 #define NETDEV_DPDK_MBUF_ALIGN      1024
 #define NETDEV_DPDK_MAX_PKT_LEN     9728
 
@@ -594,7 +595,7 @@ dpdk_calculate_mbufs(struct netdev_dpdk *dev, int mtu, bool 
per_port_mp)
          * can change dynamically at runtime. For now, use this rough
          * heurisitic.
          */
-        if (mtu >= ETHER_MTU) {
+        if (mtu >= RTE_ETHER_MTU) {
             n_mbufs = MAX_NB_MBUF;
         } else {
             n_mbufs = MIN_NB_MBUF;
@@ -909,7 +910,7 @@ dpdk_eth_dev_port_config(struct netdev_dpdk *dev, int 
n_rxq, int n_txq)
      * scatter to support jumbo RX.
      * Setting scatter for the device is done after checking for
      * scatter support in the device capabilites. */
-    if (dev->mtu > ETHER_MTU) {
+    if (dev->mtu > RTE_ETHER_MTU) {
         if (dev->hw_ol_features & NETDEV_RX_HW_SCATTER) {
             conf.rxmode.offloads |= DEV_RX_OFFLOAD_SCATTER;
         }
@@ -1021,7 +1022,7 @@ dpdk_eth_dev_init(struct netdev_dpdk *dev)
 {
     struct rte_pktmbuf_pool_private *mbp_priv;
     struct rte_eth_dev_info info;
-    struct ether_addr eth_addr;
+    struct rte_ether_addr eth_addr;
     int diag;
     int n_rxq, n_txq;
     uint32_t rx_chksm_offload_capa = DEV_RX_OFFLOAD_UDP_CKSUM |
@@ -1146,7 +1147,7 @@ common_construct(struct netdev *netdev, dpdk_port_t 
port_no,
     dev->port_id = port_no;
     dev->type = type;
     dev->flags = 0;
-    dev->requested_mtu = ETHER_MTU;
+    dev->requested_mtu = RTE_ETHER_MTU;
     dev->max_packet_len = MTU_TO_FRAME_LEN(dev->mtu);
     dev->requested_lsc_interrupt_mode = 0;
     ovsrcu_index_init(&dev->vid, -1);
@@ -1654,7 +1655,7 @@ netdev_dpdk_get_port_by_mac(const char *mac_str)
     }
 
     RTE_ETH_FOREACH_DEV (port_id) {
-        struct ether_addr ea;
+        struct rte_ether_addr ea;
 
         rte_eth_macaddr_get(port_id, &ea);
         memcpy(port_mac.ea, ea.addr_bytes, ETH_ADDR_LEN);
@@ -2022,7 +2023,7 @@ netdev_dpdk_policer_pkt_handle(struct rte_meter_srtcm 
*meter,
                                struct rte_meter_srtcm_profile *profile,
                                struct rte_mbuf *pkt, uint64_t time)
 {
-    uint32_t pkt_len = rte_pktmbuf_pkt_len(pkt) - sizeof(struct ether_hdr);
+    uint32_t pkt_len = rte_pktmbuf_pkt_len(pkt) - sizeof(struct rte_ether_hdr);
 
     return rte_meter_srtcm_color_blind_check(meter, profile, time, pkt_len) ==
                                              RTE_COLOR_GREEN;
@@ -2551,7 +2552,7 @@ netdev_dpdk_set_mtu(struct netdev *netdev, int mtu)
      * a method to retrieve the upper bound MTU for a given device.
      */
     if (MTU_TO_MAX_FRAME_LEN(mtu) > NETDEV_DPDK_MAX_PKT_LEN
-        || mtu < ETHER_MIN_MTU) {
+        || mtu < RTE_ETHER_MIN_MTU) {
         VLOG_WARN("%s: unsupported MTU %d\n", dev->up.name, mtu);
         return EINVAL;
     }
-- 
1.8.3.1

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to