Inter-revision diff: patch 1

Comparing v7 (message) to v4 (message)

--- v7
+++ v4
@@ -1,138 +1,39 @@
-ocelot_mact_learn_streamdata() can be used in VSC9959 to overwrite an
-FDB entry with stream data. The stream data includes SFID and SSID which
-can be used for PSFP and FRER set.
+From: Vladimir Oltean <vladimir.oltean@nxp.com>
 
-ocelot_mact_lookup() can be used to check if the given {DMAC, VID} FDB
-entry is exist, and also can retrieve the DEST_IDX and entry type for
-the FDB entry.
+Felix DSA needs to use this struct to export MAC table write and lookup
+operations as well, for its stream identification functions, so export
+them in preparation of that.
 
+Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
 Signed-off-by: Xiaoliang Yang <xiaoliang.yang_1@nxp.com>
 ---
- drivers/net/ethernet/mscc/ocelot.c | 81 +++++++++++++++++++++++++++---
- drivers/net/ethernet/mscc/ocelot.h | 13 -----
- include/soc/mscc/ocelot.h          | 22 ++++++++
- 3 files changed, 97 insertions(+), 19 deletions(-)
+ drivers/net/ethernet/mscc/ocelot.c |  6 ------
+ drivers/net/ethernet/mscc/ocelot.h | 13 -------------
+ include/soc/mscc/ocelot.h          | 19 +++++++++++++++++++
+ 3 files changed, 19 insertions(+), 19 deletions(-)
 
 diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c
-index e6c18b598d5c..9e981913d6ba 100644
+index c581b955efb3..39a5cee81677 100644
 --- a/drivers/net/ethernet/mscc/ocelot.c
 +++ b/drivers/net/ethernet/mscc/ocelot.c
