]> Git Repo - J-linux.git/blob - drivers/net/ethernet/mellanox/mlx5/core/accel/accel.h
Merge remote-tracking branch 'spi/for-5.14' into spi-linus
[J-linux.git] / drivers / net / ethernet / mellanox / mlx5 / core / accel / accel.h
1 #ifndef __MLX5E_ACCEL_H__
2 #define __MLX5E_ACCEL_H__
3
4 #ifdef CONFIG_MLX5_ACCEL
5
6 #include <linux/skbuff.h>
7 #include <linux/netdevice.h>
8
9 static inline bool is_metadata_hdr_valid(struct sk_buff *skb)
10 {
11         __be16 *ethtype;
12
13         if (unlikely(skb->len < ETH_HLEN + MLX5E_METADATA_ETHER_LEN))
14                 return false;
15         ethtype = (__be16 *)(skb->data + ETH_ALEN * 2);
16         if (*ethtype != cpu_to_be16(MLX5E_METADATA_ETHER_TYPE))
17                 return false;
18         return true;
19 }
20
21 static inline void remove_metadata_hdr(struct sk_buff *skb)
22 {
23         struct ethhdr *old_eth;
24         struct ethhdr *new_eth;
25
26         /* Remove the metadata from the buffer */
27         old_eth = (struct ethhdr *)skb->data;
28         new_eth = (struct ethhdr *)(skb->data + MLX5E_METADATA_ETHER_LEN);
29         memmove(new_eth, old_eth, 2 * ETH_ALEN);
30         /* Ethertype is already in its new place */
31         skb_pull_inline(skb, MLX5E_METADATA_ETHER_LEN);
32 }
33
34 #endif /* CONFIG_MLX5_ACCEL */
35
36 #endif /* __MLX5E_EN_ACCEL_H__ */
This page took 0.032684 seconds and 4 git commands to generate.