Message ID | 20241009171252.2328284-6-sdf@fomichev.me (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | selftests: ncdevmem: Add ncdevmem to ksft | expand |
On Wed, Oct 9, 2024 at 10:13 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. > > Move the invocation comment to the top, add missing -s to the client > and cleanup the client invocation a bit to make more readable. > > Cc: Mina Almasry <almasrymina@google.com> > Signed-off-by: Stanislav Fomichev <sdf@fomichev.me> > --- > tools/testing/selftests/net/ncdevmem.c | 49 ++++++++++++++------------ > 1 file changed, 27 insertions(+), 22 deletions(-) > > diff --git a/tools/testing/selftests/net/ncdevmem.c b/tools/testing/selftests/net/ncdevmem.c > index 2ee7b4eb9f71..99ae3a595787 100644 > --- a/tools/testing/selftests/net/ncdevmem.c > +++ b/tools/testing/selftests/net/ncdevmem.c > @@ -1,4 +1,19 @@ > // SPDX-License-Identifier: GPL-2.0 > +/* > + * 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 > + * > + * On client: > + * echo -n "hello\nworld" | nc -s <server IP> 5201 -p 5201 > + * No need to remove the documentation telling users how to do validation when moving these docs. Please have a secondary section that retains the docs for the validation: * Usage: (what you have) * Test data validation: (What I had before) With that: Reviewed-by: Mina Almasry <almasrymina@google.com>
On 10/12, Mina Almasry wrote: > On Wed, Oct 9, 2024 at 10:13 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. > > > > Move the invocation comment to the top, add missing -s to the client > > and cleanup the client invocation a bit to make more readable. > > > > Cc: Mina Almasry <almasrymina@google.com> > > Signed-off-by: Stanislav Fomichev <sdf@fomichev.me> > > --- > > tools/testing/selftests/net/ncdevmem.c | 49 ++++++++++++++------------ > > 1 file changed, 27 insertions(+), 22 deletions(-) > > > > diff --git a/tools/testing/selftests/net/ncdevmem.c b/tools/testing/selftests/net/ncdevmem.c > > index 2ee7b4eb9f71..99ae3a595787 100644 > > --- a/tools/testing/selftests/net/ncdevmem.c > > +++ b/tools/testing/selftests/net/ncdevmem.c > > @@ -1,4 +1,19 @@ > > // SPDX-License-Identifier: GPL-2.0 > > +/* > > + * 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 > > + * > > + * On client: > > + * echo -n "hello\nworld" | nc -s <server IP> 5201 -p 5201 > > + * > > No need to remove the documentation telling users how to do validation > when moving these docs. Please have a secondary section that retains > the docs for the validation: > > * Usage: > > (what you have) > > * Test data validation: > > (What I had before) > > With that: > > Reviewed-by: Mina Almasry <almasrymina@google.com> SG, will do, thanks!
diff --git a/tools/testing/selftests/net/ncdevmem.c b/tools/testing/selftests/net/ncdevmem.c index 2ee7b4eb9f71..99ae3a595787 100644 --- a/tools/testing/selftests/net/ncdevmem.c +++ b/tools/testing/selftests/net/ncdevmem.c @@ -1,4 +1,19 @@ // SPDX-License-Identifier: GPL-2.0 +/* + * 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 + * + * On client: + * echo -n "hello\nworld" | nc -s <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. + */ #define _GNU_SOURCE #define __EXPORTED_HEADERS__ @@ -42,32 +57,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; @@ -596,6 +592,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++)
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. Move the invocation comment to the top, add missing -s to the client and cleanup the client invocation a bit to make more readable. Cc: Mina Almasry <almasrymina@google.com> Signed-off-by: Stanislav Fomichev <sdf@fomichev.me> --- tools/testing/selftests/net/ncdevmem.c | 49 ++++++++++++++------------ 1 file changed, 27 insertions(+), 22 deletions(-)