|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v3 04/13] xen/pvcalls: implement socket command and handle events
On 07/31/2017 06:57 PM, Stefano Stabellini wrote: Send a PVCALLS_SOCKET command to the backend, use the masked req_prod_pvt as req_id. This way, req_id is guaranteed to be between 0 and PVCALLS_NR_REQ_PER_RING. We already have a slot in the rsp array ready for the response, and there cannot be two outstanding responses with the same req_id. Wait for the response by waiting on the inflight_req waitqueue and check for the req_id field in rsp[req_id]. Use atomic accesses and barriers to read the field. Note that the barriers are simple smp barriers (as opposed to virt barriers) because they are for internal frontend synchronization, not frontend<->backend communication. Once a response is received, clear the corresponding rsp slot by setting req_id to PVCALLS_INVALID_ID. Note that PVCALLS_INVALID_ID is invalid only from the frontend point of view. It is not part of the PVCalls protocol. pvcalls_front_event_handler is in charge of copying responses from the ring to the appropriate rsp slot. It is done by copying the body of the response first, then by copying req_id atomically. After the copies, wake up anybody waiting on waitqueue. pvcallss_lock protects accesses to the ring. Create a new struct sock_mapping and convert the pointer into an uint64_t and use it as id for the new socket to pass to the backend. The struct will be fully initialized later on connect or bind. In this patch the struct sock_mapping is empty, the fields will be added by the next patch. sock->sk->sk_send_head is not used for ip sockets: reuse the field to store a pointer to the struct sock_mapping corresponding to the socket. This way, we can easily get the struct sock_mapping from the struct socket. Signed-off-by: Stefano Stabellini <stefano@xxxxxxxxxxx> CC: boris.ostrovsky@xxxxxxxxxx CC: jgross@xxxxxxxx --- drivers/xen/pvcalls-front.c | 119 ++++++++++++++++++++++++++++++++++++++++++++ drivers/xen/pvcalls-front.h | 8 +++ 2 files changed, 127 insertions(+) create mode 100644 drivers/xen/pvcalls-front.h diff --git a/drivers/xen/pvcalls-front.c b/drivers/xen/pvcalls-front.c index 2afe36d..7c4a7cb 100644 --- a/drivers/xen/pvcalls-front.c +++ b/drivers/xen/pvcalls-front.c @@ -20,6 +20,8 @@ #include <xen/xenbus.h> #include <xen/interface/io/pvcalls.h>+#include "pvcalls-front.h" Is this a safe assumption? Is it conceivable that at some point in the future sk_send_head might become used? What is happening to the mapping you've linked above? Should it be
unlinked and freed? (or defer its creation until we've got a request slot?)
+ } + req = RING_GET_REQUEST(&bedata->ring, req_id); + req->req_id = req_id; + req->cmd = PVCALLS_SOCKET; + req->u.socket.id = (uint64_t) map; + req->u.socket.domain = AF_INET; + req->u.socket.type = SOCK_STREAM; + req->u.socket.protocol = 0; IPPROTO_IP? -boris _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |