From patchwork Tue Jan 7 02:45:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalesh Anakkur Purayil X-Patchwork-Id: 13928011 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (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 1BCB013AD22 for ; Tue, 7 Jan 2025 02:53:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736218410; cv=none; b=ATkd8VqIVVNHTPil/pOKpjFk6hSEcfbSSu+usymjlMoM1GEZnZaPOdL+ZO3XvednsACYDm7e7rc6aJquA+FITaMp6woBhLU44WuBkCX+ZVTavxmvj4T5TwJBJWGC6O13XqBzC0/89gPKKYQV7I7wRVjg0f/TrkoYevzCl35Zn+U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736218410; c=relaxed/simple; bh=dkUGgPaQv0HlenJL6h3glKDnebubexeUid88hsJAWbk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BWJGWCkZN/3adLv4fo/cMRFXhYXhRFhYBxQJdXvvGq1BTmFXhRsBVxs1V9TkEMTNfJ5aO0kHe5ebC/EsLX9IazM5j/BhvUyXWWRxHpmSs/UYMKbjw7lkyMO0Fvo/wzHguAtc/O0ikbyWIQ4zNtEzjg13qxtY4iN656lrHQcEoLM= 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=gnVx9rnI; arc=none smtp.client-ip=209.85.214.182 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="gnVx9rnI" Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-21a1e6fd923so21974465ad.1 for ; Mon, 06 Jan 2025 18:53:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1736218405; x=1736823205; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2T8x/Y3tf5HzBNGI9qqdrAzuAwQcN9/qZhlm85+Qs5I=; b=gnVx9rnImi1cMAf/pypHP3nrbNIauS9RUQAPz5llxCRD2KZFekAa86D56gIaYXCaGK pivtcjoqKCa/8EjYSyweeG0+7p3hziYfqntOjHVeL1akrJ6vlw6bMYqgtiFFdFvFN/Lr O62MjyTCABDVl+Tt1HKzCza/xcmQTFEcwqNec= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736218405; x=1736823205; h=content-transfer-encoding:mime-version: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=2T8x/Y3tf5HzBNGI9qqdrAzuAwQcN9/qZhlm85+Qs5I=; b=gKawSnpH6bJ67G9rEAXufWNA2t3kLnItvDHGss99N05rt07MxQtjzvGYpAVvHWyUKI 01mPDT6+xpQmuV84dCjtCfWls9r3I0mnymhLdEsLIR3KPn7to4qXbnD1jwnpmssn7otW O7m+diiK/oayigrieS1qma2VgAi5DII/lJKOIVByd1RiFDtdlFBhbtOpsS5gh5ToASNw POqmQ8UaEiXQAXQH2WmVmcfGm4rVTZerR/Jv47yWY+etL3AB8fR3O6gReblA3ndhlQr6 ZkV9BOCFoKcu+hzpeBRCV/U6YVIOqQ4YZBqdg/1foEssTmqZ+aBoBdgMQqnUI235/su3 omUA== X-Forwarded-Encrypted: i=1; AJvYcCVrILt1tfOG8L39fiLeE0fpQP09xdBKz+TWFPK1Gjz6n7HUns8XWLE7ePsNUUVMJWRLXVt+4gk=@vger.kernel.org X-Gm-Message-State: AOJu0YzuaUBo1scSJm5siiQq83Lvd1bt7Os8WCZ+ic4cepNirXYGB1Hq Cqs2Nr9En+/s9jfhglR8izfkwI3P9tfppcRc0TaZVK/JujbdbHrcUNe8VyHIgQ== X-Gm-Gg: ASbGncvrBU8Jw4tyCPlYyiZi8mPgXV4UbDeH57FvIJrtdy0XKY+j7laZW22rTuaY6qS Z7KaKdH6Bcz2TaVFklNZ5VTiKXuNTyy0GS3+kB+QjMS/UTxgCJDN19jfkDg9qmHOtd9aA/hMZ3x m0p9DoxXKrvxXVYGEM9hVlsNpF7fsmYdMupWNtZTMFSP/FCjQGLEHFfW1Z+vBEKfiJ1E04y8SN+ PKDRSCXy5qHJNZYitGTHklMXeq48cqW79Y+ZRwyPJMI5pVlnKr2JOCxxx+sT+lzvTPNJvdzKB4s 8iXY7T8pHvER9Up1uMP1SkfgJC59vRPnMpM2X6lbbVtmnSU6LkGeDyi32cQ= X-Google-Smtp-Source: AGHT+IG4Eg1Qa4bYrwkHsVmy1FJUfccMEmddhYKXobsoGSeCuWxcP/7/t0DNSwIMZtSokFC+uyzWYQ== X-Received: by 2002:a17:902:f60f:b0:216:32ea:c84b with SMTP id d9443c01a7336-219e6f25e84mr890072725ad.37.1736218405373; Mon, 06 Jan 2025 18:53:25 -0800 (PST) Received: from dhcp-10-123-157-228.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-219dc9f692fsm300093285ad.216.2025.01.06.18.53.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2025 18:53:24 -0800 (PST) From: Kalesh AP To: leon@kernel.org, jgg@ziepe.ca Cc: linux-rdma@vger.kernel.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, netdev@vger.kernel.org, pabeni@redhat.com, andrew+netdev@lunn.ch, andrew.gospodarek@broadcom.com, selvin.xavier@broadcom.com, michael.chan@broadcom.com, pavan.chebbi@broadcom.com, Kalesh AP Subject: [PATCH rdma-next v2 RESEND 1/4] bnxt_en: Add ULP call to notify async events Date: Tue, 7 Jan 2025 08:15:49 +0530 Message-ID: <20250107024553.2926983-2-kalesh-anakkur.purayil@broadcom.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250107024553.2926983-1-kalesh-anakkur.purayil@broadcom.com> References: <20250107024553.2926983-1-kalesh-anakkur.purayil@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Michael Chan When the driver receives an async event notification from the Firmware, we make the new ulp_async_notifier() call to inform the RDMA driver that a firmware async event has been received. RDMA driver can then take necessary actions based on the event type. In the next patch, we will implement the ulp_async_notifier() callbacks in the RDMA driver. Signed-off-by: Michael Chan Signed-off-by: Selvin Xavier Signed-off-by: Kalesh AP --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 1 + drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c | 28 +++++++++++++++++++ drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.h | 2 ++ 3 files changed, 31 insertions(+) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 4ec4934a4edd..25850730071b 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -2857,6 +2857,7 @@ static int bnxt_async_event_process(struct bnxt *bp, } __bnxt_queue_sp_work(bp); async_event_process_exit: + bnxt_ulp_async_events(bp, cmpl); return 0; } diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c index b771c84cdd89..59c280634bc5 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.c @@ -345,6 +345,34 @@ void bnxt_ulp_irq_restart(struct bnxt *bp, int err) } } +void bnxt_ulp_async_events(struct bnxt *bp, struct hwrm_async_event_cmpl *cmpl) +{ + u16 event_id = le16_to_cpu(cmpl->event_id); + struct bnxt_en_dev *edev = bp->edev; + struct bnxt_ulp_ops *ops; + struct bnxt_ulp *ulp; + + if (!bnxt_ulp_registered(edev)) + return; + ulp = edev->ulp_tbl; + + rcu_read_lock(); + + ops = rcu_dereference(ulp->ulp_ops); + if (!ops || !ops->ulp_async_notifier) + goto exit_unlock_rcu; + if (!ulp->async_events_bmap || event_id > ulp->max_async_event_id) + goto exit_unlock_rcu; + + /* Read max_async_event_id first before testing the bitmap. */ + smp_rmb(); + + if (test_bit(event_id, ulp->async_events_bmap)) + ops->ulp_async_notifier(ulp->handle, cmpl); +exit_unlock_rcu: + rcu_read_unlock(); +} + int bnxt_register_async_events(struct bnxt_en_dev *edev, unsigned long *events_bmap, u16 max_id) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.h b/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.h index 5d6aac60f236..a21294cf197b 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ulp.h @@ -30,6 +30,8 @@ struct bnxt_msix_entry { }; struct bnxt_ulp_ops { + /* async_notifier() cannot sleep (in BH context) */ + void (*ulp_async_notifier)(void *, struct hwrm_async_event_cmpl *); void (*ulp_irq_stop)(void *); void (*ulp_irq_restart)(void *, struct bnxt_msix_entry *); }; From patchwork Tue Jan 7 02:45:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalesh Anakkur Purayil X-Patchwork-Id: 13928012 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (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 9AF39157E88 for ; Tue, 7 Jan 2025 02:53:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736218414; cv=none; b=YKy2/0/5rlh7M1eEv3jv6jXxqRRTG2uxMbdjqNWrwEs4dk4QrzkzjybFnTuJ1+izzBrnZ0yPZStm0yaqC+jFcqxCk8UA2Pa5vWCoVoPSJRnOSJymJ/GPDgJqtWqpN3g9Kl+Bd/DLTCkXASqjDxCTFkprKjFMvdNGWBnMMQHNxFw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736218414; c=relaxed/simple; bh=CFt2wRtVsghTC9fPCTpEo5HM5TJN8QOuhLfOm6ek8ZA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=J61uNRT/v01muT7Qk2U+eGAIm+1wqMjJD2Rj+X7b50MZS67nuxw+kRTGIeRK/gvAIiRcPpQ108yfzVxNMGSvOhox1ZuQ5eonKYMym7UjE9L+pIY386lB83cl99AYV8tluhLn37gMlbQidQiMyh26svmWXCJwbubyGwe1/vNdbIo= 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=DX/hb4z7; arc=none smtp.client-ip=209.85.214.175 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="DX/hb4z7" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-2164b662090so191916865ad.1 for ; Mon, 06 Jan 2025 18:53:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1736218410; x=1736823210; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GSGckmjUr1gcXmHMYI9glP3WZPfHuctvVdT8PdD1UKk=; b=DX/hb4z7F/Qdk8AFi2XSlv1cgvGlB/uul+RhEHIZplAXoWGwA7jNp2nMJOwre+2vVD yAzh5gBTj17KDIEB4L0JSE+jIMA7NwTgAPXWnnT2SZw0yPixp4E6wXYzY0vljXWU77VH lPlENAahI88sRkW1pGbg8Lw6yKI/l0MVkL0QI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736218410; x=1736823210; h=content-transfer-encoding:mime-version: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=GSGckmjUr1gcXmHMYI9glP3WZPfHuctvVdT8PdD1UKk=; b=dNE2QPysWlq+9aSOLJNoNcsfp+OdSzOPdy4GfuEjbZRoRHydnQSYnOH9/W+wiTlZYq 87p3FFuNni98cE73lrCPR/rLpZfNXr6xzhBNaTZUXUogcksZkeiaiwuO4fkL1b2FMS01 V+I/w2desfZy8MELUxU8eGcJV2XyvAQPh4ABIeuXarEfcCx9pGIJTdOk0IqXpBKcFwJG 6vKcYw+C0QpclQO5LLaSD7e9kYzsLzBVTBI05qltO/XnzLn9AjodmLHLOcAbFtJTq7lo aSncibjO3DdY69nmA5kK4euJ3yZBY6mfgN5/Tln7ZoEcPEu/qOsHnTXYTVReqEh2UqDB 5ktQ== X-Forwarded-Encrypted: i=1; AJvYcCU+RKSoga2cRkB8DjbsbANNMmIwxLdUVfqvz1+A1sP7NJG5Gb/5+p6kOWqUD0Zjcn+NEux+Bi4=@vger.kernel.org X-Gm-Message-State: AOJu0YxMSkNWkLoyk+bJ8+Sw5AD6N1O91Y3EGPIjO9GaM4josW3HGeNj r8lFQCvp7gBusYs2cphrWbkChkXNdU6scrBaUeFggYbgnvZWI0bUY2jiIdC+uw== X-Gm-Gg: ASbGncsXHtZ0T2Ep1Jo2bsnWzDtWoqYoVL2Vb4NHDAt+zLmjKPjSKGpomi4TvTNPVrZ Ve05o0u92nDnmzqMaBCV/dw+xNoylAVePlw5QHAAjvOt4QTHEPZD7BHm2ev9ydeJAmOm5p9Rd7M v8yvvbOPAtKjhM9HYMdRxXsgEV4FkfGDDYjM7RDsBg0oHwtcsDoGBstyhcekFgWlesnspgJEqdE 8g5eCPzeQUxLUIOJbfDFFmKmd4GgS8A4QcZXa7EIvySw+pdL1GxaJRXgAteDNMVQ4bvCpmbakFW aqUHXc05zBNrLXp8ZD6SQj2MSLdEjUg/faUJtxmGVnaCNQ7NHZFigFyoHfc= X-Google-Smtp-Source: AGHT+IF8L9qH9kH4c40fqzSLcDB2Cq23VhevoV2vqYcWkmBP/ZD2HoBe7xwgmrWqd3aL19PBH0l0bA== X-Received: by 2002:a17:902:e546:b0:215:9894:5670 with SMTP id d9443c01a7336-219e6ea26b3mr726800715ad.16.1736218409764; Mon, 06 Jan 2025 18:53:29 -0800 (PST) Received: from dhcp-10-123-157-228.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-219dc9f692fsm300093285ad.216.2025.01.06.18.53.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2025 18:53:29 -0800 (PST) From: Kalesh AP To: leon@kernel.org, jgg@ziepe.ca Cc: linux-rdma@vger.kernel.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, netdev@vger.kernel.org, pabeni@redhat.com, andrew+netdev@lunn.ch, andrew.gospodarek@broadcom.com, selvin.xavier@broadcom.com, michael.chan@broadcom.com, pavan.chebbi@broadcom.com, Kalesh AP Subject: [PATCH rdma-next v2 RESEND 2/4] RDMA/bnxt_re: Add Async event handling support Date: Tue, 7 Jan 2025 08:15:50 +0530 Message-ID: <20250107024553.2926983-3-kalesh-anakkur.purayil@broadcom.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250107024553.2926983-1-kalesh-anakkur.purayil@broadcom.com> References: <20250107024553.2926983-1-kalesh-anakkur.purayil@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Using the option provided by Ethernet driver, register for FW Async event. During probe, while registeriung with Ethernet driver, provide the ulp hook 'ulp_async_notifier' for receiving the firmware events. Signed-off-by: Selvin Xavier Signed-off-by: Kalesh AP --- drivers/infiniband/hw/bnxt_re/bnxt_re.h | 1 + drivers/infiniband/hw/bnxt_re/main.c | 47 +++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/drivers/infiniband/hw/bnxt_re/bnxt_re.h b/drivers/infiniband/hw/bnxt_re/bnxt_re.h index 2975b11b79bf..018386295bcd 100644 --- a/drivers/infiniband/hw/bnxt_re/bnxt_re.h +++ b/drivers/infiniband/hw/bnxt_re/bnxt_re.h @@ -229,6 +229,7 @@ struct bnxt_re_dev { DECLARE_HASHTABLE(srq_hash, MAX_SRQ_HASH_BITS); struct dentry *dbg_root; struct dentry *qp_debugfs; + unsigned long event_bitmap; }; #define to_bnxt_re_dev(ptr, member) \ diff --git a/drivers/infiniband/hw/bnxt_re/main.c b/drivers/infiniband/hw/bnxt_re/main.c index 6d1800e285ef..1dc305689d7b 100644 --- a/drivers/infiniband/hw/bnxt_re/main.c +++ b/drivers/infiniband/hw/bnxt_re/main.c @@ -295,6 +295,20 @@ static void bnxt_re_vf_res_config(struct bnxt_re_dev *rdev) &rdev->qplib_ctx); } +static void bnxt_re_async_notifier(void *handle, struct hwrm_async_event_cmpl *cmpl) +{ + struct bnxt_re_dev *rdev = (struct bnxt_re_dev *)handle; + u32 data1, data2; + u16 event_id; + + event_id = le16_to_cpu(cmpl->event_id); + data1 = le32_to_cpu(cmpl->event_data1); + data2 = le32_to_cpu(cmpl->event_data2); + + ibdev_dbg(&rdev->ibdev, "Async event_id = %d data1 = %d data2 = %d", + event_id, data1, data2); +} + static void bnxt_re_stop_irq(void *handle) { struct bnxt_re_en_dev_info *en_info = auxiliary_get_drvdata(handle); @@ -361,6 +375,7 @@ static void bnxt_re_start_irq(void *handle, struct bnxt_msix_entry *ent) } static struct bnxt_ulp_ops bnxt_re_ulp_ops = { + .ulp_async_notifier = bnxt_re_async_notifier, .ulp_irq_stop = bnxt_re_stop_irq, .ulp_irq_restart = bnxt_re_start_irq }; @@ -1785,6 +1800,34 @@ static int bnxt_re_setup_qos(struct bnxt_re_dev *rdev) return 0; } +static void bnxt_re_net_unregister_async_event(struct bnxt_re_dev *rdev) +{ + int rc; + + if (rdev->is_virtfn) + return; + + memset(&rdev->event_bitmap, 0, sizeof(rdev->event_bitmap)); + rc = bnxt_register_async_events(rdev->en_dev, &rdev->event_bitmap, + ASYNC_EVENT_CMPL_EVENT_ID_DCB_CONFIG_CHANGE); + if (rc) + ibdev_err(&rdev->ibdev, "Failed to unregister async event"); +} + +static void bnxt_re_net_register_async_event(struct bnxt_re_dev *rdev) +{ + int rc; + + if (rdev->is_virtfn) + return; + + rdev->event_bitmap |= (1 << ASYNC_EVENT_CMPL_EVENT_ID_DCB_CONFIG_CHANGE); + rc = bnxt_register_async_events(rdev->en_dev, &rdev->event_bitmap, + ASYNC_EVENT_CMPL_EVENT_ID_DCB_CONFIG_CHANGE); + if (rc) + ibdev_err(&rdev->ibdev, "Failed to unregister async event"); +} + static void bnxt_re_query_hwrm_intf_version(struct bnxt_re_dev *rdev) { struct bnxt_en_dev *en_dev = rdev->en_dev; @@ -1864,6 +1907,8 @@ static void bnxt_re_dev_uninit(struct bnxt_re_dev *rdev, u8 op_type) bnxt_re_debugfs_rem_pdev(rdev); + bnxt_re_net_unregister_async_event(rdev); + if (test_and_clear_bit(BNXT_RE_FLAG_QOS_WORK_REG, &rdev->flags)) cancel_delayed_work_sync(&rdev->worker); @@ -2077,6 +2122,8 @@ static int bnxt_re_dev_init(struct bnxt_re_dev *rdev, u8 op_type) bnxt_re_debugfs_add_pdev(rdev); + bnxt_re_net_register_async_event(rdev); + return 0; free_sctx: bnxt_re_net_stats_ctx_free(rdev, rdev->qplib_ctx.stats.fw_id); From patchwork Tue Jan 7 02:45:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalesh Anakkur Purayil X-Patchwork-Id: 13928013 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (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 0AB2A17D358 for ; Tue, 7 Jan 2025 02:53:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736218419; cv=none; b=obFHi8YopjYz2Y84dwRRHDVXpfAMf81YKu5AS3nwmwO3nNf8v2q73bCsEvPp8wnwLlc2Uert5bHnVzwipAgq8cXV1NBv/cNQTh7ArrL001VvOHFzuq+SukYyrrJvI6BCsthqJOQUewHVkZ4r03GBAqwwCzpckIs/kODhx0yCMZc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736218419; c=relaxed/simple; bh=9Et+OTL51PQqtzERuMR71pZCuvpO0dF7doaSmf2iD3g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lnFZN3fYzzdXjlt5crYlTh/1AgbCJFogaNZGfL0Frw8h78HYyO2E5JrEpSGjBFD/5Kw1pHB5T2tAnbA17bjIGGe6mkEekD04/7RmofJYXuLtgaWg5a+8lPpzCWXSb0CPhzjhMQGnExLOFkcLHeCiwM/gfRCzFnigL7F1BcDIta8= 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=g7iHe1/L; arc=none smtp.client-ip=209.85.214.175 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="g7iHe1/L" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-218c8aca5f1so23088015ad.0 for ; Mon, 06 Jan 2025 18:53:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1736218414; x=1736823214; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fcVwvAn82oDbL4UZKDanDj9GdX7S4bHhDPNmufyqUqc=; b=g7iHe1/LmUDN9CFya0OOQ9gKitZITgLgalmyf8hewHBs3y/NZ5BtrgQJXMeq+qgiHm L1mmpZ68uPOu/k7ibaUOZVjbRFZJlCXNMSEKVYDh3QqGe5SE8rBp5oiD+SXH9Evmse6P WOPrRSNpWPGtLpN8VaFScRQQD6B6JkUohV+3g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736218414; x=1736823214; h=content-transfer-encoding:mime-version: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=fcVwvAn82oDbL4UZKDanDj9GdX7S4bHhDPNmufyqUqc=; b=aS1HvE+bft3uz/RIFXPqDL/WqDXb95pWVg/oCi6LMWUP7H7c/qR6Ml4SA+dWq4uzMV Sn2qjZpCUXE06wT49DEhlsUQ/AwG16FZnIu8goDtQUvE9stBrvvxf3dcsA4MJeZiOyHE mudIul0pQNZJNyhwYQ1rNt660205VYAsSX7JZTTmNpLtoWrHRje92qJVYhicq4AQ9XVU jJbd9VWf1SUxKZLRUVZsoEFZ3aPNzISYXS4paX4QwksKng4KKje1a9aq8Uu4Y0KOmwOO B+JS7PzNNUib1mfwEN/9QVaV5dZvRYAPhCZzPOLZupPOJrUZ9rB87Zmg7gmT29r6bWf2 FGXA== X-Forwarded-Encrypted: i=1; AJvYcCXBxfniofjhVCalbZOXXBwW4pnqCcp2uz5fJz1tkrhOYp6sTeiQ8tjeFVfQgFMZJhniDQaNafU=@vger.kernel.org X-Gm-Message-State: AOJu0YyoO1WF+kYsR2MwXM38xjbr/fvcPGipBK3Nwkx6J/dzahNyEg2E u6sHgvCXNoUsTs8e5bpySa3NuGMjZzx3xBHfI3JwlCF1GKzesN/YW4hORVOaMg== X-Gm-Gg: ASbGncv2jLvPKz/qGqlIxPCG+lvlw6De7md8pw+DJaonv9ElmSKegeU+UOk/HfmNcBp BazhgIpRUFTkh9OIC3ko0S6FlWuATtleBTvAF8Q1iN/a2EIVMHZIaWvfhto1elJhe3Fp+4YoeMe 2AOR3R3MXAGqFQOI3p89WWtchLBX3a8oRC+JOvCuFNGt1QYsIN6azjS2ytFUpZyx5Ul64KFQaj4 pOZM6wm0fhF1tGI45hosKFmSJ/Pqf6O78mcNT5Z2OqPYAcc7cFG+ehOBoJNSaJ4YkBPpFpxpKzh bj744c1ICTYgSbvWhSKD6p4/+3G6dIOL9TsVTimvKl7lLAMc/DPtPGGnOTk= X-Google-Smtp-Source: AGHT+IEQpvEF4lvCoCgENoLYRwJnaTxd3vjOWWeO7RvKuZHfHB2z6ebBtEQL8WpZb0cfxJbZjQdPxA== X-Received: by 2002:a17:902:d58e:b0:216:4724:2757 with SMTP id d9443c01a7336-219e6e8bc23mr976777985ad.4.1736218414282; Mon, 06 Jan 2025 18:53:34 -0800 (PST) Received: from dhcp-10-123-157-228.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-219dc9f692fsm300093285ad.216.2025.01.06.18.53.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2025 18:53:33 -0800 (PST) From: Kalesh AP To: leon@kernel.org, jgg@ziepe.ca Cc: linux-rdma@vger.kernel.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, netdev@vger.kernel.org, pabeni@redhat.com, andrew+netdev@lunn.ch, andrew.gospodarek@broadcom.com, selvin.xavier@broadcom.com, michael.chan@broadcom.com, pavan.chebbi@broadcom.com, Kalesh AP Subject: [PATCH rdma-next v2 RESEND 3/4] RDMA/bnxt_re: Query firmware defaults of CC params during probe Date: Tue, 7 Jan 2025 08:15:51 +0530 Message-ID: <20250107024553.2926983-4-kalesh-anakkur.purayil@broadcom.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250107024553.2926983-1-kalesh-anakkur.purayil@broadcom.com> References: <20250107024553.2926983-1-kalesh-anakkur.purayil@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Added function to query firmware default values of CC parameters during driver init. These values will be stored in driver local structure and used in subsequent patch. Signed-off-by: Selvin Xavier Signed-off-by: Kalesh AP --- drivers/infiniband/hw/bnxt_re/bnxt_re.h | 1 + drivers/infiniband/hw/bnxt_re/main.c | 5 + drivers/infiniband/hw/bnxt_re/qplib_sp.c | 113 +++++++++++++++++++++++ drivers/infiniband/hw/bnxt_re/qplib_sp.h | 2 + 4 files changed, 121 insertions(+) diff --git a/drivers/infiniband/hw/bnxt_re/bnxt_re.h b/drivers/infiniband/hw/bnxt_re/bnxt_re.h index 018386295bcd..f40aca550328 100644 --- a/drivers/infiniband/hw/bnxt_re/bnxt_re.h +++ b/drivers/infiniband/hw/bnxt_re/bnxt_re.h @@ -230,6 +230,7 @@ struct bnxt_re_dev { struct dentry *dbg_root; struct dentry *qp_debugfs; unsigned long event_bitmap; + struct bnxt_qplib_cc_param cc_param; }; #define to_bnxt_re_dev(ptr, member) \ diff --git a/drivers/infiniband/hw/bnxt_re/main.c b/drivers/infiniband/hw/bnxt_re/main.c index 1dc305689d7b..aa08eb5bbb68 100644 --- a/drivers/infiniband/hw/bnxt_re/main.c +++ b/drivers/infiniband/hw/bnxt_re/main.c @@ -2104,6 +2104,11 @@ static int bnxt_re_dev_init(struct bnxt_re_dev *rdev, u8 op_type) set_bit(BNXT_RE_FLAG_RESOURCES_INITIALIZED, &rdev->flags); if (!rdev->is_virtfn) { + /* Query f/w defaults of CC params */ + rc = bnxt_qplib_query_cc_param(&rdev->qplib_res, &rdev->cc_param); + if (rc) + ibdev_warn(&rdev->ibdev, "Failed to query CC defaults\n"); + rc = bnxt_re_setup_qos(rdev); if (rc) ibdev_info(&rdev->ibdev, diff --git a/drivers/infiniband/hw/bnxt_re/qplib_sp.c b/drivers/infiniband/hw/bnxt_re/qplib_sp.c index 7e20ae3d2c4f..d56cc3330d1b 100644 --- a/drivers/infiniband/hw/bnxt_re/qplib_sp.c +++ b/drivers/infiniband/hw/bnxt_re/qplib_sp.c @@ -1016,3 +1016,116 @@ int bnxt_qplib_read_context(struct bnxt_qplib_rcfw *rcfw, u8 res_type, dma_free_coherent(&rcfw->pdev->dev, sbuf.size, sbuf.sb, sbuf.dma_addr); return rc; } + +static void bnxt_qplib_read_cc_gen1(struct bnxt_qplib_cc_param_ext *cc_ext, + struct creq_query_roce_cc_gen1_resp_sb_tlv *sb) +{ + cc_ext->inact_th_hi = le16_to_cpu(sb->inactivity_th_hi); + cc_ext->min_delta_cnp = le16_to_cpu(sb->min_time_between_cnps); + cc_ext->init_cp = le16_to_cpu(sb->init_cp); + cc_ext->tr_update_mode = sb->tr_update_mode; + cc_ext->tr_update_cyls = sb->tr_update_cycles; + cc_ext->fr_rtt = sb->fr_num_rtts; + cc_ext->ai_rate_incr = sb->ai_rate_increase; + cc_ext->rr_rtt_th = le16_to_cpu(sb->reduction_relax_rtts_th); + cc_ext->ar_cr_th = le16_to_cpu(sb->additional_relax_cr_th); + cc_ext->cr_min_th = le16_to_cpu(sb->cr_min_th); + cc_ext->bw_avg_weight = sb->bw_avg_weight; + cc_ext->cr_factor = sb->actual_cr_factor; + cc_ext->cr_th_max_cp = le16_to_cpu(sb->max_cp_cr_th); + cc_ext->cp_bias_en = sb->cp_bias_en; + cc_ext->cp_bias = sb->cp_bias; + cc_ext->cnp_ecn = sb->cnp_ecn; + cc_ext->rtt_jitter_en = sb->rtt_jitter_en; + cc_ext->bytes_per_usec = le16_to_cpu(sb->link_bytes_per_usec); + cc_ext->cc_cr_reset_th = le16_to_cpu(sb->reset_cc_cr_th); + cc_ext->cr_width = sb->cr_width; + cc_ext->min_quota = sb->quota_period_min; + cc_ext->max_quota = sb->quota_period_max; + cc_ext->abs_max_quota = sb->quota_period_abs_max; + cc_ext->tr_lb = le16_to_cpu(sb->tr_lower_bound); + cc_ext->cr_prob_fac = sb->cr_prob_factor; + cc_ext->tr_prob_fac = sb->tr_prob_factor; + cc_ext->fair_cr_th = le16_to_cpu(sb->fairness_cr_th); + cc_ext->red_div = sb->red_div; + cc_ext->cnp_ratio_th = sb->cnp_ratio_th; + cc_ext->ai_ext_rtt = le16_to_cpu(sb->exp_ai_rtts); + cc_ext->exp_crcp_ratio = sb->exp_ai_cr_cp_ratio; + cc_ext->low_rate_en = sb->use_rate_table; + cc_ext->cpcr_update_th = le16_to_cpu(sb->cp_exp_update_th); + cc_ext->ai_rtt_th1 = le16_to_cpu(sb->high_exp_ai_rtts_th1); + cc_ext->ai_rtt_th2 = le16_to_cpu(sb->high_exp_ai_rtts_th2); + cc_ext->cf_rtt_th = le16_to_cpu(sb->actual_cr_cong_free_rtts_th); + cc_ext->sc_cr_th1 = le16_to_cpu(sb->severe_cong_cr_th1); + cc_ext->sc_cr_th2 = le16_to_cpu(sb->severe_cong_cr_th2); + cc_ext->l64B_per_rtt = le32_to_cpu(sb->link64B_per_rtt); + cc_ext->cc_ack_bytes = sb->cc_ack_bytes; + cc_ext->reduce_cf_rtt_th = le16_to_cpu(sb->reduce_init_cong_free_rtts_th); +} + +int bnxt_qplib_query_cc_param(struct bnxt_qplib_res *res, + struct bnxt_qplib_cc_param *cc_param) +{ + struct bnxt_qplib_tlv_query_rcc_sb *ext_sb; + struct bnxt_qplib_rcfw *rcfw = res->rcfw; + struct creq_query_roce_cc_resp resp = {}; + struct creq_query_roce_cc_resp_sb *sb; + struct bnxt_qplib_cmdqmsg msg = {}; + struct cmdq_query_roce_cc req = {}; + struct bnxt_qplib_rcfw_sbuf sbuf; + size_t resp_size; + int rc; + + /* Query the parameters from chip */ + bnxt_qplib_rcfw_cmd_prep((struct cmdq_base *)&req, CMDQ_BASE_OPCODE_QUERY_ROCE_CC, + sizeof(req)); + if (bnxt_qplib_is_chip_gen_p5_p7(res->cctx)) + resp_size = sizeof(*ext_sb); + else + resp_size = sizeof(*sb); + + sbuf.size = ALIGN(resp_size, BNXT_QPLIB_CMDQE_UNITS); + sbuf.sb = dma_alloc_coherent(&rcfw->pdev->dev, sbuf.size, + &sbuf.dma_addr, GFP_KERNEL); + if (!sbuf.sb) + return -ENOMEM; + + req.resp_size = sbuf.size / BNXT_QPLIB_CMDQE_UNITS; + bnxt_qplib_fill_cmdqmsg(&msg, &req, &resp, &sbuf, sizeof(req), + sizeof(resp), 0); + rc = bnxt_qplib_rcfw_send_message(res->rcfw, &msg); + if (rc) + goto out; + + ext_sb = sbuf.sb; + sb = bnxt_qplib_is_chip_gen_p5_p7(res->cctx) ? &ext_sb->base_sb : + (struct creq_query_roce_cc_resp_sb *)ext_sb; + + cc_param->enable = sb->enable_cc & CREQ_QUERY_ROCE_CC_RESP_SB_ENABLE_CC; + cc_param->tos_ecn = (sb->tos_dscp_tos_ecn & + CREQ_QUERY_ROCE_CC_RESP_SB_TOS_ECN_MASK) >> + CREQ_QUERY_ROCE_CC_RESP_SB_TOS_ECN_SFT; + cc_param->tos_dscp = (sb->tos_dscp_tos_ecn & + CREQ_QUERY_ROCE_CC_RESP_SB_TOS_DSCP_MASK) >> + CREQ_QUERY_ROCE_CC_RESP_SB_TOS_DSCP_SFT; + cc_param->alt_tos_dscp = sb->alt_tos_dscp; + cc_param->alt_vlan_pcp = sb->alt_vlan_pcp; + + cc_param->g = sb->g; + cc_param->nph_per_state = sb->num_phases_per_state; + cc_param->init_cr = le16_to_cpu(sb->init_cr); + cc_param->init_tr = le16_to_cpu(sb->init_tr); + cc_param->cc_mode = sb->cc_mode; + cc_param->inact_th = le16_to_cpu(sb->inactivity_th); + cc_param->rtt = le16_to_cpu(sb->rtt); + cc_param->tcp_cp = le16_to_cpu(sb->tcp_cp); + cc_param->time_pph = sb->time_per_phase; + cc_param->pkts_pph = sb->pkts_per_phase; + if (bnxt_qplib_is_chip_gen_p5_p7(res->cctx)) { + bnxt_qplib_read_cc_gen1(&cc_param->cc_ext, &ext_sb->gen1_sb); + cc_param->inact_th |= (cc_param->cc_ext.inact_th_hi & 0x3F) << 16; + } +out: + dma_free_coherent(&rcfw->pdev->dev, sbuf.size, sbuf.sb, sbuf.dma_addr); + return rc; +} diff --git a/drivers/infiniband/hw/bnxt_re/qplib_sp.h b/drivers/infiniband/hw/bnxt_re/qplib_sp.h index e6beeb514b7d..debb26080143 100644 --- a/drivers/infiniband/hw/bnxt_re/qplib_sp.h +++ b/drivers/infiniband/hw/bnxt_re/qplib_sp.h @@ -355,6 +355,8 @@ int bnxt_qplib_modify_cc(struct bnxt_qplib_res *res, struct bnxt_qplib_cc_param *cc_param); int bnxt_qplib_read_context(struct bnxt_qplib_rcfw *rcfw, u8 type, u32 xid, u32 resp_size, void *resp_va); +int bnxt_qplib_query_cc_param(struct bnxt_qplib_res *res, + struct bnxt_qplib_cc_param *cc_param); #define BNXT_VAR_MAX_WQE 4352 #define BNXT_VAR_MAX_SLOT_ALIGN 256 From patchwork Tue Jan 7 02:45:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kalesh Anakkur Purayil X-Patchwork-Id: 13928014 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (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 8D108193435 for ; Tue, 7 Jan 2025 02:53:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736218421; cv=none; b=dNgkOTNasR6tgKVWkbjjzi+CxUo7IAELuP1rIwxXKwLc3ctHmQy4VabUQkxxxev9p8DR9N9/l0CT3iLbIfeIdBhWzLhT3auoUc9DQ/C9exJ6BiUvPgqM9+a0XAs0SNaPlCbpVgPQ5rqP99gbLDQhrKGDGl30dUFCt2KQbqelRVQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736218421; c=relaxed/simple; bh=/jdpKowQbeecU4ZKTJnc/PaYAmGYi6GU7xs6pmyxbSI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z2N20g6je+5tjYNwqvTnErA53mmb/2lpqUtSqZ8QVEBjRMrVYEHusRJBrPz/4ytW0UcLkE0aBIi+qVj4cHYj2euDNqNK+3OpvTHhhN+8yZb2oSQDaMuUE//Td2lDrVuF2jkvUmY85yPxx6X/n1V+ujjnbuUdCEfTJMP5yV2q6ss= 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=Q6NAP8Ma; arc=none smtp.client-ip=209.85.214.179 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="Q6NAP8Ma" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-2163b0c09afso216378335ad.0 for ; Mon, 06 Jan 2025 18:53:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1736218419; x=1736823219; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=DOUZfiRlh/PtntowGINQ9eAZtcLAQkVkBrFUI6FjAOo=; b=Q6NAP8MacSRlUQ/POLOoTvXBVlRpVbfo37C4z6KQF1Vtzl2S4bHxtrmez7ieHOVzIm AjQYrR+sVad32+8+AavvT3yzryGOa2OPNgs6SI4Dw1uSYhj7bi2kE4Y2/DoL9KFFnwWQ 4beSbWDCNuspZoxeBmfs5DtO7+a0jYMqXT5oY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736218419; x=1736823219; h=content-transfer-encoding:mime-version: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=DOUZfiRlh/PtntowGINQ9eAZtcLAQkVkBrFUI6FjAOo=; b=N7kc2K6csT43aj0VZXm/FYSaBCOaKZNxc0xb01E2WfpvWzOPX/DZ348cqzsgBk1Ow4 1CBGOmNQ24R0475Ovh51pLkLpqTubm9de4DFpkeKJwUOz8OJBZ+3g96344Q9dkr/0+qq KSRe8wV7/UxamuYb/9B/1IklKeQGxS9x8U3iU9HTP3Mt8PMnQlRfONIbsoC2qDl0TZ5/ dJmMvsILhdb2gQFqlzSmX6vYlrm0pos7shtlM5QMws/601FyCoiof4vtwTF2LrGwvV7D JJjfZCk9BfJxqjR75PrnJkh6/oM/5re0b+hUMLclQvv3OboH7ydDFY9J1rVs82QKMnts 4JWQ== X-Forwarded-Encrypted: i=1; AJvYcCULLOvwwUxtb3wSd7ZH0b8wER709xJ2ucWSB6FR2HvY5ZkpTPoYP1HS8YdGNA6MlBFB+/Im0cg=@vger.kernel.org X-Gm-Message-State: AOJu0Yw1yLEUGedGXCz3t4X+MY46v/3CiREkW6dZwBvNjfyzUzOQAFqK 1A8wRNAnlnm+EYNzGSHv50JJtgxRGsvB89dR+fyfu62cNOxAtEAOORUg3+cOug== X-Gm-Gg: ASbGnctsagCjXjlzXN1zuKGFnrsifHTQthFcN+OuBRXbmuRO1u5NA6Lbew9xlOZHuHs JCSgqJIBZSaPWvZbERGkzZyPnxhctkI41P0QhJYzHZX3k+lTzLAIV6xisVIFooKubakPYDxezYr OzVCh6nRuOz5BUu3pdl1DrQDUH0HKdRkV4WwiCZQEUBrespJd73niO3PRQvOTJcRpZyyraHgAGb ceIo80ayD7jNQbXrJH8hkjwDbOkMIYGYHwCFtjUvA1ziXKdRF7hgV42ETQspBIrkheDHGlWtwVJ SEWjZn+5pBdOlF1JKj7b5jTE9wnZGjwv9/FPNcjqLC+8qrWU5p5p5rKwW5M= X-Google-Smtp-Source: AGHT+IG2e3U+yq00pJ07uOrJQJq4qZec/jeqMdETuaYq7aa6SFhtt8sOzU7w/9iXWDO+Vjh4mpYaoA== X-Received: by 2002:a17:902:f68b:b0:215:b18d:ef with SMTP id d9443c01a7336-219e6eb362amr741205275ad.25.1736218418765; Mon, 06 Jan 2025 18:53:38 -0800 (PST) Received: from dhcp-10-123-157-228.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-219dc9f692fsm300093285ad.216.2025.01.06.18.53.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jan 2025 18:53:38 -0800 (PST) From: Kalesh AP To: leon@kernel.org, jgg@ziepe.ca Cc: linux-rdma@vger.kernel.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, netdev@vger.kernel.org, pabeni@redhat.com, andrew+netdev@lunn.ch, andrew.gospodarek@broadcom.com, selvin.xavier@broadcom.com, michael.chan@broadcom.com, pavan.chebbi@broadcom.com, Kalesh AP Subject: [PATCH rdma-next v2 RESEND 4/4] RDMA/bnxt_re: Add support to handle DCB_CONFIG_CHANGE event Date: Tue, 7 Jan 2025 08:15:52 +0530 Message-ID: <20250107024553.2926983-5-kalesh-anakkur.purayil@broadcom.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250107024553.2926983-1-kalesh-anakkur.purayil@broadcom.com> References: <20250107024553.2926983-1-kalesh-anakkur.purayil@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 QP1 context in HW needs to be updated when there is a change in the default DSCP values used for RoCE traffic. Handle the event from FW and modify the dscp value used by QP1. Signed-off-by: Kalesh AP Signed-off-by: Selvin Xavier --- drivers/infiniband/hw/bnxt_re/bnxt_re.h | 1 + drivers/infiniband/hw/bnxt_re/main.c | 104 +++++++++++++++++++++++ drivers/infiniband/hw/bnxt_re/qplib_fp.h | 1 + drivers/infiniband/hw/bnxt_re/qplib_sp.h | 1 + 4 files changed, 107 insertions(+) diff --git a/drivers/infiniband/hw/bnxt_re/bnxt_re.h b/drivers/infiniband/hw/bnxt_re/bnxt_re.h index f40aca550328..dc2b193af7e8 100644 --- a/drivers/infiniband/hw/bnxt_re/bnxt_re.h +++ b/drivers/infiniband/hw/bnxt_re/bnxt_re.h @@ -231,6 +231,7 @@ struct bnxt_re_dev { struct dentry *qp_debugfs; unsigned long event_bitmap; struct bnxt_qplib_cc_param cc_param; + struct workqueue_struct *dcb_wq; }; #define to_bnxt_re_dev(ptr, member) \ diff --git a/drivers/infiniband/hw/bnxt_re/main.c b/drivers/infiniband/hw/bnxt_re/main.c index aa08eb5bbb68..1988bf884445 100644 --- a/drivers/infiniband/hw/bnxt_re/main.c +++ b/drivers/infiniband/hw/bnxt_re/main.c @@ -295,9 +295,96 @@ static void bnxt_re_vf_res_config(struct bnxt_re_dev *rdev) &rdev->qplib_ctx); } +struct bnxt_re_dcb_work { + struct work_struct work; + struct bnxt_re_dev *rdev; + struct hwrm_async_event_cmpl cmpl; +}; + +static bool bnxt_re_is_qp1_qp(struct bnxt_re_qp *qp) +{ + return qp->ib_qp.qp_type == IB_QPT_GSI; +} + +static struct bnxt_re_qp *bnxt_re_get_qp1_qp(struct bnxt_re_dev *rdev) +{ + struct bnxt_re_qp *qp; + + mutex_lock(&rdev->qp_lock); + list_for_each_entry(qp, &rdev->qp_list, list) { + if (bnxt_re_is_qp1_qp(qp)) { + mutex_unlock(&rdev->qp_lock); + return qp; + } + } + mutex_unlock(&rdev->qp_lock); + return NULL; +} + +static int bnxt_re_update_qp1_tos_dscp(struct bnxt_re_dev *rdev) +{ + struct bnxt_re_qp *qp; + + if (!bnxt_qplib_is_chip_gen_p5_p7(rdev->chip_ctx)) + return 0; + + qp = bnxt_re_get_qp1_qp(rdev); + if (!qp) + return 0; + + qp->qplib_qp.modify_flags = CMDQ_MODIFY_QP_MODIFY_MASK_TOS_DSCP; + qp->qplib_qp.tos_dscp = rdev->cc_param.qp1_tos_dscp; + + return bnxt_qplib_modify_qp(&rdev->qplib_res, &qp->qplib_qp); +} + +static void bnxt_re_init_dcb_wq(struct bnxt_re_dev *rdev) +{ + rdev->dcb_wq = create_singlethread_workqueue("bnxt_re_dcb_wq"); +} + +static void bnxt_re_uninit_dcb_wq(struct bnxt_re_dev *rdev) +{ + if (!rdev->dcb_wq) + return; + destroy_workqueue(rdev->dcb_wq); +} + +static void bnxt_re_dcb_wq_task(struct work_struct *work) +{ + struct bnxt_re_dcb_work *dcb_work = + container_of(work, struct bnxt_re_dcb_work, work); + struct bnxt_re_dev *rdev = dcb_work->rdev; + struct bnxt_qplib_cc_param *cc_param; + int rc; + + if (!rdev) + goto free_dcb; + + cc_param = &rdev->cc_param; + rc = bnxt_qplib_query_cc_param(&rdev->qplib_res, cc_param); + if (rc) { + ibdev_dbg(&rdev->ibdev, "Failed to query ccparam rc:%d", rc); + goto free_dcb; + } + if (cc_param->qp1_tos_dscp != cc_param->tos_dscp) { + cc_param->qp1_tos_dscp = cc_param->tos_dscp; + rc = bnxt_re_update_qp1_tos_dscp(rdev); + if (rc) { + ibdev_dbg(&rdev->ibdev, "%s: Failed to modify QP1 rc:%d", + __func__, rc); + goto free_dcb; + } + } + +free_dcb: + kfree(dcb_work); +} + static void bnxt_re_async_notifier(void *handle, struct hwrm_async_event_cmpl *cmpl) { struct bnxt_re_dev *rdev = (struct bnxt_re_dev *)handle; + struct bnxt_re_dcb_work *dcb_work; u32 data1, data2; u16 event_id; @@ -307,6 +394,21 @@ static void bnxt_re_async_notifier(void *handle, struct hwrm_async_event_cmpl *c ibdev_dbg(&rdev->ibdev, "Async event_id = %d data1 = %d data2 = %d", event_id, data1, data2); + + switch (event_id) { + case ASYNC_EVENT_CMPL_EVENT_ID_DCB_CONFIG_CHANGE: + dcb_work = kzalloc(sizeof(*dcb_work), GFP_ATOMIC); + if (!dcb_work) + break; + + dcb_work->rdev = rdev; + memcpy(&dcb_work->cmpl, cmpl, sizeof(*cmpl)); + INIT_WORK(&dcb_work->work, bnxt_re_dcb_wq_task); + queue_work(rdev->dcb_wq, &dcb_work->work); + break; + default: + break; + } } static void bnxt_re_stop_irq(void *handle) @@ -1908,6 +2010,7 @@ static void bnxt_re_dev_uninit(struct bnxt_re_dev *rdev, u8 op_type) bnxt_re_debugfs_rem_pdev(rdev); bnxt_re_net_unregister_async_event(rdev); + bnxt_re_uninit_dcb_wq(rdev); if (test_and_clear_bit(BNXT_RE_FLAG_QOS_WORK_REG, &rdev->flags)) cancel_delayed_work_sync(&rdev->worker); @@ -2127,6 +2230,7 @@ static int bnxt_re_dev_init(struct bnxt_re_dev *rdev, u8 op_type) bnxt_re_debugfs_add_pdev(rdev); + bnxt_re_init_dcb_wq(rdev); bnxt_re_net_register_async_event(rdev); return 0; diff --git a/drivers/infiniband/hw/bnxt_re/qplib_fp.h b/drivers/infiniband/hw/bnxt_re/qplib_fp.h index ef3424c81345..264cf0c2c1ac 100644 --- a/drivers/infiniband/hw/bnxt_re/qplib_fp.h +++ b/drivers/infiniband/hw/bnxt_re/qplib_fp.h @@ -343,6 +343,7 @@ struct bnxt_qplib_qp { u32 msn; u32 msn_tbl_sz; bool is_host_msn_tbl; + u8 tos_dscp; }; #define BNXT_QPLIB_MAX_CQE_ENTRY_SIZE sizeof(struct cq_base) diff --git a/drivers/infiniband/hw/bnxt_re/qplib_sp.h b/drivers/infiniband/hw/bnxt_re/qplib_sp.h index debb26080143..eafa0c1bc732 100644 --- a/drivers/infiniband/hw/bnxt_re/qplib_sp.h +++ b/drivers/infiniband/hw/bnxt_re/qplib_sp.h @@ -296,6 +296,7 @@ struct bnxt_qplib_cc_param_ext { struct bnxt_qplib_cc_param { u8 alt_vlan_pcp; + u8 qp1_tos_dscp; u16 alt_tos_dscp; u8 cc_mode; u8 enable;