Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/app/shared/fd_action.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ union fdctl_args {
int dump; /* whether the user requested --dump */
int dump_config; /* whether the user requested to dump the quic config */
int dump_conns; /* whether the user requested to dump the quic connections */
int trace_send; /* whether the user requested tracing send tile (1) or quic tile (0) */
} quic_trace;

struct {
Expand Down
54 changes: 34 additions & 20 deletions src/app/shared_dev/commands/quic_trace/fd_quic_trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "../../../shared/fd_config.h"
#include "../../../shared/fd_action.h"
#include "../../../../disco/net/fd_net_tile.h"
#include "../../../../disco/quic/fd_quic_tile.h"
#include "../../../../waltz/quic/fd_quic_private.h"

Expand All @@ -24,15 +25,12 @@ typedef struct peer_conn_id_map peer_conn_id_map_t;
#define MAP_LG_SLOT_CNT PEER_MAP_LG_SLOT_CNT
#include "../../../../util/tmpl/fd_map.c"

/* fd_quic_trace_ctx is the relocated fd_quic_ctx_t of the target quic
tile. fd_quic_trace_ctx_remote is the original fd_quic_ctx_t, but
the pointer itself is in the local address space. */

extern fd_quic_ctx_t fd_quic_trace_ctx;
extern fd_quic_ctx_t const * fd_quic_trace_ctx_remote;
extern ulong fd_quic_trace_ctx_raddr;
extern ulong volatile * fd_quic_trace_link_metrics;
extern void const * fd_quic_trace_log_base;
/* fd_quic_trace_ctx_remote is the original fd_quic_ctx_t, but the
pointer itself is in the local address space. */
extern void const * fd_quic_trace_tile_ctx_remote; /* local ptr to remote ctx */
extern ulong fd_quic_trace_tile_ctx_raddr; /* remote addr of remote ctx */
extern ulong volatile * fd_quic_trace_link_metrics;
extern void const * fd_quic_trace_log_base;
extern peer_conn_id_map_t _fd_quic_trace_peer_map[1UL<<PEER_MAP_LG_SLOT_CNT];
extern peer_conn_id_map_t * fd_quic_trace_peer_map;

Expand All @@ -45,8 +43,12 @@ struct fd_quic_trace_ctx {
int dump; /* whether the user requested --dump */
int dump_config; /* whether the user requested --dump-config */
int dump_conns; /* whether the user requested --dump-conns */
int net_out; /* whether to include tx (net-out) packets */
int trace_send; /* whether the user requested tracing send tile (1) or quic tile (0) */
ulong net_out_base; /* base address of net-out chunks in local addr space */

fd_quic_t * quic; /* local join to remote quic */
fd_net_rx_bounds_t net_in_bounds[1]; /* bounds of net-in chunks in local addr space */
uchar buffer[ FD_NET_MTU ];
};

typedef struct fd_quic_trace_ctx fd_quic_trace_ctx_t;
Expand All @@ -61,29 +63,41 @@ struct fd_quic_trace_frame_ctx {

typedef struct fd_quic_trace_frame_ctx fd_quic_trace_frame_ctx_t;

#define translate_ptr( ptr ) __extension__({ \
ulong rel = (ulong)(ptr) - fd_quic_trace_tile_ctx_raddr; \
ulong laddr = (ulong)fd_quic_trace_tile_ctx_remote + rel; \
(__typeof__(ptr))(laddr); \
})

#define tile_member( ctx_ptr, field, is_send ) \
*fd_ptr_if( is_send, &(((fd_send_tile_ctx_t*)(ctx_ptr))->field), &(((fd_quic_ctx_t*)(ctx_ptr))->field))


FD_PROTOTYPES_BEGIN

void
fd_quic_trace_frames( fd_quic_trace_frame_ctx_t * context,
uchar const * data,
ulong data_sz );
uchar const * data,
ulong data_sz );

void
fd_quic_trace_rx_tile( fd_quic_trace_ctx_t * trace_ctx,
fd_quic_trace_rx_tile( fd_quic_trace_ctx_t * trace_ctx,
fd_frag_meta_t const * rx_mcache,
fd_frag_meta_t const * tx_mcache );

void
fd_quic_trace_log_tile( fd_frag_meta_t const * in_mcache );
fd_quic_trace_log_tile( fd_quic_trace_ctx_t * ctx,
fd_frag_meta_t const * in_mcache );

FD_PROTOTYPES_END
static inline fd_quic_conn_t const *
fd_quic_trace_conn_at_idx( fd_quic_t const * quic, ulong idx ) {
fd_quic_state_t const * state = fd_quic_get_state_const( quic );
ulong const local_conn_base = translate_ptr( state->conn_base );
return (fd_quic_conn_t *)( local_conn_base + idx * state->conn_sz );
}

FD_PROTOTYPES_END

#define translate_ptr( ptr ) __extension__({ \
ulong rel = (ulong)(ptr) - fd_quic_trace_ctx_raddr; \
ulong laddr = (ulong)fd_quic_trace_ctx_remote + rel; \
(__typeof__(ptr))(laddr); \
})

