lro: Generic Large Receive Offload for TCP traffic
Subsystems (2)
RFC 1/1 lro: Generic Large Receive Offload for TCP traffic
Generic LRO patch
--- include/linux/inet_lro.h | 154 +++++++++++++ net/ipv4/inet_lro.c | 549 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 703 insertions(+), 0 deletions(-) create mode 100644 include/linux/inet_lro.h create mode 100644 net/ipv4/inet_lro.c
include/linux/inet_lro.h new file +154 -0
@@ -0,0 +1,154 @@ +/* +* linux/include/linux/inet_lro.h +* +* Large Receive Offload (ipv4 / tcp) +* +* (C) Copyright IBM Corp. 2007 +* +* Authors: +* Jan-Bernd Themann <[email protected]> +* Christoph Raisch <[email protected]> +* +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2, or (at your option) +* any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifndef __INET_LRO_H_ +#define __INET_LRO_H_ + +#include <net/ip.h> +#include <net/tcp.h> + +#define LRO_IPV4 1 +#define LRO_TCP 2 + +/* +* LRO descriptor for a tcp session +*/ +struct net_lro_desc { +struct sk_buff *parent; +struct sk_buff *last_skb; +struct skb_frag_struct *next_frag; +struct iphdr *iph; +struct tcphdr *tcph; +struct vlan_group *vgrp; +__wsum data_csum; +u32 tcp_rcv_tsecr; +u32 tcp_rcv_tsval; +u32 tcp_ack; +u32 tcp_next_seq; +u32 skb_tot_frags_len; +u16 ip_tot_len; +u16 tcp_saw_tstamp;/* timestamps enabled */ +u16 tcp_window; +u16 vlan_tag; +int pkt_aggr_cnt;/* counts aggregated packets */ +int vlan_packet; +int active; +}; + +/* +* Large Receive Offload (LRO) Manager +* +* Fields must be set by driver +*/ + +struct net_lro_mgr { +struct net_device *dev;/* Required for receive in page mode */ +u32 ip_summed;/* Options to be set in generated SKB in page mode */ +int max_desc;/* Max number of LRO descriptors */ +int max_aggr;/* Max number of LRO packets to be aggregated */ + +struct net_lro_desc *lro_arr;/* Array of LRO descriptors */ + +/* +* Optimized driver functions +* +* get_skb_header: returns tcp and ip header for packet in SKB +*/ +int (*get_skb_header)(struct sk_buff *skb,void **ip_hdr, +void **tcpudp_hdr,u64 *hdr_flags,void *priv); + +/* +* get_frag_header: returns mac, tcp and ip header for packet in SKB +* +* @hdr_flags: Indicate what kind of LRO has to be done +* (IPv4/IPv6/TCP/UDP) +*/ +int (*get_frag_header)(struct skb_frag_struct *frag,void **mac_hdr, +void **ip_hdr,void **tcpudp_hdr,u64 *hdr_flags, +void *priv); +}; + +/* +* Processes a SKB +* +* @lro_mgr: LRO manager to use +* @skb: SKB to aggregate +* @priv: Private data that may be used by driver functions +* (for example get_tcp_ip_hdr) +*/ + +void lro_receive_skb (struct net_lro_mgr *lro_mgr, +struct sk_buff *skb, +void *priv); + +/* +* Processes a SKB with VLAN HW acceleration support +*/ + +void lro_vlan_hwaccel_receive_skb (struct net_lro_mgr *lro_mgr, +struct sk_buff *skb, +struct vlan_group *vgrp, +u16 vlan_tag, +void *priv); + +/* +* Processes a fragment list +* +* This functions aggregate fragments and generate SKBs do pass +* the packets to the stack. +* +* @lro_mgr: LRO manager to use +* @frags: Fragment to be processed. Must contain entire header in first +* element. +* @len: Length of received data +* @true_size: Actual size of memory the fragment is consuming +* @priv: Private data that may be used by driver functions +* (for example get_tcp_ip_hdr) +*/ + +void lro_receive_frags (struct net_lro_mgr *lro_mgr, +struct skb_frag_struct *frags, +int len,int true_size,void *priv); + +void lro_vlan_hwaccel_receive_frags (struct net_lro_mgr *lro_mgr, +struct skb_frag_struct *frags, +int len, +int true_size, +struct vlan_group *vgrp, +u16 vlan_tag, +void *priv); + +/* +* Forward all aggregated SKBs held by lro_mgr to network stack +*/ + +void lro_flush_all (struct net_lro_mgr *lro_mgr); + +void lro_flush_pkt (struct net_lro_mgr *lro_mgr, +struct iphdr *iph,struct tcphdr *tcph); + +#endif
net/ipv4/inet_lro.c new file +549 -0
549 lines not on this page · raw message
Signature · 1 line
1.5.2
David Miller
maintainerFrom: Jan-Bernd Themann <[email protected]>
Date: Fri, 20 Jul 2007 17:41:48 +0200
Quoted 3 lines
Generic LRO patch
Signed-off-by Jan-Bernd Themann <[email protected]>
I have no general objections to this patch.
However I'd like to see at least one or two uses of these APIs before we put it in, and it sounds as if we have at least two pending and in the works if not ready already, so that shouldn't be an issue.
Thanks.
Hi Jan-Bernd.
Quoted 3 lines · Jan-Bernd Themann
Generic LRO patch
Signed-off-by Jan-Bernd Themann <[email protected]>
Besides couple trivial codyng/formatting nits I did not found any problematic places after review. Details below.
Thanks.
net/ipv4/inet_lro.c line 41
Quoted 2 lines
net/ipv4/inet_lro.c new file +2
-0+#define TCP_PAYLOAD_LENGTH (iph, tcph) \ +(ntohs(iph->tot_len) - IP_HDR_LEN(iph) - TCP_HDR_LEN(tcph))
A tab?
Quoted 16 lines
net/ipv4/inet_lro.c new file +16
-0+static void lro_add_common (struct net_lro_desc *lro_desc,struct iphdr *iph, +struct tcphdr *tcph,int tcp_data_len) +{ +struct sk_buff *parent = lro_desc->parent; +u32 *topt; + + lro_desc->pkt_aggr_cnt++; + lro_desc->ip_tot_len += tcp_data_len; + lro_desc->tcp_next_seq += tcp_data_len; + lro_desc->tcp_window = tcph->window; + lro_desc->tcp_ack = tcph->ack_seq; + +/* don't update tcp_rcv_tsval, would not work with PAWS */ +if (lro_desc->tcp_saw_tstamp) { + topt = (u32 *) (tcph +1 ); + lro_desc->tcp_rcv_tsecr = *(topt +2 );
net/ipv4/inet_lro.c line 212
Quoted 10 lines
net/ipv4/inet_lro.c new file +10
-0+ } + + parent->len += tcp_data_len; + parent->data_len += tcp_data_len; + + lro_desc->data_csum =csum_add (lro_desc->data_csum, +lro_tcp_data_csum (iph, tcph, + tcp_data_len)); +return ; +}
return from void? And in other places too.
net/ipv4/inet_lro.c line 334
Quoted 7 lines
net/ipv4/inet_lro.c new file +7
-0+int __lro_proc_skb (struct net_lro_mgr *lro_mgr,struct sk_buff *skb, +struct vlan_group *vgrp,u16 vlan_tag,void *priv) +{ +struct net_lro_desc *lro_desc; +struct iphdr *iph; +struct tcphdr *tcph; +u64 flags;
Broken tab and spaces.
net/ipv4/inet_lro.c line 406
Quoted 9 lines
net/ipv4/inet_lro.c new file +9
-0+struct sk_buff *lro_gen_skb (struct net_lro_mgr *lro_mgr, +struct skb_frag_struct *frags, +int len,int true_size, +void *mac_hdr, +int hlen) +{ +struct sk_buff *skb; +struct skb_frag_struct *skb_frags; +int data_len = len;
The same.
net/ipv4/inet_lro.c line 413
Quoted 6 lines
net/ipv4/inet_lro.c new file +6
-0+ skb =netdev_alloc_skb (lro_mgr->dev, hlen); +if (!skb) +return NULL ; + + skb->len = len; + skb->data_len = len - hlen;
Here too.
There is number of such places, ommitted others.
Signature · 1 line
Evgeniy Polyakov