From patchwork Tue Apr 28 02:05:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacob Keller X-Patchwork-Id: 220420 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 898A7C83003 for ; Tue, 28 Apr 2020 02:05:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 68DC5206E2 for ; Tue, 28 Apr 2020 02:05:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726335AbgD1CFP (ORCPT ); Mon, 27 Apr 2020 22:05:15 -0400 Received: from mga05.intel.com ([192.55.52.43]:46674 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726233AbgD1CFP (ORCPT ); Mon, 27 Apr 2020 22:05:15 -0400 IronPort-SDR: chmD0LsRGtO3B0TNZqwh1eJ4D7gwPmSMHfy3Uq6xkd4H0GeBKuF4+RxCQQ+ZxjWUguo2RFxIkn /LLPA0Qd1uCQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Apr 2020 19:05:14 -0700 IronPort-SDR: azfndBy5wBCHNFP/tyqMZ7JW1ZFvq6KiJtwJPh4gcOSqS4xVmxiV+aMFHTBKOtyTd6ljDEPsWK tLX8dBDY4QCA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,326,1583222400"; d="scan'208";a="367348891" Received: from jekeller-desk.amr.corp.intel.com ([10.166.241.33]) by fmsmga001.fm.intel.com with ESMTP; 27 Apr 2020 19:05:14 -0700 From: Jacob Keller To: netdev@vger.kernel.org Cc: Jakub Kicinski , Jacob Keller Subject: [iproute2] devlink: add support for DEVLINK_CMD_REGION_NEW Date: Mon, 27 Apr 2020 19:05:12 -0700 Message-Id: <20200428020512.1099264-1-jacob.e.keller@intel.com> X-Mailer: git-send-email 2.25.2 MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add support to request that a new snapshot be taken immediately for a devlink region. To avoid confusion, the desired snapshot id must be provided. Note that if a region does not support snapshots on demand, the kernel will reject the request with -EOPNOTSUP. Signed-off-by: Jacob Keller --- devlink/devlink.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/devlink/devlink.c b/devlink/devlink.c index 67e6e64181f9..c750ee1ec6d3 100644 --- a/devlink/devlink.c +++ b/devlink/devlink.c @@ -6362,10 +6362,27 @@ static int cmd_region_read(struct dl *dl) return err; } +static int cmd_region_snapshot_new(struct dl *dl) +{ + struct nlmsghdr *nlh; + int err; + + nlh = mnlg_msg_prepare(dl->nlg, DEVLINK_CMD_REGION_NEW, + NLM_F_REQUEST | NLM_F_ACK); + + err = dl_argv_parse_put(nlh, dl, DL_OPT_HANDLE_REGION | + DL_OPT_REGION_SNAPSHOT_ID, 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 new 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"); } @@ -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, "new")) { + dl_arg_inc(dl); + return cmd_region_snapshot_new(dl); } pr_err("Command \"%s\" not found\n", dl_argv(dl)); return -ENOENT;