net: dsa: sja1105: unconditionally set DESTMETA and SRCMETA in AVB table
authorVladimir Oltean <vladimir.oltean@nxp.com>
Mon, 23 Mar 2020 22:59:21 +0000 (00:59 +0200)
committerDavid S. Miller <davem@davemloft.net>
Tue, 24 Mar 2020 05:15:07 +0000 (22:15 -0700)
These fields configure the destination and source MAC address that the
switch will put in the Ethernet frames sent towards the CPU port that
contain RX timestamps for PTP.

These fields do not enable the feature itself, that is configured via
SEND_META0 and SEND_META1 in the General Params table.

The implication of this patch is that the AVB Params table will always
be present in the static config. Which doesn't really hurt.

This is needed because in a future patch, we will add another field from
this table, CAS_MASTER, for configuring the PTP_CLK pin function. That
can be configured irrespective of whether RX timestamping is enabled or
not, so always having this table present is going to simplify things a
bit.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/sja1105/sja1105_main.c
drivers/net/dsa/sja1105/sja1105_ptp.c

index afafe2ecf248c05e17fff521e9e67574d357a599..4d182293ca1fa82b26e479652b9f91329ec9d007 100644 (file)
@@ -479,6 +479,35 @@ static int sja1105_init_general_params(struct sja1105_private *priv)
        return 0;
 }
 
+static int sja1105_init_avb_params(struct sja1105_private *priv)
+{
+       struct sja1105_avb_params_entry *avb;
+       struct sja1105_table *table;
+
+       table = &priv->static_config.tables[BLK_IDX_AVB_PARAMS];
+
+       /* Discard previous AVB Parameters Table */
+       if (table->entry_count) {
+               kfree(table->entries);
+               table->entry_count = 0;
+       }
+
+       table->entries = kcalloc(SJA1105_MAX_AVB_PARAMS_COUNT,
+                                table->ops->unpacked_entry_size, GFP_KERNEL);
+       if (!table->entries)
+               return -ENOMEM;
+
+       table->entry_count = SJA1105_MAX_AVB_PARAMS_COUNT;
+
+       avb = table->entries;
+
+       /* Configure the MAC addresses for meta frames */
+       avb->destmeta = SJA1105_META_DMAC;
+       avb->srcmeta  = SJA1105_META_SMAC;
+
+       return 0;
+}
+
 #define SJA1105_RATE_MBPS(speed) (((speed) * 64000) / 1000)
 
 static void sja1105_setup_policer(struct sja1105_l2_policing_entry *policing,
@@ -567,6 +596,9 @@ static int sja1105_static_config_load(struct sja1105_private *priv,
        if (rc < 0)
                return rc;
        rc = sja1105_init_general_params(priv);
+       if (rc < 0)
+               return rc;
+       rc = sja1105_init_avb_params(priv);
        if (rc < 0)
                return rc;
 
index a836fc38c4a4db6a416c58c7326b81ec09aff740..a07aaf55068f9e9e20f06e437c3f65824c356d9a 100644 (file)
@@ -44,39 +44,6 @@ enum sja1105_ptp_clk_mode {
 #define ptp_data_to_sja1105(d) \
                container_of((d), struct sja1105_private, ptp_data)
 
-static int sja1105_init_avb_params(struct sja1105_private *priv,
-                                  bool on)
-{
-       struct sja1105_avb_params_entry *avb;
-       struct sja1105_table *table;
-
-       table = &priv->static_config.tables[BLK_IDX_AVB_PARAMS];
-
-       /* Discard previous AVB Parameters Table */
-       if (table->entry_count) {
-               kfree(table->entries);
-               table->entry_count = 0;
-       }
-
-       /* Configure the reception of meta frames only if requested */
-       if (!on)
-               return 0;
-
-       table->entries = kcalloc(SJA1105_MAX_AVB_PARAMS_COUNT,
-                                table->ops->unpacked_entry_size, GFP_KERNEL);
-       if (!table->entries)
-               return -ENOMEM;
-
-       table->entry_count = SJA1105_MAX_AVB_PARAMS_COUNT;
-
-       avb = table->entries;
-
-       avb->destmeta = SJA1105_META_DMAC;
-       avb->srcmeta  = SJA1105_META_SMAC;
-
-       return 0;
-}
-
 /* Must be called only with priv->tagger_data.state bit
  * SJA1105_HWTS_RX_EN cleared
  */
@@ -86,17 +53,12 @@ static int sja1105_change_rxtstamping(struct sja1105_private *priv,
        struct sja1105_ptp_data *ptp_data = &priv->ptp_data;
        struct sja1105_general_params_entry *general_params;
        struct sja1105_table *table;
-       int rc;
 
        table = &priv->static_config.tables[BLK_IDX_GENERAL_PARAMS];
        general_params = table->entries;
        general_params->send_meta1 = on;
        general_params->send_meta0 = on;
 
-       rc = sja1105_init_avb_params(priv, on);
-       if (rc < 0)
-               return rc;
-
        /* Initialize the meta state machine to a known state */
        if (priv->tagger_data.stampable_skb) {
                kfree_skb(priv->tagger_data.stampable_skb);