blob: a6f68d56978996d09ee010ea664ca55375f425c4 (
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
|
/* Copyright (c) 2015, Linaro Limited
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef ODP_PACKET_NETMAP_H
#define ODP_PACKET_NETMAP_H
#include <odp/api/align.h>
#include <odp/api/debug.h>
#include <odp/api/packet_io.h>
#include <odp/api/pool.h>
#include <odp/api/ticketlock.h>
#include <odp_align_internal.h>
#include <linux/if_ether.h>
#include <net/if.h>
#define NM_MAX_DESC 64
/** Ring for mapping pktin/pktout queues to netmap descriptors */
struct netmap_ring_t {
unsigned first; /**< Index of first netmap descriptor */
unsigned last; /**< Index of last netmap descriptor */
unsigned num; /**< Number of netmap descriptors */
/** Netmap metadata for the device */
struct nm_desc *desc[NM_MAX_DESC];
unsigned cur; /**< Index of current netmap descriptor */
odp_ticketlock_t lock; /**< Queue lock */
};
typedef union {
struct netmap_ring_t s;
uint8_t pad[ROUNDUP_CACHE_LINE(sizeof(struct netmap_ring_t))];
} netmap_ring_t ODP_ALIGNED_CACHE;
/** Netmap ring slot */
typedef struct {
char *buf; /**< Slot buffer pointer */
uint16_t len; /**< Slot length */
} netmap_slot_t;
/** Packet socket using netmap mmaped rings for both Rx and Tx */
typedef struct {
odp_pool_t pool; /**< pool to alloc packets from */
size_t max_frame_len; /**< buf_size - sizeof(pkt_hdr) */
uint32_t if_flags; /**< interface flags */
uint32_t mtu; /**< maximum transmission unit */
int sockfd; /**< control socket */
unsigned char if_mac[ETH_ALEN]; /**< eth mac address */
char nm_name[IF_NAMESIZE + 7]; /**< netmap:<ifname> */
char if_name[IF_NAMESIZE]; /**< interface name used in ioctl */
odp_bool_t is_virtual; /**< nm virtual port (VALE/pipe) */
odp_pktio_capability_t capa; /**< interface capabilities */
uint32_t num_rx_rings; /**< number of nm rx rings */
uint32_t num_tx_rings; /**< number of nm tx rings */
unsigned num_rx_desc_rings; /**< number of rx descriptor rings */
unsigned num_tx_desc_rings; /**< number of tx descriptor rings */
odp_bool_t lockless_rx; /**< no locking for rx */
odp_bool_t lockless_tx; /**< no locking for tx */
/** mapping of pktin queues to netmap rx descriptors */
netmap_ring_t rx_desc_ring[PKTIO_MAX_QUEUES];
/** mapping of pktout queues to netmap tx descriptors */
netmap_ring_t tx_desc_ring[PKTIO_MAX_QUEUES];
} pkt_netmap_t;
#endif
|