From patchwork Wed Aug 28 08:47:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Selvin Xavier X-Patchwork-Id: 13780938 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3851B158543 for ; Wed, 28 Aug 2024 09:08:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724836086; cv=none; b=qD8GX6VvHi/bxfhq47k3NZHewCgQzqHSImN/k4hARCR3scTM+wwXBCBqUrDhH/1pUE8OmudTH13usMth7WbSuHzmrW1K12ZfjRGPGH9i8zs/8M1FpABlif70u2ynWYmh//6WsWGqKPTET/W5mx368HwjHvEMOEsRl6i/xYr5z8Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724836086; c=relaxed/simple; bh=yQ81tQkbalyIglTbg8R6nyKp/acgwIJeHlAqVCfiubw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=mY+EIVo7hYpjz01HWWHxphY4j886232mhoU1uIRM39L4A8YLgr/28EfPV2hh29zaP1RIEkMeTesa3qJVvswgM5TWLaFlZ4ibnXXbllSiVaNJH/CcFh/Lvb28I+eVTvdNpMG2DK6+s+6HtrIkXKoHeINuL7ioZ7OI8xZ5cqxBSeI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=Y1MQ5KNC; arc=none smtp.client-ip=209.85.214.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="Y1MQ5KNC" Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-201fbd0d7c2so53782205ad.0 for ; Wed, 28 Aug 2024 02:08:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1724836084; x=1725440884; darn=vger.kernel.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=10OHoNG68SXU9rV3TemHjbm/ccgfAAiHoAdx+wtfzAI=; b=Y1MQ5KNCk3OR4nvxHDdCxMrrzVZWqhsejtJ3axGPI9GXpe7FaTsA+a0iP+qrqM478B kMQfikjNNNO9snw498lDJt5KXr4C03ZhL34QrNlw4rX3608J0pZuUj4pmNlJ4oX57qho P0XKjj6TKklVmEE5KfVjW+Bjgai9KklDTPywI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724836084; x=1725440884; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=10OHoNG68SXU9rV3TemHjbm/ccgfAAiHoAdx+wtfzAI=; b=wh/5Jfsls6CrGl7sK6UCqZxNq7lx/X3tePzMQ2VmbVrlZdK7C6fL7Sm96OK3GASvbn 4Cw5yCs1jJRaOa3KtxchmkoIwYjoiUpbLL9UBqkJ0Gz1FqbA4ievnELpFRNcm6dA3yDk 6gGFHkcEhT8Yqtub6VqLfeGlumcMK/oAvM6SMwgtBy3jjadXY/pKXjXf91OXLCMRD6Wz 22oS2mI+G2wHc1maeAMhDfvupvW2qyaA0SasvhxL6o4/s3O2mLLvX7qFDS9+6KsaLGPM wxUppnKEMAJl0kiTSPqev8/plge6yWrcyQbtvpz52lWWH2eaSRp2GIJMauzYmeXiC1M7 KeVg== X-Gm-Message-State: AOJu0Yy48YnCcBgT9TfZ+XHPC1Go2nDEzJDLqtFZP2vLL6xluqjOQvZk fJ9UG6DIhk/tWCOSiw5FX9aFWVDvE3czlzl4RleFYhEFGVQ6kTHuHyEQ7AnhllykojUIDpKUkkk = X-Google-Smtp-Source: AGHT+IG4wDsUevh5EKGyjLiNLj91aDp5VHLVEAMrSXTtuAwb5tlFd9jFJSTXWOrPyzhIKc/8F9pgmg== X-Received: by 2002:a17:902:f541:b0:1fc:6901:9c35 with SMTP id d9443c01a7336-204f9b744d2mr17350695ad.20.1724836084443; Wed, 28 Aug 2024 02:08:04 -0700 (PDT) Received: from sxavier-dev.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20385609dddsm94735955ad.196.2024.08.28.02.08.01 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Aug 2024 02:08:03 -0700 (PDT) From: Selvin Xavier To: leon@kernel.org, jgg@ziepe.ca Cc: linux-rdma@vger.kernel.org, andrew.gospodarek@broadcom.com, chandramohan.akula@broadcom.com, Hongguang Gao , Selvin Xavier Subject: [PATCH for-next 1/3] RDMA/bnxt_re: Get the toggle bits from SRQ events Date: Wed, 28 Aug 2024 01:47:10 -0700 Message-Id: <1724834832-10600-2-git-send-email-selvin.xavier@broadcom.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1724834832-10600-1-git-send-email-selvin.xavier@broadcom.com> References: <1724834832-10600-1-git-send-email-selvin.xavier@broadcom.com> Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: From: Hongguang Gao SRQ arming requires the toggle bits received from hardware. Get the toggle bits from SRQ notification for the gen p7 adapters. This value will be zero for the older adapters. Signed-off-by: Hongguang Gao Signed-off-by: Chandramohan Akula Signed-off-by: Selvin Xavier --- drivers/infiniband/hw/bnxt_re/ib_verbs.h | 1 + drivers/infiniband/hw/bnxt_re/qplib_fp.c | 11 +++++++++++ drivers/infiniband/hw/bnxt_re/qplib_fp.h | 1 + 3 files changed, 13 insertions(+) diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.h b/drivers/infiniband/hw/bnxt_re/ib_verbs.h index 3ddeda3..4e113b9 100644 --- a/drivers/infiniband/hw/bnxt_re/ib_verbs.h +++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.h @@ -77,6 +77,7 @@ struct bnxt_re_srq { struct bnxt_qplib_srq qplib_srq; struct ib_umem *umem; spinlock_t lock; /* protect srq */ + void *uctx_srq_page; }; struct bnxt_re_qp { diff --git a/drivers/infiniband/hw/bnxt_re/qplib_fp.c b/drivers/infiniband/hw/bnxt_re/qplib_fp.c index 49e4a4a..19bb453 100644 --- a/drivers/infiniband/hw/bnxt_re/qplib_fp.c +++ b/drivers/infiniband/hw/bnxt_re/qplib_fp.c @@ -54,6 +54,10 @@ #include "qplib_rcfw.h" #include "qplib_sp.h" #include "qplib_fp.h" +#include +#include "bnxt_ulp.h" +#include "bnxt_re.h" +#include "ib_verbs.h" static void __clean_cq(struct bnxt_qplib_cq *cq, u64 qp); @@ -347,6 +351,7 @@ static void bnxt_qplib_service_nq(struct tasklet_struct *t) case NQ_BASE_TYPE_SRQ_EVENT: { struct bnxt_qplib_srq *srq; + struct bnxt_re_srq *srq_p; struct nq_srq_event *nqsrqe = (struct nq_srq_event *)nqe; @@ -354,6 +359,12 @@ static void bnxt_qplib_service_nq(struct tasklet_struct *t) q_handle |= (u64)le32_to_cpu(nqsrqe->srq_handle_high) << 32; srq = (struct bnxt_qplib_srq *)q_handle; + srq->toggle = (le16_to_cpu(nqe->info10_type) & NQ_CN_TOGGLE_MASK) + >> NQ_CN_TOGGLE_SFT; + srq->dbinfo.toggle = srq->toggle; + srq_p = container_of(srq, struct bnxt_re_srq, qplib_srq); + if (srq_p->uctx_srq_page) + *((u32 *)srq_p->uctx_srq_page) = srq->toggle; bnxt_qplib_armen_db(&srq->dbinfo, DBC_DBC_TYPE_SRQ_ARMENA); if (nq->srqn_handler(nq, diff --git a/drivers/infiniband/hw/bnxt_re/qplib_fp.h b/drivers/infiniband/hw/bnxt_re/qplib_fp.h index 56538b9..e714caa 100644 --- a/drivers/infiniband/hw/bnxt_re/qplib_fp.h +++ b/drivers/infiniband/hw/bnxt_re/qplib_fp.h @@ -105,6 +105,7 @@ struct bnxt_qplib_srq { struct bnxt_qplib_sg_info sg_info; u16 eventq_hw_ring_id; spinlock_t lock; /* protect SRQE link list */ + u8 toggle; }; struct bnxt_qplib_sge { From patchwork Wed Aug 28 08:47:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Selvin Xavier X-Patchwork-Id: 13780939 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EDC2315A849 for ; Wed, 28 Aug 2024 09:08:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724836089; cv=none; b=tMHK8neVGYPqSJLM31JQqqsAx8pO+89CMbPZJtIpqLFdcvNt4BKBXXSw8tuGU2p+/stjOZjcUmEKLLBVVrGVQ8nBfiGvbVA305GKS60zajjqPcUreAKGr4vTKFu7915fGpOGbwWaFTu/tfjFxHWVsccSH4cHCeZfpDUn9YlhXFw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724836089; c=relaxed/simple; bh=L221gx8TMVtgUhpzyJXv+niB3Ixc62z7WLWBuVAmB1c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=X5ZueKu+Qohjv74u4qTxRlWuJEQbOP1K/UCLJO+iw2vDYDS2MAUlRr5AAmr7QDisk2gYGsPv0JXFuOwPMcr+fDNlAMfNZXJK5hiv9QZO3xfbp92n86YDO3XgNybgCdxsR2QpBmn+FAtorQYV/x7aOJb/Q1knZbFqML1ZbLBPb90= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=IcNLy/JI; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="IcNLy/JI" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-201e64607a5so46399695ad.2 for ; Wed, 28 Aug 2024 02:08:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1724836087; x=1725440887; darn=vger.kernel.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=66WM3UKiAkh51wtV1SpgB1n6RvJTxOU2qjO0gblS3oo=; b=IcNLy/JIaZ19JHX8NFI79RWE2Ury0VmysoNOqH+fA6EfqoPHVJzJzWwE0JWE4xBCEu cVfh58s7cLI00uPbgNihx10vAXwD10FG3jhUxF5yx5EikE0GQZoWtrIEELhHSgRLGbZT ecQO2hgyBcKZ79LSyl5/n6GNuuAVm9BWLMxks= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724836087; x=1725440887; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=66WM3UKiAkh51wtV1SpgB1n6RvJTxOU2qjO0gblS3oo=; b=mr6U1KIxAogu5idjBaLAIE7GIaCFCKpjwOWOal17haD4uIN7sny80hulADn+aFvPNi YOiNFf7TrTRJpkBeAqJ6yyvClH4odgwkXfo92VnQ/opoxktK6vijgQ1oILB20aipVqUG 62B+TJS/+AsO2WFNiD1ceSkdQYw9V1VMCVGqwI2a0V44KwjDRrQLg1Gz957NL1tTONFo /ouD8iRKCIoClHNCMWtqEQdvR6IzwZASN3NUi3WcOSxZ8dcB5lhVUMBDGrXuXDJDdv6O gyB/+Pqpj4H1MwVZs8tSBPlpvi+uIwoMR7Mc8Dmu9FqE9V7pX3lUOZjX/e9mLQVrYpYn M4bw== X-Gm-Message-State: AOJu0Yyu7HzdBkzEaUCmoKVeEH4/w63wwjNKUqS6rCRtSUokUq9dsSt8 nX7wVD3E5FRdSptAmUN7GThAeb4k7MSKnsKzvI37UGZbYT5J6OxU4w6zUqXm/SwsXq6DumwneWI = X-Google-Smtp-Source: AGHT+IFzqO7LK6pYcLctX/3uO4i76V9uNkV+F+lP+OSAEKGRvnbermMHYO1eiYLTVpiiddNOsOMssw== X-Received: by 2002:a17:902:ce92:b0:202:359:9f66 with SMTP id d9443c01a7336-2039e4fbbc8mr230095795ad.54.1724836087165; Wed, 28 Aug 2024 02:08:07 -0700 (PDT) Received: from sxavier-dev.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20385609dddsm94735955ad.196.2024.08.28.02.08.04 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Aug 2024 02:08:06 -0700 (PDT) From: Selvin Xavier To: leon@kernel.org, jgg@ziepe.ca Cc: linux-rdma@vger.kernel.org, andrew.gospodarek@broadcom.com, chandramohan.akula@broadcom.com, Selvin Xavier Subject: [PATCH for-next 2/3] RDMA/bnxt_re: Refactor the BNXT_RE_METHOD_GET_TOGGLE_MEM method Date: Wed, 28 Aug 2024 01:47:11 -0700 Message-Id: <1724834832-10600-3-git-send-email-selvin.xavier@broadcom.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1724834832-10600-1-git-send-email-selvin.xavier@broadcom.com> References: <1724834832-10600-1-git-send-email-selvin.xavier@broadcom.com> Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: From: Chandramohan Akula Refactor the code in this function to have common code. This is used in subsequent patches. Signed-off-by: Chandramohan Akula Signed-off-by: Selvin Xavier --- drivers/infiniband/hw/bnxt_re/ib_verbs.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c index 43a68e7..1e76093 100644 --- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c +++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c @@ -4494,12 +4494,12 @@ static int UVERBS_HANDLER(BNXT_RE_METHOD_GET_TOGGLE_MEM)(struct uverbs_attr_bund struct bnxt_re_ucontext *uctx; struct ib_ucontext *ib_uctx; struct bnxt_re_dev *rdev; + u32 length = PAGE_SIZE; struct bnxt_re_cq *cq; u64 mem_offset; + u32 offset = 0; u64 addr = 0; - u32 length; - u32 offset; - u32 cq_id; + u32 res_id; int err; ib_uctx = ib_uverbs_get_ucontext(attrs); @@ -4512,21 +4512,17 @@ static int UVERBS_HANDLER(BNXT_RE_METHOD_GET_TOGGLE_MEM)(struct uverbs_attr_bund uctx = container_of(ib_uctx, struct bnxt_re_ucontext, ib_uctx); rdev = uctx->rdev; + err = uverbs_copy_from(&res_id, attrs, BNXT_RE_TOGGLE_MEM_RES_ID); + if (err) + return err; switch (res_type) { case BNXT_RE_CQ_TOGGLE_MEM: - err = uverbs_copy_from(&cq_id, attrs, BNXT_RE_TOGGLE_MEM_RES_ID); - if (err) - return err; - - cq = bnxt_re_search_for_cq(rdev, cq_id); + cq = bnxt_re_search_for_cq(rdev, res_id); if (!cq) return -EINVAL; - length = PAGE_SIZE; addr = (u64)cq->uctx_cq_page; - mmap_flag = BNXT_RE_MMAP_TOGGLE_PAGE; - offset = 0; break; case BNXT_RE_SRQ_TOGGLE_MEM: break; From patchwork Wed Aug 28 08:47:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Selvin Xavier X-Patchwork-Id: 13780940 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B230F158543 for ; Wed, 28 Aug 2024 09:08:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724836092; cv=none; b=U/44chPqLZ7Z5wlcRVs9kELZTz3WIQrGLUcBGzgZGL81BnTayEJj2zosZzmDzWrz77Xl4RiDbCd91JU4/LBhb9pqQiUcMSYLUXJkyEfECWN5OuxFRScaj/ktecWaCmJ/qilrDTAo08FyHs1Y4mAT+BJHBc0/871EdiofaNvcIVA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724836092; c=relaxed/simple; bh=CahLkRkI0YEB76+DqjQuxihiWf0/LB2VTY6KvJ3bhjM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=O+5Fz2at+3qT/r5o7qRuv/Scw5Wh+gQtj0BH3cNOCIhZfc5KnqkKyERd/MjvZHeBfop7DZOlFwH2881QsA/COg756yStsm43PSVKIepSDMEJFIlqivWhUda+JrYIwONedDR5wZtfM+YAx2VJjMHssluud99BOaSOYQ/tb65p3i0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=TUllCMC3; arc=none smtp.client-ip=209.85.214.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="TUllCMC3" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-2021537a8e6so58417125ad.2 for ; Wed, 28 Aug 2024 02:08:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1724836090; x=1725440890; darn=vger.kernel.org; h=references:in-reply-to:message-id:date:subject:cc:to:from:from:to :cc:subject:date:message-id:reply-to; bh=WAyH0O3kecdWjMfkNU3QcPJXxk4o4Np6gebcGmF2oPM=; b=TUllCMC39OSiVI6MjM8XqziXaPeHNJLHrJ7PTDvt0bpAsfGZZtJR3zYUadepr1zV7i HyjdCyydTIRMH3NAIjw5UsqFvaHARHOF8GRp4ltYKxnqV8p4x+RKIrr3xJwE5nHe7uWC 6fw/fnasGnrBc9Z9zzlrEOmLzCWJ/wpfH40mE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724836090; x=1725440890; h=references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=WAyH0O3kecdWjMfkNU3QcPJXxk4o4Np6gebcGmF2oPM=; b=Gh+9sjWOCGmFGEAfaEmXpbpfSBKttWFCMuQ2BiVqF6AggZq/syNfkuBskHXrC1sFGq 8J4h2372KxgNjkYZ20UkdhIOKCu70NwEXPRqxxGeN8dIRr24IdWkPR/9yPN1C6V81T92 4yyVLeH5yPQMf0TsjSF7lTHIgAFtwoeqDrqh6va69iYH6RQ74CIi4ZeJrtgBw2AOvlr9 AT0qHM+aiHJ+5j9L6qPxjS6CHoWYLCJbRL+9+rbF4RJOpkewnT7P1e6Opiag9TzWq00e WTPgL3j0QBiZxXWlxnrif70N+Ga3Qh8u0w2bpJIQ1OxA36vmIIBlRVp9uGiir4GeDfZy +5EA== X-Gm-Message-State: AOJu0YyWVFSQxN1edt5/Xg7UFsP3JF24jWWU2DnS4mCbRFMcGH0kuwlB 0RAOEAI6fyAe+X4QQybyP00coPLaLCczeiHnq7sSst5BVoqWOcL6qibvxS/8xA== X-Google-Smtp-Source: AGHT+IEIo4ccwB5oSbTGxY0canEa43uGlTRDYjSulPYdgDvjFmB8WOW9B9So9OcOUy7TChyCELoV1Q== X-Received: by 2002:a17:902:d4ce:b0:202:dcd:d44 with SMTP id d9443c01a7336-2039e51b696mr183405975ad.54.1724836089865; Wed, 28 Aug 2024 02:08:09 -0700 (PDT) Received: from sxavier-dev.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20385609dddsm94735955ad.196.2024.08.28.02.08.07 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Aug 2024 02:08:09 -0700 (PDT) From: Selvin Xavier To: leon@kernel.org, jgg@ziepe.ca Cc: linux-rdma@vger.kernel.org, andrew.gospodarek@broadcom.com, chandramohan.akula@broadcom.com, Selvin Xavier Subject: [PATCH for-next 3/3] RDMA/bnxt_re: Share a page to expose per SRQ info with userspace Date: Wed, 28 Aug 2024 01:47:12 -0700 Message-Id: <1724834832-10600-4-git-send-email-selvin.xavier@broadcom.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1724834832-10600-1-git-send-email-selvin.xavier@broadcom.com> References: <1724834832-10600-1-git-send-email-selvin.xavier@broadcom.com> Precedence: bulk X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: From: Chandramohan Akula Gen P7 adapters needs to share a toggle bits information received in kernel driver with the user space. User space needs this info to arm the SRQ. User space application can get this page using the UAPI routines. Library will mmap this page and get the toggle bits to be used in the next ARM Doorbell. Uses a hash list to map the SRQ structure from the SRQ ID. SRQ structure is retrieved from the hash list while the library calls the UAPI routine to get the toggle page mapping. Currently the full page is mapped per SRQ. This can be optimized to enable multiple SRQs from the same application share the same page and different offsets in the page Signed-off-by: Chandramohan Akula Signed-off-by: Selvin Xavier --- drivers/infiniband/hw/bnxt_re/bnxt_re.h | 2 ++ drivers/infiniband/hw/bnxt_re/ib_verbs.c | 34 +++++++++++++++++++++++++++++++- drivers/infiniband/hw/bnxt_re/ib_verbs.h | 1 + drivers/infiniband/hw/bnxt_re/main.c | 6 +++++- include/uapi/rdma/bnxt_re-abi.h | 5 +++++ 5 files changed, 46 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/hw/bnxt_re/bnxt_re.h b/drivers/infiniband/hw/bnxt_re/bnxt_re.h index 0912d2f..2be9a62 100644 --- a/drivers/infiniband/hw/bnxt_re/bnxt_re.h +++ b/drivers/infiniband/hw/bnxt_re/bnxt_re.h @@ -141,6 +141,7 @@ struct bnxt_re_pacing { #define BNXT_RE_GRC_FIFO_REG_BASE 0x2000 #define MAX_CQ_HASH_BITS (16) +#define MAX_SRQ_HASH_BITS (16) struct bnxt_re_dev { struct ib_device ibdev; struct list_head list; @@ -196,6 +197,7 @@ struct bnxt_re_dev { struct work_struct dbq_fifo_check_work; struct delayed_work dbq_pacing_work; DECLARE_HASHTABLE(cq_hash, MAX_CQ_HASH_BITS); + DECLARE_HASHTABLE(srq_hash, MAX_SRQ_HASH_BITS); }; #define to_bnxt_re_dev(ptr, member) \ diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.c b/drivers/infiniband/hw/bnxt_re/ib_verbs.c index 1e76093..0219c8a 100644 --- a/drivers/infiniband/hw/bnxt_re/ib_verbs.c +++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.c @@ -1685,6 +1685,10 @@ int bnxt_re_destroy_srq(struct ib_srq *ib_srq, struct ib_udata *udata) if (qplib_srq->cq) nq = qplib_srq->cq->nq; + if (rdev->chip_ctx->modes.toggle_bits & BNXT_QPLIB_SRQ_TOGGLE_BIT) { + free_page((unsigned long)srq->uctx_srq_page); + hash_del(&srq->hash_entry); + } bnxt_qplib_destroy_srq(&rdev->qplib_res, qplib_srq); ib_umem_release(srq->umem); atomic_dec(&rdev->stats.res.srq_count); @@ -1789,9 +1793,18 @@ int bnxt_re_create_srq(struct ib_srq *ib_srq, } if (udata) { - struct bnxt_re_srq_resp resp; + struct bnxt_re_srq_resp resp = {}; resp.srqid = srq->qplib_srq.id; + if (rdev->chip_ctx->modes.toggle_bits & BNXT_QPLIB_SRQ_TOGGLE_BIT) { + hash_add(rdev->srq_hash, &srq->hash_entry, srq->qplib_srq.id); + srq->uctx_srq_page = (void *)get_zeroed_page(GFP_KERNEL); + if (!srq->uctx_srq_page) { + rc = -ENOMEM; + goto fail; + } + resp.comp_mask |= BNXT_RE_SRQ_TOGGLE_PAGE_SUPPORT; + } rc = ib_copy_to_udata(udata, &resp, sizeof(resp)); if (rc) { ibdev_err(&rdev->ibdev, "SRQ copy to udata failed!"); @@ -4266,6 +4279,19 @@ static struct bnxt_re_cq *bnxt_re_search_for_cq(struct bnxt_re_dev *rdev, u32 cq return cq; } +static struct bnxt_re_srq *bnxt_re_search_for_srq(struct bnxt_re_dev *rdev, u32 srq_id) +{ + struct bnxt_re_srq *srq = NULL, *tmp_srq; + + hash_for_each_possible(rdev->srq_hash, tmp_srq, hash_entry, srq_id) { + if (tmp_srq->qplib_srq.id == srq_id) { + srq = tmp_srq; + break; + } + } + return srq; +} + /* Helper function to mmap the virtual memory from user app */ int bnxt_re_mmap(struct ib_ucontext *ib_uctx, struct vm_area_struct *vma) { @@ -4494,6 +4520,7 @@ static int UVERBS_HANDLER(BNXT_RE_METHOD_GET_TOGGLE_MEM)(struct uverbs_attr_bund struct bnxt_re_ucontext *uctx; struct ib_ucontext *ib_uctx; struct bnxt_re_dev *rdev; + struct bnxt_re_srq *srq; u32 length = PAGE_SIZE; struct bnxt_re_cq *cq; u64 mem_offset; @@ -4525,6 +4552,11 @@ static int UVERBS_HANDLER(BNXT_RE_METHOD_GET_TOGGLE_MEM)(struct uverbs_attr_bund addr = (u64)cq->uctx_cq_page; break; case BNXT_RE_SRQ_TOGGLE_MEM: + srq = bnxt_re_search_for_srq(rdev, res_id); + if (!srq) + return -EINVAL; + + addr = (u64)srq->uctx_srq_page; break; default: diff --git a/drivers/infiniband/hw/bnxt_re/ib_verbs.h b/drivers/infiniband/hw/bnxt_re/ib_verbs.h index 4e113b9..9c74dfe 100644 --- a/drivers/infiniband/hw/bnxt_re/ib_verbs.h +++ b/drivers/infiniband/hw/bnxt_re/ib_verbs.h @@ -78,6 +78,7 @@ struct bnxt_re_srq { struct ib_umem *umem; spinlock_t lock; /* protect srq */ void *uctx_srq_page; + struct hlist_node hash_entry; }; struct bnxt_re_qp { diff --git a/drivers/infiniband/hw/bnxt_re/main.c b/drivers/infiniband/hw/bnxt_re/main.c index 9714b9a..1211fe5 100644 --- a/drivers/infiniband/hw/bnxt_re/main.c +++ b/drivers/infiniband/hw/bnxt_re/main.c @@ -139,8 +139,10 @@ static void bnxt_re_set_drv_mode(struct bnxt_re_dev *rdev, u8 mode) if (bnxt_re_hwrm_qcaps(rdev)) dev_err(rdev_to_dev(rdev), "Failed to query hwrm qcaps\n"); - if (bnxt_qplib_is_chip_gen_p7(rdev->chip_ctx)) + if (bnxt_qplib_is_chip_gen_p7(rdev->chip_ctx)) { cctx->modes.toggle_bits |= BNXT_QPLIB_CQ_TOGGLE_BIT; + cctx->modes.toggle_bits |= BNXT_QPLIB_SRQ_TOGGLE_BIT; + } } static void bnxt_re_destroy_chip_ctx(struct bnxt_re_dev *rdev) @@ -1771,6 +1773,8 @@ static int bnxt_re_dev_init(struct bnxt_re_dev *rdev, u8 wqe_mode) bnxt_re_vf_res_config(rdev); } hash_init(rdev->cq_hash); + if (rdev->chip_ctx->modes.toggle_bits & BNXT_QPLIB_SRQ_TOGGLE_BIT) + hash_init(rdev->srq_hash); return 0; free_sctx: diff --git a/include/uapi/rdma/bnxt_re-abi.h b/include/uapi/rdma/bnxt_re-abi.h index e61104f..84917a9 100644 --- a/include/uapi/rdma/bnxt_re-abi.h +++ b/include/uapi/rdma/bnxt_re-abi.h @@ -134,8 +134,13 @@ struct bnxt_re_srq_req { __aligned_u64 srq_handle; }; +enum bnxt_re_srq_mask { + BNXT_RE_SRQ_TOGGLE_PAGE_SUPPORT = 0x1, +}; + struct bnxt_re_srq_resp { __u32 srqid; + __aligned_u64 comp_mask; }; enum bnxt_re_shpg_offt {