Skip to content

Commit 8f30868

Browse files
committed
[Manual] Reviewers find document issues and provide prompts. [AI] Modified the document using prompts.
1 parent 9c9889c commit 8f30868

10 files changed

Lines changed: 89 additions & 45 deletions

doc/F-Stack_Development_Guide.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,17 @@ F-Stack is an open source high performant network framework based on DPDK with t
1313

1414
## Structure of F-Stack code
1515

16-
├── app -- Nginx(1.16.1)/Redis(3.2.8)/Microthread framework
16+
├── app -- Nginx(1.28.0)/Redis(6.2.6)/Microthread framework
17+
├── adapter -- Network adapters (micro_thread, syscall via LD_PRELOAD)
1718
├── config.ini
18-
├── doc
19-
├── dpdk -- Intel DPDK(16.07) directory
19+
├── doc -- Original English documentation
20+
├── docs -- Three-layer architecture knowledge base documentation
21+
├── dpdk -- Intel DPDK(23.11.5) directory
2022
├── example -- DEMO
21-
├── freebsd -- FreeBSD(11.0) Network Stack directory
23+
├── freebsd -- FreeBSD(13.0) Network Stack directory
2224
├── lib -- F-Stack lib directory
2325
├── mk
26+
├── tools -- Utility scripts (top, sysctl, ifconfig, etc.)
2427
└── start.sh
2528

2629

docs/01-LAYER1-ARCHITECTURE.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,11 @@ NIC 驱动 (igb_uio / vfio-pci)
9090
│ └── compiler.mk # 编译器配置
9191
9292
├── tools/ # 工具脚本
93-
├── doc/ # 文档
93+
├── adapter/ # 网络适配器
94+
│ ├── micro_thread/ # 微线程接口,方便有状态应用使用 F-Stack
95+
│ └── syscall/ # 通过 LD_PRELOAD 劫持 Linux syscall 为 F-Stack API
96+
├── doc/ # 原始英文文档
97+
├── docs/ # 三层架构知识库文档
9498
└── config.ini # 默认配置文件
9599
```
96100

@@ -176,7 +180,7 @@ process_packets() 函数
176180
### 4.3 发包流程 (Egress)
177181

178182
```
179-
应用 (ff_write/ff_sendto)
183+
应用 (ff_write/ff_send/ff_sendto/ff_sendmsg)
180184
181185
FreeBSD TCP/UDP 栈
182186
├─ tcp_output() / udp_output()

docs/02-LAYER2-INTERFACES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ int ff_rtioctl(int req, struct rt_addrinfo *info);
100100
// 零拷贝 mbuf 操作
101101
struct rte_mbuf *ff_zc_mbuf_get(int s);
102102
int ff_zc_mbuf_write(int s, struct rte_mbuf *m);
103-
int ff_zc_mbuf_read(int s, struct rte_mbuf **m);
103+
int ff_zc_mbuf_read(int s, struct rte_mbuf **m); // 【注】暂未实现,后续考虑支持
104104

105105
// 时间相关
106106
int ff_gettimeofday(struct timeval *tv, struct timezone *tz);

docs/03-LAYER3-FUNCTIONS.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
|-----|------|------|
8484
| `ff_zc_mbuf_get` | 获取零拷贝 mbuf | 直接访问 DMA 缓冲 |
8585
| `ff_zc_mbuf_write` | 零拷贝写入 | 跳过内存拷贝 |
86-
| `ff_zc_mbuf_read` | 零拷贝读取 | 接收原始 mbuf |
86+
| `ff_zc_mbuf_read` | 零拷贝读取 | 接收原始 mbuf**暂未实现,后续考虑支持** |
8787
| `ff_mbuf_gethdr` | 获取 mbuf | DPDK 内存池分配 |
8888
| `ff_mbuf_get` | 分配 mbuf | - |
8989
| `ff_mbuf_free` | 释放 mbuf | - |
@@ -592,8 +592,15 @@ gcc -o myapp main.c \
592592
-lpthread -lm -O2
593593

