xref: /titanic_51/usr/src/uts/common/inet/tcp_sack.h (revision d583b39bfb4e2571d3e41097c5c357ffe353ad45)
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 (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
23  */
24 
25 #ifndef	_INET_TCP_SACK_H
26 #define	_INET_TCP_SACK_H
27 
28 #ifdef	__cplusplus
29 extern "C" {
30 #endif
31 
32 /* Maximum num of receiver's SACK blocks */
33 #define	MAX_SACK_BLK	5
34 
35 /* Receiver's SACK blk structure */
36 typedef struct sack_blk
37 {
38 	tcp_seq	begin;
39 	tcp_seq	end;
40 } sack_blk_t;
41 
42 /* Sender's notsack'ed blk structure */
43 typedef struct notsack_blk
44 {
45 	struct notsack_blk	*next;
46 	tcp_seq			begin;
47 	tcp_seq			end;
48 	uint32_t		sack_cnt; /* Dup SACK count */
49 } notsack_blk_t;
50 
51 
52 /* SACK information in the tcp_t structure. */
53 typedef struct
54 {
55 	int32_t	tcp_pipe;	/* # of bytes in network */
56 	tcp_seq	tcp_fack;	/* highest sack'ed seq num */
57 	tcp_seq	tcp_sack_snxt;	/* next seq num to be rexmited using SACK. */
58 
59 	int32_t	tcp_max_sack_blk; /* max # of SACK info blk in a segment */
60 	int32_t	tcp_num_sack_blk; /* num of blks in sack list */
61 	sack_blk_t	tcp_sack_list[MAX_SACK_BLK]; /* the sack list */
62 
63 	/* num of blks in notsack list */
64 	int32_t		tcp_num_notsack_blk;
65 	/* # of bytes represented in blks in notsack list */
66 	uint32_t	tcp_cnt_notsack_list;
67 	/* the notsack list */
68 	notsack_blk_t	*tcp_notsack_list;
69 } tcp_sack_info_t;
70 
71 extern void tcp_sack_insert(sack_blk_t *, tcp_seq, tcp_seq, int32_t *);
72 extern void tcp_sack_remove(sack_blk_t *, tcp_seq, int32_t *);
73 extern void tcp_notsack_insert(notsack_blk_t **, tcp_seq, tcp_seq,
74     int32_t *, uint32_t *);
75 extern void tcp_notsack_remove(notsack_blk_t **, tcp_seq, int32_t *,
76     uint32_t *);
77 extern void tcp_notsack_update(notsack_blk_t **, tcp_seq, tcp_seq,
78     int32_t *, uint32_t *);
79 
80 /* Defined in tcp_sack.c */
81 extern kmem_cache_t	*tcp_notsack_blk_cache;
82 
83 /*
84  * Macro to remove all the notsack'ed blks in sender.
85  *
86  * Param:
87  * notsack_blk_t *head: pointer to the head of the list of notsack'ed blks.
88  */
89 #define	TCP_NOTSACK_REMOVE_ALL(head, tcp)			\
90 {								\
91 	if ((head) != NULL) {					\
92 		notsack_blk_t *prev, *tmp;			\
93 		tmp = (head);					\
94 		do  {						\
95 			prev = tmp;				\
96 			tmp = tmp->next;			\
97 			kmem_cache_free(tcp_notsack_blk_cache, prev); \
98 		} while (tmp != NULL);				\
99 		(head) = NULL;					\
100 		(tcp)->tcp_cnt_notsack_list = 0;		\
101 		(tcp)->tcp_num_notsack_blk = 0;			\
102 	} else {						\
103 		ASSERT((tcp)->tcp_cnt_notsack_list == 0);	\
104 		ASSERT((tcp)->tcp_num_notsack_blk == 0);	\
105 	}							\
106 }
107 
108 #ifdef	__cplusplus
109 }
110 #endif
111 
112 #endif	/* _INET_TCP_SACK_H */
113