diff options
author | Jiri Pirko <jpirko@redhat.com> | 2010-03-01 00:09:14 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-03-17 00:23:25 -0400 |
commit | ff6e2163f28a1094fb5ca5950fe2b43c3cf6bc7a (patch) | |
tree | 38673e8515a0948ed435dc0b9403c62269c7f8f4 /drivers/net/mlx4 | |
parent | 0dc7d2b3cbfcf4ff20bdc68f563a2e52e6a2178f (diff) |
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: Jiri Pirko <jpirko@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/mlx4')
-rw-r--r-- | drivers/net/mlx4/en_netdev.c | 49 | ||||
-rw-r--r-- | drivers/net/mlx4/mlx4_en.h | 3 |
2 files changed, 22 insertions, 30 deletions
diff --git a/drivers/net/mlx4/en_netdev.c b/drivers/net/mlx4/en_netdev.c index c48b0f4b17b7..7cd0933735e2 100644 --- a/drivers/net/mlx4/en_netdev.c +++ b/drivers/net/mlx4/en_netdev.c | |||
@@ -160,39 +160,29 @@ static void mlx4_en_do_set_mac(struct work_struct *work) | |||
160 | static void mlx4_en_clear_list(struct net_device *dev) | 160 | static void mlx4_en_clear_list(struct net_device *dev) |
161 | { | 161 | { |
162 | struct mlx4_en_priv *priv = netdev_priv(dev); | 162 | struct mlx4_en_priv *priv = netdev_priv(dev); |
163 | struct dev_mc_list *plist = priv->mc_list; | ||
164 | struct dev_mc_list *next; | ||
165 | 163 | ||
166 | while (plist) { | 164 | kfree(priv->mc_addrs); |
167 | next = plist->next; | 165 | priv->mc_addrs_cnt = 0; |
168 | kfree(plist); | ||
169 | plist = next; | ||
170 | } | ||
171 | priv->mc_list = NULL; | ||
172 | } | 166 | } |
173 | 167 | ||
174 | static void mlx4_en_cache_mclist(struct net_device *dev) | 168 | static void mlx4_en_cache_mclist(struct net_device *dev) |
175 | { | 169 | { |
176 | struct mlx4_en_priv *priv = netdev_priv(dev); | 170 | struct mlx4_en_priv *priv = netdev_priv(dev); |
177 | struct dev_mc_list *mclist; | 171 | struct dev_mc_list *mclist; |
178 | struct dev_mc_list *tmp; | 172 | char *mc_addrs; |
179 | struct dev_mc_list *plist = NULL; | 173 | int mc_addrs_cnt = netdev_mc_count(dev); |
180 | 174 | int i; | |
181 | for (mclist = dev->mc_list; mclist; mclist = mclist->next) { | 175 | |
182 | tmp = kmalloc(sizeof(struct dev_mc_list), GFP_ATOMIC); | 176 | mc_addrs = kmalloc(mc_addrs_cnt * ETH_ALEN, GFP_ATOMIC); |
183 | if (!tmp) { | 177 | if (!mc_addrs) { |
184 | en_err(priv, "failed to allocate multicast list\n"); | 178 | en_err(priv, "failed to allocate multicast list\n"); |
185 | mlx4_en_clear_list(dev); | 179 | return; |
186 | return; | ||
187 | } | ||
188 | memcpy(tmp, mclist, sizeof(struct dev_mc_list)); | ||
189 | tmp->next = NULL; | ||
190 | if (plist) | ||
191 | plist->next = tmp; | ||
192 | else | ||
193 | priv->mc_list = tmp; | ||
194 | plist = tmp; | ||
195 | } | 180 | } |
181 | i = 0; | ||
182 | netdev_for_each_mc_addr(mclist, dev) | ||
183 | memcpy(mc_addrs + i++ * ETH_ALEN, mclist->dmi_addr, ETH_ALEN); | ||
184 | priv->mc_addrs = mc_addrs; | ||
185 | priv->mc_addrs_cnt = mc_addrs_cnt; | ||
196 | } | 186 | } |
197 | 187 | ||
198 | 188 | ||
@@ -212,7 +202,6 @@ static void mlx4_en_do_set_multicast(struct work_struct *work) | |||
212 | mcast_task); | 202 | mcast_task); |
213 | struct mlx4_en_dev *mdev = priv->mdev; | 203 | struct mlx4_en_dev *mdev = priv->mdev; |
214 | struct net_device *dev = priv->dev; | 204 | struct net_device *dev = priv->dev; |
215 | struct dev_mc_list *mclist; | ||
216 | u64 mcast_addr = 0; | 205 | u64 mcast_addr = 0; |
217 | int err; | 206 | int err; |
218 | 207 | ||
@@ -288,6 +277,8 @@ static void mlx4_en_do_set_multicast(struct work_struct *work) | |||
288 | if (err) | 277 | if (err) |
289 | en_err(priv, "Failed disabling multicast filter\n"); | 278 | en_err(priv, "Failed disabling multicast filter\n"); |
290 | } else { | 279 | } else { |
280 | int i; | ||
281 | |||
291 | err = mlx4_SET_MCAST_FLTR(mdev->dev, priv->port, 0, | 282 | err = mlx4_SET_MCAST_FLTR(mdev->dev, priv->port, 0, |
292 | 0, MLX4_MCAST_DISABLE); | 283 | 0, MLX4_MCAST_DISABLE); |
293 | if (err) | 284 | if (err) |
@@ -302,8 +293,9 @@ static void mlx4_en_do_set_multicast(struct work_struct *work) | |||
302 | netif_tx_lock_bh(dev); | 293 | netif_tx_lock_bh(dev); |
303 | mlx4_en_cache_mclist(dev); | 294 | mlx4_en_cache_mclist(dev); |
304 | netif_tx_unlock_bh(dev); | 295 | netif_tx_unlock_bh(dev); |
305 | for (mclist = priv->mc_list; mclist; mclist = mclist->next) { | 296 | for (i = 0; i < priv->mc_addrs_cnt; i++) { |
306 | mcast_addr = mlx4_en_mac_to_u64(mclist->dmi_addr); | 297 | mcast_addr = |
298 | mlx4_en_mac_to_u64(priv->mc_addrs + i * ETH_ALEN); | ||
307 | mlx4_SET_MCAST_FLTR(mdev->dev, priv->port, | 299 | mlx4_SET_MCAST_FLTR(mdev->dev, priv->port, |
308 | mcast_addr, 0, MLX4_MCAST_CONFIG); | 300 | mcast_addr, 0, MLX4_MCAST_CONFIG); |
309 | } | 301 | } |
@@ -984,7 +976,6 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port, | |||
984 | priv->flags = prof->flags; | 976 | priv->flags = prof->flags; |
985 | priv->tx_ring_num = prof->tx_ring_num; | 977 | priv->tx_ring_num = prof->tx_ring_num; |
986 | priv->rx_ring_num = prof->rx_ring_num; | 978 | priv->rx_ring_num = prof->rx_ring_num; |
987 | priv->mc_list = NULL; | ||
988 | priv->mac_index = -1; | 979 | priv->mac_index = -1; |
989 | priv->msg_enable = MLX4_EN_MSG_LEVEL; | 980 | priv->msg_enable = MLX4_EN_MSG_LEVEL; |
990 | spin_lock_init(&priv->stats_lock); | 981 | spin_lock_init(&priv->stats_lock); |
diff --git a/drivers/net/mlx4/mlx4_en.h b/drivers/net/mlx4/mlx4_en.h index 82c3ebc584e3..b55e46c8b682 100644 --- a/drivers/net/mlx4/mlx4_en.h +++ b/drivers/net/mlx4/mlx4_en.h | |||
@@ -492,7 +492,8 @@ struct mlx4_en_priv { | |||
492 | struct mlx4_en_perf_stats pstats; | 492 | struct mlx4_en_perf_stats pstats; |
493 | struct mlx4_en_pkt_stats pkstats; | 493 | struct mlx4_en_pkt_stats pkstats; |
494 | struct mlx4_en_port_stats port_stats; | 494 | struct mlx4_en_port_stats port_stats; |
495 | struct dev_mc_list *mc_list; | 495 | char *mc_addrs; |
496 | int mc_addrs_cnt; | ||
496 | struct mlx4_en_stat_out_mbox hw_stats; | 497 | struct mlx4_en_stat_out_mbox hw_stats; |
497 | }; | 498 | }; |
498 | 499 | ||