Skip to content

Commit db43b30

Browse files
vishalsdkdavem330
authored andcommitted
cxgb4: add ethtool n-tuple filter deletion
Add support to delete ethtool n-tuple filter. Fetch the appropriate filter region (HPFILTER, HASH, NORMAL) in which the filter exists, and delete it from the respective region, accordingly. Signed-off-by: Rahul Lakkireddy <[email protected]> Signed-off-by: Vishal Kulkarni <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c8729ca commit db43b30

File tree

3 files changed

+84
-9
lines changed

3 files changed

+84
-9
lines changed

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

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,6 +1573,22 @@ static int set_rss_table(struct net_device *dev, const u32 *p, const u8 *key,
15731573
return -EPERM;
15741574
}
15751575

1576+
static struct filter_entry *cxgb4_get_filter_entry(struct adapter *adap,
1577+
u32 ftid)
1578+
{
1579+
struct tid_info *t = &adap->tids;
1580+
struct filter_entry *f;
1581+
1582+
if (ftid < t->nhpftids)
1583+
f = &adap->tids.hpftid_tab[ftid];
1584+
else if (ftid < t->nftids)
1585+
f = &adap->tids.ftid_tab[ftid - t->nhpftids];
1586+
else
1587+
f = lookup_tid(&adap->tids, ftid);
1588+
1589+
return f;
1590+
}
1591+
15761592
static int get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *info,
15771593
u32 *rules)
15781594
{
@@ -1636,6 +1652,48 @@ static int get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *info,
16361652
return -EOPNOTSUPP;
16371653
}
16381654

1655+
static int cxgb4_ntuple_del_filter(struct net_device *dev,
1656+
struct ethtool_rxnfc *cmd)
1657+
{
1658+
struct cxgb4_ethtool_filter_info *filter_info;
1659+
struct adapter *adapter = netdev2adap(dev);
1660+
struct port_info *pi = netdev_priv(dev);
1661+
struct filter_entry *f;
1662+
u32 filter_id;
1663+
int ret;
1664+
1665+
if (!(adapter->flags & CXGB4_FULL_INIT_DONE))
1666+
return -EAGAIN; /* can still change nfilters */
1667+
1668+
if (!adapter->ethtool_filters)
1669+
return -EOPNOTSUPP;
1670+
1671+
if (cmd->fs.location >= adapter->ethtool_filters->nentries) {
1672+
dev_err(adapter->pdev_dev,
1673+
"Location must be < %u",
1674+
adapter->ethtool_filters->nentries);
1675+
return -ERANGE;
1676+
}
1677+
1678+
filter_info = &adapter->ethtool_filters->port[pi->port_id];
1679+
1680+
if (!test_bit(cmd->fs.location, filter_info->bmap))
1681+
return -ENOENT;
1682+
1683+
filter_id = filter_info->loc_array[cmd->fs.location];
1684+
f = cxgb4_get_filter_entry(adapter, filter_id);
1685+
1686+
ret = cxgb4_flow_rule_destroy(dev, f->fs.tc_prio, &f->fs, filter_id);
1687+
if (ret)
1688+
goto err;
1689+
1690+
clear_bit(cmd->fs.location, filter_info->bmap);
1691+
filter_info->in_use--;
1692+
1693+
err:
1694+
return ret;
1695+
}
1696+
16391697
/* Add Ethtool n-tuple filters. */
16401698
static int cxgb4_ntuple_set_filter(struct net_device *netdev,
16411699
struct ethtool_rxnfc *cmd)
@@ -1702,6 +1760,9 @@ static int set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd)
17021760
case ETHTOOL_SRXCLSRLINS:
17031761
ret = cxgb4_ntuple_set_filter(dev, cmd);
17041762
break;
1763+
case ETHTOOL_SRXCLSRLDEL:
1764+
ret = cxgb4_ntuple_del_filter(dev, cmd);
1765+
break;
17051766
default:
17061767
break;
17071768
}

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

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -797,23 +797,38 @@ int cxgb4_tc_flower_replace(struct net_device *dev,
797797
return ret;
798798
}
799799

800+
int cxgb4_flow_rule_destroy(struct net_device *dev, u32 tc_prio,
801+
struct ch_filter_specification *fs, int tid)
802+
{
803+
struct adapter *adap = netdev2adap(dev);
804+
u8 hash;
805+
int ret;
806+
807+
hash = fs->hash;
808+
809+
ret = cxgb4_del_filter(dev, tid, fs);
810+
if (ret)
811+
return ret;
812+
813+
if (hash)
814+
cxgb4_tc_flower_hash_prio_del(adap, tc_prio);
815+
816+
return ret;
817+
}
818+
800819
int cxgb4_tc_flower_destroy(struct net_device *dev,
801820
struct flow_cls_offload *cls)
802821
{
803822
struct adapter *adap = netdev2adap(dev);
804823
struct ch_tc_flower_entry *ch_flower;
805-
u32 tc_prio;
806-
bool hash;
807824
int ret;
808825

809826
ch_flower = ch_flower_lookup(adap, cls->cookie);
810827
if (!ch_flower)
811828
return -ENOENT;
812829

813-
hash = ch_flower->fs.hash;
814-
tc_prio = ch_flower->fs.tc_prio;
815-
816-
ret = cxgb4_del_filter(dev, ch_flower->filter_id, &ch_flower->fs);
830+
ret = cxgb4_flow_rule_destroy(dev, ch_flower->fs.tc_prio,
831+
&ch_flower->fs, ch_flower->filter_id);
817832
if (ret)
818833
goto err;
819834

@@ -825,9 +840,6 @@ int cxgb4_tc_flower_destroy(struct net_device *dev,
825840
}
826841
kfree_rcu(ch_flower, rcu);
827842

828-
if (hash)
829-
cxgb4_tc_flower_hash_prio_del(adap, tc_prio);
830-
831843
err:
832844
return ret;
833845
}

drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ int cxgb4_tc_flower_stats(struct net_device *dev,
124124
int cxgb4_flow_rule_replace(struct net_device *dev, struct flow_rule *rule,
125125
u32 tc_prio, struct netlink_ext_ack *extack,
126126
struct ch_filter_specification *fs, u32 *tid);
127+
int cxgb4_flow_rule_destroy(struct net_device *dev, u32 tc_prio,
128+
struct ch_filter_specification *fs, int tid);
127129

128130
int cxgb4_init_tc_flower(struct adapter *adap);
129131
void cxgb4_cleanup_tc_flower(struct adapter *adap);

0 commit comments

Comments
 (0)