* [Qemu-devel] [PULL 1/4] net: Use g_strdup_printf instead of snprintf.
2014-01-27 14:48 [Qemu-devel] [PULL 0/4] Net patches Stefan Hajnoczi
@ 2014-01-27 14:48 ` Stefan Hajnoczi
2014-01-27 14:48 ` [Qemu-devel] [PULL 2/4] Fix lan9118 TX "CMD A" handling Stefan Hajnoczi
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Stefan Hajnoczi @ 2014-01-27 14:48 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Anthony Liguori
From: Hani Benhabiles <kroosec@gmail.com>
assign_name() in net/net.c is using snprintf + g_strdup to get the same
result as g_strdup_printf.
Signed-off-by: Hani Benhabiles <kroosec@gmail.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
net/net.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/net/net.c b/net/net.c
index f8db85f..2c3af20 100644
--- a/net/net.c
+++ b/net/net.c
@@ -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)
--
1.8.4.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [PULL 2/4] Fix lan9118 TX "CMD A" handling
2014-01-27 14:48 [Qemu-devel] [PULL 0/4] Net patches Stefan Hajnoczi
2014-01-27 14:48 ` [Qemu-devel] [PULL 1/4] net: Use g_strdup_printf instead of snprintf Stefan Hajnoczi
@ 2014-01-27 14:48 ` Stefan Hajnoczi
2014-01-27 14:48 ` [Qemu-devel] [PULL 3/4] Fix lan9118 buffer length handling Stefan Hajnoczi
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Stefan Hajnoczi @ 2014-01-27 14:48 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Anthony Liguori
From: Roy Franz <roy.franz@linaro.org>
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().
Signed-off-by: Roy Franz <roy.franz@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
hw/net/lan9118.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c
index 2315f99..bb0c503 100644
--- a/hw/net/lan9118.c
+++ b/hw/net/lan9118.c
@@ -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) {
--
1.8.4.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [PULL 3/4] Fix lan9118 buffer length handling
2014-01-27 14:48 [Qemu-devel] [PULL 0/4] Net patches Stefan Hajnoczi
2014-01-27 14:48 ` [Qemu-devel] [PULL 1/4] net: Use g_strdup_printf instead of snprintf Stefan Hajnoczi
2014-01-27 14:48 ` [Qemu-devel] [PULL 2/4] Fix lan9118 TX "CMD A" handling Stefan Hajnoczi
@ 2014-01-27 14:48 ` Stefan Hajnoczi
2014-01-27 14:48 ` [Qemu-devel] [PULL 4/4] tap-linux: Get features once and use it many times Stefan Hajnoczi
2014-01-31 0:09 ` [Qemu-devel] [PULL 0/4] Net patches Peter Maydell
4 siblings, 0 replies; 6+ messages in thread
From: Stefan Hajnoczi @ 2014-01-27 14:48 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Anthony Liguori
From: Roy Franz <roy.franz@linaro.org>
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.
Signed-off-by: Roy Franz <roy.franz@linaro.org>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
hw/net/lan9118.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c
index bb0c503..e528290 100644
--- a/hw/net/lan9118.c
+++ b/hw/net/lan9118.c
@@ -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--;
--
1.8.4.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [PULL 4/4] tap-linux: Get features once and use it many times
2014-01-27 14:48 [Qemu-devel] [PULL 0/4] Net patches Stefan Hajnoczi
` (2 preceding siblings ...)
2014-01-27 14:48 ` [Qemu-devel] [PULL 3/4] Fix lan9118 buffer length handling Stefan Hajnoczi
@ 2014-01-27 14:48 ` Stefan Hajnoczi
2014-01-31 0:09 ` [Qemu-devel] [PULL 0/4] Net patches Peter Maydell
4 siblings, 0 replies; 6+ messages in thread
From: Stefan Hajnoczi @ 2014-01-27 14:48 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Anthony Liguori
From: Kusanagi Kouichi <slash@ac.auone-net.jp>
Signed-off-by: Kusanagi Kouichi <slash@ac.auone-net.jp>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
net/tap-linux.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/net/tap-linux.c b/net/tap-linux.c
index 36c09e2..812bf2d 100644
--- a/net/tap-linux.c
+++ b/net/tap-linux.c
@@ -52,14 +52,17 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
memset(&ifr, 0, sizeof(ifr));
ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
- if (ioctl(fd, TUNGETFEATURES, &features) == 0 &&
- features & IFF_ONE_QUEUE) {
+ if (ioctl(fd, TUNGETFEATURES, &features) == -1) {
+ error_report("warning: TUNGETFEATURES failed: %s", strerror(errno));
+ features = 0;
+ }
+
+ if (features & IFF_ONE_QUEUE) {
ifr.ifr_flags |= IFF_ONE_QUEUE;
}
if (*vnet_hdr) {
- if (ioctl(fd, TUNGETFEATURES, &features) == 0 &&
- features & IFF_VNET_HDR) {
+ if (features & IFF_VNET_HDR) {
*vnet_hdr = 1;
ifr.ifr_flags |= IFF_VNET_HDR;
} else {
@@ -82,8 +85,7 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
}
if (mq_required) {
- if ((ioctl(fd, TUNGETFEATURES, &features) != 0) ||
- !(features & IFF_MULTI_QUEUE)) {
+ if (!(features & IFF_MULTI_QUEUE)) {
error_report("multiqueue required, but no kernel "
"support for IFF_MULTI_QUEUE available");
close(fd);
--
1.8.4.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PULL 0/4] Net patches
2014-01-27 14:48 [Qemu-devel] [PULL 0/4] Net patches Stefan Hajnoczi
` (3 preceding siblings ...)
2014-01-27 14:48 ` [Qemu-devel] [PULL 4/4] tap-linux: Get features once and use it many times Stefan Hajnoczi
@ 2014-01-31 0:09 ` Peter Maydell
4 siblings, 0 replies; 6+ messages in thread
From: Peter Maydell @ 2014-01-31 0:09 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: QEMU Developers, Anthony Liguori
On 27 January 2014 14:48, Stefan Hajnoczi <stefanha@redhat.com> wrote:
> The following changes since commit 0169c511554cb0014a00290b0d3d26c31a49818f:
>
> Merge remote-tracking branch 'qemu-kvm/uq/master' into staging (2014-01-24 15:52:44 -0800)
>
> are available in the git repository at:
>
>
> git://github.com/stefanha/qemu.git tags/net-pull-request
>
> for you to fetch changes up to 1f149e721feb617d14a3ee4f5911c47b29866a54:
>
> tap-linux: Get features once and use it many times (2014-01-27 15:44:06 +0100)
Applied, thanks.
-- PMM
^ permalink raw reply [flat|nested] 6+ messages in thread