From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: Re: [PATCH v6] net/virtio: add set_mtu in virtio Date: Wed, 21 Sep 2016 16:22:13 -0700 Message-ID: <20160921162213.4b79d1ce@xeon-e3> References: <20160921231147.26820-1-sodey@sonusnet.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: , , To: Dey 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) In-Reply-To: <20160921231147.26820-1-sodey@sonusnet.com> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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