From: Samuel Thibault <samuel.thibault@eu.citrix.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH] [Mini-OS] Fix netfront xmit overflow
Date: Fri, 23 Nov 2007 17:19:32 +0000 [thread overview]
Message-ID: <20071123171932.GA12372@implementation.uk.xensource.com> (raw)
Fix xmit overflow by making netfront_xmit sleep until
network_tx_buf_gc() frees an xmit request.
Signed-off-by: Samuel Thibault <samuel.thibault@citrix.com>
---
Note: depends on callback-safe semaphores.
diff -r dc9246357cdb extras/mini-os/netfront.c
--- a/extras/mini-os/netfront.c Fri Nov 23 16:42:44 2007 +0000
+++ b/extras/mini-os/netfront.c Fri Nov 23 17:15:51 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 @@
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 @@
buf->gref=GRANT_INVALID_REF;
add_id_to_freelist(id,tx_freelist);
+ up(&tx_sem);
}
np->tx.rsp_cons = prod;
@@ -421,16 +424,23 @@
void netfront_xmit(unsigned char* data,int len)
{
int flags;
+ struct net_info* info = &net_info;
+ struct netif_tx_request *tx;
+ RING_IDX i;
+ int notify;
+ int id;
+ struct net_buffer* buf;
+ void* page;
+
+ down(&tx_sem);
+
local_irq_save(flags);
- struct net_info* info = &net_info;
- struct netif_tx_request *tx;
- RING_IDX i = info->tx.req_prod_pvt;
- int notify;
- int id = get_id_from_freelist(tx_freelist);
- struct net_buffer* buf = &tx_buffers[id];
- void* page = buf->page;
+ 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);
reply other threads:[~2007-11-23 17:19 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20071123171932.GA12372@implementation.uk.xensource.com \
--to=samuel.thibault@eu.citrix.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.