WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] [Mini-OS] Fix netfront xmit overflow

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] [Mini-OS] Fix netfront xmit overflow
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Sat, 24 Nov 2007 19:00:14 -0800
Delivery-date: Sat, 24 Nov 2007 19:00:45 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1195910934 0
# Node ID 7eea09b188395a8e2d893bae4d5dab9b29f3ad71
# Parent  eac7ef8ba544989ea40f9beb9f1761ece595c5b3
[Mini-OS] Fix netfront xmit overflow

Fix xmit overflow by making netfront_xmit sleep until
network_tx_buf_gc() frees an xmit request.

Signed-off-by: Samuel Thibault <samuel.thibault@xxxxxxxxxx>
---
 extras/mini-os/netfront.c |   24 +++++++++++++++++-------
 1 files changed, 17 insertions(+), 7 deletions(-)

diff -r eac7ef8ba544 -r 7eea09b18839 extras/mini-os/netfront.c
--- a/extras/mini-os/netfront.c Sat Nov 24 13:28:27 2007 +0000
+++ b/extras/mini-os/netfront.c Sat Nov 24 13:28:54 2007 +0000
@@ -13,6 +13,7 @@
 #include <gnttab.h>
 #include <xmalloc.h>
 #include <time.h>
+#include <semaphore.h>
 
 void init_rx_buffers(void);
 
@@ -48,6 +49,7 @@ char* xenbus_printf(xenbus_transaction_t
 
 unsigned short rx_freelist[NET_RX_RING_SIZE];
 unsigned short tx_freelist[NET_TX_RING_SIZE];
+__DECLARE_SEMAPHORE_GENERIC(tx_sem, NET_TX_RING_SIZE);
 
 struct net_buffer {
     void* page;
@@ -188,6 +190,7 @@ void network_tx_buf_gc(void)
             buf->gref=GRANT_INVALID_REF;
 
             add_id_to_freelist(id,tx_freelist);
+            up(&tx_sem);
         }
 
         np->tx.rsp_cons = prod;
@@ -422,16 +425,23 @@ void netfront_xmit(unsigned char* data,i
 void netfront_xmit(unsigned char* data,int len)
 {
     int flags;
-    local_irq_save(flags);
-
     struct net_info* info = &net_info;
     struct netif_tx_request *tx;
-    RING_IDX i = info->tx.req_prod_pvt;
+    RING_IDX i;
     int notify;
-    int id = get_id_from_freelist(tx_freelist);
-    struct net_buffer* buf = &tx_buffers[id];
-    void* page = buf->page;
-
+    int id;
+    struct net_buffer* buf;
+    void* page;
+
+    down(&tx_sem);
+
+    local_irq_save(flags);
+
+    id = get_id_from_freelist(tx_freelist);
+    buf = &tx_buffers[id];
+    page = buf->page;
+
+    i = info->tx.req_prod_pvt;
     tx = RING_GET_REQUEST(&info->tx, i);
 
     memcpy(page,data,len);

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] [Mini-OS] Fix netfront xmit overflow, Xen patchbot-unstable <=