|
| 1 | +# Task: Document Cilium eBPF Map API |
| 2 | + |
| 3 | +## Objective |
| 4 | + |
| 5 | +Generate comprehensive API reference documentation for Cilium's eBPF map API in the `pkg/bpf` package. The documentation should serve as a complete reference for developers working with eBPF maps in Cilium. |
| 6 | + |
| 7 | +## Scope |
| 8 | + |
| 9 | +Focus on the Go wrappers in `pkg/bpf` that provide user-space interaction with kernel eBPF maps. Document: |
| 10 | + |
| 11 | +1. **Core Map Type and Creation** |
| 12 | + - `Map` struct and its primary methods |
| 13 | + - Map creation functions (`NewMap`, `OpenMap`, `OpenOrCreate`) |
| 14 | + - Map lifecycle operations (Open, Create, Close, Recreate) |
| 15 | + |
| 16 | +2. **CRUD Operations** |
| 17 | + - Lookup, Update, Delete operations |
| 18 | + - Batch operations (BatchLookup, DeleteAll) |
| 19 | + - Per-CPU map operations |
| 20 | + - Locked operations (DeleteLocked) |
| 21 | + |
| 22 | +3. **Iteration and Dumping** |
| 23 | + - Dump methods and callbacks |
| 24 | + - BatchIterator type and usage |
| 25 | + - DumpStats for tracking iteration |
| 26 | + |
| 27 | +4. **Pinning and Persistence** |
| 28 | + - Pin/Unpin operations |
| 29 | + - BPF filesystem paths (BPFFSRoot, CiliumPath, MapPath) |
| 30 | + - Map persistence behavior |
| 31 | + |
| 32 | +5. **Key/Value Interfaces** |
| 33 | + - MapKey, MapValue, MapPerCPUValue interfaces |
| 34 | + - EndpointKey as concrete example |
| 35 | + |
| 36 | +6. **Event System** |
| 37 | + - Event types (MapUpdate, MapDelete) |
| 38 | + - DumpAndSubscribe for event streaming |
| 39 | + - Event callbacks and handles |
| 40 | + |
| 41 | +7. **Collection Loading** |
| 42 | + - LoadCollection and LoadAndAssign functions |
| 43 | + - CollectionOptions |
| 44 | + |
| 45 | +## Requirements |
| 46 | + |
| 47 | +Your documentation must include: |
| 48 | + |
| 49 | +1. **API Method Signatures**: Complete signatures with parameter types and return values |
| 50 | +2. **Behavioral Semantics**: |
| 51 | + - When maps are pinned vs unpinned |
| 52 | + - Difference between Create() and CreateUnpinned() |
| 53 | + - OpenOrCreate() behavior on existing maps |
| 54 | + - How deletion works within DumpCallback (requires DeleteLocked) |
| 55 | + - Event subscription lifecycle |
| 56 | + - Batch iterator retry behavior on ENOSPC |
| 57 | +3. **Usage Examples**: Code snippets showing: |
| 58 | + - Basic map creation and CRUD |
| 59 | + - Iteration with BatchIterator |
| 60 | + - Event subscription and cleanup |
| 61 | + - Pinning and unpinning maps |
| 62 | + - Real-world patterns from Cilium internals |
| 63 | +4. **Documentation Structure**: Organize clearly with sections for each category above |
| 64 | + |
| 65 | +## Output Format |
| 66 | + |
| 67 | +Write your documentation to `/workspace/documentation.md` in Markdown format. |
| 68 | + |
| 69 | +## Constraints |
| 70 | + |
| 71 | +- Do NOT include file paths or specific implementation locations in the documentation |
| 72 | +- Focus on API contracts and behavior, not internal implementation details |
| 73 | +- Include enough behavioral detail that users can correctly use the API without reading source code |
| 74 | +- Provide accurate examples that would compile and work correctly |
0 commit comments