qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL v5 0/2] Net patches
@ 2015-03-12 20:13 Stefan Hajnoczi
  2015-03-12 20:13 ` [Qemu-devel] [PULL v5 1/2] net: synchronize net_host_device_remove with host_net_remove_completion Stefan Hajnoczi
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Stefan Hajnoczi @ 2015-03-12 20:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Stefan Hajnoczi

v5:
 * Drop rocker due to w32 warning and glib minimum version issue [Peter]

v4:
 * Drop clang 3.5.0 fixes since they break with older clang and w32 [Peter]

v3:
 * Add clang 3.5.0 warning fixes
 * Squash David Ahern's clang struct definition warnings fix

v2:
 * Squash in Jiri's fix for rocker format string specifiers [Peter]
 * Squash in Windows build fix [Peter]
 * Both build fixes are described in "rocker: add new rocker switch device"

The following changes since commit 2a5b58e2405e9fe42ba356b5a1b78146a4e9a659:

  Merge remote-tracking branch 'remotes/kraxel/tags/pull-vnc-20150312-1' into staging (2015-03-12 10:35:54 +0000)

are available in the git repository at:

  git://github.com/stefanha/qemu.git tags/net-pull-request

for you to fetch changes up to 069bb5831faf19d02041569580ad77565776bb1c:

  tests: rtl8139: test timers and interrupt (2015-03-12 19:59:39 +0000)

----------------------------------------------------------------

----------------------------------------------------------------

Frediano Ziglio (1):
  tests: rtl8139: test timers and interrupt

Paolo Bonzini (1):
  net: synchronize net_host_device_remove with
    host_net_remove_completion

 net/net.c            |   6 +-
 tests/Makefile       |   2 +-
 tests/rtl8139-test.c | 181 +++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 185 insertions(+), 4 deletions(-)

-- 
2.1.0

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PULL v5 1/2] net: synchronize net_host_device_remove with host_net_remove_completion
  2015-03-12 20:13 [Qemu-devel] [PULL v5 0/2] Net patches Stefan Hajnoczi
@ 2015-03-12 20:13 ` Stefan Hajnoczi
  2015-03-12 20:13 ` [Qemu-devel] [PULL v5 2/2] tests: rtl8139: test timers and interrupt Stefan Hajnoczi
  2015-03-13 11:50 ` [Qemu-devel] [PULL v5 0/2] Net patches Peter Maydell
  2 siblings, 0 replies; 4+ messages in thread
From: Stefan Hajnoczi @ 2015-03-12 20:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Stefan Hajnoczi, Paolo Bonzini

From: Paolo Bonzini <pbonzini@redhat.com>

Using net_host_check_device is unnecessary.  qemu_del_net_client asserts
for the non-peer case that it can only process NIC type NetClientStates,
and that assertion is valid for the peered case as well, so move it and
use the same check in net_host_device_remove.  host_net_remove_completion
is already checking the type.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Jason Wang <jasowang@redhat.com>
Message-id: 1419353600-30519-2-git-send-email-pbonzini@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 net/net.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/net.c b/net/net.c
index 11fb769..0be084d 100644
--- a/net/net.c
+++ b/net/net.c
@@ -324,6 +324,8 @@ void qemu_del_net_client(NetClientState *nc)
     NetClientState *ncs[MAX_QUEUE_NUM];
     int queues, i;
 
+    assert(nc->info->type != NET_CLIENT_OPTIONS_KIND_NIC);
+
     /* If the NetClientState belongs to a multiqueue backend, we will change all
      * other NetClientStates also.
      */
@@ -355,8 +357,6 @@ void qemu_del_net_client(NetClientState *nc)
         return;
     }
 
-    assert(nc->info->type != NET_CLIENT_OPTIONS_KIND_NIC);
-
     for (i = 0; i < queues; i++) {
         qemu_cleanup_net_client(ncs[i]);
         qemu_free_net_client(ncs[i]);
@@ -991,7 +991,7 @@ void hmp_host_net_remove(Monitor *mon, const QDict *qdict)
                      device, vlan_id);
         return;
     }
