2017-04-21 10:43:26 +00:00
|
|
|
/*
|
2021-09-18 08:05:45 +00:00
|
|
|
* Copyright (C) 2017-2021 THL A29 Limited, a Tencent company.
|
2017-04-21 10:43:26 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
|
|
* list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer in the documentation
|
|
|
|
* and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
|
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
|
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __FSTACK_CONFIG_H
|
|
|
|
#define __FSTACK_CONFIG_H
|
|
|
|
|
2018-01-02 10:22:40 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2018-08-17 17:45:11 +00:00
|
|
|
// dpdk argc, argv, max argc: 16, member of dpdk_config
|
|
|
|
#define DPDK_CONFIG_NUM 16
|
2018-11-26 18:02:38 +00:00
|
|
|
#define DPDK_CONFIG_MAXLEN 256
|
2017-09-14 11:51:07 +00:00
|
|
|
#define DPDK_MAX_LCORE 128
|
2024-09-06 12:20:44 +00:00
|
|
|
#define DPDK_MAX_VLAN_FILTER 128
|
2020-01-08 04:09:40 +00:00
|
|
|
#define PCAP_SNAP_MINLEN 94
|
|
|
|
#define PCAP_SAVE_MINLEN (2<<22)
|
2024-10-10 09:48:40 +00:00
|
|
|
/*
|
|
|
|
* KNI ratelimit default value.
|
|
|
|
* The total speed limit for a single process entering the kni ring is 10,000 QPS,
|
|
|
|
* 1000 QPS for general packets, 9000 QPS for console packets (ospf/arp, etc.)
|
|
|
|
* The total speed limit for kni forwarding to the kernel is 20,000 QPS.
|
|
|
|
*/
|
|
|
|
#define KNI_RATELIMT_PROCESS (10000)
|
|
|
|
#define KNI_RATELIMT_GENERAL (1000)
|
|
|
|
#define KNI_RATELIMT_CONSOLE (KNI_RATELIMT_PROCESS - KNI_RATELIMT_GENERAL)
|
|
|
|
#define KNI_RATELIMT_KERNEL (KNI_RATELIMT_PROCESS * 2)
|
2017-04-21 10:43:26 +00:00
|
|
|
|
|
|
|
extern int dpdk_argc;
|
|
|
|
extern char *dpdk_argv[DPDK_CONFIG_NUM + 1];
|
|
|
|
|
2019-06-27 09:44:19 +00:00
|
|
|
#define MAX_PKT_BURST 32
|
|
|
|
#define BURST_TX_DRAIN_US 100 /* TX drain every ~100us */
|
|
|
|
|
2021-06-16 11:24:35 +00:00
|
|
|
#define VIP_MAX_NUM 64
|
|
|
|
|
2023-09-19 10:28:57 +00:00
|
|
|
/* exception path(KNI) type */
|
|
|
|
#define KNI_TYPE_KNI 0
|
|
|
|
#define KNI_TYPE_VIRTIO 1
|
|
|
|
|
2017-05-06 13:52:25 +00:00
|
|
|
struct ff_hw_features {
|
|
|
|
uint8_t rx_csum;
|
|
|
|
uint8_t rx_lro;
|
|
|
|
uint8_t tx_csum_ip;
|
|
|
|
uint8_t tx_csum_l4;
|
|
|
|
uint8_t tx_tso;
|
|
|
|
};
|
|
|
|
|
2024-09-06 12:20:44 +00:00
|
|
|
#ifdef FF_IPFW
|
|
|
|
struct ff_ipfw_pr_cfg {
|
|
|
|
//uint32_t rule_num;
|
|
|
|
//uint32_t fib_num; /* Use portN or vlanN's idx * 100 */
|
|
|
|
char *addr;
|
|
|
|
char *netmask;
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
struct ff_vlan_cfg {
|
|
|
|
char *name;
|
|
|
|
char *ifname;
|
|
|
|
/* global vlan idx, also use for route table's fib num */
|
|
|
|
int vlan_idx;
|
|
|
|
uint16_t vlan_id;
|
|
|
|
uint16_t port_id;
|
|
|
|
|
|
|
|
char *addr;
|
|
|
|
char *netmask;
|
|
|
|
char *broadcast;
|
|
|
|
char *gateway;
|
|
|
|
|
|
|
|
char *vip_ifname;
|
|
|
|
char *vip_addr_str;
|
|
|
|
char **vip_addr_array;
|
|
|
|
uint32_t nb_vip;
|
|
|
|
|
|
|
|
/* simple policy routing, only need rule num(100/200/300/400), ip/mask,fib num(0/1/2/3/4) */
|
|
|
|
char *pr_addr_str;
|
|
|
|
|
|
|
|
#ifdef FF_IPFW
|
|
|
|
struct ff_ipfw_pr_cfg *pr_cfg;
|
|
|
|
uint32_t nb_pr;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef INET6
|
|
|
|
char *addr6_str;
|
|
|
|
char *gateway6_str;
|
|
|
|
uint8_t prefix_len;
|
|
|
|
|
|
|
|
char *vip_addr6_str;
|
|
|
|
char **vip_addr6_array;
|
|
|
|
uint32_t nb_vip6;
|
|
|
|
uint8_t vip_prefix_len;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2017-04-21 10:43:26 +00:00
|
|
|
struct ff_port_cfg {
|
|
|
|
char *name;
|
2021-10-30 05:01:53 +00:00
|
|
|
char *ifname;
|
2024-08-28 03:48:01 +00:00
|
|
|
uint16_t port_id;
|
2017-04-21 10:43:26 +00:00
|
|
|
uint8_t mac[6];
|
2017-05-06 13:52:25 +00:00
|
|
|
struct ff_hw_features hw_features;
|
2024-09-06 12:20:44 +00:00
|
|
|
|
2017-04-21 10:43:26 +00:00
|
|
|
char *addr;
|
|
|
|
char *netmask;
|
|
|
|
char *broadcast;
|
|
|
|
char *gateway;
|
2021-01-21 14:53:48 +00:00
|
|
|
|
2021-06-16 11:24:35 +00:00
|
|
|
char *vip_ifname;
|
|
|
|
char *vip_addr_str;
|
|
|
|
char **vip_addr_array;
|
|
|
|
uint32_t nb_vip;
|
|
|
|
|
2024-09-06 12:20:44 +00:00
|
|
|
#ifdef FF_IPFW
|
|
|
|
char *pr_addr_str;
|
|
|
|
struct ff_ipfw_pr_cfg *pr_cfg;
|
|
|
|
uint32_t nb_pr;
|
|
|
|
#endif
|
|
|
|
|
2021-01-21 14:53:48 +00:00
|
|
|
#ifdef INET6
|
2022-09-02 08:51:22 +00:00
|
|
|
char *addr6_str;
|
|
|
|
char *gateway6_str;
|
|
|
|
uint8_t prefix_len;
|
2022-09-02 11:41:14 +00:00
|
|
|
|
2022-09-02 08:51:22 +00:00
|
|
|
char *vip_addr6_str;
|
|
|
|
char **vip_addr6_array;
|
|
|
|
uint32_t nb_vip6;
|
|
|
|
uint8_t vip_prefix_len;
|
2021-01-21 14:53:48 +00:00
|
|
|
#endif
|
|
|
|
|
2017-09-14 11:51:07 +00:00
|
|
|
int nb_lcores;
|
2019-09-04 13:17:10 +00:00
|
|
|
int nb_slaves;
|
2017-09-14 11:51:07 +00:00
|
|
|
uint16_t lcore_list[DPDK_MAX_LCORE];
|
2019-09-04 13:17:10 +00:00
|
|
|
uint16_t *slave_portid_list;
|
2024-09-06 12:20:44 +00:00
|
|
|
|
|
|
|
int nb_vlan;
|
|
|
|
struct ff_vlan_cfg *vlan_cfgs[DPDK_MAX_VLAN_FILTER];
|
2017-04-21 10:43:26 +00:00
|
|
|
};
|
|
|
|
|
2018-11-26 18:02:38 +00:00
|
|
|
struct ff_vdev_cfg {
|
|
|
|
char *name;
|
|
|
|
char *iface;
|
|
|
|
char *path;
|
|
|
|
char *mac;
|
|
|
|
uint8_t vdev_id;
|
|
|
|
uint8_t nb_queues;
|
|
|
|
uint8_t nb_cq;
|
|
|
|
uint16_t queue_size;
|
|
|
|
};
|
|
|
|
|
2019-09-04 13:17:10 +00:00
|
|
|
struct ff_bond_cfg {
|
|
|
|
char *name;
|
|
|
|
char *slave;
|
|
|
|
char *primary;
|
|
|
|
char *bond_mac;
|
|
|
|
char *xmit_policy;
|
|
|
|
uint8_t bond_id;
|
|
|
|
uint8_t mode;
|
|
|
|
uint8_t socket_id;
|
|
|
|
uint8_t lsc_poll_period_ms;
|
|
|
|
uint16_t up_delay;
|
|
|
|
uint16_t down_delay;
|
|
|
|
};
|
2018-11-26 18:02:38 +00:00
|
|
|
|
2017-04-21 10:43:26 +00:00
|
|
|
struct ff_freebsd_cfg {
|
|
|
|
char *name;
|
|
|
|
char *str;
|
|
|
|
void *value;
|
|
|
|
size_t vlen;
|
|
|
|
struct ff_freebsd_cfg *next;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ff_config {
|
2017-08-08 14:36:49 +00:00
|
|
|
char *filename;
|
2017-09-14 11:51:07 +00:00
|
|
|
struct {
|
2017-08-08 14:36:49 +00:00
|
|
|
char *proc_type;
|
2017-04-21 10:43:26 +00:00
|
|
|
/* mask of enabled lcores */
|
|
|
|
char *lcore_mask;
|
|
|
|
/* mask of current proc on all lcores */
|
|
|
|
char *proc_mask;
|
2017-09-14 11:51:07 +00:00
|
|
|
|
2018-11-13 13:54:13 +00:00
|
|
|
/* specify base virtual address to map. */
|
|
|
|
char *base_virtaddr;
|
|
|
|
|
2020-11-17 11:04:23 +00:00
|
|
|
/* allow processes that do not want to co-operate to have different memory regions */
|
|
|
|
char *file_prefix;
|
|
|
|
|
|
|
|
/* load an external driver */
|
|
|
|
char *pci_whitelist;
|
|
|
|
|
2017-04-21 10:43:26 +00:00
|
|
|
int nb_channel;
|
|
|
|
int memory;
|
|
|
|
int no_huge;
|
|
|
|
int nb_procs;
|
|
|
|
int proc_id;
|
|
|
|
int promiscuous;
|
2018-11-26 18:02:38 +00:00
|
|
|
int nb_vdev;
|
2019-09-04 13:17:10 +00:00
|
|
|
int nb_bond;
|
2017-04-21 10:43:26 +00:00
|
|
|
int numa_on;
|
2017-05-06 13:52:25 +00:00
|
|
|
int tso;
|
2019-11-04 05:00:17 +00:00
|
|
|
int tx_csum_offoad_skip;
|
2017-08-09 08:52:16 +00:00
|
|
|
int vlan_strip;
|
2024-09-06 12:20:44 +00:00
|
|
|
int nb_vlan_filter;
|
|
|
|
uint16_t vlan_filter_id[DPDK_MAX_VLAN_FILTER];
|
2020-08-29 16:55:08 +00:00
|
|
|
int symmetric_rss;
|
2018-08-17 17:45:11 +00:00
|
|
|
|
|
|
|
/* sleep x microseconds when no pkts incomming */
|
|
|
|
unsigned idle_sleep;
|
|
|
|
|
2019-06-27 09:44:19 +00:00
|
|
|
/* TX burst queue drain nodelay dalay time */
|
|
|
|
unsigned pkt_tx_delay;
|
|
|
|
|
2017-08-08 14:36:49 +00:00
|
|
|
/* list of proc-lcore */
|
|
|
|
uint16_t *proc_lcore;
|
2017-09-14 11:51:07 +00:00
|
|
|
|
|
|
|
int nb_ports;
|
|
|
|
uint16_t max_portid;
|
2018-08-17 17:45:11 +00:00
|
|
|
uint16_t *portid_list;
|
2022-06-08 07:36:38 +00:00
|
|
|
|
|
|
|
// load dpdk log level
|
|
|
|
uint16_t log_level;
|
2017-09-14 11:51:07 +00:00
|
|
|
// MAP(portid => struct ff_port_cfg*)
|
2017-04-21 10:43:26 +00:00
|
|
|
struct ff_port_cfg *port_cfgs;
|
2024-09-06 12:20:44 +00:00
|
|
|
struct ff_vlan_cfg *vlan_cfgs;
|
2018-11-26 18:02:38 +00:00
|
|
|
struct ff_vdev_cfg *vdev_cfgs;
|
2019-09-04 13:17:10 +00:00
|
|
|
struct ff_bond_cfg *bond_cfgs;
|
2017-04-21 10:43:26 +00:00
|
|
|
} dpdk;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
int enable;
|
2023-09-19 10:28:57 +00:00
|
|
|
int type;
|
2024-10-10 09:48:40 +00:00
|
|
|
int console_packets_ratelimit;
|
|
|
|
int general_packets_ratelimit;
|
|
|
|
int kernel_packets_ratelimit;
|
2020-05-14 10:30:34 +00:00
|
|
|
char *kni_action;
|
2017-04-21 10:43:26 +00:00
|
|
|
char *method;
|
|
|
|
char *tcp_port;
|
|
|
|
char *udp_port;
|
|
|
|
} kni;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
int level;
|
|
|
|
const char *dir;
|
|
|
|
} log;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
struct ff_freebsd_cfg *boot;
|
|
|
|
struct ff_freebsd_cfg *sysctl;
|
|
|
|
long physmem;
|
|
|
|
int hz;
|
2017-08-08 14:36:49 +00:00
|
|
|
int fd_reserve;
|
2019-03-29 02:42:02 +00:00
|
|
|
int mem_size;
|
2017-04-21 10:43:26 +00:00
|
|
|
} freebsd;
|
2020-01-08 04:09:40 +00:00
|
|
|
|
|
|
|
struct {
|
2020-01-07 13:10:08 +00:00
|
|
|
uint16_t enable;
|
|
|
|
uint16_t snap_len;
|
|
|
|
uint32_t save_len;
|
|
|
|
char* save_path;
|
2020-01-08 04:09:40 +00:00
|
|
|
} pcap;
|
2017-04-21 10:43:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern struct ff_config ff_global_cfg;
|
|
|
|
|
2017-08-08 14:36:49 +00:00
|
|
|
int ff_load_config(int argc, char * const argv[]);
|
2017-04-21 10:43:26 +00:00
|
|
|
|
2018-01-02 10:22:40 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-04-21 10:43:26 +00:00
|
|
|
#endif /* ifndef __FSTACK_CONFIG_H */
|