Skip to content

Commit b9f2420

Browse files
committed
Merge branch 'macb-rx-filter-cleanups'
Julia Cartwright says: ==================== macb rx filter cleanups Here's a proper patchset based on net-next. v1 -> v2: - Rebased on net-next - Add Nicolas's Acks - Reorder commits, putting the list_empty() cleanups prior to the others. - Added commit reverting the GFP_ATOMIC change. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 9a63b25 + cc1674e commit b9f2420

File tree

1 file changed

+23
-24
lines changed

1 file changed

+23
-24
lines changed

drivers/net/ethernet/cadence/macb_main.c

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2796,10 +2796,11 @@ static int gem_add_flow_filter(struct net_device *netdev,
27962796
struct macb *bp = netdev_priv(netdev);
27972797
struct ethtool_rx_flow_spec *fs = &cmd->fs;
27982798
struct ethtool_rx_fs_item *item, *newfs;
2799+
unsigned long flags;
27992800
int ret = -EINVAL;
28002801
bool added = false;
28012802

2802-
newfs = kmalloc(sizeof(*newfs), GFP_ATOMIC);
2803+
newfs = kmalloc(sizeof(*newfs), GFP_KERNEL);
28032804
if (newfs == NULL)
28042805
return -ENOMEM;
28052806
memcpy(&newfs->fs, fs, sizeof(newfs->fs));
@@ -2811,35 +2812,35 @@ static int gem_add_flow_filter(struct net_device *netdev,
28112812
htonl(fs->h_u.tcp_ip4_spec.ip4dst),
28122813
htons(fs->h_u.tcp_ip4_spec.psrc), htons(fs->h_u.tcp_ip4_spec.pdst));
28132814

2815+
spin_lock_irqsave(&bp->rx_fs_lock, flags);
2816+
28142817
/* find correct place to add in list */
2815-
if (list_empty(&bp->rx_fs_list.list))
2816-
list_add(&newfs->list, &bp->rx_fs_list.list);
2817-
else {
2818-
list_for_each_entry(item, &bp->rx_fs_list.list, list) {
2819-
if (item->fs.location > newfs->fs.location) {
2820-
list_add_tail(&newfs->list, &item->list);
2821-
added = true;
2822-
break;
2823-
} else if (item->fs.location == fs->location) {
2824-
netdev_err(netdev, "Rule not added: location %d not free!\n",
2825-
fs->location);
2826-
ret = -EBUSY;
2827-
goto err;
2828-
}
2818+
list_for_each_entry(item, &bp->rx_fs_list.list, list) {
2819+
if (item->fs.location > newfs->fs.location) {
2820+
list_add_tail(&newfs->list, &item->list);
2821+
added = true;
2822+
break;
2823+
} else if (item->fs.location == fs->location) {
2824+
netdev_err(netdev, "Rule not added: location %d not free!\n",
2825+
fs->location);
2826+
ret = -EBUSY;
2827+
goto err;
28292828
}
2830-
if (!added)
2831-
list_add_tail(&newfs->list, &bp->rx_fs_list.list);
28322829
}
2830+
if (!added)
2831+
list_add_tail(&newfs->list, &bp->rx_fs_list.list);
28332832

28342833
gem_prog_cmp_regs(bp, fs);
28352834
bp->rx_fs_list.count++;
28362835
/* enable filtering if NTUPLE on */
28372836
if (netdev->features & NETIF_F_NTUPLE)
28382837
gem_enable_flow_filters(bp, 1);
28392838

2839+
spin_unlock_irqrestore(&bp->rx_fs_lock, flags);
28402840
return 0;
28412841

28422842
err:
2843+
spin_unlock_irqrestore(&bp->rx_fs_lock, flags);
28432844
kfree(newfs);
28442845
return ret;
28452846
}
@@ -2850,9 +2851,9 @@ static int gem_del_flow_filter(struct net_device *netdev,
28502851
struct macb *bp = netdev_priv(netdev);
28512852
struct ethtool_rx_fs_item *item;
28522853
struct ethtool_rx_flow_spec *fs;
2854+
unsigned long flags;
28532855

2854-
if (list_empty(&bp->rx_fs_list.list))
2855-
return -EINVAL;
2856+
spin_lock_irqsave(&bp->rx_fs_lock, flags);
28562857

28572858
list_for_each_entry(item, &bp->rx_fs_list.list, list) {
28582859
if (item->fs.location == cmd->fs.location) {
@@ -2869,12 +2870,14 @@ static int gem_del_flow_filter(struct net_device *netdev,
28692870
gem_writel_n(bp, SCRT2, fs->location, 0);
28702871

28712872
list_del(&item->list);
2872-
kfree(item);
28732873
bp->rx_fs_list.count--;
2874+
spin_unlock_irqrestore(&bp->rx_fs_lock, flags);
2875+
kfree(item);
28742876
return 0;
28752877
}
28762878
}
28772879

2880+
spin_unlock_irqrestore(&bp->rx_fs_lock, flags);
28782881
return -EINVAL;
28792882
}
28802883

@@ -2943,11 +2946,8 @@ static int gem_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd,
29432946
static int gem_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd)
29442947
{
29452948
struct macb *bp = netdev_priv(netdev);
2946-
unsigned long flags;
29472949
int ret;
29482950

2949-
spin_lock_irqsave(&bp->rx_fs_lock, flags);
2950-
29512951
switch (cmd->cmd) {
29522952
case ETHTOOL_SRXCLSRLINS:
29532953
if ((cmd->fs.location >= bp->max_tuples)
@@ -2966,7 +2966,6 @@ static int gem_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd)
29662966
ret = -EOPNOTSUPP;
29672967
}
29682968

2969-
spin_unlock_irqrestore(&bp->rx_fs_lock, flags);
29702969
return ret;
29712970
}
29722971

0 commit comments

Comments
 (0)