Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2016-June improvements #955

Merged
merged 62 commits into from
Jun 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
b34c3ee
engine: Set shm path to "app/$name"
lukego Feb 22, 2016
80614e1
doc/git-workflow.md: Rewritten based on new experience
lukego Mar 18, 2016
12d0009
doc/git-workflow.md: Added section on upstreaming subsystems
lukego Mar 18, 2016
af8ae46
doc/git-workflow.md: Partly rewritten draft
lukego Mar 21, 2016
eccb614
doc/git-workflow.md: Created .src.md
lukego Mar 21, 2016
113b607
git-workflow.md: Rewrote section on becoming a maintainer
lukego Mar 21, 2016
4a37b98
git-workflow.md: Wrote about upstreaming subsystem branches
lukego Mar 22, 2016
94ff234
Amendments to #766:
eugeneia Apr 12, 2016
aac0c8c
Merge PR #766 (engine: Set shm path to "app/$name") into yang
eugeneia Apr 12, 2016
fad0f43
core.counter: Qualify counter names using `shm.resolve'.
eugeneia Apr 13, 2016
7ed4ed0
snabb top: add `--app' option to print app counters.
eugeneia Apr 12, 2016
eb9005b
snabb top: unlink own shm tree to avoid clutter.
eugeneia Apr 13, 2016
5fbe0d6
vhost_user: Add RFC 7223 app counters.
eugeneia Apr 14, 2016
8bb3215
Intel_app: Add RFC 7223 app counters.
eugeneia Apr 14, 2016
7a55478
snabb top: Add --link parameter to list link counters.
eugeneia Apr 14, 2016
dde5da2
core.app: Put app counters under "counters/<app>", update snabb top.
eugeneia Apr 14, 2016
924ff4e
lib.json: Import JSON4Lua 1.0.0, include encode functionality.
eugeneia Apr 18, 2016
8e34093
lib.macaddress: Support numeric initialization; add method to get num…
eugeneia Apr 18, 2016
5f9efd2
core.link: Create “discontinuity-time” counters.
eugeneia Apr 18, 2016
7b39148
snabb top: add `--yang' option to print YANG model as JSON.
eugeneia Apr 19, 2016
6964969
Merge branch 'master' into doc-git-workflow-redux
lukego May 2, 2016
6c46b5d
doc: Remove stale .images/Branches.png file
lukego May 2, 2016
8984741
snabb top --yang: Represent uint64_t as decimal string.
eugeneia Apr 20, 2016
ee00d16
[core.lib] Generalize `timer' to optionally accept 'repeating'
eugeneia Apr 28, 2016
45490b8
Revert "Intel_app: Add RFC 7223 app counters."
eugeneia Apr 28, 2016
f0ed10b
intel_app: expose per-pciaddress statistics in `counters/<pciaddress>'.
eugeneia Apr 28, 2016
aca8064
Merge branch 'master' into yang-local
eugeneia May 13, 2016
c186591
lib.protocol.ethernet: Add n_mcast, branch-free Multicast predicate.
eugeneia Apr 25, 2016
b09e843
Fix for f0ed10b: require macaddress module.
eugeneia May 27, 2016
62e2fbf
Revert "lib.json: Import JSON4Lua 1.0.0, include encode functionality."
eugeneia Jun 1, 2016
f4834a5
snabb top: revert --yang dump.
eugeneia Jun 1, 2016
793c394
snabbify statistics model.
eugeneia Jun 2, 2016
2b9ef2c
intel_app: add ifTable MIB related counters.
eugeneia Jun 2, 2016
e9f5dda
lib.macaddress: add bytes method.
eugeneia Jun 2, 2016
6b12e9c
spin out SNMP code from apps.intel.intel10 to lib.ipc.shmem.iftable_mib.
eugeneia Jun 2, 2016
7c697b6
main: fork into worker and supervisor; perform clean up.
eugeneia Jun 3, 2016
be09fe5
main: send HUP instead of KILL.
eugeneia Jun 6, 2016
3db174b
main: return correct exit code.
eugeneia Jun 6, 2016
ce2f220
main: supervise xpcall(main, hanlder).
eugeneia Jun 6, 2016
4950cbb
main: check status of S.waitpid.
eugeneia Jun 6, 2016
28c568c
main: cleanup after worker_pid.
eugeneia Jun 6, 2016
4af7091
Remove obsolete `snabb gc'.
eugeneia Jun 6, 2016
1c9f585
Move model.txt to src/doc/statistics.md.
eugeneia Jun 7, 2016
339f8f1
apps.intel_app: Revert rxerrors calculation, remove broken txerrors.
eugeneia Jun 7, 2016
7ec7f80
Revert "lib.macaddress: add bytes method." and remove int method.
eugeneia Jun 7, 2016
327804f
doc/statistics.md: remove duplicates.
eugeneia Jun 9, 2016
30fcbcb
Merge branch 'master' into statistics-superset
eugeneia Jun 9, 2016
daf4243
Merge branch 'master' into supervisor
eugeneia Jun 9, 2016
90fc893
core.app: fix bug in #766 introduced while merging 6cac870a.
eugeneia Jun 10, 2016
ceb080f
core.app: fix bug in #766, use app.shmpath during reconfig.
eugeneia Jun 10, 2016
1d4e766
src/Makefile: silence grep
domenkozar Jun 10, 2016
d82729a
core.app: fix typo in previous commit.
eugeneia Jun 10, 2016
ed687f1
main: properly handle unsupported worker states (SIGSTOP/SIGCONT)-
eugeneia Jun 14, 2016
db9e343
main: comment syscall usage.
eugeneia Jun 14, 2016
c3b8672
Revert 'ed687f19f8459413145fabc56a462d7b38513ba8'.
eugeneia Jun 14, 2016
5eb0f69
core.main: handle SIGSTOP and SIGCONT to worker.
eugeneia Jun 15, 2016
76a5d6e
main: allow setting developer_debug/debug_on_error through environment.
eugeneia Jun 15, 2016
127d21f
main: do not unlink runtime directory in developer_debug mode.
eugeneia Jun 15, 2016
21d79ed
Merge PR #941 (silence grep) into kbara-next
Jun 22, 2016
9906aca
Merge PR #931 (app-local stats counters) into kbara-next
Jun 22, 2016
e7a5471
Merge PR #835 (workflow docs) into kbara-next
Jun 22, 2016
7d76551
Merge PR #930 (Supervisor, no snabb gc) into kbara-next
Jun 27, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ EXE := bin/snabb $(patsubst %,bin/%,$(PROGRAM))
# core.memory core.lib ...
# for each module that has a top-level selftest () function.
TESTMODS = $(shell find . -regex '[^\#]*\.lua' -printf '%P ' | \
xargs grep -l '^function selftest *[[:punct:]]' | \
xargs grep -s -l '^function selftest *[[:punct:]]' | \
sed -e 's_\.lua__' -e 's_/_._g')

