Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
use a monotonic counter for the RX id (similar to TX id)
wrap RX counter to 16 bit
  • Loading branch information
hannesm committed May 2, 2016
1 parent c974a67 commit 0b1e53c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/frontend.ml
Expand Up @@ -82,6 +82,7 @@ module Make(C: S.CONFIGURATION with type 'a io = 'a Lwt.t) = struct
rx_client: (RX.Response.t,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.t;
Expand Down Expand Up @@ -145,7 +146,7 @@ module Make(C: S.CONFIGURATION with type 'a io = 'a Lwt.t) = struct
(* Register callback activation *)
let backend = backend_conf.S.backend in
return { vif_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;
}

Expand All @@ -163,7 +164,12 @@ module Make(C: S.CONFIGURATION with type 'a io = 'a Lwt.t) = struct
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
Expand Down

0 comments on commit 0b1e53c

Please sign in to comment.