[PATCH mptcp-next v11 03/11] Squash to "mptcp: add sched_data_set_contexts helper"

Geliang Tang posted 11 patches 2 years, 7 months ago
Maintainers: Matthieu Baerts <matthieu.baerts@tessares.net>, Mat Martineau <martineau@kernel.org>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Andrii Nakryiko <andrii@kernel.org>, Mykola Lysenko <mykolal@fb.com>, Alexei Starovoitov <ast@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, Martin KaFai Lau <martin.lau@linux.dev>, Song Liu <song@kernel.org>, Yonghong Song <yhs@fb.com>, John Fastabend <john.fastabend@gmail.com>, KP Singh <kpsingh@kernel.org>, Stanislav Fomichev <sdf@google.com>, Hao Luo <haoluo@google.com>, Jiri Olsa <jolsa@kernel.org>, Shuah Khan <shuah@kernel.org>
[PATCH mptcp-next v11 03/11] Squash to "mptcp: add sched_data_set_contexts helper"
Posted by Geliang Tang 2 years, 7 months ago
mptcp: add sched_data helpers

Add a new helper mptcp_sched_data_set_contexts() to set the subflow
pointers array in struct mptcp_sched_data. Add a new helper
mptcp_subflow_ctx_by_pos() to get the given pos subflow from the
contexts array in struct mptcp_sched_data. They will be invoked by
the BPF schedulers to export the subflow pointers to the BPF contexts.

Signed-off-by: Geliang Tang <geliang.tang@suse.com>
---
 net/mptcp/protocol.h | 2 ++
 net/mptcp/sched.c    | 9 +++++++++
 2 files changed, 11 insertions(+)

diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
index 8c9b2a03dc94..cb2f34c8ed09 100644
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -664,6 +664,8 @@ void mptcp_subflow_set_scheduled(struct mptcp_subflow_context *subflow,
 				 bool scheduled);
 void mptcp_sched_data_set_contexts(const struct mptcp_sock *msk,
 				   struct mptcp_sched_data *data);
+struct mptcp_subflow_context *
+mptcp_subflow_ctx_by_pos(const struct mptcp_sched_data *data, unsigned int pos);
 struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk);
 struct sock *mptcp_subflow_get_retrans(struct mptcp_sock *msk);
 int mptcp_sched_get_send(struct mptcp_sock *msk);
diff --git a/net/mptcp/sched.c b/net/mptcp/sched.c
index c7c167e48d72..82665263bb94 100644
--- a/net/mptcp/sched.c
+++ b/net/mptcp/sched.c
@@ -108,11 +108,20 @@ void mptcp_sched_data_set_contexts(const struct mptcp_sock *msk,
 		mptcp_subflow_set_scheduled(subflow, false);
 		data->contexts[i++] = subflow;
 	}
+	data->subflows = i;
 
 	for (; i < MPTCP_SUBFLOWS_MAX; i++)
 		data->contexts[i] = NULL;
 }
 
+struct mptcp_subflow_context *
+mptcp_subflow_ctx_by_pos(const struct mptcp_sched_data *data, unsigned int pos)
+{
+	if (pos >= MPTCP_SUBFLOWS_MAX)
+		return NULL;
+	return data->contexts[pos];
+}
+
 int mptcp_sched_get_send(struct mptcp_sock *msk)
 {
 	struct mptcp_subflow_context *subflow;
-- 
2.35.3
Re: [PATCH mptcp-next v11 03/11] Squash to "mptcp: add sched_data_set_contexts helper"
Posted by Geliang Tang 2 years, 7 months ago
On Tue, Jun 27, 2023 at 09:06:46AM +0800, Geliang Tang wrote:
> mptcp: add sched_data helpers
> 
> Add a new helper mptcp_sched_data_set_contexts() to set the subflow
> pointers array in struct mptcp_sched_data. Add a new helper
> mptcp_subflow_ctx_by_pos() to get the given pos subflow from the
> contexts array in struct mptcp_sched_data. They will be invoked by
> the BPF schedulers to export the subflow pointers to the BPF contexts.

Hi Matt,

You forgot to help me update the subject and commit log :)

Thanks,
-Geliang

> 
> Signed-off-by: Geliang Tang <geliang.tang@suse.com>
> ---
>  net/mptcp/protocol.h | 2 ++
>  net/mptcp/sched.c    | 9 +++++++++
>  2 files changed, 11 insertions(+)
> 
> diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
> index 8c9b2a03dc94..cb2f34c8ed09 100644
> --- a/net/mptcp/protocol.h
> +++ b/net/mptcp/protocol.h
> @@ -664,6 +664,8 @@ void mptcp_subflow_set_scheduled(struct mptcp_subflow_context *subflow,
>  				 bool scheduled);
>  void mptcp_sched_data_set_contexts(const struct mptcp_sock *msk,
>  				   struct mptcp_sched_data *data);
> +struct mptcp_subflow_context *
> +mptcp_subflow_ctx_by_pos(const struct mptcp_sched_data *data, unsigned int pos);
>  struct sock *mptcp_subflow_get_send(struct mptcp_sock *msk);
>  struct sock *mptcp_subflow_get_retrans(struct mptcp_sock *msk);
>  int mptcp_sched_get_send(struct mptcp_sock *msk);
> diff --git a/net/mptcp/sched.c b/net/mptcp/sched.c
> index c7c167e48d72..82665263bb94 100644
> --- a/net/mptcp/sched.c
> +++ b/net/mptcp/sched.c
> @@ -108,11 +108,20 @@ void mptcp_sched_data_set_contexts(const struct mptcp_sock *msk,
>  		mptcp_subflow_set_scheduled(subflow, false);
>  		data->contexts[i++] = subflow;
>  	}
> +	data->subflows = i;
>  
>  	for (; i < MPTCP_SUBFLOWS_MAX; i++)
>  		data->contexts[i] = NULL;
>  }
>  
> +struct mptcp_subflow_context *
> +mptcp_subflow_ctx_by_pos(const struct mptcp_sched_data *data, unsigned int pos)
> +{
> +	if (pos >= MPTCP_SUBFLOWS_MAX)
> +		return NULL;
> +	return data->contexts[pos];
> +}
> +
>  int mptcp_sched_get_send(struct mptcp_sock *msk)
>  {
>  	struct mptcp_subflow_context *subflow;
> -- 
> 2.35.3
>
Re: [PATCH mptcp-next v11 03/11] Squash to "mptcp: add sched_data_set_contexts helper"
Posted by Matthieu Baerts 2 years, 7 months ago
Hi Geliang,

On 13/07/2023 09:15, Geliang Tang wrote:
> On Tue, Jun 27, 2023 at 09:06:46AM +0800, Geliang Tang wrote:
>> mptcp: add sched_data helpers
>>
>> Add a new helper mptcp_sched_data_set_contexts() to set the subflow
>> pointers array in struct mptcp_sched_data. Add a new helper
>> mptcp_subflow_ctx_by_pos() to get the given pos subflow from the
>> contexts array in struct mptcp_sched_data. They will be invoked by
>> the BPF schedulers to export the subflow pointers to the BPF contexts.
> 
> Hi Matt,
> 
> You forgot to help me update the subject and commit log :)

Oops, I didn't see you were asking me to change the commit message.
Thank you for your message, now fixed:

New patches for t/upstream:
- 4194305e86f7: tg:msg: apply new commit message from Geliang
- Results: 2e4f8c818fa1..3ee02a7d38ae (export)

Tests are now in progress:

https://cirrus-ci.com/github/multipath-tcp/mptcp_net-next/export/20230713T084941

Cheers,
Matt
-- 
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net