From nobody Fri Jun 6 13:57:06 2025 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4bDND30n5fz5x9td; Fri, 06 Jun 2025 13:57:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4bDND25B5Nz3mLT; Fri, 06 Jun 2025 13:57:06 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1749218226; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=CJKUKpG6dvxUSBkvRKEMKWqYQ4SrzOl5QxnFpv4Kqpg=; b=WHrcUTyMy0Ch8jabiH0Q4j3meF1Paj33GUMt8geJghDY4lZNtVthqAY8HRSxaCFGym0Pl7 bAHOkFTlETwzxZ5uipIuHwsutI0Bx5Ye14KX5vinjZ//dsO5nEQHwiQeN/68k+dzBTKiSq HnyUk4CaCAAX20YPpOVWE0f87+FH+04tJ3Nvp36qjiZctxnunXI6d8NHID4trEz1Zk/XJr 4qUwjaH80QyZvozDZb2HRnHv4iTYbGdozGFrQJRHAAypgiwzoh13MqsuVU4X76J9RMq1tt 3jbwjG7wvmzShAeUkPtKlTQljElqDWodzsasvLgAFSQNSp/rMeJ+Lq3VCuzBeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1749218226; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=CJKUKpG6dvxUSBkvRKEMKWqYQ4SrzOl5QxnFpv4Kqpg=; b=nE6bfUf38wpvAxEdaAk2ILfTiRGl7ETDXOsHrDCfCVbQLWMFBnssPcDnsvmARxXbRAzUOA CcjCtIRteXGBgbpSmW83GxW16PORyakFfXk7GsqpZP4KERRRIhfLTDOElcOnCfei4yTZA8 xpWfFrkn7+bDQd7VNYc3YZiU6xs2TJeagYUZQv4jUhNyqcelIOc0oSEuh2fD9HMnDwWL53 hTHetzEpydvA0q++vcvUCxJgBIbN4/4Lo4IRTCFfyDAldFW5+zuLT0BNyB9NwGup5P9ekZ cc7+cSyNcKZVVZzVtw2gWdz26Jdrl1Qw5Zr57D8g9FGTBz+S103KuAbgqDtjOg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1749218226; a=rsa-sha256; cv=none; b=GEpyF2kvsfZRxg2FwCNhAGX9eKsAQMcFeF6CYLP9if4WZgRYJ/rRTYNtkl02KPvdXZcbrv cl2/USkun21oJiWPxC/iO2XWw9NdDLY1z+RD6ZFQyFtMzzjEw6T15sVgLTIFdjvGtOkKLb OqPchvM+8hz/pB1b/aBOQOm/cXLszXmNzMqYNpBnGZSIVzfds+g3znr/dfNVPX9atA7ME3 ElPX5Cxfw4I2Z7tBGAHuOkWbzZqSqPbqb+HpspsAmTpu1xD+SCyniaYiHts247n3EqdG7v iOLXH8pOimgomrUGpuD1MvZHMyzrpdGcYJYoIUrgJ7N4NL7IJydUUHAEZhXSWA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4bDND22n4zzxVm; Fri, 06 Jun 2025 13:57:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 556Dv66x083993; Fri, 6 Jun 2025 13:57:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 556Dv6I7083990; Fri, 6 Jun 2025 13:57:06 GMT (envelope-from git) Date: Fri, 6 Jun 2025 13:57:06 GMT Message-Id: <202506061357.556Dv6I7083990@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: c38bafee7e18 - main - qat: move debugfs handling to separate file List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c38bafee7e182fbcdc3c346b2785ed258230cb06 Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=c38bafee7e182fbcdc3c346b2785ed258230cb06 commit c38bafee7e182fbcdc3c346b2785ed258230cb06 Author: Hareshx Sankar Raj AuthorDate: 2025-04-30 21:53:56 +0000 Commit: Mark Johnston CommitDate: 2025-06-06 13:43:22 +0000 qat: move debugfs handling to separate file Moved handling of debugfs entries to a separate file. In addition, it will allow to consolidate the addition of debugfs entries to a single location in the code. This implementation adds infrastructure to create (and remove) debugfs entries at two different stages. - Done when a device is probed, allows to keep debugfs entries persistent between a transition in device state (up to down or vice versa). - Done after the initialization phase, allows to have debugfs entries that are accessible only when the device is up. In addition, moved the creation of debugfs entries for configuration of the newly created function adf_dbgfs_init() and replace symbolic permissions with octal permissions when creating the debugfs files. Added sysctl oids storage for proper cleanup on device down. Reviewed by: markj, ziaee MFC after: 2 weeks Sponsored by: Intel Corporation Differential Revision: https://reviews.freebsd.org/D50379 --- sys/dev/qat/include/adf_dbgfs.h | 11 +++ sys/dev/qat/include/adf_heartbeat.h | 6 +- sys/dev/qat/include/common/adf_accel_devices.h | 4 + sys/dev/qat/qat_common/adf_cfg.c | 42 ++-------- .../qat/qat_common/adf_freebsd_cnvnr_ctrs_dbg.c | 55 +++++++----- sys/dev/qat/qat_common/adf_freebsd_dbgfs.c | 68 +++++++++++++++ sys/dev/qat/qat_common/adf_freebsd_heartbeat_dbg.c | 98 ++++++++++++++-------- sys/dev/qat/qat_common/adf_freebsd_ver_dbg.c | 98 ++++++++++++++-------- sys/dev/qat/qat_common/adf_fw_counters.c | 42 ++++++---- sys/dev/qat/qat_common/adf_init.c | 7 +- sys/dev/qat/qat_hw/qat_200xx/adf_drv.c | 8 +- sys/dev/qat/qat_hw/qat_4xxx/adf_drv.c | 8 +- sys/dev/qat/qat_hw/qat_4xxxvf/adf_drv.c | 6 +- sys/dev/qat/qat_hw/qat_c3xxx/adf_drv.c | 8 +- sys/dev/qat/qat_hw/qat_c4xxx/adf_drv.c | 8 +- sys/dev/qat/qat_hw/qat_c62x/adf_drv.c | 8 +- sys/dev/qat/qat_hw/qat_dh895xcc/adf_drv.c | 8 +- sys/modules/qat/qat_common/Makefile | 1 + 18 files changed, 325 insertions(+), 161 deletions(-) diff --git a/sys/dev/qat/include/adf_dbgfs.h b/sys/dev/qat/include/adf_dbgfs.h new file mode 100644 index 000000000000..a07933c0f02d --- /dev/null +++ b/sys/dev/qat/include/adf_dbgfs.h @@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: BSD-3-Clause */ +/* Copyright(c) 2007-2025 Intel Corporation */ + +#ifndef ADF_DBGFS_H +#define ADF_DBGFS_H + +void adf_dbgfs_init(struct adf_accel_dev *accel_dev); +void adf_dbgfs_add(struct adf_accel_dev *accel_dev); +void adf_dbgfs_rm(struct adf_accel_dev *accel_dev); +void adf_dbgfs_exit(struct adf_accel_dev *accel_dev); +#endif diff --git a/sys/dev/qat/include/adf_heartbeat.h b/sys/dev/qat/include/adf_heartbeat.h index b2eab7139c1f..7a72678e77de 100644 --- a/sys/dev/qat/include/adf_heartbeat.h +++ b/sys/dev/qat/include/adf_heartbeat.h @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ #ifndef ADF_HEARTBEAT_H_ #define ADF_HEARTBEAT_H_ @@ -18,8 +18,8 @@ struct adf_heartbeat { u64 last_hb_check_time; enum adf_device_heartbeat_status last_hb_status; struct qat_sysctl heartbeat; - struct qat_sysctl *heartbeat_sent; - struct qat_sysctl *heartbeat_failed; + struct qat_sysctl heartbeat_sent; + struct qat_sysctl heartbeat_failed; }; int adf_heartbeat_init(struct adf_accel_dev *accel_dev); diff --git a/sys/dev/qat/include/common/adf_accel_devices.h b/sys/dev/qat/include/common/adf_accel_devices.h index 3731cf6587b2..b3f82234bc2b 100644 --- a/sys/dev/qat/include/common/adf_accel_devices.h +++ b/sys/dev/qat/include/common/adf_accel_devices.h @@ -685,6 +685,10 @@ struct adf_accel_dev { struct sysctl_oid *ras_reset; struct sysctl_oid *pke_replay_dbgfile; struct sysctl_oid *misc_error_dbgfile; + struct sysctl_oid *fw_version_oid; + struct sysctl_oid *mmp_version_oid; + struct sysctl_oid *hw_version_oid; + struct sysctl_oid *cnv_error_oid; struct list_head list; struct adf_accel_pci accel_pci_dev; struct adf_accel_compat_manager *cm; diff --git a/sys/dev/qat/qat_common/adf_cfg.c b/sys/dev/qat/qat_common/adf_cfg.c index 736ede860840..37ab44fdb1f6 100644 --- a/sys/dev/qat/qat_common/adf_cfg.c +++ b/sys/dev/qat/qat_common/adf_cfg.c @@ -1,15 +1,10 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ #include "adf_accel_devices.h" #include "adf_cfg.h" #include "adf_common_drv.h" -#include "adf_cfg_dev_dbg.h" #include "adf_cfg_device.h" #include "adf_cfg_sysctl.h" -#include "adf_heartbeat_dbg.h" -#include "adf_ver_dbg.h" -#include "adf_fw_counters.h" -#include "adf_cnvnr_freq_counters.h" /** * adf_cfg_dev_add() - Create an acceleration device configuration table. @@ -73,31 +68,13 @@ adf_cfg_dev_add(struct adf_accel_dev *accel_dev) ADF_CFG_MAX_VAL); } - if (adf_cfg_sysctl_add(accel_dev)) - goto err; - - if (adf_cfg_dev_dbg_add(accel_dev)) - goto err; - - if (!accel_dev->is_vf) { - if (adf_heartbeat_dbg_add(accel_dev)) - goto err; - - if (adf_ver_dbg_add(accel_dev)) - goto err; - - if (adf_fw_counters_add(accel_dev)) - goto err; - - if (adf_cnvnr_freq_counters_add(accel_dev)) - goto err; + if (adf_cfg_sysctl_add(accel_dev)) { + free(dev_cfg_data, M_QAT); + accel_dev->cfg = NULL; + return EFAULT; } - return 0; -err: - free(dev_cfg_data, M_QAT); - accel_dev->cfg = NULL; - return EFAULT; + return 0; } static void adf_cfg_section_del_all(struct list_head *head); @@ -142,13 +119,6 @@ adf_cfg_dev_remove(struct adf_accel_dev *accel_dev) sx_xunlock(&dev_cfg_data->lock); adf_cfg_sysctl_remove(accel_dev); - adf_cfg_dev_dbg_remove(accel_dev); - if (!accel_dev->is_vf) { - adf_ver_dbg_del(accel_dev); - adf_heartbeat_dbg_del(accel_dev); - adf_fw_counters_remove(accel_dev); - adf_cnvnr_freq_counters_remove(accel_dev); - } free(dev_cfg_data, M_QAT); accel_dev->cfg = NULL; diff --git a/sys/dev/qat/qat_common/adf_freebsd_cnvnr_ctrs_dbg.c b/sys/dev/qat/qat_common/adf_freebsd_cnvnr_ctrs_dbg.c index 960c71472bc8..ead172635e59 100644 --- a/sys/dev/qat/qat_common/adf_freebsd_cnvnr_ctrs_dbg.c +++ b/sys/dev/qat/qat_common/adf_freebsd_cnvnr_ctrs_dbg.c @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ #include #include #include @@ -123,10 +123,12 @@ static int qat_cnvnr_ctrs_dbg_read(SYSCTL_HANDLER_ARGS) cnvnr_err_str[error_type], latest_error); if (bytes_written <= 0) { - printf("ERROR: No space left in CnV ctrs line buffer\n" - "\tAcceleration ID: %d, Engine: %d\n", - accel_dev->accel_id, - ae); + device_printf( + GET_DEV(accel_dev), + "ERROR: No space left in CnV ctrs line buffer\n" + "\tAcceleration ID: %d, Engine: %d\n", + accel_dev->accel_id, + ae); break; } report_ptr += bytes_written; @@ -141,7 +143,6 @@ adf_cnvnr_freq_counters_add(struct adf_accel_dev *accel_dev) { struct sysctl_ctx_list *qat_sysctl_ctx; struct sysctl_oid *qat_cnvnr_ctrs_sysctl_tree; - struct sysctl_oid *oid_rc; /* Defensive checks */ if (!accel_dev) @@ -154,19 +155,22 @@ adf_cnvnr_freq_counters_add(struct adf_accel_dev *accel_dev) device_get_sysctl_tree(accel_dev->accel_pci_dev.pci_dev); /* Create "cnv_error" string type leaf - with callback */ - oid_rc = SYSCTL_ADD_PROC(qat_sysctl_ctx, - SYSCTL_CHILDREN(qat_cnvnr_ctrs_sysctl_tree), - OID_AUTO, - "cnv_error", - CTLTYPE_STRING | CTLFLAG_RD, - accel_dev, - 0, - qat_cnvnr_ctrs_dbg_read, - "IU", - "QAT CnVnR status"); - - if (!oid_rc) { - printf("ERROR: Memory allocation failed\n"); + accel_dev->cnv_error_oid = + SYSCTL_ADD_PROC(qat_sysctl_ctx, + SYSCTL_CHILDREN(qat_cnvnr_ctrs_sysctl_tree), + OID_AUTO, + "cnv_error", + CTLTYPE_STRING | CTLFLAG_RD, + accel_dev, + 0, + qat_cnvnr_ctrs_dbg_read, + "IU", + "QAT CnVnR status"); + + if (!accel_dev->cnv_error_oid) { + device_printf( + GET_DEV(accel_dev), + "Failed to create qat cnvnr freq counters sysctl entry.\n"); return ENOMEM; } return 0; @@ -175,4 +179,17 @@ adf_cnvnr_freq_counters_add(struct adf_accel_dev *accel_dev) void adf_cnvnr_freq_counters_remove(struct adf_accel_dev *accel_dev) { + struct sysctl_ctx_list *qat_sysctl_ctx; + + if (!accel_dev) + return; + + qat_sysctl_ctx = + device_get_sysctl_ctx(accel_dev->accel_pci_dev.pci_dev); + + if (accel_dev->cnv_error_oid) { + sysctl_ctx_entry_del(qat_sysctl_ctx, accel_dev->cnv_error_oid); + sysctl_remove_oid(accel_dev->cnv_error_oid, 1, 1); + accel_dev->cnv_error_oid = NULL; + } } diff --git a/sys/dev/qat/qat_common/adf_freebsd_dbgfs.c b/sys/dev/qat/qat_common/adf_freebsd_dbgfs.c new file mode 100644 index 000000000000..21ffb0adf559 --- /dev/null +++ b/sys/dev/qat/qat_common/adf_freebsd_dbgfs.c @@ -0,0 +1,68 @@ +/* SPDX-License-Identifier: BSD-3-Clause */ +/* Copyright(c) 2007-2025 Intel Corporation */ + +#include "adf_accel_devices.h" +#include "adf_cfg_dev_dbg.h" +#include "adf_cnvnr_freq_counters.h" +#include "adf_common_drv.h" +#include "adf_dbgfs.h" +#include "adf_fw_counters.h" +#include "adf_freebsd_pfvf_ctrs_dbg.h" +#include "adf_heartbeat_dbg.h" +#include "adf_ver_dbg.h" + +/** + * adf_dbgfs_init() - add persistent debugfs entries + * @accel_dev: Pointer to acceleration device. + * + * This function creates debugfs entries that are persistent through a device + * state change (from up to down or vice versa). + */ +void +adf_dbgfs_init(struct adf_accel_dev *accel_dev) +{ + adf_cfg_dev_dbg_add(accel_dev); +} + +/** + * adf_dbgfs_exit() - remove persistent debugfs entries + * @accel_dev: Pointer to acceleration device. + */ +void +adf_dbgfs_exit(struct adf_accel_dev *accel_dev) +{ + adf_cfg_dev_dbg_remove(accel_dev); +} + +/** + * adf_dbgfs_add() - add non-persistent debugfs entries + * @accel_dev: Pointer to acceleration device. + * + * This function creates debugfs entries that are not persistent through + * a device state change (from up to down or vice versa). + */ +void +adf_dbgfs_add(struct adf_accel_dev *accel_dev) +{ + if (!accel_dev->is_vf) { + adf_heartbeat_dbg_add(accel_dev); + adf_ver_dbg_add(accel_dev); + adf_fw_counters_add(accel_dev); + adf_cnvnr_freq_counters_add(accel_dev); + } +} + +/** + * adf_dbgfs_rm() - remove non-persistent debugfs entries + * @accel_dev: Pointer to acceleration device. + */ +void +adf_dbgfs_rm(struct adf_accel_dev *accel_dev) +{ + if (!accel_dev->is_vf) { + adf_cnvnr_freq_counters_remove(accel_dev); + adf_fw_counters_remove(accel_dev); + adf_ver_dbg_del(accel_dev); + adf_heartbeat_dbg_del(accel_dev); + } +} diff --git a/sys/dev/qat/qat_common/adf_freebsd_heartbeat_dbg.c b/sys/dev/qat/qat_common/adf_freebsd_heartbeat_dbg.c index c22640045fda..8690c000760c 100644 --- a/sys/dev/qat/qat_common/adf_freebsd_heartbeat_dbg.c +++ b/sys/dev/qat/qat_common/adf_freebsd_heartbeat_dbg.c @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ #include #include #include @@ -48,7 +48,6 @@ adf_heartbeat_dbg_add(struct adf_accel_dev *accel_dev) struct sysctl_ctx_list *qat_hb_sysctl_ctx; struct sysctl_oid *qat_hb_sysctl_tree; struct adf_heartbeat *hb; - struct sysctl_oid *rc = 0; if (accel_dev == NULL) { return EINVAL; @@ -63,43 +62,76 @@ adf_heartbeat_dbg_add(struct adf_accel_dev *accel_dev) qat_hb_sysctl_tree = device_get_sysctl_tree(accel_dev->accel_pci_dev.pci_dev); - rc = SYSCTL_ADD_UINT(qat_hb_sysctl_ctx, - SYSCTL_CHILDREN(qat_hb_sysctl_tree), - OID_AUTO, - "heartbeat_sent", - CTLFLAG_RD, - &hb->hb_sent_counter, - 0, - "HB sent count"); - HB_SYSCTL_ERR(rc); - - rc = SYSCTL_ADD_UINT(qat_hb_sysctl_ctx, - SYSCTL_CHILDREN(qat_hb_sysctl_tree), - OID_AUTO, - "heartbeat_failed", - CTLFLAG_RD, - &hb->hb_failed_counter, - 0, - "HB failed count"); - HB_SYSCTL_ERR(rc); - - rc = SYSCTL_ADD_PROC(qat_hb_sysctl_ctx, - SYSCTL_CHILDREN(qat_hb_sysctl_tree), - OID_AUTO, - "heartbeat", - CTLTYPE_INT | CTLFLAG_RD, - accel_dev, - 0, - qat_dev_hb_read, - "IU", - "QAT device status"); - HB_SYSCTL_ERR(rc); + hb->heartbeat_sent.oid = + SYSCTL_ADD_UINT(qat_hb_sysctl_ctx, + SYSCTL_CHILDREN(qat_hb_sysctl_tree), + OID_AUTO, + "heartbeat_sent", + CTLFLAG_RD, + &hb->hb_sent_counter, + 0, + "HB sent count"); + HB_SYSCTL_ERR(hb->heartbeat_sent.oid); + + hb->heartbeat_failed.oid = + SYSCTL_ADD_UINT(qat_hb_sysctl_ctx, + SYSCTL_CHILDREN(qat_hb_sysctl_tree), + OID_AUTO, + "heartbeat_failed", + CTLFLAG_RD, + &hb->hb_failed_counter, + 0, + "HB failed count"); + HB_SYSCTL_ERR(hb->heartbeat_failed.oid); + + hb->heartbeat.oid = SYSCTL_ADD_PROC(qat_hb_sysctl_ctx, + SYSCTL_CHILDREN(qat_hb_sysctl_tree), + OID_AUTO, + "heartbeat", + CTLTYPE_INT | CTLFLAG_RD, + accel_dev, + 0, + qat_dev_hb_read, + "IU", + "QAT device status"); + HB_SYSCTL_ERR(hb->heartbeat.oid); return 0; } int adf_heartbeat_dbg_del(struct adf_accel_dev *accel_dev) { + struct sysctl_ctx_list *qat_sysctl_ctx; + struct adf_heartbeat *hb; + + if (!accel_dev) { + return EINVAL; + } + + hb = accel_dev->heartbeat; + + qat_sysctl_ctx = + device_get_sysctl_ctx(accel_dev->accel_pci_dev.pci_dev); + + if (hb->heartbeat.oid) { + sysctl_ctx_entry_del(qat_sysctl_ctx, hb->heartbeat.oid); + sysctl_remove_oid(hb->heartbeat.oid, 1, 1); + hb->heartbeat.oid = NULL; + } + + if (hb->heartbeat_failed.oid) { + sysctl_ctx_entry_del(qat_sysctl_ctx, hb->heartbeat_failed.oid); + sysctl_remove_oid(hb->heartbeat_failed.oid, 1, 1); + hb->heartbeat_failed.oid = NULL; + } + + if (hb->heartbeat_sent.oid) { + sysctl_ctx_entry_del(qat_sysctl_ctx, hb->heartbeat_sent.oid); + sysctl_remove_oid(hb->heartbeat_sent.oid, 1, 1); + hb->heartbeat_sent.oid = NULL; + } + adf_heartbeat_clean(accel_dev); + return 0; } diff --git a/sys/dev/qat/qat_common/adf_freebsd_ver_dbg.c b/sys/dev/qat/qat_common/adf_freebsd_ver_dbg.c index 31805d5fb91e..98cde6a742c1 100644 --- a/sys/dev/qat/qat_common/adf_freebsd_ver_dbg.c +++ b/sys/dev/qat/qat_common/adf_freebsd_ver_dbg.c @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ #include "qat_freebsd.h" #include "adf_cfg.h" #include "adf_common_drv.h" @@ -86,7 +86,6 @@ adf_ver_dbg_add(struct adf_accel_dev *accel_dev) { struct sysctl_ctx_list *qat_sysctl_ctx; struct sysctl_oid *qat_sysctl_tree; - struct sysctl_oid *rc = 0; if (!accel_dev) return -EINVAL; @@ -96,43 +95,46 @@ adf_ver_dbg_add(struct adf_accel_dev *accel_dev) qat_sysctl_tree = device_get_sysctl_tree(accel_dev->accel_pci_dev.pci_dev); - rc = SYSCTL_ADD_OID(qat_sysctl_ctx, - SYSCTL_CHILDREN(qat_sysctl_tree), - OID_AUTO, - "fw_version", - CTLTYPE_STRING | CTLFLAG_RD, - accel_dev, - 0, - adf_sysctl_read_fw_versions, - "A", - "QAT FW version"); - if (!rc) + accel_dev->fw_version_oid = + SYSCTL_ADD_OID(qat_sysctl_ctx, + SYSCTL_CHILDREN(qat_sysctl_tree), + OID_AUTO, + "fw_version", + CTLTYPE_STRING | CTLFLAG_RD, + accel_dev, + 0, + adf_sysctl_read_fw_versions, + "A", + "QAT FW version"); + if (!accel_dev->fw_version_oid) goto err; - rc = SYSCTL_ADD_OID(qat_sysctl_ctx, - SYSCTL_CHILDREN(qat_sysctl_tree), - OID_AUTO, - "hw_version", - CTLTYPE_STRING | CTLFLAG_RD, - accel_dev, - 0, - adf_sysctl_read_hw_versions, - "A", - "QAT HW version"); - if (!rc) + accel_dev->hw_version_oid = + SYSCTL_ADD_OID(qat_sysctl_ctx, + SYSCTL_CHILDREN(qat_sysctl_tree), + OID_AUTO, + "hw_version", + CTLTYPE_STRING | CTLFLAG_RD, + accel_dev, + 0, + adf_sysctl_read_hw_versions, + "A", + "QAT HW version"); + if (!accel_dev->hw_version_oid) goto err; - rc = SYSCTL_ADD_OID(qat_sysctl_ctx, - SYSCTL_CHILDREN(qat_sysctl_tree), - OID_AUTO, - "mmp_version", - CTLTYPE_STRING | CTLFLAG_RD, - accel_dev, - 0, - adf_sysctl_read_mmp_versions, - "A", - "QAT MMP version"); - if (!rc) + accel_dev->mmp_version_oid = + SYSCTL_ADD_OID(qat_sysctl_ctx, + SYSCTL_CHILDREN(qat_sysctl_tree), + OID_AUTO, + "mmp_version", + CTLTYPE_STRING | CTLFLAG_RD, + accel_dev, + 0, + adf_sysctl_read_mmp_versions, + "A", + "QAT MMP version"); + if (!accel_dev->mmp_version_oid) goto err; return 0; @@ -145,4 +147,30 @@ err: void adf_ver_dbg_del(struct adf_accel_dev *accel_dev) { + struct sysctl_ctx_list *qat_sysctl_ctx; + + if (!accel_dev) + return; + + qat_sysctl_ctx = + device_get_sysctl_ctx(accel_dev->accel_pci_dev.pci_dev); + + if (accel_dev->mmp_version_oid) { + sysctl_ctx_entry_del(qat_sysctl_ctx, + accel_dev->mmp_version_oid); + sysctl_remove_oid(accel_dev->mmp_version_oid, 1, 1); + accel_dev->mmp_version_oid = NULL; + } + + if (accel_dev->hw_version_oid) { + sysctl_ctx_entry_del(qat_sysctl_ctx, accel_dev->hw_version_oid); + sysctl_remove_oid(accel_dev->hw_version_oid, 1, 1); + accel_dev->hw_version_oid = NULL; + } + + if (accel_dev->fw_version_oid) { + sysctl_ctx_entry_del(qat_sysctl_ctx, accel_dev->fw_version_oid); + sysctl_remove_oid(accel_dev->fw_version_oid, 1, 1); + accel_dev->fw_version_oid = NULL; + } } diff --git a/sys/dev/qat/qat_common/adf_fw_counters.c b/sys/dev/qat/qat_common/adf_fw_counters.c index ea674b27bd0f..1acabe4c9364 100644 --- a/sys/dev/qat/qat_common/adf_fw_counters.c +++ b/sys/dev/qat/qat_common/adf_fw_counters.c @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ #include #include #include @@ -211,7 +211,6 @@ adf_fw_counters_add(struct adf_accel_dev *accel_dev) struct adf_fw_counters_data *fw_counters_data; struct sysctl_ctx_list *qat_sysctl_ctx; struct sysctl_oid *qat_sysctl_tree; - struct sysctl_oid *rc = 0; fw_counters_data = malloc(sizeof(*fw_counters_data), M_QAT, M_WAITOK | M_ZERO); @@ -225,20 +224,24 @@ adf_fw_counters_add(struct adf_accel_dev *accel_dev) device_get_sysctl_ctx(accel_dev->accel_pci_dev.pci_dev); qat_sysctl_tree = device_get_sysctl_tree(accel_dev->accel_pci_dev.pci_dev); - rc = SYSCTL_ADD_OID(qat_sysctl_ctx, - SYSCTL_CHILDREN(qat_sysctl_tree), - OID_AUTO, - "fw_counters", - CTLTYPE_STRING | CTLFLAG_RD, - accel_dev, - 0, - adf_read_fw_counters, - "A", - "QAT FW counters"); - if (!rc) + fw_counters_data->debug = + SYSCTL_ADD_OID(qat_sysctl_ctx, + SYSCTL_CHILDREN(qat_sysctl_tree), + OID_AUTO, + "fw_counters", + CTLTYPE_STRING | CTLFLAG_RD, + accel_dev, + 0, + adf_read_fw_counters, + "A", + "QAT FW counters"); + if (!fw_counters_data->debug) { + free(fw_counters_data, M_QAT); + accel_dev->fw_counters_data = NULL; return ENOMEM; - else - return 0; + } + + return 0; } static void @@ -396,12 +399,21 @@ adf_fw_counters_section_add(struct adf_accel_dev *accel_dev, void adf_fw_counters_remove(struct adf_accel_dev *accel_dev) { + struct sysctl_ctx_list *qat_sysctl_ctx; struct adf_fw_counters_data *fw_counters_data = accel_dev->fw_counters_data; if (!fw_counters_data) return; + if (fw_counters_data->debug) { + qat_sysctl_ctx = + device_get_sysctl_ctx(accel_dev->accel_pci_dev.pci_dev); + sysctl_ctx_entry_del(qat_sysctl_ctx, fw_counters_data->debug); + sysctl_remove_oid(fw_counters_data->debug, 1, 1); + fw_counters_data->debug = NULL; + } + down_write(&fw_counters_data->lock); adf_fw_counters_section_del_all(&fw_counters_data->ae_sec_list); up_write(&fw_counters_data->lock); diff --git a/sys/dev/qat/qat_common/adf_init.c b/sys/dev/qat/qat_common/adf_init.c index f0b75db3f6ed..9f239b8f63d3 100644 --- a/sys/dev/qat/qat_common/adf_init.c +++ b/sys/dev/qat/qat_common/adf_init.c @@ -1,8 +1,9 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ #include "qat_freebsd.h" #include "adf_cfg.h" #include "adf_common_drv.h" +#include "adf_dbgfs.h" #include "adf_accel_devices.h" #include "icp_qat_uclo.h" #include "icp_qat_fw.h" @@ -489,6 +490,8 @@ adf_dev_start(struct adf_accel_dev *accel_dev) clear_bit(ADF_STATUS_STARTING, &accel_dev->status); set_bit(ADF_STATUS_STARTED, &accel_dev->status); + adf_dbgfs_add(accel_dev); + return 0; } @@ -526,6 +529,8 @@ adf_dev_stop(struct adf_accel_dev *accel_dev) return EBUSY; } + adf_dbgfs_rm(accel_dev); + clear_bit(ADF_STATUS_STARTING, &accel_dev->status); clear_bit(ADF_STATUS_STARTED, &accel_dev->status); diff --git a/sys/dev/qat/qat_hw/qat_200xx/adf_drv.c b/sys/dev/qat/qat_hw/qat_200xx/adf_drv.c index f9b8c742d339..9e2462c05657 100644 --- a/sys/dev/qat/qat_hw/qat_200xx/adf_drv.c +++ b/sys/dev/qat/qat_hw/qat_200xx/adf_drv.c @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ #include "qat_freebsd.h" #include "adf_cfg.h" #include "adf_common_drv.h" @@ -7,13 +7,12 @@ #include "adf_200xx_hw_data.h" #include "adf_fw_counters.h" #include "adf_cfg_device.h" +#include "adf_dbgfs.h" #include #include #include #include #include -#include "adf_heartbeat_dbg.h" -#include "adf_cnvnr_freq_counters.h" static MALLOC_DEFINE(M_QAT_200XX, "qat_200xx", "qat_200xx"); @@ -73,6 +72,7 @@ adf_cleanup_accel(struct adf_accel_dev *accel_dev) free(accel_dev->hw_device, M_QAT_200XX); accel_dev->hw_device = NULL; } + adf_dbgfs_exit(accel_dev); adf_cfg_dev_remove(accel_dev); adf_devmgr_rm_dev(accel_dev, NULL); } @@ -215,6 +215,8 @@ adf_attach(device_t dev) } pci_enable_busmaster(dev); + adf_dbgfs_init(accel_dev); + if (!accel_dev->hw_device->config_device) { ret = EFAULT; goto out_err; diff --git a/sys/dev/qat/qat_hw/qat_4xxx/adf_drv.c b/sys/dev/qat/qat_hw/qat_4xxx/adf_drv.c index 9b585fe7d3d1..08fbf5d989e2 100644 --- a/sys/dev/qat/qat_hw/qat_4xxx/adf_drv.c +++ b/sys/dev/qat/qat_hw/qat_4xxx/adf_drv.c @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007 - 2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ #include "qat_freebsd.h" #include "adf_cfg.h" #include "adf_common_drv.h" @@ -8,13 +8,12 @@ #include "adf_gen4_hw_data.h" #include "adf_fw_counters.h" #include "adf_cfg_device.h" +#include "adf_dbgfs.h" #include #include #include #include #include -#include "adf_heartbeat_dbg.h" -#include "adf_cnvnr_freq_counters.h" static MALLOC_DEFINE(M_QAT_4XXX, "qat_4xxx", "qat_4xxx"); @@ -147,6 +146,7 @@ adf_cleanup_accel(struct adf_accel_dev *accel_dev) #ifdef QAT_DISABLE_SAFE_DC_MODE adf_4xxx_disable_safe_dc_sysctl_remove(accel_dev); #endif /* QAT_DISABLE_SAFE_DC_MODE */ + adf_dbgfs_exit(accel_dev); adf_cfg_dev_remove(accel_dev); adf_devmgr_rm_dev(accel_dev, NULL); } @@ -280,6 +280,8 @@ adf_attach(device_t dev) } pci_enable_busmaster(dev); + adf_dbgfs_init(accel_dev); + if (!accel_dev->hw_device->config_device) { ret = EFAULT; goto out_err; diff --git a/sys/dev/qat/qat_hw/qat_4xxxvf/adf_drv.c b/sys/dev/qat/qat_hw/qat_4xxxvf/adf_drv.c index 9b66ae4b2370..42189c28b21a 100644 --- a/sys/dev/qat/qat_hw/qat_4xxxvf/adf_drv.c +++ b/sys/dev/qat/qat_hw/qat_4xxxvf/adf_drv.c @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ #include "qat_freebsd.h" #include #include @@ -8,6 +8,7 @@ #include "adf_gen4_hw_data.h" #include "adf_fw_counters.h" #include "adf_cfg_device.h" +#include "adf_dbgfs.h" #include #include #include @@ -83,6 +84,7 @@ adf_cleanup_accel(struct adf_accel_dev *accel_dev) free(accel_dev->hw_device, M_QAT_4XXXVF); accel_dev->hw_device = NULL; } + adf_dbgfs_exit(accel_dev); adf_cfg_dev_remove(accel_dev); } @@ -180,6 +182,8 @@ adf_attach(device_t dev) } pci_enable_busmaster(dev); + adf_dbgfs_init(accel_dev); + /* Completion for VF2PF request/response message exchange */ init_completion(&accel_dev->u1.vf.msg_received); mutex_init(&accel_dev->u1.vf.rpreset_lock); diff --git a/sys/dev/qat/qat_hw/qat_c3xxx/adf_drv.c b/sys/dev/qat/qat_hw/qat_c3xxx/adf_drv.c index 74e9e2292623..9f2c9374e968 100644 --- a/sys/dev/qat/qat_hw/qat_c3xxx/adf_drv.c +++ b/sys/dev/qat/qat_hw/qat_c3xxx/adf_drv.c @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ #include "qat_freebsd.h" #include "adf_cfg.h" #include "adf_common_drv.h" @@ -7,13 +7,12 @@ #include "adf_c3xxx_hw_data.h" #include "adf_fw_counters.h" #include "adf_cfg_device.h" +#include "adf_dbgfs.h" #include #include #include #include #include -#include "adf_heartbeat_dbg.h" -#include "adf_cnvnr_freq_counters.h" static MALLOC_DEFINE(M_QAT_C3XXX, "qat_c3xxx", "qat_c3xxx"); @@ -73,6 +72,7 @@ adf_cleanup_accel(struct adf_accel_dev *accel_dev) free(accel_dev->hw_device, M_QAT_C3XXX); accel_dev->hw_device = NULL; } + adf_dbgfs_exit(accel_dev); adf_cfg_dev_remove(accel_dev); adf_devmgr_rm_dev(accel_dev, NULL); } @@ -204,6 +204,8 @@ adf_attach(device_t dev) } pci_enable_busmaster(dev); + adf_dbgfs_init(accel_dev); + if (!accel_dev->hw_device->config_device) { ret = EFAULT; goto out_err; diff --git a/sys/dev/qat/qat_hw/qat_c4xxx/adf_drv.c b/sys/dev/qat/qat_hw/qat_c4xxx/adf_drv.c index 0e206e960a6c..697f5b1ce786 100644 --- a/sys/dev/qat/qat_hw/qat_c4xxx/adf_drv.c +++ b/sys/dev/qat/qat_hw/qat_c4xxx/adf_drv.c @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ #include "qat_freebsd.h" #include "adf_cfg.h" #include "adf_common_drv.h" @@ -7,13 +7,12 @@ #include "adf_c4xxx_hw_data.h" #include "adf_fw_counters.h" #include "adf_cfg_device.h" +#include "adf_dbgfs.h" #include #include #include #include #include -#include "adf_heartbeat_dbg.h" -#include "adf_cnvnr_freq_counters.h" static MALLOC_DEFINE(M_QAT_C4XXX, "qat_c4xx", "qat_c4xx"); @@ -73,6 +72,7 @@ adf_cleanup_accel(struct adf_accel_dev *accel_dev) free(accel_dev->hw_device, M_QAT_C4XXX); accel_dev->hw_device = NULL; } + adf_dbgfs_exit(accel_dev); adf_cfg_dev_remove(accel_dev); adf_devmgr_rm_dev(accel_dev, NULL); } @@ -203,6 +203,8 @@ adf_attach(device_t dev) } pci_enable_busmaster(dev); + adf_dbgfs_init(accel_dev); + if (!accel_dev->hw_device->config_device) { ret = EFAULT; goto out_err; diff --git a/sys/dev/qat/qat_hw/qat_c62x/adf_drv.c b/sys/dev/qat/qat_hw/qat_c62x/adf_drv.c index 4035a8385bd5..1d48b85b2e12 100644 --- a/sys/dev/qat/qat_hw/qat_c62x/adf_drv.c +++ b/sys/dev/qat/qat_hw/qat_c62x/adf_drv.c @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ #include "qat_freebsd.h" #include "adf_cfg.h" #include "adf_common_drv.h" @@ -7,13 +7,12 @@ #include "adf_c62x_hw_data.h" #include "adf_fw_counters.h" #include "adf_cfg_device.h" +#include "adf_dbgfs.h" #include #include #include #include #include -#include "adf_heartbeat_dbg.h" -#include "adf_cnvnr_freq_counters.h" static MALLOC_DEFINE(M_QAT_C62X, "qat_c62x", "qat_c62x"); @@ -73,6 +72,7 @@ adf_cleanup_accel(struct adf_accel_dev *accel_dev) free(accel_dev->hw_device, M_QAT_C62X); accel_dev->hw_device = NULL; } + adf_dbgfs_exit(accel_dev); adf_cfg_dev_remove(accel_dev); adf_devmgr_rm_dev(accel_dev, NULL); } @@ -205,6 +205,8 @@ adf_attach(device_t dev) } pci_enable_busmaster(dev); + adf_dbgfs_init(accel_dev); + if (!accel_dev->hw_device->config_device) { ret = EFAULT; goto out_err; diff --git a/sys/dev/qat/qat_hw/qat_dh895xcc/adf_drv.c b/sys/dev/qat/qat_hw/qat_dh895xcc/adf_drv.c index f7a31da23ba9..d8f2ba0a99b7 100644 --- a/sys/dev/qat/qat_hw/qat_dh895xcc/adf_drv.c +++ b/sys/dev/qat/qat_hw/qat_dh895xcc/adf_drv.c @@ -1,5 +1,5 @@ /* SPDX-License-Identifier: BSD-3-Clause */ -/* Copyright(c) 2007-2022 Intel Corporation */ +/* Copyright(c) 2007-2025 Intel Corporation */ #include "qat_freebsd.h" #include "adf_cfg.h" #include "adf_common_drv.h" @@ -7,13 +7,12 @@ #include "adf_dh895xcc_hw_data.h" #include "adf_fw_counters.h" #include "adf_cfg_device.h" +#include "adf_dbgfs.h" #include #include #include #include #include *** 34 LINES SKIPPED ***