dpif_packet: Rename to dp_packet
authorPravin B Shelar <pshelar@nicira.com>
Wed, 25 Feb 2015 20:01:53 +0000 (12:01 -0800)
committerPravin B Shelar <pshelar@nicira.com>
Tue, 3 Mar 2015 21:37:34 +0000 (13:37 -0800)
dp_packet is short and better name for datapath packet
structure.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Jarno Rajahalme <jrajahalme@nicira.com>
22 files changed:
lib/automake.mk
lib/dp-packet.c [new file with mode: 0644]
lib/dp-packet.h [new file with mode: 0644]
lib/dpif-netdev.c
lib/dpif.c
lib/netdev-bsd.c
lib/netdev-dpdk.c
lib/netdev-dpdk.h
lib/netdev-dummy.c
lib/netdev-linux.c
lib/netdev-provider.h
lib/netdev-vport.c
lib/netdev.c
lib/netdev.h
lib/odp-execute.c
lib/odp-execute.h
lib/ofpbuf.c
lib/ofpbuf.h
lib/packet-dpif.c [deleted file]
lib/packet-dpif.h [deleted file]
lib/tnl-arp-cache.c
ofproto/ofproto-dpif-xlate.c

index 2a5844b..87441f7 100644 (file)
@@ -60,6 +60,8 @@ lib_libopenvswitch_la_SOURCES = \
        lib/dirs.h \
        lib/dpctl.c \
        lib/dpctl.h \
+       lib/dp-packet.h \
+       lib/dp-packet.c \
        lib/dpif-netdev.c \
        lib/dpif-netdev.h \
        lib/dpif-provider.h \
@@ -177,8 +179,6 @@ lib_libopenvswitch_la_SOURCES = \
        lib/ovsdb-parser.h \
        lib/ovsdb-types.c \
        lib/ovsdb-types.h \
-       lib/packet-dpif.c \
-       lib/packet-dpif.h \
        lib/packets.c \
        lib/packets.h \
        lib/pcap-file.c \
diff --git a/lib/dp-packet.c b/lib/dp-packet.c
new file mode 100644 (file)
index 0000000..d77f8e4
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2014 Nicira, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <config.h>
+#include "dp-packet.h"
+
+#include "ofpbuf.h"
+
+struct dp_packet *
+dp_packet_new_with_headroom(size_t size, size_t headroom)
+{
+    struct dp_packet *p = xmalloc(sizeof *p);
+    struct ofpbuf *b = &p->ofpbuf;
+
+    ofpbuf_init(b, size + headroom);
+    ofpbuf_reserve(b, headroom);
+    p->md = PKT_METADATA_INITIALIZER(0);
+
+    return p;
+}
+
+struct dp_packet *
+dp_packet_clone_from_ofpbuf(const struct ofpbuf *b)
+{
+    struct dp_packet *p = xmalloc(sizeof *p);
+    size_t headroom = ofpbuf_headroom(b);
+
+    ofpbuf_init(&p->ofpbuf, ofpbuf_size(b) + headroom);
+    p->md = PKT_METADATA_INITIALIZER(0);
+    ofpbuf_reserve(&p->ofpbuf, headroom);
+
+    ofpbuf_put(&p->ofpbuf, ofpbuf_data(b), ofpbuf_size(b));
+
+    if (b->frame) {
+        uintptr_t data_delta
+            = (char *)ofpbuf_data(&p->ofpbuf) - (char *)ofpbuf_data(b);
+
+        p->ofpbuf.frame = (char *) b->frame + data_delta;
+    }
+    p->ofpbuf.l2_5_ofs = b->l2_5_ofs;
+    p->ofpbuf.l3_ofs = b->l3_ofs;
+    p->ofpbuf.l4_ofs = b->l4_ofs;
+
+    return p;
+}
+
+struct dp_packet *
+dp_packet_clone(struct dp_packet *p)
+{
+    struct dp_packet *newp;
+
+    newp = dp_packet_clone_from_ofpbuf(&p->ofpbuf);
+    memcpy(&newp->md, &p->md, sizeof p->md);
+
+    dp_packet_set_dp_hash(newp, dp_packet_get_dp_hash(p));
+
+    return newp;
+}
diff --git a/lib/dp-packet.h b/lib/dp-packet.h
new file mode 100644 (file)
index 0000000..74abdec
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2014 Nicira, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef PACKET_DPIF_H
+#define PACKET_DPIF_H 1
+
+#include "ofpbuf.h"
+
+#ifdef  __cplusplus
+extern "C" {
+#endif
+
+/* A packet received from a netdev and passed to a dpif. */
+
+struct dp_packet {
+    struct ofpbuf ofpbuf;       /* Packet data. */
+#ifndef DPDK_NETDEV
+    uint32_t dp_hash;           /* Packet hash. */
+#endif
+    struct pkt_metadata md;
+};
+
+struct dp_packet *dp_packet_new_with_headroom(size_t size,
+                                                  size_t headroom);
+
+struct dp_packet *dp_packet_clone_from_ofpbuf(const struct ofpbuf *b);
+
+struct dp_packet *dp_packet_clone(struct dp_packet *p);
+
+static inline void dp_packet_delete(struct dp_packet *p)
+{
+    struct ofpbuf *buf = &p->ofpbuf;
+
+    ofpbuf_delete(buf);
+}
+
+static inline uint32_t dp_packet_get_dp_hash(struct dp_packet *p)
+{
+#ifdef DPDK_NETDEV
+    return p->ofpbuf.mbuf.pkt.hash.rss;
+#else
+    return p->dp_hash;
+#endif
+}
+
+static inline void dp_packet_set_dp_hash(struct dp_packet *p,
+                                           uint32_t hash)
+{
+#ifdef DPDK_NETDEV
+    p->ofpbuf.mbuf.pkt.hash.rss = hash;
+#else
+    p->dp_hash = hash;
+#endif
+}
+
+#ifdef  __cplusplus
+}
+#endif
+
+#endif /* dp-packet.h */
index 54bad02..70ef97b 100644 (file)
@@ -33,6 +33,7 @@
 
 #include "cmap.h"
 #include "csum.h"
+#include "dp-packet.h"
 #include "dpif.h"
 #include "dpif-provider.h"
 #include "dummy.h"
@@ -54,7 +55,6 @@
 #include "ofpbuf.h"
 #include "ovs-numa.h"
 #include "ovs-rcu.h"
-#include "packet-dpif.h"
 #include "packets.h"
 #include "poll-loop.h"
 #include "pvector.h"
@@ -415,12 +415,12 @@ static void do_del_port(struct dp_netdev *dp, struct dp_netdev_port *)
 static int dpif_netdev_open(const struct dpif_class *, const char *name,
                             bool create, struct dpif **);
 static void dp_netdev_execute_actions(struct dp_netdev_pmd_thread *pmd,
-                                      struct dpif_packet **, int c,
+                                      struct dp_packet **, int c,
                                       bool may_steal,
                                       const struct nlattr *actions,
                                       size_t actions_len);
 static void dp_netdev_input(struct dp_netdev_pmd_thread *,
-                            struct dpif_packet **, int cnt);
+                            struct dp_packet **, int cnt);
 
 static void dp_netdev_disable_upcall(struct dp_netdev *);
 void dp_netdev_pmd_reload_done(struct dp_netdev_pmd_thread *pmd);
