--- zzzz-none-000/linux-4.9.279/include/linux/skbuff.h 2021-08-08 06:38:54.000000000 +0000 +++ puma7-atom-6591-750/linux-4.9.279/include/linux/skbuff.h 2023-02-08 11:43:43.000000000 +0000 @@ -10,6 +10,12 @@ * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. */ + /* + 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 @@ -40,6 +46,17 @@ #include #include +#include + +/* 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... * @@ -213,6 +230,9 @@ * 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 @@ -394,6 +414,81 @@ SKBTX_SCHED_TSTAMP) #define SKBTX_ANY_TSTAMP (SKBTX_HW_TSTAMP | SKBTX_ANY_SW_TSTAMP) +#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 * lower device, the skb last reference should be 0 when calling this. @@ -423,6 +518,11 @@ u32 tskey; __be32 ip6_frag_id; +#ifdef CONFIG_PUMA_LITEPATH + __u8 pid:6, + dir:1, + pool_skb:1; +#endif /* * Warning : all fields before dataref are cleared in __alloc_skb() */ @@ -646,6 +746,12 @@ struct rb_node rbnode; /* used in netem, ip4 defrag, and tcp stack */ }; + /* used by directconnect peripherals to store session info */ +#if IS_ENABLED(CONFIG_DIRECTCONNECT_DP_API) + __u32 DW0, DW1, DW2, DW3; +#endif + + union { struct sock *sk; int ip_defrag_offset; @@ -669,6 +775,11 @@ #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) struct nf_conntrack *nfct; #endif +#if IS_ENABLED(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 #if IS_ENABLED(CONFIG_BRIDGE_NETFILTER) struct nf_bridge_info *nf_bridge; #endif @@ -764,6 +875,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; @@ -796,21 +912,76 @@ __u16 transport_header; __u16 network_header; __u16 mac_header; - /* 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) + #ifdef CONFIG_NETFILTER + #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; atomic_t users; }; #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 */ @@ -914,6 +1085,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); @@ -1610,6 +1786,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 newsk->next = next; newsk->prev = prev; next->prev = prev->next = newsk; @@ -1764,6 +1943,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; @@ -2031,6 +2213,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; } @@ -2314,9 +2499,12 @@ * to reduce average number of cache lines per packet. * get_rps_cpus() 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); @@ -2390,6 +2578,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; @@ -3244,6 +3435,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) @@ -3592,6 +3786,29 @@ atomic_inc(&nfct->use); } #endif + +#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 + #if IS_ENABLED(CONFIG_BRIDGE_NETFILTER) static inline void nf_bridge_put(struct nf_bridge_info *nf_bridge) { @@ -3604,7 +3821,8 @@ atomic_inc(&nf_bridge->use); } #endif /* CONFIG_BRIDGE_NETFILTER */ -static inline void nf_reset(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); @@ -3616,6 +3834,14 @@ #endif } +static inline void nf_reset(struct sk_buff *skb) +{ + nf_reset_no_generic_ct(skb); +#if IS_ENABLED(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) @@ -3631,8 +3857,9 @@ } /* 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) +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) dst->nfct = src->nfct; @@ -3650,7 +3877,17 @@ #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); +#if IS_ENABLED(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(dst->nfct); @@ -3658,7 +3895,15 @@ #if IS_ENABLED(CONFIG_BRIDGE_NETFILTER) nf_bridge_put(dst->nf_bridge); #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); +#if IS_ENABLED(CONFIG_AVM_PA_GENERIC_CT) + generic_ct_copy(dst, src); +#endif } #ifdef CONFIG_NETWORK_SECMARK @@ -3934,5 +4179,16 @@ return csum_partial(l4_hdr, csum_start - l4_hdr, partial); } +#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 */