[Xen-devel] [PATCH 08/14] xen-netback: use foreign page information from the pages themselves

2015-01-19 Thread David Vrabel
From: Jenny Herbert jennifer.herb...@citrix.com

Use the foreign page flag in netback to get the domid and grant ref
needed for the grant copy.  This signficiantly simplifies the netback
code and makes netback work with foreign pages from other backends
(e.g., blkback).

This allows blkback to use iSCSI disks provided by domUs running on
the same host.

Signed-off-by: Jenny Herbert jennifer.herb...@citrix.com
Acked-by: Ian Campbell ian.campb...@citrix.com
Acked-by: David S. Miller da...@davemloft.net
Signed-off-by: David Vrabel david.vra...@citrix.com
---
 drivers/net/xen-netback/netback.c |  100 -
 1 file changed, 9 insertions(+), 91 deletions(-)

diff --git a/drivers/net/xen-netback/netback.c 
b/drivers/net/xen-netback/netback.c
index 6441318..ae3ab37 100644
--- a/drivers/net/xen-netback/netback.c
+++ b/drivers/net/xen-netback/netback.c
@@ -314,9 +314,7 @@ static struct xenvif_rx_meta *get_next_rx_buffer(struct 
xenvif_queue *queue,
 static void xenvif_gop_frag_copy(struct xenvif_queue *queue, struct sk_buff 
*skb,
 struct netrx_pending_operations *npo,
 struct page *page, unsigned long size,
-unsigned long offset, int *head,
-struct xenvif_queue *foreign_queue,
-grant_ref_t foreign_gref)
+unsigned long offset, int *head)
 {
struct gnttab_copy *copy_gop;
struct xenvif_rx_meta *meta;
@@ -333,6 +331,8 @@ static void xenvif_gop_frag_copy(struct xenvif_queue 
*queue, struct sk_buff *skb
offset = ~PAGE_MASK;
 
while (size  0) {
+   struct xen_page_foreign *foreign;
+
BUG_ON(offset = PAGE_SIZE);
BUG_ON(npo-copy_off  MAX_BUFFER_OFFSET);
 
@@ -361,9 +361,10 @@ static void xenvif_gop_frag_copy(struct xenvif_queue 
*queue, struct sk_buff *skb
copy_gop-flags = GNTCOPY_dest_gref;
copy_gop-len = bytes;
 
-   if (foreign_queue) {
-   copy_gop-source.domid = foreign_queue-vif-domid;
-   copy_gop-source.u.ref = foreign_gref;
+   foreign = xen_page_foreign(page);
+   if (foreign) {
+   copy_gop-source.domid = foreign-domid;
+   copy_gop-source.u.ref = foreign-gref;
copy_gop-flags |= GNTCOPY_source_gref;
} else {
copy_gop-source.domid = DOMID_SELF;
@@ -406,35 +407,6 @@ static void xenvif_gop_frag_copy(struct xenvif_queue 
*queue, struct sk_buff *skb
 }
 
 /*
- * Find the grant ref for a given frag in a chain of struct ubuf_info's
- * skb: the skb itself
- * i: the frag's number
- * ubuf: a pointer to an element in the chain. It should not be NULL
- *
- * Returns a pointer to the element in the chain where the page were found. If
- * not found, returns NULL.
- * See the definition of callback_struct in common.h for more details about
- * the chain.
- */
-static const struct ubuf_info *xenvif_find_gref(const struct sk_buff *const 
skb,
-   const int i,
-   const struct ubuf_info *ubuf)
-{
-   struct xenvif_queue *foreign_queue = ubuf_to_queue(ubuf);
-
-   do {
-   u16 pending_idx = ubuf-desc;
-
-   if (skb_shinfo(skb)-frags[i].page.p ==
-   foreign_queue-mmap_pages[pending_idx])
-   break;
-   ubuf = (struct ubuf_info *) ubuf-ctx;
-   } while (ubuf);
-
-   return ubuf;
-}
-
-/*
  * Prepare an SKB to be transmitted to the frontend.
  *
  * This function is responsible for allocating grant operations, meta
@@ -459,8 +431,6 @@ static int xenvif_gop_skb(struct sk_buff *skb,
int head = 1;
int old_meta_prod;
int gso_type;
-   const struct ubuf_info *ubuf = skb_shinfo(skb)-destructor_arg;
-   const struct ubuf_info *const head_ubuf = ubuf;
 
old_meta_prod = npo-meta_prod;
 
@@ -507,68 +477,16 @@ static int xenvif_gop_skb(struct sk_buff *skb,
len = skb_tail_pointer(skb) - data;
 
xenvif_gop_frag_copy(queue, skb, npo,
-virt_to_page(data), len, offset, head,
-NULL,
-0);
+virt_to_page(data), len, offset, head);
data += len;
}
 
for (i = 0; i  nr_frags; i++) {
-   /* This variable also signals whether foreign_gref has a real
-* value or not.
-*/
-   struct xenvif_queue *foreign_queue = NULL;
-   grant_ref_t foreign_gref;
-
-   if ((skb_shinfo(skb)-tx_flags  SKBTX_DEV_ZEROCOPY) 
-   (ubuf-callback == 

Re: [Xen-devel] [PATCH 08/14] xen-netback: use foreign page information from the pages themselves

2015-01-13 Thread David Vrabel
On 12/01/15 15:43, David Vrabel wrote:
 From: Jenny Herbert jenny.herb...@citrix.com
 
 Use the foreign page flag in netback to get the domid and grant ref
 needed for the grant copy.  This signficiantly simplifies the netback
 code and makes netback work with foreign pages from other backends
 (e.g., blkback).
 
 This allows blkback to use iSCSI disks provided by domUs running on
 the same host.

Dave,

This depends on several xen changes.  It's been Acked-by: Ian Campbell
ian.campb...@citrix.com

Are you happy for me to merge this via the xen tree in 3.20?

David

 Signed-off-by: Jenny Herbert jennifer.herb...@citrix.com
 Signed-off-by: David Vrabel david.vra...@citrix.com
 ---
  drivers/net/xen-netback/netback.c |  100 
 -
  1 file changed, 9 insertions(+), 91 deletions(-)
 
 diff --git a/drivers/net/xen-netback/netback.c 
 b/drivers/net/xen-netback/netback.c
 index 6441318..ae3ab37 100644
 --- a/drivers/net/xen-netback/netback.c
 +++ b/drivers/net/xen-netback/netback.c
 @@ -314,9 +314,7 @@ static struct xenvif_rx_meta *get_next_rx_buffer(struct 
 xenvif_queue *queue,
  static void xenvif_gop_frag_copy(struct xenvif_queue *queue, struct sk_buff 
 *skb,
struct netrx_pending_operations *npo,
struct page *page, unsigned long size,
 -  unsigned long offset, int *head,
 -  struct xenvif_queue *foreign_queue,
 -  grant_ref_t foreign_gref)
 +  unsigned long offset, int *head)
  {
   struct gnttab_copy *copy_gop;
   struct xenvif_rx_meta *meta;
 @@ -333,6 +331,8 @@ static void xenvif_gop_frag_copy(struct xenvif_queue 
 *queue, struct sk_buff *skb
   offset = ~PAGE_MASK;
  
   while (size  0) {
 + struct xen_page_foreign *foreign;
 +
   BUG_ON(offset = PAGE_SIZE);
   BUG_ON(npo-copy_off  MAX_BUFFER_OFFSET);
  
 @@ -361,9 +361,10 @@ static void xenvif_gop_frag_copy(struct xenvif_queue 
 *queue, struct sk_buff *skb
   copy_gop-flags = GNTCOPY_dest_gref;
   copy_gop-len = bytes;
  
 - if (foreign_queue) {
 - copy_gop-source.domid = foreign_queue-vif-domid;
 - copy_gop-source.u.ref = foreign_gref;
 + foreign = xen_page_foreign(page);
 + if (foreign) {
 + copy_gop-source.domid = foreign-domid;
 + copy_gop-source.u.ref = foreign-gref;
   copy_gop-flags |= GNTCOPY_source_gref;
   } else {
   copy_gop-source.domid = DOMID_SELF;
 @@ -406,35 +407,6 @@ static void xenvif_gop_frag_copy(struct xenvif_queue 
 *queue, struct sk_buff *skb
  }
  
  /*
 - * Find the grant ref for a given frag in a chain of struct ubuf_info's
 - * skb: the skb itself
 - * i: the frag's number
 - * ubuf: a pointer to an element in the chain. It should not be NULL
 - *
 - * Returns a pointer to the element in the chain where the page were found. 
 If
 - * not found, returns NULL.
 - * See the definition of callback_struct in common.h for more details about
 - * the chain.
 - */
 -static const struct ubuf_info *xenvif_find_gref(const struct sk_buff *const 
 skb,
 - const int i,
 - const struct ubuf_info *ubuf)
 -{
 - struct xenvif_queue *foreign_queue = ubuf_to_queue(ubuf);
 -
 - do {
 - u16 pending_idx = ubuf-desc;
 -
 - if (skb_shinfo(skb)-frags[i].page.p ==
 - foreign_queue-mmap_pages[pending_idx])
 - break;
 - ubuf = (struct ubuf_info *) ubuf-ctx;
 - } while (ubuf);
 -
 - return ubuf;
 -}
 -
 -/*
   * Prepare an SKB to be transmitted to the frontend.
   *
   * This function is responsible for allocating grant operations, meta
 @@ -459,8 +431,6 @@ static int xenvif_gop_skb(struct sk_buff *skb,
   int head = 1;
   int old_meta_prod;
   int gso_type;
 - const struct ubuf_info *ubuf = skb_shinfo(skb)-destructor_arg;
 - const struct ubuf_info *const head_ubuf = ubuf;
  
   old_meta_prod = npo-meta_prod;
  
 @@ -507,68 +477,16 @@ static int xenvif_gop_skb(struct sk_buff *skb,
   len = skb_tail_pointer(skb) - data;
  
   xenvif_gop_frag_copy(queue, skb, npo,
 -  virt_to_page(data), len, offset, head,
 -  NULL,
 -  0);
 +  virt_to_page(data), len, offset, head);
   data += len;
   }
  
   for (i = 0; i  nr_frags; i++) {
 - /* This variable also signals whether foreign_gref has a real
 -  * value or not.
 -  */
 - struct xenvif_queue *foreign_queue = NULL;
 - grant_ref_t 

[Xen-devel] [PATCH 08/14] xen-netback: use foreign page information from the pages themselves

2015-01-12 Thread David Vrabel
From: Jenny Herbert jenny.herb...@citrix.com

Use the foreign page flag in netback to get the domid and grant ref
needed for the grant copy.  This signficiantly simplifies the netback
code and makes netback work with foreign pages from other backends
(e.g., blkback).

This allows blkback to use iSCSI disks provided by domUs running on
the same host.

Signed-off-by: Jenny Herbert jennifer.herb...@citrix.com
Signed-off-by: David Vrabel david.vra...@citrix.com
---
 drivers/net/xen-netback/netback.c |  100 -
 1 file changed, 9 insertions(+), 91 deletions(-)

diff --git a/drivers/net/xen-netback/netback.c 
b/drivers/net/xen-netback/netback.c
index 6441318..ae3ab37 100644
--- a/drivers/net/xen-netback/netback.c
+++ b/drivers/net/xen-netback/netback.c
@@ -314,9 +314,7 @@ static struct xenvif_rx_meta *get_next_rx_buffer(struct 
xenvif_queue *queue,
 static void xenvif_gop_frag_copy(struct xenvif_queue *queue, struct sk_buff 
*skb,
 struct netrx_pending_operations *npo,
 struct page *page, unsigned long size,
-unsigned long offset, int *head,
-struct xenvif_queue *foreign_queue,
-grant_ref_t foreign_gref)
+unsigned long offset, int *head)
 {
struct gnttab_copy *copy_gop;
struct xenvif_rx_meta *meta;
@@ -333,6 +331,8 @@ static void xenvif_gop_frag_copy(struct xenvif_queue 
*queue, struct sk_buff *skb
offset = ~PAGE_MASK;
 
while (size  0) {
+   struct xen_page_foreign *foreign;
+
BUG_ON(offset = PAGE_SIZE);
BUG_ON(npo-copy_off  MAX_BUFFER_OFFSET);
 
@@ -361,9 +361,10 @@ static void xenvif_gop_frag_copy(struct xenvif_queue 
*queue, struct sk_buff *skb
copy_gop-flags = GNTCOPY_dest_gref;
copy_gop-len = bytes;
 
-   if (foreign_queue) {
-   copy_gop-source.domid = foreign_queue-vif-domid;
-   copy_gop-source.u.ref = foreign_gref;
+   foreign = xen_page_foreign(page);
+   if (foreign) {
+   copy_gop-source.domid = foreign-domid;
+   copy_gop-source.u.ref = foreign-gref;
copy_gop-flags |= GNTCOPY_source_gref;
} else {
copy_gop-source.domid = DOMID_SELF;
@@ -406,35 +407,6 @@ static void xenvif_gop_frag_copy(struct xenvif_queue 
*queue, struct sk_buff *skb
 }
 
 /*
- * Find the grant ref for a given frag in a chain of struct ubuf_info's
- * skb: the skb itself
- * i: the frag's number
- * ubuf: a pointer to an element in the chain. It should not be NULL
- *
- * Returns a pointer to the element in the chain where the page were found. If
- * not found, returns NULL.
- * See the definition of callback_struct in common.h for more details about
- * the chain.
- */
-static const struct ubuf_info *xenvif_find_gref(const struct sk_buff *const 
skb,
-   const int i,
-   const struct ubuf_info *ubuf)
-{
-   struct xenvif_queue *foreign_queue = ubuf_to_queue(ubuf);
-
-   do {
-   u16 pending_idx = ubuf-desc;
-
-   if (skb_shinfo(skb)-frags[i].page.p ==
-   foreign_queue-mmap_pages[pending_idx])
-   break;
-   ubuf = (struct ubuf_info *) ubuf-ctx;
-   } while (ubuf);
-
-   return ubuf;
-}
-
-/*
  * Prepare an SKB to be transmitted to the frontend.
  *
  * This function is responsible for allocating grant operations, meta
@@ -459,8 +431,6 @@ static int xenvif_gop_skb(struct sk_buff *skb,
int head = 1;
int old_meta_prod;
int gso_type;
-   const struct ubuf_info *ubuf = skb_shinfo(skb)-destructor_arg;
-   const struct ubuf_info *const head_ubuf = ubuf;
 
old_meta_prod = npo-meta_prod;
 
@@ -507,68 +477,16 @@ static int xenvif_gop_skb(struct sk_buff *skb,
len = skb_tail_pointer(skb) - data;
 
xenvif_gop_frag_copy(queue, skb, npo,
-virt_to_page(data), len, offset, head,
-NULL,
-0);
+virt_to_page(data), len, offset, head);
data += len;
}
 
for (i = 0; i  nr_frags; i++) {
-   /* This variable also signals whether foreign_gref has a real
-* value or not.
-*/
-   struct xenvif_queue *foreign_queue = NULL;
-   grant_ref_t foreign_gref;
-
-   if ((skb_shinfo(skb)-tx_flags  SKBTX_DEV_ZEROCOPY) 
-   (ubuf-callback == xenvif_zerocopy_callback)) {
-   const struct ubuf_info *const startpoint = ubuf;
-

Re: [Xen-devel] [PATCH 08/14] xen-netback: use foreign page information from the pages themselves

2015-01-12 Thread Ian Campbell
On Mon, 2015-01-12 at 15:43 +, David Vrabel wrote:
 From: Jenny Herbert jenny.herb...@citrix.com
 
 Use the foreign page flag in netback to get the domid and grant ref
 needed for the grant copy.  This signficiantly simplifies the netback
 code and makes netback work with foreign pages from other backends
 (e.g., blkback).
 
 This allows blkback to use iSCSI disks provided by domUs running on
 the same host.
 
 Signed-off-by: Jenny Herbert jennifer.herb...@citrix.com
 Signed-off-by: David Vrabel david.vra...@citrix.com

I acked v1, has this version changed significantly enough to warrant a
re-review? (Does seem so on first glance)



___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH 08/14] xen-netback: use foreign page information from the pages themselves

2015-01-12 Thread Ian Campbell
On Mon, 2015-01-12 at 17:16 +, David Vrabel wrote:
 On 12/01/15 16:56, Ian Campbell wrote:
  On Mon, 2015-01-12 at 15:43 +, David Vrabel wrote:
  From: Jenny Herbert jenny.herb...@citrix.com
 
  Use the foreign page flag in netback to get the domid and grant ref
  needed for the grant copy.  This signficiantly simplifies the netback
  code and makes netback work with foreign pages from other backends
  (e.g., blkback).
 
  This allows blkback to use iSCSI disks provided by domUs running on
  the same host.
 
  Signed-off-by: Jenny Herbert jennifer.herb...@citrix.com
  Signed-off-by: David Vrabel david.vra...@citrix.com
  
  I acked v1, has this version changed significantly enough to warrant a
  re-review? (Does seem so on first glance)
 
 The important change is:
 
 v1:
 
 + if (PageForeign(page)) {
 + get_page_grant_ref(page, copy_gop-source.domid,
 +copy_gop-source.u.ref);
 
 v2:
 
 + struct xen_page_foreign *foreign;
 ...
 + foreign = xen_page_foreign(page);
 + if (foreign) {
 + copy_gop-source.domid = foreign-domid;
 + copy_gop-source.u.ref = foreign-gref;

Thanks, the ack can stand then.



___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel