mirror of
https://github.com/torvalds/linux.git
synced 2026-05-12 16:18:45 +02:00
net: add rps_tag_ptr type and helpers
Add a new rps_tag_ptr type to encode a pointer and a size to a power-of-two table. Three helpers are added converting an rps_tag_ptr to: 1) A log of the size. 2) A mask : (size - 1). 3) A pointer to the array. Signed-off-by: Eric Dumazet <edumazet@google.com> Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com> Link: https://patch.msgid.link/20260302181432.1836150-2-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
c26b8c4e29
commit
42a101775b
24
include/net/rps-types.h
Normal file
24
include/net/rps-types.h
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
#ifndef _NET_RPS_TYPES_H
|
||||
#define _NET_RPS_TYPES_H
|
||||
|
||||
/* Define a rps_tag_ptr:
|
||||
* Low order 5 bits are used to store the ilog2(size) of an RPS table.
|
||||
*/
|
||||
typedef unsigned long rps_tag_ptr;
|
||||
|
||||
static inline u8 rps_tag_to_log(rps_tag_ptr tag_ptr)
|
||||
{
|
||||
return tag_ptr & 31U;
|
||||
}
|
||||
|
||||
static inline u32 rps_tag_to_mask(rps_tag_ptr tag_ptr)
|
||||
{
|
||||
return (1U << rps_tag_to_log(tag_ptr)) - 1;
|
||||
}
|
||||
|
||||
static inline void *rps_tag_to_table(rps_tag_ptr tag_ptr)
|
||||
{
|
||||
return (void *)(tag_ptr & ~31UL);
|
||||
}
|
||||
#endif /* _NET_RPS_TYPES_H */
|
||||
Loading…
Reference in New Issue
Block a user