Net patches
Note this is my first signed pull request, using the PGP key that I provided at KVM Forum 2013.
The following changes since commit dd089c0a1e928fb80ba8a37983c1b0e9232d1c8b:
Merge remote-tracking branch 'pmaydell/tags/pull-cocoa-20140112' into staging (2014-01-12 17:50:52 -0800)
are available in the git repository at:
git://github.com/stefanha/qemu.git tags/net-for-anthony
for you to fetch changes up to 7a78fa0536db7fe5d95ea598386dbb4eaa9ea7d1:
Fix lan9118 buffer length handling (2014-01-13 13:44:28 +0800)
----------------------------------------------------------------
Net subsystem patch queue
----------------------------------------------------------------
Hani Benhabiles (1):
net: Use g_strdup_printf instead of snprintf.
Roy Franz (2):
Fix lan9118 TX "CMD A" handling
Fix lan9118 buffer length handling
hw/net/lan9118.c | 6 +++--- net/net.c | 5 +---- 2 files changed, 4 insertions(+), 7 deletions(-)
Signature · 1 line
1.8.4.2
[Qemu-devel] [PULL 1/3] net: Use g_strdup_printf instead of snprintf.
From: Hani Benhabiles <[email protected]>
assign_name() in net/net.c is using snprintf + g_strdup to get the same result as g_strdup_printf.
--- net/net.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
net/net.c +1 -4
@@ -164,7 +164,6 @@ void qemu_macaddr_default_if_unset(MACAddr *macaddr)static char *assign_name (NetClientState *nc1,const char *model) {NetClientState *nc; -char buf[256 ];int id =0 ; QTAILQ_FOREACH(nc, &net_clients, next) {
@@ -176,9 +175,7 @@ static char *assign_name(NetClientState *nc1, const char *model) } } -snprintf (buf,sizeof (buf),"%s.%d" , model, id); - -return g_strdup (buf); +return g_strdup_printf ("%s.%d" , model, id); }static void qemu_net_client_destructor (NetClientState *nc)
Signature · 1 line
1.8.4.2
[Qemu-devel] [PULL 2/3] Fix lan9118 TX "CMD A" handling
In reply to Stefan HajnocziFrom: Roy Franz <[email protected]>
The 9118 ethernet controller supports transmission of multi-buffer packets with arbitrary byte alignment of the start and end bytes. All writes to the packet fifo are 32 bits, so the controller discards bytes at the beginning and end of each buffer based on the 'Data start offset' and 'Buffer size' of the TX command 'A' format.
This patch changes the buffer size and offset internal state variables to be updated on every "TX command A" write. Previously they were only updated for the first segment, which resulted incorrect behavior for packets with more than one segment. Each segment of the packet has its own CMD A command, with its own buffer size and start offset.
Also update extraction of fields from the CMD A word to use extract32().
--- hw/net/lan9118.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/net/lan9118.c +2 -2
@@ -727,14 +727,14 @@ static void tx_fifo_push(lan9118_state *s, uint32_t val) s->txp->cmd_a = val &0x831f37ff ; s->txp->fifo_used++; s->txp->state =TX_B ; + s->txp->buffer_size =extract32 (s->txp->cmd_a,0 ,11 ); + s->txp->offset =extract32 (s->txp->cmd_a,16 ,5 );break ;case TX_B :if (s->txp->cmd_a &0x2000 ) {/* First segment */ s->txp->cmd_b = val; s->txp->fifo_used++; - s->txp->buffer_size = s->txp->cmd_a &0x7ff ; - s->txp->offset = (s->txp->cmd_a >>16 ) &0x1f ;/* End alignment does not include command words. */ n = (s->txp->buffer_size + s->txp->offset +3 ) >>2 ;switch ((n >>24 ) &3 ) {
Signature · 1 line
1.8.4.2
[Qemu-devel] [PULL 3/3] Fix lan9118 buffer length handling
In reply to Stefan HajnocziFrom: Roy Franz <[email protected]>
The 9118 ethernet controller supports transmission of multi-buffer packets with arbitrary byte alignment of the start and end bytes. All writes to the packet fifo are 32 bits, so the controller discards bytes at the beginning and end of each buffer based on the 'Data start offset' and 'Buffer size' of the TX command 'A' format.
This patch uses the provided buffer length to limit the bytes transmitted. Previously all the bytes of the last 32-bit word written to the TX fifo were added to the internal transmit buffer structure resulting in more bytes being transmitted than were submitted to the hardware in the command. This resulted in extra bytes being inserted into the middle of multi-buffer packets when the non-final buffers had non-32bit aligned ending addresses.
--- hw/net/lan9118.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/net/lan9118.c +1 -1
@@ -763,7 +763,7 @@ static void tx_fifo_push(lan9118_state *s, uint32_t val)if (s->txp->buffer_size <=0 && s->txp->pad !=0 ) { s->txp->pad--; }else { - n =4 ; + n =MIN (4 , s->txp->buffer_size + s->txp->offset);while (s->txp->offset) { val >>=8 ; n--;
Signature · 1 line
1.8.4.2