netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Danielle Ratson <danieller@nvidia.com>
To: <netdev@vger.kernel.org>
Cc: <mkubecek@suse.cz>, <matt@traverse.com.au>,
	<daniel.zahka@gmail.com>, <amcohen@nvidia.com>,
	<nbu-mlxsw@exchange.nvidia.com>,
	Danielle Ratson <danieller@nvidia.com>
Subject: [PATCH ethtool-next v4 14/16] ethtool: Enable JSON output support for SFF8079 and SFF8472 modules
Date: Wed, 5 Feb 2025 17:54:34 +0200	[thread overview]
Message-ID: <20250205155436.1276904-15-danieller@nvidia.com> (raw)
In-Reply-To: <20250205155436.1276904-1-danieller@nvidia.com>

 A sample output:

$ ethtool --json -m swp1
[ {
        "identifier": 3,
        "identifier_description": "SFP",
        "extended_identifier": 4,
        "extended_identifier_description": "GBIC/SFP defined by 2-wire
interface ID",
        "connector": 33,
        "connector_description": "Copper pigtail",
        "transceiver_codes": [ 1,0,0,4,0,4,128,213,0 ],
        "transceiver_type": "FC: 100 MBytes/sec",
        "encoding": 0,
        "encoding_description": "unspecified",
        "br_nominal": 10300,
        "rate_identifier": 0,
        "rate_identifier_description": "unspecified",
        "length_(smf)": 0,
        "length_(om2)": 0,
        "length_(om1)": 0,
        "length_(copper_or_active_cable)": 2,
        "length_(om3)": 0,
        "passive_cu_cmplnce.": 1,
        "passive_cu_cmplnce._description": "SFF-8431 appendix E
[SFF-8472 rev10.4 only]",
        "vendor_name": "Mellanox",
        "vendor_oui": [ 0,2,201 ],
        "vendor_pn": "MC2309130-002",
        "vendor_rev": "A2",
        "option_values": [ 0,0 ],
        "br_margin_max": 0,
        "br_margin_min": 0,
        "vendor_sn": "MT1146VS00060",
        "date_code": "111110"
} ]

Signed-off-by: Danielle Ratson <danieller@nvidia.com>
---

Notes:
    v3:
    	* Enable JSON output support for SFF8079.
    	* Reword commit message.

 ethtool.c | 4 ++++
 sfpid.c   | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/ethtool.c b/ethtool.c
index 0b876e8..8a81001 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -5007,6 +5007,8 @@ static int do_getmodule(struct cmd_context *ctx)
 		    (eeprom->len != modinfo.eeprom_len)) {
 			geeprom_dump_hex = 1;
 		} else if (!geeprom_dump_hex) {
+			new_json_obj(ctx->json);
+			open_json_object(NULL);
 			switch (modinfo.type) {
 #ifdef ETHTOOL_ENABLE_PRETTY_DUMP
 			case ETH_MODULE_SFF_8079:
@@ -5026,6 +5028,8 @@ static int do_getmodule(struct cmd_context *ctx)
 				geeprom_dump_hex = 1;
 				break;
 			}
+			close_json_object();
+			delete_json_obj();
 		}
 		if (geeprom_dump_hex)
 			dump_hex(stdout, eeprom->data,
diff --git a/sfpid.c b/sfpid.c
index 0ccf9ad..62acb4f 100644
--- a/sfpid.c
+++ b/sfpid.c
@@ -517,7 +517,11 @@ int sff8079_show_all_nl(struct cmd_context *ctx)
 	if (ret)
 		goto out;
 
+	new_json_obj(ctx->json);
+	open_json_object(NULL);
 	sff8079_show_all_common(buf);
+	close_json_object();
+	delete_json_obj();
 
 	/* Finish if A2h page is not present */
 	if (!(buf[92] & (1 << 6)))
-- 
2.47.0


  parent reply	other threads:[~2025-02-05 15:55 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-05 15:54 [PATCH ethtool-next v4 00/16] Add JSON output to --module-info Danielle Ratson
2025-02-05 15:54 ` [PATCH ethtool-next v4 01/16] module_common: Add a new file to all the common code for all module types Danielle Ratson
2025-02-05 15:54 ` [PATCH ethtool-next v4 02/16] ethtool: Standardize Link Length field names across " Danielle Ratson
2025-02-05 15:54 ` [PATCH ethtool-next v4 03/16] sff_common: Move sff_show_revision_compliance() to qsfp.c Danielle Ratson
2025-02-05 15:54 ` [PATCH ethtool-next v4 04/16] cmis: Change loop order in cmis_show_dom_chan_lvl_flags() Danielle Ratson
2025-02-05 15:54 ` [PATCH ethtool-next v4 05/16] qsfp: Reorder the channel-level flags list for SFF8636 module type Danielle Ratson
2025-02-05 15:54 ` [PATCH ethtool-next v4 06/16] qsfp: Refactor sff8636_show_dom() by moving code into separate functions Danielle Ratson
2025-02-05 15:54 ` [PATCH ethtool-next v4 07/16] module_common: Add helpers to support JSON printing for common value types Danielle Ratson
2025-02-05 15:54 ` [PATCH ethtool-next v4 08/16] cmis: Add JSON output handling to --module-info in CMIS modules Danielle Ratson
2025-02-05 15:54 ` [PATCH ethtool-next v4 09/16] cmis: Enable JSON output support " Danielle Ratson
2025-02-05 15:54 ` [PATCH ethtool-next v4 10/16] qsfp: Add JSON output handling to --module-info in SFF8636 modules Danielle Ratson
2025-02-05 15:54 ` [PATCH ethtool-next v4 11/16] qsfp: Enable JSON output support for " Danielle Ratson
2025-02-07  0:38   ` Jakub Kicinski
2025-02-05 15:54 ` [PATCH ethtool-next v4 12/16] sfpid: Add JSON output handling to --module-info in SFF8079 modules Danielle Ratson
2025-02-05 15:54 ` [PATCH ethtool-next v4 13/16] sfpdiag: Add JSON output handling to --module-info in SFF8472 modules Danielle Ratson
2025-02-05 15:54 ` Danielle Ratson [this message]
2025-02-05 15:54 ` [PATCH ethtool-next v4 15/16] module_info: Add a new JSON file for units documentation Danielle Ratson
2025-02-05 15:54 ` [PATCH ethtool-next v4 16/16] ethtool: Add '-j' support to ethtool Danielle Ratson
2025-02-07  0:39 ` [PATCH ethtool-next v4 00/16] Add JSON output to --module-info Jakub Kicinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250205155436.1276904-15-danieller@nvidia.com \
    --to=danieller@nvidia.com \
    --cc=amcohen@nvidia.com \
    --cc=daniel.zahka@gmail.com \
    --cc=matt@traverse.com.au \
    --cc=mkubecek@suse.cz \
    --cc=nbu-mlxsw@exchange.nvidia.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).