Commit Graph

66 Commits

Author SHA1 Message Date
Ivan Vecera afdf9850e0 netdevsim: fix backwards compatibility in nsim_get_iflink()
JIRA: https://issues.redhat.com/browse/RHEL-57764

commit 5add2f7288468f35a374620dabf126c13baaea9c
Author: David Wei <dw@davidwei.uk>
Date:   Thu Jun 6 07:59:08 2024 -0700

    netdevsim: fix backwards compatibility in nsim_get_iflink()

    The default ndo_get_iflink() implementation returns the current ifindex
    of the netdev. But the overridden nsim_get_iflink() returns 0 if the
    current nsim is not linked, breaking backwards compatibility for
    userspace that depend on this behaviour.

    Fix the problem by returning the current ifindex if not linked to a
    peer.

    Fixes: 8debcf5832c3 ("netdevsim: add ndo_get_iflink() implementation")
    Reported-by: Yu Watanabe <watanabe.yu@gmail.com>
    Suggested-by: Yu Watanabe <watanabe.yu@gmail.com>
    Signed-off-by: David Wei <dw@davidwei.uk>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
2024-10-07 15:18:28 +02:00
Ivan Vecera bd0b809773 netdevsim: add NAPI support
JIRA: https://issues.redhat.com/browse/RHEL-57764

commit 3762ec05a9fbda16aaaa2568df679ab8ad13f38d
Author: David Wei <dw@davidwei.uk>
Date:   Tue May 7 09:32:27 2024 -0700

    netdevsim: add NAPI support

    Add NAPI support to netdevim, similar to veth.

    * Add a nsim_rq rx queue structure to hold a NAPI instance and a skb
      queue.
    * During xmit, store the skb in the peer skb queue and schedule NAPI.
    * During napi_poll(), drain the skb queue and pass up the stack.
    * Add assoc between rxq and NAPI instance using netif_queue_set_napi().

    Signed-off-by: David Wei <dw@davidwei.uk>
    Link: https://lore.kernel.org/r/20240507163228.2066817-2-dw@davidwei.uk
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
2024-10-07 15:18:28 +02:00
Ivan Vecera 6d0149fbed net: netdevsim: add some fake page pool use
JIRA: https://issues.redhat.com/browse/RHEL-57764

commit 1580cbcbfe770b0a7fb76735c1a601483335c1c2
Author: Jakub Kicinski <kuba@kernel.org>
Date:   Fri Apr 12 07:14:31 2024 -0700

    net: netdevsim: add some fake page pool use

    Add very basic page pool use so that we can exercise
    the netlink uAPI in a selftest.

    Page pool gets created on open, destroyed on close.
    But we control allocating of a single page thru debugfs.
    This page may survive past the page pool itself so that
    we can test orphaned page pools.

    Link: https://lore.kernel.org/r/20240412141436.828666-2-kuba@kernel.org
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
2024-10-07 11:26:37 +02:00
Ivan Vecera 0b04d4dc2a netdevsim: report stats by default, like a real device
JIRA: https://issues.redhat.com/browse/RHEL-57764

commit f216306bfb602b449cb2c49cf03870fb8761d146
Author: Jakub Kicinski <kuba@kernel.org>
Date:   Thu Apr 4 19:45:24 2024 -0700

    netdevsim: report stats by default, like a real device

    Real devices should implement qstats. Devices which support
    pause or FEC configuration should also report the relevant stats.

    nsim was missing FEC stats completely, some of the qstats
    and pause stats required toggling a debugfs knob.

    Note that the tests which used pause always initialize the setting
    so they shouldn't be affected by the different starting value.

    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
2024-10-07 11:26:37 +02:00
Lucas Zampieri a14ac2400e Merge: CNB95: net: annotate writes on dev->mtu from ndo_change_mtu()
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/4387

JIRA: https://issues.redhat.com/browse/RHEL-39583  
Tested: Just built... no way to test  

Commit(s):
```
1eb2cded45b3 ("net: annotate writes on dev->mtu from ndo_change_mtu()")
```

Signed-off-by: Ivan Vecera <ivecera@redhat.com>

Approved-by: Tony Camuso <tcamuso@redhat.com>
Approved-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Approved-by: Antoine Tenart <atenart@redhat.com>
Approved-by: José Ignacio Tornos Martínez <jtornosm@redhat.com>
Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com>

Merged-by: Lucas Zampieri <lzampier@redhat.com>
2024-06-19 18:24:31 +00:00
Ivan Vecera 24ef7349da net: annotate writes on dev->mtu from ndo_change_mtu()
JIRA: https://issues.redhat.com/browse/RHEL-39583

Conflicts:
- hunks for non-existing files and non-applicable hunks for unsupported
  drivers, batman-adv and DSA were skipped