594594
# 运行示例
595-
# 指定 CPU 核心和 NIC 端口
596-
./myapp -l 0 -w 0000:01:00.0
595+
# 使用 start.sh 指定 config.ini 配置文件启动(推荐方式)
596+
bash start.sh -c config.ini -b ./myapp
597+
598+
# start.sh 会根据 config.ini 中的 lcore_mask 自动计算进程数,
599+
# 依次启动主进程 (--proc-type=primary) 和从进程 (--proc-type=secondary)。
600+
# 等效于:
601+
# ./myapp --conf config.ini --proc-type=primary --proc-id=0
602+
# ./myapp --conf config.ini --proc-type=secondary --proc-id=1
603+
# ...
597604
```
598605

599606
## 6. 线程安全性规则

docs/F-Stack_Architecture_Layer1_System_Overview.md

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,21 @@ F-Stack 模式 (用户态网络)
126126
│ ├── top/ # CPU 统计
127127
│ ├── sysctl/ # 参数管理
128128
│ ├── ifconfig/ # 网卡配置
129+
│ ├── route/ # 路由管理
130+
│ ├── netstat/ # 网络统计
131+
│ ├── arp/ # ARP 表管理
132+
│ ├── ipfw/ # 防火墙管理
133+
│ ├── knictl/ # KNI 控制
134+
│ ├── traffic/ # 流量统计
135+
│ ├── ndp/ # IPv6 邻居发现
136+
│ ├── ngctl/ # Netgraph 控制
129137
│ └── compat/ff_ipc.* # IPC 通信库
130138
131139
├── adapter/ # 网络适配器
132-
├── doc/ # 文档
140+
│ ├── micro_thread/ # 微线程接口,方便有状态应用使用 F-Stack
141+
│ └── syscall/ # 通过 LD_PRELOAD 劫持 Linux syscall 为 F-Stack API
142+
├── doc/ # 原始英文文档
143+
├── docs/ # 三层架构知识库文档
133144
├── config.ini # 默认配置文件
134145
└── start.sh # 多进程启动脚本
135146
```
@@ -309,7 +320,7 @@ FreeBSD 网络栈
309320
├─ tcp_input()/udp_input() [L4 层]
310321
└─ sorecvX() [Socket 接收缓冲]
311322
312-
应用通过 ff_read()/ff_recv() 获取数据
323+
应用通过 ff_read()/ff_recv()/ff_recvfrom()/ff_recvmsg() 获取数据
313324
```
314325

315326
**关键特性**
@@ -320,7 +331,7 @@ FreeBSD 网络栈
320331
#### **发送路径 (Egress)**
321332

322333
```
323-
应用调用 ff_write()/ff_send()/ff_sendto()
334+
应用调用 ff_write()/ff_send()/ff_sendto()/ff_sendmsg()
324335
325336
FreeBSD TCP/UDP 协议栈
326337
├─ tcp_output() [TCP 分段/排序]
@@ -769,6 +780,12 @@ LD_PRELOAD=libff_syscall.so nginx
769780
connect() → ff_connect()
770781
read() → ff_read()
771782
write() → ff_write()
783+
send() → ff_send()
784+
sendto() → ff_sendto()
785+
sendmsg() → ff_sendmsg()
786+
recv() → ff_recv()
787+
recvfrom() → ff_recvfrom()
788+
recvmsg() → ff_recvmsg()
772789
...
773790
```
774791

@@ -786,6 +803,9 @@ LD_PRELOAD=libff_syscall.so nginx
786803
| **arp** | ARP 表 | 查询 DPDK 内部状态 |
787804
| **ipfw** | 防火墙 | FF_IPFW_CTL 消息 |
788805
| **knictl** | KNI 控制 | FF_KNICTL 消息 |
806+
| **traffic** | 流量统计 | FF_TRAFFIC 消息,支持多进程汇总 |
807+
| **ndp** | IPv6 邻居发现 | ioctl 通信 (SIOCGNBRINFO_IN6 等) |
808+
| **ngctl** | Netgraph 控制 | FF_NGCTL 消息 |
789809

790810
---
791811

docs/F-Stack_Architecture_Layer2_Interface_Specification.md

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ F-Stack 导出 **80+ 个公开符号**,分为以下几大类:
4848
│ │
4949
│ 8. 零拷贝 Mbuf (3 个) │
5050
│ ff_zc_mbuf_get / ff_zc_mbuf_write │
51-
│ ff_zc_mbuf_read / ...
51+
│ ff_zc_mbuf_read (暂未实现) / ... │
5252
│ │
5353
│ 9. 多线程支持 (2 个) │
5454
│ ff_pthread_create / ff_pthread_join │
@@ -246,7 +246,7 @@ struct ff_zc_mbuf * ff_zc_mbuf_get(uint16_t len);
246246
247247
ssize_t ff_zc_mbuf_write(int fd, struct ff_zc_mbuf *zm);
248248
ssize_t ff_zc_mbuf_read(int fd, struct ff_zc_mbuf *zm);
249-
// 零拷贝 I/O
249+
// 零拷贝 I/O 【注】ff_zc_mbuf_read 暂未实现,后续考虑支持
250250
```
251251

