@@ -64,6 +64,7 @@ static int cfg_runtime_ms = -1;
static bool cfg_poll;
static int cfg_poll_loop_timeout_ms = 2000;
static bool cfg_segment;
+static bool cfg_fragment;
static bool cfg_sendmmsg;
static bool cfg_tcp;
static uint32_t cfg_tx_ts = SOF_TIMESTAMPING_TX_SOFTWARE;
@@ -375,6 +376,21 @@ static int send_udp_sendmmsg(int fd, char *data)
return ret;
}
+static int send_udp_fragment(int fd, char *data)
+{
+ int ret;
+
+ ret = sendto(fd, data, cfg_payload_len, cfg_zerocopy ? MSG_ZEROCOPY : 0,
+ cfg_connected ? NULL : (void *)&cfg_dst_addr,
+ cfg_connected ? 0 : cfg_alen);
+ if (ret == -1)
+ error(1, errno, "write");
+ if (ret != cfg_payload_len)
+ error(1, errno, "write: %uB != %uB\n", ret, cfg_payload_len);
+
+ return 1;
+}
+
static void send_udp_segment_cmsg(struct cmsghdr *cm)
{
uint16_t *valp;
@@ -429,7 +445,7 @@ static int send_udp_segment(int fd, char *data)
static void usage(const char *filepath)
{
- error(1, 0, "Usage: %s [-46acmHPtTuvz] [-C cpu] [-D dst ip] [-l secs] "
+ error(1, 0, "Usage: %s [-46acfmHPtTuvz] [-C cpu] [-D dst ip] [-l secs] "
"[-L secs] [-M messagenr] [-p port] [-s sendsize] [-S gsosize]",
filepath);
}
@@ -440,7 +456,7 @@ static void parse_opts(int argc, char **argv)
int max_len, hdrlen;
int c;
- while ((c = getopt(argc, argv, "46acC:D:Hl:L:mM:p:s:PS:tTuvz")) != -1) {
+ while ((c = getopt(argc, argv, "46acC:D:fHl:L:mM:p:s:PS:tTuvz")) != -1) {
switch (c) {
case '4':
if (cfg_family != PF_UNSPEC)
@@ -469,6 +485,9 @@ static void parse_opts(int argc, char **argv)
case 'l':
cfg_runtime_ms = strtoul(optarg, NULL, 10) * 1000;
break;
+ case 'f':
+ cfg_fragment = true;
+ break;
case 'L':
cfg_poll_loop_timeout_ms = strtoul(optarg, NULL, 10) * 1000;
break;
@@ -527,10 +546,10 @@ static void parse_opts(int argc, char **argv)
error(1, 0, "must pass one of -4 or -6");
if (cfg_tcp && !cfg_connected)
error(1, 0, "connectionless tcp makes no sense");
- if (cfg_segment && cfg_sendmmsg)
- error(1, 0, "cannot combine segment offload and sendmmsg");
- if (cfg_tx_tstamp && !(cfg_segment || cfg_sendmmsg))
- error(1, 0, "Options -T and -H require either -S or -m option");
+ if ((cfg_segment + cfg_sendmmsg + cfg_fragment) > 1)
+ error(1, 0, "cannot combine segment offload , fragment and sendmmsg");
+ if (cfg_tx_tstamp && !(cfg_segment || cfg_sendmmsg || cfg_fragment))
+ error(1, 0, "Options -T and -H require either -S or -m or -f option");
if (cfg_family == PF_INET)
hdrlen = sizeof(struct iphdr) + sizeof(struct udphdr);
@@ -695,6 +714,8 @@ int main(int argc, char **argv)
num_sends += send_udp_segment(fd, buf[i]);
else if (cfg_sendmmsg)
num_sends += send_udp_sendmmsg(fd, buf[i]);
+ else if (cfg_fragment)
+ num_sends += send_udp_fragment(fd, buf[i]);
else
num_sends += send_udp(fd, buf[i]);
num_msgs++;