Skip to content

Commit

Permalink
Merge PR snabbco#1025 (Max's tx/rx->input/output) into kbara-next
Browse files Browse the repository at this point in the history
  • Loading branch information
Katerina Barone-Adesi committed Oct 12, 2016
2 parents 82292cd + 51c135f commit 4652ea1
Show file tree
Hide file tree
Showing 60 changed files with 599 additions and 518 deletions.
4 changes: 2 additions & 2 deletions src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -877,14 +877,14 @@ Returns a copy of *array*. *Array* must not be a "sparse array".
— Function **lib.htons** *n*

Host to network byte order conversion functions for 32 and 16 bit
integers *n* respectively.
integers *n* respectively. Unsigned.

— Function **lib.ntohl** *n*

— Function **lib.ntohs** *n*

Network to host byte order conversion functions for 32 and 16 bit
integers *n* respectively.
integers *n* respectively. Unsigned.

— Function **lib.parse** *arg*, *config*

Expand Down
2 changes: 1 addition & 1 deletion src/apps/basic/basic_apps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ end
function Join:push ()
for _, inport in ipairs(self.input) do
while not link.empty(inport) do
transmit(self.output.out, receive(inport))
transmit(self.output.output, receive(inport))
end
end
end
Expand Down
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
13 changes: 12 additions & 1 deletion src/apps/intel/intel10g.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,18 @@ local timer = require("core.timer")
local bits, bitset = lib.bits, lib.bitset
local band, bor, lshift = bit.band, bit.bor, bit.lshift

num_descriptors = 1024
local num_descriptors = 1024
function ring_buffer_size (arg)
if not arg then return num_descriptors end
local ring_size = assert(tonumber(arg), "bad ring size: " .. arg)
if ring_size > 32*1024 then
error("ring size too large for hardware: " .. ring_size)
end
if math.log(ring_size)/math.log(2) % 1 ~= 0 then
error("ring size is not a power of two: " .. arg)
end
num_descriptors = assert(tonumber(arg))
end

-- Defaults for configurable items
local default = {
Expand Down
44 changes: 22 additions & 22 deletions src/apps/intel/intel1g.lua
Original file line number Diff line number Diff line change
Expand Up @@ -441,10 +441,10 @@ function Intel1g:new(conf)
poke32(r.TDT, tdt)
end

function self:push () -- move frames from link.rx to NIC.txQueue for transmission
function self:push () -- move frames from link.input to NIC.txQueue for transmission
counters.push= counters.push +1
--local li = self.input[1]
local li = self.input["rx"] -- same-same as [1]
local li = self.input.input -- same-same as [1]
assert(li, "intel1g:push: no input link")
if link.empty(li) then -- from SolarFlareNic:push()
counters.pushRxLinkEmpty= counters.pushRxLinkEmpty +1
Expand Down Expand Up @@ -580,10 +580,10 @@ function Intel1g:new(conf)
--print("sync_receive(): rdh=",rdh, " rdt=",rdt)
end

function self:pull () -- move received frames from NIC.rxQueue to link.tx
function self:pull () -- move received frames from NIC.rxQueue to link.output
counters.pull= counters.pull +1
--local lo = self.output[1]
local lo = self.output["tx"] -- same-same as [1]
local lo = self.output.output -- same-same as [1]
--assert(lo, "intel1g: no output link")
local limit = rxburst
while limit > 0 and can_receive() do
Expand Down Expand Up @@ -642,12 +642,12 @@ function selftest ()
config.app(c, "nic", Intel1g, {pciaddr=pciaddr, loopback="PHY", rxburst=512})
--config.app(c, "nic", Intel1g, {pciaddr=pciaddr, loopback="MAC", txqueue=1})
--config.app(c, "nic", Intel1g, {pciaddr=pciaddr, loopback="MAC", txqueue=1, rxqueue=1})
config.link(c, "source.tx -> nic.rx")
config.link(c, "nic.tx -> sink.rx")
config.link(c, "source.output -> nic.input")
config.link(c, "nic.output -> sink.input")
-- replace intel1g by Repeater
--config.app(c, "repeater", basic.Repeater)
--config.link(c, "source.tx -> repeater.input")
--config.link(c, "repeater.output -> sink.rx")
--config.link(c, "source.output -> repeater.input")
--config.link(c, "repeater.output -> sink.input")
engine.configure(c)

-- showlinks: src/core/app.lua calls report_links()
Expand All @@ -659,35 +659,35 @@ function selftest ()
local runtime = endTime - startTime
engine.app_table.nic.stop() -- outputs :report()

local source= engine.app_table.source.output.tx
local source= engine.app_table.source.output.output
assert(source, "Intel1g: no source?")
local s= link.stats(source)
print("source: txpackets= ", s.txpackets, " rxpackets= ", s.rxpackets, " txdrop= ", s.txdrop)
local txpackets= s.txpackets
print("source: input_packets= ", s.input_packets, " output_packets= ", s.output_packets, " input_drop= ", s.input_drop)
local input_packets= s.input_packets

--local li = engine.app_table.nic.input[1]
local li = engine.app_table.nic.input["rx"] -- same-same as [1]
local li = engine.app_table.nic.input["input"] -- same-same as [1]
assert(li, "Intel1g: no input link?")
local s= link.stats(li)
print("input link: txpackets= ", s.txpackets, " rxpackets= ", s.rxpackets, " txdrop= ", s.txdrop)
print("input link: input_packets= ", s.input_packets, " output_packets= ", s.output_packets, " input_drop= ", s.input_drop)

--local lo = engine.app_table.nic.output[1]
local lo = engine.app_table.nic.output["tx"] -- same-same as [1]
local lo = engine.app_table.nic.output["output"] -- same-same as [1]
assert(lo, "Intel1g: no output link?")
local s= link.stats(lo)
print("output link: txpackets= ", s.txpackets, " rxpackets= ", s.rxpackets, " txdrop= ", s.txdrop)
print("output link: input_packets= ", s.input_packets, " output_packets= ", s.output_packets, " input_drop= ", s.input_drop)

local sink= engine.app_table.sink.input.rx
local sink= engine.app_table.sink.input.input
assert(sink, "Intel1g: no sink?")
local s= link.stats(sink)
print("sink: txpackets= ", s.txpackets, " rxpackets= ", s.rxpackets, " txdrop= ", s.txdrop)
local rxpackets= s.rxpackets
print("sink: input_packets= ", s.input_packets, " output_packets= ", s.output_packets, " input_drop= ", s.input_drop)
local output_packets= s.output_packets

print(("Processed %.1f M 60 Byte packets in %.2f s (rate: %.1f Mpps, %.2f Gbit/s, %.2f %% packet loss).")
:format(
txpackets / 1e6, runtime,
txpackets / runtime / 1e6,
((txpackets * 60 * 8) / runtime) / (1024*1024*1024),
(txpackets - rxpackets) *100 / txpackets
input_packets / 1e6, runtime,
input_packets / runtime / 1e6,
((input_packets * 60 * 8) / runtime) / (1024*1024*1024),
(input_packets - output_packets) *100 / input_packets
))
end
Loading

0 comments on commit 4652ea1

Please sign in to comment.