-    if (!net_host_check_device(nc->model)) {
+    if (nc->info->type == NET_CLIENT_OPTIONS_KIND_NIC) {
         error_report("invalid host network device '%s'", device);
         return;
     }
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PULL v5 2/2] tests: rtl8139: test timers and interrupt
  2015-03-12 20:13 [Qemu-devel] [PULL v5 0/2] Net patches Stefan Hajnoczi
  2015-03-12 20:13 ` [Qemu-devel] [PULL v5 1/2] net: synchronize net_host_device_remove with host_net_remove_completion Stefan Hajnoczi
@ 2015-03-12 20:13 ` Stefan Hajnoczi
  2015-03-13 11:50 ` [Qemu-devel] [PULL v5 0/2] Net patches Peter Maydell
  2 siblings, 0 replies; 4+ messages in thread
From: Stefan Hajnoczi @ 2015-03-12 20:13 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Frediano Ziglio, Stefan Hajnoczi

From: Frediano Ziglio <freddy77@gmail.com>

Test behaviour of timers and interrupts related to timeouts.

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Message-id: 1420742303-3030-1-git-send-email-freddy77@gmail.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 tests/Makefile       |   2 +-
 tests/rtl8139-test.c | 181 +++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 182 insertions(+), 1 deletion(-)

diff --git a/tests/Makefile b/tests/Makefile
index 588f438..1ef95c9 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -332,7 +332,7 @@ tests/tmp105-test$(EXESUF): tests/tmp105-test.o $(libqos-omap-obj-y)
 tests/i440fx-test$(EXESUF): tests/i440fx-test.o $(libqos-pc-obj-y)
 tests/fw_cfg-test$(EXESUF): tests/fw_cfg-test.o $(libqos-pc-obj-y)
 tests/e1000-test$(EXESUF): tests/e1000-test.o
-tests/rtl8139-test$(EXESUF): tests/rtl8139-test.o
+tests/rtl8139-test$(EXESUF): tests/rtl8139-test.o $(libqos-pc-obj-y)
 tests/pcnet-test$(EXESUF): tests/pcnet-test.o
 tests/eepro100-test$(EXESUF): tests/eepro100-test.o
 tests/vmxnet3-test$(EXESUF): tests/vmxnet3-test.o
diff --git a/tests/rtl8139-test.c b/tests/rtl8139-test.c
index f6a1be3..4e0bf02 100644
--- a/tests/rtl8139-test.c
+++ b/tests/rtl8139-test.c
@@ -10,19 +10,200 @@
 #include <glib.h>
 #include <string.h>
 #include "libqtest.h"
+#include "libqos/pci-pc.h"
 #include "qemu/osdep.h"
+#include "qemu-common.h"
 
 /* Tests only initialization so far. TODO: Replace with functional tests */
 static void nop(void)
 {
 }
 
+#define CLK 33000000
+#define NS_PER_SEC 1000000000ULL
+
+static QPCIBus *pcibus;
+static QPCIDevice *dev;
+static void *dev_base;
+
+static void save_fn(QPCIDevice *dev, int devfn, void *data)
+{
+    QPCIDevice **pdev = (QPCIDevice **) data;
+
+    *pdev = dev;
+}
+
+static QPCIDevice *get_device(void)
+{
+    QPCIDevice *dev;
+
+    pcibus = qpci_init_pc();
+    qpci_device_foreach(pcibus, 0x10ec, 0x8139, save_fn, &dev);
+    g_assert(dev != NULL);
+
+    return dev;
+}
+
+#define PORT(name, len, val) \
+static unsigned __attribute__((unused)) in_##name(void) \
+{ \
+    unsigned res = qpci_io_read##len(dev, dev_base+(val)); \
+    g_test_message("*%s -> %x\n", #name, res); \
+    return res; \
+} \
+static void out_##name(unsigned v) \
+{ \
+    g_test_message("%x -> *%s\n", v, #name); \
+    qpci_io_write##len(dev, dev_base+(val), v); \
+}
+
+PORT(Timer, l, 0x48)
+PORT(IntrMask, w, 0x3c)
+PORT(IntrStatus, w, 0x3E)
+PORT(TimerInt, l, 0x54)
+
+#define fatal(...) do { g_test_message(__VA_ARGS__); g_assert(0); } while (0)
+
+static void test_timer(void)
+{
+    const unsigned from = 0.95 * CLK;
+    const unsigned to = 1.6 * CLK;
+    unsigned prev, curr, next;
+    unsigned cnt, diff;
+
+    out_IntrMask(0);
+
+    in_IntrStatus();
+    in_Timer();
+    in_Timer();
+
+    /* Test 1. test counter continue and continue */
+    out_TimerInt(0); /* disable timer */
+    out_IntrStatus(0x4000);
+    out_Timer(12345); /* reset timer to 0 */
+    curr = in_Timer();
+    if (curr > 0.1 * CLK) {
+        fatal("time too big %u\n", curr);
+    }
+    for (cnt = 0; ; ) {
+        clock_step(1 * NS_PER_SEC);
+        prev = curr;
+        curr = in_Timer();
+
+        /* test skip is in a specific range */
+        diff = (curr-prev) & 0xffffffffu;
+        if (diff < from || diff > to) {
+            fatal("Invalid diff %u (%u-%u)\n", diff, from, to);
+        }
+        if (curr < prev && ++cnt == 3) {
+            break;
+        }
+    }
+
+    /* Test 2. Check we didn't get an interrupt with TimerInt == 0 */
+    if (in_IntrStatus() & 0x4000) {
+        fatal("got an interrupt\n");
+    }
+
+    /* Test 3. Setting TimerInt to 1 and Timer to 0 get interrupt */
+    out_TimerInt(1);
+    out_Timer(0);
+    clock_step(40);
+    if ((in_IntrStatus() & 0x4000) == 0) {
+        fatal("we should have an interrupt here!\n");
+    }
+
+    /* Test 3. Check acknowledge */
+    out_IntrStatus(0x4000);
+    if (in_IntrStatus() & 0x4000) {
+        fatal("got an interrupt\n");
+    }
+
+    /* Test. Status set after Timer reset */
+    out_Timer(0);
+    out_TimerInt(0);
+    out_IntrStatus(0x4000);
+    curr = in_Timer();
+    out_TimerInt(curr + 0.5 * CLK);
+    clock_step(1 * NS_PER_SEC);
+    out_Timer(0);
+    if ((in_IntrStatus() & 0x4000) == 0) {
+        fatal("we should have an interrupt here!\n");
+    }
+
+    /* Test. Status set after TimerInt reset */
+    out_Timer(0);
+    out_TimerInt(0);
+    out_IntrStatus(0x4000);
+    curr = in_Timer();
+    out_TimerInt(curr + 0.5 * CLK);
+    clock_step(1 * NS_PER_SEC);
+    out_TimerInt(0);
+    if ((in_IntrStatus() & 0x4000) == 0) {
+        fatal("we should have an interrupt here!\n");
+    }
+
+    /* Test 4. Increment TimerInt we should see an interrupt */
+    curr = in_Timer();
+    next = curr + 5.0 * CLK;
+    out_TimerInt(next);
+    for (cnt = 0; ; ) {
+        clock_step(1 * NS_PER_SEC);
+        prev = curr;
+        curr = in_Timer();
+        diff = (curr-prev) & 0xffffffffu;
+        if (diff < from || diff > to) {
+            fatal("Invalid diff %u (%u-%u)\n", diff, from, to);
+        }
+        if (cnt < 3 && curr > next) {
+            if ((in_IntrStatus() & 0x4000) == 0) {
+                fatal("we should have an interrupt here!\n");
+            }
+            out_IntrStatus(0x4000);
+            next = curr + 5.0 * CLK;
+            out_TimerInt(next);
+            if (++cnt == 3) {
+                out_TimerInt(1);
+            }
+        /* Test 5. Second time we pass from 0 should see an interrupt */
+        } else if (cnt >= 3 && curr < prev) {
+            /* here we should have an interrupt */
+            if ((in_IntrStatus() & 0x4000) == 0) {
+                fatal("we should have an interrupt here!\n");
+            }
+            out_IntrStatus(0x4000);
+            if (++cnt == 5) {
+                break;
+            }
+        }
+    }
+
+    g_test_message("Everythink is ok!\n");
+}
+
+
+static void test_init(void)
+{
+    uint64_t barsize;
+
+    dev = get_device();
+
+    dev_base = qpci_iomap(dev, 0, &barsize);
+
+    g_assert(dev_base != NULL);
+
+    qpci_device_enable(dev);
+
+    test_timer();
+}
+
 int main(int argc, char **argv)
 {
     int ret;
 
     g_test_init(&argc, &argv, NULL);
     qtest_add_func("/rtl8139/nop", nop);
+    qtest_add_func("/rtl8139/timer", test_init);
 
     qtest_start("-device rtl8139");
     ret = g_test_run();
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PULL v5 0/2] Net patches
  2015-03-12 20:13 [Qemu-devel] [PULL v5 0/2] Net patches Stefan Hajnoczi
  2015-03-12 20:13 ` [Qemu-devel] [PULL v5 1/2] net: synchronize net_host_device_remove with host_net_remove_completion Stefan Hajnoczi
  2015-03-12 20:13 ` [Qemu-devel] [PULL v5 2/2] tests: rtl8139: test timers and interrupt Stefan Hajnoczi
@ 2015-03-13 11:50 ` Peter Maydell
  2 siblings, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2015-03-13 11:50 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: QEMU Developers

