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 D7817A0613 for ; Mon, 23 Sep 2019 18:06:28 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B19E61BF0A; Mon, 23 Sep 2019 18:06:27 +0200 (CEST) Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) by dpdk.org (Postfix) with ESMTP id 0B1671BEFA for ; Mon, 23 Sep 2019 18:06:26 +0200 (CEST) Received: by mail-pl1-f194.google.com with SMTP id t10so6693734plr.8 for ; Mon, 23 Sep 2019 09:06:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rHmY1MQ4ExNJk9NDd0AAwXBidoTvfvys+KZGT2uXQAs=; b=09FxR08rcd1NO5VRWGdTP0bLuv33iw2O5T5Fxh1k82uuP6dJX+8RpFTmg+DN95w+7y jLEgy4iY2dpjpAZwYo0AjBaxZlqMwBM9xik/RvXzmBsFvomKgLacUT8cLBZg2pW21ayz Etq9/94CU/60VUXPAQ3+Y/qpg+4ypm9yCgbLQldOM3GmfDB8HTzajA/zM2wfdveyoubr Qu5zSHRe+LIWPcOSeyLTfyTN7AQb51DlzYbj4ADjpYK/hilfA8x4ijpN8pYUtpkfN0DB I9VU8n6kyI49gplUzbsVBiRFSZQhKXRo+2RTgTm3Ew4XdZSSS1znoQYJCrmKv2ztZ5jk SBaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rHmY1MQ4ExNJk9NDd0AAwXBidoTvfvys+KZGT2uXQAs=; b=YhzCytJ+02+wKQvhJi0uWFMkqbl7jmtkYQ13PVxeGjh/YYJGDRnoTaBSYLFwVC8ZIQ TuLLIOV0jMhG0cMVgAUJxwYN5h3/snyoCFhbSnL2GVnKQxXfQLWBk+DzskRC0o8bG1+w oOCM6oEjbp3UDjmwBUPAdohxqnGm8ElcAh65zB5DXKP1IEaywgN8lBN9/z2XTinY1Agq 3e+api2Kh1oc03AE+CIi8zfMH2Qy7jibhNSiczroguwaCdrMtox0pGzfbU1XAftkGkRd nLFcZdlkALhz9RCW1eyZr6FWZDKvC2Hnm0p5V8A6Qqz8ka6NInfSIMNc2Zfw/4UCdTXN b/Vw== X-Gm-Message-State: APjAAAXOYsLhyMNNDBO/Y6FA/y7kPdFzMHjMDRvkXACwInuoREBceuxt BEzhmTn2wnktQA9hmcF+VDuZ5w== X-Google-Smtp-Source: APXvYqwuWyr2Uv8S4bRz48mb1DyRmrSRhx4aG5BwbfR97k25gu9satAtAXjTABzM2qBECcZjInqzdg== X-Received: by 2002:a17:902:850a:: with SMTP id bj10mr519891plb.254.1569254785029; Mon, 23 Sep 2019 09:06:25 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id v1sm4647339pfg.26.2019.09.23.09.06.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Sep 2019 09:06:24 -0700 (PDT) Date: Mon, 23 Sep 2019 09:06:21 -0700 From: Stephen Hemminger To: Marvin Liu Cc: tiwei.bie@intel.com, maxime.coquelin@redhat.com, dev@dpdk.org Message-ID: <20190923090621.5dafbab4@hermes.lan> In-Reply-To: <20190905161421.55981-2-yong.liu@intel.com> References: <20190905161421.55981-1-yong.liu@intel.com> <20190905161421.55981-2-yong.liu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v1 01/14] vhost: add single packet enqueue function 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" This code could be more concise. > +/* > + * Returns -1 on fail, 0 on success > + */ That is standard convention, and probably doesn't need a comment. > +static inline int > +vhost_enqueue_single_packed(struct virtio_net *dev, struct vhost_virtqueue *vq, > + struct rte_mbuf *pkt, struct buf_vector *buf_vec, uint16_t *nr_descs) > +{ > + uint16_t nr_vec = 0; > + > + uint16_t avail_idx; > + uint16_t max_tries, tries = 0; > + > + uint16_t buf_id = 0; > + uint32_t len = 0; > + uint16_t desc_count; You don't need extra blank lines in declarations. > + > + uint32_t size = pkt->pkt_len + dev->vhost_hlen; > + avail_idx = vq->last_avail_idx; > + > + if (rxvq_is_mergeable(dev)) > + max_tries = vq->size - 1; > + else > + max_tries = 1; > + > + uint16_t num_buffers = 0; > + > + while (size > 0) { > + /* > + * if we tried all available ring items, and still > + * can't get enough buf, it means something abnormal > + * happened. > + */ > + if (unlikely(++tries > max_tries)) > + return -1; > + > + if (unlikely(fill_vec_buf_packed(dev, vq, > + avail_idx, &desc_count, > + buf_vec, &nr_vec, > + &buf_id, &len, > + VHOST_ACCESS_RW) < 0)) { > + return -1; > + } Brackets are not necessary on single statement return. > + len = RTE_MIN(len, size); > + > + size -= len; No need for blank line in between. > + > + avail_idx += desc_count; > + if (avail_idx >= vq->size) > + avail_idx -= vq->size; > + > + *nr_descs += desc_count; > + num_buffers += 1; > + } > + > + if (copy_mbuf_to_desc(dev, vq, pkt, > + buf_vec, nr_vec, > + num_buffers) < 0) { > + return 0; > + } > + > + return 0; > +} > + > +