252252
**日志接口**
@@ -490,7 +490,9 @@ F-Stack 提供 Linux 兼容的系统调用接口,但底层依赖 FreeBSD 协
490490
| 发送 | ff_send() | send() | flags: MSG_MORE 等 |
491491
| 接收 | ff_recv() | recv() | 同上 |
492492
| 发送到 | ff_sendto() | sendto() | UDP only |
493+
| 发送消息 | ff_sendmsg() | sendmsg() | 支持 msghdr 控制信息 |
493494
| 接收自 | ff_recvfrom() | recvfrom() | UDP only |
495+
| 接收消息 | ff_recvmsg() | recvmsg() | 支持 msghdr 控制信息 |
494496

495497
### 2.3 事件多路复用映射
496498

@@ -739,29 +741,25 @@ ff_init(argc, argv)
739741
#### **进程启动脚本示例**
740742

741743
```bash
742-
#!/bin/bash
743-
# start.sh - 启动多进程 F-Stack
744-
745-
CONFIG_FILE="config.ini"
746-
LCORE_MASK=0x0f # 使用核心 0-3
747-
748-
# 计算进程数 = lcore_mask 中设置的位数
749-
NUM_PROCESSES=4
750-
751-
# 启动主进程
752-
export proc_type=primary
753-
export proc_id=0
754-
./app ${CONFIG_FILE} -l ${LCORE_MASK} &
755-
sleep 5 # 等待主进程初始化完成
756-
757-
# 启动从进程
758-
for i in $(seq 1 $((NUM_PROCESSES-1))); do
759-
export proc_type=secondary
760-
export proc_id=$i
761-
./app ${CONFIG_FILE} -l ${LCORE_MASK} &
762-
done
763-
764-
wait # 等待所有进程
744+
# 使用 F-Stack 自带的 start.sh 启动(推荐方式)
745+
# start.sh 参数说明:
746+
# -c [conf] 配置文件路径 (默认 config.ini)
747+
# -b [bin] 应用程序路径 (默认 ./example/helloworld)
748+
# -o [args] 传递给应用的额外参数
749+
750+
# 示例: 使用 config.ini 启动自定义应用
751+
bash start.sh -c config.ini -b ./app
752+
753+
# start.sh 会自动完成以下工作:
754+
# 1. 读取 config.ini 中的 lcore_mask,计算需要启动的进程数
755+
# 2. 启动主进程: ./app --conf config.ini --proc-type=primary --proc-id=0
756+
# 3. 等待 5 秒后依次启动从进程:
757+
# ./app --conf config.ini --proc-type=secondary --proc-id=1
758+
# ./app --conf config.ini --proc-type=secondary --proc-id=2
759+
# ...
760+
761+
# 如需传递额外参数给应用:
762+
bash start.sh -c config.ini -b ./app -o "--extra-arg value"
765763
```
766764

767765
### 4.2 进程间通信 (IPC)
@@ -1172,7 +1170,9 @@ symmetric_rss = 1 # 双向连接到同一队列
11721170
| **arp** | ARP 表查询 | 直接读内存 | `arp -a` |
11731171
| **ipfw** | 防火墙规则 | FF_IPFW_CTL | `ipfw add ...` |
11741172
| **knictl** | 虚拟网卡控制 | FF_KNICTL | `knictl set-rate ...` |
1175-
| **traffic** | 流量统计导出 | FF_TRAFFIC | `traffic --json` |
1173+
| **traffic** | 流量统计导出 | FF_TRAFFIC | `traffic -p <proc_id> -d <secs>` |
1174+
| **ndp** | IPv6 邻居发现 | ioctl (SIOCGNBRINFO_IN6) | `ndp -C <proc_id> -a` |
1175+
| **ngctl** | Netgraph 控制 | FF_NGCTL | `ngctl -p <proc_id> list` |
11761176

