1. 05 5月, 2022 4 次提交
  2. 25 4月, 2022 1 次提交
  3. 18 3月, 2022 2 次提交
    • V
      net: mscc: ocelot: offload per-flow mirroring using tc-mirred and VCAP IS2 · f2a0e216
      Vladimir Oltean 提交于
      Per-flow mirroring with the VCAP IS2 TCAM (in itself handled as an
      offload for tc-flower) is done by setting the MIRROR_ENA bit from the
      action vector of the filter. The packet is mirrored to the port mask
      configured in the ANA:ANA:MIRRORPORTS register (the same port mask as
      the destinations for port-based mirroring).
      
      Functionality was tested with:
      
      tc qdisc add dev swp3 clsact
      tc filter add dev swp3 ingress protocol ip \
      	flower skip_sw ip_proto icmp \
      	action mirred egress mirror dev swp1
      
      and pinging through swp3, while seeing that the ICMP replies are
      mirrored towards swp1.
      Signed-off-by: NVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      f2a0e216
    • V
      net: mscc: ocelot: establish functions for handling VCAP aux resources · c3d427ea
      Vladimir Oltean 提交于
      Some VCAP filters utilize resources which are global to the switch, like
      for example VCAP IS2 policers take an index into a global policer pool.
      
      In commit c9a7fe12 ("net: mscc: ocelot: add action of police on
      vcap_is2"), Xiaoliang expressed this by hooking into the low-level
      ocelot_vcap_filter_add_to_block() and ocelot_vcap_block_remove_filter()
      functions, and allocating/freeing the policers from there.
      
      Evaluating the code, there probably isn't a better place, but we'll need
      to do something similar for the mirror ports, and the code will start to
      look even more hacked up than it is right now.
      
      Create two ocelot_vcap_filter_{add,del}_aux_resources() functions to
      contain the madness, and pollute less the body of other functions such
      as ocelot_vcap_filter_add_to_block().
      Signed-off-by: NVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      c3d427ea
  4. 04 3月, 2022 2 次提交
  5. 17 2月, 2022 1 次提交
    • V
      net: mscc: ocelot: keep traps in a list · e42bd4ed
      Vladimir Oltean 提交于
      When using the ocelot-8021q tagging protocol, the CPU port isn't
      configured as an NPI port, but is a regular port. So a "trap to CPU"
      operation is actually a "redirect" operation. So DSA needs to set up the
      trapping action one way or another, depending on the tagging protocol in
      use.
      
      To ease DSA's work of modifying the action, keep all currently installed
      traps in a list, so that DSA can live-patch them when the tagging
      protocol changes.
      Signed-off-by: NVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      e42bd4ed
  6. 27 11月, 2021 1 次提交
    • V
      net: mscc: ocelot: create a function that replaces an existing VCAP filter · 95706be1
      Vladimir Oltean 提交于
      VCAP (Versatile Content Aware Processor) is the TCAM-based engine behind
      tc flower offload on ocelot, among other things. The ingress port mask
      on which VCAP rules match is present as a bit field in the actual key of
      the rule. This means that it is possible for a rule to be shared among
      multiple source ports. When the rule is added one by one on each desired
      port, that the ingress port mask of the key must be edited and rewritten
      to hardware.
      
      But the API in ocelot_vcap.c does not allow for this. For one thing,
      ocelot_vcap_filter_add() and ocelot_vcap_filter_del() are not symmetric,
      because ocelot_vcap_filter_add() works with a preallocated and
      prepopulated filter and programs it to hardware, and
      ocelot_vcap_filter_del() does both the job of removing the specified
      filter from hardware, as well as kfreeing it. That is to say, the only
      option of editing a filter in place, which is to delete it, modify the
      structure and add it back, does not work because it results in
      use-after-free.
      
      This patch introduces ocelot_vcap_filter_replace, which trivially
      reprograms a VCAP entry to hardware, at the exact same index at which it
      existed before, without modifying any list or allocating any memory.
      Signed-off-by: NVladimir Oltean <vladimir.oltean@nxp.com>
      Acked-by: NRichard Cochran <richardcochran@gmail.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      95706be1
  7. 18 11月, 2021 1 次提交
  8. 02 10月, 2021 1 次提交
  9. 11 3月, 2021 1 次提交
  10. 30 1月, 2021 3 次提交
    • V
      net: dsa: felix: perform switch setup for tag_8021q · e21268ef
      Vladimir Oltean 提交于
      Unlike sja1105, the only other user of the software-defined tag_8021q.c
      tagger format, the implementation we choose for the Felix DSA switch
      driver preserves full functionality under a vlan_filtering bridge
      (i.e. IP termination works through the DSA user ports under all
      circumstances).
      
      The tag_8021q protocol just wants:
      - Identifying the ingress switch port based on the RX VLAN ID, as seen
        by the CPU. We achieve this by using the TCAM engines (which are also
        used for tc-flower offload) to push the RX VLAN as a second, outer
        tag, on egress towards the CPU port.
      - Steering traffic injected into the switch from the network stack
        towards the correct front port based on the TX VLAN, and consuming
        (popping) that header on the switch's egress.
      
      A tc-flower pseudocode of the static configuration done by the driver
      would look like this:
      
      $ tc qdisc add dev <cpu-port> clsact
      $ for eth in swp0 swp1 swp2 swp3; do \
      	tc filter add dev <cpu-port> egress flower indev ${eth} \
      		action vlan push id <rxvlan> protocol 802.1ad; \
      	tc filter add dev <cpu-port> ingress protocol 802.1Q flower
      		vlan_id <txvlan> action vlan pop \
      		action mirred egress redirect dev ${eth}; \
      done
      
      but of course since DSA does not register network interfaces for the CPU
      port, this configuration would be impossible for the user to do. Also,
      due to the same reason, it is impossible for the user to inadvertently
      delete these rules using tc. These rules do not collide in any way with
      tc-flower, they just consume some TCAM space, which is something we can
      live with.
      Signed-off-by: NVladimir Oltean <vladimir.oltean@nxp.com>
      Reviewed-by: NFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      e21268ef
    • V
      net: mscc: ocelot: store a namespaced VCAP filter ID · 50c6cc5b
      Vladimir Oltean 提交于
      We will be adding some private VCAP filters that should not interfere in
      any way with the filters added using tc-flower. So we need to allocate
      some IDs which will not be used by tc.
      
      Currently ocelot uses an u32 id derived from the flow cookie, which in
      itself is an unsigned long. This is a problem in itself, since on 64 bit
      systems, sizeof(unsigned long)=8, so the driver is already truncating
      these.
      
      Create a struct ocelot_vcap_id which contains the full unsigned long
      cookie from tc, as well as a boolean that is supposed to namespace the
      filters added by tc with the ones that aren't.
      Signed-off-by: NVladimir Oltean <vladimir.oltean@nxp.com>
      Reviewed-by: NFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      50c6cc5b
    • V
      net: mscc: ocelot: export VCAP structures to include/soc/mscc · 0e9bb4e9
      Vladimir Oltean 提交于
      The Felix driver will need to preinstall some VCAP filters for its
      tag_8021q implementation (outside of the tc-flower offload logic), so
      these need to be exported to the common includes.
      Signed-off-by: NVladimir Oltean <vladimir.oltean@nxp.com>
      Reviewed-by: NFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      0e9bb4e9
  11. 03 10月, 2020 6 次提交
    • V
      net: mscc: ocelot: relax ocelot_exclusive_mac_etype_filter_rules() · f854e6f6
      Vladimir Oltean 提交于
      The issue which led to the introduction of this check was that MAC_ETYPE
      rules, such as filters on dst_mac and src_mac, would only match non-IP
      frames. There is a knob in VCAP_S2_CFG which forces all IP frames to be
      treated as non-IP, which is what we're currently doing if the user
      requested a dst_mac filter, in order to maintain sanity.
      
      But that knob is actually per IS2 lookup. And the good thing with
      exposing the lookups to the user via tc chains is that we're now able to
      offload MAC_ETYPE keys to one lookup, and IP keys to the other lookup.
      So let's do that.
      Signed-off-by: NVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      f854e6f6
    • V
      net: mscc: ocelot: only install TCAM entries into a specific lookup and PAG · 226e9cd8
      Vladimir Oltean 提交于
      We were installing TCAM rules with the LOOKUP field as unmasked, meaning
      that all entries were matching on all lookups. Now that lookups are
      exposed as individual chains, let's make the LOOKUP explicit when
      offloading TCAM entries.
      Signed-off-by: NVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      226e9cd8
    • X
      net: mscc: ocelot: offload egress VLAN rewriting to VCAP ES0 · 2f17c050
      Xiaoliang Yang 提交于
      VCAP ES0 is an egress VCAP operating on all outgoing frames.
      This patch added ES0 driver to support vlan push action of tc filter.
      Usage:
      
      tc filter add dev swp1 egress protocol 802.1Q flower indev swp0 skip_sw \
              vlan_id 1 vlan_prio 1 action vlan push id 2 priority 2
      Signed-off-by: NXiaoliang Yang <xiaoliang.yang_1@nxp.com>
      Signed-off-by: NVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      2f17c050
    • X
      net: mscc: ocelot: offload ingress skbedit and vlan actions to VCAP IS1 · 75944fda
      Xiaoliang Yang 提交于
      VCAP IS1 is a VCAP module which can filter on the most common L2/L3/L4
      Ethernet keys, and modify the results of the basic QoS classification
      and VLAN classification based on those flow keys.
      
      There are 3 VCAP IS1 lookups, mapped over chains 10000, 11000 and 12000.
      Currently the driver is hardcoded to use IS1_ACTION_TYPE_NORMAL half
      keys.
      
      Note that the VLAN_MANGLE has been omitted for now. In hardware, the
      VCAP_IS1_ACT_VID_REPLACE_ENA field replaces the classified VLAN
      (metadata associated with the frame) and not the VLAN from the header
      itself. There are currently some issues which need to be addressed when
      operating in standalone, or in bridge with vlan_filtering=0 modes,
      because in those cases the switch ports have VLAN awareness disabled,
      and changing the classified VLAN to anything other than the pvid causes
      the packets to be dropped. Another issue is that on egress, we expect
      port tagging to push the classified VLAN, but port tagging is disabled
      in the modes mentioned above, so although the classified VLAN is
      replaced, it is not visible in the packet transmitted by the switch.
      Signed-off-by: NXiaoliang Yang <xiaoliang.yang_1@nxp.com>
      Signed-off-by: NVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      75944fda
    • V
      net: mscc: ocelot: create TCAM skeleton from tc filter chains · 1397a2eb
      Vladimir Oltean 提交于
      For Ocelot switches, there are 2 ingress pipelines for flow offload
      rules: VCAP IS1 (Ingress Classification) and IS2 (Security Enforcement).
      IS1 and IS2 support different sets of actions. The pipeline order for a
      packet on ingress is:
      
      Basic classification -> VCAP IS1 -> VCAP IS2
      
      Furthermore, IS1 is looked up 3 times, and IS2 is looked up twice (each
      TCAM entry can be configured to match only on the first lookup, or only
      on the second, or on both etc).
      
      Because the TCAMs are completely independent in hardware, and because of
      the fixed pipeline, we actually have very limited options when it comes
      to offloading complex rules to them while still maintaining the same
      semantics with the software data path.
      
      This patch maps flow offload rules to ingress TCAMs according to a
      predefined chain index number. There is going to be a script in
      selftests that clarifies the usage model.
      
      There is also an egress TCAM (VCAP ES0, the Egress Rewriter), which is
      modeled on top of the default chain 0 of the egress qdisc, because it
      doesn't have multiple lookups.
      Suggested-by: NAllan W. Nielsen <allan.nielsen@microchip.com>
      Co-developed-by: NXiaoliang Yang <xiaoliang.yang_1@nxp.com>
      Signed-off-by: NXiaoliang Yang <xiaoliang.yang_1@nxp.com>
      Signed-off-by: NVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      1397a2eb
    • V
      net: mscc: ocelot: offload multiple tc-flower actions in same rule · ea9d1f30
      Vladimir Oltean 提交于
      At this stage, the tc-flower offload of mscc_ocelot can only delegate
      rules to the VCAP IS2 security enforcement block. These rules have, in
      hardware, separate bits for policing and for overriding the destination
      port mask and/or copying to the CPU. So it makes sense that we attempt
      to expose some more of that low-level complexity instead of simply
      choosing between a single type of action.
      
      Something similar happens with the VCAP IS1 block, where the same action
      can contain enable bits for VLAN classification and for QoS
      classification at the same time.
      
      So model the action structure after the hardware description, and let
      the high-level ocelot_flower.c construct an action vector from multiple
      tc actions.
      Signed-off-by: NVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      ea9d1f30
  12. 30 9月, 2020 8 次提交
  13. 21 6月, 2020 6 次提交
  14. 23 4月, 2020 1 次提交
    • V
      net: mscc: ocelot: refine the ocelot_ace_is_problematic_mac_etype function · 7dec902f
      Vladimir Oltean 提交于
      The commit mentioned below was a bit too harsh, and while it restricted
      the invalid key combinations which are known to not work, such as:
      
      tc filter add dev swp0 ingress proto ip \
            flower src_ip 192.0.2.1 action drop
      tc filter add dev swp0 ingress proto all \
            flower src_mac 00:11:22:33:44:55 action drop
      
      it also restricted some which still should work, such as:
      
      tc filter add dev swp0 ingress proto ip \
            flower src_ip 192.0.2.1 action drop
      tc filter add dev swp0 ingress proto 0x22f0 \
            flower src_mac 00:11:22:33:44:55 action drop
      
      What actually does not match "sanely" is a MAC_ETYPE rule on frames
      having an EtherType of ARP, IPv4, IPv6, in addition to SNAP and OAM
      frames (which the ocelot tc-flower implementation does not parse yet, so
      the function might need to be revisited again in the future).
      
      So just make the function recognize the problematic MAC_ETYPE rules by
      EtherType - thus the VCAP IS2 can be forced to match even on those
      packets.
      
      This patch makes it possible for IP rules to live on a port together
      with MAC_ETYPE rules that are non-all, non-arp, non-ip and non-ipv6.
      
      Fixes: d4d0cb741d7b ("net: mscc: ocelot: deal with problematic MAC_ETYPE VCAP IS2 rules")
      Reported-by: NAllan W. Nielsen <allan.nielsen@microchip.com>
      Signed-off-by: NVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      7dec902f
  15. 19 4月, 2020 1 次提交
    • V
      net: mscc: ocelot: deal with problematic MAC_ETYPE VCAP IS2 rules · 89f9ffd3
      Vladimir Oltean 提交于
      By default, the VCAP IS2 will produce a single match for each frame, on
      the most specific classification.
      
      Example: a ping packet (ICMP over IPv4 over Ethernet) sent from an IP
      address of 10.0.0.1 and a MAC address of 96:18:82:00:04:01 will match
      this rule:
      
      tc filter add dev swp0 ingress protocol ipv4 \
      	flower skip_sw src_ip 10.0.0.1 action drop
      
      but not this one:
      
      tc filter add dev swp0 ingress \
      	flower skip_sw src_mac 96:18:82:00:04:01 action drop
      
      Currently the driver does not really warn the user in any way about
      this, and the behavior is rather strange anyway.
      
      The current patch is a workaround to force matches on MAC_ETYPE keys
      (DMAC and SMAC) for all packets irrespective of higher layer protocol.
      The setting is made at the port level.
      
      Of course this breaks all other non-src_mac and non-dst_mac matches, so
      rule exclusivity checks have been added to the driver, in order to never
      have rules of both types on any ingress port.
      
      The bits that discard higher-level protocol information are set only
      once a MAC_ETYPE rule is added to a filter block, and only for the ports
      that are bound to that filter block. Then all further non-MAC_ETYPE
      rules added to that filter block should be denied by the ports bound to
      it.
      Signed-off-by: NVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      89f9ffd3
  16. 31 3月, 2020 1 次提交