Re: [PATCH V4 mlx5-next 01/15] net/core: Introduce netdev_get_xmit_slave

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 4/22/20 2:39 AM, Maor Gottlieb wrote:
> diff --git a/net/core/dev.c b/net/core/dev.c
> index 9c9e763bfe0e..294553551ba5 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -7785,6 +7785,36 @@ void netdev_bonding_info_change(struct net_device *dev,
>  }
>  EXPORT_SYMBOL(netdev_bonding_info_change);
>  
> +/**
> + * netdev_get_xmit_slave - Get the xmit slave of master device
> + * @skb: The packet
> + * @all_slaves: assume all the slaves are active
> + *
> + * This can be called from any context and does its own locking.
> + * The returned handle has the usage count incremented and the caller must
> + * use dev_put() to release it when it is no longer needed.
> + * %NULL is returned if no slave is found.
> + */
> +
> +struct net_device *netdev_get_xmit_slave(struct net_device *dev,
> +					 struct sk_buff *skb,
> +					 bool all_slaves)
> +{
> +	const struct net_device_ops *ops = dev->netdev_ops;
> +	struct net_device *slave_dev;
> +
> +	if (!ops->ndo_get_xmit_slave)
> +		return NULL;
> +
> +	rcu_read_lock();
> +	slave_dev = ops->ndo_get_xmit_slave(dev, skb, all_slaves);
> +	if (slave_dev)
> +		dev_hold(slave_dev);
> +	rcu_read_unlock();
> +	return slave_dev;
> +}
> +EXPORT_SYMBOL(netdev_get_xmit_slave);
> +
>  static void netdev_adjacent_add_links(struct net_device *dev)
>  {
>  	struct netdev_adjacent *iter;
> 

The rcu_read_lock and reference seem overkill for a general purpose
helper. When this set goes in I want to make modifications for use with
XDP and that does not need either.

Looking at the mlx5 changes, you could easily handle that in the driver.



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux