Skip to content

Commit b3ae245

Browse files
Tariq Toukandavem330
authored andcommitted
net/tls: Add force_resync for driver resync
This patch adds a field to the tls rx offload context which enables drivers to force a send_resync call. This field can be used by drivers to request a resync at the next possible tls record. It is beneficial for hardware that provides the resync sequence number asynchronously. In such cases, the packet that triggered the resync does not contain the information required for a resync. Instead, the driver requests resync for all the following TLS record until the asynchronous notification with the resync request TCP sequence arrives. A following series for mlx5e ConnectX-6DX TLS RX offload support will use this mechanism. Signed-off-by: Boris Pismenny <[email protected]> Signed-off-by: Tariq Toukan <[email protected]> Reviewed-by: Maxim Mikityanskiy <[email protected]> Reviewed-by: Saeed Mahameed <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent bdad7f9 commit b3ae245

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

include/net/tls.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,12 +594,22 @@ tls_driver_ctx(const struct sock *sk, enum tls_offload_ctx_dir direction)
594594
#endif
595595

596596
/* The TLS context is valid until sk_destruct is called */
597+
#define RESYNC_REQ (1 << 0)
598+
#define RESYNC_REQ_FORCE (1 << 1)
597599
static inline void tls_offload_rx_resync_request(struct sock *sk, __be32 seq)
598600
{
599601
struct tls_context *tls_ctx = tls_get_ctx(sk);
600602
struct tls_offload_context_rx *rx_ctx = tls_offload_ctx_rx(tls_ctx);
601603

602-
atomic64_set(&rx_ctx->resync_req, ((u64)ntohl(seq) << 32) | 1);
604+
atomic64_set(&rx_ctx->resync_req, ((u64)ntohl(seq) << 32) | RESYNC_REQ);
605+
}
606+
607+
static inline void tls_offload_rx_force_resync_request(struct sock *sk)
608+
{
609+
struct tls_context *tls_ctx = tls_get_ctx(sk);
610+
struct tls_offload_context_rx *rx_ctx = tls_offload_ctx_rx(tls_ctx);
611+
612+
atomic64_set(&rx_ctx->resync_req, RESYNC_REQ | RESYNC_REQ_FORCE);
603613
}
604614

605615
static inline void

net/tls/tls_device.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -694,10 +694,11 @@ void tls_device_rx_resync_new_rec(struct sock *sk, u32 rcd_len, u32 seq)
694694
{
695695
struct tls_context *tls_ctx = tls_get_ctx(sk);
696696
struct tls_offload_context_rx *rx_ctx;
697+
bool is_req_pending, is_force_resync;
697698
u8 rcd_sn[TLS_MAX_REC_SEQ_SIZE];
698-
u32 sock_data, is_req_pending;
699699
struct tls_prot_info *prot;
700700
s64 resync_req;
701+
u32 sock_data;
701702
u32 req_seq;
702703

703704
if (tls_ctx->rx_conf != TLS_HW)
@@ -712,9 +713,11 @@ void tls_device_rx_resync_new_rec(struct sock *sk, u32 rcd_len, u32 seq)
712713
resync_req = atomic64_read(&rx_ctx->resync_req);
713714
req_seq = resync_req >> 32;
714715
seq += TLS_HEADER_SIZE - 1;
715-
is_req_pending = resync_req;
716+
is_req_pending = resync_req & RESYNC_REQ;
717+
is_force_resync = resync_req & RESYNC_REQ_FORCE;
716718

717-
if (likely(!is_req_pending) || req_seq != seq ||
719+
if (likely(!is_req_pending) ||
720+
(!is_force_resync && req_seq != seq) ||
718721
!atomic64_try_cmpxchg(&rx_ctx->resync_req, &resync_req, 0))
719722
return;
720723
break;

0 commit comments

Comments
 (0)