Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

netmem: fix netmem comments

Trivial fix to a couple of outdated netmem comments. No code changes,
just more accurately describing current code.

Signed-off-by: Mina Almasry <almasrymina@google.com>
Acked-by: Stanislav Fomichev <sdf@fomichev.me>
Link: https://patch.msgid.link/20250615203511.591438-1-almasrymina@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Mina Almasry and committed by
Jakub Kicinski
0f66b616 e74058f5

+16 -5
+16 -5
include/net/netmem.h
··· 89 89 * typedef netmem_ref - a nonexistent type marking a reference to generic 90 90 * network memory. 91 91 * 92 - * A netmem_ref currently is always a reference to a struct page. This 93 - * abstraction is introduced so support for new memory types can be added. 92 + * A netmem_ref can be a struct page* or a struct net_iov* underneath. 94 93 * 95 94 * Use the supplied helpers to obtain the underlying memory pointer and fields. 96 95 */ ··· 116 117 return (__force struct page *)netmem; 117 118 } 118 119 119 - /* This conversion fails (returns NULL) if the netmem_ref is not struct page 120 - * backed. 121 - */ 122 120 static inline struct page *netmem_to_page(netmem_ref netmem) 123 121 { 124 122 if (WARN_ON_ONCE(netmem_is_net_iov(netmem))) ··· 174 178 return page_to_pfn(netmem_to_page(netmem)); 175 179 } 176 180 181 + /* __netmem_clear_lsb - convert netmem_ref to struct net_iov * for access to 182 + * common fields. 183 + * @netmem: netmem reference to extract as net_iov. 184 + * 185 + * All the sub types of netmem_ref (page, net_iov) have the same pp, pp_magic, 186 + * dma_addr, and pp_ref_count fields at the same offsets. Thus, we can access 187 + * these fields without a type check to make sure that the underlying mem is 188 + * net_iov or page. 189 + * 190 + * The resulting value of this function can only be used to access the fields 191 + * that are NET_IOV_ASSERT_OFFSET'd. Accessing any other fields will result in 192 + * undefined behavior. 193 + * 194 + * Return: the netmem_ref cast to net_iov* regardless of its underlying type. 195 + */ 177 196 static inline struct net_iov *__netmem_clear_lsb(netmem_ref netmem) 178 197 { 179 198 return (struct net_iov *)((__force unsigned long)netmem & ~NET_IOV);