features: add --json support

Adding json to make ethtool more machine friendly. 
No change in normal text output:

Features for enx0c37961ce55a:
rx-checksumming: off [fixed]
tx-checksumming: off
	tx-checksum-ipv4: off [fixed]
	tx-checksum-ip-generic: off [fixed]
	tx-checksum-ipv6: off [fixed]
	tx-checksum-fcoe-crc: off [fixed]
	tx-checksum-sctp: off [fixed]
scatter-gather: off
	tx-scatter-gather: off [fixed]
	tx-scatter-gather-fraglist: off [fixed]
tcp-segmentation-offload: off
	tx-tcp-segmentation: off [fixed]
	tx-tcp-ecn-segmentation: off [fixed]
	tx-tcp-mangleid-segmentation: off [fixed]
	tx-tcp6-segmentation: off [fixed]
generic-segmentation-offload: off [requested on]

...skip similar lines...

JSON output:
[ {
        "ifname": "enx0c37961ce55a",
        "rx-checksumming": {
            "active": false,
            "fixed": true,
            "requested": false
        },
        "tx-checksumming": {
            "active": false,
            "fixed": null,
            "requested": null
        },
        "tx-checksum-ipv4": {
            "active": false,
            "fixed": true,
            "requested": false
        },
        "tx-checksum-ip-generic": {
            "active": false,
            "fixed": true,
            "requested": false
        },
        "tx-checksum-ipv6": {
            "active": false,
            "fixed": true,
            "requested": false
        },
        "tx-checksum-fcoe-crc": {
            "active": false,
            "fixed": true,
            "requested": false
        },
        "tx-checksum-sctp": {
            "active": false,
            "fixed": true,
            "requested": false
        },
        "scatter-gather": {
            "active": false,
            "fixed": null,
            "requested": null
        },
        "tx-scatter-gather": {
            "active": false,
            "fixed": true,
            "requested": false
        },

...skip similar lines...

v2:
 - formatting fixes
 - show each feature as object with available attributes

v3:
 - report "fixed" and "requested" as nil for the special features

Signed-off-by: Denys Fedoryshchenko <denys.f@collabora.com>
2 files changed