Skip to content

Commit

Permalink
Remove rx/tx from link and counter names.
Browse files Browse the repository at this point in the history
Notable change: link counters are reversed:
 - input == enqueued onto the link
 - output == dequeued from the link
  • Loading branch information
eugeneia committed Sep 23, 2016
1 parent 9236f15 commit 01e7f64
Show file tree
Hide file tree
Showing 47 changed files with 404 additions and 392 deletions.
4 changes: 2 additions & 2 deletions src/apps/example/asm.dasl
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
Expand Down
14 changes: 7 additions & 7 deletions src/apps/intel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**

Expand Down
116 changes: 58 additions & 58 deletions src/apps/intel/intel_app.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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")
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand All @@ -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")
Expand Down
6 changes: 3 additions & 3 deletions src/apps/ipsec/esp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ AES128gcm = {
spi = {required=true}, key = {required=true}, window_size = {}
},
shm = {
txerrors = {counter}, rxerrors = {counter}
output_errors = {counter}, input_errors = {counter}
}
}

Expand Down Expand Up @@ -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
Expand All @@ -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
30 changes: 15 additions & 15 deletions src/apps/ipv6/nd_light.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -222,15 +222,15 @@ 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
-- address as target
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
Expand All @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions src/apps/keyed_ipv6_tunnel/tunnel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}})
Expand Down
Loading

0 comments on commit 01e7f64

Please sign in to comment.