Skip to contentSkip to conversation

RDMA/bnxt_re: Doorbell Drop Prevention

PATCH Superseded Selvin Xavier 3 participants 10 messages Jul 17, 2023 – Jul 18, 2023

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Selvin Xavier

author maintainer
#0 lore raw

v2 cover RDMA/bnxt_re: Doorbell Drop Prevention

The idea behind this series is to prevent Doorbell drops on some of the Broadcom adapters that require Doorbell moderation. This is achieved by pacing the doorbell writes into the hardware FIFO. The rate at which individual doorbells are written needs to be dynamically adjusted, because it depends on the ability of the hardware to drain the FIFO and on the number and behavior of individual doorbell writers. When congestion is detected by the user library, it notifies the driver and driver adjust the pacing parameters dynamically in a shared page, which will be used for pacing the Doorbells.

Currently this feature is targeted only for user applications. The corresponding user lib patch is in the pull request.
https://github.com/linux-rdma/rdma-core/pull/1360

Thanks,
Selivn

v1 -> v2:
Rebased the patches on top of the latest for-next branch

Chandramohan Akula (7):
bnxt_en: Update HW interface headers
bnxt_en: Share the bar0 address with the RoCE driver RDMA/bnxt_re: Initialize Doorbell pacing feature RDMA/bnxt_re: Enable pacing support for the user apps RDMA/bnxt_re: Update alloc_page uapi for pacing RDMA/bnxt_re: Implement doorbell pacing algorithm RDMA/bnxt_re: Add a new uapi for driver notification

 drivers/infiniband/hw/bnxt_re/bnxt_re.h       |  27 ++++
 drivers/infiniband/hw/bnxt_re/ib_verbs.c      |  51 +++++-
 drivers/infiniband/hw/bnxt_re/ib_verbs.h      |   2 +
 drivers/infiniband/hw/bnxt_re/main.c          | 220 ++++++++++++++++++++++++++
 drivers/infiniband/hw/bnxt_re/qplib_res.h     |  19 +++
 drivers/net/ethernet/broadcom/bnxt/bnxt_hsi.h |  54 +++++++
 drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c |   2 +-
 drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.h |   1 +
 include/uapi/rdma/bnxt_re-abi.h               |   7 +
 9 files changed, 379 insertions(+), 4 deletions(-)
Signature · 1 line
2.5.5
author maintainer
#1 lore raw

PATCH v2 1/7 bnxt_en: Update HW interface headers

From: Chandramohan Akula <[email protected]>

Updating the HW structures for the doorbell pacing related information. Newly added interface structures will be used in the followup patches.

---
 drivers/net/ethernet/broadcom/bnxt/bnxt_hsi.h | 54 +++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)
drivers/net/ethernet/broadcom/bnxt/bnxt_hsi.h +54 -0
index b31de4c..a2d3a80 100644
@@ -3721,6 +3721,60 @@ struct hwrm_func_backing_store_qcaps_v2_output {
 	u8	valid;
 };
 
