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):