Skip to content

Commit

Permalink
Merge #983 remote-tracking branch 'snabbco/max-next' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
lukego committed Aug 2, 2016
2 parents 4cd0fba + 77c0d57 commit e1fdc74
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 40 deletions.
11 changes: 1 addition & 10 deletions src/apps/vhost/vhost_user.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ local lib = require("core.lib")
local link = require("core.link")
local main = require("core.main")
local memory = require("core.memory")
local counter = require("core.counter")
local pci = require("lib.hardware.pci")
local net_device= require("lib.virtio.net_device")
local timer = require("core.timer")
Expand Down Expand Up @@ -42,15 +41,7 @@ function VhostUser:new (args)
function () self:process_qemu_requests() end,
5e8,-- 500 ms
'non-repeating'
),
-- counters
shm = { rxbytes = {counter},
rxpackets = {counter},
rxmcast = {counter},
rxdrop = {counter},
txbytes = {counter},
txpackets = {counter},
txmcast = {counter} }
)
}
self = setmetatable(o, {__index = VhostUser})
self.dev = net_device.VirtioNetDevice:new(self,
Expand Down
30 changes: 0 additions & 30 deletions src/lib/virtio/net_device.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ local link = require("core.link")
local memory = require("core.memory")
local packet = require("core.packet")
local timer = require("core.timer")
local counter = require("core.counter")
local ethernet = require("lib.protocol.ethernet")
local vq = require("lib.virtio.virtq_device")
local checksum = require("lib.checksum")
local ffi = require("ffi")
Expand Down Expand Up @@ -157,7 +155,6 @@ end

function VirtioNetDevice:rx_packet_end(header_id, total_size, rx_p)
local l = self.owner.output.tx
local counters = self.owner.shm
if l then
if band(self.rx_hdr_flags, C.VIO_NET_HDR_F_NEEDS_CSUM) ~= 0 and
-- Bounds-check the checksum area
Expand All @@ -169,18 +166,9 @@ function VirtioNetDevice:rx_packet_end(header_id, total_size, rx_p)
rx_p.length - self.rx_hdr_csum_start,
self.rx_hdr_csum_offset)
end
counter.add(counters.rxbytes, rx_p.length)
counter.add(counters.rxpackets)
if ethernet:is_mcast(rx_p.data) then
counter.add(counters.rxmcast)
end
if ethernet:is_bcast(rx_p.data) then
counter.add(counters.rxbcast)
end
link.transmit(l, rx_p)
else
debug("droprx", "len", rx_p.length)
counter.add(counters.rxdrop)
packet.free(rx_p)
end
self.virtq[self.ring_id]:put_buffer(header_id, total_size)
Expand Down Expand Up @@ -268,15 +256,6 @@ function VirtioNetDevice:tx_buffer_add(tx_p, addr, len)
end

function VirtioNetDevice:tx_packet_end(header_id, total_size, tx_p)
local counters = self.owner.shm
counter.add(counters.txbytes, tx_p.length)
counter.add(counters.txpackets)
if ethernet:is_mcast(tx_p.data) then
counter.add(counters.txmcast)
end
if ethernet:is_bcast(tx_p.data) then
counter.add(counters.txbcast)
end
packet.free(tx_p)
self.virtq[self.ring_id]:put_buffer(header_id, total_size)
end
Expand Down Expand Up @@ -344,17 +323,8 @@ function VirtioNetDevice:tx_buffer_add_mrg_rxbuf(tx_p, addr, len)
end

function VirtioNetDevice:tx_packet_end_mrg_rxbuf(header_id, total_size, tx_p)
local counters = self.owner.shm
-- free the packet only when all its data is processed
if self.tx.finished then
counter.add(counters.txbytes, tx_p.length)
counter.add(counters.txpackets)
if ethernet:is_mcast(tx_p.data) then
counter.add(counters.txmcast)
end
if ethernet:is_bcast(tx_p.data) then
counter.add(counters.txbcast)
end
packet.free(tx_p)
self.tx.p = nil
self.tx.data_sent = nil
Expand Down

0 comments on commit e1fdc74

Please sign in to comment.