1. 22 Jul, 2021 19 commits
    • Louis Peens's avatar
      nfp: flower-ct: add flow_pay to the offload table · 453cdc30
      Louis Peens authored
      Compile the offload flow metadata and add flow_pay to the offload
      table. Also add in the delete paths. This does not include actual
      offloading to the card yet, this will follow soon.
      Signed-off-by: default avatarLouis Peens <louis.peens@corigine.com>
      Signed-off-by: default avatarYinjun Zhang <yinjun.zhang@corigine.com>
      Signed-off-by: default avatarSimon Horman <simon.horman@corigine.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      453cdc30
    • Louis Peens's avatar
      nfp: flower-ct: add actions into flow_pay for offload · d94a63b4
      Louis Peens authored
      Combine the actions from the three different rules into one and
      convert into the payload format expected by the nfp.
      Signed-off-by: default avatarLouis Peens <louis.peens@corigine.com>
      Signed-off-by: default avatarYinjun Zhang <yinjun.zhang@corigine.com>
      Signed-off-by: default avatarSimon Horman <simon.horman@corigine.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d94a63b4
    • Louis Peens's avatar
      nfp: flower-ct: compile match sections of flow_payload · 5a2b9304
      Louis Peens authored
      Add in the code to compile match part of the payload that will be
      sent to the firmware. This works similar to match.c does it, but
      since three flows needs to be merged it iterates through all three
      rules in a loop and combine the match fields to get the most strict
      match as result.
      Signed-off-by: default avatarLouis Peens <louis.peens@corigine.com>
      Signed-off-by: default avatarYinjun Zhang <yinjun.zhang@corigine.com>
      Signed-off-by: default avatarSimon Horman <simon.horman@corigine.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      5a2b9304
    • Louis Peens's avatar
      nfp: flower-ct: calculate required key_layers · 71e88cfb
      Louis Peens authored
      This calculates the correct combined keylayers and key_layer_size
      for the to-be-offloaded flow.
      Signed-off-by: default avatarLouis Peens <louis.peens@corigine.com>
      Signed-off-by: default avatarYinjun Zhang <yinjun.zhang@corigine.com>
      Signed-off-by: default avatarSimon Horman <simon.horman@corigine.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      71e88cfb
    • Louis Peens's avatar
      nfp: flower: refactor action offload code slightly · e75dc265
      Louis Peens authored
      Change the action related offload functions to take in flow_rule *
      as input instead of flow_cls_offload * as input. The flow_rule
      parts of flow_cls_offload is the only part that is used in any
      case, and this is required for more conntrack offload patches
      which will follow later.
      Signed-off-by: default avatarLouis Peens <louis.peens@corigine.com>
      Signed-off-by: default avatarYinjun Zhang <yinjun.zhang@corigine.com>
      Signed-off-by: default avatarSimon Horman <simon.horman@corigine.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      e75dc265
    • Louis Peens's avatar
      nfp: flower: refactor match functions to take flow_rule as input · 4b15fb18
      Louis Peens authored
      This is a small cleanup to pass in flow->rule to some of the compile
      functions instead of extracting it every time. This is will also be
      useful for conntrack patches later.
      Signed-off-by: default avatarLouis Peens <louis.peens@corigine.com>
      Signed-off-by: default avatarYinjun Zhang <yinjun.zhang@corigine.com>
      Signed-off-by: default avatarSimon Horman <simon.horman@corigine.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      4b15fb18
    • Yinjun Zhang's avatar
      nfp: flower: make the match compilation functions reusable · 16416d37
      Yinjun Zhang authored
      Expose and refactor the match compilation functions so that they
      can be invoked externally. Also update the functions so they can
      be called multiple times with the results OR'd together. This is
      applicable for the flows-merging scenario, in which there could be
      overlapped and non-conflicting match fields. This will be used
      in upcoming conntrack patches. This is safe to do in the in the
      single call case as well since both unmasked_data and mask_data
      gets initialised to 0.
      Signed-off-by: default avatarYinjun Zhang <yinjun.zhang@corigine.com>
      Signed-off-by: default avatarLouis Peens <louis.peens@corigine.com>
      Signed-off-by: default avatarSimon Horman <simon.horman@corigine.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      16416d37
    • Oleksij Rempel's avatar
      net: selftests: add MTU test · 802a76af
      Oleksij Rempel authored
      Test if we actually can send/receive packets with MTU size. This kind of
      issue was detected on ASIX HW with bogus EEPROM.
      Signed-off-by: default avatarOleksij Rempel <o.rempel@pengutronix.de>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      802a76af
    • Oleksij Rempel's avatar
      net: usb: asix: ax88772: add missing stop · 9c267095
      Oleksij Rempel authored
      Add missing stop and let phylib framework suspend attached PHY.
      
      Fixes: e532a096 ("net: usb: asix: ax88772: add phylib support")
      Signed-off-by: default avatarOleksij Rempel <o.rempel@pengutronix.de>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      9c267095
    • Oleksij Rempel's avatar
      net: usb: asix: ax88772: do not poll for PHY before registering it · fdc362bf
      Oleksij Rempel authored
      asix_get_phyid() is used for two reasons here. To print debug message
      with the PHY ID and to wait until the PHY is powered up.
      
      After migrating to the phylib, we can read PHYID from sysfs. If polling
      for the PHY is really needed, then we will need to handle it in the
      phylib as well.
      
      This change was tested with:
      - ax88772a + internal PHY
      - ax88772b + external PHY
      Signed-off-by: default avatarOleksij Rempel <o.rempel@pengutronix.de>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      fdc362bf
    • Vladimir Oltean's avatar
      net: switchdev: fix FDB entries towards foreign ports not getting propagated to us · 2b0a5688
      Vladimir Oltean authored
      The newly introduced switchdev_handle_fdb_{add,del}_to_device helpers
      solved a problem but introduced another one. They have a severe design
      bug: they do not propagate FDB events on foreign interfaces to us, i.e.
      this use case:
      
               br0
              /   \
             /     \
            /       \
           /         \
         swp0       eno0
      (switchdev)  (foreign)
      
      when an address is learned on eno0, what is supposed to happen is that
      this event should also be propagated towards swp0. Somehow I managed to
      convince myself that this did work correctly, but obviously it does not.
      
      The trouble with foreign interfaces is that we must reach a switchdev
      net_device pointer through a foreign net_device that has no direct
      upper/lower relationship with it. So we need to do exploratory searching
      through the lower interfaces of the foreign net_device's bridge upper
      (to reach swp0 from eno0, we must check its upper, br0, for lower
      interfaces that pass the check_cb and foreign_dev_check_cb). This is
      something that the previous code did not do, it just assumed that "dev"
      will become a switchdev interface at some point, somehow, probably by
      magic.
      
      With this patch, assisted address learning on the CPU port works again
      in DSA:
      
      ip link add br0 type bridge
      ip link set swp0 master br0
      ip link set eno0 master br0
      ip link set br0 up
      
      [   46.708929] mscc_felix 0000:00:00.5 swp0: Adding FDB entry towards eno0, addr 00:04:9f:05:f4:ab vid 0 as host address
      
      Fixes: 8ca07176 ("net: switchdev: introduce a fanout helper for SWITCHDEV_FDB_{ADD,DEL}_TO_DEVICE")
      Reported-by: default avatarEric Woudstra <ericwouds@gmail.com>
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      2b0a5688
    • David S. Miller's avatar
      Merge branch 'bridge-port-offload' · f796fcd6
      David S. Miller authored
      Vladimir Oltean says:
      
      ====================
      Let switchdev drivers offload and unoffload bridge ports at their own convenience
      
      This series introduces an explicit API through which switchdev drivers
      mark a bridge port as offloaded or not:
      - switchdev_bridge_port_offload()
      - switchdev_bridge_port_unoffload()
      
      Currently, the bridge assumes that a port is offloaded if
      dev_get_port_parent_id(dev, &ppid, recurse=true) returns something, but
      that is just an assumption that breaks some use cases (like a
      non-offloaded LAG interface on top of a switchdev port, bridged with
      other switchdev ports).
      
      Along with some consolidation of the bridge logic to assign a "switchdev
      offloading mark" to a port (now better called a "hardware domain"), this
      series allows the bridge driver side to no longer impose restrictions on
      that configuration.
      
      Right now, all switchdev drivers must be modified to use the explicit
      API, but more and more logic can then be placed centrally in the bridge
      and therefore ease the job of a switchdev driver writer in the future.
      
      For example, the first thing we can hook into the explicit switchdev
      offloading API calls are the switchdev object and FDB replay helpers.
      So far, these have only been used by DSA in "pull" mode (where the
      driver must ask for them). Adding the replay helpers to other drivers
      involves a lot of repetition. But by moving the helpers inside the
      bridge port offload/unoffload hook points, we can move the entire replay
      process to "push" mode (where the bridge provides them automatically).
      
      The explicit switchdev offloading API will see further extensions in the
      future.
      
      The patches were split from a larger series for easier review:
      https://patchwork.kernel.org/project/netdevbpf/cover/20210718214434.3938850-1-vladimir.oltean@nxp.com/
      
      Changes in v6:
      - Make the switchdev replay helpers opt-in
      - Opt out of the replay helpers for mlxsw, rocker, prestera, sparx5,
        cpsw, am65-cpsw
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      f796fcd6
    • Vladimir Oltean's avatar
      net: bridge: move the switchdev object replay helpers to "push" mode · 4e51bf44
      Vladimir Oltean authored
      Starting with commit 4f2673b3 ("net: bridge: add helper to replay
      port and host-joined mdb entries"), DSA has introduced some bridge
      helpers that replay switchdev events (FDB/MDB/VLAN additions and
      deletions) that can be lost by the switchdev drivers in a variety of
      circumstances:
      
      - an IP multicast group was host-joined on the bridge itself before any
        switchdev port joined the bridge, leading to the host MDB entries
        missing in the hardware database.
      - during the bridge creation process, the MAC address of the bridge was
        added to the FDB as an entry pointing towards the bridge device
        itself, but with no switchdev ports being part of the bridge yet, this
        local FDB entry would remain unknown to the switchdev hardware
        database.
      - a VLAN/FDB/MDB was added to a bridge port that is a LAG interface,
        before any switchdev port joined that LAG, leading to the hardware
        database missing those entries.
      - a switchdev port left a LAG that is a bridge port, while the LAG
        remained part of the bridge, and all FDB/MDB/VLAN entries remained
        installed in the hardware database of the switchdev port.
      
      Also, since commit 0d2cfbd4 ("net: bridge: ignore switchdev events
      for LAG ports which didn't request replay"), DSA introduced a method,
      based on a const void *ctx, to ensure that two switchdev ports under the
      same LAG that is a bridge port do not see the same MDB/VLAN entry being
      replayed twice by the bridge, once for every bridge port that joins the
      LAG.
      
      With so many ordering corner cases being possible, it seems unreasonable
      to expect a switchdev driver writer to get it right from the first try.
      Therefore, now that DSA has experimented with the bridge replay helpers
      for a little bit, we can move the code to the bridge driver where it is
      more readily available to all switchdev drivers.
      
      To convert the switchdev object replay helpers from "pull mode" (where
      the driver asks for them) to a "push mode" (where the bridge offers them
      automatically), the biggest problem is that the bridge needs to be aware
      when a switchdev port joins and leaves, even when the switchdev is only
      indirectly a bridge port (for example when the bridge port is a LAG
      upper of the switchdev).
      
      Luckily, we already have a hook for that, in the form of the newly
      introduced switchdev_bridge_port_offload() and
      switchdev_bridge_port_unoffload() calls. These offer a natural place for
      hooking the object addition and deletion replays.
      
      Extend the above 2 functions with:
      - pointers to the switchdev atomic notifier (for FDB replays) and the
        blocking notifier (for MDB and VLAN replays).
      - the "const void *ctx" argument required for drivers to be able to
        disambiguate between which port is targeted, when multiple ports are
        lowers of the same LAG that is a bridge port. Most of the drivers pass
        NULL to this argument, except the ones that support LAG offload and have
        the proper context check already in place in the switchdev blocking
        notifier handler.
      
      Also unexport the replay helpers, since nobody except the bridge calls
      them directly now.
      
      Note that:
      (a) we abuse the terminology slightly, because FDB entries are not
          "switchdev objects", but we count them as objects nonetheless.
          With no direct way to prove it, I think they are not modeled as
          switchdev objects because those can only be installed by the bridge
          to the hardware (as opposed to FDB entries which can be propagated
          in the other direction too). This is merely an abuse of terms, FDB
          entries are replayed too, despite not being objects.
      (b) the bridge does not attempt to sync port attributes to newly joined
          ports, just the countable stuff (the objects). The reason for this
          is simple: no universal and symmetric way to sync and unsync them is
          known. For example, VLAN filtering: what to do on unsync, disable or
          leave it enabled? Similarly, STP state, ageing timer, etc etc. What
          a switchdev port does when it becomes standalone again is not really
          up to the bridge's competence, and the driver should deal with it.
          On the other hand, replaying deletions of switchdev objects can be
          seen a matter of cleanup and therefore be treated by the bridge,
          hence this patch.
      
      We make the replay helpers opt-in for drivers, because they might not
      bring immediate benefits for them:
      
      - nbp_vlan_init() is called _after_ netdev_master_upper_dev_link(),
        so br_vlan_replay() should not do anything for the new drivers on
        which we call it. The existing drivers where there was even a slight
        possibility for there to exist a VLAN on a bridge port before they
        join it are already guarded against this: mlxsw and prestera deny
        joining LAG interfaces that are members of a bridge.
      
      - br_fdb_replay() should now notify of local FDB entries, but I patched
        all drivers except DSA to ignore these new entries in commit
        2c4eca3e ("net: bridge: switchdev: include local flag in FDB
        notifications"). Driver authors can lift this restriction as they
        wish, and when they do, they can also opt into the FDB replay
        functionality.
      
      - br_mdb_replay() should fix a real issue which is described in commit
        4f2673b3 ("net: bridge: add helper to replay port and host-joined
        mdb entries"). However most drivers do not offload the
        SWITCHDEV_OBJ_ID_HOST_MDB to see this issue: only cpsw and am65_cpsw
        offload this switchdev object, and I don't completely understand the
        way in which they offload this switchdev object anyway. So I'll leave
        it up to these drivers' respective maintainers to opt into
        br_mdb_replay().
      
      So most of the drivers pass NULL notifier blocks for the replay helpers,
      except:
      - dpaa2-switch which was already acked/regression-tested with the
        helpers enabled (and there isn't much of a downside in having them)
      - ocelot which already had replay logic in "pull" mode
      - DSA which already had replay logic in "pull" mode
      
      An important observation is that the drivers which don't currently
      request bridge event replays don't even have the
      switchdev_bridge_port_{offload,unoffload} calls placed in proper places
      right now. This was done to avoid unnecessary rework for drivers which
      might never even add support for this. For driver writers who wish to
      add replay support, this can be used as a tentative placement guide:
      https://patchwork.kernel.org/project/netdevbpf/patch/20210720134655.892334-11-vladimir.oltean@nxp.com/
      
      Cc: Vadym Kochan <vkochan@marvell.com>
      Cc: Taras Chornyi <tchornyi@marvell.com>
      Cc: Ioana Ciornei <ioana.ciornei@nxp.com>
      Cc: Lars Povlsen <lars.povlsen@microchip.com>
      Cc: Steen Hegelund <Steen.Hegelund@microchip.com>
      Cc: UNGLinuxDriver@microchip.com
      Cc: Claudiu Manoil <claudiu.manoil@nxp.com>
      Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
      Cc: Grygorii Strashko <grygorii.strashko@ti.com>
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Acked-by: Ioana Ciornei <ioana.ciornei@nxp.com> # dpaa2-switch
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      4e51bf44
    • Vladimir Oltean's avatar
      net: bridge: guard the switchdev replay helpers against a NULL notifier block · 7105b50b
      Vladimir Oltean authored
      There is a desire to make the object and FDB replay helpers optional
      when moving them inside the bridge driver. For example a certain driver
      might not offload host MDBs and there is no case where the replay
      helpers would be of immediate use to it.
      
      So it would be nice if we could allow drivers to pass NULL pointers for
      the atomic and blocking notifier blocks, and the replay helpers to do
      nothing in that case.
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      7105b50b
    • Vladimir Oltean's avatar
      net: bridge: switchdev: let drivers inform which bridge ports are offloaded · 2f5dc00f
      Vladimir Oltean authored
      On reception of an skb, the bridge checks if it was marked as 'already
      forwarded in hardware' (checks if skb->offload_fwd_mark == 1), and if it
      is, it assigns the source hardware domain of that skb based on the
      hardware domain of the ingress port. Then during forwarding, it enforces
      that the egress port must have a different hardware domain than the
      ingress one (this is done in nbp_switchdev_allowed_egress).
      
      Non-switchdev drivers don't report any physical switch id (neither
      through devlink nor .ndo_get_port_parent_id), therefore the bridge
      assigns them a hardware domain of 0, and packets coming from them will
      always have skb->offload_fwd_mark = 0. So there aren't any restrictions.
      
      Problems appear due to the fact that DSA would like to perform software
      fallback for bonding and team interfaces that the physical switch cannot
      offload.
      
             +-- br0 ---+
            / /   |      \
           / /    |       \
          /  |    |      bond0
         /   |    |     /    \
       swp0 swp1 swp2 swp3 swp4
      
      There, it is desirable that the presence of swp3 and swp4 under a
      non-offloaded LAG does not preclude us from doing hardware bridging
      beteen swp0, swp1 and swp2. The bandwidth of the CPU is often times high
      enough that software bridging between {swp0,swp1,swp2} and bond0 is not
      impractical.
      
      But this creates an impossible paradox given the current way in which
      port hardware domains are assigned. When the driver receives a packet
      from swp0 (say, due to flooding), it must set skb->offload_fwd_mark to
      something.
      
      - If we set it to 0, then the bridge will forward it towards swp1, swp2
        and bond0. But the switch has already forwarded it towards swp1 and
        swp2 (not to bond0, remember, that isn't offloaded, so as far as the
        switch is concerned, ports swp3 and swp4 are not looking up the FDB,
        and the entire bond0 is a destination that is strictly behind the
        CPU). But we don't want duplicated traffic towards swp1 and swp2, so
        it's not ok to set skb->offload_fwd_mark = 0.
      
      - If we set it to 1, then the bridge will not forward the skb towards
        the ports with the same switchdev mark, i.e. not to swp1, swp2 and
        bond0. Towards swp1 and swp2 that's ok, but towards bond0? It should
        have forwarded the skb there.
      
      So the real issue is that bond0 will be assigned the same hardware
      domain as {swp0,swp1,swp2}, because the function that assigns hardware
      domains to bridge ports, nbp_switchdev_add(), recurses through bond0's
      lower interfaces until it finds something that implements devlink (calls
      dev_get_port_parent_id with bool recurse = true). This is a problem
      because the fact that bond0 can be offloaded by swp3 and swp4 in our
      example is merely an assumption.
      
      A solution is to give the bridge explicit hints as to what hardware
      domain it should use for each port.
      
      Currently, the bridging offload is very 'silent': a driver registers a
      netdevice notifier, which is put on the netns's notifier chain, and
      which sniffs around for NETDEV_CHANGEUPPER events where the upper is a
      bridge, and the lower is an interface it knows about (one registered by
      this driver, normally). Then, from within that notifier, it does a bunch
      of stuff behind the bridge's back, without the bridge necessarily
      knowing that there's somebody offloading that port. It looks like this:
      
           ip link set swp0 master br0
                        |
                        v
       br_add_if() calls netdev_master_upper_dev_link()
                        |
                        v
              call_netdevice_notifiers
                        |
                        v
             dsa_slave_netdevice_event
                        |
                        v
              oh, hey! it's for me!
                        |
                        v
                 .port_bridge_join
      
      What we do to solve the conundrum is to be less silent, and change the
      switchdev drivers to present themselves to the bridge. Something like this:
      
           ip link set swp0 master br0
                        |
                        v
       br_add_if() calls netdev_master_upper_dev_link()
                        |
                        v                    bridge: Aye! I'll use this
              call_netdevice_notifiers           ^  ppid as the
                        |                        |  hardware domain for
                        v                        |  this port, and zero
             dsa_slave_netdevice_event           |  if I got nothing.
                        |                        |
                        v                        |
              oh, hey! it's for me!              |
                        |                        |
                        v                        |
                 .port_bridge_join               |
                        |                        |
                        +------------------------+
                   switchdev_bridge_port_offload(swp0, swp0)
      
      Then stacked interfaces (like bond0 on top of swp3/swp4) would be
      treated differently in DSA, depending on whether we can or cannot
      offload them.
      
      The offload case:
      
          ip link set bond0 master br0
                        |
                        v
       br_add_if() calls netdev_master_upper_dev_link()
                        |
                        v                    bridge: Aye! I'll use this
              call_netdevice_notifiers           ^  ppid as the
                        |                        |  switchdev mark for
                        v                        |        bond0.
             dsa_slave_netdevice_event           | Coincidentally (or not),
                        |                        | bond0 and swp0, swp1, swp2
                        v                        | all have the same switchdev
              hmm, it's not quite for me,        | mark now, since the ASIC
               but my driver has already         | is able to forward towards
                 called .port_lag_join           | all these ports in hw.
                for it, because I have           |
            a port with dp->lag_dev == bond0.    |
                        |                        |
                        v                        |
                 .port_bridge_join               |
                 for swp3 and swp4               |
                        |                        |
                        +------------------------+
                  switchdev_bridge_port_offload(bond0, swp3)
                  switchdev_bridge_port_offload(bond0, swp4)
      
      And the non-offload case:
      
          ip link set bond0 master br0
                        |
                        v
       br_add_if() calls netdev_master_upper_dev_link()
                        |
                        v                    bridge waiting:
              call_netdevice_notifiers           ^  huh, switchdev_bridge_port_offload
                        |                        |  wasn't called, okay, I'll use a
                        v                        |  hwdom of zero for this one.
             dsa_slave_netdevice_event           :  Then packets received on swp0 will
                        |                        :  not be software-forwarded towards
                        v                        :  swp1, but they will towards bond0.
               it's not for me, but
             bond0 is an upper of swp3
            and swp4, but their dp->lag_dev
             is NULL because they couldn't
                  offload it.
      
      Basically we can draw the conclusion that the lowers of a bridge port
      can come and go, so depending on the configuration of lowers for a
      bridge port, it can dynamically toggle between offloaded and unoffloaded.
      Therefore, we need an equivalent switchdev_bridge_port_unoffload too.
      
      This patch changes the way any switchdev driver interacts with the
      bridge. From now on, everybody needs to call switchdev_bridge_port_offload
      and switchdev_bridge_port_unoffload, otherwise the bridge will treat the
      port as non-offloaded and allow software flooding to other ports from
      the same ASIC.
      
      Note that these functions lay the ground for a more complex handshake
      between switchdev drivers and the bridge in the future.
      
      For drivers that will request a replay of the switchdev objects when
      they offload and unoffload a bridge port (DSA, dpaa2-switch, ocelot), we
      place the call to switchdev_bridge_port_unoffload() strategically inside
      the NETDEV_PRECHANGEUPPER notifier's code path, and not inside
      NETDEV_CHANGEUPPER. This is because the switchdev object replay helpers
      need the netdev adjacency lists to be valid, and that is only true in
      NETDEV_PRECHANGEUPPER.
      
      Cc: Vadym Kochan <vkochan@marvell.com>
      Cc: Taras Chornyi <tchornyi@marvell.com>
      Cc: Ioana Ciornei <ioana.ciornei@nxp.com>
      Cc: Lars Povlsen <lars.povlsen@microchip.com>
      Cc: Steen Hegelund <Steen.Hegelund@microchip.com>
      Cc: UNGLinuxDriver@microchip.com
      Cc: Claudiu Manoil <claudiu.manoil@nxp.com>
      Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
      Cc: Grygorii Strashko <grygorii.strashko@ti.com>
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Tested-by: Ioana Ciornei <ioana.ciornei@nxp.com> # dpaa2-switch: regression
      Acked-by: Ioana Ciornei <ioana.ciornei@nxp.com> # dpaa2-switch
      Tested-by: Horatiu Vultur <horatiu.vultur@microchip.com> # ocelot-switch
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      2f5dc00f
    • Tobias Waldekranz's avatar
      net: bridge: switchdev: recycle unused hwdoms · 85826610
      Tobias Waldekranz authored
      Since hwdoms have only been used thus far for equality comparisons, the
      bridge has used the simplest possible assignment policy; using a
      counter to keep track of the last value handed out.
      
      With the upcoming transmit offloading, we need to perform set
      operations efficiently based on hwdoms, e.g. we want to answer
      questions like "has this skb been forwarded to any port within this
      hwdom?"
      
      Move to a bitmap-based allocation scheme that recycles hwdoms once all
      members leaves the bridge. This means that we can use a single
      unsigned long to keep track of the hwdoms that have received an skb.
      
      v1->v2: convert the typedef DECLARE_BITMAP(br_hwdom_map_t, BR_HWDOM_MAX)
              into a plain unsigned long.
      v2->v6: none
      Signed-off-by: default avatarTobias Waldekranz <tobias@waldekranz.com>
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      85826610
    • Tobias Waldekranz's avatar
      net: bridge: disambiguate offload_fwd_mark · f7cf972f
      Tobias Waldekranz authored
      Before this change, four related - but distinct - concepts where named
      offload_fwd_mark:
      
      - skb->offload_fwd_mark: Set by the switchdev driver if the underlying
        hardware has already forwarded this frame to the other ports in the
        same hardware domain.
      
      - nbp->offload_fwd_mark: An idetifier used to group ports that share
        the same hardware forwarding domain.
      
      - br->offload_fwd_mark: Counter used to make sure that unique IDs are
        used in cases where a bridge contains ports from multiple hardware
        domains.
      
      - skb->cb->offload_fwd_mark: The hardware domain on which the frame
        ingressed and was forwarded.
      
      Introduce the term "hardware forwarding domain" ("hwdom") in the
      bridge to denote a set of ports with the following property:
      
          If an skb with skb->offload_fwd_mark set, is received on a port
          belonging to hwdom N, that frame has already been forwarded to all
          other ports in hwdom N.
      
      By decoupling the name from "offload_fwd_mark", we can extend the
      term's definition in the future - e.g. to add constraints that
      describe expected egress behavior - without overloading the meaning of
      "offload_fwd_mark".
      
      - nbp->offload_fwd_mark thus becomes nbp->hwdom.
      
      - br->offload_fwd_mark becomes br->last_hwdom.
      
      - skb->cb->offload_fwd_mark becomes skb->cb->src_hwdom. The slight
        change in naming here mandates a slight change in behavior of the
        nbp_switchdev_frame_mark() function. Previously, it only set this
        value in skb->cb for packets with skb->offload_fwd_mark true (ones
        which were forwarded in hardware). Whereas now we always track the
        incoming hwdom for all packets coming from a switchdev (even for the
        packets which weren't forwarded in hardware, such as STP BPDUs, IGMP
        reports etc). As all uses of skb->cb->offload_fwd_mark were already
        gated behind checks of skb->offload_fwd_mark, this will not introduce
        any functional change, but it paves the way for future changes where
        the ingressing hwdom must be known for frames coming from a switchdev
        regardless of whether they were forwarded in hardware or not
        (basically, if the skb comes from a switchdev, skb->cb->src_hwdom now
        always tracks which one).
      
        A typical example where this is relevant: the switchdev has a fixed
        configuration to trap STP BPDUs, but STP is not running on the bridge
        and the group_fwd_mask allows them to be forwarded. Say we have this
        setup:
      
              br0
             / | \
            /  |  \
        swp0 swp1 swp2
      
        A BPDU comes in on swp0 and is trapped to the CPU; the driver does not
        set skb->offload_fwd_mark. The bridge determines that the frame should
        be forwarded to swp{1,2}. It is imperative that forward offloading is
        _not_ allowed in this case, as the source hwdom is already "poisoned".
      
        Recording the source hwdom allows this case to be handled properly.
      
      v2->v3: added code comments
      v3->v6: none
      Signed-off-by: default avatarTobias Waldekranz <tobias@waldekranz.com>
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Reviewed-by: default avatarGrygorii Strashko <grygorii.strashko@ti.com>
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      f7cf972f
    • Vladimir Oltean's avatar
      net: dpaa2-switch: refactor prechangeupper sanity checks · 45035feb
      Vladimir Oltean authored
      Make more room for some extra code in the NETDEV_PRECHANGEUPPER handler
      by moving what already exists into a dedicated function.
      
      Cc: Ioana Ciornei <ioana.ciornei@nxp.com>
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Acked-by: default avatarIoana Ciornei <ioana.ciornei@nxp.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      45035feb
    • Vladimir Oltean's avatar
      net: dpaa2-switch: use extack in dpaa2_switch_port_bridge_join · 123338d7
      Vladimir Oltean authored
      We need to propagate the extack argument for
      dpaa2_switch_port_bridge_join to use it in a future patch, and it looks
      like there is already an error message there which is currently printed
      to the console. Move it over netlink so it is properly transmitted to
      user space.
      
      Cc: Ioana Ciornei <ioana.ciornei@nxp.com>
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Tested-by: default avatarIoana Ciornei <ioana.ciornei@nxp.com>
      Acked-by: default avatarIoana Ciornei <ioana.ciornei@nxp.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      123338d7
  2. 21 Jul, 2021 21 commits
    • Leon Romanovsky's avatar
      ionic: cleanly release devlink instance · c2255ff4
      Leon Romanovsky authored
      The failure to register devlink will leave the system with dangled
      devlink resource, which is not cleaned if devlink_port_register() fails.
      
      In order to remove access to ".registered" field of struct devlink_port,
      require both devlink_register and devlink_port_register to success and
      check it through device pointer.
      
      Fixes: fbfb8031 ("ionic: Add hardware init and device commands")
      Reviewed-by: default avatarMoshe Shemesh <moshe@nvidia.com>
      Signed-off-by: default avatarLeon Romanovsky <leonro@nvidia.com>
      Acked-by: default avatarShannon Nelson <snelson@pensando.io>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c2255ff4
    • Nikolay Aleksandrov's avatar
      net: bridge: multicast: add context support for host-joined groups · 58d913a3
      Nikolay Aleksandrov authored
      Adding bridge multicast context support for host-joined groups is easy
      because we only need the proper timer value. We pass the already chosen
      context and use its timer value.
      Signed-off-by: default avatarNikolay Aleksandrov <nikolay@nvidia.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      58d913a3
    • Nikolay Aleksandrov's avatar
      net: bridge: multicast: add mdb context support · 6567cb43
      Nikolay Aleksandrov authored
      Choose the proper bridge multicast context when user-spaces is adding
      mdb entries. Currently we require the vlan to be configured on at least
      one device (port or bridge) in order to add an mdb entry if vlan
      mcast snooping is enabled (vlan snooping implies vlan filtering).
      Note that we always allow deleting an entry, regardless of the vlan state.
      Signed-off-by: default avatarNikolay Aleksandrov <nikolay@nvidia.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      6567cb43
    • Joakim Zhang's avatar
      ARM: dts: imx6qdl: move phy properties into phy device node · dabb5db1
      Joakim Zhang authored
      This patch fixes issues found by dtbs_check:
      make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- dtbs_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/net/fsl,fec.yaml
      
      According to the Micrel PHY dt-binding:
      Documentation/devicetree/bindings/net/micrel-ksz90x1.txt,
      Add clock delay in an Ethernet OF device node is deprecated, so move
      these properties to PHY OF device node.
      Suggested-by: default avatarRob Herring <robh@kernel.org>
      Signed-off-by: default avatarJoakim Zhang <qiangqing.zhang@nxp.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      dabb5db1
    • Joakim Zhang's avatar
      dt-bindings: net: fsl,fec: improve the binding a bit · 649502a3
      Joakim Zhang authored
      This patch improves the yaml a bit according to Rob Herring comments:
      1) normalize interrupt-names property, there is no reason to support
      random order.
      2) validate each string in clock-names property.
      3) add constraints for fsl,num-tx-queues/fsl,num-rx-queues property.
      4) change additionalProperties to false in order to do strict checking.
      Signed-off-by: default avatarJoakim Zhang <qiangqing.zhang@nxp.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      649502a3
    • Eric Dumazet's avatar
      tcp: tweak len/truesize ratio for coalesce candidates · 240bfd13
      Eric Dumazet authored
      tcp_grow_window() is using skb->len/skb->truesize to increase tp->rcv_ssthresh
      which has a direct impact on advertized window sizes.
      
      We added TCP coalescing in linux-3.4 & linux-3.5:
      
      Instead of storing skbs with one or two MSS in receive queue (or OFO queue),
      we try to append segments together to reduce memory overhead.
      
      High performance network drivers tend to cook skb with 3 parts :
      
      1) sk_buff structure (256 bytes)
      2) skb->head contains room to copy headers as needed, and skb_shared_info
      3) page fragment(s) containing the ~1514 bytes frame (or more depending on MTU)
      
      Once coalesced into a previous skb, 1) and 2) are freed.
      
      We can therefore tweak the way we compute len/truesize ratio knowing
      that skb->truesize is inflated by 1) and 2) soon to be freed.
      
      This is done only for in-order skb, or skb coalesced into OFO queue.
      
      The result is that low rate flows no longer pay the memory price of having
      low GRO aggregation factor. Same result for drivers not using GRO.
      
      This is critical to allow a big enough receiver window,
      typically tcp_rmem[2] / 2.
      
      We have been using this at Google for about 5 years, it is due time
      to make it upstream.
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Cc: Soheil Hassas Yeganeh <soheil@google.com>
      Cc: Neal Cardwell <ncardwell@google.com>
      Cc: Yuchung Cheng <ycheng@google.com>
      Acked-by: default avatarSoheil Hassas Yeganeh <soheil@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      240bfd13
    • Nikolay Aleksandrov's avatar
      net: bridge: multicast: fix igmp/mld port context null pointer dereferences · 54cb4319
      Nikolay Aleksandrov authored
      With the recent change to use bridge/port multicast context pointers
      instead of bridge/port I missed to convert two locations which pass the
      port pointer as-is, but with the new model we need to verify the port
      context is non-NULL first and retrieve the port from it. The first
      location is when doing querier selection when a query is received, the
      second location is when leaving a group. The port context will be null
      if the packets originated from the bridge device (i.e. from the host).
      The fix is simple just check if the port context exists and retrieve
      the port pointer from it.
      
      Fixes: adc47037 ("net: bridge: multicast: use multicast contexts instead of bridge or port")
      Signed-off-by: default avatarNikolay Aleksandrov <nikolay@nvidia.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      54cb4319
    • Leon Romanovsky's avatar
      ionic: drop useless check of PCI driver data validity · 524df92c
      Leon Romanovsky authored
      The driver core will call to .remove callback only if .probe succeeded
      and it will ensure that driver data has pointer to struct ionic.
      
      There is no need to check it again.
      
      Fixes: fbfb8031 ("ionic: Add hardware init and device commands")
      Signed-off-by: default avatarLeon Romanovsky <leonro@nvidia.com>
      Acked-by: default avatarShannon Nelson <snelson@pensando.io>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      524df92c
    • Eric Dumazet's avatar
      tcp: avoid indirect call in tcp_new_space() · 739b2adf
      Eric Dumazet authored
      For tcp sockets, sk->sk_write_space is most probably sk_stream_write_space().
      
      Other sk->sk_write_space() calls in TCP are slow path and do not deserve
      any change.
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      739b2adf
    • Andy Shevchenko's avatar
      net: wwan: iosm: Switch to use module_pci_driver() macro · 7f8b20d0
      Andy Shevchenko authored
      Eliminate some boilerplate code by using module_pci_driver() instead of
      init/exit, moving the salient bits from init into probe.
      Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Reviewed-by: default avatarLoic Poulain <loic.poulain@linaro.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      7f8b20d0
    • Dongliang Mu's avatar
      usb: hso: remove the bailout parameter · dcb713d5
      Dongliang Mu authored
      There are two invocation sites of hso_free_net_device. After
      refactoring hso_create_net_device, this parameter is useless.
      Remove the bailout in the hso_free_net_device and change the invocation
      sites of this function.
      Signed-off-by: default avatarDongliang Mu <mudongliangabcd@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      dcb713d5
    • Dongliang Mu's avatar
      usb: hso: fix error handling code of hso_create_net_device · 788e67f1
      Dongliang Mu authored
      The current error handling code of hso_create_net_device is
      hso_free_net_device, no matter which errors lead to. For example,
      WARNING in hso_free_net_device [1].
      
      Fix this by refactoring the error handling code of
      hso_create_net_device by handling different errors by different code.
      
      [1] https://syzkaller.appspot.com/bug?id=66eff8d49af1b28370ad342787413e35bbe76efe
      
      Reported-by: syzbot+44d53c7255bb1aea22d2@syzkaller.appspotmail.com
      Fixes: 5fcfb6d0 ("hso: fix bailout in error case of probe")
      Signed-off-by: default avatarDongliang Mu <mudongliangabcd@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      788e67f1
    • Piotr Kwapulinski's avatar
      i40e: add support for PTP external synchronization clock · 10507130
      Piotr Kwapulinski authored
      Add support for external synchronization clock via GPIOs.
      1PPS signals are handled via the dedicated 3 GPIOs: SDP3_2,
      SDP3_3 and GPIO_4.
      Previously it was not possible to use the external PTP
      synchronization clock.
      All possible HW configurations are supported.
      	SDP3_2,	SDP3_3,	GPIO_4
      	off,	off,	off
      	off,	in_A,	off
      	off,	out_A,	off
      	off,	in_B,	off
      	off,	out_B,	off
      	in_A,	off,	off
      	in_A,	in_B,	off
      	in_A,	out_B,	off
      	out_A,	off,	off
      	out_A,	in_B,	off
      	in_B,	off,	off
      	in_B,	in_A,	off
      	in_B,	out_A,	off
      	out_B,	off,	off
      	out_B,	in_A,	off
      	off,	off,	in_A
      	off,	out_A,	in_A
      	off,	in_B,	in_A
      	off,	out_B,	in_A
      	out_A,	off,	in_A
      	out_A,	in_B,	in_A
      	in_B,	off,	in_A
      	in_B,	out_A,	in_A
      	out_B,	off,	in_A
      	off,	off,	out_A
      	off,	in_A,	out_A
      	off,	in_B,	out_A
      	off,	out_B,	out_A
      	in_A,	off,	out_A
      	in_A,	in_B,	out_A
      	in_A,	out_B,	out_A
      	in_B,	off,	out_A
      	in_B,	in_A,	out_A
      	out_B,	off,	out_A
      	out_B,	in_A,	out_A
      	off,	off,	in_B
      	off,	in_A,	in_B
      	off,	out_A,	in_B
      	off,	out_B,	in_B
      	in_A,	off,	in_B
      	in_A,	out_B,	in_B
      	out_A,	off,	in_B
      	out_B,	off,	in_B
      	out_B,	in_A,	in_B
      	off,	off,	out_B
      	off,	in_A,	out_B
      	off,	out_A,	out_B
      	off,	in_B,	out_B
      	in_A,	off,	out_B
      	in_A,	in_B,	out_B
      	out_A,	off,	out_B
      	out_A,	in_B,	out_B
      	in_B,	off,	out_B
      	in_B,	in_A,	out_B
      	in_B,	out_A,	out_B
      
      Tested with oscilloscope, 1PPS generator and ts2phc.
      Reviewed-by: default avatarAleksandr Loktionov <aleksandr.loktionov@intel.com>
      Reviewed-by: default avatarArkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>
      Signed-off-by: default avatarPiotr Kwapulinski <piotr.kwapulinski@intel.com>
      Tested-by: default avatarAshish K <ashishx.k@intel.com>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      10507130
    • Vadim Fedorenko's avatar
      net: ipv4: Consolidate ipv4_mtu and ip_dst_mtu_maybe_forward · ac6627a2
      Vadim Fedorenko authored
      Consolidate IPv4 MTU code the same way it is done in IPv6 to have code
      aligned in both address families
      Signed-off-by: default avatarVadim Fedorenko <vfedorenko@novek.ru>
      Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      ac6627a2
    • Vadim Fedorenko's avatar
      net: ipv6: introduce ip6_dst_mtu_maybe_forward · 427faee1
      Vadim Fedorenko authored
      Replace ip6_dst_mtu_forward with ip6_dst_mtu_maybe_forward and
      reuse this code in ip6_mtu. Actually these two functions were
      almost duplicates, this change will simplify the maintaince of
      mtu calculation code.
      Signed-off-by: default avatarVadim Fedorenko <vfedorenko@novek.ru>
      Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      427faee1
    • David S. Miller's avatar
      Merge branch 'ipv6-ioam' · 7c804e91
      David S. Miller authored
      Justin Iurman says:
      
      ====================
      Support for the IOAM Pre-allocated Trace with IPv6
      
      v5:
       - Refine types, min/max and default values for new sysctls
       - Introduce a "_wide" sysctl for each "ioam6_id" sysctl
       - Add more validation on headers before processing data
       - RCU for sc <> ns pointers + appropriate accessors
       - Generic Netlink policies are now per op, not per family anymore
       - Address other comments/remarks from Jakub (thanks again)
       - Revert "__packed" to "__attribute__((packed))" for uapi headers
       - Add tests to cover the functionality added, as requested by David Ahern
      
      v4:
       - Address warnings from checkpatch (ignore errors related to unnamed bitfields
         in the first patch)
       - Use of hweight32 (thanks Jakub)
       - Remove inline keyword from static functions in C files and let the compiler
         decide what to do (thanks Jakub)
      
      v3:
       - Fix warning "unused label 'out_unregister_genl'" by adding conditional macro
       - Fix lwtunnel output redirect bug: dst cache useless in this case, use
         orig_output instead
      
      v2:
       - Fix warning with static for __ioam6_fill_trace_data
       - Fix sparse warning with __force when casting __be64 to __be32
       - Fix unchecked dereference when removing IOAM namespaces or schemas
       - exthdrs.c: Don't drop by default (now: ignore) to match the act bits "00"
       - Add control plane support for the inline insertion (lwtunnel)
       - Provide uapi structures
       - Use __net_timestamp if skb->tstamp is empty
       - Add note about the temporary IANA allocation
       - Remove support for "removable" TLVs
       - Remove support for virtual/anonymous tunnel decapsulation
      
      In-situ Operations, Administration, and Maintenance (IOAM) records
      operational and telemetry information in a packet while it traverses
      a path between two points in an IOAM domain. It is defined in
      draft-ietf-ippm-ioam-data [1]. IOAM data fields can be encapsulated
      into a variety of protocols. The IPv6 encapsulation is defined in
      draft-ietf-ippm-ioam-ipv6-options [2], via extension headers. IOAM
      can be used to complement OAM mechanisms based on e.g. ICMP or other
      types of probe packets.
      
      This patchset implements support for the Pre-allocated Trace, carried
      by a Hop-by-Hop. Therefore, a new IPv6 Hop-by-Hop TLV option is
      introduced, see IANA [3]. The three other IOAM options are not included
      in this patchset (Incremental Trace, Proof-of-Transit and Edge-to-Edge).
      The main idea behind the IOAM Pre-allocated Trace is that a node
      pre-allocates some room in packets for IOAM data. Then, each IOAM node
      on the path will insert its data. There exist several interesting use-
      cases, e.g. Fast failure detection/isolation or Smart service selection.
      Another killer use-case is what we have called Cross-Layer Telemetry,
      see the demo video on its repository [4], that aims to make the entire
      stack (L2/L3 -> L7) visible for distributed tracing tools (e.g. Jaeger),
      instead of the current L5 -> L7 limited view. So, basically, this is a
      nice feature for the Linux Kernel.
      
      This patchset also provides support for the control plane part, but only for the
      inline insertion (host-to-host use case), through lightweight tunnels. Indeed,
      for in-transit traffic, the solution is to have an IPv6-in-IPv6 encapsulation,
      which brings some difficulties and still requires a little bit of work and
      discussion (ie anonymous tunnel decapsulation and multi egress resolution).
      
      - Patch 1: IPv6 IOAM headers definition
      - Patch 2: Data plane support for Pre-allocated Trace
      - Patch 3: IOAM Generic Netlink API
      - Patch 4: Support for IOAM injection with lwtunnels
      - Patch 5: Documentation for new IOAM sysctls
      - Patch 6: Test for the IOAM insertion with IPv6
      
        [1] https://tools.ietf.org/html/draft-ietf-ippm-ioam-data
        [2] https://tools.ietf.org/html/draft-ietf-ippm-ioam-ipv6-options
        [3] https://www.iana.org/assignments/ipv6-parameters/ipv6-parameters.xhtml#ipv6-parameters-2
        [4] https://github.com/iurmanj/cross-layer-telemetry
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      7c804e91
    • Justin Iurman's avatar
      selftests: net: Test for the IOAM insertion with IPv6 · 968691c7
      Justin Iurman authored
      This test evaluates the IOAM insertion for IPv6 by checking the IOAM data
      integrity on the receiver.
      
      The topology is formed by 3 nodes: Alpha (sender), Beta (router in-between)
      and Gamma (receiver). An IOAM domain is configured from Alpha to Gamma only,
      which means not on the reverse path. When Gamma is the destination, Alpha
      adds an IOAM option (Pre-allocated Trace) inside a Hop-by-hop and fills the
      trace with its own IOAM data. Beta and Gamma also fill the trace. The IOAM
      data integrity is checked on Gamma, by comparing with the pre-defined IOAM
      configuration (see below).
      
          +-------------------+            +-------------------+
          |                   |            |                   |
          |    alpha netns    |            |    gamma netns    |
          |                   |            |                   |
          |  +-------------+  |            |  +-------------+  |
          |  |    veth0    |  |            |  |    veth0    |  |
          |  |  db01::2/64 |  |            |  |  db02::2/64 |  |
          |  +-------------+  |            |  +-------------+  |
          |         .         |            |         .         |
          +-------------------+            +-------------------+
                    .                                .
                    .                                .
                    .                                .
          +----------------------------------------------------+
          |         .                                .         |
          |  +-------------+                  +-------------+  |
          |  |    veth0    |                  |    veth1    |  |
          |  |  db01::1/64 | ................ |  db02::1/64 |  |
          |  +-------------+                  +-------------+  |
          |                                                    |
          |                      beta netns                    |
          |                                                    |
          +--------------------------+-------------------------+
      
      ~~~~~~~~~~~~~~~~~~~~~~
      | IOAM configuration |
      ~~~~~~~~~~~~~~~~~~~~~~
      
      Alpha
      +-----------------------------------------------------------+
      | Type                | Value                               |
      +-----------------------------------------------------------+
      | Node ID             | 1                                   |
      +-----------------------------------------------------------+
      | Node Wide ID        | 11111111                            |
      +-----------------------------------------------------------+
      | Ingress ID          | 0xffff (default value)              |
      +-----------------------------------------------------------+
      | Ingress Wide ID     | 0xffffffff (default value)          |
      +-----------------------------------------------------------+
      | Egress ID           | 101                                 |
      +-----------------------------------------------------------+
      | Egress Wide ID      | 101101                              |
      +-----------------------------------------------------------+
      | Namespace Data      | 0xdeadbee0                          |
      +-----------------------------------------------------------+
      | Namespace Wide Data | 0xcafec0caf00dc0de                  |
      +-----------------------------------------------------------+
      | Schema ID           | 777                                 |
      +-----------------------------------------------------------+
      | Schema Data         | something that will be 4n-aligned   |
      +-----------------------------------------------------------+
      
      Note: When Gamma is the destination, Alpha adds an IOAM Pre-allocated Trace
            option inside a Hop-by-hop, where 164 bytes are pre-allocated for the
            trace, with 123 as the IOAM-Namespace and with 0xfff00200 as the trace
            type (= all available options at this time). As a result, and based on
            IOAM configurations here, only both Alpha and Beta should be capable of
            inserting their IOAM data while Gamma won't have enough space and will
            set the overflow bit.
      
      Beta
      +-----------------------------------------------------------+
      | Type                | Value                               |
      +-----------------------------------------------------------+
      | Node ID             | 2                                   |
      +-----------------------------------------------------------+
      | Node Wide ID        | 22222222                            |
      +-----------------------------------------------------------+
      | Ingress ID          | 201                                 |
      +-----------------------------------------------------------+
      | Ingress Wide ID     | 201201                              |
      +-----------------------------------------------------------+
      | Egress ID           | 202                                 |
      +-----------------------------------------------------------+
      | Egress Wide ID      | 202202                              |
      +-----------------------------------------------------------+
      | Namespace Data      | 0xdeadbee1                          |
      +-----------------------------------------------------------+
      | Namespace Wide Data | 0xcafec0caf11dc0de                  |
      +-----------------------------------------------------------+
      | Schema ID           | 0xffffff (= None)                   |
      +-----------------------------------------------------------+
      | Schema Data         |                                     |
      +-----------------------------------------------------------+
      
      Gamma
      +-----------------------------------------------------------+
      | Type                | Value                               |
      +-----------------------------------------------------------+
      | Node ID             | 3                                   |
      +-----------------------------------------------------------+
      | Node Wide ID        | 33333333                            |
      +-----------------------------------------------------------+
      | Ingress ID          | 301                                 |
      +-----------------------------------------------------------+
      | Ingress Wide ID     | 301301                              |
      +-----------------------------------------------------------+
      | Egress ID           | 0xffff (default value)              |
      +-----------------------------------------------------------+
      | Egress Wide ID      | 0xffffffff (default value)          |
      +-----------------------------------------------------------+
      | Namespace Data      | 0xdeadbee2                          |
      +-----------------------------------------------------------+
      | Namespace Wide Data | 0xcafec0caf22dc0de                  |
      +-----------------------------------------------------------+
      | Schema ID           | 0xffffff (= None)                   |
      +-----------------------------------------------------------+
      | Schema Data         |                                     |
      +-----------------------------------------------------------+
      Signed-off-by: default avatarJustin Iurman <justin.iurman@uliege.be>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      968691c7
    • Justin Iurman's avatar
      ipv6: ioam: Documentation for new IOAM sysctls · de8e80a5
      Justin Iurman authored
      Add documentation for new IOAM sysctls:
       - ioam6_id and ioam6_id_wide: two per-namespace sysctls
       - ioam6_enabled, ioam6_id and ioam6_id_wide: three per-interface sysctls
      
      Example of IOAM configuration based on the following simple topology:
      
       _____              _____              _____
      |     | eth0  eth0 |     | eth1  eth0 |     |
      |  A  |.----------.|  B  |.----------.|  C  |
      |_____|            |_____|            |_____|
      
      1) Node and interface IDs can be configured for IOAM:
      
        # IOAM ID of A = 1, IOAM ID of A.eth0 = 11
        (A) sysctl -w net.ipv6.ioam6_id=1
        (A) sysctl -w net.ipv6.conf.eth0.ioam6_id=11
      
        # IOAM ID of B = 2, IOAM ID of B.eth0 = 21, IOAM ID of B.eth1 = 22
        (B) sysctl -w net.ipv6.ioam6_id=2
        (B) sysctl -w net.ipv6.conf.eth0.ioam6_id=21
        (B) sysctl -w net.ipv6.conf.eth1.ioam6_id=22
      
        # IOAM ID of C = 3, IOAM ID of C.eth0 = 31
        (C) sysctl -w net.ipv6.ioam6_id=3
        (C) sysctl -w net.ipv6.conf.eth0.ioam6_id=31
      
        Note that "_wide" IDs equivalents can be configured the same way.
      
      2) Each node can be configured to form an IOAM domain. For instance,
         we allow IOAM from A to C only (not the reverse path), i.e. enable
         IOAM on ingress for B.eth0 and C.eth0:
      
        (B) sysctl -w net.ipv6.conf.eth0.ioam6_enabled=1
        (C) sysctl -w net.ipv6.conf.eth0.ioam6_enabled=1
      
      3) An IOAM domain (e.g. ID=123) is defined and made known to each node:
      
        (A) ip ioam namespace add 123
        (B) ip ioam namespace add 123
        (C) ip ioam namespace add 123
      
      4) Finally, an IOAM Pre-allocated Trace can be inserted in traffic sent
         by A when C (e.g. db02::2) is the destination:
      
        (A) ip -6 route add db02::2/128 encap ioam6 trace type 0x800000 ns 123
            size 12 dev eth0
      Signed-off-by: default avatarJustin Iurman <justin.iurman@uliege.be>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      de8e80a5
    • Justin Iurman's avatar
      ipv6: ioam: Support for IOAM injection with lwtunnels · 3edede08
      Justin Iurman authored
      Add support for the IOAM inline insertion (only for the host-to-host use case)
      which is per-route configured with lightweight tunnels. The target is iproute2
      and the patch is ready. It will be posted as soon as this patchset is merged.
      Here is an overview:
      
      $ ip -6 ro ad fc00::1/128 encap ioam6 trace type 0x800000 ns 1 size 12 dev eth0
      
      This example configures an IOAM Pre-allocated Trace option attached to the
      fc00::1/128 prefix. The IOAM namespace (ns) is 1, the size of the pre-allocated
      trace data block is 12 octets (size) and only the first IOAM data (bit 0:
      hop_limit + node id) is included in the trace (type) represented as a bitfield.
      
      The reason why the in-transit (IPv6-in-IPv6 encapsulation) use case is not
      implemented is explained on the patchset cover.
      Signed-off-by: default avatarJustin Iurman <justin.iurman@uliege.be>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      3edede08
    • Justin Iurman's avatar
      ipv6: ioam: IOAM Generic Netlink API · 8c6f6fa6
      Justin Iurman authored
      Add Generic Netlink commands to allow userspace to configure IOAM
      namespaces and schemas. The target is iproute2 and the patch is ready.
      It will be posted as soon as this patchset is merged. Here is an overview:
      
      $ ip ioam
      Usage:	ip ioam { COMMAND | help }
      	ip ioam namespace show
      	ip ioam namespace add ID [ data DATA32 ] [ wide DATA64 ]
      	ip ioam namespace del ID
      	ip ioam schema show
      	ip ioam schema add ID DATA
      	ip ioam schema del ID
      	ip ioam namespace set ID schema { ID | none }
      Signed-off-by: default avatarJustin Iurman <justin.iurman@uliege.be>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      8c6f6fa6
    • Justin Iurman's avatar
      ipv6: ioam: Data plane support for Pre-allocated Trace · 9ee11f0f
      Justin Iurman authored
      Implement support for processing the IOAM Pre-allocated Trace with IPv6,
      see [1] and [2]. Introduce a new IPv6 Hop-by-Hop TLV option, see IANA [3].
      
      A new per-interface sysctl is introduced. The value is a boolean to accept (=1)
      or ignore (=0, by default) IPv6 IOAM options on ingress for an interface:
       - net.ipv6.conf.XXX.ioam6_enabled
      
      Two other sysctls are introduced to define IOAM IDs, represented by an integer.
      They are respectively per-namespace and per-interface:
       - net.ipv6.ioam6_id
       - net.ipv6.conf.XXX.ioam6_id
      
      The value of the first one represents the IOAM ID of the node itself (u32; max
      and default value = U32_MAX>>8, due to hop limit concatenation) while the other
      represents the IOAM ID of an interface (u16; max and default value = U16_MAX).
      
      Each "ioam6_id" sysctl has a "_wide" equivalent:
       - net.ipv6.ioam6_id_wide
       - net.ipv6.conf.XXX.ioam6_id_wide
      
      The value of the first one represents the wide IOAM ID of the node itself (u64;
      max and default value = U64_MAX>>8, due to hop limit concatenation) while the
      other represents the wide IOAM ID of an interface (u32; max and default value
      = U32_MAX).
      
      The use of short and wide equivalents is not exclusive, a deployment could
      choose to leverage both. For example, net.ipv6.conf.XXX.ioam6_id (short format)
      could be an identifier for a physical interface, whereas
      net.ipv6.conf.XXX.ioam6_id_wide (wide format) could be an identifier for a
      logical sub-interface. Documentation about new sysctls is provided at the end
      of this patchset.
      
      Two relativistic hash tables are used: one for IOAM namespaces, the other for
      IOAM schemas. A namespace can only have a single active schema and a schema
      can only be attached to a single namespace (1:1 relationship).
      
        [1] https://tools.ietf.org/html/draft-ietf-ippm-ioam-ipv6-options
        [2] https://tools.ietf.org/html/draft-ietf-ippm-ioam-data
        [3] https://www.iana.org/assignments/ipv6-parameters/ipv6-parameters.xhtml#ipv6-parameters-2Signed-off-by: default avatarJustin Iurman <justin.iurman@uliege.be>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      9ee11f0f