From patchwork Wed Oct 21 13:25:26 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 36560 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 54ACDB7F90 for ; Thu, 22 Oct 2009 01:04:42 +1100 (EST) Received: from localhost ([127.0.0.1]:42443 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N0bnr-00053Z-95 for incoming@patchwork.ozlabs.org; Wed, 21 Oct 2009 10:04:39 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N0bCU-0007u7-Km for qemu-devel@nongnu.org; Wed, 21 Oct 2009 09:26:02 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N0bCP-0007mA-FR for qemu-devel@nongnu.org; Wed, 21 Oct 2009 09:26:01 -0400 Received: from [199.232.76.173] (port=55717 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N0bCO-0007lc-Rw for qemu-devel@nongnu.org; Wed, 21 Oct 2009 09:25:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57317) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N0bCM-0007PG-QH for qemu-devel@nongnu.org; Wed, 21 Oct 2009 09:25:55 -0400 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n9LDPrSH028935 for ; Wed, 21 Oct 2009 09:25:53 -0400 Received: from zweiblum.home.kraxel.org (vpn2-9-113.ams2.redhat.com [10.36.9.113]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id n9LDPo5S019861; Wed, 21 Oct 2009 09:25:51 -0400 Received: by zweiblum.home.kraxel.org (Postfix, from userid 500) id D45B37010C; Wed, 21 Oct 2009 15:25:43 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Wed, 21 Oct 2009 15:25:26 +0200 Message-Id: <1256131543-28416-6-git-send-email-kraxel@redhat.com> In-Reply-To: <1256131543-28416-1-git-send-email-kraxel@redhat.com> References: <1256131543-28416-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH 05/22] qdev/net: common nic property bits X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Add a new type for properties common to all nics. Add helper functions and macros to deal with it. Signed-off-by: Gerd Hoffmann --- hw/qdev.c | 9 +++++++++ net.h | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 0 deletions(-) diff --git a/hw/qdev.c b/hw/qdev.c index 20f931c..b32dbfc 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -383,6 +383,15 @@ void qdev_get_macaddr(DeviceState *dev, uint8_t *macaddr) memcpy(macaddr, dev->nd->macaddr, 6); } +void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd) +{ + qdev_prop_set_macaddr(dev, "mac", nd->macaddr); + if (nd->vlan) + qdev_prop_set_vlan(dev, "vlan", nd->vlan); + if (nd->netdev) + qdev_prop_set_netdev(dev, "netdev", nd->netdev); +} + static int next_block_unit[IF_COUNT]; /* Get a block device. This should only be used for single-drive devices diff --git a/net.h b/net.h index 6a24f55..f2d10f0 100644 --- a/net.h +++ b/net.h @@ -11,6 +11,19 @@ struct MACAddr { uint8_t a[6]; }; +/* qdev nic properties */ + +typedef struct NICConf { + MACAddr macaddr; + VLANState *vlan; + VLANClientState *peer; +} NICConf; + +#define DEFINE_NIC_PROPERTIES(_state, _conf) \ + DEFINE_PROP_MACADDR("mac", _state, _conf.macaddr), \ + DEFINE_PROP_VLAN("vlan", _state, _conf.vlan), \ + DEFINE_PROP_NETDEV("netdev", _state, _conf.peer) + /* VLANs support */ typedef int (NetCanReceive)(VLANClientState *); @@ -158,5 +171,6 @@ VLANClientState *qdev_get_vlan_client(DeviceState *dev, NetReceiveIOV *receive_iov, NetCleanup *cleanup, void *opaque); +void qdev_set_nic_properties(DeviceState *dev, NICInfo *nd); #endif