Click
Loading...
Searching...
No Matches
dpdk_glue.hh
1#ifndef DPDKGLUE_H
2#define DPDKGLUE_H
3#include <rte_mbuf.h>
4#include <rte_version.h>
5#include <rte_hash_crc.h>
6#include <click/ipflowid.hh>
7
8#if RTE_VERSION >= RTE_VERSION_NUM(22,07,0,0)
9#define PKT_RX_TIMESTAMP RTE_MBUF_F_RX_TIMESTAMP
10#endif
11
12inline uint32_t
13ipv4_hash_crc(const void *data, uint32_t data_len,
14 uint32_t init_val)
15{
16 (void)data_len;
17 const IPFlow5ID *k;
18 uint32_t t;
19 const uint32_t *p;
20 k = (const IPFlow5ID *)data;
21 t = k->proto();
22 p = ((const uint32_t *)k) + 2;
23 init_val = rte_hash_crc_4byte(t, init_val);
24 init_val = rte_hash_crc_4byte(k->saddr(), init_val);
25 init_val = rte_hash_crc_4byte(k->daddr(), init_val);
26 init_val = rte_hash_crc_4byte(*p, init_val);
27 return init_val;
28}
29
30#if RTE_VERSION <= RTE_VERSION_NUM(2,2,0,0)
31static inline int rte_ring_mc_dequeue_bulk(struct rte_ring *r, void **obj_table, unsigned n, void *) {
32 rte_ring_mc_dequeue_bulk(r, obj_table,n);
33}
34#endif
35
36#ifndef RTE_MBUF_INDIRECT
37#define RTE_MBUF_INDIRECT(m) RTE_MBUF_CLONED(m)
38#endif
39
40#if RTE_VERSION < RTE_VERSION_NUM(20,11,0,0)
41#define TIMESTAMP_FIELD(mbuf) \
42 (mbuf->timestamp)
43#define HAS_TIMESTAMP(mbuf) \
44 (mbuf->ol_flags & PKT_RX_TIMESTAMP)
45#else
46extern "C" {
47#include <rte_mbuf_dyn.h>
48}
49#include <rte_bitops.h>
50#define TIMESTAMP_FIELD(mbuf) \
51 (*RTE_MBUF_DYNFIELD(mbuf, timestamp_dynfield_offset, uint64_t *))
52#define HAS_TIMESTAMP(mbuf) \
53 ((mbuf)->ol_flags & timestamp_dynflag)
54
55extern int timestamp_dynfield_offset;
56extern uint64_t timestamp_dynflag;
57#endif
58
59
60#endif