DPDK patches and discussions
 help / color / mirror / Atom feed
* IPv6 APIs rework
@ 2024-07-18 15:03 Robin Jarry
  2024-07-18 20:27 ` Morten Brørup
  0 siblings, 1 reply; 21+ messages in thread
From: Robin Jarry @ 2024-07-18 15:03 UTC (permalink / raw)
  To: dev
  Cc: Sunil Kumar Kori, Rakesh Kudurumalla, Vladimir Medvedkin,
	Wisam Jaddo, Cristian Dumitrescu, Konstantin Ananyev,
	Akhil Goyal, Fan Zhang, Bruce Richardson, Yipeng Wang,
	Sameh Gobriel, Nithin Dabilpuram, Kiran Kumar K, Satha Rao,
	Harman Kalra, Ankur Dwivedi, Anoob Joseph, Tejasree Kondoj,
	Gagandeep Singh, Hemant Agrawal, Ajit Khaparde, Somnath Kotur,
	Chas Williams, Min Hu (Connor),
	Potnuri Bharat Teja, Sachin Saxena, Ziyang Xuan, Xiaoyun Wang,
	Jie Hai, Yisen Zhuang, Jingjing Wu, Dariusz Sosnowski,
	Viacheslav Ovsiienko, Bing Zhao, Ori Kam, Suanming Mou,
	Matan Azrad, Chaoyong He, Devendra Singh Rawat, Alok Prasad,
	Andrew Rybchenko, Stephen Hemminger, Jiawen Wu, Jian Wang,
	Thomas Monjalon, Ferruh Yigit, Jiayu Hu, Pavan Nikhilesh,
	Maxime Coquelin, Chenbo Xia

Hi folks,

while working on IPv6 support for grout [1], I noticed that all DPDK 
IPv6 APIs used fixed sized arrays in the route lookup functions [2].

 int rte_fib6_lookup_bulk(struct rte_fib6 *fib,
                          uint8_t ips[][RTE_FIB6_IPV6_ADDR_SIZE],
                          uint64_t *next_hops,
                          int n);

If I'm not mistaken, using sized arrays in function signatures is only 
for documentation purposes and does not result in any specific compiler 
checks. In the above example, the ips parameter is considered as a plain 
old `uint8_t **` pointer.

Also, not having a dedicated type for IPv6 addresses requires obscure 
pointer arithmetic [3] and casting [4].

I'd like to introduce a real IPv6 address structure that has the same 
alignment than a dumb `uint8_t *` pointer but has an union to ease 
casting and most importantly presents the whole thing as an explicit 
typed structure:

    #define RTE_IPV6_ADDR_SIZE 16

    struct rte_ipv6_addr {
        union {
            uint8_t u8[RTE_IPV6_ADDR_SIZE];
            uint16_t u16[RTE_IPV6_ADDR_SIZE / sizeof(uint16_t)];
            uint32_t u32[RTE_IPV6_ADDR_SIZE / sizeof(uint32_t)];
            uint64_t u64[RTE_IPV6_ADDR_SIZE / sizeof(uint64_t)];
        };
    } __rte_packed __rte_aligned(1);

This would require some breakage of the APIs but I think it would 
benefit code readability and maintainability in the long term.

 int rte_fib6_lookup_bulk(struct rte_fib6 *fib,
                          const struct rte_ipv6_addr *ips,
                          uint64_t *next_hops,
                          int n);

I already have a semi-working draft and am in the process of splitting 
the changes into small chunks to make them easier to review.

https://github.com/DPDK/dpdk/compare/main...rjarry:dpdk:ipv6-address-rework

Is that something that would be of interest? If yes, I would like to 
announce API breakage before the release of 24.07 so that the changes 
can be integrated into 24.11.

Cheers!

[1] https://github.com/rjarry/grout
[2] https://doc.dpdk.org/api/rte__fib6_8h.html#a924678410ccb9551cda3e75d742a11e3
[3] https://git.dpdk.org/dpdk/tree/lib/fib/trie_avx512.c?h=v24.07-rc2#n340
[4] https://git.dpdk.org/dpdk/tree/lib/hash/rte_thash.h?h=v24.07-rc2#n156

-- 
Robin


^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2024-07-22  9:31 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-18 15:03 IPv6 APIs rework Robin Jarry
2024-07-18 20:27 ` Morten Brørup
2024-07-18 21:15   ` Stephen Hemminger
2024-07-18 21:40     ` Robin Jarry
2024-07-18 21:25   ` Vladimir Medvedkin
2024-07-18 21:34     ` Robin Jarry
2024-07-19  8:25       ` Konstantin Ananyev
2024-07-19  9:12       ` Morten Brørup
2024-07-19 10:02         ` Robin Jarry
2024-07-19 10:09           ` Bruce Richardson
2024-07-19 10:46           ` Morten Brørup
2024-07-19 11:09             ` Robin Jarry
2024-07-19 15:47               ` Morten Brørup
2024-07-19 17:07                 ` Stephen Hemminger
2024-07-20 17:43                   ` Robin Jarry
2024-07-20 20:26                     ` Stephen Hemminger
2024-07-20 20:33                       ` Robin Jarry
2024-07-21 16:12                         ` Morten Brørup
2024-07-21 21:51                           ` Robin Jarry
2024-07-22  9:31                             ` Morten Brørup
2024-07-19 10:41         ` Medvedkin, Vladimir

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).