From patchwork Mon Jan 22 19:19:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alessandro Marcolini X-Patchwork-Id: 13526126 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EB89A3DBBB for ; Mon, 22 Jan 2024 19:19:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705951155; cv=none; b=FbYdr8+xZWQGarL5AGHS9Haj2FMDx35pvBxNJdMGpHMq1YM51l4tcMfutxwU15dAbzmf0pBqQGdQnqaou9PIrJfO7XVDITElm9WcEgDYZcdmDTUpHGRJ3lfLGOWyxLfKBu9j0baEVudP6L/+pE07jiSN2R/uF+T5bOJbLL7nvrE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705951155; c=relaxed/simple; bh=NIzF4HOoeWcX09o9CigouEo1jnkrQhGpQ/EDdZaZ4zA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=V/vy66w0MxKCveE0eo3MXCYTIUYvhnlklseu5Phq56V9MH1UXDG0EvYp9IWftFj86vKBC1IvHwVdKAGkeXlTFyRhNs9IGS3mxmWqMpSnAwZQ4E0gyrWTp6UwfOOs3963mbTbphRVknexvo0J5Pb/+kAa8faaBQgJ2VDgJxjiOVI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=cdTzV2XJ; arc=none smtp.client-ip=209.85.221.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cdTzV2XJ" Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-3367a304091so3901289f8f.3 for ; Mon, 22 Jan 2024 11:19:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705951152; x=1706555952; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=t57AyYBGWcxZqrcQdzRHminQZoOXAn71o8VVm2M9WtU=; b=cdTzV2XJCEAolZWa8jGpBhuELwOoIGF5Ch4ux1ZL2XQxUgAVOo/Y3CWnF656bNFHPS Wr6Cz1qRBLvcoisD5Z7kixN9jH0WhTP8+0uj3O2Wsz1jSxIaFj/B7NZzhiN59k1KkgfT irxgp0kZOEiLDkjA3K31UGIIKTihogvG+dnuGh1JXITIZmgr4L8M8jOBkyaJJILdO2LC dnhv5aI7ideDtqxtrreTfwWYA9ww0C8MQNYklqRpbnr7kHZbpwvHd9tzKgDQJBTq22LE zv1CmFkRXKRNtBDIUrJi9hOXogr1/9LYqjZqlE4jsfPm5IrpG5OK6Cid57k3bbBAzJGG bMkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705951152; x=1706555952; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=t57AyYBGWcxZqrcQdzRHminQZoOXAn71o8VVm2M9WtU=; b=fpSZVbAk/mGkSVoHeuDACqt4M9RHQr8T7RRoSYzhlrz/h3HGtwjga4xrxC2RHfyIL1 NpL2X6PRdipHELYVoFAwYqRR/96DBPWZC0qst1ZGXUZ85j9V7YPZFKEjhYfMLW22KRdr 7Jmp2CT3b6HOgkde/WD7jDveQxoCWoBofRzYa4Glg65UwVhhECso7AzxQlwlatbdx9BS LbHL7ADtV6INMuipUsl3CIVW8yx6vvdss5W1ZcMkoAJ/L5fxcnObluw4Z2p6FvzDSH7z AfF64yYOeTsBnwtXHTcUaSt82ErZrGqZKSzFqgkrl6S3yTxM3kT2ym6zgl5JvFRv5P/J YeAg== X-Gm-Message-State: AOJu0YzzDMurcGFBsZcYnStUrpg6eQ7Agq74xY8QGh4sIXVtbeQB8w/v BZOXStSIcUA9uVcGR9OLPnvs3GKuYnYoJlH6cIT5oVsF/MrxKv2wI9yj8l7ql+tKkg== X-Google-Smtp-Source: AGHT+IHOQuIxgiyCBV5wbYT2HDXnYtBafZH9JkanrftdVJCFfPFuHYxOGEczNL7CABclb2xlVqB4MQ== X-Received: by 2002:a05:6000:1e81:b0:337:9a60:f00b with SMTP id dd1-20020a0560001e8100b003379a60f00bmr2125719wrb.127.1705951152275; Mon, 22 Jan 2024 11:19:12 -0800 (PST) Received: from localhost.localdomain ([2001:b07:646f:4a4d:e17a:bd08:d035:d8c2]) by smtp.gmail.com with ESMTPSA id t4-20020a0560001a4400b003392ba296b3sm6211104wry.56.2024.01.22.11.19.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 11:19:12 -0800 (PST) From: Alessandro Marcolini To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, donald.hunter@gmail.com, sdf@google.com, chuck.lever@oracle.com, lorenzo@kernel.org, jacob.e.keller@intel.com, jiri@resnulli.us Cc: netdev@vger.kernel.org, Alessandro Marcolini Subject: [PATCH net-next 1/3] tools: ynl: correct typo and docstring Date: Mon, 22 Jan 2024 20:19:39 +0100 Message-ID: <800f2681d56b5195c8b22173a3b83bbac021af92.1705950652.git.alessandromarcolini99@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Correct typo in SpecAttr docstring. Changed SpecSubMessageFormat docstring. Signed-off-by: Alessandro Marcolini Reviewed-by: Donald Hunter --- tools/net/ynl/lib/nlspec.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tools/net/ynl/lib/nlspec.py b/tools/net/ynl/lib/nlspec.py index 44f13e383e8a..f8feae363970 100644 --- a/tools/net/ynl/lib/nlspec.py +++ b/tools/net/ynl/lib/nlspec.py @@ -144,7 +144,7 @@ class SpecEnumSet(SpecElement): class SpecAttr(SpecElement): - """ Single Netlink atttribute type + """ Single Netlink attribute type Represents a single attribute type within an attr space. @@ -306,10 +306,9 @@ class SpecSubMessage(SpecElement): class SpecSubMessageFormat(SpecElement): - """ Netlink sub-message definition + """ Netlink sub-message format definition - Represents a set of sub-message formats for polymorphic nlattrs - that contain type-specific sub messages. + Represents a single format for a sub-message. Attributes: value attribute value to match against type selector From patchwork Mon Jan 22 19:19:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alessandro Marcolini X-Patchwork-Id: 13526127 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5DCDB3E497 for ; Mon, 22 Jan 2024 19:19:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705951157; cv=none; b=lYgWXcCyWf9XWuPUbDUkOeTW+1RVcGI76IwUk74DKVJ+ZndueZdiMwyeNDh2s9XLdMDbkBDInrYiJPgZhyuv/RQVbD5OaC0JOijqP8cY54Yc4/3qSq9s/l6ITkUsbFgnMbgRJDKpmaOsFTGC4hjG77tnYyn5dhsTIecrAAVQB+Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705951157; c=relaxed/simple; bh=x8NPH1S7ULd4Idd1WJ1rSX7ESzGQXy4OpkYM3fAuoH8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=idQT4sV1SdtTOeAFQFue493eZb5oxNL3Ze5fIsR13jneIIAykAKdrru0YCxJ0Cua37qc6+EH39emfveqgDGZ21uBZtGqoq98mcGUclnwS7KfKaS3zjdJo2bFtwojnEnI1+UktJ8XIePo5praVpaYT39iFWGH9sbs9NShucJCbac= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=V5aLk0XU; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="V5aLk0XU" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-40e8801221cso35136855e9.1 for ; Mon, 22 Jan 2024 11:19:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705951154; x=1706555954; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iCn8ZnWzJtFPz9cQe8qkKAREOwut4nhShUJbW+CGkIo=; b=V5aLk0XU+y4OYOHFOHitW8U0qKrFS2mSazmibADJjydugLkHPyv7M/5+lEyj21Toih 9dvJdRvLSmFCE82+Kcpp3QCybJlKI+ouaGHA7r/glJj4uXcxCG0fpZdCwIIl0vMjjngG UtX55NFPWrgWudVZCN2lXuq3vxwmvx3c8u8voC3H9SrhSXUB6crPFc8MoS4YJU8gax2K NT2s82OfhRihWcE4Bb83KBSBxA2kBEliEeECfq75Fh8k8mVt57QFwqA8+O820Plcq3qN vVFpmevb+dlxs44mCswSrzn1XWH6v3aK/JZbxj3IdayAqHx2zG+p1bTA4sAXHvOcxuqu y0ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705951154; x=1706555954; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iCn8ZnWzJtFPz9cQe8qkKAREOwut4nhShUJbW+CGkIo=; b=GasZpnctr3Qrvs/dhXHTSd0Kcctgi7bxVFN1kWbJ0HiqfMbBWtcn32A/iXJTUhrryD EyjJnOeFgq1i8OAHfbuc8+QMtfyFR+dGp+I4urklX5Q88f89YhdMJnvRfK9pnd6zakG3 qh8cPpJgIsI3jJV+FprM6DdaSEA+eR2MC0Ik5mCusDJaDNKcM50Rt4YAkFjg1In3/Ykk r6DUHCvgnwwXrgccxZZOcQdmx9PB0E4dJV8BGtEAE7sRyrAzGdad/YtCQsbNCr33bIzM ZXztoTWly68IdZR3JTDF9VxYF3GQWT8UTbbHCmKBpY+ta+YA/NWdjaLVM9DLesIAdwPM +FMQ== X-Gm-Message-State: AOJu0Yzr2U2je4JZPfBxCuO0mX4n13u9Kzb65LiRbfWBpqPVPSwpZCp/ gfRchzRJOLbPwJTUoo2TEM4EmTv8eHpDRt/D8GD+Ps0i631PLvet X-Google-Smtp-Source: AGHT+IGPd9VvbSqpQ2MCni93yvZMr1P50GLWQ4mibtczlLo9PujAP6SN9xI8umfRPBTKWBXgU7RKbQ== X-Received: by 2002:a05:6000:1f8b:b0:337:c553:50e2 with SMTP id bw11-20020a0560001f8b00b00337c55350e2mr3326930wrb.3.1705951154335; Mon, 22 Jan 2024 11:19:14 -0800 (PST) Received: from localhost.localdomain ([2001:b07:646f:4a4d:e17a:bd08:d035:d8c2]) by smtp.gmail.com with ESMTPSA id t4-20020a0560001a4400b003392ba296b3sm6211104wry.56.2024.01.22.11.19.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 11:19:14 -0800 (PST) From: Alessandro Marcolini To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, donald.hunter@gmail.com, sdf@google.com, chuck.lever@oracle.com, lorenzo@kernel.org, jacob.e.keller@intel.com, jiri@resnulli.us Cc: netdev@vger.kernel.org, Alessandro Marcolini Subject: [PATCH net-next 2/3] doc: netlink: specs: tc: add multi-attr to tc-taprio-sched-entry Date: Mon, 22 Jan 2024 20:19:40 +0100 Message-ID: <068dee6ab2c16a539b67ea04751aac8d096da95a.1705950652.git.alessandromarcolini99@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Add multi-attr attribute to tc-taprio-sched-entry to specify multiple entries. Also remove the TODO that will be fixed by the next commit. Signed-off-by: Alessandro Marcolini --- Documentation/netlink/specs/tc.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Documentation/netlink/specs/tc.yaml b/Documentation/netlink/specs/tc.yaml index 4346fa402fc9..5e520d3125b6 100644 --- a/Documentation/netlink/specs/tc.yaml +++ b/Documentation/netlink/specs/tc.yaml @@ -1573,6 +1573,7 @@ attribute-sets: name: entry type: nest nested-attributes: tc-taprio-sched-entry + multi-attr: true - name: tc-taprio-sched-entry attributes: @@ -1667,7 +1668,7 @@ attribute-sets: type: binary - name: app - type: binary # TODO sub-message needs 2+ level deep lookup + type: binary sub-message: tca-stats-app-msg selector: kind - From patchwork Mon Jan 22 19:19:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alessandro Marcolini X-Patchwork-Id: 13526128 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7F9103DB84 for ; Mon, 22 Jan 2024 19:19:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705951160; cv=none; b=GtGXqQ+EG/ZWkj7Ojisj5Whbr8nTesEU/AiXEJoQ+ZZEwxulhClBB1IIzRzTh/GMIw2lp+9WK2aduIeo+Y2zplUCSfquqJe2mG9cqbra66QPT4uQatdtVAOkqaIZBDeM7S7uYXvAXUNK62LLQUBT1sMPXOK9XEmTBYQwsVpfxRc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705951160; c=relaxed/simple; bh=UMu0ULEg0RSkhXHSeFI70UkeLGGrrkvDCyHYJy+rtd8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cD+yBsEBCw712/iZzbJexagrAeJqWvwwo2YLRyQIvOOVe1Dzk2MoGKxYqMceL1nKmFqKFmz/H+Wgay2XRMomt1HG9vvsUD0bH5exRni8pYEjukaoYxwPMtnB4FvYLV/1+jLn6aPkSh9BvMljnYI70yAMCOBemFnywRf+fZ4EWBI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=WR/0GZl8; arc=none smtp.client-ip=209.85.221.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WR/0GZl8" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-33921b95dddso1648415f8f.1 for ; Mon, 22 Jan 2024 11:19:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705951156; x=1706555956; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gSCdadprWeMVfFlh2AYZIyRk50xst4g5G77u6mF0zr4=; b=WR/0GZl8HXGFjHyqv1LaHiSHixEdP6q7GN56BMX2HXCDrGP9dJ/6k/5rd5PXKV/sHP 5ZUjXb2No8wO1g/GF7BfHFA6qPD7hJwrou1qWg0rVzn3AOZ7hJKAsPYhFH+QHMVFsmbK rq7UOmUByJ/5iTS58FeJhSYycp1uh1tPqur4Wye37MJgYeUJId+mQ3s1KRhmqMN5MZd4 Fuf1z+NQd/npCdSL1mfw6YDCqNW2JtCoeuOSMfQp9ny6fcs5Ny3LRn6pcbp0EIfF+G+g wkGWSbOSdy2tbNcwAWuO0s05vxc84i506dCxcw4/mTiZy6JmYAwlpZHliOCxIGk6h3Rg HdUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705951156; x=1706555956; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gSCdadprWeMVfFlh2AYZIyRk50xst4g5G77u6mF0zr4=; b=YVfzl828VFlnr12KknWI+yRS1skQgdtTFg7H70brczICqAz7lusNN3XpZcBIlsr3w1 FMJXwWxVnIGe2LjqeXY0QPtAC9TeVOywH1hw9nHPnF6Azcn7eBjtRwcIbEjYZqM3fAPY E4/EHQXziaKkvljH+WsH98HEpLpdzb1oXuCnyyOfo9d0pkR+K6Os0UoJd0yipFlK7T3e 47SAgkFq7mWWJdoLE6UY8u/57JPPtTmjQ1sF3b3FmRUNs7G5k1WmbVlIHH87XINhc6LF 22Y7j6GduW1GxCTeW0PVhOaOfd2rffYEeXK7ehqPwa2FWMeMNyKfwzqQfgdNC/0+VOfK pqmw== X-Gm-Message-State: AOJu0YzuAJ28+gu+Ul8OGXY4HsHOdrHeZWL8m0vqC1AJokWjHAo7RWf3 Uu9gYMRcts8W4D7IJDDNDOhMTNt9JhnTQoH7A97JbsrWX0RxTPv0 X-Google-Smtp-Source: AGHT+IHtNwK5E9ZQ8NyJi9eqCG6oaCAdzJRCrDwY/Ti+nZpQmZyYjbKKjjsCtG8qUeDjHUwjKe/Zpg== X-Received: by 2002:adf:f18f:0:b0:337:6951:3e36 with SMTP id h15-20020adff18f000000b0033769513e36mr2079386wro.21.1705951156474; Mon, 22 Jan 2024 11:19:16 -0800 (PST) Received: from localhost.localdomain ([2001:b07:646f:4a4d:e17a:bd08:d035:d8c2]) by smtp.gmail.com with ESMTPSA id t4-20020a0560001a4400b003392ba296b3sm6211104wry.56.2024.01.22.11.19.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 11:19:16 -0800 (PST) From: Alessandro Marcolini To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, donald.hunter@gmail.com, sdf@google.com, chuck.lever@oracle.com, lorenzo@kernel.org, jacob.e.keller@intel.com, jiri@resnulli.us Cc: netdev@vger.kernel.org, Alessandro Marcolini Subject: [PATCH net-next 3/3] tools: ynl: add encoding support for 'sub-message' to ynl Date: Mon, 22 Jan 2024 20:19:41 +0100 Message-ID: <0eedc19860e9b84f105c57d17219b3d0af3100d2.1705950652.git.alessandromarcolini99@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Add encoding support for 'sub-message' attribute and for resolving sub-message selectors at different nesting level from the key attribute. Also, add encoding support for multi-attr attributes. Signed-off-by: Alessandro Marcolini --- tools/net/ynl/lib/ynl.py | 54 +++++++++++++++++++++++++++++++++++----- 1 file changed, 48 insertions(+), 6 deletions(-) diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py index 1e10512b2117..f8c56944f7e7 100644 --- a/tools/net/ynl/lib/ynl.py +++ b/tools/net/ynl/lib/ynl.py @@ -449,7 +449,7 @@ class YnlFamily(SpecFamily): self.sock.setsockopt(Netlink.SOL_NETLINK, Netlink.NETLINK_ADD_MEMBERSHIP, mcast_id) - def _add_attr(self, space, name, value): + def _add_attr(self, space, name, value, vals): try: attr = self.attr_sets[space][name] except KeyError: @@ -458,8 +458,13 @@ class YnlFamily(SpecFamily): if attr["type"] == 'nest': nl_type |= Netlink.NLA_F_NESTED attr_payload = b'' - for subname, subvalue in value.items(): - attr_payload += self._add_attr(attr['nested-attributes'], subname, subvalue) + # Check if it's a list of values (i.e. it contains multi-attr elements) + for subname, subvalue in ( + ((k, v) for item in value for k, v in item.items()) + if isinstance(value, list) + else value.items() + ): + attr_payload += self._add_attr(attr['nested-attributes'], subname, subvalue, vals) elif attr["type"] == 'flag': attr_payload = b'' elif attr["type"] == 'string': @@ -481,6 +486,12 @@ class YnlFamily(SpecFamily): attr_payload = format.pack(int(value)) elif attr['type'] in "bitfield32": attr_payload = struct.pack("II", int(value["value"]), int(value["selector"])) + elif attr['type'] == "sub-message": + spec = self._resolve_selector(attr, vals) + attr_spec = spec["attribute-set"] + attr_payload = b'' + for subname, subvalue in value.items(): + attr_payload += self._add_attr(attr_spec, subname, subvalue, vals) else: raise Exception(f'Unknown type at {space} {name} {value} {attr["type"]}') @@ -555,9 +566,40 @@ class YnlFamily(SpecFamily): sub_msg_spec = self.sub_msgs[sub_msg] selector = attr_spec.selector - if selector not in vals: + + def _find_attr_path(attr, vals, path=None): + if path is None: + path = [] + if isinstance(vals, dict): + if attr in vals: + return path + for k, v in vals.items(): + result = _find_attr_path(attr, v, path + [k]) + if result is not None: + return result + elif isinstance(vals, list): + for idx, v in enumerate(vals): + result = _find_attr_path(attr, v, path + [idx]) + if result is not None: + return result + return None + + def _find_selector_val(sel, vals, path): + while path != []: + v = vals.copy() + for step in path: + v = v[step] + if sel in v: + return v[sel] + path.pop() + return vals[sel] if sel in vals else None + + attr_path = _find_attr_path(attr_spec.name, vals) + value = _find_selector_val(selector, vals, attr_path) + + if value is None: raise Exception(f"There is no value for {selector} to resolve '{attr_spec.name}'") - value = vals[selector] + if value not in sub_msg_spec.formats: raise Exception(f"No message format for '{value}' in sub-message spec '{sub_msg}'") @@ -772,7 +814,7 @@ class YnlFamily(SpecFamily): format = NlAttr.get_format(m.type, m.byte_order) msg += format.pack(value) for name, value in vals.items(): - msg += self._add_attr(op.attr_set.name, name, value) + msg += self._add_attr(op.attr_set.name, name, value, vals) msg = _genl_msg_finalize(msg) self.sock.send(msg, 0)