1. 15 3月, 2022 10 次提交
    • J
      ice: rename ICE_MAX_VF_COUNT to avoid confusion · dc36796e
      Jacob Keller 提交于
      The ICE_MAX_VF_COUNT field is defined in ice_sriov.h. This count is true
      for SR-IOV but will not be true for all VF implementations, such as when
      the ice driver supports Scalable IOV.
      
      Rename this definition to clearly indicate ICE_MAX_SRIOV_VFS.
      Signed-off-by: NJacob Keller <jacob.e.keller@intel.com>
      Tested-by: NKonrad Jankowski <konrad0.jankowski@intel.com>
      Signed-off-by: NTony Nguyen <anthony.l.nguyen@intel.com>
      dc36796e
    • J
      ice: remove unused definitions from ice_sriov.h · 00a57e29
      Jacob Keller 提交于
      A few more macros exist in ice_sriov.h which are not used anywhere.
      These can be safely removed. Note that ICE_VIRTCHNL_VF_CAP_L2 capability
      is set but never checked anywhere in the driver. Thus it is also safe to
      remove.
      Signed-off-by: NJacob Keller <jacob.e.keller@intel.com>
      Tested-by: NKonrad Jankowski <konrad0.jankowski@intel.com>
      Signed-off-by: NTony Nguyen <anthony.l.nguyen@intel.com>
      00a57e29
    • J
      ice: convert vf->vc_ops to a const pointer · a7e11710
      Jacob Keller 提交于
      The vc_ops structure is used to allow different handlers for virtchnl
      commands when the driver is in representor mode. The current
      implementation uses a copy of the ops table in each VF, and modifies
      this copy dynamically.
      
      The usual practice in kernel code is to store the ops table in a
      constant structure and point to different versions. This has a number of
      advantages:
      
        1. Reduced memory usage. Each VF merely points to the correct table,
           so they're able to re-use the same constant lookup table in memory.
        2. Consistency. It becomes more difficult to accidentally update or
           edit only one op call. Instead, the code switches to the correct
           able by a single pointer write. In general this is atomic, either
           the pointer is updated or its not.
        3. Code Layout. The VF structure can store a pointer to the table
           without needing to have the full structure definition defined prior
           to the VF structure definition. This will aid in future refactoring
           of code by allowing the VF pointer to be kept in ice_vf_lib.h while
           the virtchnl ops table can be maintained in ice_virtchnl.h
      
      There is one major downside in the case of the vc_ops structure. Most of
      the operations in the table are the same between the two current
      implementations. This can appear to lead to duplication since each
      implementation must now fill in the complete table. It could make
      spotting the differences in the representor mode more challenging.
      Unfortunately, methods to make this less error prone either add
      complexity overhead (macros using CPP token concatenation) or don't work
      on all compilers we support (constant initializer from another constant
      structure).
      
      The cost of maintaining two structures does not out weigh the benefits
      of the constant table model.
      
      While we're making these changes, go ahead and rename the structure and
      implementations with "virtchnl" instead of "vc_vf_". This will more
      closely align with the planned file renaming, and avoid similar names when
      we later introduce a "vf ops" table for separating Scalable IOV and
      Single Root IOV implementations.
      
      Leave the accessor/assignment functions in order to avoid issues with
      compiling with options disabled. The interface makes it easier to handle
      when CONFIG_PCI_IOV is disabled in the kernel.
      Signed-off-by: NJacob Keller <jacob.e.keller@intel.com>
      Tested-by: NSandeep Penigalapati <sandeep.penigalapati@intel.com>
      Signed-off-by: NTony Nguyen <anthony.l.nguyen@intel.com>
      a7e11710
    • J
      ice: remove circular header dependencies on ice.h · 649c87c6
      Jacob Keller 提交于
      Several headers in the ice driver include ice.h even though they are
      themselves included by that header. The most notable of these is
      ice_common.h, but several other headers also do this.
      
      Such a recursive inclusion is problematic as it forces headers to be
      included in a strict order, otherwise compilation errors can result. The
      circular inclusions do not trigger an endless loop due to standard
      header inclusion guards, however other errors can occur.
      
      For example, ice_flow.h defines ice_rss_hash_cfg, which is used by
      ice_sriov.h as part of the definition of ice_vf_hash_ip_ctx.
      
      ice_flow.h includes ice_acl.h, which includes ice_common.h, and which
      finally includes ice.h. Since ice.h itself includes ice_sriov.h, this
      creates a circular dependency.
      
      The definition in ice_sriov.h requires things from ice_flow.h, but
      ice_flow.h itself will lead to trying to load ice_sriov.h as part of its
      process for expanding ice.h. The current code avoids this issue by
      having an implicit dependency without the include of ice_flow.h.
      
      If we were to fix that so that ice_sriov.h explicitly depends on
      ice_flow.h the following pattern would occur:
      
        ice_flow.h -> ice_acl.h -> ice_common.h -> ice.h -> ice_sriov.h
      
      At this point, during the expansion of, the header guard for ice_flow.h
      is already set, so when ice_sriov.h attempts to load the ice_flow.h
      header it is skipped. Then, we go on to begin including the rest of
      ice_sriov.h, including structure definitions which depend on
      ice_rss_hash_cfg. This produces a compiler warning because
      ice_rss_hash_cfg hasn't yet been included. Remember, we're just at the
      start of ice_flow.h!
      
      If the order of headers is incorrect (ice_flow.h is not implicitly
      loaded first in all files which include ice_sriov.h) then we get the
      same failure.
      
      Removing this recursive inclusion requires fixing a few cases where some
      headers depended on the header inclusions from ice.h. In addition, a few
      other changes are also required.
      
      Most notably, ice_hw_to_dev is implemented as a macro in ice_osdep.h,
      which is the likely reason that ice_common.h includes ice.h at all. This
      macro implementation requires the full definition of ice_pf in order to
      properly compile.
      
      Fix this by moving it to a function declared in ice_main.c, so that we
      do not require all files to depend on the layout of the ice_pf
      structure.
      
      Note that this change only fixes circular dependencies, but it does not
      fully resolve all implicit dependencies where one header may depend on
      the inclusion of another. I tried to fix as many of the implicit
      dependencies as I noticed, but fixing them all requires a somewhat
      tedious analysis of each header and attempting to compile it separately.
      Signed-off-by: NJacob Keller <jacob.e.keller@intel.com>
      Tested-by: Gurucharan G <gurucharanx.g@intel.com> (A Contingent worker at Intel)
      Signed-off-by: NTony Nguyen <anthony.l.nguyen@intel.com>
      649c87c6
    • J
      ice: rename ice_virtchnl_pf.c to ice_sriov.c · 0deb0bf7
      Jacob Keller 提交于
      The ice_virtchnl_pf.c and ice_virtchnl_pf.h files are where most of the
      code for implementing Single Root IOV virtualization resides. This code
      includes support for bringing up and tearing down VFs, hooks into the
      kernel SR-IOV netdev operations, and for handling virtchnl messages from
      VFs.
      
      In the future, we plan to support Scalable IOV in addition to Single
      Root IOV as an alternative virtualization scheme. This implementation
      will re-use some but not all of the code in ice_virtchnl_pf.c
      
      To prepare for this future, we want to refactor and split up the code in
      ice_virtchnl_pf.c into the following scheme:
      
       * ice_vf_lib.[ch]
      
         Basic VF structures and accessors. This is where scheme-independent
         code will reside.
      
       * ice_virtchnl.[ch]
      
         Virtchnl message handling. This is where the bulk of the logic for
         processing messages from VFs using the virtchnl messaging scheme will
         reside. This is separated from ice_vf_lib.c because it is distinct
         and has a bulk of the processing code.
      
       * ice_sriov.[ch]
      
         Single Root IOV implementation, including initialization and the
         routines for interacting with SR-IOV based netdev operations.
      
       * (future) ice_siov.[ch]
      
         Scalable IOV implementation.
      
      As a first step, lets assume that all of the code in
      ice_virtchnl_pf.[ch] is for Single Root IOV. Rename this file to
      ice_sriov.c and its header to ice_sriov.h
      
      Future changes will further split out the code in these files following
      the plan outlined here.
      Signed-off-by: NJacob Keller <jacob.e.keller@intel.com>
      Tested-by: NKonrad Jankowski <konrad0.jankowski@intel.com>
      Signed-off-by: NTony Nguyen <anthony.l.nguyen@intel.com>
      0deb0bf7
    • J
      ice: rename ice_sriov.c to ice_vf_mbx.c · d775155a
      Jacob Keller 提交于
      The ice_sriov.c file primarily contains code which handles the logic for
      mailbox overflow detection and some other utility functions related to
      the virtualization mailbox.
      
      The bulk of the SR-IOV implementation is actually found in
      ice_virtchnl_pf.c, and this file isn't strictly SR-IOV specific.
      
      In the future, the ice driver will support an additional virtualization
      scheme known as Scalable IOV, and the code in this file will be used
      for this alternative implementation.
      
      Rename this file (and its associated header) to ice_vf_mbx.c, so that we
      can later re-use the ice_sriov.c file as the SR-IOV specific file.
      Signed-off-by: NJacob Keller <jacob.e.keller@intel.com>
      Tested-by: NKonrad Jankowski <konrad0.jankowski@intel.com>
      Signed-off-by: NTony Nguyen <anthony.l.nguyen@intel.com>
      d775155a
    • N
      nfp: flower: avoid newline at the end of message in NL_SET_ERR_MSG_MOD · bdd6a89d
      Niklas Söderlund 提交于
      Fix the following coccicheck warning:
      
          drivers/net/ethernet/netronome/nfp/flower/action.c:959:7-69: WARNING avoid newline at end of message in NL_SET_ERR_MSG_MOD
      Signed-off-by: NNiklas Söderlund <niklas.soderlund@corigine.com>
      Signed-off-by: NSimon Horman <simon.horman@corigine.com>
      Link: https://lore.kernel.org/r/20220312095823.2425775-1-niklas.soderlund@corigine.comSigned-off-by: NJakub Kicinski <kuba@kernel.org>
      bdd6a89d
    • S
      net/mlx5e: Fix use-after-free in mlx5e_stats_grp_sw_update_stats · 8772cc49
      Saeed Mahameed 提交于
      We need to sync page pool stats only for active channels. Reading ethtool
      stats on a down netdev or a netdev with modified number of channels will
      result in a user-after-free, trying to access page pools that are freed
      already.
      
      BUG: KASAN: use-after-free in mlx5e_stats_grp_sw_update_stats+0x465/0xf80
      Read of size 8 at addr ffff888004835e40 by task ethtool/720
      
      Fixes: cc10e84b ("mlx5: add support for page_pool_get_stats")
      Signed-off-by: NSaeed Mahameed <saeedm@nvidia.com>
      Reported-by: NJakub Kicinski <kuba@kernel.org>
      Acked-by: NJoe Damato <jdamato@fastly.com>
      Link: https://lore.kernel.org/r/20220312005353.786255-1-saeed@kernel.orgSigned-off-by: NJakub Kicinski <kuba@kernel.org>
      8772cc49
    • J
      net/mlx4_en: use kzalloc · 3c2dfb73
      Julia Lawall 提交于
      Use kzalloc instead of kmalloc + memset.
      
      The semantic patch that makes this change is:
      (https://coccinelle.gitlabpages.inria.fr/website/)
      
      //<smpl>
      @@
      expression res, size, flag;
      @@
      - res = kmalloc(size, flag);
      + res = kzalloc(size, flag);
        ...
      - memset(res, 0, size);
      //</smpl>
      Signed-off-by: NJulia Lawall <Julia.Lawall@inria.fr>
      Reviewed-by: NTariq Toukan <tariqt@nvidia.com>
      Link: https://lore.kernel.org/r/20220312102705.71413-3-Julia.Lawall@inria.frSigned-off-by: NJakub Kicinski <kuba@kernel.org>
      3c2dfb73
    • J
      drivers: net: packetengines: fix typos in comments · ebc0b8b5
      Julia Lawall 提交于
      Various spelling mistakes in comments.
      Detected with the help of Coccinelle.
      Signed-off-by: NJulia Lawall <Julia.Lawall@inria.fr>
      Link: https://lore.kernel.org/r/20220314115354.144023-13-Julia.Lawall@inria.frSigned-off-by: NJakub Kicinski <kuba@kernel.org>
      ebc0b8b5
  2. 14 3月, 2022 9 次提交
    • I
      dpaa2-mac: configure the SerDes phy on a protocol change · f978fe85
      Ioana Ciornei 提交于
      This patch integrates the dpaa2-eth driver with the generic PHY
      infrastructure in order to search, find and reconfigure the SerDes lanes
      in case of a protocol change.
      
      On the .mac_config() callback, the phy_set_mode_ext() API is called so
      that the Lynx 28G SerDes PHY driver can change the lane's configuration.
      In the same phylink callback the MC firmware is called so that it
      reconfigures the MAC side to run using the new protocol.
      
      The consumer drivers - dpaa2-eth and dpaa2-switch - are updated to call
      the dpaa2_mac_start/stop functions newly added which will
      power_on/power_off the associated SerDes lane.
      Signed-off-by: NIoana Ciornei <ioana.ciornei@nxp.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      f978fe85
    • I
      dpaa2-mac: move setting up supported_interfaces into a function · aa95c371
      Ioana Ciornei 提交于
      The logic to setup the supported interfaces will get annotated based on
      what the configuration of the SerDes PLLs supports. Move the current
      setup into a separate function just to try to keep it clean.
      Signed-off-by: NIoana Ciornei <ioana.ciornei@nxp.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      aa95c371
    • I
      dpaa2-mac: retrieve API version and detect features · dff95381
      Ioana Ciornei 提交于
      Retrieve the API version running on the firmware and based on it detect
      which features are available for usage.
      The first one to be listed is the capability to change the MAC protocol
      at runtime.
      Signed-off-by: NIoana Ciornei <ioana.ciornei@nxp.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      dff95381
    • I
      dpaa2-mac: add the MC API for reconfiguring the protocol · 332b9ea5
      Ioana Ciornei 提交于
      The MC firmware gained recently a new command which can reconfigure the
      running protocol on the underlying MAC. Add this new command which will
      be used in the next patches in order to do a major reconfig on the
      interface.
      Signed-off-by: NIoana Ciornei <ioana.ciornei@nxp.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      332b9ea5
    • I
      dpaa2-mac: add the MC API for retrieving the version · 38d28b02
      Ioana Ciornei 提交于
      The dpmac_get_api_version command will be used in the next patches to
      determine if the current firmware is capable or not to change the
      Ethernet protocol running on the MAC.
      Signed-off-by: NIoana Ciornei <ioana.ciornei@nxp.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      38d28b02
    • I
      phy: add support for the Layerscape SerDes 28G · 8f73b37c
      Ioana Ciornei 提交于
      This patch adds a new generic PHY driver to support the Lynx 28G SerDes
      block found on some of the Layerscape SoCs such as LX2160A.
      At the moment, only the following Ethernet protocols are supported:
      SGMII/1000Base-X and 10GBaseR.
      
      SerDes lanes which are not running an Ethernet protocol or a currently
      supported Ethenet protocol will be left as it was configured through the
      RCW (Reset Configuration Word) at boot time.
      
      At probe time, the platform driver will read the current
      configuration of both PLLs found on a SerDes block and will determine
      what protocols are supported using that PLL.
      
      For example, if a PLL is configured to generate a clock net (frate) of
      5GHz the only protocols sustained by that PLL are SGMII/1000Base-X
      (using a quarter of the full clock rate) and QSGMII using the full clock
      net frequency on the lane.
      
      On the .set_mode() callback, the PHY driver will first check if the
      requested operating mode (protocol) is even supported by the current PLL
      configuration and will error out if not.
      Then, the lane is reconfigured to run on the requested protocol.
      Signed-off-by: NIoana Ciornei <ioana.ciornei@nxp.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      8f73b37c
    • V
      net: dsa: felix: configure default-prio and dscp priorities · 978777d0
      Vladimir Oltean 提交于
      Follow the established programming model for this driver and provide
      shims in the felix DSA driver which call the implementations from the
      ocelot switch lib. The ocelot switchdev driver wasn't integrated with
      dcbnl due to lack of hardware availability.
      
      The switch doesn't have any fancy QoS classification enabled by default.
      The provided getters will create a default-prio app table entry of 0,
      and no dscp entry. However, the getters have been made to actually
      retrieve the hardware configuration rather than static values, to be
      future proof in case DSA will need this information from more call paths.
      
      For default-prio, there is a single field per port, in ANA_PORT_QOS_CFG,
      called QOS_DEFAULT_VAL.
      
      DSCP classification is enabled per-port, again via ANA_PORT_QOS_CFG
      (field QOS_DSCP_ENA), and individual DSCP values are configured as
      trusted or not through register ANA_DSCP_CFG (replicated 64 times).
      An untrusted DSCP value falls back to other QoS classification methods.
      If trusted, the selected ANA_DSCP_CFG register also holds the QoS class
      in the QOS_DSCP_VAL field.
      
      The hardware also supports DSCP remapping (DSCP value X is translated to
      DSCP value Y before the QoS class is determined based on the app table
      entry for Y) and DSCP packet rewriting. The dcbnl framework, for being
      so flexible in other useless areas, doesn't appear to support this.
      So this functionality has been left out.
      Signed-off-by: NVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      978777d0
    • Z
      net: macvlan: add net device refcount tracker · 1f4a5983
      Ziyang Xuan 提交于
      Add net device refcount tracker to macvlan.
      Signed-off-by: NZiyang Xuan <william.xuanziyang@huawei.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      1f4a5983
    • Z
      net: macvlan: fix potential UAF problem for lowerdev · 291ac684
      Ziyang Xuan 提交于
      Add the reference operation to lowerdev of macvlan to avoid
      the potential UAF problem under the following known scenario:
      
      Someone module puts the NETDEV_UNREGISTER event handler to a
      work, and lowerdev is accessed in the work handler. But when
      the work is excuted, lowerdev has been destroyed because upper
      macvlan did not get reference to lowerdev correctly.
      
      That likes as the scenario occurred by
      commit 563bcbae ("net: vlan: fix a UAF in vlan_dev_real_dev()").
      Signed-off-by: NZiyang Xuan <william.xuanziyang@huawei.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      291ac684
  3. 13 3月, 2022 13 次提交
  4. 12 3月, 2022 8 次提交