On 5/26/20 1:19 PM, Jakub Kicinski wrote: > On Fri, 22 May 2020 16:51:45 -0700 Saeed Mahameed wrote: >> +static inline __be32 mpls_label_id_field(__be32 label, u8 tos, u8 ttl) >> +{ >> + u32 res; >> + >> + /* mpls label is 32 bits long and construction as follows: >> + * 20 bits label >> + * 3 bits tos >> + * 1 bit bottom of stack. Since we support only one label, this bit is >> + * always set. >> + * 8 bits TTL >> + */ >> + res = be32_to_cpu(label) << 12 | 1 << 8 | (tos & 7) << 9 | ttl; >> + return cpu_to_be32(res); >> +} > > No static inlines in C source, please. Besides this belongs in the mpls > header, it's a generic helper. >
net/mpls/internal.h: static inline struct mpls_shim_hdr mpls_entry_encode(u32 label, unsigned ttl, unsigned tc, bool bos) { struct mpls_shim_hdr result; result.label_stack_entry = cpu_to_be32((label << MPLS_LS_LABEL_SHIFT) | (tc << MPLS_LS_TC_SHIFT) | (bos ? (1 << MPLS_LS_S_SHIFT) : 0) | (ttl << MPLS_LS_TTL_SHIFT)); return result; } perhaps that can be moved to include/net/mpls.h