On 12 March 2015 at 20:13, Stefan Hajnoczi <stefanha@redhat.com> wrote:
> v5:
>  * Drop rocker due to w32 warning and glib minimum version issue [Peter]
>
> v4:
>  * Drop clang 3.5.0 fixes since they break with older clang and w32 [Peter]
>
> v3:
>  * Add clang 3.5.0 warning fixes
>  * Squash David Ahern's clang struct definition warnings fix
>
> v2:
>  * Squash in Jiri's fix for rocker format string specifiers [Peter]
>  * Squash in Windows build fix [Peter]
>  * Both build fixes are described in "rocker: add new rocker switch device"
>
> The following changes since commit 2a5b58e2405e9fe42ba356b5a1b78146a4e9a659:
>
>   Merge remote-tracking branch 'remotes/kraxel/tags/pull-vnc-20150312-1' into staging (2015-03-12 10:35:54 +0000)
>
> are available in the git repository at:
>
>   git://github.com/stefanha/qemu.git tags/net-pull-request
>
> for you to fetch changes up to 069bb5831faf19d02041569580ad77565776bb1c:
>
>   tests: rtl8139: test timers and interrupt (2015-03-12 19:59:39 +0000)

Applied, thanks.

-- PMM

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-03-13 11:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-12 20:13 [Qemu-devel] [PULL v5 0/2] Net patches Stefan Hajnoczi
2015-03-12 20:13 ` [Qemu-devel] [PULL v5 1/2] net: synchronize net_host_device_remove with host_net_remove_completion Stefan Hajnoczi
2015-03-12 20:13 ` [Qemu-devel] [PULL v5 2/2] tests: rtl8139: test timers and interrupt Stefan Hajnoczi
2015-03-13 11:50 ` [Qemu-devel] [PULL v5 0/2] Net patches Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).