Let's take this opportunity to have a look at the NIC's side of BPF offload.
Note I don't know much about microcode and MicroC, but hopefully, if I make a mistake, someone from @Netronome can correct me.https://twitter.com/qeole/status/1162277443882766336 …
-
-
The MicroC function update_bpf_prog() writes the BPF program to the NIC's code store. Most of the code is there to ensure the write is atomic (since there are multiple threads per Flow Processing Core). https://github.com/Netronome/nic-firmware/blob/092d992f10fc8b4447baf352812f733de516b8b9/firmware/lib/nic_basic/_c/nic_internal.c#L491 …pic.twitter.com/GJpX9Earar
Prikaži ovu nit -
That's it! Loading BPF programs is pretty simple since most of the heavy lifting is performed in the kernel, thanks to the Netronome-specific JIT compiler: https://github.com/torvalds/linux/blob/a2d79c7174aeb43b13020dd53d85a7aefdd9f3e5/drivers/net/ethernet/netronome/nfp/bpf/jit.c …
Prikaži ovu nit -
We haven't seen how the BPF program is actually executed though. That happens in the microcode macro ebpf_call() in the NIC's datapath. It computes the jump offset, prepares the BPF stack, and jumps to the loaded program. https://github.com/Netronome/nic-firmware/blob/092d992f10fc8b4447baf352812f733de516b8b9/firmware/apps/nic/ebpf.uc#L173 …pic.twitter.com/kMpBTSD4xH
Prikaži ovu nit -
Looks like the ebpf_reentry() macro above ebpf_call() handles the return from BPF programs. It updates the statistics and applies the action (drop, pass to continue, or transmit on wire). https://github.com/Netronome/nic-firmware/blob/092d992f10fc8b4447baf352812f733de516b8b9/firmware/apps/nic/ebpf.uc#L137 …
Prikaži ovu nit -
One missing piece of the BPF offload are the helpers. Most of them are inlined to microcode by the JIT compiler, except... the map helpers! The htab_map_lookup_subr_func() macro, for example, implements the hashmap lookups. https://github.com/Netronome/nic-firmware/blob/092d992f10fc8b4447baf352812f733de516b8b9/firmware/apps/nic/maps/hashmap.uc#L917 …
Prikaži ovu nit -
htab_map_lookup_subr_func() defines a few return cases, but most of the code is in hashmap_ops(), a single macro for lots of different hashmap operations. https://github.com/Netronome/nic-firmware/blob/092d992f10fc8b4447baf352812f733de516b8b9/firmware/apps/nic/maps/hashmap.uc#L726 …
Prikaži ovu nit -
hashmap_ops() first looks up the map (with hashmap_get_fd()) and the entry matching the key, then applies the hashmap operation. For example, in case of a lookup, it reads the hashmap entry in out_ent_addr with macro __hashmap_read_field(). https://github.com/Netronome/nic-firmware/blob/092d992f10fc8b4447baf352812f733de516b8b9/firmware/apps/nic/maps/hashmap.uc#L777-L784 …pic.twitter.com/stZ5Kn7TeO
Prikaži ovu nit -
That's all I have for today (and until I get my hands on a microcode manual)!
Prikaži ovu nit
Kraj razgovora
Novi razgovor -
Čini se da učitavanje traje već neko vrijeme.
Twitter je možda preopterećen ili ima kratkotrajnih poteškoća u radu. Pokušajte ponovno ili potražite dodatne informacije u odjeljku Status Twittera.