From patchwork Thu Jan 9 01:08:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Keller, Jacob E" X-Patchwork-Id: 1220095 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.133; helo=hemlock.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=intel.com Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47tSh85jRgz9sPK for ; Thu, 9 Jan 2020 12:09:44 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 3AF0187E17; Thu, 9 Jan 2020 01:09:43 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id smT46XkU2kkt; Thu, 9 Jan 2020 01:09:42 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id 5FD1787E14; Thu, 9 Jan 2020 01:09:41 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 3F68F1BF39A for ; Thu, 9 Jan 2020 01:09:38 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 3A09F86447 for ; Thu, 9 Jan 2020 01:09:38 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gbaRMw7ezJrf for ; Thu, 9 Jan 2020 01:09:36 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by whitealder.osuosl.org (Postfix) with ESMTPS id 90016864C5 for ; Thu, 9 Jan 2020 01:09:36 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Jan 2020 17:09:34 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,412,1571727600"; d="scan'208";a="223112620" Received: from jekeller-desk.amr.corp.intel.com ([10.166.244.172]) by orsmga006.jf.intel.com with ESMTP; 08 Jan 2020 17:09:34 -0800 From: Jacob Keller To: Intel Wired LAN Date: Wed, 8 Jan 2020 17:08:16 -0800 Message-Id: <20200109010818.1326575-2-jacob.e.keller@intel.com> X-Mailer: git-send-email 2.25.0.rc1 In-Reply-To: <20200109010818.1326575-1-jacob.e.keller@intel.com> References: <20200109010818.1326575-1-jacob.e.keller@intel.com> MIME-Version: 1.0 Subject: [Intel-wired-lan] [PATCH 1/4] devlink: correct misspelling of snapshot X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jiri@resnulli.us, valex@mellanox.com Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" The function to obtain a unique snapshot id was mistakenly typo'd as devlink_region_shapshot_id_get. Fix this typo by renaming the function and all of its users. Signed-off-by: Jacob Keller --- drivers/net/ethernet/mellanox/mlx4/crdump.c | 2 +- drivers/net/netdevsim/dev.c | 2 +- include/net/devlink.h | 2 +- net/core/devlink.c | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/crdump.c b/drivers/net/ethernet/mellanox/mlx4/crdump.c index eaf08f7ad128..64ed725aec28 100644 --- a/drivers/net/ethernet/mellanox/mlx4/crdump.c +++ b/drivers/net/ethernet/mellanox/mlx4/crdump.c @@ -182,7 +182,7 @@ int mlx4_crdump_collect(struct mlx4_dev *dev) crdump_enable_crspace_access(dev, cr_space); /* Get the available snapshot ID for the dumps */ - id = devlink_region_shapshot_id_get(devlink); + id = devlink_region_snapshot_id_get(devlink); /* Try to capture dumps */ mlx4_crdump_collect_crspace(dev, cr_space, id); diff --git a/drivers/net/netdevsim/dev.c b/drivers/net/netdevsim/dev.c index 059711edfc61..4b39aba2e9c4 100644 --- a/drivers/net/netdevsim/dev.c +++ b/drivers/net/netdevsim/dev.c @@ -53,7 +53,7 @@ static ssize_t nsim_dev_take_snapshot_write(struct file *file, get_random_bytes(dummy_data, NSIM_DEV_DUMMY_REGION_SIZE); - id = devlink_region_shapshot_id_get(priv_to_devlink(nsim_dev)); + id = devlink_region_snapshot_id_get(priv_to_devlink(nsim_dev)); err = devlink_region_snapshot_create(nsim_dev->dummy_region, dummy_data, id, kfree); if (err) { diff --git a/include/net/devlink.h b/include/net/devlink.h index 47f87b2fcf63..38b4acb93f74 100644 --- a/include/net/devlink.h +++ b/include/net/devlink.h @@ -938,7 +938,7 @@ struct devlink_region *devlink_region_create(struct devlink *devlink, u32 region_max_snapshots, u64 region_size); void devlink_region_destroy(struct devlink_region *region); -u32 devlink_region_shapshot_id_get(struct devlink *devlink); +u32 devlink_region_snapshot_id_get(struct devlink *devlink); int devlink_region_snapshot_create(struct devlink_region *region, u8 *data, u32 snapshot_id, devlink_snapshot_data_dest_t *data_destructor); diff --git a/net/core/devlink.c b/net/core/devlink.c index 4c63c9a4c09e..b6fc67dbd612 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -7563,7 +7563,7 @@ void devlink_region_destroy(struct devlink_region *region) EXPORT_SYMBOL_GPL(devlink_region_destroy); /** - * devlink_region_shapshot_id_get - get snapshot ID + * devlink_region_snapshot_id_get - get snapshot ID * * This callback should be called when adding a new snapshot, * Driver should use the same id for multiple snapshots taken @@ -7571,7 +7571,7 @@ EXPORT_SYMBOL_GPL(devlink_region_destroy); * * @devlink: devlink */ -u32 devlink_region_shapshot_id_get(struct devlink *devlink) +u32 devlink_region_snapshot_id_get(struct devlink *devlink) { u32 id; @@ -7581,7 +7581,7 @@ u32 devlink_region_shapshot_id_get(struct devlink *devlink) return id; } -EXPORT_SYMBOL_GPL(devlink_region_shapshot_id_get); +EXPORT_SYMBOL_GPL(devlink_region_snapshot_id_get); /** * devlink_region_snapshot_create - create a new snapshot From patchwork Thu Jan 9 01:08:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Keller, Jacob E" X-Patchwork-Id: 1220093 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.138; helo=whitealder.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=intel.com Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47tSh6335Tz9sPK for ; Thu, 9 Jan 2020 12:09:42 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id C6BD286447; Thu, 9 Jan 2020 01:09:40 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id I9uXcRyUTPZd; Thu, 9 Jan 2020 01:09:38 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id B3FE2864C5; Thu, 9 Jan 2020 01:09:38 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id C441F1BF39A for ; Thu, 9 Jan 2020 01:09:36 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id C13D586503 for ; Thu, 9 Jan 2020 01:09:36 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id W2dvNwSpSfzi for ; Thu, 9 Jan 2020 01:09:36 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by whitealder.osuosl.org (Postfix) with ESMTPS id 20202864DA for ; Thu, 9 Jan 2020 01:09:36 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Jan 2020 17:09:34 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,412,1571727600"; d="scan'208";a="223112622" Received: from jekeller-desk.amr.corp.intel.com ([10.166.244.172]) by orsmga006.jf.intel.com with ESMTP; 08 Jan 2020 17:09:34 -0800 From: Jacob Keller To: Intel Wired LAN Date: Wed, 8 Jan 2020 17:08:17 -0800 Message-Id: <20200109010818.1326575-3-jacob.e.keller@intel.com> X-Mailer: git-send-email 2.25.0.rc1 In-Reply-To: <20200109010818.1326575-1-jacob.e.keller@intel.com> References: <20200109010818.1326575-1-jacob.e.keller@intel.com> MIME-Version: 1.0 Subject: [Intel-wired-lan] [PATCH 2/4] doc: fix typo of snapshot in documentation X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jiri@resnulli.us, valex@mellanox.com Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" A couple of locations accidentally misspelled snapshot as shapshot. Signed-off-by: Jacob Keller --- Documentation/admin-guide/devices.txt | 2 +- Documentation/media/v4l-drivers/meye.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/admin-guide/devices.txt b/Documentation/admin-guide/devices.txt index 1c5d2281efc9..2a97aaec8b12 100644 --- a/Documentation/admin-guide/devices.txt +++ b/Documentation/admin-guide/devices.txt @@ -319,7 +319,7 @@ 182 = /dev/perfctr Performance-monitoring counters 183 = /dev/hwrng Generic random number generator 184 = /dev/cpu/microcode CPU microcode update interface - 186 = /dev/atomicps Atomic shapshot of process state data + 186 = /dev/atomicps Atomic snapshot of process state data 187 = /dev/irnet IrNET device 188 = /dev/smbusbios SMBus BIOS 189 = /dev/ussp_ctl User space serial port control diff --git a/Documentation/media/v4l-drivers/meye.rst b/Documentation/media/v4l-drivers/meye.rst index a572996cdbf6..dc57a6a91b43 100644 --- a/Documentation/media/v4l-drivers/meye.rst +++ b/Documentation/media/v4l-drivers/meye.rst @@ -95,7 +95,7 @@ so all video4linux tools (like xawtv) should work with this driver. Besides the video4linux interface, the driver has a private interface for accessing the Motion Eye extended parameters (camera sharpness, -agc, video framerate), the shapshot and the MJPEG capture facilities. +agc, video framerate), the snapshot and the MJPEG capture facilities. This interface consists of several ioctls (prototypes and structures can be found in include/linux/meye.h): From patchwork Thu Jan 9 01:08:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Keller, Jacob E" X-Patchwork-Id: 1220096 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.133; helo=hemlock.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=intel.com Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47tSh95b6rz9sRY for ; Thu, 9 Jan 2020 12:09:45 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id B725F87E3D; Thu, 9 Jan 2020 01:09:43 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 34lI4aFElken; Thu, 9 Jan 2020 01:09:41 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id 0C0CD8791E; Thu, 9 Jan 2020 01:09:41 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 70A961BF39A for ; Thu, 9 Jan 2020 01:09:37 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 6B441864DA for ; Thu, 9 Jan 2020 01:09:37 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id SmRQkF+PkZII for ; Thu, 9 Jan 2020 01:09:36 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by whitealder.osuosl.org (Postfix) with ESMTPS id 58A8486447 for ; Thu, 9 Jan 2020 01:09:36 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Jan 2020 17:09:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,412,1571727600"; d="scan'208";a="223112626" Received: from jekeller-desk.amr.corp.intel.com ([10.166.244.172]) by orsmga006.jf.intel.com with ESMTP; 08 Jan 2020 17:09:34 -0800 From: Jacob Keller To: Intel Wired LAN Date: Wed, 8 Jan 2020 17:08:18 -0800 Message-Id: <20200109010818.1326575-4-jacob.e.keller@intel.com> X-Mailer: git-send-email 2.25.0.rc1 In-Reply-To: <20200109010818.1326575-1-jacob.e.keller@intel.com> References: <20200109010818.1326575-1-jacob.e.keller@intel.com> MIME-Version: 1.0 Subject: [Intel-wired-lan] [PATCH 3/4] devlink: add support for triggering snapshots from userspace X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jiri@resnulli.us, valex@mellanox.com Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" Currently, devlink region snapshots are captured by the driver at some internal trigger. There is no standard method for userspace to request that a snapshot be created. For some use cases of regions, this is acceptable. The snapshots only make sense if taken in response to some internal driver event. However, regions could be used for other purposes. For example, a driver might export a region that represents the contents of some portion of the device flash. In this case, there is no event that triggers a snapshot. Instead, it makes sense for user space to request a snapshot in some manner. Currently, drivers must implement such a trigger through an out-of-band mechanism. The netdevsim driver does this through a debugfs file. Create a standard interface for requesting snapshots via a new devlink command: DEVLINK_CMG_REGION_TRIGGER_SNAPSHOT. At region creation time, drivers may optionally define a trigger_snapshot function callback. If not defined, the DEVLINK_CMD_REGION_TRIGGER_SNAPSHOT will simply report EOPNOTSUPP. If defined, the command will call the trigger_snapshot function callback, resulting in a new snapshot being created. With this, there is a standard mechanism for requesting new snapshots of a given devlink region. Signed-off-by: Jacob Keller --- drivers/net/ethernet/mellanox/mlx4/crdump.c | 4 +- drivers/net/netdevsim/dev.c | 37 +++++++++++++----- include/net/devlink.h | 12 ++++-- include/uapi/linux/devlink.h | 2 + net/core/devlink.c | 43 +++++++++++++++++++-- 5 files changed, 78 insertions(+), 20 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/crdump.c b/drivers/net/ethernet/mellanox/mlx4/crdump.c index 64ed725aec28..4b1373414b0b 100644 --- a/drivers/net/ethernet/mellanox/mlx4/crdump.c +++ b/drivers/net/ethernet/mellanox/mlx4/crdump.c @@ -207,7 +207,7 @@ int mlx4_crdump_init(struct mlx4_dev *dev) devlink_region_create(devlink, region_cr_space_str, MAX_NUM_OF_DUMPS_TO_STORE, - pci_resource_len(pdev, 0)); + pci_resource_len(pdev, 0), NULL); if (IS_ERR(crdump->region_crspace)) mlx4_warn(dev, "crdump: create devlink region %s err %ld\n", region_cr_space_str, @@ -218,7 +218,7 @@ int mlx4_crdump_init(struct mlx4_dev *dev) devlink_region_create(devlink, region_fw_health_str, MAX_NUM_OF_DUMPS_TO_STORE, - HEALTH_BUFFER_SIZE); + HEALTH_BUFFER_SIZE, NULL); if (IS_ERR(crdump->region_fw_health)) mlx4_warn(dev, "crdump: create devlink region %s err %ld\n", region_fw_health_str, diff --git a/drivers/net/netdevsim/dev.c b/drivers/net/netdevsim/dev.c index 4b39aba2e9c4..4ed9c8d8de7c 100644 --- a/drivers/net/netdevsim/dev.c +++ b/drivers/net/netdevsim/dev.c @@ -38,30 +38,46 @@ static struct dentry *nsim_dev_ddir; #define NSIM_DEV_DUMMY_REGION_SIZE (1024 * 32) -static ssize_t nsim_dev_take_snapshot_write(struct file *file, - const char __user *data, - size_t count, loff_t *ppos) +static int nsim_dev_trigger_snapshot(struct devlink *devlink, + struct devlink_region *region, + struct netlink_ext_ack *extack) { - struct nsim_dev *nsim_dev = file->private_data; void *dummy_data; int err; u32 id; dummy_data = kmalloc(NSIM_DEV_DUMMY_REGION_SIZE, GFP_KERNEL); - if (!dummy_data) + if (!dummy_data) { + NL_SET_ERR_MSG(extack, "Out of memory"); return -ENOMEM; + } get_random_bytes(dummy_data, NSIM_DEV_DUMMY_REGION_SIZE); - id = devlink_region_snapshot_id_get(priv_to_devlink(nsim_dev)); - err = devlink_region_snapshot_create(nsim_dev->dummy_region, - dummy_data, id, kfree); + id = devlink_region_snapshot_id_get(devlink); + err = devlink_region_snapshot_create(region, dummy_data, id, kfree); if (err) { - pr_err("Failed to create region snapshot\n"); + NL_SET_ERR_MSG(extack, "Failed to create region snapshot"); kfree(dummy_data); return err; } + return (0); + +} + +static ssize_t nsim_dev_take_snapshot_write(struct file *file, + const char __user *data, + size_t count, loff_t *ppos) +{ + struct nsim_dev *nsim_dev = file->private_data; + int err; + + err = nsim_dev_trigger_snapshot(priv_to_devlink(nsim_dev), + nsim_dev->dummy_region, NULL); + if (err) + return err; + return count; } @@ -248,7 +264,8 @@ static int nsim_dev_dummy_region_init(struct nsim_dev *nsim_dev, nsim_dev->dummy_region = devlink_region_create(devlink, "dummy", NSIM_DEV_DUMMY_REGION_SNAPSHOT_MAX, - NSIM_DEV_DUMMY_REGION_SIZE); + NSIM_DEV_DUMMY_REGION_SIZE, + nsim_dev_trigger_snapshot); return PTR_ERR_OR_ZERO(nsim_dev->dummy_region); } diff --git a/include/net/devlink.h b/include/net/devlink.h index 38b4acb93f74..f93b1a07c9f2 100644 --- a/include/net/devlink.h +++ b/include/net/devlink.h @@ -491,6 +491,10 @@ struct devlink_info_req; typedef void devlink_snapshot_data_dest_t(const void *data); +typedef int devlink_trigger_snapshot_t(struct devlink *devlink, + struct devlink_region *region, + struct netlink_ext_ack *extack); + struct devlink_fmsg; struct devlink_health_reporter; @@ -933,10 +937,10 @@ void devlink_port_param_value_changed(struct devlink_port *devlink_port, u32 param_id); void devlink_param_value_str_fill(union devlink_param_value *dst_val, const char *src); -struct devlink_region *devlink_region_create(struct devlink *devlink, - const char *region_name, - u32 region_max_snapshots, - u64 region_size); +struct devlink_region * +devlink_region_create(struct devlink *devlink, const char *region_name, + u32 region_max_snapshots, u64 region_size, + devlink_trigger_snapshot_t *trigger_snapshot); void devlink_region_destroy(struct devlink_region *region); u32 devlink_region_snapshot_id_get(struct devlink *devlink); int devlink_region_snapshot_create(struct devlink_region *region, diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h index ae37fd4d194a..19bec058691d 100644 --- a/include/uapi/linux/devlink.h +++ b/include/uapi/linux/devlink.h @@ -117,6 +117,8 @@ enum devlink_command { DEVLINK_CMD_TRAP_GROUP_NEW, DEVLINK_CMD_TRAP_GROUP_DEL, + DEVLINK_CMD_REGION_TRIGGER_SNAPSHOT, + /* add new commands above here */ __DEVLINK_CMD_MAX, DEVLINK_CMD_MAX = __DEVLINK_CMD_MAX - 1 diff --git a/net/core/devlink.c b/net/core/devlink.c index b6fc67dbd612..ffc87dd54dbd 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -349,6 +349,7 @@ struct devlink_region { u32 max_snapshots; u32 cur_snapshots; u64 size; + devlink_trigger_snapshot_t *trigger_snapshot; }; struct devlink_snapshot { @@ -4052,6 +4053,30 @@ static int devlink_nl_cmd_region_read_dumpit(struct sk_buff *skb, return err; } +static int devlink_nl_cmd_region_trigger_snapshot(struct sk_buff *skb, + struct genl_info *info) +{ + struct devlink *devlink = info->user_ptr[0]; + struct devlink_region *region; + const char *region_name; + struct sk_buff *msg; + u32 snapshot_id; + int err; + + if (!info->attrs[DEVLINK_ATTR_REGION_NAME]) + return -EINVAL; + + region_name = nla_data(info->attrs[DEVLINK_ATTR_REGION_NAME]); + region = devlink_region_get_by_name(devlink, region_name); + if (!region) + return -EINVAL; + + if (!region->trigger_snapshot) + return -EOPNOTSUPP; + + return region->trigger_snapshot(devlink, region, info->extack); +} + struct devlink_info_req { struct sk_buff *msg; }; @@ -6158,6 +6183,14 @@ static const struct genl_ops devlink_nl_ops[] = { .flags = GENL_ADMIN_PERM, .internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK, }, + { + .cmd = DEVLINK_CMD_REGION_TRIGGER_SNAPSHOT, + .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, + .doit = devlink_nl_cmd_region_trigger_snapshot, + .flags = GENL_ADMIN_PERM, + .internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK | + DEVLINK_NL_FLAG_NO_LOCK, + }, { .cmd = DEVLINK_CMD_INFO_GET, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, @@ -7499,11 +7532,12 @@ EXPORT_SYMBOL_GPL(devlink_param_value_str_fill); * @region_name: region name * @region_max_snapshots: Maximum supported number of snapshots for region * @region_size: size of region + * @trigger_snapshot: function to trigger creation of snapshot */ -struct devlink_region *devlink_region_create(struct devlink *devlink, - const char *region_name, - u32 region_max_snapshots, - u64 region_size) +struct devlink_region * +devlink_region_create(struct devlink *devlink, const char *region_name, + u32 region_max_snapshots, u64 region_size, + devlink_trigger_snapshot_t *trigger_snapshot) { struct devlink_region *region; int err = 0; @@ -7525,6 +7559,7 @@ struct devlink_region *devlink_region_create(struct devlink *devlink, region->max_snapshots = region_max_snapshots; region->name = region_name; region->size = region_size; + region->trigger_snapshot = trigger_snapshot; INIT_LIST_HEAD(®ion->snapshot_list); list_add_tail(®ion->list, &devlink->region_list); devlink_nl_region_notify(region, NULL, DEVLINK_CMD_REGION_NEW); From patchwork Thu Jan 9 01:08:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Keller, Jacob E" X-Patchwork-Id: 1220094 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=140.211.166.137; helo=fraxinus.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=intel.com Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47tSh74WrHz9sRY for ; Thu, 9 Jan 2020 12:09:43 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id CD547844B3; Thu, 9 Jan 2020 01:09:40 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XnHXz1cTQ5mV; Thu, 9 Jan 2020 01:09:38 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id 6437C84491; Thu, 9 Jan 2020 01:09:38 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 770B21BF9B2 for ; Thu, 9 Jan 2020 01:09:36 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 73FA0864F5 for ; Thu, 9 Jan 2020 01:09:36 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9k3Zw694uqlJ for ; Thu, 9 Jan 2020 01:09:36 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by whitealder.osuosl.org (Postfix) with ESMTPS id DD776864C5 for ; Thu, 9 Jan 2020 01:09:35 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Jan 2020 17:09:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,412,1571727600"; d="scan'208";a="223112628" Received: from jekeller-desk.amr.corp.intel.com ([10.166.244.172]) by orsmga006.jf.intel.com with ESMTP; 08 Jan 2020 17:09:34 -0800 From: Jacob Keller To: Intel Wired LAN Date: Wed, 8 Jan 2020 17:08:19 -0800 Message-Id: <20200109010818.1326575-5-jacob.e.keller@intel.com> X-Mailer: git-send-email 2.25.0.rc1 In-Reply-To: <20200109010818.1326575-1-jacob.e.keller@intel.com> References: <20200109010818.1326575-1-jacob.e.keller@intel.com> MIME-Version: 1.0 Subject: [Intel-wired-lan] [PATCH 4/4] devlink: add support for DEVLINK_CMD_REGION_TRIGGER_SNAPSHOT X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jiri@resnulli.us, valex@mellanox.com Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" Add support for the devlink command to trigger a snapshot if the region supports it. Signed-off-by: Jacob Keller --- devlink/devlink.c | 20 ++++++++++++++++++++ include/uapi/linux/devlink.h | 2 ++ 2 files changed, 22 insertions(+) diff --git a/devlink/devlink.c b/devlink/devlink.c index 95f05a0b..3a473531 100644 --- a/devlink/devlink.c +++ b/devlink/devlink.c @@ -4200,6 +4200,7 @@ static const char *cmd_obj(uint8_t cmd) case DEVLINK_CMD_REGION_SET: case DEVLINK_CMD_REGION_NEW: case DEVLINK_CMD_REGION_DEL: + case DEVLINK_CMD_REGION_TRIGGER_SNAPSHOT: return "region"; case DEVLINK_CMD_FLASH_UPDATE: case DEVLINK_CMD_FLASH_UPDATE_END: @@ -6362,12 +6363,28 @@ static int cmd_region_read(struct dl *dl) return err; } +static int cmd_region_trigger(struct dl *dl) +{ + struct nlmsghdr *nlh; + int err; + + nlh = mnlg_msg_prepare(dl->nlg, DEVLINK_CMD_REGION_TRIGGER_SNAPSHOT, + NLM_F_REQUEST | NLM_F_ACK); + + err = dl_argv_parse_put(nlh, dl, DL_OPT_HANDLE_REGION, 0); + if (err) + return err; + + return _mnlg_socket_sndrcv(dl->nlg, nlh, NULL, NULL); +} + static void cmd_region_help(void) { pr_err("Usage: devlink region show [ DEV/REGION ]\n"); pr_err(" devlink region del DEV/REGION snapshot SNAPSHOT_ID\n"); pr_err(" devlink region dump DEV/REGION [ snapshot SNAPSHOT_ID ]\n"); pr_err(" devlink region read DEV/REGION [ snapshot SNAPSHOT_ID ] address ADDRESS length LENGTH\n"); + pr_err(" devlink region trigger DEV/REGION\n"); } static int cmd_region(struct dl *dl) @@ -6389,6 +6406,9 @@ static int cmd_region(struct dl *dl) } else if (dl_argv_match(dl, "read")) { dl_arg_inc(dl); return cmd_region_read(dl); + } else if (dl_argv_match(dl, "trigger")) { + dl_arg_inc(dl); + return cmd_region_trigger(dl); } pr_err("Command \"%s\" not found\n", dl_argv(dl)); return -ENOENT; diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h index 3f82dedd..37348f84 100644 --- a/include/uapi/linux/devlink.h +++ b/include/uapi/linux/devlink.h @@ -117,6 +117,8 @@ enum devlink_command { DEVLINK_CMD_TRAP_GROUP_NEW, DEVLINK_CMD_TRAP_GROUP_DEL, + DEVLINK_CMD_REGION_TRIGGER_SNAPSHOT, + /* add new commands above here */ __DEVLINK_CMD_MAX, DEVLINK_CMD_MAX = __DEVLINK_CMD_MAX - 1