2018-01-29 13:11:36 +00:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
* Copyright 2017 6WIND S.A.
|
2018-03-20 19:20:35 +00:00
|
|
|
* Copyright 2017 Mellanox Technologies, Ltd
|
2017-03-23 08:33:54 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _RTE_ETH_TAP_H_
|
|
|
|
#define _RTE_ETH_TAP_H_
|
|
|
|
|
2017-03-23 08:33:55 +00:00
|
|
|
#include <sys/queue.h>
|
2017-03-16 08:59:21 +00:00
|
|
|
#include <sys/uio.h>
|
2017-03-23 08:33:54 +00:00
|
|
|
#include <inttypes.h>
|
2017-06-27 12:33:15 +00:00
|
|
|
#include <net/if.h>
|
2017-03-23 08:33:54 +00:00
|
|
|
|
2017-03-16 08:59:21 +00:00
|
|
|
#include <linux/if_tun.h>
|
|
|
|
|
2021-01-29 16:48:19 +00:00
|
|
|
#include <ethdev_driver.h>
|
2017-03-23 08:33:54 +00:00
|
|
|
#include <rte_ether.h>
|
2018-06-23 23:17:41 +00:00
|
|
|
#include <rte_gso.h>
|
2018-04-25 15:56:37 +00:00
|
|
|
#include "tap_log.h"
|
2017-03-23 08:33:54 +00:00
|
|
|
|
2017-04-06 14:18:04 +00:00
|
|
|
#ifdef IFF_MULTI_QUEUE
|
2018-01-20 21:11:32 +00:00
|
|
|
#define RTE_PMD_TAP_MAX_QUEUES TAP_MAX_QUEUES
|
2017-04-06 14:18:04 +00:00
|
|
|
#else
|
|
|
|
#define RTE_PMD_TAP_MAX_QUEUES 1
|
|
|
|
#endif
|
2018-06-23 23:17:41 +00:00
|
|
|
#define MAX_GSO_MBUFS 64
|
2017-03-23 08:33:54 +00:00
|
|
|
|
2018-05-22 10:47:14 +00:00
|
|
|
enum rte_tuntap_type {
|
|
|
|
ETH_TUNTAP_TYPE_UNKNOWN,
|
|
|
|
ETH_TUNTAP_TYPE_TUN,
|
|
|
|
ETH_TUNTAP_TYPE_TAP,
|
|
|
|
ETH_TUNTAP_TYPE_MAX,
|
|
|
|
};
|
|
|
|
|
2017-03-23 08:33:54 +00:00
|
|
|
struct pkt_stats {
|
|
|
|
uint64_t opackets; /* Number of output packets */
|
|
|
|
uint64_t ipackets; /* Number of input packets */
|
|
|
|
uint64_t obytes; /* Number of bytes on output */
|
|
|
|
uint64_t ibytes; /* Number of bytes on input */
|
|
|
|
uint64_t errs; /* Number of TX error packets */
|
2017-03-16 08:59:21 +00:00
|
|
|
uint64_t ierrors; /* Number of RX error packets */
|
|
|
|
uint64_t rx_nombuf; /* Nb of RX mbuf alloc failures */
|
2017-03-23 08:33:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct rx_queue {
|
|
|
|
struct rte_mempool *mp; /* Mempool for RX packets */
|
|
|
|
uint32_t trigger_seen; /* Last seen Rx trigger value */
|
|
|
|
uint16_t in_port; /* Port ID */
|
2018-10-18 10:17:27 +00:00
|
|
|
uint16_t queue_id; /* queue ID*/
|
2017-03-23 08:33:54 +00:00
|
|
|
struct pkt_stats stats; /* Stats for this RX queue */
|
2017-03-16 08:59:21 +00:00
|
|
|
uint16_t nb_rx_desc; /* max number of mbufs available */
|
|
|
|
struct rte_eth_rxmode *rxmode; /* RX features */
|
|
|
|
struct rte_mbuf *pool; /* mbufs pool for this queue */
|
|
|
|
struct iovec (*iovecs)[]; /* descriptors for this queue */
|
|
|
|
struct tun_pi pi; /* packet info for iovecs */
|
2017-03-23 08:33:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct tx_queue {
|
2018-05-22 10:47:14 +00:00
|
|
|
int type; /* Type field - TUN|TAP */
|
2017-03-15 15:09:08 +00:00
|
|
|
uint16_t *mtu; /* Pointer to MTU from dev_data */
|
2018-01-17 14:04:33 +00:00
|
|
|
uint16_t csum:1; /* Enable checksum offloading */
|
2017-03-23 08:33:54 +00:00
|
|
|
struct pkt_stats stats; /* Stats for this TX queue */
|
2018-06-23 23:17:41 +00:00
|
|
|
struct rte_gso_ctx gso_ctx; /* GSO context */
|
2018-10-18 10:17:27 +00:00
|
|
|
uint16_t out_port; /* Port ID */
|
|
|
|
uint16_t queue_id; /* queue ID*/
|
2017-03-23 08:33:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct pmd_internals {
|
2017-09-16 22:32:38 +00:00
|
|
|
struct rte_eth_dev *dev; /* Ethernet device. */
|
2017-03-23 08:42:11 +00:00
|
|
|
char remote_iface[RTE_ETH_NAME_MAX_LEN]; /* Remote netdevice name */
|
2017-03-23 08:33:54 +00:00
|
|
|
char name[RTE_ETH_NAME_MAX_LEN]; /* Internal Tap device name */
|
2018-05-22 10:47:14 +00:00
|
|
|
int type; /* Type field - TUN|TAP */
|
2019-05-21 16:13:03 +00:00
|
|
|
struct rte_ether_addr eth_addr; /* Mac address of the device port */
|
|
|
|
struct ifreq remote_initial_flags;/* Remote netdevice flags on init */
|
2017-03-23 08:42:11 +00:00
|
|
|
int remote_if_index; /* remote netdevice IF_INDEX */
|
2017-03-23 08:33:54 +00:00
|
|
|
int if_index; /* IF_INDEX for the port */
|
|
|
|
int ioctl_sock; /* socket for ioctl calls */
|
net/tap: add basic flow API patterns and actions
Supported flow rules are now mapped to TC rules on the tap netdevice.
The netlink message used for creating the TC rule is stored in struct
rte_flow. That way, by simply changing a metadata in it, we can require
for the rule deletion without further parsing.
Supported items:
- eth: src and dst (with variable masks), and eth_type (0xffff mask).
- vlan: vid, pcp, tpid, but not eid.
- ipv4/6: src and dst (with variable masks), and ip_proto (0xffff mask).
- udp/tcp: src and dst port (0xffff) mask.
Supported actions:
- DROP
- QUEUE
- PASSTHRU
It is generally not possible to provide a "last" item. However, if the
"last" item, once masked, is identical to the masked spec, then it is
supported.
Only IPv4/6 and MAC addresses can use a variable mask. All other
items need a full mask (exact match).
Support for VLAN requires kernel headers >= 4.9, checked using
auto-config.sh.
Signed-off-by: Pascal Mazon <pascal.mazon@6wind.com>
Acked-by: Olga Shern <olgas@mellanox.com>
Acked-by: Keith Wiles <keith.wiles@intel.com>
2017-03-23 08:33:57 +00:00
|
|
|
int nlsk_fd; /* Netlink socket fd */
|
2017-05-24 15:41:12 +00:00
|
|
|
int flow_isolate; /* 1 if flow isolation is enabled */
|
2018-01-20 21:11:32 +00:00
|
|
|
int flower_support; /* 1 if kernel supports, else 0 */
|
|
|
|
int flower_vlan_support; /* 1 if kernel supports, else 0 */
|
2018-01-20 21:11:36 +00:00
|
|
|
int rss_enabled; /* 1 if RSS is enabled, else 0 */
|
|
|
|
/* implicit rules set when RSS is enabled */
|
|
|
|
int map_fd; /* BPF RSS map fd */
|
|
|
|
int bpf_fd[RTE_PMD_TAP_MAX_QUEUES];/* List of bpf fds per queue */
|
|
|
|
LIST_HEAD(tap_rss_flows, rte_flow) rss_flows;
|
2017-03-23 08:33:55 +00:00
|
|
|
LIST_HEAD(tap_flows, rte_flow) flows; /* rte_flow rules */
|
2017-03-23 08:42:11 +00:00
|
|
|
/* implicit rte_flow rules set when a remote device is active */
|
|
|
|
LIST_HEAD(tap_implicit_flows, rte_flow) implicit_flows;
|
2017-03-23 08:33:54 +00:00
|
|
|
struct rx_queue rxq[RTE_PMD_TAP_MAX_QUEUES]; /* List of RX queues */
|
|
|
|
struct tx_queue txq[RTE_PMD_TAP_MAX_QUEUES]; /* List of TX queues */
|
2017-03-22 08:40:01 +00:00
|
|
|
struct rte_intr_handle intr_handle; /* LSC interrupt handle. */
|
2018-05-21 07:54:33 +00:00
|
|
|
int ka_fd; /* keep-alive file descriptor */
|
2020-08-08 09:58:43 +00:00
|
|
|
struct rte_mempool *gso_ctx_mp; /* Mempool for GSO packets */
|
2017-03-23 08:33:54 +00:00
|
|
|
};
|
|
|
|
|
2018-10-18 10:17:28 +00:00
|
|
|
struct pmd_process_private {
|
|
|
|
int rxq_fds[RTE_PMD_TAP_MAX_QUEUES];
|
|
|
|
int txq_fds[RTE_PMD_TAP_MAX_QUEUES];
|
|
|
|
};
|
|
|
|
|
2018-01-28 10:45:35 +00:00
|
|
|
/* tap_intr.c */
|
|
|
|
|
|
|
|
int tap_rx_intr_vec_set(struct rte_eth_dev *dev, int set);
|
|
|
|
|
2017-03-23 08:33:54 +00:00
|
|
|
#endif /* _RTE_ETH_TAP_H_ */
|