@@ -24,6 +24,10 @@
#include "util.h"
#include "netdev-dpdk.h"
+#ifdef DPDK_NETDEV
+#include "rte_ether.h"
+#endif
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -409,17 +413,19 @@ dp_packet_size(const struct dp_packet *b)
static inline void
dp_packet_set_size(struct dp_packet *b, uint32_t v)
{
- /* netdev-dpdk does not currently support segmentation; consequently, for
- * all intents and purposes, 'data_len' (16 bit) and 'pkt_len' (32 bit) may
- * be used interchangably.
- *
- * On the datapath, it is expected that the size of packets
- * (and thus 'v') will always be <= UINT16_MAX; this means that there is no
- * loss of accuracy in assigning 'v' to 'data_len'.
+ /*
+ * Assign current segment length. If total length is greater than
+ * max data length in a segment, additional calculation is needed
*/
- b->mbuf.data_len = (uint16_t)v; /* Current seg length. */
- b->mbuf.pkt_len = v; /* Total length of all segments linked to
- * this segment. */
+ if (v > (b->mbuf.buf_len - b->mbuf.data_off)) {
+ b->mbuf.data_len =
+ (uint16_t) (b->mbuf.buf_len - b->mbuf.data_off);
+ } else {
+ b->mbuf.data_len = (uint16_t) v;
+ }
+
+ /* Total length of all segments linked to this segment. */
+ b->mbuf.pkt_len = v;
}
static inline uint16_t