From: Donald Hunter <donald.hunter@gmail.com>
To: netdev@vger.kernel.org, Jakub Kicinski <kuba@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>, Jonathan Corbet <corbet@lwn.net>,
linux-doc@vger.kernel.org
Cc: donald.hunter@redhat.com, Donald Hunter <donald.hunter@gmail.com>
Subject: [PATCH net-next v5 5/7] netlink: specs: add partial specification for openvswitch
Date: Mon, 27 Mar 2023 09:31:36 +0100 [thread overview]
Message-ID: <20230327083138.96044-6-donald.hunter@gmail.com> (raw)
In-Reply-To: <20230327083138.96044-1-donald.hunter@gmail.com>
The openvswitch family has a fixed header, uses struct attrs and has array
values. This partial spec demonstrates these features in the YNL CLI. These
specs are sufficient to create, delete and dump datapaths and to dump vports:
$ ./tools/net/ynl/cli.py \
--spec Documentation/netlink/specs/ovs_datapath.yaml \
--do dp-new --json '{ "dp-ifindex": 0, "name": "demo", "upcall-pid": 0}'
None
$ ./tools/net/ynl/cli.py \
--spec Documentation/netlink/specs/ovs_datapath.yaml \
--dump dp-get --json '{ "dp-ifindex": 0 }'
[{'dp-ifindex': 3,
'masks-cache-size': 256,
'megaflow-stats': {'cache-hits': 0,
'mask-hit': 0,
'masks': 0,
'pad1': 0,
'padding': 0},
'name': 'test',
'stats': {'flows': 0, 'hit': 0, 'lost': 0, 'missed': 0},
'user-features': {'dispatch-upcall-per-cpu',
'tc-recirc-sharing',
'unaligned'}},
{'dp-ifindex': 48,
'masks-cache-size': 256,
'megaflow-stats': {'cache-hits': 0,
'mask-hit': 0,
'masks': 0,
'pad1': 0,
'padding': 0},
'name': 'demo',
'stats': {'flows': 0, 'hit': 0, 'lost': 0, 'missed': 0},
'user-features': set()}]
$ ./tools/net/ynl/cli.py \
--spec Documentation/netlink/specs/ovs_datapath.yaml \
--do dp-del --json '{ "dp-ifindex": 0, "name": "demo"}'
None
$ ./tools/net/ynl/cli.py \
--spec Documentation/netlink/specs/ovs_vport.yaml \
--dump vport-get --json '{ "dp-ifindex": 3 }'
[{'dp-ifindex': 3,
'ifindex': 3,
'name': 'test',
'port-no': 0,
'stats': {'rx-bytes': 0,
'rx-dropped': 0,
'rx-errors': 0,
'rx-packets': 0,
'tx-bytes': 0,
'tx-dropped': 0,
'tx-errors': 0,
'tx-packets': 0},
'type': 'internal',
'upcall-pid': [0],
'upcall-stats': {'fail': 0, 'success': 0}}]
Signed-off-by: Donald Hunter <donald.hunter@gmail.com>
---
Documentation/netlink/specs/ovs_datapath.yaml | 153 ++++++++++++++++++
Documentation/netlink/specs/ovs_vport.yaml | 139 ++++++++++++++++
2 files changed, 292 insertions(+)
create mode 100644 Documentation/netlink/specs/ovs_datapath.yaml
create mode 100644 Documentation/netlink/specs/ovs_vport.yaml
diff --git a/Documentation/netlink/specs/ovs_datapath.yaml b/Documentation/netlink/specs/ovs_datapath.yaml
new file mode 100644
index 000000000000..6d71db8c4416
--- /dev/null
+++ b/Documentation/netlink/specs/ovs_datapath.yaml
@@ -0,0 +1,153 @@
+# SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)
+
+name: ovs_datapath
+version: 2
+protocol: genetlink-legacy
+
+doc:
+ OVS datapath configuration over generic netlink.
+
+definitions:
+ -
+ name: ovs-header
+ type: struct
+ members:
+ -
+ name: dp-ifindex
+ type: u32
+ -
+ name: user-features
+ type: flags
+ entries:
+ -
+ name: unaligned
+ doc: Allow last Netlink attribute to be unaligned
+ -
+ name: vport-pids
+ doc: Allow datapath to associate multiple Netlink PIDs to each vport
+ -
+ name: tc-recirc-sharing
+ doc: Allow tc offload recirc sharing
+ -
+ name: dispatch-upcall-per-cpu
+ doc: Allow per-cpu dispatch of upcalls
+ -
+ name: datapath-stats
+ type: struct
+ members:
+ -
+ name: hit
+ type: u64
+ -
+ name: missed
+ type: u64
+ -
+ name: lost
+ type: u64
+ -
+ name: flows
+ type: u64
+ -
+ name: megaflow-stats
+ type: struct
+ members:
+ -
+ name: mask-hit
+ type: u64
+ -
+ name: masks
+ type: u32
+ -
+ name: padding
+ type: u32
+ -
+ name: cache-hits
+ type: u64
+ -
+ name: pad1
+ type: u64
+
+attribute-sets:
+ -
+ name: datapath
+ attributes:
+ -
+ name: name
+ type: string
+ -
+ name: upcall-pid
+ doc: upcall pid
+ type: u32
+ -
+ name: stats
+ type: binary
+ struct: datapath-stats
+ -
+ name: megaflow-stats
+ type: binary
+ struct: megaflow-stats
+ -
+ name: user-features
+ type: u32
+ enum: user-features
+ enum-as-flags: true
+ -
+ name: pad
+ type: unused
+ -
+ name: masks-cache-size
+ type: u32
+ -
+ name: per-cpu-pids
+ type: binary
+ sub-type: u32
+
+operations:
+ fixed-header: ovs-header
+ list:
+ -
+ name: dp-get
+ doc: Get / dump OVS data path configuration and state
+ value: 3
+ attribute-set: datapath
+ do: &dp-get-op
+ request:
+ attributes:
+ - name
+ reply:
+ attributes:
+ - name
+ - upcall-pid
+ - stats
+ - megaflow-stats
+ - user-features
+ - masks-cache-size
+ - per-cpu-pids
+ dump: *dp-get-op
+ -
+ name: dp-new
+ doc: Create new OVS data path
+ value: 1
+ attribute-set: datapath
+ do:
+ request:
+ attributes:
+ - dp-ifindex
+ - name
+ - upcall-pid
+ - user-features
+ -
+ name: dp-del
+ doc: Delete existing OVS data path
+ value: 2
+ attribute-set: datapath
+ do:
+ request:
+ attributes:
+ - dp-ifindex
+ - name
+
+mcast-groups:
+ list:
+ -
+ name: ovs_datapath
diff --git a/Documentation/netlink/specs/ovs_vport.yaml b/Documentation/netlink/specs/ovs_vport.yaml
new file mode 100644
index 000000000000..8e55622ddf11
--- /dev/null
+++ b/Documentation/netlink/specs/ovs_vport.yaml
@@ -0,0 +1,139 @@
+# SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)
+
+name: ovs_vport
+version: 2
+protocol: genetlink-legacy
+
+doc:
+ OVS vport configuration over generic netlink.
+
+definitions:
+ -
+ name: ovs-header
+ type: struct
+ members:
+ -
+ name: dp-ifindex
+ type: u32
+ -
+ name: vport-type
+ type: enum
+ entries: [ unspec, netdev, internal, gre, vxlan, geneve ]
+ -
+ name: vport-stats
+ type: struct
+ members:
+ -
+ name: rx-packets
+ type: u64
+ -
+ name: tx-packets
+ type: u64
+ -
+ name: rx-bytes
+ type: u64
+ -
+ name: tx-bytes
+ type: u64
+ -
+ name: rx-errors
+ type: u64
+ -
+ name: tx-errors
+ type: u64
+ -
+ name: rx-dropped
+ type: u64
+ -
+ name: tx-dropped
+ type: u64
+
+attribute-sets:
+ -
+ name: vport-options
+ attributes:
+ -
+ name: dst-port
+ type: u32
+ -
+ name: extension
+ type: u32
+ -
+ name: upcall-stats
+ attributes:
+ -
+ name: success
+ type: u64
+ value: 0
+ -
+ name: fail
+ type: u64
+ -
+ name: vport
+ attributes:
+ -
+ name: port-no
+ type: u32
+ -
+ name: type
+ type: u32
+ enum: vport-type
+ -
+ name: name
+ type: string
+ -
+ name: options
+ type: nest
+ nested-attributes: vport-options
+ -
+ name: upcall-pid
+ type: binary
+ sub-type: u32
+ -
+ name: stats
+ type: binary
+ struct: vport-stats
+ -
+ name: pad
+ type: unused
+ -
+ name: ifindex
+ type: u32
+ -
+ name: netnsid
+ type: u32
+ -
+ name: upcall-stats
+ type: nest
+ nested-attributes: upcall-stats
+
+operations:
+ list:
+ -
+ name: vport-get
+ doc: Get / dump OVS vport configuration and state
+ value: 3
+ attribute-set: vport
+ fixed-header: ovs-header
+ do: &vport-get-op
+ request:
+ attributes:
+ - dp-ifindex
+ - name
+ reply: &dev-all
+ attributes:
+ - dp-ifindex
+ - port-no
+ - type
+ - name
+ - upcall-pid
+ - stats
+ - ifindex
+ - netnsid
+ - upcall-stats
+ dump: *vport-get-op
+
+mcast-groups:
+ list:
+ -
+ name: ovs_vport
--
2.39.0
next prev parent reply other threads:[~2023-03-27 8:38 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-27 8:31 [PATCH net-next v5 0/7] ynl: add support for user headers and struct attrs Donald Hunter
2023-03-27 8:31 ` [PATCH net-next v5 1/7] tools: ynl: Add struct parsing to nlspec Donald Hunter
2023-03-27 8:31 ` [PATCH net-next v5 2/7] tools: ynl: Add C array attribute decoding to ynl Donald Hunter
2023-03-27 8:31 ` [PATCH net-next v5 3/7] tools: ynl: Add struct attr " Donald Hunter
2023-03-27 8:31 ` [PATCH net-next v5 4/7] tools: ynl: Add fixed-header support " Donald Hunter
2023-03-27 8:31 ` Donald Hunter [this message]
2023-03-27 8:31 ` [PATCH net-next v5 6/7] docs: netlink: document struct support for genetlink-legacy Donald Hunter
2023-03-27 12:44 ` Bagas Sanjaya
2023-03-27 14:39 ` Akira Yokosawa
2023-03-28 8:38 ` Bagas Sanjaya
2023-03-27 8:31 ` [PATCH net-next v5 7/7] docs: netlink: document the sub-type attribute property Donald Hunter
2023-03-27 12:45 ` Bagas Sanjaya
2023-03-29 7:00 ` [PATCH net-next v5 0/7] ynl: add support for user headers and struct attrs patchwork-bot+netdevbpf
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=20230327083138.96044-6-donald.hunter@gmail.com \
--to=donald.hunter@gmail.com \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=donald.hunter@redhat.com \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-doc@vger.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).