]> www.infradead.org Git - users/willy/linux.git/commitdiff
net: ethernet: qualcomm: Initialize PPE queue to Ethernet DMA ring mapping
authorLuo Jie <quic_luoj@quicinc.com>
Mon, 18 Aug 2025 13:14:35 +0000 (21:14 +0800)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 21 Aug 2025 10:38:41 +0000 (12:38 +0200)
Configure the selected queues to map with an Ethernet DMA ring for the
packet to receive on ARM cores.

As default initialization, all queues assigned to CPU port 0 are mapped
to the EDMA ring 0. This configuration is later updated during Ethernet
DMA initialization.

Signed-off-by: Luo Jie <quic_luoj@quicinc.com>
Link: https://patch.msgid.link/20250818-qcom_ipq_ppe-v8-11-1d4ff641fce9@quicinc.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/ethernet/qualcomm/ppe/ppe_config.c
drivers/net/ethernet/qualcomm/ppe/ppe_config.h
drivers/net/ethernet/qualcomm/ppe/ppe_regs.h

index a794ccd3b517103f9db47e22337a413ce5cacd8b..928fc087926934497994b6e1f97b38e1af8904ba 100644 (file)
@@ -1357,6 +1357,28 @@ int ppe_rss_hash_config_set(struct ppe_device *ppe_dev, int mode,
        return 0;
 }
 
+/**
+ * ppe_ring_queue_map_set - Set the PPE queue to Ethernet DMA ring mapping
+ * @ppe_dev: PPE device
+ * @ring_id: Ethernet DMA ring ID
+ * @queue_map: Bit map of queue IDs to given Ethernet DMA ring
+ *
+ * Configure the mapping from a set of PPE queues to a given Ethernet DMA ring.
+ *
+ * Return: 0 on success, negative error code on failure.
+ */
+int ppe_ring_queue_map_set(struct ppe_device *ppe_dev, int ring_id, u32 *queue_map)
+{
+       u32 reg, queue_bitmap_val[PPE_RING_TO_QUEUE_BITMAP_WORD_CNT];
+
+       memcpy(queue_bitmap_val, queue_map, sizeof(queue_bitmap_val));
+       reg = PPE_RING_Q_MAP_TBL_ADDR + PPE_RING_Q_MAP_TBL_INC * ring_id;
+
+       return regmap_bulk_write(ppe_dev->regmap, reg,
+                                queue_bitmap_val,
+                                ARRAY_SIZE(queue_bitmap_val));
+}
+
 static int ppe_config_bm_threshold(struct ppe_device *ppe_dev, int bm_port_id,
                                   const struct ppe_bm_port_config port_cfg)
 {
@@ -1879,6 +1901,25 @@ static int ppe_rss_hash_init(struct ppe_device *ppe_dev)
        return ppe_rss_hash_config_set(ppe_dev, PPE_RSS_HASH_MODE_IPV6, hash_cfg);
 }
 
+/* Initialize mapping between PPE queues assigned to CPU port 0
+ * to Ethernet DMA ring 0.
+ */
+static int ppe_queues_to_ring_init(struct ppe_device *ppe_dev)
+{
+       u32 queue_bmap[PPE_RING_TO_QUEUE_BITMAP_WORD_CNT] = {};
+       int ret, queue_id, queue_max;
+
+       ret = ppe_port_resource_get(ppe_dev, 0, PPE_RES_UCAST,
+                                   &queue_id, &queue_max);
+       if (ret)
+               return ret;
+
+       for (; queue_id <= queue_max; queue_id++)
+               queue_bmap[queue_id / 32] |= BIT_MASK(queue_id % 32);
+
+       return ppe_ring_queue_map_set(ppe_dev, 0, queue_bmap);
+}
+
 int ppe_hw_config(struct ppe_device *ppe_dev)
 {
        int ret;
@@ -1907,5 +1948,9 @@ int ppe_hw_config(struct ppe_device *ppe_dev)
        if (ret)
                return ret;
 
-       return ppe_rss_hash_init(ppe_dev);
+       ret = ppe_rss_hash_init(ppe_dev);
+       if (ret)
+               return ret;
+
+       return ppe_queues_to_ring_init(ppe_dev);
 }
index eb4a82375bb2c1af7757424a8fc56e80b7ce47dc..4bb45ca40144f1534447cac0a7840d449013978a 100644 (file)
@@ -29,6 +29,9 @@
 #define PPE_RSS_HASH_IP_LENGTH                 4
 #define PPE_RSS_HASH_TUPLES                    5
 
+/* PPE supports 300 queues, each bit presents as one queue. */
+#define PPE_RING_TO_QUEUE_BITMAP_WORD_CNT      10
+
 /**
  * enum ppe_scheduler_frame_mode - PPE scheduler frame mode.
  * @PPE_SCH_WITH_IPG_PREAMBLE_FRAME_CRC: The scheduled frame includes IPG,
@@ -308,4 +311,7 @@ int ppe_sc_config_set(struct ppe_device *ppe_dev, int sc,
 int ppe_counter_enable_set(struct ppe_device *ppe_dev, int port);
 int ppe_rss_hash_config_set(struct ppe_device *ppe_dev, int mode,
                            struct ppe_rss_hash_cfg hash_cfg);
+int ppe_ring_queue_map_set(struct ppe_device *ppe_dev,
+                          int ring_id,
+                          u32 *queue_map);
 #endif
index 3e9cccedc6bec5f0fb5ee854afabffac590f47cc..224beda046d4d0769a2571f42e5f524c5b396d64 100644 (file)
 #define PPE_L0_COMP_CFG_TBL_SHAPER_METER_LEN   GENMASK(1, 0)
 #define PPE_L0_COMP_CFG_TBL_NODE_METER_LEN     GENMASK(3, 2)
 
+/* PPE queue to Ethernet DMA ring mapping table. */
+#define PPE_RING_Q_MAP_TBL_ADDR                        0x42a000
+#define PPE_RING_Q_MAP_TBL_ENTRIES             24
+#define PPE_RING_Q_MAP_TBL_INC                 0x40
+
 /* Table addresses for per-queue dequeue setting. */
 #define PPE_DEQ_OPR_TBL_ADDR                   0x430000
 #define PPE_DEQ_OPR_TBL_ENTRIES                        300