Skip to content

Commit 38b2cf2

Browse files
Alexei Starovoitovdavem330
authored andcommitted
net: pktgen: packet bursting via skb->xmit_more
This patch demonstrates the effect of delaying update of HW tailptr. (based on earlier patch by Jesper) burst=1 is the default. It sends one packet with xmit_more=false burst=2 sends one packet with xmit_more=true and 2nd copy of the same packet with xmit_more=false burst=3 sends two copies of the same packet with xmit_more=true and 3rd copy with xmit_more=false Performance with ixgbe (usec 30): burst=1 tx:9.2 Mpps burst=2 tx:13.5 Mpps burst=3 tx:14.5 Mpps full 10G line rate Signed-off-by: Alexei Starovoitov <ast@plumgrid.com> Signed-off-by: Eric Dumazet <edumazet@google.com> Acked-by: Jesper Dangaard Brouer <brouer@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 775dd69 commit 38b2cf2

2 files changed

Lines changed: 27 additions & 2 deletions

File tree

‎Documentation/networking/pktgen.txt‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ Examples:
9999

100100
pgset "clone_skb 1" sets the number of copies of the same packet
101101
pgset "clone_skb 0" use single SKB for all transmits
102+
pgset "burst 8" uses xmit_more API to queue 8 copies of the same
103+
packet and update HW tx queue tail pointer once.
104+
"burst 1" is the default
102105
pgset "pkt_size 9014" sets packet size to 9014
103106
pgset "frags 5" packet will consist of 5 fragments
104107
pgset "count 200000" sets number of packets to send, set to zero

‎net/core/pktgen.c‎

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ struct pktgen_dev {
387387
u16 queue_map_min;
388388
u16 queue_map_max;
389389
__u32 skb_priority; /* skb priority field */
390+
unsigned int burst; /* number of duplicated packets to burst */
390391
int node; /* Memory node */
391392

392393
#ifdef CONFIG_XFRM
@@ -613,6 +614,9 @@ static int pktgen_if_show(struct seq_file *seq, void *v)
613614
if (pkt_dev->traffic_class)
614615
seq_printf(seq, " traffic_class: 0x%02x\n", pkt_dev->traffic_class);
615616

617+
if (pkt_dev->burst > 1)
618+
seq_printf(seq, " burst: %d\n", pkt_dev->burst);
619+
616620
if (pkt_dev->node >= 0)
617621
seq_printf(seq, " node: %d\n", pkt_dev->node);
618622

@@ -1124,6 +1128,16 @@ static ssize_t pktgen_if_write(struct file *file,
11241128
pkt_dev->dst_mac_count);
11251129
return count;
11261130
}
1131+
if (!strcmp(name, "burst")) {
1132+
len = num_arg(&user_buffer[i], 10, &value);
1133+
if (len < 0)
1134+
return len;
1135+
1136+
i += len;
1137+
pkt_dev->burst = value < 1 ? 1 : value;
1138+
sprintf(pg_result, "OK: burst=%d", pkt_dev->burst);
1139+
return count;
1140+
}
11271141
if (!strcmp(name, "node")) {
11281142
len = num_arg(&user_buffer[i], 10, &value);
11291143
if (len < 0)
@@ -3297,6 +3311,7 @@ static void pktgen_wait_for_skb(struct pktgen_dev *pkt_dev)
32973311

32983312
static void pktgen_xmit(struct pktgen_dev *pkt_dev)
32993313
{
3314+
unsigned int burst = ACCESS_ONCE(pkt_dev->burst);
33003315
struct net_device *odev = pkt_dev->odev;
33013316
struct netdev_queue *txq;
33023317
int ret;
@@ -3347,15 +3362,19 @@ static void pktgen_xmit(struct pktgen_dev *pkt_dev)
33473362
pkt_dev->last_ok = 0;
33483363
goto unlock;
33493364
}
3350-
atomic_inc(&(pkt_dev->skb->users));
3351-
ret = netdev_start_xmit(pkt_dev->skb, odev, txq, false);
3365+
atomic_add(burst, &pkt_dev->skb->users);
3366+
3367+
xmit_more:
3368+
ret = netdev_start_xmit(pkt_dev->skb, odev, txq, --burst > 0);
33523369

33533370
switch (ret) {
33543371
case NETDEV_TX_OK:
33553372
pkt_dev->last_ok = 1;
33563373
pkt_dev->sofar++;
33573374
pkt_dev->seq_num++;
33583375
pkt_dev->tx_bytes += pkt_dev->last_pkt_size;
3376+
if (burst > 0 && !netif_xmit_frozen_or_drv_stopped(txq))
3377+
goto xmit_more;
33593378
break;
33603379
case NET_XMIT_DROP:
33613380
case NET_XMIT_CN:
@@ -3374,6 +3393,8 @@ static void pktgen_xmit(struct pktgen_dev *pkt_dev)
33743393
atomic_dec(&(pkt_dev->skb->users));
33753394
pkt_dev->last_ok = 0;
33763395
}
3396+
if (unlikely(burst))
3397+
atomic_sub(burst, &pkt_dev->skb->users);
33773398
unlock:
33783399
HARD_TX_UNLOCK(odev, txq);
33793400

@@ -3572,6 +3593,7 @@ static int pktgen_add_device(struct pktgen_thread *t, const char *ifname)
35723593
pkt_dev->svlan_p = 0;
35733594
pkt_dev->svlan_cfi = 0;
35743595
pkt_dev->svlan_id = 0xffff;
3596+
pkt_dev->burst = 1;
35753597
pkt_dev->node = -1;
35763598

35773599
err = pktgen_setup_dev(t->net, pkt_dev, ifname);

0 commit comments

Comments
 (0)