Sanitizing frontend-backend request completion.

We cleaned up the way the backend notifies the frontend in the send path, giving
each request a unique status variable to poll on. Instead of having just one
status variable (causing corruption when multiple requests get pushed into the
backend) IOCTLs are now cleanly notified of backend completion events.

We need to do the same for endpoints and regions (open/close,
register/de-register). Hopefully this could allow proper multiple thread
handling.
Adding a cleaner timeout for request handling.
Clarifying reg/de-reg functions.

We're adding the same functionality to registration functions. We use
request_ids and check that the specific request has been completed successfully.

This commit also fixes a bug about deferred region destroy: we skip the rcu
callback stuff, as there's a a race condition when registering/de-registering
too quickly.... Major TODO for performance enhancement ;-)
Adding xen support to omx_reg test.
Minor fixes.

Commenting out some debug stuff, clarifying some error messages.
Nailed two nasty bugs!

first one: we didn't actually re-use the grant references properly.
seg->gref_cookie->gref_head was being updated while seg->gref_head wasn't. but
we used seg->gref_head :S So we were missing some grant references in between
and kept expanding our grant table until we had no more space...

second one: upon region destroy, cmd.id wasn't passed correctly, leading to a
non-proper region release (and exponentially growing memory usage in the
guest!!).

Cleaned up a bit, fixed some indentation issues. We have to polish the code a
bit more and fix the actual freeing of grants allocated (upon module removal).
Xenback page cookies.

We fixed a couple of minor issues for cookies:
 - page allocation
 - added a placeholder for freeing the relevant pages upon removal. We have to
   fix the mappings for it to work, otherwise we corrupt the slab allocator :S
 - as get_cookie may be called in an interrupt context, and the list could be
   empty, we need to use GFP_ATOMIC in the cookie allocation function.
Revert the timeout.

why did we ever change that????

It hangs with mx_pingpong -N10000
Cherrypick the timeout patch
Timer integrity for region deregistration.
pull handle release.

We don't probably need this, but we add it just for consistency.
Inform the user about errors in the backend.
Major reg/de-reg restructure.

We are finally able to register/deregister regions without having to grant one
page at a time. We loop around all grant references to build the map and unmap
operation structures and then uses gnttab_{map,unmap}_refs for all pages within
a segment.

We don't need cookies any more, {alloc,free}_xenballooned_pages are used
instead, providing for nearly none memory leaks upon module insertion and
removal.

This has given us about 100-150MB/s more bandwidth, but still, we're on 75% of the
PCI-attached case.
Adding support for batch grants in endpoints too.

supporting batch grants/ungrants when opening/closing endpoints. Refers to
send/recv queues.

Major TODO: We still need to port the cookie functions to this new batch grant
scheme; this will save us the alloc/free cycle in *every* single registration
(we will do that only once, per count pages).
Fixing a bug when we destroy endpoints.

When we're in Xen, we shoudn't free the endpoint, as it is statically allocated on frontend-backend first contact.
Porting the cookies infrastructure.

We now support cookies for a set of pages (per segment) and not for just one page. Thus, every time we register a segment, we search for a cookie that fits the number of pages. If we haven't got one, we allocate it, and when we deregister this segment, we put it back in the free list. So, we don't need to allocate pages every time we register. We just do that when it is absolutely necessary.
Adding some extra timers.

To debug memory registration we have to add timers to account for late memory
registration both in the backend and the frontend.

It turns out that gnttab_map_refs() and unmap_refs() are taking *a lot* of time.
Hence the mx_pingpong test performs awfully...
Getting rid of a message in cookies.

...and sanitizing a perfect bug ;-)

In the backend cookies case (the set of pre-allocated pages for accepting grants
in the backend), we ask for a cookie by *_get_cookie and the first time (when
the list is empty, the code throws us to alloc_cookies(). However, if this path
is crossed more than OMX_XEN_MAX_COOKIES we see this as an error and abort.

THIS IS NOT CORRECT. We keep this for debugging purposes only, and add a message
to let us know what's going on, instead of just staring at the kernel trace and
wonder ;-)
Minor fix, better debugging!

It's better to negate successful values than assert error values ;-) (especially
when you're not sure what you're going to get for an error...
Fixing some minor typos, adding some more checks.