-#define TCP_DEBUG_CC_STAT (1)
-#define TCP_DEBUG_BUFFER_ALLOCATION (0)
-
-#define foreach_tcp_dbg_evt \
- _(INIT, "") \
- _(DEALLOC, "") \
- _(OPEN, "open") \
- _(CLOSE, "close") \
- _(BIND, "bind") \
- _(UNBIND, "unbind") \
- _(DELETE, "delete") \
- _(SYN_SENT, "SYN sent") \
- _(SYNACK_SENT, "SYNACK sent") \
- _(SYNACK_RCVD, "SYNACK rcvd") \
- _(SYN_RXT, "SYN retransmit") \
- _(FIN_SENT, "FIN sent") \
- _(ACK_SENT, "ACK sent") \
- _(DUPACK_SENT, "DUPACK sent") \
- _(RST_SENT, "RST sent") \
- _(SYN_RCVD, "SYN rcvd") \
- _(ACK_RCVD, "ACK rcvd") \
- _(DUPACK_RCVD, "DUPACK rcvd") \
- _(FIN_RCVD, "FIN rcvd") \
- _(RST_RCVD, "RST rcvd") \
- _(STATE_CHANGE, "state change") \
- _(PKTIZE, "packetize") \
- _(INPUT, "in") \
- _(SND_WND, "snd_wnd update") \
- _(OUTPUT, "output") \
- _(TIMER_POP, "timer pop") \
- _(CC_RTX, "retransmit") \
- _(CC_EVT, "cc event") \
- _(CC_PACK, "cc partial ack") \
- _(CC_STAT, "cc stats") \
- _(CC_RTO_STAT, "cc rto stats") \
- _(SEG_INVALID, "invalid segment") \
- _(PAWS_FAIL, "failed paws check") \
- _(ACK_RCV_ERR, "invalid ack") \
- _(RCV_WND_SHRUNK, "shrunk rcv_wnd") \
-
-typedef enum _tcp_dbg
+#define TCP_DEBUG_CS (0)
+#define TCP_DEBUG_LC (0 || TCP_DEBUG_SM || TCP_DEBUG_CC || TCP_DEBUG_CS)
+
+#define TCP_DEBUG (TCP_DEBUG_ALWAYS || TCP_DEBUG_ENABLE)
+#define TCP_DEBUG_BUF_ALLOC (0)
+
+#if TCP_DEBUG > 0
+#define TRANSPORT_DEBUG (1)
+#endif
+
+#define TCP_CONCAT_HELPER(_a, _b) _a##_b
+#define TCP_CC(_a, _b) TCP_CONCAT_HELPER(_a, _b)
+
+#define tcp_evt_lvl(_evt) TCP_CC(_evt, _LVL)
+#define tcp_evt_grp(_evt) TCP_CC(_evt, _GRP)
+#define tcp_evt_handler(_evt, _args...) TCP_CC(_evt, _HANDLER) (_args)
+#define tcp_evt_grp_dbg_lvl(_evt) tcp_dbg_main.grp_dbg_lvl[tcp_evt_grp (_evt)]
+
+#define foreach_tcp_evt_grp \
+ _(LC, "life cycle") \
+ _(SM, "state machine") \
+ _(CC, "congestion control") \
+ _(CS, "cc stats") \
+
+typedef enum tcp_evt_grp_
+{
+#define _(sym, str) TCP_EVT_GRP_ ## sym,
+ foreach_tcp_evt_grp
+#undef _
+ TCP_EVT_N_GRP
+} tcp_evt_grp_e;
+
+typedef struct tcp_dbg_main_
+{
+ u8 grp_dbg_lvl[TCP_EVT_N_GRP];
+ u32 *free_track_indices;
+} tcp_dbg_main_t;
+
+extern tcp_dbg_main_t tcp_dbg_main;
+
+#define foreach_tcp_dbg_evt \
+ _(INIT, LC, 1, "init") \
+ _(DEALLOC, LC, 1, "dealloc") \
+ _(OPEN, LC, 1, "open") \
+ _(CLOSE, LC, 1, "close") \
+ _(BIND, LC, 1, "bind") \
+ _(UNBIND, LC, 1, "unbind") \
+ _(DELETE, LC, 1, "delete") \
+ _(SYN_RCVD, LC, 1, "SYN rcvd") \
+ _(STATE_CHANGE, LC, 1, "state change") \
+ _(SYN_SENT, SM, 1, "SYN sent") \
+ _(SYN_RXT, SM, 1, "SYN retransmit") \
+ _(SYNACK_SENT, SM, 1, "SYNACK sent") \
+ _(SYNACK_RCVD, SM, 1, "SYNACK rcvd") \
+ _(FIN_SENT, SM, 1, "FIN sent") \
+ _(FIN_RCVD, SM, 1, "FIN rcvd") \
+ _(RST_SENT, SM, 1, "RST sent") \
+ _(RST_RCVD, SM, 1, "RST rcvd") \
+ _(TIMER_POP, SM, 1, "timer pop") \
+ _(SEG_INVALID, SM, 2, "invalid segment") \
+ _(PAWS_FAIL, SM, 2, "failed paws check") \
+ _(ACK_RCV_ERR, SM, 2, "invalid ack") \
+ _(RCV_WND_SHRUNK, SM, 2, "shrunk rcv_wnd") \
+ _(ACK_SENT, SM, 3, "ACK sent") \
+ _(ACK_RCVD, SM, 3, "ACK rcvd") \
+ _(PKTIZE, SM, 3, "packetize") \
+ _(INPUT, SM, 3, "in") \
+ _(OUTPUT, SM, 4, "output") \
+ _(SND_WND, SM, 4, "snd_wnd update") \
+ _(CC_EVT, CC, 1, "cc event") \
+ _(CC_RTX, CC, 2, "retransmit") \
+ _(CC_PACK, CC, 2, "cc partial ack") \
+ _(DUPACK_SENT, CC, 2, "DUPACK sent") \
+ _(DUPACK_RCVD, CC, 2, "DUPACK rcvd") \
+ _(CC_SCOREBOARD, CC, 2, "scoreboard stats") \
+ _(CC_SACKS, CC, 2, "snd sacks stats") \
+ _(CC_INPUT, CC, 2, "ooo data delivered") \
+ _(CC_STAT, CS, 1, "cc stats") \
+ _(CC_RTO_STAT, CS, 1, "cc rto stats") \
+
+typedef enum tcp_evt_types_
+{
+#define _(sym, grp, lvl, str) TCP_EVT_##sym,
+ foreach_tcp_dbg_evt
+#undef _
+} tcp_evt_types_e;
+
+typedef enum tcp_evt_lvl_