xref: /titanic_41/usr/src/uts/common/inet/tcp_sack.h (revision 34f9b3eef6fdadbda0a846aa4d68691ac40eace5)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_INET_TCP_SACK_H
27 #define	_INET_TCP_SACK_H
28 
29 #ifdef	__cplusplus
30 extern "C" {
31 #endif
32 
33 /* Maximum num of receiver's SACK blocks */
34 #define	MAX_SACK_BLK	5
35 
36 /* Receiver's SACK blk structure */
37 typedef struct sack_blk
38 {
39 	tcp_seq	begin;
40 	tcp_seq	end;
41 } sack_blk_t;
42 
43 /* Sender's notsack'ed blk structure */
44 typedef struct notsack_blk
45 {
46 	struct notsack_blk	*next;
47 	tcp_seq			begin;
48 	tcp_seq			end;
49 	uint32_t		sack_cnt; /* Dup SACK count */
50 } notsack_blk_t;
51 
52 
53 /* SACK information in the tcp_t structure. */
54 typedef struct
55 {
56 	int32_t	tcp_pipe;	/* # of bytes in network */
57 	tcp_seq	tcp_fack;	/* highest sack'ed seq num */
58 	tcp_seq	tcp_sack_snxt;	/* next seq num to be rexmited using SACK. */
59 
60 	int32_t	tcp_max_sack_blk; /* max # of SACK info blk in a segment */
61 	int32_t	tcp_num_sack_blk; /* num of blks in sack list */
62 	sack_blk_t	tcp_sack_list[MAX_SACK_BLK]; /* the sack list */
63 
64 	/* num of blks in notsack list */
65 	int32_t		tcp_num_notsack_blk;
66 	/* # of bytes represented in blks in notsack list */
67 	uint32_t	tcp_cnt_notsack_list;
68 	/* the notsack list */
69 	notsack_blk_t	*tcp_notsack_list;
70 } tcp_sack_info_t;
71 
72 extern void tcp_sack_insert(sack_blk_t *, tcp_seq, tcp_seq, int32_t *);
73 extern void tcp_sack_remove(sack_blk_t *, tcp_seq, int32_t *);
74 extern void tcp_notsack_insert(notsack_blk_t **, tcp_seq, tcp_seq,
75     int32_t *, uint32_t *);
76 extern void tcp_notsack_remove(notsack_blk_t **, tcp_seq, int32_t *,
77     uint32_t *);
78 extern void tcp_notsack_update(notsack_blk_t **, tcp_seq, tcp_seq,
79     int32_t *, uint32_t *);
80 
81 
82 /*
83  * Macro to remove all the notsack'ed blks in sender.
84  *
85  * Param:
86  * notsack_blk_t *head: pointer to the head of the list of notsack'ed blks.
87  */
88 #define	TCP_NOTSACK_REMOVE_ALL(head, tcp)		\
89 { \
90 	notsack_blk_t *prev, *tmp; \
91 	tmp = (head); \
92 	do { \
93 		prev = tmp; \
94 		tmp = tmp->next; \
95 		kmem_free(prev, sizeof (notsack_blk_t)); \
96 	} while (tmp != NULL); \
97 	(head) = NULL; \
98 	(tcp)->tcp_cnt_notsack_list = 0; \
99 	(tcp)->tcp_num_notsack_blk = 0; \
100 }
101 
102 
103 #ifdef	__cplusplus
104 }
105 #endif
106 
107 #endif	/* _INET_TCP_SACK_H */
108