@@ -62,7 +62,7 @@ F-Stack 导出 **80+ 个公开符号**,分为以下几大类:
6262
6363### 1.2 六个主要头文件详解
6464
65- #### ** ff_api.h (412 行) - 主 API**
65+ #### ** ff_api.h (416 行) - 主 API**
6666
6767** 初始化与启动** :
6868``` c
@@ -301,58 +301,104 @@ int ff_clock_gettime(clockid_t clock_id, struct timespec *tp);
301301
302302仅包装 ff_kqueue 为 epoll 接口,供 Linux 应用兼容性使用。
303303
304- #### **ff_config.h (2855 行) - 配置接口**
304+ #### **ff_config.h (352 行) - 配置接口**
305305
306306**核心结构体**:
307+
307308```c
308309struct ff_config {
309- // DPDK 配置
310+ char *filename;
311+
312+ // DPDK 配置部分
310313 struct {
311- int dpdk_argc;
312- char *dpdk_argv[64];
313- uint32_t dpdk_lcore_mask; // 十六进制,指定使用的核心
314- uint32_t dpdk_memory; // 内存大小 (MB)
315- uint32_t dpdk_channel; // 内存通道
314+ char *proc_type;
315+ /* mask of enabled lcores */
316+ char *lcore_mask; // [0x4] CPU 核心掩码 (十六进制)
317+ /* mask of current proc on all lcores */
318+ char *proc_mask;
319+
320+ /* specify base virtual address to map. */
321+ char *base_virtaddr;
322+
323+ /* allow processes that do not want to co-operate to have different memory regions */
324+ char *file_prefix;
325+
326+ /* pci whiltelist */
327+ char *allow;
328+
329+ int nb_channel; // [0x8] 内存通道数
330+ int memory; // [0xC] 预留内存 (MB)
331+ int no_huge;
332+ int nb_procs;
333+ int proc_id;
334+ int promiscuous; // [0x10] 混杂模式
335+ int nb_vdev;
336+ int nb_bond;
337+ int numa_on; // [0x14] NUMA 支持
338+ int tso;
339+ int tx_csum_offoad_skip;
340+ int vlan_strip;
341+ int nb_vlan_filter;
342+ uint16_t vlan_filter_id[DPDK_MAX_VLAN_FILTER];
343+ int symmetric_rss;
344+
345+ /* sleep x microseconds when no pkts incomming */
346+ unsigned idle_sleep;
347+
348+ /* TX burst queue drain nodelay dalay time */
349+ unsigned pkt_tx_delay;
350+
351+ /* list of proc-lcore */
352+ uint16_t *proc_lcore;
353+
354+ int nb_ports;
355+ uint16_t max_portid;
356+ uint16_t *portid_list;
357+
358+ // load dpdk log level
359+ uint16_t log_level;
360+ // MAP(portid => struct ff_port_cfg*)
361+ struct ff_port_cfg *port_cfgs;
362+ struct ff_vlan_cfg *vlan_cfgs;
363+ struct ff_vdev_cfg *vdev_cfgs;
364+ struct ff_bond_cfg *bond_cfgs;
365+ struct ff_rss_check_cfg *rss_check_cfgs;
316366 } dpdk;
317367
318- // 端口配置
319- struct ff_port_cfg {
320- struct in_addr addr; // IPv4 地址
321- struct in_addr netmask; // 网掩码
322- struct in_addr gateway; // 网关
323- struct in6_addr addr6; // IPv6 地址
324- struct in_addr broadcast;
325-
326- // VIP 列表 (最多 64 个)
327- struct in_addr vip_addr[FF_VIP_MAX];
328- int nb_vips;
329-
330- // 硬件特性
331- int rx_csum; // RX checksum offload
332- int tx_csum; // TX checksum offload
333- int tso; // TSO/GSO 支持
334- int lro; // LRO 支持
335- int vlan_strip; // VLAN strip
336- } port_cfg[RTE_MAX_ETHPORTS];
337-
338- // KNI 配置 (可选)
368+ // KNI 配置
339369 struct {
340370 int enable;
341- uint32_t rate_limit;
371+ int console_packets_ratelimit; // 速率限制 (QPS)
372+ int general_packets_ratelimit;
373+ int kernel_packets_ratelimit;
374+ char *kni_action;
375+ char *method;
376+ char *tcp_port;
377+ char *udp_port;
342378 } kni;
343-
344- // FreeBSD 启动配置
379+
345380 struct {
346- uint32_t hz; // 时钟频率 (默认 1000)
347- uint32_t fd_reserve; // 预留文件描述符
348- } freebsd_boot;
349-
350- // FreeBSD Sysctl
381+ int level;
382+ const char *dir;
383+ void *f; /* FILE * */
384+ } log;
385+
386+ // FreeBSD 启动参数
387+ struct {
388+ struct ff_freebsd_cfg *boot;
389+ struct ff_freebsd_cfg *sysctl;
390+ long physmem;
391+ int hz; // 时钟频率 (1000 = 1kHz)
392+ int fd_reserve; // 预留 fd 数
393+ int mem_size;
394+ } freebsd;
395+
351396 struct {
352- char *cc_algorithm; // TCP 拥塞控制算法
353- uint32_t sendspace; // socket 发送缓冲 (字节)
354- uint32_t recvspace; // socket 接收缓冲 (字节)
355- } freebsd_sysctl;
397+ uint16_t enable;
398+ uint16_t snap_len;
399+ uint32_t save_len;
400+ char* save_path;
401+ } pcap;
356402};
357403```
358404
@@ -402,13 +448,13 @@ struct kevent {
402448提供 POSIX/FreeBSD 兼容的错误编号:
403449
404450```c
405- #define FF_EPERM 1 // 操作不允许
406- #define FF_ENOENT 2 // 没有这样的文件或目录
407- #define FF_ECONNREFUSED 111 // 连接被拒绝
408- #define FF_ETIMEDOUT 110 // 连接超时
409- #define FF_ECONNRESET 104 // 连接重置
410- #define FF_EAGAIN 11 // 请重试
411- #define FF_EINPROGRESS 115 // 操作正在进行中
451+ #define ff_EPERM 1 // 操作不允许
452+ #define ff_ENOENT 2 // 没有这样的文件或目录
453+ #define ff_ECONNREFUSED 61 // 连接被拒绝
454+ #define ff_ETIMEDOUT 60 // 连接超时
455+ #define ff_ECONNRESET 54 // 连接重置
456+ #define ff_EAGAIN 35 // 请重试
457+ #define ff_EINPROGRESS 36 // 操作正在进行中
412458// ... 等等
413459```
414460
@@ -593,7 +639,8 @@ net.inet.tcp.syncache.hashsize = 512
593639net.inet.tcp.syncache.bucketlimit = 30
594640
595641# TCP 算法
596- net.inet.tcp.cc.algorithm = cubic # cubic/freebsd/rack/bbr
642+ net.inet.tcp.cc.algorithm = cubic
643+ net.inet.tcp.functions_default=freebsd # freebsd/rack/bbr
597644
598645# socket 缓冲 (关键性能参数)
599646net.inet.tcp.sendspace = 32768 # 发送缓冲 (字节)
@@ -1114,13 +1161,21 @@ symmetric_rss = 1 # 双向连接到同一队列
11141161``` ini
11151162[freebsd.sysctl]
11161163# 高延迟网络: bbr (瓶颈带宽和往返时间)
1117- # net.inet.tcp.cc.algorithm = bbr
1164+ # hz=1000000
1165+ # net.inet.tcp.functions_default=bbr
1166+ # net.inet.tcp.hpts.minsleep=250
1167+ # net.inet.tcp.hpts.maxsleep=51200
11181168
11191169# 低延迟网络: cubic (默认,平衡)
1170+ # hz=100
1171+ # net.inet.tcp.functions_default=freebsd
11201172# net.inet.tcp.cc.algorithm = cubic
11211173
11221174# 特定场景: rack (TCP 选择性确认)
1123- # net.inet.tcp.cc.algorithm = rack
1175+ # hz=1000000
1176+ # net.inet.tcp.functions_default=rack
1177+ # net.inet.tcp.hpts.minsleep=250
1178+ # net.inet.tcp.hpts.maxsleep=51200
11241179```
11251180
11261181---
0 commit comments