From patchwork Sat Jul 30 01:22:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniele Di Proietto X-Patchwork-Id: 654246 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (archives.nicira.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id 3s1SY36nrQz9sxS for ; Sat, 30 Jul 2016 11:23:51 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 7DDF51145F; Fri, 29 Jul 2016 18:23:23 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx1e4.cudamail.com (mx1.cudamail.com [69.90.118.67]) by archives.nicira.com (Postfix) with ESMTPS id A28B410CD1 for ; Fri, 29 Jul 2016 18:23:18 -0700 (PDT) Received: from bar5.cudamail.com (unknown [192.168.21.12]) by mx1e4.cudamail.com (Postfix) with ESMTPS id 207041E02C8 for ; Fri, 29 Jul 2016 19:23:18 -0600 (MDT) X-ASG-Debug-ID: 1469841797-09eadd39d486b80001-byXFYA Received: from mx3-pf2.cudamail.com ([192.168.14.1]) by bar5.cudamail.com with ESMTP id 86SJky84u3zBXlFM (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 29 Jul 2016 19:23:17 -0600 (MDT) X-Barracuda-Envelope-From: diproiettod@vmware.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.14.1 Received: from unknown (HELO EX13-EDG-OU-001.vmware.com) (208.91.0.189) by mx3-pf2.cudamail.com with ESMTPS (AES256-SHA encrypted); 30 Jul 2016 01:23:17 -0000 Received-SPF: error (mx3-pf2.cudamail.com: error in processing during lookup of vmware.com: DNS problem) Received: from sc9-mailhost1.vmware.com (10.113.161.71) by EX13-EDG-OU-001.vmware.com (10.113.208.155) with Microsoft SMTP Server id 15.0.1156.6; Fri, 29 Jul 2016 18:22:31 -0700 Received: from sc9-mailhost2.vmware.com (htb-1n-eng-dhcp84.eng.vmware.com [10.33.74.84]) by sc9-mailhost1.vmware.com (Postfix) with ESMTP id 9C43A1857C; Fri, 29 Jul 2016 18:23:15 -0700 (PDT) X-CudaMail-Envelope-Sender: diproiettod@vmware.com From: Daniele Di Proietto To: X-CudaMail-Whitelist-To: dev@openvswitch.org X-CudaMail-MID: CM-V2-728050359 X-CudaMail-DTE: 072916 X-CudaMail-Originating-IP: 208.91.0.189 Date: Fri, 29 Jul 2016 18:22:48 -0700 X-ASG-Orig-Subj: [##CM-V2-728050359##][PATCH 3/7] netdev: Pass 'netdev_class' to ->run() and ->wait(). Message-ID: <1469841772-119013-3-git-send-email-diproiettod@vmware.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1469841772-119013-1-git-send-email-diproiettod@vmware.com> References: <1469841772-119013-1-git-send-email-diproiettod@vmware.com> MIME-Version: 1.0 Received-SPF: None (EX13-EDG-OU-001.vmware.com: diproiettod@vmware.com does not designate permitted sender hosts) X-Barracuda-Connect: UNKNOWN[192.168.14.1] X-Barracuda-Start-Time: 1469841797 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-ASG-Whitelist: Header =?UTF-8?B?eFwtY3VkYW1haWxcLXdoaXRlbGlzdFwtdG8=?= X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 Subject: [ovs-dev] [PATCH 3/7] netdev: Pass 'netdev_class' to ->run() and ->wait(). X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@openvswitch.org Sender: "dev" This will allow run() and wait() methods to be shared between different classes and still perform class-specific work. Signed-off-by: Daniele Di Proietto --- lib/netdev-bsd.c | 6 +++--- lib/netdev-dummy.c | 4 ++-- lib/netdev-linux.c | 6 +++--- lib/netdev-provider.h | 14 ++++++++++---- lib/netdev-vport.c | 4 ++-- lib/netdev.c | 4 ++-- 6 files changed, 22 insertions(+), 16 deletions(-) diff --git a/lib/netdev-bsd.c b/lib/netdev-bsd.c index 2bba0ed..75a330b 100644 --- a/lib/netdev-bsd.c +++ b/lib/netdev-bsd.c @@ -146,7 +146,7 @@ static void ifr_set_flags(struct ifreq *, int flags); static int af_link_ioctl(unsigned long command, const void *arg); #endif -static void netdev_bsd_run(void); +static void netdev_bsd_run(const struct netdev_class *); static int netdev_bsd_get_mtu(const struct netdev *netdev_, int *mtup); static bool @@ -180,7 +180,7 @@ netdev_get_kernel_name(const struct netdev *netdev) * interface status changes, and eventually calls all the user callbacks. */ static void -netdev_bsd_run(void) +netdev_bsd_run(const struct netdev_class *netdev_class OVS_UNUSED) { rtbsd_notifier_run(); } @@ -190,7 +190,7 @@ netdev_bsd_run(void) * be called. */ static void -netdev_bsd_wait(void) +netdev_bsd_wait(const struct netdev_class *netdev_class OVS_UNUSED) { rtbsd_notifier_wait(); } diff --git a/lib/netdev-dummy.c b/lib/netdev-dummy.c index a950409..2a6aa56 100644 --- a/lib/netdev-dummy.c +++ b/lib/netdev-dummy.c @@ -622,7 +622,7 @@ dummy_netdev_get_conn_state(struct dummy_packet_conn *conn) } static void -netdev_dummy_run(void) +netdev_dummy_run(const struct netdev_class *netdev_class OVS_UNUSED) { struct netdev_dummy *dev; @@ -636,7 +636,7 @@ netdev_dummy_run(void) } static void -netdev_dummy_wait(void) +netdev_dummy_wait(const struct netdev_class *netdev_class OVS_UNUSED) { struct netdev_dummy *dev; diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c index fa37bcf..1b5f7c1 100644 --- a/lib/netdev-linux.c +++ b/lib/netdev-linux.c @@ -526,7 +526,7 @@ static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 20); * changes in the device miimon status, so we can use atomic_count. */ static atomic_count miimon_cnt = ATOMIC_COUNT_INIT(0); -static void netdev_linux_run(void); +static void netdev_linux_run(const struct netdev_class *); static int netdev_linux_do_ethtool(const char *name, struct ethtool_cmd *, int cmd, const char *cmd_name); @@ -623,7 +623,7 @@ netdev_linux_miimon_enabled(void) } static void -netdev_linux_run(void) +netdev_linux_run(const struct netdev_class *netdev_class OVS_UNUSED) { struct nl_sock *sock; int error; @@ -697,7 +697,7 @@ netdev_linux_run(void) } static void -netdev_linux_wait(void) +netdev_linux_wait(const struct netdev_class *netdev_class OVS_UNUSED) { struct nl_sock *sock; diff --git a/lib/netdev-provider.h b/lib/netdev-provider.h index ae390cb..5bcfeba 100644 --- a/lib/netdev-provider.h +++ b/lib/netdev-provider.h @@ -236,15 +236,21 @@ struct netdev_class { int (*init)(void); /* Performs periodic work needed by netdevs of this class. May be null if - * no periodic work is necessary. */ - void (*run)(void); + * no periodic work is necessary. + * + * 'netdev_class' points to the class. It is useful in case the same + * function is used to implement different classes. */ + void (*run)(const struct netdev_class *netdev_class); /* Arranges for poll_block() to wake up if the "run" member function needs * to be called. Implementations are additionally required to wake * whenever something changes in any of its netdevs which would cause their * ->change_seq() function to change its result. May be null if nothing is - * needed here. */ - void (*wait)(void); + * needed here. + * + * 'netdev_class' points to the class. It is useful in case the same + * function is used to implement different classes. */ + void (*wait)(const struct netdev_class *netdev_class); /* ## ---------------- ## */ /* ## netdev Functions ## */ diff --git a/lib/netdev-vport.c b/lib/netdev-vport.c index 87a30f8..7eabd2c 100644 --- a/lib/netdev-vport.c +++ b/lib/netdev-vport.c @@ -321,7 +321,7 @@ netdev_vport_update_flags(struct netdev *netdev OVS_UNUSED, } static void -netdev_vport_run(void) +netdev_vport_run(const struct netdev_class *netdev_class OVS_UNUSED) { uint64_t seq; @@ -334,7 +334,7 @@ netdev_vport_run(void) } static void -netdev_vport_wait(void) +netdev_vport_wait(const struct netdev_class *netdev_class OVS_UNUSED) { uint64_t seq; diff --git a/lib/netdev.c b/lib/netdev.c index 75bf1cb..589d37c 100644 --- a/lib/netdev.c +++ b/lib/netdev.c @@ -160,7 +160,7 @@ netdev_run(void) struct netdev_registered_class *rc; CMAP_FOR_EACH (rc, cmap_node, &netdev_classes) { if (rc->class->run) { - rc->class->run(); + rc->class->run(rc->class); } } } @@ -178,7 +178,7 @@ netdev_wait(void) struct netdev_registered_class *rc; CMAP_FOR_EACH (rc, cmap_node, &netdev_classes) { if (rc->class->wait) { - rc->class->wait(); + rc->class->wait(rc->class); } } }