Skip to content

Commit

Permalink
add doc
Browse files Browse the repository at this point in the history
  • Loading branch information
yunwei37 committed Nov 8, 2023
1 parent 04df6b5 commit c1d7c70
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions plugins/wasm_bpf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
This plugin added six host functions that give you Wasm application access to eBPF.

Six functions are listed here. And all of them are in the module `wasm_bpf`, if you loaded this plugin.

```c
/// lookup a bpf map fd by name.
i32 wasm_bpf_map_fd_by_name(u64 obj, u32 name);
Expand Down Expand Up @@ -30,7 +31,11 @@ i32 wasm_bpf_map_operate(u64 fd, i32 cmd, u32 key, u32 value,
### Install dependencies
See the https://wasmedge.org/book/en/contribute/build_from_src/linux.html for how to build `WasmEdge` from source.
See the <https://wasmedge.org/book/en/contribute/build_from_src/linux.html> for how to build `WasmEdge` from source.
```sh
apt update && apt install pkg-config libelf1 libelf-dev zlib1g-dev
```

#### libbpf

Expand All @@ -44,9 +49,9 @@ Run the following commands at the root of the `WasmEdge` project:

- Note: It's important to set `WASMEDGE_PLUGIN_WASM_BPF` to `TRUE` in the command line. This toggle controls the build of `wasm_bpf` plugin.

```
```sh
cmake -DWASMEDGE_PLUGIN_WASM_BPF:BOOL=TRUE -B ./build -G "Unix Makefiles"
cmake --build ./build
cmake --build ./build --config Release --target install
```

## How to use this plugin
Expand Down Expand Up @@ -106,4 +111,4 @@ Set `WASMEDGE_PLUGIN_PATH=./build/plugins/wasm_bpf/` and run wasmedge:
[289159] cpuUsage.sh -> cat /proc/289148/stat
[289160] cpuUsage.sh -> sleep 1
^C
```
```

0 comments on commit c1d7c70

Please sign in to comment.