Deleted Added
sdiff udiff text old ( 284961 ) new ( 294327 )
full compact
1/*-
2 * Copyright (c) 2007, Myricom Inc.
3 * Copyright (c) 2008, Intel Corporation.
4 * Copyright (c) 2012 The FreeBSD Foundation
5 * All rights reserved.
6 *
7 * Portions of this software were developed by Bjoern Zeeb
8 * under sponsorship from the FreeBSD Foundation.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:

--- 12 unchanged lines hidden (view full) ---

25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 */
31
32#include <sys/cdefs.h>
33__FBSDID("$FreeBSD: head/sys/netinet/tcp_lro.c 284961 2015-06-30 17:19:58Z np $");
34
35#include "opt_inet.h"
36#include "opt_inet6.h"
37
38#include <sys/param.h>
39#include <sys/systm.h>
40#include <sys/mbuf.h>
41#include <sys/kernel.h>

--- 11 unchanged lines hidden (view full) ---

53#include <netinet/ip_var.h>
54#include <netinet/tcp.h>
55#include <netinet/tcp_lro.h>
56
57#include <netinet6/ip6_var.h>
58
59#include <machine/in_cksum.h>
60
61#ifndef LRO_ENTRIES
62#define LRO_ENTRIES 8 /* # of LRO entries per RX queue. */
63#endif
64
65#define TCP_LRO_UPDATE_CSUM 1
66#ifndef TCP_LRO_UPDATE_CSUM
67#define TCP_LRO_INVALID_CSUM 0x0000
68#endif
69
70int
71tcp_lro_init(struct lro_ctrl *lc)
72{
73 struct lro_entry *le;
74 int error, i;
75
76 lc->lro_bad_csum = 0;
77 lc->lro_queued = 0;
78 lc->lro_flushed = 0;
79 lc->lro_cnt = 0;
80 SLIST_INIT(&lc->lro_free);
81 SLIST_INIT(&lc->lro_active);
82
83 error = 0;
84 for (i = 0; i < LRO_ENTRIES; i++) {
85 le = (struct lro_entry *)malloc(sizeof(*le), M_DEVBUF,
86 M_NOWAIT | M_ZERO);
87 if (le == NULL) {
88 if (i == 0)
89 error = ENOMEM;
90 break;
91 }
92 lc->lro_cnt = i + 1;
93 SLIST_INSERT_HEAD(&lc->lro_free, le, next);
94 }
95
96 return (error);
97}
98
99void
100tcp_lro_free(struct lro_ctrl *lc)
101{
102 struct lro_entry *le;
103
104 while (!SLIST_EMPTY(&lc->lro_free)) {
105 le = SLIST_FIRST(&lc->lro_free);
106 SLIST_REMOVE_HEAD(&lc->lro_free, next);
107 free(le, M_DEVBUF);
108 }
109}
110
111#ifdef TCP_LRO_UPDATE_CSUM
112static uint16_t
113tcp_lro_csum_th(struct tcphdr *th)
114{
115 uint32_t ch;
116 uint16_t *p, l;

--- 183 unchanged lines hidden (view full) ---

300
301 (*lc->ifp->if_input)(lc->ifp, le->m_head);
302 lc->lro_queued += le->append_cnt + 1;
303 lc->lro_flushed++;
304 bzero(le, sizeof(*le));
305 SLIST_INSERT_HEAD(&lc->lro_free, le, next);
306}
307
308#ifdef INET6
309static int
310tcp_lro_rx_ipv6(struct lro_ctrl *lc, struct mbuf *m, struct ip6_hdr *ip6,
311 struct tcphdr **th)
312{
313
314 /* XXX-BZ we should check the flow-label. */
315

--- 312 unchanged lines hidden (view full) ---

628#endif
629
630 le->m_head = m;
631 le->m_tail = m_last(m);
632
633 return (0);
634}
635
636/* end */