Commit 9c90eea3 authored by Vladimir Oltean's avatar Vladimir Oltean Committed by David S. Miller
Browse files

net: mscc: ocelot: move net_device related functions to ocelot_net.c



The ocelot hardware library shouldn't contain too much net_device
specific code, since it is shared with DSA which abstracts that
structure away. So much as much of this code as possible into the
mscc_ocelot driver and outside of the common library.

We're making an exception for MDB and LAG code. That is not yet exported
to DSA, but when it will, most of the code that's already in ocelot.c
will remain there. So, there's no point in moving code to ocelot_net.c
just to move it back later.

We could have moved all net_device code to ocelot_vsc7514.c directly,
but let's operate under the assumption that if a new switchdev ocelot
driver gets added, it'll define its SoC-specific stuff in a new
ocelot_vsc*.c file and it'll reuse the rest of the code.

Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d9feb904
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -3,10 +3,11 @@ obj-$(CONFIG_MSCC_OCELOT_SWITCH_LIB) += mscc_ocelot_switch_lib.o
mscc_ocelot_switch_lib-y := \
	ocelot.o \
	ocelot_io.o \
	ocelot_tc.o \
	ocelot_police.o \
	ocelot_ace.o \
	ocelot_flower.o \
	ocelot_ptp.o
obj-$(CONFIG_MSCC_OCELOT_SWITCH) += mscc_ocelot.o
mscc_ocelot-y := ocelot_vsc7514.o
mscc_ocelot-y := \
	ocelot_vsc7514.o \
	ocelot_net.o
+23 −886

File changed.

Preview size limit exceeded, changes collapsed.

+44 −1
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@
#include <soc/mscc/ocelot.h>
#include "ocelot_rew.h"
#include "ocelot_qs.h"
#include "ocelot_tc.h"

#define OCELOT_BUFFER_CELL_SZ 60

@@ -49,6 +48,13 @@ struct ocelot_multicast {
	u16 ports;
};

struct ocelot_port_tc {
	bool block_shared;
	unsigned long offload_cnt;

	unsigned long police_id;
};

struct ocelot_port_private {
	struct ocelot_port port;
	struct net_device *dev;
@@ -60,6 +66,43 @@ struct ocelot_port_private {
	struct ocelot_port_tc tc;
};

struct ocelot_dump_ctx {
	struct net_device *dev;
	struct sk_buff *skb;
	struct netlink_callback *cb;
	int idx;
};

/* MAC table entry types.
 * ENTRYTYPE_NORMAL is subject to aging.
 * ENTRYTYPE_LOCKED is not subject to aging.
 * ENTRYTYPE_MACv4 is not subject to aging. For IPv4 multicast.
 * ENTRYTYPE_MACv6 is not subject to aging. For IPv6 multicast.
 */
enum macaccess_entry_type {
	ENTRYTYPE_NORMAL = 0,
	ENTRYTYPE_LOCKED,
	ENTRYTYPE_MACv4,
	ENTRYTYPE_MACv6,
};

int ocelot_port_fdb_do_dump(const unsigned char *addr, u16 vid,
			    bool is_static, void *data);
int ocelot_mact_learn(struct ocelot *ocelot, int port,
		      const unsigned char mac[ETH_ALEN],
		      unsigned int vid, enum macaccess_entry_type type);
int ocelot_mact_forget(struct ocelot *ocelot,
		       const unsigned char mac[ETH_ALEN], unsigned int vid);
int ocelot_port_lag_join(struct ocelot *ocelot, int port,
			 struct net_device *bond);
void ocelot_port_lag_leave(struct ocelot *ocelot, int port,
			   struct net_device *bond);
int ocelot_port_obj_del_mdb(struct net_device *dev,
			    const struct switchdev_obj_port_mdb *mdb);
int ocelot_port_obj_add_mdb(struct net_device *dev,
			    const struct switchdev_obj_port_mdb *mdb,
			    struct switchdev_trans *trans);

u32 ocelot_port_readl(struct ocelot_port *port, u32 reg);
void ocelot_port_writel(struct ocelot_port *port, u32 val, u32 reg);

+24 −0
Original line number Diff line number Diff line
@@ -843,6 +843,30 @@ int ocelot_ace_rule_offload_add(struct ocelot *ocelot,
	return 0;
}

int ocelot_ace_policer_add(struct ocelot *ocelot, u32 pol_ix,
			   struct ocelot_policer *pol)
{
	struct qos_policer_conf pp = { 0 };

	if (!pol)
		return -EINVAL;

	pp.mode = MSCC_QOS_RATE_MODE_DATA;
	pp.pir = pol->rate;
	pp.pbs = pol->burst;

	return qos_policer_conf_set(ocelot, 0, pol_ix, &pp);
}

int ocelot_ace_policer_del(struct ocelot *ocelot, u32 pol_ix)
{
	struct qos_policer_conf pp = { 0 };

	pp.mode = MSCC_QOS_RATE_MODE_DISABLED;

	return qos_policer_conf_set(ocelot, 0, pol_ix, &pp);
}

static void ocelot_ace_police_del(struct ocelot *ocelot,
				  struct ocelot_acl_block *block,
				  u32 ix)
+0 −22
Original line number Diff line number Diff line
@@ -249,25 +249,3 @@ int ocelot_cls_flower_stats(struct ocelot *ocelot, int port,
	return 0;
}
EXPORT_SYMBOL_GPL(ocelot_cls_flower_stats);

int ocelot_setup_tc_cls_flower(struct ocelot_port_private *priv,
			       struct flow_cls_offload *f,
			       bool ingress)
{
	struct ocelot *ocelot = priv->port.ocelot;
	int port = priv->chip_port;

	if (!ingress)
		return -EOPNOTSUPP;

	switch (f->command) {
	case FLOW_CLS_REPLACE:
		return ocelot_cls_flower_replace(ocelot, port, f, ingress);
	case FLOW_CLS_DESTROY:
		return ocelot_cls_flower_destroy(ocelot, port, f, ingress);
	case FLOW_CLS_STATS:
		return ocelot_cls_flower_stats(ocelot, port, f, ingress);
	default:
		return -EOPNOTSUPP;
	}
}
Loading