+/* hwrm_func_dbr_pacing_qcfg_input (size:128b/16B) */
+struct hwrm_func_dbr_pacing_qcfg_input {
+	__le16  req_type;
+	__le16  cmpl_ring;
+	__le16  seq_id;
+	__le16  target_id;
+	__le64  resp_addr;
+};
+
+/* hwrm_func_dbr_pacing_qcfg_output (size:512b/64B) */
+struct hwrm_func_dbr_pacing_qcfg_output {
+	__le16  error_code;
+	__le16  req_type;
+	__le16  seq_id;
+	__le16  resp_len;
+	u8      flags;
+#define FUNC_DBR_PACING_QCFG_RESP_FLAGS_DBR_NQ_EVENT_ENABLED     0x1UL
+	u8      unused_0[7];
+	__le32  dbr_stat_db_fifo_reg;
+#define FUNC_DBR_PACING_QCFG_RESP_DBR_STAT_DB_FIFO_REG_ADDR_SPACE_MASK    0x3UL
+#define FUNC_DBR_PACING_QCFG_RESP_DBR_STAT_DB_FIFO_REG_ADDR_SPACE_SFT     0
+#define FUNC_DBR_PACING_QCFG_RESP_DBR_STAT_DB_FIFO_REG_ADDR_SPACE_PCIE_CFG  0x0UL
+#define FUNC_DBR_PACING_QCFG_RESP_DBR_STAT_DB_FIFO_REG_ADDR_SPACE_GRC       0x1UL
+#define FUNC_DBR_PACING_QCFG_RESP_DBR_STAT_DB_FIFO_REG_ADDR_SPACE_BAR0      0x2UL
+#define FUNC_DBR_PACING_QCFG_RESP_DBR_STAT_DB_FIFO_REG_ADDR_SPACE_BAR1      0x3UL
+#define FUNC_DBR_PACING_QCFG_RESP_DBR_STAT_DB_FIFO_REG_ADDR_SPACE_LAST     \
+		FUNC_DBR_PACING_QCFG_RESP_DBR_STAT_DB_FIFO_REG_ADDR_SPACE_BAR1
+#define FUNC_DBR_PACING_QCFG_RESP_DBR_STAT_DB_FIFO_REG_ADDR_MASK          0xfffffffcUL
+#define FUNC_DBR_PACING_QCFG_RESP_DBR_STAT_DB_FIFO_REG_ADDR_SFT           2
+	__le32  dbr_stat_db_fifo_reg_watermark_mask;
+	u8      dbr_stat_db_fifo_reg_watermark_shift;
+	u8      unused_1[3];
+	__le32  dbr_stat_db_fifo_reg_fifo_room_mask;
+	u8      dbr_stat_db_fifo_reg_fifo_room_shift;
+	u8      unused_2[3];
+	__le32  dbr_throttling_aeq_arm_reg;
+#define FUNC_DBR_PACING_QCFG_RESP_DBR_THROTTLING_AEQ_ARM_REG_ADDR_SPACE_MASK    0x3UL
+#define FUNC_DBR_PACING_QCFG_RESP_DBR_THROTTLING_AEQ_ARM_REG_ADDR_SPACE_SFT     0
+#define FUNC_DBR_PACING_QCFG_RESP_DBR_THROTTLING_AEQ_ARM_REG_ADDR_SPACE_PCIE_CFG  0x0UL
+#define FUNC_DBR_PACING_QCFG_RESP_DBR_THROTTLING_AEQ_ARM_REG_ADDR_SPACE_GRC       0x1UL
+#define FUNC_DBR_PACING_QCFG_RESP_DBR_THROTTLING_AEQ_ARM_REG_ADDR_SPACE_BAR0      0x2UL
+#define FUNC_DBR_PACING_QCFG_RESP_DBR_THROTTLING_AEQ_ARM_REG_ADDR_SPACE_BAR1      0x3UL
+#define FUNC_DBR_PACING_QCFG_RESP_DBR_THROTTLING_AEQ_ARM_REG_ADDR_SPACE_LAST	\
+		FUNC_DBR_PACING_QCFG_RESP_DBR_THROTTLING_AEQ_ARM_REG_ADDR_SPACE_BAR1
+#define FUNC_DBR_PACING_QCFG_RESP_DBR_THROTTLING_AEQ_ARM_REG_ADDR_MASK          0xfffffffcUL
+#define FUNC_DBR_PACING_QCFG_RESP_DBR_THROTTLING_AEQ_ARM_REG_ADDR_SFT           2
+	u8      dbr_throttling_aeq_arm_reg_val;
+	u8      unused_3[7];
+	__le32  primary_nq_id;
+	__le32  pacing_threshold;
+	u8      unused_4[7];
+	u8      valid;
+};
+
 /* hwrm_func_drv_if_change_input (size:192b/24B) */
 struct hwrm_func_drv_if_change_input {
 	__le16	req_type;
Signature · 1 line
2.5.5
author maintainer
#2 lore raw

PATCH v2 2/7 bnxt_en: Share the bar0 address with the RoCE driver

In reply to Selvin Xavier

From: Chandramohan Akula <[email protected]>

Add a parameter in the bnxt_en_dev structure to share the bar0 address with RoCE driver.

---
 drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c | 2 +-
 drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.h | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c +1 -1
index 852eb44..6ba2b93 100644
@@ -345,7 +345,7 @@ static void bnxt_set_edev_info(struct bnxt_en_dev *edev, struct bnxt *bp)
 	edev->hw_ring_stats_size = bp->hw_ring_stats_size;
 	edev->pf_port_id = bp->pf.port_id;
 	edev->en_state = bp->state;
-
+	edev->bar0 = bp->bar0;
 	edev->ulp_tbl->msix_requested = bnxt_get_ulp_msix_num(bp);
 }
 
drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.h +1 -0
index 80cbc4b..6ff77f0 100644
@@ -81,6 +81,7 @@ struct bnxt_en_dev {
 							 * mode only. Will be
 							 * updated in resume.
 							 */
+	void __iomem                    *bar0;
 };
 
 static inline bool bnxt_ulp_registered(struct bnxt_en_dev *edev)
Signature · 1 line
2.5.5
author maintainer
#3 lore raw

PATCH v2 3/7 RDMA/bnxt_re: Initialize Doorbell pacing feature

In reply to Selvin Xavier

From: Chandramohan Akula <[email protected]>

Checks for pacing feature capability and get the doorbell pacing configuration using FW commands. Allocate a page and initialize the pacing parameters for the applications. Cleanup the page and de-initialize the pacing during device removal.

---
 drivers/infiniband/hw/bnxt_re/bnxt_re.h   | 22 +++++++
 drivers/infiniband/hw/bnxt_re/main.c      | 96 +++++++++++++++++++++++++++++++
 drivers/infiniband/hw/bnxt_re/qplib_res.h | 19 ++++++
 3 files changed, 137 insertions(+)
drivers/infiniband/hw/bnxt_re/bnxt_re.h +22 -0
index ea81b24..1543f80 100644
@@ -112,6 +112,27 @@ struct bnxt_re_gsi_context {
 #define BNXT_RE_NQ_IDX			1
 #define BNXT_RE_GEN_P5_MAX_VF		64
 
+struct bnxt_re_pacing {
+	u64 dbr_db_fifo_reg_off;
+	void *dbr_page;
+	u64 dbr_bar_addr;
+	u32 pacing_algo_th;
+	u32 do_pacing_save;
+	u32 dbq_pacing_time; /* ms */
+	u32 dbr_def_do_pacing;
+	bool dbr_pacing;
+};
+
+#define BNXT_RE_DBR_PACING_TIME 5 /* ms */
+#define BNXT_RE_PACING_ALGO_THRESHOLD 250 /* Entries in DB FIFO */
+#define BNXT_RE_PACING_ALARM_TH_MULTIPLE 2 /* Multiple of pacing algo threshold */
+/* Default do_pacing value when there is no congestion */
+#define BNXT_RE_DBR_DO_PACING_NO_CONGESTION 0x7F /* 1 in 512 probability */
+#define BNXT_RE_DB_FIFO_ROOM_MASK 0x1FFF8000
+#define BNXT_RE_MAX_FIFO_DEPTH 0x2c00
+#define BNXT_RE_DB_FIFO_ROOM_SHIFT 15
+#define BNXT_RE_GRC_FIFO_REG_BASE 0x2000
+
 struct bnxt_re_dev {
 	struct ib_device		ibdev;
 	struct list_head		list;
@@ -171,6 +192,7 @@ struct bnxt_re_dev {
 	atomic_t nq_alloc_cnt;
 	u32 is_virtfn;
 	u32 num_vfs;
+	struct bnxt_re_pacing pacing;
 };
 
 #define to_bnxt_re_dev(ptr, member)	\
drivers/infiniband/hw/bnxt_re/main.c +96 -0

117 lines not on this page · raw message

drivers/infiniband/hw/bnxt_re/qplib_res.h +19 -0
index d850a55..57161d3 100644
@@ -48,6 +48,7 @@ extern const struct bnxt_qplib_gid bnxt_qplib_gid_zero;
 struct bnxt_qplib_drv_modes {
 	u8	wqe_mode;
 	bool db_push;
+	bool dbr_pacing;
 };
 
 struct bnxt_qplib_chip_ctx {
@@ -58,6 +59,17 @@ struct bnxt_qplib_chip_ctx {
 	u16	hwrm_cmd_max_timeout;
 	struct bnxt_qplib_drv_modes modes;
 	u64	hwrm_intf_ver;
+	u32     dbr_stat_db_fifo;
+};
+
+struct bnxt_qplib_db_pacing_data {
+	u32 do_pacing;
+	u32 pacing_th;
+	u32 alarm_th;
+	u32 fifo_max_depth;
+	u32 fifo_room_mask;
+	u32 fifo_room_shift;
+	u32 grc_reg_offset;
 };
 
 #define BNXT_QPLIB_DBR_PF_DB_OFFSET     0x10000
@@ -271,6 +283,7 @@ struct bnxt_qplib_res {
 	struct mutex                    dpi_tbl_lock;
 	bool				prio;
 	bool                            is_vf;
+	struct bnxt_qplib_db_pacing_data *pacing_data;
 };
 
 static inline bool bnxt_qplib_is_chip_gen_p5(struct bnxt_qplib_chip_ctx *cctx)
@@ -467,4 +480,10 @@ static inline bool _is_ext_stats_supported(u16 dev_cap_flags)
 	return dev_cap_flags &
 		CREQ_QUERY_FUNC_RESP_SB_EXT_STATS;
 }
+
+static inline u8 bnxt_qplib_dbr_pacing_en(struct bnxt_qplib_chip_ctx *cctx)
+{
+	return cctx->modes.dbr_pacing;
+}
+
 #endif /* __BNXT_QPLIB_RES_H__ */
Signature · 1 line
2.5.5
author maintainer
#4 lore raw

PATCH v2 4/7 RDMA/bnxt_re: Enable pacing support for the user apps

In reply to Selvin Xavier

From: Chandramohan Akula <[email protected]>

Report the pacing capability to the user applications.

---
 drivers/infiniband/hw/bnxt_re/ib_verbs.c | 2 ++
 include/uapi/rdma/bnxt_re-abi.h          | 1 +
 2 files changed, 3 insertions(+)
drivers/infiniband/hw/bnxt_re/ib_verbs.c +2 -0
index abef0b8..86b71c7 100644
@@ -4075,6 +4075,8 @@ int bnxt_re_alloc_ucontext(struct ib_ucontext *ctx, struct ib_udata *udata)
 		goto cfail;
 	}
 	uctx->shpage_mmap = &entry->rdma_entry;
+	if (rdev->pacing.dbr_pacing)
+		resp.comp_mask |= BNXT_RE_UCNTX_CMASK_DBR_PACING_ENABLED;
 
 	rc = ib_copy_to_udata(udata, &resp, min(udata->outlen, sizeof(resp)));
 	if (rc) {
include/uapi/rdma/bnxt_re-abi.h +1 -0
index 8a2a1d4..060bf1d 100644
@@ -53,6 +53,7 @@ enum {
 	BNXT_RE_UCNTX_CMASK_HAVE_CCTX = 0x1ULL,
 	BNXT_RE_UCNTX_CMASK_HAVE_MODE = 0x02ULL,
 	BNXT_RE_UCNTX_CMASK_WC_DPI_ENABLED = 0x04ULL,
+	BNXT_RE_UCNTX_CMASK_DBR_PACING_ENABLED = 0x08ULL,
 };
 
 enum bnxt_re_wqe_mode {
Signature · 1 line
2.5.5
author maintainer
#5 lore raw

PATCH v2 5/7 RDMA/bnxt_re: Update alloc_page uapi for pacing

In reply to Selvin Xavier

From: Chandramohan Akula <[email protected]>

Update the alloc_page uapi functionality for handling the mapping of doorbell pacing shared page and bar address.

---
 drivers/infiniband/hw/bnxt_re/ib_verbs.c | 34 +++++++++++++++++++++++++++++---
 drivers/infiniband/hw/bnxt_re/ib_verbs.h |  2 ++
 include/uapi/rdma/bnxt_re-abi.h          |  2 ++
 3 files changed, 35 insertions(+), 3 deletions(-)
drivers/infiniband/hw/bnxt_re/ib_verbs.c +31 -3
index 86b71c7..8238c4b 100644
@@ -565,6 +565,8 @@ bnxt_re_mmap_entry_insert(struct bnxt_re_ucontext *uctx, u64 mem_offset,
 		break;
 	case BNXT_RE_MMAP_UC_DB:
 	case BNXT_RE_MMAP_WC_DB:
+	case BNXT_RE_MMAP_DBR_BAR:
+	case BNXT_RE_MMAP_DBR_PAGE:
 		ret = rdma_user_mmap_entry_insert(&uctx->ib_uctx,
 						  &entry->rdma_entry, PAGE_SIZE);
 		break;
@@ -4149,6 +4151,18 @@ int bnxt_re_mmap(struct ib_ucontext *ib_uctx, struct vm_area_struct *vma)
 	case BNXT_RE_MMAP_SH_PAGE:
 		ret = vm_insert_page(vma, vma->vm_start, virt_to_page(uctx->shpg));
 		break;
+	case BNXT_RE_MMAP_DBR_BAR:
+		pfn = bnxt_entry->mem_offset >> PAGE_SHIFT;
+		ret = rdma_user_mmap_io(ib_uctx, vma, pfn, PAGE_SIZE,
+					pgprot_noncached(vma->vm_page_prot),
+					rdma_entry);
+		break;
+	case BNXT_RE_MMAP_DBR_PAGE:
+		/* Driver doesn't expect write access for user space */
+		if (vma->vm_flags & VM_WRITE)
+			return -EFAULT;
+		ret = vm_insert_page(vma, vma->vm_start, virt_to_page(bnxt_entry->mem_offset));
+		break;
 	default:
 		ret = -EINVAL;
 		break;
@@ -4180,7 +4194,7 @@ static int UVERBS_HANDLER(BNXT_RE_METHOD_ALLOC_PAGE)(struct uverbs_attr_bundle *
 	u64 mmap_offset;
 	u32 length;
 	u32 dpi;
-	u64 dbr;
+	u64 addr;
 	int err;
 
 	uctx = container_of(ib_uverbs_get_ucontext(attrs), struct bnxt_re_ucontext, ib_uctx);
@@ -4202,19 +4216,30 @@ static int UVERBS_HANDLER(BNXT_RE_METHOD_ALLOC_PAGE)(struct uverbs_attr_bundle *
 				return -ENOMEM;
 			length = PAGE_SIZE;
 			dpi = uctx->wcdpi.dpi;
-			dbr = (u64)uctx->wcdpi.umdbr;
+			addr = (u64)uctx->wcdpi.umdbr;
 			mmap_flag = BNXT_RE_MMAP_WC_DB;
 		} else {
 			return -EINVAL;
 		}
 
 		break;
+	case BNXT_RE_ALLOC_DBR_BAR_PAGE:
+		length = PAGE_SIZE;
+		addr = (u64)rdev->pacing.dbr_bar_addr;
+		mmap_flag = BNXT_RE_MMAP_DBR_BAR;
+		break;
+
+	case BNXT_RE_ALLOC_DBR_PAGE:
+		length = PAGE_SIZE;
+		addr = (u64)rdev->pacing.dbr_page;
+		mmap_flag = BNXT_RE_MMAP_DBR_PAGE;
+		break;
 
 	default:
 		return -EOPNOTSUPP;
 	}
 
-	entry = bnxt_re_mmap_entry_insert(uctx, dbr, mmap_flag, &mmap_offset);
+	entry = bnxt_re_mmap_entry_insert(uctx, addr, mmap_flag, &mmap_offset);
 	if (!entry)
 		return -ENOMEM;
 
@@ -4254,6 +4279,9 @@ static int alloc_page_obj_cleanup(struct ib_uobject *uobject,
 			uctx->wcdpi.dbr = NULL;
 		}
 		break;
+	case BNXT_RE_MMAP_DBR_BAR:
+	case BNXT_RE_MMAP_DBR_PAGE:
+		break;
 	default:
 		goto exit;
 	}
drivers/infiniband/hw/bnxt_re/ib_verbs.h +2 -0
index 32d9e9d..f392a09 100644
@@ -146,6 +146,8 @@ enum bnxt_re_mmap_flag {
 	BNXT_RE_MMAP_SH_PAGE,
 	BNXT_RE_MMAP_UC_DB,
 	BNXT_RE_MMAP_WC_DB,
+	BNXT_RE_MMAP_DBR_PAGE,
+	BNXT_RE_MMAP_DBR_BAR,
 };
 
 struct bnxt_re_user_mmap_entry {
include/uapi/rdma/bnxt_re-abi.h +2 -0
index 060bf1d..78a324f 100644
@@ -136,6 +136,8 @@ enum bnxt_re_objects {
 
 enum bnxt_re_alloc_page_type {
 	BNXT_RE_ALLOC_WC_PAGE = 0,
+	BNXT_RE_ALLOC_DBR_BAR_PAGE,
+	BNXT_RE_ALLOC_DBR_PAGE,
 };
 
 enum bnxt_re_var_alloc_page_attrs {
Signature · 1 line
2.5.5
#6 lore raw

Re: [PATCH for-next v2 5/7] RDMA/bnxt_re: Update alloc_page uapi for pacing

kernel test robot noticed the following build warnings:

Hi Selvin,

kernel test robot noticed the following build warnings:

[auto build test WARNING on rdma/for-next]
[also build test WARNING on linus/master v6.5-rc2 next-20230718] [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/Selvin-Xavier/bnxt_en-Share-the-bar0-address-with-the-RoCE-driver/20230718-174723
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma.git for-next
patch link:    https://lore.kernel.org/r/1689573194-27687-6-git-send-email-selvin.xavier%40broadcom.com
patch subject: [PATCH for-next v2 5/7] RDMA/bnxt_re: Update alloc_page uapi for pacing
config: arm64-allyesconfig (https://download.01.org/0day-ci/archive/20230719/[email protected]/config)
compiler: aarch64-linux-gcc (GCC) 12.3.0
reproduce: (https://download.01.org/0day-ci/archive/20230719/[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 >>):

In file included from arch/arm64/include/asm/memory.h:337,

                    from arch/arm64/include/asm/thread_info.h:17,
                    from include/linux/thread_info.h:60,
                    from arch/arm64/include/asm/preempt.h:6,
                    from include/linux/preempt.h:79,
                    from include/linux/percpu.h:6,
                    from include/linux/context_tracking_state.h:5,
                    from include/linux/hardirq.h:5,
                    from include/linux/interrupt.h:11,
                    from drivers/infiniband/hw/bnxt_re/ib_verbs.c:39:
   drivers/infiniband/hw/bnxt_re/ib_verbs.c: In function 'bnxt_re_mmap':
>> drivers/infiniband/hw/bnxt_re/ib_verbs.c:4164:81: warning: passing argument 1 of 'virt_to_pfn' makes pointer from integer without a cast [-Wint-conversion]
    4164 |                 ret = vm_insert_page(vma, vma->vm_start, virt_to_page(bnxt_entry->mem_offset));
         |                                                                       ~~~~~~~~~~^~~~~~~~~~~~
         |                                                                                 |
         |                                                                                 u64 {aka long long unsigned int}
   include/asm-generic/memory_model.h:37:45: note: in definition of macro '__pfn_to_page'
      37 | #define __pfn_to_page(pfn)      (vmemmap + (pfn))
         |                                             ^~~
   drivers/infiniband/hw/bnxt_re/ib_verbs.c:4164:58: note: in expansion of macro 'virt_to_page'
    4164 |                 ret = vm_insert_page(vma, vma->vm_start, virt_to_page(bnxt_entry->mem_offset));
         |                                                          ^~~~~~~~~~~~

arch/arm64/include/asm/memory.h:339:53: note: expected 'const void *' but argument is of type 'u64' {aka 'long long unsigned int'}
339 | static inline unsigned long virt_to_pfn(const void *kaddr)
| ~~~~~~~~~~~~^~~~~

vim +/virt_to_pfn +4164 drivers/infiniband/hw/bnxt_re/ib_verbs.c

4119
4120 /* Helper function to mmap the virtual memory from user app */
4121 int bnxt_re_mmap(struct ib_ucontext *ib_uctx, struct vm_area_struct *vma)
4122 {
4123 struct bnxt_re_ucontext *uctx = container_of(ib_uctx,
4124 struct bnxt_re_ucontext,
4125 ib_uctx);
4126 struct bnxt_re_user_mmap_entry *bnxt_entry;
4127 struct rdma_user_mmap_entry *rdma_entry;
4128 int ret = 0;
4129 u64 pfn;
4130
4131 rdma_entry = rdma_user_mmap_entry_get(&uctx->ib_uctx, vma);
4132 if (!rdma_entry)
4133 return -EINVAL;
4134
4135 bnxt_entry = container_of(rdma_entry, struct bnxt_re_user_mmap_entry,
4136 rdma_entry);
4137
4138 switch (bnxt_entry->mmap_flag) {
4139 case BNXT_RE_MMAP_WC_DB:
4140 pfn = bnxt_entry->mem_offset >> PAGE_SHIFT;
4141 ret = rdma_user_mmap_io(ib_uctx, vma, pfn, PAGE_SIZE,
4142 pgprot_writecombine(vma->vm_page_prot),
4143 rdma_entry);
4144 break;
4145 case BNXT_RE_MMAP_UC_DB:
4146 pfn = bnxt_entry->mem_offset >> PAGE_SHIFT;
4147 ret = rdma_user_mmap_io(ib_uctx, vma, pfn, PAGE_SIZE,
4148 pgprot_noncached(vma->vm_page_prot),
4149 rdma_entry);
4150 break;
4151 case BNXT_RE_MMAP_SH_PAGE:
4152 ret = vm_insert_page(vma, vma->vm_start, virt_to_page(uctx->shpg));
4153 break;
4154 case BNXT_RE_MMAP_DBR_BAR:
4155 pfn = bnxt_entry->mem_offset >> PAGE_SHIFT;
4156 ret = rdma_user_mmap_io(ib_uctx, vma, pfn, PAGE_SIZE,
4157 pgprot_noncached(vma->vm_page_prot),
4158 rdma_entry);
4159 break;
4160 case BNXT_RE_MMAP_DBR_PAGE:
4161 /* Driver doesn't expect write access for user space */
4162 if (vma->vm_flags & VM_WRITE)
4163 return -EFAULT;

> 4164			ret = vm_insert_page(vma, vma->vm_start, virt_to_page(bnxt_entry->mem_offset));

4165 break;
4166 default:
4167 ret = -EINVAL;
4168 break;
4169 }
4170
4171 rdma_user_mmap_entry_put(rdma_entry);
4172 return ret;
4173 }
4174

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
author maintainer
#7 lore raw

PATCH v2 6/7 RDMA/bnxt_re: Implement doorbell pacing algorithm

In reply to Selvin Xavier

From: Chandramohan Akula <[email protected]>

User applications alert the driver when the Doorbell FIFO reaches the alarm threshold. The driver updates the pacing parameters in the shared page to do the maximum pacing by the application till the DB FIFO congestion reduces to pacing threshold. Driver keeps checking the DB FIFO depth at the pacing interval and gradually adjusts the pacing level. Once the pacing level reaches default values (no congestion in the FIFO) pacing gets completed.

---
 drivers/infiniband/hw/bnxt_re/bnxt_re.h |   5 ++
 drivers/infiniband/hw/bnxt_re/main.c    | 124 ++++++++++++++++++++++++++++++++
 2 files changed, 129 insertions(+)
drivers/infiniband/hw/bnxt_re/bnxt_re.h +5 -0
index 1543f80..2175103 100644
@@ -121,8 +121,10 @@ struct bnxt_re_pacing {
 	u32 dbq_pacing_time; /* ms */
 	u32 dbr_def_do_pacing;
 	bool dbr_pacing;
+	struct mutex dbq_lock; /* synchronize db pacing algo */
 };
 
+#define BNXT_RE_MAX_DBR_DO_PACING 0xFFFF
 #define BNXT_RE_DBR_PACING_TIME 5 /* ms */
 #define BNXT_RE_PACING_ALGO_THRESHOLD 250 /* Entries in DB FIFO */
 #define BNXT_RE_PACING_ALARM_TH_MULTIPLE 2 /* Multiple of pacing algo threshold */
@@ -193,6 +195,8 @@ struct bnxt_re_dev {
 	u32 is_virtfn;
 	u32 num_vfs;
 	struct bnxt_re_pacing pacing;
+	struct work_struct dbq_fifo_check_work;
+	struct delayed_work dbq_pacing_work;
 };
 
 #define to_bnxt_re_dev(ptr, member)	\
@@ -203,6 +207,7 @@ struct bnxt_re_dev {
 #define BNXT_RE_ROCEV2_IPV6_PACKET	3
 
 #define BNXT_RE_CHECK_RC(x) ((x) && ((x) != -ETIMEDOUT))
+void bnxt_re_pacing_alert(struct bnxt_re_dev *rdev);
 
 static inline struct device *rdev_to_dev(struct bnxt_re_dev *rdev)
 {
drivers/infiniband/hw/bnxt_re/main.c +124 -0

141 lines not on this page · raw message

Signature · 1 line
2.5.5
author maintainer
#8 lore raw

PATCH v2 7/7 RDMA/bnxt_re: Add a new uapi for driver notification

In reply to Selvin Xavier

From: Chandramohan Akula <[email protected]>

Add driver notify uapi for application notifying
the driver about the doorbell FIFO congestion.

---
 drivers/infiniband/hw/bnxt_re/ib_verbs.c | 15 +++++++++++++++
 include/uapi/rdma/bnxt_re-abi.h          |  4 ++++
 2 files changed, 19 insertions(+)
drivers/infiniband/hw/bnxt_re/ib_verbs.c +15 -0
index 8238c4b..452fbbc 100644
@@ -4182,6 +4182,15 @@ void bnxt_re_mmap_free(struct rdma_user_mmap_entry *rdma_entry)
 	kfree(bnxt_entry);
 }
 
+static int UVERBS_HANDLER(BNXT_RE_METHOD_NOTIFY_DRV)(struct uverbs_attr_bundle *attrs)
+{
+	struct bnxt_re_ucontext *uctx;
+
+	uctx = container_of(ib_uverbs_get_ucontext(attrs), struct bnxt_re_ucontext, ib_uctx);
+	bnxt_re_pacing_alert(uctx->rdev);
+	return 0;
+}
+
 static int UVERBS_HANDLER(BNXT_RE_METHOD_ALLOC_PAGE)(struct uverbs_attr_bundle *attrs)
 {
 	struct ib_uobject *uobj = uverbs_attr_get_uobject(attrs, BNXT_RE_ALLOC_PAGE_HANDLE);
@@ -4319,7 +4328,13 @@ DECLARE_UVERBS_NAMED_OBJECT(BNXT_RE_OBJECT_ALLOC_PAGE,
 			    &UVERBS_METHOD(BNXT_RE_METHOD_ALLOC_PAGE),
 			    &UVERBS_METHOD(BNXT_RE_METHOD_DESTROY_PAGE));
 
+DECLARE_UVERBS_NAMED_METHOD(BNXT_RE_METHOD_NOTIFY_DRV);
+
+DECLARE_UVERBS_GLOBAL_METHODS(BNXT_RE_OBJECT_NOTIFY_DRV,
+			      &UVERBS_METHOD(BNXT_RE_METHOD_NOTIFY_DRV));
+
 const struct uapi_definition bnxt_re_uapi_defs[] = {
 	UAPI_DEF_CHAIN_OBJ_TREE_NAMED(BNXT_RE_OBJECT_ALLOC_PAGE),
+	UAPI_DEF_CHAIN_OBJ_TREE_NAMED(BNXT_RE_OBJECT_NOTIFY_DRV),
 	{}
 };
include/uapi/rdma/bnxt_re-abi.h +4 -0
index 78a324f..6e7c67a 100644
@@ -132,6 +132,7 @@ enum bnxt_re_shpg_offt {
 
 enum bnxt_re_objects {
 	BNXT_RE_OBJECT_ALLOC_PAGE = (1U << UVERBS_ID_NS_SHIFT),
+	BNXT_RE_OBJECT_NOTIFY_DRV,
 };
 
 enum bnxt_re_alloc_page_type {
@@ -157,4 +158,7 @@ enum bnxt_re_alloc_page_methods {
 	BNXT_RE_METHOD_DESTROY_PAGE,
 };
 
+enum bnxt_re_notify_drv_methods {
+	BNXT_RE_METHOD_NOTIFY_DRV = (1U << UVERBS_ID_NS_SHIFT),
+};
 #endif /* __BNXT_RE_UVERBS_ABI_H__*/
Signature · 1 line
2.5.5
#9 lore raw
In reply to Selvin Xavier
Quoted 22 lines · Selvin Xavier

The idea behind this series is to prevent Doorbell drops on some of the Broadcom adapters that require Doorbell moderation. This is achieved by pacing the doorbell writes into the hardware FIFO. The rate at which individual doorbells are written needs to be dynamically adjusted, because it depends on the ability of the hardware to drain the FIFO and on the number and behavior of individual doorbell writers. When congestion is detected by the user library, it notifies the driver and driver adjust the pacing parameters dynamically in a shared page, which will be used for pacing the Doorbells.

Currently this feature is targeted only for user applications. The corresponding user lib patch is in the pull request.
https://github.com/linux-rdma/rdma-core/pull/1360

Thanks,
Selivn

v1 -> v2:
Rebased the patches on top of the latest for-next branch

Quoted 8 lines

Chandramohan Akula (7):
bnxt_en: Update HW interface headers
bnxt_en: Share the bar0 address with the RoCE driver RDMA/bnxt_re: Initialize Doorbell pacing feature RDMA/bnxt_re: Enable pacing support for the user apps RDMA/bnxt_re: Update alloc_page uapi for pacing RDMA/bnxt_re: Implement doorbell pacing algorithm RDMA/bnxt_re: Add a new uapi for driver notification

Jason, any comments?

Thanks

Quoted 15 lines
 drivers/infiniband/hw/bnxt_re/bnxt_re.h       |  27 ++++
 drivers/infiniband/hw/bnxt_re/ib_verbs.c      |  51 +++++-
 drivers/infiniband/hw/bnxt_re/ib_verbs.h      |   2 +
 drivers/infiniband/hw/bnxt_re/main.c          | 220 ++++++++++++++++++++++++++
 drivers/infiniband/hw/bnxt_re/qplib_res.h     |  19 +++
 drivers/net/ethernet/broadcom/bnxt/bnxt_hsi.h |  54 +++++++
 drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c |   2 +-
 drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.h |   1 +
 include/uapi/rdma/bnxt_re-abi.h               |   7 +
 9 files changed, 379 insertions(+), 4 deletions(-)
Signature · 1 line
2.5.5