Commit 2cebaecb authored by David S. Miller's avatar David S. Miller

Merge branch 'dsa-devlink'

Andrew Lunn says:

====================
break include loop and dsa devlink support

These two patches add very basic support for devlink to DSA, in
preparation for playing with dpipe.

The first patch is needed to break an include loop between
netdevice.h, dsa.h and devlink.h. We need to remove dsa.h from
netdevice.h. As a result, some files fail to compile, because they
require includes pulled in via dsa.h. So this patch adds a number of
includes in various places. The majority is within the network
subsystem, but cifs also needs a few fixes.

0-day has been chewing on this for over a day now, and not found any
breakage. But Arnd's randconfig might uncover something.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 0e42c721 96567d5d
...@@ -10,10 +10,11 @@ ...@@ -10,10 +10,11 @@
*/ */
#include <linux/list.h> #include <linux/list.h>
#include <net/dsa.h>
#include <linux/ethtool.h> #include <linux/ethtool.h>
#include <linux/if_ether.h> #include <linux/if_ether.h>
#include <linux/in.h> #include <linux/in.h>
#include <linux/netdevice.h>
#include <net/dsa.h>
#include <linux/bitmap.h> #include <linux/bitmap.h>
#include "bcm_sf2.h" #include "bcm_sf2.h"
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/gpio/consumer.h> #include <linux/gpio/consumer.h>
#include <linux/phy.h> #include <linux/phy.h>
#include <net/dsa.h>
#ifndef UINT64_MAX #ifndef UINT64_MAX
#define UINT64_MAX (u64)(~((u64)0)) #define UINT64_MAX (u64)(~((u64)0))
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <linux/of_mdio.h> #include <linux/of_mdio.h>
#include <linux/phy.h> #include <linux/phy.h>
#include <linux/phy_fixed.h> #include <linux/phy_fixed.h>
#include <net/dsa.h>
#include <net/ip.h> #include <net/ip.h>
#include <net/ipv6.h> #include <net/ipv6.h>
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include "fman_mac.h" #include "fman_mac.h"
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/phy_fixed.h>
struct fman_mac *memac_config(struct fman_mac_params *params); struct fman_mac *memac_config(struct fman_mac_params *params);
int memac_set_promiscuous(struct fman_mac *memac, bool new_val); int memac_set_promiscuous(struct fman_mac *memac, bool new_val);
......
...@@ -9,9 +9,9 @@ ...@@ -9,9 +9,9 @@
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/of.h>
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <linux/slab.h> #include <linux/slab.h>
#include "hnae.h" #include "hnae.h"
#define cls_to_ae_dev(dev) container_of(dev, struct hnae_ae_dev, cls_dev) #define cls_to_ae_dev(dev) container_of(dev, struct hnae_ae_dev, cls_dev)
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/of.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/ieee802154.h> #include <linux/ieee802154.h>
#include <linux/irq.h> #include <linux/irq.h>
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/mii.h> #include <linux/mii.h>
#include <linux/ethtool.h> #include <linux/ethtool.h>
#include <linux/of.h>
#include <linux/phy.h> #include <linux/phy.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/smscphy.h> #include <linux/smscphy.h>
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <linux/ip.h> #include <linux/ip.h>
#include <linux/ipv6.h> #include <linux/ipv6.h>
#include <linux/mdio.h> #include <linux/mdio.h>
#include <linux/phy.h>
#include <net/ip6_checksum.h> #include <net/ip6_checksum.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/irqdomain.h> #include <linux/irqdomain.h>
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include <linux/freezer.h> #include <linux/freezer.h>
#include <linux/namei.h> #include <linux/namei.h>
#include <linux/random.h> #include <linux/random.h>
#include <linux/uuid.h>
#include <linux/xattr.h> #include <linux/xattr.h>
#include <net/ipv6.h> #include <net/ipv6.h>
#include "cifsfs.h" #include "cifsfs.h"
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include <linux/pagevec.h> #include <linux/pagevec.h>
#include <linux/freezer.h> #include <linux/freezer.h>
#include <linux/namei.h> #include <linux/namei.h>
#include <linux/uuid.h>
#include <linux/uaccess.h> #include <linux/uaccess.h>
#include <asm/processor.h> #include <asm/processor.h>
#include <linux/inet.h> #include <linux/inet.h>
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <linux/vfs.h> #include <linux/vfs.h>
#include <linux/task_io_accounting_ops.h> #include <linux/task_io_accounting_ops.h>
#include <linux/uaccess.h> #include <linux/uaccess.h>
#include <linux/uuid.h>
#include <linux/pagemap.h> #include <linux/pagemap.h>
#include <linux/xattr.h> #include <linux/xattr.h>
#include "smb2pdu.h" #include "smb2pdu.h"
......
...@@ -41,7 +41,6 @@ ...@@ -41,7 +41,6 @@
#include <linux/ethtool.h> #include <linux/ethtool.h>
#include <net/net_namespace.h> #include <net/net_namespace.h>
#include <net/dsa.h>
#ifdef CONFIG_DCB #ifdef CONFIG_DCB
#include <net/dcbnl.h> #include <net/dcbnl.h>
#endif #endif
...@@ -57,6 +56,8 @@ ...@@ -57,6 +56,8 @@
struct netpoll_info; struct netpoll_info;
struct device; struct device;
struct phy_device; struct phy_device;
struct dsa_switch_tree;
/* 802.11 specific */ /* 802.11 specific */
struct wireless_dev; struct wireless_dev;
/* 802.15.4 specific */ /* 802.15.4 specific */
...@@ -2004,15 +2005,6 @@ void dev_net_set(struct net_device *dev, struct net *net) ...@@ -2004,15 +2005,6 @@ void dev_net_set(struct net_device *dev, struct net *net)
write_pnet(&dev->nd_net, net); write_pnet(&dev->nd_net, net);
} }
static inline bool netdev_uses_dsa(struct net_device *dev)
{
#if IS_ENABLED(CONFIG_NET_DSA)
if (dev->dsa_ptr != NULL)
return dsa_uses_tagged_protocol(dev->dsa_ptr);
#endif
return false;
}
/** /**
* netdev_priv - access network device private data * netdev_priv - access network device private data
* @dev: network device * @dev: network device
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/ethtool.h> #include <linux/ethtool.h>
#include <net/devlink.h>
struct tc_action; struct tc_action;
struct phy_device; struct phy_device;
...@@ -182,6 +183,7 @@ struct dsa_port { ...@@ -182,6 +183,7 @@ struct dsa_port {
unsigned int ageing_time; unsigned int ageing_time;
u8 stp_state; u8 stp_state;
struct net_device *bridge_dev; struct net_device *bridge_dev;
struct devlink_port devlink_port;
}; };
struct dsa_switch { struct dsa_switch {
...@@ -237,6 +239,9 @@ struct dsa_switch { ...@@ -237,6 +239,9 @@ struct dsa_switch {
unsigned int ageing_time_min; unsigned int ageing_time_min;
unsigned int ageing_time_max; unsigned int ageing_time_max;
/* devlink used to represent this switch device */
struct devlink *devlink;
/* Dynamically allocated ports, keep last */ /* Dynamically allocated ports, keep last */
size_t num_ports; size_t num_ports;
struct dsa_port ports[]; struct dsa_port ports[];
...@@ -468,6 +473,15 @@ static inline bool dsa_uses_tagged_protocol(struct dsa_switch_tree *dst) ...@@ -468,6 +473,15 @@ static inline bool dsa_uses_tagged_protocol(struct dsa_switch_tree *dst)
return dst->rcv != NULL; return dst->rcv != NULL;
} }
static inline bool netdev_uses_dsa(struct net_device *dev)
{
#if IS_ENABLED(CONFIG_NET_DSA)
if (dev->dsa_ptr != NULL)
return dsa_uses_tagged_protocol(dev->dsa_ptr);
#endif
return false;
}
struct dsa_switch *dsa_switch_alloc(struct device *dev, size_t n); struct dsa_switch *dsa_switch_alloc(struct device *dev, size_t n);
void dsa_unregister_switch(struct dsa_switch *ds); void dsa_unregister_switch(struct dsa_switch *ds);
int dsa_register_switch(struct dsa_switch *ds, struct device *dev); int dsa_register_switch(struct dsa_switch *ds, struct device *dev);
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <linux/rtnetlink.h> #include <linux/rtnetlink.h>
#include <linux/if_ether.h> #include <linux/if_ether.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <net/dsa.h>
#include <net/sock.h> #include <net/sock.h>
#include <linux/if_vlan.h> #include <linux/if_vlan.h>
#include <net/switchdev.h> #include <net/switchdev.h>
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/module.h> #include <linux/module.h>
......
...@@ -14,15 +14,16 @@ ...@@ -14,15 +14,16 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/module.h> #include <linux/module.h>
#include <net/dsa.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_mdio.h> #include <linux/of_mdio.h>
#include <linux/of_platform.h> #include <linux/of_platform.h>
#include <linux/of_net.h> #include <linux/of_net.h>
#include <linux/of_gpio.h> #include <linux/of_gpio.h>
#include <linux/netdevice.h>
#include <linux/sysfs.h> #include <linux/sysfs.h>
#include <linux/phy_fixed.h> #include <linux/phy_fixed.h>
#include <linux/gpio/consumer.h> #include <linux/gpio/consumer.h>
#include <net/dsa.h>
#include "dsa_priv.h" #include "dsa_priv.h"
static struct sk_buff *dsa_slave_notag_xmit(struct sk_buff *skb, static struct sk_buff *dsa_slave_notag_xmit(struct sk_buff *skb,
......
...@@ -13,16 +13,20 @@ ...@@ -13,16 +13,20 @@
#include <linux/device.h> #include <linux/device.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/netdevice.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/rtnetlink.h> #include <linux/rtnetlink.h>
#include <net/dsa.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_net.h> #include <linux/of_net.h>
#include <net/dsa.h>
#include "dsa_priv.h" #include "dsa_priv.h"
static LIST_HEAD(dsa_switch_trees); static LIST_HEAD(dsa_switch_trees);
static DEFINE_MUTEX(dsa2_mutex); static DEFINE_MUTEX(dsa2_mutex);
static const struct devlink_ops dsa_devlink_ops = {
};
static struct dsa_switch_tree *dsa_get_dst(u32 tree) static struct dsa_switch_tree *dsa_get_dst(u32 tree)
{ {
struct dsa_switch_tree *dst; struct dsa_switch_tree *dst;
...@@ -222,12 +226,18 @@ static int dsa_dsa_port_apply(struct dsa_port *port, u32 index, ...@@ -222,12 +226,18 @@ static int dsa_dsa_port_apply(struct dsa_port *port, u32 index,
return err; return err;
} }
return 0; memset(&ds->ports[index].devlink_port, 0,
sizeof(ds->ports[index].devlink_port));
return devlink_port_register(ds->devlink,
&ds->ports[index].devlink_port,
index);
} }
static void dsa_dsa_port_unapply(struct dsa_port *port, u32 index, static void dsa_dsa_port_unapply(struct dsa_port *port, u32 index,
struct dsa_switch *ds) struct dsa_switch *ds)
{ {
devlink_port_unregister(&ds->ports[index].devlink_port);
dsa_cpu_dsa_destroy(port); dsa_cpu_dsa_destroy(port);
} }
...@@ -245,12 +255,17 @@ static int dsa_cpu_port_apply(struct dsa_port *port, u32 index, ...@@ -245,12 +255,17 @@ static int dsa_cpu_port_apply(struct dsa_port *port, u32 index,
ds->cpu_port_mask |= BIT(index); ds->cpu_port_mask |= BIT(index);
return 0; memset(&ds->ports[index].devlink_port, 0,
sizeof(ds->ports[index].devlink_port));
err = devlink_port_register(ds->devlink, &ds->ports[index].devlink_port,
index);
return err;
} }
static void dsa_cpu_port_unapply(struct dsa_port *port, u32 index, static void dsa_cpu_port_unapply(struct dsa_port *port, u32 index,
struct dsa_switch *ds) struct dsa_switch *ds)
{ {
devlink_port_unregister(&ds->ports[index].devlink_port);
dsa_cpu_dsa_destroy(port); dsa_cpu_dsa_destroy(port);
ds->cpu_port_mask &= ~BIT(index); ds->cpu_port_mask &= ~BIT(index);
...@@ -275,12 +290,23 @@ static int dsa_user_port_apply(struct dsa_port *port, u32 index, ...@@ -275,12 +290,23 @@ static int dsa_user_port_apply(struct dsa_port *port, u32 index,
return err; return err;
} }
memset(&ds->ports[index].devlink_port, 0,
sizeof(ds->ports[index].devlink_port));
err = devlink_port_register(ds->devlink, &ds->ports[index].devlink_port,
index);
if (err)
return err;
devlink_port_type_eth_set(&ds->ports[index].devlink_port,
ds->ports[index].netdev);
return 0; return 0;
} }
static void dsa_user_port_unapply(struct dsa_port *port, u32 index, static void dsa_user_port_unapply(struct dsa_port *port, u32 index,
struct dsa_switch *ds) struct dsa_switch *ds)
{ {
devlink_port_unregister(&ds->ports[index].devlink_port);
if (ds->ports[index].netdev) { if (ds->ports[index].netdev) {
dsa_slave_destroy(ds->ports[index].netdev); dsa_slave_destroy(ds->ports[index].netdev);
ds->ports[index].netdev = NULL; ds->ports[index].netdev = NULL;
...@@ -301,6 +327,17 @@ static int dsa_ds_apply(struct dsa_switch_tree *dst, struct dsa_switch *ds) ...@@ -301,6 +327,17 @@ static int dsa_ds_apply(struct dsa_switch_tree *dst, struct dsa_switch *ds)
*/ */
ds->phys_mii_mask = ds->enabled_port_mask; ds->phys_mii_mask = ds->enabled_port_mask;
/* Add the switch to devlink before calling setup, so that setup can
* add dpipe tables
*/
ds->devlink = devlink_alloc(&dsa_devlink_ops, 0);
if (!ds->devlink)
return -ENOMEM;
err = devlink_register(ds->devlink, ds->dev);
if (err)
return err;
err = ds->ops->setup(ds); err = ds->ops->setup(ds);
if (err < 0) if (err < 0)
return err; return err;
...@@ -381,6 +418,13 @@ static void dsa_ds_unapply(struct dsa_switch_tree *dst, struct dsa_switch *ds) ...@@ -381,6 +418,13 @@ static void dsa_ds_unapply(struct dsa_switch_tree *dst, struct dsa_switch *ds)
mdiobus_unregister(ds->slave_mii_bus); mdiobus_unregister(ds->slave_mii_bus);
dsa_switch_unregister_notifier(ds); dsa_switch_unregister_notifier(ds);
if (ds->devlink) {
devlink_unregister(ds->devlink);
devlink_free(ds->devlink);
ds->devlink = NULL;
}
} }
static int dsa_dst_apply(struct dsa_switch_tree *dst) static int dsa_dst_apply(struct dsa_switch_tree *dst)
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <linux/of_mdio.h> #include <linux/of_mdio.h>
#include <linux/mdio.h> #include <linux/mdio.h>
#include <linux/list.h> #include <linux/list.h>
#include <net/dsa.h>
#include <net/rtnetlink.h> #include <net/rtnetlink.h>
#include <net/switchdev.h> #include <net/switchdev.h>
#include <net/pkt_cls.h> #include <net/pkt_cls.h>
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <net/dsa.h>
#include "dsa_priv.h" #include "dsa_priv.h"
/* This tag length is 4 bytes, older ones were 6 bytes, we do not /* This tag length is 4 bytes, older ones were 6 bytes, we do not
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <net/dsa.h>
#include "dsa_priv.h" #include "dsa_priv.h"
#define DSA_HLEN 4 #define DSA_HLEN 4
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <net/dsa.h>
#include "dsa_priv.h" #include "dsa_priv.h"
#define DSA_HLEN 4 #define DSA_HLEN 4
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
*/ */
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include <net/dsa.h>
#include "dsa_priv.h" #include "dsa_priv.h"
#define QCA_HDR_LEN 2 #define QCA_HDR_LEN 2
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <net/dsa.h>
#include "dsa_priv.h" #include "dsa_priv.h"
static struct sk_buff *trailer_xmit(struct sk_buff *skb, struct net_device *dev) static struct sk_buff *trailer_xmit(struct sk_buff *skb, struct net_device *dev)
......
...@@ -57,6 +57,7 @@ ...@@ -57,6 +57,7 @@
#include <linux/export.h> #include <linux/export.h>
#include <net/net_namespace.h> #include <net/net_namespace.h>
#include <net/arp.h> #include <net/arp.h>
#include <net/dsa.h>
#include <net/ip.h> #include <net/ip.h>
#include <net/ipconfig.h> #include <net/ipconfig.h>
#include <net/route.h> #include <net/route.h>
......
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