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