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 34 extern int dpdk_argc; 35 extern char *dpdk_argv[DPDK_CONFIG_NUM + 1]; 36 37 struct ff_hw_features { 38 uint8_t rx_csum; 39 uint8_t rx_lro; 40 uint8_t tx_csum_ip; 41 uint8_t tx_csum_l4; 42 uint8_t tx_tso; 43 }; 44 45 struct ff_port_cfg { 46 char *name; 47 uint8_t port_id; 48 uint8_t mac[6]; 49 struct ff_hw_features hw_features; 50 char *addr; 51 char *netmask; 52 char *broadcast; 53 char *gateway; 54 char *pcap; 55 }; 56 57 struct ff_freebsd_cfg { 58 char *name; 59 char *str; 60 void *value; 61 size_t vlen; 62 struct ff_freebsd_cfg *next; 63 }; 64 65 struct ff_config { 66 struct { 67 /* mask of enabled lcores */ 68 char *lcore_mask; 69 /* mask of current proc on all lcores */ 70 char *proc_mask; 71 /* mask of enabled ports 72 * use uint32_t because num of max ports is 32 73 */ 74 uint32_t port_mask; 75 int nb_channel; 76 int memory; 77 int no_huge; 78 int nb_procs; 79 int proc_id; 80 int nb_ports; 81 int promiscuous; 82 int numa_on; 83 int tso; 84 struct ff_port_cfg *port_cfgs; 85 } dpdk; 86 87 struct { 88 int enable; 89 char *method; 90 char *tcp_port; 91 char *udp_port; 92 } kni; 93 94 struct { 95 int level; 96 const char *dir; 97 } log; 98 99 struct { 100 struct ff_freebsd_cfg *boot; 101 struct ff_freebsd_cfg *sysctl; 102 long physmem; 103 int hz; 104 } freebsd; 105 }; 106 107 extern struct ff_config ff_global_cfg; 108 109 int ff_load_config(const char *conf, int argc, char * const argv[]); 110 111 #endif /* ifndef __FSTACK_CONFIG_H */ 112