* [PATCH net 0/2] Fix mangled link-local MAC DAs with SJA1105 DSA
@ 2023-06-29 14:14 Vladimir Oltean
2023-06-29 14:14 ` [PATCH net 1/2] net: dsa: tag_sja1105: fix MAC DA patching from meta frames Vladimir Oltean
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Vladimir Oltean @ 2023-06-29 14:14 UTC (permalink / raw)
To: netdev
Cc: Andrew Lunn, Florian Fainelli, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, linux-kernel
The SJA1105 hardware tagging protocol is weird and will put DSA
information (source port, switch ID) in the MAC DA of the packets sent
to the CPU, and then send some additional (meta) packets which contain
the original bytes from the previous packet's MAC DA.
The tagging protocol driver contains logic to handle this, but the meta
frames are optional functionality, and there are configurations when
they aren't received (no PTP RX timestamping). Thus, the MAC DA from
packets sent to the stack is not correct in all cases.
Also, during testing it was found that the MAC DA patching procedure was
incorrect.
The investigation comes as a result of this discussion with Paolo:
https://lore.kernel.org/netdev/f494387c8d55d9b1d5a3e88beedeeb448f2e6cc3.camel@redhat.com/
Vladimir Oltean (2):
net: dsa: tag_sja1105: fix MAC DA patching from meta frames
net: dsa: sja1105: always enable the send_meta options
drivers/net/dsa/sja1105/sja1105.h | 2 +-
drivers/net/dsa/sja1105/sja1105_main.c | 5 ++-
drivers/net/dsa/sja1105/sja1105_ptp.c | 48 +++----------------------
include/linux/dsa/sja1105.h | 4 ---
net/dsa/tag_sja1105.c | 49 ++------------------------
5 files changed, 9 insertions(+), 99 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH net 1/2] net: dsa: tag_sja1105: fix MAC DA patching from meta frames
2023-06-29 14:14 [PATCH net 0/2] Fix mangled link-local MAC DAs with SJA1105 DSA Vladimir Oltean
@ 2023-06-29 14:14 ` Vladimir Oltean
2023-06-30 13:29 ` Simon Horman
2023-07-02 14:37 ` Florian Fainelli
2023-06-29 14:14 ` [PATCH net 2/2] net: dsa: sja1105: always enable the send_meta options Vladimir Oltean
2023-07-03 20:33 ` [PATCH net 0/2] Fix mangled link-local MAC DAs with SJA1105 DSA Jakub Kicinski
2 siblings, 2 replies; 10+ messages in thread
From: Vladimir Oltean @ 2023-06-29 14:14 UTC (permalink / raw)
To: netdev
Cc: Andrew Lunn, Florian Fainelli, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, linux-kernel
The SJA1105 manual says that at offset 4 into the meta frame payload we
have "MAC destination byte 2" and at offset 5 we have "MAC destination
byte 1". These are counted from the LSB, so byte 1 is h_dest[ETH_HLEN-2]
aka h_dest[4] and byte 2 is h_dest[ETH_HLEN-3] aka h_dest[3].
The sja1105_meta_unpack() function decodes these the other way around,
so a frame with MAC DA 01:80:c2:11:22:33 is received by the network
stack as having 01:80:c2:22:11:33.
Fixes: e53e18a6fe4d ("net: dsa: sja1105: Receive and decode meta frames")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
net/dsa/tag_sja1105.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/dsa/tag_sja1105.c b/net/dsa/tag_sja1105.c
index 92a626a05e82..226191ec654b 100644
--- a/net/dsa/tag_sja1105.c
+++ b/net/dsa/tag_sja1105.c
@@ -118,8 +118,8 @@ static void sja1105_meta_unpack(const struct sk_buff *skb,
* a unified unpacking command for both device series.
*/
packing(buf, &meta->tstamp, 31, 0, 4, UNPACK, 0);
- packing(buf + 4, &meta->dmac_byte_4, 7, 0, 1, UNPACK, 0);
- packing(buf + 5, &meta->dmac_byte_3, 7, 0, 1, UNPACK, 0);
+ packing(buf + 4, &meta->dmac_byte_3, 7, 0, 1, UNPACK, 0);
+ packing(buf + 5, &meta->dmac_byte_4, 7, 0, 1, UNPACK, 0);
packing(buf + 6, &meta->source_port, 7, 0, 1, UNPACK, 0);
packing(buf + 7, &meta->switch_id, 7, 0, 1, UNPACK, 0);
}
--
2.34.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH net 2/2] net: dsa: sja1105: always enable the send_meta options
2023-06-29 14:14 [PATCH net 0/2] Fix mangled link-local MAC DAs with SJA1105 DSA Vladimir Oltean
2023-06-29 14:14 ` [PATCH net 1/2] net: dsa: tag_sja1105: fix MAC DA patching from meta frames Vladimir Oltean
@ 2023-06-29 14:14 ` Vladimir Oltean
2023-06-30 13:35 ` Simon Horman
2023-07-02 14:39 ` Florian Fainelli
2023-07-03 20:33 ` [PATCH net 0/2] Fix mangled link-local MAC DAs with SJA1105 DSA Jakub Kicinski
2 siblings, 2 replies; 10+ messages in thread
From: Vladimir Oltean @ 2023-06-29 14:14 UTC (permalink / raw)
To: netdev
Cc: Andrew Lunn, Florian Fainelli, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, linux-kernel
incl_srcpt has the limitation, mentioned in commit b4638af8885a ("net:
dsa: sja1105: always enable the INCL_SRCPT option"), that frames with a
MAC DA of 01:80:c2:xx:yy:zz will be received as 01:80:c2:00:00:zz unless
PTP RX timestamping is enabled.
The incl_srcpt option was initially unconditionally enabled, then that
changed with commit 42824463d38d ("net: dsa: sja1105: Limit use of
incl_srcpt to bridge+vlan mode"), then again with b4638af8885a ("net:
dsa: sja1105: always enable the INCL_SRCPT option"). Bottom line is that
it now needs to be always enabled, otherwise the driver does not have a
reliable source of information regarding source_port and switch_id for
link-local traffic (tag_8021q VLANs may be imprecise since now they
identify an entire bridging domain when ports are not standalone).
If we accept that PTP RX timestamping (and therefore, meta frame
generation) is always enabled in hardware, then that limitation could be
avoided and packets with any MAC DA can be properly received, because
meta frames do contain the original bytes from the MAC DA of their
associated link-local packet.
This change enables meta frame generation unconditionally, which also
has the nice side effects of simplifying the switch control path
(a switch reset is no longer required on hwtstamping settings change)
and the tagger data path (it no longer needs to be informed whether to
expect meta frames or not - it always does).
Fixes: 227d07a07ef1 ("net: dsa: sja1105: Add support for traffic through standalone ports")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
drivers/net/dsa/sja1105/sja1105.h | 2 +-
drivers/net/dsa/sja1105/sja1105_main.c | 5 ++-
drivers/net/dsa/sja1105/sja1105_ptp.c | 48 +++-----------------------
include/linux/dsa/sja1105.h | 4 ---
net/dsa/tag_sja1105.c | 45 ------------------------
5 files changed, 7 insertions(+), 97 deletions(-)
diff --git a/drivers/net/dsa/sja1105/sja1105.h b/drivers/net/dsa/sja1105/sja1105.h
index fb1549a5fe32..dee35ba924ad 100644
--- a/drivers/net/dsa/sja1105/sja1105.h
+++ b/drivers/net/dsa/sja1105/sja1105.h
@@ -252,6 +252,7 @@ struct sja1105_private {
unsigned long ucast_egress_floods;
unsigned long bcast_egress_floods;
unsigned long hwts_tx_en;
+ unsigned long hwts_rx_en;
const struct sja1105_info *info;
size_t max_xfer_len;
struct spi_device *spidev;
@@ -289,7 +290,6 @@ struct sja1105_spi_message {
/* From sja1105_main.c */
enum sja1105_reset_reason {
SJA1105_VLAN_FILTERING = 0,
- SJA1105_RX_HWTSTAMPING,
SJA1105_AGEING_TIME,
SJA1105_SCHEDULING,
SJA1105_BEST_EFFORT_POLICING,
diff --git a/drivers/net/dsa/sja1105/sja1105_main.c b/drivers/net/dsa/sja1105/sja1105_main.c
index cdbadae923dc..0e21a789ca4a 100644
--- a/drivers/net/dsa/sja1105/sja1105_main.c
+++ b/drivers/net/dsa/sja1105/sja1105_main.c
@@ -870,11 +870,11 @@ static int sja1105_init_general_params(struct sja1105_private *priv)
.mac_fltres1 = SJA1105_LINKLOCAL_FILTER_A,
.mac_flt1 = SJA1105_LINKLOCAL_FILTER_A_MASK,
.incl_srcpt1 = true,
- .send_meta1 = false,
+ .send_meta1 = true,
.mac_fltres0 = SJA1105_LINKLOCAL_FILTER_B,
.mac_flt0 = SJA1105_LINKLOCAL_FILTER_B_MASK,
.incl_srcpt0 = true,
- .send_meta0 = false,
+ .send_meta0 = true,
/* Default to an invalid value */
.mirr_port = priv->ds->num_ports,
/* No TTEthernet */
@@ -2218,7 +2218,6 @@ static int sja1105_reload_cbs(struct sja1105_private *priv)
static const char * const sja1105_reset_reasons[] = {
[SJA1105_VLAN_FILTERING] = "VLAN filtering",
- [SJA1105_RX_HWTSTAMPING] = "RX timestamping",
[SJA1105_AGEING_TIME] = "Ageing time",
[SJA1105_SCHEDULING] = "Time-aware scheduling",
[SJA1105_BEST_EFFORT_POLICING] = "Best-effort policing",
diff --git a/drivers/net/dsa/sja1105/sja1105_ptp.c b/drivers/net/dsa/sja1105/sja1105_ptp.c
index f47ad55a811a..0bb99ee5ebf9 100644
--- a/drivers/net/dsa/sja1105/sja1105_ptp.c
+++ b/drivers/net/dsa/sja1105/sja1105_ptp.c
@@ -61,35 +61,10 @@ enum sja1105_ptp_clk_mode {
#define SJA1105_PTPEGR_SLEEP_US 50
#define SJA1105_PTPEGR_TIMEOUT_US 1000000
-/* Must be called only while the RX timestamping state of the tagger
- * is turned off
- */
-static int sja1105_change_rxtstamping(struct sja1105_private *priv,
- bool on)
-{
- struct sja1105_ptp_data *ptp_data = &priv->ptp_data;
- struct sja1105_general_params_entry *general_params;
- struct sja1105_table *table;
-
- table = &priv->static_config.tables[BLK_IDX_GENERAL_PARAMS];
- general_params = table->entries;
- general_params->send_meta1 = on;
- general_params->send_meta0 = on;
-
- ptp_cancel_worker_sync(ptp_data->clock);
- skb_queue_purge(&ptp_data->skb_txtstamp_queue);
- skb_queue_purge(&ptp_data->skb_rxtstamp_queue);
-
- return sja1105_static_config_reload(priv, SJA1105_RX_HWTSTAMPING);
-}
-
int sja1105_hwtstamp_set(struct dsa_switch *ds, int port, struct ifreq *ifr)
{
- struct sja1105_tagger_data *tagger_data = sja1105_tagger_data(ds);
struct sja1105_private *priv = ds->priv;
struct hwtstamp_config config;
- bool rx_on;
- int rc;
if (copy_from_user(&config, ifr->ifr_data, sizeof(config)))
return -EFAULT;
@@ -107,26 +82,13 @@ int sja1105_hwtstamp_set(struct dsa_switch *ds, int port, struct ifreq *ifr)
switch (config.rx_filter) {
case HWTSTAMP_FILTER_NONE:
- rx_on = false;
+ priv->hwts_rx_en &= ~BIT(port);
break;
default:
- rx_on = true;
+ priv->hwts_rx_en |= BIT(port);
break;
}
- if (rx_on != tagger_data->rxtstamp_get_state(ds)) {
- tagger_data->rxtstamp_set_state(ds, false);
-
- rc = sja1105_change_rxtstamping(priv, rx_on);
- if (rc < 0) {
- dev_err(ds->dev,
- "Failed to change RX timestamping: %d\n", rc);
- return rc;
- }
- if (rx_on)
- tagger_data->rxtstamp_set_state(ds, true);
- }
-
if (copy_to_user(ifr->ifr_data, &config, sizeof(config)))
return -EFAULT;
return 0;
@@ -134,7 +96,6 @@ int sja1105_hwtstamp_set(struct dsa_switch *ds, int port, struct ifreq *ifr)
int sja1105_hwtstamp_get(struct dsa_switch *ds, int port, struct ifreq *ifr)
{
- struct sja1105_tagger_data *tagger_data = sja1105_tagger_data(ds);
struct sja1105_private *priv = ds->priv;
struct hwtstamp_config config;
@@ -143,7 +104,7 @@ int sja1105_hwtstamp_get(struct dsa_switch *ds, int port, struct ifreq *ifr)
config.tx_type = HWTSTAMP_TX_ON;
else
config.tx_type = HWTSTAMP_TX_OFF;
- if (tagger_data->rxtstamp_get_state(ds))
+ if (priv->hwts_rx_en & BIT(port))
config.rx_filter = HWTSTAMP_FILTER_PTP_V2_L2_EVENT;
else
config.rx_filter = HWTSTAMP_FILTER_NONE;
@@ -419,11 +380,10 @@ static long sja1105_rxtstamp_work(struct ptp_clock_info *ptp)
bool sja1105_rxtstamp(struct dsa_switch *ds, int port, struct sk_buff *skb)
{
- struct sja1105_tagger_data *tagger_data = sja1105_tagger_data(ds);
struct sja1105_private *priv = ds->priv;
struct sja1105_ptp_data *ptp_data = &priv->ptp_data;
- if (!tagger_data->rxtstamp_get_state(ds))
+ if (!(priv->hwts_rx_en & BIT(port)))
return false;
/* We need to read the full PTP clock to reconstruct the Rx
diff --git a/include/linux/dsa/sja1105.h b/include/linux/dsa/sja1105.h
index 159e43171ccc..c177322f793d 100644
--- a/include/linux/dsa/sja1105.h
+++ b/include/linux/dsa/sja1105.h
@@ -48,13 +48,9 @@ struct sja1105_deferred_xmit_work {
/* Global tagger data */
struct sja1105_tagger_data {
- /* Tagger to switch */
void (*xmit_work_fn)(struct kthread_work *work);
void (*meta_tstamp_handler)(struct dsa_switch *ds, int port, u8 ts_id,
enum sja1110_meta_tstamp dir, u64 tstamp);
- /* Switch to tagger */
- bool (*rxtstamp_get_state)(struct dsa_switch *ds);
- void (*rxtstamp_set_state)(struct dsa_switch *ds, bool on);
};
struct sja1105_skb_cb {
diff --git a/net/dsa/tag_sja1105.c b/net/dsa/tag_sja1105.c
index 226191ec654b..9d23f5e93269 100644
--- a/net/dsa/tag_sja1105.c
+++ b/net/dsa/tag_sja1105.c
@@ -58,11 +58,8 @@
#define SJA1110_TX_TRAILER_LEN 4
#define SJA1110_MAX_PADDING_LEN 15
-#define SJA1105_HWTS_RX_EN 0
-
struct sja1105_tagger_private {
struct sja1105_tagger_data data; /* Must be first */
- unsigned long state;
/* Protects concurrent access to the meta state machine
* from taggers running on multiple ports on SMP systems
*/
@@ -392,10 +389,6 @@ static struct sk_buff
priv = sja1105_tagger_private(ds);
- if (!test_bit(SJA1105_HWTS_RX_EN, &priv->state))
- /* Do normal processing. */
- return skb;
-
spin_lock(&priv->meta_lock);
/* Was this a link-local frame instead of the meta
* that we were expecting?
@@ -431,12 +424,6 @@ static struct sk_buff
priv = sja1105_tagger_private(ds);
- /* Drop the meta frame if we're not in the right state
- * to process it.
- */
- if (!test_bit(SJA1105_HWTS_RX_EN, &priv->state))
- return NULL;
-
spin_lock(&priv->meta_lock);
stampable_skb = priv->stampable_skb;
@@ -472,30 +459,6 @@ static struct sk_buff
return skb;
}
-static bool sja1105_rxtstamp_get_state(struct dsa_switch *ds)
-{
- struct sja1105_tagger_private *priv = sja1105_tagger_private(ds);
-
- return test_bit(SJA1105_HWTS_RX_EN, &priv->state);
-}
-
-static void sja1105_rxtstamp_set_state(struct dsa_switch *ds, bool on)
-{
- struct sja1105_tagger_private *priv = sja1105_tagger_private(ds);
-
- if (on)
- set_bit(SJA1105_HWTS_RX_EN, &priv->state);
- else
- clear_bit(SJA1105_HWTS_RX_EN, &priv->state);
-
- /* Initialize the meta state machine to a known state */
- if (!priv->stampable_skb)
- return;
-
- kfree_skb(priv->stampable_skb);
- priv->stampable_skb = NULL;
-}
-
static bool sja1105_skb_has_tag_8021q(const struct sk_buff *skb)
{
u16 tpid = ntohs(eth_hdr(skb)->h_proto);
@@ -552,9 +515,6 @@ static struct sk_buff *sja1105_rcv(struct sk_buff *skb,
*/
source_port = hdr->h_dest[3];
switch_id = hdr->h_dest[4];
- /* Clear the DMAC bytes that were mangled by the switch */
- hdr->h_dest[3] = 0;
- hdr->h_dest[4] = 0;
} else if (is_meta) {
sja1105_meta_unpack(skb, &meta);
source_port = meta.source_port;
@@ -782,7 +742,6 @@ static void sja1105_disconnect(struct dsa_switch *ds)
static int sja1105_connect(struct dsa_switch *ds)
{
- struct sja1105_tagger_data *tagger_data;
struct sja1105_tagger_private *priv;
struct kthread_worker *xmit_worker;
int err;
@@ -802,10 +761,6 @@ static int sja1105_connect(struct dsa_switch *ds)
}
priv->xmit_worker = xmit_worker;
- /* Export functions for switch driver use */
- tagger_data = &priv->data;
- tagger_data->rxtstamp_get_state = sja1105_rxtstamp_get_state;
- tagger_data->rxtstamp_set_state = sja1105_rxtstamp_set_state;
ds->tagger_data = priv;
return 0;
--
2.34.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH net 1/2] net: dsa: tag_sja1105: fix MAC DA patching from meta frames
2023-06-29 14:14 ` [PATCH net 1/2] net: dsa: tag_sja1105: fix MAC DA patching from meta frames Vladimir Oltean
@ 2023-06-30 13:29 ` Simon Horman
2023-07-02 14:37 ` Florian Fainelli
1 sibling, 0 replies; 10+ messages in thread
From: Simon Horman @ 2023-06-30 13:29 UTC (permalink / raw)
To: Vladimir Oltean
Cc: netdev, Andrew Lunn, Florian Fainelli, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, linux-kernel
On Thu, Jun 29, 2023 at 05:14:52PM +0300, Vladimir Oltean wrote:
> The SJA1105 manual says that at offset 4 into the meta frame payload we
> have "MAC destination byte 2" and at offset 5 we have "MAC destination
> byte 1". These are counted from the LSB, so byte 1 is h_dest[ETH_HLEN-2]
> aka h_dest[4] and byte 2 is h_dest[ETH_HLEN-3] aka h_dest[3].
>
> The sja1105_meta_unpack() function decodes these the other way around,
> so a frame with MAC DA 01:80:c2:11:22:33 is received by the network
> stack as having 01:80:c2:22:11:33.
>
> Fixes: e53e18a6fe4d ("net: dsa: sja1105: Receive and decode meta frames")
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH net 2/2] net: dsa: sja1105: always enable the send_meta options
2023-06-29 14:14 ` [PATCH net 2/2] net: dsa: sja1105: always enable the send_meta options Vladimir Oltean
@ 2023-06-30 13:35 ` Simon Horman
2023-06-30 16:53 ` Vladimir Oltean
2023-07-02 14:39 ` Florian Fainelli
1 sibling, 1 reply; 10+ messages in thread
From: Simon Horman @ 2023-06-30 13:35 UTC (permalink / raw)
To: Vladimir Oltean
Cc: netdev, Andrew Lunn, Florian Fainelli, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, linux-kernel
On Thu, Jun 29, 2023 at 05:14:53PM +0300, Vladimir Oltean wrote:
> incl_srcpt has the limitation, mentioned in commit b4638af8885a ("net:
> dsa: sja1105: always enable the INCL_SRCPT option"), that frames with a
> MAC DA of 01:80:c2:xx:yy:zz will be received as 01:80:c2:00:00:zz unless
> PTP RX timestamping is enabled.
>
> The incl_srcpt option was initially unconditionally enabled, then that
> changed with commit 42824463d38d ("net: dsa: sja1105: Limit use of
> incl_srcpt to bridge+vlan mode"), then again with b4638af8885a ("net:
> dsa: sja1105: always enable the INCL_SRCPT option"). Bottom line is that
> it now needs to be always enabled, otherwise the driver does not have a
> reliable source of information regarding source_port and switch_id for
> link-local traffic (tag_8021q VLANs may be imprecise since now they
> identify an entire bridging domain when ports are not standalone).
>
> If we accept that PTP RX timestamping (and therefore, meta frame
> generation) is always enabled in hardware, then that limitation could be
> avoided and packets with any MAC DA can be properly received, because
> meta frames do contain the original bytes from the MAC DA of their
> associated link-local packet.
>
> This change enables meta frame generation unconditionally, which also
> has the nice side effects of simplifying the switch control path
> (a switch reset is no longer required on hwtstamping settings change)
> and the tagger data path (it no longer needs to be informed whether to
> expect meta frames or not - it always does).
>
> Fixes: 227d07a07ef1 ("net: dsa: sja1105: Add support for traffic through standalone ports")
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> ---
> drivers/net/dsa/sja1105/sja1105.h | 2 +-
> drivers/net/dsa/sja1105/sja1105_main.c | 5 ++-
> drivers/net/dsa/sja1105/sja1105_ptp.c | 48 +++-----------------------
> include/linux/dsa/sja1105.h | 4 ---
> net/dsa/tag_sja1105.c | 45 ------------------------
> 5 files changed, 7 insertions(+), 97 deletions(-)
Hi Vladimir,
this patch isn't that big, so I'm ok with it. But it also isn't that
small, so I'd just like to mention that a different approach might be a
small patch that enables meta frame generation unconditionally, as a fix.
And then, later, some cleanup, which seems to comprise most of this patch.
I do admit that I didn't try this. So it might not be sensible. And as I
said, I am ok with this patch. But I did think it was worth mentioning.
Reviewed-by: Simon Horman <simon.horman@corigine.com>
...
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH net 2/2] net: dsa: sja1105: always enable the send_meta options
2023-06-30 13:35 ` Simon Horman
@ 2023-06-30 16:53 ` Vladimir Oltean
2023-06-30 17:38 ` Simon Horman
0 siblings, 1 reply; 10+ messages in thread
From: Vladimir Oltean @ 2023-06-30 16:53 UTC (permalink / raw)
To: Simon Horman
Cc: netdev, Andrew Lunn, Florian Fainelli, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, linux-kernel
Hi Simon,
On Fri, Jun 30, 2023 at 03:35:23PM +0200, Simon Horman wrote:
> Hi Vladimir,
>
> this patch isn't that big, so I'm ok with it. But it also isn't that
> small, so I'd just like to mention that a different approach might be a
> small patch that enables meta frame generation unconditionally, as a fix.
> And then, later, some cleanup, which seems to comprise most of this patch.
>
> I do admit that I didn't try this. So it might not be sensible. And as I
> said, I am ok with this patch. But I did think it was worth mentioning.
>
> Reviewed-by: Simon Horman <simon.horman@corigine.com>
>
> ...
Thanks for the feedback.
You're saying that it's preferable to leave sja1105_rxtstamp_set_state()
and sja1105_rxtstamp_get_state() where they are, accessible through
tagger_data->rxtstamp_set_state() and tagger_data->rxtstamp_get_state(),
but to only call tagger_data->rxtstamp_set_state() once, statically with
"true", and to never call tagger_data->rxtstamp_get_state()?
I probably could, but I'd have to delay the tagger_data->rxtstamp_set_state()
call until sja1105_connect_tag_protocol(); it's not going to be available
earlier. And this is going to be just filler code that I will then delete
as soon as net-next reopens.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH net 2/2] net: dsa: sja1105: always enable the send_meta options
2023-06-30 16:53 ` Vladimir Oltean
@ 2023-06-30 17:38 ` Simon Horman
0 siblings, 0 replies; 10+ messages in thread
From: Simon Horman @ 2023-06-30 17:38 UTC (permalink / raw)
To: Vladimir Oltean
Cc: netdev, Andrew Lunn, Florian Fainelli, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, linux-kernel
On Fri, Jun 30, 2023 at 07:53:00PM +0300, Vladimir Oltean wrote:
> Hi Simon,
>
> On Fri, Jun 30, 2023 at 03:35:23PM +0200, Simon Horman wrote:
> > Hi Vladimir,
> >
> > this patch isn't that big, so I'm ok with it. But it also isn't that
> > small, so I'd just like to mention that a different approach might be a
> > small patch that enables meta frame generation unconditionally, as a fix.
> > And then, later, some cleanup, which seems to comprise most of this patch.
> >
> > I do admit that I didn't try this. So it might not be sensible. And as I
> > said, I am ok with this patch. But I did think it was worth mentioning.
> >
> > Reviewed-by: Simon Horman <simon.horman@corigine.com>
> >
> > ...
>
> Thanks for the feedback.
>
> You're saying that it's preferable to leave sja1105_rxtstamp_set_state()
> and sja1105_rxtstamp_get_state() where they are, accessible through
> tagger_data->rxtstamp_set_state() and tagger_data->rxtstamp_get_state(),
> but to only call tagger_data->rxtstamp_set_state() once, statically with
> "true", and to never call tagger_data->rxtstamp_get_state()?
I'm not the ultimate authority on what is and isn't acceptable.
But, yes, I was suggesting something like that.
> I probably could, but I'd have to delay the tagger_data->rxtstamp_set_state()
> call until sja1105_connect_tag_protocol(); it's not going to be available
> earlier. And this is going to be just filler code that I will then delete
> as soon as net-next reopens.
Right, so there is complexity. And dead code.
Or we could just cut to the chase, which is what you have done.
So it seems your approach is best.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH net 1/2] net: dsa: tag_sja1105: fix MAC DA patching from meta frames
2023-06-29 14:14 ` [PATCH net 1/2] net: dsa: tag_sja1105: fix MAC DA patching from meta frames Vladimir Oltean
2023-06-30 13:29 ` Simon Horman
@ 2023-07-02 14:37 ` Florian Fainelli
1 sibling, 0 replies; 10+ messages in thread
From: Florian Fainelli @ 2023-07-02 14:37 UTC (permalink / raw)
To: Vladimir Oltean, netdev
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, linux-kernel
On 6/29/2023 4:14 PM, Vladimir Oltean wrote:
> The SJA1105 manual says that at offset 4 into the meta frame payload we
> have "MAC destination byte 2" and at offset 5 we have "MAC destination
> byte 1". These are counted from the LSB, so byte 1 is h_dest[ETH_HLEN-2]
> aka h_dest[4] and byte 2 is h_dest[ETH_HLEN-3] aka h_dest[3].
>
> The sja1105_meta_unpack() function decodes these the other way around,
> so a frame with MAC DA 01:80:c2:11:22:33 is received by the network
> stack as having 01:80:c2:22:11:33.
>
> Fixes: e53e18a6fe4d ("net: dsa: sja1105: Receive and decode meta frames")
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
--
Florian
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH net 2/2] net: dsa: sja1105: always enable the send_meta options
2023-06-29 14:14 ` [PATCH net 2/2] net: dsa: sja1105: always enable the send_meta options Vladimir Oltean
2023-06-30 13:35 ` Simon Horman
@ 2023-07-02 14:39 ` Florian Fainelli
1 sibling, 0 replies; 10+ messages in thread
From: Florian Fainelli @ 2023-07-02 14:39 UTC (permalink / raw)
To: Vladimir Oltean, netdev
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, linux-kernel
On 6/29/2023 4:14 PM, Vladimir Oltean wrote:
> incl_srcpt has the limitation, mentioned in commit b4638af8885a ("net:
> dsa: sja1105: always enable the INCL_SRCPT option"), that frames with a
> MAC DA of 01:80:c2:xx:yy:zz will be received as 01:80:c2:00:00:zz unless
> PTP RX timestamping is enabled.
>
> The incl_srcpt option was initially unconditionally enabled, then that
> changed with commit 42824463d38d ("net: dsa: sja1105: Limit use of
> incl_srcpt to bridge+vlan mode"), then again with b4638af8885a ("net:
> dsa: sja1105: always enable the INCL_SRCPT option"). Bottom line is that
> it now needs to be always enabled, otherwise the driver does not have a
> reliable source of information regarding source_port and switch_id for
> link-local traffic (tag_8021q VLANs may be imprecise since now they
> identify an entire bridging domain when ports are not standalone).
>
> If we accept that PTP RX timestamping (and therefore, meta frame
> generation) is always enabled in hardware, then that limitation could be
> avoided and packets with any MAC DA can be properly received, because
> meta frames do contain the original bytes from the MAC DA of their
> associated link-local packet.
>
> This change enables meta frame generation unconditionally, which also
> has the nice side effects of simplifying the switch control path
> (a switch reset is no longer required on hwtstamping settings change)
> and the tagger data path (it no longer needs to be informed whether to
> expect meta frames or not - it always does).
>
> Fixes: 227d07a07ef1 ("net: dsa: sja1105: Add support for traffic through standalone ports")
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
--
Florian
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH net 0/2] Fix mangled link-local MAC DAs with SJA1105 DSA
2023-06-29 14:14 [PATCH net 0/2] Fix mangled link-local MAC DAs with SJA1105 DSA Vladimir Oltean
2023-06-29 14:14 ` [PATCH net 1/2] net: dsa: tag_sja1105: fix MAC DA patching from meta frames Vladimir Oltean
2023-06-29 14:14 ` [PATCH net 2/2] net: dsa: sja1105: always enable the send_meta options Vladimir Oltean
@ 2023-07-03 20:33 ` Jakub Kicinski
2 siblings, 0 replies; 10+ messages in thread
From: Jakub Kicinski @ 2023-07-03 20:33 UTC (permalink / raw)
To: Vladimir Oltean
Cc: netdev, Andrew Lunn, Florian Fainelli, David S. Miller,
Eric Dumazet, Paolo Abeni, linux-kernel
On Thu, 29 Jun 2023 17:14:51 +0300 Vladimir Oltean wrote:
> The SJA1105 hardware tagging protocol is weird and will put DSA
> information (source port, switch ID) in the MAC DA of the packets sent
> to the CPU, and then send some additional (meta) packets which contain
> the original bytes from the previous packet's MAC DA.
>
> The tagging protocol driver contains logic to handle this, but the meta
> frames are optional functionality, and there are configurations when
> they aren't received (no PTP RX timestamping). Thus, the MAC DA from
> packets sent to the stack is not correct in all cases.
>
> Also, during testing it was found that the MAC DA patching procedure was
> incorrect.
>
> The investigation comes as a result of this discussion with Paolo:
> https://lore.kernel.org/netdev/f494387c8d55d9b1d5a3e88beedeeb448f2e6cc3.camel@redhat.com/
This series got eaten by vger, I think. Could you repost?
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2023-07-03 20:34 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-29 14:14 [PATCH net 0/2] Fix mangled link-local MAC DAs with SJA1105 DSA Vladimir Oltean
2023-06-29 14:14 ` [PATCH net 1/2] net: dsa: tag_sja1105: fix MAC DA patching from meta frames Vladimir Oltean
2023-06-30 13:29 ` Simon Horman
2023-07-02 14:37 ` Florian Fainelli
2023-06-29 14:14 ` [PATCH net 2/2] net: dsa: sja1105: always enable the send_meta options Vladimir Oltean
2023-06-30 13:35 ` Simon Horman
2023-06-30 16:53 ` Vladimir Oltean
2023-06-30 17:38 ` Simon Horman
2023-07-02 14:39 ` Florian Fainelli
2023-07-03 20:33 ` [PATCH net 0/2] Fix mangled link-local MAC DAs with SJA1105 DSA Jakub Kicinski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox