diff mbox

[04/12] net: Add a network device specific self-announcement ability

Message ID 1495649128-10529-5-git-send-email-vyasevic@redhat.com
State New
Headers show

Commit Message

Vlad Yasevich May 24, 2017, 6:05 p.m. UTC
Some network devices have a capability to do self annoucements
(ex: virtio-new).  Add infrustrcture that would allow devices
to expose this ability.

Signed-off-by: Vladislav Yasevich <vyasevic@redhat.com>
---
 include/net/net.h  | 2 ++
 migration/savevm.c | 6 ++++++
 2 files changed, 8 insertions(+)

Comments

Jason Wang May 26, 2017, 4:17 a.m. UTC | #1
On 2017年05月25日 02:05, Vladislav Yasevich wrote:
> Some network devices have a capability to do self annoucements
> (ex: virtio-new).

I thought you mean "virtio-net" here.

> Add infrustrcture that would allow devices
> to expose this ability.
>
> Signed-off-by: Vladislav Yasevich <vyasevic@redhat.com>
> ---
>   include/net/net.h  | 2 ++
>   migration/savevm.c | 6 ++++++
>   2 files changed, 8 insertions(+)
>
> diff --git a/include/net/net.h b/include/net/net.h
> index 99b28d5..598f523 100644
> --- a/include/net/net.h
> +++ b/include/net/net.h
> @@ -64,6 +64,7 @@ typedef int (SetVnetLE)(NetClientState *, bool);
>   typedef int (SetVnetBE)(NetClientState *, bool);
>   typedef struct SocketReadState SocketReadState;
>   typedef void (SocketReadStateFinalize)(SocketReadState *rs);
> +typedef void (NetAnnounce)(NetClientState *);
>   
>   typedef struct NetClientInfo {
>       NetClientDriver type;
> @@ -84,6 +85,7 @@ typedef struct NetClientInfo {
>       SetVnetHdrLen *set_vnet_hdr_len;
>       SetVnetLE *set_vnet_le;
>       SetVnetBE *set_vnet_be;
> +    NetAnnounce *announce;
>   } NetClientInfo;
>   
>   struct NetClientState {
> diff --git a/migration/savevm.c b/migration/savevm.c
> index 555157a..a4097c9 100644
> --- a/migration/savevm.c
> +++ b/migration/savevm.c
> @@ -207,9 +207,15 @@ static void qemu_announce_self_iter(NICState *nic, void *opaque)
>       int len;
>   
>       trace_qemu_announce_self_iter(qemu_ether_ntoa(&nic->conf->macaddr));
> +
>       len = announce_self_create(buf, nic->conf->macaddr.a);
>   
>       qemu_send_packet_raw(qemu_get_queue(nic), buf, len);
> +
> +    /* if the NIC provides it's own announcement support, use it as well */
> +    if (nic->ncs->info->announce) {
> +        nic->ncs->info->announce(nic->ncs);
> +    }
>   }
>   
>   static void qemu_announce_self_once(void *opaque)

Reviewed-by: Jason Wang <jasowang@redhat.com>
diff mbox

Patch

diff --git a/include/net/net.h b/include/net/net.h
index 99b28d5..598f523 100644
--- a/include/net/net.h
+++ b/include/net/net.h
@@ -64,6 +64,7 @@  typedef int (SetVnetLE)(NetClientState *, bool);
 typedef int (SetVnetBE)(NetClientState *, bool);
 typedef struct SocketReadState SocketReadState;
 typedef void (SocketReadStateFinalize)(SocketReadState *rs);
+typedef void (NetAnnounce)(NetClientState *);
 
 typedef struct NetClientInfo {
     NetClientDriver type;
@@ -84,6 +85,7 @@  typedef struct NetClientInfo {
     SetVnetHdrLen *set_vnet_hdr_len;
     SetVnetLE *set_vnet_le;
     SetVnetBE *set_vnet_be;
+    NetAnnounce *announce;
 } NetClientInfo;
 
 struct NetClientState {
diff --git a/migration/savevm.c b/migration/savevm.c
index 555157a..a4097c9 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -207,9 +207,15 @@  static void qemu_announce_self_iter(NICState *nic, void *opaque)
     int len;
 
     trace_qemu_announce_self_iter(qemu_ether_ntoa(&nic->conf->macaddr));
+
     len = announce_self_create(buf, nic->conf->macaddr.a);
 
     qemu_send_packet_raw(qemu_get_queue(nic), buf, len);
+
+    /* if the NIC provides it's own announcement support, use it as well */
+    if (nic->ncs->info->announce) {
+        nic->ncs->info->announce(nic->ncs);
+    }
 }
 
 static void qemu_announce_self_once(void *opaque)