From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 84400A04C1; Wed, 20 Nov 2019 03:46:11 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5166E343C; Wed, 20 Nov 2019 03:46:10 +0100 (CET) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id EF6BD3195; Wed, 20 Nov 2019 03:46:07 +0100 (CET) X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Nov 2019 18:46:06 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,220,1571727600"; d="scan'208";a="231779375" Received: from dpdk-virtio-tbie-2.sh.intel.com (HELO ___) ([10.67.104.74]) by fmsmga004.fm.intel.com with ESMTP; 19 Nov 2019 18:46:05 -0800 Date: Wed, 20 Nov 2019 10:46:42 +0800 From: Tiwei Bie To: Stephen Hemminger Cc: dev@dpdk.org, maxime.coquelin@redhat.com, zhihong.wang@intel.com, stable@dpdk.org Message-ID: <20191120024642.GA24170@___> References: <20191119062948.15834-1-tiwei.bie@intel.com> <20191119083638.37097fa4@hermes.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20191119083638.37097fa4@hermes.lan> User-Agent: Mutt/1.9.4 (2018-02-28) Subject: Re: [dpdk-dev] [PATCH 20.02] net/virtio-user: do not close tap when disabling queue pairs X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Tue, Nov 19, 2019 at 08:36:38AM -0800, Stephen Hemminger wrote: > On Tue, 19 Nov 2019 14:29:48 +0800 > Tiwei Bie wrote: > > > -static int > > +int > > +vhost_kernel_tap_attach_queue(int fd) > > +{ > > + struct ifreq ifr; > > + > > + memset(&ifr, 0, sizeof(ifr)); > > + ifr.ifr_flags = IFF_ATTACH_QUEUE; > > + return ioctl(fd, TUNSETQUEUE, (void *)&ifr); > > +} > > + > > +int > > +vhost_kernel_tap_detach_queue(int fd) > > +{ > > + struct ifreq ifr; > > + > > + memset(&ifr, 0, sizeof(ifr)); > > + ifr.ifr_flags = IFF_DETACH_QUEUE; > > + return ioctl(fd, TUNSETQUEUE, (void *)&ifr); > > +} > > + > > These both could be squashed into one routine. > > int > vhost_kernel_tap_set_queue(int fd, bool attach) > { > struct ifreq ifr = { > .ifr_flags = attach ? IFF_ATTACH_QUEUE : IFF_DETACH_QUEUE > }; > > return ioctl(fd, TUNSETQUEUE, &ifr); > } > > 1. Use initializer instead of memset > 2. Cast to void * is unnecessary Thanks! Will do it in v2. Regards, Tiwei