LF-3799 dpaa2-switch: convert BR_STATE enum to DPSW_STP_STATE enum
authorRobert-Ionut Alexa <robert-ionut.alexa@nxp.com>
Fri, 21 May 2021 08:47:05 +0000 (11:47 +0300)
committerXiaobo Xie <xiaobo.xie@nxp.com>
Wed, 2 Jun 2021 09:55:29 +0000 (11:55 +0200)
Starting with mc 10.28.0, the firmware returns an error any time
an invalid STP state is configured.
An explicit function converts from BR_STATE_* kernel enums to
DPSW_STP_STATE_* mc enums.

Signed-off-by: Robert-Ionut Alexa <robert-ionut.alexa@nxp.com>
drivers/staging/fsl-dpaa2/ethsw/ethsw.c

index d524e92..90207fe 100644 (file)
@@ -199,10 +199,28 @@ static int dpaa2_switch_port_set_flood(struct ethsw_port_priv *port_priv, bool e
        return 0;
 }
 
+static enum dpsw_stp_state br_stp_state_to_dpsw(u8 state)
+{
+       switch (state) {
+       case BR_STATE_DISABLED:
+               return DPSW_STP_STATE_DISABLED;
+       case BR_STATE_LISTENING:
+               return DPSW_STP_STATE_LISTENING;
+       case BR_STATE_LEARNING:
+               return DPSW_STP_STATE_LEARNING;
+       case BR_STATE_FORWARDING:
+               return DPSW_STP_STATE_FORWARDING;
+       case BR_STATE_BLOCKING:
+               return DPSW_STP_STATE_BLOCKING;
+       default:
+               return DPSW_STP_STATE_DISABLED;
+       }
+}
+
 static int dpaa2_switch_port_set_stp_state(struct ethsw_port_priv *port_priv, u8 state)
 {
        struct dpsw_stp_cfg stp_cfg = {
-               .state = state,
+               .state = br_stp_state_to_dpsw(state),
        };
        int err;
        u16 vid;