Get rid of switchdev_ops
Subsystems (15)
cover Get rid of switchdev_ops
Hi all,
This patch series converts SWITCHDEV_PORT_ATTR_{GET,SET} to use a blocking notifier, similar to how SWITCHDEV_PORT_OBJ_{ADD,DEL} has been changed recently by Petr.
This was suggested by Ido to help with a particular use case I have where I want to be able to veto a switchdev bridge attribute from a driver (multicast_snooping).
Please review since I may not have gotten the driver abstraction right, especially for mlx5e and nfp since these are *hum* *hum* large drivers.
Florian Fainelli (13):
switchdev: Add SWITCHDEV_PORT_ATTR_SET, SWITCHDEV_PORT_ATTR_GET
rocker: Handle SWITCHDEV_PORT_ATTR_GET/SET
net: dsa: Handle SWITCHDEV_PORT_ATTR_GET/SET
mlxsw: spectrum_switchdev: Handle SWITCHDEV_PORT_ATTR_GET/SET
net: mscc: ocelot: Handle SWITCHDEV_PORT_ATTR_GET/SET
staging: fsl-dpaa2: ethsw: Handle SWITCHDEV_PORT_ATTR_GET/SET
bnxt: Handle SWITCHDEV_PORT_ATTR_GET event
liquidio: Handle SWITCHDEV_PORT_ATTR_GET event
mlxsw: switchx2: Handle SWITCHDEV_PORT_ATTR_GET event net/mlx5e: Handle SWITCHDEV_PORT_ATTR_GET event
nfp: Handle SWITCHDEV_PORT_ATTR_GET event
netdevsim: Handle SWITCHDEV_PORT_ATTR_GET event
net: switchdev: Replace port attr get/set SDO with a notification
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 63 ++++++++++- drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c | 9 +- drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.h | 8 ++ .../net/ethernet/cavium/liquidio/lio_main.c | 53 ++++++++- .../net/ethernet/cavium/liquidio/lio_vf_rep.c | 48 +++++++- .../net/ethernet/mellanox/mlx5/core/en_main.c | 4 +- .../net/ethernet/mellanox/mlx5/core/en_rep.c | 50 ++++++-- .../net/ethernet/mellanox/mlx5/core/en_rep.h | 2 +- .../net/ethernet/mellanox/mlxsw/spectrum.c | 12 -- .../net/ethernet/mellanox/mlxsw/spectrum.h | 2 - .../mellanox/mlxsw/spectrum_switchdev.c | 36 +++--- .../net/ethernet/mellanox/mlxsw/switchx2.c | 46 +++++++- drivers/net/ethernet/mscc/ocelot.c | 30 ++++- drivers/net/ethernet/netronome/nfp/nfp_main.c | 14 ++- drivers/net/ethernet/netronome/nfp/nfp_net.h | 3 + .../ethernet/netronome/nfp/nfp_net_common.c | 19 +++- .../net/ethernet/netronome/nfp/nfp_net_repr.c | 2 - drivers/net/ethernet/netronome/nfp/nfp_port.c | 17 ++- drivers/net/ethernet/netronome/nfp/nfp_port.h | 5 +- drivers/net/ethernet/rocker/rocker_main.c | 30 ++++- drivers/net/netdevsim/netdev.c | 46 +++++++- drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 30 ++++- include/linux/netdevice.h | 3 - include/net/switchdev.h | 28 ++--- net/dsa/slave.c | 30 ++++- net/switchdev/switchdev.c | 107 ++++++------------ 26 files changed, 503 insertions(+), 194 deletions(-)
Signature · 1 line
2.17.1
RFC 1/13 switchdev: Add SWITCHDEV_PORT_ATTR_SET, SWITCHDEV_PORT_ATTR_GET
In preparation for allowing switchdev enabled drivers to veto specific attribute settings from within the context of the caller, introduce a new switchdev notifier type for port attributes.
--- include/net/switchdev.h | 10 ++++++++++ 1 file changed, 10 insertions(+)
include/net/switchdev.h +10 -0
@@ -145,6 +145,9 @@ enum switchdev_notifier_type {SWITCHDEV_VXLAN_FDB_ADD_TO_DEVICE ,SWITCHDEV_VXLAN_FDB_DEL_TO_DEVICE ,SWITCHDEV_VXLAN_FDB_OFFLOADED , + +SWITCHDEV_PORT_ATTR_SET ,/* Blocking. */ + SWITCHDEV_PORT_ATTR_GET, /* Blocking. */ }; struct switchdev_notifier_info {
@@ -167,6 +170,13 @@ struct switchdev_notifier_port_obj_info {bool handled; }; +struct switchdev_notifier_port_attr_info { +struct switchdev_notifier_info info;/* must be first */ +struct switchdev_attr *attr; +struct switchdev_trans *trans; +bool handled; +}; +static inline struct net_device *switchdev_notifier_info_to_dev (const struct switchdev_notifier_info *info) {
Signature · 1 line
2.17.1
Jiri Pirko
maintainerRe: [RFC net-next 01/13] switchdev: Add SWITCHDEV_PORT_ATTR_SET, SWITCHDEV_PORT_ATTR_GET
Quoted 15 lines · Fri, Feb 01, 2019 at 11:06:45PM CET, [email protected] wrote:
In preparation for allowing switchdev enabled drivers to veto specific attribute settings from within the context of the caller, introduce a new switchdev notifier type for port attributes.
Suggested-by Ido Schimmel <[email protected]>Signed-off-by Florian Fainelli <[email protected]>---
include/net/switchdev.h| 10 ++++++++++1 file changed, 10 insertions(+)include/net/switchdev.h +0
-0
include/net/switchdev.h enum switchdev_notifier_type { · line 150
Quoted 6 lines
include/net/switchdev.h +3
-0@@ -145,6 +145,9 @@ enum switchdev_notifier_type {SWITCHDEV_VXLAN_FDB_ADD_TO_DEVICE ,SWITCHDEV_VXLAN_FDB_DEL_TO_DEVICE ,SWITCHDEV_VXLAN_FDB_OFFLOADED , + +SWITCHDEV_PORT_ATTR_SET ,/* Blocking. */ + SWITCHDEV_PORT_ATTR_GET, /* Blocking. */
Not an UAPI, so you can put this right next to PORT_OBJ_* if needed.
Quoted 20 lines
include/net/switchdev.h +7
-0};struct switchdev_notifier_info {@@ -167,6 +170,13 @@ struct switchdev_notifier_port_obj_info {bool handled; }; +struct switchdev_notifier_port_attr_info { +struct switchdev_notifier_info info;/* must be first */ +struct switchdev_attr *attr; +struct switchdev_trans *trans; +bool handled; +}; +static inline struct
net_device*switchdev_notifier_info_to_dev(const struct switchdev_notifier_info *info){Signature · 1 line
2.17.1
RFC 2/13 rocker: Handle SWITCHDEV_PORT_ATTR_GET/SET
In reply to Florian FainelliFollowing patches will change the way we communicate getting or setting a port's attribute and use a blocking notifier to perform those tasks.
Prepare rocker to support receiving notifier events targeting SWITCHDEV_PORT_ATTR_GET/SET and simply translate that into the existing rocker_port_attr_{set,get} calls.
--- drivers/net/ethernet/rocker/rocker_main.c | 24 +++++++++++++++++++++++ 1 file changed, 24 insertions(+)
drivers/net/ethernet/rocker/rocker_main.c +24 -0
@@ -2827,6 +2827,27 @@ rocker_switchdev_port_obj_event(unsigned long event, struct net_device *netdev,return notifier_from_errno (err); } +static int +rocker_switchdev_port_attr_event (unsigned long event,struct net_device *netdev, +struct switchdev_notifier_port_attr_info + *port_attr_info) +{ +int err = -EOPNOTSUPP ; + +switch (event) { +case SWITCHDEV_PORT_ATTR_SET : + err =rocker_port_attr_set (netdev, port_attr_info->attr, + port_attr_info->trans); +break ; +case SWITCHDEV_PORT_ATTR_GET : + err =rocker_port_attr_get (netdev, port_attr_info->attr); +break ; + } + + port_attr_info->handled = true; +return notifier_from_errno (err); +} +static int rocker_switchdev_blocking_event (struct notifier_block *unused,unsigned long event,void *ptr) {
@@ -2839,6 +2860,9 @@ static int rocker_switchdev_blocking_event(struct notifier_block *unused,case SWITCHDEV_PORT_OBJ_ADD :case SWITCHDEV_PORT_OBJ_DEL :return rocker_switchdev_port_obj_event (event, dev, ptr); +case SWITCHDEV_PORT_ATTR_SET : +case SWITCHDEV_PORT_ATTR_GET : +return rocker_switchdev_port_attr_event (event, dev, ptr); }return NOTIFY_DONE ;
Signature · 1 line
2.17.1
RFC 3/13 net: dsa: Handle SWITCHDEV_PORT_ATTR_GET/SET
In reply to Florian FainelliFollowing patches will change the way we communicate getting or setting a port's attribute and use a blocking notifier to perform those tasks.
Prepare DSA to support receiving notifier events targeting SWITCHDEV_PORT_ATTR_GET/SET and simply translate that into the existing dsa_slave_port_attr_{set,get} calls.
--- net/dsa/slave.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
net/dsa/slave.c +24 -0
@@ -1549,6 +1549,27 @@ dsa_slave_switchdev_port_obj_event(unsigned long event,return notifier_from_errno (err); } +static int +dsa_slave_switchdev_port_attr_event (unsigned long event, +struct net_device *netdev, +struct switchdev_notifier_port_attr_info *port_attr_info) +{ +int err = -EOPNOTSUPP ; + +switch (event) { +case SWITCHDEV_PORT_ATTR_SET : + err =dsa_slave_port_attr_set (netdev, port_attr_info->attr, + port_attr_info->trans); +break ; +case SWITCHDEV_PORT_ATTR_GET : + err =dsa_slave_port_attr_get (netdev, port_attr_info->attr); +break ; + } + + port_attr_info->handled = true; +return notifier_from_errno (err); +} +static int dsa_slave_switchdev_blocking_event (struct notifier_block *unused,unsigned long event,void *ptr) {
@@ -1561,6 +1582,9 @@ static int dsa_slave_switchdev_blocking_event(struct notifier_block *unused,case SWITCHDEV_PORT_OBJ_ADD :/* fall through */ case SWITCHDEV_PORT_OBJ_DEL :return dsa_slave_switchdev_port_obj_event (event, dev, ptr); +case SWITCHDEV_PORT_ATTR_SET :/* fallthrough */ +case SWITCHDEV_PORT_ATTR_GET : +return dsa_slave_switchdev_port_attr_event (event, dev, ptr); }return NOTIFY_DONE ;
Signature · 1 line
2.17.1
RFC 4/13 mlxsw: spectrum_switchdev: Handle SWITCHDEV_PORT_ATTR_GET/SET
In reply to Florian FainelliFollowing patches will change the way we communicate getting or setting a port's attribute and use a blocking notifier to perform those tasks.
Prepare mlxsw to support receiving notifier events targeting SWITCHDEV_PORT_ATTR_GET/SET and simply translate that into the existing mlxsw_sp_port_attr_{set,get} calls.
--- .../mellanox/mlxsw/spectrum_switchdev.c | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+)
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +23 -0
@@ -3442,6 +3442,26 @@ mlxsw_sp_switchdev_handle_vxlan_obj_del(struct net_device *vxlan_dev, } } +static int +mlxsw_sp_switchdev_port_attr_event (unsigned long event,struct net_device *dev, +struct switchdev_notifier_port_attr_info *port_attr_info) +{ +int err = -EOPNOTSUPP ; + +switch (event) { +case SWITCHDEV_PORT_ATTR_SET : + err =mlxsw_sp_port_attr_set (dev, port_attr_info->attr, + port_attr_info->trans); +break ; +case SWITCHDEV_PORT_ATTR_GET : + err =mlxsw_sp_port_attr_get (dev, port_attr_info->attr); +break ; + } + + port_attr_info->handled = true; +return notifier_from_errno (err); +} +static int mlxsw_sp_switchdev_blocking_event (struct notifier_block *unused,unsigned long event,void *ptr) {
@@ -3465,6 +3485,9 @@ static int mlxsw_sp_switchdev_blocking_event(struct notifier_block *unused, mlxsw_sp_port_dev_check, mlxsw_sp_port_obj_del);return notifier_from_errno (err); +case SWITCHDEV_PORT_ATTR_SET : +case SWITCHDEV_PORT_ATTR_GET : +return mlxsw_sp_switchdev_port_attr_event (event, dev, ptr); }return NOTIFY_DONE ;
Signature · 1 line
2.17.1
RFC 5/13 net: mscc: ocelot: Handle SWITCHDEV_PORT_ATTR_GET/SET
In reply to Florian FainelliFollowing patches will change the way we communicate getting or setting a port's attribute and use a blocking notifier to perform those tasks.
Prepare ocelot to support receiving notifier events targeting SWITCHDEV_PORT_ATTR_GET/SET and simply translate that into the existing ocelot_port_attr_{set,get} calls.
--- drivers/net/ethernet/mscc/ocelot.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
drivers/net/ethernet/mscc/ocelot.c +24 -0
@@ -1589,6 +1589,27 @@ struct notifier_block ocelot_netdevice_nb __read_mostly = { };EXPORT_SYMBOL (ocelot_netdevice_nb); +static int +ocelot_switchdev_port_attr_event (unsigned long event, +struct net_device *netdev, +struct switchdev_notifier_port_attr_info *port_attr_info) +{ +int err = -EOPNOTSUPP ; + +switch (event) { +case SWITCHDEV_PORT_ATTR_SET : + err =ocelot_port_attr_set (netdev, port_attr_info->attr, + port_attr_info->trans); +break ; +case SWITCHDEV_PORT_ATTR_GET : + err =ocelot_port_attr_get (netdev, port_attr_info->attr); +break ; + } + + port_attr_info->handled = true; +return notifier_from_errno (err); +} +static int ocelot_switchdev_blocking_event (struct notifier_block *unused,unsigned long event,void *ptr) {
@@ -1607,6 +1628,9 @@ static int ocelot_switchdev_blocking_event(struct notifier_block *unused, ocelot_netdevice_dev_check, ocelot_port_obj_del);return notifier_from_errno (err); +case SWITCHDEV_PORT_ATTR_SET : +case SWITCHDEV_PORT_ATTR_GET : +return ocelot_switchdev_port_attr_event (event, dev, ptr); }return NOTIFY_DONE ;
Signature · 1 line
2.17.1
RFC 6/13 staging: fsl-dpaa2: ethsw: Handle SWITCHDEV_PORT_ATTR_GET/SET
In reply to Florian FainelliFollowing patches will change the way we communicate getting or setting a port's attribute and use a blocking notifier to perform those tasks.
Prepare ethsw to support receiving notifier events targeting SWITCHDEV_PORT_ATTR_GET/SET and simply translate that into the existing swdev_port_attr_{set,get} calls.
--- drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
drivers/staging/fsl-dpaa2/ethsw/ethsw.c +24 -0
@@ -1103,6 +1103,27 @@ ethsw_switchdev_port_obj_event(unsigned long event, struct net_device *netdev,return notifier_from_errno (err); } +static int +ethsw_switchdev_port_attr_event (unsigned long event, +struct net_device *netdev, +struct switchdev_notifier_port_attr_info *port_attr_info) +{ +int err = -EOPNOTSUPP ; + +switch (event) { +case SWITCHDEV_PORT_ATTR_SET : + err =swdev_port_attr_set (netdev, port_attr_info->attr, + port_attr_info->trans); +break ; +case SWITCHDEV_PORT_ATTR_GET : + err =swdev_port_attr_get (netdev, port_attr_info->attr); +break ; + } + + port_attr_info->handled = true; +return notifier_from_errno (err); +} +static int port_switchdev_blocking_event (struct notifier_block *unused,unsigned long event,void *ptr) {
@@ -1115,6 +1136,9 @@ static int port_switchdev_blocking_event(struct notifier_block *unused,case SWITCHDEV_PORT_OBJ_ADD :/* fall through */ case SWITCHDEV_PORT_OBJ_DEL :return ethsw_switchdev_port_obj_event (event, dev, ptr); +case SWITCHDEV_PORT_ATTR_SET : +case SWITCHDEV_PORT_ATTR_GET : +return ethsw_switchdev_port_attr_event (event, dev, ptr); }return NOTIFY_DONE ;
Signature · 1 line
2.17.1
RFC 7/13 bnxt: Handle SWITCHDEV_PORT_ATTR_GET event
In reply to Florian FainelliFollowing patches will change the way we communicate getting or setting a port's attribute and use a blocking notifier to perform those tasks.
Prepare bnxt to support receiving notifier events targeting SWITCHDEV_PORT_ATTR_GET and simply translate that into the existing switchdev_ops::switchdev_port_attr_get operation.
We register a single blocking switchdev notifier for the entire driver instance and we differentiate a PF from a VF by comparing the network device's netdev_ops with the ones that this driver manages.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 58 ++++++++++++++++++- drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c | 4 +- drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.h | 8 +++ 3 files changed, 67 insertions(+), 3 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +57 -1
@@ -10045,6 +10045,45 @@ static const struct net_device_ops bnxt_netdev_ops = { .ndo_get_phys_port_name = bnxt_get_phys_port_name }; +static int bnxt_swdev_port_attr_event (unsigned long event, +struct net_device *dev, +struct switchdev_notifier_port_attr_info *port_attr_info) +{ +int rc; + +if (event !=SWITCHDEV_PORT_ATTR_GET ) +return NOTIFY_DONE ; + +if (bnxt_dev_is_vf_rep (dev)) + rc =bnxt_vf_rep_port_attr_get (dev, port_attr_info->attr); +else + rc =bnxt_port_attr_get (netdev_priv (dev), port_attr_info->attr); + + port_attr_info->handled = true; +return notifier_from_errno (rc); +} + +static int bnxt_switchdev_blocking_event (struct notifier_block *nb, +unsigned long event,void *ptr) +{ +struct net_device *dev =switchdev_notifier_info_to_dev (ptr); + +if (dev->netdev_ops != &bnxt_netdev_ops && + !bnxt_dev_is_vf_rep (dev)) +return NOTIFY_DONE ; + +switch (event) { +case SWITCHDEV_PORT_ATTR_GET : +return bnxt_swdev_port_attr_event (event, dev, ptr); + } + +return NOTIFY_DONE ; +} + +static struct notifier_block bnxt_swdev_blocking_nb = { + .notifier_call = bnxt_switchdev_blocking_event, +}; +static void bnxt_remove_one (struct pci_dev *pdev) {struct net_device *dev =pci_get_drvdata (pdev);
@@ -10817,8 +10856,24 @@ static struct pci_driver bnxt_pci_driver = {static int __init bnxt_init (void ) { +int rc; +bnxt_debug_init (); -return pci_register_driver (&bnxt_pci_driver); + rc =register_switchdev_blocking_notifier (&bnxt_swdev_blocking_nb); +if (rc) + goto err_debug; + + rc =pci_register_driver (&bnxt_pci_driver); +if (rc) + goto err_unreg_notifier; + +return rc; + +err_unreg_notifier: +unregister_switchdev_notifier (&bnxt_swdev_blocking_nb); +err_debug: +bnxt_debug_exit (); +return rc; } static void __exit bnxt_exit(void)
@@ -10826,6 +10881,7 @@ static void __exit bnxt_exit(void)pci_unregister_driver (&bnxt_pci_driver);if (bnxt_pf_wq)destroy_workqueue (bnxt_pf_wq); +unregister_switchdev_notifier (&bnxt_swdev_blocking_nb);bnxt_debug_exit (); }
drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c +2 -2
@@ -237,8 +237,8 @@ static void bnxt_vf_rep_get_drvinfo(struct net_device *dev,strlcpy (info->version,DRV_MODULE_VERSION ,sizeof (info->version)); } -static int bnxt_vf_rep_port_attr_get (struct net_device *dev, -struct switchdev_attr *attr) +int bnxt_vf_rep_port_attr_get (struct net_device *dev, +struct switchdev_attr *attr) {struct bnxt_vf_rep *vf_rep =netdev_priv (dev);
drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.h +8 -0
@@ -32,6 +32,8 @@ bool bnxt_dev_is_vf_rep(struct net_device *dev);int bnxt_dl_eswitch_mode_get (struct devlink *devlink,u16 *mode);int bnxt_dl_eswitch_mode_set (struct devlink *devlink,u16 mode,struct netlink_ext_ack *extack); +int bnxt_vf_rep_port_attr_get (struct net_device *dev, +struct switchdev_attr *attr);#else
@@ -61,5 +63,11 @@ static inline bool bnxt_dev_is_vf_rep(struct net_device *dev) {return false; } + +static inline int bnxt_vf_rep_port_attr_get (struct net_device *dev, +struct switchdev_attr *attr) +{ +return -EOPNOTSUPP ; +}#endif /* CONFIG_BNXT_SRIOV */ #endif /* BNXT_VFR_H */
Signature · 1 line
2.17.1
RFC 8/13 liquidio: Handle SWITCHDEV_PORT_ATTR_GET event
In reply to Florian FainelliFollowing patches will change the way we communicate getting or setting a port's attribute and use a blocking notifier to perform those tasks.
Prepare bnxt to support receiving notifier events targeting SWITCHDEV_PORT_ATTR_GET and simply translate that into the existing switchdev_ops::switchdev_port_attr_get operation.
We register a single blocking switchdev notifier for the PF part of the driver, and we register another blocking switchdev notifier, following what was done with the existing netdevice notifier within the VF representor driver.
--- .../net/ethernet/cavium/liquidio/lio_main.c | 48 ++++++++++++++++++- .../net/ethernet/cavium/liquidio/lio_vf_rep.c | 45 ++++++++++++++++- 2 files changed, 91 insertions(+), 2 deletions(-)
drivers/net/ethernet/cavium/liquidio/lio_main.c +47 -1
@@ -162,6 +162,8 @@ static int liquidio_set_vf_link_state(struct net_device *netdev, int vfidx,static struct handshake handshake[MAX_OCTEON_DEVICES ];static struct completion first_stage; +static int liquidio_switchdev_blocking_event (struct notifier_block *nb, +unsigned long event,void *ptr);static void octeon_droq_bh (unsigned long pdev) {
@@ -469,12 +471,25 @@ static struct pci_driver liquidio_pci_driver = {#endif }; +static struct notifier_block liquidio_blocking_nb = { + .notifier_call = liquidio_switchdev_blocking_event, +}; +/** * \brief register PCI driver */ static int liquidio_init_pci (void ) { -return pci_register_driver (&liquidio_pci_driver); +int rc; + + rc =register_switchdev_blocking_notifier (&liquidio_blocking_nb); +if (rc) +return rc; + rc =pci_register_driver (&liquidio_pci_driver); +if (rc) +unregister_switchdev_blocking_notifier (&liquidio_blocking_nb); + +return rc; }/**
@@ -483,6 +498,7 @@ static int liquidio_init_pci(void)static void liquidio_deinit_pci (void ) {pci_unregister_driver (&liquidio_pci_driver); +unregister_switchdev_blocking_notifier (&liquidio_blocking_nb); }/**
@@ -3261,6 +3277,36 @@ static const struct net_device_ops lionetdevops = { .ndo_get_vf_stats = liquidio_get_vf_stats, }; +static int lio_pf_attr_event (unsigned long event,struct net_device *dev, +struct switchdev_notifier_port_attr_info *port_attr_info) +{ +int rc; + +if (event !=SWITCHDEV_PORT_ATTR_GET ) +return NOTIFY_DONE ; + + rc =lio_pf_switchdev_attr_get (dev, port_attr_info->attr); + + port_attr_info->handled = true; +return notifier_from_errno (rc); +} + +static int liquidio_switchdev_blocking_event (struct notifier_block *nb, +unsigned long event,void *ptr) +{ +struct net_device *dev =switchdev_notifier_info_to_dev (ptr); + +if (dev->netdev_ops != &lionetdevops) +return NOTIFY_DONE ; + +switch (event) { +case SWITCHDEV_PORT_ATTR_GET : +return lio_pf_attr_event (event, dev, ptr); + } + +return NOTIFY_DONE ; +} +/** \brief Entry point for the liquidio module */ static int __init liquidio_init (void )
drivers/net/ethernet/cavium/liquidio/lio_vf_rep.c +44 -1
77 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [RFC net-next 08/13] liquidio: Handle SWITCHDEV_PORT_ATTR_GET event
Quoted 4 lines · Florian Fainelli
Following patches will change the way we communicate getting or setting a port's attribute and use a blocking notifier to perform those tasks.
Prepare bnxt to support receiving notifier events targeting
The code portion is fine (for 08/13), but the patch explanantion needs to be revised. "bnxt" should be replaced with "liquidio".
Thanks,
Felix
RFC 9/13 mlxsw: switchx2: Handle SWITCHDEV_PORT_ATTR_GET event
In reply to Florian FainelliFollowing patches will change the way we communicate getting or setting a port's attribute and use a blocking notifier to perform those tasks.
Prepare bnxt to support receiving notifier events targeting SWITCHDEV_PORT_ATTR_GET and simply translate that into the existing switchdev_ops::switchdev_port_attr_get operation.
We register a single blocking switchdev notifier for the entire driver instance and check that thet network device maps to the one that switchx2 manages.
--- .../net/ethernet/mellanox/mlxsw/switchx2.c | 43 ++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlxsw/switchx2.c +42 -1
@@ -923,6 +923,36 @@ static const struct switchdev_ops mlxsw_sx_port_switchdev_ops = { .switchdev_port_attr_get = mlxsw_sx_port_attr_get, }; +static int mlxsw_sx_port_attr_event (unsigned long event, +struct net_device *dev, +struct switchdev_notifier_port_attr_info *port_attr_info) +{ +int rc; + +if (event !=SWITCHDEV_PORT_ATTR_GET ) +return NOTIFY_DONE ; + + rc =mlxsw_sx_port_attr_get (dev, port_attr_info->attr); + port_attr_info->handled = true; +return notifier_from_errno (rc); +} + +static int mlxsw_sx_swdev_blocking_event (struct notifier_block *nb, +unsigned long event,void *ptr) +{ +struct net_device *dev =switchdev_notifier_info_to_dev (ptr); + +if (dev->netdev_ops != &mlxsw_sx_port_netdev_ops) +return NOTIFY_DONE ; + +switch (event) { +case SWITCHDEV_PORT_ATTR_GET : +return mlxsw_sx_port_attr_event (event, dev, ptr); + } + +return NOTIFY_DONE ; +} +static int mlxsw_sx_hw_id_get (struct mlxsw_sx *mlxsw_sx) {char spad_pl[MLXSW_REG_SPAD_LEN ] = {0 };
@@ -1638,6 +1668,10 @@ static void mlxsw_sx_fini(struct mlxsw_core *mlxsw_core)mlxsw_sx_ports_remove (mlxsw_sx); } +static struct notifier_block mlxsw_sx_swdev_nb = { + .notifier_call = mlxsw_sx_swdev_blocking_event, +}; +static const struct mlxsw_config_profile mlxsw_sx_config_profile = { .used_max_vepa_channels =1 , .max_vepa_channels =0 ,
@@ -1698,10 +1732,14 @@ static int __init mlxsw_sx_module_init(void) {int err; - err =mlxsw_core_driver_register (&mlxsw_sx_driver); + err =register_switchdev_blocking_notifier (&mlxsw_sx_swdev_nb);if (err)return err; + err =mlxsw_core_driver_register (&mlxsw_sx_driver); +if (err) + goto err_unregister_notifier; + err =mlxsw_pci_driver_register (&mlxsw_sx_pci_driver);if (err) goto err_pci_driver_register;
@@ -1710,6 +1748,8 @@ static int __init mlxsw_sx_module_init(void) err_pci_driver_register:mlxsw_core_driver_unregister (&mlxsw_sx_driver); +err_unregister_notifier: +unregister_switchdev_blocking_notifier (&mlxsw_sx_swdev_nb);return err; }
@@ -1717,6 +1757,7 @@ static void __exit mlxsw_sx_module_exit(void) {mlxsw_pci_driver_unregister (&mlxsw_sx_pci_driver);mlxsw_core_driver_unregister (&mlxsw_sx_driver); +unregister_switchdev_blocking_notifier (&mlxsw_sx_swdev_nb); }module_init (mlxsw_sx_module_init);
Signature · 1 line
2.17.1
RFC 10/13 net/mlx5e: Handle SWITCHDEV_PORT_ATTR_GET event
In reply to Florian FainelliFollowing patches will change the way we communicate getting or setting a port's attribute and use a blocking notifier to perform those tasks.
Prepare mlx5e/en_rep.c to support receiving notifier events targeting SWITCHDEV_PORT_ATTR_GET and simply translate that into the existing switchdev_ops::switchdev_port_attr_get operation.
We register a single blocking switchdev notifier for the entire set of representors given that mlx5e_rep_register_vport_reps() gets called for an Ethernet device.
--- .../net/ethernet/mellanox/mlx5/core/en_main.c | 4 +- .../net/ethernet/mellanox/mlx5/core/en_rep.c | 45 ++++++++++++++++++- .../net/ethernet/mellanox/mlx5/core/en_rep.h | 2 +- 3 files changed, 48 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +3 -1
@@ -5036,7 +5036,9 @@ static void *mlx5e_add(struct mlx5_core_dev *mdev)#ifdef CONFIG_MLX5_ESWITCH if (MLX5_ESWITCH_MANAGER (mdev) &&mlx5_eswitch_mode (mdev->priv.eswitch) ==SRIOV_OFFLOADS ) { -mlx5e_rep_register_vport_reps (mdev); + err =mlx5e_rep_register_vport_reps (mdev); +if (err) +return NULL ;return mdev; }#endif
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +44 -1
77 lines not on this page · raw message
drivers/net/ethernet/mellanox/mlx5/core/en_rep.h +1 -1
@@ -162,7 +162,7 @@ struct mlx5e_rep_sq { };void *mlx5e_alloc_nic_rep_priv (struct mlx5_core_dev *mdev); -void mlx5e_rep_register_vport_reps (struct mlx5_core_dev *mdev); +int mlx5e_rep_register_vport_reps (struct mlx5_core_dev *mdev);void mlx5e_rep_unregister_vport_reps (struct mlx5_core_dev *mdev);bool mlx5e_is_uplink_rep (struct mlx5e_priv *priv);int mlx5e_add_sqs_fwd_rules (struct mlx5e_priv *priv);
Signature · 1 line
2.17.1
RFC 11/13 nfp: Handle SWITCHDEV_PORT_ATTR_GET event
In reply to Florian FainelliFollowing patches will change the way we communicate getting or setting a port's attribute and use a blocking notifier to perform those tasks.
Prepare nfp to support receiving notifier events targeting SWITCHDEV_PORT_ATTR_GET and simply translate that into the existing switchdev_ops::switchdev_port_attr_get operation.
We register a single blocking switchdev notifier for the entire driver instance and we differentiate a "net" from a "repr" by comparing the network device's netdev_ops with the ones that this driver manages.
--- drivers/net/ethernet/netronome/nfp/nfp_main.c | 14 +++++++++++++- drivers/net/ethernet/netronome/nfp/nfp_net.h | 3 +++ .../net/ethernet/netronome/nfp/nfp_net_common.c | 17 +++++++++++++++++ drivers/net/ethernet/netronome/nfp/nfp_port.c | 15 +++++++++++++++ drivers/net/ethernet/netronome/nfp/nfp_port.h | 5 ++++- 5 files changed, 52 insertions(+), 2 deletions(-)
drivers/net/ethernet/netronome/nfp/nfp_main.c +13 -1
@@ -17,6 +17,7 @@#include <linux/vermagic.h> #include <linux/vmalloc.h> #include <net/devlink.h> +#include <net/switchdev.h> #include "nfpcore/nfp.h" #include "nfpcore/nfp_cpp.h"
@@ -708,6 +709,10 @@ static void nfp_pci_remove(struct pci_dev *pdev)pci_disable_device (pdev); } +static struct notifier_block nfp_swdev_blocking_nb = { + .notifier_call = nfp_switchdev_blocking_event, +}; +static struct pci_driver nfp_pci_driver = { .name = nfp_driver_name, .id_table = nfp_pci_device_ids,
@@ -725,9 +730,13 @@ static int __init nfp_main_init(void)nfp_net_debugfs_create (); + err =register_switchdev_blocking_notifier (&nfp_swdev_blocking_nb); +if (err) + goto err_destroy_debugfs; + err =pci_register_driver (&nfp_pci_driver);if (err <0 ) - goto err_destroy_debugfs; + goto err_unreg_notifier; err =pci_register_driver (&nfp_netvf_pci_driver);if (err)
@@ -737,6 +746,8 @@ static int __init nfp_main_init(void) err_unreg_pf:pci_unregister_driver (&nfp_pci_driver); +err_unreg_notifier: +unregister_switchdev_blocking_notifier (&nfp_swdev_blocking_nb); err_destroy_debugfs:nfp_net_debugfs_destroy ();return err;
@@ -746,6 +757,7 @@ static void __exit nfp_main_exit(void) {pci_unregister_driver (&nfp_netvf_pci_driver);pci_unregister_driver (&nfp_pci_driver); +unregister_switchdev_blocking_notifier (&nfp_swdev_blocking_nb);nfp_net_debugfs_destroy (); }
drivers/net/ethernet/netronome/nfp/nfp_net.h +3 -0
@@ -915,4 +915,7 @@ static inline void nfp_net_debugfs_dir_clean(struct dentry **dir) }#endif /* CONFIG_NFP_DEBUG */ +int nfp_switchdev_blocking_event (struct notifier_block *nb, +unsigned long event,void *ptr); +#endif /* _NFP_NET_H_ */
drivers/net/ethernet/netronome/nfp/nfp_net_common.c +17 -0
@@ -3955,3 +3955,20 @@ void nfp_net_clean(struct nfp_net *nn)unregister_netdev (nn->dp.netdev);nfp_net_reconfig_wait_posted (nn); } + +int nfp_switchdev_blocking_event (struct notifier_block *nb, +unsigned long event,void *ptr) +{ +struct net_device *dev =switchdev_notifier_info_to_dev (ptr); + +if (!nfp_netdev_is_nfp_repr (dev) && + !nfp_netdev_is_nfp_net (dev)) +return NOTIFY_DONE ; + +switch (event) { +case SWITCHDEV_PORT_ATTR_GET : +return nfp_port_switchdev_attr_event (event, dev, ptr); + } + +return NOTIFY_DONE ; +}
drivers/net/ethernet/netronome/nfp/nfp_port.c +15 -0
@@ -59,6 +59,21 @@ const struct switchdev_ops nfp_port_switchdev_ops = { .switchdev_port_attr_get = nfp_port_attr_get, }; +int nfp_port_switchdev_attr_event (unsigned long event, +struct net_device *netdev, +struct switchdev_notifier_port_attr_info *port_attr_info) +{ +int rc; + +if (event !=SWITCHDEV_PORT_ATTR_GET ) +return NOTIFY_DONE ; + + rc =nfp_port_attr_get (netdev, port_attr_info->attr); + port_attr_info->handled = true; + +return notifier_from_errno (rc); +} +int nfp_port_setup_tc (struct net_device *netdev,enum tc_setup_type type,void *type_data) {
drivers/net/ethernet/netronome/nfp/nfp_port.h +4 -1
@@ -10,6 +10,7 @@ struct net_device;struct nfp_app ;struct nfp_pf ;struct nfp_port ; +struct switchdev_notifier_port_attr_info ;/** * enum nfp_port_type - type of port NFP can switch traffic to
@@ -90,7 +91,9 @@ struct nfp_port { };extern const struct ethtool_ops nfp_port_ethtool_ops; -extern const struct switchdev_ops nfp_port_switchdev_ops; + +int nfp_port_switchdev_attr_event (unsigned long event,struct net_device *dev, +struct switchdev_notifier_port_attr_info *port_attr_info); __printf(2, 3) u8 *nfp_pr_et(u8 *data, const char *fmt, ...);
Signature · 1 line
2.17.1
Re: [RFC net-next 11/13] nfp: Handle SWITCHDEV_PORT_ATTR_GET event
Quoted 7 lines · Florian Fainelli
Following patches will change the way we communicate getting or setting a port's attribute and use a blocking notifier to perform those tasks.
Prepare nfp to support receiving notifier events targeting
SWITCHDEV_PORT_ATTR_GETand simply translate that into the existingswitchdev_ops::switchdev_port_attr_getoperation.
Quoted 5 lines
We register a single blocking switchdev notifier for the entire driver instance and we differentiate a "net" from a "repr" by comparing the network device's
netdev_opswith the ones that this driver manages.Signed-off-by Florian Fainelli <[email protected]>
Thanks Florian, the code looks good, only nit I have is - could you move nfp_switchdev_blocking_event() to nfp_port.c and nfp_port.h? We shouldn't touch nfp_net_common.c here.
In general calling a notifier to get the parent_id (which is the only thing all these SR-IOV NIC drivers implement) seems a tad heavy. It's an immutable, read-only attribute of a port, perhaps we can break it out? Could we make it an NDO, perhaps?
That's just my knee jerk reaction, given that NIC drivers don't implement any of the bridging side of switchdev I may not have a full appreciation of the abstraction you are building here :)
Re: [RFC net-next 11/13] nfp: Handle SWITCHDEV_PORT_ATTR_GET event
Le 2/1/19 à 7:45 PM, Jakub Kicinski a écrit :
Quoted 12 lines · Florian Fainelli
Quoted 11 lines
Following patches will change the way we communicate getting or setting a port's attribute and use a blocking notifier to perform those tasks.
Prepare nfp to support receiving notifier events targeting
SWITCHDEV_PORT_ATTR_GETand simply translate that into the existingswitchdev_ops::switchdev_port_attr_getoperation.We register a single blocking switchdev notifier for the entire driver instance and we differentiate a "net" from a "repr" by comparing the network device's
netdev_opswith the ones that this driver manages.
Quoted 5 lines
Quoted 1 line
Signed-off-by Florian Fainelli <[email protected]>Thanks Florian, the code looks good, only nit I have is - could you move
nfp_switchdev_blocking_event()tonfp_port.candnfp_port.h? We shouldn't touchnfp_net_common.chere.
Sounds good, thanks for the suggestion.
Quoted 5 lines
In general calling a notifier to get the
parent_id(which is the only thing all these SR-IOV NIC drivers implement) seems a tad heavy. It's an immutable, read-only attribute of a port, perhaps we can break it out? Could we make it an NDO, perhaps?
A NDO would be fine with me, Ido, what do you think?
Quoted 5 lines
That's just my knee jerk reaction, given that NIC drivers don't implement any of the bridging side of switchdev I may not have a full appreciation of the abstraction you are building here :)
Ido convinced me to convert the switchdev_port_attr_set() into a blocking notifier such that we could veto operations in switch drivers, once you do that, leaving the getter as switchdev_ops became pointless :) but yes, it's a lot of code just to get there.
Signature · 5 lines
Florian _______________________________________________ devel mailing list [email protected] http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
RFC 12/13 netdevsim: Handle SWITCHDEV_PORT_ATTR_GET event
In reply to Florian FainelliFollowing patches will change the way we communicate getting or setting a port's attribute and use a blocking notifier to perform those tasks.
Prepare netdevsim to support receiving notifier events targeting SWITCHDEV_PORT_ATTR_GET and simply translate that into the existing switchdev_ops::switchdev_port_attr_get operation.
We register a single blocking switchdev notifier for the entire driver instance.
--- drivers/net/netdevsim/netdev.c | 43 +++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-)
drivers/net/netdevsim/netdev.c +42 -1
@@ -168,6 +168,20 @@ static const struct switchdev_ops nsim_switchdev_ops = { .switchdev_port_attr_get = nsim_port_attr_get, }; +static int nsim_switchdev_port_attr_event (unsigned long event, +struct net_device *dev, +struct switchdev_notifier_port_attr_info *port_attr_info) +{ +int rc; + +if (event !=SWITCHDEV_PORT_ATTR_GET ) +return NOTIFY_DONE ; + + rc =nsim_port_attr_get (dev, port_attr_info->attr); + port_attr_info->handled = true; +return notifier_from_errno (rc); +} +static int nsim_init (struct net_device *dev) {char sdev_ddir_name[10 ], sdev_link_name[32 ];
@@ -495,6 +509,26 @@ static const struct net_device_ops nsim_netdev_ops = { .ndo_bpf = nsim_bpf, }; +static int nsim_swdev_blocking_event (struct notifier_block *nb, +unsigned long event,void *ptr) +{ +struct net_device *dev =switchdev_notifier_info_to_dev (ptr); + +if (dev->netdev_ops != &nsim_netdev_ops) +return NOTIFY_DONE ; + +switch (event) { +case SWITCHDEV_PORT_ATTR_GET : +return nsim_switchdev_port_attr_event (event, dev, ptr); + } + +return NOTIFY_DONE ; +} + +static struct notifier_block nsim_swdev_blocking_nb = { + .notifier_call = nsim_swdev_blocking_event, +}; +static void nsim_setup (struct net_device *dev) {ether_setup (dev);
@@ -583,10 +617,14 @@ static int __init nsim_module_init(void) goto err_debugfs_destroy; } - err =bus_register (&nsim_bus); + err =register_switchdev_blocking_notifier (&nsim_swdev_blocking_nb);if (err) goto err_sdir_destroy; + err =bus_register (&nsim_bus); +if (err) + goto err_unreg_notifier; + err =nsim_devlink_init ();if (err) goto err_unreg_bus;
@@ -601,6 +639,8 @@ static int __init nsim_module_init(void)nsim_devlink_exit (); err_unreg_bus:bus_unregister (&nsim_bus); +err_unreg_notifier: +unregister_switchdev_blocking_notifier (&nsim_swdev_blocking_nb); err_sdir_destroy:debugfs_remove_recursive (nsim_sdev_ddir); err_debugfs_destroy:
@@ -613,6 +653,7 @@ static void __exit nsim_module_exit(void)rtnl_link_unregister (&nsim_link_ops);nsim_devlink_exit ();bus_unregister (&nsim_bus); +unregister_switchdev_blocking_notifier (&nsim_swdev_blocking_nb);debugfs_remove_recursive (nsim_sdev_ddir);debugfs_remove_recursive (nsim_ddir); }
Signature · 1 line
2.17.1
RFC 13/13 net: switchdev: Replace port attr get/set SDO with a notification
In reply to Florian FainelliDrop switchdev_ops.switchdev_port_attr_get and _set. Drop the uses of this field from all clients, which were migrated to use switchdev notification in the previous patches.
Add a new function switchdev_port_attr_notify() that sends the switchdev notifications SWITCHDEV_PORT_ATTR_GET and _SET.
Update switchdev_port_attr_get() to dispatch to this new function. Drop __switchdev_port_attr_set() and update switchdev_port_attr_set() likewise.
--- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 5 - drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c | 5 - .../net/ethernet/cavium/liquidio/lio_main.c | 5 - .../net/ethernet/cavium/liquidio/lio_vf_rep.c | 5 - .../net/ethernet/mellanox/mlx5/core/en_rep.c | 7 -- .../net/ethernet/mellanox/mlxsw/spectrum.c | 12 -- .../net/ethernet/mellanox/mlxsw/spectrum.h | 2 - .../mellanox/mlxsw/spectrum_switchdev.c | 13 --- .../net/ethernet/mellanox/mlxsw/switchx2.c | 5 - drivers/net/ethernet/mscc/ocelot.c | 6 - .../ethernet/netronome/nfp/nfp_net_common.c | 2 - .../net/ethernet/netronome/nfp/nfp_net_repr.c | 2 - drivers/net/ethernet/netronome/nfp/nfp_port.c | 4 - drivers/net/ethernet/rocker/rocker_main.c | 6 - drivers/net/netdevsim/netdev.c | 5 - drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 6 - include/linux/netdevice.h | 3 - include/net/switchdev.h | 18 --- net/dsa/slave.c | 6 - net/switchdev/switchdev.c | 107 ++++++------------ 20 files changed, 37 insertions(+), 187 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt.c +0 -5
@@ -10007,10 +10007,6 @@ static int bnxt_swdev_port_attr_get(struct net_device *dev,return bnxt_port_attr_get (netdev_priv (dev), attr); } -static const struct switchdev_ops bnxt_switchdev_ops = { - .switchdev_port_attr_get = bnxt_swdev_port_attr_get -}; -static const struct net_device_ops bnxt_netdev_ops = { .ndo_open = bnxt_open, .ndo_start_xmit = bnxt_start_xmit,
@@ -10439,7 +10435,6 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) dev->netdev_ops = &bnxt_netdev_ops; dev->watchdog_timeo =BNXT_TX_TIMEOUT ; dev->ethtool_ops = &bnxt_ethtool_ops; -SWITCHDEV_SET_OPS (dev, &bnxt_switchdev_ops);pci_set_drvdata (pdev, dev); rc =bnxt_alloc_hwrm_resources (bp);
drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c +0 -5
@@ -248,10 +248,6 @@ int bnxt_vf_rep_port_attr_get(struct net_device *dev,return bnxt_port_attr_get (vf_rep->bp, attr); } -static const struct switchdev_ops bnxt_vf_rep_switchdev_ops = { - .switchdev_port_attr_get = bnxt_vf_rep_port_attr_get -}; -static const struct ethtool_ops bnxt_vf_rep_ethtool_ops = { .get_drvinfo = bnxt_vf_rep_get_drvinfo };
@@ -392,7 +388,6 @@ static void bnxt_vf_rep_netdev_init(struct bnxt *bp, struct bnxt_vf_rep *vf_rep, dev->netdev_ops = &bnxt_vf_rep_netdev_ops; dev->ethtool_ops = &bnxt_vf_rep_ethtool_ops; -SWITCHDEV_SET_OPS (dev, &bnxt_vf_rep_switchdev_ops);/* Just inherit all the featues of the parent PF as the VF-R * uses the RX/TX rings of the parent PF */
drivers/net/ethernet/cavium/liquidio/lio_main.c +0 -5
@@ -3222,10 +3222,6 @@ lio_pf_switchdev_attr_get(struct net_device *dev, struct switchdev_attr *attr)return 0 ; } -static const struct switchdev_ops lio_pf_switchdev_ops = { - .switchdev_port_attr_get = lio_pf_switchdev_attr_get, -}; -static int liquidio_get_vf_stats (struct net_device *netdev,int vfidx,struct ifla_vf_stats *vf_stats) {
@@ -3580,7 +3576,6 @@ static int setup_nic_devices(struct octeon_device *octeon_dev)* netdev tasks. */ netdev->netdev_ops = &lionetdevops; -SWITCHDEV_SET_OPS (netdev, &lio_pf_switchdev_ops); retval =netif_set_real_num_rx_queues (netdev, num_oqueues);if (retval) {
drivers/net/ethernet/cavium/liquidio/lio_vf_rep.c +0 -5
@@ -464,10 +464,6 @@ lio_vf_rep_attr_get(struct net_device *dev, struct switchdev_attr *attr)return 0 ; } -static const struct switchdev_ops lio_vf_rep_switchdev_ops = { - .switchdev_port_attr_get = lio_vf_rep_attr_get, -}; -static int lio_vf_rep_swdev_port_attr_event (unsigned long event,struct net_device *dev,struct switchdev_notifier_port_attr_info *port_attr_info)
@@ -539,7 +535,6 @@ lio_vf_rep_create(struct octeon_device *oct) ndev->min_mtu =LIO_MIN_MTU_SIZE ; ndev->max_mtu =LIO_MAX_MTU_SIZE ; ndev->netdev_ops = &lio_vf_rep_ndev_ops; -SWITCHDEV_SET_OPS (ndev, &lio_vf_rep_switchdev_ops); vf_rep =netdev_priv (ndev);memset (vf_rep,0 ,sizeof (*vf_rep));
drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +0 -7
@@ -1285,10 +1285,6 @@ static int mlx5e_uplink_rep_set_mac(struct net_device *netdev, void *addr)return 0 ; } -static const struct switchdev_ops mlx5e_rep_switchdev_ops = { - .switchdev_port_attr_get = mlx5e_attr_get, -}; -static int mlx5e_rep_swdev_port_attr_event (unsigned long event,struct net_device *dev,struct switchdev_notifier_port_attr_info *port_attr_info)
@@ -1423,9 +1419,6 @@ static void mlx5e_build_rep_netdev(struct net_device *netdev) netdev->watchdog_timeo =15 *HZ ; - - netdev->switchdev_ops = &mlx5e_rep_switchdev_ops; - netdev->features |=NETIF_F_HW_TC |NETIF_F_NETNS_LOCAL ; netdev->hw_features |=NETIF_F_HW_TC ;
drivers/net/ethernet/mellanox/mlxsw/spectrum.c +0 -12
@@ -3207,7 +3207,6 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port, } mlxsw_sp_port->default_vlan = mlxsw_sp_port_vlan; -mlxsw_sp_port_switchdev_init (mlxsw_sp_port); mlxsw_sp->ports[local_port] = mlxsw_sp_port; err =register_netdev (dev);if (err) {
@@ -3224,7 +3223,6 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port, err_register_netdev: mlxsw_sp->ports[local_port] =NULL ; -mlxsw_sp_port_switchdev_fini (mlxsw_sp_port);mlxsw_sp_port_vlan_destroy (mlxsw_sp_port_vlan); err_port_vlan_create: err_port_pvid_set:
@@ -3267,7 +3265,6 @@ static void mlxsw_sp_port_remove(struct mlxsw_sp *mlxsw_sp, u8 local_port)mlxsw_core_port_clear (mlxsw_sp->core, local_port, mlxsw_sp);unregister_netdev (mlxsw_sp_port->dev);/* This calls ndo_stop */ mlxsw_sp->ports[local_port] =NULL ; -mlxsw_sp_port_switchdev_fini (mlxsw_sp_port);mlxsw_sp_port_vlan_flush (mlxsw_sp_port, true);mlxsw_sp_port_nve_fini (mlxsw_sp_port);mlxsw_sp_tc_qdisc_fini (mlxsw_sp_port);
@@ -3988,12 +3985,6 @@ static int mlxsw_sp_init(struct mlxsw_core *mlxsw_core, goto err_span_init; } - err =mlxsw_sp_switchdev_init (mlxsw_sp); -if (err) { -dev_err (mlxsw_sp->bus_info->dev,"Failed to initialize switchdev\n" ); - goto err_switchdev_init; - } - err =mlxsw_sp_counter_pool_init (mlxsw_sp);if (err) {dev_err (mlxsw_sp->bus_info->dev,"Failed to init counter pool\n" );
@@ -4064,8 +4055,6 @@ static int mlxsw_sp_init(struct mlxsw_core *mlxsw_core, err_afa_init:mlxsw_sp_counter_pool_fini (mlxsw_sp); err_counter_pool_init: -mlxsw_sp_switchdev_fini (mlxsw_sp); -err_switchdev_init:mlxsw_sp_span_fini (mlxsw_sp); err_span_init:mlxsw_sp_lag_fini (mlxsw_sp);
@@ -4128,7 +4117,6 @@ static void mlxsw_sp_fini(struct mlxsw_core *mlxsw_core)mlxsw_sp_nve_fini (mlxsw_sp);mlxsw_sp_afa_fini (mlxsw_sp);mlxsw_sp_counter_pool_fini (mlxsw_sp); -mlxsw_sp_switchdev_fini (mlxsw_sp);mlxsw_sp_span_fini (mlxsw_sp);mlxsw_sp_lag_fini (mlxsw_sp);mlxsw_sp_buffers_fini (mlxsw_sp);
drivers/net/ethernet/mellanox/mlxsw/spectrum.h +0 -2
@@ -375,8 +375,6 @@ u32 mlxsw_sp_bytes_cells(const struct mlxsw_sp *mlxsw_sp, u32 bytes);/* spectrum_switchdev.c */ int mlxsw_sp_switchdev_init (struct mlxsw_sp *mlxsw_sp);void mlxsw_sp_switchdev_fini (struct mlxsw_sp *mlxsw_sp); -void mlxsw_sp_port_switchdev_init (struct mlxsw_sp_port *mlxsw_sp_port); -void mlxsw_sp_port_switchdev_fini (struct mlxsw_sp_port *mlxsw_sp_port);int mlxsw_sp_rif_fdb_op (struct mlxsw_sp *mlxsw_sp,const char *mac,u16 fid,bool adding);void
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c +0 -13
@@ -1962,11 +1962,6 @@ static struct mlxsw_sp_port *mlxsw_sp_lag_rep_port(struct mlxsw_sp *mlxsw_sp,return NULL ; } -static const struct switchdev_ops mlxsw_sp_port_switchdev_ops = { - .switchdev_port_attr_get = mlxsw_sp_port_attr_get, - .switchdev_port_attr_set = mlxsw_sp_port_attr_set, -}; - static int mlxsw_sp_bridge_8021q_port_join(struct mlxsw_sp_bridge_device *bridge_device, struct mlxsw_sp_bridge_port *bridge_port,
@@ -3575,11 +3570,3 @@ void mlxsw_sp_switchdev_fini(struct mlxsw_sp *mlxsw_sp)kfree (mlxsw_sp->bridge); } -void mlxsw_sp_port_switchdev_init (struct mlxsw_sp_port *mlxsw_sp_port) -{ - mlxsw_sp_port->dev->switchdev_ops = &mlxsw_sp_port_switchdev_ops; -} - -void mlxsw_sp_port_switchdev_fini (struct mlxsw_sp_port *mlxsw_sp_port) -{ -}
drivers/net/ethernet/mellanox/mlxsw/switchx2.c +0 -5
@@ -919,10 +919,6 @@ static int mlxsw_sx_port_attr_get(struct net_device *dev,return 0 ; } -static const struct switchdev_ops mlxsw_sx_port_switchdev_ops = { - .switchdev_port_attr_get = mlxsw_sx_port_attr_get, -}; -static int mlxsw_sx_port_attr_event (unsigned long event,struct net_device *dev,struct switchdev_notifier_port_attr_info *port_attr_info)
@@ -1064,7 +1060,6 @@ static int __mlxsw_sx_port_eth_create(struct mlxsw_sx *mlxsw_sx, u8 local_port, dev->netdev_ops = &mlxsw_sx_port_netdev_ops; dev->ethtool_ops = &mlxsw_sx_port_ethtool_ops; - dev->switchdev_ops = &mlxsw_sx_port_switchdev_ops; err =mlxsw_sx_port_dev_addr_get (mlxsw_sx_port);if (err) {
drivers/net/ethernet/mscc/ocelot.c +0 -6
@@ -1330,11 +1330,6 @@ static int ocelot_port_obj_del(struct net_device *dev,return ret; } -static const struct switchdev_ops ocelot_port_switchdev_ops = { - .switchdev_port_attr_get = ocelot_port_attr_get, - .switchdev_port_attr_set = ocelot_port_attr_set, -}; -static int ocelot_port_bridge_join (struct ocelot_port *ocelot_port,struct net_device *bridge) {
@@ -1664,7 +1659,6 @@ int ocelot_probe_port(struct ocelot *ocelot, u8 port, dev->netdev_ops = &ocelot_port_netdev_ops; dev->ethtool_ops = &ocelot_ethtool_ops; - dev->switchdev_ops = &ocelot_port_switchdev_ops; dev->hw_features |=NETIF_F_HW_VLAN_CTAG_FILTER |NETIF_F_RXFCS ; dev->features |=NETIF_F_HW_VLAN_CTAG_FILTER ;
drivers/net/ethernet/netronome/nfp/nfp_net_common.c +0 -2
@@ -3815,8 +3815,6 @@ static void nfp_net_netdev_init(struct nfp_net *nn) netdev->netdev_ops = &nfp_net_netdev_ops; netdev->watchdog_timeo =msecs_to_jiffies (5 *1000 ); -SWITCHDEV_SET_OPS (netdev, &nfp_port_switchdev_ops); -/* MTU range: 68 - hw-specific max */ netdev->min_mtu =ETH_MIN_MTU ; netdev->max_mtu = nn->max_mtu;
drivers/net/ethernet/netronome/nfp/nfp_net_repr.c +0 -2
@@ -336,8 +336,6 @@ int nfp_repr_init(struct nfp_app *app, struct net_device *netdev, netdev->max_mtu = pf_netdev->max_mtu; -SWITCHDEV_SET_OPS (netdev, &nfp_port_switchdev_ops); -/* Set features the lower device can support with representors */ if (repr_cap &NFP_NET_CFG_CTRL_LIVE_ADDR ) netdev->priv_flags |=IFF_LIVE_ADDR_CHANGE ;
drivers/net/ethernet/netronome/nfp/nfp_port.c +0 -4
@@ -55,10 +55,6 @@ nfp_port_attr_get(struct net_device *netdev, struct switchdev_attr *attr)return 0 ; } -const struct switchdev_ops nfp_port_switchdev_ops = { - .switchdev_port_attr_get = nfp_port_attr_get, -}; -int nfp_port_switchdev_attr_event (unsigned long event,struct net_device *netdev,struct switchdev_notifier_port_attr_info *port_attr_info)
drivers/net/ethernet/rocker/rocker_main.c +0 -6
@@ -2139,11 +2139,6 @@ static int rocker_port_obj_del(struct net_device *dev,return err; } -static const struct switchdev_ops rocker_port_switchdev_ops = { - .switchdev_port_attr_get = rocker_port_attr_get, - .switchdev_port_attr_set = rocker_port_attr_set, -}; -struct rocker_fib_event_work {struct work_struct work;union {
@@ -2597,7 +2592,6 @@ static int rocker_probe_port(struct rocker *rocker, unsigned int port_number)rocker_port_dev_addr_init (rocker_port); dev->netdev_ops = &rocker_port_netdev_ops; dev->ethtool_ops = &rocker_port_ethtool_ops; - dev->switchdev_ops = &rocker_port_switchdev_ops;netif_tx_napi_add (dev, &rocker_port->napi_tx, rocker_port_poll_tx,NAPI_POLL_WEIGHT ); netif_napi_add(dev, &rocker_port->napi_rx, rocker_port_poll_rx,
drivers/net/netdevsim/netdev.c +0 -5
@@ -164,10 +164,6 @@ nsim_port_attr_get(struct net_device *dev, struct switchdev_attr *attr) } } -static const struct switchdev_ops nsim_switchdev_ops = { - .switchdev_port_attr_get = nsim_port_attr_get, -}; -static int nsim_switchdev_port_attr_event (unsigned long event,struct net_device *dev,struct switchdev_notifier_port_attr_info *port_attr_info)
@@ -228,7 +224,6 @@ static int nsim_init(struct net_device *dev) goto err_bpf_uninit;SET_NETDEV_DEV (dev, &ns->dev); -SWITCHDEV_SET_OPS (dev, &nsim_switchdev_ops); err =nsim_devlink_setup (ns);if (err)
drivers/staging/fsl-dpaa2/ethsw/ethsw.c +0 -6
@@ -924,11 +924,6 @@ static int swdev_port_obj_del(struct net_device *netdev,return err; } -static const struct switchdev_ops ethsw_port_switchdev_ops = { - .switchdev_port_attr_get = swdev_port_attr_get, - .switchdev_port_attr_set = swdev_port_attr_set, -}; -/* For the moment, only flood setting needs to be updated */ static int port_bridge_join (struct net_device *netdev,struct net_device *upper_dev)
@@ -1458,7 +1453,6 @@ static int ethsw_probe_port(struct ethsw_core *ethsw, u16 port_idx)SET_NETDEV_DEV (port_netdev, dev); port_netdev->netdev_ops = ðsw_port_ops; port_netdev->ethtool_ops = ðsw_port_ethtool_ops; - port_netdev->switchdev_ops = ðsw_port_switchdev_ops;/* Set MTU limits */ port_netdev->min_mtu =ETH_MIN_MTU ;
include/linux/netdevice.h +0 -3
@@ -1826,9 +1826,6 @@ struct net_device {#endif const struct net_device_ops *netdev_ops;const struct ethtool_ops *ethtool_ops; -#ifdef CONFIG_NET_SWITCHDEV -const struct switchdev_ops *switchdev_ops; -#endif #ifdef CONFIG_NET_L3_MASTER_DEV const struct l3mdev_ops *l3mdev_ops;#endif
include/net/switchdev.h +0 -18
@@ -115,21 +115,6 @@ void *switchdev_trans_item_dequeue(struct switchdev_trans *trans);typedef int switchdev_obj_dump_cb_t (struct switchdev_obj *obj); -/** -* struct switchdev_ops - switchdev operations -* -* @switchdev_port_attr_get: Get a port attribute (see switchdev_attr). -* -* @switchdev_port_attr_set: Set a port attribute (see switchdev_attr). -*/ -struct switchdev_ops { -int (*switchdev_port_attr_get)(struct net_device *dev, -struct switchdev_attr *attr); -int (*switchdev_port_attr_set)(struct net_device *dev, -const struct switchdev_attr *attr, -struct switchdev_trans *trans); -}; -enum switchdev_notifier_type {SWITCHDEV_FDB_ADD_TO_BRIDGE =1 ,SWITCHDEV_FDB_DEL_TO_BRIDGE ,
@@ -234,7 +219,6 @@ int switchdev_handle_port_obj_del(struct net_device *dev,int (*del_cb)(struct net_device *dev, const struct switchdev_obj *obj)); -#define SWITCHDEV_SET_OPS (netdev, ops) ((netdev)->switchdev_ops = (ops))#else static inline void switchdev_deferred_process (void )
@@ -333,8 +317,6 @@ switchdev_handle_port_obj_del(struct net_device *dev,return 0 ; } -#define SWITCHDEV_SET_OPS (netdev, ops) do {} while (0) -#endif #endif /* _LINUX_SWITCHDEV_H_ */
net/dsa/slave.c +0 -6
@@ -1048,11 +1048,6 @@ static const struct net_device_ops dsa_slave_netdev_ops = { .ndo_get_stats64 = dsa_slave_get_stats64, }; -static const struct switchdev_ops dsa_slave_switchdev_ops = { - .switchdev_port_attr_get = dsa_slave_port_attr_get, - .switchdev_port_attr_set = dsa_slave_port_attr_set, -}; -static struct device_type dsa_type = { .name ="dsa" , };
@@ -1312,7 +1307,6 @@ int dsa_slave_create(struct dsa_port *port)eth_hw_addr_inherit (slave_dev, master); slave_dev->priv_flags |=IFF_NO_QUEUE ; slave_dev->netdev_ops = &dsa_slave_netdev_ops; - slave_dev->switchdev_ops = &dsa_slave_switchdev_ops; slave_dev->min_mtu =0 ; slave_dev->max_mtu =ETH_MAX_MTU ;SET_NETDEV_DEVTYPE (slave_dev, &dsa_type);
net/switchdev/switchdev.c +37 -70
138 lines not on this page · raw message
Signature · 1 line
2.17.1
Jiri Pirko
maintainerQuoted 6 lines · Fri, Feb 01, 2019 at 11:06:44PM CET, [email protected] wrote:
Hi all,
This patch series converts SWITCHDEV_PORT_ATTR_{GET,SET} to use a blocking notifier, similar to how SWITCHDEV_PORT_OBJ_{ADD,DEL} has been changed recently by Petr.
Quoted 6 lines
This was suggested by Ido to help with a particular use case I have where I want to be able to veto a switchdev bridge attribute from a driver (
multicast_snooping).Please review since I may not have gotten the driver abstraction right, especially for mlx5e and nfp since these are *hum* *hum* large drivers.
Looks fine. Thanks!