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 #ifdef __cplusplus 31 extern "C" { 32 #endif 33 34 // dpdk argc, argv, max argc: 16, member of dpdk_config 35 #define DPDK_CONFIG_NUM 16 36 #define DPDK_CONFIG_MAXLEN 256 37 #define DPDK_MAX_LCORE 128 38 39 extern int dpdk_argc; 40 extern char *dpdk_argv[DPDK_CONFIG_NUM + 1]; 41 42 #define MAX_PKT_BURST 32 43 #define BURST_TX_DRAIN_US 100 /* TX drain every ~100us */ 44 45 struct ff_hw_features { 46 uint8_t rx_csum; 47 uint8_t rx_lro; 48 uint8_t tx_csum_ip; 49 uint8_t tx_csum_l4; 50 uint8_t tx_tso; 51 }; 52 53 struct ff_port_cfg { 54 char *name; 55 uint8_t port_id; 56 uint8_t mac[6]; 57 struct ff_hw_features hw_features; 58 char *addr; 59 char *netmask; 60 char *broadcast; 61 char *gateway; 62 char *pcap; 63 64 int nb_lcores; 65 int nb_slaves; 66 uint16_t lcore_list[DPDK_MAX_LCORE]; 67 uint16_t *slave_portid_list; 68 }; 69 70 struct ff_vdev_cfg { 71 char *name; 72 char *iface; 73 char *path; 74 char *mac; 75 uint8_t vdev_id; 76 uint8_t nb_queues; 77 uint8_t nb_cq; 78 uint16_t queue_size; 79 }; 80 81 struct ff_bond_cfg { 82 char *name; 83 char *slave; 84 char *primary; 85 char *bond_mac; 86 char *xmit_policy; 87 uint8_t bond_id; 88 uint8_t mode; 89 uint8_t socket_id; 90 uint8_t lsc_poll_period_ms; 91 uint16_t up_delay; 92 uint16_t down_delay; 93 }; 94 95 struct ff_freebsd_cfg { 96 char *name; 97 char *str; 98 void *value; 99 size_t vlen; 100 struct ff_freebsd_cfg *next; 101 }; 102 103 struct ff_config { 104 char *filename; 105 struct { 106 char *proc_type; 107 /* mask of enabled lcores */ 108 char *lcore_mask; 109 /* mask of current proc on all lcores */ 110 char *proc_mask; 111 112 /* specify base virtual address to map. */ 113 char *base_virtaddr; 114 115 int nb_channel; 116 int memory; 117 int no_huge; 118 int nb_procs; 119 int proc_id; 120 int promiscuous; 121 int nb_vdev; 122 int nb_bond; 123 int numa_on; 124 int tso; 125 int tx_csum_offoad_skip; 126 int vlan_strip; 127 128 /* sleep x microseconds when no pkts incomming */ 129 unsigned idle_sleep; 130 131 /* TX burst queue drain nodelay dalay time */ 132 unsigned pkt_tx_delay; 133 134 /* list of proc-lcore */ 135 uint16_t *proc_lcore; 136 137 int nb_ports; 138 uint16_t max_portid; 139 uint16_t *portid_list; 140 // MAP(portid => struct ff_port_cfg*) 141 struct ff_port_cfg *port_cfgs; 142 struct ff_vdev_cfg *vdev_cfgs; 143 struct ff_bond_cfg *bond_cfgs; 144 } dpdk; 145 146 struct { 147 int enable; 148 char *method; 149 char *tcp_port; 150 char *udp_port; 151 } kni; 152 153 struct { 154 int level; 155 const char *dir; 156 } log; 157 158 struct { 159 struct ff_freebsd_cfg *boot; 160 struct ff_freebsd_cfg *sysctl; 161 long physmem; 162 int hz; 163 int fd_reserve; 164 int mem_size; 165 } freebsd; 166 }; 167 168 extern struct ff_config ff_global_cfg; 169 170 int ff_load_config(int argc, char * const argv[]); 171 172 #ifdef __cplusplus 173 } 174 #endif 175 176 #endif /* ifndef __FSTACK_CONFIG_H */ 177