| Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 1 | #ifndef _ACKVEC_H | 
|  | 2 | #define _ACKVEC_H | 
|  | 3 | /* | 
|  | 4 | *  net/dccp/ackvec.h | 
|  | 5 | * | 
|  | 6 | *  An implementation of the DCCP protocol | 
|  | 7 | *  Copyright (c) 2005 Arnaldo Carvalho de Melo <acme@mandriva.com> | 
|  | 8 | * | 
|  | 9 | *	This program is free software; you can redistribute it and/or modify it | 
|  | 10 | *	under the terms of the GNU General Public License version 2 as | 
|  | 11 | *	published by the Free Software Foundation. | 
|  | 12 | */ | 
|  | 13 |  | 
| Gerrit Renker | b20a9c2 | 2008-11-23 16:02:31 -0800 | [diff] [blame] | 14 | #include <linux/dccp.h> | 
| Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 15 | #include <linux/compiler.h> | 
| Arnaldo Carvalho de Melo | b8bda9d | 2007-08-19 17:17:25 -0700 | [diff] [blame] | 16 | #include <linux/ktime.h> | 
| Andrea Bittau | 02bcf28 | 2006-03-20 17:19:55 -0800 | [diff] [blame] | 17 | #include <linux/list.h> | 
| Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 18 | #include <linux/types.h> | 
|  | 19 |  | 
| Andrea Bittau | bdf13d2 | 2006-11-24 13:02:42 -0200 | [diff] [blame] | 20 | /* We can spread an ack vector across multiple options */ | 
| Gerrit Renker | b20a9c2 | 2008-11-23 16:02:31 -0800 | [diff] [blame] | 21 | #define DCCP_MAX_ACKVEC_LEN (DCCP_SINGLE_OPT_MAXLEN * 2) | 
| Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 22 |  | 
| Gerrit Renker | 361a5c1 | 2009-02-27 22:38:28 +0000 | [diff] [blame] | 23 | /* Estimated minimum average Ack Vector length - used for updating MPS */ | 
|  | 24 | #define DCCPAV_MIN_OPTLEN	16 | 
|  | 25 |  | 
| Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 26 | #define DCCP_ACKVEC_STATE_RECEIVED	0 | 
|  | 27 | #define DCCP_ACKVEC_STATE_ECN_MARKED	(1 << 6) | 
|  | 28 | #define DCCP_ACKVEC_STATE_NOT_RECEIVED	(3 << 6) | 
|  | 29 |  | 
|  | 30 | #define DCCP_ACKVEC_STATE_MASK		0xC0 /* 11000000 */ | 
|  | 31 | #define DCCP_ACKVEC_LEN_MASK		0x3F /* 00111111 */ | 
|  | 32 |  | 
|  | 33 | /** struct dccp_ackvec - ack vector | 
|  | 34 | * | 
| Gerrit Renker | 0e64e94 | 2006-10-24 16:17:51 -0700 | [diff] [blame] | 35 | * This data structure is the one defined in RFC 4340, Appendix A. | 
| Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 36 | * | 
| Gerrit Renker | a47c510 | 2007-12-30 04:19:31 -0800 | [diff] [blame] | 37 | * @av_buf_head - circular buffer head | 
|  | 38 | * @av_buf_tail - circular buffer tail | 
|  | 39 | * @av_buf_ackno - ack # of the most recent packet acknowledgeable in the | 
|  | 40 | *		       buffer (i.e. %av_buf_head) | 
|  | 41 | * @av_buf_nonce - the one-bit sum of the ECN Nonces on all packets acked | 
| Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 42 | * 		       by the buffer with State 0 | 
|  | 43 | * | 
|  | 44 | * Additionally, the HC-Receiver must keep some information about the | 
|  | 45 | * Ack Vectors it has recently sent. For each packet sent carrying an | 
|  | 46 | * Ack Vector, it remembers four variables: | 
|  | 47 | * | 
| Gerrit Renker | a47c510 | 2007-12-30 04:19:31 -0800 | [diff] [blame] | 48 | * @av_records - list of dccp_ackvec_record | 
|  | 49 | * @av_ack_nonce - the one-bit sum of the ECN Nonces for all State 0. | 
| Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 50 | * | 
| Gerrit Renker | a47c510 | 2007-12-30 04:19:31 -0800 | [diff] [blame] | 51 | * @av_time - the time in usecs | 
|  | 52 | * @av_buf - circular buffer of acknowledgeable packets | 
| Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 53 | */ | 
|  | 54 | struct dccp_ackvec { | 
| Gerrit Renker | a47c510 | 2007-12-30 04:19:31 -0800 | [diff] [blame] | 55 | u64			av_buf_ackno; | 
|  | 56 | struct list_head	av_records; | 
|  | 57 | ktime_t			av_time; | 
|  | 58 | u16			av_buf_head; | 
|  | 59 | u16			av_vec_len; | 
|  | 60 | u8			av_buf_nonce; | 
|  | 61 | u8			av_ack_nonce; | 
|  | 62 | u8			av_buf[DCCP_MAX_ACKVEC_LEN]; | 
| Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 63 | }; | 
|  | 64 |  | 
| Andrea Bittau | 02bcf28 | 2006-03-20 17:19:55 -0800 | [diff] [blame] | 65 | /** struct dccp_ackvec_record - ack vector record | 
|  | 66 | * | 
|  | 67 | * ACK vector record as defined in Appendix A of spec. | 
|  | 68 | * | 
| Gerrit Renker | a47c510 | 2007-12-30 04:19:31 -0800 | [diff] [blame] | 69 | * The list is sorted by avr_ack_seqno | 
| Andrea Bittau | 02bcf28 | 2006-03-20 17:19:55 -0800 | [diff] [blame] | 70 | * | 
| Gerrit Renker | a47c510 | 2007-12-30 04:19:31 -0800 | [diff] [blame] | 71 | * @avr_node - node in av_records | 
|  | 72 | * @avr_ack_seqno - sequence number of the packet this record was sent on | 
|  | 73 | * @avr_ack_ackno - sequence number being acknowledged | 
|  | 74 | * @avr_ack_ptr - pointer into av_buf where this record starts | 
|  | 75 | * @avr_ack_nonce - av_ack_nonce at the time this record was sent | 
|  | 76 | * @avr_sent_len - lenght of the record in av_buf | 
| Andrea Bittau | 02bcf28 | 2006-03-20 17:19:55 -0800 | [diff] [blame] | 77 | */ | 
|  | 78 | struct dccp_ackvec_record { | 
| Gerrit Renker | a47c510 | 2007-12-30 04:19:31 -0800 | [diff] [blame] | 79 | struct list_head avr_node; | 
|  | 80 | u64		 avr_ack_seqno; | 
|  | 81 | u64		 avr_ack_ackno; | 
|  | 82 | u16		 avr_ack_ptr; | 
|  | 83 | u16		 avr_sent_len; | 
|  | 84 | u8		 avr_ack_nonce; | 
| Andrea Bittau | 02bcf28 | 2006-03-20 17:19:55 -0800 | [diff] [blame] | 85 | }; | 
|  | 86 |  | 
| Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 87 | struct sock; | 
|  | 88 | struct sk_buff; | 
|  | 89 |  | 
| Arnaldo Carvalho de Melo | 9b07ef5 | 2006-03-20 17:16:17 -0800 | [diff] [blame] | 90 | extern int dccp_ackvec_init(void); | 
|  | 91 | extern void dccp_ackvec_exit(void); | 
|  | 92 |  | 
| Arnaldo Carvalho de Melo | 7400d78 | 2006-03-20 17:15:42 -0800 | [diff] [blame] | 93 | extern struct dccp_ackvec *dccp_ackvec_alloc(const gfp_t priority); | 
| Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 94 | extern void dccp_ackvec_free(struct dccp_ackvec *av); | 
|  | 95 |  | 
|  | 96 | extern int dccp_ackvec_add(struct dccp_ackvec *av, const struct sock *sk, | 
|  | 97 | const u64 ackno, const u8 state); | 
|  | 98 |  | 
|  | 99 | extern void dccp_ackvec_check_rcv_ackno(struct dccp_ackvec *av, | 
|  | 100 | struct sock *sk, const u64 ackno); | 
|  | 101 | extern int dccp_ackvec_parse(struct sock *sk, const struct sk_buff *skb, | 
| Andrea Bittau | bdf13d2 | 2006-11-24 13:02:42 -0200 | [diff] [blame] | 102 | u64 *ackno, const u8 opt, | 
|  | 103 | const u8 *value, const u8 len); | 
| Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 104 |  | 
|  | 105 | extern int dccp_insert_option_ackvec(struct sock *sk, struct sk_buff *skb); | 
|  | 106 |  | 
|  | 107 | static inline int dccp_ackvec_pending(const struct dccp_ackvec *av) | 
|  | 108 | { | 
| Gerrit Renker | a47c510 | 2007-12-30 04:19:31 -0800 | [diff] [blame] | 109 | return av->av_vec_len; | 
| Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 110 | } | 
| Arnaldo Carvalho de Melo | ae31c33 | 2005-09-18 00:17:51 -0700 | [diff] [blame] | 111 | #endif /* _ACKVEC_H */ |