Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1653299pxy; Mon, 2 Aug 2021 07:08:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwOlIb/QchbQQqarOgLhlAA905ZOLOXfrT8Ip7M6y5DtSeZEwgxHaK5j0+DmDXJDsqfG3dh X-Received: by 2002:a5e:8d03:: with SMTP id m3mr1063579ioj.200.1627913311372; Mon, 02 Aug 2021 07:08:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627913311; cv=none; d=google.com; s=arc-20160816; b=iGncLcos91dAQYZf/mb/6t8TylMtRJw80BK4xDQP6a5HXFdiG7KVGPKkTccua9d3Jl VWVKRcqzOr83y08ohHs43ViOo8cUgKC/U4G+9dBQV1yShAlEoFJsTf1ycBgOdpHh3UnU PmlODI/w33zwUxpiEf80pjAZI1GBsaLeU3yyiXXWTAYso+4VyohrvJS0wsIt/RqpUpzA s14CnjW+JZ9AsBHdICAjNvAlb9dHkI3xWIVBvnVRyx2QXQmFP48i5ZTpumGtpOH+hIXX lQnFWHlIUHBfAXyzF1mUxUPVURnlXsxh2NsGxtUYC/GOX59WZBpLYT5LNQgiAxp80N6u mDRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vXnplWdf0EDFNsX4YuLP3HTU3tUWa9blnSdYhbSyhuU=; b=QUvSgCBmdtLEp/jCYyZzSI5MqqALpUWGpJty8I3leNHNBoqpoB1qCn8kfVkWWyf1ha N8m8ll/bIIGMkHRPgn1IrIrscrtj5TZRk8uLfxFtoPi7/yIAsVdYD1fwMbf+wkmw40Iy tX8zgubm5gAZi0OCdloMkO4A05lOclhiErBLrnR+tH6aTyf5q3gbizuZsN9j1E8EEKLU /6T8Xip517PebingZxe8A2/IOJwTdYIKt5s5HHyY6bi2fZ2TkwYAO529JtxHGFslfbrp kgGTdOqG2+1ABwgbyUBWLb/2fJtwy1cc5BjdWfz0TQKnlY2rssYd8T6+FduSR3jgJEp2 5XiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HTo4Hedi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ay15si437669iob.13.2021.08.02.07.08.20; Mon, 02 Aug 2021 07:08:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HTo4Hedi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236744AbhHBOGl (ORCPT + 99 others); Mon, 2 Aug 2021 10:06:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:43958 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236883AbhHBOAB (ORCPT ); Mon, 2 Aug 2021 10:00:01 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7FD9861139; Mon, 2 Aug 2021 13:56:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627912562; bh=+1StPr8qD/al7FgqxGtqSPUkrtMv6cx6dNONqzpHg88=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HTo4HediD7eb2Gs+3dmiLsm2Jb0WDQdJdvrjuvQiD7Pw8A6MMSWXgSdoQ50PE68mY CiN9ebZWxzJaWNZ5Gq76okRcFZlDhZ8H8sNkv7xsP2wsYQPKFw6nkSWxWbmQs4Lpef OtkR8g9g7i98vgtxtZlZkuSe4/H++dMNVp8T0nMM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arkadiusz Kubalewski , Jedrzej Jagielski , Imam Hassan Reza Biswas , Tony Nguyen , Sasha Levin Subject: [PATCH 5.13 047/104] i40e: Fix queue-to-TC mapping on Tx Date: Mon, 2 Aug 2021 15:44:44 +0200 Message-Id: <20210802134345.577711895@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210802134344.028226640@linuxfoundation.org> References: <20210802134344.028226640@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jedrzej Jagielski [ Upstream commit 89ec1f0886c127c7e41ac61a6b6d539f4fb2510b ] In SW DCB mode the packets sent receive incorrect UP tags. They are constructed correctly and put into tx_ring, but UP is later remapped by HW on the basis of TCTUPR register contents according to Tx queue selected, and BW used is consistent with the new UP values. This is caused by Tx queue selection in kernel not taking into account DCB configuration. This patch fixes the issue by implementing the ndo_select_queue NDO callback. Fixes: fd0a05ce74ef ("i40e: transmit, receive, and NAPI") Signed-off-by: Arkadiusz Kubalewski Signed-off-by: Jedrzej Jagielski Tested-by: Imam Hassan Reza Biswas Signed-off-by: Tony Nguyen Signed-off-by: Sasha Levin --- drivers/net/ethernet/intel/i40e/i40e_main.c | 1 + drivers/net/ethernet/intel/i40e/i40e_txrx.c | 50 +++++++++++++++++++++ drivers/net/ethernet/intel/i40e/i40e_txrx.h | 2 + 3 files changed, 53 insertions(+) diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c index 951423e5f2c0..0207c5ceecf6 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_main.c +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c @@ -13271,6 +13271,7 @@ static const struct net_device_ops i40e_netdev_ops = { .ndo_poll_controller = i40e_netpoll, #endif .ndo_setup_tc = __i40e_setup_tc, + .ndo_select_queue = i40e_lan_select_queue, .ndo_set_features = i40e_set_features, .ndo_set_vf_mac = i40e_ndo_set_vf_mac, .ndo_set_vf_vlan = i40e_ndo_set_vf_port_vlan, diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.c b/drivers/net/ethernet/intel/i40e/i40e_txrx.c index b883ab809df3..107fb472319e 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_txrx.c +++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.c @@ -3633,6 +3633,56 @@ dma_error: return -1; } +static u16 i40e_swdcb_skb_tx_hash(struct net_device *dev, + const struct sk_buff *skb, + u16 num_tx_queues) +{ + u32 jhash_initval_salt = 0xd631614b; + u32 hash; + + if (skb->sk && skb->sk->sk_hash) + hash = skb->sk->sk_hash; + else + hash = (__force u16)skb->protocol ^ skb->hash; + + hash = jhash_1word(hash, jhash_initval_salt); + + return (u16)(((u64)hash * num_tx_queues) >> 32); +} + +u16 i40e_lan_select_queue(struct net_device *netdev, + struct sk_buff *skb, + struct net_device __always_unused *sb_dev) +{ + struct i40e_netdev_priv *np = netdev_priv(netdev); + struct i40e_vsi *vsi = np->vsi; + struct i40e_hw *hw; + u16 qoffset; + u16 qcount; + u8 tclass; + u16 hash; + u8 prio; + + /* is DCB enabled at all? */ + if (vsi->tc_config.numtc == 1) + return i40e_swdcb_skb_tx_hash(netdev, skb, + netdev->real_num_tx_queues); + + prio = skb->priority; + hw = &vsi->back->hw; + tclass = hw->local_dcbx_config.etscfg.prioritytable[prio]; + /* sanity check */ + if (unlikely(!(vsi->tc_config.enabled_tc & BIT(tclass)))) + tclass = 0; + + /* select a queue assigned for the given TC */ + qcount = vsi->tc_config.tc_info[tclass].qcount; + hash = i40e_swdcb_skb_tx_hash(netdev, skb, qcount); + + qoffset = vsi->tc_config.tc_info[tclass].qoffset; + return qoffset + hash; +} + /** * i40e_xmit_xdp_ring - transmits an XDP buffer to an XDP Tx ring * @xdpf: data to transmit diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.h b/drivers/net/ethernet/intel/i40e/i40e_txrx.h index 86fed05b4f19..bfc2845c99d1 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_txrx.h +++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.h @@ -451,6 +451,8 @@ static inline unsigned int i40e_rx_pg_order(struct i40e_ring *ring) bool i40e_alloc_rx_buffers(struct i40e_ring *rxr, u16 cleaned_count); netdev_tx_t i40e_lan_xmit_frame(struct sk_buff *skb, struct net_device *netdev); +u16 i40e_lan_select_queue(struct net_device *netdev, struct sk_buff *skb, + struct net_device *sb_dev); void i40e_clean_tx_ring(struct i40e_ring *tx_ring); void i40e_clean_rx_ring(struct i40e_ring *rx_ring); int i40e_setup_tx_descriptors(struct i40e_ring *tx_ring); -- 2.30.2