Jan-Bernd Themann | 71c87e0 | 2007-08-08 22:38:05 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/include/linux/inet_lro.h |
| 3 | * |
| 4 | * Large Receive Offload (ipv4 / tcp) |
| 5 | * |
| 6 | * (C) Copyright IBM Corp. 2007 |
| 7 | * |
| 8 | * Authors: |
| 9 | * Jan-Bernd Themann <themann@de.ibm.com> |
| 10 | * Christoph Raisch <raisch@de.ibm.com> |
| 11 | * |
| 12 | * |
| 13 | * This program is free software; you can redistribute it and/or modify |
| 14 | * it under the terms of the GNU General Public License as published by |
| 15 | * the Free Software Foundation; either version 2, or (at your option) |
| 16 | * any later version. |
| 17 | * |
| 18 | * This program is distributed in the hope that it will be useful, |
| 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 21 | * GNU General Public License for more details. |
| 22 | * |
| 23 | * You should have received a copy of the GNU General Public License |
| 24 | * along with this program; if not, write to the Free Software |
| 25 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 26 | */ |
| 27 | |
| 28 | #ifndef __INET_LRO_H_ |
| 29 | #define __INET_LRO_H_ |
| 30 | |
| 31 | #include <net/ip.h> |
| 32 | #include <net/tcp.h> |
| 33 | |
| 34 | /* |
| 35 | * LRO statistics |
| 36 | */ |
| 37 | |
| 38 | struct net_lro_stats { |
| 39 | unsigned long aggregated; |
| 40 | unsigned long flushed; |
| 41 | unsigned long no_desc; |
| 42 | }; |
| 43 | |
| 44 | /* |
| 45 | * LRO descriptor for a tcp session |
| 46 | */ |
| 47 | struct net_lro_desc { |
| 48 | struct sk_buff *parent; |
| 49 | struct sk_buff *last_skb; |
| 50 | struct skb_frag_struct *next_frag; |
| 51 | struct iphdr *iph; |
| 52 | struct tcphdr *tcph; |
| 53 | struct vlan_group *vgrp; |
| 54 | __wsum data_csum; |
Al Viro | 9df7c98 | 2007-10-14 19:40:59 +0100 | [diff] [blame] | 55 | __be32 tcp_rcv_tsecr; |
| 56 | __be32 tcp_rcv_tsval; |
Al Viro | f53f413 | 2007-10-14 19:41:09 +0100 | [diff] [blame] | 57 | __be32 tcp_ack; |
Jan-Bernd Themann | 71c87e0 | 2007-08-08 22:38:05 -0700 | [diff] [blame] | 58 | u32 tcp_next_seq; |
| 59 | u32 skb_tot_frags_len; |
| 60 | u16 ip_tot_len; |
| 61 | u16 tcp_saw_tstamp; /* timestamps enabled */ |
Al Viro | 9df7c98 | 2007-10-14 19:40:59 +0100 | [diff] [blame] | 62 | __be16 tcp_window; |
Jan-Bernd Themann | 71c87e0 | 2007-08-08 22:38:05 -0700 | [diff] [blame] | 63 | u16 vlan_tag; |
| 64 | int pkt_aggr_cnt; /* counts aggregated packets */ |
| 65 | int vlan_packet; |
| 66 | int mss; |
| 67 | int active; |
| 68 | }; |
| 69 | |
| 70 | /* |
| 71 | * Large Receive Offload (LRO) Manager |
| 72 | * |
| 73 | * Fields must be set by driver |
| 74 | */ |
| 75 | |
| 76 | struct net_lro_mgr { |
| 77 | struct net_device *dev; |
| 78 | struct net_lro_stats stats; |
| 79 | |
| 80 | /* LRO features */ |
| 81 | unsigned long features; |
| 82 | #define LRO_F_NAPI 1 /* Pass packets to stack via NAPI */ |
| 83 | #define LRO_F_EXTRACT_VLAN_ID 2 /* Set flag if VLAN IDs are extracted |
| 84 | from received packets and eth protocol |
| 85 | is still ETH_P_8021Q */ |
| 86 | |
| 87 | u32 ip_summed; /* Set in non generated SKBs in page mode */ |
| 88 | u32 ip_summed_aggr; /* Set in aggregated SKBs: CHECKSUM_UNNECESSARY |
| 89 | * or CHECKSUM_NONE */ |
| 90 | |
| 91 | int max_desc; /* Max number of LRO descriptors */ |
| 92 | int max_aggr; /* Max number of LRO packets to be aggregated */ |
| 93 | |
Andrew Gallatin | 621544e | 2007-12-05 02:31:42 -0800 | [diff] [blame^] | 94 | int frag_align_pad; /* Padding required to properly align layer 3 |
| 95 | * headers in generated skb when using frags */ |
| 96 | |
Jan-Bernd Themann | 71c87e0 | 2007-08-08 22:38:05 -0700 | [diff] [blame] | 97 | struct net_lro_desc *lro_arr; /* Array of LRO descriptors */ |
| 98 | |
| 99 | /* |
| 100 | * Optimized driver functions |
| 101 | * |
| 102 | * get_skb_header: returns tcp and ip header for packet in SKB |
| 103 | */ |
| 104 | int (*get_skb_header)(struct sk_buff *skb, void **ip_hdr, |
| 105 | void **tcpudp_hdr, u64 *hdr_flags, void *priv); |
| 106 | |
| 107 | /* hdr_flags: */ |
| 108 | #define LRO_IPV4 1 /* ip_hdr is IPv4 header */ |
| 109 | #define LRO_TCP 2 /* tcpudp_hdr is TCP header */ |
| 110 | |
| 111 | /* |
| 112 | * get_frag_header: returns mac, tcp and ip header for packet in SKB |
| 113 | * |
| 114 | * @hdr_flags: Indicate what kind of LRO has to be done |
| 115 | * (IPv4/IPv6/TCP/UDP) |
| 116 | */ |
| 117 | int (*get_frag_header)(struct skb_frag_struct *frag, void **mac_hdr, |
| 118 | void **ip_hdr, void **tcpudp_hdr, u64 *hdr_flags, |
| 119 | void *priv); |
| 120 | }; |
| 121 | |
| 122 | /* |
| 123 | * Processes a SKB |
| 124 | * |
| 125 | * @lro_mgr: LRO manager to use |
| 126 | * @skb: SKB to aggregate |
| 127 | * @priv: Private data that may be used by driver functions |
| 128 | * (for example get_tcp_ip_hdr) |
| 129 | */ |
| 130 | |
| 131 | void lro_receive_skb(struct net_lro_mgr *lro_mgr, |
| 132 | struct sk_buff *skb, |
| 133 | void *priv); |
| 134 | |
| 135 | /* |
| 136 | * Processes a SKB with VLAN HW acceleration support |
| 137 | */ |
| 138 | |
| 139 | void lro_vlan_hwaccel_receive_skb(struct net_lro_mgr *lro_mgr, |
| 140 | struct sk_buff *skb, |
| 141 | struct vlan_group *vgrp, |
| 142 | u16 vlan_tag, |
| 143 | void *priv); |
| 144 | |
| 145 | /* |
| 146 | * Processes a fragment list |
| 147 | * |
| 148 | * This functions aggregate fragments and generate SKBs do pass |
| 149 | * the packets to the stack. |
| 150 | * |
| 151 | * @lro_mgr: LRO manager to use |
| 152 | * @frags: Fragment to be processed. Must contain entire header in first |
| 153 | * element. |
| 154 | * @len: Length of received data |
| 155 | * @true_size: Actual size of memory the fragment is consuming |
| 156 | * @priv: Private data that may be used by driver functions |
| 157 | * (for example get_tcp_ip_hdr) |
| 158 | */ |
| 159 | |
| 160 | void lro_receive_frags(struct net_lro_mgr *lro_mgr, |
| 161 | struct skb_frag_struct *frags, |
| 162 | int len, int true_size, void *priv, __wsum sum); |
| 163 | |
| 164 | void lro_vlan_hwaccel_receive_frags(struct net_lro_mgr *lro_mgr, |
| 165 | struct skb_frag_struct *frags, |
| 166 | int len, int true_size, |
| 167 | struct vlan_group *vgrp, |
| 168 | u16 vlan_tag, |
| 169 | void *priv, __wsum sum); |
| 170 | |
| 171 | /* |
| 172 | * Forward all aggregated SKBs held by lro_mgr to network stack |
| 173 | */ |
| 174 | |
| 175 | void lro_flush_all(struct net_lro_mgr *lro_mgr); |
| 176 | |
| 177 | void lro_flush_pkt(struct net_lro_mgr *lro_mgr, |
| 178 | struct iphdr *iph, struct tcphdr *tcph); |
| 179 | |
| 180 | #endif |