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 struct ff_hw_features { 43 uint8_t rx_csum; 44 uint8_t rx_lro; 45 uint8_t tx_csum_ip; 46 uint8_t tx_csum_l4; 47 uint8_t tx_tso; 48 }; 49 50 struct ff_port_cfg { 51 char *name; 52 uint8_t port_id; 53 uint8_t mac[6]; 54 struct ff_hw_features hw_features; 55 char *addr; 56 char *netmask; 57 char *broadcast; 58 char *gateway; 59 char *pcap; 60 61 int nb_lcores; 62 uint16_t lcore_list[DPDK_MAX_LCORE]; 63 }; 64 65 struct ff_vdev_cfg { 66 char *name; 67 char *iface; 68 char *path; 69 char *mac; 70 uint8_t vdev_id; 71 uint8_t nb_queues; 72 uint8_t nb_cq; 73 uint16_t queue_size; 74 }; 75 76 77 78 struct ff_freebsd_cfg { 79 char *name; 80 char *str; 81 void *value; 82 size_t vlen; 83 struct ff_freebsd_cfg *next; 84 }; 85 86 struct ff_config { 87 char *filename; 88 struct { 89 char *proc_type; 90 /* mask of enabled lcores */ 91 char *lcore_mask; 92 /* mask of current proc on all lcores */ 93 char *proc_mask; 94 95 /* specify base virtual address to map. */ 96 char *base_virtaddr; 97 98 int nb_channel; 99 int memory; 100 int no_huge; 101 int nb_procs; 102 int proc_id; 103 int promiscuous; 104 int nb_vdev; 105 int numa_on; 106 int tso; 107 int vlan_strip; 108 109 /* sleep x microseconds when no pkts incomming */ 110 unsigned idle_sleep; 111 112 /* list of proc-lcore */ 113 uint16_t *proc_lcore; 114 115 int nb_ports; 116 uint16_t max_portid; 117 uint16_t *portid_list; 118 // MAP(portid => struct ff_port_cfg*) 119 struct ff_port_cfg *port_cfgs; 120 struct ff_vdev_cfg *vdev_cfgs; 121 } dpdk; 122 123 struct { 124 int enable; 125 char *method; 126 char *tcp_port; 127 char *udp_port; 128 } kni; 129 130 struct { 131 int level; 132 const char *dir; 133 } log; 134 135 struct { 136 struct ff_freebsd_cfg *boot; 137 struct ff_freebsd_cfg *sysctl; 138 long physmem; 139 int hz; 140 int fd_reserve; 141 } freebsd; 142 }; 143 144 extern struct ff_config ff_global_cfg; 145 146 int ff_load_config(int argc, char * const argv[]); 147 148 #ifdef __cplusplus 149 } 150 #endif 151 152 #endif /* ifndef __FSTACK_CONFIG_H */ 153