1. 03 Apr, 2017 15 commits
  2. 02 Apr, 2017 13 commits
    • David S. Miller's avatar
      Merge branch 'mpls-more-labels' · a6fc09df
      David S. Miller authored
      David Ahern says:
      
      ====================
      net: mpls: Allow users to configure more labels per route
      
      Increase the maximum number of new labels for MPLS routes from 2 to 30.
      
      To keep memory consumption in check, the labels array is moved to the end
      of mpls_nh and mpls_iptunnel_encap structs as a 0-sized array. Allocations
      use the maximum number of labels across all nexthops in a route for LSR
      and the number of labels configured for LWT.
      
      The mpls_route layout is changed to:
      
         +----------------------+
         | mpls_route           |
         +----------------------+
         | mpls_nh 0            |
         +----------------------+
         | alignment padding    |   4 bytes for odd number of labels; 0 for even
         +----------------------+
         | via[rt_max_alen] 0   |
         +----------------------+
         | alignment padding    |   via's aligned on sizeof(unsigned long)
         +----------------------+
         | ...                  |
      
      Meaning the via follows its mpls_nh providing better locality as the
      number of labels increases. UDP_RR tests with namespaces shows no impact
      to a modest performance increase with this layout for 1 or 2 labels and
      1 or 2 nexthops.
      
      mpls_route allocation size is limited to 4096 bytes allowing on the
      order of 30 nexthops with 30 labels (or more nexthops with fewer
      labels). LWT encap shares same maximum number of labels as mpls routing.
      
      v3
      - initialize n_labels to 0 in case RTA_NEWDST is not defined; detected
        by the kbuild test robot
      
      v2
      - updates per Eric's comments
        + added patch to ensure all reads of rt_nhn_alive and nh_flags in
          the packet path use READ_ONCE and all writes via event handlers
          use WRITE_ONCE
      
        + limit mpls_route size to 4096 (PAGE_SIZE for most arch)
      
        + mostly killed use of MAX_NEW_LABELS; it exists only for common
          limit between lwt and routing paths
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      a6fc09df
    • David Ahern's avatar
      net: mpls: Increase max number of labels for lwt encap · 1511009c
      David Ahern authored
      Alow users to push down more labels per MPLS encap. Similar to LSR case,
      move label array to the end of mpls_iptunnel_encap and allocate based on
      the number of labels for the route.
      
      For consistency with the LSR case, re-use the same maximum number of
      labels.
      Signed-off-by: default avatarDavid Ahern <dsa@cumulusnetworks.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      1511009c
    • David Ahern's avatar
      net: mpls: bump maximum number of labels · a4ac8c98
      David Ahern authored
      Allow users to push down more labels per MPLS route. With the previous
      patches, no memory allocations are based on MAX_NEW_LABELS; the limit
      is only used to keep userspace in check.
      
      At this point MAX_NEW_LABELS is only used for mpls_route_config (copying
      route data from userspace) and processing nexthops looking for the max
      number of labels across the route spec.
      Signed-off-by: default avatarDavid Ahern <dsa@cumulusnetworks.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      a4ac8c98
    • David Ahern's avatar
      net: mpls: Limit memory allocation for mpls_route · df1c6316
      David Ahern authored
      Limit memory allocation size for mpls_route to 4096.
      Signed-off-by: default avatarDavid Ahern <dsa@cumulusnetworks.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      df1c6316
    • David Ahern's avatar
      net: mpls: change mpls_route layout · 59b20966
      David Ahern authored
      Move labels to the end of mpls_nh as a 0-sized array and within mpls_route
      move the via for a nexthop after the mpls_nh. The new layout becomes:
      
         +----------------------+
         | mpls_route           |
         +----------------------+
         | mpls_nh 0            |
         +----------------------+
         | alignment padding    |   4 bytes for odd number of labels; 0 for even
         +----------------------+
         | via[rt_max_alen] 0   |
         +----------------------+
         | alignment padding    |   via's aligned on sizeof(unsigned long)
         +----------------------+
         | ...                  |
         +----------------------+
         | mpls_nh n-1          |
         +----------------------+
         | via[rt_max_alen] n-1 |
         +----------------------+
      
      Memory allocated for nexthop + via is constant across all nexthops and
      their via. It is based on the maximum number of labels across all nexthops
      and the maximum via length. The size is saved in the mpls_route as
      rt_nh_size. Accessing a nexthop becomes rt->rt_nh + index * rt->rt_nh_size.
      
      The offset of the via address from a nexthop is saved as rt_via_offset
      so that given an mpls_nh pointer the via for that hop is simply
      nh + rt->rt_via_offset.
      
      With prior code, memory allocated per mpls_route with 1 nexthop:
           via is an ethernet address - 64 bytes
           via is an ipv4 address     - 64
           via is an ipv6 address     - 72
      
      With this patch set, memory allocated per mpls_route with 1 nexthop and
      1 or 2 labels:
           via is an ethernet address - 56 bytes
           via is an ipv4 address     - 56
           via is an ipv6 address     - 64
      
      The 8-byte reduction is due to the previous patch; the change introduced
      by this patch has no impact on the size of allocations for 1 or 2 labels.
      
      Performance impact of this change was examined using network namespaces
      with veth pairs connecting namespaces. ns0 inserts the packet to the
      label-switched path using an lwt route with encap mpls. ns1 adds 1 or 2
      labels depending on test, ns2 (and ns3 for 2-label test) pops the label
      and forwards. ns3 (or ns4) for a 2-label is the destination. Similar
      series of namespaces used for 2-nexthop test.
      
      Intent is to measure changes to latency (overhead in manipulating the
      packet) in the forwarding path. Tests used netperf with UDP_RR.
      
      IPv4:                     current   patches
         1 label, 1 nexthop      29908     30115
         2 label, 1 nexthop      29071     29612
         1 label, 2 nexthop      29582     29776
         2 label, 2 nexthop      29086     29149
      
      IPv6:                     current   patches
         1 label, 1 nexthop      24502     24960
         2 label, 1 nexthop      24041     24407
         1 label, 2 nexthop      23795     23899
         2 label, 2 nexthop      23074     22959
      
      In short, the change has no effect to a modest increase in performance.
      This is expected since this patch does not really have an impact on routes
      with 1 or 2 labels (the current limit) and 1 or 2 nexthops.
      Signed-off-by: default avatarDavid Ahern <dsa@cumulusnetworks.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      59b20966
    • David Ahern's avatar
      net: mpls: Convert number of nexthops to u8 · 77ef013a
      David Ahern authored
      Number of nexthops and number of alive nexthops are tracked using an
      unsigned int. A route should never have more than 255 nexthops so
      convert both to u8. Update all references and intermediate variables
      to consistently use u8 as well.
      
      Shrinks the size of mpls_route from 32 bytes to 24 bytes with a 2-byte
      hole before the nexthops.
      Signed-off-by: default avatarDavid Ahern <dsa@cumulusnetworks.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      77ef013a
    • David Ahern's avatar
      net: mpls: rt_nhn_alive and nh_flags should be accessed using READ_ONCE · 39eb8cd1
      David Ahern authored
      The number of alive nexthops for a route (rt->rt_nhn_alive) and the
      flags for a next hop (nh->nh_flags) are modified by netdev event
      handlers. The event handlers run with rtnl_lock held so updates are
      always done with the lock held. The packet path accesses the fields
      under the rcu lock. Since those fields can change at any moment in
      the packet path, both fields should be accessed using READ_ONCE. Updates
      to both fields should use WRITE_ONCE.
      
      Update mpls_select_multipath (packet path) and mpls_ifdown and mpls_ifup
      (event handlers) accordingly.
      Signed-off-by: default avatarDavid Ahern <dsa@cumulusnetworks.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      39eb8cd1
    • Paolo Abeni's avatar
      udp: use sk_protocol instead of pcflag to detect udplite sockets · 3d8417d7
      Paolo Abeni authored
      In the udp_sock struct, the 'forward_deficit' and 'pcflag' fields
      share the same cacheline. While the first is dirtied by
      udp_recvmsg, the latter is read, possibly several times, by the
      bottom half processing to discriminate between udp and udplite
      sockets.
      
      With this patch, sk->sk_protocol is used to check is the socket is
      really an udplite one, avoiding some cache misses per
      packet and improving the performance under udp_flood with
      small packet up to 10%.
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      3d8417d7
    • Tobias Regnery's avatar
      net: dsa: fix build error with devlink build as module · 768bfa2a
      Tobias Regnery authored
      After commit 96567d5d ("net: dsa: dsa2: Add basic support of devlink")
      I see the following link error with CONFIG_NET_DSA=y and CONFIG_NET_DEVLINK=m:
      
      net/built-in.o: In function 'dsa_register_switch':
      (.text+0xe226b): undefined reference to `devlink_alloc'
      net/built-in.o: In function 'dsa_register_switch':
      (.text+0xe2284): undefined reference to `devlink_register'
      net/built-in.o: In function 'dsa_register_switch':
      (.text+0xe243e): undefined reference to `devlink_port_register'
      net/built-in.o: In function 'dsa_register_switch':
      (.text+0xe24e1): undefined reference to `devlink_port_register'
      net/built-in.o: In function 'dsa_register_switch':
      (.text+0xe24fa): undefined reference to `devlink_port_type_eth_set'
      net/built-in.o: In function 'dsa_dst_unapply.part.8':
      dsa2.c:(.text.unlikely+0x345): undefined reference to 'devlink_port_unregister'
      dsa2.c:(.text.unlikely+0x36c): undefined reference to 'devlink_port_unregister'
      dsa2.c:(.text.unlikely+0x38e): undefined reference to 'devlink_port_unregister'
      dsa2.c:(.text.unlikely+0x3f2): undefined reference to 'devlink_unregister'
      dsa2.c:(.text.unlikely+0x3fb): undefined reference to 'devlink_free'
      
      Fix this by adding a dependency on MAY_USE_DEVLINK so that CONFIG_NET_DSA
      get switched to be build as module when CONFIG_NET_DEVLINK=m.
      
      Fixes: 96567d5d ("net: dsa: dsa2: Add basic support of devlink")
      Signed-off-by: default avatarTobias Regnery <tobias.regnery@gmail.com>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      768bfa2a
    • David S. Miller's avatar
      Merge branch 'phylib-EEE-updates' · 88f913f5
      David S. Miller authored
      Russell King says:
      
      ====================
      phylib EEE updates
      
      This series of patches depends on the previous set of changes, and is
      therefore net-next material.
      
      While testing the EEE code, I discovered a number of issues:
      
      1. It is possible to enable advertisment of EEE modes which are not
         supported by the hardware.  We omit to check the supported modes
         and mask off those modes that are not supported before writing the
         EEE advertisment register.
      
      2. We need to restart autonegotiation after a change of the EEE
         advertisment, otherwise the link partner does not see the updated
         EEE modes.
      
      3. SGMII connected PHYs are also capable of supporting EEE.
      
      Through discussion with Florian, it has been decided to remove the check
      for the PHY interface mode in patch (3).
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      88f913f5
    • Russell King's avatar
      net: phy: allow EEE with any interface mode · 32d75141
      Russell King authored
      EEE is able to work in any PHY interface mode, there is nothing which
      fundamentally restricts it to only a few modes.  For example, EEE works
      in SGMII mode with the Marvell 88E1512.
      
      Rather than just adding SGMII mode to the list, Florian suggests
      removing the list of interface modes entirely:
      
        It actually sounds like we should just kill the check entirely,
        it does not appear that any of the interface mode would not
        fundamentally be able to support EEE, because the "lowest" mode
        we support is MII, and even there it's quite possible to support
        EEE.
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      32d75141
    • Russell King's avatar
      net: phy: restart phy autonegotiation after EEE advertisment change · f75abeb8
      Russell King authored
      When the EEE advertisment is changed, we should restart autonegotiation
      to update the link partner with the new EEE settings.  Add this trigger
      but only if the advertisment has changed.
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      f75abeb8
    • Russell King's avatar
      net: phy: avoid setting unsupported EEE advertisments · 83ea067f
      Russell King authored
      We currently allow userspace to set any EEE advertisments it desires,
      whether or not the PHY supports them.  For example:
      
       # ethtool --set-eee eth1 advertise 0xffffffff
       # ethtool --show-eee eth1
       EEE Settings for eth1:
              EEE status: disabled
              Tx LPI: disabled
              Supported EEE link modes:  100baseT/Full
                                         1000baseT/Full
                                         10000baseT/Full
              Advertised EEE link modes:  100baseT/Full
                                          1000baseT/Full
                                          1000baseKX/Full
                                          10000baseT/Full
                                          10000baseKX4/Full
                                          10000baseKR/Full
      
      Clearly, this is not sane, we should only allow link modes that are
      supported to be advertised (as we do elsewhere.)  Ensure that we mask
      the MDIO_AN_EEE_ADV value with the capabilities retrieved from the
      MDIO_PCS_EEE_ABLE register.
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      83ea067f
  3. 01 Apr, 2017 12 commits