1 /* 2 * Copyright (C) 2017 THL A29 Limited, a Tencent company. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright notice, this 9 * list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright notice, 11 * this list of conditions and the following disclaimer in the documentation 12 * and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 18 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 23 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * 25 */ 26 27 #ifndef __FSTACK_CONFIG_H 28 #define __FSTACK_CONFIG_H 29 30 // dpdk argc, argv, max argc: 4, member of dpdk_config 31 #define DPDK_CONFIG_NUM 4 32 #define DPDK_CONFIG_MAXLEN 64 33 #define DPDK_MAX_LCORE 128 34 35 extern int dpdk_argc; 36 extern char *dpdk_argv[DPDK_CONFIG_NUM + 1]; 37 38 struct ff_hw_features { 39 uint8_t rx_csum; 40 uint8_t rx_lro; 41 uint8_t tx_csum_ip; 42 uint8_t tx_csum_l4; 43 uint8_t tx_tso; 44 }; 45 46 struct ff_port_cfg { 47 char *name; 48 uint8_t port_id; 49 uint8_t mac[6]; 50 struct ff_hw_features hw_features; 51 char *addr; 52 char *netmask; 53 char *broadcast; 54 char *gateway; 55 char *pcap; 56 57 int nb_lcores; 58 uint16_t lcore_list[DPDK_MAX_LCORE]; 59 }; 60 61 struct ff_freebsd_cfg { 62 char *name; 63 char *str; 64 void *value; 65 size_t vlen; 66 struct ff_freebsd_cfg *next; 67 }; 68 69 struct ff_config { 70 char *filename; 71 struct { 72 char *proc_type; 73 /* mask of enabled lcores */ 74 char *lcore_mask; 75 /* mask of current proc on all lcores */ 76 char *proc_mask; 77 78 int nb_channel; 79 int memory; 80 int no_huge; 81 int nb_procs; 82 int proc_id; 83 int promiscuous; 84 int numa_on; 85 int tso; 86 int vlan_strip; 87 /* list of proc-lcore */ 88 uint16_t *proc_lcore; 89 90 int nb_ports; 91 uint16_t *portid_list; 92 uint16_t max_portid; 93 // MAP(portid => struct ff_port_cfg*) 94 struct ff_port_cfg *port_cfgs; 95 } dpdk; 96 97 struct { 98 int enable; 99 char *method; 100 char *tcp_port; 101 char *udp_port; 102 } kni; 103 104 struct { 105 int level; 106 const char *dir; 107 } log; 108 109 struct { 110 struct ff_freebsd_cfg *boot; 111 struct ff_freebsd_cfg *sysctl; 112 long physmem; 113 int hz; 114 int fd_reserve; 115 } freebsd; 116 }; 117 118 extern struct ff_config ff_global_cfg; 119 120 int ff_load_config(int argc, char * const argv[]); 121 122 #endif /* ifndef __FSTACK_CONFIG_H */ 123