ccf83d6cef428869e838becffd742002bb87762e
[samplevnf.git] / VNFs / DPPD-PROX / prox_port_cfg.h
1 /*
2 // Copyright (c) 2010-2017 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(17,11,0,0)
25 #include <rte_bus_pci.h>
26 #endif
27 #include <rte_pci.h>
28
29 #include "prox_globals.h"
30
31 enum addr_type {PROX_PORT_MAC_HW, PROX_PORT_MAC_SET, PROX_PORT_MAC_RAND};
32
33 #define IPV4_CKSUM      1
34 #define UDP_CKSUM       2
35
36 struct prox_port_cfg {
37         struct rte_mempool *pool[32];  /* Rx/Tx mempool */
38         size_t pool_size[32];
39         uint8_t promiscuous;
40         uint8_t lsc_set_explicitely; /* Explicitly enable/disable lsc */
41         uint8_t lsc_val;
42         uint8_t active;
43         int socket;
44         uint16_t max_rxq;         /* max number of Tx queues */
45         uint16_t max_txq;         /* max number of Tx queues */
46         uint16_t n_rxq;           /* number of used Rx queues */
47         uint16_t n_txq;           /* number of used Tx queues */
48         uint32_t n_rxd;
49         uint32_t n_txd;
50         uint8_t  link_up;
51         uint32_t  link_speed;
52         uint32_t  max_link_speed;
53         uint32_t  mtu;
54         enum addr_type    type;
55         struct ether_addr eth_addr;    /* port MAC address */
56         char name[MAX_NAME_SIZE];
57         char short_name[MAX_NAME_SIZE];
58         char driver_name[MAX_NAME_SIZE];
59         char rx_ring[MAX_NAME_SIZE];
60         char tx_ring[MAX_NAME_SIZE];
61         char pci_addr[32];
62         struct rte_eth_conf port_conf;
63         struct rte_eth_rxconf rx_conf;
64         struct rte_eth_txconf tx_conf;
65         uint64_t requested_rx_offload;
66         uint64_t requested_tx_offload;
67         uint64_t disabled_tx_offload;
68         struct rte_eth_dev_info dev_info;
69         struct {
70                 int tx_offload_cksum;
71         } capabilities;
72         uint32_t max_rx_pkt_len;
73         uint32_t min_rx_bufsize;
74 };
75
76 extern rte_atomic32_t lsc;
77
78 int prox_nb_active_ports(void);
79 int prox_last_port_active(void);
80
81 extern struct prox_port_cfg prox_port_cfg[];
82
83 void init_rte_dev(int use_dummy_devices);
84 uint8_t init_rte_ring_dev(void);
85 void init_port_addr(void);
86 void init_port_all(void);
87 void close_ports_atexit(void);
88
89 struct rte_mempool;
90
91 void prox_pktmbuf_init(struct rte_mempool *mp, void *opaque_arg, void *_m, unsigned i);
92 void prox_pktmbuf_reinit(void *arg, void *start, void *end, uint32_t idx);
93
94 int port_is_active(uint8_t port_id);
95
96 #endif /* __PROX_PORT_CFG_H_ */