Commit 86ae579c authored by Eli Cohen's avatar Eli Cohen Committed by Saeed Mahameed

net: Make mpls_entry_encode() available for generic users

Move mpls_entry_encode() from net/mpls/internal.h to include/net/mpls.h
and make it available for other users. Specifically, hardware driver that
offload MPLS can benefit from that.
Suggested-by: default avatarJakub Kicinski <kuba@kernel.org>
Suggested-by: default avatarDavid Ahern <dsahern@gmail.com>
Signed-off-by: default avatarEli Cohen <eli@mellanox.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
parent e1167e16
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <linux/if_ether.h> #include <linux/if_ether.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/mpls.h>
#define MPLS_HLEN 4 #define MPLS_HLEN 4
...@@ -25,4 +26,20 @@ static inline struct mpls_shim_hdr *mpls_hdr(const struct sk_buff *skb) ...@@ -25,4 +26,20 @@ static inline struct mpls_shim_hdr *mpls_hdr(const struct sk_buff *skb)
{ {
return (struct mpls_shim_hdr *)skb_network_header(skb); return (struct mpls_shim_hdr *)skb_network_header(skb);
} }
static inline struct mpls_shim_hdr mpls_entry_encode(u32 label,
unsigned int ttl,
unsigned int 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;
}
#endif #endif
...@@ -172,17 +172,6 @@ struct mpls_route { /* next hop label forwarding entry */ ...@@ -172,17 +172,6 @@ struct mpls_route { /* next hop label forwarding entry */
#define endfor_nexthops(rt) } #define endfor_nexthops(rt) }
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;
}
static inline struct mpls_entry_decoded mpls_entry_decode(struct mpls_shim_hdr *hdr) static inline struct mpls_entry_decoded mpls_entry_decode(struct mpls_shim_hdr *hdr)
{ {
struct mpls_entry_decoded result; struct mpls_entry_decoded result;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment