From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f46.google.com (mail-pa0-f46.google.com [209.85.220.46]) by dpdk.org (Postfix) with ESMTP id C3B1047CD for ; Thu, 22 Sep 2016 01:22:03 +0200 (CEST) Received: by mail-pa0-f46.google.com with SMTP id hm5so22798539pac.0 for ; Wed, 21 Sep 2016 16:22:03 -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=hwvH86x8sSm5NM8UQxEKiAvRbhYizUURzrDBqUfN8wc=; b=wfv7yw3zeMR1zz3eLDdL1c+hjWjQl0xqDL7qmY6dV6gjCyd+9eBJFUfnaKe2XscN2m YT77Vv5WQBHs3tJfnuNDyHc5JCYSzG+QawBgaLIYVFPQtN8qc9aY7PY0EmyhleRg0m5i UhgM1ubkoGYUwn5BG2vywqKkq2nN9g75vaPnnFHX4tLQP47/9hTFy9ziU9z2Kg1wsQ6M PRIyLS/bfYs9tK4SsXjVSQnNtSFr8TBilWWhjR3mWFJkJ3uDKVmHA4h/MxhvDA86WO7i DGSDGz73RaXBpOl4SwuRnqmLRFCiaN5SF+6KEQwR2D2fKzpc+hL8A7tlFL1L5x68Iu7F OzLw== 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-transfer-encoding; bh=hwvH86x8sSm5NM8UQxEKiAvRbhYizUURzrDBqUfN8wc=; b=AtEqMGmmX2Hr3moWrbssbOn2u0boP5wEEGdkH8KmyJgDxAQDk4itpHI4n2Whuzd5cM dcnKzH2CGV1AnO9TW76f3DIqvSMMvtaE5z+KvUYwz8prcDji7qTS5gQn+uzqSG0M8OHX ozAnmYMp7C9E06Gt5Lh5xgQCQYmQPOVFj8NqcCD5SeJ5HniLYtg1t3nvrRYSUYCavi8p Gzer67/1rM3ejZIFWncPJD2y8xXUQcfFxgfbE5FoqtK21XEWF+7DitgFiC0c3yiUUxmW VRz9ncAbHA5itsgYW6JhmwgL0ZxXIwlaGHM9oe+M1rQ/TlGZeXqSLB2dvEsB6pfUv/M3 Pb/Q== X-Gm-Message-State: AE9vXwMITYNHFzygBZzcWxWo+V2P7HuTX9W60b8tS/4aiiJIUibLUBFD6bowBShZLPYM3g== X-Received: by 10.66.97.72 with SMTP id dy8mr69060955pab.114.1474500123144; Wed, 21 Sep 2016 16:22:03 -0700 (PDT) Received: from xeon-e3 (static-50-53-69-251.bvtn.or.frontiernet.net. [50.53.69.251]) by smtp.gmail.com with ESMTPSA id zb14sm43417658pac.4.2016.09.21.16.22.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 21 Sep 2016 16:22:02 -0700 (PDT) Date: Wed, 21 Sep 2016 16:22:13 -0700 From: Stephen Hemminger To: Dey Cc: , , Message-ID: <20160921162213.4b79d1ce@xeon-e3> In-Reply-To: <20160921231147.26820-1-sodey@sonusnet.com> References: <20160921231147.26820-1-sodey@sonusnet.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v6] net/virtio: add set_mtu in virtio 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 Sep 2016 23:22:04 -0000 On Wed, 21 Sep 2016 19:11:47 -0400 Dey wrote: > > + > +#define VLAN_TAG_SIZE 4 /* 802.3ac tag (not DMA'd) */ > + > +static int virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) > +{ > + struct rte_eth_dev_info dev_info; > + uint32_t ether_hdr_len = ETHER_HDR_LEN + ETHER_CRC_LEN + VLAN_TAG_SIZE; > + uint32_t frame_size = mtu + ether_hdr_len; > + > + virtio_dev_info_get(dev, &dev_info); > + > + if (mtu < ETHER_MIN_MTU || frame_size > dev_info.max_rx_pktlen) { > + PMD_INIT_LOG(ERR, "MTU should be between %d and %d\n", > + ETHER_MIN_MTU, > + (dev_info.max_rx_pktlen - ether_hdr_len)); > + return -EINVAL; > + } > + return 0; > +} I am fine with the general idea of this patch but: 1. Calling virtio_dev_info_get is needlessly wasteful when all you want is to access the max packet length. Since max_rx_pktlen is always VIRTIO_MAX_RX_PKTLEN, please just use that. 2. Defining VLAN_TAG_SIZE is irrelevant if doing vlan offload. 3. Virtio doesn't insert CRC, therefore CRC_LEN is irrelevant