Commit 68cc2999 authored by David S. Miller's avatar David S. Miller

Merge branch 'devlink-small-spring-cleanup'

Jiri Pirko says:

====================
devlink: small spring cleanup

Mostly cosmetics and janitor work.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 956ca8fc f6b19b35
...@@ -505,6 +505,7 @@ source "drivers/net/hyperv/Kconfig" ...@@ -505,6 +505,7 @@ source "drivers/net/hyperv/Kconfig"
config NETDEVSIM config NETDEVSIM
tristate "Simulated networking device" tristate "Simulated networking device"
depends on DEBUG_FS depends on DEBUG_FS
select NET_DEVLINK
help help
This driver is a developer testing tool and software model that can This driver is a developer testing tool and software model that can
be used to test various control path networking APIs, especially be used to test various control path networking APIs, especially
......
...@@ -196,6 +196,7 @@ config BNXT ...@@ -196,6 +196,7 @@ config BNXT
depends on PCI depends on PCI
select FW_LOADER select FW_LOADER
select LIBCRC32C select LIBCRC32C
select NET_DEVLINK
---help--- ---help---
This driver supports Broadcom NetXtreme-C/E 10/25/40/50 gigabit This driver supports Broadcom NetXtreme-C/E 10/25/40/50 gigabit
Ethernet cards. To compile this driver as a module, choose M here: Ethernet cards. To compile this driver as a module, choose M here:
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <net/devlink.h>
#include "bnxt_hsi.h" #include "bnxt_hsi.h"
#include "bnxt.h" #include "bnxt.h"
#include "bnxt_vfr.h" #include "bnxt_vfr.h"
...@@ -228,6 +229,8 @@ int bnxt_dl_register(struct bnxt *bp) ...@@ -228,6 +229,8 @@ int bnxt_dl_register(struct bnxt *bp)
goto err_dl_unreg; goto err_dl_unreg;
} }
devlink_port_attrs_set(&bp->dl_port, DEVLINK_PORT_FLAVOUR_PHYSICAL,
bp->pf.port_id, false, 0);
rc = devlink_port_register(dl, &bp->dl_port, bp->pf.port_id); rc = devlink_port_register(dl, &bp->dl_port, bp->pf.port_id);
if (rc) { if (rc) {
netdev_err(bp->dev, "devlink_port_register failed"); netdev_err(bp->dev, "devlink_port_register failed");
......
...@@ -68,6 +68,7 @@ config LIQUIDIO ...@@ -68,6 +68,7 @@ config LIQUIDIO
imply PTP_1588_CLOCK imply PTP_1588_CLOCK
select FW_LOADER select FW_LOADER
select LIBCRC32C select LIBCRC32C
select NET_DEVLINK
---help--- ---help---
This driver supports Cavium LiquidIO Intelligent Server Adapters This driver supports Cavium LiquidIO Intelligent Server Adapters
based on CN66XX, CN68XX and CN23XX chips. based on CN66XX, CN68XX and CN23XX chips.
......
...@@ -26,6 +26,7 @@ config MLX4_EN_DCB ...@@ -26,6 +26,7 @@ config MLX4_EN_DCB
config MLX4_CORE config MLX4_CORE
tristate tristate
depends on PCI depends on PCI
select NET_DEVLINK
default n default n
config MLX4_DEBUG config MLX4_DEBUG
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
config MLX5_CORE config MLX5_CORE
tristate "Mellanox 5th generation network adapters (ConnectX series) core driver" tristate "Mellanox 5th generation network adapters (ConnectX series) core driver"
depends on PCI depends on PCI
select NET_DEVLINK
imply PTP_1588_CLOCK imply PTP_1588_CLOCK
imply VXLAN imply VXLAN
default n default n
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
config MLXSW_CORE config MLXSW_CORE
tristate "Mellanox Technologies Switch ASICs support" tristate "Mellanox Technologies Switch ASICs support"
select NET_DEVLINK
---help--- ---help---
This driver supports Mellanox Technologies Switch ASICs family. This driver supports Mellanox Technologies Switch ASICs family.
......
...@@ -1718,7 +1718,9 @@ u64 mlxsw_core_res_get(struct mlxsw_core *mlxsw_core, ...@@ -1718,7 +1718,9 @@ u64 mlxsw_core_res_get(struct mlxsw_core *mlxsw_core,
} }
EXPORT_SYMBOL(mlxsw_core_res_get); EXPORT_SYMBOL(mlxsw_core_res_get);
int mlxsw_core_port_init(struct mlxsw_core *mlxsw_core, u8 local_port) int mlxsw_core_port_init(struct mlxsw_core *mlxsw_core, u8 local_port,
u32 port_number, bool split,
u32 split_port_subnumber)
{ {
struct devlink *devlink = priv_to_devlink(mlxsw_core); struct devlink *devlink = priv_to_devlink(mlxsw_core);
struct mlxsw_core_port *mlxsw_core_port = struct mlxsw_core_port *mlxsw_core_port =
...@@ -1727,6 +1729,8 @@ int mlxsw_core_port_init(struct mlxsw_core *mlxsw_core, u8 local_port) ...@@ -1727,6 +1729,8 @@ int mlxsw_core_port_init(struct mlxsw_core *mlxsw_core, u8 local_port)
int err; int err;
mlxsw_core_port->local_port = local_port; mlxsw_core_port->local_port = local_port;
devlink_port_attrs_set(devlink_port, DEVLINK_PORT_FLAVOUR_PHYSICAL,
port_number, split, split_port_subnumber);
err = devlink_port_register(devlink, devlink_port, local_port); err = devlink_port_register(devlink, devlink_port, local_port);
if (err) if (err)
memset(mlxsw_core_port, 0, sizeof(*mlxsw_core_port)); memset(mlxsw_core_port, 0, sizeof(*mlxsw_core_port));
...@@ -1746,17 +1750,13 @@ void mlxsw_core_port_fini(struct mlxsw_core *mlxsw_core, u8 local_port) ...@@ -1746,17 +1750,13 @@ void mlxsw_core_port_fini(struct mlxsw_core *mlxsw_core, u8 local_port)
EXPORT_SYMBOL(mlxsw_core_port_fini); EXPORT_SYMBOL(mlxsw_core_port_fini);
void mlxsw_core_port_eth_set(struct mlxsw_core *mlxsw_core, u8 local_port, void mlxsw_core_port_eth_set(struct mlxsw_core *mlxsw_core, u8 local_port,
void *port_driver_priv, struct net_device *dev, void *port_driver_priv, struct net_device *dev)
u32 port_number, bool split,
u32 split_port_subnumber)
{ {
struct mlxsw_core_port *mlxsw_core_port = struct mlxsw_core_port *mlxsw_core_port =
&mlxsw_core->ports[local_port]; &mlxsw_core->ports[local_port];
struct devlink_port *devlink_port = &mlxsw_core_port->devlink_port; struct devlink_port *devlink_port = &mlxsw_core_port->devlink_port;
mlxsw_core_port->port_driver_priv = port_driver_priv; mlxsw_core_port->port_driver_priv = port_driver_priv;
devlink_port_attrs_set(devlink_port, DEVLINK_PORT_FLAVOUR_PHYSICAL,
port_number, split, split_port_subnumber);
devlink_port_type_eth_set(devlink_port, dev); devlink_port_type_eth_set(devlink_port, dev);
} }
EXPORT_SYMBOL(mlxsw_core_port_eth_set); EXPORT_SYMBOL(mlxsw_core_port_eth_set);
......
...@@ -164,12 +164,12 @@ void mlxsw_core_lag_mapping_clear(struct mlxsw_core *mlxsw_core, ...@@ -164,12 +164,12 @@ void mlxsw_core_lag_mapping_clear(struct mlxsw_core *mlxsw_core,
u16 lag_id, u8 local_port); u16 lag_id, u8 local_port);
void *mlxsw_core_port_driver_priv(struct mlxsw_core_port *mlxsw_core_port); void *mlxsw_core_port_driver_priv(struct mlxsw_core_port *mlxsw_core_port);
int mlxsw_core_port_init(struct mlxsw_core *mlxsw_core, u8 local_port); int mlxsw_core_port_init(struct mlxsw_core *mlxsw_core, u8 local_port,
u32 port_number, bool split,
u32 split_port_subnumber);
void mlxsw_core_port_fini(struct mlxsw_core *mlxsw_core, u8 local_port); void mlxsw_core_port_fini(struct mlxsw_core *mlxsw_core, u8 local_port);
void mlxsw_core_port_eth_set(struct mlxsw_core *mlxsw_core, u8 local_port, void mlxsw_core_port_eth_set(struct mlxsw_core *mlxsw_core, u8 local_port,
void *port_driver_priv, struct net_device *dev, void *port_driver_priv, struct net_device *dev);
u32 port_number, bool split,
u32 split_port_subnumber);
void mlxsw_core_port_ib_set(struct mlxsw_core *mlxsw_core, u8 local_port, void mlxsw_core_port_ib_set(struct mlxsw_core *mlxsw_core, u8 local_port,
void *port_driver_priv); void *port_driver_priv);
void mlxsw_core_port_clear(struct mlxsw_core *mlxsw_core, u8 local_port, void mlxsw_core_port_clear(struct mlxsw_core *mlxsw_core, u8 local_port,
......
...@@ -150,7 +150,8 @@ mlxsw_m_port_create(struct mlxsw_m *mlxsw_m, u8 local_port, u8 module) ...@@ -150,7 +150,8 @@ mlxsw_m_port_create(struct mlxsw_m *mlxsw_m, u8 local_port, u8 module)
struct net_device *dev; struct net_device *dev;
int err; int err;
err = mlxsw_core_port_init(mlxsw_m->core, local_port); err = mlxsw_core_port_init(mlxsw_m->core, local_port,
module + 1, false, 0);
if (err) { if (err) {
dev_err(mlxsw_m->bus_info->dev, "Port %d: Failed to init core port\n", dev_err(mlxsw_m->bus_info->dev, "Port %d: Failed to init core port\n",
local_port); local_port);
...@@ -190,7 +191,7 @@ mlxsw_m_port_create(struct mlxsw_m *mlxsw_m, u8 local_port, u8 module) ...@@ -190,7 +191,7 @@ mlxsw_m_port_create(struct mlxsw_m *mlxsw_m, u8 local_port, u8 module)
} }
mlxsw_core_port_eth_set(mlxsw_m->core, mlxsw_m_port->local_port, mlxsw_core_port_eth_set(mlxsw_m->core, mlxsw_m_port->local_port,
mlxsw_m_port, dev, module + 1, false, 0); mlxsw_m_port, dev);
return 0; return 0;
......
...@@ -3391,7 +3391,8 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port, ...@@ -3391,7 +3391,8 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port,
struct net_device *dev; struct net_device *dev;
int err; int err;
err = mlxsw_core_port_init(mlxsw_sp->core, local_port); err = mlxsw_core_port_init(mlxsw_sp->core, local_port,
module + 1, split, lane / width);
if (err) { if (err) {
dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to init core port\n", dev_err(mlxsw_sp->bus_info->dev, "Port %d: Failed to init core port\n",
local_port); local_port);
...@@ -3573,8 +3574,7 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port, ...@@ -3573,8 +3574,7 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port,
} }
mlxsw_core_port_eth_set(mlxsw_sp->core, mlxsw_sp_port->local_port, mlxsw_core_port_eth_set(mlxsw_sp->core, mlxsw_sp_port->local_port,
mlxsw_sp_port, dev, module + 1, mlxsw_sp_port, dev);
mlxsw_sp_port->split, lane / width);
mlxsw_core_schedule_dw(&mlxsw_sp_port->periodic_hw_stats.update_dw, 0); mlxsw_core_schedule_dw(&mlxsw_sp_port->periodic_hw_stats.update_dw, 0);
return 0; return 0;
......
...@@ -267,7 +267,8 @@ static int mlxsw_sib_port_create(struct mlxsw_sib *mlxsw_sib, u8 local_port, ...@@ -267,7 +267,8 @@ static int mlxsw_sib_port_create(struct mlxsw_sib *mlxsw_sib, u8 local_port,
{ {
int err; int err;
err = mlxsw_core_port_init(mlxsw_sib->core, local_port); err = mlxsw_core_port_init(mlxsw_sib->core, local_port,
module + 1, false, 0);
if (err) { if (err) {
dev_err(mlxsw_sib->bus_info->dev, "Port %d: Failed to init core port\n", dev_err(mlxsw_sib->bus_info->dev, "Port %d: Failed to init core port\n",
local_port); local_port);
......
...@@ -1102,7 +1102,7 @@ static int __mlxsw_sx_port_eth_create(struct mlxsw_sx *mlxsw_sx, u8 local_port, ...@@ -1102,7 +1102,7 @@ static int __mlxsw_sx_port_eth_create(struct mlxsw_sx *mlxsw_sx, u8 local_port,
} }
mlxsw_core_port_eth_set(mlxsw_sx->core, mlxsw_sx_port->local_port, mlxsw_core_port_eth_set(mlxsw_sx->core, mlxsw_sx_port->local_port,
mlxsw_sx_port, dev, module + 1, false, 0); mlxsw_sx_port, dev);
mlxsw_sx->ports[local_port] = mlxsw_sx_port; mlxsw_sx->ports[local_port] = mlxsw_sx_port;
return 0; return 0;
...@@ -1127,7 +1127,8 @@ static int mlxsw_sx_port_eth_create(struct mlxsw_sx *mlxsw_sx, u8 local_port, ...@@ -1127,7 +1127,8 @@ static int mlxsw_sx_port_eth_create(struct mlxsw_sx *mlxsw_sx, u8 local_port,
{ {
int err; int err;
err = mlxsw_core_port_init(mlxsw_sx->core, local_port); err = mlxsw_core_port_init(mlxsw_sx->core, local_port,
module + 1, false, 0);
if (err) { if (err) {
dev_err(mlxsw_sx->bus_info->dev, "Port %d: Failed to init core port\n", dev_err(mlxsw_sx->bus_info->dev, "Port %d: Failed to init core port\n",
local_port); local_port);
......
...@@ -19,6 +19,7 @@ config NFP ...@@ -19,6 +19,7 @@ config NFP
tristate "Netronome(R) NFP4000/NFP6000 NIC driver" tristate "Netronome(R) NFP4000/NFP6000 NIC driver"
depends on PCI && PCI_MSI depends on PCI && PCI_MSI
depends on VXLAN || VXLAN=n depends on VXLAN || VXLAN=n
select NET_DEVLINK
---help--- ---help---
This driver supports the Netronome(R) NFP4000/NFP6000 based This driver supports the Netronome(R) NFP4000/NFP6000 based
cards working as a advanced Ethernet NIC. It works with both cards working as a advanced Ethernet NIC. It works with both
......
...@@ -362,7 +362,6 @@ int nfp_devlink_port_register(struct nfp_app *app, struct nfp_port *port) ...@@ -362,7 +362,6 @@ int nfp_devlink_port_register(struct nfp_app *app, struct nfp_port *port)
if (ret) if (ret)
return ret; return ret;
devlink_port_type_eth_set(&port->dl_port, port->netdev);
devlink_port_attrs_set(&port->dl_port, DEVLINK_PORT_FLAVOUR_PHYSICAL, devlink_port_attrs_set(&port->dl_port, DEVLINK_PORT_FLAVOUR_PHYSICAL,
eth_port.label_port, eth_port.is_split, eth_port.label_port, eth_port.is_split,
eth_port.label_subport); eth_port.label_subport);
...@@ -377,6 +376,16 @@ void nfp_devlink_port_unregister(struct nfp_port *port) ...@@ -377,6 +376,16 @@ void nfp_devlink_port_unregister(struct nfp_port *port)
devlink_port_unregister(&port->dl_port); devlink_port_unregister(&port->dl_port);
} }
void nfp_devlink_port_type_eth_set(struct nfp_port *port)
{
devlink_port_type_eth_set(&port->dl_port, port->netdev);
}
void nfp_devlink_port_type_clear(struct nfp_port *port)
{
devlink_port_type_clear(&port->dl_port);
}
struct devlink *nfp_devlink_get_devlink(struct net_device *netdev) struct devlink *nfp_devlink_get_devlink(struct net_device *netdev)
{ {
struct nfp_app *app; struct nfp_app *app;
......
...@@ -160,6 +160,7 @@ nfp_net_pf_init_vnic(struct nfp_pf *pf, struct nfp_net *nn, unsigned int id) ...@@ -160,6 +160,7 @@ nfp_net_pf_init_vnic(struct nfp_pf *pf, struct nfp_net *nn, unsigned int id)
err = nfp_devlink_port_register(pf->app, nn->port); err = nfp_devlink_port_register(pf->app, nn->port);
if (err) if (err)
goto err_dfs_clean; goto err_dfs_clean;
nfp_devlink_port_type_eth_set(nn->port);
} }
nfp_net_info(nn); nfp_net_info(nn);
...@@ -173,8 +174,10 @@ nfp_net_pf_init_vnic(struct nfp_pf *pf, struct nfp_net *nn, unsigned int id) ...@@ -173,8 +174,10 @@ nfp_net_pf_init_vnic(struct nfp_pf *pf, struct nfp_net *nn, unsigned int id)
return 0; return 0;
err_devlink_port_clean: err_devlink_port_clean:
if (nn->port) if (nn->port) {
nfp_devlink_port_type_clear(nn->port);
nfp_devlink_port_unregister(nn->port); nfp_devlink_port_unregister(nn->port);
}
err_dfs_clean: err_dfs_clean:
nfp_net_debugfs_dir_clean(&nn->debugfs_dir); nfp_net_debugfs_dir_clean(&nn->debugfs_dir);
nfp_net_clean(nn); nfp_net_clean(nn);
...@@ -220,8 +223,10 @@ static void nfp_net_pf_clean_vnic(struct nfp_pf *pf, struct nfp_net *nn) ...@@ -220,8 +223,10 @@ static void nfp_net_pf_clean_vnic(struct nfp_pf *pf, struct nfp_net *nn)
{ {
if (nfp_net_is_data_vnic(nn)) if (nfp_net_is_data_vnic(nn))
nfp_app_vnic_clean(pf->app, nn); nfp_app_vnic_clean(pf->app, nn);
if (nn->port) if (nn->port) {
nfp_devlink_port_type_clear(nn->port);
nfp_devlink_port_unregister(nn->port); nfp_devlink_port_unregister(nn->port);
}
nfp_net_debugfs_dir_clean(&nn->debugfs_dir); nfp_net_debugfs_dir_clean(&nn->debugfs_dir);
nfp_net_clean(nn); nfp_net_clean(nn);
} }
......
...@@ -131,6 +131,8 @@ int nfp_net_refresh_port_table_sync(struct nfp_pf *pf); ...@@ -131,6 +131,8 @@ int nfp_net_refresh_port_table_sync(struct nfp_pf *pf);
int nfp_devlink_port_register(struct nfp_app *app, struct nfp_port *port); int nfp_devlink_port_register(struct nfp_app *app, struct nfp_port *port);
void nfp_devlink_port_unregister(struct nfp_port *port); void nfp_devlink_port_unregister(struct nfp_port *port);
void nfp_devlink_port_type_eth_set(struct nfp_port *port);
void nfp_devlink_port_type_clear(struct nfp_port *port);
/** /**
* Mac stats (0x0000 - 0x0200) * Mac stats (0x0000 - 0x0200)
......
This diff is collapsed.
...@@ -429,11 +429,8 @@ config NET_SOCK_MSG ...@@ -429,11 +429,8 @@ config NET_SOCK_MSG
with the help of BPF programs. with the help of BPF programs.
config NET_DEVLINK config NET_DEVLINK
bool "Network physical/parent device Netlink interface" bool
help default n
Network physical/parent device Netlink interface provides
infrastructure to support access to physical chip-wide config and
monitoring.
config PAGE_POOL config PAGE_POOL
bool bool
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <linux/device.h> #include <linux/device.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/spinlock.h>
#include <rdma/ib_verbs.h> #include <rdma/ib_verbs.h>
#include <net/netlink.h> #include <net/netlink.h>
#include <net/genetlink.h> #include <net/genetlink.h>
...@@ -543,12 +544,14 @@ static int devlink_nl_port_fill(struct sk_buff *msg, struct devlink *devlink, ...@@ -543,12 +544,14 @@ static int devlink_nl_port_fill(struct sk_buff *msg, struct devlink *devlink,
goto nla_put_failure; goto nla_put_failure;
if (nla_put_u32(msg, DEVLINK_ATTR_PORT_INDEX, devlink_port->index)) if (nla_put_u32(msg, DEVLINK_ATTR_PORT_INDEX, devlink_port->index))
goto nla_put_failure; goto nla_put_failure;
spin_lock(&devlink_port->type_lock);
if (nla_put_u16(msg, DEVLINK_ATTR_PORT_TYPE, devlink_port->type)) if (nla_put_u16(msg, DEVLINK_ATTR_PORT_TYPE, devlink_port->type))
goto nla_put_failure; goto nla_put_failure_type_locked;
if (devlink_port->desired_type != DEVLINK_PORT_TYPE_NOTSET && if (devlink_port->desired_type != DEVLINK_PORT_TYPE_NOTSET &&
nla_put_u16(msg, DEVLINK_ATTR_PORT_DESIRED_TYPE, nla_put_u16(msg, DEVLINK_ATTR_PORT_DESIRED_TYPE,
devlink_port->desired_type)) devlink_port->desired_type))
goto nla_put_failure; goto nla_put_failure_type_locked;
if (devlink_port->type == DEVLINK_PORT_TYPE_ETH) { if (devlink_port->type == DEVLINK_PORT_TYPE_ETH) {
struct net_device *netdev = devlink_port->type_dev; struct net_device *netdev = devlink_port->type_dev;
...@@ -557,7 +560,7 @@ static int devlink_nl_port_fill(struct sk_buff *msg, struct devlink *devlink, ...@@ -557,7 +560,7 @@ static int devlink_nl_port_fill(struct sk_buff *msg, struct devlink *devlink,
netdev->ifindex) || netdev->ifindex) ||
nla_put_string(msg, DEVLINK_ATTR_PORT_NETDEV_NAME, nla_put_string(msg, DEVLINK_ATTR_PORT_NETDEV_NAME,
netdev->name))) netdev->name)))
goto nla_put_failure; goto nla_put_failure_type_locked;
} }
if (devlink_port->type == DEVLINK_PORT_TYPE_IB) { if (devlink_port->type == DEVLINK_PORT_TYPE_IB) {
struct ib_device *ibdev = devlink_port->type_dev; struct ib_device *ibdev = devlink_port->type_dev;
...@@ -565,14 +568,17 @@ static int devlink_nl_port_fill(struct sk_buff *msg, struct devlink *devlink, ...@@ -565,14 +568,17 @@ static int devlink_nl_port_fill(struct sk_buff *msg, struct devlink *devlink,
if (ibdev && if (ibdev &&
nla_put_string(msg, DEVLINK_ATTR_PORT_IBDEV_NAME, nla_put_string(msg, DEVLINK_ATTR_PORT_IBDEV_NAME,
ibdev->name)) ibdev->name))
goto nla_put_failure; goto nla_put_failure_type_locked;
} }
spin_unlock(&devlink_port->type_lock);
if (devlink_nl_port_attrs_put(msg, devlink_port)) if (devlink_nl_port_attrs_put(msg, devlink_port))
goto nla_put_failure; goto nla_put_failure;
genlmsg_end(msg, hdr); genlmsg_end(msg, hdr);
return 0; return 0;
nla_put_failure_type_locked:
spin_unlock(&devlink_port->type_lock);
nla_put_failure: nla_put_failure:
genlmsg_cancel(msg, hdr); genlmsg_cancel(msg, hdr);
return -EMSGSIZE; return -EMSGSIZE;
...@@ -4486,6 +4492,7 @@ devlink_health_reporter_destroy(struct devlink_health_reporter *reporter) ...@@ -4486,6 +4492,7 @@ devlink_health_reporter_destroy(struct devlink_health_reporter *reporter)
{ {
mutex_lock(&reporter->devlink->lock); mutex_lock(&reporter->devlink->lock);
list_del(&reporter->list); list_del(&reporter->list);
mutex_destroy(&reporter->dump_lock);
mutex_unlock(&reporter->devlink->lock); mutex_unlock(&reporter->devlink->lock);
if (reporter->dump_fmsg) if (reporter->dump_fmsg)
devlink_fmsg_free(reporter->dump_fmsg); devlink_fmsg_free(reporter->dump_fmsg);
...@@ -5261,6 +5268,7 @@ EXPORT_SYMBOL_GPL(devlink_unregister); ...@@ -5261,6 +5268,7 @@ EXPORT_SYMBOL_GPL(devlink_unregister);
*/ */
void devlink_free(struct devlink *devlink) void devlink_free(struct devlink *devlink)
{ {
mutex_destroy(&devlink->lock);
WARN_ON(!list_empty(&devlink->reporter_list)); WARN_ON(!list_empty(&devlink->reporter_list));
WARN_ON(!list_empty(&devlink->region_list)); WARN_ON(!list_empty(&devlink->region_list));
WARN_ON(!list_empty(&devlink->param_list)); WARN_ON(!list_empty(&devlink->param_list));
...@@ -5298,6 +5306,7 @@ int devlink_port_register(struct devlink *devlink, ...@@ -5298,6 +5306,7 @@ int devlink_port_register(struct devlink *devlink,
devlink_port->devlink = devlink; devlink_port->devlink = devlink;
devlink_port->index = port_index; devlink_port->index = port_index;
devlink_port->registered = true; devlink_port->registered = true;
spin_lock_init(&devlink_port->type_lock);
list_add_tail(&devlink_port->list, &devlink->port_list); list_add_tail(&devlink_port->list, &devlink->port_list);
INIT_LIST_HEAD(&devlink_port->param_list); INIT_LIST_HEAD(&devlink_port->param_list);
mutex_unlock(&devlink->lock); mutex_unlock(&devlink->lock);
...@@ -5326,8 +5335,12 @@ static void __devlink_port_type_set(struct devlink_port *devlink_port, ...@@ -5326,8 +5335,12 @@ static void __devlink_port_type_set(struct devlink_port *devlink_port,
enum devlink_port_type type, enum devlink_port_type type,
void *type_dev) void *type_dev)
{ {
if (WARN_ON(!devlink_port->registered))
return;
spin_lock(&devlink_port->type_lock);
devlink_port->type = type; devlink_port->type = type;
devlink_port->type_dev = type_dev; devlink_port->type_dev = type_dev;
spin_unlock(&devlink_port->type_lock);
devlink_port_notify(devlink_port, DEVLINK_CMD_PORT_NEW); devlink_port_notify(devlink_port, DEVLINK_CMD_PORT_NEW);
} }
...@@ -5340,8 +5353,7 @@ static void __devlink_port_type_set(struct devlink_port *devlink_port, ...@@ -5340,8 +5353,7 @@ static void __devlink_port_type_set(struct devlink_port *devlink_port,
void devlink_port_type_eth_set(struct devlink_port *devlink_port, void devlink_port_type_eth_set(struct devlink_port *devlink_port,
struct net_device *netdev) struct net_device *netdev)
{ {
return __devlink_port_type_set(devlink_port, __devlink_port_type_set(devlink_port, DEVLINK_PORT_TYPE_ETH, netdev);
DEVLINK_PORT_TYPE_ETH, netdev);
} }
EXPORT_SYMBOL_GPL(devlink_port_type_eth_set); EXPORT_SYMBOL_GPL(devlink_port_type_eth_set);
...@@ -5354,8 +5366,7 @@ EXPORT_SYMBOL_GPL(devlink_port_type_eth_set); ...@@ -5354,8 +5366,7 @@ EXPORT_SYMBOL_GPL(devlink_port_type_eth_set);
void devlink_port_type_ib_set(struct devlink_port *devlink_port, void devlink_port_type_ib_set(struct devlink_port *devlink_port,
struct ib_device *ibdev) struct ib_device *ibdev)
{ {
return __devlink_port_type_set(devlink_port, __devlink_port_type_set(devlink_port, DEVLINK_PORT_TYPE_IB, ibdev);
DEVLINK_PORT_TYPE_IB, ibdev);
} }
EXPORT_SYMBOL_GPL(devlink_port_type_ib_set); EXPORT_SYMBOL_GPL(devlink_port_type_ib_set);
...@@ -5366,8 +5377,7 @@ EXPORT_SYMBOL_GPL(devlink_port_type_ib_set); ...@@ -5366,8 +5377,7 @@ EXPORT_SYMBOL_GPL(devlink_port_type_ib_set);
*/ */
void devlink_port_type_clear(struct devlink_port *devlink_port) void devlink_port_type_clear(struct devlink_port *devlink_port)
{ {
return __devlink_port_type_set(devlink_port, __devlink_port_type_set(devlink_port, DEVLINK_PORT_TYPE_NOTSET, NULL);
DEVLINK_PORT_TYPE_NOTSET, NULL);
} }
EXPORT_SYMBOL_GPL(devlink_port_type_clear); EXPORT_SYMBOL_GPL(devlink_port_type_clear);
...@@ -5389,12 +5399,13 @@ void devlink_port_attrs_set(struct devlink_port *devlink_port, ...@@ -5389,12 +5399,13 @@ void devlink_port_attrs_set(struct devlink_port *devlink_port,
{ {
struct devlink_port_attrs *attrs = &devlink_port->attrs; struct devlink_port_attrs *attrs = &devlink_port->attrs;
if (WARN_ON(devlink_port->registered))
return;
attrs->set = true; attrs->set = true;
attrs->flavour = flavour; attrs->flavour = flavour;
attrs->port_number = port_number; attrs->port_number = port_number;
attrs->split = split; attrs->split = split;
attrs->split_subport_number = split_subport_number; attrs->split_subport_number = split_subport_number;
devlink_port_notify(devlink_port, DEVLINK_CMD_PORT_NEW);
} }
EXPORT_SYMBOL_GPL(devlink_port_attrs_set); EXPORT_SYMBOL_GPL(devlink_port_attrs_set);
...@@ -6405,17 +6416,15 @@ void devlink_compat_running_version(struct net_device *dev, ...@@ -6405,17 +6416,15 @@ void devlink_compat_running_version(struct net_device *dev,
dev_hold(dev); dev_hold(dev);
rtnl_unlock(); rtnl_unlock();
mutex_lock(&devlink_mutex);
devlink = netdev_to_devlink(dev); devlink = netdev_to_devlink(dev);
if (!devlink || !devlink->ops->info_get) if (!devlink || !devlink->ops->info_get)
goto unlock_list; goto out;
mutex_lock(&devlink->lock); mutex_lock(&devlink->lock);
__devlink_compat_running_version(devlink, buf, len); __devlink_compat_running_version(devlink, buf, len);
mutex_unlock(&devlink->lock); mutex_unlock(&devlink->lock);
unlock_list:
mutex_unlock(&devlink_mutex);
out:
rtnl_lock(); rtnl_lock();
dev_put(dev); dev_put(dev);
} }
...@@ -6423,22 +6432,22 @@ void devlink_compat_running_version(struct net_device *dev, ...@@ -6423,22 +6432,22 @@ void devlink_compat_running_version(struct net_device *dev,
int devlink_compat_flash_update(struct net_device *dev, const char *file_name) int devlink_compat_flash_update(struct net_device *dev, const char *file_name)
{ {
struct devlink *devlink; struct devlink *devlink;
int ret = -EOPNOTSUPP; int ret;
dev_hold(dev); dev_hold(dev);
rtnl_unlock(); rtnl_unlock();
mutex_lock(&devlink_mutex);
devlink = netdev_to_devlink(dev); devlink = netdev_to_devlink(dev);
if (!devlink || !devlink->ops->flash_update) if (!devlink || !devlink->ops->flash_update) {
goto unlock_list; ret = -EOPNOTSUPP;
goto out;
}
mutex_lock(&devlink->lock); mutex_lock(&devlink->lock);
ret = devlink->ops->flash_update(devlink, file_name, NULL, NULL); ret = devlink->ops->flash_update(devlink, file_name, NULL, NULL);
mutex_unlock(&devlink->lock); mutex_unlock(&devlink->lock);
unlock_list:
mutex_unlock(&devlink_mutex);
out:
rtnl_lock(); rtnl_lock();
dev_put(dev); dev_put(dev);
......
...@@ -10,6 +10,7 @@ config NET_DSA ...@@ -10,6 +10,7 @@ config NET_DSA
depends on BRIDGE || BRIDGE=n depends on BRIDGE || BRIDGE=n
select NET_SWITCHDEV select NET_SWITCHDEV
select PHYLINK select PHYLINK
select NET_DEVLINK
---help--- ---help---
Say Y if you want to enable support for the hardware switches supported Say Y if you want to enable support for the hardware switches supported
by the Distributed Switch Architecture. by the Distributed Switch Architecture.
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <linux/rtnetlink.h> #include <linux/rtnetlink.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_net.h> #include <linux/of_net.h>
#include <net/devlink.h>
#include "dsa_priv.h" #include "dsa_priv.h"
...@@ -257,14 +258,36 @@ static void dsa_tree_teardown_default_cpu(struct dsa_switch_tree *dst) ...@@ -257,14 +258,36 @@ static void dsa_tree_teardown_default_cpu(struct dsa_switch_tree *dst)
static int dsa_port_setup(struct dsa_port *dp) static int dsa_port_setup(struct dsa_port *dp)
{ {
enum devlink_port_flavour flavour;
struct dsa_switch *ds = dp->ds; struct dsa_switch *ds = dp->ds;
int err = 0; int err;
if (dp->type == DSA_PORT_TYPE_UNUSED)
return 0;
memset(&dp->devlink_port, 0, sizeof(dp->devlink_port)); memset(&dp->devlink_port, 0, sizeof(dp->devlink_port));
if (dp->type != DSA_PORT_TYPE_UNUSED) switch (dp->type) {
err = devlink_port_register(ds->devlink, &dp->devlink_port, case DSA_PORT_TYPE_CPU:
dp->index); flavour = DEVLINK_PORT_FLAVOUR_CPU;
break;
case DSA_PORT_TYPE_DSA:
flavour = DEVLINK_PORT_FLAVOUR_DSA;
break;
case DSA_PORT_TYPE_USER: /* fall-through */
default:
flavour = DEVLINK_PORT_FLAVOUR_PHYSICAL;
break;
}
/* dp->index is used now as port_number. However
* CPU and DSA ports should have separate numbering
* independent from front panel port numbers.
*/
devlink_port_attrs_set(&dp->devlink_port, flavour,
dp->index, false, 0);
err = devlink_port_register(ds->devlink, &dp->devlink_port,
dp->index);
if (err) if (err)
return err; return err;
...@@ -272,13 +295,6 @@ static int dsa_port_setup(struct dsa_port *dp) ...@@ -272,13 +295,6 @@ static int dsa_port_setup(struct dsa_port *dp)
case DSA_PORT_TYPE_UNUSED: case DSA_PORT_TYPE_UNUSED:
break; break;
case DSA_PORT_TYPE_CPU: case DSA_PORT_TYPE_CPU:
/* dp->index is used now as port_number. However
* CPU ports should have separate numbering
* independent from front panel port numbers.
*/
devlink_port_attrs_set(&dp->devlink_port,
DEVLINK_PORT_FLAVOUR_CPU,
dp->index, false, 0);
err = dsa_port_link_register_of(dp); err = dsa_port_link_register_of(dp);
if (err) { if (err) {
dev_err(ds->dev, "failed to setup link for port %d.%d\n", dev_err(ds->dev, "failed to setup link for port %d.%d\n",
...@@ -287,13 +303,6 @@ static int dsa_port_setup(struct dsa_port *dp) ...@@ -287,13 +303,6 @@ static int dsa_port_setup(struct dsa_port *dp)
} }
break; break;
case DSA_PORT_TYPE_DSA: case DSA_PORT_TYPE_DSA:
/* dp->index is used now as port_number. However
* DSA ports should have separate numbering
* independent from front panel port numbers.
*/
devlink_port_attrs_set(&dp->devlink_port,
DEVLINK_PORT_FLAVOUR_DSA,
dp->index, false, 0);
err = dsa_port_link_register_of(dp); err = dsa_port_link_register_of(dp);
if (err) { if (err) {
dev_err(ds->dev, "failed to setup link for port %d.%d\n", dev_err(ds->dev, "failed to setup link for port %d.%d\n",
...@@ -302,9 +311,6 @@ static int dsa_port_setup(struct dsa_port *dp) ...@@ -302,9 +311,6 @@ static int dsa_port_setup(struct dsa_port *dp)
} }
break; break;
case DSA_PORT_TYPE_USER: case DSA_PORT_TYPE_USER:
devlink_port_attrs_set(&dp->devlink_port,
DEVLINK_PORT_FLAVOUR_PHYSICAL,
dp->index, false, 0);
err = dsa_slave_create(dp); err = dsa_slave_create(dp);
if (err) if (err)
dev_err(ds->dev, "failed to create slave for port %d.%d\n", dev_err(ds->dev, "failed to create slave for port %d.%d\n",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment