From 6a75793405460ad430417cde57600ee12eab0c13 Mon Sep 17 00:00:00 2001 From: Daniel Noland Date: Sat, 30 Nov 2024 18:35:18 -0700 Subject: [PATCH] hacking --- .cargo/config.toml | 6 + .github/workflows/dev.yml | 1 - Cargo.lock | 292 +++++------- Cargo.toml | 25 +- design-docs/src/mdbook/src/SUMMARY.md | 51 +-- .../mdbook/src/dataplane/design-session.md | 10 +- .../mdbook/src/dataplane/development-plan.md | 23 +- .../src/dataplane/tasks/pick-a-datastore.md | 13 +- ...configuration-persistence-investigation.md | 2 +- .../dataplane/tasks2/control-plane-dev-env.md | 9 +- .../src/dataplane/tasks2/core-pinning.md | 2 +- .../tasks2/create-control-plane-image.md | 7 +- .../dataplane-control-plane-transport.md | 2 +- .../mdbook/src/dataplane/tasks2/frr-plugin.md | 5 - .../src/dataplane/tasks2/vpc-rate-limiting.md | 6 +- .../mdbook/src/dataplane/tasks2/vxlan-tunnels | 1 - .../src/dataplane/tasks2/zebra-plugin.md | 24 + design-docs/src/mdbook/src/links.md | 4 + dpdk-sys/Cargo.toml | 4 + dpdk-sys/build.rs | 3 +- dpdk/Cargo.toml | 11 +- dpdk/src/dev.rs | 423 ++++++++++-------- dpdk/src/mem.rs | 2 +- dpdk/src/queue/rx.rs | 68 ++- dpdk/src/queue/tx.rs | 63 ++- dpdk/src/socket.rs | 10 +- errno/Cargo.toml | 1 + errno/src/lib.rs | 380 +--------------- justfile | 3 +- net/Cargo.toml | 1 + net/src/lib.rs | 22 +- scratch/Cargo.toml | 15 +- scratch/src/main.rs | 13 +- scripts/dpdk-sys.env | 2 +- 34 files changed, 578 insertions(+), 926 deletions(-) delete mode 100644 design-docs/src/mdbook/src/dataplane/tasks2/frr-plugin.md delete mode 100644 design-docs/src/mdbook/src/dataplane/tasks2/vxlan-tunnels create mode 100644 design-docs/src/mdbook/src/dataplane/tasks2/zebra-plugin.md diff --git a/.cargo/config.toml b/.cargo/config.toml index e44b40a0..50b226a3 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -9,3 +9,9 @@ target = "x86_64-unknown-linux-gnu" [alias] just = ["just", "cargo"] sterile = ["just", "sterile", "cargo"] + +[target.x86_64-unknown-linux-gnu] +runner = "/usr/bin/sudo -E" + +[target.x86_64-unknown-linux-musl] +runner = "sudo -E" diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index f942a46c..da51b765 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -186,7 +186,6 @@ jobs: with: limit-access-to-actor: true - summary: name: "Dev Test and Build" if: ${{ always() }} diff --git a/Cargo.lock b/Cargo.lock index 9cf99b35..d8156ffd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "addr2line" @@ -81,14 +81,12 @@ dependencies = [ "cexpr", "clang-sys", "itertools 0.13.0", - "log", - "prettyplease", "proc-macro2", "quote", "regex", "rustc-hash", "shlex", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -99,9 +97,9 @@ checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "bolero" -version = "0.10.1" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "212e8dca6d4001cc6cac941d6932ddaa8cd27f57e5e44a9da19c913eb6a43b33" +checksum = "3c8110b2b4255b16c25af45c2351fa26a391f899239703522995600b5eabb1f8" dependencies = [ "bolero-afl", "bolero-engine", @@ -115,9 +113,9 @@ dependencies = [ [[package]] name = "bolero-afl" -version = "0.10.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1b34f05de1527425bb05287da09ff1ff1612538648824db49e16d9693b24065" +checksum = "7152db647a5df11b8d9bc6f17916b6fbf7e8303632d1855e67939439ba26a798" dependencies = [ "bolero-engine", "cc", @@ -125,9 +123,9 @@ dependencies = [ [[package]] name = "bolero-engine" -version = "0.10.2" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6206263ebdd42e093c1229dab3957f61c9fd68d73c00f238ae25a378778b6bd3" +checksum = "cfa8aec1ff59a515462a473c56a428e8d9d7ea15df49151820dfbd63ef364b4a" dependencies = [ "anyhow", "backtrace", @@ -135,24 +133,24 @@ dependencies = [ "lazy_static", "pretty-hex", "rand", + "rand_xoshiro", ] [[package]] name = "bolero-generator" -version = "0.10.2" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac749fb4f2e14734e835a9352c0d1eb2ab62a025d4c56a823fa3f391e015741a" +checksum = "6e85be107ff475ca58de17db3f6f5d6e53a6f429f54e8b25e34d235ed2cf47e6" dependencies = [ "bolero-generator-derive", - "either", "rand_core", ] [[package]] name = "bolero-generator-derive" -version = "0.10.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53397bfda19ccb48527faa14025048fc4bb76f090ccdeef1e5a355bfe4a94467" +checksum = "c613c51da2e38c264682ab4e64db57f17fbcdcf83045779c5a0c20faa2fb9ec0" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -162,27 +160,27 @@ dependencies = [ [[package]] name = "bolero-honggfuzz" -version = "0.10.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf78581db1a7263620a8767e645b93ad287c70122ae76f5bd67040c7f06ff8e3" +checksum = "afeb0b293298dcbc70e3c0980a6588217180b83f6ef96e7684e1d3ea8a2cf522" dependencies = [ "bolero-engine", ] [[package]] name = "bolero-kani" -version = "0.10.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e55cec272a617f5ae4ce670db035108eb97c10cd4f67de851a3c8d3f18f19cb" +checksum = "cb0bb91187b113a3daf85ad86a0ac0db6ef7856b2bf15f4ac90fb8c60a641718" dependencies = [ "bolero-engine", ] [[package]] name = "bolero-libfuzzer" -version = "0.10.0" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb42f66ee3ec89b9c411994de59d4710ced19df96fea2059feea1c2d73904c5b" +checksum = "67e73a17841837494a19e574289cc9e7c185de51fd4287a0e15e440bae1ca366" dependencies = [ "bolero-engine", "cc", @@ -208,9 +206,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.1.37" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40545c26d092346d8a8dab71ee48e7685a7a9cba76e634790c215b41a4a7b4cf" +checksum = "f34d93e62b03caf570cccc334cbc6c2fceca82f39211051345108adcba3eebdc" dependencies = [ "shlex", ] @@ -270,18 +268,18 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.20" +version = "4.5.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8" +checksum = "fb3b4b9e5a7c7514dfa52869339ee98b3156b0bfb4e8a77c4ff4babb64b1604f" dependencies = [ "clap_builder", ] [[package]] name = "clap_builder" -version = "4.5.20" +version = "4.5.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54" +checksum = "b17a95aa67cc7b5ebd32aa5370189aa0d79069ef1c64ce893bd30fb24bff20ec" dependencies = [ "anstyle", "clap_lex", @@ -289,9 +287,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" +checksum = "afb84c814227b90d6895e01398aee0d8033c00e7466aca416fb6a8e0eb19d8a7" [[package]] name = "criterion" @@ -373,13 +371,13 @@ dependencies = [ name = "dpdk" version = "0.1.0" dependencies = [ + "bitflags", "dpdk-sys", "dpdk-sysroot-helper", "errno", - "etherparse", "net", "serde", - "thiserror-no-std", + "thiserror", "tracing", ] @@ -412,7 +410,7 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" name = "errno" version = "0.1.0" dependencies = [ - "thiserror-no-std", + "thiserror", ] [[package]] @@ -459,9 +457,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.15.1" +version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" [[package]] name = "hermit-abi" @@ -471,9 +469,9 @@ checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" [[package]] name = "indexmap" -version = "2.6.0" +version = "2.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" +checksum = "62f822373a4fe84d4bb149bf54e584a7f4abec90e072ed49cda0edea5b95471f" dependencies = [ "equivalent", "hashbrown", @@ -510,16 +508,17 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.11" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" +checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" [[package]] name = "js-sys" -version = "0.3.72" +version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" +checksum = "a865e038f7f6ed956f788f0d7d60c541fff74c7bd74272c5d4cf15c63743e705" dependencies = [ + "once_cell", "wasm-bindgen", ] @@ -531,15 +530,15 @@ checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" -version = "0.2.162" +version = "0.2.167" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef01506398" +checksum = "09d6582e104315a817dff97f75133544b2e094ee22447d2acf4a74e189ba06fc" [[package]] name = "libloading" -version = "0.8.5" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" +checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34" dependencies = [ "cfg-if", "windows-targets", @@ -581,7 +580,7 @@ dependencies = [ "etherparse", "rand", "serde", - "thiserror-no-std", + "thiserror", "tracing", ] @@ -595,16 +594,6 @@ dependencies = [ "minimal-lexical", ] -[[package]] -name = "nu-ansi-term" -version = "0.46.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" -dependencies = [ - "overload", - "winapi", -] - [[package]] name = "num-traits" version = "0.2.19" @@ -635,12 +624,6 @@ version = "11.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b410bbe7e14ab526a0e86877eb47c6996a2bd7746f027ba551028c925390e4e9" -[[package]] -name = "overload" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" - [[package]] name = "phf" version = "0.11.2" @@ -671,7 +654,7 @@ dependencies = [ "phf_shared", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] @@ -728,35 +711,25 @@ dependencies = [ [[package]] name = "pretty-hex" -version = "0.3.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6fa0831dd7cc608c38a5e323422a0077678fa5744aa2be4ad91c4ece8eec8d5" - -[[package]] -name = "prettyplease" -version = "0.2.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64d1ec885c64d0457d564db4ec299b2dae3f9c02808b8ad9c3a089c591b18033" -dependencies = [ - "proc-macro2", - "syn 2.0.87", -] +checksum = "bbc83ee4a840062f368f9096d80077a9841ec117e17e7f700df81958f1451254" [[package]] name = "proc-macro-crate" -version = "1.3.1" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" +checksum = "b00f26d3400549137f92511a46ac1cd8ce37cb5598a96d382381458b992a5d24" dependencies = [ - "once_cell", + "toml_datetime", "toml_edit", ] [[package]] name = "proc-macro2" -version = "1.0.89" +version = "1.0.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" +checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0" dependencies = [ "unicode-ident", ] @@ -800,6 +773,15 @@ dependencies = [ "getrandom", ] +[[package]] +name = "rand_xoshiro" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f97cdb2a36ed4183de61b2f824cc45c9f1037f28afe0a322e9fff4c108b5aaa" +dependencies = [ + "rand_core", +] + [[package]] name = "rayon" version = "1.10.0" @@ -834,9 +816,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" dependencies = [ "aho-corasick", "memchr", @@ -884,36 +866,35 @@ dependencies = [ "dpdk-sys", "dpdk-sysroot-helper", "rand", - "thiserror-no-std", "tracing", "tracing-subscriber", ] [[package]] name = "serde" -version = "1.0.214" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f55c3193aca71c12ad7890f1785d2b73e1b9f63a0bbc353c08ef26fe03fc56b5" +checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.214" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766" +checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] name = "serde_json" -version = "1.0.132" +version = "1.0.133" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" +checksum = "c7fceb2473b9166b2294ef05efcb65a3db80803f0b03ef86a5fc88a2b85ee377" dependencies = [ "itoa", "memchr", @@ -942,12 +923,6 @@ version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" -[[package]] -name = "smallvec" -version = "1.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" - [[package]] name = "syn" version = "1.0.109" @@ -961,9 +936,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.87" +version = "2.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" +checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31" dependencies = [ "proc-macro2", "quote", @@ -971,23 +946,23 @@ dependencies = [ ] [[package]] -name = "thiserror-impl-no-std" -version = "2.0.2" +name = "thiserror" +version = "2.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58e6318948b519ba6dc2b442a6d0b904ebfb8d411a3ad3e07843615a72249758" +checksum = "c006c85c7651b3cf2ada4584faa36773bd07bac24acfb39f3c431b36d7e667aa" dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", + "thiserror-impl", ] [[package]] -name = "thiserror-no-std" -version = "2.0.2" +name = "thiserror-impl" +version = "2.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3ad459d94dd517257cc96add8a43190ee620011bb6e6cdc82dafd97dfafafea" +checksum = "f077553d607adc1caf65430528a576c757a71ed73944b66ebb58ef2bbd243568" dependencies = [ - "thiserror-impl-no-std", + "proc-macro2", + "quote", + "syn 2.0.90", ] [[package]] @@ -1012,15 +987,15 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.8" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" +checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" [[package]] name = "toml_edit" -version = "0.19.15" +version = "0.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" +checksum = "396e4d48bbb2b7554c944bde63101b5ae446cff6ec4a24227428f15eb72ef338" dependencies = [ "indexmap", "toml_datetime", @@ -1029,9 +1004,9 @@ dependencies = [ [[package]] name = "tracing" -version = "0.1.40" +version = "0.1.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" dependencies = [ "pin-project-lite", "tracing-attributes", @@ -1040,61 +1015,40 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.27" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" +checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] [[package]] name = "tracing-core" -version = "0.1.32" +version = "0.1.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" dependencies = [ "once_cell", - "valuable", -] - -[[package]] -name = "tracing-log" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" -dependencies = [ - "log", - "once_cell", - "tracing-core", ] [[package]] name = "tracing-subscriber" -version = "0.3.18" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" +checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008" dependencies = [ - "nu-ansi-term", "sharded-slab", - "smallvec", "thread_local", "tracing-core", - "tracing-log", ] [[package]] name = "unicode-ident" -version = "1.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" - -[[package]] -name = "valuable" -version = "0.1.0" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" +checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83" [[package]] name = "walkdir" @@ -1114,9 +1068,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.95" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" +checksum = "d15e63b4482863c109d70a7b8706c1e364eb6ea449b201a76c5b89cedcec2d5c" dependencies = [ "cfg-if", "once_cell", @@ -1125,24 +1079,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.95" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" +checksum = "8d36ef12e3aaca16ddd3f67922bc63e48e953f126de60bd33ccc0101ef9998cd" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.95" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" +checksum = "705440e08b42d3e4b36de7d66c944be628d579796b8090bfa3471478a2260051" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1150,49 +1104,33 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.95" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" +checksum = "98c9ae5a76e46f4deecd0f0255cc223cfa18dc9b261213b8aa0c7b36f61b3f1d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.95" +version = "0.2.97" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" +checksum = "6ee99da9c5ba11bd675621338ef6fa52296b76b83305e9b6e5c77d4c286d6d49" [[package]] name = "web-sys" -version = "0.3.72" +version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6488b90108c040df0fe62fa815cbdee25124641df01814dd7282749234c6112" +checksum = "a98bc3c33f0fe7e59ad7cd041b89034fa82a7c2d4365ca538dda6cdaf513863c" dependencies = [ "js-sys", "wasm-bindgen", ] -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - [[package]] name = "winapi-util" version = "0.1.9" @@ -1202,12 +1140,6 @@ dependencies = [ "windows-sys 0.59.0", ] -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - [[package]] name = "windows-sys" version = "0.52.0" @@ -1317,5 +1249,5 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.87", + "syn 2.0.90", ] diff --git a/Cargo.toml b/Cargo.toml index 85172e2d..6e759884 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,19 +11,22 @@ resolver = "2" [workspace.dependencies] -bindgen = { version = "0.70.1" } -bolero = { version = "=0.10.1" } # TODO: update as soon as resolution bug with 0.11 or better is fixed -cc = { version = "1.1.37" } +# internal deps +dpdk-sys = { path = "./dpdk-sys" } +dpdk = { path = "./dpdk" } +dpdk-sysroot-helper = { path = "./dpdk-sysroot-helper" } +errno = { path = "./errno" } +net = { path = "./net" } + +# external deps +bindgen = { version = "0.70.1", default-features = false } +bitflags = { version = "2.6.0", default-features = false } +bolero = { version = "0.12.0", default-features = false, features = ["alloc"] } criterion = { version = "0.5.1", default-features = true } -doxygen-rs = { version = "0.4.0" } +doxygen-rs = { version = "0.4.0", default-features = false } etherparse = { version = "0.16.0", default-features = false, features = [] } -libc = { version = "0.2.161" } rand = { version = "0.8.5", default-features = false, features = [] } -rstest = { version = "0.23.0", default-features = false, features = [] } serde = { version = "1.0.213", default-features = false, features = ["derive", "alloc", "rc"] } -syscalls = { version = "0.6.18" } -thiserror = { version = "2.0.0", package = "thiserror-no-std" } # replace with regular thiserror when https://github.com/dtolnay/thiserror/pull/304 lands +thiserror = { version = "2.0.2", default-features = false } tracing = { version = "0.1.40", default-features = false, features = ["attributes"] } -tracing-subscriber = { version = "0.3.18" } -tracing-test = { version = "0.2.5" } - +tracing-subscriber = { version = "0.3.18", default-features = false } diff --git a/design-docs/src/mdbook/src/SUMMARY.md b/design-docs/src/mdbook/src/SUMMARY.md index 753aaa62..76e130ac 100644 --- a/design-docs/src/mdbook/src/SUMMARY.md +++ b/design-docs/src/mdbook/src/SUMMARY.md @@ -17,40 +17,37 @@ - [Design session](./dataplane/design-session.md) - [Development Plan](./dataplane/development-plan.md) + - [Configuration Persistence Investigation](./dataplane/tasks2/configuration-persistence-investigation.md) + - [Configuration database schema](./dataplane/tasks2/config-db-schema.md) - [Control plane dev-env](./dataplane/tasks2/control-plane-dev-env.md) + - [Core pinning](./dataplane/tasks2/core-pinning.md) - [Create control plane image](./dataplane/tasks2/create-control-plane-image.md) - - [FRR Plugin](./dataplane/tasks2/frr-plugin.md) - - [Dataplane / Control plane transport](./dataplane/tasks2/dataplane-control-plane-transport.md) - - [Dataplane / Control plane protocol](./dataplane/tasks2/dataplane-control-plane-protocol.md) - - [Dataplane / Control plane reconcile](./dataplane/tasks2/dataplane-control-plane-reconcile.md) + - [Dataplane / Control plane protocol](./dataplane/tasks2/dataplane-control-plane-protocol.md) + - [Dataplane / Control plane transport](./dataplane/tasks2/dataplane-control-plane-transport.md) + - [Dataplane worker lifecycle](./dataplane/tasks2/dataplane-worker-lifecycle.md) + - [Fault tolerance (implementation)](./dataplane/tasks2/fault-tolerance-implementation.md) + - [Fault tolerance (validation)](./dataplane/tasks2/fault-tolerance-validation.md) - [Gateway test env](./dataplane/tasks2/gateway-test-env.md) - [Identify local traffic](./dataplane/tasks2/identify-local-traffic.md) - - [Configuration Persistence Investigation](./dataplane/tasks2/configuration-persistence-investigation.md) - - [Route manager](./dataplane/tasks2/route-manager.md) - - [Dataplane worker lifecycle](./dataplane/tasks2/dataplane-worker-lifecycle.md) - - [Telemetry (investigation)](./dataplane/tasks2/telemetry-investigation.md) - - [Telemetry (basic)](./dataplane/tasks2/telemetry-basic.md) - - [Telemetry (integration)](./dataplane/tasks2/telemetry-integration.md) - - [Configuration database schema](./dataplane/tasks2/config-db-schema.md) - - [Management plane - dataplane interaction](./dataplane/tasks2/management-plane-dataplane-interaction.md) - - [VXLAN tunnels](./dataplane/tasks2/vxlan-tunnels.md) - - - [Underlay routing](./dataplane/tasks2/underlay-routing.md) - - [Management plane - dataplane interaction](./dataplane/tasks2/management-plane-dataplane-interaction.md) - [Management plane - control plane interaction](./dataplane/tasks2/management-plane-control-plane-interaction.md) - - [VPC routing](./dataplane/tasks2/vpc-routing.md) - - [Rate limiting investigation](./dataplane/tasks2/rate-limiting-investigation.md) - - [VPC rate-limiting](./dataplane/tasks2/vpc-rate-limiting.md) + - [Management plane - dataplane interaction](./dataplane/tasks2/management-plane-dataplane-interaction.md) - [NAT44](./dataplane/tasks2/NAT44.md) - - [NAT66](./dataplane/tasks2/NAT66.md) - [NAT64 (investigation)](./dataplane/tasks2/NAT64-investigation.md) - [NAT64](./dataplane/tasks2/NAT64.md) + - [NAT66](./dataplane/tasks2/NAT66.md) + - [One control plane daemon per container](./dataplane/tasks2/one-control-plane-daemon-per-container.md) + - [Performance measurement](./dataplane/tasks2/performance-measurement.md) + - [Programmatic Control of FRR](./dataplane/tasks2/programmatic-control-of-frr.md) + - [Public internet access](./dataplane/tasks2/public-internet-access.md) + - [Rate limiting investigation](./dataplane/tasks2/rate-limiting-investigation.md) + - [Route manager](./dataplane/tasks2/route-manager.md) - [State sync (design)](./dataplane/tasks2/state-sync-design.md) - [State sync (implementation)](./dataplane/tasks2/state-sync.md) - - [Public internet access](./dataplane/tasks2/public-internet-access.md) - - [Fault tolerance (implementation)](./dataplane/tasks2/fault-tolerance-implementation.md) - - [Fault tolerance (validation)](./dataplane/tasks2/fault-tolerance-validation.md) - - [Performance measurement](./dataplane/tasks2/performance-measurement.md) - - [Core pinning](./dataplane/tasks2/core-pinning.md) - - [One control plane daemon per container](./dataplane/tasks2/one-control-plane-daemon-per-container.md) - - [Programattic Control of FRR](./dataplane/tasks2/programmatic-control-of-frr.md) + - [Telemetry (basic)](./dataplane/tasks2/telemetry-basic.md) + - [Telemetry (integration)](./dataplane/tasks2/telemetry-integration.md) + - [Telemetry (investigation)](./dataplane/tasks2/telemetry-investigation.md) + - [Underlay routing](./dataplane/tasks2/underlay-routing.md) + - [VPC rate-limiting](./dataplane/tasks2/vpc-rate-limiting.md) + - [VPC routing](./dataplane/tasks2/vpc-routing.md) + - [VXLAN tunnels](./dataplane/tasks2/vxlan-tunnels.md) + - [Zebra Plugin](./dataplane/tasks2/zebra-plugin.md) diff --git a/design-docs/src/mdbook/src/dataplane/design-session.md b/design-docs/src/mdbook/src/dataplane/design-session.md index e055010f..57fa09f0 100644 --- a/design-docs/src/mdbook/src/dataplane/design-session.md +++ b/design-docs/src/mdbook/src/dataplane/design-session.md @@ -149,7 +149,7 @@ skinparam linetype ortho "frr_agent": { "text": "FRR agent", "url": "#frr-agent" }, "zebra": { "text": "zebra", "url": "https://docs.frrouting.org/en/latest/zebra.html" }, "routing_daemons": { "text": "routing daemons", "url": "#routing-daemons" }, - "hh_plugin": { "text": "Hedgehog\\nplugin", "url": "#hedgehog-plugin" }, + "zebra_plugin": { "text": "Zebra\\nplugin", "url": "#zebra-plugin" }, "kernel": { "text": "kernel", "url": "#kernel" }, "interface_manager": { "text": "interface manager", "url": "#interface-manager" }, "routing_manager": { "text": "routing manager", "url": "#routing-manager" }, @@ -186,7 +186,7 @@ $r(kernel) $r(control_plane) { $r(routing_daemons) $r(zebra) { - $r(hh_plugin) + $r(zebra_plugin) } $r(frr_agent) } @@ -223,7 +223,7 @@ dataplane_model <--> nat_manager dataplane_model <--> routing_manager management_plane_interface -- dataplane_model nat_manager <--> dataplane_workers -hh_plugin --- control_plane_interface : [[ https://en.wikipedia.org/wiki/Unix_domain_socket unix socket ]] +zebra_plugin --- control_plane_interface : [[ https://en.wikipedia.org/wiki/Unix_domain_socket unix socket ]] routing_daemons <-> zebra routing_manager <--> dataplane_workers state_sync <-> sister_state_sync : [[ https://en.wikipedia.org/wiki/Remote_direct_memory_access rdma]] @@ -284,11 +284,11 @@ Be afraid. Make Fredi fill in this section. But also be afraid.
-### Hedgehog Plugin +### Zebra Plugin This is a planned [zebra] plugin in the same spirit as [`fpm`](https://docs.frrouting.org/projects/dev-guide/en/latest/fpm.html#id1) or [`dataplane_fpm_nl`](https://docs.frrouting.org/projects/dev-guide/en/latest/fpm.html#dplane-fpm-nl). -The core idea is to have a plugin that can be dynamically loaded into `zebra` and will listen to the `zebra` event stream for updates. +The core idea is to have a plugin that can be dynamically loaded into [zebra] and will listen to the [zebra event stream](https://github.com/FRRouting/frr/blob/ee5a3456d34a756c70ad8856ab7be7bed75ee31c/zebra/zebra_dplane.h#L114-L217) for updates. The plugin will then take those updates and push them into the dataplane agent, allowing the dataplane to react to route updates.
diff --git a/design-docs/src/mdbook/src/dataplane/development-plan.md b/design-docs/src/mdbook/src/dataplane/development-plan.md index e6c36d01..d43ec74e 100644 --- a/design-docs/src/mdbook/src/dataplane/development-plan.md +++ b/design-docs/src/mdbook/src/dataplane/development-plan.md @@ -28,14 +28,13 @@ digraph g { cp_api_control_investigation [label=<programmatic control of frr
(investigation)
>, $urgent, href="$ptr/programmatic-control-of-frr.html", fontcolor=blue] cp_dev_env [label="control plane\ndev env", href="$ptr/control-plane-dev-env.html", fontcolor=blue] cp_image_creation [ label="Create control plane container image", href="$ptr/create-control-plane-image.html", fontcolor=blue] - dp_cp_reconciliation [ label="dp/cp reconcile", href="$ptr/dataplane-control-plane-reconcile.html", fontcolor=blue ] dp_dev_env [label="dataplane dev env", $completed, href="../../build/index.html", fontcolor=blue] dp_dp_state_sync [label="state sync\n(implementation)", $difficult, href="$ptr/state-sync.html", fontcolor=blue] dp_dp_state_sync_design [label="state sync\n(design)", $urgent, href="$ptr/state-sync-design.html", fontcolor=blue] dp_image_creation [label="dataplane image build", $completed] fault_tolerance [label="fault tolerance (implementation)", href="$ptr/fault-tolerance-implementation.html", fontcolor=blue] fault_tolerance_proof [label="fault tolerance (validation)", $difficult, href="$ptr/fault-tolerance-validation.html", fontcolor=blue] - frr_plugin_basic [ label="frr plugin\n(basic)", href="$ptr/frr-plugin.html", fontcolor=blue ] + zebra_plugin_basic [ label="zebra plugin\n(basic)", href="$ptr/zebra-plugin.html", fontcolor=blue ] frr_programmatic_control [label=<programmatic
control of frr
>, $difficult, href="$ptr/programmatic-control-of-frr.html", fontcolor=blue] gw_test_env [label="gateway test env", href="$ptr/gateway-test-env.html", fontcolor=blue] investigate_config_persist [ label=<configuration
persistence
(investigation)
>, $urgent, href="$ptr/configuration-persistence-investigation.html", fontcolor=blue ] @@ -44,8 +43,8 @@ digraph g { mp_dp_interaction [ label="management plane \ndataplane interaction", href="$ptr/management-plane-dataplane-interaction.html", fontcolor=blue] nat64_investigation [label=<NAT64 investigation>, $urgent, href="$ptr/NAT64-investigation.html", fontcolor=blue] performance_measurement [ label="measure performance", href="$ptr/performance-measurement.html", fontcolor=blue] - plugin_dp_proto [ label="plugin/dp protocol", $started, href="$ptr/dataplane-control-plane-protocol.html", fontcolor=blue] - plugin_dp_transport [ label="plugin/dp transport", $completed, href="$ptr/dataplane-control-plane-transport.html", fontcolor=blue] + plugin_dp_proto [ label="plugin/dataplane protocol", $started, href="$ptr/dataplane-control-plane-protocol.html", fontcolor=blue] + plugin_dp_transport [ label="plugin/dataplane transport", $completed, href="$ptr/dataplane-control-plane-transport.html", fontcolor=blue] public_internet_access [label="public internet access", href="$ptr/public-internet-access.html", fontcolor=blue] rate_limiting_investigation [label="rate limiting investigation", $completed] routing_manager [label="routing manager", href="$ptr/route-manager.html", fontcolor=blue] @@ -92,17 +91,16 @@ digraph g { cp_dev_env -> gw_test_env cp_image_creation -> cp_dev_env cp_image_creation -> separate_cp_containers - dp_cp_reconciliation -> frr_plugin_basic dp_dev_env -> gw_test_env dp_image_creation -> dp_dev_env - gw_test_env -> frr_plugin_basic - frr_plugin_basic -> routing_manager + gw_test_env -> zebra_plugin_basic + zebra_plugin_basic -> routing_manager config_db_schema -> mp_cp_interaction config_db_schema -> mp_dp_interaction - local_traffic_ident -> frr_plugin_basic + local_traffic_ident -> zebra_plugin_basic mp_dp_interaction -> vpc_routing - plugin_dp_proto -> dp_cp_reconciliation - plugin_dp_transport -> dp_cp_reconciliation + plugin_dp_proto -> zebra_plugin_basic + plugin_dp_transport -> zebra_plugin_basic routing_manager -> underlay_routing config_db_schema -> underlay_routing vpc_routing -> vpc_nat44 @@ -128,12 +126,13 @@ digraph g { } @enddot ``` +
> Graph of the engineering development plan. > Each node on the graph represents a task or required function. > No task can be _completed_ without all the other tasks which point to it. -> +> > * Tasks shown in orange are points of higher uncertainty and risk. > * Tasks shown in pink are points of expected higher difficulty. > * Tasks shown in gray are already completed. @@ -146,3 +145,5 @@ digraph g { > [!WARNING] > Tasks of high expected difficulty are different from tasks which we expect will be very time-consuming. + +{{#include ../links.md}} diff --git a/design-docs/src/mdbook/src/dataplane/tasks/pick-a-datastore.md b/design-docs/src/mdbook/src/dataplane/tasks/pick-a-datastore.md index 5eee82c6..6727c5e9 100644 --- a/design-docs/src/mdbook/src/dataplane/tasks/pick-a-datastore.md +++ b/design-docs/src/mdbook/src/dataplane/tasks/pick-a-datastore.md @@ -29,15 +29,4 @@ The remaining option I know of is [`rqlite`]. _I have not used it,_ but it seems Thus, I think the real choice is between [`etcd`] and [`rqlite`]. -That choice comes down to how much we value the functionality of sqlite (multiple indexes, referential integrity, strong schema) vs. the upsides of `etcd` (watches, battle tested and more widely used). - - - - -- management -- data-store - - - -[`rqlite`]: https://rqlite.io/ -[`etcd`]: https://github.com/coreos/etcd +That choice comes down to how much we value the functionality of sqlite (multiple indexes, referential integrity, strong schema) vs. the upsides of [etcd] (watches, battle tested, and more widely used). diff --git a/design-docs/src/mdbook/src/dataplane/tasks2/configuration-persistence-investigation.md b/design-docs/src/mdbook/src/dataplane/tasks2/configuration-persistence-investigation.md index 1ca5d887..46e4ceb5 100644 --- a/design-docs/src/mdbook/src/dataplane/tasks2/configuration-persistence-investigation.md +++ b/design-docs/src/mdbook/src/dataplane/tasks2/configuration-persistence-investigation.md @@ -12,7 +12,7 @@ Rather, this store needs to hold configuration data which is ## etcd -[`etcd`] is a reasonable choice because +[etcd] is a reasonable choice because 1. It is already in use in kubernetes and is therefore likely to be well-maintained and tested. 2. we are already using / integrating with kubernetes so any flaws in `etcd` are likely to impact us anyway. diff --git a/design-docs/src/mdbook/src/dataplane/tasks2/control-plane-dev-env.md b/design-docs/src/mdbook/src/dataplane/tasks2/control-plane-dev-env.md index ebc87385..2b8c569b 100644 --- a/design-docs/src/mdbook/src/dataplane/tasks2/control-plane-dev-env.md +++ b/design-docs/src/mdbook/src/dataplane/tasks2/control-plane-dev-env.md @@ -1,6 +1,6 @@ # Control plane dev-env -Create and document a development environment for the [`zebra`] [hedgehog plugin]. +Create and document a development environment for the [zebra] [hedgehog plugin]. Requirements: @@ -9,7 +9,6 @@ Requirements: - **REQUIRE**: CI runs tests in dev-env container or, - **IDEALLY**: tests run in a more minimal test-env container. -```yaml issue-meta -assign: - - @Fredi Raspall -``` +## Likely dispatch + +- [@Fredi-raspall] diff --git a/design-docs/src/mdbook/src/dataplane/tasks2/core-pinning.md b/design-docs/src/mdbook/src/dataplane/tasks2/core-pinning.md index ff981e1d..a8eaa4c8 100644 --- a/design-docs/src/mdbook/src/dataplane/tasks2/core-pinning.md +++ b/design-docs/src/mdbook/src/dataplane/tasks2/core-pinning.md @@ -1,4 +1,4 @@ # Core pinning > [!NOTE] -> I think we can punt on this till the last minute! +> I think we can punt on this until the last minute! diff --git a/design-docs/src/mdbook/src/dataplane/tasks2/create-control-plane-image.md b/design-docs/src/mdbook/src/dataplane/tasks2/create-control-plane-image.md index 3a92d3bd..2951d775 100644 --- a/design-docs/src/mdbook/src/dataplane/tasks2/create-control-plane-image.md +++ b/design-docs/src/mdbook/src/dataplane/tasks2/create-control-plane-image.md @@ -16,10 +16,9 @@ We need to generate a docker image to run our control plane. Both [@Fredi-raspall] and [@daniel-noland] have made some progress on this task and should sync up to get it over the line. -```yaml issue-meta -assign: - - @Fredi Raspall -``` +## Likely dispatch + +- [@Fredi-raspall] [Lua scripting]: https://docs.frrouting.org/en/latest/scripting.html diff --git a/design-docs/src/mdbook/src/dataplane/tasks2/dataplane-control-plane-transport.md b/design-docs/src/mdbook/src/dataplane/tasks2/dataplane-control-plane-transport.md index 9fcd97d1..bcf14741 100644 --- a/design-docs/src/mdbook/src/dataplane/tasks2/dataplane-control-plane-transport.md +++ b/design-docs/src/mdbook/src/dataplane/tasks2/dataplane-control-plane-transport.md @@ -2,7 +2,7 @@ It seems like we have all agreed on [unix domain sockets]. -## Likely assignment +## Likely dispatch * [@Fredi-raspall] * coordinate with: [@daniel-noland] diff --git a/design-docs/src/mdbook/src/dataplane/tasks2/frr-plugin.md b/design-docs/src/mdbook/src/dataplane/tasks2/frr-plugin.md deleted file mode 100644 index 3fa9e3ed..00000000 --- a/design-docs/src/mdbook/src/dataplane/tasks2/frr-plugin.md +++ /dev/null @@ -1,5 +0,0 @@ -# FRR Plugin (basic) - -Just a feature marker for MVP FRR [plugin][hedgehog plugin]. - -{{#include ../../links.md}} diff --git a/design-docs/src/mdbook/src/dataplane/tasks2/vpc-rate-limiting.md b/design-docs/src/mdbook/src/dataplane/tasks2/vpc-rate-limiting.md index e846fc55..ebdf647b 100644 --- a/design-docs/src/mdbook/src/dataplane/tasks2/vpc-rate-limiting.md +++ b/design-docs/src/mdbook/src/dataplane/tasks2/vpc-rate-limiting.md @@ -2,5 +2,7 @@ Just rate limiting! -Explicitly not full QoS for the moment. -If we involve QoS in the MVP then we will have zero chance on this timeline. +Explicitly not full [QoS] for the moment. +If we involve [QoS] in the MVP then we will have zero chance on this timeline. + +{{#include ../../links.md}} diff --git a/design-docs/src/mdbook/src/dataplane/tasks2/vxlan-tunnels b/design-docs/src/mdbook/src/dataplane/tasks2/vxlan-tunnels deleted file mode 100644 index f3eff1fc..00000000 --- a/design-docs/src/mdbook/src/dataplane/tasks2/vxlan-tunnels +++ /dev/null @@ -1 +0,0 @@ -# VXLAN encap/decap diff --git a/design-docs/src/mdbook/src/dataplane/tasks2/zebra-plugin.md b/design-docs/src/mdbook/src/dataplane/tasks2/zebra-plugin.md new file mode 100644 index 00000000..92866b77 --- /dev/null +++ b/design-docs/src/mdbook/src/dataplane/tasks2/zebra-plugin.md @@ -0,0 +1,24 @@ +# Zebra Plugin (basic) + +The dataplane and control plane need to communicate with each other regarding + +1. Full routing tables (for [state sync]) +2. route updates (i.e. differential updates) +3. route offloading status (including failures) +4. Address assignments, to ensure the dataplane can configure [local delivery](./identify-local-traffic.md) + +Keep in mind that route tables are, in general, notably more complex than a naive LPM trie, and may include like: + +1. [ECMP]/WCMP +2. [encapsulation rules](https://www.man7.org/linux/man-pages/man8/ip-route.8.html), +3. [nexthop groups](https://man7.org/linux/man-pages/man8/ip-nexthop.8.html), +4. multicast routes (this is unlikely to be important in the near term). + +We only expect to support basic IPv4 and IPv6 LPM routes in the near term, but feature evolution should be accounted for in the design. + +## Likely dispatch + +* [@Fredi-raspall] +* coordinate with: [@daniel-noland] + +{{#include ../../links.md}} diff --git a/design-docs/src/mdbook/src/links.md b/design-docs/src/mdbook/src/links.md index 67e17a9b..076cb541 100644 --- a/design-docs/src/mdbook/src/links.md +++ b/design-docs/src/mdbook/src/links.md @@ -24,6 +24,7 @@ [LACP]: https://en.wikipedia.org/wiki/Link_aggregation#Link_Aggregation_Control_Protocol [MySQL]: https://www.mysql.com/ [NAT]: https://en.wikipedia.org/wiki/Network_address_translation +[QoS]: https://en.wikipedia.org/wiki/Quality_of_service [TiDB]: https://www.pingcap.com/ [TiKV]: https://tikv.org/ [VXLAN]: https://en.wikipedia.org/wiki/Virtual_Extensible_LAN @@ -42,6 +43,8 @@ [cbindgen]: https://github.com/mozilla/cbindgen [distributed SQL]: https://en.wikipedia.org/wiki/Distributed_SQL [dpdk]: https://www.dpdk.org/ +[etcd]: https://github.com/coreos/etcd +[etherparse]: https://github.com/JulianSchmid/etherparse [frr]: https://frrouting.org/ [graphana]: https://grafana.com/ [kernel]: https://en.wikipedia.org/wiki/Linux_kernel @@ -51,6 +54,7 @@ [network address translation]: https://en.wikipedia.org/wiki/Network_address_translation [prometheus]: https://prometheus.io/ [protobuf]: https://protobuf.dev/ +[rqlite]: https://rqlite.io/ [rte lcores]: https://doc.dpdk.org/api/rte__lcore_8h.html [serde]: https://serde.rs/ [tracing]: https://docs.rs/tracing/latest/tracing/ diff --git a/dpdk-sys/Cargo.toml b/dpdk-sys/Cargo.toml index db912aa9..d2c5d024 100644 --- a/dpdk-sys/Cargo.toml +++ b/dpdk-sys/Cargo.toml @@ -4,6 +4,10 @@ version = "0.0.1" edition = "2021" description = "Low-level bindings to the Data Plane Development Kit (DPDK)" publish = false +resolver = "2" + +[lib] +crate-type = ["rlib"] [build-dependencies] bindgen = { workspace = true, features = ["runtime"] } diff --git a/dpdk-sys/build.rs b/dpdk-sys/build.rs index 23267f4b..1e794cbf 100644 --- a/dpdk-sys/build.rs +++ b/dpdk-sys/build.rs @@ -46,7 +46,7 @@ fn bind(path: &Path, sysroot: &str) { // (not the items themselves, just the documentation associated with them) // I suspect this is a bug in bindgen, but I'm not sure. // I don't have any reason to think we need any of these functions and I'd - // rather have the doc comments on for the rest of the project + // rather have the doc comments on for the rest of the project, so turn these off. .blocklist_type("rte_bus_cmp_t") .blocklist_type("rte_class_cmp_t") .blocklist_function("rte_bus_find") @@ -57,6 +57,7 @@ fn bind(path: &Path, sysroot: &str) { .blocklist_function("rte_pci_addr_cmp") .blocklist_function("rte_pci_addr_parse") // rustc doesn't like repr(packed) types which contain other repr(packed) types + // I am very confident that we don't need these structs anyway. .opaque_type("rte_arp_hdr") .opaque_type("rte_arp_ipv4") .opaque_type("rte_gtp_psc_generic_hdr") diff --git a/dpdk/Cargo.toml b/dpdk/Cargo.toml index 06c2d424..7c79c72b 100644 --- a/dpdk/Cargo.toml +++ b/dpdk/Cargo.toml @@ -3,6 +3,7 @@ name = "dpdk" version = "0.1.0" edition = "2021" publish = false +resolver = "2" [features] default = ["serde", "tracing_max_level_trace", "tracing_release_max_level_debug"] @@ -24,14 +25,14 @@ tracing_release_max_level_warn = ["tracing/release_max_level_warn"] [dependencies] -dpdk-sys = { path = "../dpdk-sys" } -errno = { path = "../errno" } -net = { path = "../net" } +dpdk-sys = { workspace = true } +errno = { workspace = true } +net = { workspace = true } -etherparse = { workspace = true, default-features = false, features = [] } serde = { workspace = true, optional = true } thiserror = { workspace = true } tracing = { workspace = true, features = ["attributes"] } +bitflags = { workspace = true } [build-dependencies] -dpdk-sysroot-helper = { path = "../dpdk-sysroot-helper" } +dpdk-sysroot-helper = { workspace = true } diff --git a/dpdk/src/dev.rs b/dpdk/src/dev.rs index 269af95e..9c1fb783 100644 --- a/dpdk/src/dev.rs +++ b/dpdk/src/dev.rs @@ -5,6 +5,7 @@ use alloc::format; use alloc::vec::Vec; +use bitflags::*; use core::ffi::{c_uint, CStr}; use core::fmt::{Debug, Display, Formatter}; use core::marker::PhantomData; @@ -59,7 +60,6 @@ impl DevIndex { self.0 } - #[tracing::instrument(level = "trace", ret)] /// Get information about an ethernet device. /// /// # Arguments @@ -74,33 +74,34 @@ impl DevIndex { /// # Safety /// /// This function should never panic assuming DPDK is correctly implemented. + #[tracing::instrument(level = "trace", ret)] pub fn info(&self) -> Result { let mut dev_info = rte_eth_dev_info::default(); let ret = unsafe { rte_eth_dev_info_get(self.0, &mut dev_info) }; if ret != 0 { - match ret { + return match ret { errno::NEG_ENOTSUP => { error!( "Device information not supported for port {index}", index = self.0 ); - return Err(DevInfoError::NotSupported); + Err(DevInfoError::NotSupported) } errno::NEG_ENODEV => { error!( "Device information not available for port {index}", index = self.0 ); - return Err(DevInfoError::NotAvailable); + Err(DevInfoError::NotAvailable) } errno::NEG_EINVAL => { error!( "Invalid argument when getting device info for port {index}", index = self.0 ); - return Err(DevInfoError::InvalidArgument); + Err(DevInfoError::InvalidArgument) } val => { let _unknown = match StandardErrno::parse_i32(val) { @@ -120,9 +121,9 @@ impl DevIndex { index = self.0, val = val ); - return Err(DevInfoError::Unknown(errno::Errno(val))); + Err(DevInfoError::Unknown(Errno(val))) } - } + }; // error!( // "Failed to get device info for port {index}: {err}", // index = self.0 @@ -150,7 +151,8 @@ impl DevIndex { /// (statically ensured). /// * This function may panic if DPDK returns an unexpected (undocumented) error code after /// failing to determine the socket id. - pub fn socket_id(&self) -> Result { + #[tracing::instrument(level = "trace", ret)] + pub fn socket_id(&self) -> Result { let socket_id = unsafe { rte_eth_dev_socket_id(self.as_u16()) }; if socket_id == -1 { match unsafe { wrte_errno() } { @@ -160,7 +162,7 @@ impl DevIndex { } errno::EINVAL => { // We are asking DPDK for the socket id of a port that doesn't exist. - return Err(errno::ErrorCode::parse_i32(errno::EINVAL)); + return Err(ErrorCode::parse_i32(errno::EINVAL)); } errno => { // Getting here means we have an unknown error. @@ -213,7 +215,8 @@ pub struct DevConfig { /// Setting it to `None` should disable all offloads, but instead we default to enabling all /// supported. /// Rework this bad idea. - pub tx_offloads: Option, + pub tx_offloads: Option<()>, + // pub tx_offloads: Option, } #[derive(Debug)] @@ -226,13 +229,10 @@ pub enum DevConfigError { impl DevConfig { /// Apply the configuration to the device. pub fn apply(&self, dev: DevInfo) -> Result { - const ANY_SUPPORTED: u64 = u64::MAX; let eth_conf = rte_eth_conf { txmode: rte_eth_txmode { offloads: { - let requested = self - .tx_offloads - .map_or(TxOffload(ANY_SUPPORTED), TxOffload::from); + let requested = TxOffload::ALL_KNOWN; let supported = dev.tx_offload_caps(); (requested & supported).0 }, @@ -313,159 +313,211 @@ impl From for RxOffload { } } -#[non_exhaustive] -#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] -/// Verbose configuration for transmit offloads. -/// -/// This struct is mostly for coherent reporting on network cards. -/// -/// TODO: fill in remaining offload types from `rte_ethdev.h` -pub struct TxOffloadConfig { - /// GENEVE tunnel segmentation offload. - pub geneve_tnl_tso: bool, - /// GRE tunnel segmentation offload. - pub gre_tnl_tso: bool, - /// IPIP tunnel segmentation offload. - pub ipip_tnl_tso: bool, - /// IPv4 checksum calculation. - pub ipv4_cksum: bool, - /// MACsec insertion. - pub macsec_insert: bool, - /// Outer IPv4 checksum calculation. - pub outer_ipv4_cksum: bool, - /// QinQ (double VLAN) insertion. - pub qinq_insert: bool, - /// SCTP checksum calculation. - pub sctp_cksum: bool, - /// TCP checksum calculation. - pub tcp_cksum: bool, - /// TCP segmentation offload. - pub tcp_tso: bool, - /// UDP checksum calculation. - pub udp_cksum: bool, - /// UDP segmentation offload. - pub udp_tso: bool, - /// VLAN tag insertion. - pub vlan_insert: bool, - /// VXLAN tunnel segmentation offload. - pub vxlan_tnl_tso: bool, - /// Any flags that are not known to map to a valid offload. - pub unknown: u64, -} - -impl Default for TxOffloadConfig { - /// Defaults to enabling all known offloads - fn default() -> Self { - TxOffloadConfig { - geneve_tnl_tso: true, - gre_tnl_tso: true, - ipip_tnl_tso: true, - ipv4_cksum: true, - macsec_insert: true, - outer_ipv4_cksum: true, - qinq_insert: true, - sctp_cksum: true, - tcp_cksum: true, - tcp_tso: true, - udp_cksum: true, - udp_tso: true, - vlan_insert: true, - vxlan_tnl_tso: true, - unknown: 0, - } - } -} - -impl Display for TxOffloadConfig { - fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result { - write!(f, "{self:?}") - } -} - -impl From for TxOffload { - fn from(value: TxOffloadConfig) -> Self { - use wrte_eth_tx_offload::*; - TxOffload( - if value.geneve_tnl_tso { - TX_OFFLOAD_GENEVE_TNL_TSO - } else { - 0 - } | if value.gre_tnl_tso { - TX_OFFLOAD_GRE_TNL_TSO - } else { - 0 - } | if value.ipip_tnl_tso { - TX_OFFLOAD_IPIP_TNL_TSO - } else { - 0 - } | if value.ipv4_cksum { - TX_OFFLOAD_IPV4_CKSUM - } else { - 0 - } | if value.macsec_insert { - TX_OFFLOAD_MACSEC_INSERT - } else { - 0 - } | if value.outer_ipv4_cksum { - TX_OFFLOAD_OUTER_IPV4_CKSUM - } else { - 0 - } | if value.qinq_insert { - TX_OFFLOAD_QINQ_INSERT - } else { - 0 - } | if value.sctp_cksum { - TX_OFFLOAD_SCTP_CKSUM - } else { - 0 - } | if value.tcp_cksum { - TX_OFFLOAD_TCP_CKSUM - } else { - 0 - } | if value.tcp_tso { TX_OFFLOAD_TCP_TSO } else { 0 } - | if value.udp_cksum { - TX_OFFLOAD_UDP_CKSUM - } else { - 0 - } - | if value.udp_tso { TX_OFFLOAD_UDP_TSO } else { 0 } - | if value.vlan_insert { - TX_OFFLOAD_VLAN_INSERT - } else { - 0 - } - | if value.vxlan_tnl_tso { - TX_OFFLOAD_VXLAN_TNL_TSO - } else { - 0 - } - | value.unknown, - ) - } -} - -impl From for TxOffloadConfig { - fn from(value: TxOffload) -> Self { - use wrte_eth_tx_offload::*; - TxOffloadConfig { - geneve_tnl_tso: value.0 & TX_OFFLOAD_GENEVE_TNL_TSO != 0, - gre_tnl_tso: value.0 & TX_OFFLOAD_GRE_TNL_TSO != 0, - ipip_tnl_tso: value.0 & TX_OFFLOAD_IPIP_TNL_TSO != 0, - ipv4_cksum: value.0 & TX_OFFLOAD_IPV4_CKSUM != 0, - macsec_insert: value.0 & TX_OFFLOAD_MACSEC_INSERT != 0, - outer_ipv4_cksum: value.0 & TX_OFFLOAD_OUTER_IPV4_CKSUM != 0, - qinq_insert: value.0 & TX_OFFLOAD_QINQ_INSERT != 0, - sctp_cksum: value.0 & TX_OFFLOAD_SCTP_CKSUM != 0, - tcp_cksum: value.0 & TX_OFFLOAD_TCP_CKSUM != 0, - tcp_tso: value.0 & TX_OFFLOAD_TCP_TSO != 0, - udp_cksum: value.0 & TX_OFFLOAD_UDP_CKSUM != 0, - udp_tso: value.0 & TX_OFFLOAD_UDP_TSO != 0, - vlan_insert: value.0 & TX_OFFLOAD_VLAN_INSERT != 0, - vxlan_tnl_tso: value.0 & TX_OFFLOAD_VXLAN_TNL_TSO != 0, - unknown: value.0 & !TxOffload::ALL_KNOWN.0, - } - } -} +// /// Verbose configuration for transmit offloads. +// /// +// /// This struct is mostly for coherent reporting on network cards. +// /// +// /// TODO: fill in remaining offload types from `rte_ethdev.h` +// #[non_exhaustive] +// #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +// pub struct TxOffloadConfig { +// /// GENEVE tunnel segmentation offload. +// pub geneve_tnl_tso: bool, +// /// GRE tunnel segmentation offload. +// pub gre_tnl_tso: bool, +// /// IPIP tunnel segmentation offload. +// pub ipip_tnl_tso: bool, +// /// IPv4 checksum calculation. +// pub ipv4_cksum: bool, +// /// MACsec insertion. +// pub macsec_insert: bool, +// /// Outer IPv4 checksum calculation. +// pub outer_ipv4_cksum: bool, +// /// QinQ (double VLAN) insertion. +// pub qinq_insert: bool, +// /// SCTP checksum calculation. +// pub sctp_cksum: bool, +// /// TCP checksum calculation. +// pub tcp_cksum: bool, +// /// TCP segmentation offload. +// pub tcp_tso: bool, +// /// UDP checksum calculation. +// pub udp_cksum: bool, +// /// UDP segmentation offload. +// pub udp_tso: bool, +// /// VLAN tag insertion. +// pub vlan_insert: bool, +// /// VXLAN tunnel segmentation offload. +// pub vxlan_tnl_tso: bool, +// /// Any flags that are not known to map to a valid offload. +// pub unknown: u64, +// } + +// impl Default for TxOffloadConfig { +// /// Defaults to enabling all known offloads +// fn default() -> Self { +// TxOffloadConfig { +// geneve_tnl_tso: true, +// gre_tnl_tso: true, +// ipip_tnl_tso: true, +// ipv4_cksum: true, +// macsec_insert: true, +// outer_ipv4_cksum: true, +// qinq_insert: true, +// sctp_cksum: true, +// tcp_cksum: true, +// tcp_tso: true, +// udp_cksum: true, +// udp_tso: true, +// vlan_insert: true, +// vxlan_tnl_tso: true, +// unknown: 0, +// } +// } +// } + +// impl Display for TxOffloadConfig { +// fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result { +// write!(f, "{self:?}") +// } +// } + +bitflags! { + #[repr(transparent)] + #[derive(Debug, PartialEq, Eq)] + pub struct TxOffloads: u64 { + const VLAN_INSERT = wrte_eth_tx_offload::TX_OFFLOAD_VLAN_INSERT; + const IPV4_CKSUM = wrte_eth_tx_offload::TX_OFFLOAD_IPV4_CKSUM; + const UDP_CKSUM = wrte_eth_tx_offload::TX_OFFLOAD_UDP_CKSUM; + const TCP_CKSUM = wrte_eth_tx_offload::TX_OFFLOAD_TCP_CKSUM; + const SCTP_CKSUM = wrte_eth_tx_offload::TX_OFFLOAD_SCTP_CKSUM; + const TCP_TSO = wrte_eth_tx_offload::TX_OFFLOAD_TCP_TSO; + const UDP_TSO = wrte_eth_tx_offload::TX_OFFLOAD_UDP_TSO; + const OUTER_IPV4_CKSUM = wrte_eth_tx_offload::TX_OFFLOAD_OUTER_IPV4_CKSUM; + const QINQ_INSERT = wrte_eth_tx_offload::TX_OFFLOAD_QINQ_INSERT; + const VXLAN_TNL_TSO = wrte_eth_tx_offload::TX_OFFLOAD_VXLAN_TNL_TSO; + const GRE_TNL_TSO = wrte_eth_tx_offload::TX_OFFLOAD_GRE_TNL_TSO; + const IPIP_TNL_TSO = wrte_eth_tx_offload::TX_OFFLOAD_IPIP_TNL_TSO; + const GENEVE_TNL_TSO = wrte_eth_tx_offload::TX_OFFLOAD_GENEVE_TNL_TSO; + const MACSEC_INSERT = wrte_eth_tx_offload::TX_OFFLOAD_MACSEC_INSERT; + const MT_LOCKFREE = wrte_eth_tx_offload::TX_OFFLOAD_MT_LOCKFREE; + const MULTI_SEGS = wrte_eth_tx_offload::TX_OFFLOAD_MULTI_SEGS; + const MBUF_FAST_FREE = wrte_eth_tx_offload::TX_OFFLOAD_MBUF_FAST_FREE; + const SECURITY = wrte_eth_tx_offload::TX_OFFLOAD_SECURITY; + const UDP_TNL_TSO = wrte_eth_tx_offload::TX_OFFLOAD_UDP_TNL_TSO; + const IP_TNL_TSO = wrte_eth_tx_offload::TX_OFFLOAD_IP_TNL_TSO; + const OUTER_UDP_CKSUM = wrte_eth_tx_offload::TX_OFFLOAD_OUTER_UDP_CKSUM; + const SEND_ON_TIMESTAMP = wrte_eth_tx_offload::TX_OFFLOAD_SEND_ON_TIMESTAMP; + const _ = !0; + } +} + +// // TODO: we have had some kind of merge issue and now this method is mostly nonsense +// impl From for TxOffload { +// fn from(value: TxOffloadConfig) -> Self { +// use wrte_eth_tx_offload::*; +// TxOffload( +// if value.geneve_tnl_tso { +// TX_OFFLOAD_GENEVE_TNL_TSO +// } else { +// 0 +// } | if value.gre_tnl_tso { +// TX_OFFLOAD_GRE_TNL_TSO +// } else { +// 0 +// } | if value.ipip_tnl_tso { +// TX_OFFLOAD_IPIP_TNL_TSO +// } else { +// 0 +// } | if value.ipv4_cksum { +// TX_OFFLOAD_IPV4_CKSUM +// } else { +// 0 +// } | if value.macsec_insert { +// TX_OFFLOAD_MACSEC_INSERT +// } else { +// 0 +// } | if value.outer_ipv4_cksum { +// TX_OFFLOAD_OUTER_IPV4_CKSUM +// } else { +// 0 +// } | if value.qinq_insert { +// TX_OFFLOAD_QINQ_INSERT +// } else { +// 0 +// } | if value.sctp_cksum { +// TX_OFFLOAD_SCTP_CKSUM +// } else { +// 0 +// } | if value.tcp_cksum { +// TX_OFFLOAD_TCP_CKSUM +// } else { +// 0 +// } | if value.tcp_tso { TX_OFFLOAD_TCP_TSO } else { 0 } +// | if value.udp_cksum { +// TX_OFFLOAD_UDP_CKSUM +// } else { +// 0 +// } +// | if value.qinq_insert { +// TX_OFFLOAD_QINQ_INSERT +// } else { +// 0 +// } +// | if value.sctp_cksum { +// TX_OFFLOAD_SCTP_CKSUM +// } else { +// 0 +// } +// | if value.tcp_cksum { +// TX_OFFLOAD_TCP_CKSUM +// } else { +// 0 +// } +// | if value.tcp_tso { TX_OFFLOAD_TCP_TSO } else { 0 } +// | if value.udp_cksum { +// TX_OFFLOAD_UDP_CKSUM +// } else { +// 0 +// } +// | if value.udp_tso { TX_OFFLOAD_UDP_TSO } else { 0 } +// | if value.vlan_insert { +// TX_OFFLOAD_VLAN_INSERT +// } else { +// 0 +// } +// | if value.vxlan_tnl_tso { +// TX_OFFLOAD_VXLAN_TNL_TSO +// } else { +// 0 +// } +// | value.unknown, +// ) +// } +// } + +// impl From for TxOffloadConfig { +// fn from(value: TxOffload) -> Self { +// use wrte_eth_tx_offload::*; +// TxOffloadConfig { +// geneve_tnl_tso: value.0 & TX_OFFLOAD_GENEVE_TNL_TSO != 0, +// gre_tnl_tso: value.0 & TX_OFFLOAD_GRE_TNL_TSO != 0, +// ipip_tnl_tso: value.0 & TX_OFFLOAD_IPIP_TNL_TSO != 0, +// ipv4_cksum: value.0 & TX_OFFLOAD_IPV4_CKSUM != 0, +// macsec_insert: value.0 & TX_OFFLOAD_MACSEC_INSERT != 0, +// outer_ipv4_cksum: value.0 & TX_OFFLOAD_OUTER_IPV4_CKSUM != 0, +// qinq_insert: value.0 & TX_OFFLOAD_QINQ_INSERT != 0, +// sctp_cksum: value.0 & TX_OFFLOAD_SCTP_CKSUM != 0, +// tcp_cksum: value.0 & TX_OFFLOAD_TCP_CKSUM != 0, +// tcp_tso: value.0 & TX_OFFLOAD_TCP_TSO != 0, +// udp_cksum: value.0 & TX_OFFLOAD_UDP_CKSUM != 0, +// udp_tso: value.0 & TX_OFFLOAD_UDP_TSO != 0, +// vlan_insert: value.0 & TX_OFFLOAD_VLAN_INSERT != 0, +// vxlan_tnl_tso: value.0 & TX_OFFLOAD_VXLAN_TNL_TSO != 0, +// unknown: value.0 & !TxOffload::ALL_KNOWN.0, +// } +// } +// } impl TxOffload { /// GENEVE tunnel segmentation offload. @@ -562,15 +614,28 @@ impl BitXorAssign for TxOffload { } } -#[derive(Debug, PartialEq)] /// Information about a DPDK ethernet device. /// /// This struct is a wrapper around the `rte_eth_dev_info` struct from DPDK. +#[derive(Debug, PartialEq)] pub struct DevInfo { pub(crate) index: DevIndex, pub(crate) inner: rte_eth_dev_info, } +bitflags! { + #[repr(transparent)] + #[derive(Debug, PartialEq, Eq)] + pub struct DevCapabilities: u64 { + const RUNTIME_RX_QUEUE_SETUP = RTE_ETH_DEV_CAPA_RUNTIME_RX_QUEUE_SETUP as u64; + const RUNTIME_TX_QUEUE_SETUP = RTE_ETH_DEV_CAPA_RUNTIME_TX_QUEUE_SETUP as u64; + const RXQ_SHARE = RTE_ETH_DEV_CAPA_RXQ_SHARE as u64; + const FLOW_RULE_KEEP = RTE_ETH_DEV_CAPA_FLOW_RULE_KEEP as u64; + const FLOW_SHARED_OBJECT_KEEP = RTE_ETH_DEV_CAPA_FLOW_SHARED_OBJECT_KEEP as u64; + const _ = !0; + } +} + #[repr(transparent)] #[derive(Debug)] struct DevIterator { @@ -693,30 +758,38 @@ impl DevInfo { self.inner.if_index } - #[allow(clippy::expect_used)] - #[tracing::instrument(level = "debug")] /// Get the driver name of the device. /// /// # Panics /// /// This function will panic if the driver name is not valid utf-8. + #[allow(clippy::expect_used)] + #[tracing::instrument(level = "debug")] pub fn driver_name(&self) -> &str { unsafe { CStr::from_ptr(self.inner.driver_name) } .to_str() .expect("driver name is not valid utf-8") } - #[tracing::instrument(level = "trace")] /// Get the maximum set of available tx offloads supported by the device. + #[tracing::instrument(level = "trace")] pub fn tx_offload_caps(&self) -> TxOffload { self.inner.tx_offload_capa.into() } - #[tracing::instrument(level = "trace")] /// Get the maximum set of available rx offloads supported by the device. + #[tracing::instrument(level = "trace")] pub fn rx_offload_caps(&self) -> RxOffload { self.inner.rx_offload_capa.into() } + + /// Get the capabilities of the device. + /// + /// See [`DevCapabilities`] + #[tracing::instrument(level = "trace")] + pub fn capabilities(&self) -> DevCapabilities { + DevCapabilities::from_bits_retain(self.inner.dev_capa) + } } #[derive(Debug)] @@ -728,7 +801,7 @@ pub struct Dev { pub config: DevConfig, pub(crate) rx_queues: Vec, pub(crate) tx_queues: Vec, - pub(crate) hairpin_queues: Vec, + pub(crate) hairpin_queues: Vec, } impl Dev { @@ -854,7 +927,7 @@ impl Drop for Dev { port = self.info.index() ); match self.stop() { - Ok(()) => { + Ok(_) => { info!("Device {port} stopped", port = self.info.index()); } Err(err) => { @@ -873,5 +946,5 @@ pub enum SocketIdLookupError { #[error("Invalid port ID")] DevDoesNotExist(DevIndex), #[error("Unknown error code set")] - UnknownErrno(errno::ErrorCode), + UnknownErrno(ErrorCode), } diff --git a/dpdk/src/mem.rs b/dpdk/src/mem.rs index c40fbf20..9a40cdab 100644 --- a/dpdk/src/mem.rs +++ b/dpdk/src/mem.rs @@ -385,7 +385,7 @@ impl Mbuf { pub(crate) fn new_from_raw(raw: *mut rte_mbuf) -> Option { let raw = match NonNull::new(raw) { None => { - warn!("Attempted to create Mbuf from null pointer"); + error!("Attempted to create Mbuf from null pointer"); return None; } Some(raw) => raw, diff --git a/dpdk/src/queue/rx.rs b/dpdk/src/queue/rx.rs index b5cffcff..41d2db2d 100644 --- a/dpdk/src/queue/rx.rs +++ b/dpdk/src/queue/rx.rs @@ -8,6 +8,7 @@ use crate::mem::Mbuf; use crate::socket::SocketId; use crate::{dev, mem, socket}; use dpdk_sys::*; +use errno::ErrorCode; use tracing::{trace, warn}; #[repr(transparent)] @@ -60,15 +61,15 @@ pub struct RxQueueConfig { #[derive(Debug)] pub enum ConfigFailure { /// The device has been removed. - DeviceRemoved(errno::Errno), - /// Invalid arguments were passed to the receive queue configuration. - InvalidArgument(errno::Errno), + DeviceRemoved(ErrorCode), + /// Invalid arguments were passed to the rx queue configuration. + InvalidArgument(ErrorCode), /// Memory allocation failed. - NoMemory(errno::Errno), + NoMemory(ErrorCode), /// An unexpected (i.e. undocumented) error occurred. - Unexpected(errno::Errno), + Unexpected(ErrorCode), /// The socket preference setting did not resolve a known socket. - InvalidSocket(errno::Errno), + InvalidSocket(ErrorCode), } /// DPDK rx queue @@ -87,9 +88,12 @@ impl RxQueue { /// /// This design ensures that the hairpin queue is correctly tracked in the list of queues /// associated with the device. + #[tracing::instrument(level = "info")] pub(crate) fn configure(dev: &dev::Dev, config: RxQueueConfig) -> Result { - let socket_id = SocketId::try_from(config.socket_preference) - .map_err(|_| ConfigFailure::InvalidSocket(errno::Errno(errno::NEG_EINVAL)))?; + use ConfigFailure::*; + let socket_id = SocketId::try_from(config.socket_preference).map_err(InvalidSocket)?; + // dev.info.index + // info!("Configuring RX queue on socket {socket_id} for device {dev_info}", d); let rx_conf = rte_eth_rxconf { offloads: dev.info.inner.rx_queue_offload_capa, @@ -111,14 +115,15 @@ impl RxQueue { dev: dev.info.index(), config, }), - errno::NEG_ENODEV => Err(ConfigFailure::DeviceRemoved(errno::Errno(ret))), - errno::NEG_EINVAL => Err(ConfigFailure::InvalidArgument(errno::Errno(ret))), - errno::NEG_ENOMEM => Err(ConfigFailure::NoMemory(errno::Errno(ret))), - val => Err(ConfigFailure::Unexpected(errno::Errno(val))), + errno::NEG_ENODEV => Err(DeviceRemoved(ErrorCode::parse_i32(ret))), + errno::NEG_EINVAL => Err(InvalidArgument(ErrorCode::parse_i32(ret))), + errno::NEG_ENOMEM => Err(NoMemory(ErrorCode::parse_i32(ret))), + _ => Err(Unexpected(ErrorCode::parse_i32(ret))), } } - /// Start the receive queue. + /// Start the rx queue. + #[tracing::instrument(level = "info")] pub(crate) fn start(self) -> Result { let ret = unsafe { rte_eth_dev_rx_queue_start(self.dev.as_u16(), self.config.queue_index.as_u16()) @@ -134,7 +139,8 @@ impl RxQueue { } } - /// Start the receive queue. + /// Start the rx queue. + #[tracing::instrument(level = "info")] pub(crate) fn stop(self) -> Result { let ret = unsafe { rte_eth_dev_rx_queue_stop(self.dev.as_u16(), self.config.queue_index.as_u16()) @@ -175,57 +181,45 @@ impl RxQueue { } } -/// TODO +/// Types of errors associated with starting RX queues #[derive(thiserror::Error, Debug)] pub enum RxQueueStartError { - /// TODO - #[error("Invalid port ID")] + #[error("The port ID associated with this RX queue is invalid")] InvalidPortId, - /// TODO - #[error("Queue ID out of range")] + #[error("The specified queue id is outside the range of known RX queues")] QueueIdOutOfRange, - /// TODO - #[error("Device removed")] + #[error("The network device associated with this RX queue has been removed")] DeviceRemoved, - /// TODO - #[error("Invalid argument")] + #[error("Invalid arguments supplied to RX queue configuration")] InvalidArgument, - /// TODO - #[error("Operation not supported")] + #[error("Operation is not supported (check device state and rx queue config)")] NotSupported, - /// TODO - #[error("Unknown error")] + #[error("Unknown error encountered when starting RX queue")] Unexpected(errno::Errno), } -/// TODO +/// Types of errors associated with stopping RX queues #[derive(thiserror::Error, Debug)] pub enum RxQueueStopError { - /// TODO #[error("Invalid port ID")] InvalidPortId, - /// TODO #[error("Queue ID out of range")] QueueIdOutOfRange, - /// TODO #[error("Device removed")] DeviceRemoved, - /// TODO #[error("Invalid argument")] InvalidArgument, - /// TODO #[error("Operation not supported")] NotSupported, - /// TODO #[error("Unexpected error")] Unexpected(errno::Errno), } -/// TODO +/// States of RX queues #[derive(Debug)] pub enum RxQueueState { - /// TODO + /// Stopped RX queue Stopped, - /// TODO + /// Started RX queue Started, } diff --git a/dpdk/src/queue/tx.rs b/dpdk/src/queue/tx.rs index bf4fbe25..03e665a0 100644 --- a/dpdk/src/queue/tx.rs +++ b/dpdk/src/queue/tx.rs @@ -89,6 +89,7 @@ impl TxQueue { /// /// This design ensures that the hairpin queue is correctly tracked in the list of queues /// associated with the device. + #[tracing::instrument(level = "info")] pub(crate) fn configure(dev: &dev::Dev, config: TxQueueConfig) -> Result { let socket_id = socket::SocketId::try_from(config.socket_preference) .map_err(|err| ConfigFailure::InvalidSocket(ConfigError { code: -1, err }))?; @@ -125,84 +126,74 @@ impl TxQueue { /// Start the transmit queue. pub(crate) fn start(self) -> Result { + use TxQueueStartError::*; let ret = unsafe { rte_eth_dev_tx_queue_start(self.dev.as_u16(), self.config.queue_index.as_u16()) }; match ret { errno::SUCCESS => Ok(self), - errno::NEG_ENODEV => Err(TxQueueStartError::DeviceRemoved), - errno::NEG_EINVAL => Err(TxQueueStartError::InvalidArgument), - errno::NEG_EIO => Err(TxQueueStartError::DeviceRemoved), - errno::NEG_ENOTSUP => Err(TxQueueStartError::NotSupported), - val => Err(TxQueueStartError::Unexpected(errno::Errno(val))), + errno::NEG_ENODEV => Err(DeviceRemoved), + errno::NEG_EINVAL => Err(InvalidArgument), + errno::NEG_EIO => Err(DeviceRemoved), + errno::NEG_ENOTSUP => Err(NotSupported), + val => Err(Unexpected(errno::Errno(val))), } } /// Stop the transmit queue. pub(crate) fn stop(self) -> Result { + use TxQueueStopError::*; let ret = unsafe { rte_eth_dev_tx_queue_stop(self.dev.as_u16(), self.config.queue_index.as_u16()) }; match ret { errno::SUCCESS => Ok(self), - errno::NEG_ENODEV => Err(TxQueueStopError::DeviceRemoved), - errno::NEG_EINVAL => Err(TxQueueStopError::InvalidArgument), - errno::NEG_EIO => Err(TxQueueStopError::DeviceRemoved), - errno::NEG_ENOTSUP => Err(TxQueueStopError::NotSupported), - val => Err(TxQueueStopError::Unexpected(errno::Errno(val))), + errno::NEG_ENODEV => Err(DeviceRemoved), + errno::NEG_EINVAL => Err(InvalidArgument), + errno::NEG_EIO => Err(DeviceRemoved), + errno::NEG_ENOTSUP => Err(NotSupported), + val => Err(Unexpected(errno::Errno(val))), } } } -/// TODO +/// A DPDK transmit queue #[derive(Debug)] pub struct TxQueue { pub(crate) config: TxQueueConfig, pub(crate) dev: DevIndex, } -/// TODO +/// Types of errors associated with starting TX queues #[derive(thiserror::Error, Debug)] pub enum TxQueueStartError { - /// TODO - #[error("Invalid port ID")] + #[error("The port ID associated with this TX queue is invalid")] InvalidPortId, - /// TODO - #[error("Queue ID out of range")] + #[error("The specified queue id is outside the range of known TX queues")] QueueIdOutOfRange, - /// TODO - #[error("Device removed")] + #[error("The network device associated with this TX queue has been removed")] DeviceRemoved, - /// TODO - #[error("Invalid argument")] + #[error("Invalid arguments supplied to TX queue configuration")] InvalidArgument, - /// TODO - #[error("Operation not supported")] + #[error("Operation is not supported (check device state and rx queue config)")] NotSupported, - /// TODO - #[error("Unknown error")] + #[error("Unknown error encountered when starting TX queue")] Unexpected(errno::Errno), } -/// TODO +/// Types of errors associated with stopping TX queues #[derive(thiserror::Error, Debug)] -#[repr(i32)] pub enum TxQueueStopError { - /// TODO #[error("Invalid port ID")] - InvalidPortId = errno::NEG_ENODEV, - /// TODO + InvalidPortId, #[error("Device removed")] - DeviceRemoved = errno::NEG_EIO, - /// TODO + DeviceRemoved, #[error("Invalid argument")] - InvalidArgument = errno::NEG_EINVAL, - /// TODO + InvalidArgument, #[error("Operation not supported")] - NotSupported = errno::NEG_ENOTSUP, - /// TODO - #[error("Unknown error")] + NotSupported, + #[error("Unexpected error")] Unexpected(errno::Errno), } diff --git a/dpdk/src/socket.rs b/dpdk/src/socket.rs index c2558540..7ddcad14 100644 --- a/dpdk/src/socket.rs +++ b/dpdk/src/socket.rs @@ -9,11 +9,13 @@ //! we're sticking with that. //! //! [NUMA]: https://en.wikipedia.org/wiki/Non-uniform_memory_access + use crate::dev::DevIndex; #[allow(unused_imports)] /// imported for rustdoc use crate::eal::Eal; use core::ffi::c_uint; +use core::fmt::{Display, Formatter}; use core::marker::PhantomData; use dpdk_sys::rte_socket_id; use errno::{ErrorCode, StandardErrno}; @@ -164,6 +166,12 @@ impl Iterator for SocketIdIterator { /// [NUMA]: https://en.wikipedia.org/wiki/Non-uniform_memory_access pub struct SocketId(pub(crate) c_uint); +impl Display for SocketId { + fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result { + write!(f, "{}", self.0) + } +} + impl SocketId { /// A special [`SocketId`] that represents any socket. pub const ANY: SocketId = SocketId(c_uint::MAX /* -1 in c_int */); @@ -179,7 +187,7 @@ impl SocketId { /// # Note /// /// Ideally, this method should be accessed via the [`Manager::id_for_index`] object as that - /// makes lifetime issues simpler. + /// simplifies lifetime issues. pub(crate) fn current() -> SocketId { SocketId(unsafe { rte_socket_id() }) } diff --git a/errno/Cargo.toml b/errno/Cargo.toml index c0a2296b..9ae8e173 100644 --- a/errno/Cargo.toml +++ b/errno/Cargo.toml @@ -3,6 +3,7 @@ name = "errno" version = "0.1.0" edition = "2021" publish = false +resolver = "2" [dependencies] diff --git a/errno/src/lib.rs b/errno/src/lib.rs index 67295c80..d792e1ab 100644 --- a/errno/src/lib.rs +++ b/errno/src/lib.rs @@ -1094,12 +1094,12 @@ impl TryFrom for NegStandardErrno { /// Standard errno values negated #[derive(Debug, Copy, Clone, Eq, PartialEq, thiserror::Error)] +#[must_use] #[error(transparent)] -pub struct NegStandardErrno(StandardErrno); +pub struct NegStandardErrno(pub StandardErrno); impl StandardErrno { /// Negate the errno value. - #[must_use] pub const fn neg(self) -> NegStandardErrno { NegStandardErrno(self) } @@ -1193,379 +1193,3 @@ impl ErrorCode { Self::parse_i32(val.into()) } } - -/// Standard errno values -#[derive(Debug, Copy, Clone, Eq, PartialEq, thiserror::Error)] -#[repr(i32)] -pub enum StandardErrnoAgain { - /// No error. Successful operation. - #[error("No error. Successful operation.")] - Success(u8) = SUCCESS, - /// Operation not permitted - #[error("Operation not permitted")] - PermissionDenied = EPERM, - /// No such file or directory - #[error("No such file or directory")] - NoSuchFileOrDirectory = ENOENT, - /// No such process - #[error("No such process")] - NoSuchProcess = ESRCH, - /// Interrupted system call - #[error("Interrupted system call")] - Interrupted = EINTR, - /// I/O error - #[error("I/O error")] - Io = EIO, - /// No such device or address - #[error("No such device or address")] - NoSuchDeviceOrAddress = ENXIO, - /// Argument list too long - #[error("Argument list too long")] - TooBig = E2BIG, - /// Exec format error - #[error("Exec format error")] - ExecFormat = ENOEXEC, - /// Bad file number - #[error("Bad file number")] - BadFileNumber = EBADF, - /// No child processes - #[error("No child processes")] - NoChildProcesses = ECHILD, - /// Try again - #[error("Try again")] - TryAgain = EAGAIN, - /// No memory available - #[error("No memory available")] - NoMemory = ENOMEM, - /// Access denied - #[error("Access denied")] - AccessDenied = EACCES, - /// Bad address - #[error("Bad address")] - BadAddress = EFAULT, - /// Block device required - #[error("Block device required")] - BlockDeviceRequired = ENOTBLK, - /// Device or resource busy - #[error("Device or resource busy")] - Busy = EBUSY, - /// File exists - #[error("File exists")] - FileExists = EEXIST, - /// Cross-device link - #[error("Cross-device link")] - CrossDeviceLink = EXDEV, - /// No such device - #[error("No such device")] - NoSuchDevice = ENODEV, - /// Not a directory - #[error("Not a directory")] - NotADirectory = ENOTDIR, - /// Is a directory - #[error("Is a directory")] - IsADirectory = EISDIR, - /// Invalid argument - #[error("Invalid argument")] - InvalidArgument = EINVAL, - /// File table overflow - #[error("File table overflow")] - FileTableOverflow = ENFILE, - /// Too many open files - #[error("Too many open files")] - TooManyOpenFiles = EMFILE, - /// Not a tty - #[error("Not a tty")] - NotATty = ENOTTY, - /// Text file busy - #[error("Text file busy")] - TextFileBusy = ETXTBSY, - /// File too large - #[error("File too large")] - FileTooLarge = EFBIG, - /// No space left on a device - #[error("No space left on device")] - NoSpaceLeftOnDevice = ENOSPC, - /// Illegal seek - #[error("Illegal seek")] - IllegalSeek = ESPIPE, - /// Read-only file system - #[error("Read-only file system")] - ReadOnlyFileSystem = EROFS, - /// Too many links - #[error("Too many links")] - TooManyLinks = EMLINK, - /// Broken pipe - #[error("Broken pipe")] - BrokenPipe = EPIPE, - /// Numerical argument out of domain - #[error("Numerical argument out of domain")] - NumberOutOfDomain = EDOM, - /// Result too large - #[error("Result too large")] - ResultTooLarge = ERANGE, - /// No message of desired type - #[error("No message of desired type")] - NoMessage = ENOMSG, - /// Identifier removed - #[error("Identifier removed")] - IdentifierRemoved = EIDRM, - /// Channel number out of range - #[error("Channel number out of range")] - ChannelNumberOutOfRange = ECHRNG, - /// Level 2 not synchronized - #[error("Level 2 not synchronized")] - Level2NotSynchronized = EL2NSYNC, - /// Level 3 halted - #[error("Level 3 halted")] - Level3Halted = EL3HLT, - /// Level 3 reset - #[error("Level 3 reset")] - Level3Reset = EL3RST, - /// Link number out of range - #[error("Link number out of range")] - LinkNumberOutOfRange = ELNRNG, - /// Protocol driver not attached - #[error("Protocol driver not attached")] - ProtocolDriverNotAttached = EUNATCH, - /// No CSI structure available - #[error("No CSI structure available")] - NoCsiStructureAvailable = ENOCSI, - /// Level 2 halted - #[error("Level 2 halted")] - Level2Halted = EL2HLT, - /// Deadlock condition - #[error("Deadlock condition")] - Deadlock = EDEADLK, - /// No record locks available - #[error("No record locks available")] - NoRecordLocksAvailable = ENOLCK, - /// Invalid exchange - #[error("Invalid exchange")] - InvalidExchange = EBADE, - /// Invalid request descriptor - #[error("Invalid request descriptor")] - InvalidRequestDescriptor = EBADR, - /// Exchange full - #[error("Exchange full")] - ExchangeFull = EXFULL, - /// No anode - #[error("No anode")] - NoAnode = ENOANO, - /// Invalid request code - #[error("Invalid request code")] - InvalidRequestCode = EBADRQC, - /// Invalid slot - #[error("Invalid slot")] - InvalidSlot = EBADSLT, - /// File locking deadlock error - #[error("File locking deadlock error")] - FileLockingDeadlock = EDEADLOCK, - /// Bad font file format - #[error("Bad font file format")] - BadFontFileFormat = EBFONT, - /// Device not a stream - #[error("Device not a stream")] - DeviceNotAStream = ENOSTR, - /// No data available - #[error("No data available")] - NoDataAvailable = ENODATA, - /// Timer expired - #[error("Timer expired")] - TimerExpired = ETIME, - /// Out of streams resources - #[error("Out of streams resources")] - OutOfStreamsResources = ENOSR, - /// Machine is not on the network - #[error("Machine is not on the network")] - MachineNotOnTheNetwork = ENONET, - /// Package not installed - #[error("Package not installed")] - PackageNotInstalled = ENOPKG, - /// The object is remote - #[error("The object is remote")] - ObjectIsRemote = EREMOTE, - /// The link has been severed - #[error("The link has been severed")] - LinkSevered = ENOLINK, - /// Advertise error - #[error("Advertise error")] - AdvertiseError = EADV, - /// Srmount error - #[error("Srmount error")] - SrmountError = ESRMNT, - /// Communication error on send - #[error("Communication error on send")] - CommunicationErrorOnSend = ECOMM, - /// Protocol error - #[error("Protocol error")] - ProtocolError = EPROTO, - /// Multihop attempted - #[error("Multihop attempted")] - MultihopAttempted = EMULTIHOP, - /// Inode is remote (not really error) - #[error("Inode is remote (not really error)")] - InodeIsRemote = ELBIN, - /// Cross-mount point (not really error) - #[error("Cross mount point (not really error)")] - CrossMountPoint = EDOTDOT, - /// Trying to read an unreadable message - #[error("Trying to read unreadable message")] - TryingToReadUnreadableMessage = EBADMSG, - /// Inappropriate file type or format - #[error("Inappropriate file type or format")] - InappropriateFileTypeOrFormat = EFTYPE, - /// Given log name not unique - #[error("Given log name not unique")] - GivenLogNameNotUnique = ENOTUNIQ, - /// f.d. invalid for this operation - #[error("f.d. invalid for this operation")] - FdInvalidForThisOperation = EBADFD, - /// Remote address changed - #[error("Remote address changed")] - RemoteAddressChanged = EREMCHG, - /// Can't access a necessary shared library - #[error("Can't access a needed shared library")] - CantAccessNeededSharedLibrary = ELIBACC, - /// Accessing a corrupted shared library - #[error("Accessing a corrupted shared library")] - AccessingCorruptedSharedLibrary = ELIBBAD, - /// .lib section in a.out corrupted - #[error(".lib section in a.out corrupted")] - LibSectionInAOutCorrupted = ELIBSCN, - /// Attempting to link in too many libs - #[error("Attempting to link in too many libs")] - AttemptingToLinkInTooManyLibs = ELIBMAX, - /// Attempting to exec a shared library - #[error("Attempting to exec a shared library")] - AttemptingToExecASharedLibrary = ELIBEXEC, - /// Function is not implemented - #[error("Function not implemented")] - FunctionNotImplemented = ENOSYS, - /// No more files - #[error("No more files")] - NoMoreFiles = ENMFILE, - /// Directory is not empty - #[error("Directory not empty")] - DirectoryNotEmpty = ENOTEMPTY, - /// File or path name too long - #[error("File or path name too long")] - FileOrPathNameTooLong = ENAMETOOLONG, - /// Too many symbolic links - #[error("Too many symbolic links")] - TooManySymbolicLinks = ELOOP, - /// Operation not supported on transport endpoint - #[error("Operation not supported on transport endpoint")] - OperationNotSupportedOnTransportEndpoint = EOPNOTSUPP, - /// Protocol family is not supported - #[error("Protocol family not supported")] - ProtocolFamilyNotSupported = EPFNOSUPPORT, - /// Connection reset by peer - #[error("Connection reset by peer")] - ConnectionResetByPeer = ECONNRESET, - /// No buffer space available - #[error("No buffer space available")] - NoBufferSpaceAvailable = ENOBUFS, - /// Address family not supported by protocol family - #[error("Address family not supported by protocol family")] - AddressFamilyNotSupportedByProtocolFamily = EAFNOSUPPORT, - /// Protocol wrong type for socket - #[error("Protocol wrong type for socket")] - ProtocolWrongTypeForSocket = EPROTOTYPE, - /// Socket operation on non-socket - #[error("Socket operation on non-socket")] - SocketOperationOnNonSocket = ENOTSOCK, - /// Protocol not available - #[error("Protocol not available")] - ProtocolNotAvailable = ENOPROTOOPT, - /// Can't send after socket shutdown - #[error("Can't send after socket shutdown")] - CantSendAfterSocketShutdown = ESHUTDOWN, - /// Connection refused - #[error("Connection refused")] - ConnectionRefused = ECONNREFUSED, - /// Address already in use - #[error("Address already in use")] - AddressAlreadyInUse = EADDRINUSE, - /// Connection aborted - #[error("Connection aborted")] - ConnectionAborted = ECONNABORTED, - /// Network is unreachable - #[error("Network is unreachable")] - NetworkIsUnreachable = ENETUNREACH, - /// Network interface is not configured - #[error("Network interface is not configured")] - NetworkInterfaceNotConfigured = ENETDOWN, - /// Connection timed out - #[error("Connection timed out")] - ConnectionTimedOut = ETIMEDOUT, - /// Host is down - #[error("Host is down")] - HostIsDown = EHOSTDOWN, - /// Host is unreachable - #[error("Host is unreachable")] - HostIsUnreachable = EHOSTUNREACH, - /// Connection already in progress - #[error("Connection already in progress")] - ConnectionAlreadyInProgress = EINPROGRESS, - /// Socket already connected - #[error("Socket already connected")] - SocketAlreadyConnected = EALREADY, - /// Destination address required - #[error("Destination address required")] - DestinationAddressRequired = EDESTADDRREQ, - /// Message too long - #[error("Message too long")] - MessageTooLong = EMSGSIZE, - /// Unknown protocol - #[error("Unknown protocol")] - UnknownProtocol = EPROTONOSUPPORT, - /// Socket type is not supported - #[error("Socket type not supported")] - SocketTypeNotSupported = ESOCKTNOSUPPORT, - /// Address not available - #[error("Address not available")] - AddressNotAvailable = EADDRNOTAVAIL, - /// Network dropped connection on reset - #[error("Network dropped connection on reset")] - NetworkDroppedConnectionOnReset = ENETRESET, - /// Socket is already connected - #[error("Socket is already connected")] - SocketIsAlreadyConnected = EISCONN, - /// Socket is not connected - #[error("Socket is not connected")] - SocketIsNotConnected = ENOTCONN, - /// Too many references: cannot splice - #[error("Too many references: cannot splice")] - TooManyReferences = ETOOMANYREFS, - /// The per-user limit on the new process would be exceeded by an attempted fork. - #[error("The per-user limit on new process would be exceeded by an attempted fork.")] - ProcessLimitExceeded = EPROCLIM, - /// The file quota system is confused because there are too many users. - #[error("The file quota system is confused because there are too many users.")] - TooManyUsers = EUSERS, - /// The user's disk quota was exceeded. - #[error("The user's disk quota was exceeded.")] - DiskQuotaExceeded = EDQUOT, - /// Stale NFS file handle - #[error("Stale NFS file handle")] - StaleNfsFileHandle = ESTALE, - /// Not supported - #[error("Not supported")] - NotSupported = ENOTSUP, - /// No medium (in tape drive) - #[error("No medium (in tape drive)")] - NoMedium = ENOMEDIUM, - /// No such host or network path - #[error("No such host or network path")] - NoShare = ENOSHARE, - /// Filename exists with different case - #[error("Filename exists with different case")] - CaseClash = ECASECLASH, - /// While decoding a multibyte character the function came along an invalid or an incomplete - /// sequence of bytes or the given wide character is invalid. - #[error("While decoding a multibyte character the function came along an invalid or an incomplete sequence of bytes or the given wide character is invalid.")] - IllegalSequence = EILSEQ, - /// Value too large for defined data type - #[error("Value too large for defined data type")] - Overflow = EOVERFLOW, -} diff --git a/justfile b/justfile index c2b809b6..6eb27061 100644 --- a/justfile +++ b/justfile @@ -483,11 +483,12 @@ mdbook *args="build": {{ _just_debuggable_ }} mkdir -p /tmp/doc-env cd ./design-docs/src/mdbook - docker pull {{ _doc_env_container }} + # docker pull {{ _doc_env_container }} docker run \ --rm \ --init \ --volume "$(pwd):$(pwd)" \ + --env HOME=/tmp \ --user "$(id -u):$(id -g)" \ --mount type=bind,source=/tmp/doc-env,target=/tmp \ --workdir "$(pwd)" \ diff --git a/net/Cargo.toml b/net/Cargo.toml index a4537a57..1937347f 100644 --- a/net/Cargo.toml +++ b/net/Cargo.toml @@ -3,6 +3,7 @@ name = "net" version = "0.0.1" edition = "2021" publish = false +resolver = "2" [[bench]] name = "parse" diff --git a/net/src/lib.rs b/net/src/lib.rs index 42b3e8d9..86f919ce 100644 --- a/net/src/lib.rs +++ b/net/src/lib.rs @@ -1,10 +1,14 @@ // SPDX-License-Identifier: Apache-2.0 // Copyright Open Network Fabric Authors -#![cfg_attr(not(test), no_std)] // This library should always compile without std (even if we never ship that way) -#![forbid(unsafe_code)] // Validation logic should always be strictly safe -#![deny(missing_docs, clippy::all, clippy::pedantic)] // yeah, I'm that guy. I'm not sorry. -#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic)] // Do you know where your towel is? +// This library should always compile without std (even if we never ship that way) +#![cfg_attr(not(test), no_std)] +// Validation logic should always be strictly safe +#![forbid(unsafe_code)] +// yeah, I'm that guy. I'm not sorry. +#![deny(missing_docs, clippy::all, clippy::pedantic)] +// Do you know where your towel is? +#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic)] //! A library for working with and strictly validating network data @@ -13,21 +17,24 @@ extern crate alloc; pub mod vlan; pub mod vxlan; +#[allow(clippy::unwrap_used)] #[cfg(test)] mod tests { use super::*; use alloc::vec::Vec; + use etherparse::PacketBuilder; pub fn gen_random_udp_packet() -> Vec { - use etherparse::PacketBuilder; + const MAX_PAYLOAD_LEN: u16 = 1200; let src_mac: [u8; 6] = rand::random(); let dst_mac: [u8; 6] = rand::random(); let src_ip: [u8; 4] = rand::random(); let dst_ip: [u8; 4] = rand::random(); let src_port: u16 = rand::random(); let dst_port: u16 = rand::random(); + let ttl = rand::random::(); let builder = PacketBuilder::ethernet2(src_mac, dst_mac) - .ipv4(src_ip, dst_ip, rand::random()) + .ipv4(src_ip, dst_ip, ttl) .udp(src_port, dst_port); let payload_length = (rand::random::() % 1200) as usize; let mut payload = Vec::with_capacity(payload_length + 50); @@ -50,7 +57,6 @@ mod tests { #[test] fn parse_udp_packet_bit_by_bit() { let packet = gen_random_udp_packet(); - let cursor = 0; - let _eth = etherparse::Ethernet2Header::from_slice(&packet[cursor..]).unwrap(); + etherparse::Ethernet2Header::from_slice(packet.as_slice()).unwrap(); } } diff --git a/scratch/Cargo.toml b/scratch/Cargo.toml index f8fd9794..afeeef0f 100644 --- a/scratch/Cargo.toml +++ b/scratch/Cargo.toml @@ -3,15 +3,18 @@ name = "scratch" version = "0.1.0" edition = "2021" publish = false +resolver = "2" [dependencies] -dpdk-sys = { path = "../dpdk-sys" } -dpdk = { path = "../dpdk" } -rand = { version = "0.8.5" } -thiserror = { workspace = true } +# internal +dpdk-sys = { workspace = true } +dpdk = { workspace = true } + +# external +rand = { version = "0.8.5", default-features = true } # non-workspace to prevent pulling in std in other crates tracing = { workspace = true, features = ["attributes"] } -tracing-subscriber = { workspace = true } +tracing-subscriber = { workspace = true, features = ["fmt"] } [build-dependencies] -dpdk-sysroot-helper = { path = "../dpdk-sysroot-helper" } +dpdk-sysroot-helper = { workspace = true } diff --git a/scratch/src/main.rs b/scratch/src/main.rs index 56101352..5bbb3cc5 100644 --- a/scratch/src/main.rs +++ b/scratch/src/main.rs @@ -1,7 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 // Copyright Open Network Fabric Authors -use dpdk::dev::TxOffloadConfig; use dpdk::{dev, eal, mem, queue, socket}; use dpdk_sys::*; use std::ffi::{c_uint, CStr, CString}; @@ -606,7 +605,7 @@ fn main() { fn eal_main() { tracing_subscriber::fmt() - .with_max_level(tracing::Level::WARN) + .with_max_level(tracing::Level::INFO) .with_target(false) .with_thread_ids(true) .with_line_number(true) @@ -621,7 +620,7 @@ fn eal_main() { "--huge-dir", "/mnt/huge/1G", "--allow", - "0000:85:00.0,dv_flow_en=1", + "0000:01:00.0,dv_flow_en=1", // "--trace=.*", // "--iova-mode=va", // "-l", @@ -660,21 +659,17 @@ fn eal_main() { rte.dev.iter().for_each(|dev| { info!("Device if_index: {if_index:?}", if_index = dev.if_index()); info!("Driver name: {name:?}", name = dev.driver_name()); - let tx_config: TxOffloadConfig = dev.tx_offload_caps().into(); - info!( - "Device tx offload capabilities: {tx_offload:?}", - tx_offload = tx_config - ); info!( "Device rx offload capabilities: {rx_offload:?}", rx_offload = dev.rx_offload_caps() ); + info!("Device capas: {capas:?}", capas = dev.capabilities()); let config = dev::DevConfig { num_rx_queues: 5, num_tx_queues: 5, num_hairpin_queues: 1, - tx_offloads: Some(TxOffloadConfig::default()), + tx_offloads: None, }; let mut my_dev = match config.apply(dev) { diff --git a/scripts/dpdk-sys.env b/scripts/dpdk-sys.env index 2132ad47..4053372d 100644 --- a/scripts/dpdk-sys.env +++ b/scripts/dpdk-sys.env @@ -1,2 +1,2 @@ DPDK_SYS_BRANCH="main" -DPDK_SYS_COMMIT="362f54faf27e7b02148fe524492455e2f6762854" +DPDK_SYS_COMMIT="ab1caa860a3e1a8baef37345b8740098384d4afe"