103-26-net-ethernet-qualcomm-Add-PPE-queue-map-function.patch 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. From 809513a92e3aef6ae852b35e118408059929d6d3 Mon Sep 17 00:00:00 2001
  2. From: Luo Jie <[email protected]>
  3. Date: Wed, 27 Dec 2023 15:44:37 +0800
  4. Subject: [PATCH 26/50] net: ethernet: qualcomm: Add PPE queue map function
  5. Configure the queues of CPU port mapped with the EDMA ring.
  6. All queues of CPU port are mappled to the EDMA ring 0 by default,
  7. which can be updated by EDMA driver.
  8. Change-Id: I87ab4117af86e4b3fe7a4b41490ba8ac71ce29ef
  9. Signed-off-by: Luo Jie <[email protected]>
  10. ---
  11. drivers/net/ethernet/qualcomm/ppe/ppe_api.c | 23 ++++++++++
  12. drivers/net/ethernet/qualcomm/ppe/ppe_api.h | 2 +
  13. .../net/ethernet/qualcomm/ppe/ppe_config.c | 45 ++++++++++++++++++-
  14. .../net/ethernet/qualcomm/ppe/ppe_config.h | 5 +++
  15. drivers/net/ethernet/qualcomm/ppe/ppe_regs.h | 5 +++
  16. 5 files changed, 79 insertions(+), 1 deletion(-)
  17. diff --git a/drivers/net/ethernet/qualcomm/ppe/ppe_api.c b/drivers/net/ethernet/qualcomm/ppe/ppe_api.c
  18. index 72d416e0ca44..6199c7025f66 100644
  19. --- a/drivers/net/ethernet/qualcomm/ppe/ppe_api.c
  20. +++ b/drivers/net/ethernet/qualcomm/ppe/ppe_api.c
  21. @@ -82,3 +82,26 @@ int ppe_edma_queue_resource_get(struct ppe_device *ppe_dev, int type,
  22. return ppe_port_resource_get(ppe_dev, 0, type, res_start, res_end);
  23. };
  24. +
  25. +/**
  26. + * ppe_edma_ring_to_queues_config - Map EDMA ring to PPE queues
  27. + * @ppe_dev: PPE device
  28. + * @ring_id: EDMA ring ID
  29. + * @num: Number of queues mapped to EDMA ring
  30. + * @queues: PPE queue IDs
  31. + *
  32. + * PPE queues are configured to map with the special EDMA ring ID.
  33. + *
  34. + * Return 0 on success, negative error code on failure.
  35. + */
  36. +int ppe_edma_ring_to_queues_config(struct ppe_device *ppe_dev, int ring_id,
  37. + int num, int queues[] __counted_by(num))
  38. +{
  39. + u32 queue_bmap[PPE_RING_MAPPED_BP_QUEUE_WORD_COUNT] = {};
  40. + int index;
  41. +
  42. + for (index = 0; index < num; index++)
  43. + queue_bmap[queues[index] / 32] |= BIT_MASK(queues[index] % 32);
  44. +
  45. + return ppe_ring_queue_map_set(ppe_dev, ring_id, queue_bmap);
  46. +}
  47. diff --git a/drivers/net/ethernet/qualcomm/ppe/ppe_api.h b/drivers/net/ethernet/qualcomm/ppe/ppe_api.h
  48. index ecdae4b95667..2135b5383bcd 100644
  49. --- a/drivers/net/ethernet/qualcomm/ppe/ppe_api.h
  50. +++ b/drivers/net/ethernet/qualcomm/ppe/ppe_api.h
  51. @@ -55,4 +55,6 @@ int ppe_edma_queue_offset_config(struct ppe_device *ppe_dev,
  52. int index, int queue_offset);
  53. int ppe_edma_queue_resource_get(struct ppe_device *ppe_dev, int type,
  54. int *res_start, int *res_end);
  55. +int ppe_edma_ring_to_queues_config(struct ppe_device *ppe_dev, int ring_id,
  56. + int num, int queues[] __counted_by(num));
  57. #endif
  58. diff --git a/drivers/net/ethernet/qualcomm/ppe/ppe_config.c b/drivers/net/ethernet/qualcomm/ppe/ppe_config.c
  59. index 4363ea3cfb90..a19a6472e4ed 100644
  60. --- a/drivers/net/ethernet/qualcomm/ppe/ppe_config.c
  61. +++ b/drivers/net/ethernet/qualcomm/ppe/ppe_config.c
  62. @@ -1419,6 +1419,28 @@ int ppe_rss_hash_config_set(struct ppe_device *ppe_dev, int mode,
  63. return 0;
  64. }
  65. +/**
  66. + * ppe_ring_queue_map_set - Set PPE queue mapped with EDMA ring
  67. + * @ppe_dev: PPE device
  68. + * @ring_id: EDMA ring ID
  69. + * @queue_map: Queue bit map
  70. + *
  71. + * PPE queue is configured to use the special Ring.
  72. + *
  73. + * Return 0 on success, negative error code on failure.
  74. + */
  75. +int ppe_ring_queue_map_set(struct ppe_device *ppe_dev, int ring_id, u32 *queue_map)
  76. +{
  77. + u32 reg, queue_bitmap_val[PPE_RING_MAPPED_BP_QUEUE_WORD_COUNT];
  78. +
  79. + memcpy(queue_bitmap_val, queue_map, sizeof(queue_bitmap_val));
  80. + reg = PPE_RING_Q_MAP_TBL_ADDR + PPE_RING_Q_MAP_TBL_INC * ring_id;
  81. +
  82. + return regmap_bulk_write(ppe_dev->regmap, reg,
  83. + queue_bitmap_val,
  84. + ARRAY_SIZE(queue_bitmap_val));
  85. +}
  86. +
  87. static int ppe_config_bm_threshold(struct ppe_device *ppe_dev, int bm_port_id,
  88. struct ppe_bm_port_config port_cfg)
  89. {
  90. @@ -1918,6 +1940,23 @@ static int ppe_rss_hash_init(struct ppe_device *ppe_dev)
  91. return ppe_rss_hash_config_set(ppe_dev, PPE_RSS_HASH_MODE_IPV6, hash_cfg);
  92. }
  93. +/* Initialize queues of CPU port mapped with EDMA ring 0. */
  94. +static int ppe_queues_to_ring_init(struct ppe_device *ppe_dev)
  95. +{
  96. + u32 queue_bmap[PPE_RING_MAPPED_BP_QUEUE_WORD_COUNT] = {};
  97. + int ret, queue_id, queue_max;
  98. +
  99. + ret = ppe_port_resource_get(ppe_dev, 0, PPE_RES_UCAST,
  100. + &queue_id, &queue_max);
  101. + if (ret)
  102. + return ret;
  103. +
  104. + for (; queue_id <= queue_max; queue_id++)
  105. + queue_bmap[queue_id / 32] |= BIT_MASK(queue_id % 32);
  106. +
  107. + return ppe_ring_queue_map_set(ppe_dev, 0, queue_bmap);
  108. +}
  109. +
  110. /* Initialize PPE device to handle traffic correctly. */
  111. static int ppe_dev_hw_init(struct ppe_device *ppe_dev)
  112. {
  113. @@ -1935,7 +1974,11 @@ static int ppe_dev_hw_init(struct ppe_device *ppe_dev)
  114. if (ret)
  115. return ret;
  116. - return ppe_rss_hash_init(ppe_dev);
  117. + ret = ppe_rss_hash_init(ppe_dev);
  118. + if (ret)
  119. + return ret;
  120. +
  121. + return ppe_queues_to_ring_init(ppe_dev);
  122. }
  123. int ppe_hw_config(struct ppe_device *ppe_dev)
  124. diff --git a/drivers/net/ethernet/qualcomm/ppe/ppe_config.h b/drivers/net/ethernet/qualcomm/ppe/ppe_config.h
  125. index 6dd91bc45908..9be749800f14 100644
  126. --- a/drivers/net/ethernet/qualcomm/ppe/ppe_config.h
  127. +++ b/drivers/net/ethernet/qualcomm/ppe/ppe_config.h
  128. @@ -20,6 +20,8 @@
  129. #define PPE_RSS_HASH_IP_LENGTH 4
  130. #define PPE_RSS_HASH_TUPLES 5
  131. +#define PPE_RING_MAPPED_BP_QUEUE_WORD_COUNT 10
  132. +
  133. /**
  134. * struct ppe_qos_scheduler_cfg - PPE QoS scheduler configuration.
  135. * @flow_id: PPE flow ID.
  136. @@ -263,4 +265,7 @@ int ppe_servcode_config_set(struct ppe_device *ppe_dev,
  137. int ppe_counter_set(struct ppe_device *ppe_dev, int port, bool enable);
  138. int ppe_rss_hash_config_set(struct ppe_device *ppe_dev, int mode,
  139. struct ppe_rss_hash_cfg hash_cfg);
  140. +int ppe_ring_queue_map_set(struct ppe_device *ppe_dev,
  141. + int ring_id,
  142. + u32 *queue_map);
  143. #endif
  144. diff --git a/drivers/net/ethernet/qualcomm/ppe/ppe_regs.h b/drivers/net/ethernet/qualcomm/ppe/ppe_regs.h
  145. index 29001a2599d8..8c6cd6b52b0f 100644
  146. --- a/drivers/net/ethernet/qualcomm/ppe/ppe_regs.h
  147. +++ b/drivers/net/ethernet/qualcomm/ppe/ppe_regs.h
  148. @@ -212,6 +212,11 @@
  149. #define PPE_L0_COMP_CFG_TBL_SHAPER_METER_LEN GENMASK(1, 0)
  150. #define PPE_L0_COMP_CFG_TBL_NODE_METER_LEN GENMASK(3, 2)
  151. +/* PPE queue bitmap. */
  152. +#define PPE_RING_Q_MAP_TBL_ADDR 0x42a000
  153. +#define PPE_RING_Q_MAP_TBL_NUM 24
  154. +#define PPE_RING_Q_MAP_TBL_INC 0x40
  155. +
  156. #define PPE_DEQ_OPR_TBL_ADDR 0x430000
  157. #define PPE_DEQ_OPR_TBL_NUM 300
  158. #define PPE_DEQ_OPR_TBL_INC 0x10
  159. --
  160. 2.45.2