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 uint16_t lcore_list[DPDK_MAX_LCORE]; 66 }; 67 68 struct ff_vdev_cfg { 69 char *name; 70 char *iface; 71 char *path; 72 char *mac; 73 uint8_t vdev_id; 74 uint8_t nb_queues; 75 uint8_t nb_cq; 76 uint16_t queue_size; 77 }; 78 79 80 81 struct ff_freebsd_cfg { 82 char *name; 83 char *str; 84 void *value; 85 size_t vlen; 86 struct ff_freebsd_cfg *next; 87 }; 88 89 struct ff_config { 90 char *filename; 91 struct { 92 char *proc_type; 93 /* mask of enabled lcores */ 94 char *lcore_mask; 95 /* mask of current proc on all lcores */ 96 char *proc_mask; 97 98 /* specify base virtual address to map. */ 99 char *base_virtaddr; 100 101 int nb_channel; 102 int memory; 103 int no_huge; 104 int nb_procs; 105 int proc_id; 106 int promiscuous; 107 int nb_vdev; 108 int numa_on; 109 int tso; 110 int vlan_strip; 111 112 /* sleep x microseconds when no pkts incomming */ 113 unsigned idle_sleep; 114 115 /* TX burst queue drain nodelay dalay time */ 116 unsigned pkt_tx_delay; 117 118 /* list of proc-lcore */ 119 uint16_t *proc_lcore; 120 121 int nb_ports; 122 uint16_t max_portid; 123 uint16_t *portid_list; 124 // MAP(portid => struct ff_port_cfg*) 125 struct ff_port_cfg *port_cfgs; 126 struct ff_vdev_cfg *vdev_cfgs; 127 } dpdk; 128 129 struct { 130 int enable; 131 char *method; 132 char *tcp_port; 133 char *udp_port; 134 } kni; 135 136 struct { 137 int level; 138 const char *dir; 139 } log; 140 141 struct { 142 struct ff_freebsd_cfg *boot; 143 struct ff_freebsd_cfg *sysctl; 144 long physmem; 145 int hz; 146 int fd_reserve; 147 int mem_size; 148 } freebsd; 149 }; 150 151 extern struct ff_config ff_global_cfg; 152 153 int ff_load_config(int argc, char * const argv[]); 154 155 #ifdef __cplusplus 156 } 157 #endif 158 159 #endif /* ifndef __FSTACK_CONFIG_H */ 160