From patchwork Mon Aug 21 17:16:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Nguyen X-Patchwork-Id: 13359688 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0B9B28C1E for ; Mon, 21 Aug 2023 17:23:44 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82774EE for ; Mon, 21 Aug 2023 10:23:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1692638622; x=1724174622; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=djQgZ2ODSqQVYzFXQHbxXS3UiU8FkJquXrHds7tfzRM=; b=Ydqx/jB0R5S9ZSRh60SA1mlwyT89O+6X3p7L6sg2FE6B3kCja5Yx3aEX JRQX15tkMcbDQWnosYNOHKZiNzvNX/DimYR7Ff5MGQpwYBTUixDx8EEAn xqgPfMEv6VuC0sKE4YfatE1X/HD33UtEnMWgnNgWWu4EkrYw54IAB52rV 3BL+IOqk43hSa7BSqOfIK+PxslcMcBZXVne/7cIqp3tdkktWh2OnYYEfU 0TA2oBhp3YCBUaqPgt+Ki0Yi/flToNKAFNuNKeQ5x+BHPZ1bKz8Fecoqi UlTSNsFEtll+HWAm1IF13DyCYquTBJ5X8lKd77Dve2g0Io5Cy42hdGIzz A==; X-IronPort-AV: E=McAfee;i="6600,9927,10809"; a="404658876" X-IronPort-AV: E=Sophos;i="6.01,190,1684825200"; d="scan'208";a="404658876" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Aug 2023 10:23:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10809"; a="909782082" X-IronPort-AV: E=Sophos;i="6.01,190,1684825200"; d="scan'208";a="909782082" Received: from anguy11-upstream.jf.intel.com ([10.166.9.133]) by orsmga005.jf.intel.com with ESMTP; 21 Aug 2023 10:23:40 -0700 From: Tony Nguyen To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, netdev@vger.kernel.org Cc: Jesse Brandeburg , anthony.l.nguyen@intel.com, Przemek Kitszel , Leon Romanovsky , Pucha Himasekhar Reddy Subject: [PATCH net 1/3] ice: fix receive buffer size miscalculation Date: Mon, 21 Aug 2023 10:16:31 -0700 Message-Id: <20230821171633.2203505-2-anthony.l.nguyen@intel.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230821171633.2203505-1-anthony.l.nguyen@intel.com> References: <20230821171633.2203505-1-anthony.l.nguyen@intel.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Jesse Brandeburg The driver is misconfiguring the hardware for some values of MTU such that it could use multiple descriptors to receive a packet when it could have simply used one. Change the driver to use a round-up instead of the result of a shift, as the shift can truncate the lower bits of the size, and result in the problem noted above. It also aligns this driver with similar code in i40e. The insidiousness of this problem is that everything works with the wrong size, it's just not working as well as it could, as some MTU sizes end up using two or more descriptors, and there is no way to tell that is happening without looking at ice_trace or a bus analyzer. Fixes: efc2214b6047 ("ice: Add support for XDP") Reviewed-by: Przemek Kitszel Signed-off-by: Jesse Brandeburg Reviewed-by: Leon Romanovsky Tested-by: Pucha Himasekhar Reddy (A Contingent worker at Intel) Signed-off-by: Tony Nguyen --- drivers/net/ethernet/intel/ice/ice_base.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/ice/ice_base.c b/drivers/net/ethernet/intel/ice/ice_base.c index b678bdf96f3a..074bf9403cd1 100644 --- a/drivers/net/ethernet/intel/ice/ice_base.c +++ b/drivers/net/ethernet/intel/ice/ice_base.c @@ -435,7 +435,8 @@ static int ice_setup_rx_ctx(struct ice_rx_ring *ring) /* Receive Packet Data Buffer Size. * The Packet Data Buffer Size is defined in 128 byte units. */ - rlan_ctx.dbuf = ring->rx_buf_len >> ICE_RLAN_CTX_DBUF_S; + rlan_ctx.dbuf = DIV_ROUND_UP(ring->rx_buf_len, + BIT_ULL(ICE_RLAN_CTX_DBUF_S)); /* use 32 byte descriptors */ rlan_ctx.dsize = 1;