Thread (9 messages) 9 messages, 4 authors, 2022-02-18

Re: [PATCH net-next 2/2] net: dsa: realtek: rtl8365mb: add support for rtl8_4t

From: Luiz Angelo Daros de Luca <hidden>
Date: 2022-02-18 05:39:11

quoted
 rtl8365mb_get_tag_protocol(struct dsa_switch *ds, int port,
                         enum dsa_tag_protocol mp)
 {
+     struct realtek_priv *priv = ds->priv;
+     u32 val;
+
+     /* No way to return error */
+     regmap_read(priv->map, RTL8365MB_CPU_CTRL_REG, &val);
+
+     switch (FIELD_GET(RTL8365MB_CPU_CTRL_TAG_FORMAT_MASK, val)) {
+     case RTL8365MB_CPU_FORMAT_4BYTES:
+             /* Similar to DSA_TAG_PROTO_RTL4_A but with 1-byte version
+              * To CPU: [0x88 0x99 0x04 portnum]. Not supported yet.
+              */
+             break;
+     case RTL8365MB_CPU_FORMAT_8BYTES:
+             switch (FIELD_GET(RTL8365MB_CPU_CTRL_TAG_POSITION_MASK, val)) {
+             case RTL8365MB_CPU_POS_BEFORE_CRC:
+                     return DSA_TAG_PROTO_RTL8_4T;
+             case RTL8365MB_CPU_POS_AFTER_SA:
+             default:
+                     return DSA_TAG_PROTO_RTL8_4;
+             }
+             break;
+     }
+
      return DSA_TAG_PROTO_RTL8_4;
Not great. dsa_get_tag_protocol gets called from dsa_port_parse_cpu,
which is earlier than rtl8365mb_cpu_config, so you may temporarily
report a tagging protocol which you don't expect (depending on what is
in hardware at the time). Can you not keep the current tagging protocol
in a variable? You could then avoid the need to return an error on
regmap_read too.
Thanks Vladimir.

Sure. I added the variable to the chip_data struct. With that, I can
also remove the tag-related code and variables from
rtl8365mb_cpu_config() and rtl8365mb_cpu. Now I simply call the same
rtl8365mb_change_tag_protocol() during setup. I believe it is better
to have a single place that touches that config.

Regards,

Luiz
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help