From: Stanislav Fomichev <sdf@google.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, Stanislav Fomichev <sdf@google.com>
Subject: [PATCH net-next 1/4] ynl: support be16 in schemas
Date: Fri, 17 Mar 2023 17:23:37 -0700 [thread overview]
Message-ID: <20230318002340.1306356-2-sdf@google.com> (raw)
In-Reply-To: <20230318002340.1306356-1-sdf@google.com>
Used by ethtool spec.
Signed-off-by: Stanislav Fomichev <sdf@google.com>
---
Documentation/netlink/genetlink-c.yaml | 2 +-
Documentation/netlink/genetlink-legacy.yaml | 4 ++--
Documentation/netlink/genetlink.yaml | 2 +-
tools/net/ynl/lib/ynl.py | 7 +++++++
4 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/Documentation/netlink/genetlink-c.yaml b/Documentation/netlink/genetlink-c.yaml
index 8e8c17b0a6c6..1b057fc9326c 100644
--- a/Documentation/netlink/genetlink-c.yaml
+++ b/Documentation/netlink/genetlink-c.yaml
@@ -148,7 +148,7 @@ additionalProperties: False
name:
type: string
type: &attr-type
- enum: [ unused, pad, flag, binary, u8, u16, u32, u64, s32, s64,
+ enum: [ unused, pad, flag, binary, u8, u16, be16, u32, u64, s32, s64,
string, nest, array-nest, nest-type-value ]
doc:
description: Documentation of the attribute.
diff --git a/Documentation/netlink/genetlink-legacy.yaml b/Documentation/netlink/genetlink-legacy.yaml
index 5dc6f1c07a97..3796d8be9045 100644
--- a/Documentation/netlink/genetlink-legacy.yaml
+++ b/Documentation/netlink/genetlink-legacy.yaml
@@ -119,7 +119,7 @@ additionalProperties: False
name:
type: string
type:
- enum: [ u8, u16, u32, u64, s8, s16, s32, s64, string ]
+ enum: [ u8, u16, be16, u32, u64, s8, s16, s32, s64, string ]
len:
$ref: '#/$defs/len-or-define'
# End genetlink-legacy
@@ -171,7 +171,7 @@ additionalProperties: False
name:
type: string
type: &attr-type
- enum: [ unused, pad, flag, binary, u8, u16, u32, u64, s32, s64,
+ enum: [ unused, pad, flag, binary, u8, u16, be16, u32, u64, s32, s64,
string, nest, array-nest, nest-type-value ]
doc:
description: Documentation of the attribute.
diff --git a/Documentation/netlink/genetlink.yaml b/Documentation/netlink/genetlink.yaml
index d8b2cdeba058..a143221c3d2e 100644
--- a/Documentation/netlink/genetlink.yaml
+++ b/Documentation/netlink/genetlink.yaml
@@ -121,7 +121,7 @@ additionalProperties: False
name:
type: string
type: &attr-type
- enum: [ unused, pad, flag, binary, u8, u16, u32, u64, s32, s64,
+ enum: [ unused, pad, flag, binary, u8, u16, be16, u32, u64, s32, s64,
string, nest, array-nest, nest-type-value ]
doc:
description: Documentation of the attribute.
diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py
index 90764a83c646..21c015911803 100644
--- a/tools/net/ynl/lib/ynl.py
+++ b/tools/net/ynl/lib/ynl.py
@@ -81,6 +81,9 @@ from .nlspec import SpecFamily
def as_u16(self):
return struct.unpack("H", self.raw)[0]
+ def as_be16(self):
+ return struct.unpack(">H", self.raw)[0]
+
def as_u32(self):
return struct.unpack("I", self.raw)[0]
@@ -334,6 +337,8 @@ genl_family_name_to_id = None
attr_payload += self._add_attr(attr['nested-attributes'], subname, subvalue)
elif attr["type"] == 'flag':
attr_payload = b''
+ elif attr["type"] == 'be16':
+ attr_payload = struct.pack(">H", int(value))
elif attr["type"] == 'u32':
attr_payload = struct.pack("I", int(value))
elif attr["type"] == 'string':
@@ -371,6 +376,8 @@ genl_family_name_to_id = None
decoded = subdict
elif attr_spec['type'] == 'u8':
decoded = attr.as_u8()
+ elif attr_spec['type'] == 'be16':
+ decoded = attr.as_be16()
elif attr_spec['type'] == 'u32':
decoded = attr.as_u32()
elif attr_spec['type'] == 'u64':
--
2.40.0.rc1.284.g88254d51c5-goog
next prev parent reply other threads:[~2023-03-18 0:23 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-18 0:23 [PATCH net-next 0/4] ynl: fill in some gaps of ethtool spec Stanislav Fomichev
2023-03-18 0:23 ` Stanislav Fomichev [this message]
2023-03-18 4:18 ` [PATCH net-next 1/4] ynl: support be16 in schemas Jakub Kicinski
2023-03-20 18:03 ` Stanislav Fomichev
2023-03-18 0:23 ` [PATCH net-next 2/4] ynl: populate most of the ethtool spec Stanislav Fomichev
2023-03-18 4:33 ` Jakub Kicinski
2023-03-20 18:03 ` Stanislav Fomichev
2023-03-20 18:59 ` Jakub Kicinski
2023-03-18 0:23 ` [PATCH net-next 3/4] ynl: replace print with NlError Stanislav Fomichev
2023-03-18 4:21 ` Jakub Kicinski
2023-03-20 18:03 ` Stanislav Fomichev
2023-03-20 18:53 ` Jakub Kicinski
2023-03-18 0:23 ` [PATCH net-next 4/4] ynl: ethtool testing tool Stanislav Fomichev
2023-03-18 4:23 ` Jakub Kicinski
2023-03-20 18:03 ` Stanislav Fomichev
2023-03-18 4:24 ` 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=20230318002340.1306356-2-sdf@google.com \
--to=sdf@google.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/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).