commit 1eb2cded45b35816085c1f962933c187d970f9dc
Author: Eric Dumazet <edumazet@google.com>
Date:   Mon May 6 10:28:12 2024 +0000

    net: annotate writes on dev->mtu from ndo_change_mtu()

    Simon reported that ndo_change_mtu() methods were never
    updated to use WRITE_ONCE(dev->mtu, new_mtu) as hinted
    in commit 501a90c945 ("inet: protect against too small
    mtu values.")

    We read dev->mtu without holding RTNL in many places,
    with READ_ONCE() annotations.

    It is time to take care of ndo_change_mtu() methods
    to use corresponding WRITE_ONCE()

    Signed-off-by: Eric Dumazet <edumazet@google.com>
    Reported-by: Simon Horman <horms@kernel.org>
    Closes: https://lore.kernel.org/netdev/20240505144608.GB67882@kernel.org/
    Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
    Reviewed-by: Sabrina Dubroca <sd@queasysnail.net>
    Reviewed-by: Simon Horman <horms@kernel.org>
    Acked-by: Shannon Nelson <shannon.nelson@amd.com>
    Link: https://lore.kernel.org/r/20240506102812.3025432-1-edumazet@google.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
2024-05-31 21:00:33 +02:00
Petr Oros a1de480ea9 netdevsim: add ndo_get_iflink() implementation
JIRA: https://issues.redhat.com/browse/RHEL-38987

Upstream commit(s):
commit 8debcf5832c3e8a6baaea27c75ad8a6ba5077beb
Author: David Wei <dw@davidwei.uk>
Date:   Wed Feb 28 15:22:51 2024 -0800

    netdevsim: add ndo_get_iflink() implementation

    Add an implementation for ndo_get_iflink() in netdevsim that shows the
    ifindex of the linked peer, if any.

    Signed-off-by: David Wei <dw@davidwei.uk>
    Reviewed-by: Maciek Machnikowski <maciek@machnikowski.net>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Petr Oros <poros@redhat.com>
2024-05-28 13:35:19 +02:00
Petr Oros 3f7a63081f netdevsim: forward skbs from one connected port to another
JIRA: https://issues.redhat.com/browse/RHEL-38987

Upstream commit(s):
commit 9eb95228a74163e26d338913a5d61e571ea45307
Author: David Wei <dw@davidwei.uk>
Date:   Wed Feb 28 15:22:50 2024 -0800

    netdevsim: forward skbs from one connected port to another

    Forward skbs sent from one netdevsim port to its connected netdevsim
    port using dev_forward_skb, in a spirit similar to veth.

    Add a tx_dropped variable to struct netdevsim, tracking the number of
    skbs that could not be forwarded using dev_forward_skb().

    The xmit() function accessing the peer ptr is protected by an RCU read
    critical section. The rcu_read_lock() is functionally redundant as since
    v5.0 all softirqs are implicitly RCU read critical sections; but it is
    useful for human readers.

    If another CPU is concurrently in nsim_destroy(), then it will first set
    the peer ptr to NULL. This does not affect any existing readers that
    dereferenced a non-NULL peer. Then, in unregister_netdevice(), there is
    a synchronize_rcu() before the netdev is actually unregistered and
    freed. This ensures that any readers i.e. xmit() that got a non-NULL
    peer will complete before the netdev is freed.

    Any readers after the RCU_INIT_POINTER() but before synchronize_rcu()
    will dereference NULL, making it safe.

    The codepath to nsim_destroy() and nsim_create() takes both the newly
    added nsim_dev_list_lock and rtnl_lock. This makes it safe with
    concurrent calls to linking two netdevsims together.

    Signed-off-by: David Wei <dw@davidwei.uk>
    Reviewed-by: Maciek Machnikowski <maciek@machnikowski.net>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Petr Oros <poros@redhat.com>
2024-05-28 13:35:19 +02:00
Petr Oros ee1ffb10b7 netdevsim: allow two netdevsim ports to be connected
JIRA: https://issues.redhat.com/browse/RHEL-38987

Upstream commit(s):
commit f532957d76de89b8ee2545cb6ad5265e1701d0ba
Author: David Wei <dw@davidwei.uk>
Date:   Wed Feb 28 15:22:49 2024 -0800

    netdevsim: allow two netdevsim ports to be connected

    Add two netdevsim bus attribute to sysfs:
    /sys/bus/netdevsim/link_device
    /sys/bus/netdevsim/unlink_device

    Writing "A M B N" to link_device will link netdevsim M in netnsid A with
    netdevsim N in netnsid B.

    Writing "A M" to unlink_device will unlink netdevsim M in netnsid A from
    its peer, if any.

    rtnl_lock is taken to ensure nothing changes during the linking.

    Signed-off-by: David Wei <dw@davidwei.uk>
    Reviewed-by: Maciek Machnikowski <maciek@machnikowski.net>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Petr Oros <poros@redhat.com>
2024-05-28 13:35:19 +02:00
Ivan Vecera 0225067fcd net: netdevsim: don't try to destroy PHC on VFs
JIRA: https://issues.redhat.com/browse/RHEL-36218

commit ea937f77208323d35ffe2f8d8fc81b00118bfcda
Author: Jakub Kicinski <kuba@kernel.org>
Date:   Tue Jan 16 11:14:00 2024 -0800

    net: netdevsim: don't try to destroy PHC on VFs

    PHC gets initialized in nsim_init_netdevsim(), which
    is only called if (nsim_dev_port_is_pf()).

    Create a counterpart of nsim_init_netdevsim() and
    move the mock_phc_destroy() there.

    This fixes a crash trying to destroy netdevsim with
    VFs instantiated, as caught by running the devlink.sh test:

        BUG: kernel NULL pointer dereference, address: 00000000000000b8
        RIP: 0010:mock_phc_destroy+0xd/0x30
        Call Trace:
         <TASK>
         nsim_destroy+0x4a/0x70 [netdevsim]
         __nsim_dev_port_del+0x47/0x70 [netdevsim]
         nsim_dev_reload_destroy+0x105/0x120 [netdevsim]
         nsim_drv_remove+0x2f/0xb0 [netdevsim]
         device_release_driver_internal+0x1a1/0x210
         bus_remove_device+0xd5/0x120
         device_del+0x159/0x490
         device_unregister+0x12/0x30
         del_device_store+0x11a/0x1a0 [netdevsim]
         kernfs_fop_write_iter+0x130/0x1d0
         vfs_write+0x30b/0x4b0
         ksys_write+0x69/0xf0
         do_syscall_64+0xcc/0x1e0
         entry_SYSCALL_64_after_hwframe+0x6f/0x77

    Fixes: b63e78fca889 ("net: netdevsim: use mock PHC driver")
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Reviewed-by: Simon Horman <horms@kernel.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
2024-05-14 13:13:25 +02:00
Ivan Vecera a00effc205 net: netdevsim: mimic tc-taprio offload
JIRA: https://issues.redhat.com/browse/RHEL-36218

commit 35da47fe1c4766451def03a1b4f59c6b13a9373c
Author: Vladimir Oltean <vladimir.oltean@nxp.com>
Date:   Mon Aug 7 22:33:21 2023 +0300

    net: netdevsim: mimic tc-taprio offload

    To be able to use netdevsim for tc-testing with an offloaded tc-taprio
    schedule, it needs to report a PTP clock (which it now does), and to
    accept ndo_setup_tc(TC_SETUP_QDISC_TAPRIO) calls.

    Since netdevsim has no packet I/O, this doesn't do anything intelligent,
    it only allows taprio offload code paths to go through some level of
    automated testing.

    Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
    Link: https://lore.kernel.org/r/20230807193324.4128292-9-vladimir.oltean@nxp.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
2024-05-14 13:13:16 +02:00
Ivan Vecera 8f46a36b17 net: netdevsim: use mock PHC driver
JIRA: https://issues.redhat.com/browse/RHEL-36218

commit b63e78fca889e07931ec8f259701718a24e5052e
Author: Vladimir Oltean <vladimir.oltean@nxp.com>
Date:   Mon Aug 7 22:33:20 2023 +0300

    net: netdevsim: use mock PHC driver

    I'd like to make netdevsim offload tc-taprio, but currently, this Qdisc
    emits a ETHTOOL_GET_TS_INFO call to the driver to make sure that it has
    a PTP clock, so that it is reasonably capable of offloading the schedule.

    By using the mock PHC driver, that becomes possible.

    Hardware timestamping is not necessary, and netdevsim does not support
    packet I/O anyway.

    Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
    Link: https://lore.kernel.org/r/20230807193324.4128292-8-vladimir.oltean@nxp.com
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
2024-05-14 13:13:16 +02:00
Scott Weaver a184e90347 Merge: net: add macsec offload selftest
MR: https://gitlab.com/redhat/rhel/src/kernel/rhel-9/-/merge_requests/1353

JIRA: https://issues.redhat.com/browse/RHEL-24616

Backport of commits:

ecb3c1e675c7 selftests: rtnetlink: Make the set of tests to run
configurable
02b34d03a24b netdevsim: add dummy macsec offload
3b5222e2ac57 selftests: rtnetlink: add MACsec offload tests

Patch 1 avoids a conflict when backporting the selftests.

Signed-off-by: Sabrina Dubroca <sdubroca@redhat.com>

Approved-by: Davide Caratti <dcaratti@redhat.com>
Approved-by: Antoine Tenart <atenart@redhat.com>

Merged-by: Scott Weaver <scweaver@redhat.com>
2024-03-11 11:59:38 -04:00
Sabrina Dubroca af8abe5cc4 netdevsim: add dummy macsec offload
JIRA: https://issues.redhat.com/browse/RHEL-24616

commit 02b34d03a24b18970925cf57434be28ba4a29d3a
Author: Sabrina Dubroca <sd@queasysnail.net>
Date:   Thu Jul 13 15:20:23 2023 +0200

    netdevsim: add dummy macsec offload

    When the kernel is compiled with MACsec support, add the
    NETIF_F_HW_MACSEC feature to netdevsim devices and implement
    macsec_ops.

    To allow easy testing of failure from the device, support is limited
    to 3 SecY's per netdevsim device, and 1 RXSC per SecY.

    v2:
     - nsim_macsec_add_secy, return -ENOSPC if secy_count isn't full but
       we can't find an empty slot (Simon Horman)
     - add sci_to_cpu to make sparse happy (Simon Horman)
     - remove set but not used secy variable (kernel test robot and
       Simon Horman)

    Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
    Reviewed-by: Simon Horman <simon.horman@corigine.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Sabrina Dubroca <sdubroca@redhat.com>
2024-02-07 10:06:55 +01:00
Jose Ignacio Tornos Martinez 1354fa36c5 net: fill in MODULE_DESCRIPTION()s in kuba@'s modules
JIRA: https://issues.redhat.com/browse/RHEL-19746

commit 1fff1f799038a99cd1f2ae3999661ad9d506bb8c
Author: Jakub Kicinski <kuba@kernel.org>
Date:   Fri Oct 27 14:13:08 2023 -0700

    net: fill in MODULE_DESCRIPTION()s in kuba@'s modules
    
    W=1 builds now warn if module is built without a MODULE_DESCRIPTION().
    Fill it in for the modules I maintain.
    
    Acked-by: Kalle Valo <kvalo@kernel.org>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2024-02-01 15:29:57 +01:00
Jan Stancek e341c7e709 Merge: bpf, xdp: update to 6.3
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/2583

Rebase bpf and xdp to 6.3.

Bugzilla: https://bugzilla.redhat.com/2178930

Signed-off-by: Viktor Malik <vmalik@redhat.com>

Approved-by: Rafael Aquini <aquini@redhat.com>
Approved-by: Artem Savkov <asavkov@redhat.com>
Approved-by: Jason Wang <jasowang@redhat.com>
Approved-by: Jiri Benc <jbenc@redhat.com>
Approved-by: Jan Stancek <jstancek@redhat.com>
Approved-by: Baoquan He <5820488-baoquan_he@users.noreply.gitlab.com>

Signed-off-by: Jan Stancek <jstancek@redhat.com>
2023-06-28 07:52:45 +02:00
Felix Maurer d892a11ed2 drivers: net: turn on XDP features
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2178930
Conflicts:
- drivers/net/ethernet/engleder/tsnep_main.c: We don't have this driver
- drivers/net/ethernet/fungible/funeth/funeth_main.c: We don't have this
  driver
- drivers/net/ethernet/aquantia/atlantic/aq_nic.c: left out because it
  does not have XDP support
- drivers/net/ethernet/mediatek/mtk_eth_soc.c: left out because mtk_eth_soc
  does not have XDP support
- drivers/net/ethernet/freescale/dpaa/dpaa_eth.c: left out because driver
  is not enabled
- drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c: left out because driver
  is not enabled
- drivers/net/ethernet/freescale/enetc/enetc_pf.c: left out because driver
  is not enabled
- drivers/net/ethernet/marvell/mvneta.c: left out because driver is not
  enabled
- drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c: left out because driver
  is not enabled
- drivers/net/ethernet/socionext/netsec.c: left out because driver is not
  enabled
- drivers/net/ethernet/ti/cpsw.c: left out because driver is not enabled
- drivers/net/ethernet/ti/cpsw_new.c: left out because driver is not
  enabled
- drivers/net/ethernet/netronome/nfp/nfp_net_common.c: Context difference
  due to missing 67d2656b48f1 ("nfp: support RX VLAN ctag/stag strip") and
  7de8b691615f ("nfp: enable TSO by default for nfp netdev")
- drivers/net/ethernet/intel/ice/ice_main.c: Merge conflict upstream
  between 5b246e533d01 ("ice: split probe into smaller functions") and this
  commit. Resolved the same way as upstream in de4287336794 (pull-request:
  bpf-next 2023-02-11): only add the XDP features to the existing
  ice_cfg_netdev() function.
- drivers/net/ethernet/intel/i40e/i40e_main.c: Code difference because the
  driver does not have support for frags/multi-buff. The last parameter of
  xdp_features_set_redirect_target indicates if frags are supported for Tx,
  we change the code to set it to false.

Omitted-fix: 1dc55923296d ("net: mvneta: do not set xdp_features for hw
buffer devices")
mvneta is not enabled and hunks in this commit are skipped
Omitted-fix: 481e96fc1307 ("mvpp2: take care of xdp_features when
reconfiguring queues")
mvpp2 is not enabled and hunks in this commit are skipped
Omitted-fix: e4ac7cc6e5a4 ("net: fec: turn on XDP features")
fec does not have XDP support

commit 66c0e13ad236c74ea88c7c1518f3cef7f372e3da
Author: Marek Majtyka <alardam@gmail.com>
Date:   Wed Feb 1 11:24:18 2023 +0100

    drivers: net: turn on XDP features

    A summary of the flags being set for various drivers is given below.
    Note that XDP_F_REDIRECT_TARGET and XDP_F_FRAG_TARGET are features
    that can be turned off and on at runtime. This means that these flags
    may be set and unset under RTNL lock protection by the driver. Hence,
    READ_ONCE must be used by code loading the flag value.

    Also, these flags are not used for synchronization against the availability
    of XDP resources on a device. It is merely a hint, and hence the read
    may race with the actual teardown of XDP resources on the device. This
    may change in the future, e.g. operations taking a reference on the XDP
    resources of the driver, and in turn inhibiting turning off this flag.
    However, for now, it can only be used as a hint to check whether device
    supports becoming a redirection target.

    Turn 'hw-offload' feature flag on for:
     - netronome (nfp)
     - netdevsim.

    Turn 'native' and 'zerocopy' features flags on for:
     - intel (i40e, ice, ixgbe, igc)
     - mellanox (mlx5).
     - stmmac
     - netronome (nfp)

    Turn 'native' features flags on for:
     - amazon (ena)
     - broadcom (bnxt)
     - freescale (dpaa, dpaa2, enetc)
     - funeth
     - intel (igb)
     - marvell (mvneta, mvpp2, octeontx2)
     - mellanox (mlx4)
     - mtk_eth_soc
     - qlogic (qede)
     - sfc
     - socionext (netsec)
     - ti (cpsw)
     - tap
     - tsnep
     - veth
     - xen
     - virtio_net.

    Turn 'basic' (tx, pass, aborted and drop) features flags on for:
     - netronome (nfp)
     - cavium (thunder)
     - hyperv.

    Turn 'redirect_target' feature flag on for:
     - amanzon (ena)
     - broadcom (bnxt)
     - freescale (dpaa, dpaa2)
     - intel (i40e, ice, igb, ixgbe)
     - ti (cpsw)
     - marvell (mvneta, mvpp2)
     - sfc
     - socionext (netsec)
     - qlogic (qede)
     - mellanox (mlx5)
     - tap
     - veth
     - virtio_net
     - xen

    Reviewed-by: Gerhard Engleder <gerhard@engleder-embedded.com>
    Reviewed-by: Simon Horman <simon.horman@corigine.com>
    Acked-by: Stanislav Fomichev <sdf@google.com>
    Acked-by: Jakub Kicinski <kuba@kernel.org>
    Co-developed-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
    Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
    Co-developed-by: Lorenzo Bianconi <lorenzo@kernel.org>
    Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
    Signed-off-by: Marek Majtyka <alardam@gmail.com>
    Link: https://lore.kernel.org/r/3eca9fafb308462f7edb1f58e451d59209aa07eb.1675245258.git.lorenzo@kernel.org
    Signed-off-by: Alexei Starovoitov <ast@kernel.org>

Signed-off-by: Felix Maurer <fmaurer@redhat.com>
2023-06-14 10:33:43 +02:00
Ivan Vecera 59591f9868 net: Remove the obsolte u64_stats_fetch_*_irq() users (drivers).
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2193170

Conflicts:
- small context conflict around required change
- hunks for missing files were skipped
- several hunks for existing files were skipped as they are not
  applicable (missing get_stats callback etc.)
- hunks for aquantia, i40e, iavf, igb were skipped as they are already applied

commit 068c38ad88ccb09e5e966d4db5cedab0e02b3b95
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Wed Oct 26 15:22:14 2022 +0200

    net: Remove the obsolte u64_stats_fetch_*_irq() users (drivers).

    Now that the 32bit UP oddity is gone and 32bit uses always a sequence
    count, there is no need for the fetch_irq() variants anymore.

    Convert to the regular interface.

    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
    Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Ivan Vecera <ivecera@redhat.com>
2023-06-08 13:37:52 +02:00
Petr Oros e462bc9297 net: remove unused ndo_get_devlink_port
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2172273

Conflicts:
-  drivers/net/ethernet/marvell/prestera/prestera_devlink.c: adjusted
   context conflict due to missing 4beb0c241bfac5 ("net/prestera:
   Split devlink and traps registrations to separate routines")
-  drivers/net/ethernet/mscc/ocelot_net.c: adjusted context
   conflict due to missing 7e708760fc114f ("net: mscc: ocelot:
   move ocelot_port_private :: chip_port to ocelot_port :: index")
-  drivers/net/ethernet/netronome/nfp/nfp_net_common.c:
   adjusted context conflict due to missing be80141108bc04
   ("nfp: support vepa mode in HW bridge")
-  net/dsa/slave.c:
   adjusted context conflict due to missing 45b987d5edf227 ("net:
   dsa: remove ndo_get_phys_port_name and ndo_get_port_parent_id")
-  Unmerged, because file missing in rhel:
    drivers/net/ethernet/fungible/funeth/funeth_main.c

Upstream commit(s):
commit 77df1db80da384c565106321f5934967690da7dd
Author: Jiri Pirko <jiri@nvidia.com>
Date:   Wed Nov 2 17:02:10 2022 +0100

    net: remove unused ndo_get_devlink_port

    Remove ndo_get_devlink_port which is no longer used alongside with the
    implementations in drivers.

    Signed-off-by: Jiri Pirko <jiri@nvidia.com>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Petr Oros <poros@redhat.com>
2023-04-03 11:18:21 +02:00
Petr Oros 7bb2823ab1 net: make drivers to use SET_NETDEV_DEVLINK_PORT to set devlink_port
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2172273

Conflicts:
- drivers/net/ethernet/mellanox/mlxsw/core.c: adjusted context conflicts
  due to missing 3471ac9b22c18a ("mlxsw: Remove unused IB stuff")
- drivers/net/ethernet/mellanox/mlxsw/spectrum.c: adjusted context
  conflicts due to missing a159e986ad26d3 ("mlxsw: spectrum: Clear PTP
  configuration after unregistering the netdevice")
- drivers/net/ethernet/marvell/prestera/prestera_main.c: adjusted context
  conflict due to missing 52323ef75414d6 ("net: marvell: prestera:
  add phylink support")
- drivers/net/ethernet/mscc/ocelot_vsc7514.c: adjusted context conflict
  due to missing e6e12df625f23e net: mscc: ocelot: convert to phylink
- drivers/net/ethernet/ti/am65-cpsw-nuss.c: skipped chunk due to
  missing 0680e20af5fbf4 ("net: ethernet: ti: am65-cpsw: Fix devlink
  port register sequence")
- drivers/net/ethernet/fungible/funeth/funeth_main.c: unmerged path
  because file missing in RHEL

Upstream commit(s):
commit ac73d4bf2cdaf2cb8a43df8ee4a5c066d2c5d7b4
Author: Jiri Pirko <jiri@nvidia.com>
Date:   Wed Nov 2 17:02:04 2022 +0100

    net: make drivers to use SET_NETDEV_DEVLINK_PORT to set devlink_port

    Benefit from the previously implemented tracking of netdev events in
    devlink code and instead of calling  devlink_port_type_eth_set() and
    devlink_port_type_clear() to set devlink port type and link to related
    netdev, use SET_NETDEV_DEVLINK_PORT() macro to assign devlink_port
    pointer to netdevice which is about to be registered.

    Signed-off-by: Jiri Pirko <jiri@nvidia.com>
    Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Signed-off-by: Petr Oros <poros@redhat.com>
2023-04-03 10:57:13 +02:00
Juri Lelli 8def9d55d8 net: Use u64_stats_fetch_begin_irq() for stats fetch.
Bugzilla: https://bugzilla.redhat.com/2171995
Conflicts: RHEL doesn't have ethernet fungible driver. Also, missing
           mac80211 hunk due to RHEL9's commit c2d826628b ("net:
           Use u64_stats_fetch_begin_irq() for stats fetch.") which
           introduced only the mac80211 portion of the change below.

commit 278d3ba61563ceed3cb248383ced19e14ec7bc1f
Author:    Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date:      Thu Aug 25 13:36:45 2022 +0200

    net: Use u64_stats_fetch_begin_irq() for stats fetch.

    On 32bit-UP u64_stats_fetch_begin() disables only preemption. If the
    reader is in preemptible context and the writer side
    (u64_stats_update_begin*()) runs in an interrupt context (IRQ or
    softirq) then the writer can update the stats during the read operation.
    This update remains undetected.

    Use u64_stats_fetch_begin_irq() to ensure the stats fetch on 32bit-UP
    are not interrupted by a writer. 32bit-SMP remains unaffected by this
    change.

    Cc: "David S. Miller" <davem@davemloft.net>
    Cc: Catherine Sullivan <csully@google.com>
    Cc: David Awogbemila <awogbemila@google.com>
    Cc: Dimitris Michailidis <dmichail@fungible.com>
    Cc: Eric Dumazet <edumazet@google.com>
    Cc: Hans Ulli Kroll <ulli.kroll@googlemail.com>
    Cc: Jakub Kicinski <kuba@kernel.org>
    Cc: Jeroen de Borst <jeroendb@google.com>
    Cc: Johannes Berg <johannes@sipsolutions.net>
    Cc: Linus Walleij <linus.walleij@linaro.org>
    Cc: Paolo Abeni <pabeni@redhat.com>
    Cc: Simon Horman <simon.horman@corigine.com>
    Cc: linux-arm-kernel@lists.infradead.org
    Cc: linux-wireless@vger.kernel.org
    Cc: netdev@vger.kernel.org
    Cc: oss-drivers@corigine.com
    Cc: stable@vger.kernel.org
    Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
    Reviewed-by: Simon Horman <simon.horman@corigine.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Juri Lelli <juri.lelli@redhat.com>
2023-02-27 13:46:07 +01:00
Petr Oros d0fd866953 netdevsim: move vfconfig to nsim_dev
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2112332

Conflicts:
- adjusted context conflict due to already applied 4c897cfc46a554
  ("devlink: Simplify devlink resources unregister call")

Upstream commit(s):
commit 5e388f3dc38c72da2880549e68374c3b6ba7c589
Author: Jakub Kicinski <kuba@kernel.org>
Date:   Sat Oct 30 16:15:02 2021 -0700

    netdevsim: move vfconfig to nsim_dev

    When netdevsim got split into the faux bus vfconfig ended
    up in the bus device (think pci_dev) which is strange because
    it contains very networky not to say netdevy information.
    Move it to nsim_dev, which is the driver "priv" structure
    for the device.

    To make sure we don't race with probe/remove take
    the device lock (much like PCI).

    While at it remove the NULL-checking of vfconfigs.
    It appears to be pointless.

    Signed-off-by: Jakub Kicinski <kuba@kernel.org>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Petr Oros <poros@redhat.com>
2022-07-29 13:22:58 +02:00
Jiri Benc 05f1e863a0 netdevsim: Add multi-queue support
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2071618

commit d4861fc6be581561d6964700110a4dede54da6a6
Author: Peilin Ye <peilin.ye@bytedance.com>
Date:   Thu Jul 15 18:52:45 2021 -0700

    netdevsim: Add multi-queue support

    Currently netdevsim only supports a single queue per port, which is
    insufficient for testing multi-queue TC schedulers e.g. sch_mq.  Extend
    the current sysfs interface so that users can create ports with multiple
    queues:

    $ echo "[ID] [PORT_COUNT] [NUM_QUEUES]" > /sys/bus/netdevsim/new_device

    As an example, echoing "2 4 8" creates 4 ports, with 8 queues per port.
    Note, this is compatible with the current interface, with default number
    of queues set to 1.  For example, echoing "2 4" creates 4 ports with 1
    queue per port; echoing "2" simply creates 1 port with 1 queue.

    Reviewed-by: Cong Wang <cong.wang@bytedance.com>
    Signed-off-by: Peilin Ye <peilin.ye@bytedance.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Signed-off-by: Jiri Benc <jbenc@redhat.com>
2022-05-12 17:29:45 +02:00
Dmytro Linkin 160dc373ee netdevsim: Implement legacy/switchdev mode for VFs
Implement callbacks to set/get eswitch mode value. Add helpers to check
current mode.

Instantiate VFs' net devices and devlink ports on switchdev enabling and
remove them on legacy enabling. Changing number of VFs while in
switchdev mode triggers VFs creation/deletion.

Also disable NDO API callback to set VF rate, since it's legacy API.
Switchdev API to set VF rate will be implemented in one of the next
patches.

Signed-off-by: Dmytro Linkin <dlinkin@nvidia.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2021-06-02 14:08:36 -07:00
Dmytro Linkin 92ba1f29e6 netdevsim: Implement VFs
Allow creation of netdevsim ports for VFs along with allocations of
corresponding net devices and devlink ports.
Add enums and helpers to distinguish PFs' ports from VFs' ports.

Ports creation/deletion debugfs API intended to be used with physical
ports only.
VFs instantiation will be done in one of the next patches.

Signed-off-by: Dmytro Linkin <dlinkin@nvidia.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2021-06-02 14:08:36 -07:00
Hillf Danton 863a42b289 netdevsim: init u64 stats for 32bit hardware
Init the u64 stats in order to avoid the lockdep prints on the 32bit
hardware like

 INFO: trying to register non-static key.
 the code is fine but needs lockdep annotation.
 turning off the locking correctness validator.
 CPU: 0 PID: 4695 Comm: syz-executor.0 Not tainted 5.11.0-rc5-syzkaller #0
 Hardware name: ARM-Versatile Express
 Backtrace:
 [<826fc5b8>] (dump_backtrace) from [<826fc82c>] (show_stack+0x18/0x1c arch/arm/kernel/traps.c:252)
 [<826fc814>] (show_stack) from [<8270d1f8>] (__dump_stack lib/dump_stack.c:79 [inline])
 [<826fc814>] (show_stack) from [<8270d1f8>] (dump_stack+0xa8/0xc8 lib/dump_stack.c:120)
 [<8270d150>] (dump_stack) from [<802bf9c0>] (assign_lock_key kernel/locking/lockdep.c:935 [inline])
 [<8270d150>] (dump_stack) from [<802bf9c0>] (register_lock_class+0xabc/0xb68 kernel/locking/lockdep.c:1247)
 [<802bef04>] (register_lock_class) from [<802baa2c>] (__lock_acquire+0x84/0x32d4 kernel/locking/lockdep.c:4711)
 [<802ba9a8>] (__lock_acquire) from [<802be840>] (lock_acquire.part.0+0xf0/0x554 kernel/locking/lockdep.c:5442)
 [<802be750>] (lock_acquire.part.0) from [<802bed10>] (lock_acquire+0x6c/0x74 kernel/locking/lockdep.c:5415)
 [<802beca4>] (lock_acquire) from [<81560548>] (seqcount_lockdep_reader_access include/linux/seqlock.h:103 [inline])
 [<802beca4>] (lock_acquire) from [<81560548>] (__u64_stats_fetch_begin include/linux/u64_stats_sync.h:164 [inline])
 [<802beca4>] (lock_acquire) from [<81560548>] (u64_stats_fetch_begin include/linux/u64_stats_sync.h:175 [inline])
 [<802beca4>] (lock_acquire) from [<81560548>] (nsim_get_stats64+0xdc/0xf0 drivers/net/netdevsim/netdev.c:70)
 [<8156046c>] (nsim_get_stats64) from [<81e2efa0>] (dev_get_stats+0x44/0xd0 net/core/dev.c:10405)
 [<81e2ef5c>] (dev_get_stats) from [<81e53204>] (rtnl_fill_stats+0x38/0x120 net/core/rtnetlink.c:1211)
 [<81e531cc>] (rtnl_fill_stats) from [<81e59d58>] (rtnl_fill_ifinfo+0x6d4/0x148c net/core/rtnetlink.c:1783)
 [<81e59684>] (rtnl_fill_ifinfo) from [<81e5ceb4>] (rtmsg_ifinfo_build_skb+0x9c/0x108 net/core/rtnetlink.c:3798)
 [<81e5ce18>] (rtmsg_ifinfo_build_skb) from [<81e5d0ac>] (rtmsg_ifinfo_event net/core/rtnetlink.c:3830 [inline])
 [<81e5ce18>] (rtmsg_ifinfo_build_skb) from [<81e5d0ac>] (rtmsg_ifinfo_event net/core/rtnetlink.c:3821 [inline])
 [<81e5ce18>] (rtmsg_ifinfo_build_skb) from [<81e5d0ac>] (rtmsg_ifinfo+0x44/0x70 net/core/rtnetlink.c:3839)
 [<81e5d068>] (rtmsg_ifinfo) from [<81e45c2c>] (register_netdevice+0x664/0x68c net/core/dev.c:10103)
 [<81e455c8>] (register_netdevice) from [<815608bc>] (nsim_create+0xf8/0x124 drivers/net/netdevsim/netdev.c:317)
 [<815607c4>] (nsim_create) from [<81561184>] (__nsim_dev_port_add+0x108/0x188 drivers/net/netdevsim/dev.c:941)
 [<8156107c>] (__nsim_dev_port_add) from [<815620d8>] (nsim_dev_port_add_all drivers/net/netdevsim/dev.c:990 [inline])
 [<8156107c>] (__nsim_dev_port_add) from [<815620d8>] (nsim_dev_probe+0x5cc/0x750 drivers/net/netdevsim/dev.c:1119)
 [<81561b0c>] (nsim_dev_probe) from [<815661dc>] (nsim_bus_probe+0x10/0x14 drivers/net/netdevsim/bus.c:287)
 [<815661cc>] (nsim_bus_probe) from [<811724c0>] (really_probe+0x100/0x50c drivers/base/dd.c:554)
 [<811723c0>] (really_probe) from [<811729c4>] (driver_probe_device+0xf8/0x1c8 drivers/base/dd.c:740)
 [<811728cc>] (driver_probe_device) from [<81172fe4>] (__device_attach_driver+0x8c/0xf0 drivers/base/dd.c:846)
 [<81172f58>] (__device_attach_driver) from [<8116fee0>] (bus_for_each_drv+0x88/0xd8 drivers/base/bus.c:431)
 [<8116fe58>] (bus_for_each_drv) from [<81172c6c>] (__device_attach+0xdc/0x1d0 drivers/base/dd.c:914)
 [<81172b90>] (__device_attach) from [<8117305c>] (device_initial_probe+0x14/0x18 drivers/base/dd.c:961)
 [<81173048>] (device_initial_probe) from [<81171358>] (bus_probe_device+0x90/0x98 drivers/base/bus.c:491)
 [<811712c8>] (bus_probe_device) from [<8116e77c>] (device_add+0x320/0x824 drivers/base/core.c:3109)
 [<8116e45c>] (device_add) from [<8116ec9c>] (device_register+0x1c/0x20 drivers/base/core.c:3182)
 [<8116ec80>] (device_register) from [<81566710>] (nsim_bus_dev_new drivers/net/netdevsim/bus.c:336 [inline])
 [<8116ec80>] (device_register) from [<81566710>] (new_device_store+0x178/0x208 drivers/net/netdevsim/bus.c:215)
 [<81566598>] (new_device_store) from [<8116fcb4>] (bus_attr_store+0x2c/0x38 drivers/base/bus.c:122)
 [<8116fc88>] (bus_attr_store) from [<805b4b8c>] (sysfs_kf_write+0x48/0x54 fs/sysfs/file.c:139)
 [<805b4b44>] (sysfs_kf_write) from [<805b3c90>] (kernfs_fop_write_iter+0x128/0x1ec fs/kernfs/file.c:296)
 [<805b3b68>] (kernfs_fop_write_iter) from [<804d22fc>] (call_write_iter include/linux/fs.h:1901 [inline])
 [<805b3b68>] (kernfs_fop_write_iter) from [<804d22fc>] (new_sync_write fs/read_write.c:518 [inline])
 [<805b3b68>] (kernfs_fop_write_iter) from [<804d22fc>] (vfs_write+0x3dc/0x57c fs/read_write.c:605)
 [<804d1f20>] (vfs_write) from [<804d2604>] (ksys_write+0x68/0xec fs/read_write.c:658)
 [<804d259c>] (ksys_write) from [<804d2698>] (__do_sys_write fs/read_write.c:670 [inline])
 [<804d259c>] (ksys_write) from [<804d2698>] (sys_write+0x10/0x14 fs/read_write.c:667)
 [<804d2688>] (sys_write) from [<80200060>] (ret_fast_syscall+0x0/0x2c arch/arm/mm/proc-v7.S:64)

Fixes: 83c9e13aa3 ("netdevsim: add software driver for testing offloads")
Reported-by: syzbot+e74a6857f2d0efe3ad81@syzkaller.appspotmail.com
Tested-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Hillf Danton <hdanton@sina.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2021-03-04 14:36:26 -08:00
Jakub Kicinski 30bfce1094 net: remove ndo_udp_tunnel_* callbacks
All UDP tunnel port management is now routed via udp_tunnel_nic
infra directly. Remove the old callbacks.

Reviewed-by: Alexander Duyck <alexanderduyck@fb.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2021-01-07 12:53:29 -08:00
Jakub Kicinski ff1f7c17fb netdevsim: add pause frame stats
Add minimal ethtool interface for testing ethtool pause stats.

v2: add missing static on nsim_ethtool_ops

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Saeed Mahameed <saeedm@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-09-15 13:26:28 -07:00
David S. Miller a57066b1a0 Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
The UDP reuseport conflict was a little bit tricky.

The net-next code, via bpf-next, extracted the reuseport handling
into a helper so that the BPF sk lookup code could invoke it.

At the same time, the logic for reuseport handling of unconnected
sockets changed via commit efc6b6f6c3
which changed the logic to carry on the reuseport result into the
rest of the lookup loop if we do not return immediately.

This requires moving the reuseport_has_conns() logic into the callers.

While we are here, get rid of inline directives as they do not belong
in foo.c files.

The other changes were cases of more straightforward overlapping
modifications.

Signed-off-by: David S. Miller <davem@davemloft.net>
2020-07-25 17:49:04 -07:00
Taehee Yoo 2c9d8e01f0 netdevsim: fix unbalaced locking in nsim_create()
In the nsim_create(), rtnl_lock() is called before nsim_bpf_init().
If nsim_bpf_init() is failed, rtnl_unlock() should be called,
but it isn't called.
So, unbalanced locking would occur.

Fixes: e05b2d141f ("netdevsim: move netdev creation/destruction to dev probe")
Signed-off-by: Taehee Yoo <ap420073@gmail.com>
Reviewed-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-07-21 16:00:43 -07:00
Jakub Kicinski 424be63ad8 netdevsim: add UDP tunnel port offload support
Add UDP tunnel port handlers to our fake driver so we can test
the core infra.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-07-10 13:54:00 -07:00
Jiri Pirko 90d299138d netdevsim: register port netdevices into net of device
Register newly created port netdevice into net namespace
that the parent device belongs to.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-10-04 11:10:56 -07:00
Jiri Pirko a5facc4cac netdevsim: change fib accounting and limitations to be per-device
Currently, the accounting is done per-namespace. However, devlink
instance is always in init_net namespace for now, so only the accounting
related to init_net is used. Limitations set using devlink resources
are only considered for init_net. nsim_devlink_net() always
returns init_net always.

Make the accounting per-device. This brings no functional change.
Per-device accounting has the same values as per-net.
For a single netdevsim instance, the behaviour is exactly the same
as before. When multiple netdevsim instances are created, each
can have different limits.

This is in prepare to implement proper devlink netns support. After
that, the devlink instance which would exist in particular netns would
account and limit that netns.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-10-04 11:10:55 -07:00
David Ahern 59c84b9fcf netdevsim: Restore per-network namespace accounting for fib entries
Prior to the commit in the fixes tag, the resource controller in netdevsim
tracked fib entries and rules per network namespace. Restore that behavior.

Fixes: 5fc494225c ("netdevsim: create devlink instance per netdevsim instance")
Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-08-11 20:59:19 -07:00
Pablo Neira Ayuso 955bcb6ea0 drivers: net: use flow block API
This patch updates flow_block_cb_setup_simple() to use the flow block API.
Several drivers are also adjusted to use it.

This patch introduces the per-driver list of flow blocks to account for
blocks that are already in use.

Remove tc_block_offload alias.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-07-09 14:38:50 -07:00
Pablo Neira Ayuso 4e95bc268b net: flow_offload: add flow_block_cb_setup_simple()
Most drivers do the same thing to set up the flow block callbacks, this
patch adds a helper function to do this.

This preparation patch reduces the number of changes to adapt the
existing drivers to use the flow block callback API.

This new helper function takes a flow block list per-driver, which is
set to NULL until this driver list is used.

This patch also introduces the flow_block_command and
flow_block_binder_type enumerations, which are renamed to use
FLOW_BLOCK_* in follow up patches.

There are three definitions (aliases) in order to reduce the number of
updates in this patch, which go away once drivers are fully adapted to
use this flow block API.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-07-09 14:38:50 -07:00
Jiri Pirko a62fdbbe94 netdevsim: implement ndo_get_devlink_port
Implement ndo_get_devlink_port and allow switch_id and port_name to be
handled by devlink.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-04-26 01:52:03 -04:00
Jiri Pirko e05b2d141f netdevsim: move netdev creation/destruction to dev probe
Remove the existing way to create netdevsim over rtnetlink and move the
netdev creation/destruction to dev probe, so for every probed port,
a netdevsim-netdev instance is created.

Adjust selftests to work with new interface.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-04-26 01:52:03 -04:00
Jiri Pirko 8320d14591 netdevsim: implement dev probe/remove skeleton with port initialization
Implement netdevsim bus probing of netdevsim devices. For every probed
device create a devlink instance. According to the user-passed value,
create a number of ports represented by devlink port instances.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-04-26 01:52:02 -04:00
Jiri Pirko ab1d0cc004 netdevsim: change debugfs tree topology
With the model where dev is represented by devlink and ports are
represented by devlink ports, make debugfs file names independent
on netdev names. Change the topology to the one illustrated
by the following example:

$ ls /sys/kernel/debug/netdevsim/
netdevsim1
$ ls /sys/kernel/debug/netdevsim/netdevsim1/
bpf_bind_accept  bpf_bind_verifier_delay  bpf_bound_progs  ports
$ ls /sys/kernel/debug/netdevsim/netdevsim1/ports/
0  1
$ ls /sys/kernel/debug/netdevsim/netdevsim1/ports/0/
bpf_map_accept  bpf_offloaded_id  bpf_tc_accept  bpf_tc_non_bound_accept  bpf_xdpdrv_accept  bpf_xdpoffload_accept  dev  ipsec
$ ls /sys/kernel/debug/netdevsim/netdevsim1/ports/0/dev -l
lrwxrwxrwx 1 root root 0 Apr 13 15:58 /sys/kernel/debug/netdevsim/netdevsim1/ports/0/dev -> ../../../netdevsim1

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-04-26 01:52:02 -04:00
Jiri Pirko 514cf64cc5 netdevsim: generate random switch id instead of using dev id
Current implementation of parent_id/switch_id does not follow the
original idea of being unique. The values are "0", "1", etc. Instead of
that, generate 32 random bytes.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-04-26 01:52:02 -04:00
Jiri Pirko d514f41e79 netdevsim: merge sdev into dev
As previously introduce dev which is mapped 1:1 to a bus device covers
the purpose of the original shared device, merge the sdev code into dev.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-04-26 01:52:02 -04:00
Jiri Pirko a60f9e48b7 netdevsim: rename dev_init/exit() functions and make them independent on ns
These functions are going to be called from bus probe/release(),
therefore make them independent on ns struct and rename accordingly.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-04-26 01:52:02 -04:00
Jiri Pirko f9d9db47d3 netdevsim: add bus attributes to add new and delete devices
Add a way to add new netdevsim device on netdevsim bus and also to
delete existing netdevsim device from the bus. Track the bus devices
in using a list.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-04-26 01:52:02 -04:00
Jiri Pirko 40e4fe4ce1 netdevsim: move device registration and related code to bus.c
Move netdevsim device registration into bus.c and alongside with that
the related sysfs attributes. Introduce new struct nsim_bus_dev to
represent a netdevsim device on netdevsim bus.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-04-26 01:52:02 -04:00
Jiri Pirko 925f5afedb netdevsim: put netdevsim bus code into separate file
As the code related to netdevsim bus is going to get bigger, move the
existing code to a separate file.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-04-26 01:52:02 -04:00
Jiri Pirko 8fb4bc6fd5 netdevsim: rename devlink.c to dev.c to contain per-dev(asic) items
The existing devlink.c code is going to be extended to represent asic
device on a bus. As this is about more than just devlink,
rename the file. Do appropriate prefix renaming alongside with that.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-04-26 01:52:02 -04:00
Jiri Pirko 5fc494225c netdevsim: create devlink instance per netdevsim instance
Currently there is one devlink instance created per network namespace.
That is quite odd considering the fact that devlink instance should
represent an ASIC. The following patches are going to move the devlink
instance even more down to a bus device, but until then, have one
devlink instance per netdevsim instance. Struct nsim_devlink is
introduced to hold fib setting.

The changes in the fib code are only related to holding the
configuration per devlink instance instead of network namespace.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-04-26 01:52:02 -04:00
Jiri Pirko 1daf36c0db netdevsim: move device registration on bus to be done earlier in init
As a dependency of the subsequent patch, mode device registration to be
done earlier, directly in nsim_newlink().

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-04-26 01:52:02 -04:00
Jiri Pirko af9095f00d netdevsim: move shared dev creation and destruction into separate file
To make code easier to read, move shared dev bits into a separate file.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-04-12 16:49:54 -07:00