mirror of
https://github.com/Heleguo/lede.git
synced 2025-12-16 10:51:12 +00:00
Merge branch 'coolsnowwolf:master' into master
This commit is contained in:
commit
24221a2dde
@ -17,29 +17,39 @@
|
||||
#size-cells = <2>;
|
||||
ranges;
|
||||
|
||||
npu-binary@84000000 {
|
||||
atf@80000000 {
|
||||
no-map;
|
||||
reg = <0x0 0x80000000 0x0 0x200000>;
|
||||
};
|
||||
|
||||
npu_binary: npu-binary@84000000 {
|
||||
no-map;
|
||||
reg = <0x0 0x84000000 0x0 0xa00000>;
|
||||
};
|
||||
|
||||
npu-flag@84b0000 {
|
||||
qdma0_buf: qdma0-buf@87000000 {
|
||||
no-map;
|
||||
reg = <0x0 0x84b00000 0x0 0x100000>;
|
||||
reg = <0x0 0x87000000 0x0 0x2000000>;
|
||||
};
|
||||
|
||||
npu-pkt@85000000 {
|
||||
qdma1_buf: qdma1-buf@89000000 {
|
||||
no-map;
|
||||
reg = <0x0 0x85000000 0x0 0x1a00000>;
|
||||
reg = <0x0 0x89000000 0x0 0x1000000>;
|
||||
};
|
||||
|
||||
npu-phyaddr@86b00000 {
|
||||
npu_pkt: npu-pkt@8a000000 {
|
||||
no-map;
|
||||
reg = <0x0 0x86b00000 0x0 0x100000>;
|
||||
reg = <0x0 0x8a000000 0x0 0x2c00000>;
|
||||
};
|
||||
|
||||
npu-rxdesc@86d00000 {
|
||||
npu_txpkt: npu-txpkt@8cc00000 {
|
||||
no-map;
|
||||
reg = <0x0 0x86d00000 0x0 0x100000>;
|
||||
reg = <0x0 0x8cc00000 0x0 0x4000000>;
|
||||
};
|
||||
|
||||
npu_txbufid: npu-txbufid@90c00000 {
|
||||
no-map;
|
||||
reg = <0x0 0x90c00000 0x0 0x6800>;
|
||||
};
|
||||
};
|
||||
|
||||
@ -433,7 +443,7 @@
|
||||
reg = <0x0 0x1fa20000 0x0 0x388>;
|
||||
};
|
||||
|
||||
syscon@1fbe3400 {
|
||||
pbus_csr: syscon@1fbe3400 {
|
||||
compatible = "airoha,en7581-pbus-csr", "syscon";
|
||||
reg = <0x0 0x1fbe3400 0x0 0xff>;
|
||||
};
|
||||
@ -603,6 +613,8 @@
|
||||
<&scuclk EN7581_PCIE2_RST>;
|
||||
reset-names = "phy-lane0", "phy-lane1", "phy-lane2";
|
||||
|
||||
mediatek,pbus-csr = <&pbus_csr 0x0 0x4>;
|
||||
|
||||
interrupts = <GIC_SPI 39 IRQ_TYPE_LEVEL_HIGH>;
|
||||
bus-range = <0x00 0xff>;
|
||||
#interrupt-cells = <1>;
|
||||
@ -644,6 +656,8 @@
|
||||
<&scuclk EN7581_PCIE2_RST>;
|
||||
reset-names = "phy-lane0", "phy-lane1", "phy-lane2";
|
||||
|
||||
mediatek,pbus-csr = <&pbus_csr 0x8 0xc>;
|
||||
|
||||
interrupts = <GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH>;
|
||||
bus-range = <0x00 0xff>;
|
||||
#interrupt-cells = <1>;
|
||||
@ -662,6 +676,31 @@
|
||||
};
|
||||
};
|
||||
|
||||
npu: npu@1e900000 {
|
||||
compatible = "airoha,en7581-npu";
|
||||
reg = <0x0 0x1e900000 0x0 0x313000>;
|
||||
interrupts = <GIC_SPI 125 IRQ_TYPE_LEVEL_HIGH>,
|
||||
<GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>,
|
||||
<GIC_SPI 109 IRQ_TYPE_LEVEL_HIGH>,
|
||||
<GIC_SPI 113 IRQ_TYPE_LEVEL_HIGH>,
|
||||
<GIC_SPI 117 IRQ_TYPE_LEVEL_HIGH>,
|
||||
<GIC_SPI 134 IRQ_TYPE_LEVEL_HIGH>,
|
||||
<GIC_SPI 135 IRQ_TYPE_LEVEL_HIGH>,
|
||||
<GIC_SPI 136 IRQ_TYPE_LEVEL_HIGH>,
|
||||
<GIC_SPI 137 IRQ_TYPE_LEVEL_HIGH>,
|
||||
<GIC_SPI 118 IRQ_TYPE_LEVEL_HIGH>,
|
||||
<GIC_SPI 119 IRQ_TYPE_LEVEL_HIGH>,
|
||||
<GIC_SPI 120 IRQ_TYPE_LEVEL_HIGH>,
|
||||
<GIC_SPI 121 IRQ_TYPE_LEVEL_HIGH>,
|
||||
<GIC_SPI 122 IRQ_TYPE_LEVEL_HIGH>,
|
||||
<GIC_SPI 123 IRQ_TYPE_LEVEL_HIGH>;
|
||||
memory-region = <&npu_binary>, <&npu_pkt>, <&npu_txpkt>,
|
||||
<&npu_txbufid>;
|
||||
memory-region-names = "binary", "pkt", "tx-pkt",
|
||||
"tx-bufid";
|
||||
status = "disabled";
|
||||
};
|
||||
|
||||
eth: ethernet@1fb50000 {
|
||||
compatible = "airoha,en7581-eth";
|
||||
reg = <0 0x1fb50000 0 0x2600>,
|
||||
@ -692,6 +731,11 @@
|
||||
<GIC_SPI 49 IRQ_TYPE_LEVEL_HIGH>,
|
||||
<GIC_SPI 64 IRQ_TYPE_LEVEL_HIGH>;
|
||||
|
||||
memory-region = <&qdma0_buf>, <&qdma1_buf>;
|
||||
memory-region-names = "qdma0-buf", "qdma1-buf";
|
||||
|
||||
airoha,npu = <&npu>;
|
||||
|
||||
status = "disabled";
|
||||
|
||||
#address-cells = <1>;
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
From 0e7a622da17da0042294860cdb7a2fac091d25b1 Mon Sep 17 00:00:00 2001
|
||||
Message-ID: <0e7a622da17da0042294860cdb7a2fac091d25b1.1736960708.git.lorenzo@kernel.org>
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Wed, 8 Jan 2025 10:50:40 +0100
|
||||
Subject: [PATCH 1/6] PCI: mediatek-gen3: Rely on clk_bulk_prepare_enable() in
|
||||
@ -1,7 +1,4 @@
|
||||
From e4c7dfd953f7618f0ccb70d87c1629634f306fab Mon Sep 17 00:00:00 2001
|
||||
Message-ID: <e4c7dfd953f7618f0ccb70d87c1629634f306fab.1736960708.git.lorenzo@kernel.org>
|
||||
In-Reply-To: <0e7a622da17da0042294860cdb7a2fac091d25b1.1736960708.git.lorenzo@kernel.org>
|
||||
References: <0e7a622da17da0042294860cdb7a2fac091d25b1.1736960708.git.lorenzo@kernel.org>
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Wed, 8 Jan 2025 10:50:41 +0100
|
||||
Subject: [PATCH 2/6] PCI: mediatek-gen3: Move reset/assert callbacks in
|
||||
@ -1,7 +1,4 @@
|
||||
From 0c9d2d2ef0d916b490a9222ed20ff4616fca876d Mon Sep 17 00:00:00 2001
|
||||
Message-ID: <0c9d2d2ef0d916b490a9222ed20ff4616fca876d.1736960708.git.lorenzo@kernel.org>
|
||||
In-Reply-To: <0e7a622da17da0042294860cdb7a2fac091d25b1.1736960708.git.lorenzo@kernel.org>
|
||||
References: <0e7a622da17da0042294860cdb7a2fac091d25b1.1736960708.git.lorenzo@kernel.org>
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Wed, 8 Jan 2025 10:50:42 +0100
|
||||
Subject: [PATCH 3/6] PCI: mediatek-gen3: Add comment about initialization
|
||||
@ -1,7 +1,4 @@
|
||||
From 90d4e466c9ea2010f33880a36317a8486ccbe082 Mon Sep 17 00:00:00 2001
|
||||
Message-ID: <90d4e466c9ea2010f33880a36317a8486ccbe082.1736960708.git.lorenzo@kernel.org>
|
||||
In-Reply-To: <0e7a622da17da0042294860cdb7a2fac091d25b1.1736960708.git.lorenzo@kernel.org>
|
||||
References: <0e7a622da17da0042294860cdb7a2fac091d25b1.1736960708.git.lorenzo@kernel.org>
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Wed, 8 Jan 2025 10:50:43 +0100
|
||||
Subject: [PATCH 4/6] PCI: mediatek-gen3: Move reset delay in
|
||||
@ -1,7 +1,4 @@
|
||||
From c98bee18d0a094e37100c85effe5e161418f8644 Mon Sep 17 00:00:00 2001
|
||||
Message-ID: <c98bee18d0a094e37100c85effe5e161418f8644.1736960708.git.lorenzo@kernel.org>
|
||||
In-Reply-To: <0e7a622da17da0042294860cdb7a2fac091d25b1.1736960708.git.lorenzo@kernel.org>
|
||||
References: <0e7a622da17da0042294860cdb7a2fac091d25b1.1736960708.git.lorenzo@kernel.org>
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Wed, 8 Jan 2025 10:50:44 +0100
|
||||
Subject: [PATCH 5/6] PCI: mediatek-gen3: Rely on msleep() in
|
||||
@ -1,7 +1,4 @@
|
||||
From 491cb9c5084790aafa02e843349492c284373231 Mon Sep 17 00:00:00 2001
|
||||
Message-ID: <491cb9c5084790aafa02e843349492c284373231.1736960708.git.lorenzo@kernel.org>
|
||||
In-Reply-To: <0e7a622da17da0042294860cdb7a2fac091d25b1.1736960708.git.lorenzo@kernel.org>
|
||||
References: <0e7a622da17da0042294860cdb7a2fac091d25b1.1736960708.git.lorenzo@kernel.org>
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Thu, 9 Jan 2025 00:30:45 +0100
|
||||
Subject: [PATCH 6/6] PCI: mediatek-gen3: Avoid PCIe resetting via PERST# for
|
||||
@ -0,0 +1,34 @@
|
||||
From b6d7bb0d3bd74b491e2e6fd59c4d5110d06fd63b Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Sat, 1 Feb 2025 12:00:18 +0100
|
||||
Subject: [PATCH] PCI: mediatek-gen3: Remove leftover mac_reset assert for
|
||||
Airoha EN7581 SoC
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Remove a leftover assert for mac_reset line in mtk_pcie_en7581_power_up().
|
||||
|
||||
This is not harmful since EN7581 does not requires mac_reset and
|
||||
mac_reset is not defined in EN7581 device tree.
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
|
||||
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
|
||||
Link: https://lore.kernel.org/r/20250201-pcie-en7581-remove-mac_reset-v2-1-a06786cdc683@kernel.org
|
||||
[kwilczynski: commit log]
|
||||
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
|
||||
---
|
||||
drivers/pci/controller/pcie-mediatek-gen3.c | 1 -
|
||||
1 file changed, 1 deletion(-)
|
||||
|
||||
--- a/drivers/pci/controller/pcie-mediatek-gen3.c
|
||||
+++ b/drivers/pci/controller/pcie-mediatek-gen3.c
|
||||
@@ -902,7 +902,6 @@ static int mtk_pcie_en7581_power_up(stru
|
||||
*/
|
||||
reset_control_bulk_assert(pcie->soc->phy_resets.num_resets,
|
||||
pcie->phy_resets);
|
||||
- reset_control_assert(pcie->mac_reset);
|
||||
|
||||
/* Wait for the time needed to complete the reset lines assert. */
|
||||
msleep(PCIE_EN7581_RESET_TIME_MS);
|
||||
@ -0,0 +1,81 @@
|
||||
From 249b78298078448a699c39356d27d8183af4b281 Mon Sep 17 00:00:00 2001
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Tue, 25 Feb 2025 09:04:07 +0100
|
||||
Subject: [PATCH] PCI: mediatek-gen3: Configure PBUS_CSR registers for EN7581
|
||||
SoC
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Configure PBus base address and address mask to allow the hw
|
||||
to detect if a given address is accessible on PCIe controller.
|
||||
|
||||
Fixes: f6ab898356dd ("PCI: mediatek-gen3: Add Airoha EN7581 support")
|
||||
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Link: https://lore.kernel.org/r/20250225-en7581-pcie-pbus-csr-v4-2-24324382424a@kernel.org
|
||||
Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org>
|
||||
---
|
||||
drivers/pci/controller/pcie-mediatek-gen3.c | 28 ++++++++++++++++++++-
|
||||
1 file changed, 27 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/pci/controller/pcie-mediatek-gen3.c
|
||||
+++ b/drivers/pci/controller/pcie-mediatek-gen3.c
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <linux/irqchip/chained_irq.h>
|
||||
#include <linux/irqdomain.h>
|
||||
#include <linux/kernel.h>
|
||||
+#include <linux/mfd/syscon.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/msi.h>
|
||||
#include <linux/of_device.h>
|
||||
@@ -24,6 +25,7 @@
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/pm_domain.h>
|
||||
#include <linux/pm_runtime.h>
|
||||
+#include <linux/regmap.h>
|
||||
#include <linux/reset.h>
|
||||
|
||||
#include "../pci.h"
|
||||
@@ -892,9 +894,13 @@ static int mtk_pcie_parse_port(struct mt
|
||||
|
||||
static int mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie)
|
||||
{
|
||||
+ struct pci_host_bridge *host = pci_host_bridge_from_priv(pcie);
|
||||
struct device *dev = pcie->dev;
|
||||
+ struct resource_entry *entry;
|
||||
+ struct regmap *pbus_regmap;
|
||||
+ u32 val, args[2], size;
|
||||
+ resource_size_t addr;
|
||||
int err;
|
||||
- u32 val;
|
||||
|
||||
/*
|
||||
* The controller may have been left out of reset by the bootloader
|
||||
@@ -907,6 +913,26 @@ static int mtk_pcie_en7581_power_up(stru
|
||||
msleep(PCIE_EN7581_RESET_TIME_MS);
|
||||
|
||||
/*
|
||||
+ * Configure PBus base address and base address mask to allow the
|
||||
+ * hw to detect if a given address is accessible on PCIe controller.
|
||||
+ */
|
||||
+ pbus_regmap = syscon_regmap_lookup_by_phandle_args(dev->of_node,
|
||||
+ "mediatek,pbus-csr",
|
||||
+ ARRAY_SIZE(args),
|
||||
+ args);
|
||||
+ if (IS_ERR(pbus_regmap))
|
||||
+ return PTR_ERR(pbus_regmap);
|
||||
+
|
||||
+ entry = resource_list_first_type(&host->windows, IORESOURCE_MEM);
|
||||
+ if (!entry)
|
||||
+ return -ENODEV;
|
||||
+
|
||||
+ addr = entry->res->start - entry->offset;
|
||||
+ regmap_write(pbus_regmap, args[0], lower_32_bits(addr));
|
||||
+ size = lower_32_bits(resource_size(entry->res));
|
||||
+ regmap_write(pbus_regmap, args[1], GENMASK(31, __fls(size)));
|
||||
+
|
||||
+ /*
|
||||
* Unlike the other MediaTek Gen3 controllers, the Airoha EN7581
|
||||
* requires PHY initialization and power-on before PHY reset deassert.
|
||||
*/
|
||||
@ -1,81 +0,0 @@
|
||||
From ca4217f3117dceb2d01e179d02031a8758404624 Mon Sep 17 00:00:00 2001
|
||||
Message-ID: <ca4217f3117dceb2d01e179d02031a8758404624.1736961235.git.lorenzo@kernel.org>
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Tue, 3 Sep 2024 23:14:02 +0200
|
||||
Subject: [PATCH] PCI: mediatek-gen3: Configure PBUS_CSR registers for EN7581
|
||||
SoC
|
||||
|
||||
Configure PBus base address and address mask in order to allow the hw
|
||||
detecting if a given address is on PCIE0, PCIE1 or PCIE2.
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
---
|
||||
drivers/pci/controller/pcie-mediatek-gen3.c | 29 ++++++++++++++++++++-
|
||||
1 file changed, 28 insertions(+), 1 deletion(-)
|
||||
|
||||
--- a/drivers/pci/controller/pcie-mediatek-gen3.c
|
||||
+++ b/drivers/pci/controller/pcie-mediatek-gen3.c
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <linux/irqchip/chained_irq.h>
|
||||
#include <linux/irqdomain.h>
|
||||
#include <linux/kernel.h>
|
||||
+#include <linux/mfd/syscon.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/msi.h>
|
||||
#include <linux/of_device.h>
|
||||
@@ -24,6 +25,7 @@
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/pm_domain.h>
|
||||
#include <linux/pm_runtime.h>
|
||||
+#include <linux/regmap.h>
|
||||
#include <linux/reset.h>
|
||||
|
||||
#include "../pci.h"
|
||||
@@ -122,6 +124,13 @@
|
||||
|
||||
#define PCIE_MTK_RESET_TIME_US 10
|
||||
|
||||
+#define PCIE_EN7581_PBUS_ADDR(_n) (0x00 + ((_n) << 3))
|
||||
+#define PCIE_EN7581_PBUS_ADDR_MASK(_n) (0x04 + ((_n) << 3))
|
||||
+#define PCIE_EN7581_PBUS_BASE_ADDR(_n) \
|
||||
+ ((_n) == 2 ? 0x28000000 : \
|
||||
+ (_n) == 1 ? 0x24000000 : 0x20000000)
|
||||
+#define PCIE_EN7581_PBUS_BASE_ADDR_MASK GENMASK(31, 26)
|
||||
+
|
||||
/* Time in ms needed to complete PCIe reset on EN7581 SoC */
|
||||
#define PCIE_EN7581_RESET_TIME_MS 100
|
||||
|
||||
@@ -893,7 +902,8 @@ static int mtk_pcie_parse_port(struct mt
|
||||
static int mtk_pcie_en7581_power_up(struct mtk_gen3_pcie *pcie)
|
||||
{
|
||||
struct device *dev = pcie->dev;
|
||||
- int err;
|
||||
+ struct regmap *map;
|
||||
+ int err, slot;
|
||||
u32 val;
|
||||
|
||||
/*
|
||||
@@ -907,6 +917,23 @@ static int mtk_pcie_en7581_power_up(stru
|
||||
/* Wait for the time needed to complete the reset lines assert. */
|
||||
msleep(PCIE_EN7581_RESET_TIME_MS);
|
||||
|
||||
+ map = syscon_regmap_lookup_by_compatible("airoha,en7581-pbus-csr");
|
||||
+ if (IS_ERR(map))
|
||||
+ return PTR_ERR(map);
|
||||
+
|
||||
+ /*
|
||||
+ * Configure PBus base address and address mask in order to allow the
|
||||
+ * hw detecting if a given address is on PCIE0, PCIE1 or PCIE2.
|
||||
+ */
|
||||
+ slot = of_get_pci_domain_nr(dev->of_node);
|
||||
+ if (slot < 0)
|
||||
+ return slot;
|
||||
+
|
||||
+ regmap_write(map, PCIE_EN7581_PBUS_ADDR(slot),
|
||||
+ PCIE_EN7581_PBUS_BASE_ADDR(slot));
|
||||
+ regmap_write(map, PCIE_EN7581_PBUS_ADDR_MASK(slot),
|
||||
+ PCIE_EN7581_PBUS_BASE_ADDR_MASK);
|
||||
+
|
||||
/*
|
||||
* Unlike the other MediaTek Gen3 controllers, the Airoha EN7581
|
||||
* requires PHY initialization and power-on before PHY reset deassert.
|
||||
@ -1,26 +0,0 @@
|
||||
From c4defe43ce17a87e6341d126ba736d9f7ebdc541 Mon Sep 17 00:00:00 2001
|
||||
Message-ID: <c4defe43ce17a87e6341d126ba736d9f7ebdc541.1736962769.git.lorenzo@kernel.org>
|
||||
From: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
Date: Wed, 15 Jan 2025 18:36:26 +0100
|
||||
Subject: [PATCH] PCI: mediatek-gen3: Remove mac_reset assert leftover for
|
||||
Airoha EN7581 SoC.
|
||||
|
||||
Remove a leftover assert for mac_reset line in mtk_pcie_en7581_power_up().
|
||||
This is not armful since EN7581 does not requires mac_reset and
|
||||
mac_reset is not defined in EN7581 device tree.
|
||||
|
||||
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
|
||||
---
|
||||
drivers/pci/controller/pcie-mediatek-gen3.c | 1 -
|
||||
1 file changed, 1 deletion(-)
|
||||
|
||||
--- a/drivers/pci/controller/pcie-mediatek-gen3.c
|
||||
+++ b/drivers/pci/controller/pcie-mediatek-gen3.c
|
||||
@@ -912,7 +912,6 @@ static int mtk_pcie_en7581_power_up(stru
|
||||
*/
|
||||
reset_control_bulk_assert(pcie->soc->phy_resets.num_resets,
|
||||
pcie->phy_resets);
|
||||
- reset_control_assert(pcie->mac_reset);
|
||||
|
||||
/* Wait for the time needed to complete the reset lines assert. */
|
||||
msleep(PCIE_EN7581_RESET_TIME_MS);
|
||||
@ -0,0 +1,101 @@
|
||||
From d11e63119432bdb55065d094cb6fd37e9147c70d Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Asbj=C3=B8rn=20Sloth=20T=C3=B8nnesen?= <ast@fiberby.net>
|
||||
Date: Thu, 11 Apr 2024 10:52:54 +0000
|
||||
Subject: [PATCH] flow_offload: add control flag checking helpers
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
These helpers aim to help drivers, with checking
|
||||
for the presence of unsupported control flags.
|
||||
|
||||
For drivers supporting at least one control flag:
|
||||
flow_rule_is_supp_control_flags()
|
||||
|
||||
For drivers using flow_rule_match_control(), but not using flags:
|
||||
flow_rule_has_control_flags()
|
||||
|
||||
For drivers not using flow_rule_match_control():
|
||||
flow_rule_match_has_control_flags()
|
||||
|
||||
While primarily aimed at FLOW_DISSECTOR_KEY_CONTROL
|
||||
and flow_rule_match_control(), then the first two
|
||||
can also be used with FLOW_DISSECTOR_KEY_ENC_CONTROL
|
||||
and flow_rule_match_enc_control().
|
||||
|
||||
These helpers mirrors the existing check done in sfc:
|
||||
drivers/net/ethernet/sfc/tc.c +276
|
||||
|
||||
Only compile-tested.
|
||||
|
||||
Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>
|
||||
Reviewed-by: Louis Peens <louis.peens@corigine.com>
|
||||
Signed-off-by: David S. Miller <davem@davemloft.net>
|
||||
---
|
||||
include/net/flow_offload.h | 55 ++++++++++++++++++++++++++++++++++++++
|
||||
1 file changed, 55 insertions(+)
|
||||
|
||||
--- a/include/net/flow_offload.h
|
||||
+++ b/include/net/flow_offload.h
|
||||
@@ -449,6 +449,61 @@ static inline bool flow_rule_match_key(c
|
||||
return dissector_uses_key(rule->match.dissector, key);
|
||||
}
|
||||
|
||||
+/**
|
||||
+ * flow_rule_is_supp_control_flags() - check for supported control flags
|
||||
+ * @supp_flags: control flags supported by driver
|
||||
+ * @ctrl_flags: control flags present in rule
|
||||
+ * @extack: The netlink extended ACK for reporting errors.
|
||||
+ *
|
||||
+ * Return: true if only supported control flags are set, false otherwise.
|
||||
+ */
|
||||
+static inline bool flow_rule_is_supp_control_flags(const u32 supp_flags,
|
||||
+ const u32 ctrl_flags,
|
||||
+ struct netlink_ext_ack *extack)
|
||||
+{
|
||||
+ if (likely((ctrl_flags & ~supp_flags) == 0))
|
||||
+ return true;
|
||||
+
|
||||
+ NL_SET_ERR_MSG_FMT_MOD(extack,
|
||||
+ "Unsupported match on control.flags %#x",
|
||||
+ ctrl_flags);
|
||||
+
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ * flow_rule_has_control_flags() - check for presence of any control flags
|
||||
+ * @ctrl_flags: control flags present in rule
|
||||
+ * @extack: The netlink extended ACK for reporting errors.
|
||||
+ *
|
||||
+ * Return: true if control flags are set, false otherwise.
|
||||
+ */
|
||||
+static inline bool flow_rule_has_control_flags(const u32 ctrl_flags,
|
||||
+ struct netlink_ext_ack *extack)
|
||||
+{
|
||||
+ return !flow_rule_is_supp_control_flags(0, ctrl_flags, extack);
|
||||
+}
|
||||
+
|
||||
+/**
|
||||
+ * flow_rule_match_has_control_flags() - match and check for any control flags
|
||||
+ * @rule: The flow_rule under evaluation.
|
||||
+ * @extack: The netlink extended ACK for reporting errors.
|
||||
+ *
|
||||
+ * Return: true if control flags are set, false otherwise.
|
||||
+ */
|
||||
+static inline bool flow_rule_match_has_control_flags(struct flow_rule *rule,
|
||||
+ struct netlink_ext_ack *extack)
|
||||
+{
|
||||
+ struct flow_match_control match;
|
||||
+
|
||||
+ if (!flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_CONTROL))
|
||||
+ return false;
|
||||
+
|
||||
+ flow_rule_match_control(rule, &match);
|
||||
+
|
||||
+ return flow_rule_has_control_flags(match.mask->flags, extack);
|
||||
+}
|
||||
+
|
||||
struct flow_stats {
|
||||
u64 pkts;
|
||||
u64 bytes;
|
||||
@ -0,0 +1,40 @@
|
||||
From f40a455d01f80c6638be382d75cb1c4e7748d8af Mon Sep 17 00:00:00 2001
|
||||
From: Simon Horman <horms@kernel.org>
|
||||
Date: Tue, 13 Aug 2024 14:33:47 +0100
|
||||
Subject: [PATCH] ipv6: Add ipv6_addr_{cpu_to_be32,be32_to_cpu} helpers
|
||||
|
||||
Add helpers to convert an ipv6 addr, expressed as an array
|
||||
of words, from CPU to big-endian byte order, and vice versa.
|
||||
|
||||
No functional change intended.
|
||||
Compile tested only.
|
||||
|
||||
Suggested-by: Andrew Lunn <andrew@lunn.ch>
|
||||
Link: https://lore.kernel.org/netdev/c7684349-535c-45a4-9a74-d47479a50020@lunn.ch/
|
||||
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
|
||||
Signed-off-by: Simon Horman <horms@kernel.org>
|
||||
Link: https://patch.msgid.link/20240813-ipv6_addr-helpers-v2-1-5c974f8cca3e@kernel.org
|
||||
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
|
||||
---
|
||||
include/net/ipv6.h | 12 ++++++++++++
|
||||
1 file changed, 12 insertions(+)
|
||||
|
||||
--- a/include/net/ipv6.h
|
||||
+++ b/include/net/ipv6.h
|
||||
@@ -1382,4 +1382,16 @@ static inline void ip6_sock_set_recvpkti
|
||||
release_sock(sk);
|
||||
}
|
||||
|
||||
+#define IPV6_ADDR_WORDS 4
|
||||
+
|
||||
+static inline void ipv6_addr_cpu_to_be32(__be32 *dst, const u32 *src)
|
||||
+{
|
||||
+ cpu_to_be32_array(dst, src, IPV6_ADDR_WORDS);
|
||||
+}
|
||||
+
|
||||
+static inline void ipv6_addr_be32_to_cpu(u32 *dst, const __be32 *src)
|
||||
+{
|
||||
+ be32_to_cpu_array(dst, src, IPV6_ADDR_WORDS);
|
||||
+}
|
||||
+
|
||||
#endif /* _NET_IPV6_H */
|
||||
Loading…
Reference in New Issue
Block a user