@@ -2046,7 +2046,7 @@ dpif_netdev_execute(struct dpif *dpif, struct dpif_execute *execute)
 {
     struct dp_netdev *dp = get_dp_netdev(dpif);
     struct dp_netdev_pmd_thread *pmd;
-    struct dpif_packet packet, *pp;
+    struct dp_packet packet, *pp;
 
     if (ofpbuf_size(execute->packet) < ETH_HEADER_LEN ||
         ofpbuf_size(execute->packet) > UINT16_MAX) {
@@ -2230,7 +2230,7 @@ dp_netdev_process_rxq_port(struct dp_netdev_pmd_thread *pmd,
                            struct dp_netdev_port *port,
                            struct netdev_rxq *rxq)
 {
-    struct dpif_packet *packets[NETDEV_MAX_RX_BATCH];
+    struct dp_packet *packets[NETDEV_MAX_RX_BATCH];
     int error, cnt;
 
     error = netdev_rxq_recv(rxq, packets, &cnt);
@@ -2693,7 +2693,7 @@ dp_netdev_count_packet(struct dp_netdev_pmd_thread *pmd,
 }
 
 static int
-dp_netdev_upcall(struct dp_netdev_pmd_thread *pmd, struct dpif_packet *packet_,
+dp_netdev_upcall(struct dp_netdev_pmd_thread *pmd, struct dp_packet *packet_,
                  struct flow *flow, struct flow_wildcards *wc, ovs_u128 *ufid,
                  enum dpif_upcall_type type, const struct nlattr *userdata,
                  struct ofpbuf *actions, struct ofpbuf *put_actions)
@@ -2736,15 +2736,15 @@ dp_netdev_upcall(struct dp_netdev_pmd_thread *pmd, struct dpif_packet *packet_,
 }
 
 static inline uint32_t
-dpif_netdev_packet_get_dp_hash(struct dpif_packet *packet,
+dpif_netdev_packet_get_dp_hash(struct dp_packet *packet,
                                const struct miniflow *mf)
 {
     uint32_t hash;
 
-    hash = dpif_packet_get_dp_hash(packet);
+    hash = dp_packet_get_dp_hash(packet);
     if (OVS_UNLIKELY(!hash)) {
         hash = miniflow_hash_5tuple(mf, 0);
-        dpif_packet_set_dp_hash(packet, hash);
+        dp_packet_set_dp_hash(packet, hash);
     }
     return hash;
 }
@@ -2756,11 +2756,11 @@ struct packet_batch {
 
     struct dp_netdev_flow *flow;
 
-    struct dpif_packet *packets[NETDEV_MAX_RX_BATCH];
+    struct dp_packet *packets[NETDEV_MAX_RX_BATCH];
 };
 
 static inline void
-packet_batch_update(struct packet_batch *batch, struct dpif_packet *packet,
+packet_batch_update(struct packet_batch *batch, struct dp_packet *packet,
                     const struct miniflow *mf)
 {
     batch->tcp_flags |= miniflow_get_tcp_flags(mf);
@@ -2797,7 +2797,7 @@ packet_batch_execute(struct packet_batch *batch,
 }
 
 static inline bool
-dp_netdev_queue_batches(struct dpif_packet *pkt,
+dp_netdev_queue_batches(struct dp_packet *pkt,
                         struct dp_netdev_flow *flow, const struct miniflow *mf,
                         struct packet_batch *batches, size_t *n_batches,
                         size_t max_batches)
@@ -2832,9 +2832,9 @@ dp_netdev_queue_batches(struct dpif_packet *pkt,
 }
 
 static inline void
-dpif_packet_swap(struct dpif_packet **a, struct dpif_packet **b)
+dp_packet_swap(struct dp_packet **a, struct dp_packet **b)
 {
-    struct dpif_packet *tmp = *a;
+    struct dp_packet *tmp = *a;
     *a = *b;
     *b = tmp;
 }
@@ -2848,7 +2848,7 @@ dpif_packet_swap(struct dpif_packet **a, struct dpif_packet **b)
  * 'packets' array (they have been moved to the beginning of the vector).
  */
 static inline size_t
-emc_processing(struct dp_netdev_pmd_thread *pmd, struct dpif_packet **packets,
+emc_processing(struct dp_netdev_pmd_thread *pmd, struct dp_packet **packets,
                size_t cnt, struct netdev_flow_key *keys)
 {
     struct netdev_flow_key key;
@@ -2863,7 +2863,7 @@ emc_processing(struct dp_netdev_pmd_thread *pmd, struct dpif_packet **packets,
         struct dp_netdev_flow *flow;
 
         if (OVS_UNLIKELY(ofpbuf_size(&packets[i]->ofpbuf) < ETH_HEADER_LEN)) {
-            dpif_packet_delete(packets[i]);
+            dp_packet_delete(packets[i]);
             continue;
         }
 
@@ -2876,7 +2876,7 @@ emc_processing(struct dp_netdev_pmd_thread *pmd, struct dpif_packet **packets,
                                                   batches, &n_batches,
                                                   ARRAY_SIZE(batches)))) {
             if (i != notfound_cnt) {
-                dpif_packet_swap(&packets[i], &packets[notfound_cnt]);
+                dp_packet_swap(&packets[i], &packets[notfound_cnt]);
             }
 
             keys[notfound_cnt++] = key;
@@ -2892,7 +2892,7 @@ emc_processing(struct dp_netdev_pmd_thread *pmd, struct dpif_packet **packets,
 
 static inline void
 fast_path_processing(struct dp_netdev_pmd_thread *pmd,
-                     struct dpif_packet **packets, size_t cnt,
+                     struct dp_packet **packets, size_t cnt,
                      struct netdev_flow_key *keys)
 {
 #if !defined(__CHECKER__) && !defined(_WIN32)
@@ -2992,7 +2992,7 @@ fast_path_processing(struct dp_netdev_pmd_thread *pmd,
 
         for (i = 0; i < cnt; i++) {
             if (OVS_UNLIKELY(!rules[i])) {
-                dpif_packet_delete(packets[i]);
+                dp_packet_delete(packets[i]);
                 dropped_cnt++;
             }
         }
@@ -3002,7 +3002,7 @@ fast_path_processing(struct dp_netdev_pmd_thread *pmd,
 
     n_batches = 0;
     for (i = 0; i < cnt; i++) {
-        struct dpif_packet *packet = packets[i];
+        struct dp_packet *packet = packets[i];
         struct dp_netdev_flow *flow;
 
         if (OVS_UNLIKELY(!rules[i])) {
@@ -3023,7 +3023,7 @@ fast_path_processing(struct dp_netdev_pmd_thread *pmd,
 
 static void
 dp_netdev_input(struct dp_netdev_pmd_thread *pmd,
-                struct dpif_packet **packets, int cnt)
+                struct dp_packet **packets, int cnt)
 {
 #if !defined(__CHECKER__) && !defined(_WIN32)
     const size_t PKT_ARRAY_SIZE = cnt;
@@ -3054,13 +3054,13 @@ dpif_netdev_register_upcall_cb(struct dpif *dpif, upcall_callback *cb,
 }
 
 static void
-dp_netdev_drop_packets(struct dpif_packet ** packets, int cnt, bool may_steal)
+dp_netdev_drop_packets(struct dp_packet ** packets, int cnt, bool may_steal)
 {
     if (may_steal) {
         int i;
 
         for (i = 0; i < cnt; i++) {
-            dpif_packet_delete(packets[i]);
+            dp_packet_delete(packets[i]);
         }
     }
 }
@@ -3068,7 +3068,7 @@ dp_netdev_drop_packets(struct dpif_packet ** packets, int cnt, bool may_steal)
 static int
 push_tnl_action(const struct dp_netdev *dp,
                    const struct nlattr *attr,
-                   struct dpif_packet **packets, int cnt)
+                   struct dp_packet **packets, int cnt)
 {
     struct dp_netdev_port *tun_port;
     const struct ovs_action_push_tnl *data;
@@ -3085,18 +3085,18 @@ push_tnl_action(const struct dp_netdev *dp,
 }
 
 static void
-dp_netdev_clone_pkt_batch(struct dpif_packet **tnl_pkt,
-                          struct dpif_packet **packets, int cnt)
+dp_netdev_clone_pkt_batch(struct dp_packet **tnl_pkt,
+                          struct dp_packet **packets, int cnt)
 {
     int i;
 
     for (i = 0; i < cnt; i++) {
-        tnl_pkt[i] = dpif_packet_clone(packets[i]);
+        tnl_pkt[i] = dp_packet_clone(packets[i]);
     }
 }
 
 static void
-dp_execute_cb(void *aux_, struct dpif_packet **packets, int cnt,
+dp_execute_cb(void *aux_, struct dp_packet **packets, int cnt,
               const struct nlattr *a, bool may_steal)
     OVS_NO_THREAD_SAFETY_ANALYSIS
 {
@@ -3119,7 +3119,7 @@ dp_execute_cb(void *aux_, struct dpif_packet **packets, int cnt,
 
     case OVS_ACTION_ATTR_TUNNEL_PUSH:
         if (*depth < MAX_RECIRC_DEPTH) {
-            struct dpif_packet *tnl_pkt[NETDEV_MAX_RX_BATCH];
+            struct dp_packet *tnl_pkt[NETDEV_MAX_RX_BATCH];
             int err;
 
             if (!may_steal) {
@@ -3145,7 +3145,7 @@ dp_execute_cb(void *aux_, struct dpif_packet **packets, int cnt,
 
             p = dp_netdev_lookup_port(dp, portno);
             if (p) {
-                struct dpif_packet *tnl_pkt[NETDEV_MAX_RX_BATCH];
+                struct dp_packet *tnl_pkt[NETDEV_MAX_RX_BATCH];
                 int err;
 
                 if (!may_steal) {
@@ -3196,7 +3196,7 @@ dp_execute_cb(void *aux_, struct dpif_packet **packets, int cnt,
                                               ofpbuf_data(&actions),
                                               ofpbuf_size(&actions));
                 } else if (may_steal) {
-                    dpif_packet_delete(packets[i]);
+                    dp_packet_delete(packets[i]);
                 }
             }
             ofpbuf_uninit(&actions);
@@ -3211,15 +3211,15 @@ dp_execute_cb(void *aux_, struct dpif_packet **packets, int cnt,
 
             (*depth)++;
             for (i = 0; i < cnt; i++) {
-                struct dpif_packet *recirc_pkt;
+                struct dp_packet *recirc_pkt;
 
                 recirc_pkt = (may_steal) ? packets[i]
-                                    : dpif_packet_clone(packets[i]);
+                                    : dp_packet_clone(packets[i]);
 
                 recirc_pkt->md.recirc_id = nl_attr_get_u32(a);
 
                 /* Hash is private to each packet */
-                recirc_pkt->md.dp_hash = dpif_packet_get_dp_hash(packets[i]);
+                recirc_pkt->md.dp_hash = dp_packet_get_dp_hash(packets[i]);
 
                 dp_netdev_input(pmd, &recirc_pkt, 1);
             }
@@ -3249,7 +3249,7 @@ dp_execute_cb(void *aux_, struct dpif_packet **packets, int cnt,
 
 static void
 dp_netdev_execute_actions(struct dp_netdev_pmd_thread *pmd,
-                          struct dpif_packet **packets, int cnt,
+                          struct dp_packet **packets, int cnt,
                           bool may_steal,
                           const struct nlattr *actions, size_t actions_len)
 {
index 6ecd1d9..44cd54a 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "coverage.h"
 #include "dpctl.h"
+#include "dp-packet.h"
 #include "dynamic-string.h"
 #include "flow.h"
 #include "netdev.h"
@@ -35,7 +36,6 @@
 #include "ofp-print.h"
 #include "ofp-util.h"
 #include "ofpbuf.h"
-#include "packet-dpif.h"
 #include "packets.h"
 #include "poll-loop.h"
 #include "route-table.h"
@@ -1075,7 +1075,7 @@ struct dpif_execute_helper_aux {
 /* This is called for actions that need the context of the datapath to be
  * meaningful. */
 static void
-dpif_execute_helper_cb(void *aux_, struct dpif_packet **packets, int cnt,
+dpif_execute_helper_cb(void *aux_, struct dp_packet **packets, int cnt,
                        const struct nlattr *action, bool may_steal OVS_UNUSED)
 {
     struct dpif_execute_helper_aux *aux = aux_;
@@ -1146,7 +1146,7 @@ static int
 dpif_execute_with_help(struct dpif *dpif, struct dpif_execute *execute)
 {
     struct dpif_execute_helper_aux aux = {dpif, 0};
-    struct dpif_packet packet, *pp;
+    struct dp_packet packet, *pp;
 
     COVERAGE_INC(dpif_execute_with_help);
 
index 00e8bcd..36a2642 100644 (file)
 
 #include "rtbsd.h"
 #include "coverage.h"
+#include "dp-packet.h"
 #include "dpif-netdev.h"
 #include "dynamic-string.h"
 #include "fatal-signal.h"
 #include "ofpbuf.h"
 #include "openflow/openflow.h"
 #include "ovs-thread.h"
-#include "packet-dpif.h"
 #include "packets.h"
 #include "poll-loop.h"
 #include "shash.h"
@@ -621,12 +621,12 @@ netdev_rxq_bsd_recv_tap(struct netdev_rxq_bsd *rxq, struct ofpbuf *buffer)
 }
 
 static int
-netdev_bsd_rxq_recv(struct netdev_rxq *rxq_, struct dpif_packet **packets,
+netdev_bsd_rxq_recv(struct netdev_rxq *rxq_, struct dp_packet **packets,
                     int *c)
 {
     struct netdev_rxq_bsd *rxq = netdev_rxq_bsd_cast(rxq_);
     struct netdev *netdev = rxq->up.netdev;
-    struct dpif_packet *packet;
+    struct dp_packet *packet;
     struct ofpbuf *buffer;
     ssize_t retval;
     int mtu;
@@ -635,7 +635,7 @@ netdev_bsd_rxq_recv(struct netdev_rxq *rxq_, struct dpif_packet **packets,
         mtu = ETH_PAYLOAD_MAX;
     }
 
-    packet = dpif_packet_new_with_headroom(VLAN_ETH_HEADER_LEN + mtu,
+    packet = dp_packet_new_with_headroom(VLAN_ETH_HEADER_LEN + mtu,
                                            DP_NETDEV_HEADROOM);
     buffer = &packet->ofpbuf;
 
@@ -644,10 +644,10 @@ netdev_bsd_rxq_recv(struct netdev_rxq *rxq_, struct dpif_packet **packets,
             : netdev_rxq_bsd_recv_tap(rxq, buffer));
 
     if (retval) {
-        dpif_packet_delete(packet);
+        dp_packet_delete(packet);
     } else {
         dp_packet_pad(buffer);
-        dpif_packet_set_dp_hash(packet, 0);
+        dp_packet_set_dp_hash(packet, 0);
         packets[0] = packet;
         *c = 1;
     }
@@ -688,7 +688,7 @@ netdev_bsd_rxq_drain(struct netdev_rxq *rxq_)
  */
 static int
 netdev_bsd_send(struct netdev *netdev_, int qid OVS_UNUSED,
-                struct dpif_packet **pkts, int cnt, bool may_steal)
+                struct dp_packet **pkts, int cnt, bool may_steal)
 {
     struct netdev_bsd *dev = netdev_bsd_cast(netdev_);
     const char *name = netdev_get_name(netdev_);
@@ -737,7 +737,7 @@ netdev_bsd_send(struct netdev *netdev_, int qid OVS_UNUSED,
     ovs_mutex_unlock(&dev->mutex);
     if (may_steal) {
         for (i = 0; i < cnt; i++) {
-            dpif_packet_delete(pkts[i]);
+            dp_packet_delete(pkts[i]);
         }
     }
 
index aea2016..34dd706 100644 (file)
@@ -28,6 +28,7 @@
 #include <unistd.h>
 #include <stdio.h>
 
+#include "dp-packet.h"
 #include "dpif-netdev.h"
 #include "list.h"
 #include "netdev-dpdk.h"
@@ -39,7 +40,6 @@
 #include "ovs-numa.h"
 #include "ovs-thread.h"
 #include "ovs-rcu.h"
-#include "packet-dpif.h"
 #include "packets.h"
 #include "shash.h"
 #include "sset.h"
@@ -238,7 +238,7 @@ dpdk_rte_mzalloc(size_t sz)
 /* XXX this function should be called only by pmd threads (or by non pmd
  * threads holding the nonpmd_mempool_mutex) */
 void
-free_dpdk_buf(struct dpif_packet *p)
+free_dpdk_buf(struct dp_packet *p)
 {
     struct rte_mbuf *pkt = (struct rte_mbuf *) p;
 
@@ -252,16 +252,16 @@ __rte_pktmbuf_init(struct rte_mempool *mp,
                    unsigned i OVS_UNUSED)
 {
     struct rte_mbuf *m = _m;
-    uint32_t buf_len = mp->elt_size - sizeof(struct dpif_packet);
+    uint32_t buf_len = mp->elt_size - sizeof(struct dp_packet);
 
-    RTE_MBUF_ASSERT(mp->elt_size >= sizeof(struct dpif_packet));
+    RTE_MBUF_ASSERT(mp->elt_size >= sizeof(struct dp_packet));
 
     memset(m, 0, mp->elt_size);
 
     /* start of buffer is just after mbuf structure */
-    m->buf_addr = (char *)m + sizeof(struct dpif_packet);
+    m->buf_addr = (char *)m + sizeof(struct dp_packet);
     m->buf_physaddr = rte_mempool_virt2phy(mp, m) +
-                    sizeof(struct dpif_packet);
+                    sizeof(struct dp_packet);
     m->buf_len = (uint16_t)buf_len;
 
     /* keep some headroom between start of buffer and data */
@@ -731,7 +731,7 @@ dpdk_queue_flush(struct netdev_dpdk *dev, int qid)
 }
 
 static int
-netdev_dpdk_rxq_recv(struct netdev_rxq *rxq_, struct dpif_packet **packets,
+netdev_dpdk_rxq_recv(struct netdev_rxq *rxq_, struct dp_packet **packets,
                      int *c)
 {
     struct netdev_rxq_dpdk *rx = netdev_rxq_dpdk_cast(rxq_);
@@ -789,7 +789,7 @@ dpdk_queue_pkts(struct netdev_dpdk *dev, int qid,
 
 /* Tx function. Transmit packets indefinitely */
 static void
-dpdk_do_tx_copy(struct netdev *netdev, int qid, struct dpif_packet ** pkts,
+dpdk_do_tx_copy(struct netdev *netdev, int qid, struct dp_packet ** pkts,
                 int cnt)
     OVS_NO_THREAD_SAFETY_ANALYSIS
 {
@@ -849,7 +849,7 @@ dpdk_do_tx_copy(struct netdev *netdev, int qid, struct dpif_packet ** pkts,
 
 static inline void
 netdev_dpdk_send__(struct netdev_dpdk *dev, int qid,
-                   struct dpif_packet **pkts, int cnt, bool may_steal)
+                   struct dp_packet **pkts, int cnt, bool may_steal)
 {
     int i;
 
@@ -861,7 +861,7 @@ netdev_dpdk_send__(struct netdev_dpdk *dev, int qid,
 
         if (may_steal) {
             for (i = 0; i < cnt; i++) {
-                dpif_packet_delete(pkts[i]);
+                dp_packet_delete(pkts[i]);
             }
         }
     } else {
@@ -880,7 +880,7 @@ netdev_dpdk_send__(struct netdev_dpdk *dev, int qid,
                 VLOG_WARN_RL(&rl, "Too big size %d max_packet_len %d",
                              (int)size , dev->max_packet_len);
 
-                dpif_packet_delete(pkts[i]);
+                dp_packet_delete(pkts[i]);
                 dropped++;
                 next_tx_idx = i + 1;
             }
@@ -901,7 +901,7 @@ netdev_dpdk_send__(struct netdev_dpdk *dev, int qid,
 
 static int
 netdev_dpdk_eth_send(struct netdev *netdev, int qid,
-                     struct dpif_packet **pkts, int cnt, bool may_steal)
+                     struct dp_packet **pkts, int cnt, bool may_steal)
 {
     struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
 
@@ -1371,7 +1371,7 @@ dpdk_ring_open(const char dev_name[], unsigned int *eth_port_id) OVS_REQUIRES(dp
 
 static int
 netdev_dpdk_ring_send(struct netdev *netdev, int qid OVS_UNUSED,
-                      struct dpif_packet **pkts, int cnt, bool may_steal)
+                      struct dp_packet **pkts, int cnt, bool may_steal)
 {
     struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
 
index 694899c..d3840f9 100644 (file)
@@ -3,7 +3,7 @@
 
 #include <config.h>
 
-struct dpif_packet;
+struct dp_packet;
 
 /* Reserves cpu core 0 for all non-pmd threads.  Changing the value of this
  * macro will allow pmd thread to be pinned on cpu core 0.  This may not be
@@ -27,7 +27,7 @@ struct dpif_packet;
 
 int dpdk_init(int argc, char **argv);
 void netdev_dpdk_register(void);
-void free_dpdk_buf(struct dpif_packet *);
+void free_dpdk_buf(struct dp_packet *);
 int pmd_thread_setaffinity_cpu(int cpu);
 void thread_set_nonpmd(void);
 
@@ -51,7 +51,7 @@ netdev_dpdk_register(void)
 }
 
 static inline void
-free_dpdk_buf(struct dpif_packet *buf OVS_UNUSED)
+free_dpdk_buf(struct dp_packet *buf OVS_UNUSED)
 {
     /* Nothing */
 }
index fcb0b77..5abac31 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <errno.h>
 
+#include "dp-packet.h"
 #include "dpif-netdev.h"
 #include "dynamic-string.h"
 #include "flow.h"
@@ -29,7 +30,6 @@
 #include "odp-util.h"
 #include "ofp-print.h"
 #include "ofpbuf.h"
-#include "packet-dpif.h"
 #include "packets.h"
 #include "pcap-file.h"
 #include "poll-loop.h"
@@ -808,7 +808,7 @@ netdev_dummy_rxq_dealloc(struct netdev_rxq *rxq_)
 }
 
 static int
-netdev_dummy_rxq_recv(struct netdev_rxq *rxq_, struct dpif_packet **arr,
+netdev_dummy_rxq_recv(struct netdev_rxq *rxq_, struct dp_packet **arr,
                       int *c)
 {
     struct netdev_rxq_dummy *rx = netdev_rxq_dummy_cast(rxq_);
@@ -835,8 +835,8 @@ netdev_dummy_rxq_recv(struct netdev_rxq *rxq_, struct dpif_packet **arr,
     dp_packet_pad(packet);
 
     /* This performs a (sometimes unnecessary) copy */
-    arr[0] = dpif_packet_clone_from_ofpbuf(packet);
-    dpif_packet_set_dp_hash(arr[0], 0);
+    arr[0] = dp_packet_clone_from_ofpbuf(packet);
+    dp_packet_set_dp_hash(arr[0], 0);
     ofpbuf_delete(packet);
     *c = 1;
     return 0;
@@ -876,7 +876,7 @@ netdev_dummy_rxq_drain(struct netdev_rxq *rxq_)
 
 static int
 netdev_dummy_send(struct netdev *netdev, int qid OVS_UNUSED,
-                  struct dpif_packet **pkts, int cnt, bool may_steal)
+                  struct dp_packet **pkts, int cnt, bool may_steal)
 {
     struct netdev_dummy *dev = netdev_dummy_cast(netdev);
     int error = 0;
@@ -925,7 +925,7 @@ netdev_dummy_send(struct netdev *netdev, int qid OVS_UNUSED,
 
     if (may_steal) {
         for (i = 0; i < cnt; i++) {
-            dpif_packet_delete(pkts[i]);
+            dp_packet_delete(pkts[i]);
         }
     }
 
index a1e4979..2b7ceaf 100644 (file)
@@ -48,6 +48,7 @@
 #include <unistd.h>
 
 #include "coverage.h"
+#include "dp-packet.h"
 #include "dpif-netlink.h"
 #include "dpif-netdev.h"
 #include "dynamic-string.h"
@@ -62,7 +63,6 @@
 #include "ofpbuf.h"
 #include "openflow/openflow.h"
 #include "ovs-atomic.h"
-#include "packet-dpif.h"
 #include "packets.h"
 #include "poll-loop.h"
 #include "rtnetlink-link.h"
@@ -1024,12 +1024,12 @@ netdev_linux_rxq_recv_tap(int fd, struct ofpbuf *buffer)
 }
 
 static int
-netdev_linux_rxq_recv(struct netdev_rxq *rxq_, struct dpif_packet **packets,
+netdev_linux_rxq_recv(struct netdev_rxq *rxq_, struct dp_packet **packets,
                       int *c)
 {
     struct netdev_rxq_linux *rx = netdev_rxq_linux_cast(rxq_);
     struct netdev *netdev = rx->up.netdev;
-    struct dpif_packet *packet;
+    struct dp_packet *packet;
     struct ofpbuf *buffer;
     ssize_t retval;
     int mtu;
@@ -1038,7 +1038,7 @@ netdev_linux_rxq_recv(struct netdev_rxq *rxq_, struct dpif_packet **packets,
         mtu = ETH_PAYLOAD_MAX;
     }
 
-    packet = dpif_packet_new_with_headroom(VLAN_ETH_HEADER_LEN + mtu,
+    packet = dp_packet_new_with_headroom(VLAN_ETH_HEADER_LEN + mtu,
                                            DP_NETDEV_HEADROOM);
     buffer = &packet->ofpbuf;
 
@@ -1051,10 +1051,10 @@ netdev_linux_rxq_recv(struct netdev_rxq *rxq_, struct dpif_packet **packets,
             VLOG_WARN_RL(&rl, "error receiving Ethernet packet on %s: %s",
                          ovs_strerror(errno), netdev_rxq_get_name(rxq_));
         }
-        dpif_packet_delete(packet);
+        dp_packet_delete(packet);
     } else {
         dp_packet_pad(buffer);
-        dpif_packet_set_dp_hash(packet, 0);
+        dp_packet_set_dp_hash(packet, 0);
         packets[0] = packet;
         *c = 1;
     }
@@ -1098,7 +1098,7 @@ netdev_linux_rxq_drain(struct netdev_rxq *rxq_)
  * expected to do additional queuing of packets. */
 static int
 netdev_linux_send(struct netdev *netdev_, int qid OVS_UNUSED,
-                  struct dpif_packet **pkts, int cnt, bool may_steal)
+                  struct dp_packet **pkts, int cnt, bool may_steal)
 {
     int i;
     int error = 0;
@@ -1180,7 +1180,7 @@ netdev_linux_send(struct netdev *netdev_, int qid OVS_UNUSED,
 
     if (may_steal) {
         for (i = 0; i < cnt; i++) {
-            dpif_packet_delete(pkts[i]);
+            dp_packet_delete(pkts[i]);
         }
     }
 
index e0b76fc..915e54a 100644 (file)
@@ -264,13 +264,13 @@ struct netdev_class {
      * a packet on actual transmit.  It uses partial header build by
      * build_header() which is passed as data. */
     int (*push_header)(const struct netdev *netdev,
-                       struct dpif_packet **buffers, int cnt,
+                       struct dp_packet **buffers, int cnt,
                        const struct ovs_action_push_tnl *data);
 
     /* Pop tunnel header from packet, build tunnel metadata and resize packet
      * for further processing. */
     int  (*pop_header)(struct netdev *netdev,
-                       struct dpif_packet **buffers, int cnt);
+                       struct dp_packet **buffers, int cnt);
 
     /* Returns the id of the numa node the 'netdev' is on.  If there is no
      * such info, returns NETDEV_NUMA_UNSPEC. */
@@ -309,7 +309,7 @@ struct netdev_class {
      * network device from being usefully used by the netdev-based "userspace
      * datapath".  It will also prevent the OVS implementation of bonding from
      * working properly over 'netdev'.) */
-    int (*send)(struct netdev *netdev, int qid, struct dpif_packet **buffers,
+    int (*send)(struct netdev *netdev, int qid, struct dp_packet **buffers,
                 int cnt, bool may_steal);
 
     /* Registers with the poll loop to wake up from the next call to
@@ -710,7 +710,7 @@ struct netdev_class {
      * Caller is expected to pass array of size MAX_RX_BATCH.
      * This function may be set to null if it would always return EOPNOTSUPP
      * anyhow. */
-    int (*rxq_recv)(struct netdev_rxq *rx, struct dpif_packet **pkts,
+    int (*rxq_recv)(struct netdev_rxq *rx, struct dp_packet **pkts,
                     int *cnt);
 
     /* Registers with the poll loop to wake up from the next call to
index 9d02f2f..34874a9 100644 (file)
@@ -29,6 +29,7 @@
 #include "daemon.h"
 #include "dirs.h"
 #include "dpif.h"
+#include "dp-packet.h"
 #include "dynamic-string.h"
 #include "flow.h"
 #include "hash.h"
@@ -39,7 +40,6 @@
 #include "ofpbuf.h"
 #include "ovs-router.h"
 #include "packets.h"
-#include "packet-dpif.h"
 #include "poll-loop.h"
 #include "route-table.h"
 #include "shash.h"
@@ -944,7 +944,7 @@ reset_tnl_md(struct pkt_metadata *md)
 }
 
 static void
-gre_extract_md(struct dpif_packet *dpif_pkt)
+gre_extract_md(struct dp_packet *dpif_pkt)
 {
     struct ofpbuf *packet = &dpif_pkt->ofpbuf;
     struct pkt_metadata *md = &dpif_pkt->md;
@@ -967,7 +967,7 @@ gre_extract_md(struct dpif_packet *dpif_pkt)
 
 static int
 netdev_gre_pop_header(struct netdev *netdev_ OVS_UNUSED,
-                      struct dpif_packet **pkt, int cnt)
+                      struct dp_packet **pkt, int cnt)
 {
     int i;
 
@@ -996,7 +996,7 @@ netdev_gre_push_header__(struct ofpbuf *packet,
 
 static int
 netdev_gre_push_header(const struct netdev *netdev OVS_UNUSED,
-                       struct dpif_packet **packets, int cnt,
+                       struct dp_packet **packets, int cnt,
                        const struct ovs_action_push_tnl *data)
 {
     int i;
@@ -1057,7 +1057,7 @@ netdev_gre_build_header(const struct netdev *netdev,
 }
 
 static void
-vxlan_extract_md(struct dpif_packet *dpif_pkt)
+vxlan_extract_md(struct dp_packet *dpif_pkt)
 {
     struct ofpbuf *packet = &dpif_pkt->ofpbuf;
     struct pkt_metadata *md = &dpif_pkt->md;
@@ -1093,7 +1093,7 @@ vxlan_extract_md(struct dpif_packet *dpif_pkt)
 
 static int
 netdev_vxlan_pop_header(struct netdev *netdev_ OVS_UNUSED,
-                        struct dpif_packet **pkt, int cnt)
+                        struct dp_packet **pkt, int cnt)
 {
     int i;
 
@@ -1134,18 +1134,18 @@ netdev_vxlan_build_header(const struct netdev *netdev,
 }
 
 static ovs_be16
-get_src_port(struct dpif_packet *packet)
+get_src_port(struct dp_packet *packet)
 {
     uint32_t hash;
 
-    hash = dpif_packet_get_dp_hash(packet);
+    hash = dp_packet_get_dp_hash(packet);
 
     return htons((((uint64_t) hash * (tnl_udp_port_max - tnl_udp_port_min)) >> 32) +
                  tnl_udp_port_min);
 }
 
 static void
-netdev_vxlan_push_header__(struct dpif_packet *packet,
+netdev_vxlan_push_header__(struct dp_packet *packet,
                            const void *header, int size)
 {
     struct udp_header *udp;
@@ -1161,7 +1161,7 @@ netdev_vxlan_push_header__(struct dpif_packet *packet,
 
 static int
 netdev_vxlan_push_header(const struct netdev *netdev OVS_UNUSED,
-                         struct dpif_packet **packets, int cnt,
+                         struct dp_packet **packets, int cnt,
                          const struct ovs_action_push_tnl *data)
 {
     int i;
index 2bda77f..cfd979a 100644 (file)
@@ -641,7 +641,7 @@ netdev_rxq_close(struct netdev_rxq *rx)
  * This function may be set to null if it would always return EOPNOTSUPP
  * anyhow. */
 int
-netdev_rxq_recv(struct netdev_rxq *rx, struct dpif_packet **buffers, int *cnt)
+netdev_rxq_recv(struct netdev_rxq *rx, struct dp_packet **buffers, int *cnt)
 {
     int retval;
 
@@ -716,7 +716,7 @@ netdev_set_multiq(struct netdev *netdev, unsigned int n_txq,
  * Some network devices may not implement support for this function.  In such
  * cases this function will always return EOPNOTSUPP. */
 int
-netdev_send(struct netdev *netdev, int qid, struct dpif_packet **buffers,
+netdev_send(struct netdev *netdev, int qid, struct dp_packet **buffers,
             int cnt, bool may_steal)
 {
     int error;
@@ -731,7 +731,7 @@ netdev_send(struct netdev *netdev, int qid, struct dpif_packet **buffers,
 }
 
 int
-netdev_pop_header(struct netdev *netdev, struct dpif_packet **buffers, int cnt)
+netdev_pop_header(struct netdev *netdev, struct dp_packet **buffers, int cnt)
 {
     return (netdev->netdev_class->pop_header
              ? netdev->netdev_class->pop_header(netdev, buffers, cnt)
@@ -749,7 +749,7 @@ netdev_build_header(const struct netdev *netdev, struct ovs_action_push_tnl *dat
 
 int
 netdev_push_header(const struct netdev *netdev,
-                   struct dpif_packet **buffers, int cnt,
+                   struct dp_packet **buffers, int cnt,
                    const struct ovs_action_push_tnl *data)
 {
     if (netdev->netdev_class->push_header) {
index 33f301a..9a647f0 100644 (file)
@@ -60,7 +60,7 @@ extern "C" {
  *      netdev and access each of those from a different thread.)
  */
 
-struct dpif_packet;
+struct dp_packet;
 struct netdev;
 struct netdev_class;
 struct netdev_rxq;
@@ -174,21 +174,21 @@ void netdev_rxq_close(struct netdev_rxq *);
 
 const char *netdev_rxq_get_name(const struct netdev_rxq *);
 
-int netdev_rxq_recv(struct netdev_rxq *rx, struct dpif_packet **buffers,
+int netdev_rxq_recv(struct netdev_rxq *rx, struct dp_packet **buffers,
                     int *cnt);
 void netdev_rxq_wait(struct netdev_rxq *);
 int netdev_rxq_drain(struct netdev_rxq *);
 
 /* Packet transmission. */
-int netdev_send(struct netdev *, int qid, struct dpif_packet **, int cnt,
+int netdev_send(struct netdev *, int qid, struct dp_packet **, int cnt,
                 bool may_steal);
 void netdev_send_wait(struct netdev *, int qid);
 
 int netdev_build_header(const struct netdev *, struct ovs_action_push_tnl *data);
 int netdev_push_header(const struct netdev *netdev,
-                       struct dpif_packet **buffers, int cnt,
+                       struct dp_packet **buffers, int cnt,
                        const struct ovs_action_push_tnl *data);
-int netdev_pop_header(struct netdev *netdev, struct dpif_packet **buffers,
+int netdev_pop_header(struct netdev *netdev, struct dp_packet **buffers,
                       int cnt);
 
 /* Hardware address. */
index 98ac18c..079b0b4 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 
+#include "dp-packet.h"
 #include "dpif.h"
 #include "netlink.h"
 #include "ofpbuf.h"
 #include "odp-netlink.h"
 #include "odp-util.h"
-#include "packet-dpif.h"
 #include "packets.h"
 #include "flow.h"
 #include "unaligned.h"
@@ -225,7 +225,7 @@ odp_set_nd(struct ofpbuf *packet, const struct ovs_key_nd *key,
 }
 
 static void
-odp_execute_set_action(struct dpif_packet *packet, const struct nlattr *a)
+odp_execute_set_action(struct dp_packet *packet, const struct nlattr *a)
 {
     enum ovs_key_attr type = nl_attr_type(a);
     const struct ovs_key_ipv4 *ipv4_key;
@@ -313,7 +313,7 @@ odp_execute_set_action(struct dpif_packet *packet, const struct nlattr *a)
 
     case OVS_KEY_ATTR_DP_HASH:
         md->dp_hash = nl_attr_get_u32(a);
-        dpif_packet_set_dp_hash(packet, md->dp_hash);
+        dp_packet_set_dp_hash(packet, md->dp_hash);
         break;
 
     case OVS_KEY_ATTR_RECIRC_ID:
@@ -337,7 +337,7 @@ odp_execute_set_action(struct dpif_packet *packet, const struct nlattr *a)
 #define get_mask(a, type) ((const type *)(const void *)(a + 1) + 1)
 
 static void
-odp_execute_masked_set_action(struct dpif_packet *packet,
+odp_execute_masked_set_action(struct dp_packet *packet,
                               const struct nlattr *a)
 {
     struct pkt_metadata *md = &packet->md;
@@ -406,8 +406,8 @@ odp_execute_masked_set_action(struct dpif_packet *packet,
 
     case OVS_KEY_ATTR_DP_HASH:
         md->dp_hash = nl_attr_get_u32(a)
-            | (dpif_packet_get_dp_hash(packet) & ~*get_mask(a, uint32_t));
-        dpif_packet_set_dp_hash(packet, md->dp_hash);
+            | (dp_packet_get_dp_hash(packet) & ~*get_mask(a, uint32_t));
+        dp_packet_set_dp_hash(packet, md->dp_hash);
         break;
 
     case OVS_KEY_ATTR_RECIRC_ID:
@@ -431,7 +431,7 @@ odp_execute_masked_set_action(struct dpif_packet *packet,
 }
 
 static void
-odp_execute_sample(void *dp, struct dpif_packet *packet, bool steal,
+odp_execute_sample(void *dp, struct dp_packet *packet, bool steal,
                    const struct nlattr *action,
                    odp_execute_cb dp_execute_action)
 {
@@ -446,7 +446,7 @@ odp_execute_sample(void *dp, struct dpif_packet *packet, bool steal,
         case OVS_SAMPLE_ATTR_PROBABILITY:
             if (random_uint32() >= nl_attr_get_u32(a)) {
                 if (steal) {
-                    dpif_packet_delete(packet);
+                    dp_packet_delete(packet);
                 }
                 return;
             }
@@ -468,7 +468,7 @@ odp_execute_sample(void *dp, struct dpif_packet *packet, bool steal,
 }
 
 void
-odp_execute_actions(void *dp, struct dpif_packet **packets, int cnt, bool steal,
+odp_execute_actions(void *dp, struct dp_packet **packets, int cnt, bool steal,
                     const struct nlattr *actions, size_t actions_len,
                     odp_execute_cb dp_execute_action)
 {
@@ -518,7 +518,7 @@ odp_execute_actions(void *dp, struct dpif_packet **packets, int cnt, bool steal,
                     hash = flow_hash_5tuple(&flow, hash_act->hash_basis);
 
                     /* We also store the hash value with each packet */
-                    dpif_packet_set_dp_hash(packets[i], hash ? hash : 1);
+                    dp_packet_set_dp_hash(packets[i], hash ? hash : 1);
                 }
             } else {
                 /* Assert on unknown hash algorithm.  */
@@ -598,7 +598,7 @@ odp_execute_actions(void *dp, struct dpif_packet **packets, int cnt, bool steal,
 
     if (steal) {
         for (i = 0; i < cnt; i++) {
-            dpif_packet_delete(packets[i]);
+            dp_packet_delete(packets[i]);
         }
     }
 }
index 4710bec..c602bb4 100644 (file)
 #include "openvswitch/types.h"
 
 struct nlattr;
-struct dpif_packet;
+struct dp_packet;
 struct pkt_metadata;
 
-typedef void (*odp_execute_cb)(void *dp, struct dpif_packet **packets, int cnt,
+typedef void (*odp_execute_cb)(void *dp, struct dp_packet **packets, int cnt,
                                const struct nlattr *action, bool may_steal);
 
 /* Actions that need to be executed in the context of a datapath are handed
  * to 'dp_execute_action', if non-NULL.  Currently this is called only for
  * actions OVS_ACTION_ATTR_OUTPUT and OVS_ACTION_ATTR_USERSPACE so
  * 'dp_execute_action' needs to handle only these. */
-void odp_execute_actions(void *dp, struct dpif_packet **packets, int cnt,
+void odp_execute_actions(void *dp, struct dp_packet **packets, int cnt,
                          bool steal,
                          const struct nlattr *actions, size_t actions_len,
                          odp_execute_cb dp_execute_action);
index 4946e6f..3886261 100644 (file)
@@ -138,8 +138,8 @@ ofpbuf_uninit(struct ofpbuf *b)
         } else if (b->source == OFPBUF_DPDK) {
 #ifdef DPDK_NETDEV
             /* If this ofpbuf was allocated by DPDK it must have been
-             * created as a dpif_packet */
-            free_dpdk_buf((struct dpif_packet*) b);
+             * created as a dp_packet */
+            free_dpdk_buf((struct dp_packet*) b);
 #else
             ovs_assert(b->source != OFPBUF_DPDK);
 #endif
index 4e7038d..8067779 100644 (file)
@@ -181,8 +181,8 @@ static inline void ofpbuf_delete(struct ofpbuf *b)
     if (b) {
         if (b->source == OFPBUF_DPDK) {
             /* If this ofpbuf was allocated by DPDK it must have been
-             * created as a dpif_packet */
-            free_dpdk_buf((struct dpif_packet*) b);
+             * created as a dp_packet */
+            free_dpdk_buf((struct dp_packet*) b);
             return;
         }
 
diff --git a/lib/packet-dpif.c b/lib/packet-dpif.c
deleted file mode 100644 (file)
index db739c5..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2014 Nicira, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <config.h>
-#include "packet-dpif.h"
-
-#include "ofpbuf.h"
-
-struct dpif_packet *
-dpif_packet_new_with_headroom(size_t size, size_t headroom)
-{
-    struct dpif_packet *p = xmalloc(sizeof *p);
-    struct ofpbuf *b = &p->ofpbuf;
-
-    ofpbuf_init(b, size + headroom);
-    ofpbuf_reserve(b, headroom);
-    p->md = PKT_METADATA_INITIALIZER(0);
-
-    return p;
-}
-
-struct dpif_packet *
-dpif_packet_clone_from_ofpbuf(const struct ofpbuf *b)
-{
-    struct dpif_packet *p = xmalloc(sizeof *p);
-    size_t headroom = ofpbuf_headroom(b);
-
-    ofpbuf_init(&p->ofpbuf, ofpbuf_size(b) + headroom);
-    p->md = PKT_METADATA_INITIALIZER(0);
-    ofpbuf_reserve(&p->ofpbuf, headroom);
-
-    ofpbuf_put(&p->ofpbuf, ofpbuf_data(b), ofpbuf_size(b));
-
-    if (b->frame) {
-        uintptr_t data_delta
-            = (char *)ofpbuf_data(&p->ofpbuf) - (char *)ofpbuf_data(b);
-
-        p->ofpbuf.frame = (char *) b->frame + data_delta;
-    }
-    p->ofpbuf.l2_5_ofs = b->l2_5_ofs;
-    p->ofpbuf.l3_ofs = b->l3_ofs;
-    p->ofpbuf.l4_ofs = b->l4_ofs;
-
-    return p;
-}
-
-struct dpif_packet *
-dpif_packet_clone(struct dpif_packet *p)
-{
-    struct dpif_packet *newp;
-
-    newp = dpif_packet_clone_from_ofpbuf(&p->ofpbuf);
-    memcpy(&newp->md, &p->md, sizeof p->md);
-
-    dpif_packet_set_dp_hash(newp, dpif_packet_get_dp_hash(p));
-
-    return newp;
-}
diff --git a/lib/packet-dpif.h b/lib/packet-dpif.h
deleted file mode 100644 (file)
index 1a5efb6..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2014 Nicira, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef PACKET_DPIF_H
-#define PACKET_DPIF_H 1
-
-#include "ofpbuf.h"
-
-#ifdef  __cplusplus
-extern "C" {
-#endif
-
-/* A packet received from a netdev and passed to a dpif. */
-
-struct dpif_packet {
-    struct ofpbuf ofpbuf;       /* Packet data. */
-#ifndef DPDK_NETDEV
-    uint32_t dp_hash;           /* Packet hash. */
-#endif
-    struct pkt_metadata md;
-};
-
-struct dpif_packet *dpif_packet_new_with_headroom(size_t size,
-                                                  size_t headroom);
-
-struct dpif_packet *dpif_packet_clone_from_ofpbuf(const struct ofpbuf *b);
-
-struct dpif_packet *dpif_packet_clone(struct dpif_packet *p);
-
-static inline void dpif_packet_delete(struct dpif_packet *p)
-{
-    struct ofpbuf *buf = &p->ofpbuf;
-
-    ofpbuf_delete(buf);
-}
-
-static inline uint32_t dpif_packet_get_dp_hash(struct dpif_packet *p)
-{
-#ifdef DPDK_NETDEV
-    return p->ofpbuf.mbuf.pkt.hash.rss;
-#else
-    return p->dp_hash;
-#endif
-}
-
-static inline void dpif_packet_set_dp_hash(struct dpif_packet *p,
-                                           uint32_t hash)
-{
-#ifdef DPDK_NETDEV
-    p->ofpbuf.mbuf.pkt.hash.rss = hash;
-#else
-    p->dp_hash = hash;
-#endif
-}
-
-#ifdef  __cplusplus
-}
-#endif
-
-#endif /* packet-dpif.h */
index 89f38cf..0113474 100644 (file)
@@ -28,7 +28,6 @@
 #include "netdev.h"
 #include "ovs-thread.h"
 #include "packets.h"
-#include "packet-dpif.h"
 #include "poll-loop.h"
 #include "seq.h"
 #include "timeval.h"
index 5b9f1c8..2373820 100644 (file)
@@ -31,6 +31,7 @@
 #include "cfm.h"
 #include "connmgr.h"
 #include "coverage.h"
+#include "dp-packet.h"
 #include "dpif.h"
 #include "dynamic-string.h"
 #include "in-band.h"
@@ -52,7 +53,6 @@
 #include "ofproto/ofproto-dpif-sflow.h"
 #include "ofproto/ofproto-dpif.h"
 #include "ofproto/ofproto-provider.h"
-#include "packet-dpif.h"
 #include "ovs-router.h"
 #include "tnl-ports.h"
 #include "tunnel.h"
@@ -3196,14 +3196,14 @@ execute_controller_action(struct xlate_ctx *ctx, int len,
                           uint16_t controller_id)
 {
     struct ofproto_packet_in *pin;
-    struct dpif_packet *packet;
+    struct dp_packet *packet;
 
     ctx->xout->slow |= SLOW_CONTROLLER;
     if (!ctx->xin->packet) {
         return;
     }
 
-    packet = dpif_packet_clone_from_ofpbuf(ctx->xin->packet);
+    packet = dp_packet_clone_from_ofpbuf(ctx->xin->packet);
 
     ctx->xout->slow |= commit_odp_actions(&ctx->xin->flow, &ctx->base_flow,
                                           ctx->xout->odp_actions,
@@ -3244,7 +3244,7 @@ execute_controller_action(struct xlate_ctx *ctx, int len,
         }
     }
     ofproto_dpif_send_packet_in(ctx->xbridge->ofproto, pin);
-    dpif_packet_delete(packet);
+    dp_packet_delete(packet);
 }
 
 static void