From patchwork Thu Mar 14 11:05:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hyong Youb Kim (hyonkim)" X-Patchwork-Id: 51178 X-Patchwork-Delegate: ferruh.yigit@amd.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 2C3584C9C; Thu, 14 Mar 2019 12:05:47 +0100 (CET) Received: from rcdn-iport-1.cisco.com (rcdn-iport-1.cisco.com [173.37.86.72]) by dpdk.org (Postfix) with ESMTP id 79BA12C28; Thu, 14 Mar 2019 12:05:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=2016; q=dns/txt; s=iport; t=1552561546; x=1553771146; h=from:to:cc:subject:date:message-id; bh=BBfwgl/k0ojyJWTC9U3NM8EVpDUg6P8JiASiobAIb58=; b=Ru7BTXdYKMFpHBwpnTH35GMxxs6qM6tFUhpo3qEwyYwwBc6l+8Z45s/A 1bv5f2+8uBJX+kO9gRO6DwtF1cXRmA0/aOoxO4H2d8fpjLDb+laXVyKzM HQsuKp6HWSMbbgPhKLjRxqWafLRcsrhMCCXUg9pqGbNNUtYiJXqsLibDG c=; X-IronPort-AV: E=Sophos;i="5.58,478,1544486400"; d="scan'208";a="535284668" Received: from alln-core-5.cisco.com ([173.36.13.138]) by rcdn-iport-1.cisco.com with ESMTP/TLS/DHE-RSA-SEED-SHA; 14 Mar 2019 11:05:45 +0000 Received: from cisco.com (savbu-usnic-a.cisco.com [10.193.184.48]) by alln-core-5.cisco.com (8.15.2/8.15.2) with ESMTP id x2EB5j4T013649; Thu, 14 Mar 2019 11:05:45 GMT Received: by cisco.com (Postfix, from userid 508933) id EFF0820F2001; Thu, 14 Mar 2019 04:05:44 -0700 (PDT) From: Hyong Youb Kim To: Ferruh Yigit Cc: dev@dpdk.org, John Daley , Hyong Youb Kim , stable@dpdk.org Date: Thu, 14 Mar 2019 04:05:32 -0700 Message-Id: <20190314110532.22638-1-hyonkim@cisco.com> X-Mailer: git-send-email 2.16.2 X-Outbound-SMTP-Client: 10.193.184.48, savbu-usnic-a.cisco.com X-Outbound-Node: alln-core-5.cisco.com Subject: [dpdk-dev] [PATCH] net/enic: fix max MTU calculation 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" The maximum packet length (max_pkt_len) from the firmware does not include CRC, so do not subtract 4 when deriving the max MTU. This change effectively increases the max MTU by 4B. Apps often assume max MTU = max_rx_pkt_len - 14 (ethernet header), and attempt to set the MTU to that value (i.e. set MTU to max HW value). This change incidentally allows such apps to change MTU to max value successfully. Fixes: bb34ffb848a0 ("net/enic: determine max egress packet size and max MTU") Cc: stable@dpdk.org Signed-off-by: Hyong Youb Kim Reviewed-by: John Daley --- drivers/net/enic/enic.h | 4 ++-- drivers/net/enic/enic_res.c | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/net/enic/enic.h b/drivers/net/enic/enic.h index fa4d5590e..9193fb038 100644 --- a/drivers/net/enic/enic.h +++ b/drivers/net/enic/enic.h @@ -203,8 +203,8 @@ struct enic { /* Compute ethdev's max packet size from MTU */ static inline uint32_t enic_mtu_to_max_rx_pktlen(uint32_t mtu) { - /* ethdev max size includes eth and crc whereas NIC MTU does not */ - return mtu + ETHER_HDR_LEN + ETHER_CRC_LEN; + /* ethdev max size includes eth whereas NIC MTU does not */ + return mtu + ETHER_HDR_LEN; } /* Get the CQ index from a Start of Packet(SOP) RQ index */ diff --git a/drivers/net/enic/enic_res.c b/drivers/net/enic/enic_res.c index d289f3da8..f7cbc90fb 100644 --- a/drivers/net/enic/enic_res.c +++ b/drivers/net/enic/enic_res.c @@ -61,10 +61,9 @@ int enic_get_vnic_config(struct enic *enic) * and will be 0 for legacy firmware and VICs */ if (c->max_pkt_size > ENIC_DEFAULT_RX_MAX_PKT_SIZE) - enic->max_mtu = c->max_pkt_size - (ETHER_HDR_LEN + 4); + enic->max_mtu = c->max_pkt_size - ETHER_HDR_LEN; else - enic->max_mtu = ENIC_DEFAULT_RX_MAX_PKT_SIZE - - (ETHER_HDR_LEN + 4); + enic->max_mtu = ENIC_DEFAULT_RX_MAX_PKT_SIZE - ETHER_HDR_LEN; if (c->mtu == 0) c->mtu = 1500;