inet_lro.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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. u32 tcp_rcv_tsecr;
  51. u32 tcp_rcv_tsval;
  52. u32 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. u16 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. u32 ip_summed; /* Set in non generated SKBs in page mode */
  79. u32 ip_summed_aggr; /* Set in aggregated SKBs: CHECKSUM_UNNECESSARY
  80. * or CHECKSUM_NONE */
  81. int max_desc; /* Max number of LRO descriptors */
  82. int max_aggr; /* Max number of LRO packets to be aggregated */
  83. struct net_lro_desc *lro_arr; /* Array of LRO descriptors */
  84. /*
  85. * Optimized driver functions
  86. *
  87. * get_skb_header: returns tcp and ip header for packet in SKB
  88. */
  89. int (*get_skb_header)(struct sk_buff *skb, void **ip_hdr,
  90. void **tcpudp_hdr, u64 *hdr_flags, void *priv);
  91. /* hdr_flags: */
  92. #define LRO_IPV4 1 /* ip_hdr is IPv4 header */
  93. #define LRO_TCP 2 /* tcpudp_hdr is TCP header */
  94. /*
  95. * get_frag_header: returns mac, tcp and ip header for packet in SKB
  96. *
  97. * @hdr_flags: Indicate what kind of LRO has to be done
  98. * (IPv4/IPv6/TCP/UDP)
  99. */
  100. int (*get_frag_header)(struct skb_frag_struct *frag, void **mac_hdr,
  101. void **ip_hdr, void **tcpudp_hdr, u64 *hdr_flags,
  102. void *priv);
  103. };
  104. /*
  105. * Processes a SKB
  106. *
  107. * @lro_mgr: LRO manager to use
  108. * @skb: SKB to aggregate
  109. * @priv: Private data that may be used by driver functions
  110. * (for example get_tcp_ip_hdr)
  111. */
  112. void lro_receive_skb(struct net_lro_mgr *lro_mgr,
  113. struct sk_buff *skb,
  114. void *priv);
  115. /*
  116. * Processes a SKB with VLAN HW acceleration support
  117. */
  118. void lro_vlan_hwaccel_receive_skb(struct net_lro_mgr *lro_mgr,
  119. struct sk_buff *skb,
  120. struct vlan_group *vgrp,
  121. u16 vlan_tag,
  122. void *priv);
  123. /*
  124. * Processes a fragment list
  125. *
  126. * This functions aggregate fragments and generate SKBs do pass
  127. * the packets to the stack.
  128. *
  129. * @lro_mgr: LRO manager to use
  130. * @frags: Fragment to be processed. Must contain entire header in first
  131. * element.
  132. * @len: Length of received data
  133. * @true_size: Actual size of memory the fragment is consuming
  134. * @priv: Private data that may be used by driver functions
  135. * (for example get_tcp_ip_hdr)
  136. */
  137. void lro_receive_frags(struct net_lro_mgr *lro_mgr,
  138. struct skb_frag_struct *frags,
  139. int len, int true_size, void *priv, __wsum sum);
  140. void lro_vlan_hwaccel_receive_frags(struct net_lro_mgr *lro_mgr,
  141. struct skb_frag_struct *frags,
  142. int len, int true_size,
  143. struct vlan_group *vgrp,
  144. u16 vlan_tag,
  145. void *priv, __wsum sum);
  146. /*
  147. * Forward all aggregated SKBs held by lro_mgr to network stack
  148. */
  149. void lro_flush_all(struct net_lro_mgr *lro_mgr);
  150. void lro_flush_pkt(struct net_lro_mgr *lro_mgr,
  151. struct iphdr *iph, struct tcphdr *tcph);
  152. #endif