1 /* SPDX-License-Identifier: GPL-2.0-only */ 1 2 #ifndef _CCID_H 3 #define _CCID_H 4 /* 5 * net/dccp/ccid.h 6 * 7 * An implementation of the DCCP protocol 8 * Arnaldo Carvalho de Melo <acme@conectiva.c 9 * 10 * CCID infrastructure 11 */ 12 13 #include <net/sock.h> 14 #include <linux/compiler.h> 15 #include <linux/dccp.h> 16 #include <linux/list.h> 17 #include <linux/module.h> 18 19 /* maximum value for a CCID (RFC 4340, 19.5) * 20 #define CCID_MAX 255 21 #define CCID_SLAB_NAME_LENGTH 32 22 23 struct tcp_info; 24 25 /** 26 * struct ccid_operations - Interface to Co 27 * 28 * @ccid_id: numerical CCID ID (up to %CCID_M 29 * @ccid_ccmps: the CCMPS including network/t 30 * @ccid_name: alphabetical identifier string 31 * @ccid_hc_{r,t}x_slab: memory pool for the 32 * @ccid_hc_{r,t}x_obj_size: size of the rece 33 * 34 * @ccid_hc_{r,t}x_init: CCID-specific initia 35 * @ccid_hc_{r,t}x_exit: CCID-specific cleanu 36 * @ccid_hc_rx_packet_recv: implements the HC 37 * @ccid_hc_{r,t}x_parse_options: parsing rou 38 * @ccid_hc_{r,t}x_insert_options: insert rou 39 * @ccid_hc_tx_packet_recv: implements feedba 40 * @ccid_hc_tx_send_packet: implements the se 41 * @ccid_hc_tx_packet_sent: does accounting f 42 * @ccid_hc_{r,t}x_get_info: INET_DIAG inform 43 * @ccid_hc_{r,t}x_getsockopt: socket options 44 */ 45 struct ccid_operations { 46 unsigned char ccid_id; 47 __u32 ccid_ccmps; 48 const char *ccid_name; 49 struct kmem_cache *ccid_hc_rx_sl 50 *ccid_hc_tx_sl 51 char ccid_hc_rx_sla 52 char ccid_hc_tx_sla 53 __u32 ccid_hc_rx_obj 54 ccid_hc_tx_obj 55 /* Interface Routines */ 56 int (*ccid_hc_rx_init)(str 57 int (*ccid_hc_tx_init)(str 58 void (*ccid_hc_rx_exit)(str 59 void (*ccid_hc_tx_exit)(str 60 void (*ccid_hc_rx_packet_re 61 62 int (*ccid_hc_rx_parse_opt 63 64 int (*ccid_hc_rx_insert_op 65 66 void (*ccid_hc_tx_packet_re 67 68 int (*ccid_hc_tx_parse_opt 69 70 int (*ccid_hc_tx_send_pack 71 72 void (*ccid_hc_tx_packet_se 73 74 void (*ccid_hc_rx_get_info) 75 76 void (*ccid_hc_tx_get_info) 77 78 int (*ccid_hc_rx_getsockop 79 80 81 82 int (*ccid_hc_tx_getsockop 83 84 85 86 }; 87 88 extern struct ccid_operations ccid2_ops; 89 #ifdef CONFIG_IP_DCCP_CCID3 90 extern struct ccid_operations ccid3_ops; 91 #endif 92 93 int ccid_initialize_builtins(void); 94 void ccid_cleanup_builtins(void); 95 96 struct ccid { 97 struct ccid_operations *ccid_ops; 98 char ccid_priv[]; 99 }; 100 101 static inline void *ccid_priv(const struct cci 102 { 103 return (void *)ccid->ccid_priv; 104 } 105 106 bool ccid_support_check(u8 const *ccid_array, 107 int ccid_get_builtin_ccids(u8 **ccid_array, u8 108 int ccid_getsockopt_builtin_ccids(struct sock 109 char __user 110 111 struct ccid *ccid_new(const u8 id, struct sock 112 113 static inline int ccid_get_current_rx_ccid(str 114 { 115 struct ccid *ccid = dp->dccps_hc_rx_cc 116 117 if (ccid == NULL || ccid->ccid_ops == 118 return -1; 119 return ccid->ccid_ops->ccid_id; 120 } 121 122 static inline int ccid_get_current_tx_ccid(str 123 { 124 struct ccid *ccid = dp->dccps_hc_tx_cc 125 126 if (ccid == NULL || ccid->ccid_ops == 127 return -1; 128 return ccid->ccid_ops->ccid_id; 129 } 130 131 void ccid_hc_rx_delete(struct ccid *ccid, stru 132 void ccid_hc_tx_delete(struct ccid *ccid, stru 133 134 /* 135 * Congestion control of queued data packets v 136 * 137 * The TX CCID performs its congestion-control 138 * queued packet may be sent, using the return 139 * The following modes are supported via the s 140 * - timer-based pacing (CCID returns a del 141 * - autonomous dequeueing (CCID internally sc 142 */ 143 144 enum ccid_dequeueing_decision { 145 CCID_PACKET_SEND_AT_ONCE = 0x000 146 CCID_PACKET_DELAY_MAX = 0x0FF 147 CCID_PACKET_DELAY = 0x100 148 CCID_PACKET_WILL_DEQUEUE_LATER = 0x200 149 CCID_PACKET_ERR = 0xF00 150 }; 151 152 static inline int ccid_packet_dequeue_eval(con 153 { 154 if (return_code < 0) 155 return CCID_PACKET_ERR; 156 if (return_code == 0) 157 return CCID_PACKET_SEND_AT_ONC 158 if (return_code <= CCID_PACKET_DELAY_M 159 return CCID_PACKET_DELAY; 160 return return_code; 161 } 162 163 static inline int ccid_hc_tx_send_packet(struc 164 struc 165 { 166 if (ccid->ccid_ops->ccid_hc_tx_send_pa 167 return ccid->ccid_ops->ccid_hc 168 return CCID_PACKET_SEND_AT_ONCE; 169 } 170 171 static inline void ccid_hc_tx_packet_sent(stru 172 unsi 173 { 174 if (ccid->ccid_ops->ccid_hc_tx_packet_ 175 ccid->ccid_ops->ccid_hc_tx_pac 176 } 177 178 static inline void ccid_hc_rx_packet_recv(stru 179 stru 180 { 181 if (ccid->ccid_ops->ccid_hc_rx_packet_ 182 ccid->ccid_ops->ccid_hc_rx_pac 183 } 184 185 static inline void ccid_hc_tx_packet_recv(stru 186 stru 187 { 188 if (ccid->ccid_ops->ccid_hc_tx_packet_ 189 ccid->ccid_ops->ccid_hc_tx_pac 190 } 191 192 /** 193 * ccid_hc_tx_parse_options - Parse CCID-spe 194 * @pkt: type of packet that @opt appears on ( 195 * @opt: the CCID-specific option type (RFC 43 196 * @val: value of @opt 197 * @len: length of @val in bytes 198 */ 199 static inline int ccid_hc_tx_parse_options(str 200 u8 201 { 202 if (!ccid || !ccid->ccid_ops->ccid_hc_ 203 return 0; 204 return ccid->ccid_ops->ccid_hc_tx_pars 205 } 206 207 /** 208 * ccid_hc_rx_parse_options - Parse CCID-spe 209 * Arguments are analogous to ccid_hc_tx_parse 210 */ 211 static inline int ccid_hc_rx_parse_options(str 212 u8 213 { 214 if (!ccid || !ccid->ccid_ops->ccid_hc_ 215 return 0; 216 return ccid->ccid_ops->ccid_hc_rx_pars 217 } 218 219 static inline int ccid_hc_rx_insert_options(st 220 st 221 { 222 if (ccid->ccid_ops->ccid_hc_rx_insert_ 223 return ccid->ccid_ops->ccid_hc 224 return 0; 225 } 226 227 static inline void ccid_hc_rx_get_info(struct 228 struct 229 { 230 if (ccid->ccid_ops->ccid_hc_rx_get_inf 231 ccid->ccid_ops->ccid_hc_rx_get 232 } 233 234 static inline void ccid_hc_tx_get_info(struct 235 struct 236 { 237 if (ccid->ccid_ops->ccid_hc_tx_get_inf 238 ccid->ccid_ops->ccid_hc_tx_get 239 } 240 241 static inline int ccid_hc_rx_getsockopt(struct 242 const 243 u32 __ 244 { 245 int rc = -ENOPROTOOPT; 246 if (ccid != NULL && ccid->ccid_ops->cc 247 rc = ccid->ccid_ops->ccid_hc_r 248 249 return rc; 250 } 251 252 static inline int ccid_hc_tx_getsockopt(struct 253 const 254 u32 __ 255 { 256 int rc = -ENOPROTOOPT; 257 if (ccid != NULL && ccid->ccid_ops->cc 258 rc = ccid->ccid_ops->ccid_hc_t 259 260 return rc; 261 } 262 #endif /* _CCID_H */ 263
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.