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: 13928016 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (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 0D80386355 for ; Tue, 7 Jan 2025 02:53:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736218410; cv=none; b=apoi13UUYIUU4/QqQ2bcJiDzxLoOxVMM83F0ToiyNImATw0S8/KCOjORe5/wk7U9vD/McUuYtq849wZtedfz0MyG3ymF9UhKSvp8hXO1u+nWj21t9/sCbrTeJ75WrS4UBR0qyUgediuUbng0zsy9npjQdPF5Lra3YVdZBkIQwHQ= 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.180 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-f180.google.com with SMTP id d9443c01a7336-21a1e6fd923so21974445ad.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=sFfGT4Jg+iyH9adgyjgi/tXLLCtbXWv5z52lrWIyRAtsedgbLVKa5PUToieuCjAYGi ETKsfhcw7hIibRs1s7z/q5oSX/Hy9Z0fE5ULMEnJeZZocNt2LMdrSua8pQ3SBuN7mUmC /ZK0yqaQTfiH9S6ItodzE2hZEVfvTwtpnQnkpFrnNnB8WTqXx2ZTygzqxq7xKPspmmtg JkcUdZqp+dDvuOY9TCua9UHWr3bHC9QuQWGhxWQW7VFPNEgzxsn2slt0/I+7rKdQ6MXN a9zTRc2hvs0wUUlry7vy/KM/dA4QM4S2GrWgCNzsW0rty04RWPWFHCfhrKEiZltaU5fu 4CVg== X-Gm-Message-State: AOJu0Yx6eyWxUPhUH5eFyN/ao9RcwpTk6+VB6DOkiUT0AxgqIiiPbSWo BE1kj+mywgdkaWx4fPFcgKgtIcntDv5dYwj2WFBwTb16wj7JbaX3RC4NLz0ftw== X-Gm-Gg: ASbGncv9c0bXwDV2+xZt6k+Z8IYrgMHbDzKZUIFIC5kxeDvnJ27hvCSa8xQNmVLuYkg y+vDV+OKao2SiHyUKE7sKVAlIOuaZv4pp8LdiTs2Zgc7tEHMtm+1TmFxgz9vlKrbpNYoAYj1Hso ZpURkdgZqFWz+BDbjo2GOuDKNOTyHlxYCrcOba+TnstpOzN5LgKKaLxhLuWraTvkUk+jBijYUb6 p8cAePuxgaTE0UfcXjU37AVOh71WEInGp6ckcdWi2vkP+gYl+eYbpQiB13jQx96zfhTpH5gaVEN Ml1skVKnLcoE48EWFszcIPDoxwp+iJm2GQeHLCY0m3+Ym6Z562gIdl3qVzo= 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: linux-rdma@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13928017 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (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 9AE08157493 for ; Tue, 7 Jan 2025 02:53:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736218413; cv=none; b=OP5BvYIOYstrbY8jNXNw/lpwskHOhTCwX/HioB3yMOCjNC5eE3TcaZztCHuiNUDDZMA/nhWudNWHBDa4A+lrSTpXHiYBRzVamhJ6jeEbGhz9EVjWQPMWTIfKZZtiUX/zCRV6VGre9MaBu1P9pVeJvXDCJgXFNXDfIMOa6FvU7k0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736218413; c=relaxed/simple; bh=CFt2wRtVsghTC9fPCTpEo5HM5TJN8QOuhLfOm6ek8ZA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JOt8gkB3c3PWTZSmMenzBhEGBlw7r1BfDBR8+I39M1e3DVkce94mWNHUaSXSxJOzhDc4CotZAza5duWl26Ts+vE2AX6hs25TGUrWKqMxwpv+k60sy62704as9kZaa7SHG0KbA8ZqJsixreDbeiXzGN7tLGAi0QpzzR2J/JZGWR4= 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.169 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-f169.google.com with SMTP id d9443c01a7336-2164b1f05caso213679635ad.3 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=FXB/D7ny45UzhQSmFvVv7SJb3QNvk5TFFN5rU8eSupWCFr0XAM7MO0codZLFkelW4x l3y4hkWNBQ1nz6alZePAlR8qBLWEXt5avZKe12qJRI0+x3KG6JGCr9JYsoIW16x8HSR8 7tMFGfzLFaVEJqtYjMbvm7j1Wwfz8co8vHKnbxkJW4lL6GJ36Z88WO0H/YZjJCMKJhV9 V6E6N+XzpaoFbSRCl2L86QtOLfZZBYsVd8El8yF8YjheeCe1JOh2H2z7zDAXk+udE8j/ AxdyjjB+w8BjZ8ujapRyFUC9H/aEFZvEs/vF/j1B2mNgL3NgyJwxmvqv0oxD4V0vrdm6 XhuA== X-Gm-Message-State: AOJu0Yy/jIprajiNxlf5Ky0oWBU5D0lcDi6kwctONhf4ux3H+DrUnh0A 56Lhbn/f5h2d8jI3RCZKzTcFQcnz70BTiyamUxsqsIxKWv18S4jujJxLOkv9rA== X-Gm-Gg: ASbGncsze+poi3wriocyza8lNFz3B+2BbRCvBsKuDNwg9IzKzI5uIvIAX0VEcvqZ+Kg iBF3TWXBNAbGZDNSQz3lxS4LJkVQPUJYBWNNfY/lohEHmH1Su4fhtb+IoKza9492vx7ETDrgVT7 1Ofa7ld21yGCeEjcGPfAsd1US9PuQeET8Xdm4BWmN966jFuPR/E6GuIfwejjiExZaJW5ql+qn7M MsnGnArvd6l/NH/7YMBPOzd3r6MhNyzeeBrX2kNCt4V3phcBL3C9DAwuK3PBJBNrSGDZbJpnae4 wJNEqHDtBkIJBVxbbEsk2x7NWAoB1lh530YJMIemCLjlWRtQvoGRCKN25dE= 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: linux-rdma@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: 13928018 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 0AB7418BBA8 for ; Tue, 7 Jan 2025 02:53:34 +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=1736218418; cv=none; b=i/TyuMffQpvw2YBtk2tHn52xelLaYFOescLUtARMraEoEEJHLTTM7C0rXgPVWfUgt/olLo1yBeb5ZTiF5JimKDkAN4Ht9ouhup/nYKxgXB4rcV5tlBKBHB8lA4TDS6FGT2tlV1rQscWdpxJ27BTiEesXjbgB2jfSlXwxAgQXg3s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736218418; c=relaxed/simple; bh=9Et+OTL51PQqtzERuMR71pZCuvpO0dF7doaSmf2iD3g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sMjtoOYl5OB9KhfqVKudnMfUfj9FFKk9YUKqxEhzKz3z+HVUSyXG4jZyP41mWPFBC1S1dnzTffOBOIsjPzKA+ezijzddZE1UnF+RO0fMm9/pmTz3Z/a0sF++G0pzm1IRrAL8yY0Vwjc/J+xL2ZNdaHKLvC64VOrHS6X6SHhyS5k= 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.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="g7iHe1/L" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-21675fd60feso21144895ad.2 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=OyLC1er1rMAcxV7JHzSXp5UMAomW+18uxiei2AXgxGrsC1O/4k8SQwhZz7EY6J0Nge +n8X1Ucbc/dl1ujN8x5GkMpR0C0ZqgY7fURa73m86SuX3smAUnhVRz+YSSm4inDYt8ZW 1gaSJr/RLiUgN0yPze7WQbH//tLdEevyhtZxbSy3gkWYBhZSvbuxovrRfdtrDalbcLuN ELit4RNCsQEzrQmSvbXs+WVlZhqK1PYs3/+k0uO+17vFJeOfHOlMZQJgyIjH+t81NRwV CBROZj5eVoTgCwwYPuArAbX0fxW5Zot3ZI03myhiOR7F161aMtEsLJMdLWl4WSmgnyp/ eOQw== X-Gm-Message-State: AOJu0Yzyy1l2+Rr1STtpUq/c3tQTsiXcFcG8MNZgMbZu434sGAk5IwP0 RHuczIPu2sHO7iavdlqEM3A67ppG0kyZthwnwdmZGVzpVBlq/eMrZSZOfXeCoA== X-Gm-Gg: ASbGnctowdpLvhyvgjElQrJO1Y4lJT6ESVW+7xX49fcQQyKW7bwINHw3VcqtzNOym6H ZFXp2wPcpQDzBBmst5zHUNyJUr+tu/KQAL8KFHR6cKaeMl9zMv+11lOG0YOOsFzbedkWgw/Y7tp +uTEvl2/iVfAstT2K4FQ2vScKPo+V1JXvA8VH7ZGMrx0YxH5tBYQ7YQoXK3nG1621DWEEXIPH1Z vCIGSDkDOlZy/tX1SVDsZQxOcEko2ug93VXGVDo/Z3myCxYm/WRjG8PMTYajiHLnmCCc2j6Cwra iK5JiKYTgJgk/i5munGQSXVEG/F+eac8dTvZx39qrCj7tEIBBzAcyTJ+DFo= 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: linux-rdma@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: 13928019 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 75F7118BBA8 for ; Tue, 7 Jan 2025 02:53:39 +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=1736218421; cv=none; b=CkheOda/EQQmuDUboMtVwn0jzWPUNeidje9Vj/iA75kA10m53+eMj37f1wtspSjTSiyRyKBwdNHZHyY9EmIY638N9GIjOzMH9bxEcvSYCESDRXc4pgNDAJzE9D2G1JnYIZOcPsRvx/YwqVfFGJbnxvtZs9q1cKQrr5SJeyBbFPI= 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.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="Q6NAP8Ma" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-2163b0c09afso216378325ad.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=SVCTt4jZtuDwgF2qY/e4yXKZa/JDlUZHgfN99UcAZwWZwANuLQbTs2bicfpasCUHZZ hQI5FUrcgsK2jxbS3/ZePncK2hl68kquhQMnq5H9TjY3L2eSNDYbT1sg7rMZmysMjEyL tS/59RQPQjHS1ty5QvlWhpszB4NyUo04tx6Gz5xqe96SRjDLzvPV5F8bp/i11dJrpIM7 7W4RTQJaDZJ844SxQrjcNTSEXvWfxMQL1r7OY+d9kqAmHxtTXMJ6eSGnSLi2gAqZQl/o SvFOF1i/PSHqB8DbPg86semkYWnSwU2G3kjY9a/y527YyB4v6vVeKeVsX5hpnpz1rZsx TqSQ== X-Gm-Message-State: AOJu0Yx3NtK0h5AWWIz9E1/sYlJSBV/I72VkMkh9VfDnNgBOERbRWnkv WSjeDKoCRxpTeqGalQuzYkWhCAn2mjBi9LZyKkIZt4XjrB1YX0hPVHtvIof/gg== X-Gm-Gg: ASbGncuLBrIRWUFFTLUPlEdyLE+br3CjtpMx5CBzD0Jv7Vff2aKgZliGcJjma8d8cBk l1Quo4ZWITMoOXNlyfgOf/XSj3N9PSFWo3Lb2cSUrbRYdR+FgaEKG5ASupiPV2KZiHzO0mnfxtW UFbRtxCFjuwHPeP1U62VLwEkZ/MQk2o15TNdt7DNEAsTV+EsjDREC2qhfKM4dAyuQFlNVL6VNfN MjUO22lo+CS7D6R57JFomyr1SSI1546ujkFeCKxbag6fu+Ue2o2GWTUrHtVmCE3GweN8lS1vfbs py3OO6rpbi/HcXm9aXqQ6mIzKqzpGFvxTbg5HutrBdq+i1pKFtYEate/owo= 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: linux-rdma@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;