mirror of
https://github.com/breeze303/nss-packages.git
synced 2025-12-16 16:57:29 +00:00
nss-dp: fix switchdev for 5.15
Apply upstream switchdev changes to allow utilizing the switchdev code on 5.15 kernel. Signed-off-by: Robert Marko <robimarko@gmail.com>
This commit is contained in:
parent
f1c646d45b
commit
8987699f24
@ -0,0 +1,53 @@
|
||||
From c9afdcdd2642485a6476906be9da2e811090fc7a Mon Sep 17 00:00:00 2001
|
||||
From: Robert Marko <robimarko@gmail.com>
|
||||
Date: Fri, 18 Mar 2022 18:06:03 +0100
|
||||
Subject: [PATCH] switchdev: remove the transaction structure
|
||||
|
||||
Since 5.12 there is no transaction structure anymore, so drop it for
|
||||
5.12 and newer.
|
||||
|
||||
Signed-off-by: Robert Marko <robimarko@gmail.com>
|
||||
---
|
||||
nss_dp_switchdev.c | 10 ++++++++++
|
||||
1 file changed, 10 insertions(+)
|
||||
|
||||
diff --git a/nss_dp_switchdev.c b/nss_dp_switchdev.c
|
||||
index 68bc769..d85e725 100644
|
||||
--- a/nss_dp_switchdev.c
|
||||
+++ b/nss_dp_switchdev.c
|
||||
@@ -279,13 +279,19 @@ void nss_dp_switchdev_setup(struct net_device *dev)
|
||||
* Sets attributes
|
||||
*/
|
||||
static int nss_dp_port_attr_set(struct net_device *dev,
|
||||
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 12, 0))
|
||||
const struct switchdev_attr *attr,
|
||||
struct switchdev_trans *trans)
|
||||
+#else
|
||||
+ const struct switchdev_attr *attr)
|
||||
+#endif
|
||||
{
|
||||
struct nss_dp_dev *dp_priv = (struct nss_dp_dev *)netdev_priv(dev);
|
||||
|
||||
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 12, 0))
|
||||
if (switchdev_trans_ph_prepare(trans))
|
||||
return 0;
|
||||
+#endif
|
||||
|
||||
switch (attr->id) {
|
||||
case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS:
|
||||
@@ -309,8 +315,12 @@ static int nss_dp_switchdev_port_attr_set_event(struct net_device *netdev,
|
||||
{
|
||||
int err;
|
||||
|
||||
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 12, 0))
|
||||
err = nss_dp_port_attr_set(netdev, port_attr_info->attr,
|
||||
port_attr_info->trans);
|
||||
+#else
|
||||
+ err = nss_dp_port_attr_set(netdev, port_attr_info->attr);
|
||||
+#endif
|
||||
|
||||
port_attr_info->handled = true;
|
||||
return notifier_from_errno(err);
|
||||
--
|
||||
2.35.1
|
||||
|
||||
@ -0,0 +1,58 @@
|
||||
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(-)
|
||||
|
||||
diff --git a/include/nss_dp_dev.h b/include/nss_dp_dev.h
|
||||
index 7dbacee..df36b69 100644
|
||||
--- a/include/nss_dp_dev.h
|
||||
+++ b/include/nss_dp_dev.h
|
||||
@@ -26,6 +26,9 @@
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/if_vlan.h>
|
||||
#include <linux/phy.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"
|
||||
@@ -69,7 +72,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
|
||||
};
|
||||
|
||||
diff --git a/nss_dp_switchdev.c b/nss_dp_switchdev.c
|
||||
index d85e725..e72cfbc 100644
|
||||
--- a/nss_dp_switchdev.c
|
||||
+++ b/nss_dp_switchdev.c
|
||||
@@ -296,7 +296,7 @@ static int nss_dp_port_attr_set(struct net_device *dev,
|
||||
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);
|
||||
--
|
||||
2.35.1
|
||||
|
||||
Loading…
Reference in New Issue
Block a user