inet_lro.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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. #ifndef __INET_LRO_H_
  28. #define __INET_LRO_H_
  29. #include <net/ip.h>
  30. #include <net/tcp.h>
  31. /*
  32. * LRO statistics
  33. */
  34. struct net_lro_stats {
  35. unsigned long aggregated;
  36. unsigned long flushed;
  37. unsigned long no_desc;
  38. };
  39. /*
  40. * LRO descriptor for a tcp session
  41. */
  42. struct net_lro_desc {
  43. struct sk_buff *parent;
  44. struct sk_buff *last_skb;
  45. struct skb_frag_struct *next_frag;
  46. struct iphdr *iph;
  47. struct tcphdr *tcph;
  48. struct vlan_group *vgrp;
  49. __wsum data_csum;
  50. __be32 tcp_rcv_tsecr;
  51. __be32 tcp_rcv_tsval;
  52. __be32 tcp_ack;
  53. u32 tcp_next_seq;
  54. u32 skb_tot_frags_len;
  55. u16 ip_tot_len;
  56. u16 tcp_saw_tstamp; /* timestamps enabled */
  57. __be16 tcp_window;
  58. u16 vlan_tag;
  59. int pkt_aggr_cnt; /* counts aggregated packets */
  60. int vlan_packet;
  61. int mss;
  62. int active;
  63. };
  64. /*
  65. * Large Receive Offload (LRO) Manager
  66. *
  67. * Fields must be set by driver
  68. */
  69. struct net_lro_mgr {
  70. struct net_device *dev;
  71. struct net_lro_stats stats;
  72. /* LRO features */
  73. unsigned long features;
  74. #define LRO_F_NAPI 1 /* Pass packets to stack via NAPI */
  75. #define LRO_F_EXTRACT_VLAN_ID 2 /* Set flag if VLAN IDs are extracted
  76. from received packets and eth protocol
  77. is still ETH_P_8021Q */
  78. /*
  79. * Set for generated SKBs that are not added to
  80. * the frag list in fragmented mode
  81. */
  82. u32 ip_summed;
  83. u32 ip_summed_aggr; /* Set in aggregated SKBs: CHECKSUM_UNNECESSARY
  84. * or CHECKSUM_NONE */
  85. int max_desc; /* Max number of LRO descriptors */
  86. int max_aggr; /* Max number of LRO packets to be aggregated */
  87. int frag_align_pad; /* Padding required to properly align layer 3
  88. * headers in generated skb when using frags */
  89. struct net_lro_desc *lro_arr; /* Array of LRO descriptors */
  90. /*
  91. * Optimized driver functions
  92. *
  93. * get_skb_header: returns tcp and ip header for packet in SKB
  94. */
  95. int (*get_skb_header)(struct sk_buff *skb, void **ip_hdr,
  96. void **tcpudp_hdr, u64 *hdr_flags, void *priv);
  97. /* hdr_flags: */
  98. #define LRO_IPV4 1 /* ip_hdr is IPv4 header */
  99. #define LRO_TCP 2 /* tcpudp_hdr is TCP header */
  100. /*
  101. * get_frag_header: returns mac, tcp and ip header for packet in SKB
  102. *
  103. * @hdr_flags: Indicate what kind of LRO has to be done
  104. * (IPv4/IPv6/TCP/UDP)
  105. */
  106. int (*get_frag_header)(struct skb_frag_struct *frag, void **mac_hdr,
  107. void **ip_hdr, void **tcpudp_hdr, u64 *hdr_flags,
  108. void *priv);
  109. };
  110. /*
  111. * Processes a SKB
  112. *
  113. * @lro_mgr: LRO manager to use
  114. * @skb: SKB to aggregate
  115. * @priv: Private data that may be used by driver functions
  116. * (for example get_tcp_ip_hdr)
  117. */
  118. void lro_receive_skb(struct net_lro_mgr *lro_mgr,
  119. struct sk_buff *skb,
  120. void *priv);
  121. /*
  122. * Processes a SKB with VLAN HW acceleration support
  123. */
  124. void lro_vlan_hwaccel_receive_skb(struct net_lro_mgr *lro_mgr,
  125. struct sk_buff *skb,
  126. struct vlan_group *vgrp,
  127. u16 vlan_tag,
  128. void *priv);
  129. /*
  130. * Processes a fragment list
  131. *
  132. * This functions aggregate fragments and generate SKBs do pass
  133. * the packets to the stack.
  134. *
  135. * @lro_mgr: LRO manager to use
  136. * @frags: Fragment to be processed. Must contain entire header in first
  137. * element.
  138. * @len: Length of received data
  139. * @true_size: Actual size of memory the fragment is consuming
  140. * @priv: Private data that may be used by driver functions
  141. * (for example get_tcp_ip_hdr)
  142. */
  143. void lro_receive_frags(struct net_lro_mgr *lro_mgr,
  144. struct skb_frag_struct *frags,
  145. int len, int true_size, void *priv, __wsum sum);
  146. void lro_vlan_hwaccel_receive_frags(struct net_lro_mgr *lro_mgr,
  147. struct skb_frag_struct *frags,
  148. int len, int true_size,
  149. struct vlan_group *vgrp,
  150. u16 vlan_tag,
  151. void *priv, __wsum sum);
  152. /*
  153. * Forward all aggregated SKBs held by lro_mgr to network stack
  154. */
  155. void lro_flush_all(struct net_lro_mgr *lro_mgr);
  156. void lro_flush_pkt(struct net_lro_mgr *lro_mgr,
  157. struct iphdr *iph, struct tcphdr *tcph);
  158. #endif