# TESTSCRIPTS expands to:
Expand Down
14 changes: 11 additions & 3 deletions src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -549,10 +549,18 @@ Returns a table that acts as a bounds checked wrapper around a C array of
ctype and the caller must ensure that the allocated memory region at
*base*/*offset* is at least `sizeof(type)*size` bytes long.

— Function **lib.timer** *s*
— Function **lib.timer** *duration*, *mode*, *timefun*

Returns a closure that will return `false` until *duration* has elapsed. If
*mode* is `'repeating'` the timer will reset itself after returning `true`,
thus implementing an interval timer. *Timefun* is used to get a monotonic time.
*Timefun* defaults to `C.get_time_ns`.

The “deadline” for a given *duration* is computed by adding *duration* to the
result of calling *timefun*, and is saved in the resulting closure. A
*duration* has elapsed when its deadline is less than or equal the value
obtained using *timefun* when calling the closure.

Returns a function that accepts no parameters and acts as a predicate to
test if *ns* nanoseconds have elapsed.

— Function **lib.waitfor** *condition*

Expand Down
188 changes: 6 additions & 182 deletions src/apps/intel/intel10g.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
--- affordable (~$400) network cards made by Intel and others.
---
--- You will need to familiarize yourself with the excellent [data
--- sheet]() to understand this module.
--- sheet](http://www.intel.com/content/dam/www/public/us/en/documents/datasheets/82599-10-gbe-controller-datasheet.pdf)
--- to understand this module.

module(...,package.seeall)

Expand All @@ -17,7 +18,6 @@ local pci = require("lib.hardware.pci")
local register = require("lib.hardware.register")
local index_set = require("lib.index_set")
local macaddress = require("lib.macaddress")
local mib = require("lib.ipc.shmem.mib")
local timer = require("core.timer")

local bits, bitset = lib.bits, lib.bitset
Expand Down Expand Up @@ -49,10 +49,6 @@ local default = {
-- The default MTU allows for an IP packet of a total size of 9000
-- bytes without VLAN tagging.
mtu = 9014,

snmp = {
status_timer = 5, -- Interval for IF status check and MIB update
}
}

local function pass (...) return ... end
Expand All @@ -79,7 +75,6 @@ function new_sf (conf)
rdh = 0, -- Cache of receive head (RDH) register
rdt = 0, -- Cache of receive tail (RDT) register
rxnext = 0, -- Index of next buffer to receive
snmp = conf.snmp,
}
return setmetatable(dev, M_sf)
end
Expand Down Expand Up @@ -118,9 +113,6 @@ end
--- See data sheet section 4.6.3 "Initialization Sequence."

function M_sf:init ()
if self.snmp then
self:init_snmp()
end
self:init_dma_memory()

self.redos = 0
Expand Down Expand Up @@ -190,156 +182,6 @@ function M_sf:ingress_packet_drops ()
return self.qs.QPRDC[0]()
end

function M_sf:init_snmp ()
-- Rudimentary population of a row in the ifTable MIB. Allocation
-- of the ifIndex is delegated to the SNMP agent via the name of
-- the interface in ifDescr (currently the PCI address).
local ifTable = mib:new({ directory = self.snmp.directory or nil,
filename = self.pciaddress })
self.snmp.ifTable = ifTable
-- ifTable
ifTable:register('ifDescr', 'OctetStr', self.pciaddress)
ifTable:register('ifType', 'Integer32', 6) -- ethernetCsmacd
ifTable:register('ifMtu', 'Integer32', self.mtu)
ifTable:register('ifSpeed', 'Gauge32', 10000000)

-- After a reset of the NIC, the "native" MAC address is copied to
-- the receive address register #0 from the EEPROM
local ral, rah = self.r.RAL[0](), self.r.RAH[0]()
assert(bit.band(rah, bits({ AV = 31 })) == bits({ AV = 31 }),
"MAC address on "..self.pciaddress.." is not valid ")
local mac = ffi.new("struct { uint32_t lo; uint16_t hi; }")
mac.lo = ral
mac.hi = bit.band(rah, 0xFFFF)
ifTable:register('ifPhysAddress', { type = 'OctetStr', length = 6 },
ffi.string(mac, 6))
ifTable:register('ifAdminStatus', 'Integer32', 1) -- up
ifTable:register('ifOperStatus', 'Integer32', 2) -- down
ifTable:register('ifLastChange', 'TimeTicks', 0)
ifTable:register('_X_ifLastChange_TicksBase', 'Counter64', C.get_unix_time())
ifTable:register('ifInOctets', 'Counter32', 0)
ifTable:register('ifInUcastPkts', 'Counter32', 0)
ifTable:register('ifInDiscards', 'Counter32', 0)
ifTable:register('ifInErrors', 'Counter32', 0) -- TBD
ifTable:register('ifInUnknownProtos', 'Counter32', 0) -- TBD
ifTable:register('ifOutOctets', 'Counter32', 0)
ifTable:register('ifOutUcastPkts', 'Counter32', 0)
ifTable:register('ifOutDiscards', 'Counter32', 0)
ifTable:register('ifOutErrors', 'Counter32', 0) -- TBD
-- ifXTable
ifTable:register('ifName', { type = 'OctetStr', length = 255 },
self.pciaddress)
ifTable:register('ifInMulticastPkts', 'Counter32', 0)
ifTable:register('ifInBroadcastPkts', 'Counter32', 0)
ifTable:register('ifOutMulticastPkts', 'Counter32', 0)
ifTable:register('ifOutBroadcastPkts', 'Counter32', 0)
ifTable:register('ifHCInOctets', 'Counter64', 0)
ifTable:register('ifHCInUcastPkts', 'Counter64', 0)
ifTable:register('ifHCInMulticastPkts', 'Counter64', 0)
ifTable:register('ifHCInBroadcastPkts', 'Counter64', 0)
ifTable:register('ifHCOutOctets', 'Counter64', 0)
ifTable:register('ifHCOutUcastPkts', 'Counter64', 0)
ifTable:register('ifHCOutMulticastPkts', 'Counter64', 0)
ifTable:register('ifHCOutBroadcastPkts', 'Counter64', 0)
ifTable:register('ifLinkUpDownTrapEnable', 'Integer32', 2) -- disabled
ifTable:register('ifHighSpeed', 'Gauge32', 10000)
ifTable:register('ifPromiscuousMode', 'Integer32', 2) -- false
ifTable:register('ifConnectorPresent', 'Integer32', 1) -- true
ifTable:register('ifAlias', { type = 'OctetStr', length = 64 },
self.pciaddress) -- TBD add description
ifTable:register('ifCounterDiscontinuityTime', 'TimeTicks', 0) -- TBD
ifTable:register('_X_ifCounterDiscontinuityTime', 'Counter64', 0) -- TBD

--- Create a timer to periodically check the interface status.
--- Static variables are used in the timer function to avoid
--- garbage.
local status = { [1] = 'up', [2] = 'down' }
local mask = bits{Link_up=30}
local promisc = bits({UPE = 9})
-- Pre-allocate storage for the results of register-reads
local r = {
in_mcast_pkts = { r = self.s.MPRC },
in_bcast_pkts = { r = self.s.BPRC },
in_pkts = { r = self.s.GPRC },
in_octets64 = { r = self.s.GORC64 },

out_mcast_pkts = { r = self.s.MPTC },
out_bcast_pkts = { r = self.s.BPTC },
out_pkts = { r = self.s.GPTC },
out_octets64 = { r = self.s.GOTC64 },
}
local r_keys = {}
for k, _ in pairs(r) do
table.insert(r_keys, k)
r[k].v = ffi.new("uint64_t [1]")
end
local function read_registers()
for _, k in ipairs(r_keys) do
r[k].v[0] = r[k].r()
end
end
self.logger = lib.logger_new({ module = 'intel10g' })
local t = timer.new("Interface "..self.pciaddress.." status checker",
function(t)
local old = ifTable:get('ifOperStatus')
local new = 1
if band(self.r.LINKS(), mask) ~= mask then
new = 2
end
if old ~= new then
self.logger:log("Interface "..self.pciaddress..
" status change: "..status[old]..
" => "..status[new])
ifTable:set('ifOperStatus', new)
ifTable:set('ifLastChange', 0)
ifTable:set('_X_ifLastChange_TicksBase',
C.get_unix_time())
end

ifTable:set('ifPromiscuousMode',
(bit.band(self.r.FCTRL(), promisc) ~= 0ULL
and 1) or 2)
-- Update counters
read_registers()
ifTable:set('ifHCInMulticastPkts', r.in_mcast_pkts.v[0])
ifTable:set('ifInMulticastPkts', r.in_mcast_pkts.v[0])
ifTable:set('ifHCInBroadcastPkts', r.in_bcast_pkts.v[0])
ifTable:set('ifInBroadcastPkts', r.in_bcast_pkts.v[0])
local in_ucast_pkts = r.in_pkts.v[0] - r.in_bcast_pkts.v[0]
- r.in_mcast_pkts.v[0]
ifTable:set('ifHCInUcastPkts', in_ucast_pkts)
ifTable:set('ifInUcastPkts', in_ucast_pkts)
ifTable:set('ifHCInOctets', r.in_octets64.v[0])
ifTable:set('ifInOctets', r.in_octets64.v[0])

ifTable:set('ifHCOutMulticastPkts', r.out_mcast_pkts.v[0])
ifTable:set('ifOutMulticastPkts', r.out_mcast_pkts.v[0])
ifTable:set('ifHCOutBroadcastPkts', r.out_bcast_pkts.v[0])
ifTable:set('ifOutBroadcastPkts', r.out_bcast_pkts.v[0])
local out_ucast_pkts = r.out_pkts.v[0] - r.out_bcast_pkts.v[0]
- r.out_mcast_pkts.v[0]
ifTable:set('ifHCOutUcastPkts', out_ucast_pkts)
ifTable:set('ifOutUcastPkts', out_ucast_pkts)
ifTable:set('ifHCOutOctets', r.out_octets64.v[0])
ifTable:set('ifOutOctets', r.out_octets64.v[0])

-- The RX receive drop counts are only
-- available through the RX stats register.
-- We only read stats register #0 here. See comment
-- in init_statistics()
ifTable:set('ifInDiscards', self.qs.QPRDC[0]())

ifTable:set('ifInErrors', self.s.CRCERRS() +
self.s.ILLERRC() + self.s.ERRBC() +
self.s.RUC() + self.s.RFC() +
self.s.ROC() + self.s.RJC())
end,
1e9 * (self.snmp.status_timer or
default.snmp.status_timer), 'repeating')
timer.activate(t)
return self
end

function M_sf:global_reset ()
local reset = bits{LinkReset=3, DeviceReset=26}
self.r.CTRL(reset)
Expand Down Expand Up @@ -452,22 +294,10 @@ end
local txdesc_flags = bits{ifcs=25, dext=29, dtyp0=20, dtyp1=21, eop=24}

function M_sf:transmit (p)
-- 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.mtu then
-- if self.snmp then
-- local errors = self.snmp.ifTable:ptr('ifOutDiscards')
-- errors[0] = errors[0] + 1
-- end
-- packet.free(p)
-- else
do
self.txdesc[self.tdt].address = memory.virtual_to_physical(p.data)
self.txdesc[self.tdt].options = bor(p.length, txdesc_flags, lshift(p.length+0ULL, 46))
self.txpackets[self.tdt] = p
self.tdt = band(self.tdt + 1, num_descriptors - 1)
end
self.txdesc[self.tdt].address = memory.virtual_to_physical(p.data)
self.txdesc[self.tdt].options = bor(p.length, txdesc_flags, lshift(p.length+0ULL, 46))
self.txpackets[self.tdt] = p
self.tdt = band(self.tdt + 1, num_descriptors - 1)
end

function M_sf:sync_transmit ()
Expand Down Expand Up @@ -653,7 +483,6 @@ function new_pf (conf)
mac_set = index_set:new(127, "MAC address table"),
vlan_set = index_set:new(64, "VLAN Filter table"),
mirror_set = index_set:new(4, "Mirror pool table"),
snmp = conf.snmp,
}
return setmetatable(dev, M_pf)
end
Expand All @@ -679,9 +508,6 @@ function M_pf:close()
end

function M_pf:init ()
if self.snmp then
self:init_snmp()
end
self.redos = 0
local mask = bits{Link_up=30}
for i = 1, 100 do
Expand All @@ -707,7 +533,6 @@ function M_pf:init ()
return self
end

M_pf.init_snmp = M_sf.init_snmp
M_pf.global_reset = M_sf.global_reset
M_pf.disable_interrupts = M_sf.disable_interrupts
M_pf.set_receive_descriptors = pass
Expand Down Expand Up @@ -788,7 +613,6 @@ function M_pf:new_vf (poolnum)
base = self.base, -- mmap()ed register file
s = self.s, -- Statistics registers
mtu = self.mtu,
snmp = self.snmp,
-- and others are our own
r = {}, -- Configuration registers
poolnum = poolnum,
Expand Down
Loading