OSDN Git Service

mediatek: add missing Kconfig
[immortalwrt/immortalwrt.git] / target / linux / generic / hack-5.10 / 953-net-patch-linux-kernel-to-support-shortcut-fe.patch
1 --- a/include/linux/if_bridge.h
2 +++ b/include/linux/if_bridge.h
3 @@ -62,6 +62,9 @@ struct br_ip_list {
4  
5  extern void brioctl_set(int (*ioctl_hook)(struct net *, unsigned int, void __user *));
6  
7 +extern void br_dev_update_stats(struct net_device *dev,
8 +                               struct rtnl_link_stats64 *nlstats);
9 +
10  #if IS_ENABLED(CONFIG_BRIDGE) && IS_ENABLED(CONFIG_BRIDGE_IGMP_SNOOPING)
11  int br_multicast_list_adjacent(struct net_device *dev,
12                                struct list_head *br_ip_list);
13 --- a/include/linux/skbuff.h
14 +++ b/include/linux/skbuff.h
15 @@ -860,6 +860,10 @@ struct sk_buff {
16  #endif
17         __u8                    gro_skip:1;
18  
19 +#ifdef CONFIG_SHORTCUT_FE
20 +       __u8                    fast_forwarded:1;
21 +#endif
22 +
23  #ifdef CONFIG_NET_SCHED
24         __u16                   tc_index;       /* traffic control index */
25  #endif
26 --- a/include/linux/timer.h
27 +++ b/include/linux/timer.h
28 @@ -18,6 +18,10 @@ struct timer_list {
29         void                    (*function)(struct timer_list *);
30         u32                     flags;
31  
32 +#ifdef CONFIG_SHORTCUT_FE
33 +       unsigned long           cust_data;
34 +#endif
35 +
36  #ifdef CONFIG_LOCKDEP
37         struct lockdep_map      lockdep_map;
38  #endif
39 --- a/include/net/netfilter/nf_conntrack_ecache.h
40 +++ b/include/net/netfilter/nf_conntrack_ecache.h
41 @@ -75,6 +75,8 @@ struct nf_ct_event {
42  #ifdef CONFIG_NF_CONNTRACK_CHAIN_EVENTS
43  extern int nf_conntrack_register_notifier(struct net *net, struct notifier_block *nb);
44  extern int nf_conntrack_unregister_notifier(struct net *net, struct notifier_block *nb);
45 +extern int nf_conntrack_register_chain_notifier(struct net *net, struct notifier_block *nb);
46 +extern int nf_conntrack_unregister_chain_notifier(struct net *net, struct notifier_block *nb);
47  #else
48  struct nf_ct_event_notifier {
49         int (*fcn)(unsigned int events, struct nf_ct_event *item);
50 --- a/net/bridge/br_if.c
51 +++ b/net/bridge/br_if.c
52 @@ -779,6 +779,28 @@ void br_port_flags_change(struct net_bri
53                 br_recalculate_neigh_suppress_enabled(br);
54  }
55  
56 +void br_dev_update_stats(struct net_device *dev,
57 +                        struct rtnl_link_stats64 *nlstats)
58 +{
59 +       struct net_bridge *br;
60 +       struct pcpu_sw_netstats *stats;
61 +
62 +       /* Is this a bridge? */
63 +       if (!(dev->priv_flags & IFF_EBRIDGE))
64 +               return;
65 +
66 +       br = netdev_priv(dev);
67 +       stats = this_cpu_ptr(br->stats);
68 +
69 +       u64_stats_update_begin(&stats->syncp);
70 +       stats->rx_packets += nlstats->rx_packets;
71 +       stats->rx_bytes += nlstats->rx_bytes;
72 +       stats->tx_packets += nlstats->tx_packets;
73 +       stats->tx_bytes += nlstats->tx_bytes;
74 +       u64_stats_update_end(&stats->syncp);
75 +}
76 +EXPORT_SYMBOL_GPL(br_dev_update_stats);
77 +
78  bool br_port_flag_is_set(const struct net_device *dev, unsigned long flag)
79  {
80         struct net_bridge_port *p;
81 --- a/net/core/dev.c
82 +++ b/net/core/dev.c
83 @@ -3643,8 +3643,17 @@ static int xmit_one(struct sk_buff *skb,
84         unsigned int len;
85         int rc;
86  
87 +#ifdef CONFIG_SHORTCUT_FE
88 +       /* If this skb has been fast forwarded then we don't want it to
89 +        * go to any taps (by definition we're trying to bypass them).
90 +        */
91 +       if (!skb->fast_forwarded) {
92 +#endif
93         if (dev_nit_active(dev))
94                 dev_queue_xmit_nit(skb, dev);
95 +#ifdef CONFIG_SHORTCUT_FE
96 +       }
97 +#endif
98  
99  #ifdef CONFIG_ETHERNET_PACKET_MANGLE
100         if (dev->eth_mangle_tx && !(skb = dev->eth_mangle_tx(dev, skb)))
101 @@ -5195,6 +5204,11 @@ void netdev_rx_handler_unregister(struct
102  }
103  EXPORT_SYMBOL_GPL(netdev_rx_handler_unregister);
104  
105 +#ifdef CONFIG_SHORTCUT_FE
106 +int (*athrs_fast_nat_recv)(struct sk_buff *skb) __rcu __read_mostly;
107 +EXPORT_SYMBOL_GPL(athrs_fast_nat_recv);
108 +#endif
109 +
110  /*
111   * Limit the use of PFMEMALLOC reserves to those protocols that implement
112   * the special handling of PFMEMALLOC skbs.
113 @@ -5243,6 +5257,10 @@ static int __netif_receive_skb_core(stru
114         int ret = NET_RX_DROP;
115         __be16 type;
116  
117 +#ifdef CONFIG_SHORTCUT_FE
118 +       int (*fast_recv)(struct sk_buff *skb);
119 +#endif
120 +
121         net_timestamp_check(!netdev_tstamp_prequeue, skb);
122  
123         trace_netif_receive_skb(skb);
124 @@ -5282,6 +5300,16 @@ another_round:
125                         goto out;
126         }
127  
128 +#ifdef CONFIG_SHORTCUT_FE
129 +       fast_recv = rcu_dereference(athrs_fast_nat_recv);
130 +       if (fast_recv) {
131 +               if (fast_recv(skb)) {
132 +                       ret = NET_RX_SUCCESS;
133 +                       goto out;
134 +               }
135 +       }
136 +#endif
137 +
138         if (skb_skip_tc_classify(skb))
139                 goto skip_classify;
140  
141 --- a/net/Kconfig
142 +++ b/net/Kconfig
143 @@ -481,3 +481,6 @@ config HAVE_CBPF_JIT
144  # Extended BPF JIT (eBPF)
145  config HAVE_EBPF_JIT
146         bool
147 +
148 +config SHORTCUT_FE
149 +       bool "Enables kernel network stack path for Shortcut  Forwarding Engine
150 --- a/net/netfilter/nf_conntrack_proto_tcp.c
151 +++ b/net/netfilter/nf_conntrack_proto_tcp.c
152 @@ -34,11 +34,19 @@
153  /* Do not check the TCP window for incoming packets  */
154  static int nf_ct_tcp_no_window_check __read_mostly = 1;
155  
156 +#ifdef CONFIG_SHORTCUT_FE
157 +EXPORT_SYMBOL_GPL(nf_ct_tcp_no_window_check);
158 +#endif
159 +
160  /* "Be conservative in what you do,
161      be liberal in what you accept from others."
162      If it's non-zero, we mark only out of window RST segments as INVALID. */
163  static int nf_ct_tcp_be_liberal __read_mostly = 0;
164  
165 +#ifdef CONFIG_SHORTCUT_FE
166 +EXPORT_SYMBOL_GPL(nf_ct_tcp_be_liberal);
167 +#endif
168 +
169  /* If it is set to zero, we disable picking up already established
170     connections. */
171  static int nf_ct_tcp_loose __read_mostly = 1;
172 --- a/net/netfilter/nf_conntrack_ecache.c
173 +++ b/net/netfilter/nf_conntrack_ecache.c
174 @@ -171,7 +171,11 @@ int nf_conntrack_eventmask_report(unsign
175  
176         rcu_read_lock();
177         notify = rcu_dereference(net->ct.nf_conntrack_event_cb);
178 +#ifdef CONFIG_NF_CONNTRACK_CHAIN_EVENTS
179 +       if (!notify && !rcu_dereference_raw(net->ct.nf_conntrack_chain.head))
180 +#else
181         if (!notify)
182 +#endif
183                 goto out_unlock;
184  
185         e = nf_ct_ecache_find(ct);
186 @@ -190,7 +194,14 @@ int nf_conntrack_eventmask_report(unsign
187                 if (!((eventmask | missed) & e->ctmask))
188                         goto out_unlock;
189  
190 +#ifdef CONFIG_NF_CONNTRACK_CHAIN_EVENTS
191 +               ret = atomic_notifier_call_chain(&net->ct.nf_conntrack_chain,
192 +                       eventmask | missed, &item);
193 +               if (notify)
194 +                       ret = notify->fcn(eventmask | missed, &item);
195 +#else
196                 ret = notify->fcn(eventmask | missed, &item);
197 +#endif
198                 if (unlikely(ret < 0 || missed)) {
199                         spin_lock_bh(&ct->lock);
200                         if (ret < 0) {
201 @@ -272,7 +283,11 @@ void nf_ct_deliver_cached_events(struct
202  
203         rcu_read_lock();
204         notify = rcu_dereference(net->ct.nf_conntrack_event_cb);
205 +#ifdef CONFIG_NF_CONNTRACK_CHAIN_EVENTS
206 +       if ((notify == NULL) && !rcu_dereference_raw(net->ct.nf_conntrack_chain.head))
207 +#else
208         if (notify == NULL)
209 +#endif
210                 goto out_unlock;
211  
212         if (!nf_ct_is_confirmed(ct) || nf_ct_is_dying(ct))
213 @@ -296,7 +311,15 @@ void nf_ct_deliver_cached_events(struct
214         item.portid = 0;
215         item.report = 0;
216  
217 +#ifdef CONFIG_NF_CONNTRACK_CHAIN_EVENTS
218 +       ret = atomic_notifier_call_chain(&net->ct.nf_conntrack_chain,
219 +                       events | missed,
220 +                       &item);
221 +       if (notify != NULL)
222 +               ret = notify->fcn(events | missed, &item);
223 +#else
224         ret = notify->fcn(events | missed, &item);
225 +#endif
226  
227         if (likely(ret == 0 && !missed))
228                 goto out_unlock;
229 @@ -350,6 +373,11 @@ int nf_conntrack_register_notifier(struc
230  {
231          return atomic_notifier_chain_register(&net->ct.nf_conntrack_chain, nb);
232  }
233 +int nf_conntrack_register_chain_notifier(struct net *net, struct notifier_block *nb)
234 +{
235 +       return atomic_notifier_chain_register(&net->ct.nf_conntrack_chain, nb);
236 +}
237 +EXPORT_SYMBOL_GPL(nf_conntrack_register_chain_notifier);
238  #else
239  int nf_conntrack_register_notifier(struct net *net,
240                                    struct nf_ct_event_notifier *new)
241 @@ -379,6 +407,11 @@ int nf_conntrack_unregister_notifier(str
242  {
243         return atomic_notifier_chain_unregister(&net->ct.nf_conntrack_chain, nb);
244  }
245 +int nf_conntrack_unregister_chain_notifier(struct net *net, struct notifier_block *nb)
246 +{
247 +       return atomic_notifier_chain_unregister(&net->ct.nf_conntrack_chain, nb);
248 +}
249 +EXPORT_SYMBOL_GPL(nf_conntrack_unregister_chain_notifier);
250  #else
251  void nf_conntrack_unregister_notifier(struct net *net,
252                                       struct nf_ct_event_notifier *new)