1*e616c07cSJakub Kicinski# SPDX-License-Identifier: GPL-2.0
2*e616c07cSJakub Kicinski%YAML 1.2
3*e616c07cSJakub Kicinski---
4*e616c07cSJakub Kicinski$id: http://kernel.org/schemas/netlink/genetlink-legacy.yaml#
5*e616c07cSJakub Kicinski$schema: https://json-schema.org/draft-07/schema
6*e616c07cSJakub Kicinski
7*e616c07cSJakub Kicinski# Common defines
8*e616c07cSJakub Kicinski$defs:
9*e616c07cSJakub Kicinski  uint:
10*e616c07cSJakub Kicinski    type: integer
11*e616c07cSJakub Kicinski    minimum: 0
12*e616c07cSJakub Kicinski  len-or-define:
13*e616c07cSJakub Kicinski    type: [ string, integer ]
14*e616c07cSJakub Kicinski    pattern: ^[0-9A-Za-z_]+( - 1)?$
15*e616c07cSJakub Kicinski    minimum: 0
16*e616c07cSJakub Kicinski
17*e616c07cSJakub Kicinski# Schema for specs
18*e616c07cSJakub Kicinskititle: Protocol
19*e616c07cSJakub Kicinskidescription: Specification of a genetlink protocol
20*e616c07cSJakub Kicinskitype: object
21*e616c07cSJakub Kicinskirequired: [ name, doc, attribute-sets, operations ]
22*e616c07cSJakub KicinskiadditionalProperties: False
23*e616c07cSJakub Kicinskiproperties:
24*e616c07cSJakub Kicinski  name:
25*e616c07cSJakub Kicinski    description: Name of the genetlink family.
26*e616c07cSJakub Kicinski    type: string
27*e616c07cSJakub Kicinski  doc:
28*e616c07cSJakub Kicinski    type: string
29*e616c07cSJakub Kicinski  version:
30*e616c07cSJakub Kicinski    description: Generic Netlink family version. Default is 1.
31*e616c07cSJakub Kicinski    type: integer
32*e616c07cSJakub Kicinski    minimum: 1
33*e616c07cSJakub Kicinski  protocol:
34*e616c07cSJakub Kicinski    description: Schema compatibility level. Default is "genetlink".
35*e616c07cSJakub Kicinski    enum: [ genetlink, genetlink-c, genetlink-legacy ] # Trim
36*e616c07cSJakub Kicinski  # Start genetlink-c
37*e616c07cSJakub Kicinski  uapi-header:
38*e616c07cSJakub Kicinski    description: Path to the uAPI header, default is linux/${family-name}.h
39*e616c07cSJakub Kicinski    type: string
40*e616c07cSJakub Kicinski  c-family-name:
41*e616c07cSJakub Kicinski    description: Name of the define for the family name.
42*e616c07cSJakub Kicinski    type: string
43*e616c07cSJakub Kicinski  c-version-name:
44*e616c07cSJakub Kicinski    description: Name of the define for the verion of the family.
45*e616c07cSJakub Kicinski    type: string
46*e616c07cSJakub Kicinski  max-by-define:
47*e616c07cSJakub Kicinski    description: Makes the number of attributes and commands be specified by a define, not an enum value.
48*e616c07cSJakub Kicinski    type: boolean
49*e616c07cSJakub Kicinski  # End genetlink-c
50*e616c07cSJakub Kicinski  # Start genetlink-legacy
51*e616c07cSJakub Kicinski  kernel-policy:
52*e616c07cSJakub Kicinski    description: |
53*e616c07cSJakub Kicinski      Defines if the input policy in the kernel is global, per-operation, or split per operation type.
54*e616c07cSJakub Kicinski      Default is split.
55*e616c07cSJakub Kicinski    enum: [ split, per-op, global ]
56*e616c07cSJakub Kicinski  # End genetlink-legacy
57*e616c07cSJakub Kicinski
58*e616c07cSJakub Kicinski  definitions:
59*e616c07cSJakub Kicinski    description: List of type and constant definitions (enums, flags, defines).
60*e616c07cSJakub Kicinski    type: array
61*e616c07cSJakub Kicinski    items:
62*e616c07cSJakub Kicinski      type: object
63*e616c07cSJakub Kicinski      required: [ type, name ]
64*e616c07cSJakub Kicinski      additionalProperties: False
65*e616c07cSJakub Kicinski      properties:
66*e616c07cSJakub Kicinski        name:
67*e616c07cSJakub Kicinski          type: string
68*e616c07cSJakub Kicinski        header:
69*e616c07cSJakub Kicinski          description: For C-compatible languages, header which already defines this value.
70*e616c07cSJakub Kicinski          type: string
71*e616c07cSJakub Kicinski        type:
72*e616c07cSJakub Kicinski          enum: [ const, enum, flags, struct ] # Trim
73*e616c07cSJakub Kicinski        doc:
74*e616c07cSJakub Kicinski          type: string
75*e616c07cSJakub Kicinski        # For const
76*e616c07cSJakub Kicinski        value:
77*e616c07cSJakub Kicinski          description: For const - the value.
78*e616c07cSJakub Kicinski          type: [ string, integer ]
79*e616c07cSJakub Kicinski        # For enum and flags
80*e616c07cSJakub Kicinski        value-start:
81*e616c07cSJakub Kicinski          description: For enum or flags the literal initializer for the first value.
82*e616c07cSJakub Kicinski          type: [ string, integer ]
83*e616c07cSJakub Kicinski        entries:
84*e616c07cSJakub Kicinski          description: For enum or flags array of values.
85*e616c07cSJakub Kicinski          type: array
86*e616c07cSJakub Kicinski          items:
87*e616c07cSJakub Kicinski            oneOf:
88*e616c07cSJakub Kicinski              - type: string
89*e616c07cSJakub Kicinski              - type: object
90*e616c07cSJakub Kicinski                required: [ name ]
91*e616c07cSJakub Kicinski                additionalProperties: False
92*e616c07cSJakub Kicinski                properties:
93*e616c07cSJakub Kicinski                  name:
94*e616c07cSJakub Kicinski                    type: string
95*e616c07cSJakub Kicinski                  value:
96*e616c07cSJakub Kicinski                    type: integer
97*e616c07cSJakub Kicinski                  doc:
98*e616c07cSJakub Kicinski                    type: string
99*e616c07cSJakub Kicinski        render-max:
100*e616c07cSJakub Kicinski          description: Render the max members for this enum.
101*e616c07cSJakub Kicinski          type: boolean
102*e616c07cSJakub Kicinski        # Start genetlink-c
103*e616c07cSJakub Kicinski        enum-name:
104*e616c07cSJakub Kicinski          description: Name for enum, if empty no name will be used.
105*e616c07cSJakub Kicinski          type: [ string, "null" ]
106*e616c07cSJakub Kicinski        name-prefix:
107*e616c07cSJakub Kicinski          description: For enum the prefix of the values, optional.
108*e616c07cSJakub Kicinski          type: string
109*e616c07cSJakub Kicinski        # End genetlink-c
110*e616c07cSJakub Kicinski        # Start genetlink-legacy
111*e616c07cSJakub Kicinski        members:
112*e616c07cSJakub Kicinski          description: List of struct members. Only scalars and strings members allowed.
113*e616c07cSJakub Kicinski          type: array
114*e616c07cSJakub Kicinski          items:
115*e616c07cSJakub Kicinski            type: object
116*e616c07cSJakub Kicinski            required: [ name, type ]
117*e616c07cSJakub Kicinski            additionalProperties: False
118*e616c07cSJakub Kicinski            properties:
119*e616c07cSJakub Kicinski              name:
120*e616c07cSJakub Kicinski                type: string
121*e616c07cSJakub Kicinski              type:
122*e616c07cSJakub Kicinski                enum: [ u8, u16, u32, u64, s8, s16, s32, s64, string ]
123*e616c07cSJakub Kicinski              len:
124*e616c07cSJakub Kicinski                $ref: '#/$defs/len-or-define'
125*e616c07cSJakub Kicinski        # End genetlink-legacy
126*e616c07cSJakub Kicinski
127*e616c07cSJakub Kicinski  attribute-sets:
128*e616c07cSJakub Kicinski    description: Definition of attribute spaces for this family.
129*e616c07cSJakub Kicinski    type: array
130*e616c07cSJakub Kicinski    items:
131*e616c07cSJakub Kicinski      description: Definition of a single attribute space.
132*e616c07cSJakub Kicinski      type: object
133*e616c07cSJakub Kicinski      required: [ name, attributes ]
134*e616c07cSJakub Kicinski      additionalProperties: False
135*e616c07cSJakub Kicinski      properties:
136*e616c07cSJakub Kicinski        name:
137*e616c07cSJakub Kicinski          description: |
138*e616c07cSJakub Kicinski            Name used when referring to this space in other definitions, not used outside of the spec.
139*e616c07cSJakub Kicinski          type: string
140*e616c07cSJakub Kicinski        name-prefix:
141*e616c07cSJakub Kicinski          description: |
142*e616c07cSJakub Kicinski            Prefix for the C enum name of the attributes. Default family[name]-set[name]-a-
143*e616c07cSJakub Kicinski          type: string
144*e616c07cSJakub Kicinski        enum-name:
145*e616c07cSJakub Kicinski          description: Name for the enum type of the attribute.
146*e616c07cSJakub Kicinski          type: string
147*e616c07cSJakub Kicinski        doc:
148*e616c07cSJakub Kicinski          description: Documentation of the space.
149*e616c07cSJakub Kicinski          type: string
150*e616c07cSJakub Kicinski        subset-of:
151*e616c07cSJakub Kicinski          description: |
152*e616c07cSJakub Kicinski            Name of another space which this is a logical part of. Sub-spaces can be used to define
153*e616c07cSJakub Kicinski            a limited group of attributes which are used in a nest.
154*e616c07cSJakub Kicinski          type: string
155*e616c07cSJakub Kicinski        # Start genetlink-c
156*e616c07cSJakub Kicinski        attr-cnt-name:
157*e616c07cSJakub Kicinski          description: The explicit name for constant holding the count of attributes (last attr + 1).
158*e616c07cSJakub Kicinski          type: string
159*e616c07cSJakub Kicinski        attr-max-name:
160*e616c07cSJakub Kicinski          description: The explicit name for last member of attribute enum.
161*e616c07cSJakub Kicinski          type: string
162*e616c07cSJakub Kicinski        # End genetlink-c
163*e616c07cSJakub Kicinski        attributes:
164*e616c07cSJakub Kicinski          description: List of attributes in the space.
165*e616c07cSJakub Kicinski          type: array
166*e616c07cSJakub Kicinski          items:
167*e616c07cSJakub Kicinski            type: object
168*e616c07cSJakub Kicinski            required: [ name, type ]
169*e616c07cSJakub Kicinski            additionalProperties: False
170*e616c07cSJakub Kicinski            properties:
171*e616c07cSJakub Kicinski              name:
172*e616c07cSJakub Kicinski                type: string
173*e616c07cSJakub Kicinski              type: &attr-type
174*e616c07cSJakub Kicinski                enum: [ unused, pad, flag, binary, u8, u16, u32, u64, s32, s64,
175*e616c07cSJakub Kicinski                        string, nest, array-nest, nest-type-value ]
176*e616c07cSJakub Kicinski              doc:
177*e616c07cSJakub Kicinski                description: Documentation of the attribute.
178*e616c07cSJakub Kicinski                type: string
179*e616c07cSJakub Kicinski              value:
180*e616c07cSJakub Kicinski                description: Value for the enum item representing this attribute in the uAPI.
181*e616c07cSJakub Kicinski                $ref: '#/$defs/uint'
182*e616c07cSJakub Kicinski              type-value:
183*e616c07cSJakub Kicinski                description: Name of the value extracted from the type of a nest-type-value attribute.
184*e616c07cSJakub Kicinski                type: array
185*e616c07cSJakub Kicinski                items:
186*e616c07cSJakub Kicinski                  type: string
187*e616c07cSJakub Kicinski              byte-order:
188*e616c07cSJakub Kicinski                enum: [ little-endian, big-endian ]
189*e616c07cSJakub Kicinski              multi-attr:
190*e616c07cSJakub Kicinski                type: boolean
191*e616c07cSJakub Kicinski              nested-attributes:
192*e616c07cSJakub Kicinski                description: Name of the space (sub-space) used inside the attribute.
193*e616c07cSJakub Kicinski                type: string
194*e616c07cSJakub Kicinski              enum:
195*e616c07cSJakub Kicinski                description: Name of the enum type used for the attribute.
196*e616c07cSJakub Kicinski                type: string
197*e616c07cSJakub Kicinski              enum-as-flags:
198*e616c07cSJakub Kicinski                description: |
199*e616c07cSJakub Kicinski                  Treat the enum as flags. In most cases enum is either used as flags or as values.
200*e616c07cSJakub Kicinski                  Sometimes, however, both forms are necessary, in which case header contains the enum
201*e616c07cSJakub Kicinski                  form while specific attributes may request to convert the values into a bitfield.
202*e616c07cSJakub Kicinski                type: boolean
203*e616c07cSJakub Kicinski              checks:
204*e616c07cSJakub Kicinski                description: Kernel input validation.
205*e616c07cSJakub Kicinski                type: object
206*e616c07cSJakub Kicinski                additionalProperties: False
207*e616c07cSJakub Kicinski                properties:
208*e616c07cSJakub Kicinski                  flags-mask:
209*e616c07cSJakub Kicinski                    description: Name of the flags constant on which to base mask (unsigned scalar types only).
210*e616c07cSJakub Kicinski                    type: string
211*e616c07cSJakub Kicinski                  min:
212*e616c07cSJakub Kicinski                    description: Min value for an integer attribute.
213*e616c07cSJakub Kicinski                    type: integer
214*e616c07cSJakub Kicinski                  min-len:
215*e616c07cSJakub Kicinski                    description: Min length for a binary attribute.
216*e616c07cSJakub Kicinski                    $ref: '#/$defs/len-or-define'
217*e616c07cSJakub Kicinski                  max-len:
218*e616c07cSJakub Kicinski                    description: Max length for a string or a binary attribute.
219*e616c07cSJakub Kicinski                    $ref: '#/$defs/len-or-define'
220*e616c07cSJakub Kicinski              sub-type: *attr-type
221*e616c07cSJakub Kicinski
222*e616c07cSJakub Kicinski      # Make sure name-prefix does not appear in subsets (subsets inherit naming)
223*e616c07cSJakub Kicinski      dependencies:
224*e616c07cSJakub Kicinski        name-prefix:
225*e616c07cSJakub Kicinski          not:
226*e616c07cSJakub Kicinski            required: [ subset-of ]
227*e616c07cSJakub Kicinski        subset-of:
228*e616c07cSJakub Kicinski          not:
229*e616c07cSJakub Kicinski            required: [ name-prefix ]
230*e616c07cSJakub Kicinski
231*e616c07cSJakub Kicinski  operations:
232*e616c07cSJakub Kicinski    description: Operations supported by the protocol.
233*e616c07cSJakub Kicinski    type: object
234*e616c07cSJakub Kicinski    required: [ list ]
235*e616c07cSJakub Kicinski    additionalProperties: False
236*e616c07cSJakub Kicinski    properties:
237*e616c07cSJakub Kicinski      enum-model:
238*e616c07cSJakub Kicinski        description: |
239*e616c07cSJakub Kicinski          The model of assigning values to the operations.
240*e616c07cSJakub Kicinski          "unified" is the recommended model where all message types belong
241*e616c07cSJakub Kicinski          to a single enum.
242*e616c07cSJakub Kicinski          "directional" has the messages sent to the kernel and from the kernel
243*e616c07cSJakub Kicinski          enumerated separately.
244*e616c07cSJakub Kicinski          "notify-split" has the notifications and request-response types in
245*e616c07cSJakub Kicinski          different enums.
246*e616c07cSJakub Kicinski        enum: [ unified, directional, notify-split ]
247*e616c07cSJakub Kicinski      name-prefix:
248*e616c07cSJakub Kicinski        description: |
249*e616c07cSJakub Kicinski          Prefix for the C enum name of the command. The name is formed by concatenating
250*e616c07cSJakub Kicinski          the prefix with the upper case name of the command, with dashes replaced by underscores.
251*e616c07cSJakub Kicinski        type: string
252*e616c07cSJakub Kicinski      enum-name:
253*e616c07cSJakub Kicinski        description: Name for the enum type with commands.
254*e616c07cSJakub Kicinski        type: string
255*e616c07cSJakub Kicinski      async-prefix:
256*e616c07cSJakub Kicinski        description: Same as name-prefix but used to render notifications and events to separate enum.
257*e616c07cSJakub Kicinski        type: string
258*e616c07cSJakub Kicinski      async-enum:
259*e616c07cSJakub Kicinski        description: Name for the enum type with notifications/events.
260*e616c07cSJakub Kicinski        type: string
261*e616c07cSJakub Kicinski      list:
262*e616c07cSJakub Kicinski        description: List of commands
263*e616c07cSJakub Kicinski        type: array
264*e616c07cSJakub Kicinski        items:
265*e616c07cSJakub Kicinski          type: object
266*e616c07cSJakub Kicinski          additionalProperties: False
267*e616c07cSJakub Kicinski          required: [ name, doc ]
268*e616c07cSJakub Kicinski          properties:
269*e616c07cSJakub Kicinski            name:
270*e616c07cSJakub Kicinski              description: Name of the operation, also defining its C enum value in uAPI.
271*e616c07cSJakub Kicinski              type: string
272*e616c07cSJakub Kicinski            doc:
273*e616c07cSJakub Kicinski              description: Documentation for the command.
274*e616c07cSJakub Kicinski              type: string
275*e616c07cSJakub Kicinski            value:
276*e616c07cSJakub Kicinski              description: Value for the enum in the uAPI.
277*e616c07cSJakub Kicinski              $ref: '#/$defs/uint'
278*e616c07cSJakub Kicinski            attribute-set:
279*e616c07cSJakub Kicinski              description: |
280*e616c07cSJakub Kicinski                Attribute space from which attributes directly in the requests and replies
281*e616c07cSJakub Kicinski                to this command are defined.
282*e616c07cSJakub Kicinski              type: string
283*e616c07cSJakub Kicinski            flags: &cmd_flags
284*e616c07cSJakub Kicinski              description: Command flags.
285*e616c07cSJakub Kicinski              type: array
286*e616c07cSJakub Kicinski              items:
287*e616c07cSJakub Kicinski                enum: [ admin-perm ]
288*e616c07cSJakub Kicinski            dont-validate:
289*e616c07cSJakub Kicinski              description: Kernel attribute validation flags.
290*e616c07cSJakub Kicinski              type: array
291*e616c07cSJakub Kicinski              items:
292*e616c07cSJakub Kicinski                enum: [ strict, dump ]
293*e616c07cSJakub Kicinski            do: &subop-type
294*e616c07cSJakub Kicinski              description: Main command handler.
295*e616c07cSJakub Kicinski              type: object
296*e616c07cSJakub Kicinski              additionalProperties: False
297*e616c07cSJakub Kicinski              properties:
298*e616c07cSJakub Kicinski                request: &subop-attr-list
299*e616c07cSJakub Kicinski                  description: Definition of the request message for a given command.
300*e616c07cSJakub Kicinski                  type: object
301*e616c07cSJakub Kicinski                  additionalProperties: False
302*e616c07cSJakub Kicinski                  properties:
303*e616c07cSJakub Kicinski                    attributes:
304*e616c07cSJakub Kicinski                      description: |
305*e616c07cSJakub Kicinski                        Names of attributes from the attribute-set (not full attribute
306*e616c07cSJakub Kicinski                        definitions, just names).
307*e616c07cSJakub Kicinski                      type: array
308*e616c07cSJakub Kicinski                      items:
309*e616c07cSJakub Kicinski                        type: string
310*e616c07cSJakub Kicinski                reply: *subop-attr-list
311*e616c07cSJakub Kicinski                pre:
312*e616c07cSJakub Kicinski                  description: Hook for a function to run before the main callback (pre_doit or start).
313*e616c07cSJakub Kicinski                  type: string
314*e616c07cSJakub Kicinski                post:
315*e616c07cSJakub Kicinski                  description: Hook for a function to run after the main callback (post_doit or done).
316*e616c07cSJakub Kicinski                  type: string
317*e616c07cSJakub Kicinski            dump: *subop-type
318*e616c07cSJakub Kicinski            notify:
319*e616c07cSJakub Kicinski              description: Name of the command sharing the reply type with this notification.
320*e616c07cSJakub Kicinski              type: string
321*e616c07cSJakub Kicinski            event:
322*e616c07cSJakub Kicinski              type: object
323*e616c07cSJakub Kicinski              additionalProperties: False
324*e616c07cSJakub Kicinski              properties:
325*e616c07cSJakub Kicinski                attributes:
326*e616c07cSJakub Kicinski                  description: Explicit list of the attributes for the notification.
327*e616c07cSJakub Kicinski                  type: array
328*e616c07cSJakub Kicinski                  items:
329*e616c07cSJakub Kicinski                    type: string
330*e616c07cSJakub Kicinski            mcgrp:
331*e616c07cSJakub Kicinski              description: Name of the multicast group generating given notification.
332*e616c07cSJakub Kicinski              type: string
333*e616c07cSJakub Kicinski  mcast-groups:
334*e616c07cSJakub Kicinski    description: List of multicast groups.
335*e616c07cSJakub Kicinski    type: object
336*e616c07cSJakub Kicinski    required: [ list ]
337*e616c07cSJakub Kicinski    additionalProperties: False
338*e616c07cSJakub Kicinski    properties:
339*e616c07cSJakub Kicinski      list:
340*e616c07cSJakub Kicinski        description: List of groups.
341*e616c07cSJakub Kicinski        type: array
342*e616c07cSJakub Kicinski        items:
343*e616c07cSJakub Kicinski          type: object
344*e616c07cSJakub Kicinski          required: [ name ]
345*e616c07cSJakub Kicinski          additionalProperties: False
346*e616c07cSJakub Kicinski          properties:
347*e616c07cSJakub Kicinski            name:
348*e616c07cSJakub Kicinski              description: |
349*e616c07cSJakub Kicinski                The name for the group, used to form the define and the value of the define.
350*e616c07cSJakub Kicinski              type: string
351*e616c07cSJakub Kicinski            # Start genetlink-c
352*e616c07cSJakub Kicinski            c-define-name:
353*e616c07cSJakub Kicinski              description: Override for the name of the define in C uAPI.
354*e616c07cSJakub Kicinski              type: string
355*e616c07cSJakub Kicinski            # End genetlink-c
356*e616c07cSJakub Kicinski            flags: *cmd_flags
357