From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f54.google.com (mail-pa0-f54.google.com [209.85.220.54]) by dpdk.org (Postfix) with ESMTP id 2F0B26A95 for ; Wed, 21 Oct 2015 06:43:45 +0200 (CEST) Received: by pabrc13 with SMTP id rc13so42549325pab.0 for ; Tue, 20 Oct 2015 21:43:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=XJjnPRXhllXXcnSIsuQBA5yy7WKR/NolaCHh51KaPfs=; b=M+QwmCOHohIr3h9R5djFtry+r1Esx9Dkb/pxJB9FLdpGsxvZw0bjc8p2yJvaVuzY7p uqG7Hzqu5PjfK1lRqEs+rLQQ+h0XVpwJykxUK7wCyxIdlIgRcReoI5ORJ1mWPkXkq/Zl ENmaN6xJF1yXUJxJ/U3B0d322Tfvq78NqXRbKdD/YYmKv3CSFo1NKxQFtQZn6HWzRNO/ uGnVGq5hxEg+I+1JYNjlPGSvEozCs+PZ5TUijIqLn76r0dTBx6ec64Y9Q2Gn1mvm4ys3 naq2j49TZ79JMc2jfxxbKnI9dMB9qHR+9KCpo922AwOrnTEeBilyiItd6dnagM0vBdGa 1Ekg== X-Gm-Message-State: ALoCoQlmcPvHspJbxm0S5gN54FvtS09lZL1Sc2kmP+uFKBnW7J8gk40NxH4c476d642h6+uTLqMC X-Received: by 10.66.184.203 with SMTP id ew11mr8148113pac.24.1445402624477; Tue, 20 Oct 2015 21:43:44 -0700 (PDT) Received: from xeon-e3 (static-50-53-82-155.bvtn.or.frontiernet.net. [50.53.82.155]) by smtp.gmail.com with ESMTPSA id bs3sm6577079pbd.89.2015.10.20.21.43.44 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Oct 2015 21:43:44 -0700 (PDT) Date: Tue, 20 Oct 2015 21:43:54 -0700 From: Stephen Hemminger To: Yuanhan Liu Message-ID: <20151020214354.12ac5ce1@xeon-e3> In-Reply-To: <1445399294-18826-5-git-send-email-yuanhan.liu@linux.intel.com> References: <1445399294-18826-1-git-send-email-yuanhan.liu@linux.intel.com> <1445399294-18826-5-git-send-email-yuanhan.liu@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: dev@dpdk.org, marcel@redhat.com, Changchun Ouyang , "Michael S. Tsirkin" Subject: Re: [dpdk-dev] [PATCH v7 4/8] vhost: rxtx: use queue id instead of constant ring index X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Oct 2015 04:43:45 -0000 On Wed, 21 Oct 2015 11:48:10 +0800 Yuanhan Liu wrote: > > +static inline int __attribute__((always_inline)) > +is_valid_virt_queue_idx(uint32_t virtq_idx, int is_tx, uint32_t max_qp_idx) > +{ > + if ((is_tx ^ (virtq_idx & 0x1)) || > + (virtq_idx >= max_qp_idx * VIRTIO_QNUM)) > + return 0; > + > + return 1; > +} minor nits: * this doesn't need to be marked as always inline, that is as they say in English "shooting a fly with a bazooka" * prefer to just return logical result rather than have conditional: * for booleans prefer the type boolean. static bool is_valid_virt_queue_idx(uint32_t virtq_idx, bool is_tx, uint32_t max_qp_idx) { return (is_tx ^ (virtq_idx & 1)) || virtq_idx >= max_qp_idx * VIRTIO_QNUM; }