--- zzzz-none-000/linux-5.4.213/include/linux/skbuff.h 2022-09-15 10:04:56.000000000 +0000 +++ alder-5690pro-762/linux-5.4.213/include/linux/skbuff.h 2024-08-14 09:02:08.000000000 +0000 @@ -41,6 +41,19 @@ #include #endif +/* Do not include avm_pa.h to avoid include cycle. Since we can't determine + * the size here we reserve some space, including some extra space for future + * extensions without having to rebuild the world. + * + * avm_pa contains a BUILD_BUG_ON() in case the reserve is too small. + */ +#define AVM_PA_PKT_INFO_SKB_RESERVE 256 +struct avm_pa_pkt_info; + +#if defined(CONFIG_AVM_PA_GENERIC_CT) +#include +#endif + /* The interface for checksum offload between the stack and networking drivers * is as follows... * @@ -238,6 +251,14 @@ SKB_DATA_ALIGN(sizeof(struct sk_buff)) + \ SKB_DATA_ALIGN(sizeof(struct skb_shared_info))) +#define SKB_SAWF_VALID_TAG 0xAA +#define SKB_SAWF_TAG_SHIFT 24 +#define SKB_SAWF_SERVICE_CLASS_SHIFT 16 +#define SKB_SAWF_SERVICE_CLASS_MASK 0xff + +#define SKB_GET_SAWF_TAG(x) ((x) >> SKB_SAWF_TAG_SHIFT) +#define SKB_GET_SAWF_SERVICE_CLASS(x) (((x) >> SKB_SAWF_SERVICE_CLASS_SHIFT) & SKB_SAWF_SERVICE_CLASS_MASK) + struct net_device; struct scatterlist; struct pipe_inode_info; @@ -633,6 +654,7 @@ * @offload_fwd_mark: Packet was L2-forwarded in hardware * @offload_l3_fwd_mark: Packet was L3-forwarded in hardware * @tc_skip_classify: do not classify packet. set by IFB device + * @tc_skip_classify_offload: do not classify packet set by offload IFB device * @tc_at_ingress: used within tc_classify to distinguish in/egress * @redirected: packet was redirected by packet classifier * @from_ingress: packet was redirected from the ingress path @@ -730,6 +752,11 @@ #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) unsigned long _nfct; #endif +#ifdef CONFIG_AVM_PA_GENERIC_CT + struct generic_ct_data ct_data; +#define SKB_GENERIC_CT(skb) ((skb)->ct_data.generic_ct) +#define SKB_GENERIC_CT_DIR(skb) ((skb)->ct_data.generic_ct_dir) +#endif unsigned int len, data_len; __u16 mac_len, @@ -816,6 +843,7 @@ #ifdef CONFIG_NET_CLS_ACT __u8 tc_skip_classify:1; __u8 tc_at_ingress:1; + __u8 tc_skip_classify_offload:1; #endif #ifdef CONFIG_NET_REDIRECT __u8 redirected:1; @@ -824,6 +852,22 @@ #ifdef CONFIG_TLS_DEVICE __u8 decrypted:1; #endif + __u8 gro_skip:1; + __u8 fast_forwarded:1; + /* Linear packets processed by dev_fast_xmit() */ + __u8 fast_xmit:1; + /* Flag to check if skb is allocated from recycler */ + __u8 is_from_recycler:1; + /* Flag for fast recycle in fast xmit path */ + __u8 fast_recycled:1; + + /* Flag for recycle in PPE DS */ + __u8 recycled_for_ds:1; + /* 1 or 3 bit hole */ + __u8 fast_qdisc:1; + /* Packets processed in dev_fast_xmit_qdisc() path */ + __u8 int_pri:4; + /* Priority info for hardware qdiscs */ #ifdef CONFIG_NET_SCHED __u16 tc_index; /* traffic control index */ @@ -872,6 +916,13 @@ /* private: */ __u32 headers_end[0]; + +#ifdef CONFIG_AVM_PA + __u8 avm_pa[AVM_PA_PKT_INFO_SKB_RESERVE]; +#define AVM_PKT_INFO(skb) ((struct avm_pa_pkt_info *) (skb)->avm_pa) +#else +#define AVM_PKT_INFO(skb) ((struct avm_pa_pkt_info *) NULL) +#endif /* public: */ /* These elements must be at the end, see alloc_skb() for details. */ @@ -886,6 +937,13 @@ /* only useable after checking ->active_extensions != 0 */ struct skb_ext *extensions; #endif + +#ifdef CONFIG_DEBUG_OBJECTS_SKBUFF +#define DEBUG_OBJECTS_SKBUFF_STACKSIZE 20 + void *free_addr[DEBUG_OBJECTS_SKBUFF_STACKSIZE]; + void *alloc_addr[DEBUG_OBJECTS_SKBUFF_STACKSIZE]; + u32 sum; +#endif }; #ifdef __KERNEL__ @@ -1023,9 +1081,13 @@ void skb_dump(const char *level, const struct sk_buff *skb, bool full_pkt); void skb_tx_error(struct sk_buff *skb); void consume_skb(struct sk_buff *skb); +void consume_skb_list_fast(struct sk_buff_head *skb_list); +void check_skb_fast_recyclable(struct sk_buff *skb); void __consume_stateless_skb(struct sk_buff *skb); void __kfree_skb(struct sk_buff *skb); extern struct kmem_cache *skbuff_head_cache; +extern void kfree_skbmem(struct sk_buff *skb); +extern void skb_release_data(struct sk_buff *skb); void kfree_skb_partial(struct sk_buff *skb, bool head_stolen); bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from, @@ -1143,6 +1205,12 @@ return __skb_pad(skb, pad, true); } #define dev_kfree_skb(a) consume_skb(a) +#define dev_kfree_skb_list_fast(a) consume_skb_list_fast(a) +#if defined(SKB_FAST_RECYCLABLE_DEBUG_ENABLE) && defined(CONFIG_SKB_RECYCLER) +#define dev_check_skb_fast_recyclable(a) check_skb_fast_recyclable(a) +#else +#define dev_check_skb_fast_recyclable(a) +#endif int skb_append_pagefrags(struct sk_buff *skb, struct page *page, int offset, size_t size); @@ -2318,6 +2386,25 @@ void skb_condense(struct sk_buff *skb); /** + * skb_set_int_pri - sets the int_pri field in skb with given value. + * @skb: buffer to fill + * @int_pri: value that is to be filled + */ +static inline void skb_set_int_pri(struct sk_buff *skb, uint8_t int_pri) +{ + skb->int_pri = int_pri; +} + +/** + * skb_get_int_pri - gets the int_pri value from the given skb. + * @skb: buffer to check + */ +static inline uint8_t skb_get_int_pri(struct sk_buff *skb) +{ + return skb->int_pri; +} + +/** * skb_headroom - bytes at buffer head * @skb: buffer to check * @@ -2658,7 +2745,7 @@ * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8) */ #ifndef NET_SKB_PAD -#define NET_SKB_PAD max(32, L1_CACHE_BYTES) +#define NET_SKB_PAD max(64, L1_CACHE_BYTES) #endif int ___pskb_trim(struct sk_buff *skb, unsigned int len); @@ -2691,6 +2778,10 @@ return (len < skb->len) ? __pskb_trim(skb, len) : 0; } +extern struct sk_buff *__netdev_alloc_skb_ip_align(struct net_device *dev, + unsigned int length, gfp_t gfp); + + /** * pskb_trim_unique - remove end from a paged unique (not cloned) buffer * @skb: buffer to alter @@ -2789,6 +2880,9 @@ struct sk_buff *__netdev_alloc_skb(struct net_device *dev, unsigned int length, gfp_t gfp_mask); +struct sk_buff *__netdev_alloc_skb_no_skb_reset(struct net_device *dev, unsigned int length, + gfp_t gfp_mask); + /** * netdev_alloc_skb - allocate an skbuff for rx on a specific device * @dev: network device to receive on @@ -2822,16 +2916,6 @@ } -static inline struct sk_buff *__netdev_alloc_skb_ip_align(struct net_device *dev, - unsigned int length, gfp_t gfp) -{ - struct sk_buff *skb = __netdev_alloc_skb(dev, length + NET_IP_ALIGN, gfp); - - if (NET_IP_ALIGN && skb) - skb_reserve(skb, NET_IP_ALIGN); - return skb; -} - static inline struct sk_buff *netdev_alloc_skb_ip_align(struct net_device *dev, unsigned int length) { @@ -4081,6 +4165,28 @@ skb->csum = csum_add(skb->csum, delta); } +#if IS_ENABLED(CONFIG_AVM_PA_GENERIC_CT) +static inline void generic_ct_reset(struct sk_buff *skb) +{ + generic_ct_put(SKB_GENERIC_CT(skb)); + SKB_GENERIC_CT(skb) = NULL; +} + +static inline void __generic_ct_copy(struct sk_buff *dst, + const struct sk_buff *src) +{ + SKB_GENERIC_CT(dst) = generic_ct_get(SKB_GENERIC_CT(src)); + SKB_GENERIC_CT_DIR(dst) = SKB_GENERIC_CT_DIR(src); +} + +static inline void generic_ct_copy(struct sk_buff *dst, + const struct sk_buff *src) +{ + generic_ct_put(SKB_GENERIC_CT(dst)); + __generic_ct_copy(dst, src); +} +#endif + static inline struct nf_conntrack *skb_nfct(const struct sk_buff *skb) { #if IS_ENABLED(CONFIG_NF_CONNTRACK) @@ -4214,7 +4320,7 @@ static inline bool skb_has_extensions(struct sk_buff *skb) { return false; } #endif /* CONFIG_SKB_EXTENSIONS */ -static inline void nf_reset_ct(struct sk_buff *skb) +static inline void nf_reset_no_generic_ct(struct sk_buff *skb) { #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) nf_conntrack_put(skb_nfct(skb)); @@ -4222,6 +4328,14 @@ #endif } +static inline void nf_reset_ct(struct sk_buff *skb) +{ + nf_reset_no_generic_ct(skb); +#ifdef CONFIG_AVM_PA_GENERIC_CT + generic_ct_reset(skb); +#endif +} + static inline void nf_reset_trace(struct sk_buff *skb) { #if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE) || defined(CONFIG_NF_TABLES) @@ -4237,7 +4351,7 @@ } /* Note: This doesn't put any conntrack info in dst. */ -static inline void __nf_copy(struct sk_buff *dst, const struct sk_buff *src, +static inline void __nf_copy_no_generic_ct(struct sk_buff *dst, const struct sk_buff *src, bool copy) { #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) @@ -4250,12 +4364,31 @@ #endif } -static inline void nf_copy(struct sk_buff *dst, const struct sk_buff *src) +/* Note: This doesn't put any conntrack and bridge info in dst. */ +static inline void __nf_copy(struct sk_buff *dst, const struct sk_buff *src, + bool copy) +{ + __nf_copy_no_generic_ct(dst, src, copy); +#ifdef CONFIG_AVM_PA_GENERIC_CT + __generic_ct_copy(dst, src); +#endif +} + +static inline void nf_copy_no_generic_ct(struct sk_buff *dst, + const struct sk_buff *src) { #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) nf_conntrack_put(skb_nfct(dst)); #endif - __nf_copy(dst, src, true); + __nf_copy_no_generic_ct(dst, src, true); +} + +static inline void nf_copy(struct sk_buff *dst, const struct sk_buff *src) +{ + nf_copy_no_generic_ct(dst, src); +#ifdef CONFIG_AVM_PA_GENERIC_CT + generic_ct_copy(dst, src); +#endif } #ifdef CONFIG_NETWORK_SECMARK