Skip to content

Commit d023cdf

Browse files
committed
【manual】Review and moodify diff.md's diff, and remove diff.md.
1 parent 2563623 commit d023cdf

File tree

5 files changed

+216
-269
lines changed

5 files changed

+216
-269
lines changed

docs/03-LAYER3-FUNCTIONS.md

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151

5252
| 函数 | 用途 | 参数数 | 返回值 |
5353
|-----|------|--------|--------|
54-
| `ff_kqueue` | BSD 事件队列 | 1 | int(kq_fd) |
54+
| `ff_kqueue` | BSD 事件队列 | 0 | int(kq_fd) |
5555
| `ff_kevent` | BSD 事件等待 | 6 | 事件数/-1 |
5656
| `ff_kevent_do_each` | BSD 遍历事件 | 4 | void |
5757
| `ff_epoll_create` | Linux epoll | 1 | int(ep_fd) |
@@ -124,15 +124,20 @@ struct kevent {
124124
};
125125

126126
// 过滤器类型 (filter 值)
127-
#define EVFILT_READ 0 // 读就绪
128-
#define EVFILT_WRITE 1 // 写就绪
129-
#define EVFILT_AIO 2 // 异步 I/O
130-
#define EVFILT_TIMER 3 // 定时器
131-
#define EVFILT_SIGNAL 4 // 信号
132-
#define EVFILT_VNODE 5 // 文件变化
133-
#define EVFILT_PROC 6 // 进程事件
134-
#define EVFILT_NETDEV 7 // 网卡事件
135-
// ... 共 13 种过滤器
127+
#define EVFILT_READ -1 // 读就绪
128+
#define EVFILT_WRITE -2 // 写就绪
129+
#define EVFILT_AIO -3 // 异步 I/O
130+
#define EVFILT_VNODE -4 // 文件/目录 inode 事件
131+
#define EVFILT_PROC -5 // 进程事件
132+
#define EVFILT_SIGNAL -6 // 信号递送
133+
#define EVFILT_TIMER -7 // 定时器
134+
#define EVFILT_PROCDESC -8 // 进程描述符事件
135+
#define EVFILT_FS -9 // 文件变化
136+
#define EVFILT_LIO -10 // 异步 I/O 列表
137+
#define EVFILT_USER -11 // 用户事件
138+
#define EVFILT_SENDFILE -12 // 内核发送文件事件
139+
#define EVFILT_EMPTY -13 // 清空发送套接字缓冲区
140+
#define EVFILT_SYSCOUNT 13 // ... 共 13 种过滤器
136141

137142
// 控制标志 (flags)
138143
#define EV_ADD 0x0001 // 添加事件

docs/F-Stack_Architecture_Layer1_System_Overview.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ F-Stack 模式 (用户态网络)
8888
│ ├── ff_host_interface.c # 主机 OS 接口
8989
│ ├── ff_dpdk_kni.c # 虚拟网卡支持
9090
│ ├── ff_*.h # API 和数据结构定义
91-
│ └── Makefile (264行) # 编译系统
91+
│ └── Makefile (765行) # 编译系统
9292
9393
├── freebsd/ # FreeBSD 13.0 内核移植
9494
│ ├── sys/
@@ -748,7 +748,7 @@ int main() {
748748
**方式 2:LD_PRELOAD 拦截 (如 Nginx)**
749749
```bash
750750
# Nginx 启用 F-Stack 支持
751-
LD_PRELOAD=libfstack.so nginx
751+
LD_PRELOAD=libff_syscall.so nginx
752752

753753
# LD_PRELOAD 钩子拦截:
754754
socket() → ff_socket()

docs/F-Stack_Architecture_Layer2_Interface_Specification.md

Lines changed: 106 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -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
308309
struct 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
593639
net.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 缓冲 (关键性能参数)
599646
net.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

Comments
 (0)