netlink: specs: support setting prefix-name per attribute
Ethtool's PSE PoDL has a attr nest with different prefixes: /* Power Sourcing Equipment */ enum { ETHTOOL_A_PSE_UNSPEC, ETHTOOL_A_PSE_HEADER, /* nest - _A_HEADER_* */ ETHTOOL_A_PODL_PSE_ADMIN_STATE, /* u32 */ ETHTOOL_A_PODL_PSE_ADMIN_CONTROL, /* u32 */ ETHTOOL_A_PODL_PSE_PW_D_STATUS, /* u32 */ Header has a prefix of ETHTOOL_A_PSE_ and other attrs prefix of ETHTOOL_A_PODL_PSE_ we can't cover them uniformly. If PODL was after PSE life would be easy. Now we either need to add prefixes to attr names which is yucky or support setting prefix name per attr. Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
33eedb0071
commit
ed2042cc77
@ -195,6 +195,10 @@ properties:
|
|||||||
description: Max length for a string or a binary attribute.
|
description: Max length for a string or a binary attribute.
|
||||||
$ref: '#/$defs/len-or-define'
|
$ref: '#/$defs/len-or-define'
|
||||||
sub-type: *attr-type
|
sub-type: *attr-type
|
||||||
|
# Start genetlink-c
|
||||||
|
name-prefix:
|
||||||
|
type: string
|
||||||
|
# End genetlink-c
|
||||||
|
|
||||||
# Make sure name-prefix does not appear in subsets (subsets inherit naming)
|
# Make sure name-prefix does not appear in subsets (subsets inherit naming)
|
||||||
dependencies:
|
dependencies:
|
||||||
|
@ -226,6 +226,10 @@ properties:
|
|||||||
description: Max length for a string or a binary attribute.
|
description: Max length for a string or a binary attribute.
|
||||||
$ref: '#/$defs/len-or-define'
|
$ref: '#/$defs/len-or-define'
|
||||||
sub-type: *attr-type
|
sub-type: *attr-type
|
||||||
|
# Start genetlink-c
|
||||||
|
name-prefix:
|
||||||
|
type: string
|
||||||
|
# End genetlink-c
|
||||||
# Start genetlink-legacy
|
# Start genetlink-legacy
|
||||||
struct:
|
struct:
|
||||||
description: Name of the struct type used for the attribute.
|
description: Name of the struct type used for the attribute.
|
||||||
|
@ -58,8 +58,11 @@ class Type(SpecAttr):
|
|||||||
delattr(self, "enum_name")
|
delattr(self, "enum_name")
|
||||||
|
|
||||||
def resolve(self):
|
def resolve(self):
|
||||||
self.enum_name = f"{self.attr_set.name_prefix}{self.name}"
|
if 'name-prefix' in self.attr:
|
||||||
self.enum_name = c_upper(self.enum_name)
|
enum_name = f"{self.attr['name-prefix']}{self.name}"
|
||||||
|
else:
|
||||||
|
enum_name = f"{self.attr_set.name_prefix}{self.name}"
|
||||||
|
self.enum_name = c_upper(enum_name)
|
||||||
|
|
||||||
def is_multi_val(self):
|
def is_multi_val(self):
|
||||||
return None
|
return None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user