View | Details | Raw Unified | Return to bug 187149 | Differences between
and this patch

Collapse All | Expand All

(-)tools/tools/netmap/pkt-gen.c (-1 / +25 lines)
Lines 174-179 Link Here
174
	int nthreads;
174
	int nthreads;
175
	int cpus;
175
	int cpus;
176
	int options;	/* testing */
176
	int options;	/* testing */
177
	int softchecksum;   /* Software UDP checksum calculation */
177
#define OPT_PREFETCH	1
178
#define OPT_PREFETCH	1
178
#define OPT_ACCESS	2
179
#define OPT_ACCESS	2
179
#define OPT_COPY	4
180
#define OPT_COPY	4
Lines 561-566 Link Here
561
{
562
{
562
	uint32_t a;
563
	uint32_t a;
563
	uint16_t p;
564
	uint16_t p;
565
	struct ether_header *eh = &pkt->eh;
564
	struct ip *ip = &pkt->ip;
566
	struct ip *ip = &pkt->ip;
565
	struct udphdr *udp = &pkt->udp;
567
	struct udphdr *udp = &pkt->udp;
566
568
Lines 595-600 Link Here
595
	ip->ip_dst.s_addr = htonl(g->dst_ip.start);
597
	ip->ip_dst.s_addr = htonl(g->dst_ip.start);
596
    } while (0);
598
    } while (0);
597
    // update checksum
599
    // update checksum
600
	/* Some NIC disable hardware CRC checksum in netmap mode
601
	 * and don't allow to re-enable it */
602
603
	if (g->softchecksum) {
604
		ip->ip_sum = 0;
605
		ip->ip_sum = wrapsum(checksum(ip, sizeof(*ip), 0));
606
		/* UDP checksum */
607
		uint16_t paylen = g->pkt_size - sizeof(*eh) - sizeof(struct ip);
608
		udp->uh_sum = 0;
609
		udp->uh_sum = wrapsum(checksum(udp, sizeof(*udp),
610
			checksum(pkt->body,
611
				paylen - sizeof(*udp),
612
				checksum(&ip->ip_src, 2 * sizeof(ip->ip_src),
613
					IPPROTO_UDP + (u_int32_t)ntohs(udp->uh_ulen)
614
				)
615
			)
616
		));
617
	}
598
}
618
}
599
619
600
/*
620
/*
Lines 1366-1371 Link Here
1366
		"\t-R rate		in packets per second\n"
1386
		"\t-R rate		in packets per second\n"
1367
		"\t-X			dump payload\n"
1387
		"\t-X			dump payload\n"
1368
		"\t-H len		add empty virtio-net-header with size 'len'\n"
1388
		"\t-H len		add empty virtio-net-header with size 'len'\n"
1389
		"\t-U           enable software UDP CRC chekcsum\n"
1369
		"",
1390
		"",
1370
		cmd);
1391
		cmd);
1371
1392
Lines 1638-1644 Link Here
1638
	g.virt_header = 0;
1659
	g.virt_header = 0;
1639
1660
1640
	while ( (ch = getopt(arc, argv,
1661
	while ( (ch = getopt(arc, argv,
1641
			"a:f:F:n:i:Il:d:s:D:S:b:c:o:p:T:w:WvR:XC:H:e:m:")) != -1) {
1662
			"a:f:F:n:i:Il:d:s:D:S:b:c:o:p:T:w:WvUR:XC:H:e:m:")) != -1) {
1642
		struct sf *fn;
1663
		struct sf *fn;
1643
1664
1644
		switch(ch) {
1665
		switch(ch) {
Lines 1740-1745 Link Here
1740
		case 'b':	/* burst */
1761
		case 'b':	/* burst */
1741
			g.burst = atoi(optarg);
1762
			g.burst = atoi(optarg);
1742
			break;
1763
			break;
1764
		case 'U':   /* software UDP checksum */
1765
			g.softchecksum = 1;
1766
			break;
1743
		case 'c':
1767
		case 'c':
1744
			g.cpus = atoi(optarg);
1768
			g.cpus = atoi(optarg);
1745
			break;
1769
			break;

Return to bug 187149