Commit d0d7b10b authored by Parav Pandit's avatar Parav Pandit Committed by David S. Miller

net-next: treewide use is_vlan_dev() helper function.

This patch makes use of is_vlan_dev() function instead of flag
comparison which is exactly done by is_vlan_dev() helper function.
Signed-off-by: default avatarParav Pandit <parav@mellanox.com>
Reviewed-by: default avatarDaniel Jurgens <danielj@mellanox.com>
Acked-by: default avatarStephen Hemminger <stephen@networkplumber.org>
Acked-by: default avatarJon Maxwell <jmaxwell37@gmail.com>
Acked-by: default avatarJohannes Thumshirn <jth@kernel.org>
Acked-by: default avatarHaiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 73cfb2a2
...@@ -2467,14 +2467,12 @@ static int iboe_tos_to_sl(struct net_device *ndev, int tos) ...@@ -2467,14 +2467,12 @@ static int iboe_tos_to_sl(struct net_device *ndev, int tos)
struct net_device *dev; struct net_device *dev;
prio = rt_tos2priority(tos); prio = rt_tos2priority(tos);
dev = ndev->priv_flags & IFF_802_1Q_VLAN ? dev = is_vlan_dev(ndev) ? vlan_dev_real_dev(ndev) : ndev;
vlan_dev_real_dev(ndev) : ndev;
if (dev->num_tc) if (dev->num_tc)
return netdev_get_prio_tc_map(dev, prio); return netdev_get_prio_tc_map(dev, prio);
#if IS_ENABLED(CONFIG_VLAN_8021Q) #if IS_ENABLED(CONFIG_VLAN_8021Q)
if (ndev->priv_flags & IFF_802_1Q_VLAN) if (is_vlan_dev(ndev))
return (vlan_dev_get_egress_qos_mask(ndev, prio) & return (vlan_dev_get_egress_qos_mask(ndev, prio) &
VLAN_PRIO_MASK) >> VLAN_PRIO_SHIFT; VLAN_PRIO_MASK) >> VLAN_PRIO_SHIFT;
#endif #endif
......
...@@ -118,7 +118,7 @@ static struct device *dma_device(struct rxe_dev *rxe) ...@@ -118,7 +118,7 @@ static struct device *dma_device(struct rxe_dev *rxe)
ndev = rxe->ndev; ndev = rxe->ndev;
if (ndev->priv_flags & IFF_802_1Q_VLAN) if (is_vlan_dev(ndev))
ndev = vlan_dev_real_dev(ndev); ndev = vlan_dev_real_dev(ndev);
return ndev->dev.parent; return ndev->dev.parent;
......
...@@ -3665,7 +3665,7 @@ static int cnic_cm_destroy(struct cnic_sock *csk) ...@@ -3665,7 +3665,7 @@ static int cnic_cm_destroy(struct cnic_sock *csk)
static inline u16 cnic_get_vlan(struct net_device *dev, static inline u16 cnic_get_vlan(struct net_device *dev,
struct net_device **vlan_dev) struct net_device **vlan_dev)
{ {
if (dev->priv_flags & IFF_802_1Q_VLAN) { if (is_vlan_dev(dev)) {
*vlan_dev = vlan_dev_real_dev(dev); *vlan_dev = vlan_dev_real_dev(dev);
return vlan_dev_vlan_id(dev); return vlan_dev_vlan_id(dev);
} }
......
...@@ -351,7 +351,7 @@ struct l2t_entry *t3_l2t_get(struct t3cdev *cdev, struct dst_entry *dst, ...@@ -351,7 +351,7 @@ struct l2t_entry *t3_l2t_get(struct t3cdev *cdev, struct dst_entry *dst,
e->smt_idx = smt_idx; e->smt_idx = smt_idx;
atomic_set(&e->refcnt, 1); atomic_set(&e->refcnt, 1);
neigh_replace(e, neigh); neigh_replace(e, neigh);
if (neigh->dev->priv_flags & IFF_802_1Q_VLAN) if (is_vlan_dev(neigh->dev))
e->vlan = vlan_dev_vlan_id(neigh->dev); e->vlan = vlan_dev_vlan_id(neigh->dev);
else else
e->vlan = VLAN_NONE; e->vlan = VLAN_NONE;
......
...@@ -1805,7 +1805,7 @@ static void check_neigh_update(struct neighbour *neigh) ...@@ -1805,7 +1805,7 @@ static void check_neigh_update(struct neighbour *neigh)
const struct device *parent; const struct device *parent;
const struct net_device *netdev = neigh->dev; const struct net_device *netdev = neigh->dev;
if (netdev->priv_flags & IFF_802_1Q_VLAN) if (is_vlan_dev(netdev))
netdev = vlan_dev_real_dev(netdev); netdev = vlan_dev_real_dev(netdev);
parent = netdev->dev.parent; parent = netdev->dev.parent;
if (parent && parent->driver == &cxgb4_driver.driver) if (parent && parent->driver == &cxgb4_driver.driver)
...@@ -2111,7 +2111,7 @@ static int cxgb4_inet6addr_handler(struct notifier_block *this, ...@@ -2111,7 +2111,7 @@ static int cxgb4_inet6addr_handler(struct notifier_block *this,
#if IS_ENABLED(CONFIG_BONDING) #if IS_ENABLED(CONFIG_BONDING)
struct adapter *adap; struct adapter *adap;
#endif #endif
if (event_dev->priv_flags & IFF_802_1Q_VLAN) if (is_vlan_dev(event_dev))
event_dev = vlan_dev_real_dev(event_dev); event_dev = vlan_dev_real_dev(event_dev);
#if IS_ENABLED(CONFIG_BONDING) #if IS_ENABLED(CONFIG_BONDING)
if (event_dev->flags & IFF_MASTER) { if (event_dev->flags & IFF_MASTER) {
......
...@@ -432,7 +432,7 @@ struct l2t_entry *cxgb4_l2t_get(struct l2t_data *d, struct neighbour *neigh, ...@@ -432,7 +432,7 @@ struct l2t_entry *cxgb4_l2t_get(struct l2t_data *d, struct neighbour *neigh,
else else
lport = netdev2pinfo(physdev)->lport; lport = netdev2pinfo(physdev)->lport;
if (neigh->dev->priv_flags & IFF_802_1Q_VLAN) if (is_vlan_dev(neigh->dev))
vlan = vlan_dev_vlan_id(neigh->dev); vlan = vlan_dev_vlan_id(neigh->dev);
else else
vlan = VLAN_NONE; vlan = VLAN_NONE;
......
...@@ -3264,7 +3264,7 @@ netxen_list_config_ip(struct netxen_adapter *adapter, ...@@ -3264,7 +3264,7 @@ netxen_list_config_ip(struct netxen_adapter *adapter,
cur = kzalloc(sizeof(struct nx_ip_list), GFP_ATOMIC); cur = kzalloc(sizeof(struct nx_ip_list), GFP_ATOMIC);
if (cur == NULL) if (cur == NULL)
goto out; goto out;
if (dev->priv_flags & IFF_802_1Q_VLAN) if (is_vlan_dev(dev))
dev = vlan_dev_real_dev(dev); dev = vlan_dev_real_dev(dev);
cur->master = !!netif_is_bond_master(dev); cur->master = !!netif_is_bond_master(dev);
cur->ip_addr = ifa->ifa_address; cur->ip_addr = ifa->ifa_address;
...@@ -3374,7 +3374,7 @@ static void netxen_config_master(struct net_device *dev, unsigned long event) ...@@ -3374,7 +3374,7 @@ static void netxen_config_master(struct net_device *dev, unsigned long event)
!netif_is_bond_slave(dev)) { !netif_is_bond_slave(dev)) {
netxen_config_indev_addr(adapter, master, event); netxen_config_indev_addr(adapter, master, event);
for_each_netdev_rcu(&init_net, slave) for_each_netdev_rcu(&init_net, slave)
if (slave->priv_flags & IFF_802_1Q_VLAN && if (is_vlan_dev(slave) &&
vlan_dev_real_dev(slave) == master) vlan_dev_real_dev(slave) == master)
netxen_config_indev_addr(adapter, slave, event); netxen_config_indev_addr(adapter, slave, event);
} }
...@@ -3400,7 +3400,7 @@ static int netxen_netdev_event(struct notifier_block *this, ...@@ -3400,7 +3400,7 @@ static int netxen_netdev_event(struct notifier_block *this,
if (dev == NULL) if (dev == NULL)
goto done; goto done;
if (dev->priv_flags & IFF_802_1Q_VLAN) { if (is_vlan_dev(dev)) {
dev = vlan_dev_real_dev(dev); dev = vlan_dev_real_dev(dev);
goto recheck; goto recheck;
} }
...@@ -3445,7 +3445,7 @@ netxen_inetaddr_event(struct notifier_block *this, ...@@ -3445,7 +3445,7 @@ netxen_inetaddr_event(struct notifier_block *this,
if (dev == NULL) if (dev == NULL)
goto done; goto done;
if (dev->priv_flags & IFF_802_1Q_VLAN) { if (is_vlan_dev(dev)) {
dev = vlan_dev_real_dev(dev); dev = vlan_dev_real_dev(dev);
goto recheck; goto recheck;
} }
......
...@@ -4220,7 +4220,7 @@ static int qlcnic_netdev_event(struct notifier_block *this, ...@@ -4220,7 +4220,7 @@ static int qlcnic_netdev_event(struct notifier_block *this,
if (dev == NULL) if (dev == NULL)
goto done; goto done;
if (dev->priv_flags & IFF_802_1Q_VLAN) { if (is_vlan_dev(dev)) {
dev = vlan_dev_real_dev(dev); dev = vlan_dev_real_dev(dev);
goto recheck; goto recheck;
} }
...@@ -4256,7 +4256,7 @@ qlcnic_inetaddr_event(struct notifier_block *this, ...@@ -4256,7 +4256,7 @@ qlcnic_inetaddr_event(struct notifier_block *this,
if (dev == NULL) if (dev == NULL)
goto done; goto done;
if (dev->priv_flags & IFF_802_1Q_VLAN) { if (is_vlan_dev(dev)) {
dev = vlan_dev_real_dev(dev); dev = vlan_dev_real_dev(dev);
goto recheck; goto recheck;
} }
......
...@@ -1605,7 +1605,7 @@ static int netvsc_netdev_event(struct notifier_block *this, ...@@ -1605,7 +1605,7 @@ static int netvsc_netdev_event(struct notifier_block *this,
return NOTIFY_DONE; return NOTIFY_DONE;
/* Avoid Vlan dev with same MAC registering as VF */ /* Avoid Vlan dev with same MAC registering as VF */
if (event_dev->priv_flags & IFF_802_1Q_VLAN) if (is_vlan_dev(event_dev))
return NOTIFY_DONE; return NOTIFY_DONE;
/* Avoid Bonding master dev with same MAC registering as VF */ /* Avoid Bonding master dev with same MAC registering as VF */
......
...@@ -2282,7 +2282,7 @@ static int _bnx2fc_create(struct net_device *netdev, ...@@ -2282,7 +2282,7 @@ static int _bnx2fc_create(struct net_device *netdev,
} }
/* obtain physical netdev */ /* obtain physical netdev */
if (netdev->priv_flags & IFF_802_1Q_VLAN) if (is_vlan_dev(netdev))
phys_dev = vlan_dev_real_dev(netdev); phys_dev = vlan_dev_real_dev(netdev);
/* verify if the physical device is a netxtreme2 device */ /* verify if the physical device is a netxtreme2 device */
...@@ -2320,7 +2320,7 @@ static int _bnx2fc_create(struct net_device *netdev, ...@@ -2320,7 +2320,7 @@ static int _bnx2fc_create(struct net_device *netdev,
goto ifput_err; goto ifput_err;
} }
if (netdev->priv_flags & IFF_802_1Q_VLAN) { if (is_vlan_dev(netdev)) {
vlan_id = vlan_dev_vlan_id(netdev); vlan_id = vlan_dev_vlan_id(netdev);
interface->vlan_enabled = 1; interface->vlan_enabled = 1;
} }
...@@ -2538,7 +2538,7 @@ static bool bnx2fc_match(struct net_device *netdev) ...@@ -2538,7 +2538,7 @@ static bool bnx2fc_match(struct net_device *netdev)
struct net_device *phys_dev = netdev; struct net_device *phys_dev = netdev;
mutex_lock(&bnx2fc_dev_lock); mutex_lock(&bnx2fc_dev_lock);
if (netdev->priv_flags & IFF_802_1Q_VLAN) if (is_vlan_dev(netdev))
phys_dev = vlan_dev_real_dev(netdev); phys_dev = vlan_dev_real_dev(netdev);
if (bnx2fc_hba_lookup(phys_dev)) { if (bnx2fc_hba_lookup(phys_dev)) {
......
...@@ -223,7 +223,7 @@ struct cxgbi_device *cxgbi_device_find_by_netdev(struct net_device *ndev, ...@@ -223,7 +223,7 @@ struct cxgbi_device *cxgbi_device_find_by_netdev(struct net_device *ndev,
struct cxgbi_device *cdev, *tmp; struct cxgbi_device *cdev, *tmp;
int i; int i;
if (ndev->priv_flags & IFF_802_1Q_VLAN) { if (is_vlan_dev(ndev)) {
vdev = ndev; vdev = ndev;
ndev = vlan_dev_real_dev(ndev); ndev = vlan_dev_real_dev(ndev);
log_debug(1 << CXGBI_DBG_DEV, log_debug(1 << CXGBI_DBG_DEV,
...@@ -256,7 +256,7 @@ struct cxgbi_device *cxgbi_device_find_by_netdev_rcu(struct net_device *ndev, ...@@ -256,7 +256,7 @@ struct cxgbi_device *cxgbi_device_find_by_netdev_rcu(struct net_device *ndev,
struct cxgbi_device *cdev; struct cxgbi_device *cdev;
int i; int i;
if (ndev->priv_flags & IFF_802_1Q_VLAN) { if (is_vlan_dev(ndev)) {
vdev = ndev; vdev = ndev;
ndev = vlan_dev_real_dev(ndev); ndev = vlan_dev_real_dev(ndev);
pr_info("vlan dev %s -> %s.\n", vdev->name, ndev->name); pr_info("vlan dev %s -> %s.\n", vdev->name, ndev->name);
...@@ -290,7 +290,7 @@ static struct cxgbi_device *cxgbi_device_find_by_mac(struct net_device *ndev, ...@@ -290,7 +290,7 @@ static struct cxgbi_device *cxgbi_device_find_by_mac(struct net_device *ndev,
struct cxgbi_device *cdev, *tmp; struct cxgbi_device *cdev, *tmp;
int i; int i;
if (ndev->priv_flags & IFF_802_1Q_VLAN) { if (is_vlan_dev(ndev)) {
vdev = ndev; vdev = ndev;
ndev = vlan_dev_real_dev(ndev); ndev = vlan_dev_real_dev(ndev);
pr_info("vlan dev %s -> %s.\n", vdev->name, ndev->name); pr_info("vlan dev %s -> %s.\n", vdev->name, ndev->name);
......
...@@ -326,8 +326,7 @@ static int fcoe_interface_setup(struct fcoe_interface *fcoe, ...@@ -326,8 +326,7 @@ static int fcoe_interface_setup(struct fcoe_interface *fcoe,
/* look for SAN MAC address, if multiple SAN MACs exist, only /* look for SAN MAC address, if multiple SAN MACs exist, only
* use the first one for SPMA */ * use the first one for SPMA */
real_dev = (netdev->priv_flags & IFF_802_1Q_VLAN) ? real_dev = is_vlan_dev(netdev) ? vlan_dev_real_dev(netdev) : netdev;
vlan_dev_real_dev(netdev) : netdev;
fcoe->realdev = real_dev; fcoe->realdev = real_dev;
rcu_read_lock(); rcu_read_lock();
for_each_dev_addr(real_dev, ha) { for_each_dev_addr(real_dev, ha) {
...@@ -730,7 +729,7 @@ static int fcoe_netdev_config(struct fc_lport *lport, struct net_device *netdev) ...@@ -730,7 +729,7 @@ static int fcoe_netdev_config(struct fc_lport *lport, struct net_device *netdev)
ctlr = fcoe_to_ctlr(fcoe); ctlr = fcoe_to_ctlr(fcoe);
/* Figure out the VLAN ID, if any */ /* Figure out the VLAN ID, if any */
if (netdev->priv_flags & IFF_802_1Q_VLAN) if (is_vlan_dev(netdev))
lport->vlan = vlan_dev_vlan_id(netdev); lport->vlan = vlan_dev_vlan_id(netdev);
else else
lport->vlan = 0; lport->vlan = 0;
...@@ -959,13 +958,13 @@ static inline int fcoe_em_config(struct fc_lport *lport) ...@@ -959,13 +958,13 @@ static inline int fcoe_em_config(struct fc_lport *lport)
* Reuse existing offload em instance in case * Reuse existing offload em instance in case
* it is already allocated on real eth device * it is already allocated on real eth device
*/ */
if (fcoe->netdev->priv_flags & IFF_802_1Q_VLAN) if (is_vlan_dev(fcoe->netdev))
cur_real_dev = vlan_dev_real_dev(fcoe->netdev); cur_real_dev = vlan_dev_real_dev(fcoe->netdev);
else else
cur_real_dev = fcoe->netdev; cur_real_dev = fcoe->netdev;
list_for_each_entry(oldfcoe, &fcoe_hostlist, list) { list_for_each_entry(oldfcoe, &fcoe_hostlist, list) {
if (oldfcoe->netdev->priv_flags & IFF_802_1Q_VLAN) if (is_vlan_dev(oldfcoe->netdev))
old_real_dev = vlan_dev_real_dev(oldfcoe->netdev); old_real_dev = vlan_dev_real_dev(oldfcoe->netdev);
else else
old_real_dev = oldfcoe->netdev; old_real_dev = oldfcoe->netdev;
...@@ -1563,7 +1562,7 @@ static int fcoe_xmit(struct fc_lport *lport, struct fc_frame *fp) ...@@ -1563,7 +1562,7 @@ static int fcoe_xmit(struct fc_lport *lport, struct fc_frame *fp)
skb->protocol = htons(ETH_P_FCOE); skb->protocol = htons(ETH_P_FCOE);
skb->priority = fcoe->priority; skb->priority = fcoe->priority;
if (fcoe->netdev->priv_flags & IFF_802_1Q_VLAN && if (is_vlan_dev(fcoe->netdev) &&
fcoe->realdev->features & NETIF_F_HW_VLAN_CTAG_TX) { fcoe->realdev->features & NETIF_F_HW_VLAN_CTAG_TX) {
/* must set skb->dev before calling vlan_put_tag */ /* must set skb->dev before calling vlan_put_tag */
skb->dev = fcoe->realdev; skb->dev = fcoe->realdev;
...@@ -1794,7 +1793,7 @@ fcoe_hostlist_lookup_realdev_port(struct net_device *netdev) ...@@ -1794,7 +1793,7 @@ fcoe_hostlist_lookup_realdev_port(struct net_device *netdev)
struct net_device *real_dev; struct net_device *real_dev;
list_for_each_entry(fcoe, &fcoe_hostlist, list) { list_for_each_entry(fcoe, &fcoe_hostlist, list) {
if (fcoe->netdev->priv_flags & IFF_802_1Q_VLAN) if (is_vlan_dev(fcoe->netdev))
real_dev = vlan_dev_real_dev(fcoe->netdev); real_dev = vlan_dev_real_dev(fcoe->netdev);
else else
real_dev = fcoe->netdev; real_dev = fcoe->netdev;
......
...@@ -160,8 +160,7 @@ static inline int rdma_addr_gid_offset(struct rdma_dev_addr *dev_addr) ...@@ -160,8 +160,7 @@ static inline int rdma_addr_gid_offset(struct rdma_dev_addr *dev_addr)
static inline u16 rdma_vlan_dev_vlan_id(const struct net_device *dev) static inline u16 rdma_vlan_dev_vlan_id(const struct net_device *dev)
{ {
return dev->priv_flags & IFF_802_1Q_VLAN ? return is_vlan_dev(dev) ? vlan_dev_vlan_id(dev) : 0xffff;
vlan_dev_vlan_id(dev) : 0xffff;
} }
static inline int rdma_ip2gid(struct sockaddr *addr, union ib_gid *gid) static inline int rdma_ip2gid(struct sockaddr *addr, union ib_gid *gid)
...@@ -326,8 +325,7 @@ static inline u16 rdma_get_vlan_id(union ib_gid *dgid) ...@@ -326,8 +325,7 @@ static inline u16 rdma_get_vlan_id(union ib_gid *dgid)
static inline struct net_device *rdma_vlan_dev_real_dev(const struct net_device *dev) static inline struct net_device *rdma_vlan_dev_real_dev(const struct net_device *dev)
{ {
return dev->priv_flags & IFF_802_1Q_VLAN ? return is_vlan_dev(dev) ? vlan_dev_real_dev(dev) : NULL;
vlan_dev_real_dev(dev) : NULL;
} }
#endif /* IB_ADDR_H */ #endif /* IB_ADDR_H */
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "hsr_slave.h" #include "hsr_slave.h"
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include <linux/if_arp.h> #include <linux/if_arp.h>
#include <linux/if_vlan.h>
#include "hsr_main.h" #include "hsr_main.h"
#include "hsr_device.h" #include "hsr_device.h"
#include "hsr_forward.h" #include "hsr_forward.h"
...@@ -81,7 +82,7 @@ static int hsr_check_dev_ok(struct net_device *dev) ...@@ -81,7 +82,7 @@ static int hsr_check_dev_ok(struct net_device *dev)
return -EINVAL; return -EINVAL;
} }
if (dev->priv_flags & IFF_802_1Q_VLAN) { if (is_vlan_dev(dev)) {
netdev_info(dev, "HSR on top of VLAN is not yet supported in this driver.\n"); netdev_info(dev, "HSR on top of VLAN is not yet supported in this driver.\n");
return -EINVAL; return -EINVAL;
} }
......
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