blob: 94fe376a875eeeb80d741320ce487fb3a185d0c7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
/* Copyright (c) 2016-2018, Linaro Limited
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef ODP_PACKET_DPDK_H
#define ODP_PACKET_DPDK_H
#include <odp/api/packet_io.h>
#include <odp/api/pool.h>
#include <odp/api/ticketlock.h>
#include <net/if.h>
#ifdef ODP_PKTIO_DPDK
#include <rte_config.h>
#include <rte_mbuf.h>
#define DPDK_MEMORY_MB 512
#define DPDK_NB_MBUF 16384
#define DPDK_MBUF_BUF_SIZE RTE_MBUF_DEFAULT_BUF_SIZE
#define DPDK_MEMPOOL_CACHE_SIZE 64
#define DPDK_NM_RX_DESC 128
#define DPDK_NM_TX_DESC 512
ODP_STATIC_ASSERT((DPDK_NB_MBUF % DPDK_MEMPOOL_CACHE_SIZE == 0) &&
(DPDK_MEMPOOL_CACHE_SIZE <= RTE_MEMPOOL_CACHE_MAX_SIZE) &&
(DPDK_MEMPOOL_CACHE_SIZE <= DPDK_MBUF_BUF_SIZE * 10 / 15)
, "DPDK mempool cache size failure");
#endif
/* Minimum RX burst size */
#define DPDK_MIN_RX_BURST 4
/** Cache for storing packets */
struct pkt_cache_t {
/** array for storing extra RX packets */
struct rte_mbuf *pkt[DPDK_MIN_RX_BURST];
unsigned idx; /**< head of cache */
unsigned count; /**< packets in cache */
};
typedef union ODP_ALIGNED_CACHE {
struct pkt_cache_t s;
uint8_t pad[ROUNDUP_CACHE_LINE(sizeof(struct pkt_cache_t))];
} pkt_cache_t;
/** Packet IO using DPDK interface */
typedef struct ODP_ALIGNED_CACHE {
odp_pool_t pool; /**< pool to alloc packets from */
struct rte_mempool *pkt_pool; /**< DPDK packet pool */
uint32_t data_room; /**< maximum packet length */
unsigned min_rx_burst; /**< minimum RX burst size */
odp_pktin_hash_proto_t hash; /**< Packet input hash protocol */
uint16_t mtu; /**< maximum transmission unit */
uint16_t port_id; /**< DPDK port identifier */
/** Use system call to get/set vdev promisc mode */
uint8_t vdev_sysc_promisc;
uint8_t lockless_rx; /**< no locking for rx */
uint8_t lockless_tx; /**< no locking for tx */
/** RX queue locks */
odp_ticketlock_t ODP_ALIGNED_CACHE rx_lock[PKTIO_MAX_QUEUES];
odp_ticketlock_t tx_lock[PKTIO_MAX_QUEUES]; /**< TX queue locks */
/** cache for storing extra RX packets */
pkt_cache_t rx_cache[PKTIO_MAX_QUEUES];
} pkt_dpdk_t;
#endif
|