Skip to content

Commit

Permalink
Merge pull request #1 from lukego/strline
Browse files Browse the repository at this point in the history
Straight line: Fixes to make more tests cases pass
  • Loading branch information
n-nikolaev committed Jan 21, 2015
2 parents da26055 + 5807cb6 commit c1b5209
Show file tree
Hide file tree
Showing 23 changed files with 52 additions and 1,250 deletions.
14 changes: 0 additions & 14 deletions src/apps/README.md.src
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,3 @@ discards them. This can be handy in combination with a `Source`.
| |
+--------+

## Buzz

The `Buzz` app simply prints a message to standard output each time a
callback runs. This can be useful for observing the execution of the app
framework in a primitive way.

DIAGRAM: Buzz
+--------+
| |
| |
| Buzz |
| |
| |
+--------+
89 changes: 8 additions & 81 deletions src/apps/basic/basic_apps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ Source = setmetatable({zone = "Source"}, {__index = Basic})
function Source:new(size)
size = tonumber(size) or 60
local data = ffi.new("char[?]", size)
data[12] = 0x08
data[13] = 0x00
local p = packet.from_pointer(data, size)
return setmetatable({size=size, packet=p}, {__index=Source})
end
Expand All @@ -39,14 +37,14 @@ function Source:pull ()
for _, o in ipairs(self.outputi) do
for i = 1, link.nwritable(o) do
transmit(o, packet.clone(self.packet))
-- To repeatedly resend the same packet requires a
-- corresponding change in intel10g.lua sync_transmit() to
-- skip the call to packet.free()
--transmit(o, self.packet)
end
end
end

function Source:stop ()
packet.free(self.packet)
end

--- # `Join` app: Merge multiple inputs onto one output

Join = setmetatable({zone = "Join"}, {__index = Basic})
Expand Down Expand Up @@ -100,26 +98,6 @@ function Sink:push ()
end
end

--- ### `FastSink` app: Receive and discard packets

-- It is hacked Sink with very low packet processing overhead
-- Only for test purpose, never use it in real world application
-- Assumed to be used in pair with FastRepeater
-- FastSink doesn't calculate rx statistics

FastSink = setmetatable({zone = "FastSink"}, {__index = Basic})

function FastSink:new ()
return setmetatable({}, {__index=Sink})
end

function FastSink:push ()
local i = self.input.input
-- make link empty
i.read = 0
i.write = 0
end

--- ### `Tee` app: Send inputs to all outputs

Tee = setmetatable({zone = "Tee"}, {__index = Basic})
Expand All @@ -141,7 +119,7 @@ function Tee:push ()
maxoutput = maxoutput - 1
do local outputi = self.outputi
for k = 1, #outputi do
transmit(outputi[k], p)
transmit(outputi[k], k == #outputi and p or packet.clone(p))
end
end
end
Expand All @@ -162,7 +140,6 @@ function Repeater:push ()
local i, o = self.input.input, self.output.output
for _ = 1, link.nreadable(i) do
local p = receive(i)
-- packet.tenure(p)
table.insert(self.packets, p)
end
local npackets = #self.packets
Expand All @@ -175,59 +152,9 @@ function Repeater:push ()
end
end

--- ### `FastRepeater` app: Send all received packets in a loop

-- It is hacked Repeater with very low packet processing overhead
-- Only for test purpose, never use it in real world application
-- Assumed to be used in pair with FastSink

FastRepeater = setmetatable({zone = "FastRepeater"}, {__index = Basic})

function FastRepeater:new ()
return setmetatable({init = true},
{__index=FastRepeater})
end

do
local ring_size = C.LINK_RING_SIZE
local max_packets = C.LINK_MAX_PACKETS

function FastRepeater:push ()
local o = self.output.output
-- on first call read all packets
if self.init then
local i = self.input.input
local npackets = link.nreadable(i)
for index = 1, npackets do
local p = receive(i)
packet.tenure(p)
o.packets[index - 1] = p
end
-- and fullfil output link buffer
for index = npackets, max_packets do
o.packets[index] = o.packets[index % npackets]
end
o.stats.txpackets = ring_size
self.init = false
return
end
-- reset output link, make it full again
o.write = (o.write + link.nwritable(o)) % ring_size
-- assert(link.full(o)) -- hint how to debug
o.stats.txpackets = o.stats.txpackets + ring_size
-- intentionally don't calculate txbytes
function Repeater:stop ()
for i = 1, #self.packets do
packet.free(self.packets[i])
end
end

--- ### `Buzz` app: Print a debug message when called

Buzz = setmetatable({zone = "Buzz"}, {__index = Basic})

function Buzz:new ()
return setmetatable({}, {__index=Buzz})
end

function Buzz:pull () print "bzzz pull" end
function Buzz:push () print "bzzz push" end


55 changes: 0 additions & 55 deletions src/apps/fuzz/ethernet.lua

This file was deleted.

88 changes: 0 additions & 88 deletions src/apps/fuzz/fuzz.lua

This file was deleted.

Loading

0 comments on commit c1b5209

Please sign in to comment.