diff mbox series

[net-next,v2,05/12] selftests: ncdevmem: Remove default arguments

Message ID 20240930171753.2572922-6-sdf@fomichev.me (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series selftests: ncdevmem: Add ncdevmem to ksft | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 9 this patch: 9
netdev/build_tools success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 2 maintainers not CCed: shuah@kernel.org linux-kselftest@vger.kernel.org
netdev/build_clang success Errors and warnings before: 9 this patch: 9
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn fail Errors and warnings before: 12 this patch: 12
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 50 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Stanislav Fomichev Sept. 30, 2024, 5:17 p.m. UTC
To make it clear what's required and what's not. Also, some of the
values don't seem like a good defaults; for example eth1.

Cc: Mina Almasry <almasrymina@google.com>
Signed-off-by: Stanislav Fomichev <sdf@fomichev.me>
---
 tools/testing/selftests/net/ncdevmem.c | 34 +++++++++-----------------
 1 file changed, 12 insertions(+), 22 deletions(-)

Comments

Mina Almasry Oct. 3, 2024, 6:59 a.m. UTC | #1
On Mon, Sep 30, 2024 at 10:18 AM Stanislav Fomichev <sdf@fomichev.me> wrote:
>
> To make it clear what's required and what's not. Also, some of the
> values don't seem like a good defaults; for example eth1.
>
> Cc: Mina Almasry <almasrymina@google.com>
> Signed-off-by: Stanislav Fomichev <sdf@fomichev.me>
> ---
>  tools/testing/selftests/net/ncdevmem.c | 34 +++++++++-----------------
>  1 file changed, 12 insertions(+), 22 deletions(-)
>
> diff --git a/tools/testing/selftests/net/ncdevmem.c b/tools/testing/selftests/net/ncdevmem.c
> index 699692fdfd7d..bf446d74a4f0 100644
> --- a/tools/testing/selftests/net/ncdevmem.c
> +++ b/tools/testing/selftests/net/ncdevmem.c
> @@ -42,32 +42,13 @@
>  #define MSG_SOCK_DEVMEM 0x2000000
>  #endif
>
> -/*
> - * tcpdevmem netcat. Works similarly to netcat but does device memory TCP
> - * instead of regular TCP. Uses udmabuf to mock a dmabuf provider.
> - *
> - * Usage:
> - *
> - *     On server:
> - *     ncdevmem -s <server IP> -c <client IP> -f eth1 -l -p 5201 -v 7
> - *

No need to remove this documentation I think. This is useful since we
don't have a proper docs anywhere.

Please instead update the args in the above line, if they need
updating, but looks like it's already correct even after this change.

> - *     On client:
> - *     yes $(echo -e \\x01\\x02\\x03\\x04\\x05\\x06) | \
> - *             tr \\n \\0 | \
> - *             head -c 5G | \
> - *             nc <server IP> 5201 -p 5201
> - *
> - * Note this is compatible with regular netcat. i.e. the sender or receiver can
> - * be replaced with regular netcat to test the RX or TX path in isolation.
> - */
> -
> -static char *server_ip = "192.168.1.4";
> +static char *server_ip;
>  static char *client_ip;
> -static char *port = "5201";
> +static char *port;
>  static size_t do_validation;
>  static int start_queue = 8;
>  static int num_queues = 8;
> -static char *ifname = "eth1";
> +static char *ifname;
>  static unsigned int ifindex;
>  static unsigned int dmabuf_id;
>
> @@ -613,6 +594,15 @@ int main(int argc, char *argv[])
>                 }
>         }
>
> +       if (!server_ip)
> +               error(1, 0, "Missing -s argument\n");
> +
> +       if (!port)
> +               error(1, 0, "Missing -p argument\n");
> +
> +       if (!ifname)
> +               error(1, 0, "Missing -f argument\n");
> +
>         ifindex = if_nametoindex(ifname);
>
>         for (; optind < argc; optind++)
> --
> 2.46.0
>
Stanislav Fomichev Oct. 3, 2024, 4:36 p.m. UTC | #2
On 10/02, Mina Almasry wrote:
> On Mon, Sep 30, 2024 at 10:18 AM Stanislav Fomichev <sdf@fomichev.me> wrote:
> >
> > To make it clear what's required and what's not. Also, some of the
> > values don't seem like a good defaults; for example eth1.
> >
> > Cc: Mina Almasry <almasrymina@google.com>
> > Signed-off-by: Stanislav Fomichev <sdf@fomichev.me>
> > ---
> >  tools/testing/selftests/net/ncdevmem.c | 34 +++++++++-----------------
> >  1 file changed, 12 insertions(+), 22 deletions(-)
> >
> > diff --git a/tools/testing/selftests/net/ncdevmem.c b/tools/testing/selftests/net/ncdevmem.c
> > index 699692fdfd7d..bf446d74a4f0 100644
> > --- a/tools/testing/selftests/net/ncdevmem.c
> > +++ b/tools/testing/selftests/net/ncdevmem.c
> > @@ -42,32 +42,13 @@
> >  #define MSG_SOCK_DEVMEM 0x2000000
> >  #endif
> >
> > -/*
> > - * tcpdevmem netcat. Works similarly to netcat but does device memory TCP
> > - * instead of regular TCP. Uses udmabuf to mock a dmabuf provider.
> > - *
> > - * Usage:
> > - *
> > - *     On server:
> > - *     ncdevmem -s <server IP> -c <client IP> -f eth1 -l -p 5201 -v 7
> > - *
> 
> No need to remove this documentation I think. This is useful since we
> don't have a proper docs anywhere.
> 
> Please instead update the args in the above line, if they need
> updating, but looks like it's already correct even after this change.

The client needs '-s' part. That's why I removed it - most likely
will tend to go stale and we now have the invocation example in the
selftest. But if you want to keep it, how about I move it to the
top of the file and cleanup a bit? Will do for the next iteration..
Mina Almasry Oct. 3, 2024, 6:51 p.m. UTC | #3
On Thu, Oct 3, 2024 at 9:36 AM Stanislav Fomichev <stfomichev@gmail.com> wrote:
>
> On 10/02, Mina Almasry wrote:
> > On Mon, Sep 30, 2024 at 10:18 AM Stanislav Fomichev <sdf@fomichev.me> wrote:
> > >
> > > To make it clear what's required and what's not. Also, some of the
> > > values don't seem like a good defaults; for example eth1.
> > >
> > > Cc: Mina Almasry <almasrymina@google.com>
> > > Signed-off-by: Stanislav Fomichev <sdf@fomichev.me>
> > > ---
> > >  tools/testing/selftests/net/ncdevmem.c | 34 +++++++++-----------------
> > >  1 file changed, 12 insertions(+), 22 deletions(-)
> > >
> > > diff --git a/tools/testing/selftests/net/ncdevmem.c b/tools/testing/selftests/net/ncdevmem.c
> > > index 699692fdfd7d..bf446d74a4f0 100644
> > > --- a/tools/testing/selftests/net/ncdevmem.c
> > > +++ b/tools/testing/selftests/net/ncdevmem.c
> > > @@ -42,32 +42,13 @@
> > >  #define MSG_SOCK_DEVMEM 0x2000000
> > >  #endif
> > >
> > > -/*
> > > - * tcpdevmem netcat. Works similarly to netcat but does device memory TCP
> > > - * instead of regular TCP. Uses udmabuf to mock a dmabuf provider.
> > > - *
> > > - * Usage:
> > > - *
> > > - *     On server:
> > > - *     ncdevmem -s <server IP> -c <client IP> -f eth1 -l -p 5201 -v 7
> > > - *
> >
> > No need to remove this documentation I think. This is useful since we
> > don't have a proper docs anywhere.
> >
> > Please instead update the args in the above line, if they need
> > updating, but looks like it's already correct even after this change.
>
> The client needs '-s' part. That's why I removed it - most likely
> will tend to go stale and we now have the invocation example in the
> selftest. But if you want to keep it, how about I move it to the
> top of the file and cleanup a bit? Will do for the next iteration..

Yeah, the 'docs' will need to be updated for the TX path, but I hope,
not removed. We don't really have any other clues on how to run this
thing. The docs will become less important when the kselftest is
properly up and running because it is self documenting, but just in
case anyone wants to run ncdevmem manually the docs are nice. Any
cleanup and movement for clarity is welcome indeed.
diff mbox series

Patch

diff --git a/tools/testing/selftests/net/ncdevmem.c b/tools/testing/selftests/net/ncdevmem.c
index 699692fdfd7d..bf446d74a4f0 100644
--- a/tools/testing/selftests/net/ncdevmem.c
+++ b/tools/testing/selftests/net/ncdevmem.c
@@ -42,32 +42,13 @@ 
 #define MSG_SOCK_DEVMEM 0x2000000
 #endif
 
-/*
- * tcpdevmem netcat. Works similarly to netcat but does device memory TCP
- * instead of regular TCP. Uses udmabuf to mock a dmabuf provider.
- *
- * Usage:
- *
- *	On server:
- *	ncdevmem -s <server IP> -c <client IP> -f eth1 -l -p 5201 -v 7
- *
- *	On client:
- *	yes $(echo -e \\x01\\x02\\x03\\x04\\x05\\x06) | \
- *		tr \\n \\0 | \
- *		head -c 5G | \
- *		nc <server IP> 5201 -p 5201
- *
- * Note this is compatible with regular netcat. i.e. the sender or receiver can
- * be replaced with regular netcat to test the RX or TX path in isolation.
- */
-
-static char *server_ip = "192.168.1.4";
+static char *server_ip;
 static char *client_ip;
-static char *port = "5201";
+static char *port;
 static size_t do_validation;
 static int start_queue = 8;
 static int num_queues = 8;
-static char *ifname = "eth1";
+static char *ifname;
 static unsigned int ifindex;
 static unsigned int dmabuf_id;
 
@@ -613,6 +594,15 @@  int main(int argc, char *argv[])
 		}
 	}
 
+	if (!server_ip)
+		error(1, 0, "Missing -s argument\n");
+
+	if (!port)
+		error(1, 0, "Missing -p argument\n");
+
+	if (!ifname)
+		error(1, 0, "Missing -f argument\n");
+
 	ifindex = if_nametoindex(ifname);
 
 	for (; optind < argc; optind++)