Skip to content

Instantly share code, notes, and snippets.

@dpino
Created July 27, 2015 10:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dpino/c34eb8b4df2d46721363 to your computer and use it in GitHub Desktop.
Save dpino/c34eb8b4df2d46721363 to your computer and use it in GitHub Desktop.
local Intel82599 = require("apps.intel.intel_app").Intel82599
local app = require("core.app")
local basic_apps = require("apps.basic.basic_apps")
local config = require("core.config")
local lib = require("core.lib")
local link = require("core.link")
local C = require("ffi").C
function mq_sq (pcidevA, pcidevB)
local d1 = lib.hexundump ([[
52:54:00:02:02:02 52:54:00:01:01:01 08 00 45 00
00 54 c3 cd 40 00 40 01 f3 23 c0 a8 01 66 c0 a8
01 01 08 00 57 ea 61 1a 00 06 5c ba 16 53 00 00
00 00 04 15 09 00 00 00 00 00 10 11 12 13 14 15
16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25
26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35
36 37
]], 98) -- src: Am0 dst: Am1
local d2 = lib.hexundump ([[
52:54:00:03:03:03 52:54:00:01:01:01 08 00 45 00
00 54 c3 cd 40 00 40 01 f3 23 c0 a8 01 66 c0 a8
01 01 08 00 57 ea 61 1a 00 06 5c ba 16 53 00 00
00 00 04 15 09 00 00 00 00 00 10 11 12 13 14 15
16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25
26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35
36 37
]], 98) -- src: Am0 dst: ---
engine.configure(config.new())
local c = config.new()
config.app(c, 'source_ms', basic_apps.Join)
config.app(c, 'repeater_ms', basic_apps.Repeater)
config.app(c, 'nicAm0', Intel82599,
{-- first VF on NIC A
pciaddr = pcidevA,
vmdq = true,
macaddr = '52:54:00:01:01:01'})
config.app(c, 'nicAm1', Intel82599,
{-- second VF on NIC A
pciaddr = pcidevB,
vmdq = true,
macaddr = '52:54:00:02:02:02'})
config.app(c, 'sink_ms', basic_apps.Sink)
print ('-------')
print ("Send a bunch of packets from Am0")
print ("half of them go to nicAm1 and half go nowhere")
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')
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))
end
function run (parameters)
local pcidevA = parameters.pcidevA or "0000:05:00.0"
local pcidevB = parameters.pcidevA or "0000:05:00.1"
mq_sq(pcidevA, pcidevB)
engine.main({duration = 1, report={showlinks=true, showapps=false}})
end
run(main.parameters)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment