Skip to content

Commit fa99608

Browse files
Luo JiePaolo Abeni
authored andcommitted
net: ethernet: qualcomm: Initialize PPE queue to Ethernet DMA ring mapping
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 <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent 1c46c3c commit fa99608

File tree

3 files changed

+57
-1
lines changed

3 files changed

+57
-1
lines changed

drivers/net/ethernet/qualcomm/ppe/ppe_config.c

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1357,6 +1357,28 @@ int ppe_rss_hash_config_set(struct ppe_device *ppe_dev, int mode,
13571357
return 0;
13581358
}
13591359

1360+
/**
1361+
* ppe_ring_queue_map_set - Set the PPE queue to Ethernet DMA ring mapping
1362+
* @ppe_dev: PPE device
1363+
* @ring_id: Ethernet DMA ring ID
1364+
* @queue_map: Bit map of queue IDs to given Ethernet DMA ring
1365+
*
1366+
* Configure the mapping from a set of PPE queues to a given Ethernet DMA ring.
1367+
*
1368+
* Return: 0 on success, negative error code on failure.
1369+
*/
1370+
int ppe_ring_queue_map_set(struct ppe_device *ppe_dev, int ring_id, u32 *queue_map)
1371+
{
1372+
u32 reg, queue_bitmap_val[PPE_RING_TO_QUEUE_BITMAP_WORD_CNT];
1373+
1374+
memcpy(queue_bitmap_val, queue_map, sizeof(queue_bitmap_val));
1375+
reg = PPE_RING_Q_MAP_TBL_ADDR + PPE_RING_Q_MAP_TBL_INC * ring_id;
1376+
1377+
return regmap_bulk_write(ppe_dev->regmap, reg,
1378+
queue_bitmap_val,
1379+
ARRAY_SIZE(queue_bitmap_val));
1380+
}
1381+
13601382
static int ppe_config_bm_threshold(struct ppe_device *ppe_dev, int bm_port_id,
13611383
const struct ppe_bm_port_config port_cfg)
13621384
{
@@ -1879,6 +1901,25 @@ static int ppe_rss_hash_init(struct ppe_device *ppe_dev)
18791901
return ppe_rss_hash_config_set(ppe_dev, PPE_RSS_HASH_MODE_IPV6, hash_cfg);
18801902
}
18811903

1904+
/* Initialize mapping between PPE queues assigned to CPU port 0
1905+
* to Ethernet DMA ring 0.
1906+
*/
1907+
static int ppe_queues_to_ring_init(struct ppe_device *ppe_dev)
1908+
{
1909+
u32 queue_bmap[PPE_RING_TO_QUEUE_BITMAP_WORD_CNT] = {};
1910+
int ret, queue_id, queue_max;
1911+
1912+
ret = ppe_port_resource_get(ppe_dev, 0, PPE_RES_UCAST,
1913+
&queue_id, &queue_max);
1914+
if (ret)
1915+
return ret;
1916+
1917+
for (; queue_id <= queue_max; queue_id++)
1918+
queue_bmap[queue_id / 32] |= BIT_MASK(queue_id % 32);
1919+
1920+
return ppe_ring_queue_map_set(ppe_dev, 0, queue_bmap);
1921+
}
1922+
18821923
int ppe_hw_config(struct ppe_device *ppe_dev)
18831924
{
18841925
int ret;
@@ -1907,5 +1948,9 @@ int ppe_hw_config(struct ppe_device *ppe_dev)
19071948
if (ret)
19081949
return ret;
19091950

1910-
return ppe_rss_hash_init(ppe_dev);
1951+
ret = ppe_rss_hash_init(ppe_dev);
1952+
if (ret)
1953+
return ret;
1954+
1955+
return ppe_queues_to_ring_init(ppe_dev);
19111956
}

drivers/net/ethernet/qualcomm/ppe/ppe_config.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
#define PPE_RSS_HASH_IP_LENGTH 4
3030
#define PPE_RSS_HASH_TUPLES 5
3131

32+
/* PPE supports 300 queues, each bit presents as one queue. */
33+
#define PPE_RING_TO_QUEUE_BITMAP_WORD_CNT 10
34+
3235
/**
3336
* enum ppe_scheduler_frame_mode - PPE scheduler frame mode.
3437
* @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,
308311
int ppe_counter_enable_set(struct ppe_device *ppe_dev, int port);
309312
int ppe_rss_hash_config_set(struct ppe_device *ppe_dev, int mode,
310313
struct ppe_rss_hash_cfg hash_cfg);
314+
int ppe_ring_queue_map_set(struct ppe_device *ppe_dev,
315+
int ring_id,
316+
u32 *queue_map);
311317
#endif

drivers/net/ethernet/qualcomm/ppe/ppe_regs.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,11 @@
207207
#define PPE_L0_COMP_CFG_TBL_SHAPER_METER_LEN GENMASK(1, 0)
208208
#define PPE_L0_COMP_CFG_TBL_NODE_METER_LEN GENMASK(3, 2)
209209

210+
/* PPE queue to Ethernet DMA ring mapping table. */
211+
#define PPE_RING_Q_MAP_TBL_ADDR 0x42a000
212+
#define PPE_RING_Q_MAP_TBL_ENTRIES 24
213+
#define PPE_RING_Q_MAP_TBL_INC 0x40
214+
210215
/* Table addresses for per-queue dequeue setting. */
211216
#define PPE_DEQ_OPR_TBL_ADDR 0x430000
212217
#define PPE_DEQ_OPR_TBL_ENTRIES 300

0 commit comments

Comments
 (0)