2021-08-18 06:11:34

by Xiaoliang Yang

[permalink] [raw]
Subject: [RFC v2 net-next 2/8] net: mscc: ocelot: export MAC table lookup and write

Felix DSA needs to use these operations as well, for its stream
identification functions, so export them in preparation of that.

Signed-off-by: Vladimir Oltean <[email protected]>
Signed-off-by: Xiaoliang Yang <[email protected]>
---
drivers/net/ethernet/mscc/ocelot.c | 6 ------
drivers/net/ethernet/mscc/ocelot.h | 13 -------------
include/soc/mscc/ocelot.h | 24 ++++++++++++++++++++++++
3 files changed, 24 insertions(+), 19 deletions(-)

diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c
index 0241272e9ce9..fe6378ecb66d 100644
--- a/drivers/net/ethernet/mscc/ocelot.c
+++ b/drivers/net/ethernet/mscc/ocelot.c
@@ -14,12 +14,6 @@
#define TABLE_UPDATE_SLEEP_US 10
#define TABLE_UPDATE_TIMEOUT_US 100000

-struct ocelot_mact_entry {
- u8 mac[ETH_ALEN];
- u16 vid;
- enum macaccess_entry_type type;
-};
-
static inline u32 ocelot_mact_read_macaccess(struct ocelot *ocelot)
{
return ocelot_read(ocelot, ANA_TABLES_MACACCESS);
diff --git a/drivers/net/ethernet/mscc/ocelot.h b/drivers/net/ethernet/mscc/ocelot.h
index db6b1a4c3926..24a676b5abd6 100644
--- a/drivers/net/ethernet/mscc/ocelot.h
+++ b/drivers/net/ethernet/mscc/ocelot.h
@@ -57,19 +57,6 @@ struct ocelot_dump_ctx {
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,
-};
-
/* A (PGID) port mask structure, encoding the 2^ocelot->num_phys_ports
* possibilities of egress port masks for L2 multicast traffic.
* For a switch with 9 user ports, there are 512 possible port masks, but the
diff --git a/include/soc/mscc/ocelot.h b/include/soc/mscc/ocelot.h
index 2f5ce4d4fdbf..1bbba424c189 100644
--- a/include/soc/mscc/ocelot.h
+++ b/include/soc/mscc/ocelot.h
@@ -695,6 +695,25 @@ struct ocelot_skb_cb {
u8 ts_id;
};

+/* 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,
+};
+
+struct ocelot_mact_entry {
+ u8 mac[ETH_ALEN];
+ u16 vid;
+ enum macaccess_entry_type type;
+};
+
#define OCELOT_SKB_CB(skb) \
((struct ocelot_skb_cb *)((skb)->cb))

@@ -893,6 +912,11 @@ int ocelot_sb_occ_tc_port_bind_get(struct ocelot *ocelot, int port,
unsigned int sb_index, u16 tc_index,
enum devlink_sb_pool_type pool_type,
u32 *p_cur, u32 *p_max);
+int ocelot_mact_lookup(struct ocelot *ocelot, const unsigned char mac[ETH_ALEN],
+ unsigned int vid, int *row, int *col);
+void ocelot_mact_write(struct ocelot *ocelot, int port,
+ const struct ocelot_mact_entry *entry,
+ int row, int col);

#if IS_ENABLED(CONFIG_BRIDGE_MRP)
int ocelot_mrp_add(struct ocelot *ocelot, int port,
--
2.17.1


2021-08-18 14:09:08

by Vladimir Oltean

[permalink] [raw]
Subject: Re: [RFC v2 net-next 2/8] net: mscc: ocelot: export MAC table lookup and write

On Wed, Aug 18, 2021 at 02:19:16PM +0800, Xiaoliang Yang wrote:
> Felix DSA needs to use these operations as well, for its stream
> identification functions, so export them in preparation of that.
>
> Signed-off-by: Vladimir Oltean <[email protected]>
> Signed-off-by: Xiaoliang Yang <[email protected]>
> ---

So maybe reorder the patches, first export struct ocelot_mact_entry and
enum macaccess_entry_type, then introduce the ocelot_mact_lookup and
ocelot_mact_write functions directly as exported?

2021-08-18 14:10:49

by Vladimir Oltean

[permalink] [raw]
Subject: Re: [RFC v2 net-next 2/8] net: mscc: ocelot: export MAC table lookup and write

On Wed, Aug 18, 2021 at 02:19:16PM +0800, Xiaoliang Yang wrote:
> Felix DSA needs to use these operations as well, for its stream
> identification functions, so export them in preparation of that.
>
> Signed-off-by: Vladimir Oltean <[email protected]>
> Signed-off-by: Xiaoliang Yang <[email protected]>
> ---

Also, this patch misses a tag:

From: Vladimir Oltean <[email protected]>

The first sign-off is also the patch author.