-@@ -61,9 +61,9 @@ static void ocelot_mact_select(struct ocelot *ocelot,
+@@ -14,12 +14,6 @@
+ #define TABLE_UPDATE_SLEEP_US 10
+ #define TABLE_UPDATE_TIMEOUT_US 100000
  
- }
- 
--int ocelot_mact_learn(struct ocelot *ocelot, int port,
--		      const unsigned char mac[ETH_ALEN],
--		      unsigned int vid, enum macaccess_entry_type type)
-+static int __ocelot_mact_learn(struct ocelot *ocelot, int port,
-+			       const unsigned char mac[ETH_ALEN],
-+			       unsigned int vid, enum macaccess_entry_type type)
+-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)
  {
- 	u32 cmd = ANA_TABLES_MACACCESS_VALID |
- 		ANA_TABLES_MACACCESS_DEST_IDX(port) |
-@@ -83,8 +83,6 @@ int ocelot_mact_learn(struct ocelot *ocelot, int port,
- 	if (mc_ports & BIT(ocelot->num_phys_ports))
- 		cmd |= ANA_TABLES_MACACCESS_MAC_CPU_COPY;
- 
--	mutex_lock(&ocelot->mact_lock);
--
- 	ocelot_mact_select(ocelot, mac, vid);
- 
- 	/* Issue a write command */
-@@ -92,9 +90,20 @@ int ocelot_mact_learn(struct ocelot *ocelot, int port,
- 
- 	err = ocelot_mact_wait_for_completion(ocelot);
- 
-+	return err;
-+}
-+
-+int ocelot_mact_learn(struct ocelot *ocelot, int port,
-+		      const unsigned char mac[ETH_ALEN],
-+		      unsigned int vid, enum macaccess_entry_type type)
-+{
-+	int ret;
-+
-+	mutex_lock(&ocelot->mact_lock);
-+	ret = __ocelot_mact_learn(ocelot, port, mac, vid, type);
- 	mutex_unlock(&ocelot->mact_lock);
- 
--	return err;
-+	return ret;
- }
- EXPORT_SYMBOL(ocelot_mact_learn);
- 
-@@ -120,6 +129,66 @@ int ocelot_mact_forget(struct ocelot *ocelot,
- }
- EXPORT_SYMBOL(ocelot_mact_forget);
- 
-+int ocelot_mact_lookup(struct ocelot *ocelot, int *dst_idx,
-+		       const unsigned char mac[ETH_ALEN],
-+		       unsigned int vid, enum macaccess_entry_type *type)
-+{
-+	int val;
-+
-+	mutex_lock(&ocelot->mact_lock);
-+
-+	ocelot_mact_select(ocelot, mac, vid);
-+
-+	/* Issue a read command with MACACCESS_VALID=1. */
-+	ocelot_write(ocelot, ANA_TABLES_MACACCESS_VALID |
-+		     ANA_TABLES_MACACCESS_MAC_TABLE_CMD(MACACCESS_CMD_READ),
-+		     ANA_TABLES_MACACCESS);
-+
-+	if (ocelot_mact_wait_for_completion(ocelot)) {
-+		mutex_unlock(&ocelot->mact_lock);
-+		return -ETIMEDOUT;
-+	}
-+
-+	/* Read back the entry flags */
-+	val = ocelot_read(ocelot, ANA_TABLES_MACACCESS);
-+
-+	mutex_unlock(&ocelot->mact_lock);
-+
-+	if (!(val & ANA_TABLES_MACACCESS_VALID))
-+		return -ENOENT;
-+
-+	*dst_idx = ANA_TABLES_MACACCESS_DEST_IDX_X(val);
-+	*type = ANA_TABLES_MACACCESS_ENTRYTYPE_X(val);
-+
-+	return 0;
-+}
-+EXPORT_SYMBOL(ocelot_mact_lookup);
-+
-+int ocelot_mact_learn_streamdata(struct ocelot *ocelot, int dst_idx,
-+				 const unsigned char mac[ETH_ALEN],
-+				 unsigned int vid,
-+				 enum macaccess_entry_type type,
-+				 int sfid, int ssid)
-+{
-+	int ret;
-+
-+	mutex_lock(&ocelot->mact_lock);
-+
-+	ocelot_write(ocelot,
-+		     (sfid < 0 ? 0 : ANA_TABLES_STREAMDATA_SFID_VALID) |
-+		     ANA_TABLES_STREAMDATA_SFID(sfid) |
-+		     (ssid < 0 ? 0 : ANA_TABLES_STREAMDATA_SSID_VALID) |
-+		     ANA_TABLES_STREAMDATA_SSID(ssid),
-+		     ANA_TABLES_STREAMDATA);
-+
-+	ret = __ocelot_mact_learn(ocelot, dst_idx, mac, vid, type);
-+
-+	mutex_unlock(&ocelot->mact_lock);
-+
-+	return ret;
-+}
-+EXPORT_SYMBOL(ocelot_mact_learn_streamdata);
-+
- static void ocelot_mact_init(struct ocelot *ocelot)
- {
- 	/* Configure the learning mode entries attributes:
+ 	return ocelot_read(ocelot, ANA_TABLES_MACACCESS);
 diff --git a/drivers/net/ethernet/mscc/ocelot.h b/drivers/net/ethernet/mscc/ocelot.h
-index e43da09b8f91..1eb0b5ad51e9 100644
+index 1952d6a1b98a..a77050b13d18 100644
 --- a/drivers/net/ethernet/mscc/ocelot.h
 +++ b/drivers/net/ethernet/mscc/ocelot.h
-@@ -55,19 +55,6 @@ struct ocelot_dump_ctx {
+@@ -54,19 +54,6 @@ struct ocelot_dump_ctx {
  	int idx;
  };
  
@@ -153,11 +54,11 @@
   * 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 fef3a36b0210..1d5ff11e4100 100644
+index 06706a9fd5b1..32b3c60d6046 100644
 --- a/include/soc/mscc/ocelot.h
 +++ b/include/soc/mscc/ocelot.h
-@@ -593,6 +593,19 @@ enum ocelot_sb_pool {
- 	OCELOT_SB_POOL_NUM,
+@@ -698,6 +698,25 @@ struct ocelot_skb_cb {
+ 	u8 ts_id;
  };
  
 +/* MAC table entry types.
@@ -173,25 +74,15 @@
 +	ENTRYTYPE_MACv6,
 +};
 +
- #define OCELOT_QUIRK_PCS_PERFORMS_RATE_ADAPTATION	BIT(0)
- #define OCELOT_QUIRK_QSGMII_PORTS_MUST_BE_UP		BIT(1)
++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))
  
-@@ -870,6 +883,15 @@ void ocelot_phylink_mac_link_up(struct ocelot *ocelot, int port,
- 				bool tx_pause, bool rx_pause,
- 				unsigned long quirks);
- 
-+int ocelot_mact_lookup(struct ocelot *ocelot, int *dst_idx,
-+		       const unsigned char mac[ETH_ALEN],
-+		       unsigned int vid, enum macaccess_entry_type *type);
-+int ocelot_mact_learn_streamdata(struct ocelot *ocelot, int dst_idx,
-+				 const unsigned char mac[ETH_ALEN],
-+				 unsigned int vid,
-+				 enum macaccess_entry_type type,
-+				 int sfid, int ssid);
-+
- #if IS_ENABLED(CONFIG_BRIDGE_MRP)
- int ocelot_mrp_add(struct ocelot *ocelot, int port,
- 		   const struct switchdev_obj_mrp *mrp);
 -- 
 2.17.1
 
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help