Skip to content

Commit 09427c1

Browse files
chelsiocudbgdavem330
authored andcommitted
cxgb4: fix wrong ethtool n-tuple rule lookup
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: db43b30 ("cxgb4: add ethtool n-tuple filter deletion") Signed-off-by: Rahul Lakkireddy <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 49a10c7 commit 09427c1

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1624,16 +1624,14 @@ static struct filter_entry *cxgb4_get_filter_entry(struct adapter *adap,
16241624
u32 ftid)
16251625
{
16261626
struct tid_info *t = &adap->tids;
1627-
struct filter_entry *f;
16281627

1629-
if (ftid < t->nhpftids)
1630-
f = &adap->tids.hpftid_tab[ftid];
1631-
else if (ftid < t->nftids)
1632-
f = &adap->tids.ftid_tab[ftid - t->nhpftids];
1633-
else
1634-
f = lookup_tid(&adap->tids, ftid);
1628+
if (ftid >= t->hpftid_base && ftid < t->hpftid_base + t->nhpftids)
1629+
return &t->hpftid_tab[ftid - t->hpftid_base];
1630+
1631+
if (ftid >= t->ftid_base && ftid < t->ftid_base + t->nftids)
1632+
return &t->ftid_tab[ftid - t->ftid_base];
16351633

1636-
return f;
1634+
return lookup_tid(t, ftid);
16371635
}
16381636

16391637
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,
18401838
filter_id = filter_info->loc_array[cmd->fs.location];
18411839
f = cxgb4_get_filter_entry(adapter, filter_id);
18421840

1841+
if (f->fs.prio)
1842+
filter_id -= adapter->tids.hpftid_base;
1843+
else if (!f->fs.hash)
1844+
filter_id -= (adapter->tids.ftid_base - adapter->tids.nhpftids);
1845+
18431846
ret = cxgb4_flow_rule_destroy(dev, f->fs.tc_prio, &f->fs, filter_id);
18441847
if (ret)
18451848
goto err;
@@ -1899,6 +1902,11 @@ static int cxgb4_ntuple_set_filter(struct net_device *netdev,
18991902

19001903
filter_info = &adapter->ethtool_filters->port[pi->port_id];
19011904

1905+
if (fs.prio)
1906+
tid += adapter->tids.hpftid_base;
1907+
else if (!fs.hash)
1908+
tid += (adapter->tids.ftid_base - adapter->tids.nhpftids);
1909+
19021910
filter_info->loc_array[cmd->fs.location] = tid;
19031911
set_bit(cmd->fs.location, filter_info->bmap);
19041912
filter_info->in_use++;

0 commit comments

Comments
 (0)