IB/core: Move rdma_is_upper_dev_rcu to header file
In order to validate the route, we need an easy way to check if a net-device belongs to our RDMA device. Move this helper function to a header file in order to make this check easier. Signed-off-by: Matan Barak <matanb@mellanox.com> Reviewed-by: Haggai Eran <haggaie@mellanox.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
This commit is contained in:
parent
c865f24628
commit
6020d7e500
|
@ -96,4 +96,17 @@ int ib_cache_setup_one(struct ib_device *device);
|
|||
void ib_cache_cleanup_one(struct ib_device *device);
|
||||
void ib_cache_release_one(struct ib_device *device);
|
||||
|
||||
static inline bool rdma_is_upper_dev_rcu(struct net_device *dev,
|
||||
struct net_device *upper)
|
||||
{
|
||||
struct net_device *_upper = NULL;
|
||||
struct list_head *iter;
|
||||
|
||||
netdev_for_each_all_upper_dev_rcu(dev, _upper, iter)
|
||||
if (_upper == upper)
|
||||
break;
|
||||
|
||||
return _upper == upper;
|
||||
}
|
||||
|
||||
#endif /* _CORE_PRIV_H */
|
||||
|
|
|
@ -139,18 +139,6 @@ static enum bonding_slave_state is_eth_active_slave_of_bonding_rcu(struct net_de
|
|||
return BONDING_SLAVE_STATE_NA;
|
||||
}
|
||||
|
||||
static bool is_upper_dev_rcu(struct net_device *dev, struct net_device *upper)
|
||||
{
|
||||
struct net_device *_upper = NULL;
|
||||
struct list_head *iter;
|
||||
|
||||
netdev_for_each_all_upper_dev_rcu(dev, _upper, iter)
|
||||
if (_upper == upper)
|
||||
break;
|
||||
|
||||
return _upper == upper;
|
||||
}
|
||||
|
||||
#define REQUIRED_BOND_STATES (BONDING_SLAVE_STATE_ACTIVE | \
|
||||
BONDING_SLAVE_STATE_NA)
|
||||
static int is_eth_port_of_netdev(struct ib_device *ib_dev, u8 port,
|
||||
|
@ -168,7 +156,7 @@ static int is_eth_port_of_netdev(struct ib_device *ib_dev, u8 port,
|
|||
if (!real_dev)
|
||||
real_dev = event_ndev;
|
||||
|
||||
res = ((is_upper_dev_rcu(rdma_ndev, event_ndev) &&
|
||||
res = ((rdma_is_upper_dev_rcu(rdma_ndev, event_ndev) &&
|
||||
(is_eth_active_slave_of_bonding_rcu(rdma_ndev, real_dev) &
|
||||
REQUIRED_BOND_STATES)) ||
|
||||
real_dev == rdma_ndev);
|
||||
|
@ -214,7 +202,7 @@ static int upper_device_filter(struct ib_device *ib_dev, u8 port,
|
|||
return 1;
|
||||
|
||||
rcu_read_lock();
|
||||
res = is_upper_dev_rcu(rdma_ndev, event_ndev);
|
||||
res = rdma_is_upper_dev_rcu(rdma_ndev, event_ndev);
|
||||
rcu_read_unlock();
|
||||
|
||||
return res;
|
||||
|
@ -244,7 +232,7 @@ static void enum_netdev_default_gids(struct ib_device *ib_dev,
|
|||
rcu_read_lock();
|
||||
if (!rdma_ndev ||
|
||||
((rdma_ndev != event_ndev &&
|
||||
!is_upper_dev_rcu(rdma_ndev, event_ndev)) ||
|
||||
!rdma_is_upper_dev_rcu(rdma_ndev, event_ndev)) ||
|
||||
is_eth_active_slave_of_bonding_rcu(rdma_ndev,
|
||||
netdev_master_upper_dev_get_rcu(rdma_ndev)) ==
|
||||
BONDING_SLAVE_STATE_INACTIVE)) {
|
||||
|
@ -274,7 +262,7 @@ static void bond_delete_netdev_default_gids(struct ib_device *ib_dev,
|
|||
|
||||
rcu_read_lock();
|
||||
|
||||
if (is_upper_dev_rcu(rdma_ndev, event_ndev) &&
|
||||
if (rdma_is_upper_dev_rcu(rdma_ndev, event_ndev) &&
|
||||
is_eth_active_slave_of_bonding_rcu(rdma_ndev, real_dev) ==
|
||||
BONDING_SLAVE_STATE_INACTIVE) {
|
||||
unsigned long gid_type_mask;
|
||||
|
|
Loading…
Reference in a new issue