Skip to content

Commit

Permalink
a reload method makes it easier to keep allocated stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
javierguerragiraldez committed Nov 18, 2014
1 parent efde1f2 commit 61ac245
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/apps/intel/intel10g.lua
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,42 @@ function M_vf:close()
return M_sf.close(self)
end

function M_vf:reconfig(opts)
io.write(string.format('reconfig %s - %d\n', self.pf.pciaddress, self.poolnum))
self:disable_transmit()
:disable_receive()

local poolnum = self.poolnum or 0
local pf = self.pf

do
pf.r.PFVFSPOOF[math.floor(poolnum/8)]:clr(bits{MACAS=poolnum%8, VLANAS=poolnum%8+8})
pf.r.PFVMVIR[poolnum](0x00)
local msk = bits{PoolEna=poolnum%32}
for vlan_index = 0, 63 do
pf.r.PFVLVFB[2*vlan_index + math.floor(poolnum/32)]:clr(msk)
end
end
-- TODO: unset mirror
-- unset MAC
do
local msk = bits{Ena=self.poolnum%32}
for mac_index = 0, 127 do
pf.r.MPSAR[2*mac_index + math.floor(poolnum/32)]:set(msk)
end
end

return self
:set_MAC(opts.macaddr)
:set_mirror(opts.mirror)
:set_VLAN(opts.vlan)
:set_rx_stats(opts.rxcounter)
:set_tx_stats(opts.txcounter)
:set_tx_rate(opts.rate_limit, opts.priority)
:enable_receive()
:enable_transmit()
end

function M_vf:init (opts)
return self
:init_dma_memory()
Expand Down
8 changes: 8 additions & 0 deletions src/apps/intel/intel_app.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ function Intel82599:stop()
end
end


function Intel82599:reconfig(arg)
local conf = config.parse_app_arg(arg)
assert((not not self.dev.pf) == (not not conf.vmdq), "Can't reconfig from VMDQ to single-port or viceversa")

self.dev:reconfig(conf)
end

-- Allocate receive buffers from the given freelist.
function Intel82599:set_rx_buffer_freelist (fl)
self.rx_buffer_freelist = fl
Expand Down

0 comments on commit 61ac245

Please sign in to comment.