From 01e7f64c6a140d20fa675d4336dadd1fdf8303c2 Mon Sep 17 00:00:00 2001 From: Max Rottenkolber Date: Fri, 23 Sep 2016 18:11:49 +0200 Subject: [PATCH] Remove rx/tx from link and counter names. Notable change: link counters are reversed: - input == enqueued onto the link - output == dequeued from the link --- src/apps/example/asm.dasl | 4 +- src/apps/intel/README.md | 14 +-- src/apps/intel/intel_app.lua | 116 +++++++++--------- src/apps/ipsec/esp.lua | 6 +- src/apps/ipv6/nd_light.lua | 30 ++--- src/apps/keyed_ipv6_tunnel/tunnel.lua | 6 +- src/apps/lwaftr/benchmark.lua | 20 +-- src/apps/packet_filter/pcap_filter.lua | 12 +- src/apps/rate_limiter/README.md | 4 +- src/apps/rate_limiter/rate_limiter.lua | 16 +-- src/apps/socket/README.md | 14 +-- src/apps/socket/raw.lua | 40 +++--- src/apps/socket/unix.lua | 16 +-- src/apps/solarflare/README.md | 14 +-- src/apps/solarflare/solarflare.lua | 4 +- src/apps/tap/tap.lua | 43 +++---- src/apps/test/README.md | 16 +-- src/apps/test/match.lua | 10 +- src/apps/test/synth.lua | 2 +- src/apps/vhost/README.md | 14 +-- src/apps/vhost/vhost_user.lua | 6 +- src/apps/virtio_net/README.md | 14 +-- src/apps/virtio_net/virtio_net.lua | 8 +- src/apps/vlan/vlan.lua | 4 +- src/core/app.lua | 8 +- src/core/config.lua | 2 +- src/core/link.h | 5 +- src/core/link.lua | 29 +++-- src/lib/io/virtual_ether_mux.lua | 22 ++-- src/lib/ipc/shmem/iftable_mib.lua | 68 +++++----- src/lib/virtio/net_device.lua | 6 +- src/program/example_replay/example_replay.lua | 2 +- .../lisper/dev-env-perftest/baseline.lua | 4 +- src/program/lisper/dev-env-perftest/count.lua | 4 +- src/program/lisper/lisper.lua | 20 +-- src/program/lwaftr/csv_stats.lua | 12 +- src/program/lwaftr/loadtest/loadtest.lua | 12 +- src/program/lwaftr/run/run.lua | 4 +- src/program/lwaftr/run_nohw/run_nohw.lua | 12 +- src/program/lwaftr/setup.lua | 8 +- src/program/lwaftr/transient/transient.lua | 8 +- src/program/packetblaster/lwaftr/lwaftr.lua | 6 +- src/program/snabbmark/snabbmark.lua | 40 +++--- src/program/snabbnfv/nfvconfig.lua | 34 ++--- src/program/snabbnfv/traffic/traffic.lua | 16 +-- src/program/top/README | 22 ++-- src/program/top/top.lua | 19 +-- 47 files changed, 404 insertions(+), 392 deletions(-) diff --git a/src/apps/example/asm.dasl b/src/apps/example/asm.dasl index f221af735e..0e45dd21da 100644 --- a/src/apps/example/asm.dasl +++ b/src/apps/example/asm.dasl @@ -52,8 +52,8 @@ function selftest () config.app(c, "source", basic_apps.Source) config.app(c, "sink", basic_apps.Sink) config.app(c, "asm", Asm) - config.link(c, "source.tx -> asm.rx") - config.link(c, "asm.tx -> sink.rx") + config.link(c, "source.output -> asm.input") + config.link(c, "asm.output -> sink.input") app.configure(c) app.main({duration = 0.1}) print("magic number: 0x"..bit.tohex(asm_status[0])) diff --git a/src/apps/intel/README.md b/src/apps/intel/README.md index 40e9aa0115..d6130d0b1e 100644 --- a/src/apps/intel/README.md +++ b/src/apps/intel/README.md @@ -3,15 +3,15 @@ ## Intel10G (apps.intel.intel_app) The `Intel10G` drives one port of an Intel 82599 Ethernet controller. -Packets taken from the `rx` port are transmitted onto the network. -Packets received from the network are put on the `tx` port. +Packets taken from the `input` port are transmitted onto the network. +Packets received from the network are put on the `output` port. DIAGRAM: Intel10G - +----------+ - | | - rx ---->* Intel10G *----> tx - | | - +----------+ + +----------+ + | | + input ---->* Intel10G *----> output + | | + +----------+ — Method **Intel10G.dev:get_rxstats** diff --git a/src/apps/intel/intel_app.lua b/src/apps/intel/intel_app.lua index 0302e623e5..2c11a66542 100644 --- a/src/apps/intel/intel_app.lua +++ b/src/apps/intel/intel_app.lua @@ -73,24 +73,24 @@ function Intel82599:new (conf) if not self.stats.shm then self.stats.shm = shm.create_frame( "pci/"..conf.pciaddr, - {dtime = {counter, C.get_unix_time()}, - mtu = {counter, self.dev.mtu}, - speed = {counter, 10000000000}, -- 10 Gbits - status = {counter, 2}, -- Link down - promisc = {counter}, - macaddr = {counter}, - rxbytes = {counter}, - rxpackets = {counter}, - rxmcast = {counter}, - rxbcast = {counter}, - rxdrop = {counter}, - rxerrors = {counter}, - txbytes = {counter}, - txpackets = {counter}, - txmcast = {counter}, - txbcast = {counter}, - txdrop = {counter}, - txerrors = {counter}}) + {dtime = {counter, C.get_unix_time()}, + mtu = {counter, self.dev.mtu}, + speed = {counter, 10000000000}, -- 10 Gbits + status = {counter, 2}, -- Link down + promisc = {counter}, + macaddr = {counter}, + input_bytes = {counter}, + input_packets = {counter}, + input_mcast = {counter}, + input_bcast = {counter}, + input_drop = {counter}, + input_errors = {counter}, + output_bytes = {counter}, + output_packets = {counter}, + output_mcast = {counter}, + output_bcast = {counter}, + output_drop = {counter}, + output_errors = {counter}}) self.stats.sync_timer = lib.timer(0.001, 'repeating', engine.now) if not conf.vmdq and conf.macaddr then @@ -140,9 +140,9 @@ function Intel82599:set_rx_buffer_freelist (fl) self.rx_buffer_freelist = fl end --- Pull in packets from the network and queue them on our 'tx' link. +-- Pull in packets from the network and queue them on our 'output' link. function Intel82599:pull () - local l = self.output.tx + local l = self.output.output if l == nil then return end self.dev:sync_receive() for i = 1, engine.pull_npackets do @@ -172,21 +172,21 @@ local promisc_mask = lib.bits{UPE=9} function Intel82599:sync_stats () local counters = self.stats.shm local s, r, qs = self.stats.s, self.stats.r, self.stats.qs - counter.set(counters.rxbytes, s.GORC64()) - counter.set(counters.rxpackets, s.GPRC()) + counter.set(counters.input_bytes, s.GORC64()) + counter.set(counters.input_packets, s.GPRC()) local mprc, bprc = s.MPRC(), s.BPRC() - counter.set(counters.rxmcast, mprc + bprc) - counter.set(counters.rxbcast, bprc) + counter.set(counters.input_mcast, mprc + bprc) + counter.set(counters.input_bcast, bprc) -- The RX receive drop counts are only available through the RX stats -- register. We only read stats register #0 here. - counter.set(counters.rxdrop, qs.QPRDC[0]()) - counter.set(counters.rxerrors, s.CRCERRS() + s.ILLERRC() + s.ERRBC() + - s.RUC() + s.RFC() + s.ROC() + s.RJC()) - counter.set(counters.txbytes, s.GOTC64()) - counter.set(counters.txpackets, s.GPTC()) + counter.set(counters.input_drop, qs.QPRDC[0]()) + counter.set(counters.input_errors, s.CRCERRS() + s.ILLERRC() + s.ERRBC() + + s.RUC() + s.RFC() + s.ROC() + s.RJC()) + counter.set(counters.output_bytes, s.GOTC64()) + counter.set(counters.output_packets, s.GPTC()) local mptc, bptc = s.MPTC(), s.BPTC() - counter.set(counters.txmcast, mptc + bptc) - counter.set(counters.txbcast, bptc) + counter.set(counters.output_mcast, mptc + bptc) + counter.set(counters.output_bcast, bptc) if bit.band(r.LINKS(), link_up_mask) == link_up_mask then counter.set(counters.status, 1) -- Up else @@ -199,16 +199,16 @@ function Intel82599:sync_stats () end end --- Push packets from our 'rx' link onto the network. +-- Push packets from our 'input' link onto the network. function Intel82599:push () - local l = self.input.rx + local l = self.input.input if l == nil then return end while not empty(l) and self.dev:can_transmit() do -- We must not send packets that are bigger than the MTU. This -- check is currently disabled to satisfy some selftests until -- agreement on this strategy is reached. -- if p.length > self.dev.mtu then - -- counter.add(self.stats.shm.txdrop) + -- counter.add(self.stats.shm.output_drop) -- packet.free(p) -- else do local p = receive(l) @@ -266,8 +266,8 @@ function selftest () mq_sw(pcideva) engine.main({duration = 1, report={showlinks=true, showapps=false}}) do - local a0Sends = link.stats(engine.app_table.nicAm0.input.rx).txpackets - local a1Gets = link.stats(engine.app_table.nicAm1.output.tx).rxpackets + local a0Sends = link.stats(engine.app_table.nicAm0.input.input).input_packets + local a1Gets = link.stats(engine.app_table.nicAm1.output.output).output_packets -- Check propertions with some modest margin for error if a1Gets < a0Sends * 0.45 or a1Gets > a0Sends * 0.55 then print("mq_sw: wrong proportion of packets passed/discarded") @@ -290,10 +290,10 @@ function selftest () engine.main({duration = 1, report={showlinks=true, showapps=false}}) do - local aSends = link.stats(engine.app_table.nicA.input.rx).txpackets - local aGets = link.stats(engine.app_table.nicA.output.tx).rxpackets - local bSends = link.stats(engine.app_table.nicB.input.rx).txpackets - local bGets = link.stats(engine.app_table.nicB.output.tx).rxpackets + local aSends = link.stats(engine.app_table.nicA.input.input).input_packets + local aGets = link.stats(engine.app_table.nicA.output.output).output_packets + local bSends = link.stats(engine.app_table.nicB.input.input).input_packets + local bGets = link.stats(engine.app_table.nicB.output.output).output_packets if bGets < aSends/2 or aGets < bSends/2 @@ -313,9 +313,9 @@ function selftest () engine.main({duration = 1, report={showlinks=true, showapps=false}}) do - local aSends = link.stats(engine.app_table.nicAs.input.rx).txpackets - local b0Gets = link.stats(engine.app_table.nicBm0.output.tx).rxpackets - local b1Gets = link.stats(engine.app_table.nicBm1.output.tx).rxpackets + local aSends = link.stats(engine.app_table.nicAs.input.input).input_packets + local b0Gets = link.stats(engine.app_table.nicBm0.output.output).output_packets + local b1Gets = link.stats(engine.app_table.nicBm1.output.output).output_packets if b0Gets < b1Gets/2 or b1Gets < b0Gets/2 or @@ -339,10 +339,10 @@ function sq_sq(pcidevA, pcidevB) config.app(c, 'nicA', Intel82599, {pciaddr=pcidevA}) config.app(c, 'nicB', Intel82599, {pciaddr=pcidevB}) config.app(c, 'sink', basic_apps.Sink) - config.link(c, 'source1.out -> nicA.rx') - config.link(c, 'source2.out -> nicB.rx') - config.link(c, 'nicA.tx -> sink.in1') - config.link(c, 'nicB.tx -> sink.in2') + config.link(c, 'source1.out -> nicA.input') + config.link(c, 'source2.out -> nicB.input') + config.link(c, 'nicA.output -> sink.in1') + config.link(c, 'nicB.output -> sink.in2') engine.configure(c) end @@ -389,10 +389,10 @@ function mq_sq(pcidevA, pcidevB) print("The packets should arrive evenly split between the VFs") config.app(c, 'sink_ms', basic_apps.Sink) config.link(c, 'source_ms.out -> repeater_ms.input') - config.link(c, 'repeater_ms.output -> nicAs.rx') - config.link(c, 'nicAs.tx -> sink_ms.in1') - config.link(c, 'nicBm0.tx -> sink_ms.in2') - config.link(c, 'nicBm1.tx -> sink_ms.in3') + config.link(c, 'repeater_ms.output -> nicAs.input') + config.link(c, 'nicAs.output -> sink_ms.in1') + config.link(c, 'nicBm0.output -> sink_ms.in2') + config.link(c, 'nicBm1.output -> sink_ms.in3') engine.configure(c) link.transmit(engine.app_table.source_ms.output.out, packet.from_string(d1)) link.transmit(engine.app_table.source_ms.output.out, packet.from_string(d2)) @@ -437,9 +437,9 @@ function mq_sw(pcidevA) print ("half of them go to nicAm1 and half go nowhere") config.app(c, 'sink_ms', basic_apps.Sink) config.link(c, 'source_ms.out -> repeater_ms.input') - config.link(c, 'repeater_ms.output -> nicAm0.rx') - config.link(c, 'nicAm0.tx -> sink_ms.in1') - config.link(c, 'nicAm1.tx -> sink_ms.in2') + config.link(c, 'repeater_ms.output -> nicAm0.input') + config.link(c, 'nicAm0.output -> sink_ms.in1') + config.link(c, 'nicAm1.output -> sink_ms.in2') engine.configure(c) link.transmit(engine.app_table.source_ms.output.out, packet.from_string(d1)) link.transmit(engine.app_table.source_ms.output.out, packet.from_string(d2)) @@ -489,9 +489,9 @@ function manyreconf(pcidevA, pcidevB, n, do_pf) }) config.app(c, 'sink_ms', basic_apps.Sink) config.link(c, 'source_ms.out -> repeater_ms.input') - config.link(c, 'repeater_ms.output -> nicAm0.rx') - config.link(c, 'nicAm0.tx -> sink_ms.in1') - config.link(c, 'nicAm1.tx -> sink_ms.in2') + config.link(c, 'repeater_ms.output -> nicAm0.input') + config.link(c, 'nicAm0.output -> sink_ms.in1') + config.link(c, 'nicAm1.output -> sink_ms.in2') if do_pf then engine.configure(config.new()) end engine.configure(c) link.transmit(engine.app_table.source_ms.output.out, packet.from_string(d1)) @@ -501,7 +501,7 @@ function manyreconf(pcidevA, pcidevB, n, do_pf) redos = redos + engine.app_table.nicAm1.dev.pf.redos maxredos = math.max(maxredos, engine.app_table.nicAm1.dev.pf.redos) waits = waits + engine.app_table.nicAm1.dev.pf.waitlu_ms - local sent = link.stats(engine.app_table.nicAm0.input.rx).txpackets + local sent = link.stats(engine.app_table.nicAm0.input.input).input_packets io.write (('test #%3d: VMDq VLAN=%d; 100ms burst. packet sent: %s\n'):format(i, 100+i, lib.comma_value(sent-prevsent))) if sent == prevsent then io.write("error: NIC transmit counter did not increase\n") diff --git a/src/apps/ipsec/esp.lua b/src/apps/ipsec/esp.lua index 15dee45fbc..f009d23eb3 100644 --- a/src/apps/ipsec/esp.lua +++ b/src/apps/ipsec/esp.lua @@ -13,7 +13,7 @@ AES128gcm = { spi = {required=true}, key = {required=true}, window_size = {} }, shm = { - txerrors = {counter}, rxerrors = {counter} + output_errors = {counter}, input_errors = {counter} } } @@ -43,7 +43,7 @@ function AES128gcm:push () link.transmit(output, p) else packet.free(p) - counter.add(self.shm.txerrors) + counter.add(self.shm.output_errors) end end -- Decapsulation path @@ -55,7 +55,7 @@ function AES128gcm:push () link.transmit(output, p) else packet.free(p) - counter.add(self.shm.rxerrors) + counter.add(self.shm.input_errors) end end end diff --git a/src/apps/ipv6/nd_light.lua b/src/apps/ipv6/nd_light.lua index 3147e5a333..e3e8ec8e38 100644 --- a/src/apps/ipv6/nd_light.lua +++ b/src/apps/ipv6/nd_light.lua @@ -59,9 +59,9 @@ nd_light.config = { } nd_light.shm = { status = {counter, 2}, -- Link down - rxerrors = {counter}, - txerrors = {counter}, - txdrop = {counter}, + input_errors = {counter}, + output_errors = {counter}, + output_drop = {counter}, ns_checksum_errors = {counter}, ns_target_address_errors = {counter}, na_duplicate_errors = {counter}, @@ -222,7 +222,7 @@ local function ns (self, dgram, eth, ipv6, icmp) mem[0], length = dgram:payload() if not icmp:checksum_check(mem[0], length, ipv6) then counter.add(self.shm.ns_checksum_errors) - counter.add(self.shm.rxerrors) + counter.add(self.shm.input_errors) return nil end -- Parse the neighbor solicitation and check if it contains our own @@ -230,7 +230,7 @@ local function ns (self, dgram, eth, ipv6, icmp) local ns = dgram:parse_match(nil, self._match_ns) if not ns then counter.add(self.shm.ns_target_address_errors) - counter.add(self.shm.rxerrors) + counter.add(self.shm.input_errors) return nil end -- Ignore options as long as we don't implement a proper neighbor @@ -252,20 +252,20 @@ end local function na (self, dgram, eth, ipv6, icmp) if self._eth_header then counter.add(self.shm.na_duplicate_errors) - counter.add(self.shm.rxerrors) + counter.add(self.shm.input_errors) return nil end local na = dgram:parse_match(nil, self._match_na) if not na then counter.add(self.shm.na_target_address_errors) - counter.add(self.shm.rxerrors) + counter.add(self.shm.input_errors) return nil end local option = na:options(dgram:payload()) if not (#option == 1 and option[1]:type() == 2) then -- Invalid NS, ignore counter.add(self.shm.nd_protocol_errors) - counter.add(self.shm.rxerrors) + counter.add(self.shm.input_errors) return nil end self._eth_header = ethernet:new({ src = self._config.local_mac, @@ -288,7 +288,7 @@ local function from_south (self, p) if ipv6:hop_limit() ~= 255 then -- Avoid off-link spoofing as per RFC counter.add(self.shm.nd_protocol_errors) - counter.add(self.shm.rxerrors) + counter.add(self.shm.input_errors) return nil end local result @@ -335,7 +335,7 @@ function nd_light:push () -- Drop packets until ND for the next-hop -- has completed. packet.free(link.receive(l_in)) - counter.add(self.shm.txdrop) + counter.add(self.shm.output_drop) else local p = cache.p p[0] = link.receive(l_in) @@ -344,7 +344,7 @@ function nd_light:push () link.transmit(l_out, p[0]) else packet.free(p[0]) - counter.add(self.shm.txerrors) + counter.add(self.shm.output_errors) end end end @@ -371,10 +371,10 @@ function selftest () config.app(c, "sink2", sink) config.link(c, "nd1.south -> nd2.south") config.link(c, "nd2.south -> nd1.south") - config.link(c, "sink1.tx -> nd1.north") - config.link(c, "nd1.north -> sink1.rx") - config.link(c, "sink2.tx -> nd2.north") - config.link(c, "nd2.north -> sink2.rx") + config.link(c, "sink1.output -> nd1.north") + config.link(c, "nd1.north -> sink1.input") + config.link(c, "sink2.output -> nd2.north") + config.link(c, "nd2.north -> sink2.input") engine.configure(c) engine.main({ duration = 2 }) assert(engine.app_table.nd1._eth_header) diff --git a/src/apps/keyed_ipv6_tunnel/tunnel.lua b/src/apps/keyed_ipv6_tunnel/tunnel.lua index ad78f36cfd..55d0fc7580 100644 --- a/src/apps/keyed_ipv6_tunnel/tunnel.lua +++ b/src/apps/keyed_ipv6_tunnel/tunnel.lua @@ -116,7 +116,7 @@ SimpleKeyedTunnel = { -- unsigned integer <= 255 hop_limit = {} }, - shm = { rxerrors = {counter}, + shm = { input_errors = {counter}, length_errors = {counter}, protocol_errors = {counter}, cookie_errors = {counter}, @@ -245,7 +245,7 @@ function SimpleKeyedTunnel:push() until true if drop then - counter.add(self.shm.rxerrors) + counter.add(self.shm.input_errors) -- discard packet packet.free(p) else @@ -279,7 +279,7 @@ function selftest () config.link(c, "source.output -> tunnel.decapsulated") config.link(c, "comparator.output -> match.comparator") config.link(c, "tunnel.encapsulated -> tunnel.encapsulated") - config.link(c, "tunnel.decapsulated -> match.rx") + config.link(c, "tunnel.decapsulated -> match.input") app.configure(c) app.main({duration = 0.0001, report = {showapps=true,showlinks=true}}) diff --git a/src/apps/lwaftr/benchmark.lua b/src/apps/lwaftr/benchmark.lua index 68da805d1d..4ba50abc35 100644 --- a/src/apps/lwaftr/benchmark.lua +++ b/src/apps/lwaftr/benchmark.lua @@ -11,10 +11,10 @@ local lwaftr = require("apps.lwaftr.lwaftr") local C = ffi.C local paths = { - ["nicv4-in"] = "nicv4.input.rx", - ["nicv6-in"] = "nicv6.input.rx", - ["nicv4-out"] = "nicv4.output.tx", - ["nicv6-out"] = "nicv6.output.tx", + ["nicv4-in"] = "nicv4.input.input", + ["nicv6-in"] = "nicv6.input.input", + ["nicv4-out"] = "nicv4.output.output", + ["nicv6-out"] = "nicv6.output.output", ["lwaftrv4-out"] = "lwaftr.output.v4", ["lwaftrv6-out"] = "lwaftr.output.v6", ["lwaftrv4-in"] = "lwaftr.input.v4", @@ -56,10 +56,10 @@ Rate(Mpps): {rate_mpps} end local function report_bench(input, name, engine, finish, start) local breaths = tonumber(counter.read(engine.breaths)) - local bytes = input.txbytes + local bytes = input.input_bytes -- Don't bother to report on interfaces that were boring if bytes == 0 then return end - local packets = input.txpackets + local packets = input.input_packets local runtime = finish - start report(name, breaths, bytes, packets, runtime) end @@ -117,13 +117,13 @@ local function testInternalLoopbackFromPcapFile (params) config.link(c, 'pcapv4.output -> repeater_v4.input') config.link(c, 'repeater_v4.output -> lwaftr.v4') - config.link(c, 'lwaftr.v4 -> nicv4.rx') - config.link(c, 'nicv4.tx -> sink.in1') + config.link(c, 'lwaftr.v4 -> nicv4.input') + config.link(c, 'nicv4.output -> sink.in1') config.link(c, 'pcapv6.output -> repeater_v6.input') config.link(c, 'repeater_v6.output -> lwaftr.v6') - config.link(c, 'lwaftr.v6 -> nicv6.rx') - config.link(c, 'nicv6.tx -> sink.in1') + config.link(c, 'lwaftr.v6 -> nicv6.input') + config.link(c, 'nicv6.output -> sink.in1') engine.configure(c) diff --git a/src/apps/packet_filter/pcap_filter.lua b/src/apps/packet_filter/pcap_filter.lua index c832b60945..dea3a27c97 100644 --- a/src/apps/packet_filter/pcap_filter.lua +++ b/src/apps/packet_filter/pcap_filter.lua @@ -33,15 +33,15 @@ function PcapFilter:new (conf) -- XXX Investigate the latency impact of filter compilation. accept_fn = pf.compile_filter(conf.filter), state_table = conf.state_table or false, - shm = { rxerrors = {counter}, sessions_established = {counter} } + shm = { input_errors = {counter}, sessions_established = {counter} } } if conf.state_table then conntrack.define(conf.state_table) end return setmetatable(o, { __index = PcapFilter }) end function PcapFilter:push () - local i = assert(self.input.input or self.input.rx, "input port not found") - local o = assert(self.output.output or self.output.tx, "output port not found") + local i = assert(self.input.input or self.input.input, "input port not found") + local o = assert(self.output.output or self.output.output, "output port not found") while not link.empty(i) do local p = link.receive(i) @@ -57,7 +57,7 @@ function PcapFilter:push () link.transmit(o, p) else packet.free(p) - counter.add(self.shm.rxerrors) + counter.add(self.shm.input_errors) end end end @@ -117,8 +117,8 @@ function selftest_run (stateful, expected, tolerance) repeat app.breathe() until deadline() app.report({showlinks=true}) - local sent = link.stats(app.app_table.pcap_filter.input.input).rxpackets - local accepted = link.stats(app.app_table.pcap_filter.output.output).txpackets + local sent = link.stats(app.app_table.pcap_filter.input.input).output_packets + local accepted = link.stats(app.app_table.pcap_filter.output.output).input_packets local acceptrate = accepted * 100 / sent if acceptrate >= expected and acceptrate <= expected+tolerance then print(("ok: accepted %.4f%% of inputs (within tolerance)"):format(acceptrate)) diff --git a/src/apps/rate_limiter/README.md b/src/apps/rate_limiter/README.md index 4b990bbc33..5ee924b944 100644 --- a/src/apps/rate_limiter/README.md +++ b/src/apps/rate_limiter/README.md @@ -17,8 +17,8 @@ the `input` port and transmits conforming packets to the `output` port. Returns throughput statistics in form of a table with the following fields: -* `rx` - Number of packets received -* `tx` - Number of packets transmitted +* `input` - Number of packets received +* `output` - Number of packets transmitted * `time` - Current time in nanoseconds diff --git a/src/apps/rate_limiter/rate_limiter.lua b/src/apps/rate_limiter/rate_limiter.lua index 3b68b65c62..4ae32540a6 100644 --- a/src/apps/rate_limiter/rate_limiter.lua +++ b/src/apps/rate_limiter/rate_limiter.lua @@ -39,7 +39,7 @@ function RateLimiter:new (conf) rate = conf.rate, bucket_capacity = conf.bucket_capacity, bucket_content = conf.initial_capacity, - shm = { txdrop = {counter} } + shm = { output_drop = {counter} } } return setmetatable(o, {__index=RateLimiter}) end @@ -56,8 +56,8 @@ end function RateLimiter:get_stat_snapshot () return { - rx = link.stats(self.input.input).txpackets, - tx = link.stats(self.output.output).txpackets, + input = link.stats(self.input.input).output_packets, + output = link.stats(self.output.output).output_packets, time = tonumber(C.get_time_ns()), } end @@ -86,7 +86,7 @@ function RateLimiter:push () link.transmit(o, p) else -- discard packet - counter.add(self.shm.txdrop) + counter.add(self.shm.output_drop) packet.free(p) end end @@ -95,8 +95,8 @@ end local function compute_effective_rate (rl, rate, snapshot) local elapsed_time = (tonumber(C.get_time_ns()) - snapshot.time) / 1e9 - local tx = link.stats(rl.output.output).txpackets - snapshot.tx - return floor(tx * PACKET_SIZE / elapsed_time) + local output = link.stats(rl.output.output).output_packets - snapshot.output + return floor(output * PACKET_SIZE / elapsed_time) end function selftest () @@ -202,8 +202,8 @@ function selftest () (tonumber(C.get_time_ns()) - snapshot.time) / 1e9 print("elapsed time ", elapsed_time, "seconds") - local rx = link.stats(rl.input.input).txpackets - snapshot.rx - print("packets received", rx, floor(rx / elapsed_time / 1e6), "Mpps") + local input = link.stats(rl.input.input).output_packets - snapshot.input + print("packets received", input, floor(input / elapsed_time / 1e6), "Mpps") effective_rate_busy_loop = compute_effective_rate( rl, diff --git a/src/apps/socket/README.md b/src/apps/socket/README.md index d6823ce160..a39b0a2a71 100644 --- a/src/apps/socket/README.md +++ b/src/apps/socket/README.md @@ -1,16 +1,16 @@ # RawSocket App (apps.socket.raw) The `RawSocket` app is a bridge between Linux network interfaces (`eth0`, -`lo`, etc.) and a Snabb app network. Packets taken from the `rx` port are +`lo`, etc.) and a Snabb app network. Packets taken from the `input` port are transmitted over the selected interface. Packets received on the -interface are put on the `tx` port. +interface are put on the `output` port. DIAGRAM: RawSocket - +-----------+ - | | - rx ---->* RawSocket *----> tx - | | - +-----------+ + +-----------+ + | | + input ---->* RawSocket *----> output + | | + +-----------+ ## Configuration diff --git a/src/apps/socket/raw.lua b/src/apps/socket/raw.lua index 13ecb8d635..30e8c66897 100644 --- a/src/apps/socket/raw.lua +++ b/src/apps/socket/raw.lua @@ -44,19 +44,19 @@ function RawSocket:new (ifname) end return setmetatable({sock = sock, rx_p = packet.allocate(), - shm = { rxbytes = {counter}, - rxpackets = {counter}, - rxmcast = {counter}, - rxbcast = {counter}, - txbytes = {counter}, - txpackets = {counter}, - txmcast = {counter}, - txbcast = {counter} }}, + shm = { input_bytes = {counter}, + input_packets = {counter}, + input_mcast = {counter}, + input_bcast = {counter}, + output_bytes = {counter}, + output_packets = {counter}, + output_mcast = {counter}, + output_bcast = {counter} }}, {__index = RawSocket}) end function RawSocket:pull () - local l = self.output.tx + local l = self.output.output if l == nil then return end local limit = engine.pull_npackets while limit > 0 and self:can_receive() do @@ -78,30 +78,30 @@ function RawSocket:receive () local p = self.rx_p local sz = assert(S.read(self.sock, p.data, packet.max_payload)) p.length = sz - counter.add(self.shm.rxbytes, sz) - counter.add(self.shm.rxpackets) + counter.add(self.shm.input_bytes, sz) + counter.add(self.shm.input_packets) if ethernet:is_mcast(p.data) then - counter.add(self.shm.rxmcast) + counter.add(self.shm.input_mcast) end if ethernet:is_bcast(p.data) then - counter.add(self.shm.rxbcast) + counter.add(self.shm.input_bcast) end return packet.clone(p) end function RawSocket:push () - local l = self.input.rx + local l = self.input.input if l == nil then return end while not link.empty(l) and self:can_transmit() do local p = link.receive(l) self:transmit(p) - counter.add(self.shm.txbytes, p.length) - counter.add(self.shm.txpackets) + counter.add(self.shm.output_bytes, p.length) + counter.add(self.shm.output_packets) if ethernet:is_mcast(p.data) then - counter.add(self.shm.txmcast) + counter.add(self.shm.output_mcast) end if ethernet:is_bcast(p.data) then - counter.add(self.shm.txbcast) + counter.add(self.shm.output_bcast) end packet.free(p) end @@ -139,10 +139,10 @@ function selftest () local c = config.new() config.app(c, "lo", RawSocket, "lo") config.app(c, "match", Match, {fuzzy=true}) - config.link(c, "lo.tx->match.rx") + config.link(c, "lo.output->match.input") engine.configure(c) local link_in, link_cmp = link.new("test_in"), link.new("test_cmp") - engine.app_table.lo.input.rx = link_in + engine.app_table.lo.input.input = link_in engine.app_table.match.input.comparator = link_cmp -- Construct packet. local dg_tx = datagram:new() diff --git a/src/apps/socket/unix.lua b/src/apps/socket/unix.lua index 57d29f2b92..7bb416c479 100644 --- a/src/apps/socket/unix.lua +++ b/src/apps/socket/unix.lua @@ -146,7 +146,7 @@ function UnixSocket:new (arg) local self = setmetatable({}, self) function self:pull() - local l = self.output.tx + local l = self.output.output if l == nil then return end local limit = engine.pull_npackets while limit > 0 and can_receive() do @@ -159,7 +159,7 @@ function UnixSocket:new (arg) end function self:push() - local l = self.input.rx + local l = self.input.input if l == nil then return end while not link.empty(l) and can_send() do local p = link.receive(l) --we own p now so we must free it @@ -182,7 +182,7 @@ function selftest () function printapp:new (name) return { push = function(self) - local l = self.input.rx + local l = self.input.input if l == nil then return end while not link.empty(l) do local p = link.receive(l) @@ -197,7 +197,7 @@ function selftest () function echoapp:new (text) return { pull = function(self) - local l = self.output.tx + local l = self.output.output if l == nil then return end for i=1,engine.pull_npackets do local p = packet.allocate() @@ -213,11 +213,11 @@ function selftest () local c = config.new() config.app(c, "server", UnixSocket, {filename = file, listen = true}) config.app(c, "client", UnixSocket, file) - config.app(c, "print_client_tx", printapp, "client tx") + config.app(c, "print_client_output", printapp, "client output") config.app(c, "say_hello", echoapp, "hello ") - config.link(c, "client.tx -> print_client_tx.rx") - config.link(c, "say_hello.tx -> client.rx") - config.link(c, "server.tx -> server.rx") + config.link(c, "client.output -> print_client_output.input") + config.link(c, "say_hello.output -> client.input") + config.link(c, "server.output -> server.input") engine.configure(c) engine.main({duration=0.1, report = {showlinks=true}}) diff --git a/src/apps/solarflare/README.md b/src/apps/solarflare/README.md index 15cb695591..e0b11ac341 100644 --- a/src/apps/solarflare/README.md +++ b/src/apps/solarflare/README.md @@ -6,15 +6,15 @@ The `Solarflare` app drives one port of a Solarflare SFN7 Ethernet controller. Multiple instances of the Solarflare app can be instantiated on the same PCI device. Packets received from the network will be dispatched between apps based on destination MAC address and VLAN. -Packets taken from the `rx` port are transmitted onto the network. -Packets received from the network are put on the `tx` port. +Packets taken from the `input` port are transmitted onto the network. +Packets received from the network are put on the `output` port. DIAGRAM: Solarflare - +------------+ - | | - rx ---->* Solarflare *----> tx - | | - +------------+ + +------------+ + | | + input ---->* Solarflare *----> output + | | + +------------+ The `Solarflare` app requires [OpenOnload](http://www.openonload.org/) version *201502* to be installed and the `sfc` module to be loaded. diff --git a/src/apps/solarflare/solarflare.lua b/src/apps/solarflare/solarflare.lua index 1e0c2e0102..f1f0944fc1 100644 --- a/src/apps/solarflare/solarflare.lua +++ b/src/apps/solarflare/solarflare.lua @@ -254,7 +254,7 @@ function SolarFlareNic:pull() local rxpacket = self.rxpackets[self.poll_structure.events[i].rx.rq_id] rxpacket.length = self.poll_structure.events[i].rx.len self.stats.rx = (self.stats.rx or 0) + 1 - link.transmit(self.output.tx, rxpacket) + link.transmit(self.output.output, rxpacket) self.enqueue_receive(self, self.poll_structure.events[i].rx.rq_id) elseif event_type == C.EF_EVENT_TYPE_RX and pull_npackets == 0 then self.stats.rxdrop = (self.stats.rxdrop or 0) + 1 @@ -285,7 +285,7 @@ end function SolarFlareNic:push() need_poll = 1 self.stats.push = (self.stats.push or 0) + 1 - local l = self.input.rx + local l = self.input.input local push = not link.empty(l) while not link.empty(l) and self.tx_space >= 1 do self.enqueue_transmit(self, link.receive(l)) diff --git a/src/apps/tap/tap.lua b/src/apps/tap/tap.lua index f0fb97bc98..c1bd5fdd8c 100644 --- a/src/apps/tap/tap.lua +++ b/src/apps/tap/tap.lua @@ -14,7 +14,18 @@ local os = require("os") local t = S.types.t -Tap = { } +Tap = { + shm = { + input_bytes = {counter}, + input_packets = {counter}, + input_mcast = {counter}, + input_bcast = {counter}, + output_bytes = {counter}, + output_packets = {counter}, + output_mcast = {counter}, + output_bcast = {counter} + } +} function Tap:new (name) assert(name, "missing tap interface name") @@ -29,17 +40,7 @@ function Tap:new (name) sock:close() error("Error opening /dev/net/tun: " .. tostring(err)) end - return setmetatable({sock = sock, - name = name, - shm = { rxbytes = {counter}, - rxpackets = {counter}, - rxmcast = {counter}, - rxbcast = {counter}, - txbytes = {counter}, - txpackets = {counter}, - txmcast = {counter}, - txbcast = {counter} }}, - {__index = Tap}) + return setmetatable({sock = sock, name = name}, {__index = Tap}) end function Tap:pull () @@ -60,13 +61,13 @@ function Tap:pull () end p.length = len link.transmit(l, p) - counter.add(self.shm.rxbytes, len) - counter.add(self.shm.rxpackets) + counter.add(self.shm.input_bytes, len) + counter.add(self.shm.input_packets) if ethernet:is_mcast(p.data) then - counter.add(self.shm.rxmcast) + counter.add(self.shm.input_mcast) end if ethernet:is_bcast(p.data) then - counter.add(self.shm.rxbcast) + counter.add(self.shm.input_bcast) end end end @@ -85,13 +86,13 @@ function Tap:push () if len ~= p.length and err.errno == const.E.AGAIN then return end - counter.add(self.shm.txbytes, len) - counter.add(self.shm.txpackets) + counter.add(self.shm.output_bytes, len) + counter.add(self.shm.output_packets) if ethernet:is_mcast(p.data) then - counter.add(self.shm.txmcast) + counter.add(self.shm.output_mcast) end if ethernet:is_bcast(p.data) then - counter.add(self.shm.txbcast) + counter.add(self.shm.output_bcast) end -- The write completed so dequeue it from the link and free the packet link.receive(l) @@ -124,7 +125,7 @@ function selftest() src="00:0c:29:3e:ca:7d"}) config.link(c, "comparator.output->match.comparator") config.link(c, "source.output->tap_in.input") - config.link(c, "tap_out.output->match.rx") + config.link(c, "tap_out.output->match.input") engine.configure(c) engine.main({duration = 0.01, report = {showapps=true,showlinks=true}}) assert(#engine.app_table.match:errors() == 0) diff --git a/src/apps/test/README.md b/src/apps/test/README.md index 8af07fbda0..832572396e 100644 --- a/src/apps/test/README.md +++ b/src/apps/test/README.md @@ -2,14 +2,14 @@ ## Match (apps.test.match) -The `Match` app compares packets received on its input port `rx` with those -received on the reference input port `comparator`, and reports mismatches as -well as packets from `comparator` that were not matched. +The `Match` app compares packets received on its `input` port with those +received on the `comparator` port, and reports mismatches as well as packets +from `comparator` that were not matched. DIAGRAM: Match +----------+ | | - rx ----* | + input ----* | | Match | comparator ---* | | | @@ -26,14 +26,14 @@ keys are defined: — Key **fuzzy** -*Optional.* If this key is `true` packets from `rx` that do not match the next -packet from `comparator` are ignored. The default is `false`. +*Optional.* If this key is `true` packets from `input` that do not match the +next packet from `comparator` are ignored. The default is `false`. — Key **modest** *Optional.* If this key is `true` unmatched packets from `comparator` are -ignored if at least one packet from ´rx´ was successfully matched. The default -is `false`. +ignored if at least one packet from `input` was successfully matched. The +default is `false`. ## Synth (apps.test.synth) diff --git a/src/apps/test/match.lua b/src/apps/test/match.lua index f8a2e4a47b..dee1aacff9 100644 --- a/src/apps/test/match.lua +++ b/src/apps/test/match.lua @@ -23,8 +23,8 @@ function Match:new (conf) end function Match:push () - while not link.empty(self.input.rx) do - local p = link.receive(self.input.rx) + while not link.empty(self.input.input) do + local p = link.receive(self.input.input) local cmp = link.front(self.input.comparator) if not cmp then elseif cmp.length ~= p.length @@ -65,7 +65,7 @@ function selftest() config.app(c, "comparator", basic_apps.Source, 8) config.link(c, "comparator.output -> sink.comparator") engine.configure(c) - engine.app_table.sink.input.rx = link.new("null") + engine.app_table.sink.input.input = link.new("null") engine.app_table.sink.seen = 1 engine.main({duration=0.0001}) assert(#engine.app_table.sink:errors() == 0) @@ -73,7 +73,7 @@ function selftest() engine.configure(config.new()) config.app(c, "sink", Match) config.app(c, "src", basic_apps.Source, 8) - config.link(c, "src.output -> sink.rx") + config.link(c, "src.output -> sink.input") engine.configure(c) engine.main({duration=0.0001}) assert(#engine.app_table.sink:errors() == 0) @@ -91,7 +91,7 @@ function selftest() config.app(c, "join", basic_apps.Join) config.link(c, "src.output -> join.src") config.link(c, "garbage.output -> join.garbage") - config.link(c, "join.out -> sink.rx") + config.link(c, "join.out -> sink.input") engine.configure(c) engine.main({duration=0.0001}) assert(#engine.app_table.sink:errors() == 0) diff --git a/src/apps/test/synth.lua b/src/apps/test/synth.lua index 93172fc2f9..d0656387ca 100644 --- a/src/apps/test/synth.lua +++ b/src/apps/test/synth.lua @@ -59,7 +59,7 @@ function selftest () src = "11:11:11:11:11:11", dst = "22:22:22:22:22:22" }) config.link(c, "reader.output->match.comparator") - config.link(c, "synth.output->match.rx") + config.link(c, "synth.output->match.input") engine.configure(c) engine.main({ duration = 0.0001, report = {showapps=true,showlinks=true}}) assert(#engine.app_table.match:errors() == 0) diff --git a/src/apps/vhost/README.md b/src/apps/vhost/README.md index 85f822b30f..a936f211fb 100644 --- a/src/apps/vhost/README.md +++ b/src/apps/vhost/README.md @@ -10,15 +10,15 @@ devices. With `VhostUser` SnabbSwitch can be used as a virtual ethernet interface by *QEMU virtual machines*. When connected via a UNIX socket, packets can -be sent to the virtual machine by transmitting them on the `rx` port and -packets send by the virtual machine will arrive on the `tx` port. +be sent to the virtual machine by transmitting them on the `input` port and +packets send by the virtual machine will arrive on the `output` port. DIAGRAM: VhostUser - +-----------+ - | | - rx --->* VhostUser *----> tx - | | - +-----------+ + +-----------+ + | | + input --->* VhostUser *----> output + | | + +-----------+ ## Configuration diff --git a/src/apps/vhost/vhost_user.lua b/src/apps/vhost/vhost_user.lua index 72df66cba2..7f7f005e20 100644 --- a/src/apps/vhost/vhost_user.lua +++ b/src/apps/vhost/vhost_user.lua @@ -414,12 +414,12 @@ function selftest () config.app(c, "source", basic_apps.Source, "250") config.app(c, "source_tee", basic_apps.Tee) - config.link(c, "vhost_user.tx -> vhost_tee.input") + config.link(c, "vhost_user.output -> vhost_tee.input") --config.link(c, "vhost_tee.dump -> vhost_dump.input") config.link(c, "vhost_tee.traffic -> sink.in") - config.link(c, "source.tx -> source_tee.input") - config.link(c, "source_tee.traffic -> vhost_user.rx") + config.link(c, "source.output -> source_tee.input") + config.link(c, "source_tee.traffic -> vhost_user.input") app.configure(c) local vhost_user = app.app_table.vhost_user diff --git a/src/apps/virtio_net/README.md b/src/apps/virtio_net/README.md index 451cf47ac3..02d3e03d61 100644 --- a/src/apps/virtio_net/README.md +++ b/src/apps/virtio_net/README.md @@ -4,15 +4,15 @@ The `VirtioNet` app implements a subset of the driver part of the [virtio-net](http://docs.oasis-open.org/virtio/virtio/v1.0/csprd04/virtio-v1.0-csprd04.html) specification. It can connect to a virtio-net device from within a QEMU virtual machine. Packets can be sent out of the virtual machine by transmitting them on -the `rx` port, and packets sent to the virtual machine will arrive on the `tx` -port. +the `input` port, and packets sent to the virtual machine will arrive on the +`output` port. DIAGRAM: VirtioNet - +-----------+ - | | - rx --->* VirtioNet *----> tx - | | - +-----------+ + +-----------+ + | | + input --->* VirtioNet *----> output + | | + +-----------+ ## Configuration diff --git a/src/apps/virtio_net/virtio_net.lua b/src/apps/virtio_net/virtio_net.lua index ffb6dc8c76..b842e2e008 100644 --- a/src/apps/virtio_net/virtio_net.lua +++ b/src/apps/virtio_net/virtio_net.lua @@ -32,7 +32,7 @@ end function VirtioNet:push() local dev = self.device - local l = self.input.rx + local l = self.input.input dev:recycle_transmit_buffers() @@ -49,7 +49,7 @@ end function VirtioNet:pull() local dev = self.device - local l = self.output.tx + local l = self.output.output if not l then return end local to_receive = math.min(engine.pull_npackets, dev:can_receive()) @@ -72,8 +72,8 @@ function selftest() config.app(c, 'source', pcap.PcapReader, input_file) config.app(c, 'VirtioNet', VirtioNet, {pciaddr=pcidev}) config.app(c, 'sink', basic_apps.Sink) - config.link(c, 'source.output -> VirtioNet.rx') - config.link(c, 'VirtioNet.tx -> sink.input') + config.link(c, 'source.output -> VirtioNet.input') + config.link(c, 'VirtioNet.output -> sink.input') engine.configure(c) engine.main({duration = 1, report={showlinks=true, showapps=true}}) end diff --git a/src/apps/vlan/vlan.lua b/src/apps/vlan/vlan.lua index 2024e72624..056056ecec 100644 --- a/src/apps/vlan/vlan.lua +++ b/src/apps/vlan/vlan.lua @@ -162,6 +162,6 @@ function selftest() app.configure(c) app.main({duration = 1}) - print("source sent: " .. link.stats(app.app_table.source.output.output).txpackets) - print("sink received: " .. link.stats(app.app_table.sink.input.input).rxpackets) + print("source sent: " .. link.stats(app.app_table.source.output.output).input_packets) + print("sink received: " .. link.stats(app.app_table.sink.input.input).output_packets) end diff --git a/src/core/app.lua b/src/core/app.lua index 50f05d991a..d1a416ec8f 100644 --- a/src/core/app.lua +++ b/src/core/app.lua @@ -409,10 +409,12 @@ function report_links () table.sort(names) for i, name in ipairs(names) do l = link_table[name] - local txpackets = counter.read(l.stats.txpackets) - local txdrop = counter.read(l.stats.txdrop) + local input_packets = counter.read(l.stats.input_packets) + local input_drop = counter.read(l.stats.input_drop) print(("%20s sent on %s (loss rate: %d%%)"):format( - lib.comma_value(txpackets), name, loss_rate(txdrop, txpackets))) + lib.comma_value(input_packets), + name, + loss_rate(input_drop, input_packets))) end end diff --git a/src/core/config.lua b/src/core/config.lua index 16492c1a1c..5f84d97535 100644 --- a/src/core/config.lua +++ b/src/core/config.lua @@ -37,7 +37,7 @@ end -- API: Add a link to the configuration. -- --- Example: config.link(c, "nic.tx -> vm.rx") +-- Example: config.link(c, "nic.output -> vm.input") function link (config, spec) config.links[canonical_link(spec)] = true end diff --git a/src/core/link.h b/src/core/link.h index add1d73bd1..ec3e0e57eb 100644 --- a/src/core/link.h +++ b/src/core/link.h @@ -9,7 +9,10 @@ struct link { // http://en.wikipedia.org/wiki/Circular_buffer struct packet *packets[LINK_RING_SIZE]; struct { - struct counter *dtime, *txbytes, *rxbytes, *txpackets, *rxpackets, *txdrop; + struct counter *dtime, + *input_bytes, *output_bytes, + *input_packets, *output_packets, + *input_drop; } stats; // Two cursors: // read: the next element to be read diff --git a/src/core/link.lua b/src/core/link.lua index 6fcc9fb58c..21b265ff50 100644 --- a/src/core/link.lua +++ b/src/core/link.lua @@ -23,7 +23,10 @@ local size = C.LINK_RING_SIZE -- NB: Huge slow-down if this is not local max = C.LINK_MAX_PACKETS local provided_counters = { - "dtime", "rxpackets", "rxbytes", "txpackets", "txbytes", "txdrop" + "dtime", + "output_packets", "output_bytes", + "input_packets", "input_bytes", + "input_drop" } function new (name) @@ -47,8 +50,8 @@ function receive (r) local p = r.packets[r.read] r.read = band(r.read + 1, size - 1) - counter.add(r.stats.rxpackets) - counter.add(r.stats.rxbytes, p.length) + counter.add(r.stats.output_packets) + counter.add(r.stats.output_bytes, p.length) return p end @@ -59,13 +62,13 @@ end function transmit (r, p) -- assert(p) if full(r) then - counter.add(r.stats.txdrop) + counter.add(r.stats.input_drop) packet.free(p) else r.packets[r.write] = p r.write = band(r.write + 1, size - 1) - counter.add(r.stats.txpackets) - counter.add(r.stats.txbytes, p.length) + counter.add(r.stats.input_packets) + counter.add(r.stats.input_bytes, p.length) r.has_new_data = true end end @@ -105,24 +108,24 @@ function selftest () print("selftest: link") local r = new("test") local p = packet.allocate() - assert(counter.read(r.stats.txpackets) == 0 and empty(r) == true and full(r) == false) + assert(counter.read(r.stats.input_packets) == 0 and empty(r) == true and full(r) == false) assert(nreadable(r) == 0) transmit(r, p) - assert(counter.read(r.stats.txpackets) == 1 and empty(r) == false and full(r) == false) + assert(counter.read(r.stats.input_packets) == 1 and empty(r) == false and full(r) == false) for i = 1, max-2 do transmit(r, p) end - assert(counter.read(r.stats.txpackets) == max-1 and empty(r) == false and full(r) == false) - assert(nreadable(r) == counter.read(r.stats.txpackets)) + assert(counter.read(r.stats.input_packets) == max-1 and empty(r) == false and full(r) == false) + assert(nreadable(r) == counter.read(r.stats.input_packets)) transmit(r, p) - assert(counter.read(r.stats.txpackets) == max and empty(r) == false and full(r) == true) + assert(counter.read(r.stats.input_packets) == max and empty(r) == false and full(r) == true) transmit(r, p) - assert(counter.read(r.stats.txpackets) == max and counter.read(r.stats.txdrop) == 1) + assert(counter.read(r.stats.input_packets) == max and counter.read(r.stats.input_drop) == 1) assert(not empty(r) and full(r)) while not empty(r) do receive(r) end - assert(counter.read(r.stats.rxpackets) == max) + assert(counter.read(r.stats.output_packets) == max) link.free(r, "test") print("selftest OK") end diff --git a/src/lib/io/virtual_ether_mux.lua b/src/lib/io/virtual_ether_mux.lua index 5fe69438d5..e03cfff0ee 100644 --- a/src/lib/io/virtual_ether_mux.lua +++ b/src/lib/io/virtual_ether_mux.lua @@ -29,15 +29,15 @@ function configure (c, ports, io) if io and io.iface then config.app(c, "TrunkIface", RawSocket, io.iface) Trunk = {port = "TrunkIface", - input = "TrunkIface.rx", - output = "TrunkIface.tx"} + input = "TrunkIface.input", + output = "TrunkIface.output"} end if io and io.bench then config.app(c, "BenchSource", Synth, io.bench) config.app(c, "BenchSink", basic_apps.Sink) Trunk = {port = "TrunkBench", - input = "BenchSink.rx", - output = "BenchSource.tx"} + input = "BenchSink.input", + output = "BenchSource.output"} end if Trunk then switch_ports[#switch_ports+1] = Trunk.port end if #ports <= 2 then @@ -53,17 +53,17 @@ function configure (c, ports, io) for i, port in ipairs(ports) do local name = port_name(port) local Switch_link = Switch.."."..name - local Port_tx, Port_rx = Switch_link, Switch_link + local Port_output, Port_input = Switch_link, Switch_link if port.vlan then local VlanTag, VlanUntag = name.."_VlanTag", name.."_VlanUntag" config.app(c, VlanTag, vlan.Tagger, {tag = port.vlan}) - config.link(c, VlanTag..".output -> "..Port_rx) - Port_rx = VlanTag..".input" + config.link(c, VlanTag..".output -> "..Port_input) + Port_input = VlanTag..".input" config.app(c, VlanUntag, vlan.Untagger, {tag = port.vlan}) - config.link(c, Port_tx.." -> "..VlanUntag..".input") - Port_tx = VlanUntag..".output" + config.link(c, Port_output.." -> "..VlanUntag..".input") + Port_output = VlanUntag..".output" end - links[i] = {input = Port_rx, output = Port_tx} + links[i] = {input = Port_input, output = Port_output} end end return links @@ -91,7 +91,7 @@ function configureVMDq (c, device, ports) vmdq = vmdq, macaddr = port.mac_address, vlan = port.vlan}) - links[i] = {input = NIC..".rx", output = NIC..".tx"} + links[i] = {input = NIC..".input", output = NIC..".output"} end return links end diff --git a/src/lib/ipc/shmem/iftable_mib.lua b/src/lib/ipc/shmem/iftable_mib.lua index c03f98c29a..5eb5f2821a 100644 --- a/src/lib/ipc/shmem/iftable_mib.lua +++ b/src/lib/ipc/shmem/iftable_mib.lua @@ -103,53 +103,57 @@ function init_snmp (name, counters, directory, interval) ifTable:set('ifPromiscuousMode', counter.read(counters.promisc)) end -- Update counters - if counters.rxpackets and counters.rxmcast and counters.rxbcast then - local rxbcast = counter.read(counters.rxbcast) - local rxmcast = counter.read(counters.rxmcast) - local rxpackets = counter.read(counters.rxpackets) - local inMcast = rxmcast - rxbcast - local inUcast = rxpackets - rxmcast + if counters.input_packets and + counters.input_mcast and + counters.input_bcast then + local input_bcast = counter.read(counters.input_bcast) + local input_mcast = counter.read(counters.input_mcast) + local input_packets = counter.read(counters.input_packets) + local inMcast = input_mcast - input_bcast + local inUcast = input_packets - input_mcast ifTable:set('ifHCInMulticastPkts', inMcast) ifTable:set('ifInMulticastPkts', inMcast) - ifTable:set('ifHCInBroadcastPkts', rxbcast) - ifTable:set('ifInBroadcastPkts', rxbcast) + ifTable:set('ifHCInBroadcastPkts', input_bcast) + ifTable:set('ifInBroadcastPkts', input_bcast) ifTable:set('ifHCInUcastPkts', inUcast) ifTable:set('ifInUcastPkts', inUcast) end - if counters.rxbytes then - local rxbytes = counter.read(counters.rxbytes) - ifTable:set('ifHCInOctets', rxbytes) - ifTable:set('ifInOctets', rxbytes) + if counters.input_bytes then + local input_bytes = counter.read(counters.input_bytes) + ifTable:set('ifHCInOctets', input_bytes) + ifTable:set('ifInOctets', input_bytes) end - if counters.rxdrop then - ifTable:set('ifInDiscards', counter.read(counters.rxdrop)) + if counters.input_drop then + ifTable:set('ifInDiscards', counter.read(counters.input_drop)) end - if counters.rxerrors then - ifTable:set('ifInErrors', counter.read(counters.rxerrors)) + if counters.input_errors then + ifTable:set('ifInErrors', counter.read(counters.input_errors)) end - if counters.txpackets and counters.txmcast and counters.txbcast then - local txbcast = counter.read(counters.txbcast) - local txmcast = counter.read(counters.txmcast) - local txpackets = counter.read(counters.txpackets) - local outMcast = txmcast - txbcast - local outUcast = txpackets - txmcast + if counters.output_packets and + counters.output_mcast and + counters.output_bcast then + local output_bcast = counter.read(counters.output_bcast) + local output_mcast = counter.read(counters.output_mcast) + local output_packets = counter.read(counters.output_packets) + local outMcast = output_mcast - output_bcast + local outUcast = output_packets - output_mcast ifTable:set('ifHCOutMulticastPkts', outMcast) ifTable:set('ifOutMulticastPkts', outMcast) - ifTable:set('ifHCOutBroadcastPkts', txbcast) - ifTable:set('ifOutBroadcastPkts', txbcast) + ifTable:set('ifHCOutBroadcastPkts', output_bcast) + ifTable:set('ifOutBroadcastPkts', output_bcast) ifTable:set('ifHCOutUcastPkts', outUcast) ifTable:set('ifOutUcastPkts', outUcast) end - if counters.txbytes then - local txbytes = counter.read(counters.txbytes) - ifTable:set('ifHCOutOctets', txbytes) - ifTable:set('ifOutOctets', txbytes) + if counters.output_bytes then + local output_bytes = counter.read(counters.output_bytes) + ifTable:set('ifHCOutOctets', output_bytes) + ifTable:set('ifOutOctets', output_bytes) end - if counters.txdrop then - ifTable:set('ifOutDiscards', counter.read(counters.txdrop)) + if counters.output_drop then + ifTable:set('ifOutDiscards', counter.read(counters.output_drop)) end - if counters.txerrors then - ifTable:set('ifOutErrors', counter.read(counters.txerrors)) + if counters.output_errors then + ifTable:set('ifOutErrors', counter.read(counters.output_errors)) end end local t = timer.new("Interface "..name.." status checker", diff --git a/src/lib/virtio/net_device.lua b/src/lib/virtio/net_device.lua index 10164d3a11..281d19c5cf 100644 --- a/src/lib/virtio/net_device.lua +++ b/src/lib/virtio/net_device.lua @@ -153,7 +153,7 @@ function VirtioNetDevice:rx_buffer_add(rx_p, addr, len) end function VirtioNetDevice:rx_packet_end(header_id, total_size, rx_p) - local l = self.owner.output.tx + local l = self.owner.output.output if l then if band(self.rx_hdr_flags, C.VIO_NET_HDR_F_NEEDS_CSUM) ~= 0 and -- Bounds-check the checksum area @@ -225,7 +225,7 @@ end function VirtioNetDevice:tx_packet_start(addr, len) - local l = self.owner.input.rx + local l = self.owner.input.input if link.empty(l) then return nil, nil end local tx_p = link.receive(l) @@ -261,7 +261,7 @@ end function VirtioNetDevice:tx_packet_start_mrg_rxbuf(addr, len) local tx_mrg_hdr = ffi.cast(virtio_net_hdr_mrg_rxbuf_type, self:map_from_guest(addr)) - local l = self.owner.input.rx + local l = self.owner.input.input local tx_p = self.tx.p ffi.fill(tx_mrg_hdr, virtio_net_hdr_mrg_rxbuf_size) diff --git a/src/program/example_replay/example_replay.lua b/src/program/example_replay/example_replay.lua index 1375611109..424e7921fd 100755 --- a/src/program/example_replay/example_replay.lua +++ b/src/program/example_replay/example_replay.lua @@ -17,7 +17,7 @@ function run (parameters) config.app(c, "capture", pcap.PcapReader, pcap_file) config.app(c, "playback", raw.RawSocket, interface) - config.link(c, "capture.output -> playback.rx") + config.link(c, "capture.output -> playback.input") engine.configure(c) engine.main({duration=1, report = {showlinks=true}}) diff --git a/src/program/lisper/dev-env-perftest/baseline.lua b/src/program/lisper/dev-env-perftest/baseline.lua index 1db94c9af5..5906765be3 100755 --- a/src/program/lisper/dev-env-perftest/baseline.lua +++ b/src/program/lisper/dev-env-perftest/baseline.lua @@ -20,8 +20,8 @@ config.app(c, "e1", intel.Intel82599, { macaddr = "00:00:00:00:01:02", }) -config.link(c, "e0.tx -> e1.rx") -config.link(c, "e1.tx -> e0.rx") +config.link(c, "e0.output -> e1.input") +config.link(c, "e1.output -> e0.input") engine.configure(c) engine.main({report = {showlinks=true}}) diff --git a/src/program/lisper/dev-env-perftest/count.lua b/src/program/lisper/dev-env-perftest/count.lua index 9b95f1d2ac..42515eb9b2 100755 --- a/src/program/lisper/dev-env-perftest/count.lua +++ b/src/program/lisper/dev-env-perftest/count.lua @@ -24,7 +24,7 @@ function Counter:new() end function Counter:push() - local rx = self.input.rx + local rx = self.input.input if rx == nil then return end while not link.empty(rx) do local p = link.receive(rx) @@ -42,7 +42,7 @@ config.app(c, "eth", intel.Intel82599, { macaddr = "00:00:00:00:02:02", }) -config.link(c, "eth.tx -> count.rx") +config.link(c, "eth.output -> count.input") engine.configure(c) engine.main({report = {showlinks=true}}) diff --git a/src/program/lisper/lisper.lua b/src/program/lisper/lisper.lua index 0f43e4c181..2b0a5b93b3 100644 --- a/src/program/lisper/lisper.lua +++ b/src/program/lisper/lisper.lua @@ -591,7 +591,7 @@ function Ctl:new() end function Ctl:push() - local rx = self.input.rx + local rx = self.input.input if rx == nil then return end while not link.empty(rx) do local p = link.receive(rx) @@ -607,7 +607,7 @@ function Punt:new() end function Punt:pull() - local tx = self.output.tx + local tx = self.output.output if tx == nil then return end for i=1,engine.pull_npackets do local s = get_punt_message() @@ -652,8 +652,8 @@ function Dumper:new(text) end function Dumper:push() - local rx = self.input.rx - local tx = self.output.tx + local rx = self.input.input + local tx = self.output.output if rx == nil or tx == nil then return end while not link.empty(rx) do local p = link.receive(rx) @@ -703,7 +703,7 @@ function run(args) listen = true, mode = "packet", }) - config.link(c, "ctl_sock.tx -> ctl.rx") + config.link(c, "ctl_sock.output -> ctl.input") end if conf.punt_sock then @@ -713,7 +713,7 @@ function run(args) listen = false, mode = "packet", }) - config.link(c, "punt.tx -> punt_sock.rx") + config.link(c, "punt.output -> punt_sock.input") end --data plane @@ -749,16 +749,16 @@ function run(args) next_hop = ip6str(exit.next_hop), }) - config.link(c, _("nd_%s.south -> if_%s.rx", ifname, ifname)) - config.link(c, _("if_%s.tx -> nd_%s.south", ifname, ifname)) + config.link(c, _("nd_%s.south -> if_%s.input", ifname, ifname)) + config.link(c, _("if_%s.output -> nd_%s.south", ifname, ifname)) config.link(c, _("lisper.%s -> nd_%s.north", ifname, ifname)) config.link(c, _("nd_%s.north -> lisper.%s", ifname, ifname)) else -- phy -> lisper - config.link(c, _("lisper.%s -> if_%s.rx", ifname, ifname)) - config.link(c, _("if_%s.tx -> lisper.%s", ifname, ifname)) + config.link(c, _("lisper.%s -> if_%s.input", ifname, ifname)) + config.link(c, _("if_%s.output -> lisper.%s", ifname, ifname)) end diff --git a/src/program/lwaftr/csv_stats.lua b/src/program/lwaftr/csv_stats.lua index 778537cc92..d4d8cfd5dc 100644 --- a/src/program/lwaftr/csv_stats.lua +++ b/src/program/lwaftr/csv_stats.lua @@ -24,8 +24,8 @@ function CSVStatsTimer:add_app(id, links, link_names) local h = (',%s MPPS,%s Gbps'):format(pretty_name, pretty_name) self.header = self.header..h local data = { - txpackets = link.stats.txpackets, - txbytes = link.stats.txbytes, + txpackets = link.stats.input_packets, + txbytes = link.stats.input_bytes, } table.insert(self.link_data, data) end @@ -52,8 +52,8 @@ function CSVStatsTimer:activate() self.start = engine.now() self.prev_elapsed = 0 for _,data in ipairs(self.link_data) do - data.prev_txpackets = counter.read(data.txpackets) - data.prev_txbytes = counter.read(data.txbytes) + data.prev_txpackets = counter.read(data.input_packets) + data.prev_txbytes = counter.read(data.input_bytes) end local function tick() return self:tick() end local t = timer.new('csv_stats', tick, self.period*1e9, 'repeating') @@ -67,8 +67,8 @@ function CSVStatsTimer:tick() self.prev_elapsed = elapsed self.file:write(('%f'):format(elapsed)) for _,data in ipairs(self.link_data) do - local txpackets = counter.read(data.txpackets) - local txbytes = counter.read(data.txbytes) + local txpackets = counter.read(data.input_packets) + local txbytes = counter.read(data.input_bytes) local diff_txpackets = tonumber(txpackets - data.prev_txpackets) local diff_txbytes = tonumber(txbytes - data.prev_txbytes) data.prev_txpackets = txpackets diff --git a/src/program/lwaftr/loadtest/loadtest.lua b/src/program/lwaftr/loadtest/loadtest.lua index 1874e871fd..56293def59 100644 --- a/src/program/lwaftr/loadtest/loadtest.lua +++ b/src/program/lwaftr/loadtest/loadtest.lua @@ -83,8 +83,8 @@ end local function read_counters(link) return { - txpackets = counter.read(link.stats.txpackets), - txbytes = counter.read(link.stats.txbytes) + txpackets = counter.read(link.stats.input_packets), + txbytes = counter.read(link.stats.input_bytes) } end @@ -111,9 +111,9 @@ function run(args) config.app(c, stream.rx_sink_id, basic_apps.Sink) config.link(c, stream.pcap_id..".output -> "..stream.repeater_id..".input") - config.link(c, stream.repeater_id..".output -> "..stream.nic_tx_id..".rx") + config.link(c, stream.repeater_id..".output -> "..stream.nic_tx_id..".input") - config.link(c, stream.nic_rx_id..".tx -> "..stream.rx_sink_id..".input") + config.link(c, stream.nic_rx_id..".output -> "..stream.rx_sink_id..".input") end engine.configure(c) @@ -145,8 +145,8 @@ function run(args) local rx_nic = assert(engine.app_table[stream.nic_rx_id], "NIC "..stream.nic_rx_id.." not found") ret[stream.nic_tx_id] = { - tx = read_counters(tx_nic.input.rx), - rx = read_counters(rx_nic.output.tx) + tx = read_counters(tx_nic.input.input), + rx = read_counters(rx_nic.output.output) } end return ret diff --git a/src/program/lwaftr/run/run.lua b/src/program/lwaftr/run/run.lua index 4ff6d32212..d5fe916976 100644 --- a/src/program/lwaftr/run/run.lua +++ b/src/program/lwaftr/run/run.lua @@ -138,8 +138,8 @@ function run(args) if opts.verbosity >= 1 then local csv = csv_stats.CSVStatsTimer.new() - csv:add_app('inetNic', { 'tx', 'rx' }, { tx='IPv4 RX', rx='IPv4 TX' }) - csv:add_app('b4sideNic', { 'tx', 'rx' }, { tx='IPv6 RX', rx='IPv6 TX' }) + csv:add_app('inetNic', { 'output', 'input' }, { output='IPv4 INPUT', input='IPv4 OUTPUT' }) + csv:add_app('b4sideNic', { 'output', 'input' }, { output='IPv6 INPUT', input='IPv6 OUTPUT' }) csv:activate() end diff --git a/src/program/lwaftr/run_nohw/run_nohw.lua b/src/program/lwaftr/run_nohw/run_nohw.lua index 9563b2de25..2db81bf42b 100644 --- a/src/program/lwaftr/run_nohw/run_nohw.lua +++ b/src/program/lwaftr/run_nohw/run_nohw.lua @@ -69,15 +69,15 @@ function run(parameters) config.app(c, "inet", RawSocket, inet_if) -- Connect apps - config.link(c, "inet.tx -> aftr.v4") - config.link(c, "b4if.tx -> aftr.v6") - config.link(c, "aftr.v4 -> inet.rx") - config.link(c, "aftr.v6 -> b4if.rx") + config.link(c, "inet.output -> aftr.v4") + config.link(c, "b4if.output -> aftr.v6") + config.link(c, "aftr.v4 -> inet.input") + config.link(c, "aftr.v6 -> b4if.input") if verbosity >= 1 then local csv = CSVStatsTimer.new() - csv:add_app("inet", {"tx", "rx"}, { tx = "IPv4 TX", rx = "IPv4 RX" }) - csv:add_app("tob4", {"tx", "rx"}, { tx = "IPv6 TX", rx = "IPv6 RX" }) + csv:add_app("inet", {"output", "input"}, { output = "IPv4 OUTPUT", input = "IPv4 INPUT" }) + csv:add_app("tob4", {"output", "input"}, { output = "IPv6 OUTPUT", input = "IPv6 INPUT" }) csv:activate() if verbosity >= 2 then diff --git a/src/program/lwaftr/setup.lua b/src/program/lwaftr/setup.lua index fdd6f277a5..8bcb0e86b1 100644 --- a/src/program/lwaftr/setup.lua +++ b/src/program/lwaftr/setup.lua @@ -129,8 +129,8 @@ function load_phy(c, conf, v4_nic_name, v4_nic_pci, v6_nic_name, v6_nic_pci) rxcounter=1, macaddr = ethernet:ntop(conf.aftr_mac_b4_side)}) - link_source(c, v4_nic_name..'.tx', v6_nic_name..'.tx') - link_sink(c, v4_nic_name..'.rx', v6_nic_name..'.rx') + link_source(c, v4_nic_name..'.output', v6_nic_name..'.output') + link_sink(c, v4_nic_name..'.input', v6_nic_name..'.input') end function load_virt(c, conf, v4_nic_name, v4_nic_pci, v6_nic_name, v6_nic_pci) @@ -145,8 +145,8 @@ function load_virt(c, conf, v4_nic_name, v4_nic_pci, v6_nic_name, v6_nic_pci) vlan=conf.vlan_tagging and conf.v6_vlan_tag, macaddr = ethernet:ntop(conf.aftr_mac_b4_side)}) - link_source(c, v4_nic_name..'.tx', v6_nic_name..'.tx') - link_sink(c, v4_nic_name..'.rx', v6_nic_name..'.rx') + link_source(c, v4_nic_name..'.output', v6_nic_name..'.output') + link_sink(c, v4_nic_name..'.input', v6_nic_name..'.input') end function load_bench(c, conf, v4_pcap, v6_pcap, v4_sink, v6_sink) diff --git a/src/program/lwaftr/transient/transient.lua b/src/program/lwaftr/transient/transient.lua index 1ce34cb09f..ac50dbc023 100644 --- a/src/program/lwaftr/transient/transient.lua +++ b/src/program/lwaftr/transient/transient.lua @@ -113,9 +113,9 @@ function run(args) config.app(c, stream.rx_sink_id, basic_apps.Sink) config.link(c, stream.pcap_id..".output -> "..stream.repeater_id..".input") - config.link(c, stream.repeater_id..".output -> "..stream.nic_id..".rx") + config.link(c, stream.repeater_id..".output -> "..stream.nic_id..".input") - config.link(c, stream.nic_id..".tx -> "..stream.rx_sink_id..".input") + config.link(c, stream.nic_id..".output -> "..stream.rx_sink_id..".input") end engine.configure(c) @@ -126,8 +126,8 @@ function run(args) opts.duration * 1e9, 'repeating')) local csv = csv_stats.CSVStatsTimer.new() for _,stream in ipairs(streams) do - csv:add_app(stream.nic_id, { 'rx', 'tx' }, - { rx=stream.name..' TX', tx=stream.name..' RX' }) + csv:add_app(stream.nic_id, { 'input', 'output' }, + { input=stream.name..' OUTPUT', output=stream.name..' INPUT' }) end csv:activate() engine.busywait = true diff --git a/src/program/packetblaster/lwaftr/lwaftr.lua b/src/program/packetblaster/lwaftr/lwaftr.lua index 90dd22c879..3b9c30cfda 100644 --- a/src/program/packetblaster/lwaftr/lwaftr.lua +++ b/src/program/packetblaster/lwaftr/lwaftr.lua @@ -216,16 +216,16 @@ function run (args) if device_info then config.app(c, "nic", require(device_info.driver).driver, {pciaddr = pciaddr, vmdq = false, macaddr = src_mac, mtu = 9500}) - input, output = "nic.rx", "nic.tx" + input, output = "nic.input", "nic.output" else fatal(("Couldn't find device info for PCI or tap device %s"):format(pciaddr)) end elseif int_interface then config.app(c, "int", raw.RawSocket, int_interface) - input, output = "int.rx", "int.tx" + input, output = "int.input", "int.output" elseif sock_interface then config.app(c, "virtio", VhostUser, { socket_path=sock_interface } ) - input, output = "virtio.rx", "virtio.tx" + input, output = "virtio.input", "virtio.output" else config.app(c, "pcap", pcap.PcapWriter, pcap_file) input, output = "pcap.input", "pcap.output" diff --git a/src/program/snabbmark/snabbmark.lua b/src/program/snabbmark/snabbmark.lua index aff47256e1..d0d2ebea78 100644 --- a/src/program/snabbmark/snabbmark.lua +++ b/src/program/snabbmark/snabbmark.lua @@ -45,18 +45,18 @@ function basic1 (npackets) config.app(c, "Source", basic_apps.Source) config.app(c, "Tee", basic_apps.Tee) config.app(c, "Sink", basic_apps.Sink) - config.link(c, "Source.tx -> Tee.rx") - config.link(c, "Tee.tx1 -> Sink.rx1") - config.link(c, "Tee.tx2 -> Sink.rx2") + config.link(c, "Source.output -> Tee.input") + config.link(c, "Tee.output1 -> Sink.input1") + config.link(c, "Tee.output2 -> Sink.input2") engine.configure(c) local start = C.get_monotonic_time() timer.activate(timer.new("null", function () end, 1e6, 'repeating')) - while link.stats(engine.app_table.Source.output.tx).txpackets < npackets do + while link.stats(engine.app_table.Source.output.output).output_packets < npackets do engine.main({duration = 0.01, no_report = true}) end local finish = C.get_monotonic_time() local runtime = finish - start - local packets = link.stats(engine.app_table.Source.output.tx).txpackets + local packets = link.stats(engine.app_table.Source.output.output).output_packets engine.report() print() print(("Processed %.1f million packets in %.2f seconds (rate: %.1f Mpps)."):format(packets / 1e6, runtime, packets / runtime / 1e6)) @@ -195,8 +195,8 @@ function solarflare (npackets, packet_size, timeout) config.app(c, receive_device.interface, SolarFlareNic, {ifname=receive_device.interface, mac_address = ethernet:pton("02:00:00:00:00:02")}) config.app(c, "sink", basic_apps.Sink) - config.link(c, "source.tx -> " .. send_device.interface .. ".rx") - config.link(c, receive_device.interface .. ".tx -> sink.rx") + config.link(c, "source.output -> " .. send_device.interface .. ".input") + config.link(c, receive_device.interface .. ".output -> sink.input") engine.configure(c) @@ -213,7 +213,7 @@ function solarflare (npackets, packet_size, timeout) if timeout then n_max = timeout * 100 end - while link.stats(engine.app_table.source.output.tx).txpackets < npackets + while link.stats(engine.app_table.source.output.output).output_packets < npackets and (not timeout or n < n_max) do engine.main({duration = 0.01, no_report = true}) @@ -221,7 +221,7 @@ function solarflare (npackets, packet_size, timeout) end local finish = C.get_monotonic_time() local runtime = finish - start - local packets = link.stats(engine.app_table.source.output.tx).txpackets + local packets = link.stats(engine.app_table.source.output.output).output_packets engine.report() engine.app_table[send_device.interface]:report() engine.app_table[receive_device.interface]:report() @@ -229,7 +229,7 @@ function solarflare (npackets, packet_size, timeout) print(("Processed %.1f million packets in %.2f seconds (rate: %.1f Mpps, %.2f Gbit/s)."):format(packets / 1e6, runtime, packets / runtime / 1e6, gbits(packets * packet_size / runtime))) - if link.stats(engine.app_table.source.output.tx).txpackets < npackets then + if link.stats(engine.app_table.source.output.output).output_packets < npackets then print("Packets lost. Test failed!") main.exit(1) end @@ -285,8 +285,8 @@ receive_device.interface= "rx1GE" config.app(c, receive_device.interface, Intel1gNic, {pciaddr=pciaddr1, rxburst=512}) config.app(c, "sink", basic_apps.Sink) - config.link(c, "source.tx -> " .. send_device.interface .. ".rx") - config.link(c, receive_device.interface .. ".tx -> sink.rx") + config.link(c, "source.output -> " .. send_device.interface .. ".input") + config.link(c, receive_device.interface .. ".output -> sink.input") engine.configure(c) @@ -305,7 +305,7 @@ receive_device.interface= "rx1GE" if timeout then n_max = timeout * 100 end - while link.stats(engine.app_table.source.output.tx).txpackets < npackets + while link.stats(engine.app_table.source.output.output).output_packets < npackets and (not timeout or n < n_max) do engine.main({duration = 0.01, no_report = true}) @@ -313,19 +313,19 @@ receive_device.interface= "rx1GE" end local finish = C.get_monotonic_time() local runtime = finish - start - local txpackets = link.stats(engine.app_table.source.output.tx).txpackets - local rxpackets = link.stats(engine.app_table.sink.input.rx).rxpackets + local output_packets = link.stats(engine.app_table.source.output.output).output_packets + local input_packets = link.stats(engine.app_table.sink.input.input).input_packets engine.report() engine.app_table[send_device.interface]:report() engine.app_table[receive_device.interface]:report() print() print(("Processed %.1f million packets in %.2f seconds (rate: %.1f Mpps, %.2f Gbit/s, %.2f %% packet loss)."):format( - txpackets / 1e6, runtime, - txpackets / runtime / 1e6, - ((txpackets * packet_size * 8) / runtime) / (1024*1024*1024), - (txpackets - rxpackets) *100 / txpackets + output_packets / 1e6, runtime, + output_packets / runtime / 1e6, + ((output_packets * packet_size * 8) / runtime) / (1024*1024*1024), + (output_packets - input_packets) *100 / output_packets )) - if link.stats(engine.app_table.source.output.tx).txpackets < npackets then + if link.stats(engine.app_table.source.output.output).output_packets < npackets then print("Packets lost. Test failed!") main.exit(1) end diff --git a/src/program/snabbnfv/nfvconfig.lua b/src/program/snabbnfv/nfvconfig.lua index cca18be263..ce08cbe852 100644 --- a/src/program/snabbnfv/nfvconfig.lua +++ b/src/program/snabbnfv/nfvconfig.lua @@ -37,13 +37,13 @@ function load (file, pciaddr, sockpath, soft_bench) {socket_path=sockpath:format(t.port_id), disable_mrg_rxbuf=t.disable_mrg_rxbuf, disable_indirect_desc=t.disable_indirect_desc}) - local VM_rx, VM_tx = Virtio..".rx", Virtio..".tx" + local VM_input, VM_output = Virtio..".input", Virtio..".output" if t.tx_police_gbps then local TxLimit = name.."_TxLimit" local rate = t.tx_police_gbps * 1e9 / 8 config.app(c, TxLimit, RateLimiter, {rate = rate, bucket_capacity = rate}) - config.link(c, VM_tx.." -> "..TxLimit..".input") - VM_tx = TxLimit..".output" + config.link(c, VM_output.." -> "..TxLimit..".input") + VM_output = TxLimit..".output" end -- If enabled, track allowed connections statefully on a per-port basis. -- (The table tracking connection state is named after the port ID.) @@ -52,15 +52,15 @@ function load (file, pciaddr, sockpath, soft_bench) local Filter = name.."_Filter_in" config.app(c, Filter, PcapFilter, { filter = t.ingress_filter, state_table = pf_state_table }) - config.link(c, Filter..".tx -> " .. VM_rx) - VM_rx = Filter..".rx" + config.link(c, Filter..".output -> " .. VM_input) + VM_input = Filter..".input" end if t.egress_filter then local Filter = name..'_Filter_out' config.app(c, Filter, PcapFilter, { filter = t.egress_filter, state_table = pf_state_table }) - config.link(c, VM_tx..' -> '..Filter..'.rx') - VM_tx = Filter..'.tx' + config.link(c, VM_output..' -> '..Filter..'.input') + VM_output = Filter..'.output' end if t.tunnel and t.tunnel.type == "L2TPv3" then local Tunnel = name.."_Tunnel" @@ -78,12 +78,12 @@ function load (file, pciaddr, sockpath, soft_bench) local_ip = t.tunnel.local_ip, next_hop = t.tunnel.next_hop}) -- VM -> Tunnel -> ND <-> Network - config.link(c, VM_tx.." -> "..Tunnel..".decapsulated") + config.link(c, VM_output.." -> "..Tunnel..".decapsulated") config.link(c, Tunnel..".encapsulated -> "..ND..".north") -- Network <-> ND -> Tunnel -> VM config.link(c, ND..".north -> "..Tunnel..".encapsulated") - config.link(c, Tunnel..".decapsulated -> "..VM_rx) - VM_rx, VM_tx = ND..".south", ND..".south" + config.link(c, Tunnel..".decapsulated -> "..VM_input) + VM_input, VM_output = ND..".south", ND..".south" end if t.crypto and t.crypto.type == "esp-aes-128-gcm" then local Crypto = name.."_Crypto" @@ -91,19 +91,19 @@ function load (file, pciaddr, sockpath, soft_bench) {spi = t.crypto.spi, key = t.crypto.key, replay_window = t.crypto.replay_window}) - config.link(c, VM_tx.." -> "..Crypto..".decapsulated") - config.link(c, Crypto..".decapsulated -> "..VM_rx) - VM_rx, VM_tx = Crypto..".encapsulated", Crypto..".encapsulated" + config.link(c, VM_output.." -> "..Crypto..".decapsulated") + config.link(c, Crypto..".decapsulated -> "..VM_input) + VM_input, VM_output = Crypto..".encapsulated", Crypto..".encapsulated" end if t.rx_police_gbps then local RxLimit = name.."_RxLimit" local rate = t.rx_police_gbps * 1e9 / 8 config.app(c, RxLimit, RateLimiter, {rate = rate, bucket_capacity = rate}) - config.link(c, RxLimit..".output -> "..VM_rx) - VM_rx = RxLimit..".input" + config.link(c, RxLimit..".output -> "..VM_input) + VM_input = RxLimit..".input" end - config.link(c, io_links[i].output.." -> "..VM_rx) - config.link(c, VM_tx.." -> "..io_links[i].input) + config.link(c, io_links[i].output.." -> "..VM_input) + config.link(c, VM_output.." -> "..io_links[i].input) end -- Return configuration c. diff --git a/src/program/snabbnfv/traffic/traffic.lua b/src/program/snabbnfv/traffic/traffic.lua index 4b5739d439..1e46e0f122 100644 --- a/src/program/snabbnfv/traffic/traffic.lua +++ b/src/program/snabbnfv/traffic/traffic.lua @@ -119,11 +119,11 @@ function bench (pciaddr, confpath, sockpath, npackets) -- From designs/nfv local start, packets, bytes = 0, 0, 0 local done = function () - local input = link.stats(engine.app_table[nic].input.rx) - if start == 0 and input.rxpackets > 0 then + local input = link.stats(engine.app_table[nic].input.input) + if start == 0 and input.output_packets > 0 then -- started receiving, record time and packet count - packets = input.rxpackets - bytes = input.rxbytes + packets = input.output_packets + bytes = input.output_bytes start = C.get_monotonic_time() if os.getenv("NFV_PROF") then require("jit.p").start(os.getenv("NFV_PROF"), os.getenv("NFV_PROF_FILE")) @@ -137,7 +137,7 @@ function bench (pciaddr, confpath, sockpath, npackets) print("No LuaJIT dump enabled ($NFV_DUMP unset).") end end - return input.rxpackets - packets >= npackets + return input.output_packets - packets >= npackets end engine.main({done = done, no_report = true}) @@ -145,9 +145,9 @@ function bench (pciaddr, confpath, sockpath, npackets) local runtime = finish - start local breaths = tonumber(counter.read(engine.breaths)) - local input = link.stats(engine.app_table[nic].input.rx) - packets = input.rxpackets - packets - bytes = input.rxbytes - bytes + local input = link.stats(engine.app_table[nic].input.input) + packets = input.output_packets - packets + bytes = input.output_bytes - bytes engine.report() print() print(("Processed %.1f million packets in %.2f seconds (%d bytes; %.2f Gbps)"):format(packets / 1e6, runtime, bytes, bytes * 8.0 / 1e9 / runtime)) diff --git a/src/program/top/README b/src/program/top/README index fc7d0aa34d..e9038a746c 100644 --- a/src/program/top/README +++ b/src/program/top/README @@ -7,7 +7,7 @@ Usage: List shared memory objects in and exit. Examples: snabb top -l engine snabb top -l apps/foo - snabb top -l "links/foo.tx -> bar.rx" + snabb top -l "links/foo.output -> bar.input" Display realtime performance statistics for a running Snabb instance with . If is not supplied and there is only one Snabb instance, top will @@ -24,15 +24,13 @@ The following global metrics will be displayed: The following metrics will be displayed per link: - rx - Millions of packets received per second. - tx - Millions of packets transmitted per second. - rxGb - Gigabytes of packet data received per - second. - txGb - Gigabytes of packet data transmitted per - second. - txdrop + input + Millions of packets enqueued per second. + output + Millions of packets dequeued per second. + inputGb + Gigabytes of packet data enqueued per second. + outputGb + Gigabytes of packet data dequeued per second. + drop Millions of packets dropped per second. diff --git a/src/program/top/top.lua b/src/program/top/top.lua index 8c1aec02d3..bc26d52d7f 100644 --- a/src/program/top/top.lua +++ b/src/program/top/top.lua @@ -123,7 +123,8 @@ function get_stats (counters) for linkspec, link in pairs(counters.links) do new_stats.links[linkspec] = {} for _, name - in ipairs({"rxpackets", "txpackets", "rxbytes", "txbytes", "txdrop" }) do + in ipairs({"output_packets", "input_packets", + "output_bytes", "input_bytes", "input_drop" }) do new_stats.links[linkspec][name] = counter.read(link[name]) end end @@ -169,18 +170,18 @@ end local link_metrics_row = {31, 7, 7, 7, 7, 7} function print_link_metrics (new_stats, last_stats) print_row(link_metrics_row, - {"Links (rx/tx/txdrop in Mpps)", "rx", "tx", "rxGb", "txGb", "txdrop"}) + {"Links (input/output/drop in Mpps)", "input", "output", "inputGb", "outputGb", "drop"}) for linkspec, link in pairs(new_stats.links) do if last_stats.links[linkspec] then - local rx = tonumber(new_stats.links[linkspec].rxpackets - last_stats.links[linkspec].rxpackets) - local tx = tonumber(new_stats.links[linkspec].txpackets - last_stats.links[linkspec].txpackets) - local rxbytes = tonumber(new_stats.links[linkspec].rxbytes - last_stats.links[linkspec].rxbytes) - local txbytes = tonumber(new_stats.links[linkspec].txbytes - last_stats.links[linkspec].txbytes) - local drop = tonumber(new_stats.links[linkspec].txdrop - last_stats.links[linkspec].txdrop) + local input = tonumber(new_stats.links[linkspec].input_packets - last_stats.links[linkspec].input_packets) + local output = tonumber(new_stats.links[linkspec].output_packets - last_stats.links[linkspec].output_packets) + local input_bytes = tonumber(new_stats.links[linkspec].input_bytes - last_stats.links[linkspec].input_bytes) + local output_bytes = tonumber(new_stats.links[linkspec].output_bytes - last_stats.links[linkspec].output_bytes) + local drop = tonumber(new_stats.links[linkspec].input_drop - last_stats.links[linkspec].input_drop) print_row(link_metrics_row, {linkspec, - float_s(rx / 1e6), float_s(tx / 1e6), - float_s(rxbytes / (1000^3)), float_s(txbytes / (1000^3)), + float_s(input / 1e6), float_s(output / 1e6), + float_s(input_bytes / (1000^3)), float_s(output_bytes / (1000^3)), float_s(drop / 1e6)}) end end