2014-06-23 11:43:57 -07:00
|
|
|
/*
|
|
|
|
* 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. */
|
|
|
|
|
2015-02-25 12:01:53 -08:00
|
|
|
struct dp_packet {
|
2014-06-23 11:43:57 -07:00
|
|
|
struct ofpbuf ofpbuf; /* Packet data. */
|
2014-08-29 16:06:42 -07:00
|
|
|
#ifndef DPDK_NETDEV
|
2014-06-23 11:43:59 -07:00
|
|
|
uint32_t dp_hash; /* Packet hash. */
|
2014-08-29 16:06:42 -07:00
|
|
|
#endif
|
2014-10-03 20:23:58 -07:00
|
|
|
struct pkt_metadata md;
|
2014-06-23 11:43:57 -07:00
|
|
|
};
|
|
|
|
|
2015-02-25 12:01:53 -08:00
|
|
|
struct dp_packet *dp_packet_new_with_headroom(size_t size,
|
2014-06-23 11:43:57 -07:00
|
|
|
size_t headroom);
|
|
|
|
|
2015-02-25 12:01:53 -08:00
|
|
|
struct dp_packet *dp_packet_clone_from_ofpbuf(const struct ofpbuf *b);
|
2014-06-23 11:43:57 -07:00
|
|
|
|
2015-02-25 12:01:53 -08:00
|
|
|
struct dp_packet *dp_packet_clone(struct dp_packet *p);
|
2014-06-23 11:43:57 -07:00
|
|
|
|
2015-02-25 12:01:53 -08:00
|
|
|
static inline void dp_packet_delete(struct dp_packet *p)
|
2014-06-23 11:43:57 -07:00
|
|
|
{
|
2014-06-24 13:00:52 -07:00
|
|
|
struct ofpbuf *buf = &p->ofpbuf;
|
2014-06-23 11:43:57 -07:00
|
|
|
|
2014-06-24 13:00:52 -07:00
|
|
|
ofpbuf_delete(buf);
|
2014-06-23 11:43:57 -07:00
|
|
|
}
|
|
|
|
|
2015-02-25 12:01:53 -08:00
|
|
|
static inline uint32_t dp_packet_get_dp_hash(struct dp_packet *p)
|
2014-08-29 16:06:42 -07:00
|
|
|
{
|
|
|
|
#ifdef DPDK_NETDEV
|
|
|
|
return p->ofpbuf.mbuf.pkt.hash.rss;
|
|
|
|
#else
|
|
|
|
return p->dp_hash;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-02-25 12:01:53 -08:00
|
|
|
static inline void dp_packet_set_dp_hash(struct dp_packet *p,
|
2014-08-29 16:06:42 -07:00
|
|
|
uint32_t hash)
|
|
|
|
{
|
|
|
|
#ifdef DPDK_NETDEV
|
|
|
|
p->ofpbuf.mbuf.pkt.hash.rss = hash;
|
|
|
|
#else
|
|
|
|
p->dp_hash = hash;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-06-23 11:43:57 -07:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-02-25 12:01:53 -08:00
|
|
|
#endif /* dp-packet.h */
|