Permalink
Browse files

use monotonic counter for RX, wrap counters on 2^16

  • Loading branch information...
hannesm committed May 2, 2016
1 parent b6b07d7 commit 6daad38af2f0b5c58d6c1fb24252c3eed737ede4
Showing with 8 additions and 2 deletions.
  1. +8 −2 lib/netif.ml
View
@@ -260,6 +260,7 @@ type transport = {
rx_client: (RX.response,int) Lwt_ring.Front.t;
rx_map: (int, Gnt.gntref * Io_page.t) Hashtbl.t;
rx_gnt: Gnt.gntref;
mutable rx_id: Cstruct.uint16;
evtchn: Eventchn.t;
features: features;
stats : stats;
@@ -351,7 +352,7 @@ let plug_inner id =
let tx_pool = Shared_page_pool.make grant_tx_page in
(* Register callback activation *)
return { id; backend_id; tx_client; tx_gnt; tx_mutex; tx_pool;
rx_gnt; rx_fring; rx_client; rx_map; stats;
rx_gnt; rx_fring; rx_client; rx_map; rx_id = 0; stats;
evtchn; mac; backend; features;
}
@@ -382,7 +383,12 @@ let refill_requests nf =
let pages = Io_page.pages num in
List.iter
(fun (gref, page) ->
let id = gref mod (1 lsl 16) in
let rec next () =
let id = nf.rx_id in
nf.rx_id <- (succ nf.rx_id) mod (1 lsl 16);
if Hashtbl.mem nf.rx_map id then next () else id
in
let id = next () in
Gnt.Gntshr.grant_access ~domid:nf.backend_id ~writable:true gref page;
Hashtbl.add nf.rx_map id (gref, page);
let slot_id = Ring.Rpc.Front.next_req_id nf.rx_fring in

0 comments on commit 6daad38

Please sign in to comment.