1. 28 8月, 2019 6 次提交
    • V
      net: dsa: clear VLAN PVID flag for CPU port · b9499904
      Vivien Didelot 提交于
      When the bridge offloads a VLAN on a slave port, we also need to
      program its dedicated CPU port as a member of the VLAN.
      
      Drivers may handle the CPU port's membership as they want. For example,
      Marvell as a special "Unmodified" mode to pass frames as is through
      such ports.
      
      Even though DSA expects the drivers to handle the CPU port membership,
      it does not make sense to program user VLANs as PVID on the CPU port.
      This patch clears this flag before programming the CPU port.
      Signed-off-by: NVivien Didelot <vivien.didelot@gmail.com>
      Suggested-by: NVladimir Oltean <olteanv@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      b9499904
    • V
      net: dsa: program VLAN on CPU port from slave · 7e1741b4
      Vivien Didelot 提交于
      DSA currently programs a VLAN on the CPU port implicitly after the
      related notifier is received by a switch.
      
      While we still need to do this transparent programmation of the DSA
      links in the fabric, programming the CPU port this way may cause
      problems in some corners such as the tag_8021q driver.
      
      Because the dedicated CPU port is specific to a slave, make their
      programmation explicit a few layers up, in the slave code.
      
      Note that technically, DSA links have a dedicated CPU port as well,
      but since they are only used as conduit between interconnected switches
      of a fabric, programming them transparently this way is what we want.
      Signed-off-by: NVivien Didelot <vivien.didelot@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      7e1741b4
    • V
      net: dsa: check bridge VLAN in slave operations · c5335d73
      Vivien Didelot 提交于
      The bridge VLANs are not offloaded by dsa_port_vlan_* if the port is
      not bridged or if its bridge is not VLAN aware.
      
      This is a good thing but other corners of DSA, such as the tag_8021q
      driver, may need to program VLANs regardless the bridge state.
      
      And also because bridge_dev is specific to user ports anyway, move
      these checks were it belongs, one layer up in the slave code.
      Signed-off-by: NVivien Didelot <vivien.didelot@gmail.com>
      Suggested-by: NVladimir Oltean <olteanv@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      c5335d73
    • V
      net: dsa: add slave VLAN helpers · bdcff080
      Vivien Didelot 提交于
      Add dsa_slave_vlan_add and dsa_slave_vlan_del helpers to handle
      SWITCHDEV_OBJ_ID_PORT_VLAN switchdev objects. Also copy the
      switchdev_obj_port_vlan structure on add since we will modify it in
      future patches.
      Signed-off-by: NVivien Didelot <vivien.didelot@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      bdcff080
    • V
      net: dsa: do not skip -EOPNOTSUPP in dsa_port_vid_add · cf360866
      Vivien Didelot 提交于
      Currently dsa_port_vid_add returns 0 if the switch returns -EOPNOTSUPP.
      
      This function is used in the tag_8021q.c code to offload the PVID of
      ports, which would simply not work if .port_vlan_add is not supported
      by the underlying switch.
      
      Do not skip -EOPNOTSUPP in dsa_port_vid_add but only when necessary,
      that is to say in dsa_slave_vlan_rx_add_vid.
      Signed-off-by: NVivien Didelot <vivien.didelot@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      cf360866
    • V
      net: dsa: remove bitmap operations · e65d45cc
      Vivien Didelot 提交于
      The bitmap operations were introduced to simplify the switch drivers
      in the future, since most of them could implement the common VLAN and
      MDB operations (add, del, dump) with simple functions taking all target
      ports at once, and thus limiting the number of hardware accesses.
      
      Programming an MDB or VLAN this way in a single operation would clearly
      simplify the drivers a lot but would require a new get-set interface
      in DSA. The usage of such bitmap from the stack also raised concerned
      in the past, leading to the dynamic allocation of a new ds->_bitmap
      member in the dsa_switch structure. So let's get rid of them for now.
      
      This commit nicely wraps the ds->ops->port_{mdb,vlan}_{prepare,add}
      switch operations into new dsa_switch_{mdb,vlan}_{prepare,add}
      variants not using any bitmap argument anymore.
      
      New dsa_switch_{mdb,vlan}_match helpers have been introduced to make
      clear which local port of a switch must be programmed with the target
      object. While the targeted user port is an obvious candidate, the
      DSA links must also be programmed, as well as the CPU port for VLANs.
      
      While at it, also remove local variables that are only used once.
      Signed-off-by: NVivien Didelot <vivien.didelot@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      e65d45cc
  2. 21 8月, 2019 2 次提交
  3. 18 8月, 2019 1 次提交
  4. 12 8月, 2019 1 次提交
    • C
      net: dsa: Check existence of .port_mdb_add callback before calling it · 58799865
      Chen-Yu Tsai 提交于
      The dsa framework has optional .port_mdb_{prepare,add,del} callback fields
      for drivers to handle multicast database entries. When adding an entry, the
      framework goes through a prepare phase, then a commit phase. Drivers not
      providing these callbacks should be detected in the prepare phase.
      
      DSA core may still bypass the bridge layer and call the dsa_port_mdb_add
      function directly with no prepare phase or no switchdev trans object,
      and the framework ends up calling an undefined .port_mdb_add callback.
      This results in a NULL pointer dereference, as shown in the log below.
      
      The other functions seem to be properly guarded. Do the same for
      .port_mdb_add in dsa_switch_mdb_add_bitmap() as well.
      
          8<--- cut here ---
          Unable to handle kernel NULL pointer dereference at virtual address 00000000
          pgd = (ptrval)
          [00000000] *pgd=00000000
          Internal error: Oops: 80000005 [#1] SMP ARM
          Modules linked in: rtl8xxxu rtl8192cu rtl_usb rtl8192c_common rtlwifi mac80211 cfg80211
          CPU: 1 PID: 134 Comm: kworker/1:2 Not tainted 5.3.0-rc1-00247-gd3519030752a #1
          Hardware name: Allwinner sun7i (A20) Family
          Workqueue: events switchdev_deferred_process_work
          PC is at 0x0
          LR is at dsa_switch_event+0x570/0x620
          pc : [<00000000>]    lr : [<c08533ec>]    psr: 80070013
          sp : ee871db8  ip : 00000000  fp : ee98d0a4
          r10: 0000000c  r9 : 00000008  r8 : ee89f710
          r7 : ee98d040  r6 : ee98d088  r5 : c0f04c48  r4 : ee98d04c
          r3 : 00000000  r2 : ee89f710  r1 : 00000008  r0 : ee98d040
          Flags: Nzcv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
          Control: 10c5387d  Table: 6deb406a  DAC: 00000051
          Process kworker/1:2 (pid: 134, stack limit = 0x(ptrval))
          Stack: (0xee871db8 to 0xee872000)
          1da0:                                                       ee871e14 103ace2d
          1dc0: 00000000 ffffffff 00000000 ee871e14 00000005 00000000 c08524a0 00000000
          1de0: ffffe000 c014bdfc c0f04c48 ee871e98 c0f04c48 ee9e5000 c0851120 c014bef0
          1e00: 00000000 b643aea2 ee9b4068 c08509a8 ee2bf940 ee89f710 ee871ecb 00000000
          1e20: 00000008 103ace2d 00000000 c087e248 ee29c868 103ace2d 00000001 ffffffff
          1e40: 00000000 ee871e98 00000006 00000000 c0fb2a50 c087e2d0 ffffffff c08523c4
          1e60: ffffffff c014bdfc 00000006 c0fad2d0 ee871e98 ee89f710 00000000 c014c500
          1e80: 00000000 ee89f3c0 c0f04c48 00000000 ee9e5000 c087dfb4 ee9e5000 00000000
          1ea0: ee89f710 ee871ecb 00000001 103ace2d 00000000 c0f04c48 00000000 c087e0a8
          1ec0: 00000000 efd9a3e0 0089f3c0 103ace2d ee89f700 ee89f710 ee9e5000 00000122
          1ee0: 00000100 c087e130 ee89f700 c0fad2c8 c1003ef0 c087de4c 2e928000 c0fad2ec
          1f00: c0fad2ec ee839580 ef7a62c0 ef7a9400 00000000 c087def8 c0fad2ec c01447dc
          1f20: ef315640 ef7a62c0 00000008 ee839580 ee839594 ef7a62c0 00000008 c0f03d00
          1f40: ef7a62d8 ef7a62c0 ffffe000 c0145b84 ffffe000 c0fb2420 c0bfaa8c 00000000
          1f60: ffffe000 ee84b600 ee84b5c0 00000000 ee870000 ee839580 c0145b40 ef0e5ea4
          1f80: ee84b61c c014a6f8 00000001 ee84b5c0 c014a5b0 00000000 00000000 00000000
          1fa0: 00000000 00000000 00000000 c01010e8 00000000 00000000 00000000 00000000
          1fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
          1fe0: 00000000 00000000 00000000 00000000 00000013 00000000 00000000 00000000
          [<c08533ec>] (dsa_switch_event) from [<c014bdfc>] (notifier_call_chain+0x48/0x84)
          [<c014bdfc>] (notifier_call_chain) from [<c014bef0>] (raw_notifier_call_chain+0x18/0x20)
          [<c014bef0>] (raw_notifier_call_chain) from [<c08509a8>] (dsa_port_mdb_add+0x48/0x74)
          [<c08509a8>] (dsa_port_mdb_add) from [<c087e248>] (__switchdev_handle_port_obj_add+0x54/0xd4)
          [<c087e248>] (__switchdev_handle_port_obj_add) from [<c087e2d0>] (switchdev_handle_port_obj_add+0x8/0x14)
          [<c087e2d0>] (switchdev_handle_port_obj_add) from [<c08523c4>] (dsa_slave_switchdev_blocking_event+0x94/0xa4)
          [<c08523c4>] (dsa_slave_switchdev_blocking_event) from [<c014bdfc>] (notifier_call_chain+0x48/0x84)
          [<c014bdfc>] (notifier_call_chain) from [<c014c500>] (blocking_notifier_call_chain+0x50/0x68)
          [<c014c500>] (blocking_notifier_call_chain) from [<c087dfb4>] (switchdev_port_obj_notify+0x44/0xa8)
          [<c087dfb4>] (switchdev_port_obj_notify) from [<c087e0a8>] (switchdev_port_obj_add_now+0x90/0x104)
          [<c087e0a8>] (switchdev_port_obj_add_now) from [<c087e130>] (switchdev_port_obj_add_deferred+0x14/0x5c)
          [<c087e130>] (switchdev_port_obj_add_deferred) from [<c087de4c>] (switchdev_deferred_process+0x64/0x104)
          [<c087de4c>] (switchdev_deferred_process) from [<c087def8>] (switchdev_deferred_process_work+0xc/0x14)
          [<c087def8>] (switchdev_deferred_process_work) from [<c01447dc>] (process_one_work+0x218/0x50c)
          [<c01447dc>] (process_one_work) from [<c0145b84>] (worker_thread+0x44/0x5bc)
          [<c0145b84>] (worker_thread) from [<c014a6f8>] (kthread+0x148/0x150)
          [<c014a6f8>] (kthread) from [<c01010e8>] (ret_from_fork+0x14/0x2c)
          Exception stack(0xee871fb0 to 0xee871ff8)
          1fa0:                                     00000000 00000000 00000000 00000000
          1fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
          1fe0: 00000000 00000000 00000000 00000000 00000013 00000000
          Code: bad PC value
          ---[ end trace 1292c61abd17b130 ]---
      
          [<c08533ec>] (dsa_switch_event) from [<c014bdfc>] (notifier_call_chain+0x48/0x84)
          corresponds to
      
      	$ arm-linux-gnueabihf-addr2line -C -i -e vmlinux c08533ec
      
      	linux/net/dsa/switch.c:156
      	linux/net/dsa/switch.c:178
      	linux/net/dsa/switch.c:328
      
      Fixes: e6db98db ("net: dsa: add switch mdb bitmap functions")
      Signed-off-by: NChen-Yu Tsai <wens@csie.org>
      Reviewed-by: NVivien Didelot <vivien.didelot@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      58799865
  5. 07 8月, 2019 4 次提交
    • V
      net: dsa: sja1105: Fix memory leak on meta state machine error path · 93fa8587
      Vladimir Oltean 提交于
      When RX timestamping is enabled and two link-local (non-meta) frames are
      received in a row, this constitutes an error.
      
      The tagger is always caching the last link-local frame, in an attempt to
      merge it with the meta follow-up frame when that arrives. To recover
      from the above error condition, the initial cached link-local frame is
      dropped and the second frame in a row is cached (in expectance of the
      second meta frame).
      
      However, when dropping the initial link-local frame, its backing memory
      was being leaked.
      
      Fixes: f3097be2 ("net: dsa: sja1105: Add a state machine for RX timestamping")
      Signed-off-by: NVladimir Oltean <olteanv@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      93fa8587
    • V
      net: dsa: sja1105: Fix memory leak on meta state machine normal path · f163fed2
      Vladimir Oltean 提交于
      After a meta frame is received, it is associated with the cached
      sp->data->stampable_skb from the DSA tagger private structure.
      
      Cached means its refcount is incremented with skb_get() in order for
      dsa_switch_rcv() to not free it when the tagger .rcv returns NULL.
      
      The mistake is that skb_unref() is not the correct function to use. It
      will correctly decrement the refcount (which will go back to zero) but
      the skb memory will not be freed.  That is the job of kfree_skb(), which
      also calls skb_unref().
      
      But it turns out that freeing the cached stampable_skb is in fact not
      necessary.  It is still a perfectly valid skb, and now it is even
      annotated with the partial RX timestamp.  So remove the skb_copy()
      altogether and simply pass the stampable_skb with a refcount of 1
      (incremented by us, decremented by dsa_switch_rcv) up the stack.
      
      Fixes: f3097be2 ("net: dsa: sja1105: Add a state machine for RX timestamping")
      Signed-off-by: NVladimir Oltean <olteanv@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      f163fed2
    • V
      net: dsa: dump CPU port regs through master · 48e23311
      Vivien Didelot 提交于
      Merge the CPU port registers dump into the master interface registers
      dump through ethtool, by nesting the ethtool_drvinfo and ethtool_regs
      structures of the CPU port into the dump.
      
      drvinfo->regdump_len will contain the full data length, while regs->len
      will contain only the master interface registers dump length.
      
      This allows for example to dump the CPU port registers on a ZII Dev
      C board like this:
      
          # ethtool -d eth1
          0x004:                                              0x00000000
          0x008:                                              0x0a8000aa
          0x010:                                              0x01000000
          0x014:                                              0x00000000
          0x024:                                              0xf0000102
          0x040:                                              0x6d82c800
          0x044:                                              0x00000020
          0x064:                                              0x40000000
          0x084: RCR (Receive Control Register)               0x47c00104
              MAX_FL (Maximum frame length)                   1984
              FCE (Flow control enable)                       0
              BC_REJ (Broadcast frame reject)                 0
              PROM (Promiscuous mode)                         0
              DRT (Disable receive on transmit)               0
              LOOP (Internal loopback)                        0
          0x0c4: TCR (Transmit Control Register)              0x00000004
              RFC_PAUSE (Receive frame control pause)         0
              TFC_PAUSE (Transmit frame control pause)        0
              FDEN (Full duplex enable)                       1
              HBC (Heartbeat control)                         0
              GTS (Graceful transmit stop)                    0
          0x0e4:                                              0x76735d6d
          0x0e8:                                              0x7e9e8808
          0x0ec:                                              0x00010000
          .
          .
          .
          88E6352  Switch Port Registers
          ------------------------------
          00: Port Status                            0x4d04
                Pause Enabled                        0
                My Pause                             1
                802.3 PHY Detected                   0
                Link Status                          Up
                Duplex                               Full
                Speed                                100 or 200 Mbps
                EEE Enabled                          0
                Transmitter Paused                   0
                Flow Control                         0
                Config Mode                          0x4
          01: Physical Control                       0x003d
                RGMII Receive Timing Control         Default
                RGMII Transmit Timing Control        Default
                200 BASE Mode                        100
                Flow Control's Forced value          0
                Force Flow Control                   0
                Link's Forced value                  Up
                Force Link                           1
                Duplex's Forced value                Full
                Force Duplex                         1
                Force Speed                          100 or 200 Mbps
          .
          .
          .
      Signed-off-by: NVivien Didelot <vivien.didelot@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      48e23311
    • M
      net: dsa: ksz: Drop NET_DSA_TAG_KSZ9477 · 267df70f
      Marek Vasut 提交于
      This Kconfig option is unused, drop it.
      Signed-off-by: NMarek Vasut <marex@denx.de>
      Cc: Andrew Lunn <andrew@lunn.ch>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: Tristram Ha <Tristram.Ha@microchip.com>
      Cc: Vivien Didelot <vivien.didelot@gmail.com>
      Cc: Woojung Huh <woojung.huh@microchip.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      267df70f
  6. 31 7月, 2019 1 次提交
  7. 20 7月, 2019 3 次提交
  8. 19 7月, 2019 1 次提交
  9. 10 7月, 2019 5 次提交
  10. 15 6月, 2019 3 次提交
  11. 14 6月, 2019 1 次提交
  12. 13 6月, 2019 1 次提交
  13. 09 6月, 2019 8 次提交
  14. 01 6月, 2019 1 次提交
    • V
      net: dsa: sja1105: Don't store frame type in skb->cb · e8d67fa5
      Vladimir Oltean 提交于
      Due to a confusion I thought that eth_type_trans() was called by the
      network stack whereas it can actually be called by network drivers to
      figure out the skb protocol and next packet_type handlers.
      
      In light of the above, it is not safe to store the frame type from the
      DSA tagger's .filter callback (first entry point on RX path), since GRO
      is yet to be invoked on the received traffic.  Hence it is very likely
      that the skb->cb will actually get overwritten between eth_type_trans()
      and the actual DSA packet_type handler.
      
      Of course, what this patch fixes is the actual overwriting of the
      SJA1105_SKB_CB(skb)->type field from the GRO layer, which made all
      frames be seen as SJA1105_FRAME_TYPE_NORMAL (0).
      
      Fixes: 227d07a0 ("net: dsa: sja1105: Add support for traffic through standalone ports")
      Signed-off-by: NVladimir Oltean <olteanv@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      e8d67fa5
  15. 31 5月, 2019 2 次提交
    • I
      net: dsa: Add error path handling in dsa_tree_setup() · e70c7aad
      Ioana Ciornei 提交于
      In case a call to dsa_tree_setup() fails, an attempt to cleanup is made
      by calling dsa_tree_remove_switch(), which should take care of
      removing/unregistering any resources previously allocated. This does not
      happen because it is conditioned by dst->setup being true, which is set
      only after _all_ setup steps were performed successfully.
      
      This is especially interesting when the internal MDIO bus is registered
      but afterwards, a port setup fails and the mdiobus_unregister() is never
      called. This leads to a BUG_ON() complaining about the fact that it's
      trying to free an MDIO bus that's still registered.
      
      Add proper error handling in all functions branching from
      dsa_tree_setup().
      Signed-off-by: NIoana Ciornei <ioana.ciornei@nxp.com>
      Reported-by: Nkernel test robot <rong.a.chen@intel.com>
      Reviewed-by: NAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      e70c7aad
    • V
      net: dsa: tag_8021q: Create a stable binary format · 0471dd42
      Vladimir Oltean 提交于
      Tools like tcpdump need to be able to decode the significance of fake
      VLAN headers that DSA uses to separate switch ports.
      
      But currently these have no global significance - they are simply an
      ordered list of DSA_MAX_SWITCHES x DSA_MAX_PORTS numbers ending at 4095.
      
      The reason why this is submitted as a fix is that the existing mapping
      of VIDs should not enter into a stable kernel, so we can pretend that
      only the new format exists. This way tcpdump won't need to try to make
      something out of the VLAN tags on 5.2 kernels.
      
      Fixes: f9bbe447 ("net: dsa: Optional VLAN-based port separation for switches without tagging")
      Signed-off-by: NVladimir Oltean <olteanv@gmail.com>
      Reviewed-by: NFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      0471dd42