Skip to content

Commit

Permalink
ON-15745: shuffle enlarged timestamps into packet metadata padding
Browse files Browse the repository at this point in the history
  • Loading branch information
abower-amd committed May 21, 2024
1 parent 3ab5f84 commit b320f71
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 18 deletions.
38 changes: 24 additions & 14 deletions src/include/ci/internal/ip_shared_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ typedef struct {
typedef ci_uint16 oo_ts_flags_t;

/* Timestamp structure including fractional nanoseconds and the sync
* flags that apply to the timetamp. Equivalent to ef_precisetime. */
* flags that apply to the timestamp. Equivalent to ef_precisetime. */
struct oo_timespec {
ci_int64 tv_sec;
ci_uint32 tv_nsec;
Expand Down Expand Up @@ -239,9 +239,6 @@ typedef union {
oo_pkt_p block_end; /* end of the current (un)sacked block */
oo_sp sock_id; /* The socket this pkt is tx'd on:
* used in oo_deferred_arp_failed() */
#if CI_CFG_TIMESTAMPING
struct oo_timespec first_tx_hw_stamp; /* Timestamp of the first transmit */
#endif
ci_user_ptr_t next CI_ALIGN(8); /* for ci_tcp_sendmsg() local use only! */
} tcp_tx CI_ALIGN(8);
struct {
Expand Down Expand Up @@ -276,8 +273,28 @@ struct ci_ip_pkt_fmt_s {
* latency). The speculation is that the cause of the slowdown is cache
* associativity set contention. Ideas for removing this wasted space
* include non-power-of-2 packet buffers and split metadata/payload of
* packet buffers. */
char unused_padding[CI_CACHE_LINE_SIZE];
* packet buffers.
*
* Share said wasted space with expanded timestamp structure */
union {
char unused_padding[CI_CACHE_LINE_SIZE];

#if CI_CFG_TIMESTAMPING
struct {
/*! Timestamp of the first TCP transmit */
struct oo_timespec first_tx_hw_stamp;

/*! UTC time we were sent or received according to hw */
struct oo_timespec hw_stamp;

/*! Key for SOF_TIMESTAMPING_OPT_ID */
ci_uint32 ts_key;
};
#endif
};

/* N.B. The first member after the above padding is the subject of
* a static assertion defined after this struct. */

/* For use by transport layer to form linked lists. */
oo_pkt_p next;
Expand Down Expand Up @@ -343,14 +360,6 @@ struct ci_ip_pkt_fmt_s {
/*! Length of data from base_addr used in this buffer. */
ci_int16 buf_len;

#if CI_CFG_TIMESTAMPING
/*! UTC time we were sent or received according to hw */
struct oo_timespec hw_stamp;

/*! Key for SOF_TIMESTAMPING_OPT_ID */
ci_uint32 ts_key;
#endif

union {
struct {
oo_pkt_p dmaq_next; /**< Next packet in the overflow queue. */
Expand Down Expand Up @@ -462,6 +471,7 @@ struct ci_ip_pkt_fmt_s {
ci_uint8 dma_start[1] CI_ALIGN(EF_VI_DMA_ALIGN);
};

CI_BUILD_ASSERT(offsetof(struct ci_ip_pkt_fmt_s, next) == CI_CACHE_LINE_SIZE);

#define CI_PKT_ZC_PAYLOAD_ALIGN 8
struct ci_pkt_zc_payload {
Expand Down
6 changes: 3 additions & 3 deletions src/lib/transport/ip/ip_tx_cmsg.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,10 @@ static inline int ci_ip_tx_timestamping_to_cmsg(int proto, ci_netif* ni,
OO_TS_FLAG_ACCEPTABLE;

if( pkt->flags & CI_PKT_FLAG_RTQ_RETRANS ) {
if( pkt->pf.tcp_tx.first_tx_hw_stamp.tv_flags &
if( pkt->first_tx_hw_stamp.tv_flags &
OO_TS_FLAG_ACCEPTABLE ) {
stamps.first_sent.tv_sec = pkt->pf.tcp_tx.first_tx_hw_stamp.tv_sec;
stamps.first_sent.tv_nsec = pkt->pf.tcp_tx.first_tx_hw_stamp.tv_nsec;
stamps.first_sent.tv_sec = pkt->first_tx_hw_stamp.tv_sec;
stamps.first_sent.tv_nsec = pkt->first_tx_hw_stamp.tv_nsec;
}
if( tx_hw_stamp_in_sync ) {
stamps.last_sent.tv_sec = pkt->hw_stamp.tv_sec;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/transport/ip/tcp_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,7 @@ int ci_tcp_retrans_one(ci_tcp_state* ts, ci_netif* netif, ci_ip_pkt_fmt* pkt)
#if CI_CFG_TIMESTAMPING
if( (pkt->flags & (CI_PKT_FLAG_RTQ_RETRANS | CI_PKT_FLAG_TX_TIMESTAMPED)) ==
CI_PKT_FLAG_TX_TIMESTAMPED )
pkt->pf.tcp_tx.first_tx_hw_stamp = pkt->hw_stamp;
pkt->first_tx_hw_stamp = pkt->hw_stamp;
#endif
ci_tcp_tx_maybe_do_striping(pkt, ts);
__ci_ip_send_tcp(netif, pkt, ts);
Expand Down

0 comments on commit b320f71

Please sign in to comment.