1. Jan 23, 2021
    • Parav Pandit's avatar
      devlink: Extend devlink port documentation for subfunctions · 6474ce7e
      Parav Pandit authored
      
      
      Add devlink port documentation for subfunction management.
      
      Signed-off-by: default avatarParav Pandit <parav@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      6474ce7e
    • Parav Pandit's avatar
      devlink: Add devlink port documentation · c736111c
      Parav Pandit authored
      
      
      Added documentation for devlink port and port function related commands.
      
      Signed-off-by: default avatarParav Pandit <parav@nvidia.com>
      Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
      Reviewed-by: default avatarJacob Keller <jacob.e.keller@intel.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      c736111c
    • Parav Pandit's avatar
      net/mlx5: SF, Port function state change support · 6a327321
      Parav Pandit authored
      
      
      Support changing the state of the SF port's function through devlink.
      When activating the SF port's function, enable the hca in the device
      followed by adding its auxiliary device.
      When deactivating the SF port's function, delete its auxiliary device
      followed by disabling the vHCA.
      
      Port function attributes get/set callbacks are invoked with devlink
      instance lock held. Such callbacks need to synchronize with sf port
      table getting disabled either via sriov sysfs callback. Such callbacks
      synchronize with table disable context holding table refcount.
      
      $ devlink dev eswitch set pci/0000:06:00.0 mode switchdev
      
      $ devlink port show
      pci/0000:06:00.0/65535: type eth netdev ens2f0np0 flavour physical port 0 splittable false
      
      $ devlink port add pci/0000:06:00.0 flavour pcisf pfnum 0 sfnum 88
      pci/0000:06:00.0/32768: type eth netdev eth6 flavour pcisf controller 0 pfnum 0 sfnum 88 external false splittable false
        function:
          hw_addr 00:00:00:00:00:00 state inactive opstate detached
      
      $ devlink port show ens2f0npf0sf88
      pci/0000:06:00.0/32768: type eth netdev ens2f0npf0sf88 flavour pcisf controller 0 pfnum 0 sfnum 88 external false splittable false
        function:
          hw_addr 00:00:00:00:88:88 state inactive opstate detached
      
      $ devlink port function set pci/0000:06:00.0/32768 hw_addr 00:00:00:00:88:88 state active
      
      $ devlink port show ens2f0npf0sf88 -jp
      {
          "port": {
              "pci/0000:06:00.0/32768": {
                  "type": "eth",
                  "netdev": "ens2f0npf0sf88",
                  "flavour": "pcisf",
                  "controller": 0,
                  "pfnum": 0,
                  "sfnum": 88,
                  "external": false,
                  "splittable": false,
                  "function": {
                      "hw_addr": "00:00:00:00:88:88",
                      "state": "active",
                      "opstate": "attached"
                  }
              }
          }
      }
      
      On port function activation, an auxiliary device is created in below
      example.
      
      $ devlink dev show
      devlink dev show auxiliary/mlx5_core.sf.4
      
      $ devlink port show auxiliary/mlx5_core.sf.4/1
      auxiliary/mlx5_core.sf.4/1: type eth netdev p0sf88 flavour virtual port 0 splittable false
      
      Signed-off-by: default avatarParav Pandit <parav@nvidia.com>
      Reviewed-by: default avatarVu Pham <vuhuong@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      6a327321
    • Parav Pandit's avatar
      net/mlx5: SF, Add port add delete functionality · 8f010541
      Parav Pandit authored
      
      
      To handle SF port management outside of the eswitch as independent
      software layer, introduce eswitch notifier APIs so that mlx5 upper
      layer who wish to support sf port management in switchdev mode can
      perform its task whenever eswitch mode is set to switchdev or before
      eswitch is disabled.
      
      Initialize sf port table on such eswitch event.
      
      Add SF port add and delete functionality in switchdev mode.
      Destroy all SF ports when eswitch is disabled.
      Expose SF port add and delete to user via devlink commands.
      
      $ devlink dev eswitch set pci/0000:06:00.0 mode switchdev
      
      $ devlink port show
      pci/0000:06:00.0/65535: type eth netdev ens2f0np0 flavour physical port 0 splittable false
      
      $ devlink port add pci/0000:06:00.0 flavour pcisf pfnum 0 sfnum 88
      pci/0000:06:00.0/32768: type eth netdev eth6 flavour pcisf controller 0 pfnum 0 sfnum 88 external false splittable false
        function:
          hw_addr 00:00:00:00:00:00 state inactive opstate detached
      
      $ devlink port show ens2f0npf0sf88
      pci/0000:06:00.0/32768: type eth netdev ens2f0npf0sf88 flavour pcisf controller 0 pfnum 0 sfnum 88 external false splittable false
        function:
          hw_addr 00:00:00:00:00:00 state inactive opstate detached
      
      or by its unique port index:
      $ devlink port show pci/0000:06:00.0/32768
      pci/0000:06:00.0/32768: type eth netdev ens2f0npf0sf88 flavour pcisf controller 0 pfnum 0 sfnum 88 external false splittable false
        function:
          hw_addr 00:00:00:00:00:00 state inactive opstate detached
      
      $ devlink port show ens2f0npf0sf88 -jp
      {
          "port": {
              "pci/0000:06:00.0/32768": {
                  "type": "eth",
                  "netdev": "ens2f0npf0sf88",
                  "flavour": "pcisf",
                  "controller": 0,
                  "pfnum": 0,
                  "sfnum": 88,
                  "external": false,
                  "splittable": false,
                  "function": {
                      "hw_addr": "00:00:00:00:00:00",
                      "state": "inactive",
                      "opstate": "detached"
                  }
              }
          }
      }
      
      Signed-off-by: default avatarParav Pandit <parav@nvidia.com>
      Reviewed-by: default avatarVu Pham <vuhuong@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      8f010541
    • Parav Pandit's avatar
      net/mlx5: E-switch, Add eswitch helpers for SF vport · d970812b
      Parav Pandit authored
      
      
      Add helpers to enable/disable eswitch port, register its devlink port and
      load its representor.
      
      Signed-off-by: default avatarVu Pham <vuhuong@nvidia.com>
      Signed-off-by: default avatarParav Pandit <parav@nvidia.com>
      Reviewed-by: default avatarRoi Dayan <roid@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      d970812b
    • Vu Pham's avatar
      net/mlx5: E-switch, Prepare eswitch to handle SF vport · d7f33a45
      Vu Pham authored
      
      
      Prepare eswitch to handle SF vport during
      (a) querying eswitch functions
      (b) egress ACL creation
      (c) account for SF vports in total vports calculation
      
      Assign a dedicated placeholder for SFs vports and their representors.
      They are placed after VFs vports and before ECPF vports as below:
      [PF,VF0,...,VFn,SF0,...SFm,ECPF,UPLINK].
      
      Change functions to map SF's vport numbers to indices when
      accessing the vports or representors arrays, and vice versa.
      
      Signed-off-by: default avatarVu Pham <vuhuong@nvidia.com>
      Signed-off-by: default avatarParav Pandit <parav@nvidia.com>
      Reviewed-by: default avatarRoi Dayan <roid@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      d7f33a45
    • Parav Pandit's avatar
      net/mlx5: SF, Add auxiliary device driver · 1958fc2f
      Parav Pandit authored
      Add auxiliary device driver for mlx5 subfunction auxiliary device.
      
      A mlx5 subfunction is similar to PCI PF and VF. For a subfunction
      an auxiliary device is created.
      
      As a result, when mlx5 SF auxiliary device binds to the driver,
      its netdev and rdma device are created, they appear as
      
      $ ls -l /sys/bus/auxiliary/devices/
      mlx5_core.sf.4 -> ../../../devices/pci0000:00/0000:00:03.0/0000:06:00.0/mlx5_core.sf.4
      
      $ ls -l /sys/class/net/eth1/device
      /sys/class/net/eth1/device -> ../../../mlx5_core.sf.4
      
      $ cat /sys/bus/auxiliary/devices/mlx5_core.sf.4/sfnum
      88
      
      $ devlink dev show
      pci/0000:06:00.0
      auxiliary/mlx5_core.sf.4
      
      $ devlink port show auxiliary/mlx5_core.sf.4/1
      auxiliary/mlx5_core.sf.4/1: type eth netdev p0sf88 flavour virtual port 0 splittable false
      
      $ rdma link show mlx5_0/1
      link mlx5_0/1 state ACTIVE physical_state LINK_UP netdev p0sf88
      
      $ rdma dev show
      8: rocep6s0f1: node_type ca fw 16.29.0550 node_guid 248a:0703:00b3:d113 sys_image_guid 248a:0703:00b3:d112
      13: mlx5_0: node_type ca fw 16.29.0550 node_guid 0000:00ff:fe00:8888 sys_image_guid 248a:0703:00b3:d112
      
      In future, devlink device instance name will adapt to have sfnum
      annotation using either an alias or as devlink instance name described
      in RFC [1].
      
      [1] https://lore.kernel.org/netdev/20200519092258.GF4655@nanopsycho/
      
      
      
      Signed-off-by: default avatarParav Pandit <parav@nvidia.com>
      Reviewed-by: default avatarVu Pham <vuhuong@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      1958fc2f
    • Parav Pandit's avatar
      net/mlx5: SF, Add auxiliary device support · 90d010b8
      Parav Pandit authored
      
      
      Introduce API to add and delete an auxiliary device for an SF.
      Each SF has its own dedicated window in the PCI BAR 2.
      
      SF device is similar to PCI PF and VF that supports multiple class of
      devices such as net, rdma and vdpa.
      
      SF device will be added or removed in subsequent patch during SF
      devlink port function state change command.
      
      A subfunction device exposes user supplied subfunction number which will
      be further used by systemd/udev to have deterministic name for its
      netdevice and rdma device.
      
      An mlx5 subfunction auxiliary device example:
      
      $ devlink dev eswitch set pci/0000:06:00.0 mode switchdev
      
      $ devlink port show
      pci/0000:06:00.0/65535: type eth netdev ens2f0np0 flavour physical port 0 splittable false
      
      $ devlink port add pci/0000:06:00.0 flavour pcisf pfnum 0 sfnum 88
      pci/0000:08:00.0/32768: type eth netdev eth6 flavour pcisf controller 0 pfnum 0 sfnum 88 external false splittable false
        function:
          hw_addr 00:00:00:00:00:00 state inactive opstate detached
      
      $ devlink port show ens2f0npf0sf88
      pci/0000:06:00.0/32768: type eth netdev ens2f0npf0sf88 flavour pcisf controller 0 pfnum 0 sfnum 88 external false splittable false
        function:
          hw_addr 00:00:00:00:88:88 state inactive opstate detached
      
      $ devlink port function set ens2f0npf0sf88 hw_addr 00:00:00:00:88:88 state active
      
      On activation,
      
      $ ls -l /sys/bus/auxiliary/devices/
      mlx5_core.sf.4 -> ../../../devices/pci0000:00/0000:00:03.0/0000:06:00.0/mlx5_core.sf.4
      
      $ cat /sys/bus/auxiliary/devices/mlx5_core.sf.4/sfnum
      88
      
      Signed-off-by: default avatarParav Pandit <parav@nvidia.com>
      Reviewed-by: default avatarVu Pham <vuhuong@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      90d010b8
    • Parav Pandit's avatar
      net/mlx5: Introduce vhca state event notifier · f3196bb0
      Parav Pandit authored
      
      
      vhca state events indicates change in the state of the vhca that may
      occur due to a SF allocation, deallocation or enabling/disabling the
      SF HCA.
      
      Introduce vhca state event handler which will be used by SF devlink
      port manager and SF hardware id allocator in subsequent patches
      to act on the event.
      
      This enables single entity to subscribe, query and rearm the event
      for a function.
      
      Signed-off-by: default avatarParav Pandit <parav@nvidia.com>
      Reviewed-by: default avatarVu Pham <vuhuong@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      f3196bb0
    • Parav Pandit's avatar
      devlink: Support get and set state of port function · a556dded
      Parav Pandit authored
      
      
      devlink port function can be in active or inactive state.
      Allow users to get and set port function's state.
      
      When the port function it activated, its operational state may change
      after a while when the device is created and driver binds to it.
      Similarly on deactivation flow.
      
      To clearly describe the state of the port function and its device's
      operational state in the host system, define state and opstate
      attributes.
      
      Example of a PCI SF port which supports a port function:
      
      $ devlink dev eswitch set pci/0000:06:00.0 mode switchdev
      
      $ devlink port show
      pci/0000:06:00.0/65535: type eth netdev ens2f0np0 flavour physical port 0 splittable false
      
      $ devlink port add pci/0000:06:00.0 flavour pcisf pfnum 0 sfnum 88
      pci/0000:08:00.0/32768: type eth netdev eth6 flavour pcisf controller 0 pfnum 0 sfnum 88 external false splittable false
        function:
          hw_addr 00:00:00:00:00:00 state inactive opstate detached
      
      $ devlink port show pci/0000:06:00.0/32768
      pci/0000:06:00.0/32768: type eth netdev ens2f0npf0sf88 flavour pcisf controller 0 pfnum 0 sfnum 88 external false splittable false
        function:
          hw_addr 00:00:00:00:88:88 state inactive opstate detached
      
      $ devlink port function set pci/0000:06:00.0/32768 hw_addr 00:00:00:00:88:88 state active
      
      $ devlink port show pci/0000:06:00.0/32768 -jp
      {
          "port": {
              "pci/0000:06:00.0/32768": {
                  "type": "eth",
                  "netdev": "ens2f0npf0sf88",
                  "flavour": "pcisf",
                  "controller": 0,
                  "pfnum": 0,
                  "sfnum": 88,
                  "external": false,
                  "splittable": false,
                  "function": {
                      "hw_addr": "00:00:00:00:88:88",
                      "state": "active",
                      "opstate": "attached"
                  }
              }
          }
      }
      
      Signed-off-by: default avatarParav Pandit <parav@nvidia.com>
      Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
      Reviewed-by: default avatarVu Pham <vuhuong@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      a556dded
    • Parav Pandit's avatar
      devlink: Support add and delete devlink port · cd76dcd6
      Parav Pandit authored
      
      
      Extended devlink interface for the user to add and delete a port.
      Extend devlink to connect user requests to driver to add/delete
      a port in the device.
      
      Driver routines are invoked without holding devlink instance lock.
      This enables driver to perform several devlink objects registration,
      unregistration such as (port, health reporter, resource etc) by using
      existing devlink APIs.
      This also helps to uniformly use the code for port unregistration
      during driver unload and during port deletion initiated by user.
      
      Examples of add, show and delete commands:
      $ devlink dev eswitch set pci/0000:06:00.0 mode switchdev
      
      $ devlink port show
      pci/0000:06:00.0/65535: type eth netdev ens2f0np0 flavour physical port 0 splittable false
      
      $ devlink port add pci/0000:06:00.0 flavour pcisf pfnum 0 sfnum 88
      pci/0000:06:00.0/32768: type eth netdev eth6 flavour pcisf controller 0 pfnum 0 sfnum 88 external false splittable false
        function:
          hw_addr 00:00:00:00:00:00 state inactive opstate detached
      
      $ devlink port show pci/0000:06:00.0/32768
      pci/0000:06:00.0/32768: type eth netdev eth6 flavour pcisf controller 0 pfnum 0 sfnum 88 external false splittable false
        function:
          hw_addr 00:00:00:00:00:00 state inactive opstate detached
      
      $ udevadm test-builtin net_id /sys/class/net/eth6
      Load module index
      Parsed configuration file /usr/lib/systemd/network/99-default.link
      Created link configuration context.
      Using default interface naming scheme 'v245'.
      ID_NET_NAMING_SCHEME=v245
      ID_NET_NAME_PATH=enp6s0f0npf0sf88
      ID_NET_NAME_SLOT=ens2f0npf0sf88
      Unload module index
      Unloaded link configuration context.
      
      Signed-off-by: default avatarParav Pandit <parav@nvidia.com>
      Reviewed-by: default avatarVu Pham <vuhuong@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      cd76dcd6
    • Parav Pandit's avatar
      devlink: Introduce PCI SF port flavour and port attribute · b8288837
      Parav Pandit authored
      
      
      A PCI sub-function (SF) represents a portion of the device similar
      to PCI VF.
      
      In an eswitch, PCI SF may have port which is normally represented
      using a representor netdevice.
      To have better visibility of eswitch port, its association with SF,
      and its representor netdevice, introduce a PCI SF port flavour.
      
      When devlink port flavour is PCI SF, fill up PCI SF attributes of the
      port.
      
      Extend port name creation using PCI PF and SF number scheme on best
      effort basis, so that vendor drivers can skip defining their own
      scheme.
      This is done as cApfNSfM, where A, N and M are controller, PCI PF and
      PCI SF number respectively.
      This is similar to existing naming for PCI PF and PCI VF ports.
      
      An example view of a PCI SF port:
      
      $ devlink port show pci/0000:06:00.0/32768
      pci/0000:06:00.0/32768: type eth netdev ens2f0npf0sf88 flavour pcisf controller 0 pfnum 0 sfnum 88 external false splittable false
        function:
          hw_addr 00:00:00:00:88:88 state active opstate attached
      
      $ devlink port show pci/0000:06:00.0/32768 -jp
      {
          "port": {
              "pci/0000:06:00.0/32768": {
                  "type": "eth",
                  "netdev": "ens2f0npf0sf88",
                  "flavour": "pcisf",
                  "controller": 0,
                  "pfnum": 0,
                  "sfnum": 88,
                  "splittable": false,
                  "function": {
                      "hw_addr": "00:00:00:00:88:88",
                      "state": "active",
                      "opstate": "attached"
                  }
              }
          }
      }
      
      Signed-off-by: default avatarParav Pandit <parav@nvidia.com>
      Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
      Reviewed-by: default avatarVu Pham <vuhuong@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      b8288837
    • Parav Pandit's avatar
      devlink: Prepare code to fill multiple port function attributes · 1230d948
      Parav Pandit authored
      
      
      Prepare code to fill zero or more port function optional attributes.
      Subsequent patch makes use of this to fill more port function
      attributes.
      
      Signed-off-by: default avatarParav Pandit <parav@nvidia.com>
      Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
      Reviewed-by: default avatarVu Pham <vuhuong@nvidia.com>
      Signed-off-by: default avatarSaeed Mahameed <saeedm@nvidia.com>
      1230d948
  2. Jan 20, 2021
  3. Jan 19, 2021
    • Tom Rix's avatar
      net: hns: fix variable used when DEBUG is defined · 99d51897
      Tom Rix authored
      
      
      When DEBUG is defined this error occurs
      
      drivers/net/ethernet/hisilicon/hns/hns_enet.c:1505:36: error:
        ‘struct net_device’ has no member named ‘ae_handle’;
        did you mean ‘rx_handler’?
        assert(skb->queue_mapping < ndev->ae_handle->q_num);
                                          ^~~~~~~~~
      
      ae_handle is an element of struct hns_nic_priv, so change
      ndev to priv.
      
      Signed-off-by: default avatarTom Rix <trix@redhat.com>
      Link: https://lore.kernel.org/r/20210117191044.533725-1-trix@redhat.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      99d51897
    • Tom Rix's avatar
      arcnet: fix macro name when DEBUG is defined · 7cfabe4f
      Tom Rix authored
      
      
      When DEBUG is defined this error occurs
      
      drivers/net/arcnet/com20020_cs.c:70:15: error: ‘com20020_REG_W_ADDR_HI’
        undeclared (first use in this function);
        did you mean ‘COM20020_REG_W_ADDR_HI’?
             ioaddr, com20020_REG_W_ADDR_HI);
                     ^~~~~~~~~~~~~~~~~~~~~~
      
      From reviewing the context, the suggestion is what is meant.
      
      Signed-off-by: default avatarTom Rix <trix@redhat.com>
      Acked-by: default avatarJoe Perches <joe@perches.com>
      Link: https://lore.kernel.org/r/20210117181519.527625-1-trix@redhat.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      7cfabe4f
    • Jakub Kicinski's avatar
      Merge branch 'tls-device-offload-for-bond' · be7f4578
      Jakub Kicinski authored
      Tariq Toukan says:
      
      ====================
      TLS device offload for Bond
      
      This series opens TX and RX TLS device offload for bond interfaces.
      This allows bond interfaces to benefit from capable lower devices.
      
      We add a new ndo_sk_get_lower_dev() to be used to get the lower dev that
      corresponds to a given socket.
      The TLS module uses it to interact directly with the lowest device in
      chain, and invoke the control operations in tlsdev_ops. This means that the
      bond interface doesn't have his own struct tlsdev_ops instance and
      derived logic/callbacks.
      
      To keep simple track of the HW and SW TLS contexts, we bind each socket to
      a specific lower device for the socket's whole lifetime. This is logically
      valid (and similar to the SW kTLS behavior) in the following bond configuration,
      so we restrict the offload support to it:
      
      ((mode == balance-xor) or (mode == 802.3ad))
      and xmit_hash_policy == layer3+4.
      
      In this design, TLS TX/RX offload feature flags of the bond device are
      independent from the lower devices. They reflect the current features state,
      but are not directly controllable.
      This is because the bond driver is bypassed by the call to
      ndo_sk_get_lower_dev(), without him knowing who the caller is.
      The bond TLS feature flags are set/cleared only according to the configuration
      of the mode and xmit_hash_policy.
      
      Bypass is true only for the control flow. Packets in fast path still go through
      the bond logic.
      
      The design here differs from the xfrm/ipsec offload, where the bond driver
      has his own copy of struct xfrmdev_ops and callbacks.
      ====================
      
      Link: https://lore.kernel.org/r/20210117145949.8632-1-tariqt@nvidia.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      be7f4578
    • Tariq Toukan's avatar
      net/tls: Except bond interface from some TLS checks · 4e5a7332
      Tariq Toukan authored
      
      
      In the tls_dev_event handler, ignore tlsdev_ops requirement for bond
      interfaces, they do not exist as the interaction is done directly with
      the lower device.
      
      Also, make the validate function pass when it's called with the upper
      bond interface.
      
      Signed-off-by: default avatarTariq Toukan <tariqt@nvidia.com>
      Reviewed-by: default avatarBoris Pismenny <borisp@nvidia.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      4e5a7332