aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-07-27 15:03:20 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-07-27 15:03:20 -0400
commit468fc7ed5537615efe671d94248446ac24679773 (patch)
tree27bc9de792e863d6ec1630927b77ac9e7dabb38a /tools
parent08fd8c17686c6b09fa410a26d516548dd80ff147 (diff)
parent36232012344b8db67052432742deaf17f82e70e6 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
Pull networking updates from David Miller: 1) Unified UDP encapsulation offload methods for drivers, from Alexander Duyck. 2) Make DSA binding more sane, from Andrew Lunn. 3) Support QCA9888 chips in ath10k, from Anilkumar Kolli. 4) Several workqueue usage cleanups, from Bhaktipriya Shridhar. 5) Add XDP (eXpress Data Path), essentially running BPF programs on RX packets as soon as the device sees them, with the option to mirror the packet on TX via the same interface. From Brenden Blanco and others. 6) Allow qdisc/class stats dumps to run lockless, from Eric Dumazet. 7) Add VLAN support to b53 and bcm_sf2, from Florian Fainelli. 8) Simplify netlink conntrack entry layout, from Florian Westphal. 9) Add ipv4 forwarding support to mlxsw spectrum driver, from Ido Schimmel, Yotam Gigi, and Jiri Pirko. 10) Add SKB array infrastructure and convert tun and macvtap over to it. From Michael S Tsirkin and Jason Wang. 11) Support qdisc packet injection in pktgen, from John Fastabend. 12) Add neighbour monitoring framework to TIPC, from Jon Paul Maloy. 13) Add NV congestion control support to TCP, from Lawrence Brakmo. 14) Add GSO support to SCTP, from Marcelo Ricardo Leitner. 15) Allow GRO and RPS to function on macsec devices, from Paolo Abeni. 16) Support MPLS over IPV4, from Simon Horman. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next: (1622 commits) xgene: Fix build warning with ACPI disabled. be2net: perform temperature query in adapter regardless of its interface state l2tp: Correctly return -EBADF from pppol2tp_getname. net/mlx5_core/health: Remove deprecated create_singlethread_workqueue net: ipmr/ip6mr: update lastuse on entry change macsec: ensure rx_sa is set when validation is disabled tipc: dump monitor attributes tipc: add a function to get the bearer name tipc: get monitor threshold for the cluster tipc: make cluster size threshold for monitoring configurable tipc: introduce constants for tipc address validation net: neigh: disallow transition to NUD_STALE if lladdr is unchanged in neigh_update() MAINTAINERS: xgene: Add driver and documentation path Documentation: dtb: xgene: Add MDIO node dtb: xgene: Add MDIO node drivers: net: xgene: ethtool: Use phy_ethtool_gset and sset drivers: net: xgene: Use exported functions drivers: net: xgene: Enable MDIO driver drivers: net: xgene: Add backward compatibility drivers: net: phy: xgene: Add MDIO driver ...
Diffstat (limited to 'tools')
-rwxr-xr-xtools/hv/bondvf.sh193
-rw-r--r--tools/perf/scripts/python/netdev-times.py11
-rw-r--r--tools/virtio/ringtest/Makefile5
-rw-r--r--tools/virtio/ringtest/ptr_ring.c197
4 files changed, 401 insertions, 5 deletions
diff --git a/tools/hv/bondvf.sh b/tools/hv/bondvf.sh
new file mode 100755
index 000000000000..8e960234013d
--- /dev/null
+++ b/tools/hv/bondvf.sh
@@ -0,0 +1,193 @@
1#!/bin/bash
2
3# This example script creates bonding network devices based on synthetic NIC
4# (the virtual network adapter usually provided by Hyper-V) and the matching
5# VF NIC (SRIOV virtual function). So the synthetic NIC and VF NIC can
6# function as one network device, and fail over to the synthetic NIC if VF is
7# down.
8#
9# Usage:
10# - After configured vSwitch and vNIC with SRIOV, start Linux virtual
11# machine (VM)
12# - Run this scripts on the VM. It will create configuration files in
13# distro specific directory.
14# - Reboot the VM, so that the bonding config are enabled.
15#
16# The config files are DHCP by default. You may edit them if you need to change
17# to Static IP or change other settings.
18#
19
20sysdir=/sys/class/net
21netvsc_cls={f8615163-df3e-46c5-913f-f2d2f965ed0e}
22bondcnt=0
23
24# Detect Distro
25if [ -f /etc/redhat-release ];
26then
27 cfgdir=/etc/sysconfig/network-scripts
28 distro=redhat
29elif grep -q 'Ubuntu' /etc/issue
30then
31 cfgdir=/etc/network
32 distro=ubuntu
33elif grep -q 'SUSE' /etc/issue
34then
35 cfgdir=/etc/sysconfig/network
36 distro=suse
37else
38 echo "Unsupported Distro"
39 exit 1
40fi
41
42echo Detected Distro: $distro, or compatible
43
44# Get a list of ethernet names
45list_eth=(`cd $sysdir && ls -d */ | cut -d/ -f1 | grep -v bond`)
46eth_cnt=${#list_eth[@]}
47
48echo List of net devices:
49
50# Get the MAC addresses
51for (( i=0; i < $eth_cnt; i++ ))
52do
53 list_mac[$i]=`cat $sysdir/${list_eth[$i]}/address`
54 echo ${list_eth[$i]}, ${list_mac[$i]}
55done
56
57# Find NIC with matching MAC
58for (( i=0; i < $eth_cnt-1; i++ ))
59do
60 for (( j=i+1; j < $eth_cnt; j++ ))
61 do
62 if [ "${list_mac[$i]}" = "${list_mac[$j]}" ]
63 then
64 list_match[$i]=${list_eth[$j]}
65 break
66 fi
67 done
68done
69
70function create_eth_cfg_redhat {
71 local fn=$cfgdir/ifcfg-$1
72
73 rm -f $fn
74 echo DEVICE=$1 >>$fn
75 echo TYPE=Ethernet >>$fn
76 echo BOOTPROTO=none >>$fn
77 echo ONBOOT=yes >>$fn
78 echo NM_CONTROLLED=no >>$fn
79 echo PEERDNS=yes >>$fn
80 echo IPV6INIT=yes >>$fn
81 echo MASTER=$2 >>$fn
82 echo SLAVE=yes >>$fn
83}
84
85function create_eth_cfg_pri_redhat {
86 create_eth_cfg_redhat $1 $2
87}
88
89function create_bond_cfg_redhat {
90 local fn=$cfgdir/ifcfg-$1
91
92 rm -f $fn
93 echo DEVICE=$1 >>$fn
94 echo TYPE=Bond >>$fn
95 echo BOOTPROTO=dhcp >>$fn
96 echo ONBOOT=yes >>$fn
97 echo NM_CONTROLLED=no >>$fn
98 echo PEERDNS=yes >>$fn
99 echo IPV6INIT=yes >>$fn
100 echo BONDING_MASTER=yes >>$fn
101 echo BONDING_OPTS=\"mode=active-backup miimon=100 primary=$2\" >>$fn
102}
103
104function create_eth_cfg_ubuntu {
105 local fn=$cfgdir/interfaces
106
107 echo $'\n'auto $1 >>$fn
108 echo iface $1 inet manual >>$fn
109 echo bond-master $2 >>$fn
110}
111
112function create_eth_cfg_pri_ubuntu {
113 local fn=$cfgdir/interfaces
114
115 create_eth_cfg_ubuntu $1 $2
116 echo bond-primary $1 >>$fn
117}
118
119function create_bond_cfg_ubuntu {
120 local fn=$cfgdir/interfaces
121
122 echo $'\n'auto $1 >>$fn
123 echo iface $1 inet dhcp >>$fn
124 echo bond-mode active-backup >>$fn
125 echo bond-miimon 100 >>$fn
126 echo bond-slaves none >>$fn
127}
128
129function create_eth_cfg_suse {
130 local fn=$cfgdir/ifcfg-$1
131
132 rm -f $fn
133 echo BOOTPROTO=none >>$fn
134 echo STARTMODE=auto >>$fn
135}
136
137function create_eth_cfg_pri_suse {
138 create_eth_cfg_suse $1
139}
140
141function create_bond_cfg_suse {
142 local fn=$cfgdir/ifcfg-$1
143
144 rm -f $fn
145 echo BOOTPROTO=dhcp >>$fn
146 echo STARTMODE=auto >>$fn
147 echo BONDING_MASTER=yes >>$fn
148 echo BONDING_SLAVE_0=$2 >>$fn
149 echo BONDING_SLAVE_1=$3 >>$fn
150 echo BONDING_MODULE_OPTS=\'mode=active-backup miimon=100 primary=$2\' >>$fn
151}
152
153function create_bond {
154 local bondname=bond$bondcnt
155 local primary
156 local secondary
157
158 local class_id1=`cat $sysdir/$1/device/class_id 2>/dev/null`
159 local class_id2=`cat $sysdir/$2/device/class_id 2>/dev/null`
160
161 if [ "$class_id1" = "$netvsc_cls" ]
162 then
163 primary=$2
164 secondary=$1
165 elif [ "$class_id2" = "$netvsc_cls" ]
166 then
167 primary=$1
168 secondary=$2
169 else
170 return 0
171 fi
172
173 echo $'\nBond name:' $bondname
174
175 echo configuring $primary
176 create_eth_cfg_pri_$distro $primary $bondname
177
178 echo configuring $secondary
179 create_eth_cfg_$distro $secondary $bondname
180
181 echo creating: $bondname with primary slave: $primary
182 create_bond_cfg_$distro $bondname $primary $secondary
183
184 let bondcnt=bondcnt+1
185}
186
187for (( i=0; i < $eth_cnt-1; i++ ))
188do
189 if [ -n "${list_match[$i]}" ]
190 then
191 create_bond ${list_eth[$i]} ${list_match[$i]}
192 fi
193done
diff --git a/tools/perf/scripts/python/netdev-times.py b/tools/perf/scripts/python/netdev-times.py
index 4d21ef2d601d..4c6f09ac7d12 100644
--- a/tools/perf/scripts/python/netdev-times.py
+++ b/tools/perf/scripts/python/netdev-times.py
@@ -252,9 +252,10 @@ def irq__irq_handler_exit(name, context, cpu, sec, nsec, pid, comm, callchain, i
252 event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm, irq, ret) 252 event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm, irq, ret)
253 all_event_list.append(event_info) 253 all_event_list.append(event_info)
254 254
255def napi__napi_poll(name, context, cpu, sec, nsec, pid, comm, callchain, napi, dev_name): 255def napi__napi_poll(name, context, cpu, sec, nsec, pid, comm, callchain, napi,
256 dev_name, work=None, budget=None):
256 event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm, 257 event_info = (name, context, cpu, nsecs(sec, nsec), pid, comm,
257 napi, dev_name) 258 napi, dev_name, work, budget)
258 all_event_list.append(event_info) 259 all_event_list.append(event_info)
259 260
260def net__netif_receive_skb(name, context, cpu, sec, nsec, pid, comm, callchain, skbaddr, 261def net__netif_receive_skb(name, context, cpu, sec, nsec, pid, comm, callchain, skbaddr,
@@ -354,11 +355,13 @@ def handle_irq_softirq_exit(event_info):
354 receive_hunk_list.append(rec_data) 355 receive_hunk_list.append(rec_data)
355 356
356def handle_napi_poll(event_info): 357def handle_napi_poll(event_info):
357 (name, context, cpu, time, pid, comm, napi, dev_name) = event_info 358 (name, context, cpu, time, pid, comm, napi, dev_name,
359 work, budget) = event_info
358 if cpu in net_rx_dic.keys(): 360 if cpu in net_rx_dic.keys():
359 event_list = net_rx_dic[cpu]['event_list'] 361 event_list = net_rx_dic[cpu]['event_list']
360 rec_data = {'event_name':'napi_poll', 362 rec_data = {'event_name':'napi_poll',
361 'dev':dev_name, 'event_t':time} 363 'dev':dev_name, 'event_t':time,
364 'work':work, 'budget':budget}
362 event_list.append(rec_data) 365 event_list.append(rec_data)
363 366
364def handle_netif_rx(event_info): 367def handle_netif_rx(event_info):
diff --git a/tools/virtio/ringtest/Makefile b/tools/virtio/ringtest/Makefile
index 6173adae9f08..877a8a4721b6 100644
--- a/tools/virtio/ringtest/Makefile
+++ b/tools/virtio/ringtest/Makefile
@@ -1,6 +1,6 @@
1all: 1all:
2 2
3all: ring virtio_ring_0_9 virtio_ring_poll virtio_ring_inorder noring 3all: ring virtio_ring_0_9 virtio_ring_poll virtio_ring_inorder ptr_ring noring
4 4
5CFLAGS += -Wall 5CFLAGS += -Wall
6CFLAGS += -pthread -O2 -ggdb 6CFLAGS += -pthread -O2 -ggdb
@@ -8,6 +8,7 @@ LDFLAGS += -pthread -O2 -ggdb
8 8
9main.o: main.c main.h 9main.o: main.c main.h
10ring.o: ring.c main.h 10ring.o: ring.c main.h
11ptr_ring.o: ptr_ring.c main.h ../../../include/linux/ptr_ring.h
11virtio_ring_0_9.o: virtio_ring_0_9.c main.h 12virtio_ring_0_9.o: virtio_ring_0_9.c main.h
12virtio_ring_poll.o: virtio_ring_poll.c virtio_ring_0_9.c main.h 13virtio_ring_poll.o: virtio_ring_poll.c virtio_ring_0_9.c main.h
13virtio_ring_inorder.o: virtio_ring_inorder.c virtio_ring_0_9.c main.h 14virtio_ring_inorder.o: virtio_ring_inorder.c virtio_ring_0_9.c main.h
@@ -15,6 +16,7 @@ ring: ring.o main.o
15virtio_ring_0_9: virtio_ring_0_9.o main.o 16virtio_ring_0_9: virtio_ring_0_9.o main.o
16virtio_ring_poll: virtio_ring_poll.o main.o 17virtio_ring_poll: virtio_ring_poll.o main.o
17virtio_ring_inorder: virtio_ring_inorder.o main.o 18virtio_ring_inorder: virtio_ring_inorder.o main.o
19ptr_ring: ptr_ring.o main.o
18noring: noring.o main.o 20noring: noring.o main.o
19clean: 21clean:
20 -rm main.o 22 -rm main.o
@@ -22,6 +24,7 @@ clean:
22 -rm virtio_ring_0_9.o virtio_ring_0_9 24 -rm virtio_ring_0_9.o virtio_ring_0_9
23 -rm virtio_ring_poll.o virtio_ring_poll 25 -rm virtio_ring_poll.o virtio_ring_poll
24 -rm virtio_ring_inorder.o virtio_ring_inorder 26 -rm virtio_ring_inorder.o virtio_ring_inorder
27 -rm ptr_ring.o ptr_ring
25 -rm noring.o noring 28 -rm noring.o noring
26 29
27.PHONY: all clean 30.PHONY: all clean
diff --git a/tools/virtio/ringtest/ptr_ring.c b/tools/virtio/ringtest/ptr_ring.c
new file mode 100644
index 000000000000..68e4f9f0da3a
--- /dev/null
+++ b/tools/virtio/ringtest/ptr_ring.c
@@ -0,0 +1,197 @@
1#define _GNU_SOURCE
2#include "main.h"
3#include <stdlib.h>
4#include <stdio.h>
5#include <string.h>
6#include <pthread.h>
7#include <malloc.h>
8#include <assert.h>
9#include <errno.h>
10#include <limits.h>
11
12#define SMP_CACHE_BYTES 64
13#define cache_line_size() SMP_CACHE_BYTES
14#define ____cacheline_aligned_in_smp __attribute__ ((aligned (SMP_CACHE_BYTES)))
15#define unlikely(x) (__builtin_expect(!!(x), 0))
16#define ALIGN(x, a) (((x) + (a) - 1) / (a) * (a))
17typedef pthread_spinlock_t spinlock_t;
18
19typedef int gfp_t;
20static void *kmalloc(unsigned size, gfp_t gfp)
21{
22 return memalign(64, size);
23}
24
25static void *kzalloc(unsigned size, gfp_t gfp)
26{
27 void *p = memalign(64, size);
28 if (!p)
29 return p;
30 memset(p, 0, size);
31
32 return p;
33}
34
35static void kfree(void *p)
36{
37 if (p)
38 free(p);
39}
40
41static void spin_lock_init(spinlock_t *lock)
42{
43 int r = pthread_spin_init(lock, 0);
44 assert(!r);
45}
46
47static void spin_lock(spinlock_t *lock)
48{
49 int ret = pthread_spin_lock(lock);
50 assert(!ret);
51}
52
53static void spin_unlock(spinlock_t *lock)
54{
55 int ret = pthread_spin_unlock(lock);
56 assert(!ret);
57}
58
59static void spin_lock_bh(spinlock_t *lock)
60{
61 spin_lock(lock);
62}
63
64static void spin_unlock_bh(spinlock_t *lock)
65{
66 spin_unlock(lock);
67}
68
69static void spin_lock_irq(spinlock_t *lock)
70{
71 spin_lock(lock);
72}
73
74static void spin_unlock_irq(spinlock_t *lock)
75{
76 spin_unlock(lock);
77}
78
79static void spin_lock_irqsave(spinlock_t *lock, unsigned long f)
80{
81 spin_lock(lock);
82}
83
84static void spin_unlock_irqrestore(spinlock_t *lock, unsigned long f)
85{
86 spin_unlock(lock);
87}
88
89#include "../../../include/linux/ptr_ring.h"
90
91static unsigned long long headcnt, tailcnt;
92static struct ptr_ring array ____cacheline_aligned_in_smp;
93
94/* implemented by ring */
95void alloc_ring(void)
96{
97 int ret = ptr_ring_init(&array, ring_size, 0);
98 assert(!ret);
99}
100
101/* guest side */
102int add_inbuf(unsigned len, void *buf, void *datap)
103{
104 int ret;
105
106 ret = __ptr_ring_produce(&array, buf);
107 if (ret >= 0) {
108 ret = 0;
109 headcnt++;
110 }
111
112 return ret;
113}
114
115/*
116 * ptr_ring API provides no way for producer to find out whether a given
117 * buffer was consumed. Our tests merely require that a successful get_buf
118 * implies that add_inbuf succeed in the past, and that add_inbuf will succeed,
119 * fake it accordingly.
120 */
121void *get_buf(unsigned *lenp, void **bufp)
122{
123 void *datap;
124
125 if (tailcnt == headcnt || __ptr_ring_full(&array))
126 datap = NULL;
127 else {
128 datap = "Buffer\n";
129 ++tailcnt;
130 }
131
132 return datap;
133}
134
135void poll_used(void)
136{
137 void *b;
138
139 do {
140 if (tailcnt == headcnt || __ptr_ring_full(&array)) {
141 b = NULL;
142 barrier();
143 } else {
144 b = "Buffer\n";
145 }
146 } while (!b);
147}
148
149void disable_call()
150{
151 assert(0);
152}
153
154bool enable_call()
155{
156 assert(0);
157}
158
159void kick_available(void)
160{
161 assert(0);
162}
163
164/* host side */
165void disable_kick()
166{
167 assert(0);
168}
169
170bool enable_kick()
171{
172 assert(0);
173}
174
175void poll_avail(void)
176{
177 void *b;
178
179 do {
180 barrier();
181 b = __ptr_ring_peek(&array);
182 } while (!b);
183}
184
185bool use_buf(unsigned *lenp, void **bufp)
186{
187 void *ptr;
188
189 ptr = __ptr_ring_consume(&array);
190
191 return ptr;
192}
193
194void call_used(void)
195{
196 assert(0);
197}