extern action_t fd_action_quic_trace;

Expand Down
42 changes: 21 additions & 21 deletions src/app/shared_dev/commands/quic_trace/fd_quic_trace_log_tile.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,25 @@ before_frag( void * _ctx FD_FN_UNUSED,
}

static void
during_frag( void * _ctx FD_PARAM_UNUSED,
ulong in_idx FD_PARAM_UNUSED,
ulong seq FD_PARAM_UNUSED,
ulong sig FD_PARAM_UNUSED,
ulong chunk,
ulong sz,
ulong ctl FD_PARAM_UNUSED ) {
fd_quic_ctx_t * ctx = &fd_quic_trace_ctx;
during_frag( fd_quic_trace_ctx_t * ctx,
ulong in_idx FD_PARAM_UNUSED,
ulong seq FD_PARAM_UNUSED,
ulong sig FD_PARAM_UNUSED,
ulong chunk,
ulong sz,
ulong ctl FD_PARAM_UNUSED ) {
fd_memcpy( ctx->buffer, fd_chunk_to_laddr_const( fd_quic_trace_log_base, chunk ), sz );
}

static void
after_frag( void * _ctx FD_FN_UNUSED,
ulong in_idx FD_FN_UNUSED,
ulong seq FD_FN_UNUSED,
ulong sig FD_FN_UNUSED,
ulong sz FD_FN_UNUSED,
ulong tsorig FD_FN_UNUSED,
ulong tspub FD_FN_UNUSED,
fd_stem_context_t * stem FD_FN_UNUSED ) {
fd_quic_ctx_t * ctx = &fd_quic_trace_ctx;
after_frag( fd_quic_trace_ctx_t * ctx,
ulong in_idx FD_FN_UNUSED,
ulong seq FD_FN_UNUSED,
ulong sig FD_FN_UNUSED,
ulong sz FD_FN_UNUSED,
ulong tsorig FD_FN_UNUSED,
ulong tspub FD_FN_UNUSED,
fd_stem_context_t * stem FD_FN_UNUSED ) {
fd_quic_log_error_t const * error = fd_type_pun_const( ctx->buffer );
printf( "event=conn_close_quic conn_id=%016lx src_ip=%08x enc=%d pktnum=%8lu close_code=0x%lx loc=%.*s(%u)\n",
error->hdr.conn_id,
Expand All @@ -49,16 +47,18 @@ after_frag( void * _ctx FD_FN_UNUSED,

#define STEM_BURST (1UL)

#define STEM_CALLBACK_CONTEXT_TYPE void
#define STEM_CALLBACK_CONTEXT_ALIGN 1
#define STEM_CALLBACK_CONTEXT_TYPE fd_quic_trace_ctx_t
#define STEM_CALLBACK_CONTEXT_ALIGN alignof(fd_quic_trace_ctx_t)

#define STEM_CALLBACK_BEFORE_FRAG before_frag
#define STEM_CALLBACK_DURING_FRAG during_frag
#define STEM_CALLBACK_AFTER_FRAG after_frag

#include "../../../../disco/stem/fd_stem.c"

void
fd_quic_trace_log_tile( fd_frag_meta_t const * in_mcache ) {
fd_quic_trace_log_tile( fd_quic_trace_ctx_t * ctx,
fd_frag_meta_t const * in_mcache ) {
fd_frag_meta_t const * in_mcache_tbl[1] = { in_mcache };

uchar fseq_mem[ FD_FSEQ_FOOTPRINT ] __attribute__((aligned(FD_FSEQ_ALIGN)));
Expand All @@ -82,7 +82,7 @@ fd_quic_trace_log_tile( fd_frag_meta_t const * in_mcache ) {
/* stem_lazy */ 0L,
/* rng */ rng,
/* scratch */ scratch,
/* ctx */ NULL );
/* ctx */ ctx );

fd_fseq_delete( fd_fseq_leave( fseq ) );
}
Loading
Loading