1. 02 6月, 2021 24 次提交
  2. 01 6月, 2021 16 次提交
    • J
      net: hns3: add debugfs support for vlan configuration · 0ca821da
      Jian Shen 提交于
      Add debugfs support for vlan configuraion. create a single file
      "vlan_config" for it, and query it by command "cat vlan_config",
      return the result to userspace.
      
      The new display style is below:
      $ cat vlan_config
      I_PORT_VLAN_FILTER: on
      E_PORT_VLAN_FILTER: off
      FUNC_ID  I_VF_VLAN_FILTER  E_VF_VLAN_FILTER  PORT_VLAN_FILTER_BYPASS
      pf       off               on                off
      vf0      off               on                off
      FUNC_ID  PVID    ACCEPT_TAG1  ACCEPT_TAG2  ACCEPT_UNTAG1  ACCEPT_UNTAG2
      pf       0       on           on           on             on
      vf0      0       on           on           on             on
      Signed-off-by: NJian Shen <shenjian15@huawei.com>
      Signed-off-by: NHuazhong Tan <tanhuazhong@huawei.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      0ca821da
    • J
      net: hns3: add support for VF modify VLAN filter state · fa6a262a
      Jian Shen 提交于
      Previously, there is hardware limitation for VF to modify
      the VLAN filter state, and the VLAN filter state is default
      enabled. Now the limitation has been removed in some device,
      so add capability flag to check whether the device supports
      modify VLAN filter state. If flag on, user will be able to
      modify the VLAN filter state by ethtool -K.
      VF needs to send mailbox to request the PF to modify the VLAN
      filter state for it.
      Signed-off-by: NJian Shen <shenjian15@huawei.com>
      Signed-off-by: NHuazhong Tan <tanhuazhong@huawei.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      fa6a262a
    • J
      net: hns3: add query basic info support for VF · 32e6d104
      Jian Shen 提交于
      There are some features of VF depend on PF, so it's necessary
      for VF to know whether PF supports. For compatibility, modify
      the mailbox HCLGE_MBX_GET_TCINFO, extend its function, use to
      get the basic information of PF, including mailbox api version
      and PF capabilities.
      Signed-off-by: NJian Shen <shenjian15@huawei.com>
      Signed-off-by: NHuazhong Tan <tanhuazhong@huawei.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      32e6d104
    • J
      net: hns3: add support for modify VLAN filter state · 2ba30662
      Jian Shen 提交于
      Previously, with hardware limitation, the port VLAN filter are
      effective for both PF and its VFs simultaneously, so a single
      function is not able to enable/disable separately, and the VLAN
      filter state is default enabled. Now some device supports each
      function to bypass port VLAN filter, then each function can
      switch VLAN filter separately. Add capability flag to check
      whether the device supports modify VLAN filter state. If flag
      on, user will be able to modify the VLAN filter state by ethtool
      -K.
      
      Furtherly, the default VLAN filter state is also changed
      according to whether non-zero VLAN used. Then the device can
      receive packet with any VLAN tag if only VLAN 0 used.
      
      The function hclge_need_enable_vport_vlan_filter() is used to
      help implement above changes. And the VLAN filter handle for
      promisc mode can also be simplified by this function.
      Signed-off-by: NJian Shen <shenjian15@huawei.com>
      Signed-off-by: NHuazhong Tan <tanhuazhong@huawei.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      2ba30662
    • J
      net: hns3: refine function hclge_set_vf_vlan_cfg() · 060e9acc
      Jian Shen 提交于
      The struct hclge_vf_vlan_cfg is firstly designed for setting
      VLAN filter tag. And it's reused for enable RX VLAN offload
      later. It's strange to use member "is_kill" to indicate "enable".
      So redefine the struct hclge_vf_vlan_cfg to adapt it.
      
      For there are already 3 subcodes being used in function
      hclge_set_vf_vlan_cfg(), use "switch-case" style for each
      branch, rather than "if-else". Also simplify the assignment for
      each branch to make it more clearly.
      Signed-off-by: NJian Shen <shenjian15@huawei.com>
      Signed-off-by: NHuazhong Tan <tanhuazhong@huawei.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      060e9acc
    • J
      net: hns3: remove unnecessary updating port based VLAN · 132023de
      Jian Shen 提交于
      For the PF have called hclge_update_port_base_vlan_cfg() already
      before notify VF, it's unnecessary to update port based VLAN again
      when received mailbox request from VF.
      Signed-off-by: NJian Shen <shenjian15@huawei.com>
      Signed-off-by: NHuazhong Tan <tanhuazhong@huawei.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      132023de
    • J
      net: hns3: refine for hclge_push_vf_port_base_vlan_info() · f2dbf0ed
      Jian Shen 提交于
      Use struct "hclge_vlan_info" instead of separately parameters
      for function hclge_push_vf_port_base_vlan_info(), to make it
      more concise.
      Signed-off-by: NJian Shen <shenjian15@huawei.com>
      Signed-off-by: NHuazhong Tan <tanhuazhong@huawei.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      f2dbf0ed
    • J
      net: hns3: add 'QoS' support for port based VLAN configuration · b44eb28d
      Jian Shen 提交于
      Currently, option "qos" is igored by HNS3 driver for command
      "ip link set ethx vf <vf id> vlan <vlan id> qos <qos value>".
      Add support for it.
      Signed-off-by: NJian Shen <shenjian15@huawei.com>
      Signed-off-by: NHuazhong Tan <tanhuazhong@huawei.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      b44eb28d
    • V
      net: dsa: sja1105: some table entries are always present when read dynamically · 96c85f51
      Vladimir Oltean 提交于
      The SJA1105 has a static configuration comprised of a number of tables
      with entries. Some of these can be read and modified at runtime as well,
      through the dynamic configuration interface.
      
      As a careful reader can notice from the comments in this file, the
      software interface for accessing a table entry through the dynamic
      reconfiguration is a bit of a no man's land, and varies wildly across
      switch generations and even from one kind of table to another.
      
      I have tried my best to come up with a software representation of a
      'common denominator' SPI command to access a table entry through the
      dynamic configuration interface:
      
      struct sja1105_dyn_cmd {
      	bool search;
      	u64 valid; /* must be set to 1 */
      	u64 rdwrset; /* 0 to read, 1 to write */
      	u64 errors;
      	u64 valident; /* 0 if entry is invalid, 1 if valid */
      	u64 index;
      };
      
      Relevant to this patch is the VALIDENT bit, which for READ commands is
      populated by the switch and lets us know if we're looking at junk or at
      a real table entry.
      
      In SJA1105, the dynamic reconfiguration interface for management routes
      has notably not implemented the VALIDENT bit, leading to a workaround to
      ignore this field in sja1105_dynamic_config_read(), as it will be set to
      zero, but the data is valid nonetheless.
      
      In SJA1110, this pattern has sadly been abused to death, and while there
      are many more tables which can be read back over the dynamic config
      interface compared to SJA1105, their handling isn't in any way more
      uniform. Generally speaking, if there is a single possible entry in a
      given table, and loading that table in the static config is mandatory as
      per the documentation, then the VALIDENT bit is deemed as redundant and
      more than likely not implemented.
      
      So it is time to make the workaround more official, and add a bit to the
      flags implemented by dynamic config tables. It will be used by more
      tables when SJA1110 support arrives.
      Signed-off-by: NVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      96c85f51
    • V
      net: dsa: sja1105: always keep RGMII ports in the MAC role · f41fad3c
      Vladimir Oltean 提交于
      In SJA1105, the xMII Mode Parameters Table field called PHY_MAC denotes
      the 'role' of the port, be it a PHY or a MAC. This makes a difference in
      the MII and RMII protocols, but RGMII is symmetric, so either PHY or MAC
      settings result in the same hardware behavior.
      
      The SJA1110 is different, and the RGMII ports only work when configured
      in MAC mode, so keep the port roles in MAC mode unconditionally.
      
      Why we had an RGMII port in the PHY role in the first place was because
      we wanted to have a way in the driver to denote whether RGMII delays
      should be applied based on the phy-mode property or not. This is already
      done in sja1105_parse_rgmii_delays() based on an intermediary
      struct sja1105_dt_port (which contains the port role). So it is a
      logical fallacy to use the hardware configuration as a scratchpad for
      driver data, it isn't necessary.
      
      We can also remove the gating condition for applying RGMII delays only
      for ports in the PHY role. The .setup_rgmii_delay() method looks at
      the priv->rgmii_rx_delay[port] and priv->rgmii_tx_delay[port] properties
      which are already populated properly (in the case of a port in the MAC
      role they are false). Removing this condition generates a few more SPI
      writes for these ports (clearing the RGMII delays) which are perhaps
      useless for SJA1105P/Q/R/S, where we know that the delays are disabled
      by default. But for SJA1110, the firmware on the embedded microcontroller
      might have done something funny, so it's always a good idea to clear the
      RGMII delays if that's what Linux expects.
      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>
      f41fad3c
    • V
      net: dsa: sja1105: add a translation table for port speeds · 41fed17f
      Vladimir Oltean 提交于
      In order to support the new speed of 2500Mbps, the SJA1110 has achieved
      the great performance of changing the encoding in the MAC Configuration
      Table for the port speeds of 10, 100, 1000 compared to SJA1105.
      
      Because this is a common driver, we need a layer of indirection in order
      to program the hardware with the right values irrespective of switch
      generation.
      Signed-off-by: NVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      41fed17f
    • V
      net: dsa: sja1105: add a PHY interface type compatibility matrix · 91a05078
      Vladimir Oltean 提交于
      On the SJA1105, all ports support the parallel "xMII" protocols (MII,
      RMII, RGMII) except for port 4 on SJA1105R/S which supports only SGMII.
      This was relatively easy to model, by special-casing the SGMII port.
      
      On the SJA1110, certain ports can be pinmuxed between SGMII and xMII, or
      between SGMII and an internal 100base-TX PHY. This creates problems,
      because the driver's assumption so far was that if a port supports
      SGMII, it uses SGMII.
      
      We allow the device tree to tell us how the port pinmuxing is done, and
      check that against a PHY interface type compatibility matrix for
      plausibility.
      
      The other big change is that instead of doing SGMII configuration based
      on what the port supports, we do it based on what is the configured
      phy_mode of the port.
      
      The 2500base-x support added in this patch is not complete.
      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>
      91a05078
    • V
      net: dsa: sja1105: cache the phy-mode port property · bf4edf4a
      Vladimir Oltean 提交于
      So far we've succeeded in operating without keeping a copy of the
      phy-mode in the driver, since we already have the static config and we
      can look at the xMII Mode Parameters Table which already holds that
      information.
      
      But with the SJA1110, we cannot make the distinction between sgmii and
      2500base-x, because to the hardware's static config, it's all SGMII.
      So add a phy_mode property per port inside struct sja1105_private.
      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>
      bf4edf4a
    • V
      net: dsa: sja1105: the 0x1F0000 SGMII "base address" is actually MDIO_MMD_VEND2 · 4c7ee010
      Vladimir Oltean 提交于
      Looking at the SGMII PCS from SJA1110, which is accessed indirectly
      through a different base address as can be seen in the next patch, it
      appears odd that the address accessed through indirection still
      references the base address from the SJA1105S register map (first MDIO
      register is at 0x1f0000), when it could index the SGMII registers
      starting from zero.
      
      Except that the 0x1f0000 is not a base address at all, it seems. It is
      0x1f << 16 | 0x0000, and 0x1f is coding for the vendor-specific MMD2.
      So, it turns out, the Synopsys PCS implements all its registers inside
      the vendor-specific MMDs 1 and 2 (0x1e and 0x1f). This explains why the
      PCS has no overlaps (for the other MMDs) with other register regions of
      the switch (because no other MMDs are implemented).
      
      Change the code to remove the SGMII "base address" and explicitly encode
      the MMD for reads/writes. This will become necessary for SJA1110 support.
      
      Cc: Russell King <linux@armlinux.org.uk>
      Cc: Heiner Kallweit <hkallweit1@gmail.com>
      Signed-off-by: NVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: NJakub Kicinski <kuba@kernel.org>
      4c7ee010
    • V
      net: dsa: sja1105: allow SGMII PCS configuration to be per port · 84db00f2
      Vladimir Oltean 提交于
      The SJA1105 R and S switches have 1 SGMII port (port 4). Because there
      is only one such port, there is no "port" parameter in the configuration
      code for the SGMII PCS.
      
      However, the SJA1110 can have up to 4 SGMII ports, each with its own
      SGMII register map. So we need to generalize the logic.
      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>
      84db00f2
    • V
      net: dsa: sja1105: be compatible with "ethernet-ports" OF node name · 15074a36
      Vladimir Oltean 提交于
      Since commit f2f3e09396be ("net: dsa: sja1105: be compatible with
      "ethernet-ports" OF node name"), DSA supports the "ethernet-ports" name
      for the container node of the ports, but the sja1105 driver doesn't,
      because it handles some device tree parsing of its own.
      
      Add the second node name as a fallback.
      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>
      15074a36