1. 18 Sep, 2020 31 commits
    • Randy Dunlap's avatar
      net: atm: delete duplicated words · 563f63e3
      Randy Dunlap authored
      Drop repeated words in net/atm/.
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Jakub Kicinski <kuba@kernel.org>
      Cc: Chas Williams <3chas3@gmail.com>
      Cc: linux-atm-general@lists.sourceforge.net
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      563f63e3
    • Randy Dunlap's avatar
      net: tipc: delete duplicated words · 60462191
      Randy Dunlap authored
      Drop repeated words in net/tipc/.
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Jakub Kicinski <kuba@kernel.org>
      Cc: Jon Maloy <jmaloy@redhat.com>
      Cc: Ying Xue <ying.xue@windriver.com>
      Cc: tipc-discussion@lists.sourceforge.net
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      60462191
    • Randy Dunlap's avatar
      net: bluetooth: delete duplicated words · bb6d6895
      Randy Dunlap authored
      Drop repeated words in net/bluetooth/.
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Jakub Kicinski <kuba@kernel.org>
      Cc: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
      Cc: Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      bb6d6895
    • Randy Dunlap's avatar
      net: ipv6: delete duplicated words · 634a63e7
      Randy Dunlap authored
      Drop repeated words in net/ipv6/.
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Jakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      634a63e7
    • Randy Dunlap's avatar
      net: rds: delete duplicated words · d936b1d5
      Randy Dunlap authored
      Drop repeated words in net/rds/.
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Jakub Kicinski <kuba@kernel.org>
      Cc: Santosh Shilimkar <santosh.shilimkar@oracle.com>
      Cc: linux-rdma@vger.kernel.org
      Cc: rds-devel@oss.oracle.com
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d936b1d5
    • Randy Dunlap's avatar
      net: core: delete duplicated words · 4250b75b
      Randy Dunlap authored
      Drop repeated words in net/core/.
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Jakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      4250b75b
    • Lijun Pan's avatar
      Revert "ibmvnic: remove never executed if statement" · 785a2b10
      Lijun Pan authored
      This reverts commit 550f4d46.
      
      adapter->from_passive_init may be changed in ibmvnic_handle_crq
      while ibmvnic_reset_init is waiting for the completion of
      adapter->init_done.
      Signed-off-by: default avatarLijun Pan <ljp@linux.ibm.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      785a2b10
    • David S. Miller's avatar
      Merge branch 'tipc-add-more-features-to-TIPC-encryption' · 5d7d28e5
      David S. Miller authored
      Tuong Lien says:
      
      ====================
      tipc: add more features to TIPC encryption
      
      This series adds some new features to TIPC encryption:
      
      - Patch 1 ("tipc: optimize key switching time and logic") optimizes the
      code and logic in preparation for the following commits.
      
      - Patch 2 ("tipc: introduce encryption master key") introduces support
      of 'master key' for authentication of new nodes and key exchange. A
      master key can be set/changed by user via netlink (eg. using the same
      'tipc node set key' command in iproute2/tipc).
      
      - Patch 3 ("tipc: add automatic session key exchange") allows a session
      key to be securely exchanged between nodes as needed.
      
      - Patch 4 ("tipc: add automatic rekeying for encryption key") adds
      automatic 'rekeying' of session keys a specific interval. The new key
      will be distributed automatically to peer nodes, so become active then.
      The rekeying interval is configurable via netlink as well.
      
      v2: update the "tipc: add automatic session key exchange" patch to fix
      "implicit declaration" issue when built without "CONFIG_TIPC_CRYPTO".
      
      v3: update the patches according to David comments by using the
      "genl_info->extack" for messages in response to netlink user config
      requests.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      5d7d28e5
    • Tuong Lien's avatar
      tipc: add automatic rekeying for encryption key · 23700da2
      Tuong Lien authored
      Rekeying is required for security since a key is less secure when using
      for a long time. Also, key will be detached when its nonce value (or
      seqno ...) is exhausted. We now make the rekeying process automatic and
      configurable by user.
      
      Basically, TIPC will at a specific interval generate a new key by using
      the kernel 'Random Number Generator' cipher, then attach it as the node
      TX key and securely distribute to others in the cluster as RX keys (-
      the key exchange). The automatic key switching will then take over, and
      make the new key active shortly. Afterwards, the traffic from this node
      will be encrypted with the new session key. The same can happen in peer
      nodes but not necessarily at the same time.
      
      For simplicity, the automatically generated key will be initiated as a
      per node key. It is not too hard to also support a cluster key rekeying
      (e.g. a given node will generate a unique cluster key and update to the
      others in the cluster...), but that doesn't bring much benefit, while a
      per-node key is even more secure.
      
      We also enable user to force a rekeying or change the rekeying interval
      via netlink, the new 'set key' command option: 'TIPC_NLA_NODE_REKEYING'
      is added for these purposes as follows:
      - A value >= 1 will be set as the rekeying interval (in minutes);
      - A value of 0 will disable the rekeying;
      - A value of 'TIPC_REKEYING_NOW' (~0) will force an immediate rekeying;
      
      The default rekeying interval is (60 * 24) minutes i.e. done every day.
      There isn't any restriction for the value but user shouldn't set it too
      small or too large which results in an "ineffective" rekeying (thats ok
      for testing though).
      Acked-by: default avatarJon Maloy <jmaloy@redhat.com>
      Signed-off-by: default avatarTuong Lien <tuong.t.lien@dektech.com.au>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      23700da2
    • Tuong Lien's avatar
      tipc: add automatic session key exchange · 1ef6f7c9
      Tuong Lien authored
      With support from the master key option in the previous commit, it
      becomes easy to make frequent updates/exchanges of session keys between
      authenticated cluster nodes.
      Basically, there are two situations where the key exchange will take in
      place:
      
      - When a new node joins the cluster (with the master key), it will need
        to get its peer's TX key, so that be able to decrypt further messages
        from that peer.
      
      - When a new session key is generated (by either user manual setting or
        later automatic rekeying feature), the key will be distributed to all
        peer nodes in the cluster.
      
      A key to be exchanged is encapsulated in the data part of a 'MSG_CRYPTO
      /KEY_DISTR_MSG' TIPC v2 message, then xmit-ed as usual and encrypted by
      using the master key before sending out. Upon receipt of the message it
      will be decrypted in the same way as regular messages, then attached as
      the sender's RX key in the receiver node.
      
      In this way, the key exchange is reliable by the link layer, as well as
      security, integrity and authenticity by the crypto layer.
      
      Also, the forward security will be easily achieved by user changing the
      master key actively but this should not be required very frequently.
      
      The key exchange feature is independent on the presence of a master key
      Note however that the master key still is needed for new nodes to be
      able to join the cluster. It is also optional, and can be turned off/on
      via the sysfs: 'net/tipc/key_exchange_enabled' [default 1: enabled].
      
      Backward compatibility is guaranteed because for nodes that do not have
      master key support, key exchange using master key ie. tx_key = 0 if any
      will be shortly discarded at the message validation step. In other
      words, the key exchange feature will be automatically disabled to those
      nodes.
      
      v2: fix the "implicit declaration of function 'tipc_crypto_key_flush'"
      error in node.c. The function only exists when built with the TIPC
      "CONFIG_TIPC_CRYPTO" option.
      
      v3: use 'info->extack' for a message emitted due to netlink operations
      instead (- David's comment).
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Acked-by: default avatarJon Maloy <jmaloy@redhat.com>
      Signed-off-by: default avatarTuong Lien <tuong.t.lien@dektech.com.au>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      1ef6f7c9
    • Tuong Lien's avatar
      tipc: introduce encryption master key · daef1ee3
      Tuong Lien authored
      In addition to the supported cluster & per-node encryption keys for the
      en/decryption of TIPC messages, we now introduce one option for user to
      set a cluster key as 'master key', which is simply a symmetric key like
      the former but has a longer life cycle. It has two purposes:
      
      - Authentication of new member nodes in the cluster. New nodes, having
        no knowledge of current session keys in the cluster will still be
        able to join the cluster as long as they know the master key. This is
        because all neighbor discovery (LINK_CONFIG) messages must be
        encrypted with this key.
      
      - Encryption of session encryption keys during automatic exchange and
        update of those.This is a feature we will introduce in a later commit
        in this series.
      
      We insert the new key into the currently unused slot 0 in the key array
      and start using it immediately once the user has set it.
      After joining, a node only knowing the master key should be fully
      communicable to existing nodes in the cluster, although those nodes may
      have their own session keys activated (i.e. not the master one). To
      support this, we define a 'grace period', starting from the time a node
      itself reports having no RX keys, so the existing nodes will use the
      master key for encryption instead. The grace period can be extended but
      will automatically stop after e.g. 5 seconds without a new report. This
      is also the basis for later key exchanging feature as the new node will
      be impossible to decrypt anything without the support from master key.
      
      For user to set a master key, we define a new netlink flag -
      'TIPC_NLA_NODE_KEY_MASTER', so it can be added to the current 'set key'
      netlink command to specify the setting key to be a master key.
      
      Above all, the traditional cluster/per-node key mechanism is guaranteed
      to work when user comes not to use this master key option. This is also
      compatible to legacy nodes without the feature supported.
      
      Even this master key can be updated without any interruption of cluster
      connectivity but is so is needed, this has to be coordinated and set by
      the user.
      Acked-by: default avatarJon Maloy <jmaloy@redhat.com>
      Signed-off-by: default avatarTuong Lien <tuong.t.lien@dektech.com.au>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      daef1ee3
    • Tuong Lien's avatar
      tipc: optimize key switching time and logic · f779bf79
      Tuong Lien authored
      We reduce the lasting time for a pending TX key to be active as well as
      for a passive RX key to be freed which generally helps speed up the key
      switching. It is not expected to be too fast but should not be too slow
      either. Also the key handling logic is simplified that a pending RX key
      will be removed automatically if it is found not working after a number
      of times; the probing for a pending TX key is now carried on a specific
      message user ('LINK_PROTOCOL' or 'LINK_CONFIG') which is more efficient
      than using a timer on broadcast messages, the timer is reserved for use
      later as needed.
      
      The kernel logs or 'pr***()' are now made as clear as possible to user.
      Some prints are added, removed or changed to the debug-level. The
      'TIPC_CRYPTO_DEBUG' definition is removed, and the 'pr_debug()' is used
      instead which will be much helpful in runtime.
      
      Besides we also optimize the code in some other places as a preparation
      for later commits.
      
      v2: silent more kernel logs, also use 'info->extack' for a message
      emitted due to netlink operations instead (- David's comments).
      Acked-by: default avatarJon Maloy <jmaloy@redhat.com>
      Signed-off-by: default avatarTuong Lien <tuong.t.lien@dektech.com.au>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      f779bf79
    • David S. Miller's avatar
      Merge branch 'ionic-add-devlink-dev-flash-support' · cb589a55
      David S. Miller authored
      Shannon Nelson says:
      
      ====================
      ionic: add devlink dev flash support
      
      Add support for using devlink's dev flash facility to update the
      firmware on an ionic device, and add a new timeout parameter to the
      devlink flash netlink message.
      
      For long-running flash commands, we add a timeout element to the dev
      flash notify message in order for a userland utility to display a timeout
      deadline to the user.  This allows the userland utility to display a
      count down to the user when a firmware update action is otherwise going
      to go for ahile without any updates.  An example use is added to the
      netdevsim module.
      
      The ionic driver uses this timeout element in its new flash function.
      The driver uses a simple model of pushing the firmware file to the NIC,
      asking the NIC to unpack and install the file into the device, and then
      selecting it for the next boot.  If any of these steps fail, the whole
      transaction is failed.  A couple of the steps can take a long time,
      so we use the timeout status message rather than faking it with bogus
      done/total messages.
      
      The driver doesn't currently support doing these steps individually.
      In the future we want to be able to list the FW that is installed and
      selectable but we don't yet have the API to fully support that.
      
      v5: pulled the cmd field back out of the new params struct
          changed netdevsim example message to "Flash select"
      
      v4: Added a new devlink status notify message for showing timeout
          information, and modified the ionic fw update to use it for its long
          running firmware commands.
      
      v3: Changed long dev_cmd timeout on status check calls to a loop around
          calls with a normal timeout, which allows for more intermediate log
          messaging when in a long wait, and for letting other threads run
          dev_cmds if waiting.
      
      v2: Changed "Activate" to "Select" in status messages.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      cb589a55
    • Shannon Nelson's avatar
      ionic: add devlink firmware update · 30b5191a
      Shannon Nelson authored
      Add support for firmware update through the devlink interface.
      This update copies the firmware object into the device, asks
      the current firmware to install it, then asks the firmware to
      select the new firmware for the next boot-up.
      
      The install and select steps are launched as asynchronous
      requests, which are then followed up with status request
      commands.  These status request commands will be answered with
      an EAGAIN return value and will try again until the request
      has completed or reached the timeout specified.
      Signed-off-by: default avatarShannon Nelson <snelson@pensando.io>
      Acked-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      30b5191a
    • Shannon Nelson's avatar
      ionic: update the fw update api · 87c905d8
      Shannon Nelson authored
      Add the rest of the firmware api bits needed to support the
      driver running a firmware update.
      Signed-off-by: default avatarShannon Nelson <snelson@pensando.io>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      87c905d8
    • Shannon Nelson's avatar
      netdevsim: devlink flash timeout message · b311b001
      Shannon Nelson authored
      Add a simple devlink flash timeout message to exercise
      the message mechanism.
      Signed-off-by: default avatarShannon Nelson <snelson@pensando.io>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      b311b001
    • Shannon Nelson's avatar
      devlink: collect flash notify params into a struct · 6700acc5
      Shannon Nelson authored
      The dev flash status notify function parameter lists are getting
      rather long, so add a struct to be filled and passed rather than
      continuously changing the function signatures.
      Signed-off-by: default avatarShannon Nelson <snelson@pensando.io>
      Reviewed-by: default avatarJacob Keller <jacob.e.keller@intel.com>
      Reviewed-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      6700acc5
    • Shannon Nelson's avatar
      devlink: add timeout information to status_notify · f92970c6
      Shannon Nelson authored
      Add a timeout element to the DEVLINK_CMD_FLASH_UPDATE_STATUS
      netlink message for use by a userland utility to show that
      a particular firmware flash activity may take a long but
      bounded time to finish.  Also add a handy helper for drivers
      to make use of the new timeout value.
      
      UI usage hints:
       - if non-zero, add timeout display to the end of the status line
       	[component] status_msg  ( Xm Ys : Am Bs )
           using the timeout value for Am Bs and updating the Xm Ys
           every second
       - if the timeout expires while awaiting the next update,
         display something like
       	[component] status_msg  ( timeout reached : Am Bs )
       - if new status notify messages are received, remove
         the timeout and start over
      Signed-off-by: default avatarShannon Nelson <snelson@pensando.io>
      Reviewed-by: default avatarJakub Kicinski <kuba@kernel.org>
      Reviewed-by: default avatarJacob Keller <jacob.e.keller@intel.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      f92970c6
    • Francesco Ruggeri's avatar
      net: use exponential backoff in netdev_wait_allrefs · 0e4be9e5
      Francesco Ruggeri authored
      The combination of aca_free_rcu, introduced in commit 2384d025
      ("net/ipv6: Add anycast addresses to a global hashtable"), and
      fib6_info_destroy_rcu, introduced in commit 9b0a8da8 ("net/ipv6:
      respect rcu grace period before freeing fib6_info"), can result in
      an extra rcu grace period being needed when deleting an interface,
      with the result that netdev_wait_allrefs ends up hitting the msleep(250),
      which is considerably longer than the required grace period.
      This can result in long delays when deleting a large number of interfaces,
      and it can be observed with this script:
      
      ns=dummy-ns
      NIFS=100
      
      ip netns add $ns
      ip netns exec $ns ip link set lo up
      ip netns exec $ns sysctl net.ipv6.conf.default.disable_ipv6=0
      ip netns exec $ns sysctl net.ipv6.conf.default.forwarding=1
      
      for ((i=0; i<$NIFS; i++))
      do
              if=eth$i
              ip netns exec $ns ip link add $if type dummy
              ip netns exec $ns ip link set $if up
              ip netns exec $ns ip -6 addr add 2021:$i::1/120 dev $if
      done
      
      for ((i=0; i<$NIFS; i++))
      do
              if=eth$i
              ip netns exec $ns ip link del $if
      done
      
      ip netns del $ns
      
      Instead of using a fixed msleep(250), this patch tries an extra
      rcu_barrier() followed by an exponential backoff.
      
      Time with this patch on a 5.4 kernel:
      
      real	0m7.704s
      user	0m0.385s
      sys	0m1.230s
      
      Time without this patch:
      
      real    0m31.522s
      user    0m0.438s
      sys     0m1.156s
      
      v2: use exponential backoff instead of trying to wake up
          netdev_wait_allrefs.
      v3: preserve reverse christmas tree ordering of local variables
      v4: try an extra rcu_barrier before the backoff, plus some
          cosmetic changes.
      Signed-off-by: default avatarFrancesco Ruggeri <fruggeri@arista.com>
      Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      0e4be9e5
    • Paolo Abeni's avatar
      mptcp: fix integer overflow in mptcp_subflow_discard_data() · 1d39cd8c
      Paolo Abeni authored
      Christoph reported an infinite loop in the subflow receive path
      under stress condition.
      
      If there are multiple subflows, each of them using a large send
      buffer, the delta between the sequence number used by
      MPTCP-level retransmission can and the current msk->ack_seq
      can be greater than MAX_INT.
      
      In the above scenario, when calling mptcp_subflow_discard_data(),
      such delta will be truncated to int, and could result in a negative
      number: no bytes will be dropped, and subflow_check_data_avail()
      will try again to process the same packet, looping forever.
      
      This change addresses the issue by expanding the 'limit' size to 64
      bits, so that overflows are not possible anymore.
      
      Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/87
      Fixes: 6719331c ("mptcp: trigger msk processing even for OoO data")
      Reported-and-tested-by: default avatarChristoph Paasch <cpaasch@apple.com>
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Reviewed-by: default avatarMat Martineau <mathew.j.martineau@linux.intel.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      1d39cd8c
    • Ursula Braun's avatar
      net/smc: fix double kfree in smc_listen_work() · ac679364
      Ursula Braun authored
      If smc_listen_rmda_finish() returns with an error, the storage
      addressed by 'buf' is freed a second time.
      Consolidate freeing under a common label and jump to that label.
      
      Fixes: 6bb14e48 ("net/smc: dynamic allocation of CLC proposal buffer")
      Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarUrsula Braun <ubraun@linux.ibm.com>
      Signed-off-by: default avatarKarsten Graul <kgraul@linux.ibm.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      ac679364
    • Shannon Nelson's avatar
      ionic: add DIMLIB to Kconfig · 86d009f1
      Shannon Nelson authored
      >> ld.lld: error: undefined symbol: net_dim_get_rx_moderation
         >>> referenced by ionic_lif.c:52 (drivers/net/ethernet/pensando/ionic/ionic_lif.c:52)
         >>> net/ethernet/pensando/ionic/ionic_lif.o:(ionic_dim_work) in archive drivers/built-in.a
      
      >> ld.lld: error: undefined symbol: net_dim
         >>> referenced by ionic_txrx.c:456 (drivers/net/ethernet/pensando/ionic/ionic_txrx.c:456)
         >>> net/ethernet/pensando/ionic/ionic_txrx.o:(ionic_dim_update) in archive drivers/built-in.a
      
      v2: removed sketchy dashes in commit message
      
      Fixes: 04a83459 ("ionic: dynamic interrupt moderation")
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Signed-off-by: default avatarShannon Nelson <snelson@pensando.io>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      86d009f1
    • Jakub Kicinski's avatar
      net: remove comments on struct rtnl_link_stats · 78a3ea55
      Jakub Kicinski authored
      We removed the misleading comments from struct rtnl_link_stats64
      when we added proper kdoc. struct rtnl_link_stats has the same
      inline comments, so remove them, too.
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Reviewed-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      78a3ea55
    • Andrew Lunn's avatar
      net: mdio: octeon: Select MDIO_DEVRES · 529d1fdf
      Andrew Lunn authored
      This driver makes use of devm_mdiobus_alloc_size. To ensure this is
      available select MDIO_DEVRES which provides it.
      Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Reported-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Acked-by: Randy Dunlap <rdunlap@infradead.org> # build-tested
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      529d1fdf
    • David Ahern's avatar
      selftests: Set default protocol for raw sockets in nettest · 897217b9
      David Ahern authored
      IPPROTO_IP (0) is not valid for raw sockets. Default the protocol for
      raw sockets to IPPROTO_RAW if the protocol has not been set via the -P
      option.
      Signed-off-by: default avatarDavid Ahern <dsahern@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      897217b9
    • Qinglang Miao's avatar
    • Qinglang Miao's avatar
      net: hsr: Convert to DEFINE_SHOW_ATTRIBUTE · 2170ff08
      Qinglang Miao authored
      Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.
      Signed-off-by: default avatarQinglang Miao <miaoqinglang@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      2170ff08
    • David S. Miller's avatar
      Merge branch 'mlxsw-Support-dcbnl_setbuffer-dcbnl_getbuffer' · 72d61d30
      David S. Miller authored
      Ido Schimmel says:
      
      ====================
      mlxsw: Support dcbnl_setbuffer, dcbnl_getbuffer
      
      Petr says:
      
      On Spectrum, port buffers, also called port headroom, is where packets are
      stored while they are parsed and the forwarding decision is being made. For
      lossless traffic flows, in case shared buffer admission is not allowed,
      headroom is also where to put the extra traffic received before the sent
      PAUSE takes effect.
      
      Linux supports two DCB interfaces related to the headroom: dcbnl_setbuffer
      for configuration, and dcbnl_getbuffer for inspection. This patch set
      implements them.
      
      With dcbnl_setbuffer in place, there will be two sources of authority over
      the ingress configuration: the DCB ETS hook, because ETS configuration is
      mirrored to ingress, and the DCB setbuffer hook. mlxsw is in a similar
      situation on the egress side, where there are two sources of the ETS
      configuration: the DCB ETS hook, and the TC qdisc hooks. This is a
      non-intuitive situation, because the way the ASIC ends up being configured
      depends not only on the actual configured bits, but also on the order in
      which they were configured.
      
      To prevent these issues on the ingress side, two configuration modes will
      exist: DCB mode and TC mode. DCB ETS will keep getting projected to ingress
      in the (default) DCB mode. When a qdisc is installed on a port, it will be
      switched to the TC mode, the ingress configuration will be done through the
      dcbnl_setbuffer callback. The reason is that the dcbnl_setbuffer hook is
      not standardized and supported by lldpad. Projecting DCB ETS configuration
      to ingress is a reasonable heuristic to configure ingress especially when
      PFC is in effect.
      
      In patch #1, the toggle between the DCB and TC modes of headroom
      configuration, described above, is introduced.
      
      Patch #2 implements dcbnl_getbuffer and dcbnl_setbuffer. dcbnl_getbuffer
      can be always used to determine the current port headroom configuration.
      dcbnl_setbuffer is only permitted in the TC mode.
      
      In patch #3, make the qdisc module toggle the headroom mode from DCB to TC
      and back, depending on whether there is an offloaded qdisc on the port.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      72d61d30
    • Petr Machata's avatar
      mlxsw: spectrum_qdisc: Disable port buffer autoresize with qdiscs · 509f04ca
      Petr Machata authored
      There are two interfaces to configure ETS: qdiscs and DCB. Historically,
      DCB ETS configuration was projected to ingress as well, and configured port
      buffers. Qdisc was not.
      
      Keep qdiscs behaving this way, and if an offloaded qdisc is configured on a
      port, move this port's headroom to a manual mode, thus allowing
      configuration of port buffers through dcbnl_setbuffer.
      Signed-off-by: default avatarPetr Machata <petrm@nvidia.com>
      Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
      Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      509f04ca
    • Petr Machata's avatar
      mlxsw: spectrum_dcb: Implement dcbnl_setbuffer / getbuffer · 5ebc6031
      Petr Machata authored
      Add dcbnl_setbuffer, which bounces requests if a headroom is in DCB mode.
      Implement dcbnl_getbuffer such that it can always be used to determine
      port-buffer configuration, regardless of headroom mode.
      Signed-off-by: default avatarPetr Machata <petrm@nvidia.com>
      Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
      Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      5ebc6031
    • Petr Machata's avatar
      mlxsw: spectrum_buffers: Support two headroom modes · 69e408a2
      Petr Machata authored
      There are two interfaces to configure ETS: qdiscs and DCB. Historically,
      DCB ETS configuration was projected to ingress as well, and configured port
      buffers. Qdisc was not.
      
      So as not to break clients that today use DCB ETS and PFC and rely on
      getting a reasonable ingress buffer priomap, keep the ETS mirroring in
      effect.
      
      Since qdiscs have not done this mirroring historically, it is reasonable
      not to introduce it, but rather permit manual ingress configuration through
      dcbnl_setbuffer only in the qdisc mode.
      
      This will require a toggle to indicate whether buffer sizes should be
      autocomputed or taken from dcbnl_setbuffer, and likewise for priomaps.
      Introduce such and initialize it, and guard port buffer size configuration
      as appropriate. The toggle is currently left in the DCB position. In a
      following patch, qdisc code will switch it.
      Signed-off-by: default avatarPetr Machata <petrm@nvidia.com>
      Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
      Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      69e408a2
  2. 17 Sep, 2020 9 commits
    • Yang Yingliang's avatar
      netlink: add spaces around '&' in netlink_recv/sendmsg() · 4d11af5d
      Yang Yingliang authored
      It's hard to read the code without spaces around '&',
      for better reading, add spaces around '&'.
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      4d11af5d
    • YueHaibing's avatar
      netdev: Remove unused functions · 2492c205
      YueHaibing authored
      There is no callers in tree, so can remove it.
      Signed-off-by: default avatarYueHaibing <yuehaibing@huawei.com>
      Reviewed-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      2492c205
    • Ye Bin's avatar
      mptcp: Fix unsigned 'max_seq' compared with zero in mptcp_data_queue_ofo · c2ec6bc0
      Ye Bin authored
      Fixes coccicheck warnig:
      net/mptcp/protocol.c:164:11-18: WARNING: Unsigned expression compared with zero: max_seq > 0
      
      Fixes: ab174ad8 ("mptcp: move ooo skbs into msk out of order queue")
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarYe Bin <yebin10@huawei.com>
      Acked-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c2ec6bc0
    • David S. Miller's avatar
      Merge branch... · 3ce406bd
      David S. Miller authored
      Merge branch 'net-marvell-prestera-Add-Switchdev-driver-for-Prestera-family-ASIC-device-98DX3255-AC3x'
      
      Vadym Kochan says:
      
      ====================
      net: marvell: prestera: Add Switchdev driver for Prestera family ASIC device 98DX3255 (AC3x)
      
      Marvell Prestera 98DX3255 integrates up to 24 ports of 1GbE with 8
      ports of 10GbE uplinks or 2 ports of 40Gbps stacking for a largely
      wireless SMB deployment.
      
      Prestera Switchdev is a firmware based driver that operates via PCI bus.  The
      current implementation supports only boards designed for the Marvell Switchdev
      solution and requires special firmware.
      
      This driver implementation includes only L1, basic L2 support, and RX/TX.
      
      The core Prestera switching logic is implemented in prestera_main.c, there is
      an intermediate hw layer between core logic and firmware. It is
      implemented in prestera_hw.c, the purpose of it is to encapsulate hw
      related logic, in future there is a plan to support more devices with
      different HW related configurations.
      
      The following Switchdev features are supported:
      
          - VLAN-aware bridge offloading
          - VLAN-unaware bridge offloading
          - FDB offloading (learning, ageing)
          - Switchport configuration
      
      The original firmware image is uploaded to the linux-firmware repository.
      
      PATCH v9:
          1) Replace read_poll_timeout_atomic() by original 'do {} while()' loop
             because it works much better than read_poll_timeout_atomic()
             considering the TX rate. Also it fixes warning reported on v8.
      
          2) Use ENOENT instead of EEXIST when item is not found in few
             places - prestera_hw.c and prestera_rxtx.c
      
          Patches updated:
              [1] net: marvell: prestera: Add driver for Prestera family ASIC devices
      
      PATCH v8:
          1) Put license in one line.
      
          2) Sort includes.
      
          3) Add missing comma for last enum member
      
          4) Return original error code from last called func
             in places where instead other error code was used.
      
          5) Add comma for last member in initialized struct in prestera_hw.c
      
          6) Do not initialize 'int err = 0' where it is not needed.
      
          7) Simplify device-tree "marvell,prestera" node parsing by removing not
             needed checking on 'np == NULL'.
      
          8) Use u32p_replace_bits() instead of open-coded ((word & ~mask) | val)
      
          9) Use dev_warn_ratelimited() instead of pr_warn_ratelimited to indicate the device
              instance in prestera_rxtx.c
      
          10) Simplify circular buffer list creation in prestera_sdma_{rx,tx}_init() by using
              do { } while (prev != tail) construction.
      
          11) Use MSEC_PER_SEC instead of hard-coded 1000.
      
          12) Use traditional error handling pattern:
      
             err = F();
             if (err)
                 return err;
      
          13) Use ether_addr_copy() instead of memcpy() for mac FDB copying in prestera_hw.c
      
          14) Drop swdev->ageing_time member which is not used.
      
          15) Fix ageing macro to be in ms instead of seconds.
      
          Patches updated:
              [1] net: marvell: prestera: Add driver for Prestera family ASIC devices
      	[2] net: marvell: prestera: Add PCI interface support
              [3] net: marvell: prestera: Add basic devlink support
      	[4] net: marvell: prestera: Add ethtool interface support
      	[5] net: marvell: prestera: Add Switchdev driver implementation
      
      PATCH v7:
          1) Use ether_addr_copy() in prestera_main.c:prestera_port_set_mac_address()
             instead of memcpy().
      
          2) Removed not needed device's DMA address range check on
             dma_pool_alloc() in prestera_rxtx.c:prestera_sdma_buf_init(),
             this should be handled by dma_xxx() API considerig device's DMA mask.
      
          3) Removed not needed device's DMA address range check on
             dma_map_single() in prestera_rxtx.c:prestera_sdma_rx_skb_alloc(),
             this should be handled by dma_xxx() API considerig device's DMA mask.
      
          4) Add comment about port mac address limitation in the code where
             it is used and checked - prestera_main.c:
      
                 - prestera_is_valid_mac_addr()
                 - prestera_port_create()
      
          5) Add missing destroy_workqueue(swdev_wq) in prestera_switchdev.c:prestera_switchdev_init()
             on error path handling.
      
          Patches updated:
              [1] net: marvell: prestera: Add driver for Prestera family ASIC devices
              [5] net: marvell: prestera: Add Switchdev driver implementation
      
      PATCH v6:
          1) Use rwlock to protect port list on create/delete stages. The list
             is mostly readable by fw event handler or packets receiver, but
             updated only on create/delete port which are performed on switch init/fini
             stages.
      
          2) Remove not needed variable initialization in prestera_dsa.c:prestera_dsa_parse()
      
          3) Get rid of bounce buffer used by tx handler in prestera_rxtx.c,
             the bounce buffer should be handled by dma_xxx API via swiotlb.
      
          4) Fix PRESTERA_SDMA_RX_DESC_PKT_LEN macro by using correct GENMASK(13, 0) in prestera_rxtx.c
      
          Patches updated:
              [1] net: marvell: prestera: Add driver for Prestera family ASIC devices
      
      PATCH v5:
          0) add Co-developed tags for people who was involved in development.
      
          1) Make SPDX license as separate comment
      
          2) Change 'u8 *' -> 'void *', It allows to avoid not-needed u8* casting.
      
          3) Remove "," in terminated enum's.
      
          4) Use GENMASK(end, start) where it is applicable in.
      
          5) Remove not-needed 'u8 *' casting.
      
          6) Apply common error-check pattern
      
          7) Use ether_addr_copy instead of memcpy
      
          8) Use define for maximum MAC address range (255)
      
          9) Simplify prestera_port_state_set() in prestera_main.c by
             using separate if-blocks for state setting:
      
              if (is_up) {
              ...
              } else {
              ...
              }
      
            which makes logic more understandable.
      
          10) Simplify sdma tx wait logic when checking/updating tx_ring->burst.
      
          11) Remove not-needed packed & aligned attributes
      
          12) Use USEC_PER_MSEC as multiplier when converting ms -> usec on calling
              readl_poll_timeout.
      
          13) Simplified some error path handling by simple return error code in.
      
          14) Remove not-needed err assignment in.
      
          15) Use dev_err() in prestera_devlink_register(...).
      
          Patches updated:
              [1] net: marvell: prestera: Add driver for Prestera family ASIC devices
      	[2] net: marvell: prestera: Add PCI interface support
              [3] net: marvell: prestera: Add basic devlink support
      	[4] net: marvell: prestera: Add ethtool interface support
      	[5] net: marvell: prestera: Add Switchdev driver implementation
      
      PATCH v4:
          1) Use prestera_ prefix in netdev_ops variable.
      
          2) Kconfig: use 'default PRESTERA' build type for CONFIG_PRESTERA_PCI to be
             synced by default with prestera core module.
      
          3) Use memcpy_xxio helpers in prestera_pci.c for IO buffer copying.
      
          4) Generate fw image path via snprintf() instead of macroses.
      
          5) Use pcim_ helpers in prestera_pci.c which simplified the
             probe/remove logic.
      
          6) Removed not needed initializations of variables which are used in
             readl_poll_xxx() helpers.
      
          7) Fixed few grammar mistakes in patch[2] description.
      
          8) Export only prestera_ethtool_ops struct instead of each
             ethtool handler.
      
          9) Add check for prestera_dev_check() in switchdev event handling to
             make sure there is no wrong topology.
      
          Patches updated:
              [1] net: marvell: prestera: Add driver for Prestera family ASIC devices
      	[2] net: marvell: prestera: Add PCI interface support
      	[4] net: marvell: prestera: Add ethtool interface support
      	[5] net: marvell: prestera: Add Switchdev driver implementation
      
      PATCH v3:
          1) Simplify __be32 type casting in prestera_dsa.c
      
          2) Added per-patch changelog under "---" line.
      
      PATCH v2:
          1) Use devlink_port_type_clear()
      
          2) Add _MS prefix to timeout defines.
      
          3) Remove not-needed packed attribute from the firmware ipc structs,
             also the firmware image needs to be uploaded too (will do it soon).
      
          4) Introduce prestera_hw_switch_fini(), to be mirrored with init and
             do simple validation if the event handlers are unregistered.
      
          5) Use kfree_rcu() for event handler unregistering.
      
          6) Get rid of rcu-list usage when dealing with ports, not needed for
             now.
      
          7) Little spelling corrections in the error/info messages.
      
          8) Make pci probe & remove logic mirrored.
      
          9) Get rid of ETH_FCS_LEN in headroom setting, not needed.
      
      PATCH:
          1) Fixed W=1 warnings
      
          2) Renamed PCI driver name to be more generic "Prestera DX" because
             there will be more devices supported.
      
          3) Changed firmware image dir path: marvell/ -> mrvl/prestera/
             to be aligned with location in linux-firmware.git (if such
             will be accepted).
      
      RFC v3:
          1) Fix prestera prefix in prestera_rxtx.c
      
          2) Protect concurrent access from multiple ports on multiple CPU system
             on tx path by spinlock in prestera_rxtx.c
      
          3) Try to get base mac address from device-tree, otherwise use a random generated one.
      
          4) Move ethtool interface support into separate prestera_ethtool.c file.
      
          5) Add basic devlink support and get rid of physical port naming ops.
      
          6) Add STP support in Switchdev driver.
      
          7) Removed MODULE_AUTHOR
      
          8) Renamed prestera.c -> prestera_main.c, and kernel module to
             prestera.ko
      
      RFC v2:
          1) Use "pestera_" prefix in struct's and functions instead of mvsw_pr_
      
          2) Original series split into additional patches for Switchdev ethtool support.
      
          3) Use major and minor firmware version numbers in the firmware image filename.
      
          4) Removed not needed prints.
      
          5) Use iopoll API for waiting on register's value in prestera_pci.c
      
          6) Use standart approach for describing PCI ID matching section instead of using
             custom wrappers in prestera_pci.c
      
          7) Add RX/TX support in prestera_rxtx.c.
      
          8) Rewritten prestera_switchdev.c with following changes:
             - handle netdev events from prestera.c
      
             - use struct prestera_bridge for bridge objects, and get rid of
               struct prestera_bridge_device which may confuse.
      
             - use refcount_t
      
          9) Get rid of macro usage for sending fw requests in prestera_hw.c
      
          10) Add base_mac setting as module parameter. base_mac is required for
              generation default port's mac.
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      3ce406bd
    • Vadym Kochan's avatar
      dt-bindings: marvell,prestera: Add description for device-tree bindings · 40acc052
      Vadym Kochan authored
      Add brief description how to configure base mac address binding in
      device-tree.
      
      Describe requirement for the PCI port which is connected to the ASIC, to
      allow access to the firmware related registers.
      Signed-off-by: default avatarVadym Kochan <vadym.kochan@plvision.eu>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      40acc052
    • Vadym Kochan's avatar
      net: marvell: prestera: Add Switchdev driver implementation · e1189d9a
      Vadym Kochan authored
      The following features are supported:
      
          - VLAN-aware bridge offloading
          - VLAN-unaware bridge offloading
          - FDB offloading (learning, ageing)
          - Switchport configuration
      
      Currently there are some limitations like:
      
          - Only 1 VLAN-aware bridge instance supported
          - FDB ageing timeout parameter is set globally per device
      Co-developed-by: default avatarSerhiy Boiko <serhiy.boiko@plvision.eu>
      Signed-off-by: default avatarSerhiy Boiko <serhiy.boiko@plvision.eu>
      Co-developed-by: default avatarSerhiy Pshyk <serhiy.pshyk@plvision.eu>
      Signed-off-by: default avatarSerhiy Pshyk <serhiy.pshyk@plvision.eu>
      Co-developed-by: default avatarTaras Chornyi <taras.chornyi@plvision.eu>
      Signed-off-by: default avatarTaras Chornyi <taras.chornyi@plvision.eu>
      Signed-off-by: default avatarVadym Kochan <vadym.kochan@plvision.eu>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      e1189d9a
    • Vadym Kochan's avatar
      net: marvell: prestera: Add ethtool interface support · a97d3c69
      Vadym Kochan authored
      The ethtool API provides support for the configuration of the following
      features: speed and duplex, auto-negotiation, MDI-x, forward error
      correction, port media type. The API also provides information about the
      port status, hardware and software statistic. The following limitation
      exists:
      
          - port media type should be configured before speed setting
          - ethtool -m option is not supported
          - ethtool -p option is not supported
          - ethtool -r option is supported for RJ45 port only
          - the following combination of parameters is not supported:
      
                ethtool -s sw1pX port XX autoneg on
      
          - forward error correction feature is supported only on SFP ports, 10G
            speed
      
          - auto-negotiation and MDI-x features are not supported on
            Copper-to-Fiber SFP module
      Co-developed-by: default avatarAndrii Savka <andrii.savka@plvision.eu>
      Signed-off-by: default avatarAndrii Savka <andrii.savka@plvision.eu>
      Co-developed-by: default avatarSerhiy Boiko <serhiy.boiko@plvision.eu>
      Signed-off-by: default avatarSerhiy Boiko <serhiy.boiko@plvision.eu>
      Signed-off-by: default avatarVadym Kochan <vadym.kochan@plvision.eu>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      a97d3c69
    • Vadym Kochan's avatar
      net: marvell: prestera: Add basic devlink support · 34dd1710
      Vadym Kochan authored
      Add very basic support for devlink interface:
      
          - driver name
          - fw version
          - devlink ports
      Signed-off-by: default avatarVadym Kochan <vadym.kochan@plvision.eu>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      34dd1710
    • Vadym Kochan's avatar
      net: marvell: prestera: Add PCI interface support · 4c2703df
      Vadym Kochan authored
      Add PCI interface driver for Prestera Switch ASICs family devices, which
      provides:
      
          - Firmware loading mechanism
          - Requests & events handling to/from the firmware
          - Access to the firmware on the bus level
      
      The firmware has to be loaded each time the device is reset. The driver
      is loading it from:
      
          /lib/firmware/mrvl/prestera/mvsw_prestera_fw-v{MAJOR}.{MINOR}.img
      
      The full firmware image version is located within the internal header
      and consists of 3 numbers - MAJOR.MINOR.PATCH. Additionally, driver has
      hard-coded minimum supported firmware version which it can work with:
      
          MAJOR - reflects the support on ABI level between driver and loaded
                  firmware, this number should be the same for driver and loaded
                  firmware.
      
          MINOR - this is the minimum supported version between driver and the
                  firmware.
      
          PATCH - indicates only fixes, firmware ABI is not changed.
      
      Firmware image file name contains only MAJOR and MINOR numbers to make
      driver be compatible with any PATCH version.
      Co-developed-by: default avatarOleksandr Mazur <oleksandr.mazur@plvision.eu>
      Signed-off-by: default avatarOleksandr Mazur <oleksandr.mazur@plvision.eu>
      Signed-off-by: default avatarVadym Kochan <vadym.kochan@plvision.eu>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      4c2703df