From patchwork Thu Oct 3 15:01:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13821118 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 04B2D16F0F0 for ; Thu, 3 Oct 2024 15:01:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727967718; cv=none; b=fdAqautkYpXLpEVE6UP8R3W9qlc6Ktsh5CTdDZnYceIoc0MTzaB1qC3tiDgDuLPpeNPrXR7VuVdxysz7eW73DJ5JWekoRqvvTAX2f5SNwz0RDa7s/dJY3W0JR8pRbmNeoRGh+XLAAjXjmvBd8Rs3I+IEiyKo+9LECZnOv+vyX+Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727967718; c=relaxed/simple; bh=gRs3qK/pMAHS5JndlfkrrZYNxpjLyrlsQBN+cRdHt40=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=N1qeSJm0PaIAevGo+PWOj/QhwKbC225O4PWevqRMzr0QdY7GsNbvMlZwDVgVMz9hII2bSzgThIwulSgcOW0SI6Wk8w5bxEI7+t+Om/ASGR6uYeEjShxIjRKHhnTJ70hVWoO8+pVZ12Wv+0L7jzB0gH1N4dqUqwzGCqRK62EINfc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rVzzRMBW; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="rVzzRMBW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0661EC4CECE; Thu, 3 Oct 2024 15:01:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727967717; bh=gRs3qK/pMAHS5JndlfkrrZYNxpjLyrlsQBN+cRdHt40=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rVzzRMBWgkVRD61fbpjzXI/CDckeXMyNEqNuu2Clp2719yeuyU8qQYNxvbZIm7ECT E6YGwvXI6pymJ4xC10Tj92oLPZix7nMaRgv/AnXJ/sp/3AwIRZgC+N/qsey/TbgSa7 pksbBIHs3CuvGvAFaVZydRLLWxJtkGuVlzZTvr/26rlcnka5WcadaDqnESfeBRCZ9I 6t0NPZsXIoAt686UuEBygAP6uE6vjACfscAEJ/dx/xx/qVu7kKrBVQjTQk9+N+sqgx 32KEUP9//mN+ydN04f2ClLoHlcPVHjVCCOiTtcP+k8ocwT7kKP0nFTetE+1CbxTHYW 7p4u2PhQNyVXQ== From: cel@kernel.org To: Neil Brown , Jeff Layton , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: , Chuck Lever Subject: [PATCH 01/16] xdrgen: Refactor transformer arms Date: Thu, 3 Oct 2024 11:01:43 -0400 Message-ID: <20241003150151.81951-2-cel@kernel.org> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003150151.81951-1-cel@kernel.org> References: <20241003150151.81951-1-cel@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Chuck Lever Clean up: Add a __post_init__ function to the data classes that need to update the "structs" and "pass_by_reference" sets. Signed-off-by: Chuck Lever --- tools/net/sunrpc/xdrgen/xdr_ast.py | 57 +++++++++++++++++------------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/tools/net/sunrpc/xdrgen/xdr_ast.py b/tools/net/sunrpc/xdrgen/xdr_ast.py index d5f0535ec84c..68f09945f2c4 100644 --- a/tools/net/sunrpc/xdrgen/xdr_ast.py +++ b/tools/net/sunrpc/xdrgen/xdr_ast.py @@ -51,13 +51,17 @@ class _XdrTypeSpecifier(_XdrAst): """Corresponds to 'type_specifier' in the XDR language grammar""" type_name: str - c_classifier: str + c_classifier: str = "" @dataclass class _XdrDefinedType(_XdrTypeSpecifier): """Corresponds to a type defined by the input specification""" + def __post_init__(self): + if self.type_name in structs: + self.c_classifier = "struct " + @dataclass class _XdrBuiltInType(_XdrTypeSpecifier): @@ -124,6 +128,10 @@ class _XdrOptionalData(_XdrDeclaration): spec: _XdrTypeSpecifier template: str = "optional_data" + def __post_init__(self): + structs.add(self.name) + pass_by_reference.add(self.name) + @dataclass class _XdrBasic(_XdrDeclaration): @@ -174,6 +182,10 @@ class _XdrStruct(_XdrAst): name: str fields: List[_XdrDeclaration] + def __post_init__(self): + structs.add(self.name) + pass_by_reference.add(self.name) + @dataclass class _XdrPointer(_XdrAst): @@ -182,6 +194,10 @@ class _XdrPointer(_XdrAst): name: str fields: List[_XdrDeclaration] + def __post_init__(self): + structs.add(self.name) + pass_by_reference.add(self.name) + @dataclass class _XdrTypedef(_XdrAst): @@ -189,6 +205,15 @@ class _XdrTypedef(_XdrAst): declaration: _XdrDeclaration + def __post_init__(self): + if not isinstance(self.declaration, _XdrBasic): + return + + new_type = self.declaration + if isinstance(new_type.spec, _XdrDefinedType): + if new_type.spec.type_name in pass_by_reference: + pass_by_reference.add(new_type.name) + @dataclass class _XdrCaseSpec(_XdrAst): @@ -216,6 +241,10 @@ class _XdrUnion(_XdrAst): cases: List[_XdrCaseSpec] default: _XdrDeclaration + def __post_init__(self): + structs.add(self.name) + pass_by_reference.add(self.name) + @dataclass class _RpcProcedure(_XdrAst): @@ -290,22 +319,13 @@ class ParseToAst(Transformer): return _XdrConstantValue(value) def type_specifier(self, children): - """Instantiate one type_specifier object""" - c_classifier = "" + """Instantiate one _XdrTypeSpecifier object""" if isinstance(children[0], _XdrIdentifier): name = children[0].symbol - if name in structs: - c_classifier = "struct " - return _XdrDefinedType( - type_name=name, - c_classifier=c_classifier, - ) + return _XdrDefinedType(type_name=name) name = children[0].data.value - return _XdrBuiltInType( - type_name=name, - c_classifier=c_classifier, - ) + return _XdrBuiltInType(type_name=name) def constant_def(self, children): """Instantiate one _XdrConstant object""" @@ -380,8 +400,6 @@ class ParseToAst(Transformer): """Instantiate one _XdrOptionalData declaration object""" spec = children[0] name = children[1].symbol - structs.add(name) - pass_by_reference.add(name) return _XdrOptionalData(name, spec) @@ -400,8 +418,6 @@ class ParseToAst(Transformer): def struct(self, children): """Instantiate one _XdrStruct object""" name = children[0].symbol - structs.add(name) - pass_by_reference.add(name) fields = children[1].children last_field = fields[-1] @@ -416,11 +432,6 @@ class ParseToAst(Transformer): def typedef(self, children): """Instantiate one _XdrTypedef object""" new_type = children[0] - if isinstance(new_type, _XdrBasic) and isinstance( - new_type.spec, _XdrDefinedType - ): - if new_type.spec.type_name in pass_by_reference: - pass_by_reference.add(new_type.name) return _XdrTypedef(new_type) @@ -442,8 +453,6 @@ class ParseToAst(Transformer): def union(self, children): """Instantiate one _XdrUnion object""" name = children[0].symbol - structs.add(name) - pass_by_reference.add(name) body = children[1] discriminant = body.children[0].children[0] From patchwork Thu Oct 3 15:01:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13821119 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0BA7F16F0F0 for ; Thu, 3 Oct 2024 15:01:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727967719; cv=none; b=OGk3SkFY2A87aJGakAwm1dmWTD6PVr9E4nEHKnPIaj+DqncsWoRvAN6Z/tpK7Z3eY/Nb7bbR2NGPX8cBy1QXXTQsR9hXp/Gx96eCDtimUv0Sz76wyGLTLzlO+0Q1RskUTnEz2E+mBIAIc7fAJVL16aNLW3nZlZqt1+eM29GttRM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727967719; c=relaxed/simple; bh=Bk6ELu4MeGgeda4QU7tKlTn/kVW80wjJBNqAYlXaxgs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pZgSwTSezgE+RZWojGHKSSEzAHJcv5Dkjvxrrnegj+h71sOQiLD6HoDpC/v4qfurR7BIEDzGhZwIcVRLAU5/pG54UG+XxIbwkx1wFx0uKwwSdPwy4Hy5p1ZpiUJnZ+ctqgFn4wKdAdbUCz/glYJB+SG1NVLdQm74d6TS7kECd5E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pb6UjcRL; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pb6UjcRL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E42EDC4CECF; Thu, 3 Oct 2024 15:01:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727967718; bh=Bk6ELu4MeGgeda4QU7tKlTn/kVW80wjJBNqAYlXaxgs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pb6UjcRLJlJ9RBiRVslMPJXKkVxx18AAT//dWzcbOvbMwxfqDrITc5c2LecRVSuIG p0Rp7aSyfKIE1Xw4OkJvwk5AN8SIS8p3pFqzFAxda6n45eSGsLR97n2VFj/wItDW5z V1JmY/y714gz1RAK1RIyAS1ZUNUuGYhO9jg4uJFvV9nMQFFLdWZRk6JUUcMgdgW6sO GLRRnHy4VtK0rEkzewmbJxCeSJg9bU1jU/hBhUG14bArU86Pmi4IOu+KDMKthKUU+y a94r62MBmS47Tf/7XN+obaFTyR/3QQmne/w3Fz/LPoiZ5oKy7lm0+AnQMSEU96gKiu 2+XipPUQsrz1w== From: cel@kernel.org To: Neil Brown , Jeff Layton , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: , Chuck Lever Subject: [PATCH 02/16] xdrgen: Track constant values Date: Thu, 3 Oct 2024 11:01:44 -0400 Message-ID: <20241003150151.81951-3-cel@kernel.org> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003150151.81951-1-cel@kernel.org> References: <20241003150151.81951-1-cel@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Chuck Lever In order to compute the numeric on-the-wire width of XDR types, xdrgen needs to keep track of the numeric value of constants that are defined in the input specification so it can perform calculations with those values. Signed-off-by: Chuck Lever --- tools/net/sunrpc/xdrgen/xdr_ast.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/net/sunrpc/xdrgen/xdr_ast.py b/tools/net/sunrpc/xdrgen/xdr_ast.py index 68f09945f2c4..b7df45f47707 100644 --- a/tools/net/sunrpc/xdrgen/xdr_ast.py +++ b/tools/net/sunrpc/xdrgen/xdr_ast.py @@ -19,6 +19,8 @@ public_apis = [] structs = set() pass_by_reference = set() +constants = {} + @dataclass class _XdrAst(ast_utils.Ast): @@ -156,6 +158,10 @@ class _XdrConstant(_XdrAst): name: str value: str + def __post_init__(self): + if self.value not in constants: + constants[self.name] = int(self.value, 0) + @dataclass class _XdrEnumerator(_XdrAst): @@ -164,6 +170,10 @@ class _XdrEnumerator(_XdrAst): name: str value: str + def __post_init__(self): + if self.value not in constants: + constants[self.name] = int(self.value, 0) + @dataclass class _XdrEnum(_XdrAst): From patchwork Thu Oct 3 15:01:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13821120 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ECF9316F0F0 for ; Thu, 3 Oct 2024 15:01:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727967720; cv=none; b=W7euQacSfQjOEBS0O1gZ38R9X4geMLKQUlSXR9Hx7MF+mlCg9MXKeyILgf02tuvB2wR407MRvO7yCIO1ltdZ2ItRh4e1DhAXtqyeHEqvhoso9gDree9BMtemEkzVFSdPwSaL3J39460Ucek7DY8yO9UFETP7u/01q4y07L74u8g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727967720; c=relaxed/simple; bh=5Fxm3WlxwUd6LYcPwTxxa5VUv2bnYW6sxcIdtPqTwWk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nWjUIxelsgMvcA27DUjKWSttM+sukFwSoJsKBibuIipaRp76mHSsQSHaV1PzTX0E5Kq/TM5wPYGbg0SypGJX2MmssCmdBZWk4qXoipBgVyuNwYwCNgaO62UUwCZNfVVCIgIBaonSrqSqKQlIsLCr23KuyzY23K1n8GK0RuoEe/4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=arbrFfsU; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="arbrFfsU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CC73BC4CEC7; Thu, 3 Oct 2024 15:01:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727967719; bh=5Fxm3WlxwUd6LYcPwTxxa5VUv2bnYW6sxcIdtPqTwWk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=arbrFfsUW8VNNO54dhI9z5pNkCeKlpasvZXUn0atgYmIR6HdLJFz/TZ/yShexg1L/ syl9zIeCXvKSCsjClz2BFjVTkttKwhPfX2Q72Bs3rJWq7pnCX1IKWqK32XOpq/soXX rYrMWxPob+8gwSGjEKCDwKG2JYoChYXRdmCfvxNyKlVkXCBid3Z5Y5Lx9mtvWR2b4y yyGA+VaSyK9szQGWW+n+qReHqLcrrEmGL6irppfsO5ZWMkQj6DY1iJW4yt6lLIBJ9I pkOVJS0c+QdXiN+M16ZcQ8Gxty9JABwkR6Ilgx29yo1lZTNQzwVddFNCN/lMaqSbDX EvZlmyPFWjzCw== From: cel@kernel.org To: Neil Brown , Jeff Layton , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: , Chuck Lever Subject: [PATCH 03/16] xdrgen: Keep track of on-the-wire data type widths Date: Thu, 3 Oct 2024 11:01:45 -0400 Message-ID: <20241003150151.81951-4-cel@kernel.org> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003150151.81951-1-cel@kernel.org> References: <20241003150151.81951-1-cel@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Chuck Lever The generic parts of the RPC layer need to know the widths (in XDR_UNIT increments) of the XDR data types defined for each protocol. As a first step, add dictionaries to keep track of the symbolic and actual maximum XDR width of XDR types. This makes it straightforward to look up the width of a type by its name. The built-in dictionaries are pre-loaded with the widths of the built-in XDR types as defined in RFC 4506. Signed-off-by: Chuck Lever --- include/linux/sunrpc/xdrgen/_defs.h | 9 ++++++ tools/net/sunrpc/xdrgen/xdr_ast.py | 43 +++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/include/linux/sunrpc/xdrgen/_defs.h b/include/linux/sunrpc/xdrgen/_defs.h index be9e62371758..20c7270aa64d 100644 --- a/include/linux/sunrpc/xdrgen/_defs.h +++ b/include/linux/sunrpc/xdrgen/_defs.h @@ -23,4 +23,13 @@ typedef struct { u8 *data; } opaque; +#define XDR_void (0) +#define XDR_bool (1) +#define XDR_int (1) +#define XDR_unsigned_int (1) +#define XDR_long (1) +#define XDR_unsigned_long (1) +#define XDR_hyper (2) +#define XDR_unsigned_hyper (2) + #endif /* _SUNRPC_XDRGEN__DEFS_H_ */ diff --git a/tools/net/sunrpc/xdrgen/xdr_ast.py b/tools/net/sunrpc/xdrgen/xdr_ast.py index b7df45f47707..f1d93a1d0ed8 100644 --- a/tools/net/sunrpc/xdrgen/xdr_ast.py +++ b/tools/net/sunrpc/xdrgen/xdr_ast.py @@ -21,6 +21,31 @@ pass_by_reference = set() constants = {} +symbolic_widths = { + "void": ["XDR_void"], + "bool": ["XDR_bool"], + "int": ["XDR_int"], + "unsigned_int": ["XDR_unsigned_int"], + "long": ["XDR_long"], + "unsigned_long": ["XDR_unsigned_long"], + "hyper": ["XDR_hyper"], + "unsigned_hyper": ["XDR_unsigned_hyper"], +} + +# Numeric XDR widths are tracked in a dictionary that is keyed +# by type_name because sometimes a caller has nothing more than +# the type_name to use to figure out the numeric width. +max_widths = { + "void": 0, + "bool": 1, + "int": 1, + "unsigned_int": 1, + "long": 1, + "unsigned_long": 1, + "hyper": 2, + "unsigned_hyper": 2, +} + @dataclass class _XdrAst(ast_utils.Ast): @@ -60,15 +85,24 @@ class _XdrTypeSpecifier(_XdrAst): class _XdrDefinedType(_XdrTypeSpecifier): """Corresponds to a type defined by the input specification""" + def symbolic_width(self) -> List: + """Return list containing XDR width of type's components""" + return [get_header_name().upper() + "_" + self.type_name + "_sz"] + def __post_init__(self): if self.type_name in structs: self.c_classifier = "struct " + symbolic_widths[self.type_name] = self.symbolic_width() @dataclass class _XdrBuiltInType(_XdrTypeSpecifier): """Corresponds to a built-in XDR type""" + def symbolic_width(self) -> List: + """Return list containing XDR width of type's components""" + return symbolic_widths[self.type_name] + @dataclass class _XdrDeclaration(_XdrAst): @@ -148,8 +182,17 @@ class _XdrBasic(_XdrDeclaration): class _XdrVoid(_XdrDeclaration): """A void declaration""" + name: str = "void" template: str = "void" + def max_width(self) -> int: + """Return width of type in XDR_UNITS""" + return 0 + + def symbolic_width(self) -> List: + """Return list containing XDR width of type's components""" + return [] + @dataclass class _XdrConstant(_XdrAst): From patchwork Thu Oct 3 15:01:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13821121 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B615416F0F0 for ; Thu, 3 Oct 2024 15:02:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727967720; cv=none; b=hAIIlwAaCEH+BEmrtoBZ1qM1d9Q+zW4KWziLETRjwBQ/1UNJnk7Dor4n0bVl7WtMAv7YIvHAMp6FMpgyM1P/0cvtTswV/+MU2pxyZpSVr11td5x2M+clS3Y4Trr9UV2od5Zxy68IYNtTc8qUpqZb+FMbXB4u3T6ahCnNtg5Su9E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727967720; c=relaxed/simple; bh=SoSWvT0n8eQFx0vdcmEa/oaMA3v+0uKf/pAk5pq1oZc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ga3qct1ws6Bxru3a3FNh2SGUMA2BjM8Gvg24aP+E/P6DwHutE7Wfz3e/ggGrwc0+EiLm5Bkqi2X+QRWyOBbMn0HJLRrwA1Hq9eBt8rcaGl1GkT5/wPHjd+A85tBnhfdDFI0/Pxfdu8PMqMP06bG4gOP+OsstwWIOqhwyMotJ2ag= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sHHZSoAZ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="sHHZSoAZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B4CE0C4CEC5; Thu, 3 Oct 2024 15:01:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727967720; bh=SoSWvT0n8eQFx0vdcmEa/oaMA3v+0uKf/pAk5pq1oZc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sHHZSoAZIODCV+blaL4tniSbCbVsjRfvCa9KsPe6TJrnz2UmmaKHdP/oyRCQPi8bh W+zUPLav1UX5Gwkk9jjN62QfF1S6+Q5fp8zC5Cny8H9pMKjDx+2Z5Z0imWcot3ne5z bjbn0Y3nNZ+8OqD5FYzUQQCK2LKQUw+iIH/n/rZ1rg9RbhXtod4TY9jHaP1ySUWhox k7RfuviEdqqix0Cm6WSoWGrMTSroNAqSCAmg1XHsRfhcEDr2+Y43AD7b0mH0hxXbu7 818SDWKQ4teiIM0x7Rei9HUAt6A62KNxn8/pWCcsfdzH8IE2JtwXqByAVAGz4aXUiK qSYXC1rSEbQyg== From: cel@kernel.org To: Neil Brown , Jeff Layton , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: , Chuck Lever Subject: [PATCH 04/16] xdrgen: XDR widths for enum types Date: Thu, 3 Oct 2024 11:01:46 -0400 Message-ID: <20241003150151.81951-5-cel@kernel.org> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003150151.81951-1-cel@kernel.org> References: <20241003150151.81951-1-cel@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Chuck Lever RFC 4506 says that an XDR enum is represented as a signed integer on the wire; thus its width is 1 XDR_UNIT. Signed-off-by: Chuck Lever --- tools/net/sunrpc/xdrgen/xdr_ast.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tools/net/sunrpc/xdrgen/xdr_ast.py b/tools/net/sunrpc/xdrgen/xdr_ast.py index f1d93a1d0ed8..fbee954c7f70 100644 --- a/tools/net/sunrpc/xdrgen/xdr_ast.py +++ b/tools/net/sunrpc/xdrgen/xdr_ast.py @@ -227,6 +227,18 @@ class _XdrEnum(_XdrAst): maximum: int enumerators: List[_XdrEnumerator] + def max_width(self) -> int: + """Return width of type in XDR_UNITS""" + return 1 + + def symbolic_width(self) -> List: + """Return list containing XDR width of type's components""" + return ["XDR_int"] + + def __post_init__(self): + max_widths[self.name] = self.max_width() + symbolic_widths[self.name] = self.symbolic_width() + @dataclass class _XdrStruct(_XdrAst): From patchwork Thu Oct 3 15:01:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13821122 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1F96316F0F0 for ; Thu, 3 Oct 2024 15:02:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727967722; cv=none; b=dwRSS7FwWKrxIqM0tQI8Fxv3rEvUOUDCUk00Pk1JDgBsHA9Xcb/Zjr5KaP5jUSbUhTA42MrhaCkV/ZX+/K7SamU5+KhnAPKmL4OiXwZezRcG635XkzvFb0qkJCo5VooI1l5zo05beZsjxaoRzGCadCHl80un4qCtdf5XrbubSdA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727967722; c=relaxed/simple; bh=zVPNu+hait7j1cpUDsk2WqOtmmz2VyWXZW/4CWdhAEY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jDLpTwfVK5J6agk8Ej1cs0gFCyntGhe19JPoEPTlDjBwRaVOi9cF0P2+Ex4qH4GbIlI2tabIA431vcd4xA/2e5n+JdLGyMjTD3G+UdRDdIsWQqy9XxFXSQYya1fea60Y00w+RThr59yLu+bIYc3MC1vuQLnzx7hc5sUmqQ12Pp4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TvvSeCpv; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TvvSeCpv" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9D9A4C4CEC7; Thu, 3 Oct 2024 15:02:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727967721; bh=zVPNu+hait7j1cpUDsk2WqOtmmz2VyWXZW/4CWdhAEY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TvvSeCpvk66Q1iJP6YMYm6M9UWj3O+ctVMCh6NSw1DBihZ/RzKSrlPDk7U4E5K9yr hAPcwFbtX/k/TEaI7TL0eoDHsllBBUr759H90ulWy22N2V6bISqk2U1SFguWaEr8lQ xsZClI8bScui35lYr8fESwN5n/7puW2HnLANpFsWaXhuKqULtw1rDbIUeX2DBe++hv KRZ5eXOlSsRzpF5Mrux6RDmTpA1x8QyZdT0T10w/4Em/603CJd7ndD3EHQnrFV3jV8 vizhsVXjCPcCakmtU6Cgy2DxpYazSRQygZPKqV1FwPiAkcHYzcaKBGcw8ujoeWYKXD ZaWea/TpMBaVQ== From: cel@kernel.org To: Neil Brown , Jeff Layton , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: , Chuck Lever Subject: [PATCH 05/16] xdrgen: XDR width for fixed-length opaque Date: Thu, 3 Oct 2024 11:01:47 -0400 Message-ID: <20241003150151.81951-6-cel@kernel.org> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003150151.81951-1-cel@kernel.org> References: <20241003150151.81951-1-cel@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Chuck Lever The XDR width for a fixed-length opaque is the byte size of the opaque rounded up to the next XDR_UNIT, divided by XDR_UNIT. Signed-off-by: Chuck Lever --- tools/net/sunrpc/xdrgen/xdr_ast.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tools/net/sunrpc/xdrgen/xdr_ast.py b/tools/net/sunrpc/xdrgen/xdr_ast.py index fbee954c7f70..9fe7fa688caa 100644 --- a/tools/net/sunrpc/xdrgen/xdr_ast.py +++ b/tools/net/sunrpc/xdrgen/xdr_ast.py @@ -21,6 +21,16 @@ pass_by_reference = set() constants = {} + +def xdr_quadlen(val: str) -> int: + """Return integer XDR width of an XDR type""" + if val in constants: + octets = constants[val] + else: + octets = int(val) + return int((octets + 3) / 4) + + symbolic_widths = { "void": ["XDR_void"], "bool": ["XDR_bool"], @@ -117,6 +127,18 @@ class _XdrFixedLengthOpaque(_XdrDeclaration): size: str template: str = "fixed_length_opaque" + def max_width(self) -> int: + """Return width of type in XDR_UNITS""" + return xdr_quadlen(self.size) + + def symbolic_width(self) -> List: + """Return list containing XDR width of type's components""" + return ["XDR_QUADLEN(" + self.size + ")"] + + def __post_init__(self): + max_widths[self.name] = self.max_width() + symbolic_widths[self.name] = self.symbolic_width() + @dataclass class _XdrVariableLengthOpaque(_XdrDeclaration): From patchwork Thu Oct 3 15:01:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13821123 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9FA4E1A073A for ; Thu, 3 Oct 2024 15:02:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727967722; cv=none; b=DDsLXIIWs7z0EdixlhxtOAyQZ9Fvjn1DW99mPI0w322tMMvDOAfwsS1376SLGD+TSU4gtg9/QZk8MbWeKVO2Bu5IrPhAiaGMYzjw2bSmj7gE1VCSS388QTP3njDlSejyXH4he5/6ZsrDYRLG60N2JOY1aySkhjjJxzt5mV+xi7o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727967722; c=relaxed/simple; bh=pRnpR6P5t42iIkCEFsBPKe8PwabUnPoOZMinZ/zFYto=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MpxX6MwzPhvhERiLazO9BCUU0dSW6u5TbCjZsaQq+ia49fIH/3rWb+8bq5MguoO1OBWTYqjpsCmHRsGVZKQZ9zqZX0Kv4oruqU3DzeFMUR7CckuxuX4t0I4nYGgOjCb2+TPn4C3DWKTif34rWmnAadNf5G5yvtEY9l0N0LcvM+w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jbABxVET; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jbABxVET" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D33A1C4CECF; Thu, 3 Oct 2024 15:02:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727967722; bh=pRnpR6P5t42iIkCEFsBPKe8PwabUnPoOZMinZ/zFYto=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jbABxVETtqj/X0QH9DbWeReXOI7KEi4wkRYPSa7qDW67b2DpqRqG3qeBFXfy2V7q+ kL+JrJmwyh38mp0MI2Kuhl80grBMovro61AyXX9ldw61m+1Zh724xZsHxTPWM95LZU KzvK3HCd1zrhJSzqbqbkyRW2DXORUa6ONvMbXN4OIexmZqcOA+SqhnIykf7gXmNtq7 uofRuLc7Od+CitC0tBTeExcHgjc7SXJHXZt4u3hISCGnV4UG4JxzrqC/jAOqFYsbOm WwAtA8RlHREI7+ZacSPIJ+rJJgaOHGZLMROUekIRkQ860Ybd40TTHA5tyDWMwImfVj LMosJy6VvkKzA== From: cel@kernel.org To: Neil Brown , Jeff Layton , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: , Chuck Lever Subject: [PATCH 06/16] xdrgen: XDR width for variable-length opaque Date: Thu, 3 Oct 2024 11:01:48 -0400 Message-ID: <20241003150151.81951-7-cel@kernel.org> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003150151.81951-1-cel@kernel.org> References: <20241003150151.81951-1-cel@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Chuck Lever The byte size of a variable-length opaque is conveyed in an unsigned integer. If there is a specified maximum size, that is included in the type's widths list. Signed-off-by: Chuck Lever --- tools/net/sunrpc/xdrgen/xdr_ast.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tools/net/sunrpc/xdrgen/xdr_ast.py b/tools/net/sunrpc/xdrgen/xdr_ast.py index 9fe7fa688caa..94cdcfb36e77 100644 --- a/tools/net/sunrpc/xdrgen/xdr_ast.py +++ b/tools/net/sunrpc/xdrgen/xdr_ast.py @@ -148,6 +148,21 @@ class _XdrVariableLengthOpaque(_XdrDeclaration): maxsize: str template: str = "variable_length_opaque" + def max_width(self) -> int: + """Return width of type in XDR_UNITS""" + return 1 + xdr_quadlen(self.maxsize) + + def symbolic_width(self) -> List: + """Return list containing XDR width of type's components""" + widths = ["XDR_unsigned_int"] + if self.maxsize != "0": + widths.append("XDR_QUADLEN(" + self.maxsize + ")") + return widths + + def __post_init__(self): + max_widths[self.name] = self.max_width() + symbolic_widths[self.name] = self.symbolic_width() + @dataclass class _XdrString(_XdrDeclaration): From patchwork Thu Oct 3 15:01:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13821124 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8932F19CCFB for ; Thu, 3 Oct 2024 15:02:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727967723; cv=none; b=EByG+ESLmLlTlniRZm4D8WGs7fH/aO29FpqC2eLSFOzXKteHvRdfVChF7JvYR9QvFUW7gq3Jn/j9LOFBSQo2d2CKRfVKfmYknu3tBI9G2Ln7jpPz7VI3bWQ9eblAbileFnWu8KoaFJ3+2BytV7V1+A5THrDNDB+xJW/IOeL/dmw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727967723; c=relaxed/simple; bh=B1K+TALLHIEHvj5rQFKCTcCLrKzUGlUJX2BnsjrwRdI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lKKRDbLdqgFfEy/ghXbOyo/DwM+QeAKy/NieYc7x3zVbGlEgNP34r4CynZ8FYlbbInYGa+NlXr0f+H3YTpV0xqlGhP404lJ2Qwa9pViJOJtx6HsK+f2otzMy0TNIYYrPuwnWavbSozcD6eUh0MrAiRBG86ZD0klV+Q0nQeqYsQc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Tvmj8Z5J; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Tvmj8Z5J" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BBD83C4CED2; Thu, 3 Oct 2024 15:02:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727967723; bh=B1K+TALLHIEHvj5rQFKCTcCLrKzUGlUJX2BnsjrwRdI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Tvmj8Z5JRAAW2KQHJ+UFuDX+nhqDcsua64J30IJL9F5SBjmFHgG+Q1I7Yuikj4rF+ /DWNnuwRMoW4bSj/smbz54lzTDloMS5blAzj31ZG2u3FUN/58xXmrRy2pEFv66oykr GwPOCwfTPByqMh7IIDU70eGrBH040u8rWM09HMabCdGNcWNH/Krjf1vz9TdUZH0lMa 7aP6qi7OwSNxXItS0eUR92KA5FXWEsw4eDcrNovM1FL1i7wcCn7ytjAo/+8jmqBRud wo/gBOA7XBqdGAFL9uP8JRj79Bfhr7txlod7upyh6vMDvBooj1btI9KBHXxe60onx3 0tFE+flQSQTSQ== From: cel@kernel.org To: Neil Brown , Jeff Layton , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: , Chuck Lever Subject: [PATCH 07/16] xdrgen: XDR width for a string Date: Thu, 3 Oct 2024 11:01:49 -0400 Message-ID: <20241003150151.81951-8-cel@kernel.org> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003150151.81951-1-cel@kernel.org> References: <20241003150151.81951-1-cel@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Chuck Lever A string works like a variable-length opaque. See Section 4.11 of RFC 4506. Signed-off-by: Chuck Lever --- tools/net/sunrpc/xdrgen/xdr_ast.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tools/net/sunrpc/xdrgen/xdr_ast.py b/tools/net/sunrpc/xdrgen/xdr_ast.py index 94cdcfb36e77..d5f48c094729 100644 --- a/tools/net/sunrpc/xdrgen/xdr_ast.py +++ b/tools/net/sunrpc/xdrgen/xdr_ast.py @@ -172,6 +172,21 @@ class _XdrString(_XdrDeclaration): maxsize: str template: str = "string" + def max_width(self) -> int: + """Return width of type in XDR_UNITS""" + return 1 + xdr_quadlen(self.maxsize) + + def symbolic_width(self) -> List: + """Return list containing XDR width of type's components""" + widths = ["XDR_unsigned_int"] + if self.maxsize != "0": + widths.append("XDR_QUADLEN(" + self.maxsize + ")") + return widths + + def __post_init__(self): + max_widths[self.name] = self.max_width() + symbolic_widths[self.name] = self.symbolic_width() + @dataclass class _XdrFixedLengthArray(_XdrDeclaration): From patchwork Thu Oct 3 15:01:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13821125 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C6ECF45BE3 for ; Thu, 3 Oct 2024 15:02:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727967724; cv=none; b=JKZADvyueE9kbn12vRr8+mFS5UQF58zfl/+McprjzLYpwo70erJzLP6MONDHsB0OSR1UjHFUk3VphLfPBxZu1UqsFGCXmwDFwQ3tG2QXuzo0iFi6Qe3/eCiqzyfQUfSZg8DAuoWDS6C67XEGRcmyJ2C9YCPBc1F3yI3Dr+Kojl4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727967724; c=relaxed/simple; bh=nqS0Fn7I2oTlrMlM/WcOIsUdT7xMf9K3lZTtNZxR9HM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=axK5mIaidqZJHcUqiGfA7Bi32bL4rawCsBGy/ustORgm7zIP1QpV3QKdTNYEc5ez+zLcXBBIEbPdIPbfWBrJKP7/zlktXr46jsbD5/9VBVJmz6Tj/QS/u99Zpmx8hdNmJGjumgoW+YV7tld6YAZw9QZj0Ftv9qdIihMbL01CBjU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=B/2kUCHB; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="B/2kUCHB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A366CC4CEC7; Thu, 3 Oct 2024 15:02:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727967724; bh=nqS0Fn7I2oTlrMlM/WcOIsUdT7xMf9K3lZTtNZxR9HM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B/2kUCHBXfizaG6Pp/at/9GAtnJ3eu54xCSQO8rW24Gc3WeXCrvUwdlGbXY08CH4o z9EvaIs7ZTwcURp1Zr7LIX7DoFUbm853BZGf3oFIE3LYdP43xxCUa2UVpn2Kd+2aKk 8gsis3hSR6kBCl88+JGrtxgS6SoJZwe3DXIb7MKb64bpWoIgnsW11maaZylvvfrk+k P51owVZuGVI6HtfYJKLzrRJFMCVgMxOn9+LQ1qDJnPUgcdS/h4cJhzGO4ywK314ZeV 6b0DoyCjdUxv5D3V3hHgSvOGPQgDoF8zK4bqTRp+0jFfHgYVu9AWmPqPz2ruIv0yFj xM32bfLznkv8w== From: cel@kernel.org To: Neil Brown , Jeff Layton , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: , Chuck Lever Subject: [PATCH 08/16] xdrgen: XDR width for fixed-length array Date: Thu, 3 Oct 2024 11:01:50 -0400 Message-ID: <20241003150151.81951-9-cel@kernel.org> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003150151.81951-1-cel@kernel.org> References: <20241003150151.81951-1-cel@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Chuck Lever Signed-off-by: Chuck Lever --- tools/net/sunrpc/xdrgen/xdr_ast.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tools/net/sunrpc/xdrgen/xdr_ast.py b/tools/net/sunrpc/xdrgen/xdr_ast.py index d5f48c094729..e9bc81e83b48 100644 --- a/tools/net/sunrpc/xdrgen/xdr_ast.py +++ b/tools/net/sunrpc/xdrgen/xdr_ast.py @@ -197,6 +197,19 @@ class _XdrFixedLengthArray(_XdrDeclaration): size: str template: str = "fixed_length_array" + def max_width(self) -> int: + """Return width of type in XDR_UNITS""" + return xdr_quadlen(self.size) * max_widths[self.spec.type_name] + + def symbolic_width(self) -> List: + """Return list containing XDR width of type's components""" + item_width = " + ".join(symbolic_widths[self.spec.type_name]) + return ["(" + self.size + " * (" + item_width + "))"] + + def __post_init__(self): + max_widths[self.name] = self.max_width() + symbolic_widths[self.name] = self.symbolic_width() + @dataclass class _XdrVariableLengthArray(_XdrDeclaration): From patchwork Thu Oct 3 15:01:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13821126 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF9F245BE3 for ; Thu, 3 Oct 2024 15:02:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727967725; cv=none; b=fi3az8vJDLGwLA9MNQoJCq4tohsbxyXBtbBcmEtC5S1g6LDjuMrud96b44bCHqaO3cCgOSwoSttJ7EFkjgRiXpWULqqYJTN8zbNSiMFPFXSnva3BoCYQX10iiD8fq6kac3+FkDnf4UN3rp4zr9hKyn4eQKHBHQTZv0SzbGcAm2c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727967725; c=relaxed/simple; bh=0+PUm9bD/Z9aDEFRgodi0+MqUkWZ9gSLz8zL+lzVuG0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fK5J67jxSRaRKHSY7hwGI1nnwzky9i2cgHFw+BpsY48jmLGdFRlV2/pVDtYSMF96bEPbyLjfacR+m1iWXS1jx2F2xFTEz/w27QaH4xM0rNLplLurMLxFc9NzNuT3zyNnzhZuEaQha1ZnfF9HyA7yQSz8qIjRN9GDFNZpbMuNbjs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=I7yjaJKp; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="I7yjaJKp" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8A086C4CEC5; Thu, 3 Oct 2024 15:02:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727967725; bh=0+PUm9bD/Z9aDEFRgodi0+MqUkWZ9gSLz8zL+lzVuG0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I7yjaJKpEDIHJ07hiQlcutaIFvBHxBxDeGN2UvyY2W+cbzvi82z5Y9f5+VxFUDt26 0u/BNwJTXSCpDCCrbjrXB5MVS11jmOcHdpVRDlRJ/SsIO3NWu9t9D7GUEXkglYy/+9 zqxGGDpsRTUScbJzzdY69OWg/zscuEkuNdR/Vc9yXT7pbfB/i3JK8T6MNHQ3WlJLGQ gNr+wJ52GxDvt0M0fOvcHmkwFrKhKsS42vgKzwoG91sbhcj2kR0x1QVHYQHcfVLmfN +xso0OrnHyRYER41XjQmbycCS0oK1d8fxM+an/wP9lez1oWBEYZhPTs+Ykci/RQb/p ySB424q29KoMA== From: cel@kernel.org To: Neil Brown , Jeff Layton , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: , Chuck Lever Subject: [PATCH 09/16] xdrgen: XDR width for variable-length array Date: Thu, 3 Oct 2024 11:01:51 -0400 Message-ID: <20241003150151.81951-10-cel@kernel.org> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241003150151.81951-1-cel@kernel.org> References: <20241003150151.81951-1-cel@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Chuck Lever Signed-off-by: Chuck Lever --- tools/net/sunrpc/xdrgen/xdr_ast.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tools/net/sunrpc/xdrgen/xdr_ast.py b/tools/net/sunrpc/xdrgen/xdr_ast.py index e9bc81e83b48..cb89d5d9987c 100644 --- a/tools/net/sunrpc/xdrgen/xdr_ast.py +++ b/tools/net/sunrpc/xdrgen/xdr_ast.py @@ -220,6 +220,22 @@ class _XdrVariableLengthArray(_XdrDeclaration): maxsize: str template: str = "variable_length_array" + def max_width(self) -> int: + """Return width of type in XDR_UNITS""" + return 1 + (xdr_quadlen(self.maxsize) * max_widths[self.spec.type_name]) + + def symbolic_width(self) -> List: + """Return list containing XDR width of type's components""" + widths = ["XDR_unsigned_int"] + if self.maxsize != "0": + item_width = " + ".join(symbolic_widths[self.spec.type_name]) + widths.append("(" + self.maxsize + " * (" + item_width + "))") + return widths + + def __post_init__(self): + max_widths[self.name] = self.max_width() + symbolic_widths[self.name] = self.symbolic_width() + @dataclass class _XdrOptionalData(_XdrDeclaration):