Commit ff6e2163 authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller

net: convert multiple drivers to use netdev_for_each_mc_addr, part7

In mlx4, using char * to store mc address in private structure instead.
Signed-off-by: default avatarJiri Pirko <jpirko@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0dc7d2b3
...@@ -1140,7 +1140,6 @@ static void wq_set_multicast_list (struct work_struct *work) ...@@ -1140,7 +1140,6 @@ static void wq_set_multicast_list (struct work_struct *work)
dprintk("%s: allmulti mode\n", dev->name); dprintk("%s: allmulti mode\n", dev->name);
priv->rx_mode = RX_MODE_ALL_MULTI; priv->rx_mode = RX_MODE_ALL_MULTI;
} else if (!netdev_mc_empty(dev)) { } else if (!netdev_mc_empty(dev)) {
int mci;
struct dev_mc_list *mc; struct dev_mc_list *mc;
dprintk("%s: set_mc_list, %d entries\n", dprintk("%s: set_mc_list, %d entries\n",
...@@ -1149,12 +1148,9 @@ static void wq_set_multicast_list (struct work_struct *work) ...@@ -1149,12 +1148,9 @@ static void wq_set_multicast_list (struct work_struct *work)
priv->rx_mode = RX_MODE_MULTI; priv->rx_mode = RX_MODE_MULTI;
priv->multi_num = 0; priv->multi_num = 0;
for (mci = 0, mc=dev->mc_list; netdev_for_each_mc_addr(mc, dev)
mci < netdev_mc_count(dev);
mc = mc->next, mci++) {
dvb_set_mc_filter(dev, mc); dvb_set_mc_filter(dev, mc);
} }
}
netif_addr_unlock_bh(dev); netif_addr_unlock_bh(dev);
dvb_net_feed_start(dev); dvb_net_feed_start(dev);
......
...@@ -160,39 +160,29 @@ static void mlx4_en_do_set_mac(struct work_struct *work) ...@@ -160,39 +160,29 @@ static void mlx4_en_do_set_mac(struct work_struct *work)
static void mlx4_en_clear_list(struct net_device *dev) static void mlx4_en_clear_list(struct net_device *dev)
{ {
struct mlx4_en_priv *priv = netdev_priv(dev); struct mlx4_en_priv *priv = netdev_priv(dev);
struct dev_mc_list *plist = priv->mc_list;
struct dev_mc_list *next;
while (plist) { kfree(priv->mc_addrs);
next = plist->next; priv->mc_addrs_cnt = 0;
kfree(plist);
plist = next;
}
priv->mc_list = NULL;
} }
static void mlx4_en_cache_mclist(struct net_device *dev) static void mlx4_en_cache_mclist(struct net_device *dev)
{ {
struct mlx4_en_priv *priv = netdev_priv(dev); struct mlx4_en_priv *priv = netdev_priv(dev);
struct dev_mc_list *mclist; struct dev_mc_list *mclist;
struct dev_mc_list *tmp; char *mc_addrs;
struct dev_mc_list *plist = NULL; int mc_addrs_cnt = netdev_mc_count(dev);
int i;
for (mclist = dev->mc_list; mclist; mclist = mclist->next) { mc_addrs = kmalloc(mc_addrs_cnt * ETH_ALEN, GFP_ATOMIC);
tmp = kmalloc(sizeof(struct dev_mc_list), GFP_ATOMIC); if (!mc_addrs) {
if (!tmp) {
en_err(priv, "failed to allocate multicast list\n"); en_err(priv, "failed to allocate multicast list\n");
mlx4_en_clear_list(dev);
return; return;
} }
memcpy(tmp, mclist, sizeof(struct dev_mc_list)); i = 0;
tmp->next = NULL; netdev_for_each_mc_addr(mclist, dev)
if (plist) memcpy(mc_addrs + i++ * ETH_ALEN, mclist->dmi_addr, ETH_ALEN);
plist->next = tmp; priv->mc_addrs = mc_addrs;
else priv->mc_addrs_cnt = mc_addrs_cnt;
priv->mc_list = tmp;
plist = tmp;
}
} }
...@@ -212,7 +202,6 @@ static void mlx4_en_do_set_multicast(struct work_struct *work) ...@@ -212,7 +202,6 @@ static void mlx4_en_do_set_multicast(struct work_struct *work)
mcast_task); mcast_task);
struct mlx4_en_dev *mdev = priv->mdev; struct mlx4_en_dev *mdev = priv->mdev;
struct net_device *dev = priv->dev; struct net_device *dev = priv->dev;
struct dev_mc_list *mclist;
u64 mcast_addr = 0; u64 mcast_addr = 0;
int err; int err;
...@@ -288,6 +277,8 @@ static void mlx4_en_do_set_multicast(struct work_struct *work) ...@@ -288,6 +277,8 @@ static void mlx4_en_do_set_multicast(struct work_struct *work)
if (err) if (err)
en_err(priv, "Failed disabling multicast filter\n"); en_err(priv, "Failed disabling multicast filter\n");
} else { } else {
int i;
err = mlx4_SET_MCAST_FLTR(mdev->dev, priv->port, 0, err = mlx4_SET_MCAST_FLTR(mdev->dev, priv->port, 0,
0, MLX4_MCAST_DISABLE); 0, MLX4_MCAST_DISABLE);
if (err) if (err)
...@@ -302,8 +293,9 @@ static void mlx4_en_do_set_multicast(struct work_struct *work) ...@@ -302,8 +293,9 @@ static void mlx4_en_do_set_multicast(struct work_struct *work)
netif_tx_lock_bh(dev); netif_tx_lock_bh(dev);
mlx4_en_cache_mclist(dev); mlx4_en_cache_mclist(dev);
netif_tx_unlock_bh(dev); netif_tx_unlock_bh(dev);
for (mclist = priv->mc_list; mclist; mclist = mclist->next) { for (i = 0; i < priv->mc_addrs_cnt; i++) {
mcast_addr = mlx4_en_mac_to_u64(mclist->dmi_addr); mcast_addr =
mlx4_en_mac_to_u64(priv->mc_addrs + i * ETH_ALEN);
mlx4_SET_MCAST_FLTR(mdev->dev, priv->port, mlx4_SET_MCAST_FLTR(mdev->dev, priv->port,
mcast_addr, 0, MLX4_MCAST_CONFIG); mcast_addr, 0, MLX4_MCAST_CONFIG);
} }
...@@ -984,7 +976,6 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port, ...@@ -984,7 +976,6 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
priv->flags = prof->flags; priv->flags = prof->flags;
priv->tx_ring_num = prof->tx_ring_num; priv->tx_ring_num = prof->tx_ring_num;
priv->rx_ring_num = prof->rx_ring_num; priv->rx_ring_num = prof->rx_ring_num;
priv->mc_list = NULL;
priv->mac_index = -1; priv->mac_index = -1;
priv->msg_enable = MLX4_EN_MSG_LEVEL; priv->msg_enable = MLX4_EN_MSG_LEVEL;
spin_lock_init(&priv->stats_lock); spin_lock_init(&priv->stats_lock);
......
...@@ -492,7 +492,8 @@ struct mlx4_en_priv { ...@@ -492,7 +492,8 @@ struct mlx4_en_priv {
struct mlx4_en_perf_stats pstats; struct mlx4_en_perf_stats pstats;
struct mlx4_en_pkt_stats pkstats; struct mlx4_en_pkt_stats pkstats;
struct mlx4_en_port_stats port_stats; struct mlx4_en_port_stats port_stats;
struct dev_mc_list *mc_list; char *mc_addrs;
int mc_addrs_cnt;
struct mlx4_en_stat_out_mbox hw_stats; struct mlx4_en_stat_out_mbox hw_stats;
}; };
......
...@@ -619,7 +619,7 @@ static void qeth_l2_set_multicast_list(struct net_device *dev) ...@@ -619,7 +619,7 @@ static void qeth_l2_set_multicast_list(struct net_device *dev)
return; return;
qeth_l2_del_all_mc(card); qeth_l2_del_all_mc(card);
spin_lock_bh(&card->mclock); spin_lock_bh(&card->mclock);
for (dm = dev->mc_list; dm; dm = dm->next) netdev_for_each_mc_addr(dm, dev)
qeth_l2_add_mc(card, dm->da_addr, 0); qeth_l2_add_mc(card, dm->da_addr, 0);
netdev_for_each_uc_addr(ha, dev) netdev_for_each_uc_addr(ha, dev)
......
...@@ -87,7 +87,7 @@ static void bnep_net_set_mc_list(struct net_device *dev) ...@@ -87,7 +87,7 @@ static void bnep_net_set_mc_list(struct net_device *dev)
memcpy(__skb_put(skb, ETH_ALEN), dev->broadcast, ETH_ALEN); memcpy(__skb_put(skb, ETH_ALEN), dev->broadcast, ETH_ALEN);
r->len = htons(ETH_ALEN * 2); r->len = htons(ETH_ALEN * 2);
} else { } else {
struct dev_mc_list *dmi = dev->mc_list; struct dev_mc_list *dmi;
int i, len = skb->len; int i, len = skb->len;
if (dev->flags & IFF_BROADCAST) { if (dev->flags & IFF_BROADCAST) {
...@@ -97,12 +97,12 @@ static void bnep_net_set_mc_list(struct net_device *dev) ...@@ -97,12 +97,12 @@ static void bnep_net_set_mc_list(struct net_device *dev)
/* FIXME: We should group addresses here. */ /* FIXME: We should group addresses here. */
for (i = 0; i = 0;
i < netdev_mc_count(dev) && i < BNEP_MAX_MULTICAST_FILTERS; netdev_for_each_mc_addr(dmi, dev) {
i++) { if (i == BNEP_MAX_MULTICAST_FILTERS)
break;
memcpy(__skb_put(skb, ETH_ALEN), dmi->dmi_addr, ETH_ALEN); memcpy(__skb_put(skb, ETH_ALEN), dmi->dmi_addr, ETH_ALEN);
memcpy(__skb_put(skb, ETH_ALEN), dmi->dmi_addr, ETH_ALEN); memcpy(__skb_put(skb, ETH_ALEN), dmi->dmi_addr, ETH_ALEN);
dmi = dmi->next;
} }
r->len = htons(skb->len - len); r->len = htons(skb->len - len);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment