From patchwork Wed Jan 3 00:34:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 13509584 X-Patchwork-Delegate: dsahern@gmail.com Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1127D257E for ; Wed, 3 Jan 2024 00:36:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=networkplumber.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=networkplumber.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=networkplumber-org.20230601.gappssmtp.com header.i=@networkplumber-org.20230601.gappssmtp.com header.b="yLgnA4eT" Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-6d9b37f4804so4207377b3a.1 for ; Tue, 02 Jan 2024 16:36:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1704242169; x=1704846969; 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=PgVIYHhcRrcBmcar/jXnvQJ+Eb4s64gp589ASDDzuQ4=; b=yLgnA4eTo6K52wgvPdw/B6HHH0A12AN/ettWceA3gJKQC/VhxHoIStoLl8dw8jFYoZ b6BFjwUUwR06MyjxjT0B2xIeVKIy+qoPn+Sp0St5PZzCv7jglcev6+6EYE973AvEoe4g pA0I1rhAiHwFnF0SEXDn6ESIf1WX38svNdlA2pp0OlfE6p6OlVxC4pGSg8nhJU6umE5N AdyWuTaApTDKPfKfxMSbF5EG1GjLFL0LaWvi5sy/a0I0OO1TMubBxRm91z2YnTsQg+OJ abJxCFGUAAJwETde3mpTxJC/glKEFz72S7KuAx5Y8jOdNCi4v4P+6pN8klbxawVT4Lv7 IoDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704242169; x=1704846969; 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=PgVIYHhcRrcBmcar/jXnvQJ+Eb4s64gp589ASDDzuQ4=; b=OrANulU0IwvBHu7nKXq3Atordv+vhDGlaD+OviW35g0TZas0Ed/cRFoYYWYTyNT1wA PNu8u7odHc8j4eOXUPu9tkDr0igUw5KLweIAH6G1iFgj6g84B1rU8YK/YuVCu0r3W4eY vvzv3OfJqSN4DRYqxsgP06kgwddWVEo4qOOlJ6xVPsqH7bq03fgiGn1TGiSGF0yFM7WL lGYlbWPYtddyUyGQhXTl0wstdZYqFT6otbq3idXxMUP5ZOmM8skNQ5MEIVl/VLEFBrAA eBf29gungBtq7upfymBPhLYVI6KrOg4NjsnqslOBFdKY/Z7jiiyfRR1rxTn/94KoUN3e Xbpw== X-Gm-Message-State: AOJu0YzlMGTReqXHdHlZ5K1s1MOmuX9pu65b7xT4yyTi4+OiYsQqaJdF xjog/PcBYQ/0x2b1eRSWp7wNOAC7Ptulcw== X-Google-Smtp-Source: AGHT+IGyWjZYDL2ueMyie/4skyDTevHUh5mG7WaH+deZsZj9CgzhwBTd0zlBUMHrZUVyZRL+lqWIFw== X-Received: by 2002:a05:6a00:130f:b0:6d9:b5cb:d773 with SMTP id j15-20020a056a00130f00b006d9b5cbd773mr341915pfu.22.1704242169202; Tue, 02 Jan 2024 16:36:09 -0800 (PST) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id y12-20020aa7854c000000b006d9af59eecesm16698260pfn.20.2024.01.02.16.36.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 16:36:08 -0800 (PST) From: Stephen Hemminger To: leon@kernel.org Cc: netdev@vger.kernel.org, Stephen Hemminger Subject: [RFC iproute2 1/8] rdma: shorten print_ lines Date: Tue, 2 Jan 2024 16:34:26 -0800 Message-ID: <20240103003558.20615-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240103003558.20615-1-stephen@networkplumber.org> References: <20240103003558.20615-1-stephen@networkplumber.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: dsahern@gmail.com X-Patchwork-State: RFC With the shorter form of print_ function some of the lines can now be shortened. Max line length in iproute2 should be 100 characters or less. Signed-off-by: Stephen Hemminger --- rdma/dev.c | 6 ++---- rdma/link.c | 16 ++++++---------- rdma/res-cq.c | 3 +-- rdma/res-qp.c | 9 +++------ rdma/res-srq.c | 3 +-- rdma/res.c | 11 ++++------- rdma/stat.c | 20 +++++++------------- rdma/sys.c | 10 +++------- rdma/utils.c | 15 +++++---------- 9 files changed, 32 insertions(+), 61 deletions(-) diff --git a/rdma/dev.c b/rdma/dev.c index e3483482c823..7496162df9e2 100644 --- a/rdma/dev.c +++ b/rdma/dev.c @@ -144,8 +144,7 @@ static void dev_print_sys_image_guid(struct rd *rd, struct nlattr **tb) sys_image_guid = mnl_attr_get_u64(tb[RDMA_NLDEV_ATTR_SYS_IMAGE_GUID]); memcpy(vp, &sys_image_guid, sizeof(uint64_t)); snprintf(str, 32, "%04x:%04x:%04x:%04x", vp[3], vp[2], vp[1], vp[0]); - print_string(PRINT_ANY, "sys_image_guid", - "sys_image_guid %s ", str); + print_string(PRINT_ANY, "sys_image_guid", "sys_image_guid %s ", str); } static void dev_print_dim_setting(struct rd *rd, struct nlattr **tb) @@ -185,8 +184,7 @@ static void dev_print_node_type(struct rd *rd, struct nlattr **tb) node_type = mnl_attr_get_u8(tb[RDMA_NLDEV_ATTR_DEV_NODE_TYPE]); node_str = node_type_to_str(node_type); - print_string(PRINT_ANY, "node_type", "node_type %s ", - node_str); + print_string(PRINT_ANY, "node_type", "node_type %s ", node_str); } static void dev_print_dev_proto(struct rd *rd, struct nlattr **tb) diff --git a/rdma/link.c b/rdma/link.c index 913186cbfd73..48f7b0877468 100644 --- a/rdma/link.c +++ b/rdma/link.c @@ -120,8 +120,7 @@ static void link_print_subnet_prefix(struct rd *rd, struct nlattr **tb) subnet_prefix = mnl_attr_get_u64(tb[RDMA_NLDEV_ATTR_SUBNET_PREFIX]); memcpy(vp, &subnet_prefix, sizeof(uint64_t)); snprintf(str, 32, "%04x:%04x:%04x:%04x", vp[3], vp[2], vp[1], vp[0]); - print_string(PRINT_ANY, "subnet_prefix", - "subnet_prefix %s ", str); + print_string(PRINT_ANY, "subnet_prefix", "subnet_prefix %s ", str); } static void link_print_lid(struct rd *rd, struct nlattr **tb) @@ -176,8 +175,7 @@ static void link_print_state(struct rd *rd, struct nlattr **tb) return; state = mnl_attr_get_u8(tb[RDMA_NLDEV_ATTR_PORT_STATE]); - print_string(PRINT_ANY, "state", "state %s ", - link_state_to_str(state)); + print_string(PRINT_ANY, "state", "state %s ", link_state_to_str(state)); } static const char *phys_state_to_str(uint8_t phys_state) @@ -202,8 +200,8 @@ static void link_print_phys_state(struct rd *rd, struct nlattr **tb) return; phys_state = mnl_attr_get_u8(tb[RDMA_NLDEV_ATTR_PORT_PHYS_STATE]); - print_string(PRINT_ANY, "physical_state", - "physical_state %s ", phys_state_to_str(phys_state)); + print_string(PRINT_ANY, "physical_state", "physical_state %s ", + phys_state_to_str(phys_state)); } static void link_print_netdev(struct rd *rd, struct nlattr **tb) @@ -216,10 +214,8 @@ static void link_print_netdev(struct rd *rd, struct nlattr **tb) netdev_name = mnl_attr_get_str(tb[RDMA_NLDEV_ATTR_NDEV_NAME]); idx = mnl_attr_get_u32(tb[RDMA_NLDEV_ATTR_NDEV_INDEX]); - print_string(PRINT_ANY, "netdev", "netdev %s ", - netdev_name); - print_uint(PRINT_ANY, "netdev_index", - rd->show_details ? "netdev_index %u " : "", idx); + print_string(PRINT_ANY, "netdev", "netdev %s ", netdev_name); + print_uint(PRINT_ANY, "netdev_index", rd->show_details ? "netdev_index %u " : "", idx); } static int link_parse_cb(const struct nlmsghdr *nlh, void *data) diff --git a/rdma/res-cq.c b/rdma/res-cq.c index 9656773ffe6e..b4dcc026ed4b 100644 --- a/rdma/res-cq.c +++ b/rdma/res-cq.c @@ -21,8 +21,7 @@ static void print_poll_ctx(struct rd *rd, uint8_t poll_ctx, struct nlattr *attr) { if (!attr) return; - print_string(PRINT_ANY, "poll-ctx", "poll-ctx %s ", - poll_ctx_to_str(poll_ctx)); + print_string(PRINT_ANY, "poll-ctx", "poll-ctx %s ", poll_ctx_to_str(poll_ctx)); } static void print_cq_dim_setting(struct rd *rd, struct nlattr *attr) diff --git a/rdma/res-qp.c b/rdma/res-qp.c index ef062c764c06..2390c0b5732b 100644 --- a/rdma/res-qp.c +++ b/rdma/res-qp.c @@ -37,14 +37,12 @@ static void print_rqpn(struct rd *rd, uint32_t val, struct nlattr **nla_line) static void print_type(struct rd *rd, uint32_t val) { - print_string(PRINT_ANY, "type", "type %s ", - qp_types_to_str(val)); + print_string(PRINT_ANY, "type", "type %s ", qp_types_to_str(val)); } static void print_state(struct rd *rd, uint32_t val) { - print_string(PRINT_ANY, "state", "state %s ", - qp_states_to_str(val)); + print_string(PRINT_ANY, "state", "state %s ", qp_states_to_str(val)); } static void print_rqpsn(struct rd *rd, uint32_t val, struct nlattr **nla_line) @@ -60,8 +58,7 @@ static void print_pathmig(struct rd *rd, uint32_t val, struct nlattr **nla_line) if (!nla_line[RDMA_NLDEV_ATTR_RES_PATH_MIG_STATE]) return; - print_string(PRINT_ANY, "path-mig-state", - "path-mig-state %s ", path_mig_to_str(val)); + print_string(PRINT_ANY, "path-mig-state", "path-mig-state %s ", path_mig_to_str(val)); } static int res_qp_line_raw(struct rd *rd, const char *name, int idx, diff --git a/rdma/res-srq.c b/rdma/res-srq.c index 714abb96711a..e702fecd1f34 100644 --- a/rdma/res-srq.c +++ b/rdma/res-srq.c @@ -22,8 +22,7 @@ static const char *srq_types_to_str(uint8_t idx) static void print_type(struct rd *rd, uint32_t val) { - print_string(PRINT_ANY, "type", "type %s ", - srq_types_to_str(val)); + print_string(PRINT_ANY, "type", "type %s ", srq_types_to_str(val)); } static void print_qps(char *qp_str) diff --git a/rdma/res.c b/rdma/res.c index b0efcd95f4fe..715cf93c4fab 100644 --- a/rdma/res.c +++ b/rdma/res.c @@ -51,9 +51,8 @@ static int res_print_summary(struct rd *rd, struct nlattr **tb) name = mnl_attr_get_str(nla_line[RDMA_NLDEV_ATTR_RES_SUMMARY_ENTRY_NAME]); curr = mnl_attr_get_u64(nla_line[RDMA_NLDEV_ATTR_RES_SUMMARY_ENTRY_CURR]); - res_print_u64( - rd, name, curr, - nla_line[RDMA_NLDEV_ATTR_RES_SUMMARY_ENTRY_CURR]); + res_print_u64(rd, name, curr, + nla_line[RDMA_NLDEV_ATTR_RES_SUMMARY_ENTRY_CURR]); } return 0; } @@ -189,14 +188,12 @@ void print_link(struct rd *rd, uint32_t idx, const char *name, uint32_t port, } if (!rd->json_output) - print_string(PRINT_ANY, NULL, "link %s ", - tmp); + print_string(PRINT_ANY, NULL, "link %s ", tmp); } void print_qp_type(struct rd *rd, uint32_t val) { - print_string(PRINT_ANY, "qp-type", "qp-type %s ", - qp_types_to_str(val)); + print_string(PRINT_ANY, "qp-type", "qp-type %s ", qp_types_to_str(val)); } void print_key(struct rd *rd, const char *name, uint64_t val, diff --git a/rdma/stat.c b/rdma/stat.c index 53d829e9ccf8..28b1ad857219 100644 --- a/rdma/stat.c +++ b/rdma/stat.c @@ -304,8 +304,7 @@ static int res_counter_line(struct rd *rd, const char *name, int index, qpn = mnl_attr_get_u32(qp_line[RDMA_NLDEV_ATTR_RES_LQPN]); if (!isfirst) - print_string(PRINT_FP, NULL, ",", - NULL); + print_string(PRINT_FP, NULL, ",", NULL); print_uint(PRINT_ANY, NULL, "%d", qpn); isfirst = false; } @@ -790,28 +789,23 @@ static int do_stat_mode_parse_cb(const struct nlmsghdr *nlh, void *data, if (supported || enabled) { if (isfirst) { open_json_object(NULL); - print_string(PRINT_ANY, - "ifname", "link %s/", dev); - print_uint(PRINT_ANY, "port", - "%u ", port); + print_string(PRINT_ANY, "ifname", "link %s/", dev); + print_uint(PRINT_ANY, "port", "%u ", port); if (supported) open_json_array(PRINT_ANY, - "supported optional-counters"); + "supported optional-counters"); else open_json_array(PRINT_ANY, "optional-counters"); - print_string(PRINT_FP, NULL, - " ", NULL); + print_string(PRINT_FP, NULL, " ", NULL); isfirst = false; } else { - print_string(PRINT_FP, NULL, - ",", NULL); + print_string(PRINT_FP, NULL, ",", NULL); } if (rd->pretty_output && !rd->json_output) newline_indent(rd); - print_string(PRINT_ANY, NULL, "%s", - name); + print_string(PRINT_ANY, NULL, "%s", name); } } diff --git a/rdma/sys.c b/rdma/sys.c index d7403a24027d..7bb0edbfec2b 100644 --- a/rdma/sys.c +++ b/rdma/sys.c @@ -36,8 +36,7 @@ static int sys_show_parse_cb(const struct nlmsghdr *nlh, void *data) else mode_str = "unknown"; - print_string(PRINT_ANY, "netns", "netns %s ", - mode_str); + print_string(PRINT_ANY, "netns", "netns %s ", mode_str); } if (tb[RDMA_NLDEV_SYS_ATTR_PRIVILEGED_QKEY_MODE]) { @@ -45,17 +44,14 @@ static int sys_show_parse_cb(const struct nlmsghdr *nlh, void *data) mode = mnl_attr_get_u8(tb[RDMA_NLDEV_SYS_ATTR_PRIVILEGED_QKEY_MODE]); - print_on_off(PRINT_ANY, "privileged-qkey", - "privileged-qkey %s ", mode); + print_on_off(PRINT_ANY, "privileged-qkey", "privileged-qkey %s ", mode); } if (tb[RDMA_NLDEV_SYS_ATTR_COPY_ON_FORK]) cof = mnl_attr_get_u8(tb[RDMA_NLDEV_SYS_ATTR_COPY_ON_FORK]); - print_on_off(PRINT_ANY, "copy-on-fork", - "copy-on-fork %s\n", - cof); + print_on_off(PRINT_ANY, "copy-on-fork", "copy-on-fork %s\n", cof); return MNL_CB_OK; } diff --git a/rdma/utils.c b/rdma/utils.c index d647813c37fa..f73a9f19b617 100644 --- a/rdma/utils.c +++ b/rdma/utils.c @@ -872,24 +872,19 @@ static int print_driver_entry(struct rd *rd, struct nlattr *key_attr, switch (attr_type) { case RDMA_NLDEV_ATTR_DRIVER_STRING: - ret = print_driver_string(rd, key_str, - mnl_attr_get_str(val_attr)); + ret = print_driver_string(rd, key_str, mnl_attr_get_str(val_attr)); break; case RDMA_NLDEV_ATTR_DRIVER_S32: - ret = print_driver_s32(rd, key_str, mnl_attr_get_u32(val_attr), - print_type); + ret = print_driver_s32(rd, key_str, mnl_attr_get_u32(val_attr), print_type); break; case RDMA_NLDEV_ATTR_DRIVER_U32: - ret = print_driver_u32(rd, key_str, mnl_attr_get_u32(val_attr), - print_type); + ret = print_driver_u32(rd, key_str, mnl_attr_get_u32(val_attr), print_type); break; case RDMA_NLDEV_ATTR_DRIVER_S64: - ret = print_driver_s64(rd, key_str, mnl_attr_get_u64(val_attr), - print_type); + ret = print_driver_s64(rd, key_str, mnl_attr_get_u64(val_attr), print_type); break; case RDMA_NLDEV_ATTR_DRIVER_U64: - ret = print_driver_u64(rd, key_str, mnl_attr_get_u64(val_attr), - print_type); + ret = print_driver_u64(rd, key_str, mnl_attr_get_u64(val_attr), print_type); break; } free(key_str); From patchwork Wed Jan 3 00:34:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 13509587 X-Patchwork-Delegate: dsahern@gmail.com Received: from mail-oi1-f181.google.com (mail-oi1-f181.google.com [209.85.167.181]) (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 659AF655 for ; Wed, 3 Jan 2024 00:36:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=networkplumber.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=networkplumber.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=networkplumber-org.20230601.gappssmtp.com header.i=@networkplumber-org.20230601.gappssmtp.com header.b="ezpBRlDm" Received: by mail-oi1-f181.google.com with SMTP id 5614622812f47-3bbebe6191bso2891810b6e.3 for ; Tue, 02 Jan 2024 16:36:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1704242170; x=1704846970; 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=joh+KKCav0TyiAWmMDEkWm48inIYUD1e06QlNTY3D3Y=; b=ezpBRlDm8aNCLaslaMfATM4cMraeAEhFzogx23w8UTF7FdRhW7ACvCBuc0mfv8hOFW sp5I9EVWmgClaNfXllEN9ZoiVwcSgbunJxMYJHCMly5xEVpGJzDkK49forUQfBaERQGh HDhMz+UdmeGTPAlTZa1UxoWPPYxEeRkDEsNN1PGCjPjy8/TKp0ekz/TC9VSsOqAqZz5r EmQngW4ljWvP6N6IhMh2tzcLRw32a9NMbsNI/zuHlQ1SeHZYAE/fDOy8li2noCG8fHe4 UiVNEdGH9I1IofEOLRkfngWCKieKcyr2U2NpsMfhdSeeeKZG9XckfALl/yDdlPeMptPC 5/Sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704242170; x=1704846970; 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=joh+KKCav0TyiAWmMDEkWm48inIYUD1e06QlNTY3D3Y=; b=WWsEn+9Try+h+gY9BL8wqM10dHZtYwY8+KtwMtyhQEJqWpmzIWbua9B3Nfne6c9aVh U4sCCWoAlybGuNYwEOlf7t3id2ouaa+GetY0c41hiQPzlGcvYodf9ZnH7FKcACR2AZ4a R/YlpahpPHbgDtN101KOS8yw7fCZvncTyzVQx5yU2S9qk8W5kBnSMZVbS8gRCTcNRwT7 UVzGRmprVjvYmsvC59S2bDguTFoNIxCw71vJJUT9MvLGeOa+ThYMSz3v+iqhqkTjzvZf M5BkX/ioK9fVRB20inTNpMBJ+9zZaBrum3P5Z0jnBUUSW15HF+Tim1OytOEI1IZXoi9/ uhKg== X-Gm-Message-State: AOJu0YwnHhFvru3nqpMB/z2GR9ly6GUftyL+jzTIWOxSIUc44WyYFOuw WSXu2OA+ZH7+u4hvLB+VQ+Jnxf76scWRXQ== X-Google-Smtp-Source: AGHT+IGH9Mk8vHs6LOaqNgxPvjewYYEir9LD+VyTQVXK65zCsh8MiJqHt3eNZmK1qrY+EwkEb/8Xnw== X-Received: by 2002:a05:6808:23ce:b0:3bc:2217:61ac with SMTP id bq14-20020a05680823ce00b003bc221761acmr935052oib.15.1704242170450; Tue, 02 Jan 2024 16:36:10 -0800 (PST) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id y12-20020aa7854c000000b006d9af59eecesm16698260pfn.20.2024.01.02.16.36.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 16:36:09 -0800 (PST) From: Stephen Hemminger To: leon@kernel.org Cc: netdev@vger.kernel.org, Stephen Hemminger Subject: [RFC iproute2 2/8] rdma: use standard flag for json Date: Tue, 2 Jan 2024 16:34:27 -0800 Message-ID: <20240103003558.20615-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240103003558.20615-1-stephen@networkplumber.org> References: <20240103003558.20615-1-stephen@networkplumber.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: dsahern@gmail.com X-Patchwork-State: RFC The other iproute2 utils use variable json as flag. Signed-off-by: Stephen Hemminger --- rdma/rdma.c | 7 ++++--- rdma/rdma.h | 1 - rdma/res.c | 5 ++--- rdma/stat.c | 4 ++-- rdma/utils.c | 12 ++++++------ 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/rdma/rdma.c b/rdma/rdma.c index 8dc2d3e344be..60ba8c0e5594 100644 --- a/rdma/rdma.c +++ b/rdma/rdma.c @@ -8,6 +8,9 @@ #include "version.h" #include "color.h" +/* Global utils flags */ +int json; + static void help(char *name) { pr_out("Usage: %s [ OPTIONS ] OBJECT { COMMAND | help }\n" @@ -96,7 +99,6 @@ int main(int argc, char **argv) bool show_driver_details = false; const char *batch_file = NULL; bool show_details = false; - bool json_output = false; bool show_raw = false; bool force = false; struct rd rd = {}; @@ -125,7 +127,7 @@ int main(int argc, char **argv) show_raw = true; break; case 'j': - json_output = 1; + ++json; break; case 'f': force = true; @@ -151,7 +153,6 @@ int main(int argc, char **argv) rd.show_details = show_details; rd.show_driver_details = show_driver_details; - rd.json_output = json_output; rd.pretty_output = pretty; rd.show_raw = show_raw; diff --git a/rdma/rdma.h b/rdma/rdma.h index 0bf77f4dcf9e..f6830c851fb1 100644 --- a/rdma/rdma.h +++ b/rdma/rdma.h @@ -68,7 +68,6 @@ struct rd { struct nlmsghdr *nlh; char *buff; json_writer_t *jw; - int json_output; int pretty_output; bool suppress_errors; struct list_head filter_list; diff --git a/rdma/res.c b/rdma/res.c index 715cf93c4fab..f64224e1f3eb 100644 --- a/rdma/res.c +++ b/rdma/res.c @@ -160,7 +160,7 @@ void print_comm(struct rd *rd, const char *str, struct nlattr **nla_line) if (!str) return; - if (nla_line[RDMA_NLDEV_ATTR_RES_PID] || rd->json_output) + if (nla_line[RDMA_NLDEV_ATTR_RES_PID] || is_json_context()) snprintf(tmp, sizeof(tmp), "%s", str); else snprintf(tmp, sizeof(tmp), "[%s]", str); @@ -187,8 +187,7 @@ void print_link(struct rd *rd, uint32_t idx, const char *name, uint32_t port, snprintf(tmp, sizeof(tmp), "%s/-", name); } - if (!rd->json_output) - print_string(PRINT_ANY, NULL, "link %s ", tmp); + print_string(PRINT_FP, NULL, "link %s ", tmp); } void print_qp_type(struct rd *rd, uint32_t val) diff --git a/rdma/stat.c b/rdma/stat.c index 28b1ad857219..6a3f8ca44892 100644 --- a/rdma/stat.c +++ b/rdma/stat.c @@ -208,7 +208,7 @@ int res_get_hwcounters(struct rd *rd, struct nlattr *hwc_table, bool print) nm = mnl_attr_get_str(hw_line[RDMA_NLDEV_ATTR_STAT_HWCOUNTER_ENTRY_NAME]); v = mnl_attr_get_u64(hw_line[RDMA_NLDEV_ATTR_STAT_HWCOUNTER_ENTRY_VALUE]); - if (rd->pretty_output && !rd->json_output) + if (rd->pretty_output) newline_indent(rd); res_print_u64(rd, nm, v, hw_line[RDMA_NLDEV_ATTR_STAT_HWCOUNTER_ENTRY_NAME]); } @@ -802,7 +802,7 @@ static int do_stat_mode_parse_cb(const struct nlmsghdr *nlh, void *data, } else { print_string(PRINT_FP, NULL, ",", NULL); } - if (rd->pretty_output && !rd->json_output) + if (rd->pretty_output) newline_indent(rd); print_string(PRINT_ANY, NULL, "%s", name); diff --git a/rdma/utils.c b/rdma/utils.c index f73a9f19b617..32e12a64193a 100644 --- a/rdma/utils.c +++ b/rdma/utils.c @@ -572,7 +572,7 @@ int rd_exec_link(struct rd *rd, int (*cb)(struct rd *rd), bool strict_port) uint32_t port; int ret = 0; - new_json_obj(rd->json_output); + new_json_obj(json); if (rd_no_arg(rd)) { list_for_each_entry(dev_map, &rd->dev_map_list, list) { rd->dev_idx = dev_map->idx; @@ -621,7 +621,7 @@ int rd_exec_dev(struct rd *rd, int (*cb)(struct rd *rd)) struct dev_map *dev_map; int ret = 0; - new_json_obj(rd->json_output); + new_json_obj(json); if (rd_no_arg(rd)) { list_for_each_entry(dev_map, &rd->dev_map_list, list) { rd->dev_idx = dev_map->idx; @@ -794,7 +794,7 @@ static int print_driver_string(struct rd *rd, const char *key_str, static int print_driver_s32(struct rd *rd, const char *key_str, int32_t val, enum rdma_nldev_print_type print_type) { - if (!rd->json_output) { + if (!is_json_context()) { switch (print_type) { case RDMA_NLDEV_PRINT_TYPE_UNSPEC: return pr_out("%s %d ", key_str, val); @@ -811,7 +811,7 @@ static int print_driver_s32(struct rd *rd, const char *key_str, int32_t val, static int print_driver_u32(struct rd *rd, const char *key_str, uint32_t val, enum rdma_nldev_print_type print_type) { - if (!rd->json_output) { + if (!is_json_context()) { switch (print_type) { case RDMA_NLDEV_PRINT_TYPE_UNSPEC: return pr_out("%s %u ", key_str, val); @@ -828,7 +828,7 @@ static int print_driver_u32(struct rd *rd, const char *key_str, uint32_t val, static int print_driver_s64(struct rd *rd, const char *key_str, int64_t val, enum rdma_nldev_print_type print_type) { - if (!rd->json_output) { + if (!is_json_context()) { switch (print_type) { case RDMA_NLDEV_PRINT_TYPE_UNSPEC: return pr_out("%s %" PRId64 " ", key_str, val); @@ -845,7 +845,7 @@ static int print_driver_s64(struct rd *rd, const char *key_str, int64_t val, static int print_driver_u64(struct rd *rd, const char *key_str, uint64_t val, enum rdma_nldev_print_type print_type) { - if (!rd->json_output) { + if (!is_json_context()) { switch (print_type) { case RDMA_NLDEV_PRINT_TYPE_UNSPEC: return pr_out("%s %" PRIu64 " ", key_str, val); From patchwork Wed Jan 3 00:34:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 13509585 X-Patchwork-Delegate: dsahern@gmail.com Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.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 CBD512580 for ; Wed, 3 Jan 2024 00:36:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=networkplumber.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=networkplumber.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=networkplumber-org.20230601.gappssmtp.com header.i=@networkplumber-org.20230601.gappssmtp.com header.b="IlmK1pPd" Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-6d9a795cffbso4696228b3a.0 for ; Tue, 02 Jan 2024 16:36:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1704242171; x=1704846971; 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=yHkrjOkOte7bqKcE1yFAWukI27bsGeUXJY3eIZvDCE4=; b=IlmK1pPdeRD3IoHt+wfkQOXPb3cFO7azQ9eGcbz4SWEgmVItdIi80KYn0XH5YMhVFR CtQ3RLNUviMPAHfnggsTNQ0nL7BRS9nplYQAhoHq/g7sq9YK4t5t3hhxVKKoZD83Lko1 YZcs5JnJKmlTfEZLKEWUs5WnH7VmQHB7s8tTCP61lTkEWgJIb9Swd9GnkB6m4YsSE/HL L4kmr/jEMLDqjycrEO52v/LE4fXjNtYqS1U0oTgULnK1dRzTSP0lKtcmP4tAJqK0p7Yk H9Rov0Jh/rNCev1A/5aN3qhnqWTKTbvlxzbTphy3rJk1+zroJWvvdRyzqHgojoC8s64c 8/6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704242171; x=1704846971; 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=yHkrjOkOte7bqKcE1yFAWukI27bsGeUXJY3eIZvDCE4=; b=wijaCfiYusTBDVwRj1KqxBXnzVkC/buQIDqbvmMvkYA37xRM3HuHy7xXmpB/KMUb18 4M3lGhxzT0RIGL5zrg6nqUotTWMgNSCj38ZXerDnmrey0Bv7KMgRvW7si73Tfvzmc8Ym 1QJM6E8n0e/9rKbVOZ4PqGMAzVWx98O+REgREn1M2LraH3eCiyoKOv8gko96W4GbxirZ Cp7TZEUOCM3AMFyrrfaQ9BF0hvK/0t+P75nGPpIvXfzfJG7tfvdkH2R6vWD8jJ8LjB28 9OndkPlxa0umF4vA87y4irNx76XzQEDDULgNmSqLOYkVfTwT9Vdsqa04XfC8G338e7YV owSg== X-Gm-Message-State: AOJu0Yz7g/csEofct+FhcIKxp+9Ejk6UaVLtOd+4b+TdagWDPtFS4grW pb/HBFEpkCipY4pBsceZeYrr/5Kh2VsPZQ== X-Google-Smtp-Source: AGHT+IFzISESChFBSf3uNjITx7VGfMPOQ9b/b8lBWRO7prmqXYDqcoZ2Q9sDDjjzIOREo1Ehadn5WA== X-Received: by 2002:a05:6a00:acd:b0:6d9:93d7:478 with SMTP id c13-20020a056a000acd00b006d993d70478mr255927pfl.34.1704242171103; Tue, 02 Jan 2024 16:36:11 -0800 (PST) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id y12-20020aa7854c000000b006d9af59eecesm16698260pfn.20.2024.01.02.16.36.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 16:36:10 -0800 (PST) From: Stephen Hemminger To: leon@kernel.org Cc: netdev@vger.kernel.org, Stephen Hemminger Subject: [RFC iproute2 3/8] rdma: make pretty behave like other commands Date: Tue, 2 Jan 2024 16:34:28 -0800 Message-ID: <20240103003558.20615-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240103003558.20615-1-stephen@networkplumber.org> References: <20240103003558.20615-1-stephen@networkplumber.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: dsahern@gmail.com X-Patchwork-State: RFC For tc, ip, etc the -pretty flag only has meaning if json is used. Signed-off-by: Stephen Hemminger --- rdma/rdma.c | 3 +-- rdma/rdma.h | 1 - rdma/stat.c | 6 ++---- rdma/utils.c | 6 ++---- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/rdma/rdma.c b/rdma/rdma.c index 60ba8c0e5594..bee1985f96d8 100644 --- a/rdma/rdma.c +++ b/rdma/rdma.c @@ -115,7 +115,7 @@ int main(int argc, char **argv) filename, version); return EXIT_SUCCESS; case 'p': - pretty = 1; + ++pretty; break; case 'd': if (show_details) @@ -153,7 +153,6 @@ int main(int argc, char **argv) rd.show_details = show_details; rd.show_driver_details = show_driver_details; - rd.pretty_output = pretty; rd.show_raw = show_raw; err = rd_init(&rd, filename); diff --git a/rdma/rdma.h b/rdma/rdma.h index f6830c851fb1..f9308dbcfafd 100644 --- a/rdma/rdma.h +++ b/rdma/rdma.h @@ -68,7 +68,6 @@ struct rd { struct nlmsghdr *nlh; char *buff; json_writer_t *jw; - int pretty_output; bool suppress_errors; struct list_head filter_list; char *link_name; diff --git a/rdma/stat.c b/rdma/stat.c index 6a3f8ca44892..b428a62ac707 100644 --- a/rdma/stat.c +++ b/rdma/stat.c @@ -208,8 +208,7 @@ int res_get_hwcounters(struct rd *rd, struct nlattr *hwc_table, bool print) nm = mnl_attr_get_str(hw_line[RDMA_NLDEV_ATTR_STAT_HWCOUNTER_ENTRY_NAME]); v = mnl_attr_get_u64(hw_line[RDMA_NLDEV_ATTR_STAT_HWCOUNTER_ENTRY_VALUE]); - if (rd->pretty_output) - newline_indent(rd); + newline_indent(rd); res_print_u64(rd, nm, v, hw_line[RDMA_NLDEV_ATTR_STAT_HWCOUNTER_ENTRY_NAME]); } @@ -802,8 +801,7 @@ static int do_stat_mode_parse_cb(const struct nlmsghdr *nlh, void *data, } else { print_string(PRINT_FP, NULL, ",", NULL); } - if (rd->pretty_output) - newline_indent(rd); + newline_indent(rd); print_string(PRINT_ANY, NULL, "%s", name); } diff --git a/rdma/utils.c b/rdma/utils.c index 32e12a64193a..f332b2602e6f 100644 --- a/rdma/utils.c +++ b/rdma/utils.c @@ -920,8 +920,7 @@ void print_driver_table(struct rd *rd, struct nlattr *tb) if (!rd->show_driver_details || !tb) return; - if (rd->pretty_output) - newline_indent(rd); + newline_indent(rd); /* * Driver attrs are tuples of {key, [print-type], value}. @@ -933,8 +932,7 @@ void print_driver_table(struct rd *rd, struct nlattr *tb) mnl_attr_for_each_nested(tb_entry, tb) { if (cc > MAX_LINE_LENGTH) { - if (rd->pretty_output) - newline_indent(rd); + newline_indent(rd); cc = 0; } if (rd_attr_check(tb_entry, &type) != MNL_CB_OK) From patchwork Wed Jan 3 00:34:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 13509586 X-Patchwork-Delegate: dsahern@gmail.com Received: from mail-pg1-f182.google.com (mail-pg1-f182.google.com [209.85.215.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6952B657 for ; Wed, 3 Jan 2024 00:36:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=networkplumber.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=networkplumber.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=networkplumber-org.20230601.gappssmtp.com header.i=@networkplumber-org.20230601.gappssmtp.com header.b="blq72EDG" Received: by mail-pg1-f182.google.com with SMTP id 41be03b00d2f7-5cdfed46372so6036786a12.3 for ; Tue, 02 Jan 2024 16:36:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1704242172; x=1704846972; 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=y/BS9I1G25iZlaKnjcUNfLqctGtiSHWfr43vpJ46xOc=; b=blq72EDGdbQOXNL+P8KhmAMQE6sASM2fKDCj9QgQyC9nZ7VZbvFWwlz1Pde7ETbp/u Zvgbg5Xlsps0qvL9/F2cW0XXBNaLI+ZHZdhP2G4ee4wZi3dogInsHprjFVcpSvcmwfCG 1qK1bxPAQmgxBhm6fKwQsuuW5jJgWebE7XvjrFtDkkei9fmwpdeB9iyBjfb08x/olFrh bNSMPP8dhWkz75FgnNgt66lNvFjyXZvAxbGjjrcINLrqKje000ufA5aY/lufbRg0Z3GH AJqKqbnPNS1oCF52JxFAUrWzALnetbBJmhajrnHu1qqdYEMiGnJ0WyOOOlrDJZmkK9Io 3vag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704242172; x=1704846972; 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=y/BS9I1G25iZlaKnjcUNfLqctGtiSHWfr43vpJ46xOc=; b=ezWFB1rxNl75P57lDXNmWPTjUKIC4bsri3Pk37JMF0h7mRWjYTW3ydyssdFX3myWrR f4Q9BDCyBUn6qxEacBs+77z4AfUhISVD+3gcnMt8L/pwmFXQgmfo/ttOGsFzE6GLqOLO zOxObEWBoxqOBwpV7gjUVhsxCjaD7HVrFQBDLL4LriwN6qFylChmymOLp5GZPQEL9Rve 4xNE/bxklSWMzW7x99Uocs8N5RZQioKkheDJ9xz5ruXVEV/4JGC9kStZmhR/Gqq0H/yI f1NEsS0rExR+Cg8dyGPJzk6nlTRqNRsIbW6AU+lCPuCdYUw/EfvQTSGY08rpeqz90EH3 xWUA== X-Gm-Message-State: AOJu0YwSpQHjrq4wryl/CZjCryatEN3OFw261YCEhMOK997Ydkktsvy2 YsoIq3YkUuomHNqKL1kV74vflBzTfMiYMQ== X-Google-Smtp-Source: AGHT+IFjqIiEeh9Kogv9fa3yCDvszG3hFCuGHmO12V01W1c3FGULl0DD8mQcWAoSHRR+mpLNMG2mrA== X-Received: by 2002:a05:6a20:8e04:b0:196:34fb:89db with SMTP id y4-20020a056a208e0400b0019634fb89dbmr12905934pzj.52.1704242171804; Tue, 02 Jan 2024 16:36:11 -0800 (PST) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id y12-20020aa7854c000000b006d9af59eecesm16698260pfn.20.2024.01.02.16.36.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 16:36:11 -0800 (PST) From: Stephen Hemminger To: leon@kernel.org Cc: netdev@vger.kernel.org, Stephen Hemminger Subject: [RFC iproute2 4/8] rdma: make supress_errors a bit Date: Tue, 2 Jan 2024 16:34:29 -0800 Message-ID: <20240103003558.20615-5-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240103003558.20615-1-stephen@networkplumber.org> References: <20240103003558.20615-1-stephen@networkplumber.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: dsahern@gmail.com X-Patchwork-State: RFC Like other command line flags supress_errors can be a bit. Signed-off-by: Stephen Hemminger --- rdma/rdma.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rdma/rdma.h b/rdma/rdma.h index f9308dbcfafd..65e3557d4036 100644 --- a/rdma/rdma.h +++ b/rdma/rdma.h @@ -61,6 +61,7 @@ struct rd { uint8_t show_details:1; uint8_t show_driver_details:1; uint8_t show_raw:1; + uint8_t suppress_errors:1; struct list_head dev_map_list; uint32_t dev_idx; uint32_t port_idx; @@ -68,7 +69,6 @@ struct rd { struct nlmsghdr *nlh; char *buff; json_writer_t *jw; - bool suppress_errors; struct list_head filter_list; char *link_name; char *link_type; From patchwork Wed Jan 3 00:34:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 13509588 X-Patchwork-Delegate: dsahern@gmail.com Received: from mail-oi1-f180.google.com (mail-oi1-f180.google.com [209.85.167.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 37C7BA54 for ; Wed, 3 Jan 2024 00:36:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=networkplumber.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=networkplumber.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=networkplumber-org.20230601.gappssmtp.com header.i=@networkplumber-org.20230601.gappssmtp.com header.b="xgai9Lcm" Received: by mail-oi1-f180.google.com with SMTP id 5614622812f47-3bbce1202ebso4236197b6e.2 for ; Tue, 02 Jan 2024 16:36:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1704242172; x=1704846972; 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=AYyU+71JNEa9ChMbxk4Ddokt/Dh5PGrhJl1Fn3uUx/8=; b=xgai9LcmcvggVdEApFqpTbru1d3nwL8sQjwkgPbYkg8E+pjH8yFYXQmAmzAiYekh3h eNDvvmhuuUXQNnHQanoriZXqvCbE7DrDFpSqlGaodTvMyoBUMyaMI1V44N9U1hkBO0s/ tnt+3StxQyRohn9MBTRwUYLl9kPgyurvaRa5vOuCYcW9ssve3DdSsS8HR4ShFzjGgnLH kxxZIix38PhWpT/IljPjPB7HI+7iMCirva8js/AyFakK0aNPcSPZE5wnjzAg4BGJYWMt w5yxT0Nb1M0nCj+aG4+PvWENFTxM6bjbs8M34RPdOo2fyHWLUiSoNjTBj5xzVXGCM68/ MDGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704242172; x=1704846972; 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=AYyU+71JNEa9ChMbxk4Ddokt/Dh5PGrhJl1Fn3uUx/8=; b=NjVOM5Av+g8/9FDqVWBVS7M8dCiUKWO8SiSksRM+j6TN8Ky1CDlurFGRCQgsl1cWI/ McT3/X/EnMqM6owTaM/7dSPGg7wMsbhym4hj9cw22oWzGiZZ24MWFSk0QxagO0+giz1U kJL27bIhVr5Zm3LDOBkuZtgXbSrwR0A7JlGSkNkbI6rBrB7unlcKZoWqwviBIqKnssqs ee+6snx3dQjm8fKzpo0Q4RXBeeO5kAInEEEwx6uMkDzRuajTWB2IQmO+rQHYlykRuVT4 bV5DfiXAEd619My7HBsjLeLynbUWikjgqXn8nQzc40PcI9X8g4X1TdiVQl6VoRwB4zJw 1eCw== X-Gm-Message-State: AOJu0YwUt/d7ueOD+N2gFZI0a+Zyk54QzMYNU0BIAvddabsp5nI53sAG G098WGjtFAwNQZwDDuspLPXkXAOjhAWpmpFxDYI5d+g1CBg= X-Google-Smtp-Source: AGHT+IFSVjI+bySJZQ38hfyaPdZR8nlRCcEZ9HtfDQD1CXYW16e5WIr+xMtif/lCI1S3q+EXlfrZ/w== X-Received: by 2002:a05:6808:2226:b0:3b9:df4a:978b with SMTP id bd38-20020a056808222600b003b9df4a978bmr23704960oib.82.1704242172466; Tue, 02 Jan 2024 16:36:12 -0800 (PST) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id y12-20020aa7854c000000b006d9af59eecesm16698260pfn.20.2024.01.02.16.36.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 16:36:12 -0800 (PST) From: Stephen Hemminger To: leon@kernel.org Cc: netdev@vger.kernel.org, Stephen Hemminger Subject: [RFC iproute2 5/8] rdma: add oneline flag Date: Tue, 2 Jan 2024 16:34:30 -0800 Message-ID: <20240103003558.20615-6-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240103003558.20615-1-stephen@networkplumber.org> References: <20240103003558.20615-1-stephen@networkplumber.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: dsahern@gmail.com X-Patchwork-State: RFC Add oneline output format like other commands. Signed-off-by: Stephen Hemminger --- man/man8/rdma.8 | 12 ++++++++++-- rdma/dev.c | 2 +- rdma/link.c | 2 +- rdma/rdma.c | 11 +++++++++-- rdma/stat.c | 2 +- rdma/sys.c | 3 ++- rdma/utils.c | 2 +- 7 files changed, 25 insertions(+), 9 deletions(-) diff --git a/man/man8/rdma.8 b/man/man8/rdma.8 index c9e5d50d5ad7..5088b9ec3cf2 100644 --- a/man/man8/rdma.8 +++ b/man/man8/rdma.8 @@ -25,8 +25,9 @@ rdma \- RDMA tool .ti -8 .IR OPTIONS " := { " \fB\-V\fR[\fIersion\fR] | -\fB\-d\fR[\fIetails\fR] } -\fB\-j\fR[\fIson\fR] } +\fB\-d\fR[\fIetails\fR] | +\fB\-j\fR[\fIson\fR] | +\fB\-o\fR[\fIneline\fR] | \fB\-p\fR[\fIretty\fR] } .SH OPTIONS @@ -63,6 +64,13 @@ When combined with -j generate a pretty JSON output. .BR "\-j" , " --json" Generate JSON output. +.TP +.BR "\-o" , " \-oneline" +output each record on a single line, replacing line feeds +with the +.B '\e' +character. + .SS .I OBJECT diff --git a/rdma/dev.c b/rdma/dev.c index 7496162df9e2..31868c6fe43e 100644 --- a/rdma/dev.c +++ b/rdma/dev.c @@ -94,7 +94,7 @@ static void dev_print_caps(struct rd *rd, struct nlattr **tb) caps = mnl_attr_get_u64(tb[RDMA_NLDEV_ATTR_CAP_FLAGS]); - print_string(PRINT_FP, NULL, "\n caps: <", NULL); + print_string(PRINT_FP, NULL, "%s caps: <", _SL_); open_json_array(PRINT_JSON, "caps"); for (idx = 0; caps; idx++) { if (caps & 0x1) diff --git a/rdma/link.c b/rdma/link.c index 48f7b0877468..d7d9558b49f2 100644 --- a/rdma/link.c +++ b/rdma/link.c @@ -96,7 +96,7 @@ static void link_print_caps(struct rd *rd, struct nlattr **tb) caps = mnl_attr_get_u64(tb[RDMA_NLDEV_ATTR_CAP_FLAGS]); - print_string(PRINT_FP, NULL, "\n caps: <", NULL); + print_string(PRINT_FP, NULL, "%s caps: <", _SL_); open_json_array(PRINT_JSON, "caps"); for (idx = 0; caps; idx++) { if (caps & 0x1) diff --git a/rdma/rdma.c b/rdma/rdma.c index bee1985f96d8..131c6b2abd34 100644 --- a/rdma/rdma.c +++ b/rdma/rdma.c @@ -16,7 +16,7 @@ static void help(char *name) pr_out("Usage: %s [ OPTIONS ] OBJECT { COMMAND | help }\n" " %s [ -f[orce] ] -b[atch] filename\n" "where OBJECT := { dev | link | resource | system | statistic | help }\n" - " OPTIONS := { -V[ersion] | -d[etails] | -j[son] | -p[retty] -r[aw]}\n", name, name); + " OPTIONS := { -V[ersion] | -d[etails] | -j[son] | -p[retty] | -r[aw]}\n", name, name); } static int cmd_help(struct rd *rd) @@ -89,6 +89,7 @@ int main(int argc, char **argv) { "version", no_argument, NULL, 'V' }, { "help", no_argument, NULL, 'h' }, { "json", no_argument, NULL, 'j' }, + { "oneline", no_argument, NULL, 'o' }, { "pretty", no_argument, NULL, 'p' }, { "details", no_argument, NULL, 'd' }, { "raw", no_argument, NULL, 'r' }, @@ -101,13 +102,14 @@ int main(int argc, char **argv) bool show_details = false; bool show_raw = false; bool force = false; + bool oneline = false; struct rd rd = {}; char *filename; int opt; int err; filename = basename(argv[0]); - while ((opt = getopt_long(argc, argv, ":Vhdrpjfb:", + while ((opt = getopt_long(argc, argv, ":Vhdropjfb:", long_options, NULL)) >= 0) { switch (opt) { case 'V': @@ -126,6 +128,9 @@ int main(int argc, char **argv) case 'r': show_raw = true; break; + case 'o': + oneline = true; + break; case 'j': ++json; break; @@ -151,6 +156,8 @@ int main(int argc, char **argv) argc -= optind; argv += optind; + _SL_ = oneline ? "\\" : "\n"; + rd.show_details = show_details; rd.show_driver_details = show_driver_details; rd.show_raw = show_raw; diff --git a/rdma/stat.c b/rdma/stat.c index b428a62ac707..e90b6197ceb7 100644 --- a/rdma/stat.c +++ b/rdma/stat.c @@ -291,7 +291,7 @@ static int res_counter_line(struct rd *rd, const char *name, int index, res_get_hwcounters(rd, hwc_table, true); isfirst = true; open_json_array(PRINT_JSON, "lqpn"); - print_string(PRINT_FP, NULL, "\n LQPN: <", NULL); + print_string(PRINT_FP, NULL, "%s LQPN: <", _SL_); mnl_attr_for_each_nested(nla_entry, qp_table) { struct nlattr *qp_line[RDMA_NLDEV_ATTR_MAX] = {}; err = mnl_attr_parse_nested(nla_entry, rd_attr_cb, qp_line); diff --git a/rdma/sys.c b/rdma/sys.c index 7bb0edbfec2b..7dbe44094820 100644 --- a/rdma/sys.c +++ b/rdma/sys.c @@ -51,7 +51,8 @@ static int sys_show_parse_cb(const struct nlmsghdr *nlh, void *data) if (tb[RDMA_NLDEV_SYS_ATTR_COPY_ON_FORK]) cof = mnl_attr_get_u8(tb[RDMA_NLDEV_SYS_ATTR_COPY_ON_FORK]); - print_on_off(PRINT_ANY, "copy-on-fork", "copy-on-fork %s\n", cof); + print_on_off(PRINT_ANY, "copy-on-fork", "copy-on-fork %s", cof); + print_nl(); return MNL_CB_OK; } diff --git a/rdma/utils.c b/rdma/utils.c index f332b2602e6f..aeb627be7715 100644 --- a/rdma/utils.c +++ b/rdma/utils.c @@ -774,7 +774,7 @@ struct dev_map *dev_map_lookup(struct rd *rd, bool allow_port_index) void newline(struct rd *rd) { close_json_object(); - print_string(PRINT_FP, NULL, "\n", NULL); + print_nl(); } void newline_indent(struct rd *rd) From patchwork Wed Jan 3 00:34:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 13509589 X-Patchwork-Delegate: dsahern@gmail.com Received: from mail-oi1-f181.google.com (mail-oi1-f181.google.com [209.85.167.181]) (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 E4FD410EE for ; Wed, 3 Jan 2024 00:36:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=networkplumber.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=networkplumber.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=networkplumber-org.20230601.gappssmtp.com header.i=@networkplumber-org.20230601.gappssmtp.com header.b="AV602S5W" Received: by mail-oi1-f181.google.com with SMTP id 5614622812f47-3bb9d54575cso6687396b6e.2 for ; Tue, 02 Jan 2024 16:36:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1704242173; x=1704846973; 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=Nraeyg+4k4cc+BR0LzOMPEDsmsLwNY2VG0Tez2jvnRM=; b=AV602S5WZcDhMgT7xFzgAPM13wCcTUOEq5LA8pgIF8YlZZxFKkVcWnFXdIbbWOpWQ6 p59NzEPLZYXsKdHNoBubAl34H7gueyMPItIWKr3I+F0zu3Dfu3PT8rr86YGvEFyziKGd ZiPDXhS464faDTKZgjz3widGScQa9SaZYpDe17LQGhWETkFeWvxZaWYp/auqQU4RCdO1 3ZMWJWvA0xT3ESGCQkFs7D+yKfcMsE5Cybs/D3ZY+iU0VpievUpQ6Uu9VfBAsszdZqr6 gYkDbUxsmBemy1ZO8qHathHOuD2L1OqN4Lv4tjBBwa+R+VpmXRg7UjP77akJcte1QxSY Fbtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704242173; x=1704846973; 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=Nraeyg+4k4cc+BR0LzOMPEDsmsLwNY2VG0Tez2jvnRM=; b=XLZRRCusFMi1gpv3AJei1ZY4TS7tckHSpYdmXL5mXVwser1//HDIby2k1cLoJTtxVH 6EJrHrjMsPHgXLhi9Rpgf69EaQW5cQ9Z1PYAAOseERnCS0dg11bjiz4iuZYLFIdEmUdn T2jBwD8OqZ4QGoPskqzAcgIAmHQky/WpHpxM1h/16aYvm95pILRqh5IrdohHuz1BCGpH ewITsNn3E5Gce9RPL7GBsE5KlFqFMDV0lpsWc1khxwPsRJbAGQq8cVr6KzPag/gfkG18 TEi2fDfFK8ZxJLwxPYKAPm1zfusJ+ErMhEmtq66bGORrzhCpl3g2qsQ7U/t72jKJH9wI yxww== X-Gm-Message-State: AOJu0YxgdDulE3sxUtPk09FTcZqXjdH2PiGQ/JrBRvY8L0s4Q+jYVb6h cbo/c/5ZsCrapM+epIo8PBptXXNUM/mTVH/ewERMuWzknLQ= X-Google-Smtp-Source: AGHT+IEFp+dA/pw3ENsiEbI8b761XuNWyOEcOChOFgyubYWMDdDipR03xLLfmXBvkQF54vc7EkisGg== X-Received: by 2002:a05:6808:3999:b0:3bb:bfcb:d14b with SMTP id gq25-20020a056808399900b003bbbfcbd14bmr16906284oib.94.1704242173116; Tue, 02 Jan 2024 16:36:13 -0800 (PST) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id y12-20020aa7854c000000b006d9af59eecesm16698260pfn.20.2024.01.02.16.36.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 16:36:12 -0800 (PST) From: Stephen Hemminger To: leon@kernel.org Cc: netdev@vger.kernel.org, Stephen Hemminger Subject: [RFC iproute2 6/8] rdma: do not mix newline and json object Date: Tue, 2 Jan 2024 16:34:31 -0800 Message-ID: <20240103003558.20615-7-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240103003558.20615-1-stephen@networkplumber.org> References: <20240103003558.20615-1-stephen@networkplumber.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: dsahern@gmail.com X-Patchwork-State: RFC Mixing the semantics of ending lines with the json object leads to several bugs where json object is closed twice, etc. Replace by breaking the meaning of newline() function into two parts. Signed-off-by: Stephen Hemminger --- rdma/dev.c | 3 ++- rdma/link.c | 4 +++- rdma/rdma.h | 5 +++-- rdma/res-cmid.c | 3 ++- rdma/res-cq.c | 7 +++++-- rdma/res-ctx.c | 3 ++- rdma/res-mr.c | 6 ++++-- rdma/res-pd.c | 4 ++-- rdma/res-qp.c | 6 ++++-- rdma/res-srq.c | 6 ++++-- rdma/res.c | 4 +++- rdma/stat-mr.c | 3 ++- rdma/stat.c | 17 ++++++++++------- rdma/utils.c | 16 +++++----------- 14 files changed, 51 insertions(+), 36 deletions(-) diff --git a/rdma/dev.c b/rdma/dev.c index 31868c6fe43e..c8cb6d675c3b 100644 --- a/rdma/dev.c +++ b/rdma/dev.c @@ -224,7 +224,8 @@ static int dev_parse_cb(const struct nlmsghdr *nlh, void *data) dev_print_caps(rd, tb); } - newline(rd); + close_json_object(); + print_nl(); return MNL_CB_OK; } diff --git a/rdma/link.c b/rdma/link.c index d7d9558b49f2..0c57a01480ba 100644 --- a/rdma/link.c +++ b/rdma/link.c @@ -252,7 +252,9 @@ static int link_parse_cb(const struct nlmsghdr *nlh, void *data) if (rd->show_details) link_print_caps(rd, tb); - newline(rd); + close_json_object(); + print_nl(); + return MNL_CB_OK; } diff --git a/rdma/rdma.h b/rdma/rdma.h index 65e3557d4036..e93e34cbce45 100644 --- a/rdma/rdma.h +++ b/rdma/rdma.h @@ -135,9 +135,10 @@ int rd_attr_cb(const struct nlattr *attr, void *data); */ void print_driver_table(struct rd *rd, struct nlattr *tb); void print_raw_data(struct rd *rd, struct nlattr **nla_line); -void newline(struct rd *rd); -void newline_indent(struct rd *rd); void print_raw_data(struct rd *rd, struct nlattr **nla_line); +void print_nl_indent(void); + #define MAX_LINE_LENGTH 80 + #endif /* _RDMA_TOOL_H_ */ diff --git a/rdma/res-cmid.c b/rdma/res-cmid.c index fb32c58a695a..9714404aaded 100644 --- a/rdma/res-cmid.c +++ b/rdma/res-cmid.c @@ -198,7 +198,8 @@ static int res_cm_id_line(struct rd *rd, const char *name, int idx, print_ipaddr(rd, "dst-addr", dst_addr_str, dst_port); print_driver_table(rd, nla_line[RDMA_NLDEV_ATTR_DRIVER]); - newline(rd); + close_json_object(); + print_nl(); out: return MNL_CB_OK; diff --git a/rdma/res-cq.c b/rdma/res-cq.c index b4dcc026ed4b..0d705a552781 100644 --- a/rdma/res-cq.c +++ b/rdma/res-cq.c @@ -47,7 +47,8 @@ static int res_cq_line_raw(struct rd *rd, const char *name, int idx, open_json_object(NULL); print_dev(rd, idx, name); print_raw_data(rd, nla_line); - newline(rd); + close_json_object(); + print_nl(); return MNL_CB_OK; } @@ -122,7 +123,9 @@ static int res_cq_line(struct rd *rd, const char *name, int idx, print_comm(rd, comm, nla_line); print_driver_table(rd, nla_line[RDMA_NLDEV_ATTR_DRIVER]); - newline(rd); + close_json_object(); + print_nl(); + out: return MNL_CB_OK; diff --git a/rdma/res-ctx.c b/rdma/res-ctx.c index 500186d9ff59..1a5d31e817ff 100644 --- a/rdma/res-ctx.c +++ b/rdma/res-ctx.c @@ -47,7 +47,8 @@ static int res_ctx_line(struct rd *rd, const char *name, int idx, print_comm(rd, comm, nla_line); print_driver_table(rd, nla_line[RDMA_NLDEV_ATTR_DRIVER]); - newline(rd); + close_json_object(); + print_nl(); out: return MNL_CB_OK; diff --git a/rdma/res-mr.c b/rdma/res-mr.c index fb48d5df6cad..8b647efbc6a9 100644 --- a/rdma/res-mr.c +++ b/rdma/res-mr.c @@ -16,7 +16,8 @@ static int res_mr_line_raw(struct rd *rd, const char *name, int idx, open_json_object(NULL); print_dev(rd, idx, name); print_raw_data(rd, nla_line); - newline(rd); + close_json_object(); + print_nl(); return MNL_CB_OK; } @@ -87,7 +88,8 @@ static int res_mr_line(struct rd *rd, const char *name, int idx, print_driver_table(rd, nla_line[RDMA_NLDEV_ATTR_DRIVER]); print_raw_data(rd, nla_line); - newline(rd); + close_json_object(); + print_nl(); out: return MNL_CB_OK; diff --git a/rdma/res-pd.c b/rdma/res-pd.c index 66f91f42860f..3ccfa364a236 100644 --- a/rdma/res-pd.c +++ b/rdma/res-pd.c @@ -76,8 +76,8 @@ static int res_pd_line(struct rd *rd, const char *name, int idx, print_comm(rd, comm, nla_line); print_driver_table(rd, nla_line[RDMA_NLDEV_ATTR_DRIVER]); - newline(rd); - + close_json_object(); + print_nl(); out: return MNL_CB_OK; } diff --git a/rdma/res-qp.c b/rdma/res-qp.c index 2390c0b5732b..d5d6a836e358 100644 --- a/rdma/res-qp.c +++ b/rdma/res-qp.c @@ -70,7 +70,8 @@ static int res_qp_line_raw(struct rd *rd, const char *name, int idx, open_json_object(NULL); print_link(rd, idx, name, rd->port_idx, nla_line); print_raw_data(rd, nla_line); - newline(rd); + close_json_object(); + print_nl(); return MNL_CB_OK; } @@ -176,7 +177,8 @@ static int res_qp_line(struct rd *rd, const char *name, int idx, print_comm(rd, comm, nla_line); print_driver_table(rd, nla_line[RDMA_NLDEV_ATTR_DRIVER]); - newline(rd); + close_json_object(); + print_nl(); out: return MNL_CB_OK; } diff --git a/rdma/res-srq.c b/rdma/res-srq.c index e702fecd1f34..b9d1fc45a1a4 100644 --- a/rdma/res-srq.c +++ b/rdma/res-srq.c @@ -170,7 +170,8 @@ static int res_srq_line_raw(struct rd *rd, const char *name, int idx, open_json_object(NULL); print_dev(rd, idx, name); print_raw_data(rd, nla_line); - newline(rd); + close_json_object(); + print_nl(); return MNL_CB_OK; } @@ -241,7 +242,8 @@ static int res_srq_line(struct rd *rd, const char *name, int idx, print_comm(rd, comm, nla_line); print_driver_table(rd, nla_line[RDMA_NLDEV_ATTR_DRIVER]); - newline(rd); + close_json_object(); + print_nl(); out: return MNL_CB_OK; diff --git a/rdma/res.c b/rdma/res.c index f64224e1f3eb..2c4507da8223 100644 --- a/rdma/res.c +++ b/rdma/res.c @@ -81,7 +81,9 @@ static int res_no_args_parse_cb(const struct nlmsghdr *nlh, void *data) print_uint(PRINT_ANY, "ifindex", "%u: ", idx); print_string(PRINT_ANY, "ifname", "%s: ", name); res_print_summary(rd, tb); - newline(rd); + close_json_object(); + print_nl(); + return MNL_CB_OK; } diff --git a/rdma/stat-mr.c b/rdma/stat-mr.c index 2ba6cb07693e..be41f0db3d93 100644 --- a/rdma/stat-mr.c +++ b/rdma/stat-mr.c @@ -31,7 +31,8 @@ static int stat_mr_line(struct rd *rd, const char *name, int idx, return ret; } - newline(rd); + close_json_object(); + print_nl(); out: return MNL_CB_OK; } diff --git a/rdma/stat.c b/rdma/stat.c index e90b6197ceb7..865f301370a0 100644 --- a/rdma/stat.c +++ b/rdma/stat.c @@ -136,7 +136,8 @@ static int qp_link_get_mode_parse_cb(const struct nlmsghdr *nlh, void *data) open_json_object(NULL); print_link(rd, idx, name, port, tb); print_string(PRINT_ANY, "mode", "mode %s ", output); - newline(rd); + close_json_object(); + print_nl(); return MNL_CB_OK; } @@ -208,7 +209,7 @@ int res_get_hwcounters(struct rd *rd, struct nlattr *hwc_table, bool print) nm = mnl_attr_get_str(hw_line[RDMA_NLDEV_ATTR_STAT_HWCOUNTER_ENTRY_NAME]); v = mnl_attr_get_u64(hw_line[RDMA_NLDEV_ATTR_STAT_HWCOUNTER_ENTRY_VALUE]); - newline_indent(rd); + print_nl_indent(); res_print_u64(rd, nm, v, hw_line[RDMA_NLDEV_ATTR_STAT_HWCOUNTER_ENTRY_NAME]); } @@ -308,7 +309,8 @@ static int res_counter_line(struct rd *rd, const char *name, int index, isfirst = false; } close_json_array(PRINT_ANY, ">"); - newline(rd); + close_json_object(); + print_nl(); return MNL_CB_OK; } @@ -757,7 +759,6 @@ static int do_stat_mode_parse_cb(const struct nlmsghdr *nlh, void *data, struct nlattr *tb[RDMA_NLDEV_ATTR_MAX] = {}; struct nlattr *nla_entry; const char *dev, *name; - struct rd *rd = data; int enabled, err = 0; bool isfirst = true; uint32_t port; @@ -801,7 +802,7 @@ static int do_stat_mode_parse_cb(const struct nlmsghdr *nlh, void *data, } else { print_string(PRINT_FP, NULL, ",", NULL); } - newline_indent(rd); + print_nl_indent(); print_string(PRINT_ANY, NULL, "%s", name); } @@ -809,7 +810,8 @@ static int do_stat_mode_parse_cb(const struct nlmsghdr *nlh, void *data, if (!isfirst) { close_json_array(PRINT_JSON, NULL); - newline(rd); + close_json_object(); + print_nl(); } return 0; @@ -1070,7 +1072,8 @@ static int stat_show_parse_cb(const struct nlmsghdr *nlh, void *data) print_uint(PRINT_ANY, "port", "%u ", port); ret = res_get_hwcounters(rd, tb[RDMA_NLDEV_ATTR_STAT_HWCOUNTERS], true); - newline(rd); + close_json_object(); + print_nl(); return ret; } diff --git a/rdma/utils.c b/rdma/utils.c index aeb627be7715..64f598c5aa8f 100644 --- a/rdma/utils.c +++ b/rdma/utils.c @@ -771,16 +771,10 @@ struct dev_map *dev_map_lookup(struct rd *rd, bool allow_port_index) #define nla_type(attr) ((attr)->nla_type & NLA_TYPE_MASK) -void newline(struct rd *rd) +void print_nl_indent(void) { - close_json_object(); - print_nl(); -} - -void newline_indent(struct rd *rd) -{ - newline(rd); - print_string(PRINT_FP, NULL, " ", NULL); + if (!is_json_context()) + printf("%s ", _SL_); } static int print_driver_string(struct rd *rd, const char *key_str, @@ -920,7 +914,7 @@ void print_driver_table(struct rd *rd, struct nlattr *tb) if (!rd->show_driver_details || !tb) return; - newline_indent(rd); + print_nl_indent(); /* * Driver attrs are tuples of {key, [print-type], value}. @@ -932,7 +926,7 @@ void print_driver_table(struct rd *rd, struct nlattr *tb) mnl_attr_for_each_nested(tb_entry, tb) { if (cc > MAX_LINE_LENGTH) { - newline_indent(rd); + print_nl_indent(); cc = 0; } if (rd_attr_check(tb_entry, &type) != MNL_CB_OK) From patchwork Wed Jan 3 00:34:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 13509590 X-Patchwork-Delegate: dsahern@gmail.com Received: from mail-ot1-f52.google.com (mail-ot1-f52.google.com [209.85.210.52]) (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 B8DA415AF for ; Wed, 3 Jan 2024 00:36:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=networkplumber.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=networkplumber.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=networkplumber-org.20230601.gappssmtp.com header.i=@networkplumber-org.20230601.gappssmtp.com header.b="RI3lboul" Received: by mail-ot1-f52.google.com with SMTP id 46e09a7af769-6dbca115636so6073259a34.2 for ; Tue, 02 Jan 2024 16:36:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1704242173; x=1704846973; 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=Zf22eup/92NwdG7c8/XQ2OZXhp+h3axYo/8yiikPijg=; b=RI3lboul7G3XIyLlyW7MjMUXQeliXBX/rQBBp8jRrzbUCu3rwCDP0gw7kCmyLCROfN VzlxLAhWhbudIFf//n+t0SQiEPfnMqX3nM8J+sZ5Bm2vzmvHiDlDo/GKItAcx7NMAlze XkZHh0ikXtL6jLTB0DFs0a4RFvChAqDVO0PEwElNoEtZcAHDjKN+YGlWNIWhXUb09C1P w5xGzqnPYmLHwfOvlQ6IEbi4Z1ZfTFqwOKvDeD5gIZRsTxaCY1aUrWiPx66g6Ca7nSYA fJLM+qQGhDYPcm8RBVObqOQWBmCQDT0b+NGHh/0ewgZsl1WTp2GAAccPIgeB05qyhXFn 6X9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704242173; x=1704846973; 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=Zf22eup/92NwdG7c8/XQ2OZXhp+h3axYo/8yiikPijg=; b=DM427zZHCVUdsRHPIpKwRmUMIQmO6Dud3meWlgC79ieVuh3904ji3kmMC0X23m//KU HC065ZSI5vVIUeLCbiEQaUTsJYjjDleeYS4fb87lX4tqCN+LM9C0UdoWqmh7zoD1Hwbc wD2b5CWzxZV5RlhByIWqxKV9MilV3KyIvr4/wqDBxluLm824b9jtwqqmdsKWB6oQMlze m/aU3FP3OkEIxbtgmEMfuxpzWqInkz3aglN0xh3TbZlZB/0DHMcj6nNFvxWuzfPExJFB nh2S22zgvjjzC6/d0l0TClr766zFOR4oNXHOmExovlunebHH8ZzhioWG/9Q8viZop8fc PPoQ== X-Gm-Message-State: AOJu0YyVXzBDGumdUfyF/k0QxNPAIDEogt2SQl70pqSECckd4CiDn7Qb MtKyqyW8UFhZncDE+MLlxW/rWqgV/bduCBQsU0uN1b1n/SQ= X-Google-Smtp-Source: AGHT+IEu4Ue+ePAkRdvaC9gc/5c59HqPNebLWBz8/ChxOEYCt99bdRsgzKGJaiK9U1KxgHyQOb54gQ== X-Received: by 2002:a9d:4f14:0:b0:6da:46fb:76c with SMTP id d20-20020a9d4f14000000b006da46fb076cmr14848760otl.8.1704242173801; Tue, 02 Jan 2024 16:36:13 -0800 (PST) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id y12-20020aa7854c000000b006d9af59eecesm16698260pfn.20.2024.01.02.16.36.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 16:36:13 -0800 (PST) From: Stephen Hemminger To: leon@kernel.org Cc: netdev@vger.kernel.org, Stephen Hemminger Subject: [RFC iproute2 7/8] rdma: remove duplicate forward declaration Date: Tue, 2 Jan 2024 16:34:32 -0800 Message-ID: <20240103003558.20615-8-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240103003558.20615-1-stephen@networkplumber.org> References: <20240103003558.20615-1-stephen@networkplumber.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: dsahern@gmail.com X-Patchwork-State: RFC Signed-off-by: Stephen Hemminger --- rdma/rdma.h | 1 - 1 file changed, 1 deletion(-) diff --git a/rdma/rdma.h b/rdma/rdma.h index e93e34cbce45..08b26a07a003 100644 --- a/rdma/rdma.h +++ b/rdma/rdma.h @@ -135,7 +135,6 @@ int rd_attr_cb(const struct nlattr *attr, void *data); */ void print_driver_table(struct rd *rd, struct nlattr *tb); void print_raw_data(struct rd *rd, struct nlattr **nla_line); -void print_raw_data(struct rd *rd, struct nlattr **nla_line); void print_nl_indent(void); #define MAX_LINE_LENGTH 80 From patchwork Wed Jan 3 00:34:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 13509591 X-Patchwork-Delegate: dsahern@gmail.com Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (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 716D61877 for ; Wed, 3 Jan 2024 00:36:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=networkplumber.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=networkplumber.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=networkplumber-org.20230601.gappssmtp.com header.i=@networkplumber-org.20230601.gappssmtp.com header.b="AacSSC8x" Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-6d9af1f12d5so5942382b3a.3 for ; Tue, 02 Jan 2024 16:36:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1704242175; x=1704846975; 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=mNWzhxNt9LAD97OFJG4YSt1VEpptfaDchIPiJAoK0hY=; b=AacSSC8xz2HRUg30eG7U3+WN5FBWREXgQB/GhYxALaLMeDBoXvYzyIinlen00Geu+D xAoWCxSS46ieI743vtSXg2+8WgAIr6rhhG1INU+qh2y+/v99/UHWijs/DEoo6ZUOgUlL hiAi9+XaYNSSJqOcxSib4UxOf49RwqI9iiqQIRxx96F3yISo/aMETzwFpgFOSy4Z3l/l RWD1IoN980T6s0Mz8GIkG6CH09k8xzlZ69nX0YJJbm6UWKiKrycJAP4iXb+UrOu52xZm ylFG0JTH1Tkyf5g4j0zdR3DztYzuBmkQ8HINA5Zn8u/hfNBN6HqHxRQ1uaTMBijABJkP iSZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704242175; x=1704846975; 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=mNWzhxNt9LAD97OFJG4YSt1VEpptfaDchIPiJAoK0hY=; b=q+52YfplZbx3xP1lnNLGKy4utShqKK7YmiCbdf4eGrpY0Khj2S/z9W37CK5/ZOrBfn OImfdhO/newAMlGzJh5c2bX6gejh2E84ZC6UhGGV15HKl4E2FRfhUrp7UJz5GAqkmtce ZX3aFSIcoPqQYdc7HfzuLgOVyzMxzuQYTB2SAf1T4VyOKxxXCkV2E/rXqSAGrUuZkRMJ 2lg3IPl0oJmCfc/R8CE9tnt1FROR1qPW2cx7TQnouy6L7mfTqpxEneJGrSbkgAIly5Ue aMVe+xHuPVjYTgn3KenxNi8H/ktAXRLplt97LpHxmOuTtCzpTPLOhZg7xWwyKePz7B3W nmEA== X-Gm-Message-State: AOJu0YzsYKFBaoxqpccIKvW7zeQkFisBZV4XnhnVYUasem3eLmRNkBRQ +BVFogcbuq5Pf65P2Q0Nck+UkO4WOut88goVoOPLx8nQUFk= X-Google-Smtp-Source: AGHT+IFvvjqm8ZCKepCYYXw83gLut7H8hocc98z356UomHJmh3yYJTV0LtI07lJtH+q9uwbYZtf9WQ== X-Received: by 2002:a05:6a21:339b:b0:197:570c:c3a6 with SMTP id yy27-20020a056a21339b00b00197570cc3a6mr1588014pzb.101.1704242174528; Tue, 02 Jan 2024 16:36:14 -0800 (PST) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id y12-20020aa7854c000000b006d9af59eecesm16698260pfn.20.2024.01.02.16.36.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 16:36:14 -0800 (PST) From: Stephen Hemminger To: leon@kernel.org Cc: netdev@vger.kernel.org, Stephen Hemminger Subject: [RFC iproute2 8/8] rdma: remove unused rd argument Date: Tue, 2 Jan 2024 16:34:33 -0800 Message-ID: <20240103003558.20615-9-stephen@networkplumber.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240103003558.20615-1-stephen@networkplumber.org> References: <20240103003558.20615-1-stephen@networkplumber.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: dsahern@gmail.com X-Patchwork-State: RFC Lots of functions were taking the rdma data structure as argument but never using it. Signed-off-by: Stephen Hemminger --- rdma/dev.c | 29 +++++++++++++++-------------- rdma/link.c | 30 +++++++++++++++--------------- rdma/res-cmid.c | 34 +++++++++++++++------------------- rdma/res-cq.c | 25 ++++++++++++------------- rdma/res-ctx.c | 8 ++++---- rdma/res-mr.c | 20 ++++++++++---------- rdma/res-pd.c | 17 ++++++++--------- rdma/res-qp.c | 35 +++++++++++++++++------------------ rdma/res-srq.c | 18 +++++++++--------- rdma/res.c | 25 ++++++++++--------------- rdma/res.h | 18 +++++++----------- rdma/stat-mr.c | 7 +++---- rdma/stat.c | 27 ++++++++++++--------------- rdma/stat.h | 4 +--- rdma/utils.c | 36 +++++++++++++++++------------------- 15 files changed, 155 insertions(+), 178 deletions(-) diff --git a/rdma/dev.c b/rdma/dev.c index c8cb6d675c3b..adf378b1f74e 100644 --- a/rdma/dev.c +++ b/rdma/dev.c @@ -84,7 +84,7 @@ static const char *dev_caps_to_str(uint32_t idx) return "UNKNOWN"; } -static void dev_print_caps(struct rd *rd, struct nlattr **tb) +static void dev_print_caps(struct nlattr **tb) { uint64_t caps; uint32_t idx; @@ -106,9 +106,10 @@ static void dev_print_caps(struct rd *rd, struct nlattr **tb) close_json_array(PRINT_ANY, ">"); } -static void dev_print_fw(struct rd *rd, struct nlattr **tb) +static void dev_print_fw(struct nlattr **tb) { const char *str; + if (!tb[RDMA_NLDEV_ATTR_FW_VERSION]) return; @@ -116,7 +117,7 @@ static void dev_print_fw(struct rd *rd, struct nlattr **tb) print_string(PRINT_ANY, "fw", "fw %s ", str); } -static void dev_print_node_guid(struct rd *rd, struct nlattr **tb) +static void dev_print_node_guid(struct nlattr **tb) { uint64_t node_guid; uint16_t vp[4]; @@ -132,7 +133,7 @@ static void dev_print_node_guid(struct rd *rd, struct nlattr **tb) str); } -static void dev_print_sys_image_guid(struct rd *rd, struct nlattr **tb) +static void dev_print_sys_image_guid(struct nlattr **tb) { uint64_t sys_image_guid; uint16_t vp[4]; @@ -147,7 +148,7 @@ static void dev_print_sys_image_guid(struct rd *rd, struct nlattr **tb) print_string(PRINT_ANY, "sys_image_guid", "sys_image_guid %s ", str); } -static void dev_print_dim_setting(struct rd *rd, struct nlattr **tb) +static void dev_print_dim_setting(struct nlattr **tb) { uint8_t dim_setting; @@ -174,7 +175,7 @@ static const char *node_type_to_str(uint8_t node_type) return "unknown"; } -static void dev_print_node_type(struct rd *rd, struct nlattr **tb) +static void dev_print_node_type(struct nlattr **tb) { const char *node_str; uint8_t node_type; @@ -187,7 +188,7 @@ static void dev_print_node_type(struct rd *rd, struct nlattr **tb) print_string(PRINT_ANY, "node_type", "node_type %s ", node_str); } -static void dev_print_dev_proto(struct rd *rd, struct nlattr **tb) +static void dev_print_dev_proto(struct nlattr **tb) { const char *str; @@ -214,14 +215,14 @@ static int dev_parse_cb(const struct nlmsghdr *nlh, void *data) print_uint(PRINT_ANY, "ifindex", "%u: ", idx); print_string(PRINT_ANY, "ifname", "%s: ", name); - dev_print_node_type(rd, tb); - dev_print_dev_proto(rd, tb); - dev_print_fw(rd, tb); - dev_print_node_guid(rd, tb); - dev_print_sys_image_guid(rd, tb); + dev_print_node_type(tb); + dev_print_dev_proto(tb); + dev_print_fw(tb); + dev_print_node_guid(tb); + dev_print_sys_image_guid(tb); if (rd->show_details) { - dev_print_dim_setting(rd, tb); - dev_print_caps(rd, tb); + dev_print_dim_setting(tb); + dev_print_caps(tb); } close_json_object(); diff --git a/rdma/link.c b/rdma/link.c index 0c57a01480ba..6d9f322b4fa5 100644 --- a/rdma/link.c +++ b/rdma/link.c @@ -86,7 +86,7 @@ static const char *caps_to_str(uint32_t idx) return "UNKNOWN"; } -static void link_print_caps(struct rd *rd, struct nlattr **tb) +static void link_print_caps(struct nlattr **tb) { uint64_t caps; uint32_t idx; @@ -108,7 +108,7 @@ static void link_print_caps(struct rd *rd, struct nlattr **tb) close_json_array(PRINT_ANY, ">"); } -static void link_print_subnet_prefix(struct rd *rd, struct nlattr **tb) +static void link_print_subnet_prefix(struct nlattr **tb) { uint64_t subnet_prefix; uint16_t vp[4]; @@ -123,7 +123,7 @@ static void link_print_subnet_prefix(struct rd *rd, struct nlattr **tb) print_string(PRINT_ANY, "subnet_prefix", "subnet_prefix %s ", str); } -static void link_print_lid(struct rd *rd, struct nlattr **tb) +static void link_print_lid(struct nlattr **tb) { uint32_t lid; @@ -134,7 +134,7 @@ static void link_print_lid(struct rd *rd, struct nlattr **tb) print_uint(PRINT_ANY, "lid", "lid %u ", lid); } -static void link_print_sm_lid(struct rd *rd, struct nlattr **tb) +static void link_print_sm_lid(struct nlattr **tb) { uint32_t sm_lid; @@ -145,7 +145,7 @@ static void link_print_sm_lid(struct rd *rd, struct nlattr **tb) print_uint(PRINT_ANY, "sm_lid", "sm_lid %u ", sm_lid); } -static void link_print_lmc(struct rd *rd, struct nlattr **tb) +static void link_print_lmc(struct nlattr **tb) { uint8_t lmc; @@ -167,7 +167,7 @@ static const char *link_state_to_str(uint8_t link_state) return "UNKNOWN"; } -static void link_print_state(struct rd *rd, struct nlattr **tb) +static void link_print_state(struct nlattr **tb) { uint8_t state; @@ -192,7 +192,7 @@ static const char *phys_state_to_str(uint8_t phys_state) return "UNKNOWN"; }; -static void link_print_phys_state(struct rd *rd, struct nlattr **tb) +static void link_print_phys_state(struct nlattr **tb) { uint8_t phys_state; @@ -204,7 +204,7 @@ static void link_print_phys_state(struct rd *rd, struct nlattr **tb) phys_state_to_str(phys_state)); } -static void link_print_netdev(struct rd *rd, struct nlattr **tb) +static void link_print_netdev(const struct rd * rd, struct nlattr **tb) { const char *netdev_name; uint32_t idx; @@ -242,15 +242,15 @@ static int link_parse_cb(const struct nlmsghdr *nlh, void *data) print_uint(PRINT_JSON, "ifindex", NULL, idx); print_string(PRINT_ANY, "ifname", "link %s/", name); print_uint(PRINT_ANY, "port", "%u ", port); - link_print_subnet_prefix(rd, tb); - link_print_lid(rd, tb); - link_print_sm_lid(rd, tb); - link_print_lmc(rd, tb); - link_print_state(rd, tb); - link_print_phys_state(rd, tb); + link_print_subnet_prefix(tb); + link_print_lid(tb); + link_print_sm_lid(tb); + link_print_lmc(tb); + link_print_state(tb); + link_print_phys_state(tb); link_print_netdev(rd, tb); if (rd->show_details) - link_print_caps(rd, tb); + link_print_caps(tb); close_json_object(); print_nl(); diff --git a/rdma/res-cmid.c b/rdma/res-cmid.c index 9714404aaded..03b3f339384d 100644 --- a/rdma/res-cmid.c +++ b/rdma/res-cmid.c @@ -37,20 +37,17 @@ static const char *cm_id_ps_to_str(uint32_t ps) } } -static void print_cm_id_state(struct rd *rd, uint8_t state) +static void print_cm_id_state(uint8_t state) { - print_string(PRINT_ANY, "state", "state %s ", - cm_id_state_to_str(state)); + print_string(PRINT_ANY, "state", "state %s ", cm_id_state_to_str(state)); } -static void print_ps(struct rd *rd, uint32_t ps) +static void print_ps(uint32_t ps) { - print_string(PRINT_ANY, "ps", "ps %s ", - cm_id_ps_to_str(ps)); + print_string(PRINT_ANY, "ps", "ps %s ", cm_id_ps_to_str(ps)); } -static void print_ipaddr(struct rd *rd, const char *key, char *addrstr, - uint16_t port) +static void print_ipaddr(const char *key, char *addrstr, uint16_t port) { int name_size = INET6_ADDRSTRLEN + strlen(":65535"); char json_name[name_size]; @@ -181,21 +178,20 @@ static int res_cm_id_line(struct rd *rd, const char *name, int idx, goto out; open_json_object(NULL); - print_link(rd, idx, name, port, nla_line); - res_print_u32(rd, "cm-idn", cm_idn, - nla_line[RDMA_NLDEV_ATTR_RES_CM_IDN]); - res_print_u32(rd, "lqpn", lqpn, nla_line[RDMA_NLDEV_ATTR_RES_LQPN]); + print_link(idx, name, port, nla_line); + res_print_u32("cm-idn", cm_idn, nla_line[RDMA_NLDEV_ATTR_RES_CM_IDN]); + res_print_u32("lqpn", lqpn, nla_line[RDMA_NLDEV_ATTR_RES_LQPN]); if (nla_line[RDMA_NLDEV_ATTR_RES_TYPE]) - print_qp_type(rd, type); - print_cm_id_state(rd, state); - print_ps(rd, ps); - res_print_u32(rd, "pid", pid, nla_line[RDMA_NLDEV_ATTR_RES_PID]); - print_comm(rd, comm, nla_line); + print_qp_type(type); + print_cm_id_state(state); + print_ps(ps); + res_print_u32("pid", pid, nla_line[RDMA_NLDEV_ATTR_RES_PID]); + print_comm(comm, nla_line); if (nla_line[RDMA_NLDEV_ATTR_RES_SRC_ADDR]) - print_ipaddr(rd, "src-addr", src_addr_str, src_port); + print_ipaddr("src-addr", src_addr_str, src_port); if (nla_line[RDMA_NLDEV_ATTR_RES_DST_ADDR]) - print_ipaddr(rd, "dst-addr", dst_addr_str, dst_port); + print_ipaddr("dst-addr", dst_addr_str, dst_port); print_driver_table(rd, nla_line[RDMA_NLDEV_ATTR_DRIVER]); close_json_object(); diff --git a/rdma/res-cq.c b/rdma/res-cq.c index 0d705a552781..5cba432d1c75 100644 --- a/rdma/res-cq.c +++ b/rdma/res-cq.c @@ -17,14 +17,14 @@ static const char *poll_ctx_to_str(uint8_t idx) return "UNKNOWN"; } -static void print_poll_ctx(struct rd *rd, uint8_t poll_ctx, struct nlattr *attr) +static void print_poll_ctx(uint8_t poll_ctx, struct nlattr *attr) { if (!attr) return; print_string(PRINT_ANY, "poll-ctx", "poll-ctx %s ", poll_ctx_to_str(poll_ctx)); } -static void print_cq_dim_setting(struct rd *rd, struct nlattr *attr) +static void print_cq_dim_setting(struct nlattr *attr) { uint8_t dim_setting; @@ -45,7 +45,7 @@ static int res_cq_line_raw(struct rd *rd, const char *name, int idx, return MNL_CB_ERROR; open_json_object(NULL); - print_dev(rd, idx, name); + print_dev(idx, name); print_raw_data(rd, nla_line); close_json_object(); print_nl(); @@ -111,16 +111,15 @@ static int res_cq_line(struct rd *rd, const char *name, int idx, goto out; open_json_object(NULL); - print_dev(rd, idx, name); - res_print_u32(rd, "cqn", cqn, nla_line[RDMA_NLDEV_ATTR_RES_CQN]); - res_print_u32(rd, "cqe", cqe, nla_line[RDMA_NLDEV_ATTR_RES_CQE]); - res_print_u64(rd, "users", users, - nla_line[RDMA_NLDEV_ATTR_RES_USECNT]); - print_poll_ctx(rd, poll_ctx, nla_line[RDMA_NLDEV_ATTR_RES_POLL_CTX]); - print_cq_dim_setting(rd, nla_line[RDMA_NLDEV_ATTR_DEV_DIM]); - res_print_u32(rd, "ctxn", ctxn, nla_line[RDMA_NLDEV_ATTR_RES_CTXN]); - res_print_u32(rd, "pid", pid, nla_line[RDMA_NLDEV_ATTR_RES_PID]); - print_comm(rd, comm, nla_line); + print_dev(idx, name); + res_print_u32("cqn", cqn, nla_line[RDMA_NLDEV_ATTR_RES_CQN]); + res_print_u32("cqe", cqe, nla_line[RDMA_NLDEV_ATTR_RES_CQE]); + res_print_u64("users", users, nla_line[RDMA_NLDEV_ATTR_RES_USECNT]); + print_poll_ctx(poll_ctx, nla_line[RDMA_NLDEV_ATTR_RES_POLL_CTX]); + print_cq_dim_setting(nla_line[RDMA_NLDEV_ATTR_DEV_DIM]); + res_print_u32("ctxn", ctxn, nla_line[RDMA_NLDEV_ATTR_RES_CTXN]); + res_print_u32("pid", pid, nla_line[RDMA_NLDEV_ATTR_RES_PID]); + print_comm(comm, nla_line); print_driver_table(rd, nla_line[RDMA_NLDEV_ATTR_DRIVER]); close_json_object(); diff --git a/rdma/res-ctx.c b/rdma/res-ctx.c index 1a5d31e817ff..de35618cb889 100644 --- a/rdma/res-ctx.c +++ b/rdma/res-ctx.c @@ -41,10 +41,10 @@ static int res_ctx_line(struct rd *rd, const char *name, int idx, goto out; open_json_object(NULL); - print_dev(rd, idx, name); - res_print_u32(rd, "ctxn", ctxn, nla_line[RDMA_NLDEV_ATTR_RES_CTXN]); - res_print_u32(rd, "pid", pid, nla_line[RDMA_NLDEV_ATTR_RES_PID]); - print_comm(rd, comm, nla_line); + print_dev(idx, name); + res_print_u32("ctxn", ctxn, nla_line[RDMA_NLDEV_ATTR_RES_CTXN]); + res_print_u32("pid", pid, nla_line[RDMA_NLDEV_ATTR_RES_PID]); + print_comm(comm, nla_line); print_driver_table(rd, nla_line[RDMA_NLDEV_ATTR_DRIVER]); close_json_object(); diff --git a/rdma/res-mr.c b/rdma/res-mr.c index 8b647efbc6a9..aa3d33749423 100644 --- a/rdma/res-mr.c +++ b/rdma/res-mr.c @@ -14,7 +14,7 @@ static int res_mr_line_raw(struct rd *rd, const char *name, int idx, return MNL_CB_ERROR; open_json_object(NULL); - print_dev(rd, idx, name); + print_dev(idx, name); print_raw_data(rd, nla_line); close_json_object(); print_nl(); @@ -76,15 +76,15 @@ static int res_mr_line(struct rd *rd, const char *name, int idx, goto out; open_json_object(NULL); - print_dev(rd, idx, name); - res_print_u32(rd, "mrn", mrn, nla_line[RDMA_NLDEV_ATTR_RES_MRN]); - print_key(rd, "rkey", rkey, nla_line[RDMA_NLDEV_ATTR_RES_RKEY]); - print_key(rd, "lkey", lkey, nla_line[RDMA_NLDEV_ATTR_RES_LKEY]); - print_key(rd, "iova", iova, nla_line[RDMA_NLDEV_ATTR_RES_IOVA]); - res_print_u64(rd, "mrlen", mrlen, nla_line[RDMA_NLDEV_ATTR_RES_MRLEN]); - res_print_u32(rd, "pdn", pdn, nla_line[RDMA_NLDEV_ATTR_RES_PDN]); - res_print_u32(rd, "pid", pid, nla_line[RDMA_NLDEV_ATTR_RES_PID]); - print_comm(rd, comm, nla_line); + print_dev(idx, name); + res_print_u32("mrn", mrn, nla_line[RDMA_NLDEV_ATTR_RES_MRN]); + print_key("rkey", rkey, nla_line[RDMA_NLDEV_ATTR_RES_RKEY]); + print_key("lkey", lkey, nla_line[RDMA_NLDEV_ATTR_RES_LKEY]); + print_key("iova", iova, nla_line[RDMA_NLDEV_ATTR_RES_IOVA]); + res_print_u64("mrlen", mrlen, nla_line[RDMA_NLDEV_ATTR_RES_MRLEN]); + res_print_u32("pdn", pdn, nla_line[RDMA_NLDEV_ATTR_RES_PDN]); + res_print_u32("pid", pid, nla_line[RDMA_NLDEV_ATTR_RES_PID]); + print_comm(comm, nla_line); print_driver_table(rd, nla_line[RDMA_NLDEV_ATTR_DRIVER]); print_raw_data(rd, nla_line); diff --git a/rdma/res-pd.c b/rdma/res-pd.c index 3ccfa364a236..8ca2744bf9f4 100644 --- a/rdma/res-pd.c +++ b/rdma/res-pd.c @@ -63,17 +63,16 @@ static int res_pd_line(struct rd *rd, const char *name, int idx, goto out; open_json_object(NULL); - print_dev(rd, idx, name); - res_print_u32(rd, "pdn", pdn, nla_line[RDMA_NLDEV_ATTR_RES_PDN]); - print_key(rd, "local_dma_lkey", local_dma_lkey, + print_dev(idx, name); + res_print_u32("pdn", pdn, nla_line[RDMA_NLDEV_ATTR_RES_PDN]); + print_key("local_dma_lkey", local_dma_lkey, nla_line[RDMA_NLDEV_ATTR_RES_LOCAL_DMA_LKEY]); - res_print_u64(rd, "users", users, - nla_line[RDMA_NLDEV_ATTR_RES_USECNT]); - print_key(rd, "unsafe_global_rkey", unsafe_global_rkey, + res_print_u64("users", users, nla_line[RDMA_NLDEV_ATTR_RES_USECNT]); + print_key("unsafe_global_rkey", unsafe_global_rkey, nla_line[RDMA_NLDEV_ATTR_RES_UNSAFE_GLOBAL_RKEY]); - res_print_u32(rd, "ctxn", ctxn, nla_line[RDMA_NLDEV_ATTR_RES_CTXN]); - res_print_u32(rd, "pid", pid, nla_line[RDMA_NLDEV_ATTR_RES_PID]); - print_comm(rd, comm, nla_line); + res_print_u32("ctxn", ctxn, nla_line[RDMA_NLDEV_ATTR_RES_CTXN]); + res_print_u32("pid", pid, nla_line[RDMA_NLDEV_ATTR_RES_PID]); + print_comm(comm, nla_line); print_driver_table(rd, nla_line[RDMA_NLDEV_ATTR_DRIVER]); close_json_object(); diff --git a/rdma/res-qp.c b/rdma/res-qp.c index d5d6a836e358..78af7c630d63 100644 --- a/rdma/res-qp.c +++ b/rdma/res-qp.c @@ -28,24 +28,24 @@ static const char *qp_states_to_str(uint8_t idx) return "UNKNOWN"; } -static void print_rqpn(struct rd *rd, uint32_t val, struct nlattr **nla_line) +static void print_rqpn(uint32_t val, struct nlattr **nla_line) { if (!nla_line[RDMA_NLDEV_ATTR_RES_RQPN]) return; print_uint(PRINT_ANY, "rqpn", "rqpn %d ", val); } -static void print_type(struct rd *rd, uint32_t val) +static void print_type(uint32_t val) { print_string(PRINT_ANY, "type", "type %s ", qp_types_to_str(val)); } -static void print_state(struct rd *rd, uint32_t val) +static void print_state(uint32_t val) { print_string(PRINT_ANY, "state", "state %s ", qp_states_to_str(val)); } -static void print_rqpsn(struct rd *rd, uint32_t val, struct nlattr **nla_line) +static void print_rqpsn(uint32_t val, struct nlattr **nla_line) { if (!nla_line[RDMA_NLDEV_ATTR_RES_RQ_PSN]) return; @@ -53,7 +53,7 @@ static void print_rqpsn(struct rd *rd, uint32_t val, struct nlattr **nla_line) print_uint(PRINT_ANY, "rq-psn", "rq-psn %d ", val); } -static void print_pathmig(struct rd *rd, uint32_t val, struct nlattr **nla_line) +static void print_pathmig(uint32_t val, struct nlattr **nla_line) { if (!nla_line[RDMA_NLDEV_ATTR_RES_PATH_MIG_STATE]) return; @@ -68,7 +68,7 @@ static int res_qp_line_raw(struct rd *rd, const char *name, int idx, return MNL_CB_ERROR; open_json_object(NULL); - print_link(rd, idx, name, rd->port_idx, nla_line); + print_link(idx, name, rd->port_idx, nla_line); print_raw_data(rd, nla_line); close_json_object(); print_nl(); @@ -160,21 +160,20 @@ static int res_qp_line(struct rd *rd, const char *name, int idx, goto out; open_json_object(NULL); - print_link(rd, idx, name, port, nla_line); - res_print_u32(rd, "lqpn", lqpn, nla_line[RDMA_NLDEV_ATTR_RES_LQPN]); - print_rqpn(rd, rqpn, nla_line); + print_link(idx, name, port, nla_line); + res_print_u32("lqpn", lqpn, nla_line[RDMA_NLDEV_ATTR_RES_LQPN]); + print_rqpn(rqpn, nla_line); - print_type(rd, type); - print_state(rd, state); + print_type(type); + print_state(state); - print_rqpsn(rd, rq_psn, nla_line); - res_print_u32(rd, "sq-psn", sq_psn, - nla_line[RDMA_NLDEV_ATTR_RES_SQ_PSN]); + print_rqpsn(rq_psn, nla_line); + res_print_u32("sq-psn", sq_psn, nla_line[RDMA_NLDEV_ATTR_RES_SQ_PSN]); - print_pathmig(rd, path_mig_state, nla_line); - res_print_u32(rd, "pdn", pdn, nla_line[RDMA_NLDEV_ATTR_RES_PDN]); - res_print_u32(rd, "pid", pid, nla_line[RDMA_NLDEV_ATTR_RES_PID]); - print_comm(rd, comm, nla_line); + print_pathmig(path_mig_state, nla_line); + res_print_u32("pdn", pdn, nla_line[RDMA_NLDEV_ATTR_RES_PDN]); + res_print_u32("pid", pid, nla_line[RDMA_NLDEV_ATTR_RES_PID]); + print_comm(comm, nla_line); print_driver_table(rd, nla_line[RDMA_NLDEV_ATTR_DRIVER]); close_json_object(); diff --git a/rdma/res-srq.c b/rdma/res-srq.c index b9d1fc45a1a4..14f72e3288ca 100644 --- a/rdma/res-srq.c +++ b/rdma/res-srq.c @@ -20,7 +20,7 @@ static const char *srq_types_to_str(uint8_t idx) return "UNKNOWN"; } -static void print_type(struct rd *rd, uint32_t val) +static void print_type(uint32_t val) { print_string(PRINT_ANY, "type", "type %s ", srq_types_to_str(val)); } @@ -168,7 +168,7 @@ static int res_srq_line_raw(struct rd *rd, const char *name, int idx, return MNL_CB_ERROR; open_json_object(NULL); - print_dev(rd, idx, name); + print_dev(idx, name); print_raw_data(rd, nla_line); close_json_object(); print_nl(); @@ -232,14 +232,14 @@ static int res_srq_line(struct rd *rd, const char *name, int idx, goto out; open_json_object(NULL); - print_dev(rd, idx, name); - res_print_u32(rd, "srqn", srqn, nla_line[RDMA_NLDEV_ATTR_RES_SRQN]); - print_type(rd, type); + print_dev(idx, name); + res_print_u32("srqn", srqn, nla_line[RDMA_NLDEV_ATTR_RES_SRQN]); + print_type(type); print_qps(qp_str); - res_print_u32(rd, "pdn", pdn, nla_line[RDMA_NLDEV_ATTR_RES_PDN]); - res_print_u32(rd, "cqn", cqn, nla_line[RDMA_NLDEV_ATTR_RES_CQN]); - res_print_u32(rd, "pid", pid, nla_line[RDMA_NLDEV_ATTR_RES_PID]); - print_comm(rd, comm, nla_line); + res_print_u32("pdn", pdn, nla_line[RDMA_NLDEV_ATTR_RES_PDN]); + res_print_u32("cqn", cqn, nla_line[RDMA_NLDEV_ATTR_RES_CQN]); + res_print_u32("pid", pid, nla_line[RDMA_NLDEV_ATTR_RES_PID]); + print_comm(comm, nla_line); print_driver_table(rd, nla_line[RDMA_NLDEV_ATTR_DRIVER]); close_json_object(); diff --git a/rdma/res.c b/rdma/res.c index 2c4507da8223..e802aa0fe056 100644 --- a/rdma/res.c +++ b/rdma/res.c @@ -29,7 +29,7 @@ static int res_help(struct rd *rd) return 0; } -static int res_print_summary(struct rd *rd, struct nlattr **tb) +static int res_print_summary(struct nlattr **tb) { struct nlattr *nla_table = tb[RDMA_NLDEV_ATTR_RES_SUMMARY]; struct nlattr *nla_entry; @@ -51,8 +51,7 @@ static int res_print_summary(struct rd *rd, struct nlattr **tb) name = mnl_attr_get_str(nla_line[RDMA_NLDEV_ATTR_RES_SUMMARY_ENTRY_NAME]); curr = mnl_attr_get_u64(nla_line[RDMA_NLDEV_ATTR_RES_SUMMARY_ENTRY_CURR]); - res_print_u64(rd, name, curr, - nla_line[RDMA_NLDEV_ATTR_RES_SUMMARY_ENTRY_CURR]); + res_print_u64(name, curr, nla_line[RDMA_NLDEV_ATTR_RES_SUMMARY_ENTRY_CURR]); } return 0; } @@ -65,7 +64,6 @@ static int res_no_args_idx_parse_cb(const struct nlmsghdr *nlh, void *data) static int res_no_args_parse_cb(const struct nlmsghdr *nlh, void *data) { struct nlattr *tb[RDMA_NLDEV_ATTR_MAX] = {}; - struct rd *rd = data; const char *name; uint32_t idx; @@ -80,7 +78,7 @@ static int res_no_args_parse_cb(const struct nlmsghdr *nlh, void *data) open_json_object(NULL); print_uint(PRINT_ANY, "ifindex", "%u: ", idx); print_string(PRINT_ANY, "ifname", "%s: ", name); - res_print_summary(rd, tb); + res_print_summary(tb); close_json_object(); print_nl(); @@ -155,7 +153,7 @@ const char *qp_types_to_str(uint8_t idx) return (idx == 0xFF) ? "DRIVER" : "UNKNOWN"; } -void print_comm(struct rd *rd, const char *str, struct nlattr **nla_line) +void print_comm(const char *str, struct nlattr **nla_line) { char tmp[18]; @@ -169,13 +167,13 @@ void print_comm(struct rd *rd, const char *str, struct nlattr **nla_line) print_string(PRINT_ANY, "comm", "comm %s ", tmp); } -void print_dev(struct rd *rd, uint32_t idx, const char *name) +void print_dev(uint32_t idx, const char *name) { print_int(PRINT_ANY, "ifindex", NULL, idx); print_string(PRINT_ANY, "ifname", "dev %s ", name); } -void print_link(struct rd *rd, uint32_t idx, const char *name, uint32_t port, +void print_link(uint32_t idx, const char *name, uint32_t port, struct nlattr **nla_line) { char tmp[64] = {}; @@ -192,13 +190,12 @@ void print_link(struct rd *rd, uint32_t idx, const char *name, uint32_t port, print_string(PRINT_FP, NULL, "link %s ", tmp); } -void print_qp_type(struct rd *rd, uint32_t val) +void print_qp_type(uint32_t val) { print_string(PRINT_ANY, "qp-type", "qp-type %s ", qp_types_to_str(val)); } -void print_key(struct rd *rd, const char *name, uint64_t val, - struct nlattr *nlattr) +void print_key(const char *name, uint64_t val, struct nlattr *nlattr) { if (!nlattr) return; @@ -206,8 +203,7 @@ void print_key(struct rd *rd, const char *name, uint64_t val, print_hex(PRINT_ANY, name, " 0x%" PRIx64 " ", val); } -void res_print_u32(struct rd *rd, const char *name, uint32_t val, - struct nlattr *nlattr) +void res_print_u32(const char *name, uint32_t val, struct nlattr *nlattr) { if (!nlattr) return; @@ -215,8 +211,7 @@ void res_print_u32(struct rd *rd, const char *name, uint32_t val, print_uint(PRINT_FP, NULL, " %" PRIu32 " ", val); } -void res_print_u64(struct rd *rd, const char *name, uint64_t val, - struct nlattr *nlattr) +void res_print_u64(const char *name, uint64_t val, struct nlattr *nlattr) { if (!nlattr) return; diff --git a/rdma/res.h b/rdma/res.h index e880c28be569..fd09ce7dc084 100644 --- a/rdma/res.h +++ b/rdma/res.h @@ -185,16 +185,12 @@ struct filters srq_valid_filters[MAX_NUMBER_OF_FILTERS] = { RES_FUNC(res_srq, RDMA_NLDEV_CMD_RES_SRQ_GET, srq_valid_filters, true, RDMA_NLDEV_ATTR_RES_SRQN); -void print_dev(struct rd *rd, uint32_t idx, const char *name); -void print_link(struct rd *rd, uint32_t idx, const char *name, uint32_t port, - struct nlattr **nla_line); -void print_key(struct rd *rd, const char *name, uint64_t val, - struct nlattr *nlattr); -void res_print_u32(struct rd *rd, const char *name, uint32_t val, - struct nlattr *nlattr); -void res_print_u64(struct rd *rd, const char *name, uint64_t val, - struct nlattr *nlattr); -void print_comm(struct rd *rd, const char *str, struct nlattr **nla_line); +void print_dev(uint32_t idx, const char *name); +void print_link(uint32_t idx, const char *name, uint32_t port, struct nlattr **nla_line); +void print_key(const char *name, uint64_t val, struct nlattr *nlattr); +void res_print_u32(const char *name, uint32_t val, struct nlattr *nlattr); +void res_print_u64(const char *name, uint64_t val, struct nlattr *nlattr); +void print_comm(const char *str, struct nlattr **nla_line); const char *qp_types_to_str(uint8_t idx); -void print_qp_type(struct rd *rd, uint32_t val); +void print_qp_type(uint32_t val); #endif /* _RDMA_TOOL_RES_H_ */ diff --git a/rdma/stat-mr.c b/rdma/stat-mr.c index be41f0db3d93..8f9eb17f00b7 100644 --- a/rdma/stat-mr.c +++ b/rdma/stat-mr.c @@ -21,12 +21,11 @@ static int stat_mr_line(struct rd *rd, const char *name, int idx, goto out; open_json_object(NULL); - print_dev(rd, idx, name); - res_print_u32(rd, "mrn", mrn, nla_line[RDMA_NLDEV_ATTR_RES_MRN]); + print_dev(idx, name); + res_print_u32("mrn", mrn, nla_line[RDMA_NLDEV_ATTR_RES_MRN]); if (nla_line[RDMA_NLDEV_ATTR_STAT_HWCOUNTERS]) { - ret = res_get_hwcounters( - rd, nla_line[RDMA_NLDEV_ATTR_STAT_HWCOUNTERS], true); + ret = res_get_hwcounters(nla_line[RDMA_NLDEV_ATTR_STAT_HWCOUNTERS], true); if (ret != MNL_CB_OK) return ret; } diff --git a/rdma/stat.c b/rdma/stat.c index 865f301370a0..dc01ac74f9b4 100644 --- a/rdma/stat.c +++ b/rdma/stat.c @@ -62,8 +62,7 @@ static struct counter_param auto_params[] = { { NULL }, }; -static int prepare_auto_mode_str(struct nlattr **tb, uint32_t mask, - char *output, int len) +static int prepare_auto_mode_str(uint32_t mask, char *output, int len) { char s[] = "qp auto"; int i, outlen = strlen(s); @@ -105,7 +104,6 @@ static int qp_link_get_mode_parse_cb(const struct nlmsghdr *nlh, void *data) struct nlattr *tb[RDMA_NLDEV_ATTR_MAX] = {}; uint32_t mode = 0, mask = 0; char output[128] = {}; - struct rd *rd = data; uint32_t idx, port; const char *name; @@ -128,13 +126,13 @@ static int qp_link_get_mode_parse_cb(const struct nlmsghdr *nlh, void *data) if (!tb[RDMA_NLDEV_ATTR_STAT_AUTO_MODE_MASK]) return MNL_CB_ERROR; mask = mnl_attr_get_u32(tb[RDMA_NLDEV_ATTR_STAT_AUTO_MODE_MASK]); - prepare_auto_mode_str(tb, mask, output, sizeof(output)); + prepare_auto_mode_str(mask, output, sizeof(output)); } else { snprintf(output, sizeof(output), "qp auto off"); } open_json_object(NULL); - print_link(rd, idx, name, port, tb); + print_link(idx, name, port, tb); print_string(PRINT_ANY, "mode", "mode %s ", output); close_json_object(); print_nl(); @@ -185,7 +183,7 @@ static int stat_qp_get_mode(struct rd *rd) return rd_exec_cmd(rd, cmds, "parameter"); } -int res_get_hwcounters(struct rd *rd, struct nlattr *hwc_table, bool print) +int res_get_hwcounters(struct nlattr *hwc_table, bool print) { struct nlattr *nla_entry; const char *nm; @@ -210,7 +208,7 @@ int res_get_hwcounters(struct rd *rd, struct nlattr *hwc_table, bool print) nm = mnl_attr_get_str(hw_line[RDMA_NLDEV_ATTR_STAT_HWCOUNTER_ENTRY_NAME]); v = mnl_attr_get_u64(hw_line[RDMA_NLDEV_ATTR_STAT_HWCOUNTER_ENTRY_VALUE]); print_nl_indent(); - res_print_u64(rd, nm, v, hw_line[RDMA_NLDEV_ATTR_STAT_HWCOUNTER_ENTRY_NAME]); + res_print_u64(nm, v, hw_line[RDMA_NLDEV_ATTR_STAT_HWCOUNTER_ENTRY_NAME]); } return MNL_CB_OK; @@ -279,17 +277,17 @@ static int res_counter_line(struct rd *rd, const char *name, int index, return MNL_CB_OK; } - err = res_get_hwcounters(rd, hwc_table, false); + err = res_get_hwcounters(hwc_table, false); if (err != MNL_CB_OK) return err; open_json_object(NULL); - print_link(rd, index, name, port, nla_line); + print_link(index, name, port, nla_line); print_uint(PRINT_ANY, "cntn", "cntn %u ", cntn); if (nla_line[RDMA_NLDEV_ATTR_RES_TYPE]) - print_qp_type(rd, qp_type); - res_print_u64(rd, "pid", pid, nla_line[RDMA_NLDEV_ATTR_RES_PID]); - print_comm(rd, comm, nla_line); - res_get_hwcounters(rd, hwc_table, true); + print_qp_type(qp_type); + res_print_u64("pid", pid, nla_line[RDMA_NLDEV_ATTR_RES_PID]); + print_comm(comm, nla_line); + res_get_hwcounters(hwc_table, true); isfirst = true; open_json_array(PRINT_JSON, "lqpn"); print_string(PRINT_FP, NULL, "%s LQPN: <", _SL_); @@ -1054,7 +1052,6 @@ static int stat_unset(struct rd *rd) static int stat_show_parse_cb(const struct nlmsghdr *nlh, void *data) { struct nlattr *tb[RDMA_NLDEV_ATTR_MAX] = {}; - struct rd *rd = data; const char *name; uint32_t port; int ret; @@ -1070,7 +1067,7 @@ static int stat_show_parse_cb(const struct nlmsghdr *nlh, void *data) open_json_object(NULL); print_string(PRINT_ANY, "ifname", "link %s/", name); print_uint(PRINT_ANY, "port", "%u ", port); - ret = res_get_hwcounters(rd, tb[RDMA_NLDEV_ATTR_STAT_HWCOUNTERS], true); + ret = res_get_hwcounters(tb[RDMA_NLDEV_ATTR_STAT_HWCOUNTERS], true); close_json_object(); print_nl(); diff --git a/rdma/stat.h b/rdma/stat.h index b03a10c9eef6..5adcf4f37e20 100644 --- a/rdma/stat.h +++ b/rdma/stat.h @@ -9,9 +9,7 @@ #include "rdma.h" -int res_get_hwcounters(struct rd *rd, struct nlattr *hwc_table, - bool print); - +int res_get_hwcounters(struct nlattr *hwc_table, bool print); int stat_mr_parse_cb(const struct nlmsghdr *nlh, void *data); int stat_mr_idx_parse_cb(const struct nlmsghdr *nlh, void *data); diff --git a/rdma/utils.c b/rdma/utils.c index 64f598c5aa8f..9671addba72a 100644 --- a/rdma/utils.c +++ b/rdma/utils.c @@ -777,16 +777,15 @@ void print_nl_indent(void) printf("%s ", _SL_); } -static int print_driver_string(struct rd *rd, const char *key_str, - const char *val_str) +static int print_driver_string(const char *key_str, const char *val_str) { print_string(PRINT_ANY, key_str, key_str, val_str); print_string(PRINT_FP, NULL, " %s ", val_str); return 0; } -static int print_driver_s32(struct rd *rd, const char *key_str, int32_t val, - enum rdma_nldev_print_type print_type) +static int print_driver_s32(const char *key_str, int32_t val, + enum rdma_nldev_print_type print_type) { if (!is_json_context()) { switch (print_type) { @@ -802,8 +801,8 @@ static int print_driver_s32(struct rd *rd, const char *key_str, int32_t val, return 0; } -static int print_driver_u32(struct rd *rd, const char *key_str, uint32_t val, - enum rdma_nldev_print_type print_type) +static int print_driver_u32(const char *key_str, uint32_t val, + enum rdma_nldev_print_type print_type) { if (!is_json_context()) { switch (print_type) { @@ -819,8 +818,8 @@ static int print_driver_u32(struct rd *rd, const char *key_str, uint32_t val, return 0; } -static int print_driver_s64(struct rd *rd, const char *key_str, int64_t val, - enum rdma_nldev_print_type print_type) +static int print_driver_s64(const char *key_str, int64_t val, + enum rdma_nldev_print_type print_type) { if (!is_json_context()) { switch (print_type) { @@ -836,8 +835,8 @@ static int print_driver_s64(struct rd *rd, const char *key_str, int64_t val, return 0; } -static int print_driver_u64(struct rd *rd, const char *key_str, uint64_t val, - enum rdma_nldev_print_type print_type) +static int print_driver_u64(const char *key_str, uint64_t val, + enum rdma_nldev_print_type print_type) { if (!is_json_context()) { switch (print_type) { @@ -853,9 +852,8 @@ static int print_driver_u64(struct rd *rd, const char *key_str, uint64_t val, return 0; } -static int print_driver_entry(struct rd *rd, struct nlattr *key_attr, - struct nlattr *val_attr, - enum rdma_nldev_print_type print_type) +static int print_driver_entry(struct nlattr *key_attr, struct nlattr *val_attr, + enum rdma_nldev_print_type print_type) { int attr_type = nla_type(val_attr); int ret = -EINVAL; @@ -866,19 +864,19 @@ static int print_driver_entry(struct rd *rd, struct nlattr *key_attr, switch (attr_type) { case RDMA_NLDEV_ATTR_DRIVER_STRING: - ret = print_driver_string(rd, key_str, mnl_attr_get_str(val_attr)); + ret = print_driver_string(key_str, mnl_attr_get_str(val_attr)); break; case RDMA_NLDEV_ATTR_DRIVER_S32: - ret = print_driver_s32(rd, key_str, mnl_attr_get_u32(val_attr), print_type); + ret = print_driver_s32(key_str, mnl_attr_get_u32(val_attr), print_type); break; case RDMA_NLDEV_ATTR_DRIVER_U32: - ret = print_driver_u32(rd, key_str, mnl_attr_get_u32(val_attr), print_type); + ret = print_driver_u32(key_str, mnl_attr_get_u32(val_attr), print_type); break; case RDMA_NLDEV_ATTR_DRIVER_S64: - ret = print_driver_s64(rd, key_str, mnl_attr_get_u64(val_attr), print_type); + ret = print_driver_s64(key_str, mnl_attr_get_u64(val_attr), print_type); break; case RDMA_NLDEV_ATTR_DRIVER_U64: - ret = print_driver_u64(rd, key_str, mnl_attr_get_u64(val_attr), print_type); + ret = print_driver_u64(key_str, mnl_attr_get_u64(val_attr), print_type); break; } free(key_str); @@ -939,7 +937,7 @@ void print_driver_table(struct rd *rd, struct nlattr *tb) print_type = mnl_attr_get_u8(tb_entry); } else { val = tb_entry; - ret = print_driver_entry(rd, key, val, print_type); + ret = print_driver_entry(key, val, print_type); if (ret < 0) return; cc += ret;