netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Boris Pismenny <borisp@mellanox.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, saeedm@mellanox.com, borisp@mellanox.com,
	davejwatson@fb.com, ktkhai@virtuozzo.com,
	Ilya Lesokhin <ilyal@mellanox.com>,
	Aviad Yehezkel <aviadye@mellanox.com>
Subject: [PATCH V7 net-next 01/14] tcp: Add clean acked data hook
Date: Tue, 24 Apr 2018 16:12:52 +0300	[thread overview]
Message-ID: <1524575585-49541-2-git-send-email-borisp@mellanox.com> (raw)
In-Reply-To: <1524575585-49541-1-git-send-email-borisp@mellanox.com>

From: Ilya Lesokhin <ilyal@mellanox.com>

Called when a TCP segment is acknowledged.
Could be used by application protocols who hold additional
metadata associated with the stream data.

This is required by TLS device offload to release
metadata associated with acknowledged TLS records.

Signed-off-by: Ilya Lesokhin <ilyal@mellanox.com>
Signed-off-by: Boris Pismenny <borisp@mellanox.com>
Signed-off-by: Aviad Yehezkel <aviadye@mellanox.com>
---
 include/net/inet_connection_sock.h |  2 ++
 include/net/tcp.h                  |  8 ++++++++
 net/ipv4/tcp_input.c               | 25 +++++++++++++++++++++++++
 3 files changed, 35 insertions(+)

diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
index b68fea0..2ab6667 100644
--- a/include/net/inet_connection_sock.h
+++ b/include/net/inet_connection_sock.h
@@ -77,6 +77,7 @@ struct inet_connection_sock_af_ops {
  * @icsk_af_ops		   Operations which are AF_INET{4,6} specific
  * @icsk_ulp_ops	   Pluggable ULP control hook
  * @icsk_ulp_data	   ULP private data
+ * @icsk_clean_acked	   Clean acked data hook
  * @icsk_listen_portaddr_node	hash to the portaddr listener hashtable
  * @icsk_ca_state:	   Congestion control state
  * @icsk_retransmits:	   Number of unrecovered [RTO] timeouts
@@ -102,6 +103,7 @@ struct inet_connection_sock {
 	const struct inet_connection_sock_af_ops *icsk_af_ops;
 	const struct tcp_ulp_ops  *icsk_ulp_ops;
 	void			  *icsk_ulp_data;
+	void (*icsk_clean_acked)(struct sock *sk, u32 acked_seq);
 	struct hlist_node         icsk_listen_portaddr_node;
 	unsigned int		  (*icsk_sync_mss)(struct sock *sk, u32 pmtu);
 	__u8			  icsk_ca_state:6,
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 833154e..cf803fe 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -2105,4 +2105,12 @@ static inline bool tcp_bpf_ca_needs_ecn(struct sock *sk)
 #if IS_ENABLED(CONFIG_SMC)
 extern struct static_key_false tcp_have_smc;
 #endif
+
+#if IS_ENABLED(CONFIG_TLS_DEVICE)
+void clean_acked_data_enable(struct inet_connection_sock *icsk,
+			     void (*cad)(struct sock *sk, u32 ack_seq));
+void clean_acked_data_disable(struct inet_connection_sock *icsk);
+
+#endif
+
 #endif	/* _TCP_H */
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 17b7858..8b92cd2 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -112,6 +112,25 @@
 #define REXMIT_LOST	1 /* retransmit packets marked lost */
 #define REXMIT_NEW	2 /* FRTO-style transmit of unsent/new packets */
 
+#if IS_ENABLED(CONFIG_TLS_DEVICE)
+static DEFINE_STATIC_KEY_FALSE(clean_acked_data_enabled);
+
+void clean_acked_data_enable(struct inet_connection_sock *icsk,
+			     void (*cad)(struct sock *sk, u32 ack_seq))
+{
+	icsk->icsk_clean_acked = cad;
+	static_branch_inc(&clean_acked_data_enabled);
+}
+EXPORT_SYMBOL_GPL(clean_acked_data_enable);
+
+void clean_acked_data_disable(struct inet_connection_sock *icsk)
+{
+	static_branch_dec(&clean_acked_data_enabled);
+	icsk->icsk_clean_acked = NULL;
+}
+EXPORT_SYMBOL_GPL(clean_acked_data_disable);
+#endif
+
 static void tcp_gro_dev_warn(struct sock *sk, const struct sk_buff *skb,
 			     unsigned int len)
 {
@@ -3561,6 +3580,12 @@ static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag)
 	if (after(ack, prior_snd_una)) {
 		flag |= FLAG_SND_UNA_ADVANCED;
 		icsk->icsk_retransmits = 0;
+
+#if IS_ENABLED(CONFIG_TLS_DEVICE)
+		if (static_branch_unlikely(&clean_acked_data_enabled))
+			if (icsk->icsk_clean_acked)
+				icsk->icsk_clean_acked(sk, ack);
+#endif
 	}
 
 	prior_fack = tcp_is_sack(tp) ? tcp_highest_sack_seq(tp) : tp->snd_una;
-- 
1.8.3.1

  reply	other threads:[~2018-04-24 13:13 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-24 13:12 [PATCH V7 net-next 00/14] TLS offload, netdev & MLX5 support Boris Pismenny
2018-04-24 13:12 ` Boris Pismenny [this message]
2018-04-24 13:12 ` [PATCH V7 net-next 02/14] net: Rename and export copy_skb_header Boris Pismenny
2018-04-24 13:12 ` [PATCH V7 net-next 03/14] net: Add Software fallback infrastructure for socket dependent offloads Boris Pismenny
2018-04-24 13:12 ` [PATCH V7 net-next 04/14] net: Add TLS offload netdev ops Boris Pismenny
2018-04-24 13:12 ` [PATCH V7 net-next 05/14] net: Add TLS TX offload features Boris Pismenny
2018-04-24 13:12 ` [PATCH V7 net-next 06/14] net/tls: Split conf to rx + tx Boris Pismenny
2018-04-24 13:12 ` [PATCH V7 net-next 07/14] net/tls: Add generic NIC offload infrastructure Boris Pismenny
2018-04-24 13:12 ` [PATCH V7 net-next 08/14] net/mlx5e: Move defines out of ipsec code Boris Pismenny
2018-04-24 13:13 ` [PATCH V7 net-next 09/14] net/mlx5: Accel, Add TLS tx offload interface Boris Pismenny
2018-04-24 13:13 ` [PATCH V7 net-next 10/14] net/mlx5e: TLS, Add Innova TLS TX support Boris Pismenny
2018-04-24 13:13 ` [PATCH V7 net-next 11/14] net/mlx5e: TLS, Add Innova TLS TX offload data path Boris Pismenny
2018-04-24 13:13 ` [PATCH V7 net-next 12/14] net/mlx5e: TLS, Add error statistics Boris Pismenny
2018-04-24 13:13 ` [PATCH V7 net-next 13/14] MAINTAINERS: Update mlx5 innova driver maintainers Boris Pismenny
2018-04-24 13:13 ` [PATCH V7 net-next 14/14] MAINTAINERS: Update TLS maintainers Boris Pismenny
2018-04-24 18:02 ` [PATCH V7 net-next 00/14] TLS offload, netdev & MLX5 support David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1524575585-49541-2-git-send-email-borisp@mellanox.com \
    --to=borisp@mellanox.com \
    --cc=aviadye@mellanox.com \
    --cc=davejwatson@fb.com \
    --cc=davem@davemloft.net \
    --cc=ilyal@mellanox.com \
    --cc=ktkhai@virtuozzo.com \
    --cc=netdev@vger.kernel.org \
    --cc=saeedm@mellanox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).