1*42a10177SEric Dumazet /* SPDX-License-Identifier: GPL-2.0-or-later */ 2*42a10177SEric Dumazet #ifndef _NET_RPS_TYPES_H 3*42a10177SEric Dumazet #define _NET_RPS_TYPES_H 4*42a10177SEric Dumazet 5*42a10177SEric Dumazet /* Define a rps_tag_ptr: 6*42a10177SEric Dumazet * Low order 5 bits are used to store the ilog2(size) of an RPS table. 7*42a10177SEric Dumazet */ 8*42a10177SEric Dumazet typedef unsigned long rps_tag_ptr; 9*42a10177SEric Dumazet 10*42a10177SEric Dumazet static inline u8 rps_tag_to_log(rps_tag_ptr tag_ptr) 11*42a10177SEric Dumazet { 12*42a10177SEric Dumazet return tag_ptr & 31U; 13*42a10177SEric Dumazet } 14*42a10177SEric Dumazet 15*42a10177SEric Dumazet static inline u32 rps_tag_to_mask(rps_tag_ptr tag_ptr) 16*42a10177SEric Dumazet { 17*42a10177SEric Dumazet return (1U << rps_tag_to_log(tag_ptr)) - 1; 18*42a10177SEric Dumazet } 19*42a10177SEric Dumazet 20*42a10177SEric Dumazet static inline void *rps_tag_to_table(rps_tag_ptr tag_ptr) 21*42a10177SEric Dumazet { 22*42a10177SEric Dumazet return (void *)(tag_ptr & ~31UL); 23*42a10177SEric Dumazet } 24*42a10177SEric Dumazet #endif /* _NET_RPS_TYPES_H */ 25