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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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. --- a/drivers/net/ethernet/qualcomm/ppe/ppe_api.c
  18. +++ b/drivers/net/ethernet/qualcomm/ppe/ppe_api.c
  19. @@ -82,3 +82,26 @@ int ppe_edma_queue_resource_get(struct p
  20. return ppe_port_resource_get(ppe_dev, 0, type, res_start, res_end);
  21. };
  22. +
  23. +/**
  24. + * ppe_edma_ring_to_queues_config - Map EDMA ring to PPE queues
  25. + * @ppe_dev: PPE device
  26. + * @ring_id: EDMA ring ID
  27. + * @num: Number of queues mapped to EDMA ring
  28. + * @queues: PPE queue IDs
  29. + *
  30. + * PPE queues are configured to map with the special EDMA ring ID.
  31. + *
  32. + * Return 0 on success, negative error code on failure.
  33. + */
  34. +int ppe_edma_ring_to_queues_config(struct ppe_device *ppe_dev, int ring_id,
  35. + int num, int queues[] __counted_by(num))
  36. +{
  37. + u32 queue_bmap[PPE_RING_MAPPED_BP_QUEUE_WORD_COUNT] = {};
  38. + int index;
  39. +
  40. + for (index = 0; index < num; index++)
  41. + queue_bmap[queues[index] / 32] |= BIT_MASK(queues[index] % 32);
  42. +
  43. + return ppe_ring_queue_map_set(ppe_dev, ring_id, queue_bmap);
  44. +}
  45. --- a/drivers/net/ethernet/qualcomm/ppe/ppe_api.h
  46. +++ b/drivers/net/ethernet/qualcomm/ppe/ppe_api.h
  47. @@ -55,4 +55,6 @@ int ppe_edma_queue_offset_config(struct
  48. int index, int queue_offset);
  49. int ppe_edma_queue_resource_get(struct ppe_device *ppe_dev, int type,
  50. int *res_start, int *res_end);
  51. +int ppe_edma_ring_to_queues_config(struct ppe_device *ppe_dev, int ring_id,
  52. + int num, int queues[] __counted_by(num));
  53. #endif
  54. --- a/drivers/net/ethernet/qualcomm/ppe/ppe_config.c
  55. +++ b/drivers/net/ethernet/qualcomm/ppe/ppe_config.c
  56. @@ -1419,6 +1419,28 @@ int ppe_rss_hash_config_set(struct ppe_d
  57. return 0;
  58. }
  59. +/**
  60. + * ppe_ring_queue_map_set - Set PPE queue mapped with EDMA ring
  61. + * @ppe_dev: PPE device
  62. + * @ring_id: EDMA ring ID
  63. + * @queue_map: Queue bit map
  64. + *
  65. + * PPE queue is configured to use the special Ring.
  66. + *
  67. + * Return 0 on success, negative error code on failure.
  68. + */
  69. +int ppe_ring_queue_map_set(struct ppe_device *ppe_dev, int ring_id, u32 *queue_map)
  70. +{
  71. + u32 reg, queue_bitmap_val[PPE_RING_MAPPED_BP_QUEUE_WORD_COUNT];
  72. +
  73. + memcpy(queue_bitmap_val, queue_map, sizeof(queue_bitmap_val));
  74. + reg = PPE_RING_Q_MAP_TBL_ADDR + PPE_RING_Q_MAP_TBL_INC * ring_id;
  75. +
  76. + return regmap_bulk_write(ppe_dev->regmap, reg,
  77. + queue_bitmap_val,
  78. + ARRAY_SIZE(queue_bitmap_val));
  79. +}
  80. +
  81. static int ppe_config_bm_threshold(struct ppe_device *ppe_dev, int bm_port_id,
  82. struct ppe_bm_port_config port_cfg)
  83. {
  84. @@ -1918,6 +1940,23 @@ static int ppe_rss_hash_init(struct ppe_
  85. return ppe_rss_hash_config_set(ppe_dev, PPE_RSS_HASH_MODE_IPV6, hash_cfg);
  86. }
  87. +/* Initialize queues of CPU port mapped with EDMA ring 0. */
  88. +static int ppe_queues_to_ring_init(struct ppe_device *ppe_dev)
  89. +{
  90. + u32 queue_bmap[PPE_RING_MAPPED_BP_QUEUE_WORD_COUNT] = {};
  91. + int ret, queue_id, queue_max;
  92. +
  93. + ret = ppe_port_resource_get(ppe_dev, 0, PPE_RES_UCAST,
  94. + &queue_id, &queue_max);
  95. + if (ret)
  96. + return ret;
  97. +
  98. + for (; queue_id <= queue_max; queue_id++)
  99. + queue_bmap[queue_id / 32] |= BIT_MASK(queue_id % 32);
  100. +
  101. + return ppe_ring_queue_map_set(ppe_dev, 0, queue_bmap);
  102. +}
  103. +
  104. /* Initialize PPE device to handle traffic correctly. */
  105. static int ppe_dev_hw_init(struct ppe_device *ppe_dev)
  106. {
  107. @@ -1935,7 +1974,11 @@ static int ppe_dev_hw_init(struct ppe_de
  108. if (ret)
  109. return ret;
  110. - return ppe_rss_hash_init(ppe_dev);
  111. + ret = ppe_rss_hash_init(ppe_dev);
  112. + if (ret)
  113. + return ret;
  114. +
  115. + return ppe_queues_to_ring_init(ppe_dev);
  116. }
  117. int ppe_hw_config(struct ppe_device *ppe_dev)
  118. --- a/drivers/net/ethernet/qualcomm/ppe/ppe_config.h
  119. +++ b/drivers/net/ethernet/qualcomm/ppe/ppe_config.h
  120. @@ -20,6 +20,8 @@
  121. #define PPE_RSS_HASH_IP_LENGTH 4
  122. #define PPE_RSS_HASH_TUPLES 5
  123. +#define PPE_RING_MAPPED_BP_QUEUE_WORD_COUNT 10
  124. +
  125. /**
  126. * struct ppe_qos_scheduler_cfg - PPE QoS scheduler configuration.
  127. * @flow_id: PPE flow ID.
  128. @@ -263,4 +265,7 @@ int ppe_servcode_config_set(struct ppe_d
  129. int ppe_counter_set(struct ppe_device *ppe_dev, int port, bool enable);
  130. int ppe_rss_hash_config_set(struct ppe_device *ppe_dev, int mode,
  131. struct ppe_rss_hash_cfg hash_cfg);
  132. +int ppe_ring_queue_map_set(struct ppe_device *ppe_dev,
  133. + int ring_id,
  134. + u32 *queue_map);
  135. #endif
  136. --- a/drivers/net/ethernet/qualcomm/ppe/ppe_regs.h
  137. +++ b/drivers/net/ethernet/qualcomm/ppe/ppe_regs.h
  138. @@ -212,6 +212,11 @@
  139. #define PPE_L0_COMP_CFG_TBL_SHAPER_METER_LEN GENMASK(1, 0)
  140. #define PPE_L0_COMP_CFG_TBL_NODE_METER_LEN GENMASK(3, 2)
  141. +/* PPE queue bitmap. */
  142. +#define PPE_RING_Q_MAP_TBL_ADDR 0x42a000
  143. +#define PPE_RING_Q_MAP_TBL_NUM 24
  144. +#define PPE_RING_Q_MAP_TBL_INC 0x40
  145. +
  146. #define PPE_DEQ_OPR_TBL_ADDR 0x430000
  147. #define PPE_DEQ_OPR_TBL_NUM 300
  148. #define PPE_DEQ_OPR_TBL_INC 0x10