CNDP  22.08.0
cnet_tcp.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
3  * The Regents of the University of California. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * 3. All advertising materials mentioning features or use of this software
14  * must display the following acknowledgement:
15  * This product includes software developed by the University of
16  * California, Berkeley and its contributors.
17  * 4. Neither the name of the University nor the names of its contributors
18  * may be used to endorse or promote products derived from this software
19  * without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31  * SUCH DAMAGE.
32  */
33 /* SPDX-License-Identifier: BSD-3-Clause
34  * Copyright (c) 2016-2022 Intel Corporation
35  */
36 
37 #ifndef __CNET_TCP_H
38 #define __CNET_TCP_H
39 
45 #include "cnet_const.h" // for bool_t
46 #include "cnet_pcb.h" // for pcb_hd
47 
48 #include <net/cne_tcp.h>
49 #include <stdint.h> // for uint32_t, uint16_t, int32_t, int16_t, uint8_t
50 #include <stdio.h> // for NULL
51 #include <stdbool.h>
52 #include <sys/queue.h> // for TAILQ_ENTRY, TAILQ_INSERT_TAIL, TAILQ_REMOVE
53 
54 #include "cne_log.h" // for CNE_LOG, CNE_LOG_DEBUG
55 #include "cnet_const.h" // for bool_t
56 #include "cnet_pcb.h" // for pcb_entry (ptr only), pcb_hd
57 #include "cnet_stk.h" // for per_thread_stk, stk_entry, this_stk
58 #include "cnet_tcp.h" // for tcb_entry (ptr only)
59 #include "mempool.h" // for mempool_get, mempool_put
60 #include "pktmbuf.h" // for pktmbuf_t
61 #ifdef __cplusplus
62 extern "C" {
63 #endif
64 
65 #define CNET_TCP_REASSEMBLE_COUNT 256
66 #define CNET_TCP_BACKLOG_COUNT 128
67 #define CNET_TCP_HALF_OPEN_COUNT 128
68 
69 /* Basic TCP packet header
70  *
71  * TCP Header Format
72  *
73  * 0 1 2 3
74  * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
75  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
76  * | Source Port | Destination Port |
77  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
78  * | Sequence Number |
79  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
80  * | Acknowledgment Number |
81  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
82  * | Data | |U|A|P|R|S|F| |
83  * | Offset| Reserved |R|C|S|S|Y|I| Window |
84  * | | |G|K|H|T|N|N| |
85  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
86  * | Checksum | Urgent Pointer |
87  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
88  * | Options | Padding |
89  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
90  * | data |
91  * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
92  */
93 
94 struct cne_tcp_hdr;
95 struct cne_vec;
96 
97 typedef uint32_t seq_t; /* TCP Sequence type */
98 
99 /* Timestamp modulo math test macros */
100 static inline int
101 tstampLT(uint32_t a, uint32_t b)
102 {
103  return (int32_t)(a - b) < 0;
104 }
105 
106 static inline int
107 tstampLEQ(uint32_t a, uint32_t b)
108 {
109  return (int32_t)(a - b) <= 0;
110 }
111 
112 static inline int
113 tstampGEQ(uint32_t a, uint32_t b)
114 {
115  return (int32_t)(a - b) >= 0;
116 }
117 
118 /* Number of milli-seconds for 24 days */
119 #define TCP_PAWS_IDLE (24 * 24 * 60 * 60 * 1000)
120 
122 typedef enum {
123  TCPS_FREE = 0,
136 
137 #define TCP_INPUT_STATES \
138  { \
139  "Free", "Closed", "Listen", "SYN Sent", "SYN Rcvd", "Established", "CloseWait", "Fin1", \
140  "Closing", "LastAck", "Fin2", "TimeWait", "DeleteTCB" \
141  }
142 
143 #define TCPS_HAVE_RCVD_SYN(s) ((s) >= TCPS_SYN_RCVD)
144 #define TCPS_HAVE_ESTABLISHED (s)((s) >= TCPS_ESTABLISHED)
145 #define TCPS_HAVE_RCVD_FIN(s) ((s) >= TCPS_TIME_WAIT)
146 
147 /* tcp_hdr.flags TCP Header flags and seg_entry.flags */
148 enum {
149  TCP_FIN = 0x01,
150  TCP_SYN = 0x02,
151  TCP_RST = 0x04,
152  TCP_PSH = 0x08,
153  TCP_ACK = 0x10,
154  TCP_URG = 0x20,
155  TCP_MASK = 0x3F,
156  SYN_FIN = (TCP_SYN | TCP_FIN),
157  RST_ACK = (TCP_RST | TCP_ACK),
158  FIN_ACK = (TCP_FIN | TCP_ACK),
159  SYN_ACK = (TCP_SYN | TCP_ACK),
160  SYN_RST = (TCP_SYN | TCP_RST),
161  HDR_PREDIC = (TCP_SYN | TCP_FIN | TCP_RST | TCP_URG | TCP_ACK)
162 };
163 
164 /* Keep in bit order with above enums */
165 #define TCP_FLAGS \
166  { \
167  "FIN", "SYN", "RST", "PSH", "ACK", "URG" \
168  }
169 
170 // clang-format off
171 /* State of the flags for all possible states in TCP */
172 #define TCP_OUTPUT_FLAGS \
173  { \
174  0, /* TCPS_FREE */ \
175  RST_ACK, /* TCPS_CLOSED */ \
176  0, /* TCPS_LISTEN */ \
177  TCP_SYN, /* TCPS_SYN_SENT */ \
178  SYN_ACK, /* TCPS_SYN_RCVD */ \
179  TCP_ACK, /* TCPS_ESTABLISHED */ \
180  TCP_ACK, /* TCPS_CLOSE_WAIT */ \
181  FIN_ACK, /* TCPS_FIN_WAIT_1 */ \
182  TCP_ACK, /* TCPS_CLOSING */ \
183  FIN_ACK, /* TCPS_LAST_ACK */ \
184  TCP_ACK, /* TCPS_FIN_WAIT_2 */ \
185  TCP_ACK /* TCPS_TIME_WAIT */ \
186  }
187 // clang-format on
188 
189 /* TCP Output Events to drive the output Finite State Machine. */
190 enum { SEND_EVENT, PERSIST_EVENT, RETRANSMIT_EVENT, DELETE_EVENT };
191 
192 #define TCP_OUTPUT_EVENTS \
193  { \
194  "Send", "Persist", "Rexmit", "Delete" \
195  }
196 
197 /* TCP Option values */
198 enum {
205  TCP_OPT_TSTAMP = 8
206 };
207 
208 /* A few option lengths */
209 #define TCP_OPT_SACK_LEN 2
210 #define TCP_OPT_MSS_LEN 4
211 #define TCP_OPT_WSOPT_LEN 3
212 #define TCP_OPT_TSTAMP_LEN 10
213 #define TCP_MAX_OPTIONS 32
214 
215 /* Few default values */
216 #ifdef TCP_MSS
217 #undef TCP_MSS
218 #endif
219 #define TCP_MIN_MSS 64
220 #define TCP_MSS 536
221 #define TCP_NORMAL_MSS 1460
222 #define TCP_MAX_MSS (16384 - 64)
223 #define TCP_MSS_OVERHEAD 52
224 #define TCP_DEFAULT_HDR_SIZE 20
225 #undef TCP_MAXWIN
226 #ifndef ETHER_MAX_MTU
227 #define ETHER_MAX_MTU 65535
228 #endif
229 #define TCP_MAXWIN ETHER_MAX_MTU
230 #define TCP_MAX_WINSHIFT 14
231 #define TCP_INITIAL_CWND 4380
232 #define TCP_VEC_SIZE 1024
234 /* The following values are define in 500ms ticks slow timeout */
235 #define TCP_MSL_TV 60
236 #define TCP_MIN_TV 2
237 #define TCP_REXMTMAX_TV 128
238 #define TCP_PERSMIN_TV 10
239 #define TCP_PERSMAX_TV 120
240 #define TCP_KEEP_INIT_TV 150
241 #define TCP_KEEP_IDLE_TV 14400
242 #define TCP_KEEPINTVL_TV 150
243 #define TCP_KEEPCNT_TV 8
244 #define TCP_SRTTBASE_TV 0
245 #define TCP_SRTTDFLT_TV 2
246 #define TCP_KEEPCNT_TV 8
248 #define TCP_RTT_SCALE 8
249 #define TCP_RTT_SHIFT 3
250 #define TCP_RTTVAR_SCALE 4
251 #define TCP_RTTVAR_SHIFT 2
253 #define TCP_ISSINCR 0x01000000
254 #define TCP_SLOWHZ 2
256 /* Number of ms per timeout */
257 #define TCP_REXMT_TIMEOUT_MS 100UL
258 #define TCP_FAST_TIMEOUT_MS 200UL
259 #define TCP_SLOW_TIMEOUT_MS 500UL
260 
261 /*
262  * The initial retransmission should happen at rtt + 4 * rttvar.
263  * Because of the way we do the smoothing, srtt and rttvar
264  * will each average +1/2 tick of bias. When we compute
265  * the retransmit timer, we want 1/2 tick of rounding and
266  * 1 extra tick because of +-1/2 tick uncertainty in the
267  * firing of the timer. The bias will give us exactly the
268  * 1.5 tick we need. But, because the bias is
269  * statistical, we have to test that we don't drop below
270  * the minimum feasible timer (which is 2 ticks).
271  *
272  * This macro assumes that the value of TCP_RTTVAR_SCALE
273  * is the same as the multiplier for rttvar.
274  */
275 #define tcpRexmtVal(_t) ((((_t)->srtt >> TCP_RTT_SHIFT) + (_t)->rttvar) / 500)
276 
277 #define seqLT(a, b) ((int)((a) - (b)) < 0)
278 #define seqLEQ(a, b) ((int)((a) - (b)) <= 0)
279 #define seqGT(a, b) ((int)((a) - (b)) > 0)
280 #define seqGEQ(a, b) ((int)((a) - (b)) >= 0)
281 #define seqEQ(a, b) ((int)((a) - (b)) == 0)
282 #define seqNE(a, b) ((int)((a) - (b)) != 0)
283 
284 #define TCP_MAXRXTSHIFT 12
285 #define TCP_RETRANSMIT_THRESHOLD 3
286 
287 #define MAX_TCP_RCV_SIZE (128 * 1024)
288 #define MAX_TCP_SND_SIZE MAX_TCP_RCV_SIZE
289 
290 /* Macro to deal with cne_mbuf pointer in TCP header */
291 #define reassPkt(_t) (*(pktmbuf_t **)&((_t)->tcp.src_port))
292 
293 /* Index into the tcb.timers array */
294 enum {
299  TCP_NTIMERS
300 };
301 
302 /* Current Segment information in host order. */
303 struct seg_entry {
304  TAILQ_ENTRY(seg_entry) entry;
305  pktmbuf_t *mbuf;
306  struct pcb_entry *pcb;
307  uint8_t flags;
308  uint8_t offset;
309  uint16_t mss;
310  uint16_t urp;
311  uint16_t len;
312  uint16_t iplen;
313  uint16_t sflags;
314  uint16_t lport;
315  uint32_t wnd;
316  seq_t seq;
317  seq_t ack;
318  uint32_t ts_val;
319  uint32_t ts_ecr;
320  void *ip;
321  uint8_t req_scale;
322  uint8_t optlen;
323  uint8_t opts[TCP_MAX_OPTIONS];
324 };
325 
326 /* seg_entry.sflags bit definitions */
327 enum {
328  SEG_TS_PRESENT = 0x8000,
329  SEG_MSS_PRESENT = 0x4000,
330  SEG_WS_PRESENT = 0x2000,
331  SEG_SACK_PERMIT = 0x1000
332 };
333 
334 enum {
337 };
338 
339 struct stk_s;
340 struct tcp_entry;
341 struct netif;
342 
343 struct tcp_q {
344  TAILQ_HEAD(, pcb_entry) head;
345  atomic_uint_least32_t cnt;
346 };
347 
348 /* TCP Transmission Control Block */
349 struct tcb_entry {
350  TAILQ_ENTRY(tcb_entry) entry;
352  pktmbuf_t **reassemble;
353  struct tcp_q backlog_q;
354  struct tcp_q half_open_q;
356  struct netif *netif;
357  struct tcp_entry *tcp;
358  struct pcb_entry *pcb;
359  struct pcb_entry *ppcb;
361  uint32_t tflags;
362  uint32_t persist;
363  tcb_state_t state;
364  uint16_t max_mss;
366  int16_t timers[TCP_NTIMERS] __cne_aligned(8);
367  int32_t qLimit;
369  /* RFC1323 variables */
370  uint8_t snd_scale;
371  uint8_t rcv_scale;
372  uint8_t req_recv_scale;
373  uint8_t req_send_scale;
374  uint32_t ts_recent;
375  uint32_t ts_recent_age;
376  seq_t last_ack_sent;
378  /* Send segment information */
379  seq_t snd_una;
380  seq_t snd_nxt;
381  seq_t snd_up;
382  seq_t snd_wl1;
383  seq_t snd_wl2;
384  seq_t snd_iss;
385  seq_t snd_max;
386  uint32_t snd_wnd;
387  uint32_t snd_ssthresh;
388  uint32_t snd_cwnd;
389  uint32_t max_sndwnd;
391  /* Receive Segment information */
392  seq_t rcv_wnd;
393  seq_t rcv_nxt;
394  seq_t rcv_irs;
395  seq_t rcv_adv;
396  int32_t rcv_bsize;
397  seq_t rcv_ssthresh;
398  uint16_t snd_urp;
399  uint16_t rcv_urp;
401  /* Retransmission timeout values */
402  seq_t rttseq;
403  seq_t total_retrans;
404  int16_t rtt;
405  int16_t srtt;
406  int16_t rttvar;
407  int16_t dupacks;
408  int16_t rxtcur;
409  uint16_t rttmin;
410  int16_t rxtshift;
411  uint16_t idle;
412 };
413 
414 /* tcb_entry.tflags values */
415 // clang-format off
416 enum {
417  TCBF_PASSIVE_OPEN = 0x10000000,
418  TCBF_FORCE_TX = 0x20000000,
419  TCBF_DELAYED_ACK = 0x40000000,
420  TCBF_FREE_BIT_1 = 0x80000000,
421 
422  TCBF_RFC1122_URG = 0x01000000,
423  TCBF_BOUND = 0x02000000,
424  TCBF_FREE_BIT_2 = 0x04000000,
425  TCBF_FREE_BIT_3 = 0x08000000,
426 
427  TCBF_REQ_TSTAMP = 0x00100000,
428  TCBF_RCVD_SCALE = 0x00200000,
429  TCBF_REQ_SCALE = 0x00400000,
430  TCBF_SEND_URG = 0x00800000,
432  TCBF_ACK_NOW = 0x00010000,
433  TCBF_SENT_FIN = 0x00020000,
434  TCBF_SACK_PERMIT = 0x00040000,
435  TCBF_RCVD_TSTAMP = 0x00080000,
437  TCBF_NODELAY = 0x00001000,
438  TCBF_NAGLE_CREDIT = 0x00002000,
439  TCBF_OUR_FIN_ACKED = 0x00004000,
440  TCBF_FREE_BIT_4 = 0x00008000,
441 
442  TCBF_FREE_BIT_5 = 0x00000100,
443  TCBF_NEED_FAST_REXMT = 0x00000200,
444  TCBF_NOPUSH = 0x00000400,
445  TCBF_NOOPT = 0x00000800,
446 };
447 
448 #define TCB_FLAGS \
449  { \
450  "Free_1", \
451  "DELAYED_ACK", \
452  "FORCE_TX", \
453  "PASSIVE_OPEN", \
454  \
455  "Free_3", \
456  "Free_2", \
457  "BOUND", \
458  "RFC1122_URG", \
459  \
460  "SEND_URG", \
461  "REQ_SCALE", \
462  "RCVD_SCALE", \
463  "REQ_TSTAMP", \
464  \
465  "RCVD_TSTAMP", \
466  "SACK_PERMIT", \
467  "SENT_FIN", \
468  "ACK_NOW", \
469  \
470  "Free_4", \
471  "OUR_FIN_ACKED", \
472  "NAGLE_CREDIT", \
473  "NO_DELAY", \
474  \
475  "NOOPT", \
476  "NOPUSH", \
477  "NeedFastRexmt", \
478  "Free_5", \
479  NULL \
480  }
481 // clang-format on
482 
483 extern const char *tcb_in_states[];
484 
485 struct chnl;
486 
487 struct tcp_entry {
488  TAILQ_ENTRY(tcb_entry) entry;
489  uint32_t rcv_size;
490  uint32_t snd_size;
491  uint32_t snd_ISS;
492  int32_t keep_intvl;
493  int32_t keep_idle;
494  int32_t keep_cnt;
495  int32_t max_idle;
496  uint16_t pad0;
497  uint16_t default_MSS;
498  int32_t default_RTT;
499  struct pcb_hd tcp_hd;
500 };
501 
505 typedef struct tcp_stats {
506  uint64_t S_TCPS_CLOSED;
507  uint64_t S_TCPS_LISTEN;
508  uint64_t S_TCPS_SYN_SENT;
509  uint64_t S_TCPS_SYN_RCVD;
510  uint64_t S_TCPS_ESTABLISHED;
511  uint64_t S_TCPS_CLOSE_WAIT;
512  uint64_t S_TCPS_FIN_WAIT_1;
513  uint64_t S_TCPS_CLOSING;
514  uint64_t S_TCPS_LAST_ACK;
515  uint64_t S_TCPS_FIN_WAIT_2;
516  uint64_t S_TCPS_TIME_WAIT;
517 
518  uint64_t S_no_syn_rcvd;
519  uint64_t S_invalid_ack;
520  uint64_t S_passive_open;
521  uint64_t S_tcp_rst;
522  uint64_t S_ack_predicted;
523  uint64_t S_data_predicted;
524  uint64_t S_rx_total;
525  uint64_t S_rx_short;
526  uint64_t S_rx_badoff;
527  uint64_t S_delayed_ack;
528  uint64_t S_tcp_rexmit;
529  uint64_t S_resets_sent;
530  uint64_t S_tcp_connect;
532 
533 #define INC_TCP_STAT(x) \
534  do { \
535  this_stk->tcp_stats->S_##x++; \
536  } while (/*CONSTCOND*/ 0)
537 
538 static inline void
539 tcp_send_seq_set(struct tcb_entry *tcb, int x)
540 {
541  struct tcp_entry *tcp = tcb->tcp;
542 
543  tcb->snd_iss = tcp->snd_ISS;
544  tcp->snd_ISS += (TCP_ISSINCR / x);
545  tcb->snd_una = tcb->snd_nxt = tcb->snd_max = tcb->snd_iss;
546 }
547 
548 static inline uint16_t
549 tcp_range_set(int val, int tvmin, int tvmax)
550 {
551  return (uint16_t)((val < tvmin) ? tvmin : (val > tvmax) ? tvmax : val);
552 }
553 
554 static inline void
555 tcb_kill_timers(struct tcb_entry *tcb)
556 {
557  uint64_t *p = (uint64_t *)(uintptr_t)tcb->timers;
558 
559  p[0] = 0;
560 }
561 
565 static inline struct tcb_entry *
567 {
568  struct tcb_entry *tcb = NULL;
569  stk_t *stk = this_stk;
570 
571  if (mempool_get(stk->tcb_objs, (void *)&tcb) < 0)
572  return NULL;
573 
574  if (stk_lock()) {
575  int idx = mempool_obj_index(stk->tcb_objs, tcb);
576 
577  if (idx < 0) {
578  mempool_put(stk->tcb_objs, (void *)tcb);
579  stk_unlock();
580  CNE_NULL_RET("TCB pointer is invalid\n");
581  }
582  bit_set(stk->tcbs, idx);
583  stk_unlock();
584  }
585 
586  return tcb;
587 }
588 
589 static inline void
590 tcb_free(struct tcb_entry *tcb)
591 {
592  stk_t *stk = this_stk;
593 
594  if (tcb) {
595  if (stk_lock()) {
596  int idx = mempool_obj_index(stk->tcb_objs, tcb);
597 
598  if (idx < 0) {
599  CNE_ERR("invalid TCB pointer\n");
600  return;
601  }
602  bit_clear(stk->tcbs, idx);
603  memset(tcb, 0, sizeof(struct tcb_entry));
604  stk_unlock();
605  }
606 
607  mempool_put(stk->tcb_objs, tcb);
608  }
609 }
610 
611 static inline void
612 tcp_flags_dump(const char *msg, uint8_t flags)
613 {
614  const char *flag_names[] = TCP_FLAGS;
615 
616  if (msg)
617  cne_printf("[magenta]%s[]: ", msg);
618  for (int i = 0; i < cne_countof(flag_names); i++) {
619  if (flags & (1 << i))
620  cne_printf("[orange]%s[] ", flag_names[i]);
621  }
622  cne_printf("\n");
623 }
624 
625 #if CNET_TCP_DUMP_ENABLED
626 #define TCP_DUMP(tcp) \
627  do { \
628  cne_printf("[cyan]([orange]%s[cyan]:[orange]%d[cyan]) ", __func__, __LINE__); \
629  cnet_tcp_dump(NULL, tcp); \
630  } while (0)
631 #else
632 #define TCP_DUMP(tcp) \
633  do { \
634  } while (0)
635 #endif
636 
647 CNDP_API int cnet_tcp_input(struct pcb_entry *pcb, pktmbuf_t *mbuf);
648 
655 CNDP_API void cnet_tcp_output(struct tcb_entry *tcb);
656 
665 CNDP_API int cnet_tcp_connect(struct pcb_entry *pcb);
666 
675 CNDP_API struct tcb_entry *cnet_tcb_new(struct pcb_entry *pcb);
676 
683 CNDP_API void cnet_tcp_abort(struct pcb_entry *pcb);
684 
693 CNDP_API int cnet_tcp_close(struct pcb_entry *pcb);
694 
704 void *tcp_q_pop(struct tcp_q *tq);
705 
714 CNDP_API void cnet_tcp_dump(const char *msg, struct cne_tcp_hdr *tcp);
715 
724 CNDP_API void cnet_tcb_list(stk_t *stk, struct tcb_entry *tcb);
725 
729 CNDP_API void cnet_tcb_dump(void);
730 
731 #ifdef __cplusplus
732 }
733 #endif
734 
735 #endif /* __CNET_TCP_H */
#define __cne_aligned(a)
Definition: cne_common.h:124
#define CNE_NULL_RET(...)
Definition: cne_log.h:262
CNDP_API int cne_printf(const char *fmt,...)
CNDP_API int cnet_tcp_connect(struct pcb_entry *pcb)
CNDP_API int cnet_tcp_close(struct pcb_entry *pcb)
CNDP_API void cnet_tcb_list(stk_t *stk, struct tcb_entry *tcb)
tcb_state_t
Definition: cnet_tcp.h:122
@ TCPS_FIN_WAIT_1
Definition: cnet_tcp.h:130
@ TCPS_CLOSED
Definition: cnet_tcp.h:124
@ TCPS_FIN_WAIT_2
Definition: cnet_tcp.h:133
@ TCPS_CLOSING
Definition: cnet_tcp.h:131
@ TCPS_ESTABLISHED
Definition: cnet_tcp.h:128
@ TCPS_TIME_WAIT
Definition: cnet_tcp.h:134
@ TCPS_CLOSE_WAIT
Definition: cnet_tcp.h:129
@ TCPS_SYN_SENT
Definition: cnet_tcp.h:126
@ TCPS_LISTEN
Definition: cnet_tcp.h:125
@ TCPS_LAST_ACK
Definition: cnet_tcp.h:132
@ TCPS_SYN_RCVD
Definition: cnet_tcp.h:127
CNDP_API void cnet_tcp_dump(const char *msg, struct cne_tcp_hdr *tcp)
@ TCP_FAST_TIMER
Definition: cnet_tcp.h:335
@ TCP_SLOW_TIMER
Definition: cnet_tcp.h:336
CNDP_API void cnet_tcp_abort(struct pcb_entry *pcb)
static struct tcb_entry * tcb_alloc(void)
Definition: cnet_tcp.h:566
#define TCP_ISSINCR
Definition: cnet_tcp.h:253
struct tcp_stats tcp_stats_t
CNDP_API void cnet_tcp_output(struct tcb_entry *tcb)
CNDP_API int cnet_tcp_input(struct pcb_entry *pcb, pktmbuf_t *mbuf)
@ SEG_TS_PRESENT
Definition: cnet_tcp.h:328
@ SEG_WS_PRESENT
Definition: cnet_tcp.h:330
@ SEG_MSS_PRESENT
Definition: cnet_tcp.h:329
@ SEG_SACK_PERMIT
Definition: cnet_tcp.h:331
@ TCBF_NODELAY
Definition: cnet_tcp.h:437
@ TCBF_REQ_SCALE
Definition: cnet_tcp.h:429
@ TCBF_RCVD_TSTAMP
Definition: cnet_tcp.h:435
@ TCBF_OUR_FIN_ACKED
Definition: cnet_tcp.h:439
@ TCBF_FORCE_TX
Definition: cnet_tcp.h:418
@ TCBF_NEED_FAST_REXMT
Definition: cnet_tcp.h:443
@ TCBF_ACK_NOW
Definition: cnet_tcp.h:432
@ TCBF_RCVD_SCALE
Definition: cnet_tcp.h:428
@ TCBF_SACK_PERMIT
Definition: cnet_tcp.h:434
@ TCBF_SEND_URG
Definition: cnet_tcp.h:430
@ TCBF_NAGLE_CREDIT
Definition: cnet_tcp.h:438
@ TCBF_NOPUSH
Definition: cnet_tcp.h:444
@ TCBF_NOOPT
Definition: cnet_tcp.h:445
@ TCBF_BOUND
Definition: cnet_tcp.h:423
@ TCBF_REQ_TSTAMP
Definition: cnet_tcp.h:427
@ TCBF_DELAYED_ACK
Definition: cnet_tcp.h:419
@ TCBF_PASSIVE_OPEN
Definition: cnet_tcp.h:417
@ TCBF_RFC1122_URG
Definition: cnet_tcp.h:422
@ TCBF_SENT_FIN
Definition: cnet_tcp.h:433
void * tcp_q_pop(struct tcp_q *tq)
@ TCP_NTIMERS
Definition: cnet_tcp.h:299
@ TCPT_2MSL
Definition: cnet_tcp.h:298
@ TCPT_REXMT
Definition: cnet_tcp.h:295
@ TCPT_PERSIST
Definition: cnet_tcp.h:296
@ TCPT_KEEP
Definition: cnet_tcp.h:297
CNDP_API struct tcb_entry * cnet_tcb_new(struct pcb_entry *pcb)
@ TCP_OPT_WSOPT
Definition: cnet_tcp.h:202
@ TCP_OPT_MSS
Definition: cnet_tcp.h:201
@ TCP_OPT_SACK_OK
Definition: cnet_tcp.h:203
@ TCP_OPT_SACK
Definition: cnet_tcp.h:204
@ TCP_OPT_NOP
Definition: cnet_tcp.h:200
@ TCP_OPT_TSTAMP
Definition: cnet_tcp.h:205
@ TCP_OPT_EOL
Definition: cnet_tcp.h:199
CNDP_API void cnet_tcb_dump(void)
CNDP_API int mempool_obj_index(mempool_t *mp, void *obj)
CNDP_API int mempool_get(mempool_t *mp, void **obj_p)
CNDP_API void mempool_put(mempool_t *mp, void *obj)
TAILQ_HEAD(pktdev_driver_list, pktdev_driver)
uint64_t S_tcp_rst
Definition: cnet_tcp.h:521
uint64_t S_invalid_ack
Definition: cnet_tcp.h:519
uint64_t S_tcp_connect
Definition: cnet_tcp.h:530
uint64_t S_TCPS_CLOSED
Definition: cnet_tcp.h:506
uint64_t S_rx_total
Definition: cnet_tcp.h:524
uint64_t S_passive_open
Definition: cnet_tcp.h:520
uint64_t S_resets_sent
Definition: cnet_tcp.h:529
uint64_t S_rx_short
Definition: cnet_tcp.h:525
uint64_t S_no_syn_rcvd
Definition: cnet_tcp.h:518
uint64_t S_rx_badoff
Definition: cnet_tcp.h:526
uint64_t S_delayed_ack
Definition: cnet_tcp.h:527
uint64_t S_ack_predicted
Definition: cnet_tcp.h:522
uint64_t S_data_predicted
Definition: cnet_tcp.h:523
uint64_t S_tcp_rexmit
Definition: cnet_tcp.h:528