Commit 4fb56e3e authored by Jakub Kicinski's avatar Jakub Kicinski

Merge branch 'devlink-finish-conversion-to-generated-split_ops'

Jiri Pirko says:

====================
devlink: finish conversion to generated split_ops

This patchset converts the remaining genetlink commands to generated
split_ops and removes the existing small_ops arrays entirely
alongside with shared netlink attribute policy.

Patches #1-#6 are just small preparations and small fixes on multiple
              places. Note that couple of patches contain the "Fixes"
              tag but no need to put them into -net tree.
Patch #7 is a simple rename preparation
Patch #8 is the main one in this set and adds actual definitions of cmds
         in to yaml file.
Patches #9-#10 finalize the change removing bits that are no longer in
               use.
====================

Link: https://lore.kernel.org/r/20231021112711.660606-1-jiri@resnulli.usSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 70b1aca3 cebe7306
......@@ -192,7 +192,7 @@ properties:
type: string
type: &attr-type
description: The netlink attribute type
enum: [ unused, pad, flag, binary,
enum: [ unused, pad, flag, binary, bitfield32,
uint, sint, u8, u16, u32, u64, s32, s64,
string, nest, array-nest, nest-type-value ]
doc:
......
......@@ -15,6 +15,161 @@ definitions:
name: ingress
-
name: egress
-
type: enum
name: port-type
entries:
-
name: notset
-
name: auto
-
name: eth
-
name: ib
-
type: enum
name: port-flavour
entries:
-
name: physical
-
name: cpu
-
name: dsa
-
name: pci_pf
-
name: pci_vf
-
name: virtual
-
name: unused
-
name: pci_sf
-
type: enum
name: port-fn-state
entries:
-
name: inactive
-
name: active
-
type: enum
name: port-fn-opstate
entries:
-
name: detached
-
name: attached
-
type: enum
name: port-fn-attr-cap
entries:
-
name: roce-bit
-
name: migratable-bit
-
type: enum
name: sb-threshold-type
entries:
-
name: static
-
name: dynamic
-
type: enum
name: eswitch-mode
entries:
-
name: legacy
-
name: switchdev
-
type: enum
name: eswitch-inline-mode
entries:
-
name: none
-
name: link
-
name: network
-
name: transport
-
type: enum
name: eswitch-encap-mode
entries:
-
name: none
-
name: basic
-
type: enum
name: dpipe-match-type
entries:
-
name: field-exact
-
type: enum
name: dpipe-action-type
entries:
-
name: field-modify
-
type: enum
name: dpipe-field-mapping-type
entries:
-
name: none
-
name: ifindex
-
type: enum
name: resource-unit
entries:
-
name: entry
-
type: enum
name: reload-action
entries:
-
name: driver-reinit
value: 1
-
name: fw-activate
-
type: enum
name: param-cmode
entries:
-
name: runtime
-
name: driverinit
-
name: permanent
-
type: enum
name: flash-overwrite
entries:
-
name: settings-bit
-
name: identifiers-bit
-
type: enum
name: trap-action
entries:
-
name: drop
-
name: trap
-
name: mirror
attribute-sets:
-
......@@ -31,6 +186,17 @@ attribute-sets:
-
name: port-index
type: u32
-
name: port-type
type: u16
enum: port-type
# TODO: fill in the attributes in between
-
name: port-split-count
type: u32
value: 9
# TODO: fill in the attributes in between
......@@ -45,18 +211,224 @@ attribute-sets:
name: sb-pool-index
type: u16
value: 17
-
name: sb-pool-type
type: u8
enum: sb-pool-type
-
name: sb-pool-size
type: u32
-
name: sb-pool-threshold-type
type: u8
enum: sb-threshold-type
-
name: sb-threshold
type: u32
-
name: sb-tc-index
type: u16
value: 22
# TODO: fill in the attributes in between
-
name: sb-tc-index
name: eswitch-mode
type: u16
value: 22
value: 25
enum: eswitch-mode
-
name: eswitch-inline-mode
type: u16
enum: eswitch-inline-mode
-
name: dpipe-tables
type: nest
nested-attributes: dl-dpipe-tables
-
name: dpipe-table
type: nest
multi-attr: true
nested-attributes: dl-dpipe-table
-
name: dpipe-table-name
type: string
-
name: dpipe-table-size
type: u64
-
name: dpipe-table-matches
type: nest
nested-attributes: dl-dpipe-table-matches
-
name: dpipe-table-actions
type: nest
nested-attributes: dl-dpipe-table-actions
-
name: dpipe-table-counters-enabled
type: u8
-
name: dpipe-entries
type: nest
nested-attributes: dl-dpipe-entries
-
name: dpipe-entry
type: nest
multi-attr: true
nested-attributes: dl-dpipe-entry
-
name: dpipe-entry-index
type: u64
-
name: dpipe-entry-match-values
type: nest
nested-attributes: dl-dpipe-entry-match-values
-
name: dpipe-entry-action-values
type: nest
nested-attributes: dl-dpipe-entry-action-values
-
name: dpipe-entry-counter
type: u64
-
name: dpipe-match
type: nest
multi-attr: true
nested-attributes: dl-dpipe-match
-
name: dpipe-match-value
type: nest
multi-attr: true
nested-attributes: dl-dpipe-match-value
-
name: dpipe-match-type
type: u32
enum: dpipe-match-type
-
name: dpipe-action
type: nest
multi-attr: true
nested-attributes: dl-dpipe-action
-
name: dpipe-action-value
type: nest
multi-attr: true
nested-attributes: dl-dpipe-action-value
-
name: dpipe-action-type
type: u32
enum: dpipe-action-type
-
name: dpipe-value
type: binary
-
name: dpipe-value-mask
type: binary
-
name: dpipe-value-mapping
type: u32
-
name: dpipe-headers
type: nest
nested-attributes: dl-dpipe-headers
-
name: dpipe-header
type: nest
multi-attr: true
nested-attributes: dl-dpipe-header
-
name: dpipe-header-name
type: string
-
name: dpipe-header-id
type: u32
-
name: dpipe-header-fields
type: nest
nested-attributes: dl-dpipe-header-fields
-
name: dpipe-header-global
type: u8
-
name: dpipe-header-index
type: u32
-
name: dpipe-field
type: nest
multi-attr: true
nested-attributes: dl-dpipe-field
-
name: dpipe-field-name
type: string
-
name: dpipe-field-id
type: u32
-
name: dpipe-field-bitwidth
type: u32
-
name: dpipe-field-mapping-type
type: u32
enum: dpipe-field-mapping-type
-
name: pad
type: pad
-
name: eswitch-encap-mode
type: u8
value: 62
enum: eswitch-encap-mode
-
name: resource-list
type: nest
nested-attributes: dl-resource-list
-
name: resource
type: nest
multi-attr: true
nested-attributes: dl-resource
-
name: resource-name
type: string
-
name: resource-id
type: u64
-
name: resource-size
type: u64
-
name: resource-size-new
type: u64
-
name: resource-size-valid
type: u8
-
name: resource-size-min
type: u64
-
name: resource-size-max
type: u64
-
name: resource-size-gran
type: u64
-
name: resource-unit
type: u8
enum: resource-unit
-
name: resource-occ
type: u64
-
name: dpipe-table-resource-id
type: u64
-
name: dpipe-table-resource-units
type: u64
-
name: port-flavour
type: u16
enum: port-flavour
# TODO: fill in the attributes in between
......@@ -67,17 +439,41 @@ attribute-sets:
# TODO: fill in the attributes in between
-
name: param-type
type: u8
value: 83
# TODO: fill in the attributes in between
-
name: param-value-cmode
type: u8
enum: param-cmode
value: 87
-
name: region-name
type: string
value: 88
# TODO: fill in the attributes in between
-
name: region-snapshot-id
type: u32
value: 92
# TODO: fill in the attributes in between
-
name: region-chunk-addr
type: u64
value: 96
-
name: region-chunk-len
type: u64
-
name: info-driver-name
type: string
value: 98
-
name: info-serial-number
type: string
......@@ -105,6 +501,29 @@ attribute-sets:
# TODO: fill in the attributes in between
-
name: fmsg
type: nest
nested-attributes: dl-fmsg
value: 106
-
name: fmsg-obj-nest-start
type: flag
-
name: fmsg-pair-nest-start
type: flag
-
name: fmsg-arr-nest-start
type: flag
-
name: fmsg-nest-end
type: flag
-
name: fmsg-obj-name
type: string
# TODO: fill in the attributes in between
-
name: health-reporter-name
type: string
......@@ -112,10 +531,37 @@ attribute-sets:
# TODO: fill in the attributes in between
-
name: health-reporter-graceful-period
type: u64
value: 120
-
name: health-reporter-auto-recover
type: u8
-
name: flash-update-file-name
type: string
-
name: flash-update-component
type: string
# TODO: fill in the attributes in between
-
name: port-pci-pf-number
type: u16
value: 127
# TODO: fill in the attributes in between
-
name: trap-name
type: string
value: 130
-
name: trap-action
type: u8
enum: trap-action
# TODO: fill in the attributes in between
......@@ -131,23 +577,68 @@ attribute-sets:
# TODO: fill in the attributes in between
-
name: trap-policer-id
name: netns-fd
type: u32
value: 138
-
name: netns-pid
type: u32
-
name: netns-id
type: u32
value: 142
# TODO: fill in the attributes in between
-
name: reload-action
name: health-reporter-auto-dump
type: u8
value: 153
value: 141
-
name: trap-policer-id
type: u32
-
name: trap-policer-rate
type: u64
-
name: trap-policer-burst
type: u64
-
name: port-function
type: nest
nested-attributes: dl-port-function
# TODO: fill in the attributes in between
-
name: port-controller-number
type: u32
value: 150
# TODO: fill in the attributes in between
-
name: flash-update-overwrite-mask
type: bitfield32
enum: flash-overwrite
enum-as-flags: True
value: 152
-
name: reload-action
type: u8
enum: reload-action
-
name: reload-actions-performed
type: bitfield32
enum: reload-action
enum-as-flags: True
-
name: reload-limits
type: bitfield32
enum: reload-action
enum-as-flags: True
-
name: dev-stats
type: nest
value: 156
nested-attributes: dl-dev-stats
-
name: reload-stats
......@@ -181,10 +672,26 @@ attribute-sets:
# TODO: fill in the attributes in between
-
name: port-pci-sf-number
type: u32
value: 164
# TODO: fill in the attributes in between
-
name: rate-tx-share
type: u64
value: 166
-
name: rate-tx-max
type: u64
-
name: rate-node-name
type: string
value: 168
-
name: rate-parent-node-name
type: string
# TODO: fill in the attributes in between
......@@ -193,6 +700,30 @@ attribute-sets:
type: u32
value: 171
# TODO: fill in the attributes in between
-
name: linecard-type
type: string
value: 173
# TODO: fill in the attributes in between
-
name: selftests
type: nest
value: 176
nested-attributes: dl-selftest-id
-
name: rate-tx-priority
type: u32
-
name: rate-tx-weight
type: u32
-
name: region-direct
type: flag
-
name: dl-dev-stats
subset-of: devlink
......@@ -237,6 +768,261 @@ attribute-sets:
name: info-version-name
-
name: info-version-value
-
name: dl-port-function
name-prefix: devlink-port-fn-attr-
attr-max-name: devlink-port-function-attr-max
attributes:
-
name-prefix: devlink-port-function-attr-
name: hw-addr
type: binary
value: 1
-
name: state
type: u8
enum: port-fn-state
-
name: opstate
type: u8
enum: port-fn-opstate
-
name: caps
type: bitfield32
enum: port-fn-attr-cap
enum-as-flags: True
-
name: dl-dpipe-tables
subset-of: devlink
attributes:
-
name: dpipe-table
-
name: dl-dpipe-table
subset-of: devlink
attributes:
-
name: dpipe-table-name
-
name: dpipe-table-size
-
name: dpipe-table-name
-
name: dpipe-table-size
-
name: dpipe-table-matches
-
name: dpipe-table-actions
-
name: dpipe-table-counters-enabled
-
name: dpipe-table-resource-id
-
name: dpipe-table-resource-units
-
name: dl-dpipe-table-matches
subset-of: devlink
attributes:
-
name: dpipe-match
-
name: dl-dpipe-table-actions
subset-of: devlink
attributes:
-
name: dpipe-action
-
name: dl-dpipe-entries
subset-of: devlink
attributes:
-
name: dpipe-entry
-
name: dl-dpipe-entry
subset-of: devlink
attributes:
-
name: dpipe-entry-index
-
name: dpipe-entry-match-values
-
name: dpipe-entry-action-values
-
name: dpipe-entry-counter
-
name: dl-dpipe-entry-match-values
subset-of: devlink
attributes:
-
name: dpipe-match-value
-
name: dl-dpipe-entry-action-values
subset-of: devlink
attributes:
-
name: dpipe-action-value
-
name: dl-dpipe-match
subset-of: devlink
attributes:
-
name: dpipe-match-type
-
name: dpipe-header-id
-
name: dpipe-header-global
-
name: dpipe-header-index
-
name: dpipe-field-id
-
name: dl-dpipe-match-value
subset-of: devlink
attributes:
-
name: dpipe-match
-
name: dpipe-value
-
name: dpipe-value-mask
-
name: dpipe-value-mapping
-
name: dl-dpipe-action
subset-of: devlink
attributes:
-
name: dpipe-action-type
-
name: dpipe-header-id
-
name: dpipe-header-global
-
name: dpipe-header-index
-
name: dpipe-field-id
-
name: dl-dpipe-action-value
subset-of: devlink
attributes:
-
name: dpipe-action
-
name: dpipe-value
-
name: dpipe-value-mask
-
name: dpipe-value-mapping
-
name: dl-dpipe-headers
subset-of: devlink
attributes:
-
name: dpipe-header
-
name: dl-dpipe-header
subset-of: devlink
attributes:
-
name: dpipe-header-name
-
name: dpipe-header-id
-
name: dpipe-header-global
-
name: dpipe-header-fields
-
name: dl-dpipe-header-fields
subset-of: devlink
attributes:
-
name: dpipe-field
-
name: dl-dpipe-field
subset-of: devlink
attributes:
-
name: dpipe-field-name
-
name: dpipe-field-id
-
name: dpipe-field-bitwidth
-
name: dpipe-field-mapping-type
-
name: dl-resource
subset-of: devlink
attributes:
# -
# name: resource-list
# This is currently unsupported due to circular dependency
-
name: resource-name
-
name: resource-id
-
name: resource-size
-
name: resource-size-new
-
name: resource-size-valid
-
name: resource-size-min
-
name: resource-size-max
-
name: resource-size-gran
-
name: resource-unit
-
name: resource-occ
-
name: dl-resource-list
subset-of: devlink
attributes:
-
name: resource
-
name: dl-fmsg
subset-of: devlink
attributes:
-
name: fmsg-obj-nest-start
-
name: fmsg-pair-nest-start
-
name: fmsg-arr-nest-start
-
name: fmsg-nest-end
-
name: fmsg-obj-name
-
name: dl-selftest-id
name-prefix: devlink-attr-selftest-id-
attributes:
-
name: flash
type: flag
operations:
enum-model: directional
......@@ -245,10 +1031,7 @@ operations:
name: get
doc: Get devlink instances.
attribute-set: devlink
dont-validate:
- strict
- dump
dont-validate: [ strict, dump ]
do:
pre: devlink-nl-pre-doit
post: devlink-nl-post-doit
......@@ -263,7 +1046,6 @@ operations:
- bus-name
- dev-name
- reload-failed
- reload-action
- dev-stats
dump:
reply: *get-reply
......@@ -272,9 +1054,7 @@ operations:
name: port-get
doc: Get devlink port instances.
attribute-set: devlink
dont-validate:
- strict
dont-validate: [ strict ]
do:
pre: devlink-nl-pre-doit-port
post: devlink-nl-post-doit
......@@ -293,16 +1073,90 @@ operations:
reply:
value: 3 # due to a bug, port dump returns DEVLINK_CMD_NEW
attributes: *port-id-attrs
-
name: port-set
doc: Set devlink port instances.
attribute-set: devlink
dont-validate: [ strict ]
flags: [ admin-perm ]
do:
pre: devlink-nl-pre-doit-port
post: devlink-nl-post-doit
request:
attributes:
- bus-name
- dev-name
- port-index
- port-type
- port-function
-
name: port-new
doc: Create devlink port instances.
attribute-set: devlink
dont-validate: [ strict ]
flags: [ admin-perm ]
do:
pre: devlink-nl-pre-doit
post: devlink-nl-post-doit
request:
attributes:
- bus-name
- dev-name
- port-index
- port-flavour
- port-pci-pf-number
- port-pci-sf-number
- port-controller-number
reply:
value: 7
attributes: *port-id-attrs
-
name: port-del
doc: Delete devlink port instances.
attribute-set: devlink
dont-validate: [ strict ]
flags: [ admin-perm ]
do:
pre: devlink-nl-pre-doit-port
post: devlink-nl-post-doit
request:
attributes: *port-id-attrs
-
name: port-split
doc: Split devlink port instances.
attribute-set: devlink
dont-validate: [ strict ]
flags: [ admin-perm ]
do:
pre: devlink-nl-pre-doit-port
post: devlink-nl-post-doit
request:
attributes:
- bus-name
- dev-name
- port-index
- port-split-count
# TODO: fill in the operations in between
-
name: port-unsplit
doc: Unplit devlink port instances.
attribute-set: devlink
dont-validate: [ strict ]
flags: [ admin-perm ]
do:
pre: devlink-nl-pre-doit-port
post: devlink-nl-post-doit
request:
attributes: *port-id-attrs
-
name: sb-get
doc: Get shared buffer instances.
attribute-set: devlink
dont-validate:
- strict
dont-validate: [ strict ]
do:
pre: devlink-nl-pre-doit
post: devlink-nl-post-doit
......@@ -320,15 +1174,11 @@ operations:
attributes: *dev-id-attrs
reply: *sb-get-reply
# TODO: fill in the operations in between
-
name: sb-pool-get
doc: Get shared buffer pool instances.
attribute-set: devlink
dont-validate:
- strict
dont-validate: [ strict ]
do:
pre: devlink-nl-pre-doit
post: devlink-nl-post-doit
......@@ -347,15 +1197,29 @@ operations:
attributes: *dev-id-attrs
reply: *sb-pool-get-reply
# TODO: fill in the operations in between
-
name: sb-pool-set
doc: Set shared buffer pool instances.
attribute-set: devlink
dont-validate: [ strict ]
flags: [ admin-perm ]
do:
pre: devlink-nl-pre-doit
post: devlink-nl-post-doit
request:
attributes:
- bus-name
- dev-name
- sb-index
- sb-pool-index
- sb-pool-threshold-type
- sb-pool-size
-
name: sb-port-pool-get
doc: Get shared buffer port-pool combinations and threshold.
attribute-set: devlink
dont-validate:
- strict
dont-validate: [ strict ]
do:
pre: devlink-nl-pre-doit-port
post: devlink-nl-post-doit
......@@ -364,81 +1228,318 @@ operations:
attributes: &sb-port-pool-id-attrs
- bus-name
- dev-name
- port-index
- sb-index
- sb-pool-index
reply: &sb-port-pool-get-reply
value: 21
attributes: *sb-port-pool-id-attrs
dump:
request:
attributes: *dev-id-attrs
reply: *sb-port-pool-get-reply
# TODO: fill in the operations in between
- port-index
- sb-index
- sb-pool-index
reply: &sb-port-pool-get-reply
value: 21
attributes: *sb-port-pool-id-attrs
dump:
request:
attributes: *dev-id-attrs
reply: *sb-port-pool-get-reply
-
name: sb-port-pool-set
doc: Set shared buffer port-pool combinations and threshold.
attribute-set: devlink
dont-validate: [ strict ]
flags: [ admin-perm ]
do:
pre: devlink-nl-pre-doit-port
post: devlink-nl-post-doit
request:
attributes:
- bus-name
- dev-name
- port-index
- sb-index
- sb-pool-index
- sb-threshold
-
name: sb-tc-pool-bind-get
doc: Get shared buffer port-TC to pool bindings and threshold.
attribute-set: devlink
dont-validate: [ strict ]
do:
pre: devlink-nl-pre-doit-port
post: devlink-nl-post-doit
request:
value: 23
attributes: &sb-tc-pool-bind-id-attrs
- bus-name
- dev-name
- port-index
- sb-index
- sb-pool-type
- sb-tc-index
reply: &sb-tc-pool-bind-get-reply
value: 25
attributes: *sb-tc-pool-bind-id-attrs
dump:
request:
attributes: *dev-id-attrs
reply: *sb-tc-pool-bind-get-reply
-
name: sb-tc-pool-bind-set
doc: Set shared buffer port-TC to pool bindings and threshold.
attribute-set: devlink
dont-validate: [ strict ]
flags: [ admin-perm ]
do:
pre: devlink-nl-pre-doit-port
post: devlink-nl-post-doit
request:
attributes:
- bus-name
- dev-name
- port-index
- sb-index
- sb-pool-index
- sb-pool-type
- sb-tc-index
- sb-threshold
-
name: sb-occ-snapshot
doc: Take occupancy snapshot of shared buffer.
attribute-set: devlink
dont-validate: [ strict ]
flags: [ admin-perm ]
do:
pre: devlink-nl-pre-doit
post: devlink-nl-post-doit
request:
value: 27
attributes:
- bus-name
- dev-name
- sb-index
-
name: sb-occ-max-clear
doc: Clear occupancy watermarks of shared buffer.
attribute-set: devlink
dont-validate: [ strict ]
flags: [ admin-perm ]
do:
pre: devlink-nl-pre-doit
post: devlink-nl-post-doit
request:
attributes:
- bus-name
- dev-name
- sb-index
-
name: eswitch-get
doc: Get eswitch attributes.
attribute-set: devlink
dont-validate: [ strict ]
flags: [ admin-perm ]
do:
pre: devlink-nl-pre-doit
post: devlink-nl-post-doit
request:
attributes: *dev-id-attrs
reply:
value: 29
attributes: &eswitch-attrs
- bus-name
- dev-name
- eswitch-mode
- eswitch-inline-mode
- eswitch-encap-mode
-
name: eswitch-set
doc: Set eswitch attributes.
attribute-set: devlink
dont-validate: [ strict ]
flags: [ admin-perm ]
do:
pre: devlink-nl-pre-doit
post: devlink-nl-post-doit
request:
attributes: *eswitch-attrs
-
name: dpipe-table-get
doc: Get dpipe table attributes.
attribute-set: devlink
dont-validate: [ strict ]
do:
pre: devlink-nl-pre-doit
post: devlink-nl-post-doit
request:
attributes:
- bus-name
- dev-name
- dpipe-table-name
reply:
value: 31
attributes:
- bus-name
- dev-name
- dpipe-tables
-
name: dpipe-entries-get
doc: Get dpipe entries attributes.
attribute-set: devlink
dont-validate: [ strict ]
do:
pre: devlink-nl-pre-doit
post: devlink-nl-post-doit
request:
attributes:
- bus-name
- dev-name
- dpipe-table-name
reply:
attributes:
- bus-name
- dev-name
- dpipe-entries
-
name: dpipe-headers-get
doc: Get dpipe headers attributes.
attribute-set: devlink
dont-validate: [ strict ]
do:
pre: devlink-nl-pre-doit
post: devlink-nl-post-doit
request:
attributes:
- bus-name
- dev-name
reply:
attributes:
- bus-name
- dev-name
- dpipe-headers
-
name: dpipe-table-counters-set
doc: Set dpipe counter attributes.
attribute-set: devlink
dont-validate: [ strict ]
flags: [ admin-perm ]
do:
pre: devlink-nl-pre-doit
post: devlink-nl-post-doit
request:
attributes:
- bus-name
- dev-name
- dpipe-table-name
- dpipe-table-counters-enabled
-
name: resource-set
doc: Set resource attributes.
attribute-set: devlink
dont-validate: [ strict ]
flags: [ admin-perm ]
do:
pre: devlink-nl-pre-doit
post: devlink-nl-post-doit
request:
attributes:
- bus-name
- dev-name
- resource-id
- resource-size
-
name: resource-dump
doc: Get resource attributes.
attribute-set: devlink
dont-validate: [ strict ]
do:
pre: devlink-nl-pre-doit
post: devlink-nl-post-doit
request:
attributes:
- bus-name
- dev-name
reply:
value: 36
attributes:
- bus-name
- dev-name
- resource-list
-
name: sb-tc-pool-bind-get
doc: Get shared buffer port-TC to pool bindings and threshold.
name: reload
doc: Reload devlink.
attribute-set: devlink
dont-validate:
- strict
dont-validate: [ strict ]
flags: [ admin-perm ]
do:
pre: devlink-nl-pre-doit-port
pre: devlink-nl-pre-doit
post: devlink-nl-post-doit
request:
value: 23
attributes: &sb-tc-pool-bind-id-attrs
attributes:
- bus-name
- dev-name
- port-index
- sb-index
- sb-pool-type
- sb-tc-index
reply: &sb-tc-pool-bind-get-reply
value: 25
attributes: *sb-tc-pool-bind-id-attrs
dump:
request:
attributes: *dev-id-attrs
reply: *sb-tc-pool-bind-get-reply
# TODO: fill in the operations in between
- reload-action
- reload-limits
- netns-pid
- netns-fd
- netns-id
reply:
attributes:
- bus-name
- dev-name
- reload-actions-performed
-
name: param-get
doc: Get param instances.
attribute-set: devlink
dont-validate:
- strict
dont-validate: [ strict ]
do:
pre: devlink-nl-pre-doit
post: devlink-nl-post-doit
request:
value: 38
attributes: &param-id-attrs
- bus-name
- dev-name
- param-name
reply: &param-get-reply
value: 38
attributes: *param-id-attrs
dump:
request:
attributes: *dev-id-attrs
reply: *param-get-reply
# TODO: fill in the operations in between
-
name: param-set
doc: Set param instances.
attribute-set: devlink
dont-validate: [ strict ]
flags: [ admin-perm ]
do:
pre: devlink-nl-pre-doit
post: devlink-nl-post-doit
request:
attributes:
- bus-name
- dev-name
- param-name
- param-type
# param-value-data is missing here as the type is variable
- param-value-cmode
-
name: region-get
doc: Get region instances.
attribute-set: devlink
dont-validate:
- strict
dont-validate: [ strict ]
do:
pre: devlink-nl-pre-doit-port-optional
post: devlink-nl-post-doit
......@@ -457,16 +1558,97 @@ operations:
attributes: *dev-id-attrs
reply: *region-get-reply
# TODO: fill in the operations in between
-
name: region-new
doc: Create region snapshot.
attribute-set: devlink
dont-validate: [ strict ]
flags: [ admin-perm ]
do:
pre: devlink-nl-pre-doit-port-optional
post: devlink-nl-post-doit
request:
value: 44
attributes: &region-snapshot-id-attrs
- bus-name
- dev-name
- port-index
- region-name
- region-snapshot-id
reply:
value: 44
attributes: *region-snapshot-id-attrs
-
name: region-del
doc: Delete region snapshot.
attribute-set: devlink
dont-validate: [ strict ]
flags: [ admin-perm ]
do:
pre: devlink-nl-pre-doit-port-optional
post: devlink-nl-post-doit
request:
attributes: *region-snapshot-id-attrs
-
name: region-read
doc: Read region data.
attribute-set: devlink
dont-validate: [ dump-strict ]
flags: [ admin-perm ]
dump:
request:
attributes:
- bus-name
- dev-name
- port-index
- region-name
- region-snapshot-id
- region-direct
- region-chunk-addr
- region-chunk-len
reply:
value: 46
attributes:
- bus-name
- dev-name
- port-index
- region-name
-
name: port-param-get
doc: Get port param instances.
attribute-set: devlink
dont-validate: [ strict, dump-strict ]
do:
pre: devlink-nl-pre-doit-port
post: devlink-nl-post-doit
request:
attributes: *port-id-attrs
reply:
attributes: *port-id-attrs
dump:
reply:
attributes: *port-id-attrs
-
name: port-param-set
doc: Set port param instances.
attribute-set: devlink
dont-validate: [ strict ]
flags: [ admin-perm ]
do:
pre: devlink-nl-pre-doit-port
post: devlink-nl-post-doit
request:
attributes: *port-id-attrs
-
name: info-get
doc: Get device information, like driver name, hardware and firmware versions etc.
attribute-set: devlink
dont-validate:
- strict
- dump
dont-validate: [ strict, dump ]
do:
pre: devlink-nl-pre-doit
post: devlink-nl-post-doit
......@@ -490,9 +1672,7 @@ operations:
name: health-reporter-get
doc: Get health reporter instances.
attribute-set: devlink
dont-validate:
- strict
dont-validate: [ strict ]
do:
pre: devlink-nl-pre-doit-port-optional
post: devlink-nl-post-doit
......@@ -509,15 +1689,97 @@ operations:
attributes: *port-id-attrs
reply: *health-reporter-get-reply
# TODO: fill in the operations in between
-
name: health-reporter-set
doc: Set health reporter instances.
attribute-set: devlink
dont-validate: [ strict ]
flags: [ admin-perm ]
do:
pre: devlink-nl-pre-doit-port-optional
post: devlink-nl-post-doit
request:
attributes:
- bus-name
- dev-name
- port-index
- health-reporter-name
- health-reporter-graceful-period
- health-reporter-auto-recover
- health-reporter-auto-dump
-
name: health-reporter-recover
doc: Recover health reporter instances.
attribute-set: devlink
dont-validate: [ strict ]
flags: [ admin-perm ]
do:
pre: devlink-nl-pre-doit-port-optional
post: devlink-nl-post-doit
request:
attributes: *health-reporter-id-attrs
-
name: health-reporter-diagnose
doc: Diagnose health reporter instances.
attribute-set: devlink
dont-validate: [ strict ]
flags: [ admin-perm ]
do:
pre: devlink-nl-pre-doit-port-optional
post: devlink-nl-post-doit
request:
attributes: *health-reporter-id-attrs
-
name: health-reporter-dump-get
doc: Dump health reporter instances.
attribute-set: devlink
dont-validate: [ dump-strict ]
flags: [ admin-perm ]
dump:
request:
attributes: *health-reporter-id-attrs
reply:
value: 56
attributes:
- fmsg
-
name: health-reporter-dump-clear
doc: Clear dump of health reporter instances.
attribute-set: devlink
dont-validate: [ strict ]
flags: [ admin-perm ]
do:
pre: devlink-nl-pre-doit-port-optional
post: devlink-nl-post-doit
request:
attributes: *health-reporter-id-attrs
-
name: flash-update
doc: Flash update devlink instances.
attribute-set: devlink
dont-validate: [ strict ]
flags: [ admin-perm ]
do:
pre: devlink-nl-pre-doit
post: devlink-nl-post-doit
request:
attributes:
- bus-name
- dev-name
- flash-update-file-name
- flash-update-component
- flash-update-overwrite-mask
-
name: trap-get
doc: Get trap instances.
attribute-set: devlink
dont-validate:
- strict
dont-validate: [ strict ]
do:
pre: devlink-nl-pre-doit
post: devlink-nl-post-doit
......@@ -535,15 +1797,27 @@ operations:
attributes: *dev-id-attrs
reply: *trap-get-reply
# TODO: fill in the operations in between
-
name: trap-set
doc: Set trap instances.
attribute-set: devlink
dont-validate: [ strict ]
flags: [ admin-perm ]
do:
pre: devlink-nl-pre-doit
post: devlink-nl-post-doit
request:
attributes:
- bus-name
- dev-name
- trap-name
- trap-action
-
name: trap-group-get
doc: Get trap group instances.
attribute-set: devlink
dont-validate:
- strict
dont-validate: [ strict ]
do:
pre: devlink-nl-pre-doit
post: devlink-nl-post-doit
......@@ -561,15 +1835,28 @@ operations:
attributes: *dev-id-attrs
reply: *trap-group-get-reply
# TODO: fill in the operations in between
-
name: trap-group-set
doc: Set trap group instances.
attribute-set: devlink
dont-validate: [ strict ]
flags: [ admin-perm ]
do:
pre: devlink-nl-pre-doit
post: devlink-nl-post-doit
request:
attributes:
- bus-name
- dev-name
- trap-group-name
- trap-action
- trap-policer-id
-
name: trap-policer-get
doc: Get trap policer instances.
attribute-set: devlink
dont-validate:
- strict
dont-validate: [ strict ]
do:
pre: devlink-nl-pre-doit
post: devlink-nl-post-doit
......@@ -587,15 +1874,41 @@ operations:
attributes: *dev-id-attrs
reply: *trap-policer-get-reply
# TODO: fill in the operations in between
-
name: trap-policer-set
doc: Get trap policer instances.
attribute-set: devlink
dont-validate: [ strict ]
flags: [ admin-perm ]
do:
pre: devlink-nl-pre-doit
post: devlink-nl-post-doit
request:
attributes:
- bus-name
- dev-name
- trap-policer-id
- trap-policer-rate
- trap-policer-burst
-
name: health-reporter-test
doc: Test health reporter instances.
attribute-set: devlink
dont-validate: [ strict ]
flags: [ admin-perm ]
do:
pre: devlink-nl-pre-doit-port-optional
post: devlink-nl-post-doit
request:
value: 73
attributes: *health-reporter-id-attrs
-
name: rate-get
doc: Get rate instances.
attribute-set: devlink
dont-validate:
- strict
dont-validate: [ strict ]
do:
pre: devlink-nl-pre-doit
post: devlink-nl-post-doit
......@@ -614,15 +1927,66 @@ operations:
attributes: *dev-id-attrs
reply: *rate-get-reply
# TODO: fill in the operations in between
-
name: rate-set
doc: Set rate instances.
attribute-set: devlink
dont-validate: [ strict ]
flags: [ admin-perm ]
do:
pre: devlink-nl-pre-doit
post: devlink-nl-post-doit
request:
attributes:
- bus-name
- dev-name
- rate-node-name
- rate-tx-share
- rate-tx-max
- rate-tx-priority
- rate-tx-weight
- rate-parent-node-name
-
name: rate-new
doc: Create rate instances.
attribute-set: devlink
dont-validate: [ strict ]
flags: [ admin-perm ]
do:
pre: devlink-nl-pre-doit
post: devlink-nl-post-doit
request:
attributes:
- bus-name
- dev-name
- rate-node-name
- rate-tx-share
- rate-tx-max
- rate-tx-priority
- rate-tx-weight
- rate-parent-node-name
-
name: rate-del
doc: Delete rate instances.
attribute-set: devlink
dont-validate: [ strict ]
flags: [ admin-perm ]
do:
pre: devlink-nl-pre-doit
post: devlink-nl-post-doit
request:
attributes:
- bus-name
- dev-name
- rate-node-name
-
name: linecard-get
doc: Get line card instances.
attribute-set: devlink
dont-validate:
- strict
dont-validate: [ strict ]
do:
pre: devlink-nl-pre-doit
post: devlink-nl-post-doit
......@@ -640,16 +2004,27 @@ operations:
attributes: *dev-id-attrs
reply: *linecard-get-reply
# TODO: fill in the operations in between
-
name: linecard-set
doc: Set line card instances.
attribute-set: devlink
dont-validate: [ strict ]
flags: [ admin-perm ]
do:
pre: devlink-nl-pre-doit
post: devlink-nl-post-doit
request:
attributes:
- bus-name
- dev-name
- linecard-index
- linecard-type
-
name: selftests-get
doc: Get device selftest instances.
attribute-set: devlink
dont-validate:
- strict
- dump
dont-validate: [ strict, dump ]
do:
pre: devlink-nl-pre-doit
post: devlink-nl-post-doit
......@@ -661,3 +2036,18 @@ operations:
attributes: *dev-id-attrs
dump:
reply: *selftests-get-reply
-
name: selftests-run
doc: Run device selftest instances.
attribute-set: devlink
dont-validate: [ strict ]
flags: [ admin-perm ]
do:
pre: devlink-nl-pre-doit
post: devlink-nl-post-doit
request:
attributes:
- bus-name
- dev-name
- selftests
......@@ -182,7 +182,7 @@ members
- ``name`` - The attribute name of the struct member
- ``type`` - One of the scalar types ``u8``, ``u16``, ``u32``, ``u64``, ``s8``,
``s16``, ``s32``, ``s64``, ``string`` or ``binary``.
``s16``, ``s32``, ``s64``, ``string``, ``binary`` or ``bitfield32``.
- ``byte-order`` - ``big-endian`` or ``little-endian``
- ``doc``, ``enum``, ``enum-as-flags``, ``display-hint`` - Same as for
:ref:`attribute definitions <attribute_properties>`
......
......@@ -265,7 +265,7 @@ enum {
* Documentation/networking/devlink/devlink-flash.rst
*
*/
enum {
enum devlink_flash_overwrite {
DEVLINK_FLASH_OVERWRITE_SETTINGS_BIT,
DEVLINK_FLASH_OVERWRITE_IDENTIFIERS_BIT,
......
......@@ -492,7 +492,7 @@ devlink_nl_reload_actions_performed_snd(struct devlink *devlink, u32 actions_per
return -EMSGSIZE;
}
int devlink_nl_cmd_reload(struct sk_buff *skb, struct genl_info *info)
int devlink_nl_reload_doit(struct sk_buff *skb, struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
enum devlink_reload_action action;
......@@ -658,7 +658,7 @@ static int devlink_nl_eswitch_fill(struct sk_buff *msg, struct devlink *devlink,
return err;
}
int devlink_nl_cmd_eswitch_get_doit(struct sk_buff *skb, struct genl_info *info)
int devlink_nl_eswitch_get_doit(struct sk_buff *skb, struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
struct sk_buff *msg;
......@@ -679,7 +679,7 @@ int devlink_nl_cmd_eswitch_get_doit(struct sk_buff *skb, struct genl_info *info)
return genlmsg_reply(msg, info);
}
int devlink_nl_cmd_eswitch_set_doit(struct sk_buff *skb, struct genl_info *info)
int devlink_nl_eswitch_set_doit(struct sk_buff *skb, struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
const struct devlink_ops *ops = devlink->ops;
......@@ -1108,7 +1108,7 @@ static int devlink_flash_component_get(struct devlink *devlink,
return 0;
}
int devlink_nl_cmd_flash_update(struct sk_buff *skb, struct genl_info *info)
int devlink_nl_flash_update_doit(struct sk_buff *skb, struct genl_info *info)
{
struct nlattr *nla_overwrite_mask, *nla_file_name;
struct devlink_flash_update_params params = {};
......@@ -1351,7 +1351,7 @@ static const struct nla_policy devlink_selftest_nl_policy[DEVLINK_ATTR_SELFTEST_
[DEVLINK_ATTR_SELFTEST_ID_FLASH] = { .type = NLA_FLAG },
};
int devlink_nl_cmd_selftests_run(struct sk_buff *skb, struct genl_info *info)
int devlink_nl_selftests_run_doit(struct sk_buff *skb, struct genl_info *info)
{
struct nlattr *tb[DEVLINK_ATTR_SELFTEST_ID_MAX + 1];
struct devlink *devlink = info->user_ptr[0];
......
......@@ -227,67 +227,3 @@ int devlink_rate_nodes_check(struct devlink *devlink, u16 mode,
/* Linecards */
unsigned int devlink_linecard_index(struct devlink_linecard *linecard);
/* Devlink nl cmds */
int devlink_nl_cmd_reload(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_cmd_eswitch_get_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_cmd_eswitch_set_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_cmd_flash_update(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_cmd_selftests_run(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_cmd_port_set_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_cmd_port_split_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_cmd_port_unsplit_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_cmd_port_new_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_cmd_port_del_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_cmd_sb_pool_set_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_cmd_sb_port_pool_set_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_cmd_sb_tc_pool_bind_set_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_cmd_sb_occ_snapshot_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_cmd_sb_occ_max_clear_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_cmd_dpipe_table_get(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_cmd_dpipe_entries_get(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_cmd_dpipe_headers_get(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_cmd_dpipe_table_counters_set(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_cmd_resource_set(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_cmd_resource_dump(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_cmd_param_set_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_cmd_port_param_get_dumpit(struct sk_buff *msg,
struct netlink_callback *cb);
int devlink_nl_cmd_port_param_get_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_cmd_port_param_set_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_cmd_region_new(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_cmd_region_del(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_cmd_region_read_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_cmd_health_reporter_set_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_cmd_health_reporter_recover_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_cmd_health_reporter_diagnose_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_cmd_health_reporter_dump_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_cmd_health_reporter_dump_clear_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_cmd_health_reporter_test_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_cmd_trap_set_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_cmd_trap_group_set_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_cmd_trap_policer_set_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_cmd_rate_set_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_cmd_rate_new_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_cmd_rate_del_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_cmd_linecard_set_doit(struct sk_buff *skb,
struct genl_info *info);
......@@ -289,7 +289,7 @@ static int devlink_dpipe_tables_fill(struct genl_info *info,
return err;
}
int devlink_nl_cmd_dpipe_table_get(struct sk_buff *skb, struct genl_info *info)
int devlink_nl_dpipe_table_get_doit(struct sk_buff *skb, struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
const char *table_name = NULL;
......@@ -562,8 +562,8 @@ static int devlink_dpipe_entries_fill(struct genl_info *info,
return genlmsg_reply(dump_ctx.skb, info);
}
int devlink_nl_cmd_dpipe_entries_get(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_dpipe_entries_get_doit(struct sk_buff *skb,
struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
struct devlink_dpipe_table *table;
......@@ -712,8 +712,8 @@ static int devlink_dpipe_headers_fill(struct genl_info *info,
return err;
}
int devlink_nl_cmd_dpipe_headers_get(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_dpipe_headers_get_doit(struct sk_buff *skb,
struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
......@@ -746,8 +746,8 @@ static int devlink_dpipe_table_counters_set(struct devlink *devlink,
return 0;
}
int devlink_nl_cmd_dpipe_table_counters_set(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_dpipe_table_counters_set_doit(struct sk_buff *skb,
struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
const char *table_name;
......
......@@ -452,8 +452,8 @@ int devlink_nl_health_reporter_get_dumpit(struct sk_buff *skb,
devlink_nl_health_reporter_get_dump_one);
}
int devlink_nl_cmd_health_reporter_set_doit(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_health_reporter_set_doit(struct sk_buff *skb,
struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
struct devlink_health_reporter *reporter;
......@@ -655,8 +655,8 @@ devlink_health_reporter_state_update(struct devlink_health_reporter *reporter,
}
EXPORT_SYMBOL_GPL(devlink_health_reporter_state_update);
int devlink_nl_cmd_health_reporter_recover_doit(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_health_reporter_recover_doit(struct sk_buff *skb,
struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
struct devlink_health_reporter *reporter;
......@@ -1108,8 +1108,8 @@ static int devlink_fmsg_dumpit(struct devlink_fmsg *fmsg, struct sk_buff *skb,
return err;
}
int devlink_nl_cmd_health_reporter_diagnose_doit(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_health_reporter_diagnose_doit(struct sk_buff *skb,
struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
struct devlink_health_reporter *reporter;
......@@ -1163,8 +1163,8 @@ devlink_health_reporter_get_from_cb_lock(struct netlink_callback *cb)
return reporter;
}
int devlink_nl_cmd_health_reporter_dump_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb)
int devlink_nl_health_reporter_dump_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb)
{
struct devlink_nl_dump_state *state = devlink_dump_state(cb);
struct devlink_health_reporter *reporter;
......@@ -1202,8 +1202,8 @@ int devlink_nl_cmd_health_reporter_dump_get_dumpit(struct sk_buff *skb,
return err;
}
int devlink_nl_cmd_health_reporter_dump_clear_doit(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_health_reporter_dump_clear_doit(struct sk_buff *skb,
struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
struct devlink_health_reporter *reporter;
......@@ -1219,8 +1219,8 @@ int devlink_nl_cmd_health_reporter_dump_clear_doit(struct sk_buff *skb,
return 0;
}
int devlink_nl_cmd_health_reporter_test_doit(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_health_reporter_test_doit(struct sk_buff *skb,
struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
struct devlink_health_reporter *reporter;
......
......@@ -369,8 +369,7 @@ static int devlink_linecard_type_unset(struct devlink_linecard *linecard,
return err;
}
int devlink_nl_cmd_linecard_set_doit(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_linecard_set_doit(struct sk_buff *skb, struct genl_info *info)
{
struct netlink_ext_ack *extack = info->extack;
struct devlink *devlink = info->user_ptr[0];
......
......@@ -13,75 +13,6 @@ static const struct genl_multicast_group devlink_nl_mcgrps[] = {
[DEVLINK_MCGRP_CONFIG] = { .name = DEVLINK_GENL_MCGRP_CONFIG_NAME },
};
static const struct nla_policy devlink_nl_policy[DEVLINK_ATTR_MAX + 1] = {
[DEVLINK_ATTR_UNSPEC] = { .strict_start_type =
DEVLINK_ATTR_TRAP_POLICER_ID },
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING },
[DEVLINK_ATTR_PORT_INDEX] = { .type = NLA_U32 },
[DEVLINK_ATTR_PORT_TYPE] = NLA_POLICY_RANGE(NLA_U16, DEVLINK_PORT_TYPE_AUTO,
DEVLINK_PORT_TYPE_IB),
[DEVLINK_ATTR_PORT_SPLIT_COUNT] = { .type = NLA_U32 },
[DEVLINK_ATTR_SB_INDEX] = { .type = NLA_U32 },
[DEVLINK_ATTR_SB_POOL_INDEX] = { .type = NLA_U16 },
[DEVLINK_ATTR_SB_POOL_TYPE] = { .type = NLA_U8 },
[DEVLINK_ATTR_SB_POOL_SIZE] = { .type = NLA_U32 },
[DEVLINK_ATTR_SB_POOL_THRESHOLD_TYPE] = { .type = NLA_U8 },
[DEVLINK_ATTR_SB_THRESHOLD] = { .type = NLA_U32 },
[DEVLINK_ATTR_SB_TC_INDEX] = { .type = NLA_U16 },
[DEVLINK_ATTR_ESWITCH_MODE] = NLA_POLICY_RANGE(NLA_U16, DEVLINK_ESWITCH_MODE_LEGACY,
DEVLINK_ESWITCH_MODE_SWITCHDEV),
[DEVLINK_ATTR_ESWITCH_INLINE_MODE] = { .type = NLA_U8 },
[DEVLINK_ATTR_ESWITCH_ENCAP_MODE] = { .type = NLA_U8 },
[DEVLINK_ATTR_DPIPE_TABLE_NAME] = { .type = NLA_NUL_STRING },
[DEVLINK_ATTR_DPIPE_TABLE_COUNTERS_ENABLED] = { .type = NLA_U8 },
[DEVLINK_ATTR_RESOURCE_ID] = { .type = NLA_U64},
[DEVLINK_ATTR_RESOURCE_SIZE] = { .type = NLA_U64},
[DEVLINK_ATTR_PARAM_NAME] = { .type = NLA_NUL_STRING },
[DEVLINK_ATTR_PARAM_TYPE] = { .type = NLA_U8 },
[DEVLINK_ATTR_PARAM_VALUE_CMODE] = { .type = NLA_U8 },
[DEVLINK_ATTR_REGION_NAME] = { .type = NLA_NUL_STRING },
[DEVLINK_ATTR_REGION_SNAPSHOT_ID] = { .type = NLA_U32 },
[DEVLINK_ATTR_REGION_CHUNK_ADDR] = { .type = NLA_U64 },
[DEVLINK_ATTR_REGION_CHUNK_LEN] = { .type = NLA_U64 },
[DEVLINK_ATTR_HEALTH_REPORTER_NAME] = { .type = NLA_NUL_STRING },
[DEVLINK_ATTR_HEALTH_REPORTER_GRACEFUL_PERIOD] = { .type = NLA_U64 },
[DEVLINK_ATTR_HEALTH_REPORTER_AUTO_RECOVER] = { .type = NLA_U8 },
[DEVLINK_ATTR_FLASH_UPDATE_FILE_NAME] = { .type = NLA_NUL_STRING },
[DEVLINK_ATTR_FLASH_UPDATE_COMPONENT] = { .type = NLA_NUL_STRING },
[DEVLINK_ATTR_FLASH_UPDATE_OVERWRITE_MASK] =
NLA_POLICY_BITFIELD32(DEVLINK_SUPPORTED_FLASH_OVERWRITE_SECTIONS),
[DEVLINK_ATTR_TRAP_NAME] = { .type = NLA_NUL_STRING },
[DEVLINK_ATTR_TRAP_ACTION] = { .type = NLA_U8 },
[DEVLINK_ATTR_TRAP_GROUP_NAME] = { .type = NLA_NUL_STRING },
[DEVLINK_ATTR_NETNS_PID] = { .type = NLA_U32 },
[DEVLINK_ATTR_NETNS_FD] = { .type = NLA_U32 },
[DEVLINK_ATTR_NETNS_ID] = { .type = NLA_U32 },
[DEVLINK_ATTR_HEALTH_REPORTER_AUTO_DUMP] = { .type = NLA_U8 },
[DEVLINK_ATTR_TRAP_POLICER_ID] = { .type = NLA_U32 },
[DEVLINK_ATTR_TRAP_POLICER_RATE] = { .type = NLA_U64 },
[DEVLINK_ATTR_TRAP_POLICER_BURST] = { .type = NLA_U64 },
[DEVLINK_ATTR_PORT_FUNCTION] = { .type = NLA_NESTED },
[DEVLINK_ATTR_RELOAD_ACTION] = NLA_POLICY_RANGE(NLA_U8, DEVLINK_RELOAD_ACTION_DRIVER_REINIT,
DEVLINK_RELOAD_ACTION_MAX),
[DEVLINK_ATTR_RELOAD_LIMITS] = NLA_POLICY_BITFIELD32(DEVLINK_RELOAD_LIMITS_VALID_MASK),
[DEVLINK_ATTR_PORT_FLAVOUR] = { .type = NLA_U16 },
[DEVLINK_ATTR_PORT_PCI_PF_NUMBER] = { .type = NLA_U16 },
[DEVLINK_ATTR_PORT_PCI_SF_NUMBER] = { .type = NLA_U32 },
[DEVLINK_ATTR_PORT_CONTROLLER_NUMBER] = { .type = NLA_U32 },
[DEVLINK_ATTR_RATE_TYPE] = { .type = NLA_U16 },
[DEVLINK_ATTR_RATE_TX_SHARE] = { .type = NLA_U64 },
[DEVLINK_ATTR_RATE_TX_MAX] = { .type = NLA_U64 },
[DEVLINK_ATTR_RATE_NODE_NAME] = { .type = NLA_NUL_STRING },
[DEVLINK_ATTR_RATE_PARENT_NODE_NAME] = { .type = NLA_NUL_STRING },
[DEVLINK_ATTR_LINECARD_INDEX] = { .type = NLA_U32 },
[DEVLINK_ATTR_LINECARD_TYPE] = { .type = NLA_NUL_STRING },
[DEVLINK_ATTR_SELFTESTS] = { .type = NLA_NESTED },
[DEVLINK_ATTR_RATE_TX_PRIORITY] = { .type = NLA_U32 },
[DEVLINK_ATTR_RATE_TX_WEIGHT] = { .type = NLA_U32 },
[DEVLINK_ATTR_REGION_DIRECT] = { .type = NLA_FLAG },
};
int devlink_nl_put_nested_handle(struct sk_buff *msg, struct net *net,
struct devlink *devlink, int attrtype)
{
......@@ -191,7 +122,7 @@ static int __devlink_nl_pre_doit(struct sk_buff *skb, struct genl_info *info,
int devlink_nl_pre_doit(const struct genl_split_ops *ops,
struct sk_buff *skb, struct genl_info *info)
{
return __devlink_nl_pre_doit(skb, info, ops->internal_flags);
return __devlink_nl_pre_doit(skb, info, 0);
}
int devlink_nl_pre_doit_port(const struct genl_split_ops *ops,
......@@ -287,269 +218,12 @@ int devlink_nl_dumpit(struct sk_buff *msg, struct netlink_callback *cb,
return devlink_nl_inst_iter_dumpit(msg, cb, flags, dump_one);
}
static const struct genl_small_ops devlink_nl_small_ops[40] = {
{
.cmd = DEVLINK_CMD_PORT_SET,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = devlink_nl_cmd_port_set_doit,
.flags = GENL_ADMIN_PERM,
.internal_flags = DEVLINK_NL_FLAG_NEED_PORT,
},
{
.cmd = DEVLINK_CMD_RATE_SET,
.doit = devlink_nl_cmd_rate_set_doit,
.flags = GENL_ADMIN_PERM,
},
{
.cmd = DEVLINK_CMD_RATE_NEW,
.doit = devlink_nl_cmd_rate_new_doit,
.flags = GENL_ADMIN_PERM,
},
{
.cmd = DEVLINK_CMD_RATE_DEL,
.doit = devlink_nl_cmd_rate_del_doit,
.flags = GENL_ADMIN_PERM,
},
{
.cmd = DEVLINK_CMD_PORT_SPLIT,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = devlink_nl_cmd_port_split_doit,
.flags = GENL_ADMIN_PERM,
.internal_flags = DEVLINK_NL_FLAG_NEED_PORT,
},
{
.cmd = DEVLINK_CMD_PORT_UNSPLIT,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = devlink_nl_cmd_port_unsplit_doit,
.flags = GENL_ADMIN_PERM,
.internal_flags = DEVLINK_NL_FLAG_NEED_PORT,
},
{
.cmd = DEVLINK_CMD_PORT_NEW,
.doit = devlink_nl_cmd_port_new_doit,
.flags = GENL_ADMIN_PERM,
},
{
.cmd = DEVLINK_CMD_PORT_DEL,
.doit = devlink_nl_cmd_port_del_doit,
.flags = GENL_ADMIN_PERM,
.internal_flags = DEVLINK_NL_FLAG_NEED_PORT,
},
{
.cmd = DEVLINK_CMD_LINECARD_SET,
.doit = devlink_nl_cmd_linecard_set_doit,
.flags = GENL_ADMIN_PERM,
},
{
.cmd = DEVLINK_CMD_SB_POOL_SET,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = devlink_nl_cmd_sb_pool_set_doit,
.flags = GENL_ADMIN_PERM,
},
{
.cmd = DEVLINK_CMD_SB_PORT_POOL_SET,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = devlink_nl_cmd_sb_port_pool_set_doit,
.flags = GENL_ADMIN_PERM,
.internal_flags = DEVLINK_NL_FLAG_NEED_PORT,
},
{
.cmd = DEVLINK_CMD_SB_TC_POOL_BIND_SET,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = devlink_nl_cmd_sb_tc_pool_bind_set_doit,
.flags = GENL_ADMIN_PERM,
.internal_flags = DEVLINK_NL_FLAG_NEED_PORT,
},
{
.cmd = DEVLINK_CMD_SB_OCC_SNAPSHOT,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = devlink_nl_cmd_sb_occ_snapshot_doit,
.flags = GENL_ADMIN_PERM,
},
{
.cmd = DEVLINK_CMD_SB_OCC_MAX_CLEAR,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = devlink_nl_cmd_sb_occ_max_clear_doit,
.flags = GENL_ADMIN_PERM,
},
{
.cmd = DEVLINK_CMD_ESWITCH_GET,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = devlink_nl_cmd_eswitch_get_doit,
.flags = GENL_ADMIN_PERM,
},
{
.cmd = DEVLINK_CMD_ESWITCH_SET,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = devlink_nl_cmd_eswitch_set_doit,
.flags = GENL_ADMIN_PERM,
},
{
.cmd = DEVLINK_CMD_DPIPE_TABLE_GET,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = devlink_nl_cmd_dpipe_table_get,
/* can be retrieved by unprivileged users */
},
{
.cmd = DEVLINK_CMD_DPIPE_ENTRIES_GET,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = devlink_nl_cmd_dpipe_entries_get,
/* can be retrieved by unprivileged users */
},
{
.cmd = DEVLINK_CMD_DPIPE_HEADERS_GET,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = devlink_nl_cmd_dpipe_headers_get,
/* can be retrieved by unprivileged users */
},
{
.cmd = DEVLINK_CMD_DPIPE_TABLE_COUNTERS_SET,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = devlink_nl_cmd_dpipe_table_counters_set,
.flags = GENL_ADMIN_PERM,
},
{
.cmd = DEVLINK_CMD_RESOURCE_SET,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = devlink_nl_cmd_resource_set,
.flags = GENL_ADMIN_PERM,
},
{
.cmd = DEVLINK_CMD_RESOURCE_DUMP,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = devlink_nl_cmd_resource_dump,
/* can be retrieved by unprivileged users */
},
{
.cmd = DEVLINK_CMD_RELOAD,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = devlink_nl_cmd_reload,
.flags = GENL_ADMIN_PERM,
},
{
.cmd = DEVLINK_CMD_PARAM_SET,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = devlink_nl_cmd_param_set_doit,
.flags = GENL_ADMIN_PERM,
},
{
.cmd = DEVLINK_CMD_PORT_PARAM_GET,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = devlink_nl_cmd_port_param_get_doit,
.dumpit = devlink_nl_cmd_port_param_get_dumpit,
.internal_flags = DEVLINK_NL_FLAG_NEED_PORT,
/* can be retrieved by unprivileged users */
},
{
.cmd = DEVLINK_CMD_PORT_PARAM_SET,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = devlink_nl_cmd_port_param_set_doit,
.flags = GENL_ADMIN_PERM,
.internal_flags = DEVLINK_NL_FLAG_NEED_PORT,
},
{
.cmd = DEVLINK_CMD_REGION_NEW,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = devlink_nl_cmd_region_new,
.flags = GENL_ADMIN_PERM,
},
{
.cmd = DEVLINK_CMD_REGION_DEL,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = devlink_nl_cmd_region_del,
.flags = GENL_ADMIN_PERM,
},
{
.cmd = DEVLINK_CMD_REGION_READ,
.validate = GENL_DONT_VALIDATE_STRICT |
GENL_DONT_VALIDATE_DUMP_STRICT,
.dumpit = devlink_nl_cmd_region_read_dumpit,
.flags = GENL_ADMIN_PERM,
},
{
.cmd = DEVLINK_CMD_HEALTH_REPORTER_SET,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = devlink_nl_cmd_health_reporter_set_doit,
.flags = GENL_ADMIN_PERM,
.internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT,
},
{
.cmd = DEVLINK_CMD_HEALTH_REPORTER_RECOVER,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = devlink_nl_cmd_health_reporter_recover_doit,
.flags = GENL_ADMIN_PERM,
.internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT,
},
{
.cmd = DEVLINK_CMD_HEALTH_REPORTER_DIAGNOSE,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = devlink_nl_cmd_health_reporter_diagnose_doit,
.flags = GENL_ADMIN_PERM,
.internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT,
},
{
.cmd = DEVLINK_CMD_HEALTH_REPORTER_DUMP_GET,
.validate = GENL_DONT_VALIDATE_STRICT |
GENL_DONT_VALIDATE_DUMP_STRICT,
.dumpit = devlink_nl_cmd_health_reporter_dump_get_dumpit,
.flags = GENL_ADMIN_PERM,
},
{
.cmd = DEVLINK_CMD_HEALTH_REPORTER_DUMP_CLEAR,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = devlink_nl_cmd_health_reporter_dump_clear_doit,
.flags = GENL_ADMIN_PERM,
.internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT,
},
{
.cmd = DEVLINK_CMD_HEALTH_REPORTER_TEST,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = devlink_nl_cmd_health_reporter_test_doit,
.flags = GENL_ADMIN_PERM,
.internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK_OR_PORT,
},
{
.cmd = DEVLINK_CMD_FLASH_UPDATE,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = devlink_nl_cmd_flash_update,
.flags = GENL_ADMIN_PERM,
},
{
.cmd = DEVLINK_CMD_TRAP_SET,
.doit = devlink_nl_cmd_trap_set_doit,
.flags = GENL_ADMIN_PERM,
},
{
.cmd = DEVLINK_CMD_TRAP_GROUP_SET,
.doit = devlink_nl_cmd_trap_group_set_doit,
.flags = GENL_ADMIN_PERM,
},
{
.cmd = DEVLINK_CMD_TRAP_POLICER_SET,
.doit = devlink_nl_cmd_trap_policer_set_doit,
.flags = GENL_ADMIN_PERM,
},
{
.cmd = DEVLINK_CMD_SELFTESTS_RUN,
.doit = devlink_nl_cmd_selftests_run,
.flags = GENL_ADMIN_PERM,
},
/* -- No new ops here! Use split ops going forward! -- */
};
struct genl_family devlink_nl_family __ro_after_init = {
.name = DEVLINK_GENL_NAME,
.version = DEVLINK_GENL_VERSION,
.maxattr = DEVLINK_ATTR_MAX,
.policy = devlink_nl_policy,
.netnsok = true,
.parallel_ops = true,
.pre_doit = devlink_nl_pre_doit,
.post_doit = devlink_nl_post_doit,
.module = THIS_MODULE,
.small_ops = devlink_nl_small_ops,
.n_small_ops = ARRAY_SIZE(devlink_nl_small_ops),
.split_ops = devlink_nl_ops,
.n_split_ops = ARRAY_SIZE(devlink_nl_ops),
.resv_start_op = DEVLINK_CMD_SELFTESTS_RUN + 1,
......
......@@ -10,6 +10,18 @@
#include <uapi/linux/devlink.h>
/* Common nested types */
const struct nla_policy devlink_dl_port_function_nl_policy[DEVLINK_PORT_FN_ATTR_CAPS + 1] = {
[DEVLINK_PORT_FUNCTION_ATTR_HW_ADDR] = { .type = NLA_BINARY, },
[DEVLINK_PORT_FN_ATTR_STATE] = NLA_POLICY_MAX(NLA_U8, 1),
[DEVLINK_PORT_FN_ATTR_OPSTATE] = NLA_POLICY_MAX(NLA_U8, 1),
[DEVLINK_PORT_FN_ATTR_CAPS] = NLA_POLICY_BITFIELD32(3),
};
const struct nla_policy devlink_dl_selftest_id_nl_policy[DEVLINK_ATTR_SELFTEST_ID_FLASH + 1] = {
[DEVLINK_ATTR_SELFTEST_ID_FLASH] = { .type = NLA_FLAG, },
};
/* DEVLINK_CMD_GET - do */
static const struct nla_policy devlink_get_nl_policy[DEVLINK_ATTR_DEV_NAME + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
......@@ -29,6 +41,48 @@ static const struct nla_policy devlink_port_get_dump_nl_policy[DEVLINK_ATTR_DEV_
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
};
/* DEVLINK_CMD_PORT_SET - do */
static const struct nla_policy devlink_port_set_nl_policy[DEVLINK_ATTR_PORT_FUNCTION + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_PORT_INDEX] = { .type = NLA_U32, },
[DEVLINK_ATTR_PORT_TYPE] = NLA_POLICY_MAX(NLA_U16, 3),
[DEVLINK_ATTR_PORT_FUNCTION] = NLA_POLICY_NESTED(devlink_dl_port_function_nl_policy),
};
/* DEVLINK_CMD_PORT_NEW - do */
static const struct nla_policy devlink_port_new_nl_policy[DEVLINK_ATTR_PORT_PCI_SF_NUMBER + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_PORT_INDEX] = { .type = NLA_U32, },
[DEVLINK_ATTR_PORT_FLAVOUR] = NLA_POLICY_MAX(NLA_U16, 7),
[DEVLINK_ATTR_PORT_PCI_PF_NUMBER] = { .type = NLA_U16, },
[DEVLINK_ATTR_PORT_PCI_SF_NUMBER] = { .type = NLA_U32, },
[DEVLINK_ATTR_PORT_CONTROLLER_NUMBER] = { .type = NLA_U32, },
};
/* DEVLINK_CMD_PORT_DEL - do */
static const struct nla_policy devlink_port_del_nl_policy[DEVLINK_ATTR_PORT_INDEX + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_PORT_INDEX] = { .type = NLA_U32, },
};
/* DEVLINK_CMD_PORT_SPLIT - do */
static const struct nla_policy devlink_port_split_nl_policy[DEVLINK_ATTR_PORT_SPLIT_COUNT + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_PORT_INDEX] = { .type = NLA_U32, },
[DEVLINK_ATTR_PORT_SPLIT_COUNT] = { .type = NLA_U32, },
};
/* DEVLINK_CMD_PORT_UNSPLIT - do */
static const struct nla_policy devlink_port_unsplit_nl_policy[DEVLINK_ATTR_PORT_INDEX + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_PORT_INDEX] = { .type = NLA_U32, },
};
/* DEVLINK_CMD_SB_GET - do */
static const struct nla_policy devlink_sb_get_do_nl_policy[DEVLINK_ATTR_SB_INDEX + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
......@@ -56,6 +110,16 @@ static const struct nla_policy devlink_sb_pool_get_dump_nl_policy[DEVLINK_ATTR_D
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
};
/* DEVLINK_CMD_SB_POOL_SET - do */
static const struct nla_policy devlink_sb_pool_set_nl_policy[DEVLINK_ATTR_SB_POOL_THRESHOLD_TYPE + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_SB_INDEX] = { .type = NLA_U32, },
[DEVLINK_ATTR_SB_POOL_INDEX] = { .type = NLA_U16, },
[DEVLINK_ATTR_SB_POOL_THRESHOLD_TYPE] = NLA_POLICY_MAX(NLA_U8, 1),
[DEVLINK_ATTR_SB_POOL_SIZE] = { .type = NLA_U32, },
};
/* DEVLINK_CMD_SB_PORT_POOL_GET - do */
static const struct nla_policy devlink_sb_port_pool_get_do_nl_policy[DEVLINK_ATTR_SB_POOL_INDEX + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
......@@ -71,6 +135,16 @@ static const struct nla_policy devlink_sb_port_pool_get_dump_nl_policy[DEVLINK_A
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
};
/* DEVLINK_CMD_SB_PORT_POOL_SET - do */
static const struct nla_policy devlink_sb_port_pool_set_nl_policy[DEVLINK_ATTR_SB_THRESHOLD + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_PORT_INDEX] = { .type = NLA_U32, },
[DEVLINK_ATTR_SB_INDEX] = { .type = NLA_U32, },
[DEVLINK_ATTR_SB_POOL_INDEX] = { .type = NLA_U16, },
[DEVLINK_ATTR_SB_THRESHOLD] = { .type = NLA_U32, },
};
/* DEVLINK_CMD_SB_TC_POOL_BIND_GET - do */
static const struct nla_policy devlink_sb_tc_pool_bind_get_do_nl_policy[DEVLINK_ATTR_SB_TC_INDEX + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
......@@ -87,6 +161,100 @@ static const struct nla_policy devlink_sb_tc_pool_bind_get_dump_nl_policy[DEVLIN
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
};
/* DEVLINK_CMD_SB_TC_POOL_BIND_SET - do */
static const struct nla_policy devlink_sb_tc_pool_bind_set_nl_policy[DEVLINK_ATTR_SB_TC_INDEX + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_PORT_INDEX] = { .type = NLA_U32, },
[DEVLINK_ATTR_SB_INDEX] = { .type = NLA_U32, },
[DEVLINK_ATTR_SB_POOL_INDEX] = { .type = NLA_U16, },
[DEVLINK_ATTR_SB_POOL_TYPE] = NLA_POLICY_MAX(NLA_U8, 1),
[DEVLINK_ATTR_SB_TC_INDEX] = { .type = NLA_U16, },
[DEVLINK_ATTR_SB_THRESHOLD] = { .type = NLA_U32, },
};
/* DEVLINK_CMD_SB_OCC_SNAPSHOT - do */
static const struct nla_policy devlink_sb_occ_snapshot_nl_policy[DEVLINK_ATTR_SB_INDEX + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_SB_INDEX] = { .type = NLA_U32, },
};
/* DEVLINK_CMD_SB_OCC_MAX_CLEAR - do */
static const struct nla_policy devlink_sb_occ_max_clear_nl_policy[DEVLINK_ATTR_SB_INDEX + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_SB_INDEX] = { .type = NLA_U32, },
};
/* DEVLINK_CMD_ESWITCH_GET - do */
static const struct nla_policy devlink_eswitch_get_nl_policy[DEVLINK_ATTR_DEV_NAME + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
};
/* DEVLINK_CMD_ESWITCH_SET - do */
static const struct nla_policy devlink_eswitch_set_nl_policy[DEVLINK_ATTR_ESWITCH_ENCAP_MODE + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_ESWITCH_MODE] = NLA_POLICY_MAX(NLA_U16, 1),
[DEVLINK_ATTR_ESWITCH_INLINE_MODE] = NLA_POLICY_MAX(NLA_U16, 3),
[DEVLINK_ATTR_ESWITCH_ENCAP_MODE] = NLA_POLICY_MAX(NLA_U8, 1),
};
/* DEVLINK_CMD_DPIPE_TABLE_GET - do */
static const struct nla_policy devlink_dpipe_table_get_nl_policy[DEVLINK_ATTR_DPIPE_TABLE_NAME + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DPIPE_TABLE_NAME] = { .type = NLA_NUL_STRING, },
};
/* DEVLINK_CMD_DPIPE_ENTRIES_GET - do */
static const struct nla_policy devlink_dpipe_entries_get_nl_policy[DEVLINK_ATTR_DPIPE_TABLE_NAME + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DPIPE_TABLE_NAME] = { .type = NLA_NUL_STRING, },
};
/* DEVLINK_CMD_DPIPE_HEADERS_GET - do */
static const struct nla_policy devlink_dpipe_headers_get_nl_policy[DEVLINK_ATTR_DEV_NAME + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
};
/* DEVLINK_CMD_DPIPE_TABLE_COUNTERS_SET - do */
static const struct nla_policy devlink_dpipe_table_counters_set_nl_policy[DEVLINK_ATTR_DPIPE_TABLE_COUNTERS_ENABLED + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DPIPE_TABLE_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DPIPE_TABLE_COUNTERS_ENABLED] = { .type = NLA_U8, },
};
/* DEVLINK_CMD_RESOURCE_SET - do */
static const struct nla_policy devlink_resource_set_nl_policy[DEVLINK_ATTR_RESOURCE_SIZE + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_RESOURCE_ID] = { .type = NLA_U64, },
[DEVLINK_ATTR_RESOURCE_SIZE] = { .type = NLA_U64, },
};
/* DEVLINK_CMD_RESOURCE_DUMP - do */
static const struct nla_policy devlink_resource_dump_nl_policy[DEVLINK_ATTR_DEV_NAME + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
};
/* DEVLINK_CMD_RELOAD - do */
static const struct nla_policy devlink_reload_nl_policy[DEVLINK_ATTR_RELOAD_LIMITS + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_RELOAD_ACTION] = NLA_POLICY_RANGE(NLA_U8, 1, 2),
[DEVLINK_ATTR_RELOAD_LIMITS] = NLA_POLICY_BITFIELD32(6),
[DEVLINK_ATTR_NETNS_PID] = { .type = NLA_U32, },
[DEVLINK_ATTR_NETNS_FD] = { .type = NLA_U32, },
[DEVLINK_ATTR_NETNS_ID] = { .type = NLA_U32, },
};
/* DEVLINK_CMD_PARAM_GET - do */
static const struct nla_policy devlink_param_get_do_nl_policy[DEVLINK_ATTR_PARAM_NAME + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
......@@ -100,6 +268,15 @@ static const struct nla_policy devlink_param_get_dump_nl_policy[DEVLINK_ATTR_DEV
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
};
/* DEVLINK_CMD_PARAM_SET - do */
static const struct nla_policy devlink_param_set_nl_policy[DEVLINK_ATTR_PARAM_VALUE_CMODE + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_PARAM_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_PARAM_TYPE] = { .type = NLA_U8, },
[DEVLINK_ATTR_PARAM_VALUE_CMODE] = NLA_POLICY_MAX(NLA_U8, 2),
};
/* DEVLINK_CMD_REGION_GET - do */
static const struct nla_policy devlink_region_get_do_nl_policy[DEVLINK_ATTR_REGION_NAME + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
......@@ -114,6 +291,50 @@ static const struct nla_policy devlink_region_get_dump_nl_policy[DEVLINK_ATTR_DE
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
};
/* DEVLINK_CMD_REGION_NEW - do */
static const struct nla_policy devlink_region_new_nl_policy[DEVLINK_ATTR_REGION_SNAPSHOT_ID + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_PORT_INDEX] = { .type = NLA_U32, },
[DEVLINK_ATTR_REGION_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_REGION_SNAPSHOT_ID] = { .type = NLA_U32, },
};
/* DEVLINK_CMD_REGION_DEL - do */
static const struct nla_policy devlink_region_del_nl_policy[DEVLINK_ATTR_REGION_SNAPSHOT_ID + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_PORT_INDEX] = { .type = NLA_U32, },
[DEVLINK_ATTR_REGION_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_REGION_SNAPSHOT_ID] = { .type = NLA_U32, },
};
/* DEVLINK_CMD_REGION_READ - dump */
static const struct nla_policy devlink_region_read_nl_policy[DEVLINK_ATTR_REGION_DIRECT + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_PORT_INDEX] = { .type = NLA_U32, },
[DEVLINK_ATTR_REGION_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_REGION_SNAPSHOT_ID] = { .type = NLA_U32, },
[DEVLINK_ATTR_REGION_DIRECT] = { .type = NLA_FLAG, },
[DEVLINK_ATTR_REGION_CHUNK_ADDR] = { .type = NLA_U64, },
[DEVLINK_ATTR_REGION_CHUNK_LEN] = { .type = NLA_U64, },
};
/* DEVLINK_CMD_PORT_PARAM_GET - do */
static const struct nla_policy devlink_port_param_get_nl_policy[DEVLINK_ATTR_PORT_INDEX + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_PORT_INDEX] = { .type = NLA_U32, },
};
/* DEVLINK_CMD_PORT_PARAM_SET - do */
static const struct nla_policy devlink_port_param_set_nl_policy[DEVLINK_ATTR_PORT_INDEX + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_PORT_INDEX] = { .type = NLA_U32, },
};
/* DEVLINK_CMD_INFO_GET - do */
static const struct nla_policy devlink_info_get_nl_policy[DEVLINK_ATTR_DEV_NAME + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
......@@ -135,6 +356,58 @@ static const struct nla_policy devlink_health_reporter_get_dump_nl_policy[DEVLIN
[DEVLINK_ATTR_PORT_INDEX] = { .type = NLA_U32, },
};
/* DEVLINK_CMD_HEALTH_REPORTER_SET - do */
static const struct nla_policy devlink_health_reporter_set_nl_policy[DEVLINK_ATTR_HEALTH_REPORTER_AUTO_DUMP + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_PORT_INDEX] = { .type = NLA_U32, },
[DEVLINK_ATTR_HEALTH_REPORTER_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_HEALTH_REPORTER_GRACEFUL_PERIOD] = { .type = NLA_U64, },
[DEVLINK_ATTR_HEALTH_REPORTER_AUTO_RECOVER] = { .type = NLA_U8, },
[DEVLINK_ATTR_HEALTH_REPORTER_AUTO_DUMP] = { .type = NLA_U8, },
};
/* DEVLINK_CMD_HEALTH_REPORTER_RECOVER - do */
static const struct nla_policy devlink_health_reporter_recover_nl_policy[DEVLINK_ATTR_HEALTH_REPORTER_NAME + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_PORT_INDEX] = { .type = NLA_U32, },
[DEVLINK_ATTR_HEALTH_REPORTER_NAME] = { .type = NLA_NUL_STRING, },
};
/* DEVLINK_CMD_HEALTH_REPORTER_DIAGNOSE - do */
static const struct nla_policy devlink_health_reporter_diagnose_nl_policy[DEVLINK_ATTR_HEALTH_REPORTER_NAME + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_PORT_INDEX] = { .type = NLA_U32, },
[DEVLINK_ATTR_HEALTH_REPORTER_NAME] = { .type = NLA_NUL_STRING, },
};
/* DEVLINK_CMD_HEALTH_REPORTER_DUMP_GET - dump */
static const struct nla_policy devlink_health_reporter_dump_get_nl_policy[DEVLINK_ATTR_HEALTH_REPORTER_NAME + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_PORT_INDEX] = { .type = NLA_U32, },
[DEVLINK_ATTR_HEALTH_REPORTER_NAME] = { .type = NLA_NUL_STRING, },
};
/* DEVLINK_CMD_HEALTH_REPORTER_DUMP_CLEAR - do */
static const struct nla_policy devlink_health_reporter_dump_clear_nl_policy[DEVLINK_ATTR_HEALTH_REPORTER_NAME + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_PORT_INDEX] = { .type = NLA_U32, },
[DEVLINK_ATTR_HEALTH_REPORTER_NAME] = { .type = NLA_NUL_STRING, },
};
/* DEVLINK_CMD_FLASH_UPDATE - do */
static const struct nla_policy devlink_flash_update_nl_policy[DEVLINK_ATTR_FLASH_UPDATE_OVERWRITE_MASK + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_FLASH_UPDATE_FILE_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_FLASH_UPDATE_COMPONENT] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_FLASH_UPDATE_OVERWRITE_MASK] = NLA_POLICY_BITFIELD32(3),
};
/* DEVLINK_CMD_TRAP_GET - do */
static const struct nla_policy devlink_trap_get_do_nl_policy[DEVLINK_ATTR_TRAP_NAME + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
......@@ -148,6 +421,14 @@ static const struct nla_policy devlink_trap_get_dump_nl_policy[DEVLINK_ATTR_DEV_
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
};
/* DEVLINK_CMD_TRAP_SET - do */
static const struct nla_policy devlink_trap_set_nl_policy[DEVLINK_ATTR_TRAP_ACTION + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_TRAP_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_TRAP_ACTION] = NLA_POLICY_MAX(NLA_U8, 2),
};
/* DEVLINK_CMD_TRAP_GROUP_GET - do */
static const struct nla_policy devlink_trap_group_get_do_nl_policy[DEVLINK_ATTR_TRAP_GROUP_NAME + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
......@@ -161,6 +442,15 @@ static const struct nla_policy devlink_trap_group_get_dump_nl_policy[DEVLINK_ATT
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
};
/* DEVLINK_CMD_TRAP_GROUP_SET - do */
static const struct nla_policy devlink_trap_group_set_nl_policy[DEVLINK_ATTR_TRAP_POLICER_ID + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_TRAP_GROUP_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_TRAP_ACTION] = NLA_POLICY_MAX(NLA_U8, 2),
[DEVLINK_ATTR_TRAP_POLICER_ID] = { .type = NLA_U32, },
};
/* DEVLINK_CMD_TRAP_POLICER_GET - do */
static const struct nla_policy devlink_trap_policer_get_do_nl_policy[DEVLINK_ATTR_TRAP_POLICER_ID + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
......@@ -174,6 +464,23 @@ static const struct nla_policy devlink_trap_policer_get_dump_nl_policy[DEVLINK_A
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
};
/* DEVLINK_CMD_TRAP_POLICER_SET - do */
static const struct nla_policy devlink_trap_policer_set_nl_policy[DEVLINK_ATTR_TRAP_POLICER_BURST + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_TRAP_POLICER_ID] = { .type = NLA_U32, },
[DEVLINK_ATTR_TRAP_POLICER_RATE] = { .type = NLA_U64, },
[DEVLINK_ATTR_TRAP_POLICER_BURST] = { .type = NLA_U64, },
};
/* DEVLINK_CMD_HEALTH_REPORTER_TEST - do */
static const struct nla_policy devlink_health_reporter_test_nl_policy[DEVLINK_ATTR_HEALTH_REPORTER_NAME + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_PORT_INDEX] = { .type = NLA_U32, },
[DEVLINK_ATTR_HEALTH_REPORTER_NAME] = { .type = NLA_NUL_STRING, },
};
/* DEVLINK_CMD_RATE_GET - do */
static const struct nla_policy devlink_rate_get_do_nl_policy[DEVLINK_ATTR_RATE_NODE_NAME + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
......@@ -188,6 +495,37 @@ static const struct nla_policy devlink_rate_get_dump_nl_policy[DEVLINK_ATTR_DEV_
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
};
/* DEVLINK_CMD_RATE_SET - do */
static const struct nla_policy devlink_rate_set_nl_policy[DEVLINK_ATTR_RATE_TX_WEIGHT + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_RATE_NODE_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_RATE_TX_SHARE] = { .type = NLA_U64, },
[DEVLINK_ATTR_RATE_TX_MAX] = { .type = NLA_U64, },
[DEVLINK_ATTR_RATE_TX_PRIORITY] = { .type = NLA_U32, },
[DEVLINK_ATTR_RATE_TX_WEIGHT] = { .type = NLA_U32, },
[DEVLINK_ATTR_RATE_PARENT_NODE_NAME] = { .type = NLA_NUL_STRING, },
};
/* DEVLINK_CMD_RATE_NEW - do */
static const struct nla_policy devlink_rate_new_nl_policy[DEVLINK_ATTR_RATE_TX_WEIGHT + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_RATE_NODE_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_RATE_TX_SHARE] = { .type = NLA_U64, },
[DEVLINK_ATTR_RATE_TX_MAX] = { .type = NLA_U64, },
[DEVLINK_ATTR_RATE_TX_PRIORITY] = { .type = NLA_U32, },
[DEVLINK_ATTR_RATE_TX_WEIGHT] = { .type = NLA_U32, },
[DEVLINK_ATTR_RATE_PARENT_NODE_NAME] = { .type = NLA_NUL_STRING, },
};
/* DEVLINK_CMD_RATE_DEL - do */
static const struct nla_policy devlink_rate_del_nl_policy[DEVLINK_ATTR_RATE_NODE_NAME + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_RATE_NODE_NAME] = { .type = NLA_NUL_STRING, },
};
/* DEVLINK_CMD_LINECARD_GET - do */
static const struct nla_policy devlink_linecard_get_do_nl_policy[DEVLINK_ATTR_LINECARD_INDEX + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
......@@ -201,14 +539,29 @@ static const struct nla_policy devlink_linecard_get_dump_nl_policy[DEVLINK_ATTR_
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
};
/* DEVLINK_CMD_LINECARD_SET - do */
static const struct nla_policy devlink_linecard_set_nl_policy[DEVLINK_ATTR_LINECARD_TYPE + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_LINECARD_INDEX] = { .type = NLA_U32, },
[DEVLINK_ATTR_LINECARD_TYPE] = { .type = NLA_NUL_STRING, },
};
/* DEVLINK_CMD_SELFTESTS_GET - do */
static const struct nla_policy devlink_selftests_get_nl_policy[DEVLINK_ATTR_DEV_NAME + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
};
/* DEVLINK_CMD_SELFTESTS_RUN - do */
static const struct nla_policy devlink_selftests_run_nl_policy[DEVLINK_ATTR_SELFTESTS + 1] = {
[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
[DEVLINK_ATTR_SELFTESTS] = NLA_POLICY_NESTED(devlink_dl_selftest_id_nl_policy),
};
/* Ops table for devlink */
const struct genl_split_ops devlink_nl_ops[32] = {
const struct genl_split_ops devlink_nl_ops[73] = {
{
.cmd = DEVLINK_CMD_GET,
.validate = GENL_DONT_VALIDATE_STRICT,
......@@ -242,6 +595,56 @@ const struct genl_split_ops devlink_nl_ops[32] = {
.maxattr = DEVLINK_ATTR_DEV_NAME,
.flags = GENL_CMD_CAP_DUMP,
},
{
.cmd = DEVLINK_CMD_PORT_SET,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit_port,
.doit = devlink_nl_port_set_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_port_set_nl_policy,
.maxattr = DEVLINK_ATTR_PORT_FUNCTION,
.flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_PORT_NEW,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit,
.doit = devlink_nl_port_new_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_port_new_nl_policy,
.maxattr = DEVLINK_ATTR_PORT_PCI_SF_NUMBER,
.flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_PORT_DEL,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit_port,
.doit = devlink_nl_port_del_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_port_del_nl_policy,
.maxattr = DEVLINK_ATTR_PORT_INDEX,
.flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_PORT_SPLIT,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit_port,
.doit = devlink_nl_port_split_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_port_split_nl_policy,
.maxattr = DEVLINK_ATTR_PORT_SPLIT_COUNT,
.flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_PORT_UNSPLIT,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit_port,
.doit = devlink_nl_port_unsplit_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_port_unsplit_nl_policy,
.maxattr = DEVLINK_ATTR_PORT_INDEX,
.flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_SB_GET,
.validate = GENL_DONT_VALIDATE_STRICT,
......@@ -276,6 +679,16 @@ const struct genl_split_ops devlink_nl_ops[32] = {
.maxattr = DEVLINK_ATTR_DEV_NAME,
.flags = GENL_CMD_CAP_DUMP,
},
{
.cmd = DEVLINK_CMD_SB_POOL_SET,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit,
.doit = devlink_nl_sb_pool_set_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_sb_pool_set_nl_policy,
.maxattr = DEVLINK_ATTR_SB_POOL_THRESHOLD_TYPE,
.flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_SB_PORT_POOL_GET,
.validate = GENL_DONT_VALIDATE_STRICT,
......@@ -293,6 +706,16 @@ const struct genl_split_ops devlink_nl_ops[32] = {
.maxattr = DEVLINK_ATTR_DEV_NAME,
.flags = GENL_CMD_CAP_DUMP,
},
{
.cmd = DEVLINK_CMD_SB_PORT_POOL_SET,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit_port,
.doit = devlink_nl_sb_port_pool_set_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_sb_port_pool_set_nl_policy,
.maxattr = DEVLINK_ATTR_SB_THRESHOLD,
.flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_SB_TC_POOL_BIND_GET,
.validate = GENL_DONT_VALIDATE_STRICT,
......@@ -310,6 +733,126 @@ const struct genl_split_ops devlink_nl_ops[32] = {
.maxattr = DEVLINK_ATTR_DEV_NAME,
.flags = GENL_CMD_CAP_DUMP,
},
{
.cmd = DEVLINK_CMD_SB_TC_POOL_BIND_SET,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit_port,
.doit = devlink_nl_sb_tc_pool_bind_set_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_sb_tc_pool_bind_set_nl_policy,
.maxattr = DEVLINK_ATTR_SB_TC_INDEX,
.flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_SB_OCC_SNAPSHOT,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit,
.doit = devlink_nl_sb_occ_snapshot_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_sb_occ_snapshot_nl_policy,
.maxattr = DEVLINK_ATTR_SB_INDEX,
.flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_SB_OCC_MAX_CLEAR,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit,
.doit = devlink_nl_sb_occ_max_clear_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_sb_occ_max_clear_nl_policy,
.maxattr = DEVLINK_ATTR_SB_INDEX,
.flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_ESWITCH_GET,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit,
.doit = devlink_nl_eswitch_get_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_eswitch_get_nl_policy,
.maxattr = DEVLINK_ATTR_DEV_NAME,
.flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_ESWITCH_SET,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit,
.doit = devlink_nl_eswitch_set_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_eswitch_set_nl_policy,
.maxattr = DEVLINK_ATTR_ESWITCH_ENCAP_MODE,
.flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_DPIPE_TABLE_GET,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit,
.doit = devlink_nl_dpipe_table_get_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_dpipe_table_get_nl_policy,
.maxattr = DEVLINK_ATTR_DPIPE_TABLE_NAME,
.flags = GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_DPIPE_ENTRIES_GET,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit,
.doit = devlink_nl_dpipe_entries_get_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_dpipe_entries_get_nl_policy,
.maxattr = DEVLINK_ATTR_DPIPE_TABLE_NAME,
.flags = GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_DPIPE_HEADERS_GET,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit,
.doit = devlink_nl_dpipe_headers_get_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_dpipe_headers_get_nl_policy,
.maxattr = DEVLINK_ATTR_DEV_NAME,
.flags = GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_DPIPE_TABLE_COUNTERS_SET,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit,
.doit = devlink_nl_dpipe_table_counters_set_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_dpipe_table_counters_set_nl_policy,
.maxattr = DEVLINK_ATTR_DPIPE_TABLE_COUNTERS_ENABLED,
.flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_RESOURCE_SET,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit,
.doit = devlink_nl_resource_set_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_resource_set_nl_policy,
.maxattr = DEVLINK_ATTR_RESOURCE_SIZE,
.flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_RESOURCE_DUMP,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit,
.doit = devlink_nl_resource_dump_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_resource_dump_nl_policy,
.maxattr = DEVLINK_ATTR_DEV_NAME,
.flags = GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_RELOAD,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit,
.doit = devlink_nl_reload_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_reload_nl_policy,
.maxattr = DEVLINK_ATTR_RELOAD_LIMITS,
.flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_PARAM_GET,
.validate = GENL_DONT_VALIDATE_STRICT,
......@@ -327,6 +870,16 @@ const struct genl_split_ops devlink_nl_ops[32] = {
.maxattr = DEVLINK_ATTR_DEV_NAME,
.flags = GENL_CMD_CAP_DUMP,
},
{
.cmd = DEVLINK_CMD_PARAM_SET,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit,
.doit = devlink_nl_param_set_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_param_set_nl_policy,
.maxattr = DEVLINK_ATTR_PARAM_VALUE_CMODE,
.flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_REGION_GET,
.validate = GENL_DONT_VALIDATE_STRICT,
......@@ -344,6 +897,60 @@ const struct genl_split_ops devlink_nl_ops[32] = {
.maxattr = DEVLINK_ATTR_DEV_NAME,
.flags = GENL_CMD_CAP_DUMP,
},
{
.cmd = DEVLINK_CMD_REGION_NEW,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit_port_optional,
.doit = devlink_nl_region_new_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_region_new_nl_policy,
.maxattr = DEVLINK_ATTR_REGION_SNAPSHOT_ID,
.flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_REGION_DEL,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit_port_optional,
.doit = devlink_nl_region_del_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_region_del_nl_policy,
.maxattr = DEVLINK_ATTR_REGION_SNAPSHOT_ID,
.flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_REGION_READ,
.validate = GENL_DONT_VALIDATE_DUMP_STRICT,
.dumpit = devlink_nl_region_read_dumpit,
.policy = devlink_region_read_nl_policy,
.maxattr = DEVLINK_ATTR_REGION_DIRECT,
.flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DUMP,
},
{
.cmd = DEVLINK_CMD_PORT_PARAM_GET,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit_port,
.doit = devlink_nl_port_param_get_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_port_param_get_nl_policy,
.maxattr = DEVLINK_ATTR_PORT_INDEX,
.flags = GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_PORT_PARAM_GET,
.validate = GENL_DONT_VALIDATE_DUMP_STRICT,
.dumpit = devlink_nl_port_param_get_dumpit,
.flags = GENL_CMD_CAP_DUMP,
},
{
.cmd = DEVLINK_CMD_PORT_PARAM_SET,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit_port,
.doit = devlink_nl_port_param_set_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_port_param_set_nl_policy,
.maxattr = DEVLINK_ATTR_PORT_INDEX,
.flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_INFO_GET,
.validate = GENL_DONT_VALIDATE_STRICT,
......@@ -377,6 +984,64 @@ const struct genl_split_ops devlink_nl_ops[32] = {
.maxattr = DEVLINK_ATTR_PORT_INDEX,
.flags = GENL_CMD_CAP_DUMP,
},
{
.cmd = DEVLINK_CMD_HEALTH_REPORTER_SET,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit_port_optional,
.doit = devlink_nl_health_reporter_set_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_health_reporter_set_nl_policy,
.maxattr = DEVLINK_ATTR_HEALTH_REPORTER_AUTO_DUMP,
.flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_HEALTH_REPORTER_RECOVER,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit_port_optional,
.doit = devlink_nl_health_reporter_recover_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_health_reporter_recover_nl_policy,
.maxattr = DEVLINK_ATTR_HEALTH_REPORTER_NAME,
.flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_HEALTH_REPORTER_DIAGNOSE,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit_port_optional,
.doit = devlink_nl_health_reporter_diagnose_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_health_reporter_diagnose_nl_policy,
.maxattr = DEVLINK_ATTR_HEALTH_REPORTER_NAME,
.flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_HEALTH_REPORTER_DUMP_GET,
.validate = GENL_DONT_VALIDATE_DUMP_STRICT,
.dumpit = devlink_nl_health_reporter_dump_get_dumpit,
.policy = devlink_health_reporter_dump_get_nl_policy,
.maxattr = DEVLINK_ATTR_HEALTH_REPORTER_NAME,
.flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DUMP,
},
{
.cmd = DEVLINK_CMD_HEALTH_REPORTER_DUMP_CLEAR,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit_port_optional,
.doit = devlink_nl_health_reporter_dump_clear_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_health_reporter_dump_clear_nl_policy,
.maxattr = DEVLINK_ATTR_HEALTH_REPORTER_NAME,
.flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_FLASH_UPDATE,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit,
.doit = devlink_nl_flash_update_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_flash_update_nl_policy,
.maxattr = DEVLINK_ATTR_FLASH_UPDATE_OVERWRITE_MASK,
.flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_TRAP_GET,
.validate = GENL_DONT_VALIDATE_STRICT,
......@@ -394,6 +1059,16 @@ const struct genl_split_ops devlink_nl_ops[32] = {
.maxattr = DEVLINK_ATTR_DEV_NAME,
.flags = GENL_CMD_CAP_DUMP,
},
{
.cmd = DEVLINK_CMD_TRAP_SET,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit,
.doit = devlink_nl_trap_set_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_trap_set_nl_policy,
.maxattr = DEVLINK_ATTR_TRAP_ACTION,
.flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_TRAP_GROUP_GET,
.validate = GENL_DONT_VALIDATE_STRICT,
......@@ -411,6 +1086,16 @@ const struct genl_split_ops devlink_nl_ops[32] = {
.maxattr = DEVLINK_ATTR_DEV_NAME,
.flags = GENL_CMD_CAP_DUMP,
},
{
.cmd = DEVLINK_CMD_TRAP_GROUP_SET,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit,
.doit = devlink_nl_trap_group_set_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_trap_group_set_nl_policy,
.maxattr = DEVLINK_ATTR_TRAP_POLICER_ID,
.flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_TRAP_POLICER_GET,
.validate = GENL_DONT_VALIDATE_STRICT,
......@@ -428,6 +1113,26 @@ const struct genl_split_ops devlink_nl_ops[32] = {
.maxattr = DEVLINK_ATTR_DEV_NAME,
.flags = GENL_CMD_CAP_DUMP,
},
{
.cmd = DEVLINK_CMD_TRAP_POLICER_SET,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit,
.doit = devlink_nl_trap_policer_set_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_trap_policer_set_nl_policy,
.maxattr = DEVLINK_ATTR_TRAP_POLICER_BURST,
.flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_HEALTH_REPORTER_TEST,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit_port_optional,
.doit = devlink_nl_health_reporter_test_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_health_reporter_test_nl_policy,
.maxattr = DEVLINK_ATTR_HEALTH_REPORTER_NAME,
.flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_RATE_GET,
.validate = GENL_DONT_VALIDATE_STRICT,
......@@ -445,6 +1150,36 @@ const struct genl_split_ops devlink_nl_ops[32] = {
.maxattr = DEVLINK_ATTR_DEV_NAME,
.flags = GENL_CMD_CAP_DUMP,
},
{
.cmd = DEVLINK_CMD_RATE_SET,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit,
.doit = devlink_nl_rate_set_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_rate_set_nl_policy,
.maxattr = DEVLINK_ATTR_RATE_TX_WEIGHT,
.flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_RATE_NEW,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit,
.doit = devlink_nl_rate_new_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_rate_new_nl_policy,
.maxattr = DEVLINK_ATTR_RATE_TX_WEIGHT,
.flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_RATE_DEL,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit,
.doit = devlink_nl_rate_del_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_rate_del_nl_policy,
.maxattr = DEVLINK_ATTR_RATE_NODE_NAME,
.flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_LINECARD_GET,
.validate = GENL_DONT_VALIDATE_STRICT,
......@@ -462,6 +1197,16 @@ const struct genl_split_ops devlink_nl_ops[32] = {
.maxattr = DEVLINK_ATTR_DEV_NAME,
.flags = GENL_CMD_CAP_DUMP,
},
{
.cmd = DEVLINK_CMD_LINECARD_SET,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit,
.doit = devlink_nl_linecard_set_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_linecard_set_nl_policy,
.maxattr = DEVLINK_ATTR_LINECARD_TYPE,
.flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
},
{
.cmd = DEVLINK_CMD_SELFTESTS_GET,
.validate = GENL_DONT_VALIDATE_STRICT,
......@@ -478,4 +1223,14 @@ const struct genl_split_ops devlink_nl_ops[32] = {
.dumpit = devlink_nl_selftests_get_dumpit,
.flags = GENL_CMD_CAP_DUMP,
},
{
.cmd = DEVLINK_CMD_SELFTESTS_RUN,
.validate = GENL_DONT_VALIDATE_STRICT,
.pre_doit = devlink_nl_pre_doit,
.doit = devlink_nl_selftests_run_doit,
.post_doit = devlink_nl_post_doit,
.policy = devlink_selftests_run_nl_policy,
.maxattr = DEVLINK_ATTR_SELFTESTS,
.flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO,
},
};
......@@ -11,8 +11,12 @@
#include <uapi/linux/devlink.h>
/* Common nested types */
extern const struct nla_policy devlink_dl_port_function_nl_policy[DEVLINK_PORT_FN_ATTR_CAPS + 1];
extern const struct nla_policy devlink_dl_selftest_id_nl_policy[DEVLINK_ATTR_SELFTEST_ID_FLASH + 1];
/* Ops table for devlink */
extern const struct genl_split_ops devlink_nl_ops[32];
extern const struct genl_split_ops devlink_nl_ops[73];
int devlink_nl_pre_doit(const struct genl_split_ops *ops, struct sk_buff *skb,
struct genl_info *info);
......@@ -30,25 +34,61 @@ int devlink_nl_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb);
int devlink_nl_port_get_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_port_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_port_set_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_port_new_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_port_del_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_port_split_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_port_unsplit_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_sb_get_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_sb_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb);
int devlink_nl_sb_pool_get_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_sb_pool_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_sb_pool_set_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_sb_port_pool_get_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_sb_port_pool_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_sb_port_pool_set_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_sb_tc_pool_bind_get_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_sb_tc_pool_bind_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_sb_tc_pool_bind_set_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_sb_occ_snapshot_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_sb_occ_max_clear_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_eswitch_get_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_eswitch_set_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_dpipe_table_get_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_dpipe_entries_get_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_dpipe_headers_get_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_dpipe_table_counters_set_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_resource_set_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_resource_dump_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_reload_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_param_get_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_param_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_param_set_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_region_get_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_region_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_region_new_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_region_del_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_region_read_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_port_param_get_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_port_param_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_port_param_set_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_info_get_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_info_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
......@@ -56,24 +96,46 @@ int devlink_nl_health_reporter_get_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_health_reporter_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_health_reporter_set_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_health_reporter_recover_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_health_reporter_diagnose_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_health_reporter_dump_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_health_reporter_dump_clear_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_flash_update_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_trap_get_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_trap_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_trap_set_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_trap_group_get_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_trap_group_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_trap_group_set_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_trap_policer_get_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_trap_policer_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_trap_policer_set_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_health_reporter_test_doit(struct sk_buff *skb,
struct genl_info *info);
int devlink_nl_rate_get_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_rate_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_rate_set_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_rate_new_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_rate_del_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_linecard_get_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_linecard_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_linecard_set_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_selftests_get_doit(struct sk_buff *skb, struct genl_info *info);
int devlink_nl_selftests_get_dumpit(struct sk_buff *skb,
struct netlink_callback *cb);
int devlink_nl_selftests_run_doit(struct sk_buff *skb, struct genl_info *info);
#endif /* _LINUX_DEVLINK_GEN_H */
......@@ -581,7 +581,7 @@ static int __devlink_nl_cmd_param_set_doit(struct devlink *devlink,
return 0;
}
int devlink_nl_cmd_param_set_doit(struct sk_buff *skb, struct genl_info *info)
int devlink_nl_param_set_doit(struct sk_buff *skb, struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
......@@ -589,22 +589,22 @@ int devlink_nl_cmd_param_set_doit(struct sk_buff *skb, struct genl_info *info)
info, DEVLINK_CMD_PARAM_NEW);
}
int devlink_nl_cmd_port_param_get_dumpit(struct sk_buff *msg,
struct netlink_callback *cb)
int devlink_nl_port_param_get_dumpit(struct sk_buff *msg,
struct netlink_callback *cb)
{
NL_SET_ERR_MSG(cb->extack, "Port params are not supported");
return msg->len;
}
int devlink_nl_cmd_port_param_get_doit(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_port_param_get_doit(struct sk_buff *skb,
struct genl_info *info)
{
NL_SET_ERR_MSG(info->extack, "Port params are not supported");
return -EINVAL;
}
int devlink_nl_cmd_port_param_set_doit(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_port_param_set_doit(struct sk_buff *skb,
struct genl_info *info)
{
NL_SET_ERR_MSG(info->extack, "Port params are not supported");
return -EINVAL;
......
......@@ -772,7 +772,7 @@ static int devlink_port_function_set(struct devlink_port *port,
return err;
}
int devlink_nl_cmd_port_set_doit(struct sk_buff *skb, struct genl_info *info)
int devlink_nl_port_set_doit(struct sk_buff *skb, struct genl_info *info)
{
struct devlink_port *devlink_port = info->user_ptr[1];
int err;
......@@ -798,7 +798,7 @@ int devlink_nl_cmd_port_set_doit(struct sk_buff *skb, struct genl_info *info)
return 0;
}
int devlink_nl_cmd_port_split_doit(struct sk_buff *skb, struct genl_info *info)
int devlink_nl_port_split_doit(struct sk_buff *skb, struct genl_info *info)
{
struct devlink_port *devlink_port = info->user_ptr[1];
struct devlink *devlink = info->user_ptr[0];
......@@ -829,8 +829,7 @@ int devlink_nl_cmd_port_split_doit(struct sk_buff *skb, struct genl_info *info)
info->extack);
}
int devlink_nl_cmd_port_unsplit_doit(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_port_unsplit_doit(struct sk_buff *skb, struct genl_info *info)
{
struct devlink_port *devlink_port = info->user_ptr[1];
struct devlink *devlink = info->user_ptr[0];
......@@ -840,7 +839,7 @@ int devlink_nl_cmd_port_unsplit_doit(struct sk_buff *skb,
return devlink_port->ops->port_unsplit(devlink, devlink_port, info->extack);
}
int devlink_nl_cmd_port_new_doit(struct sk_buff *skb, struct genl_info *info)
int devlink_nl_port_new_doit(struct sk_buff *skb, struct genl_info *info)
{
struct netlink_ext_ack *extack = info->extack;
struct devlink_port_new_attrs new_attrs = {};
......@@ -904,7 +903,7 @@ int devlink_nl_cmd_port_new_doit(struct sk_buff *skb, struct genl_info *info)
return err;
}
int devlink_nl_cmd_port_del_doit(struct sk_buff *skb, struct genl_info *info)
int devlink_nl_port_del_doit(struct sk_buff *skb, struct genl_info *info)
{
struct devlink_port *devlink_port = info->user_ptr[1];
struct netlink_ext_ack *extack = info->extack;
......
......@@ -458,7 +458,7 @@ static bool devlink_rate_set_ops_supported(const struct devlink_ops *ops,
return true;
}
int devlink_nl_cmd_rate_set_doit(struct sk_buff *skb, struct genl_info *info)
int devlink_nl_rate_set_doit(struct sk_buff *skb, struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
struct devlink_rate *devlink_rate;
......@@ -480,7 +480,7 @@ int devlink_nl_cmd_rate_set_doit(struct sk_buff *skb, struct genl_info *info)
return err;
}
int devlink_nl_cmd_rate_new_doit(struct sk_buff *skb, struct genl_info *info)
int devlink_nl_rate_new_doit(struct sk_buff *skb, struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
struct devlink_rate *rate_node;
......@@ -536,7 +536,7 @@ int devlink_nl_cmd_rate_new_doit(struct sk_buff *skb, struct genl_info *info)
return err;
}
int devlink_nl_cmd_rate_del_doit(struct sk_buff *skb, struct genl_info *info)
int devlink_nl_rate_del_doit(struct sk_buff *skb, struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
struct devlink_rate *rate_node;
......
......@@ -588,7 +588,7 @@ int devlink_nl_region_get_dumpit(struct sk_buff *skb,
return devlink_nl_dumpit(skb, cb, devlink_nl_region_get_dump_one);
}
int devlink_nl_cmd_region_del(struct sk_buff *skb, struct genl_info *info)
int devlink_nl_region_del_doit(struct sk_buff *skb, struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
struct devlink_snapshot *snapshot;
......@@ -633,7 +633,7 @@ int devlink_nl_cmd_region_del(struct sk_buff *skb, struct genl_info *info)
return 0;
}
int devlink_nl_cmd_region_new(struct sk_buff *skb, struct genl_info *info)
int devlink_nl_region_new_doit(struct sk_buff *skb, struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
struct devlink_snapshot *snapshot;
......@@ -863,8 +863,8 @@ devlink_region_direct_fill(void *cb_priv, u8 *chunk, u32 chunk_size,
curr_offset, chunk_size, chunk);
}
int devlink_nl_cmd_region_read_dumpit(struct sk_buff *skb,
struct netlink_callback *cb)
int devlink_nl_region_read_dumpit(struct sk_buff *skb,
struct netlink_callback *cb)
{
const struct genl_dumpit_info *info = genl_dumpit_info(cb);
struct devlink_nl_dump_state *state = devlink_dump_state(cb);
......
......@@ -105,7 +105,7 @@ devlink_resource_validate_size(struct devlink_resource *resource, u64 size,
return err;
}
int devlink_nl_cmd_resource_set(struct sk_buff *skb, struct genl_info *info)
int devlink_nl_resource_set_doit(struct sk_buff *skb, struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
struct devlink_resource *resource;
......@@ -285,7 +285,7 @@ static int devlink_resource_fill(struct genl_info *info,
return err;
}
int devlink_nl_cmd_resource_dump(struct sk_buff *skb, struct genl_info *info)
int devlink_nl_resource_dump_doit(struct sk_buff *skb, struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
......
......@@ -413,7 +413,7 @@ static int devlink_sb_pool_set(struct devlink *devlink, unsigned int sb_index,
return -EOPNOTSUPP;
}
int devlink_nl_cmd_sb_pool_set_doit(struct sk_buff *skb, struct genl_info *info)
int devlink_nl_sb_pool_set_doit(struct sk_buff *skb, struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
enum devlink_sb_threshold_type threshold_type;
......@@ -621,8 +621,8 @@ static int devlink_sb_port_pool_set(struct devlink_port *devlink_port,
return -EOPNOTSUPP;
}
int devlink_nl_cmd_sb_port_pool_set_doit(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_sb_port_pool_set_doit(struct sk_buff *skb,
struct genl_info *info)
{
struct devlink_port *devlink_port = info->user_ptr[1];
struct devlink *devlink = info->user_ptr[0];
......@@ -861,8 +861,8 @@ static int devlink_sb_tc_pool_bind_set(struct devlink_port *devlink_port,
return -EOPNOTSUPP;
}
int devlink_nl_cmd_sb_tc_pool_bind_set_doit(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_sb_tc_pool_bind_set_doit(struct sk_buff *skb,
struct genl_info *info)
{
struct devlink_port *devlink_port = info->user_ptr[1];
struct devlink *devlink = info->user_ptr[0];
......@@ -900,8 +900,7 @@ int devlink_nl_cmd_sb_tc_pool_bind_set_doit(struct sk_buff *skb,
pool_index, threshold, info->extack);
}
int devlink_nl_cmd_sb_occ_snapshot_doit(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_sb_occ_snapshot_doit(struct sk_buff *skb, struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
const struct devlink_ops *ops = devlink->ops;
......@@ -916,8 +915,8 @@ int devlink_nl_cmd_sb_occ_snapshot_doit(struct sk_buff *skb,
return -EOPNOTSUPP;
}
int devlink_nl_cmd_sb_occ_max_clear_doit(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_sb_occ_max_clear_doit(struct sk_buff *skb,
struct genl_info *info)
{
struct devlink *devlink = info->user_ptr[0];
const struct devlink_ops *ops = devlink->ops;
......
......@@ -414,7 +414,7 @@ static int devlink_trap_action_set(struct devlink *devlink,
info->extack);
}
int devlink_nl_cmd_trap_set_doit(struct sk_buff *skb, struct genl_info *info)
int devlink_nl_trap_set_doit(struct sk_buff *skb, struct genl_info *info)
{
struct netlink_ext_ack *extack = info->extack;
struct devlink *devlink = info->user_ptr[0];
......@@ -684,8 +684,7 @@ static int devlink_trap_group_set(struct devlink *devlink,
return 0;
}
int devlink_nl_cmd_trap_group_set_doit(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_trap_group_set_doit(struct sk_buff *skb, struct genl_info *info)
{
struct netlink_ext_ack *extack = info->extack;
struct devlink *devlink = info->user_ptr[0];
......@@ -926,8 +925,8 @@ devlink_trap_policer_set(struct devlink *devlink,
return 0;
}
int devlink_nl_cmd_trap_policer_set_doit(struct sk_buff *skb,
struct genl_info *info)
int devlink_nl_trap_policer_set_doit(struct sk_buff *skb,
struct genl_info *info)
{
struct devlink_trap_policer_item *policer_item;
struct netlink_ext_ack *extack = info->extack;
......
......@@ -225,7 +225,8 @@ static void genl_op_from_split(struct genl_op_iter *iter)
}
if (i + cnt < family->n_split_ops &&
family->split_ops[i + cnt].flags & GENL_CMD_CAP_DUMP) {
family->split_ops[i + cnt].flags & GENL_CMD_CAP_DUMP &&
(!cnt || family->split_ops[i + cnt].cmd == iter->doit.cmd)) {
iter->dumpit = family->split_ops[i + cnt];
genl_op_fill_in_reject_policy_split(family, &iter->dumpit);
cnt++;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -379,6 +379,12 @@ int ynl_attr_validate(struct ynl_parse_arg *yarg, const struct nlattr *attr)
yerr(yarg->ys, YNL_ERROR_ATTR_INVALID,
"Invalid attribute (string %s)", policy->name);
return -1;
case YNL_PT_BITFIELD32:
if (len == sizeof(struct nla_bitfield32))
break;
yerr(yarg->ys, YNL_ERROR_ATTR_INVALID,
"Invalid attribute (bitfield32 %s)", policy->name);
return -1;
default:
yerr(yarg->ys, YNL_ERROR_ATTR_INVALID,
"Invalid attribute (unknown %s)", policy->name);
......
......@@ -135,6 +135,7 @@ enum ynl_policy_type {
YNL_PT_U64,
YNL_PT_UINT,
YNL_PT_NUL_STR,
YNL_PT_BITFIELD32,
};
struct ynl_policy_attr {
......
......@@ -478,6 +478,8 @@ class YnlFamily(SpecFamily):
elif attr['type'] in NlAttr.type_formats:
format = NlAttr.get_format(attr['type'], attr.byte_order)
attr_payload = format.pack(int(value))
elif attr['type'] in "bitfield32":
attr_payload = struct.pack("II", int(value["value"]), int(value["selector"]))
else:
raise Exception(f'Unknown type at {space} {name} {value} {attr["type"]}')
......@@ -545,14 +547,19 @@ class YnlFamily(SpecFamily):
decoded = attr.as_auto_scalar(attr_spec['type'], attr_spec.byte_order)
elif attr_spec["type"] in NlAttr.type_formats:
decoded = attr.as_scalar(attr_spec['type'], attr_spec.byte_order)
if 'enum' in attr_spec:
decoded = self._decode_enum(decoded, attr_spec)
elif attr_spec["type"] == 'array-nest':
decoded = self._decode_array_nest(attr, attr_spec)
elif attr_spec["type"] == 'bitfield32':
value, selector = struct.unpack("II", attr.raw)
if 'enum' in attr_spec:
value = self._decode_enum(value, attr_spec)
selector = self._decode_enum(selector, attr_spec)
decoded = {"value": value, "selector": selector}
else:
raise Exception(f'Unknown {attr_spec["type"]} with name {attr_spec["name"]}')
if 'enum' in attr_spec:
decoded = self._decode_enum(decoded, attr_spec)
if not attr_spec.is_multi:
rsp[attr_spec['name']] = decoded
elif attr_spec.name in rsp:
......
......@@ -488,6 +488,31 @@ class TypeBinary(Type):
f'memcpy({member}, {self.c_name}, {presence}_len);']
class TypeBitfield32(Type):
def _complex_member_type(self, ri):
return "struct nla_bitfield32"
def _attr_typol(self):
return f'.type = YNL_PT_BITFIELD32, '
def _attr_policy(self, policy):
if not 'enum' in self.attr:
raise Exception('Enum required for bitfield32 attr')
enum = self.family.consts[self.attr['enum']]
mask = enum.get_mask(as_flags=True)
return f"NLA_POLICY_BITFIELD32({mask})"
def attr_put(self, ri, var):
line = f"mnl_attr_put(nlh, {self.enum_name}, sizeof(struct nla_bitfield32), &{var}->{self.c_name})"
self._attr_put_line(ri, var, line)
def _attr_get(self, ri, var):
return f"memcpy(&{var}->{self.c_name}, mnl_attr_get_payload(attr), sizeof(struct nla_bitfield32));", None, None
def _setter_lines(self, ri, member, presence):
return [f"memcpy(&{member}, {self.c_name}, sizeof(struct nla_bitfield32));"]
class TypeNest(Type):
def _complex_member_type(self, ri):
return self.nested_struct_type
......@@ -786,6 +811,8 @@ class AttrSet(SpecAttrSet):
t = TypeString(self.family, self, elem, value)
elif elem['type'] == 'binary':
t = TypeBinary(self.family, self, elem, value)
elif elem['type'] == 'bitfield32':
t = TypeBitfield32(self.family, self, elem, value)
elif elem['type'] == 'nest':
t = TypeNest(self.family, self, elem, value)
elif elem['type'] == 'array-nest':
......@@ -1085,10 +1112,13 @@ class RenderInfo:
# 'do' and 'dump' response parsing is identical
self.type_consistent = True
if op_mode != 'do' and 'dump' in op and 'do' in op:
if ('reply' in op['do']) != ('reply' in op["dump"]):
self.type_consistent = False
elif 'reply' in op['do'] and op["do"]["reply"] != op["dump"]["reply"]:
if op_mode != 'do' and 'dump' in op:
if 'do' in op:
if ('reply' in op['do']) != ('reply' in op["dump"]):
self.type_consistent = False
elif 'reply' in op['do'] and op["do"]["reply"] != op["dump"]["reply"]:
self.type_consistent = False
else:
self.type_consistent = False
self.attr_set = attr_set
......@@ -2414,6 +2444,16 @@ def render_user_family(family, cw, prototype):
cw.block_end(line=';')
def family_contains_bitfield32(family):
for _, attr_set in family.attr_sets.items():
if attr_set.subset_of:
continue
for _, attr in attr_set.items():
if attr.type == "bitfield32":
return True
return False
def find_kernel_root(full_path):
sub_path = ''
while True:
......@@ -2499,6 +2539,8 @@ def main():
cw.p('#include <string.h>')
if args.header:
cw.p('#include <linux/types.h>')
if family_contains_bitfield32(parsed):
cw.p('#include <linux/netlink.h>')
else:
cw.p(f'#include "{parsed.name}-user.h"')
cw.p('#include "ynl.h"')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment