1. 28 Jun, 2024 14 commits
    • Petr Machata's avatar
      selftests: lib: tc_rule_stats_get(): Move default to argument definition · 9b5d5f27
      Petr Machata authored
      The argument $dir has a fallback value of "ingress". Move the fallback from
      the usage site to the argument definition block to make the fact clearer.
      Signed-off-by: default avatarPetr Machata <petrm@nvidia.com>
      Reviewed-by: default avatarDanielle Ratson <danieller@nvidia.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      9b5d5f27
    • Petr Machata's avatar
      selftests: mirror: Drop direction argument from several functions · 28e67746
      Petr Machata authored
      The argument is not used by these functions except to propagate it for
      ultimately no purpose.
      Signed-off-by: default avatarPetr Machata <petrm@nvidia.com>
      Reviewed-by: default avatarDanielle Ratson <danieller@nvidia.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      28e67746
    • Petr Machata's avatar
      selftests: libs: Expand "$@" where possible · d5fbb2eb
      Petr Machata authored
      In some functions, argument-forwarding through "$@" without listing the
      individual arguments explicitly is fundamental to the operation of a
      function. E.g. xfail_on_veth() should be able to run various tests in the
      fail-to-xfail regime, and usage of "$@" is appropriate as an abstraction
      mechanism. For functions such as simple_if_init(), $@ is a handy way to
      pass an array.
      
      In other functions, it's merely a mechanism to save some typing, which
      however ends up obscuring the real arguments and makes life hard for those
      that end up reading the code.
      
      This patch adds some of the implicit function arguments and correspondingly
      expands $@'s. In several cases this will come in handy as following patches
      adjust the parameter lists.
      Signed-off-by: default avatarPetr Machata <petrm@nvidia.com>
      Reviewed-by: default avatarDanielle Ratson <danieller@nvidia.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d5fbb2eb
    • David S. Miller's avatar
      Merge branch 'net-flash-modees-firmware' into main · c977ac49
      David S. Miller authored
      Danielle Ratson says:
      
      ====================
      Add ability to flash modules' firmware
      
      CMIS compliant modules such as QSFP-DD might be running a firmware that
      can be updated in a vendor-neutral way by exchanging messages between
      the host and the module as described in section 7.2.2 of revision
      4.0 of the CMIS standard.
      
      According to the CMIS standard, the firmware update process is done
      using a CDB commands sequence.
      
      CDB (Command Data Block Message Communication) reads and writes are
      performed on memory map pages 9Fh-AFh according to the CMIS standard,
      section 8.12 of revision 4.0.
      
      Add a pair of new ethtool messages that allow:
      
      * User space to trigger firmware update of transceiver modules
      
      * The kernel to notify user space about the progress of the process
      
      The user interface is designed to be asynchronous in order to avoid RTNL
      being held for too long and to allow several modules to be updated
      simultaneously. The interface is designed with CMIS compliant modules in
      mind, but kept generic enough to accommodate future use cases, if these
      arise.
      
      The kernel interface that will implement the firmware update using CDB
      command will include 2 layers that will be added under ethtool:
      
      * The upper layer that will be triggered from the module layer, is
       cmis_ fw_update.
      * The lower one is cmis_cdb.
      
      In the future there might be more operations to implement using CDB
      commands. Therefore, the idea is to keep the cmis_cdb interface clean and
      the cmis_fw_update specific to the cdb commands handling it.
      
      The communication between the kernel and the driver will be done using
      two ethtool operations that enable reading and writing the transceiver
      module EEPROM.
      The operation ethtool_ops::get_module_eeprom_by_page, that is already
      implemented, will be used for reading from the EEPROM the CDB reply,
      e.g. reading module setting, state, etc.
      The operation ethtool_ops::set_module_eeprom_by_page, that is added in
      the current patchset, will be used for writing to the EEPROM the CDB
      command such as start firmware image, run firmware image, etc.
      
      Therefore in order for a driver to implement module flashing, that
      driver needs to implement the two functions mentioned above.
      
      Patchset overview:
      Patch #1-#2: Implement the EEPROM writing in mlxsw.
      Patch #3: Define the interface between the kernel and user space.
      Patch #4: Add ability to notify the flashing firmware progress.
      Patch #5: Veto operations during flashing.
      Patch #6: Add extended compliance codes.
      Patch #7: Add the cdb layer.
      Patch #8: Add the fw_update layer.
      Patch #9: Add ability to flash transceiver modules' firmware.
      
      v8:
      	Patch #7:
      	* In the ethtool_cmis_wait_for_cond() evaluate the condition once more
      	  to decide if the error code should be -ETIMEDOUT or something else.
      	* s/netdev_err/netdev_err_once.
      
      v7:
      	Patch #4:
      		* Return -ENOMEM instead of PTR_ERR(attr) on
      		  ethnl_module_fw_flash_ntf_put_err().
      	Patch #9:
      		* Fix Warning for not unlocking the spin_lock in the error flow
                	  on module_flash_fw_work_list_add().
      		* Avoid the fall-through on ethnl_sock_priv_destroy().
      
      v6:
      	* Squash some of the last patch to patch #5 and patch #9.
      	Patch #3:
      		* Add paragraph in .rst file.
      	Patch #4:
      		* Reserve '1' more place on SKB for NUL terminator in
      		  the error message string.
      		* Add more prints on error flow, re-write the printing
      		  function and add ethnl_module_fw_flash_ntf_put_err().
      		* Change the communication method so notification will be
      		  sent in unicast instead of multicast.
      		* Add new 'struct ethnl_module_fw_flash_ntf_params' that holds
      		  the relevant info for unicast communication and use it to
      		  send notification to the specific socket.
      		* s/nla_put_u64_64bit/nla_put_uint/
      	Patch #7:
      		* In ethtool_cmis_cdb_init(), Use 'const' for the 'params'
      		  parameter.
      	Patch #8:
      		* Add a list field to struct ethtool_module_fw_flash for
      		  module_fw_flash_work_list that will be presented in the next
      		  patch.
      		* Move ethtool_cmis_fw_update() cleaning to a new function that
      		  will be represented in the next patch.
      		* Move some of the fields in struct ethtool_module_fw_flash to
      		  a separate struct, so ethtool_cmis_fw_update() will get only
      		  the relevant parameters for it.
      		* Edit the relevant functions to get the relevant params for
      		  them.
      		* s/CMIS_MODULE_READY_MAX_DURATION_USEC/CMIS_MODULE_READY_MAX_DURATION_MSEC
      	Patch #9:
      		* Add a paragraph in the commit message.
      		* Rename labels in module_flash_fw_schedule().
      		* Add info to genl_sk_priv_*() and implement the relevant
      		  callbacks, in order to handle properly a scenario of closing
      		  the socket from user space before the work item was ended.
      		* Add a list the holds all the ethtool_module_fw_flash struct
      		  that corresponds to the in progress work items.
      		* Add a new enum for the socket types.
      		* Use both above to identify a flashing socket, add it to the
      		  list and when closing socket affect only the flashing type.
      		* Create a new function that will get the work item instead of
      		  ethtool_cmis_fw_update().
      		* Edit the relevant functions to get the relevant params for
      		  them.
      		* The new function will call the old ethtool_cmis_fw_update(),
      		  and do the cleaning, so the existence of the list should be
      		  completely isolated in module.c.
      ===================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c977ac49
    • Danielle Ratson's avatar
      ethtool: Add ability to flash transceiver modules' firmware · 32b4c8b5
      Danielle Ratson authored
      Add the ability to flash the modules' firmware by implementing the
      interface between the user space and the kernel.
      
      Example from a succeeding implementation:
      
       # ethtool --flash-module-firmware swp40 file test.bin
      
       Transceiver module firmware flashing started for device swp40
       Transceiver module firmware flashing in progress for device swp40
       Progress: 99%
       Transceiver module firmware flashing completed for device swp40
      
      In addition, add infrastructure that allows modules to set socket-specific
      private data. This ensures that when a socket is closed from user space
      during the flashing process, the right socket halts sending notifications
      to user space until the work item is completed.
      Signed-off-by: default avatarDanielle Ratson <danieller@nvidia.com>
      Reviewed-by: default avatarPetr Machata <petrm@nvidia.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      32b4c8b5
    • Danielle Ratson's avatar
      ethtool: cmis_fw_update: add a layer for supporting firmware update using CDB · c4f78134
      Danielle Ratson authored
      According to the CMIS standard, the firmware update process is done using
      a CDB commands sequence.
      
      Implement a work that will be triggered from the module layer in the
      next patch the will initiate and execute all the CDB commands in order, to
      eventually complete the firmware update process.
      
      This flashing process includes, writing the firmware image, running the new
      firmware image and committing it after testing, so that it will run upon
      reset.
      
      This work will also notify user space about the progress of the firmware
      update process.
      Signed-off-by: default avatarDanielle Ratson <danieller@nvidia.com>
      Reviewed-by: default avatarPetr Machata <petrm@nvidia.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c4f78134
    • Danielle Ratson's avatar
      ethtool: cmis_cdb: Add a layer for supporting CDB commands · a39c84d7
      Danielle Ratson authored
      CDB (Command Data Block Message Communication) reads and writes are
      performed on memory map pages 9Fh-AFh according to the CMIS standard,
      section 8.20 of revision 5.2.
      Page 9Fh is used to specify the CDB command to be executed and also
      provides an area for a local payload (LPL).
      
      According to the CMIS standard, the firmware update process is done using
      a CDB commands sequence that will be implemented in the next patch.
      
      The kernel interface that will implement the firmware update using CDB
      command will include 2 layers that will be added under ethtool:
      
      * The upper layer that will be triggered from the module layer, is
        cmis_fw_update.
      * The lower one is cmis_cdb.
      
      In the future there might be more operations to implement using CDB
      commands. Therefore, the idea is to keep the CDB interface clean and the
      cmis_fw_update specific to the CDB commands handling it.
      
      These two layers will communicate using the API the consists of three
      functions:
      
      - struct ethtool_cmis_cdb *
        ethtool_cmis_cdb_init(struct net_device *dev,
      			struct ethtool_module_fw_flash_params *params);
      - void ethtool_cmis_cdb_fini(struct ethtool_cmis_cdb *cdb);
      - int ethtool_cmis_cdb_execute_cmd(struct net_device *dev,
      				   struct ethtool_cmis_cdb_cmd_args *args);
      
      Add the CDB layer to support initializing, finishing and executing CDB
      commands:
      
      * The initialization process will include creating of an ethtool_cmis_cdb
        instance, querying the module CDB support, entering and validating the
        password from user space (CMD 0x0000) and querying the module features
        (CMD 0x0040).
      
      * The finishing API will simply free the ethtool_cmis_cdb instance.
      
      * The executing process will write the CDB command to EEPROM using
        set_module_eeprom_by_page() that was presented earlier, and will
        process the reply from EEPROM.
      Signed-off-by: default avatarDanielle Ratson <danieller@nvidia.com>
      Reviewed-by: default avatarPetr Machata <petrm@nvidia.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      a39c84d7
    • Danielle Ratson's avatar
      net: sfp: Add more extended compliance codes · e4f91936
      Danielle Ratson authored
      SFF-8024 is used to define various constants re-used in several SFF
      SFP-related specifications.
      
      Add SFF-8024 extended compliance code definitions for CMIS compliant
      modules and use them in the next patch to determine the firmware flashing
      work.
      Signed-off-by: default avatarDanielle Ratson <danieller@nvidia.com>
      Reviewed-by: default avatarPetr Machata <petrm@nvidia.com>
      Reviewed-by: default avatarRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      e4f91936
    • Danielle Ratson's avatar
      ethtool: Veto some operations during firmware flashing process · 31e0aa99
      Danielle Ratson authored
      Some operations cannot be performed during the firmware flashing
      process.
      
      For example:
      
      - Port must be down during the whole flashing process to avoid packet loss
        while committing reset for example.
      
      - Writing to EEPROM interrupts the flashing process, so operations like
        ethtool dump, module reset, get and set power mode should be vetoed.
      
      - Split port firmware flashing should be vetoed.
      
      In order to veto those scenarios, add a flag in 'struct net_device' that
      indicates when a firmware flash is taking place on the module and use it
      to prevent interruptions during the process.
      Signed-off-by: default avatarDanielle Ratson <danieller@nvidia.com>
      Reviewed-by: default avatarPetr Machata <petrm@nvidia.com>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      31e0aa99
    • Danielle Ratson's avatar
      ethtool: Add flashing transceiver modules' firmware notifications ability · d7d4cfc4
      Danielle Ratson authored
      Add progress notifications ability to user space while flashing modules'
      firmware by implementing the interface between the user space and the
      kernel.
      Signed-off-by: default avatarDanielle Ratson <danieller@nvidia.com>
      Reviewed-by: default avatarPetr Machata <petrm@nvidia.com>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d7d4cfc4
    • Danielle Ratson's avatar
      ethtool: Add an interface for flashing transceiver modules' firmware · 46fb3ba9
      Danielle Ratson authored
      CMIS compliant modules such as QSFP-DD might be running a firmware that
      can be updated in a vendor-neutral way by exchanging messages between
      the host and the module as described in section 7.3.1 of revision 5.2 of
      the CMIS standard.
      
      Add a pair of new ethtool messages that allow:
      
      * User space to trigger firmware update of transceiver modules
      
      * The kernel to notify user space about the progress of the process
      
      The user interface is designed to be asynchronous in order to avoid
      RTNL being held for too long and to allow several modules to be
      updated simultaneously. The interface is designed with CMIS compliant
      modules in mind, but kept generic enough to accommodate future use
      cases, if these arise.
      Signed-off-by: default avatarDanielle Ratson <danieller@nvidia.com>
      Reviewed-by: default avatarPetr Machata <petrm@nvidia.com>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      46fb3ba9
    • Ido Schimmel's avatar
      mlxsw: Implement ethtool operation to write to a transceiver module EEPROM · 1983a800
      Ido Schimmel authored
      Implement the ethtool_ops::set_module_eeprom_by_page operation to allow
      ethtool to write to a transceiver module EEPROM, in a similar fashion to
      the ethtool_ops::get_module_eeprom_by_page operation.
      Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
      Reviewed-by: default avatarPetr Machata <petrm@nvidia.com>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      1983a800
    • Ido Schimmel's avatar
      ethtool: Add ethtool operation to write to a transceiver module EEPROM · 69540b79
      Ido Schimmel authored
      Ethtool can already retrieve information from a transceiver module
      EEPROM by invoking the ethtool_ops::get_module_eeprom_by_page operation.
      Add a corresponding operation that allows ethtool to write to a
      transceiver module EEPROM.
      
      The new write operation is purely an in-kernel API and is not exposed to
      user space.
      
      The purpose of this operation is not to enable arbitrary read / write
      access, but to allow the kernel to write to specific addresses as part
      of transceiver module firmware flashing. In the future, more
      functionality can be implemented on top of these read / write
      operations.
      
      Adjust the comments of the 'ethtool_module_eeprom' structure as it is
      no longer used only for read access.
      Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
      Signed-off-by: default avatarDanielle Ratson <danieller@nvidia.com>
      Reviewed-by: default avatarPetr Machata <petrm@nvidia.com>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      69540b79
    • Marek Vasut's avatar
      dt-bindings: net: realtek,rtl82xx: Document known PHY IDs as compatible strings · 8fda5371
      Marek Vasut authored
      Extract known PHY IDs from Linux kernel realtek PHY driver
      and convert them into supported compatible string list for
      this DT binding document.
      Signed-off-by: default avatarMarek Vasut <marex@denx.de>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      8fda5371
  2. 27 Jun, 2024 26 commits