inet_lro.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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. __wsum data_csum;
  49. __be32 tcp_rcv_tsecr;
  50. __be32 tcp_rcv_tsval;
  51. __be32 tcp_ack;
  52. u32 tcp_next_seq;
  53. u32 skb_tot_frags_len;
  54. u16 ip_tot_len;
  55. u16 tcp_saw_tstamp; /* timestamps enabled */
  56. __be16 tcp_window;
  57. int pkt_aggr_cnt; /* counts aggregated packets */
  58. int vlan_packet;
  59. int mss;
  60. int active;
  61. };
  62. /*
  63. * Large Receive Offload (LRO) Manager
  64. *
  65. * Fields must be set by driver
  66. */
  67. struct net_lro_mgr {
  68. struct net_device *dev;
  69. struct net_lro_stats stats;
  70. /* LRO features */
  71. unsigned long features;
  72. #define LRO_F_NAPI 1 /* Pass packets to stack via NAPI */
  73. #define LRO_F_EXTRACT_VLAN_ID 2 /* Set flag if VLAN IDs are extracted
  74. from received packets and eth protocol
  75. is still ETH_P_8021Q */
  76. /*
  77. * Set for generated SKBs that are not added to
  78. * the frag list in fragmented mode
  79. */
  80. u32 ip_summed;
  81. u32 ip_summed_aggr; /* Set in aggregated SKBs: CHECKSUM_UNNECESSARY
  82. * or CHECKSUM_NONE */
  83. int max_desc; /* Max number of LRO descriptors */
  84. int max_aggr; /* Max number of LRO packets to be aggregated */
  85. int frag_align_pad; /* Padding required to properly align layer 3
  86. * headers in generated skb when using frags */
  87. struct net_lro_desc *lro_arr; /* Array of LRO descriptors */
  88. /*
  89. * Optimized driver functions
  90. *
  91. * get_skb_header: returns tcp and ip header for packet in SKB
  92. */
  93. int (*get_skb_header)(struct sk_buff *skb, void **ip_hdr,
  94. void **tcpudp_hdr, u64 *hdr_flags, void *priv);
  95. /* hdr_flags: */
  96. #define LRO_IPV4 1 /* ip_hdr is IPv4 header */
  97. #define LRO_TCP 2 /* tcpudp_hdr is TCP header */
  98. /*
  99. * get_frag_header: returns mac, tcp and ip header for packet in SKB
  100. *
  101. * @hdr_flags: Indicate what kind of LRO has to be done
  102. * (IPv4/IPv6/TCP/UDP)
  103. */
  104. int (*get_frag_header)(struct skb_frag_struct *frag, void **mac_hdr,
  105. void **ip_hdr, void **tcpudp_hdr, u64 *hdr_flags,
  106. void *priv);
  107. };
  108. /*
  109. * Processes a SKB
  110. *
  111. * @lro_mgr: LRO manager to use
  112. * @skb: SKB to aggregate
  113. * @priv: Private data that may be used by driver functions
  114. * (for example get_tcp_ip_hdr)
  115. */
  116. void lro_receive_skb(struct net_lro_mgr *lro_mgr,
  117. struct sk_buff *skb,
  118. void *priv);
  119. /*
  120. * Forward all aggregated SKBs held by lro_mgr to network stack
  121. */
  122. void lro_flush_all(struct net_lro_mgr *lro_mgr);
  123. #endif