Add support for DPDK 22.11
[samplevnf.git] / VNFs / DPPD-PROX / prox_port_cfg.h
1 /*
2 // Copyright (c) 2010-2020 Intel Corporation
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 */
16
17 #ifndef _PROX_PORT_CFG_H
18 #define _PROX_PORT_CFG_H
19
20 #include <rte_pci.h>
21 #include <rte_ether.h>
22 #include <rte_ethdev.h>
23 #include <rte_version.h>
24 #if RTE_VERSION >= RTE_VERSION_NUM(22,11,0,0)
25 #include <bus_pci_driver.h>     // Please configure DPDK with meson option -Denable_driver_sdk=true
26 #else
27 #if RTE_VERSION >= RTE_VERSION_NUM(17,11,0,0)
28 #include <rte_bus_pci.h>
29 #endif
30 #endif
31 #include <rte_pci.h>
32
33 #include "prox_compat.h"
34 #include "prox_globals.h"
35 #include "ip_subnet.h"
36
37 enum addr_type {PROX_PORT_MAC_HW, PROX_PORT_MAC_SET, PROX_PORT_MAC_RAND};
38
39 #define IPV4_CKSUM      1
40 #define UDP_CKSUM       2
41 #define NB_MCAST_ADDR   16
42 #define PROX_MAX_VLAN_TAGS      256
43
44 struct prox_port_cfg {
45         struct rte_mempool *pool[32];  /* Rx/Tx mempool */
46         size_t pool_size[32];
47         uint8_t promiscuous;
48         uint8_t lsc_set_explicitely; /* Explicitly enable/disable lsc */
49         uint8_t lsc_val;
50         uint8_t active;
51         int socket;
52         uint16_t max_rxq;         /* max number of Tx queues */
53         uint16_t max_txq;         /* max number of Tx queues */
54         uint16_t n_rxq;           /* number of used Rx queues */
55         uint16_t n_txq;           /* number of used Tx queues */
56         uint32_t n_rxd;
57         uint32_t n_txd;
58         uint8_t  link_up;
59         uint32_t  link_speed;
60         uint32_t  max_link_speed;
61         uint32_t  mtu;
62         enum addr_type    type;
63         prox_rte_ether_addr eth_addr;    /* port MAC address */
64         char names[PROX_MAX_VLAN_TAGS][MAX_NAME_SIZE];
65         char vdev[MAX_NAME_SIZE];
66         char short_name[MAX_NAME_SIZE];
67         char driver_name[MAX_NAME_SIZE];
68         char rx_ring[MAX_NAME_SIZE];
69         char tx_ring[MAX_NAME_SIZE];
70         char pci_addr[32];
71         struct rte_eth_conf port_conf;
72         struct rte_eth_rxconf rx_conf;
73         struct rte_eth_txconf tx_conf;
74         uint64_t requested_rx_offload;
75         uint64_t requested_tx_offload;
76         uint64_t disabled_tx_offload;
77         struct rte_eth_dev_info dev_info;
78         struct {
79                 int tx_offload_cksum;
80         } capabilities;
81         uint32_t max_rx_pkt_len;
82         uint32_t min_rx_bufsize;
83         uint16_t min_rx_desc;
84         uint16_t max_rx_desc;
85         uint16_t min_tx_desc;
86         uint16_t max_tx_desc;
87         uint32_t nb_mc_addr;
88         uint8_t available;
89         prox_rte_ether_addr mc_addr[NB_MCAST_ADDR];
90         int dpdk_mapping;
91         struct ip4_subnet ip_addr[PROX_MAX_VLAN_TAGS];
92         int fds[PROX_MAX_VLAN_TAGS];
93         uint32_t vlan_tags[PROX_MAX_VLAN_TAGS];
94         uint8_t is_vdev;
95         uint8_t virtual;
96         uint8_t all_rx_queues;
97         uint16_t n_vlans;
98         uint32_t v6_mask_length;
99 };
100
101 extern rte_atomic32_t lsc;
102
103 int prox_nb_active_ports(void);
104 int prox_last_port_active(void);
105
106 extern struct prox_port_cfg prox_port_cfg[];
107
108 void init_rte_dev(int use_dummy_devices);
109 uint8_t init_rte_ring_dev(void);
110 void init_port_addr(void);
111 void init_port_all(void);
112 void close_ports_atexit(void);
113
114 struct rte_mempool;
115
116 void prox_pktmbuf_init(struct rte_mempool *mp, void *opaque_arg, void *_m, unsigned i);
117 void prox_pktmbuf_reinit(void *arg, void *start, void *end, uint32_t idx);
118
119 int port_is_active(uint8_t port_id);
120
121 #endif /* __PROX_PORT_CFG_H_ */