Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3925481pxj; Mon, 21 Jun 2021 09:30:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxilb3CgQAIV9Ya/KmTdjpXmoxfbV+6TLRpYsz6puB1GLtwJX4+8XY1o1cPSnkAtj6CYsqk X-Received: by 2002:a05:6e02:2142:: with SMTP id d2mr2517503ilv.48.1624293028437; Mon, 21 Jun 2021 09:30:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624293028; cv=none; d=google.com; s=arc-20160816; b=UouG88XG9mmAzTTW6S6GG4Dn++Daq+Mcw2QUjaoUMpDDMMqMIeh0qcru6Q43NQ2gSt IggM/w8eLAlDHmzUmabwQozJ6PYRmIbRDstBEDlcWIBeGkra5c1rn4/u3nI739maUawb h8yANhtOsq+pgGCEPfJ1Pizav1E+5hoanqvu8INtwAEth5TuwRgEZVR6pPOwx23Wloa8 WD1WHDeUFhfkVpJWrG00Q9M6jRVU0p1fc52wJQ2BykwehH9hOg7LxPR89/lPrUmVcYrh C7BFrOexbkFeo0mIvYGPqEDFmfeuWn+DRBNwNPZdP17Bx5YshdYfNgbB6qngvNkA1g6L 9vbA== 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=LBu9yDVOpWAdpoJu7jQ2DOGzcO0h1DUUuMhtJmSy/wAV5t2FYKs/4LX9OHK5ozYNfF iRTm7vxSOBZB7EU8BmGer74Yb6q5OGIrXvWAh/dOuWs9uC4dgdqVJq7iBX+SQG80t/+u z2z7xW+R+u2+MDQX9udYhaibTR1e9ZqXDLc9H2uv8lThnqRtkin06ktywwskYwJaoP2l jmJfkGB2A0gDg+WifwSKCWfp+ATkzmlMjVnhUSaz6QzMZJ8CdB4eXKHtwTUKOAv14LV5 OKvhsAHp/kEEUu8/t1P6vrkg7kjiWm0Z332tjoquSPjjDyGjFmvKrVfp9BTuPGfBVBCa b8zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rVYfrJiT; 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 y6si14771257ilu.110.2021.06.21.09.30.16; Mon, 21 Jun 2021 09:30:28 -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=rVYfrJiT; 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 S232480AbhFUQcC (ORCPT + 99 others); Mon, 21 Jun 2021 12:32:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:49228 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232488AbhFUQ3e (ORCPT ); Mon, 21 Jun 2021 12:29:34 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 19BC360698; Mon, 21 Jun 2021 16:24:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1624292663; bh=OIJ5zuKMLWnx1LGBRc4sPjL5ZG9GfRsEd9Ll1vtkaso=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rVYfrJiTOaZdHQviwI9btbSJOdwOpoXbXuYk8plFT2bIzeaLq9s6t9Rja6G3aqbMq V39z3Y9rIWdGuO2FQaWDpzVKRU2VPa/ioZv2+FfFLjAZq/dF6eAkTC57U+a/ZZCnJl SCsum4FgDYJUKPNoIZw9hIqMNu1brSjJqebPBQLM= 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.10 051/146] cxgb4: fix wrong ethtool n-tuple rule lookup Date: Mon, 21 Jun 2021 18:14:41 +0200 Message-Id: <20210621154913.379818528@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210621154911.244649123@linuxfoundation.org> References: <20210621154911.244649123@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