diff options
author | Jiri Pirko <jpirko@redhat.com> | 2011-07-20 00:54:22 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-07-21 16:47:55 -0400 |
commit | f1b553fbe73bfad38f41269d1c7a7ce3176d9539 (patch) | |
tree | 827da7588b9a8e9780f24787c2861f0e332319d3 | |
parent | 5043f5057773ba8b539eb51b9a4007e99599824f (diff) |
mlx4: do vlan cleanup
- unify vlan and nonvlan path
- kill priv->vlgrp and mlx4_en_vlan_rx_register
Signed-off-by: Jiri Pirko <jpirko@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/mlx4/en_netdev.c | 49 | ||||
-rw-r--r-- | drivers/net/mlx4/en_port.c | 23 | ||||
-rw-r--r-- | drivers/net/mlx4/en_rx.c | 24 | ||||
-rw-r--r-- | drivers/net/mlx4/mlx4_en.h | 6 |
4 files changed, 37 insertions, 65 deletions
diff --git a/drivers/net/mlx4/en_netdev.c b/drivers/net/mlx4/en_netdev.c index 61850adae6f7..9d3f57e76f2f 100644 --- a/drivers/net/mlx4/en_netdev.c +++ b/drivers/net/mlx4/en_netdev.c | |||
@@ -45,25 +45,6 @@ | |||
45 | #include "mlx4_en.h" | 45 | #include "mlx4_en.h" |
46 | #include "en_port.h" | 46 | #include "en_port.h" |
47 | 47 | ||
48 | |||
49 | static void mlx4_en_vlan_rx_register(struct net_device *dev, struct vlan_group *grp) | ||
50 | { | ||
51 | struct mlx4_en_priv *priv = netdev_priv(dev); | ||
52 | struct mlx4_en_dev *mdev = priv->mdev; | ||
53 | int err; | ||
54 | |||
55 | en_dbg(HW, priv, "Registering VLAN group:%p\n", grp); | ||
56 | priv->vlgrp = grp; | ||
57 | |||
58 | mutex_lock(&mdev->state_lock); | ||
59 | if (mdev->device_up && priv->port_up) { | ||
60 | err = mlx4_SET_VLAN_FLTR(mdev->dev, priv->port, grp); | ||
61 | if (err) | ||
62 | en_err(priv, "Failed configuring VLAN filter\n"); | ||
63 | } | ||
64 | mutex_unlock(&mdev->state_lock); | ||
65 | } | ||
66 | |||
67 | static void mlx4_en_vlan_rx_add_vid(struct net_device *dev, unsigned short vid) | 48 | static void mlx4_en_vlan_rx_add_vid(struct net_device *dev, unsigned short vid) |
68 | { | 49 | { |
69 | struct mlx4_en_priv *priv = netdev_priv(dev); | 50 | struct mlx4_en_priv *priv = netdev_priv(dev); |
@@ -71,16 +52,14 @@ static void mlx4_en_vlan_rx_add_vid(struct net_device *dev, unsigned short vid) | |||
71 | int err; | 52 | int err; |
72 | int idx; | 53 | int idx; |
73 | 54 | ||
74 | if (!priv->vlgrp) | 55 | en_dbg(HW, priv, "adding VLAN:%d\n", vid); |
75 | return; | ||
76 | 56 | ||
77 | en_dbg(HW, priv, "adding VLAN:%d (vlgrp entry:%p)\n", | 57 | set_bit(vid, priv->active_vlans); |
78 | vid, vlan_group_get_device(priv->vlgrp, vid)); | ||
79 | 58 | ||
80 | /* Add VID to port VLAN filter */ | 59 | /* Add VID to port VLAN filter */ |
81 | mutex_lock(&mdev->state_lock); | 60 | mutex_lock(&mdev->state_lock); |
82 | if (mdev->device_up && priv->port_up) { | 61 | if (mdev->device_up && priv->port_up) { |
83 | err = mlx4_SET_VLAN_FLTR(mdev->dev, priv->port, priv->vlgrp); | 62 | err = mlx4_SET_VLAN_FLTR(mdev->dev, priv); |
84 | if (err) | 63 | if (err) |
85 | en_err(priv, "Failed configuring VLAN filter\n"); | 64 | en_err(priv, "Failed configuring VLAN filter\n"); |
86 | } | 65 | } |
@@ -97,12 +76,9 @@ static void mlx4_en_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid) | |||
97 | int err; | 76 | int err; |
98 | int idx; | 77 | int idx; |
99 | 78 | ||
100 | if (!priv->vlgrp) | 79 | en_dbg(HW, priv, "Killing VID:%d\n", vid); |
101 | return; | ||
102 | 80 | ||
103 | en_dbg(HW, priv, "Killing VID:%d (vlgrp:%p vlgrp entry:%p)\n", | 81 | clear_bit(vid, priv->active_vlans); |
104 | vid, priv->vlgrp, vlan_group_get_device(priv->vlgrp, vid)); | ||
105 | vlan_group_set_device(priv->vlgrp, vid, NULL); | ||
106 | 82 | ||
107 | /* Remove VID from port VLAN filter */ | 83 | /* Remove VID from port VLAN filter */ |
108 | mutex_lock(&mdev->state_lock); | 84 | mutex_lock(&mdev->state_lock); |
@@ -112,7 +88,7 @@ static void mlx4_en_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid) | |||
112 | en_err(priv, "could not find vid %d in cache\n", vid); | 88 | en_err(priv, "could not find vid %d in cache\n", vid); |
113 | 89 | ||
114 | if (mdev->device_up && priv->port_up) { | 90 | if (mdev->device_up && priv->port_up) { |
115 | err = mlx4_SET_VLAN_FLTR(mdev->dev, priv->port, priv->vlgrp); | 91 | err = mlx4_SET_VLAN_FLTR(mdev->dev, priv); |
116 | if (err) | 92 | if (err) |
117 | en_err(priv, "Failed configuring VLAN filter\n"); | 93 | en_err(priv, "Failed configuring VLAN filter\n"); |
118 | } | 94 | } |
@@ -265,12 +241,10 @@ static void mlx4_en_do_set_multicast(struct work_struct *work) | |||
265 | priv->flags |= MLX4_EN_FLAG_MC_PROMISC; | 241 | priv->flags |= MLX4_EN_FLAG_MC_PROMISC; |
266 | } | 242 | } |
267 | 243 | ||
268 | if (priv->vlgrp) { | 244 | /* Disable port VLAN filter */ |
269 | /* Disable port VLAN filter */ | 245 | err = mlx4_SET_VLAN_FLTR(mdev->dev, priv); |
270 | err = mlx4_SET_VLAN_FLTR(mdev->dev, priv->port, NULL); | 246 | if (err) |
271 | if (err) | 247 | en_err(priv, "Failed disabling VLAN filter\n"); |
272 | en_err(priv, "Failed disabling VLAN filter\n"); | ||
273 | } | ||
274 | } | 248 | } |
275 | goto out; | 249 | goto out; |
276 | } | 250 | } |
@@ -304,7 +278,7 @@ static void mlx4_en_do_set_multicast(struct work_struct *work) | |||
304 | } | 278 | } |
305 | 279 | ||
306 | /* Enable port VLAN filter */ | 280 | /* Enable port VLAN filter */ |
307 | err = mlx4_SET_VLAN_FLTR(mdev->dev, priv->port, priv->vlgrp); | 281 | err = mlx4_SET_VLAN_FLTR(mdev->dev, priv); |
308 | if (err) | 282 | if (err) |
309 | en_err(priv, "Failed enabling VLAN filter\n"); | 283 | en_err(priv, "Failed enabling VLAN filter\n"); |
310 | } | 284 | } |
@@ -1046,7 +1020,6 @@ static const struct net_device_ops mlx4_netdev_ops = { | |||
1046 | .ndo_validate_addr = eth_validate_addr, | 1020 | .ndo_validate_addr = eth_validate_addr, |
1047 | .ndo_change_mtu = mlx4_en_change_mtu, | 1021 | .ndo_change_mtu = mlx4_en_change_mtu, |
1048 | .ndo_tx_timeout = mlx4_en_tx_timeout, | 1022 | .ndo_tx_timeout = mlx4_en_tx_timeout, |
1049 | .ndo_vlan_rx_register = mlx4_en_vlan_rx_register, | ||
1050 | .ndo_vlan_rx_add_vid = mlx4_en_vlan_rx_add_vid, | 1023 | .ndo_vlan_rx_add_vid = mlx4_en_vlan_rx_add_vid, |
1051 | .ndo_vlan_rx_kill_vid = mlx4_en_vlan_rx_kill_vid, | 1024 | .ndo_vlan_rx_kill_vid = mlx4_en_vlan_rx_kill_vid, |
1052 | #ifdef CONFIG_NET_POLL_CONTROLLER | 1025 | #ifdef CONFIG_NET_POLL_CONTROLLER |
diff --git a/drivers/net/mlx4/en_port.c b/drivers/net/mlx4/en_port.c index f2a4f5dd313d..2a74bc81b9f7 100644 --- a/drivers/net/mlx4/en_port.c +++ b/drivers/net/mlx4/en_port.c | |||
@@ -48,7 +48,7 @@ int mlx4_SET_MCAST_FLTR(struct mlx4_dev *dev, u8 port, | |||
48 | MLX4_CMD_SET_MCAST_FLTR, MLX4_CMD_TIME_CLASS_B); | 48 | MLX4_CMD_SET_MCAST_FLTR, MLX4_CMD_TIME_CLASS_B); |
49 | } | 49 | } |
50 | 50 | ||
51 | int mlx4_SET_VLAN_FLTR(struct mlx4_dev *dev, u8 port, struct vlan_group *grp) | 51 | int mlx4_SET_VLAN_FLTR(struct mlx4_dev *dev, struct mlx4_en_priv *priv) |
52 | { | 52 | { |
53 | struct mlx4_cmd_mailbox *mailbox; | 53 | struct mlx4_cmd_mailbox *mailbox; |
54 | struct mlx4_set_vlan_fltr_mbox *filter; | 54 | struct mlx4_set_vlan_fltr_mbox *filter; |
@@ -63,20 +63,15 @@ int mlx4_SET_VLAN_FLTR(struct mlx4_dev *dev, u8 port, struct vlan_group *grp) | |||
63 | return PTR_ERR(mailbox); | 63 | return PTR_ERR(mailbox); |
64 | 64 | ||
65 | filter = mailbox->buf; | 65 | filter = mailbox->buf; |
66 | if (grp) { | 66 | memset(filter, 0, sizeof(*filter)); |
67 | memset(filter, 0, sizeof *filter); | 67 | for (i = VLAN_FLTR_SIZE - 1; i >= 0; i--) { |
68 | for (i = VLAN_FLTR_SIZE - 1; i >= 0; i--) { | 68 | entry = 0; |
69 | entry = 0; | 69 | for (j = 0; j < 32; j++) |
70 | for (j = 0; j < 32; j++) | 70 | if (test_bit(index++, priv->active_vlans)) |
71 | if (vlan_group_get_device(grp, index++)) | 71 | entry |= 1 << j; |
72 | entry |= 1 << j; | 72 | filter->entry[i] = cpu_to_be32(entry); |
73 | filter->entry[i] = cpu_to_be32(entry); | ||
74 | } | ||
75 | } else { | ||
76 | /* When no vlans are configured we block all vlans */ | ||
77 | memset(filter, 0, sizeof(*filter)); | ||
78 | } | 73 | } |
79 | err = mlx4_cmd(dev, mailbox->dma, port, 0, MLX4_CMD_SET_VLAN_FLTR, | 74 | err = mlx4_cmd(dev, mailbox->dma, priv->port, 0, MLX4_CMD_SET_VLAN_FLTR, |
80 | MLX4_CMD_TIME_CLASS_B); | 75 | MLX4_CMD_TIME_CLASS_B); |
81 | mlx4_free_cmd_mailbox(dev, mailbox); | 76 | mlx4_free_cmd_mailbox(dev, mailbox); |
82 | return err; | 77 | return err; |
diff --git a/drivers/net/mlx4/en_rx.c b/drivers/net/mlx4/en_rx.c index 5197b50b2d81..37cc9e5c56be 100644 --- a/drivers/net/mlx4/en_rx.c +++ b/drivers/net/mlx4/en_rx.c | |||
@@ -611,11 +611,14 @@ int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int bud | |||
611 | gro_skb->truesize += length; | 611 | gro_skb->truesize += length; |
612 | gro_skb->ip_summed = CHECKSUM_UNNECESSARY; | 612 | gro_skb->ip_summed = CHECKSUM_UNNECESSARY; |
613 | 613 | ||
614 | if (priv->vlgrp && (cqe->vlan_my_qpn & | 614 | if (cqe->vlan_my_qpn & |
615 | cpu_to_be32(MLX4_CQE_VLAN_PRESENT_MASK))) | 615 | cpu_to_be32(MLX4_CQE_VLAN_PRESENT_MASK)) { |
616 | vlan_gro_frags(&cq->napi, priv->vlgrp, be16_to_cpu(cqe->sl_vid)); | 616 | u16 vid = be16_to_cpu(cqe->sl_vid); |
617 | else | 617 | |
618 | napi_gro_frags(&cq->napi); | 618 | __vlan_hwaccel_put_tag(gro_skb, vid); |
619 | } | ||
620 | |||
621 | napi_gro_frags(&cq->napi); | ||
619 | 622 | ||
620 | goto next; | 623 | goto next; |
621 | } | 624 | } |
@@ -647,13 +650,12 @@ int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int bud | |||
647 | skb->protocol = eth_type_trans(skb, dev); | 650 | skb->protocol = eth_type_trans(skb, dev); |
648 | skb_record_rx_queue(skb, cq->ring); | 651 | skb_record_rx_queue(skb, cq->ring); |
649 | 652 | ||
653 | if (be32_to_cpu(cqe->vlan_my_qpn) & | ||
654 | MLX4_CQE_VLAN_PRESENT_MASK) | ||
655 | __vlan_hwaccel_put_tag(skb, be16_to_cpu(cqe->sl_vid)); | ||
656 | |||
650 | /* Push it up the stack */ | 657 | /* Push it up the stack */ |
651 | if (priv->vlgrp && (be32_to_cpu(cqe->vlan_my_qpn) & | 658 | netif_receive_skb(skb); |
652 | MLX4_CQE_VLAN_PRESENT_MASK)) { | ||
653 | vlan_hwaccel_receive_skb(skb, priv->vlgrp, | ||
654 | be16_to_cpu(cqe->sl_vid)); | ||
655 | } else | ||
656 | netif_receive_skb(skb); | ||
657 | 659 | ||
658 | next: | 660 | next: |
659 | ++cq->mcq.cons_index; | 661 | ++cq->mcq.cons_index; |
diff --git a/drivers/net/mlx4/mlx4_en.h b/drivers/net/mlx4/mlx4_en.h index 0b5150df0585..ed84811766e6 100644 --- a/drivers/net/mlx4/mlx4_en.h +++ b/drivers/net/mlx4/mlx4_en.h | |||
@@ -34,10 +34,12 @@ | |||
34 | #ifndef _MLX4_EN_H_ | 34 | #ifndef _MLX4_EN_H_ |
35 | #define _MLX4_EN_H_ | 35 | #define _MLX4_EN_H_ |
36 | 36 | ||
37 | #include <linux/bitops.h> | ||
37 | #include <linux/compiler.h> | 38 | #include <linux/compiler.h> |
38 | #include <linux/list.h> | 39 | #include <linux/list.h> |
39 | #include <linux/mutex.h> | 40 | #include <linux/mutex.h> |
40 | #include <linux/netdevice.h> | 41 | #include <linux/netdevice.h> |
42 | #include <linux/if_vlan.h> | ||
41 | 43 | ||
42 | #include <linux/mlx4/device.h> | 44 | #include <linux/mlx4/device.h> |
43 | #include <linux/mlx4/qp.h> | 45 | #include <linux/mlx4/qp.h> |
@@ -418,7 +420,7 @@ struct mlx4_en_priv { | |||
418 | struct mlx4_en_dev *mdev; | 420 | struct mlx4_en_dev *mdev; |
419 | struct mlx4_en_port_profile *prof; | 421 | struct mlx4_en_port_profile *prof; |
420 | struct net_device *dev; | 422 | struct net_device *dev; |
421 | struct vlan_group *vlgrp; | 423 | unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)]; |
422 | struct net_device_stats stats; | 424 | struct net_device_stats stats; |
423 | struct net_device_stats ret_stats; | 425 | struct net_device_stats ret_stats; |
424 | struct mlx4_en_port_state port_state; | 426 | struct mlx4_en_port_state port_state; |
@@ -553,7 +555,7 @@ int mlx4_en_free_tx_buf(struct net_device *dev, struct mlx4_en_tx_ring *ring); | |||
553 | void mlx4_en_rx_irq(struct mlx4_cq *mcq); | 555 | void mlx4_en_rx_irq(struct mlx4_cq *mcq); |
554 | 556 | ||
555 | int mlx4_SET_MCAST_FLTR(struct mlx4_dev *dev, u8 port, u64 mac, u64 clear, u8 mode); | 557 | int mlx4_SET_MCAST_FLTR(struct mlx4_dev *dev, u8 port, u64 mac, u64 clear, u8 mode); |
556 | int mlx4_SET_VLAN_FLTR(struct mlx4_dev *dev, u8 port, struct vlan_group *grp); | 558 | int mlx4_SET_VLAN_FLTR(struct mlx4_dev *dev, struct mlx4_en_priv *priv); |
557 | int mlx4_SET_PORT_general(struct mlx4_dev *dev, u8 port, int mtu, | 559 | int mlx4_SET_PORT_general(struct mlx4_dev *dev, u8 port, int mtu, |
558 | u8 pptx, u8 pfctx, u8 pprx, u8 pfcrx); | 560 | u8 pptx, u8 pfctx, u8 pprx, u8 pfcrx); |
559 | int mlx4_SET_PORT_qpn_calc(struct mlx4_dev *dev, u8 port, u32 base_qpn, | 561 | int mlx4_SET_PORT_qpn_calc(struct mlx4_dev *dev, u8 port, u32 base_qpn, |