Commit d8f375ea authored by David S. Miller's avatar David S. Miller

Merge branch 'net-dsa-loop-Preparatory-changes-for-802-1Q-data-path'

net: dsa: loop: Preparatory changes for 802.1Q data path
Florian Fainelli says:

====================
These patches are all meant to help pave the way for a 802.1Q data path
added to the mockup driver, making it more useful than just testing for
configuration. Sending those out now since there is no real need to
wait.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 59b328cf 947b6ef9
......@@ -14,28 +14,11 @@
#include <linux/workqueue.h>
#include <linux/module.h>
#include <linux/if_bridge.h>
#include <linux/dsa/loop.h>
#include <net/dsa.h>
#include "dsa_loop.h"
struct dsa_loop_vlan {
u16 members;
u16 untagged;
};
struct dsa_loop_mib_entry {
char name[ETH_GSTRING_LEN];
unsigned long val;
};
enum dsa_loop_mib_counters {
DSA_LOOP_PHY_READ_OK,
DSA_LOOP_PHY_READ_ERR,
DSA_LOOP_PHY_WRITE_OK,
DSA_LOOP_PHY_WRITE_ERR,
__DSA_LOOP_CNT_MAX,
};
static struct dsa_loop_mib_entry dsa_loop_mibs[] = {
[DSA_LOOP_PHY_READ_OK] = { "phy_read_ok", },
[DSA_LOOP_PHY_READ_ERR] = { "phy_read_err", },
......@@ -43,21 +26,6 @@ static struct dsa_loop_mib_entry dsa_loop_mibs[] = {
[DSA_LOOP_PHY_WRITE_ERR] = { "phy_write_err", },
};
struct dsa_loop_port {
struct dsa_loop_mib_entry mib[__DSA_LOOP_CNT_MAX];
};
#define DSA_LOOP_VLANS 5
struct dsa_loop_priv {
struct mii_bus *bus;
unsigned int port_base;
struct dsa_loop_vlan vlans[DSA_LOOP_VLANS];
struct net_device *netdev;
struct dsa_loop_port ports[DSA_MAX_PORTS];
u16 pvid;
};
static struct phy_device *phydevs[PHY_MAX_ADDR];
static enum dsa_tag_protocol dsa_loop_get_protocol(struct dsa_switch *ds,
......@@ -191,7 +159,7 @@ dsa_loop_port_vlan_prepare(struct dsa_switch *ds, int port,
/* Just do a sleeping operation to make lockdep checks effective */
mdiobus_read(bus, ps->port_base + port, MII_BMSR);
if (vlan->vid_end > DSA_LOOP_VLANS)
if (vlan->vid_end > ARRAY_SIZE(ps->vlans))
return -ERANGE;
return 0;
......@@ -224,7 +192,7 @@ static void dsa_loop_port_vlan_add(struct dsa_switch *ds, int port,
}
if (pvid)
ps->pvid = vid;
ps->ports[port].pvid = vid;
}
static int dsa_loop_port_vlan_del(struct dsa_switch *ds, int port,
......@@ -234,7 +202,7 @@ static int dsa_loop_port_vlan_del(struct dsa_switch *ds, int port,
struct dsa_loop_priv *ps = ds->priv;
struct mii_bus *bus = ps->bus;
struct dsa_loop_vlan *vl;
u16 vid, pvid = ps->pvid;
u16 vid, pvid = ps->ports[port].pvid;
/* Just do a sleeping operation to make lockdep checks effective */
mdiobus_read(bus, ps->port_base + port, MII_BMSR);
......@@ -252,11 +220,26 @@ static int dsa_loop_port_vlan_del(struct dsa_switch *ds, int port,
dev_dbg(ds->dev, "%s: port: %d vlan: %d, %stagged, pvid: %d\n",
__func__, port, vid, untagged ? "un" : "", pvid);
}
ps->pvid = pvid;
ps->ports[port].pvid = pvid;
return 0;
}
static int dsa_loop_port_change_mtu(struct dsa_switch *ds, int port,
int new_mtu)
{
struct dsa_loop_priv *priv = ds->priv;
priv->ports[port].mtu = new_mtu;
return 0;
}
static int dsa_loop_port_max_mtu(struct dsa_switch *ds, int port)
{
return ETH_MAX_MTU;
}
static const struct dsa_switch_ops dsa_loop_driver = {
.get_tag_protocol = dsa_loop_get_protocol,
.setup = dsa_loop_setup,
......@@ -273,6 +256,8 @@ static const struct dsa_switch_ops dsa_loop_driver = {
.port_vlan_prepare = dsa_loop_port_vlan_prepare,
.port_vlan_add = dsa_loop_port_vlan_add,
.port_vlan_del = dsa_loop_port_vlan_del,
.port_change_mtu = dsa_loop_port_change_mtu,
.port_max_mtu = dsa_loop_port_max_mtu,
};
static int dsa_loop_drv_probe(struct mdio_device *mdiodev)
......@@ -290,7 +275,7 @@ static int dsa_loop_drv_probe(struct mdio_device *mdiodev)
return -ENOMEM;
ds->dev = &mdiodev->dev;
ds->num_ports = DSA_MAX_PORTS;
ds->num_ports = DSA_LOOP_NUM_PORTS;
ps = devm_kzalloc(&mdiodev->dev, sizeof(*ps), GFP_KERNEL);
if (!ps)
......
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef DSA_LOOP_H
#define DSA_LOOP_H
#include <linux/types.h>
#include <linux/ethtool.h>
#include <net/dsa.h>
struct dsa_loop_vlan {
u16 members;
u16 untagged;
};
struct dsa_loop_mib_entry {
char name[ETH_GSTRING_LEN];
unsigned long val;
};
enum dsa_loop_mib_counters {
DSA_LOOP_PHY_READ_OK,
DSA_LOOP_PHY_READ_ERR,
DSA_LOOP_PHY_WRITE_OK,
DSA_LOOP_PHY_WRITE_ERR,
__DSA_LOOP_CNT_MAX,
};
struct dsa_loop_port {
struct dsa_loop_mib_entry mib[__DSA_LOOP_CNT_MAX];
u16 pvid;
int mtu;
};
struct dsa_loop_priv {
struct mii_bus *bus;
unsigned int port_base;
struct dsa_loop_vlan vlans[VLAN_N_VID];
struct net_device *netdev;
struct dsa_loop_port ports[DSA_MAX_PORTS];
};
#endif /* DSA_LOOP_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