mirror of
https://github.com/openwrt/openwrt.git
synced 2025-02-22 18:02:46 +00:00
Add initial support for new target with the initial patch for ethernet support using pending upstream patches for PCS UNIPHY, PPE and EDMA. Only initramfs currently working as support for new SPI/NAND implementation, USB, CPUFreq and other devices is still unfinished and needs to be evaluated. Link: https://github.com/openwrt/openwrt/pull/17725 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
239 lines
8.5 KiB
Diff
239 lines
8.5 KiB
Diff
From 61881bae3ad9d961139e970f1aae75070cd45b5c Mon Sep 17 00:00:00 2001
|
|
From: Luo Jie <quic_luoj@quicinc.com>
|
|
Date: Wed, 27 Dec 2023 14:11:40 +0800
|
|
Subject: [PATCH 24/50] net: ethernet: qualcomm: Add PPE port control config
|
|
|
|
1. Initialize and setup the physical port.
|
|
2. Configure the default action as drop when the packet size
|
|
is more than the configured MTU of physical port.
|
|
|
|
Change-Id: Id98aea7b17556f85021905978b3403ca6d427557
|
|
Signed-off-by: Luo Jie <quic_luoj@quicinc.com>
|
|
---
|
|
.../net/ethernet/qualcomm/ppe/ppe_config.c | 91 ++++++++++++++++++-
|
|
.../net/ethernet/qualcomm/ppe/ppe_config.h | 11 +++
|
|
drivers/net/ethernet/qualcomm/ppe/ppe_regs.h | 50 ++++++++++
|
|
3 files changed, 151 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/drivers/net/ethernet/qualcomm/ppe/ppe_config.c b/drivers/net/ethernet/qualcomm/ppe/ppe_config.c
|
|
index a8e7a536a6e0..18296a449d4e 100644
|
|
--- a/drivers/net/ethernet/qualcomm/ppe/ppe_config.c
|
|
+++ b/drivers/net/ethernet/qualcomm/ppe/ppe_config.c
|
|
@@ -1238,6 +1238,50 @@ int ppe_servcode_config_set(struct ppe_device *ppe_dev, int servcode,
|
|
return regmap_write(ppe_dev->regmap, reg, val);
|
|
}
|
|
|
|
+/**
|
|
+ * ppe_counter_set - Set PPE port counter enabled or not
|
|
+ * @ppe_dev: PPE device
|
|
+ * @port: PPE port ID
|
|
+ * @enable: Counter status
|
|
+ *
|
|
+ * PPE port counter is optionally configured as enabled or not.
|
|
+ *
|
|
+ * Return 0 on success, negative error code on failure.
|
|
+ */
|
|
+int ppe_counter_set(struct ppe_device *ppe_dev, int port, bool enable)
|
|
+{
|
|
+ u32 reg, val, mru_mtu_val[3];
|
|
+ int ret;
|
|
+
|
|
+ reg = PPE_MRU_MTU_CTRL_TBL_ADDR + PPE_MRU_MTU_CTRL_TBL_INC * port;
|
|
+ ret = regmap_bulk_read(ppe_dev->regmap, reg,
|
|
+ mru_mtu_val, ARRAY_SIZE(mru_mtu_val));
|
|
+ if (ret)
|
|
+ return ret;
|
|
+
|
|
+ PPE_MRU_MTU_CTRL_SET_RX_CNT_EN(mru_mtu_val, enable);
|
|
+ PPE_MRU_MTU_CTRL_SET_TX_CNT_EN(mru_mtu_val, enable);
|
|
+ ret = regmap_bulk_write(ppe_dev->regmap, reg,
|
|
+ mru_mtu_val, ARRAY_SIZE(mru_mtu_val));
|
|
+ if (ret)
|
|
+ return ret;
|
|
+
|
|
+ reg = PPE_MC_MTU_CTRL_TBL_ADDR + PPE_MC_MTU_CTRL_TBL_INC * port;
|
|
+ val = FIELD_PREP(PPE_MC_MTU_CTRL_TBL_TX_CNT_EN, enable);
|
|
+ ret = regmap_update_bits(ppe_dev->regmap, reg,
|
|
+ PPE_MC_MTU_CTRL_TBL_TX_CNT_EN,
|
|
+ val);
|
|
+ if (ret)
|
|
+ return ret;
|
|
+
|
|
+ reg = PPE_PORT_EG_VLAN_ADDR + PPE_PORT_EG_VLAN_INC * port;
|
|
+ val = FIELD_PREP(PPE_PORT_EG_VLAN_TX_COUNTING_EN, enable);
|
|
+
|
|
+ return regmap_update_bits(ppe_dev->regmap, reg,
|
|
+ PPE_PORT_EG_VLAN_TX_COUNTING_EN,
|
|
+ val);
|
|
+}
|
|
+
|
|
static int ppe_config_bm_threshold(struct ppe_device *ppe_dev, int bm_port_id,
|
|
struct ppe_bm_port_config port_cfg)
|
|
{
|
|
@@ -1659,6 +1703,47 @@ static int ppe_servcode_init(struct ppe_device *ppe_dev)
|
|
return ppe_servcode_config_set(ppe_dev, PPE_EDMA_SC_BYPASS_ID, servcode_cfg);
|
|
}
|
|
|
|
+/* Initialize PPE port configurations. */
|
|
+static int ppe_port_ctrl_init(struct ppe_device *ppe_dev)
|
|
+{
|
|
+ u32 reg, val, mru_mtu_val[3];
|
|
+ int i, ret;
|
|
+
|
|
+ for (i = 1; i < ppe_dev->num_ports; i++) {
|
|
+ /* Enable PPE port counter */
|
|
+ ret = ppe_counter_set(ppe_dev, i, true);
|
|
+ if (ret)
|
|
+ return ret;
|
|
+
|
|
+ reg = PPE_MRU_MTU_CTRL_TBL_ADDR + PPE_MRU_MTU_CTRL_TBL_INC * i;
|
|
+ ret = regmap_bulk_read(ppe_dev->regmap, reg,
|
|
+ mru_mtu_val, ARRAY_SIZE(mru_mtu_val));
|
|
+ if (ret)
|
|
+ return ret;
|
|
+
|
|
+ /* Drop the packet when the packet size is more than
|
|
+ * the MTU or MRU of the physical PPE port.
|
|
+ */
|
|
+ PPE_MRU_MTU_CTRL_SET_MRU_CMD(mru_mtu_val, PPE_ACTION_DROP);
|
|
+ PPE_MRU_MTU_CTRL_SET_MTU_CMD(mru_mtu_val, PPE_ACTION_DROP);
|
|
+ ret = regmap_bulk_write(ppe_dev->regmap, reg,
|
|
+ mru_mtu_val, ARRAY_SIZE(mru_mtu_val));
|
|
+ if (ret)
|
|
+ return ret;
|
|
+
|
|
+ reg = PPE_MC_MTU_CTRL_TBL_ADDR + PPE_MC_MTU_CTRL_TBL_INC * i;
|
|
+ val = FIELD_PREP(PPE_MC_MTU_CTRL_TBL_MTU_CMD, PPE_ACTION_DROP);
|
|
+ ret = regmap_update_bits(ppe_dev->regmap, reg,
|
|
+ PPE_MC_MTU_CTRL_TBL_MTU_CMD,
|
|
+ val);
|
|
+ if (ret)
|
|
+ return ret;
|
|
+ }
|
|
+
|
|
+ /* Enable CPU port counter. */
|
|
+ return ppe_counter_set(ppe_dev, 0, true);
|
|
+}
|
|
+
|
|
/* Initialize PPE device to handle traffic correctly. */
|
|
static int ppe_dev_hw_init(struct ppe_device *ppe_dev)
|
|
{
|
|
@@ -1668,7 +1753,11 @@ static int ppe_dev_hw_init(struct ppe_device *ppe_dev)
|
|
if (ret)
|
|
return ret;
|
|
|
|
- return ppe_servcode_init(ppe_dev);
|
|
+ ret = ppe_servcode_init(ppe_dev);
|
|
+ if (ret)
|
|
+ return ret;
|
|
+
|
|
+ return ppe_port_ctrl_init(ppe_dev);
|
|
}
|
|
|
|
int ppe_hw_config(struct ppe_device *ppe_dev)
|
|
diff --git a/drivers/net/ethernet/qualcomm/ppe/ppe_config.h b/drivers/net/ethernet/qualcomm/ppe/ppe_config.h
|
|
index dcb557ed843c..7f5d92c39dd3 100644
|
|
--- a/drivers/net/ethernet/qualcomm/ppe/ppe_config.h
|
|
+++ b/drivers/net/ethernet/qualcomm/ppe/ppe_config.h
|
|
@@ -192,6 +192,16 @@ struct ppe_servcode_cfg {
|
|
int offset_sel;
|
|
};
|
|
|
|
+/* The action of packet received by PPE can be forwarded, dropped, copied
|
|
+ * to CPU (enter multicast queue), redirected to CPU (enter unicast queue).
|
|
+ */
|
|
+enum ppe_action_type {
|
|
+ PPE_ACTION_FORWARD = 0,
|
|
+ PPE_ACTION_DROP = 1,
|
|
+ PPE_ACTION_COPY_TO_CPU = 2,
|
|
+ PPE_ACTION_REDIRECT_TO_CPU = 3,
|
|
+};
|
|
+
|
|
int ppe_hw_config(struct ppe_device *ppe_dev);
|
|
int ppe_queue_scheduler_set(struct ppe_device *ppe_dev,
|
|
int node_id, bool flow_level, int port,
|
|
@@ -216,4 +226,5 @@ int ppe_port_resource_get(struct ppe_device *ppe_dev, int port, int type,
|
|
int ppe_servcode_config_set(struct ppe_device *ppe_dev,
|
|
int servcode,
|
|
struct ppe_servcode_cfg cfg);
|
|
+int ppe_counter_set(struct ppe_device *ppe_dev, int port, bool enable);
|
|
#endif
|
|
diff --git a/drivers/net/ethernet/qualcomm/ppe/ppe_regs.h b/drivers/net/ethernet/qualcomm/ppe/ppe_regs.h
|
|
index 3122743af98d..e981a1c0e670 100644
|
|
--- a/drivers/net/ethernet/qualcomm/ppe/ppe_regs.h
|
|
+++ b/drivers/net/ethernet/qualcomm/ppe/ppe_regs.h
|
|
@@ -18,6 +18,11 @@
|
|
#define PPE_BM_SCH_CTRL_SCH_OFFSET GENMASK(14, 8)
|
|
#define PPE_BM_SCH_CTRL_SCH_EN BIT(31)
|
|
|
|
+#define PPE_RX_FIFO_CFG_ADDR 0xb004
|
|
+#define PPE_RX_FIFO_CFG_NUM 8
|
|
+#define PPE_RX_FIFO_CFG_INC 4
|
|
+#define PPE_RX_FIFO_CFG_THRSH GENMASK(2, 0)
|
|
+
|
|
#define PPE_BM_SCH_CFG_TBL_ADDR 0xc000
|
|
#define PPE_BM_SCH_CFG_TBL_NUM 128
|
|
#define PPE_BM_SCH_CFG_TBL_INC 0x10
|
|
@@ -39,6 +44,17 @@
|
|
#define PPE_SERVICE_SET_RX_CNT_EN(tbl_cfg, value) \
|
|
u32p_replace_bits((u32 *)(tbl_cfg) + 0x1, value, PPE_SERVICE_W1_RX_CNT_EN)
|
|
|
|
+#define PPE_PORT_EG_VLAN_ADDR 0x20020
|
|
+#define PPE_PORT_EG_VLAN_NUM 8
|
|
+#define PPE_PORT_EG_VLAN_INC 4
|
|
+#define PPE_PORT_EG_VLAN_VLAN_TYPE BIT(0)
|
|
+#define PPE_PORT_EG_VLAN_CTAG_MODE GENMASK(2, 1)
|
|
+#define PPE_PORT_EG_VLAN_STAG_MODE GENMASK(4, 3)
|
|
+#define PPE_PORT_EG_VLAN_VSI_TAG_MODE_EN BIT(5)
|
|
+#define PPE_PORT_EG_VLAN_PCP_PROP_CMD BIT(6)
|
|
+#define PPE_PORT_EG_VLAN_DEI_PROP_CMD BIT(7)
|
|
+#define PPE_PORT_EG_VLAN_TX_COUNTING_EN BIT(8)
|
|
+
|
|
#define PPE_EG_BRIDGE_CONFIG_ADDR 0x20044
|
|
#define PPE_EG_BRIDGE_CONFIG_QUEUE_CNT_EN BIT(2)
|
|
|
|
@@ -63,6 +79,40 @@
|
|
#define PPE_EG_SERVICE_SET_TX_CNT_EN(tbl_cfg, value) \
|
|
u32p_replace_bits((u32 *)(tbl_cfg) + 0x1, value, PPE_EG_SERVICE_W1_TX_CNT_EN)
|
|
|
|
+#define PPE_MC_MTU_CTRL_TBL_ADDR 0x60a00
|
|
+#define PPE_MC_MTU_CTRL_TBL_NUM 8
|
|
+#define PPE_MC_MTU_CTRL_TBL_INC 4
|
|
+#define PPE_MC_MTU_CTRL_TBL_MTU GENMASK(13, 0)
|
|
+#define PPE_MC_MTU_CTRL_TBL_MTU_CMD GENMASK(15, 14)
|
|
+#define PPE_MC_MTU_CTRL_TBL_TX_CNT_EN BIT(16)
|
|
+
|
|
+/* PPE port control configuration, the MTU and MRU configs. */
|
|
+#define PPE_MRU_MTU_CTRL_TBL_ADDR 0x65000
|
|
+#define PPE_MRU_MTU_CTRL_TBL_NUM 256
|
|
+#define PPE_MRU_MTU_CTRL_TBL_INC 0x10
|
|
+#define PPE_MRU_MTU_CTRL_W0_MRU GENMASK(13, 0)
|
|
+#define PPE_MRU_MTU_CTRL_W0_MRU_CMD GENMASK(15, 14)
|
|
+#define PPE_MRU_MTU_CTRL_W0_MTU GENMASK(29, 16)
|
|
+#define PPE_MRU_MTU_CTRL_W0_MTU_CMD GENMASK(31, 30)
|
|
+#define PPE_MRU_MTU_CTRL_W1_RX_CNT_EN BIT(0)
|
|
+#define PPE_MRU_MTU_CTRL_W1_TX_CNT_EN BIT(1)
|
|
+#define PPE_MRU_MTU_CTRL_W1_SRC_PROFILE GENMASK(3, 2)
|
|
+#define PPE_MRU_MTU_CTRL_W1_INNER_PREC_LOW BIT(31)
|
|
+#define PPE_MRU_MTU_CTRL_W2_INNER_PREC_HIGH GENMASK(1, 0)
|
|
+
|
|
+#define PPE_MRU_MTU_CTRL_SET_MRU(tbl_cfg, value) \
|
|
+ u32p_replace_bits((u32 *)tbl_cfg, value, PPE_MRU_MTU_CTRL_W0_MRU)
|
|
+#define PPE_MRU_MTU_CTRL_SET_MRU_CMD(tbl_cfg, value) \
|
|
+ u32p_replace_bits((u32 *)tbl_cfg, value, PPE_MRU_MTU_CTRL_W0_MRU_CMD)
|
|
+#define PPE_MRU_MTU_CTRL_SET_MTU(tbl_cfg, value) \
|
|
+ u32p_replace_bits((u32 *)tbl_cfg, value, PPE_MRU_MTU_CTRL_W0_MTU)
|
|
+#define PPE_MRU_MTU_CTRL_SET_MTU_CMD(tbl_cfg, value) \
|
|
+ u32p_replace_bits((u32 *)tbl_cfg, value, PPE_MRU_MTU_CTRL_W0_MTU_CMD)
|
|
+#define PPE_MRU_MTU_CTRL_SET_RX_CNT_EN(tbl_cfg, value) \
|
|
+ u32p_replace_bits((u32 *)(tbl_cfg) + 0x1, value, PPE_MRU_MTU_CTRL_W1_RX_CNT_EN)
|
|
+#define PPE_MRU_MTU_CTRL_SET_TX_CNT_EN(tbl_cfg, value) \
|
|
+ u32p_replace_bits((u32 *)(tbl_cfg) + 0x1, value, PPE_MRU_MTU_CTRL_W1_TX_CNT_EN)
|
|
+
|
|
#define PPE_IN_L2_SERVICE_TBL_ADDR 0x66000
|
|
#define PPE_IN_L2_SERVICE_TBL_NUM 256
|
|
#define PPE_IN_L2_SERVICE_TBL_INC 0x10
|
|
--
|
|
2.45.2
|
|
|