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