[Bridge] [PATCH net-next v5 01/14] vlan: wrap hw-acceleration calls in separate functions.

Stephen Hemminger shemminger at vyatta.com
Thu Jan 10 18:25:25 UTC 2013


On Wed,  9 Jan 2013 12:17:48 -0500
Vlad Yasevich <vyasevic at redhat.com> wrote:

>  
>  /**
> + * vlan_hw_buggy - Check to see if VLAN hw acceleration is supported.
> + * @dev: netdevice of the lowerdev/hw nic
> + *
> + * Checks to see if HW and driver report VLAN acceleration correctly.
> + */
> +static inline bool vlan_hw_buggy(const struct net_device *dev)
> +{
> +	const struct net_device_ops *ops = dev->netdev_ops;
> +
> +	if ((dev->features & NETIF_F_HW_VLAN_FILTER) &&
> +	    (!ops->ndo_vlan_rx_add_vid || !ops->ndo_vlan_rx_kill_vid))
> +		return true;
> +
> +	return false;
> +}
> +
> +/**
> + * vlan_vid_add_hw - Add the VLAN vid to the HW filter
> + * @dev: netdevice of the lowerdev/hw nic
> + * @vid: vlan id.
> + *
> + * Inserts the vid into the HW vlan filter table if hw supports it.
> + */
> +static inline int vlan_vid_add_hw(struct net_device *dev,
> +				  unsigned short vid)
> +{
> +	const struct net_device_ops *ops = dev->netdev_ops;
> +	int err = 0;
> +
> +	if ((dev->features & NETIF_F_HW_VLAN_FILTER) &&
> +	    ops->ndo_vlan_rx_add_vid)
> +		err = ops->ndo_vlan_rx_add_vid(dev, vid);
> +
> +	return err;
> +}
> +
> +/**
> + * vlan_vid_del_hw - Delete the VLAN vid from the HW filter
> + * @dev: netdevice of the lowerdev/hw nic
> + * @vid: vlan id.
> + *
> + * Delete the vid from the HW vlan filter table if hw supports it.
> + */
> +static inline int vlan_vid_del_hw(struct net_device *dev,
> +				  unsigned short vid)
> +{
> +	const struct net_device_ops *ops = dev->netdev_ops;
> +	int err = 0;
> +
> +	if ((dev->features & NETIF_F_HW_VLAN_FILTER) &&
> +	    ops->ndo_vlan_rx_kill_vid)
> +		err = ops->ndo_vlan_rx_add_vid(dev, vid);
> +
> +	return err;
> +}
> +

I would rather not have all these inline's. This isn't performance critical.
Also, the check for buggy devices should be done inside the vlan code,
not repeated in the functions using the add/remove API. When device is
registered the flag and add/kill should be checked, and if the device driver
is buggy it should fail the register_netdevice.



More information about the Bridge mailing list