Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp442356ybk; Wed, 13 May 2020 04:19:25 -0700 (PDT) X-Google-Smtp-Source: APiQypJK1Z/SZpsERAoqAzj4uTiDAdyluoiepleoumASK/7bsv9KV+5YEhFpsU9nAtzueYDliy7s X-Received: by 2002:a05:6402:688:: with SMTP id f8mr21327330edy.233.1589368765459; Wed, 13 May 2020 04:19:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589368765; cv=none; d=google.com; s=arc-20160816; b=hdrFmgF+IT4XfxuaVhjBpCTQeGB9zciE3thdI3Crd9ZGSYKO18yA21Ke8cQfIk+Qkk GW/qdCfC5Nqp/TfdX0QDZ8pOR7X3kZdVaZcI7+6e7EGTxFYFlAstk1WiYy0zUtTH13o4 rJwiewt5BfW7Hp69nstO02BugSWjpykWENHvJsqxOOrYn2v8SEsXp2IoiTEcd1xWrHgw 9MVZEs62TMlMyihr85/NNDzLAr9ukL17KnXkY4Q7EFaTcPCNgLd6MPpW7INGak8Jo+2G UEkFEhkNYGgjB138U+o9JkZxJwRMewm5VfvQJdaRTQ9qz/QGCjAdcbEAK3wmv/kziLas RHUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qENddVFDVeZPNfD7SBslD7BctIV/ajndyphnBiCMTeY=; b=F1Yad11seWVRxN2/8xxJIQcYKf/g4XrKGAYHsnqbArnGygxENQwABWX01oVkbiL98n dVQXFrvKhi1JKmomg+3pq/SwEtMEVxdThqDtvDHwefQa1BGoi0EJS77fWIPWFQUnzRg6 T6REWJx10vgGKyNfVQxQ3zoQZxnsuZEB5d+f+61774UfU+8krs59Oca8kwG6ccWCrF8r xwMd2d9VHZU3HCitmmnc8VqfhyCMUqB7gLNX+8ttHy+4L4db8JT49G9miGYYsXhCnnB8 u8LhOIOXW8XL9wfH6ZB2IiC1Juewkhg8HYqnEgbNligfGECrGoPy12xTkDt2aVOIni5E XQWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0XA7pMBA; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u8si9363451eds.295.2020.05.13.04.19.02; Wed, 13 May 2020 04:19:25 -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=@kernel.org header.s=default header.b=0XA7pMBA; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388462AbgEMKAg (ORCPT + 99 others); Wed, 13 May 2020 06:00:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:52924 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387682AbgEMJvt (ORCPT ); Wed, 13 May 2020 05:51:49 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 37D4520769; Wed, 13 May 2020 09:51:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589363508; bh=I2jwnxVXM12FKVcYuCcTAMuuoCTdocvVrL5yu3rWjI4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0XA7pMBAV46Tvdq+trzNetGPAaTY55J4XWC87iJSMQpSLbu9veSDBFfp0KCPM51fT QDPxl0g/w4UQ5oIeEQF+GM8WUWxUdKU9K/B1s878LyxOBerO5OywWRXB/IDedWxmYv ViuxEvH7rWIIDxca40meDZLqmsEzjpONTM/+EGUU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rahul Lakkireddy , "David S. Miller" Subject: [PATCH 5.6 013/118] cxgb4: fix EOTID leak when disabling TC-MQPRIO offload Date: Wed, 13 May 2020 11:43:52 +0200 Message-Id: <20200513094418.847414141@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200513094417.618129545@linuxfoundation.org> References: <20200513094417.618129545@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rahul Lakkireddy [ Upstream commit 69422a7e5d578aab277091f4ebb7c1b387f3e355 ] Under heavy load, the EOTID termination FLOWC request fails to get enqueued to the end of the Tx ring due to lack of credits. This results in EOTID leak. When disabling TC-MQPRIO offload, the link is already brought down to cleanup EOTIDs. So, flush any pending enqueued skbs that can't be sent outside the wire, to make room for FLOWC request. Also, move the FLOWC descriptor consumption logic closer to when the FLOWC request is actually posted to hardware. Fixes: 0e395b3cb1fb ("cxgb4: add FLOWC based QoS offload") Signed-off-by: Rahul Lakkireddy Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/chelsio/cxgb4/sge.c | 39 ++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) --- a/drivers/net/ethernet/chelsio/cxgb4/sge.c +++ b/drivers/net/ethernet/chelsio/cxgb4/sge.c @@ -2202,6 +2202,9 @@ static void ethofld_hard_xmit(struct net if (unlikely(skip_eotx_wr)) { start = (u64 *)wr; eosw_txq->state = next_state; + eosw_txq->cred -= wrlen16; + eosw_txq->ncompl++; + eosw_txq->last_compl = 0; goto write_wr_headers; } @@ -2360,6 +2363,34 @@ netdev_tx_t t4_start_xmit(struct sk_buff return cxgb4_eth_xmit(skb, dev); } +static void eosw_txq_flush_pending_skbs(struct sge_eosw_txq *eosw_txq) +{ + int pktcount = eosw_txq->pidx - eosw_txq->last_pidx; + int pidx = eosw_txq->pidx; + struct sk_buff *skb; + + if (!pktcount) + return; + + if (pktcount < 0) + pktcount += eosw_txq->ndesc; + + while (pktcount--) { + pidx--; + if (pidx < 0) + pidx += eosw_txq->ndesc; + + skb = eosw_txq->desc[pidx].skb; + if (skb) { + dev_consume_skb_any(skb); + eosw_txq->desc[pidx].skb = NULL; + eosw_txq->inuse--; + } + } + + eosw_txq->pidx = eosw_txq->last_pidx + 1; +} + /** * cxgb4_ethofld_send_flowc - Send ETHOFLD flowc request to bind eotid to tc. * @dev - netdevice @@ -2435,9 +2466,11 @@ int cxgb4_ethofld_send_flowc(struct net_ FW_FLOWC_MNEM_EOSTATE_CLOSING : FW_FLOWC_MNEM_EOSTATE_ESTABLISHED); - eosw_txq->cred -= len16; - eosw_txq->ncompl++; - eosw_txq->last_compl = 0; + /* Free up any pending skbs to ensure there's room for + * termination FLOWC. + */ + if (tc == FW_SCHED_CLS_NONE) + eosw_txq_flush_pending_skbs(eosw_txq); ret = eosw_txq_enqueue(eosw_txq, skb); if (ret) {