From: Jay Jayatheerthan <jay.jayatheerthan@intel.com>
To: magnus.karlsson@intel.com, bjorn.topel@intel.com, ast@kernel.org,
daniel@iogearbox.net, netdev@vger.kernel.org,
jonathan.lemon@gmail.com
Cc: bpf@vger.kernel.org, Jay Jayatheerthan <jay.jayatheerthan@intel.com>
Subject: [PATCH bpf-next 6/6] samples/bpf: xdpsock: Add option to specify transmit fill pattern
Date: Fri, 20 Dec 2019 14:25:30 +0530 [thread overview]
Message-ID: <20191220085530.4980-7-jay.jayatheerthan@intel.com> (raw)
In-Reply-To: <20191220085530.4980-1-jay.jayatheerthan@intel.com>
The UDP payload fill pattern can be specified using '-P' or '--tx-pkt-pattern'
option. It is an unsigned 32 bit field and defaulted to 0x12345678.
The IP and UDP checksum is calculated by the code as per the content of
the packet before transmission.
Signed-off-by: Jay Jayatheerthan <jay.jayatheerthan@intel.com>
---
samples/bpf/xdpsock_user.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/samples/bpf/xdpsock_user.c b/samples/bpf/xdpsock_user.c
index 2297158a32bd..d74c4c83fc93 100644
--- a/samples/bpf/xdpsock_user.c
+++ b/samples/bpf/xdpsock_user.c
@@ -76,7 +76,7 @@ static bool benchmark_done;
static u32 opt_batch_size = 64;
static int opt_pkt_count;
static u16 opt_pkt_size = MIN_PKT_SIZE;
-static u32 pkt_fill_pattern = 0x12345678;
+static u32 opt_pkt_fill_pattern = 0x12345678;
static int opt_poll;
static int opt_interval = 1;
static u32 opt_xdp_bind_flags = XDP_USE_NEED_WAKEUP;
@@ -517,7 +517,7 @@ static void gen_eth_hdr_data(void)
udp_hdr->len = htons(UDP_PKT_SIZE);
/* UDP data */
- memset32_htonl(pkt_data + PKT_HDR_SIZE, pkt_fill_pattern,
+ memset32_htonl(pkt_data + PKT_HDR_SIZE, opt_pkt_fill_pattern,
UDP_PKT_DATA_SIZE);
/* UDP header checksum */
@@ -630,6 +630,7 @@ static struct option long_options[] = {
{"batch-size", required_argument, 0, 'b'},
{"tx-pkt-count", required_argument, 0, 'C'},
{"tx-pkt-size", required_argument, 0, 's'},
+ {"tx-pkt-pattern", required_argument, 0, 'P'},
{0, 0, 0, 0}
};
@@ -663,10 +664,11 @@ static void usage(const char *prog)
" -s, --tx-pkt-size=n Transmit packet size.\n"
" (Default: %d bytes)\n"
" Min size: %d, Max size %d.\n"
+ " -P, --tx-pkt-pattern=nPacket fill pattern. Default: 0x%x\n"
"\n";
fprintf(stderr, str, prog, XSK_UMEM__DEFAULT_FRAME_SIZE,
opt_batch_size, MIN_PKT_SIZE, MIN_PKT_SIZE,
- XSK_UMEM__DEFAULT_FRAME_SIZE);
+ XSK_UMEM__DEFAULT_FRAME_SIZE, opt_pkt_fill_pattern);
exit(EXIT_FAILURE);
}
@@ -678,7 +680,7 @@ static void parse_command_line(int argc, char **argv)
opterr = 0;
for (;;) {
- c = getopt_long(argc, argv, "Frtli:q:pSNn:czf:muMd:b:C:s:",
+ c = getopt_long(argc, argv, "Frtli:q:pSNn:czf:muMd:b:C:s:P:",
long_options, &option_index);
if (c == -1)
break;
@@ -756,6 +758,9 @@ static void parse_command_line(int argc, char **argv)
usage(basename(argv[0]));
}
break;
+ case 'P':
+ opt_pkt_fill_pattern = strtol(optarg, NULL, 16);
+ break;
default:
usage(basename(argv[0]));
}
--
2.17.1
next prev parent reply other threads:[~2019-12-20 8:55 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-20 8:55 [PATCH bpf-next 0/6] Enhancements to xdpsock application Jay Jayatheerthan
2019-12-20 8:55 ` [PATCH bpf-next 1/6] samples/bpf: xdpsock: Add duration option to specify how long to run Jay Jayatheerthan
2019-12-20 8:55 ` [PATCH bpf-next 2/6] samples/bpf: xdpsock: Use common code to handle signal and main exit Jay Jayatheerthan
2019-12-20 8:55 ` [PATCH bpf-next 3/6] samples/bpf: xdpsock: Add option to specify batch size Jay Jayatheerthan
2019-12-20 8:55 ` [PATCH bpf-next 4/6] samples/bpf: xdpsock: Add option to specify number of packets to send Jay Jayatheerthan
2019-12-20 8:55 ` [PATCH bpf-next 5/6] samples/bpf: xdpsock: Add option to specify tx packet size Jay Jayatheerthan
2019-12-20 8:55 ` Jay Jayatheerthan [this message]
2019-12-20 10:04 ` [PATCH bpf-next 0/6] Enhancements to xdpsock application Björn Töpel
2019-12-21 0:12 ` Alexei Starovoitov
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=20191220085530.4980-7-jay.jayatheerthan@intel.com \
--to=jay.jayatheerthan@intel.com \
--cc=ast@kernel.org \
--cc=bjorn.topel@intel.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=jonathan.lemon@gmail.com \
--cc=magnus.karlsson@intel.com \
--cc=netdev@vger.kernel.org \
/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).