[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <97ec57bc-c46d-f9ca-037a-a9e07ad0fc08@gmail.com>
Date: Tue, 26 May 2020 13:27:05 -0600
From: David Ahern <dsahern@...il.com>
To: Jakub Kicinski <kuba@...nel.org>,
Saeed Mahameed <saeedm@...lanox.com>
Cc: "David S. Miller" <davem@...emloft.net>, netdev@...r.kernel.org,
Eli Cohen <eli@...lanox.com>, Roi Dayan <roid@...lanox.com>,
Eli Britstein <elibr@...lanox.com>
Subject: Re: [net-next 07/10] net/mlx5e: Add support for hw encapsulation of
MPLS over UDP
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
Powered by blists - more mailing lists