-
Notifications
You must be signed in to change notification settings - Fork 144
/
Copy pathtcp_lro.h
81 lines (69 loc) · 2.95 KB
/
tcp_lro.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
* Copyright (c) 2011 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* compliance with the License. The rights granted to you under the License
* may not be used to create, or enable the creation or redistribution of,
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
*
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
#ifndef TCP_LRO_H_
#define TCP_LRO_H_
#ifdef BSD_KERNEL_PRIVATE
#define TCP_LRO_NUM_FLOWS (16) /* must be <= 255 for char lro_flow_map */
#define TCP_LRO_FLOW_MAP (1024)
struct lro_flow {
struct mbuf *lr_mhead; /* coalesced mbuf chain head */
struct mbuf *lr_mtail; /* coalesced mbuf chain tail */
struct tcphdr *lr_tcphdr; /* ptr to TCP hdr in frame */
u_int32_t *lr_tsval; /* address of tsval in frame */
u_int32_t *lr_tsecr; /* tsecr field in TCP header */
tcp_seq lr_seq; /* next expected seq num */
unsigned int lr_len; /* length of LRO frame */
struct in_addr lr_faddr; /* foreign address */
struct in_addr lr_laddr; /* local address */
unsigned short int lr_fport; /* foreign port */
unsigned short int lr_lport; /* local port */
u_int32_t lr_timestamp; /* for ejecting the flow */
unsigned short int lr_hash_map; /* back pointer to hash map */
unsigned short int lr_flags; /* pad */
} __attribute__((aligned(8)));
/* lr_flags - only 16 bits available */
#define LRO_EJECT_REQ 0x1
#define TCP_LRO_FLOW_UNINIT TCP_LRO_NUM_FLOWS+1
#define TCP_LRO_FLOW_NOTFOUND TCP_LRO_FLOW_UNINIT
/* Max packets to be coalesced before pushing to app */
#define LRO_MX_COALESCE_PKTS (8)
/*
* Min num of bytes in a packet to trigger coalescing
*/
#define LRO_MIN_COALESC_SZ (1300)
/*
* Max amount of time to wait before flushing flows in msecs.
* Units are in msecs.
* This number has been carefully chosen and should be altered with care.
*/
#define LRO_MX_TIME_TO_BUFFER 10
/* similar to INP_PCBHASH */
#define LRO_HASH(faddr, laddr, fport, lport, mask) \
(((faddr) ^ ((laddr) >> 16) ^ ntohs((lport) ^ (fport))) & (mask))
#endif
#endif /* TCP_LRO_H_ */