--- zzzz-none-000/linux-5.15.111/include/linux/skbuff.h 2023-05-11 14:00:40.000000000 +0000 +++ puma7-atom-6670-761/linux-5.15.111/include/linux/skbuff.h 2024-02-07 10:23:27.000000000 +0000 @@ -6,6 +6,13 @@ * Alan Cox, * Florian La Roche, */ +/* + * Includes Maxlinear's changes/modifications dated: 2022. + * Changed/modified portions - Copyright © 2022 Maxlinear, Inc. + * Includes Intel Corporation's changes/modifications dated: Oct.2011, 2020. + * Changed/modified portions - Copyright © 2015-2020 Intel Corporation + * 1. TI Meta Data Extensions for packet processor. + */ #ifndef _LINUX_SKBUFF_H #define _LINUX_SKBUFF_H @@ -41,6 +48,18 @@ #if IS_ENABLED(CONFIG_NF_CONNTRACK) #include #endif +#if IS_ENABLED(CONFIG_AVM_PA_GENERIC_CT) +#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; /* The interface for checksum offload between the stack and networking drivers * is as follows... @@ -217,6 +236,9 @@ * (two offloaded checksums are possible with UDP encapsulation). */ +#ifndef CONFIG_ARM_AVALANCHE_SOC +#include +#endif /* Don't change this without changing skb_csum_unnecessary! */ #define CHECKSUM_NONE 0 #define CHECKSUM_UNNECESSARY 1 @@ -496,6 +518,80 @@ }; #define SKBFL_ZEROCOPY_FRAG (SKBFL_ZEROCOPY_ENABLE | SKBFL_SHARED_FRAG) +#ifdef CONFIG_TI_PACKET_PROCESSOR + + #include + + #ifdef CONFIG_ARM_AVALANCHE_PPD + #include + #endif + + #ifdef CONFIG_TI_PACKET_PROCESSOR_STATS + #include + #endif + + #include + + /* Egress queue definitions... */ + #define TI_PPM_EGRESS_QUEUE_INVALID (-1) + + /* The structure contains information that needs to be stored on a per packet basis + * for the TI Packet Processor to operate. */ + typedef struct + { + #ifdef CONFIG_ARM_AVALANCHE_PPD + TI_PP_SESSION ti_session; + #endif + + AVALANCHE_PP_SESSION_INFO_t pp_session; + + unsigned int flags; + int input_device_index; + + /* The length of the EPI header is 8 bytes. */ + char ti_epi_header[ 8 ]; + int egress_queue; + + #ifdef CONFIG_TI_PACKET_PROCESSOR_STATS + struct PpsgcAssignedGroupCounters assignedGroupCounters; + #endif + + }PP_PACKET_INFO_t; + +#ifdef CONFIG_INTEL_KERNEL_SKB_COOKIE + typedef union + { + unsigned int raw[ 0 ]; + struct + { + PP_PACKET_INFO_t pp_packet_info; + void *nfct; + /* Add the additinal info below ... */ +#define AVM_PKT_INFO_MAX AVM_PA_PKT_INFO_SKB_RESERVE + /* Reserve space for avm_pa_pkt_info. The data needs to be maintained + * when packets travel through the ARM and come back from it (i.e. + * packets destined to the CPE). Then the AVM_PA can recognize + * such packets even though the skb itself has changed. + * + * !! If you change the buffer size, the ARM must be updated too !! + * + * Reserve unconditionally, so that ARM doesn't need to be recompiled + * if avm_pa is disabled + */ + __u8 avm_pa[AVM_PKT_INFO_MAX]; +#ifdef CONFIG_AVM_PA +#define AVM_PKT_INFO(skb) ((struct avm_pa_pkt_info *) &SKB_GET_COOKIE_P(skb)->s.avm_pa) +#else +#define AVM_PKT_INFO(skb) ((struct avm_pa_pkt_info *) NULL) +#endif + }s; + } + SKB_INTEL_COOKIE; +#else + #define SKB_INTEL_COOKIE PP_PACKET_INFO_t +#endif + +#endif /* CONFIG_TI_PACKET_PROCESSOR */ /* * The callback notifies userspace to release buffers when skb DMA is done in @@ -564,6 +660,11 @@ unsigned int gso_type; u32 tskey; +#ifdef CONFIG_PUMA_LITEPATH + __u8 pid:6, + dir:1, + pool_skb:1; +#endif /* * Warning : all fields before dataref are cleared in __alloc_skb() */ @@ -809,6 +910,11 @@ #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) unsigned long _nfct; #endif +#if defined(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, @@ -926,6 +1032,11 @@ }; }; __u32 priority; +#ifdef CONFIG_BRIDGE_NETFILTER +#ifdef CONFIG_BRIDGE_EBT_FORWARD + struct net_bridge_port *bridge_forward_port; +#endif +#endif int skb_iif; __u32 hash; __be16 vlan_proto; @@ -963,15 +1074,74 @@ u64 kcov_handle; #endif +#if IS_ENABLED(CONFIG_DIRECTCONNECT_DP_API) + /* used by directconnect peripherals to store session info */ + __u32 DW0, DW1, DW2, DW3; + unsigned char *buf_base; +#endif +#if IS_ENABLED(CONFIG_BRIDGE_IGMP_SNOOPING) +#if IS_ENABLED(CONFIG_MCAST_HELPER) + int mc_gid; +#endif +#endif + /* private: */ __u32 headers_end[0]; /* public: */ +#ifdef CONFIG_TI_META_DATA + unsigned int ti_meta_info; + unsigned int ti_meta_info2; + unsigned int ti_ds_traffic_prio; +#endif /* CONFIG_TI_META_DATA */ +#ifdef CONFIG_INTEL_NF_GWMETA_SUPPORT + __u32 ti_gw_meta; +#endif /* INTEL_NF_GWMETA_SUPPORT */ + +#ifdef CONFIG_TI_DOCSIS_INPUT_DEV + struct net_device *ti_docsis_input_dev; +#endif /* CONFIG_TI_DOCSIS_INPUT_DEV */ +#ifdef CONFIG_INTEL_DOCSIS_ICMP_IIF + int docsis_icmp_iif; +#endif /* CONFIG_INTEL_DOCSIS_ICMP_IIF */ +#ifdef CONFIG_TI_L2_SELECTIVE_FORWARDER + unsigned long long ti_selective_fwd_dev_info; +#endif /* CONFIG_TI_L2_SELECTIVE_FORWARDER */ +#ifdef CONFIG_TI_PACKET_PROCESSOR + #if PUMA7_OR_NEWER_SOC_TYPE + #ifdef CONFIG_INTEL_KERNEL_SKB_COOKIE + + SKB_INTEL_COOKIE * intel_cookie; + #define SKB_GET_PP_INFO_P(skb) (&(skb)->intel_cookie->s.pp_packet_info) + #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_AVM_PA_GENERIC_CT) + #define SKB_GET_COOKIE_NFCT_P(skb) ((skb)->intel_cookie->s.nfct) + #endif + #define SKB_GET_COOKIE_P(skb) ((skb)->intel_cookie) + + #else + + PP_PACKET_INFO_t * pp_packet_info; + #define SKB_GET_PP_INFO_P(skb) ((skb)->pp_packet_info) + #define SKB_GET_COOKIE_P(skb) ((skb)->pp_packet_info) + + #endif + + #else + PP_PACKET_INFO_t pp_packet_info; + #define SKB_GET_PP_INFO_P(skb) (&(skb)->pp_packet_info) + #endif + __u16 vpid_vlan_tci; + + __u16 parent_vpid_vlan_tci; +#endif /* CONFIG_TI_PACKET_PROCESSOR */ /* These elements must be at the end, see alloc_skb() for details. */ sk_buff_data_t tail; sk_buff_data_t end; unsigned char *head, *data; +#ifdef CONFIG_AVM_NET_DEBUG_SKBUFF_LEAK + void *last_user; +#endif unsigned int truesize; refcount_t users; @@ -982,6 +1152,13 @@ }; #ifdef __KERNEL__ + +#ifdef CONFIG_AVM_NET_DEBUG_SKBUFF_LEAK +#define skb_track_caller(skb) do { if (skb) (skb)->last_user = (void *)_RET_IP_; } while (0) +#define skb_track_func(skb) do { if (skb) (skb)->last_user = (void *)_THIS_IP_; } while (0) +#define skb_track_funccall(skb, func) do { if (skb) (skb)->last_user = (void *)func; } while (0) +#endif + /* * Handling routines are only of interest to the kernel */ @@ -1145,6 +1322,11 @@ bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from, bool *fragstolen, int *delta_truesize); +#ifdef CONFIG_TI_PACKET_PROCESSOR +extern void* __alloc_skb_intel_cookie(void); +extern void kfree_skb_intel_cookie(struct sk_buff *skb); +#endif + struct sk_buff *__alloc_skb(unsigned int size, gfp_t priority, int flags, int node); struct sk_buff *__build_skb(void *data, unsigned int frag_size); @@ -2010,6 +2192,9 @@ struct sk_buff *prev, struct sk_buff *next, struct sk_buff_head *list) { +#ifdef CONFIG_AVM_NET_DEBUG_SKBUFF_LEAK + skb_track_caller(newsk); +#endif /* See skb_queue_empty_lockless() and skb_peek_tail() * for the opposite READ_ONCE() */ @@ -2168,6 +2353,9 @@ { struct sk_buff *next, *prev; +#ifdef CONFIG_AVM_NET_DEBUG_SKBUFF_LEAK + skb_track_caller(skb); +#endif WRITE_ONCE(list->qlen, list->qlen - 1); next = skb->next; prev = skb->prev; @@ -2521,6 +2709,9 @@ */ static inline void skb_reserve(struct sk_buff *skb, int len) { +#ifdef CONFIG_AVM_NET_DEBUG_SKBUFF_LEAK + skb_track_caller(skb); +#endif skb->data += len; skb->tail += len; } @@ -2818,9 +3009,12 @@ * to reduce average number of cache lines per packet. * get_rps_cpu() for example only access one 64 bytes aligned block : * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8) + * + * AVM/TMA: increased to a minimum of 64 for XFRM use cases, + * xfrm_skb_check_space() otherwise reallocates frequently. */ #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); @@ -2892,6 +3086,9 @@ */ static inline void skb_orphan(struct sk_buff *skb) { +#ifdef CONFIG_AVM_NET_DEBUG_SKBUFF_LEAK + skb_track_caller(skb); +#endif if (skb->destructor) { skb->destructor(skb); skb->destructor = NULL; @@ -3927,6 +4124,9 @@ static inline void __net_timestamp(struct sk_buff *skb) { skb->tstamp = ktime_get_real(); +#ifdef CONFIG_AVM_NET_DEBUG_SKBUFF_LEAK + skb_track_caller(skb); +#endif } static inline ktime_t net_timedelta(ktime_t t) @@ -4452,7 +4652,30 @@ 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) + +#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 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)); @@ -4460,6 +4683,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) || IS_ENABLED(CONFIG_NF_TABLES) @@ -4475,7 +4706,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) @@ -4488,13 +4719,32 @@ #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 dst->slow_gro = src->slow_gro; - __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 @@ -4837,5 +5087,16 @@ return page_pool_return_skb_page(virt_to_page(data)); } +#ifdef CONFIG_PUMA_LITEPATH +struct skb_buf_manager_cb { + bool (*is_bm_skb)(struct sk_buff *skb); + int (*bm_free_skb)(struct sk_buff *skb); + void (*bm_clear_skb)(struct sk_buff *skb); +}; + +int skb_register_buf_manager(struct skb_buf_manager_cb *cb); +void skb_unregister_buf_manager(void); +#endif + #endif /* __KERNEL__ */ #endif /* _LINUX_SKBUFF_H */