Skip to content

Commit

Permalink
pktgen: add flag NO_TIMESTAMP to disable timestamping
Browse files Browse the repository at this point in the history
Then testing the TX limits of the stack, then it is useful to
be-able to disable the do_gettimeofday() timetamping on every packet.

This implements a pktgen flag NO_TIMESTAMP which will disable this
call to do_gettimeofday().

The performance change on (my system E5-2695) with skb_clone=0, goes
from TX 2,423,751 pps to 2,567,165 pps with flag NO_TIMESTAMP. Thus,
the cost of do_gettimeofday() or saving is approx 23 nanosec.

Signed-off-by: Jesper Dangaard Brouer <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
netoptimizer authored and davem330 committed Sep 2, 2014
1 parent 05f8461 commit afb84b6
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions net/core/pktgen.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@
#define F_QUEUE_MAP_CPU (1<<14) /* queue map mirrors smp_processor_id() */
#define F_NODE (1<<15) /* Node memory alloc*/
#define F_UDPCSUM (1<<16) /* Include UDP checksum */
#define F_NO_TIMESTAMP (1<<17) /* Don't timestamp packets (default TS) */

/* Thread control flag bits */
#define T_STOP (1<<0) /* Stop run */
Expand Down Expand Up @@ -638,6 +639,9 @@ static int pktgen_if_show(struct seq_file *seq, void *v)
if (pkt_dev->flags & F_UDPCSUM)
seq_puts(seq, "UDPCSUM ");

if (pkt_dev->flags & F_NO_TIMESTAMP)
seq_puts(seq, "NO_TIMESTAMP ");

if (pkt_dev->flags & F_MPLS_RND)
seq_puts(seq, "MPLS_RND ");

Expand Down Expand Up @@ -1243,6 +1247,9 @@ static ssize_t pktgen_if_write(struct file *file,
else if (strcmp(f, "!UDPCSUM") == 0)
pkt_dev->flags &= ~F_UDPCSUM;

else if (strcmp(f, "NO_TIMESTAMP") == 0)
pkt_dev->flags |= F_NO_TIMESTAMP;

else {
sprintf(pg_result,
"Flag -:%s:- unknown\nAvailable flags, (prepend ! to un-set flag):\n%s",
Expand All @@ -1251,6 +1258,7 @@ static ssize_t pktgen_if_write(struct file *file,
"MACSRC_RND, MACDST_RND, TXSIZE_RND, IPV6, "
"MPLS_RND, VID_RND, SVID_RND, FLOW_SEQ, "
"QUEUE_MAP_RND, QUEUE_MAP_CPU, UDPCSUM, "
"NO_TIMESTAMP, "
#ifdef CONFIG_XFRM
"IPSEC, "
#endif
Expand Down Expand Up @@ -2685,9 +2693,14 @@ static void pktgen_finalize_skb(struct pktgen_dev *pkt_dev, struct sk_buff *skb,
pgh->pgh_magic = htonl(PKTGEN_MAGIC);
pgh->seq_num = htonl(pkt_dev->seq_num);

do_gettimeofday(&timestamp);
pgh->tv_sec = htonl(timestamp.tv_sec);
pgh->tv_usec = htonl(timestamp.tv_usec);
if (pkt_dev->flags & F_NO_TIMESTAMP) {
pgh->tv_sec = 0;
pgh->tv_usec = 0;
} else {
do_gettimeofday(&timestamp);
pgh->tv_sec = htonl(timestamp.tv_sec);
pgh->tv_usec = htonl(timestamp.tv_usec);
}
}

static struct sk_buff *pktgen_alloc_skb(struct net_device *dev,
Expand Down

0 comments on commit afb84b6

Please sign in to comment.