--- zzzz-none-000/linux-5.15.111/net/ipv4/ip_input.c 2023-05-11 14:00:40.000000000 +0000 +++ puma7-atom-6670-761/linux-5.15.111/net/ipv4/ip_input.c 2024-02-07 10:23:30.000000000 +0000 @@ -105,6 +105,10 @@ * output should probably do its own fragmentation at the UDP/RAW layer. TCP shouldn't cause * fragmentation anyway. */ + /* + * Includes Intel Corporation's changes/modifications dated: 2018. + * Changed/modified portions - Copyright 2018, Intel Corporation. + */ #define pr_fmt(fmt) "IPv4: " fmt @@ -142,6 +146,12 @@ #include #include +#include + +#ifdef CONFIG_TI_PACKET_PROCESSOR +#include +#endif + /* * Process Router Attention IP option (RFC 2113) */ @@ -223,7 +233,7 @@ } } -static int ip_local_deliver_finish(struct net *net, struct sock *sk, struct sk_buff *skb) +int ip_local_deliver_finish(struct net *net, struct sock *sk, struct sk_buff *skb) { __skb_pull(skb, skb_network_header_len(skb)); @@ -233,6 +243,7 @@ return 0; } +EXPORT_SYMBOL(ip_local_deliver_finish); /* * Deliver IP Packets to the higher protocol layers. @@ -253,7 +264,6 @@ net, NULL, skb, skb->dev, NULL, ip_local_deliver_finish); } -EXPORT_SYMBOL(ip_local_deliver); static inline bool ip_rcv_options(struct sk_buff *skb, struct net_device *dev) { @@ -419,6 +429,11 @@ return NET_RX_SUCCESS; drop: + +#if defined(CONFIG_APPCPU_GW_PP_HANDLE) || defined(CONFIG_TI_PACKET_PROCESSOR) + /* Create a NULL PP device, to drop all dropped packets before they reach the host */ + ti_hil_pp_event (TI_IP_DISCARD_PKT_IPV4, (void *)skb); +#endif kfree_skb_reason(skb, drop_reason); return NET_RX_DROP; @@ -669,3 +684,43 @@ if (!list_empty(&sublist)) ip_sublist_rcv(&sublist, curr_dev, curr_net); } + +static void ip_avm_pa_transmit(void *arg, struct sk_buff *skb) +{ + /* We can safely pass NULL as sk parameter, it is just required + * to be a valid netfilter hook. The initiator, ip_local_deliver() + * passes a NULL sock because it doesn't even know the socket yet. + */ + ip_local_deliver_finish((struct net *) arg, NULL, skb); +} + +static void __init ip_avm_pa_register(void) +{ + struct avm_pa_dev_info *ip_dev = AVM_PA_NET_IP_DEVINFO(&init_net); + struct avm_pa_pid_cfg cfg = {0}; + struct avm_pa_pid_ecfg ecfg = { 0 }; + + if (!ip_dev) + return; + + strlcpy(cfg.name, "ipv4", sizeof(cfg.name)); + cfg.framing = avm_pa_framing_ipdev; + cfg.default_mtu = 0xffff; + cfg.tx_func = ip_avm_pa_transmit; + cfg.tx_arg = &init_net; + + if (avm_pa_dev_pid_register(ip_dev, &cfg) < 0) { + pr_err("failed to register avm_pa pid %s\n", cfg.name); + return; + } + + ecfg.version = AVM_PA_PID_ECFG_VERSION; + ecfg.cb_start = 0; + ecfg.cb_len = sizeof(struct inet_skb_parm); + avm_pa_pid_set_ecfg(ip_dev->pid_handle, &ecfg); +} + +void __init ip_input_init(void) +{ + ip_avm_pa_register(); +}