11771177
### 6.2 应用集成接口
11781178

docs/F-Stack_Architecture_Layer3_Function_Index.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ ssize_t ff_zc_mbuf_write(int fd, struct ff_zc_mbuf *zm)
313313
ssize_t ff_zc_mbuf_read(int fd, struct ff_zc_mbuf *zm)
314314
// 零拷贝接收 (应用获取指向报文的指针)
315315
// 线程安全: 是
316+
// 【注】暂未实现,后续考虑支持
316317
```
317318
318319
#### **多线程支持 (2 个)**
@@ -1125,8 +1126,9 @@ python dpdk_devbind.py -b igb_uio 0000:05:00.0 # 绑定网卡
11251126
modprobe vfio_pci
11261127
python dpdk_devbind.py -b vfio-pci 0000:05:00.0
11271128

1128-
# 3. 运行应用
1129-
./app -c 0x0f -n 4 -- -c config.ini
1129+
# 3. 运行应用(使用 start.sh 指定 config.ini 配置文件启动)
1130+
bash start.sh -c config.ini -b ./app
1131+
# start.sh 会根据 config.ini 中的 lcore_mask 自动启动主/从进程
11301132
```
11311133

11321134
---

docs/F-Stack_Knowledge_Base_Summary.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ F-Stack 架构知识库
161161
162162
生态集成
163163
→ Nginx/Redis 集成方式
164-
→ 运维工具列表 (top/sysctl/route/etc)
164+
→ 运维工具列表 (top/sysctl/route/traffic/ndp/ngctl/etc)
165165
```
166166

167167
**适读人群**: 架构师、CTO、性能分析师、系统设计师
@@ -211,7 +211,7 @@ F-Stack 架构知识库
211211
→ 5 个性能优化建议
212212
213213
工具与集成
214-
8 个 IPC 运维工具
214+
11 个 IPC 运维工具
215215
→ LD_PRELOAD 集成方式
216216
→ 应用集成接口
217217
```
@@ -410,8 +410,14 @@ ff_close(fd);
410410
// I/O 操作
411411
ssize_t n = ff_read(fd, buf, sizeof(buf));
412412
ssize_t n = ff_write(fd, data, len); // 缓冲满返回 -1!
413+
ssize_t n = ff_readv(fd, iov, iovcnt); // 分散读
414+
ssize_t n = ff_writev(fd, iov, iovcnt); // 分散写
413415
ssize_t n = ff_send(fd, data, len, 0);
416+
ssize_t n = ff_sendto(fd, data, len, 0, &addr, addrlen); // UDP 发送到指定地址
417+
ssize_t n = ff_sendmsg(fd, &msg, 0); // 发送消息 (msghdr)
414418
ssize_t n = ff_recv(fd, buf, sizeof(buf), 0);
419+
ssize_t n = ff_recvfrom(fd, buf, sizeof(buf), 0, &addr, &addrlen); // UDP 接收
420+
ssize_t n = ff_recvmsg(fd, &msg, 0); // 接收消息 (msghdr)
415421

416422
// 事件多路复用
417423
int kq = ff_kqueue();

docs/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ ff_init / ff_run / ff_stop_run
114114

115115
// Socket (25+)
116116
ff_socket / ff_bind / ff_listen / ff_accept / ff_connect / ff_close
117-
ff_read / ff_write / ff_send / ff_recv / ...
117+
ff_read / ff_write / ff_readv / ff_writev
118+
ff_send / ff_sendto / ff_sendmsg
119+
ff_recv / ff_recvfrom / ff_recvmsg / ...
118120

119121
// 事件多路复用 (5)
120122
ff_kqueue / ff_kevent / ff_select / ff_poll

docs/SUMMARY.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ F-Stack v1.25 完整架构知识库 - 生成总结
2828

2929
内容:
3030
- F-Stack 三大核心创新: Kernel Bypass / FreeBSD 移植 / 多核并行
31-
- 顶层目录结构 (lib/, freebsd/, dpdk/, example/ 等)
31+
- 顶层目录结构 (lib/, freebsd/, dpdk/, adapter/, example/, tools/, doc/, docs/ 等)
3232
- 模块职责边界 (8 个核心模块分析)
3333
- FreeBSD TCP/IP 栈完整移植方式
3434
- DPDK 集成与 NIC 驱动层详解

0 commit comments

Comments
 (0)