RDMA/erdma: Introduce hardware statistics support
Subsystems (2)
Cheng Xu
maintainerv2 cover RDMA/erdma: Introduce hardware statistics support
This small patchset introduces the support of hardware statistics. Statistics counters can not be put in CQEs due to limited CQE size. To address this, we provide an extra dma buffer to hardware when posting statistics query request, and then hardware writes back the response to this dma buffer. Based on this, we add the hardware statistics support of erdma.
- #1 introduces dma pool used for hardware responses of CMDQ requests.
- #2 adds hardware statistics support.
Changes in v2:
- Remove extra layer of erdma_dma_pools_init and erdma_dma_pools_destroy
- Move ERDMA_HW_RESP_SIZE from patch #2 to #1 because it's used in #1
- Remove unrelated change in patch #2
- Remove "hw_" prefix and add "tx_" prefix to some items in erdma_descs
- Use dma_pool_zalloc instead of dma_pool_alloc with __GFP_ZERO flag
- Remove port index check logic in erdma_get_hw_stats
Cheng Xu (2):
RDMA/erdma: Introduce dma pool for hardware responses of CMDQ requests RDMA/erdma: Add hardware statistics support
drivers/infiniband/hw/erdma/erdma.h | 2 + drivers/infiniband/hw/erdma/erdma_hw.h | 39 ++++++++++ drivers/infiniband/hw/erdma/erdma_main.c | 26 ++++++- drivers/infiniband/hw/erdma/erdma_verbs.c | 89 +++++++++++++++++++++++ drivers/infiniband/hw/erdma/erdma_verbs.h | 4 + 5 files changed, 158 insertions(+), 2 deletions(-)
Signature · 1 line
2.31.1
Cheng Xu
maintainerPATCH v2 1/2 RDMA/erdma: Introduce dma pool for hardware responses of CMDQ requests
Hardware response, such as the result of query statistics, may be too long to be directly accommodated within the CQE structure. To address this, we introduce a DMA pool to hold the hardware's responses of CMDQ requests.
--- drivers/infiniband/hw/erdma/erdma.h | 2 ++ drivers/infiniband/hw/erdma/erdma_hw.h | 2 ++ drivers/infiniband/hw/erdma/erdma_main.c | 24 ++++++++++++++++++++++-- 3 files changed, 26 insertions(+), 2 deletions(-)
drivers/infiniband/hw/erdma/erdma.h +2 -0
@@ -212,6 +212,8 @@ struct erdma_dev {atomic_t num_ctx;struct list_head cep_list; + +struct dma_pool *resp_pool; };static inline void *get_queue_entry (void *qbuf,u32 idx,u32 depth,u32 shift)
drivers/infiniband/hw/erdma/erdma_hw.h +2 -0
@@ -357,6 +357,8 @@ struct erdma_cmdq_reflush_req {u32 rq_pi; }; +#define ERDMA_HW_RESP_SIZE 256 +/* cap qword 0 definition */ #define ERDMA_CMD_DEV_CAP_MAX_CQE_MASK GENMASK_ULL(47, 40)#define ERDMA_CMD_DEV_CAP_FLAGS_MASK GENMASK_ULL(31, 24)
drivers/infiniband/hw/erdma/erdma_main.c +22 -2
@@ -172,14 +172,30 @@ static int erdma_device_init(struct erdma_dev *dev, struct pci_dev *pdev) {int ret; + dev->resp_pool =dma_pool_create ("erdma_resp_pool" , &pdev->dev, +ERDMA_HW_RESP_SIZE ,ERDMA_HW_RESP_SIZE , +0 ); +if (!dev->resp_pool) +return -ENOMEM ; + ret =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (ERDMA_PCI_WIDTH ));if (ret) -return ret; + goto destroy_pool;dma_set_max_seg_size (&pdev->dev,UINT_MAX );return 0 ; + +destroy_pool: +dma_pool_destroy (dev->resp_pool); + +return ret; +} + +static void erdma_device_uninit (struct erdma_dev *dev) +{ +dma_pool_destroy (dev->resp_pool); }static void erdma_hw_reset (struct erdma_dev *dev)
@@ -273,7 +289,7 @@ static int erdma_probe_dev(struct pci_dev *pdev) err =erdma_request_vectors (dev);if (err) - goto err_iounmap_func_bar; + goto err_uninit_device; err =erdma_comm_irq_init (dev);if (err)
@@ -314,6 +330,9 @@ static int erdma_probe_dev(struct pci_dev *pdev) err_free_vectors:pci_free_irq_vectors (dev->pdev); +err_uninit_device: +erdma_device_uninit (dev); + err_iounmap_func_bar:devm_iounmap (&pdev->dev, dev->func_bar);
@@ -339,6 +358,7 @@ static void erdma_remove_dev(struct pci_dev *pdev)erdma_aeq_destroy (dev);erdma_comm_irq_uninit (dev);pci_free_irq_vectors (dev->pdev); +erdma_device_uninit (dev);devm_iounmap (&pdev->dev, dev->func_bar);pci_release_selected_regions (pdev,ERDMA_BAR_MASK );
Signature · 1 line
2.31.1
Cheng Xu
maintainerPATCH v2 2/2 RDMA/erdma: Add hardware statistics support
In reply to Cheng XuFirst, we add a new command to query hardware statistics, and then implement two functions: ib_device_ops.alloc_hw_port_stats and ib_device_ops.get_hw_stats to allow rdma tool can get the statistics of erdma device.
--- drivers/infiniband/hw/erdma/erdma_hw.h | 37 ++++++++++ drivers/infiniband/hw/erdma/erdma_main.c | 2 + drivers/infiniband/hw/erdma/erdma_verbs.c | 89 +++++++++++++++++++++++ drivers/infiniband/hw/erdma/erdma_verbs.h | 4 + 4 files changed, 132 insertions(+)
drivers/infiniband/hw/erdma/erdma_hw.h +37 -0
@@ -146,6 +146,7 @@ enum CMDQ_COMMON_OPCODE {CMDQ_OPCODE_DESTROY_EQ =1 ,CMDQ_OPCODE_QUERY_FW_INFO =2 ,CMDQ_OPCODE_CONF_MTU =3 , +CMDQ_OPCODE_GET_STATS =4 ,CMDQ_OPCODE_CONF_DEVICE =5 ,CMDQ_OPCODE_ALLOC_DB =8 , CMDQ_OPCODE_FREE_DB = 9,
@@ -359,6 +360,42 @@ struct erdma_cmdq_reflush_req {#define ERDMA_HW_RESP_SIZE 256 +struct erdma_cmdq_query_req { +u64 hdr; +u32 rsvd; +u32 index; + +u64 target_addr; +u32 target_length; +}; + +#define ERDMA_HW_RESP_MAGIC 0x5566 + +struct erdma_cmdq_query_resp_hdr { +u16 magic; +u8 ver; +u8 length; + +u32 index; +u32 rsvd[2 ]; +}; + +struct erdma_cmdq_query_stats_resp { +struct erdma_cmdq_query_resp_hdr hdr; + +u64 tx_req_cnt; +u64 tx_packets_cnt; +u64 tx_bytes_cnt; +u64 tx_drop_packets_cnt; +u64 tx_bps_meter_drop_packets_cnt; +u64 tx_pps_meter_drop_packets_cnt; +u64 rx_packets_cnt; +u64 rx_bytes_cnt; +u64 rx_drop_packets_cnt; +u64 rx_bps_meter_drop_packets_cnt; +u64 rx_pps_meter_drop_packets_cnt; +}; +/* cap qword 0 definition */ #define ERDMA_CMD_DEV_CAP_MAX_CQE_MASK GENMASK_ULL(47, 40)#define ERDMA_CMD_DEV_CAP_FLAGS_MASK GENMASK_ULL(31, 24)
drivers/infiniband/hw/erdma/erdma_main.c +2 -0
@@ -468,6 +468,7 @@ static const struct ib_device_ops erdma_device_ops = { .driver_id = RDMA_DRIVER_ERDMA, .uverbs_abi_ver = ERDMA_ABI_VERSION, + .alloc_hw_port_stats = erdma_alloc_hw_port_stats, .alloc_mr = erdma_ib_alloc_mr, .alloc_pd = erdma_alloc_pd, .alloc_ucontext = erdma_alloc_ucontext,
@@ -479,6 +480,7 @@ static const struct ib_device_ops erdma_device_ops = { .destroy_cq = erdma_destroy_cq, .destroy_qp = erdma_destroy_qp, .get_dma_mr = erdma_get_dma_mr, + .get_hw_stats = erdma_get_hw_stats, .get_port_immutable = erdma_get_port_immutable, .iw_accept = erdma_accept, .iw_add_ref = erdma_qp_get_ref,
drivers/infiniband/hw/erdma/erdma_verbs.c +89 -0
92 lines not on this page · raw message
drivers/infiniband/hw/erdma/erdma_verbs.h +4 -0
@@ -361,5 +361,9 @@ int erdma_map_mr_sg(struct ib_mr *ibmr, struct scatterlist *sg, int sg_nents, unsigned int *sg_offset);void erdma_port_event (struct erdma_dev *dev,enum ib_event_type reason);void erdma_set_mtu (struct erdma_dev *dev,u32 mtu); +struct rdma_hw_stats *erdma_alloc_hw_port_stats (struct ib_device *device, +u32 port_num); +int erdma_get_hw_stats (struct ib_device *ibdev,struct rdma_hw_stats *stats, +u32 port,int index);#endif
Signature · 1 line
2.31.1
kernel test robot
build botRe: [PATCH for-next v2 2/2] RDMA/erdma: Add hardware statistics support
kernel test robot noticed the following build warnings:
Hi Cheng,
kernel test robot noticed the following build warnings:
[auto build test WARNING on rdma/for-next]
[also build test WARNING on linus/master v6.7-rc7 next-20231222] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Cheng-Xu/RDMA-erdma-Introduce-dma-pool-for-hardware-responses-of-CMDQ-requests/20231225-154653 base: https://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma.git for-next patch link: https://lore.kernel.org/r/20231225032117.7493-3-chengyou%40linux.alibaba.com patch subject: [PATCH for-next v2 2/2] RDMA/erdma: Add hardware statistics support config: s390-allyesconfig (https://download.01.org/0day-ci/archive/20231226/[email protected]/config) compiler: s390-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231226/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
>> drivers/infiniband/hw/erdma/erdma_verbs.c:1750:5: warning: no previous prototype for 'erdma_query_hw_stats' [-Wmissing-prototypes]
1750 | int erdma_query_hw_stats(struct erdma_dev *dev, struct rdma_hw_stats *stats)
| ^~~~~~~~~~~~~~~~~~~~
vim +/erdma_query_hw_stats +1750 drivers/infiniband/hw/erdma/erdma_verbs.c
1749
> 1750 int erdma_query_hw_stats(struct erdma_dev *dev, struct rdma_hw_stats *stats)
1751 {
1752 struct erdma_cmdq_query_stats_resp *resp;
1753 struct erdma_cmdq_query_req req;
1754 dma_addr_t dma_addr;
1755 int err;
1756
1757 erdma_cmdq_build_reqhdr(&req.hdr, CMDQ_SUBMOD_COMMON,
1758 CMDQ_OPCODE_GET_STATS);
1759
1760 resp = dma_pool_zalloc(dev->resp_pool, GFP_KERNEL, &dma_addr);
1761 if (!resp)
1762 return -ENOMEM;
1763
1764 req.target_addr = dma_addr;
1765 req.target_length = ERDMA_HW_RESP_SIZE;
1766
1767 err = erdma_post_cmd_wait(&dev->cmdq, &req, sizeof(req), NULL, NULL);
1768 if (err)
1769 goto out;
1770
1771 if (resp->hdr.magic != ERDMA_HW_RESP_MAGIC) {
1772 err = -EINVAL;
1773 goto out;
1774 }
1775
1776 memcpy(&stats->value[0], &resp->tx_req_cnt,
1777 sizeof(u64) * stats->num_counters);
1778
1779 out:
1780 dma_pool_free(dev->resp_pool, resp, dma_addr);
1781
1782 return err;
1783 }
1784
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Re: [PATCH for-next v2 2/2] RDMA/erdma: Add hardware statistics support
Quoted 23 lines · kernel test robot
Hi Cheng,
kernel test robot noticed the following build warnings:
[auto build test WARNING on rdma/for-next]
[also build test WARNING on linus/master v6.7-rc7 next-20231222] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]url: https://github.com/intel-lab-lkp/linux/commits/Cheng-Xu/RDMA-erdma-Introduce-dma-pool-for-hardware-responses-of-CMDQ-requests/20231225-154653 base: https://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma.git for-next patch link: https://lore.kernel.org/r/20231225032117.7493-3-chengyou%40linux.alibaba.com patch subject: [PATCH for-next v2 2/2] RDMA/erdma: Add hardware statistics support config: s390-allyesconfig (https://download.01.org/0day-ci/archive/20231226/[email protected]/config) compiler: s390-linux-gcc (GCC) 13.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231226/[email protected]/reproduce)If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
Quoted 6 lines
All warnings (new ones prefixed by >>):
Quoted 1 line
Quoted 1 line
drivers/infiniband/hw/erdma/erdma_verbs.c:1750:5: warning: no previous prototype for 'erdma_query_hw_stats' [-Wmissing-prototypes]1750 | int
erdma_query_hw_stats(struct erdma_dev *dev, struct rdma_hw_stats *stats)
| ^~~~~~~~~~~~~~~~~~~~
Prepending "static" can fix this problem.
drivers/infiniband/hw/erdma/erdma_verbs.c +1 -1
@@ -1747,7 +1747,7 @@ struct rdma_hw_stats *erdma_alloc_hw_port_stats(struct ib_device *device, RDMA_HW_STATS_DEFAULT_LIFESPAN); } -int erdma_query_hw_stats (struct erdma_dev *dev,struct rdma_hw_stats *stats) +static int erdma_query_hw_stats (struct erdma_dev *dev,struct rdma_hw_stats *stats) {struct erdma_cmdq_query_stats_resp *resp;struct erdma_cmdq_query_req req;
Quoted 40 lines
vim +/erdma_query_hw_stats +1750
drivers/infiniband/hw/erdma/erdma_verbs.c1749Quoted 1 line
1750 int
erdma_query_hw_stats(struct erdma_dev *dev, struct rdma_hw_stats *stats)1751 { 1752 struct erdma_cmdq_query_stats_resp *resp; 1753 struct erdma_cmdq_query_req req; 1754 dma_addr_t dma_addr; 1755 int err; 1756 1757 erdma_cmdq_build_reqhdr(&req.hdr, CMDQ_SUBMOD_COMMON, 1758 CMDQ_OPCODE_GET_STATS); 1759 1760 resp = dma_pool_zalloc(dev->resp_pool, GFP_KERNEL, &dma_addr); 1761 if (!resp) 1762 return -ENOMEM; 1763 1764 req.target_addr = dma_addr; 1765 req.target_length = ERDMA_HW_RESP_SIZE; 1766 1767 err = erdma_post_cmd_wait(&dev->cmdq, &req, sizeof(req), NULL, NULL); 1768 if (err) 1769 goto out; 1770 1771 if (resp->hdr.magic != ERDMA_HW_RESP_MAGIC) { 1772 err = -EINVAL; 1773 goto out; 1774 } 1775 1776 memcpy(&stats->value[0], &resp->tx_req_cnt, 1777 sizeof(u64) * stats->num_counters); 1778 1779 out: 1780 dma_pool_free(dev->resp_pool, resp, dma_addr); 1781 1782 return err; 1783 } 1784
Cheng Xu
maintainerRe: [PATCH for-next v2 2/2] RDMA/erdma: Add hardware statistics support
Quoted 24 lines · Zhu Yanjun
Quoted 23 lines · kernel test robot
Hi Cheng,
kernel test robot noticed the following build warnings:
[auto build test WARNING on rdma/for-next]
[also build test WARNING on linus/master v6.7-rc7 next-20231222] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]url: https://github.com/intel-lab-lkp/linux/commits/Cheng-Xu/RDMA-erdma-Introduce-dma-pool-for-hardware-responses-of-CMDQ-requests/20231225-154653
base: https://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma.git for-next
patch link: https://lore.kernel.org/r/20231225032117.7493-3-chengyou%40linux.alibaba.com
patch subject: [PATCH for-next v2 2/2] RDMA/erdma: Add hardware statistics support
config: s390-allyesconfig (https://download.01.org/0day-ci/archive/20231226/[email protected]/config)
compiler: s390-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231226/[email protected]/reproduce)If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
Quoted 9 lines
Quoted 6 lines
All warnings (new ones prefixed by >>):
Quoted 1 line
Quoted 1 line
drivers/infiniband/hw/erdma/erdma_verbs.c:1750:5: warning: no previous prototype for 'erdma_query_hw_stats' [-Wmissing-prototypes]1750 | int
erdma_query_hw_stats(struct erdma_dev *dev, struct rdma_hw_stats *stats)| ^~~~~~~~~~~~~~~~~~~~Prepending "static" can fix this problem.
You are right, thanks for your suggestion.
Cheng Xu
kernel test robot
build botRe: [PATCH for-next v2 2/2] RDMA/erdma: Add hardware statistics support
In reply to Cheng Xukernel test robot noticed the following build warnings:
Hi Cheng,
kernel test robot noticed the following build warnings:
[auto build test WARNING on rdma/for-next]
[also build test WARNING on linus/master v6.7-rc7 next-20231222] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Cheng-Xu/RDMA-erdma-Introduce-dma-pool-for-hardware-responses-of-CMDQ-requests/20231225-154653 base: https://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma.git for-next patch link: https://lore.kernel.org/r/20231225032117.7493-3-chengyou%40linux.alibaba.com patch subject: [PATCH for-next v2 2/2] RDMA/erdma: Add hardware statistics support config: x86_64-allyesconfig (https://download.01.org/0day-ci/archive/20231226/[email protected]/config) compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231226/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
>> drivers/infiniband/hw/erdma/erdma_verbs.c:1750:5: warning: no previous prototype for function 'erdma_query_hw_stats' [-Wmissing-prototypes]
int erdma_query_hw_stats(struct erdma_dev *dev, struct rdma_hw_stats *stats)
^ drivers/infiniband/hw/erdma/erdma_verbs.c:1750:1: note: declare 'static' if the function is not intended to be used outside of this translation unit int erdma_query_hw_stats(struct erdma_dev *dev, struct rdma_hw_stats *stats)
^
static
1 warning generated.
vim +/erdma_query_hw_stats +1750 drivers/infiniband/hw/erdma/erdma_verbs.c
1749
> 1750 int erdma_query_hw_stats(struct erdma_dev *dev, struct rdma_hw_stats *stats)
1751 {
1752 struct erdma_cmdq_query_stats_resp *resp;
1753 struct erdma_cmdq_query_req req;
1754 dma_addr_t dma_addr;
1755 int err;
1756
1757 erdma_cmdq_build_reqhdr(&req.hdr, CMDQ_SUBMOD_COMMON,
1758 CMDQ_OPCODE_GET_STATS);
1759
1760 resp = dma_pool_zalloc(dev->resp_pool, GFP_KERNEL, &dma_addr);
1761 if (!resp)
1762 return -ENOMEM;
1763
1764 req.target_addr = dma_addr;
1765 req.target_length = ERDMA_HW_RESP_SIZE;
1766
1767 err = erdma_post_cmd_wait(&dev->cmdq, &req, sizeof(req), NULL, NULL);
1768 if (err)
1769 goto out;
1770
1771 if (resp->hdr.magic != ERDMA_HW_RESP_MAGIC) {
1772 err = -EINVAL;
1773 goto out;
1774 }
1775
1776 memcpy(&stats->value[0], &resp->tx_req_cnt,
1777 sizeof(u64) * stats->num_counters);
1778
1779 out:
1780 dma_pool_free(dev->resp_pool, resp, dma_addr);
1781
1782 return err;
1783 }
1784
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki