Commit 0eb74fdd authored by Yan Burman's avatar Yan Burman Committed by David S. Miller

net/mlx4_en: Re-arrange ndo_set_rx_mode related code

Currently, mlx4_en_do_set_multicast serves as the ndo_set_rx_mode entry for mlx4_en,
doing all related work. Split it to few calls, one per required functionality
(e.g multicast, promiscuous, etc) and rename some structures and calls
to use rx_mode notation instead of multicast.
Signed-off-by: default avatarYan Burman <yanb@mellanox.com>
Signed-off-by: default avatarAmir Vadai <amirv@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 16a10ffd
...@@ -747,52 +747,21 @@ static void update_mclist_flags(struct mlx4_en_priv *priv, ...@@ -747,52 +747,21 @@ static void update_mclist_flags(struct mlx4_en_priv *priv,
} }
} }
static void mlx4_en_set_multicast(struct net_device *dev) static void mlx4_en_set_rx_mode(struct net_device *dev)
{ {
struct mlx4_en_priv *priv = netdev_priv(dev); struct mlx4_en_priv *priv = netdev_priv(dev);
if (!priv->port_up) if (!priv->port_up)
return; return;
queue_work(priv->mdev->workqueue, &priv->mcast_task); queue_work(priv->mdev->workqueue, &priv->rx_mode_task);
} }
static void mlx4_en_do_set_multicast(struct work_struct *work) static void mlx4_en_set_promisc_mode(struct mlx4_en_priv *priv,
struct mlx4_en_dev *mdev)
{ {
struct mlx4_en_priv *priv = container_of(work, struct mlx4_en_priv,
mcast_task);
struct mlx4_en_dev *mdev = priv->mdev;
struct net_device *dev = priv->dev;
struct mlx4_en_mc_list *mclist, *tmp;
u64 mcast_addr = 0;
u8 mc_list[16] = {0};
int err = 0; int err = 0;
mutex_lock(&mdev->state_lock);
if (!mdev->device_up) {
en_dbg(HW, priv, "Card is not up, ignoring multicast change.\n");
goto out;
}
if (!priv->port_up) {
en_dbg(HW, priv, "Port is down, ignoring multicast change.\n");
goto out;
}
if (!netif_carrier_ok(dev)) {
if (!mlx4_en_QUERY_PORT(mdev, priv->port)) {
if (priv->port_state.link_state) {
priv->last_link_state = MLX4_DEV_EVENT_PORT_UP;
netif_carrier_on(dev);
en_dbg(LINK, priv, "Link Up\n");
}
}
}
/*
* Promsicuous mode: disable all filters
*/
if (dev->flags & IFF_PROMISC) {
if (!(priv->flags & MLX4_EN_FLAG_PROMISC)) { if (!(priv->flags & MLX4_EN_FLAG_PROMISC)) {
if (netif_msg_rx_status(priv)) if (netif_msg_rx_status(priv))
en_warn(priv, "Entering promiscuous mode\n"); en_warn(priv, "Entering promiscuous mode\n");
...@@ -851,14 +820,13 @@ static void mlx4_en_do_set_multicast(struct work_struct *work) ...@@ -851,14 +820,13 @@ static void mlx4_en_do_set_multicast(struct work_struct *work)
if (err) if (err)
en_err(priv, "Failed disabling VLAN filter\n"); en_err(priv, "Failed disabling VLAN filter\n");
} }
goto out; }
}
/* static void mlx4_en_clear_promisc_mode(struct mlx4_en_priv *priv,
* Not in promiscuous mode struct mlx4_en_dev *mdev)
*/ {
int err = 0;
if (priv->flags & MLX4_EN_FLAG_PROMISC) {
if (netif_msg_rx_status(priv)) if (netif_msg_rx_status(priv))
en_warn(priv, "Leaving promiscuous mode\n"); en_warn(priv, "Leaving promiscuous mode\n");
priv->flags &= ~MLX4_EN_FLAG_PROMISC; priv->flags &= ~MLX4_EN_FLAG_PROMISC;
...@@ -904,7 +872,16 @@ static void mlx4_en_do_set_multicast(struct work_struct *work) ...@@ -904,7 +872,16 @@ static void mlx4_en_do_set_multicast(struct work_struct *work)
err = mlx4_SET_VLAN_FLTR(mdev->dev, priv); err = mlx4_SET_VLAN_FLTR(mdev->dev, priv);
if (err) if (err)
en_err(priv, "Failed enabling VLAN filter\n"); en_err(priv, "Failed enabling VLAN filter\n");
} }
static void mlx4_en_do_multicast(struct mlx4_en_priv *priv,
struct net_device *dev,
struct mlx4_en_dev *mdev)
{
struct mlx4_en_mc_list *mclist, *tmp;
u64 mcast_addr = 0;
u8 mc_list[16] = {0};
int err = 0;
/* Enable/disable the multicast filter according to IFF_ALLMULTI */ /* Enable/disable the multicast filter according to IFF_ALLMULTI */
if (dev->flags & IFF_ALLMULTI) { if (dev->flags & IFF_ALLMULTI) {
...@@ -1018,6 +995,46 @@ static void mlx4_en_do_set_multicast(struct work_struct *work) ...@@ -1018,6 +995,46 @@ static void mlx4_en_do_set_multicast(struct work_struct *work)
} }
} }
} }
}
static void mlx4_en_do_set_rx_mode(struct work_struct *work)
{
struct mlx4_en_priv *priv = container_of(work, struct mlx4_en_priv,
rx_mode_task);
struct mlx4_en_dev *mdev = priv->mdev;
struct net_device *dev = priv->dev;
mutex_lock(&mdev->state_lock);
if (!mdev->device_up) {
en_dbg(HW, priv, "Card is not up, ignoring rx mode change.\n");
goto out;
}
if (!priv->port_up) {
en_dbg(HW, priv, "Port is down, ignoring rx mode change.\n");
goto out;
}
if (!netif_carrier_ok(dev)) {
if (!mlx4_en_QUERY_PORT(mdev, priv->port)) {
if (priv->port_state.link_state) {
priv->last_link_state = MLX4_DEV_EVENT_PORT_UP;
netif_carrier_on(dev);
en_dbg(LINK, priv, "Link Up\n");
}
}
}
/* Promsicuous mode: disable all filters */
if (dev->flags & IFF_PROMISC) {
mlx4_en_set_promisc_mode(priv, mdev);
goto out;
}
/* Not in promiscuous mode */
if (priv->flags & MLX4_EN_FLAG_PROMISC)
mlx4_en_clear_promisc_mode(priv, mdev);
mlx4_en_do_multicast(priv, dev, mdev);
out: out:
mutex_unlock(&mdev->state_lock); mutex_unlock(&mdev->state_lock);
} }
...@@ -1374,7 +1391,7 @@ int mlx4_en_start_port(struct net_device *dev) ...@@ -1374,7 +1391,7 @@ int mlx4_en_start_port(struct net_device *dev)
priv->flags &= ~(MLX4_EN_FLAG_PROMISC | MLX4_EN_FLAG_MC_PROMISC); priv->flags &= ~(MLX4_EN_FLAG_PROMISC | MLX4_EN_FLAG_MC_PROMISC);
/* Schedule multicast task to populate multicast list */ /* Schedule multicast task to populate multicast list */
queue_work(mdev->workqueue, &priv->mcast_task); queue_work(mdev->workqueue, &priv->rx_mode_task);
mlx4_set_stats_bitmap(mdev->dev, &priv->stats_bitmap); mlx4_set_stats_bitmap(mdev->dev, &priv->stats_bitmap);
...@@ -1777,7 +1794,7 @@ static const struct net_device_ops mlx4_netdev_ops = { ...@@ -1777,7 +1794,7 @@ static const struct net_device_ops mlx4_netdev_ops = {
.ndo_start_xmit = mlx4_en_xmit, .ndo_start_xmit = mlx4_en_xmit,
.ndo_select_queue = mlx4_en_select_queue, .ndo_select_queue = mlx4_en_select_queue,
.ndo_get_stats = mlx4_en_get_stats, .ndo_get_stats = mlx4_en_get_stats,
.ndo_set_rx_mode = mlx4_en_set_multicast, .ndo_set_rx_mode = mlx4_en_set_rx_mode,
.ndo_set_mac_address = mlx4_en_set_mac, .ndo_set_mac_address = mlx4_en_set_mac,
.ndo_validate_addr = eth_validate_addr, .ndo_validate_addr = eth_validate_addr,
.ndo_change_mtu = mlx4_en_change_mtu, .ndo_change_mtu = mlx4_en_change_mtu,
...@@ -1847,7 +1864,7 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port, ...@@ -1847,7 +1864,7 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
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);
INIT_WORK(&priv->mcast_task, mlx4_en_do_set_multicast); INIT_WORK(&priv->rx_mode_task, mlx4_en_do_set_rx_mode);
INIT_WORK(&priv->mac_task, mlx4_en_do_set_mac); INIT_WORK(&priv->mac_task, mlx4_en_do_set_mac);
INIT_WORK(&priv->watchdog_task, mlx4_en_restart); INIT_WORK(&priv->watchdog_task, mlx4_en_restart);
INIT_WORK(&priv->linkstate_task, mlx4_en_linkstate); INIT_WORK(&priv->linkstate_task, mlx4_en_linkstate);
......
...@@ -504,7 +504,7 @@ struct mlx4_en_priv { ...@@ -504,7 +504,7 @@ struct mlx4_en_priv {
struct mlx4_en_cq *tx_cq; struct mlx4_en_cq *tx_cq;
struct mlx4_en_cq rx_cq[MAX_RX_RINGS]; struct mlx4_en_cq rx_cq[MAX_RX_RINGS];
struct mlx4_qp drop_qp; struct mlx4_qp drop_qp;
struct work_struct mcast_task; struct work_struct rx_mode_task;
struct work_struct mac_task; struct work_struct mac_task;
struct work_struct watchdog_task; struct work_struct watchdog_task;
struct work_struct linkstate_task; struct work_struct linkstate_task;
......
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