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 \
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 \
--- /dev/null
+/*
+ * 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;
+}
--- /dev/null
+/*
+ * 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 */
#include "cmap.h"
#include "csum.h"
+#include "dp-packet.h"
#include "dpif.h"
#include "dpif-provider.h"
#include "dummy.h"
#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"
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);
{
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) {
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);
}
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)
}
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;
}
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);
}
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)
}
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;
}
* '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;
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;
}
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;
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)
for (i = 0; i < cnt; i++) {
if (OVS_UNLIKELY(!rules[i])) {
- dpif_packet_delete(packets[i]);
+ dp_packet_delete(packets[i]);
dropped_cnt++;
}
}
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])) {
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;
}
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]);
}
}
}
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;
}
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
{
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) {
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) {
ofpbuf_data(&actions),
ofpbuf_size(&actions));
} else if (may_steal) {
- dpif_packet_delete(packets[i]);
+ dp_packet_delete(packets[i]);
}
}
ofpbuf_uninit(&actions);
(*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);
}
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)
{
#include "coverage.h"
#include "dpctl.h"
+#include "dp-packet.h"
#include "dynamic-string.h"
#include "flow.h"
#include "netdev.h"
#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"
/* 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_;
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);
#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"
}
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;
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;
: 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;
}
*/
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_);
ovs_mutex_unlock(&dev->mutex);
if (may_steal) {
for (i = 0; i < cnt; i++) {
- dpif_packet_delete(pkts[i]);
+ dp_packet_delete(pkts[i]);
}
}
#include <unistd.h>
#include <stdio.h>
+#include "dp-packet.h"
#include "dpif-netdev.h"
#include "list.h"
#include "netdev-dpdk.h"
#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"
/* 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;
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 */
}
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_);
/* 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
{
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;
if (may_steal) {
for (i = 0; i < cnt; i++) {
- dpif_packet_delete(pkts[i]);
+ dp_packet_delete(pkts[i]);
}
}
} else {
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;
}
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);
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);
#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
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);
}
static inline void
-free_dpdk_buf(struct dpif_packet *buf OVS_UNUSED)
+free_dpdk_buf(struct dp_packet *buf OVS_UNUSED)
{
/* Nothing */
}
#include <errno.h>
+#include "dp-packet.h"
#include "dpif-netdev.h"
#include "dynamic-string.h"
#include "flow.h"
#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"
}
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_);
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;
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;
if (may_steal) {
for (i = 0; i < cnt; i++) {
- dpif_packet_delete(pkts[i]);
+ dp_packet_delete(pkts[i]);
}
}
#include <unistd.h>
#include "coverage.h"
+#include "dp-packet.h"
#include "dpif-netlink.h"
#include "dpif-netdev.h"
#include "dynamic-string.h"
#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"
}
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;
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;
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;
}
* 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;
if (may_steal) {
for (i = 0; i < cnt; i++) {
- dpif_packet_delete(pkts[i]);
+ dp_packet_delete(pkts[i]);
}
}
* 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. */
* 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
* 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
#include "daemon.h"
#include "dirs.h"
#include "dpif.h"
+#include "dp-packet.h"
#include "dynamic-string.h"
#include "flow.h"
#include "hash.h"
#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"
}
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;
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;
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;
}
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;
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;
}
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;
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;
* 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;
* 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;
}
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)
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) {
* netdev and access each of those from a different thread.)
*/
-struct dpif_packet;
+struct dp_packet;
struct netdev;
struct netdev_class;
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. */
#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"
}
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;
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:
#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;
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:
}
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)
{
case OVS_SAMPLE_ATTR_PROBABILITY:
if (random_uint32() >= nl_attr_get_u32(a)) {
if (steal) {
- dpif_packet_delete(packet);
+ dp_packet_delete(packet);
}
return;
}
}
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)
{
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. */
if (steal) {
for (i = 0; i < cnt; i++) {
- dpif_packet_delete(packets[i]);
+ dp_packet_delete(packets[i]);
}
}
}
#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);
} 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
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;
}
+++ /dev/null
-/*
- * 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;
-}
+++ /dev/null
-/*
- * 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 */
#include "netdev.h"
#include "ovs-thread.h"
#include "packets.h"
-#include "packet-dpif.h"
#include "poll-loop.h"
#include "seq.h"
#include "timeval.h"
#include "cfm.h"
#include "connmgr.h"
#include "coverage.h"
+#include "dp-packet.h"
#include "dpif.h"
#include "dynamic-string.h"
#include "in-band.h"
#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"
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,
}
}
ofproto_dpif_send_packet_in(ctx->xbridge->ofproto, pin);
- dpif_packet_delete(packet);
+ dp_packet_delete(packet);
}
static void