From f95868d54301c0f54e968ec9d978c9caa02ee425 Mon Sep 17 00:00:00 2001
From: Robert Marko <robimarko@gmail.com>
Date: Fri, 18 Mar 2022 18:24:18 +0100
Subject: [PATCH] switchdev: use new switchdev flags

Since kernel 5.12 switched utilizes a new way of setting the flags by
using a dedicated structure with flags and mask.

So fix using kernels 5.12 and later.

Signed-off-by: Robert Marko <robimarko@gmail.com>
---
 include/nss_dp_dev.h | 7 +++++++
 nss_dp_switchdev.c   | 2 +-
 2 files changed, 8 insertions(+), 1 deletion(-)

--- a/include/nss_dp_dev.h
+++ b/include/nss_dp_dev.h
@@ -24,6 +24,9 @@
 #include <linux/platform_device.h>
 #include <linux/phy.h>
 #include <linux/version.h>
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 12, 0))
+#include <net/switchdev.h>
+#endif
 
 #include "nss_dp_api_if.h"
 #include "nss_dp_hal_if.h"
@@ -126,7 +129,11 @@ struct nss_dp_dev {
 	/* switchdev related attributes */
 #ifdef CONFIG_NET_SWITCHDEV
 	u8 stp_state;			/* STP state of this physical port */
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 12, 0))
 	unsigned long brport_flags;	/* bridge port flags */
+#else
+	struct switchdev_brport_flags brport_flags;	/* bridge port flags */
+#endif
 #endif
 	uint32_t rx_page_mode;		/* page mode for Rx processing */
 	uint32_t rx_jumbo_mru;		/* Jumbo mru value for Rx processing */
--- a/nss_dp_switchdev.c
+++ b/nss_dp_switchdev.c
@@ -296,7 +296,7 @@ static int nss_dp_port_attr_set(struct n
 	switch (attr->id) {
 	case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS:
 		dp_priv->brport_flags = attr->u.brport_flags;
-		netdev_dbg(dev, "set brport_flags %lu\n", attr->u.brport_flags);
+		netdev_dbg(dev, "set brport_flags %lu\n", attr->u.brport_flags.val);
 		return 0;
 	case SWITCHDEV_ATTR_ID_PORT_STP_STATE:
 		return nss_dp_stp_state_set(dp_priv, attr->u.stp_state);
