From patchwork Fri Feb 1 10:03:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Freimann X-Patchwork-Id: 50110 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2F4601B4AD; Fri, 1 Feb 2019 11:03:56 +0100 (CET) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 1D6241B4AB for ; Fri, 1 Feb 2019 11:03:55 +0100 (CET) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 62973A0BF5; Fri, 1 Feb 2019 10:03:54 +0000 (UTC) Received: from localhost (unknown [10.36.118.114]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 920FB5D6AA; Fri, 1 Feb 2019 10:03:49 +0000 (UTC) From: Jens Freimann To: dev@dpdk.org Cc: tiwei.bie@intel.com, maxime.coquelin@redhat.com Date: Fri, 1 Feb 2019 11:03:48 +0100 Message-Id: <20190201100348.6730-1-jfreimann@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 01 Feb 2019 10:03:54 +0000 (UTC) Subject: [dpdk-dev] [PATCH v4] net/virtio: set offload flag for jumbo frames 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" Port configuration fails because offload flags don't match the expected value when max-pkt-len is set to a value that should enable receive port offloading but doesn't. There are two cases to consider: 1. VIRTIO_NET_F_MTU is set. Then we need to check if the requested max-pkt-len fits into the MTU plus header. If yes we set the offload flag. 2. VIRTIO_NET_F_MTU is not set. We can set the offload flag. Fixes: a4996bd89c42 ("ethdev: new Rx/Tx offloads API") Cc: stable@dpdk.org Signed-off-by: Jens Freimann --- v3->v4: * make use of hw-max_mtu which is calculated during device init. This way we don't have to re-read the mtu from config space again. This is safe because hw->max_mtu is not changed after init. v2->v3: * remove unnecessary brackets (Maxime) * fix commit message (David) v1->v2: * include virtnet hdr, ethernet header, vlan tag when comparing against max-rx-pkt-len (Maxime) drivers/net/virtio/virtio_ethdev.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index 7c4c1df00..4cf91909d 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -2351,6 +2351,16 @@ virtio_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) if ((host_features & tso_mask) == tso_mask) dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_TCP_LRO; + if (host_features & (1ULL << VIRTIO_NET_F_MTU)) { + uint32_t ether_hdr_len = ETHER_HDR_LEN + VLAN_TAG_LEN + + hw->vtnet_hdr_size; + if (dev->data->dev_conf.rxmode.max_rx_pkt_len <= + hw->max_mtu + ether_hdr_len) + dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_JUMBO_FRAME; + } else { + dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_JUMBO_FRAME; + } + dev_info->tx_offload_capa = DEV_TX_OFFLOAD_MULTI_SEGS | DEV_TX_OFFLOAD_VLAN_INSERT; if (host_features & (1ULL << VIRTIO_NET_F_CSUM)) {