Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3937942pxj; Mon, 21 Jun 2021 09:46:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxokSRBJuwv/3MY5hc36rO8lRFPv3XqFrVjOeLsBf1jZAw0NLHTzSkDERgZsKDo7WrP/wBq X-Received: by 2002:a05:6638:13c3:: with SMTP id i3mr18551003jaj.140.1624293978182; Mon, 21 Jun 2021 09:46:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624293978; cv=none; d=google.com; s=arc-20160816; b=IKKazhdUqjEaNTGvFdaUy6PXpTj0NObHoR8+iVGfSlwJO+NruNYWjzqoHZJ3hq3ojf yUcu5b3pivo0BnfmmkYvgzwAAfs3Eg1ABNJEYkHqWuWqodSN2q+TZOQhNAWqUYLOofpl l5KEcBqY+vCsLmDU0Zw3QS5+zqxJb4Tnn8C91ZE2sOcYSWWtR7nMSK/sCbISlrMK0Ohx 8FlyKLZqjaMaCO1A7ecmSULqZZt2/cmJwxueKOr+Em/4XqzNAWg6bngYPGPPWlQyOqdW TBLjl5Mfv8krgm3jQ1OOZFwFdZ3Evosc9zhJMuoUqd5nPQ1K1cUUVKu+j18aaF/YBDEE I3+Q== 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=sFpTWVG4AMDMQhJHcTA8Az7yUtTpyPDbpEIAhp9H/00=; b=KTgQXQrGNT64kjhJF//yQc8Z3eVp3ekc2t7lxAIlRjaM8h8gRZBfaXqQ96jSkTry/f e9+6MM7x6n82OG6ypTY+3juVWrmpJsHaee94vLvQ2gantgPDeFa2jOR+7CqBm8z4ZLD1 qZZwcSVKWpEfni0ddRtnygI4rvTPlxunVJu6lnQ7PYCv/pWp8nb+lFRtrJuOIiWmczWG m6GtRScpRCXl7DtAxdGrXmfimWE2DK7Asf/hMidkIAoFefsbEGP18XTb028BibVXv/RB A/hpzPwBH4FzSZFhXQLsxo+LlK9RowGC3apmkchYkQn7z0Enr9OmsbjNHTyNO/ojqwIk j1Vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sGYIVxnw; 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 m2si16177172ilu.120.2021.06.21.09.46.06; Mon, 21 Jun 2021 09:46:18 -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=sGYIVxnw; 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 S232129AbhFUQq7 (ORCPT + 99 others); Mon, 21 Jun 2021 12:46:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:33418 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233038AbhFUQl4 (ORCPT ); Mon, 21 Jun 2021 12:41:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 83D74613C1; Mon, 21 Jun 2021 16:31:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1624293068; bh=OIJ5zuKMLWnx1LGBRc4sPjL5ZG9GfRsEd9Ll1vtkaso=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sGYIVxnw/f9D60adF4VczgZ2sQ7XevrUdm5bBn04U9O6hLh+uPddDy8W/GsMqJmEU LUfH+UZ9LuyfW3GOFX8/TClvk7Cs414yE0Gzd093z94rPyW4oxt14TMbmLIrh70Gtf Q9vQXhwh/xRoa1CaqlmUFCp2ZHnvcFQ7PYOAkC8E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rahul Lakkireddy , "David S. Miller" , Sasha Levin Subject: [PATCH 5.12 059/178] cxgb4: fix wrong ethtool n-tuple rule lookup Date: Mon, 21 Jun 2021 18:14:33 +0200 Message-Id: <20210621154924.474158563@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210621154921.212599475@linuxfoundation.org> References: <20210621154921.212599475@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: Rahul Lakkireddy [ Upstream commit 09427c1915f754ebe7d3d8e54e79bbee48afe916 ] The TID returned during successful filter creation is relative to the region in which the filter is created. Using it directly always returns Hi Prio/Normal filter region's entry for the first couple of entries, even though the rule is actually inserted in Hash region. Fix by analyzing in which region the filter has been inserted and save the absolute TID to be used for lookup later. Fixes: db43b30cd89c ("cxgb4: add ethtool n-tuple filter deletion") Signed-off-by: Rahul Lakkireddy Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- .../ethernet/chelsio/cxgb4/cxgb4_ethtool.c | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c index df20485b5744..83ed10ac8660 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c @@ -1624,16 +1624,14 @@ static struct filter_entry *cxgb4_get_filter_entry(struct adapter *adap, u32 ftid) { struct tid_info *t = &adap->tids; - struct filter_entry *f; - if (ftid < t->nhpftids) - f = &adap->tids.hpftid_tab[ftid]; - else if (ftid < t->nftids) - f = &adap->tids.ftid_tab[ftid - t->nhpftids]; - else - f = lookup_tid(&adap->tids, ftid); + if (ftid >= t->hpftid_base && ftid < t->hpftid_base + t->nhpftids) + return &t->hpftid_tab[ftid - t->hpftid_base]; + + if (ftid >= t->ftid_base && ftid < t->ftid_base + t->nftids) + return &t->ftid_tab[ftid - t->ftid_base]; - return f; + return lookup_tid(t, ftid); } static void cxgb4_fill_filter_rule(struct ethtool_rx_flow_spec *fs, @@ -1840,6 +1838,11 @@ static int cxgb4_ntuple_del_filter(struct net_device *dev, filter_id = filter_info->loc_array[cmd->fs.location]; f = cxgb4_get_filter_entry(adapter, filter_id); + if (f->fs.prio) + filter_id -= adapter->tids.hpftid_base; + else if (!f->fs.hash) + filter_id -= (adapter->tids.ftid_base - adapter->tids.nhpftids); + ret = cxgb4_flow_rule_destroy(dev, f->fs.tc_prio, &f->fs, filter_id); if (ret) goto err; @@ -1899,6 +1902,11 @@ static int cxgb4_ntuple_set_filter(struct net_device *netdev, filter_info = &adapter->ethtool_filters->port[pi->port_id]; + if (fs.prio) + tid += adapter->tids.hpftid_base; + else if (!fs.hash) + tid += (adapter->tids.ftid_base - adapter->tids.nhpftids); + filter_info->loc_array[cmd->fs.location] = tid; set_bit(cmd->fs.location, filter_info->bmap); filter_info->in_use++; -- 2.30.2