Skip to content

Commit

Permalink
Pass config for 82599 driver down to intel10g module
Browse files Browse the repository at this point in the history
The configuration supplied to Intel82500:new() is passed down to the
new_pf() and new_sf() functions of the intel10g module to allow
low-level configurations of an instance of the driver.
  • Loading branch information
alexandergall committed Apr 9, 2015
1 parent 7fbd27c commit dd709ee
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
30 changes: 17 additions & 13 deletions src/apps/intel/intel10g.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@ local band, bor, lshift = bit.band, bit.bor, bit.lshift
num_descriptors = 512
--num_descriptors = 32

-- Set to true to enable IF-MIB support via the ipc/shmem mechanism
enable_snmp = false
-- Timer for interface status check in seconds (only active when
-- enable_snmp=true)
status_timer = 5
-- Defaults for configurable items
local default = { snmp = {
status_timer = 5, -- Interval for IF status check and MIB update
}
}

local function pass (...) return ... end


--- ### SF: single function: non-virtualized device
local M_sf = {}; M_sf.__index = M_sf

function new_sf (pciaddress)
local dev = { pciaddress = pciaddress, -- PCI device address
function new_sf (conf)
local dev = { pciaddress = conf.pciaddr, -- PCI device address
fd = false, -- File descriptor for PCI memory
r = {}, -- Configuration registers
s = {}, -- Statistics registers
Expand All @@ -51,7 +51,8 @@ function new_sf (pciaddress)
rxpackets = {}, -- Rx descriptor index -> packet mapping
rdh = 0, -- Cache of receive head (RDH) register
rdt = 0, -- Cache of receive tail (RDT) register
rxnext = 0 -- Index of next buffer to receive
rxnext = 0, -- Index of next buffer to receive
snmp = conf.snmp,
}
return setmetatable(dev, M_sf)
end
Expand Down Expand Up @@ -88,7 +89,7 @@ end
--- See data sheet section 4.6.3 "Initialization Sequence."

function M_sf:init ()
if enable_snmp then
if self.snmp then
self:init_snmp()
end
self:init_dma_memory()
Expand Down Expand Up @@ -188,7 +189,9 @@ function M_sf:init_snmp ()
ifTable:set('_X_ifLastChange_TicksBase',
C.get_unix_time())
end
end, 1e9 * status_timer, 'repeating')
end,
1e9 * (self.snmp.status_timer or
default.snmp.status_timer), 'repeating')
timer.activate(t)
return self
end
Expand Down Expand Up @@ -462,14 +465,15 @@ end
--- ### PF: the physiscal device in a virtualized setup
local M_pf = {}; M_pf.__index = M_pf

function new_pf (pciaddress)
local dev = { pciaddress = pciaddress, -- PCI device address
function new_pf (conf)
local dev = { pciaddress = conf.pciaddr, -- PCI device address
r = {}, -- Configuration registers
s = {}, -- Statistics registers
qs = {}, -- queue statistic registers
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 @@ -495,7 +499,7 @@ function M_pf:close()
end

function M_pf:init ()
if enable_snmp then
if self.snmp then
self:init_snmp()
end
self.redos = 0
Expand Down
4 changes: 2 additions & 2 deletions src/apps/intel/intel_app.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ function Intel82599:new (arg)

if conf.vmdq then
if devices[conf.pciaddr] == nil then
devices[conf.pciaddr] = {pf=intel10g.new_pf(conf.pciaddr):open(), vflist={}}
devices[conf.pciaddr] = {pf=intel10g.new_pf(conf):open(), vflist={}}
end
local dev = devices[conf.pciaddr]
local poolnum = firsthole(dev.vflist)-1
local vf = dev.pf:new_vf(poolnum)
dev.vflist[poolnum+1] = vf
return setmetatable({dev=vf:open(conf)}, Intel82599)
else
local dev = intel10g.new_sf(conf.pciaddr):open()
local dev = intel10g.new_sf(conf):open()
if not dev then return null end
return setmetatable({dev=dev, zone="intel"}, Intel82599)
end
Expand Down

0 comments on commit dd709ee

Please sign in to comment.