On Tue, Feb 23, 2016 at 4:53 AM, Paolo Abeni <pab...@redhat.com> wrote:
> This patch implements bookkeeping support to compute the maximum
> headroom for all the devices in each datapath. When said value
> changes, the underlying devs are notified via the
> ndo_set_rx_headroom method.
>
> This also increases the internal vports xmit performance.
>
> Signed-off-by: Paolo Abeni <pab...@redhat.com>
> ---
> net/openvswitch/datapath.c | 48
> ++++++++++++++++++++++++++++++++++++
> net/openvswitch/datapath.h | 4 +++
> net/openvswitch/vport-internal_dev.c | 10 +++++++-
> 3 files changed, 61 insertions(+), 1 deletion(-)
>
> diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
> index c4e8455..7b37288 100644
> --- a/net/openvswitch/datapath.c
> +++ b/net/openvswitch/datapath.c
> @@ -1908,6 +1908,34 @@ static struct vport *lookup_vport(struct net *net,
> return ERR_PTR(-EINVAL);
> }
>
> +/* Called with ovs_mutex */
> +static void update_headroom(struct datapath *dp)
> +{
> + int i;
> + struct vport *vport;
> + struct net_device *dev;
> + unsigned dev_headroom, max_headroom = 0;
> +
> + for (i = 0; i < DP_VPORT_HASH_BUCKETS; i++) {
> + hlist_for_each_entry_rcu(vport, &dp->ports[i], dp_hash_node) {
> + dev = vport->dev;
> + dev_headroom = netdev_get_fwd_headroom(dev);
> + if (dev_headroom > max_headroom)
> + max_headroom = dev_headroom;
> + }
> + }
> +
> + dp->max_headroom = max_headroom;
> + for (i = 0; i < DP_VPORT_HASH_BUCKETS; i++) {
> + hlist_for_each_entry_rcu(vport, &dp->ports[i], dp_hash_node) {
> + dev = vport->dev;
> + if (dev->netdev_ops->ndo_set_rx_headroom)
> + dev->netdev_ops->ndo_set_rx_headroom(dev,
> +
> max_headroom);
> + }
> + }
> +}
> +
Code looks fine. But It could be kept in sync with bridge code from patch 2.