From patchwork Mon Feb 19 17:25:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 13562923 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (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 59C304594E for ; Mon, 19 Feb 2024 17:25:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708363535; cv=none; b=ewEscbHVHfo5CJpBPdOSnFEV3xUE6Q/xDNNMTlo676WqFaUxXMktJo7kJUQIcjhb9wchU4mFBValK1wEwChwtGOrLtKAzJ9jgP1Vg5jLKE2qMXu2G0Vw120wCzgnI43wVjUDcspn0GXhn5nfRWp42Y+Wll4eXwyR2d6eWKHFGUE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708363535; c=relaxed/simple; bh=j8oL6u7LIz1kVWmjKRw4xt8aa5zLt1brU8S6+j9SIOg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uQA8bqIE2LhO8U3nyp8PslRRsMkjca7g1do+CvVPkGIwYhWcfD1CcUIounywlCrNL3YgRZD5OaSZCx2eGqYCoiBKM17UooTo/jfnVsgTH8G+tkt1jKJLYfMP3FVGqpluoUC5eu963lgkKXTQzCRSLh8fOGnDlXtgwGSw9A645l8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=resnulli.us; spf=none smtp.mailfrom=resnulli.us; dkim=pass (2048-bit key) header.d=resnulli-us.20230601.gappssmtp.com header.i=@resnulli-us.20230601.gappssmtp.com header.b=w6JTHxvE; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=resnulli.us Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=resnulli.us Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=resnulli-us.20230601.gappssmtp.com header.i=@resnulli-us.20230601.gappssmtp.com header.b="w6JTHxvE" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-41242d2f73cso23136795e9.0 for ; Mon, 19 Feb 2024 09:25:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20230601.gappssmtp.com; s=20230601; t=1708363532; x=1708968332; 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=s/QhDRwym0LVRokbBfusx2gFhFFv/dhMOJxMFuna4ss=; b=w6JTHxvE30nvvyY2JzJ4Y+f75cWHdGjlDTGENIsD/Aj0CJU17hZhjgPDxFQOiBDhUQ JnhvsqXtnIldO+U0LTRJGM9CQ8OFufZnkd1SzPcEeG0zqm6BFeCMLnPfE12f42N6IAAJ eLFcADeWkVJvkHn2zgx/huU2fToF0qEq0g4d6Ndx0mGTcrXnz/aBepAAU1QQW+QSxhW/ +2rTH9yrAZfdLfsJgEo5vMYhfku1bTwD9eIkilTA8TQNsan9HYvz6gPrpLI589wfsXYw j9h+HUKo3uIkKHue0siqdreNxu18M6B3hR9knkuJL0ugN4Gzq83paXwEVc3Succje87j 40uA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708363532; x=1708968332; 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=s/QhDRwym0LVRokbBfusx2gFhFFv/dhMOJxMFuna4ss=; b=t81HT0i/KgfXdNuAR2joPFe98Zp1uI4as+/wMD4tkU0AfURCwX+zfbsaW2sxm7OVg+ +ZOfxftOlrJ9OCCIu6SjOwC39pr7e54vyadYT1OeC7HK9qoBJhrUWC3c5D7U3aTXJRqR kPOMKyFftrxkAzJV/U/p56NqCX4GYTm4LhhAdIarAmwIsNTZdGITHwBrV3wpGhTd2MOY /qVoPQ3LF0eneLBZ90dxq3Mf/2f+6W1zwHDs9gXlgE99+NFgiC/OrrRiAZ6x8JjzLCmf lX5XvdqJ7Ib4UrGeFY8TnjBHF6KSBbtZJmTMS724j9AbexJwgBNoZ6A0ZtKNNpvd6D4A r36w== X-Gm-Message-State: AOJu0Yzvo2CLfbIru7h1ovun1BOLBVw3mYgWRkd4DBBDfyg/mRgt4Y5V wvHmq7oRLGCYWolja6vyyj4HctJE6JhwbfCo+L9D+BwqCTWeshuQzDALhP9gmKkkJBhS/A/vTqK A X-Google-Smtp-Source: AGHT+IEKv4LObKlbx5807pgp95FujRxBeTiB9RE4GBrfd0kzVS05TgRINYh4QMMmeFPhxRnRv604Dw== X-Received: by 2002:a05:600c:1d04:b0:412:56ab:5bf6 with SMTP id l4-20020a05600c1d0400b0041256ab5bf6mr5233876wms.10.1708363531762; Mon, 19 Feb 2024 09:25:31 -0800 (PST) Received: from localhost ([193.47.165.251]) by smtp.gmail.com with ESMTPSA id z19-20020a7bc7d3000000b00411e1574f7fsm11825041wmk.44.2024.02.19.09.25.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 09:25:31 -0800 (PST) From: Jiri Pirko To: netdev@vger.kernel.org Cc: kuba@kernel.org, pabeni@redhat.com, davem@davemloft.net, edumazet@google.com, jacob.e.keller@intel.com, swarupkotikalapudi@gmail.com, donald.hunter@gmail.com, sdf@google.com, lorenzo@kernel.org, alessandromarcolini99@gmail.com Subject: [patch net-next 01/13] tools: ynl: allow user to specify flag attr with bool values Date: Mon, 19 Feb 2024 18:25:17 +0100 Message-ID: <20240219172525.71406-2-jiri@resnulli.us> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240219172525.71406-1-jiri@resnulli.us> References: <20240219172525.71406-1-jiri@resnulli.us> 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 From: Jiri Pirko The flag attr presence in Netlink message indicates value "true", if it is missing in the message it means "false". Allow user to specify attrname with value "true"/"false" in json for flag attrs, treat "false" value properly. Signed-off-by: Jiri Pirko --- tools/net/ynl/lib/ynl.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py index f45ee5f29bed..108fe7eadd93 100644 --- a/tools/net/ynl/lib/ynl.py +++ b/tools/net/ynl/lib/ynl.py @@ -459,6 +459,8 @@ class YnlFamily(SpecFamily): attr_payload += self._add_attr(attr['nested-attributes'], subname, subvalue, sub_attrs) elif attr["type"] == 'flag': + if value == False: + return b'' attr_payload = b'' elif attr["type"] == 'string': attr_payload = str(value).encode('ascii') + b'\x00' From patchwork Mon Feb 19 17:25:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 13562924 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (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 0B45C45974 for ; Mon, 19 Feb 2024 17:25:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708363538; cv=none; b=dh/ABC8HxoIogmmouCyIPR0cGVYhveaY1Co1wwbpmg6FxZzNWCOOOAaDNQMORXSjVOWhXtXmkUW/CcEAqjl+lTgahxS/6arsCddJyalzOHa37f3fVCRpGZND6ta3Nuf4V/8EOahLhgQE4H6thpGuc5NqouqDLBnLbbVhYx6ztl8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708363538; c=relaxed/simple; bh=7GJNeyqKKI2gUP8y+Pel3YsLRHMvcG0b0D71Qjle/ns=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=V0vblX7HP/XJSHmBVYXDq33RuBdkR0PNxC/pMAlKhmxYNlgsJQeuY9Bj+KN4XKUhMCNM1Gwb26eJtKMeq+RdVz/ZZj3HS2xrl9HqSlzbnwOycLxt45bTxQz1gjvPg6uhOP/wX7gxestn/fI8zP69Y+T0umXDSmaifrMljFfwtvk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=resnulli.us; spf=none smtp.mailfrom=resnulli.us; dkim=pass (2048-bit key) header.d=resnulli-us.20230601.gappssmtp.com header.i=@resnulli-us.20230601.gappssmtp.com header.b=W3V1p1pB; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=resnulli.us Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=resnulli.us Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=resnulli-us.20230601.gappssmtp.com header.i=@resnulli-us.20230601.gappssmtp.com header.b="W3V1p1pB" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-41267d9d6faso7253415e9.3 for ; Mon, 19 Feb 2024 09:25:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20230601.gappssmtp.com; s=20230601; t=1708363535; x=1708968335; 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=KA8nIxPfxUck1LxHT5Y/kVmB4xqHdbqDGqS9lzCV8Ns=; b=W3V1p1pBrmZuTT0HKf+04f1VMySu0CEtnOC6aTh8UU6dVHMJdn5SpMLW40HYpkGQVK rXu/gp5IpMouSkWm0iDnyufFeS0Z0qKJe8nAbFcOcfCAeESMCi4N8Wclkarnq2760yOv LlpCHzLO/hak8avlc+1Odf9o9rClofwv5yYNkS6mjssnco2L9ee6Nw6XM3pZsnA0CJzZ WgGHAYYobu+enQ3EpF3qkfjOyoKGUdTF9zDToqglVo3SN8AbHZ1FhlP1St18J+89ycpg rOH72sE1BJkm7BPrhyPStRtXyNFzRjlW1hSy7TFrfqBsf/0sLAI/MSNQOKKUG4fd2nHm FQqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708363535; x=1708968335; 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=KA8nIxPfxUck1LxHT5Y/kVmB4xqHdbqDGqS9lzCV8Ns=; b=BdnEOd+GG4w6FRg7twpzpQPFhCzjTBI1n2wsFLiCYa8X7jgYP97QMPSfNLMgF5+2LA Fx17novlt0CLxQfQKVpLUEDjCgC/hLa1jX8IwRb9MZmExXUDeFidP1o1toJ3Ye/a3VnY 0XBQLEtWsom9MFUySQn09n3cKins3hB4qjEl7+HXRFi+DY4Vsu4YiR2asrTykCqJIJm4 FrwHSQOXUawK8ndZxl70I02NdENPINSzNISdu2i3D0DmvCaOm7MGc6FVol7/GqyHySn9 y/SArme4/b7cbf6xty3YaBeGg2nyCITqqf6KKQA2KYszUUzvDg58+gqGsBdc0EoPNU32 v6cw== X-Gm-Message-State: AOJu0YwakPpZTBWIqLxqWtTf19w4Y1+GnQg8WxQP15QZ9iQlrCzKY8EW zngbDHN0VKNTMqclA5PQCRWDJh/CyB2vWmZoMLgFtNCs8kByX7GXeAmDCOjpfmgBjYY7GRUz5lv I X-Google-Smtp-Source: AGHT+IG8s/7WPmn4JNpphEFvBQRyKyHjMhixvvis2sWm4GJD1iSGD3HPxoPxPiYeeUwl2TrN6w2MLg== X-Received: by 2002:a05:600c:3b20:b0:412:63f3:2b9d with SMTP id m32-20020a05600c3b2000b0041263f32b9dmr2834775wms.31.1708363535154; Mon, 19 Feb 2024 09:25:35 -0800 (PST) Received: from localhost ([193.47.165.251]) by smtp.gmail.com with ESMTPSA id w9-20020a05600c474900b00412684fbcf3sm2490174wmo.28.2024.02.19.09.25.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 09:25:34 -0800 (PST) From: Jiri Pirko To: netdev@vger.kernel.org Cc: kuba@kernel.org, pabeni@redhat.com, davem@davemloft.net, edumazet@google.com, jacob.e.keller@intel.com, swarupkotikalapudi@gmail.com, donald.hunter@gmail.com, sdf@google.com, lorenzo@kernel.org, alessandromarcolini99@gmail.com Subject: [patch net-next 02/13] tools: ynl: process all scalar types encoding in single elif statement Date: Mon, 19 Feb 2024 18:25:18 +0100 Message-ID: <20240219172525.71406-3-jiri@resnulli.us> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240219172525.71406-1-jiri@resnulli.us> References: <20240219172525.71406-1-jiri@resnulli.us> 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 From: Jiri Pirko As a preparation to handle enums for scalar values, unify the processing of all scalar types in a single elif statement. Signed-off-by: Jiri Pirko --- tools/net/ynl/lib/ynl.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py index 108fe7eadd93..ccdb2f1e7379 100644 --- a/tools/net/ynl/lib/ynl.py +++ b/tools/net/ynl/lib/ynl.py @@ -473,14 +473,14 @@ class YnlFamily(SpecFamily): attr_payload = self._encode_struct(attr.struct_name, value) else: raise Exception(f'Unknown type for binary attribute, value: {value}') - elif attr.is_auto_scalar: + elif attr['type'] in NlAttr.type_formats or attr.is_auto_scalar: scalar = int(value) - real_type = attr["type"][0] + ('32' if scalar.bit_length() <= 32 else '64') - format = NlAttr.get_format(real_type, attr.byte_order) - attr_payload = format.pack(int(value)) - elif attr['type'] in NlAttr.type_formats: - format = NlAttr.get_format(attr['type'], attr.byte_order) - attr_payload = format.pack(int(value)) + if attr.is_auto_scalar: + attr_type = attr["type"][0] + ('32' if scalar.bit_length() <= 32 else '64') + else: + attr_type = attr["type"] + format = NlAttr.get_format(attr_type, attr.byte_order) + attr_payload = format.pack(scalar) elif attr['type'] in "bitfield32": attr_payload = struct.pack("II", int(value["value"]), int(value["selector"])) elif attr['type'] == 'sub-message': From patchwork Mon Feb 19 17:25:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 13562925 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) (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 7C99545974 for ; Mon, 19 Feb 2024 17:25:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708363542; cv=none; b=Rgz1Jc5x6YMLMtM78Y9I67b8SoBjMoNpMideXOrZcMQmvQR/ZNChCSoj7e6NYFBm3AIc3Pl+0B5cpSz882n/1btRySNDBD/LScEI2I4DtoQfT3sSwnNO0UhXKQQEHIspG/B32G7LRk2xBvqq0CPgmi9nhiyJOa1LjjUqupUPY2o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708363542; c=relaxed/simple; bh=lvSfM/i6wOhZcCTEXxaoYGvVxCN7p/ZUbuPR6CSRw/A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Dn77ZLIM6A30kGd81ZBomBSl5V7HfrZsryopuEdkocAjiOJKenk/+khec0fECJ2B77HnUwyRfG9yOlV2GuI/8Gr3yr0yZ3z9z0ow1aDo83cZcf7ZAD81PqHp/UZOH8bU9DABZQzSEOpgKX+GsIrZydlYVnYjW9HGKizScYE3uLg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=resnulli.us; spf=none smtp.mailfrom=resnulli.us; dkim=pass (2048-bit key) header.d=resnulli-us.20230601.gappssmtp.com header.i=@resnulli-us.20230601.gappssmtp.com header.b=1iwfo/R4; arc=none smtp.client-ip=209.85.208.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=resnulli.us Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=resnulli.us Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=resnulli-us.20230601.gappssmtp.com header.i=@resnulli-us.20230601.gappssmtp.com header.b="1iwfo/R4" Received: by mail-lj1-f180.google.com with SMTP id 38308e7fff4ca-2d1094b549cso67783701fa.3 for ; Mon, 19 Feb 2024 09:25:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20230601.gappssmtp.com; s=20230601; t=1708363539; x=1708968339; 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=jSoLiCYPAJ2jEwbCCH45PxOLjMDhrFfC7O2BBdy6iUE=; b=1iwfo/R4fQHTw2XOzh5uqvDwk2H631S1w2EZP+1JO+f4/FORRPkEq1BRvRr6PCojj0 atWDE0Cz2dWhULPPkX9V6Lnq3pQLZw+6E8iE5+IUX1FFfUXogBoKdEYK2YLsn7tPukhV I+D8jHPia6U+v44KPfLQsf0UjkDg8knS62SVE3y8ZPnjYxA4u7ZWtSry8KE94W6NqFd7 tur/+F5ci2Eavtcp+DMAeKTP7ZHR6/LyWx82MylKev+fdIUimDZNWLsk7B8hE8J2AEtx LS8C5h7Xlbqe+5UB0GhsDkGMbAod2rg/G3rRR3/In8OUJPVYonMv6g56IWyUc9pZnmjW yXLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708363539; x=1708968339; 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=jSoLiCYPAJ2jEwbCCH45PxOLjMDhrFfC7O2BBdy6iUE=; b=uq9fEu5gZyryE0bPWf/EYYtiYs8ixHM0HEfwdDH6D+WUccv03VOmnST/VZhP/5ldno PKPGIxkTVHGHiOr8y+Ore3Ss7BY4orNFB52T6XiJdiEzAH6TpUYZsQZhSY3FV4Uh7gJv LFVtilPlPyZ1W8sXmOx1tMVcUvzCqofcvc4v6o4sr0ieU72J1d8/bRfpf9dcm0ZQTccv PCEeVTJufDQV8Oo78Hxvuquv5PqeLniEgEukxsZn61Z1Mo/goT8ra8TFMI+fPvda5DW0 sUty6h5KCwnbzFN9ZtecqLE0Rg+dqn3QLlOMpUIJ56R3+zed34vpvf5TsuHHa9b41pyv WEPQ== X-Gm-Message-State: AOJu0Yw7XiugufbQ9hM3nYQf4QWquOcJnTPw5XAZgWOJmGsX9NFsDCxY BdmDu+8TrNpAuntAl9t9Grh3BxJ5QiV3gTvNcufsJ80s8gqgHp6jU7iYUMtrFeHAkpkVJvdl0dl 4 X-Google-Smtp-Source: AGHT+IFfK8oxV/mQ12ZeRx+Jw4cq/zmOwIIaXiFmkqFPuf0tiZz6ltjeBLW81coywvSpXjBWtbF6Fw== X-Received: by 2002:a2e:9685:0:b0:2d2:36bb:5abb with SMTP id q5-20020a2e9685000000b002d236bb5abbmr2976565lji.20.1708363538646; Mon, 19 Feb 2024 09:25:38 -0800 (PST) Received: from localhost ([193.47.165.251]) by smtp.gmail.com with ESMTPSA id i6-20020a05600c354600b004107686650esm12079906wmq.36.2024.02.19.09.25.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 09:25:38 -0800 (PST) From: Jiri Pirko To: netdev@vger.kernel.org Cc: kuba@kernel.org, pabeni@redhat.com, davem@davemloft.net, edumazet@google.com, jacob.e.keller@intel.com, swarupkotikalapudi@gmail.com, donald.hunter@gmail.com, sdf@google.com, lorenzo@kernel.org, alessandromarcolini99@gmail.com Subject: [patch net-next 03/13] tools: ynl: allow user to pass enum string instead of scalar value Date: Mon, 19 Feb 2024 18:25:19 +0100 Message-ID: <20240219172525.71406-4-jiri@resnulli.us> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240219172525.71406-1-jiri@resnulli.us> References: <20240219172525.71406-1-jiri@resnulli.us> 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 From: Jiri Pirko During decoding of messages coming from kernel, attribute values are converted to enum names in case the attribute type is enum of bitfield32. However, when user constructs json message, he has to pass plain scalar values. See "state" "selector" and "value" attributes in following examples: $ sudo ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/dpll.yaml --do pin-set --json '{"id": 0, "parent-device": {"parent-id": 0, "state": 1}}' $ sudo ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/devlink.yaml --do port-set --json '{"bus-name": "pci", "dev-name": "0000:08:00.1", "port-index": 98304, "port-function": {"caps": {"selector": 1, "value": 1 }}}' Allow user to pass strings containing enum names, convert them to scalar values to be encoded into Netlink message: $ sudo ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/dpll.yaml --do pin-set --json '{"id": 0, "parent-device": {"parent-id": 0, "state": "connected"}}' $ sudo ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/devlink.yaml --do port-set --json '{"bus-name": "pci", "dev-name": "0000:08:00.1", "port-index": 98304, "port-function": {"caps": {"selector": ["roce-bit"], "value": ["roce-bit"] }}}' Signed-off-by: Jiri Pirko --- tools/net/ynl/lib/ynl.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py index ccdb2f1e7379..d2ea1571d00c 100644 --- a/tools/net/ynl/lib/ynl.py +++ b/tools/net/ynl/lib/ynl.py @@ -438,6 +438,21 @@ class YnlFamily(SpecFamily): self.sock.setsockopt(Netlink.SOL_NETLINK, Netlink.NETLINK_ADD_MEMBERSHIP, mcast_id) + def _get_scalar(self, attr_spec, value): + try: + return int(value) + except (ValueError, TypeError) as e: + if 'enum' not in attr_spec: + raise e + enum = self.consts[attr_spec['enum']] + if enum.type == 'flags' or attr_spec.get('enum-as-flags', False): + scalar = 0 + for single_value in value: + scalar += enum.entries[single_value].user_value(as_flags = True) + return scalar + else: + return enum.entries[value].user_value() + def _add_attr(self, space, name, value, search_attrs): try: attr = self.attr_sets[space][name] @@ -474,7 +489,7 @@ class YnlFamily(SpecFamily): else: raise Exception(f'Unknown type for binary attribute, value: {value}') elif attr['type'] in NlAttr.type_formats or attr.is_auto_scalar: - scalar = int(value) + scalar = self._get_scalar(attr, value) if attr.is_auto_scalar: attr_type = attr["type"][0] + ('32' if scalar.bit_length() <= 32 else '64') else: @@ -482,7 +497,9 @@ class YnlFamily(SpecFamily): format = NlAttr.get_format(attr_type, attr.byte_order) attr_payload = format.pack(scalar) elif attr['type'] in "bitfield32": - attr_payload = struct.pack("II", int(value["value"]), int(value["selector"])) + scalar_value = self._get_scalar(attr, value["value"]) + scalar_selector = self._get_scalar(attr, value["selector"]) + attr_payload = struct.pack("II", scalar_value, scalar_selector) elif attr['type'] == 'sub-message': msg_format = self._resolve_selector(attr, search_attrs) attr_payload = b'' From patchwork Mon Feb 19 17:25:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 13562926 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (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 1663744C93 for ; Mon, 19 Feb 2024 17:25:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708363546; cv=none; b=MeAtBHBrXdKoyUukWd0JVp4loXWuEdM0J6+1Z35iuvsEo3VAJYSEt6WDr2L/b/M+svNqoh4IOxbDdCkX3vhFOweUnKkyJdBdq3dDTBG13rjEOnJfgpQ8V7BHcJRU9f2xoT/IE3/gTdZ30DmFRnZbsdToUcOfZoHiwyCDUAXSA88= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708363546; c=relaxed/simple; bh=d0eb+U915M3GJ1QpP3eRMvvJkhiVcCy55exGLeOsQug=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fyZN1dPkWcRklgrgKx9LQw8XfVftmcbf0S7nigabnH7U28ERt+w6F9JznowBdIbKlYMkW74Dq1vYEWQ2iHOxo6IrfgQiBFt0gAauECU4GjbRM4At4kGKQjAF/pNzTxU18wy8B5MqIvwXKmgMh0HjyX74smxCIw9AhFvZmwRqaT4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=resnulli.us; spf=none smtp.mailfrom=resnulli.us; dkim=pass (2048-bit key) header.d=resnulli-us.20230601.gappssmtp.com header.i=@resnulli-us.20230601.gappssmtp.com header.b=IqA17tyQ; arc=none smtp.client-ip=209.85.221.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=resnulli.us Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=resnulli.us Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=resnulli-us.20230601.gappssmtp.com header.i=@resnulli-us.20230601.gappssmtp.com header.b="IqA17tyQ" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-33d640e7b48so101157f8f.2 for ; Mon, 19 Feb 2024 09:25:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20230601.gappssmtp.com; s=20230601; t=1708363542; x=1708968342; 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=L6Oq8wW83mYv2l6m5dZRs9rPR7CIzDAECgxUbwAoQGs=; b=IqA17tyQqqhCIGFqltowlZ25vmnRJmDvpngLKNtRv95L2Ye7nIceHr1X6JH6RybWSV +rhwZR+fPjdp1RS/YKkp9lt9jRJAt4//K1FiZhVFQHK6cpZyPJTxhJd/IOEpPjeHLgVn /FBrVUh6TxzA2HPD+/KGsanW1Wh+gBfu9DjH7pp5b9w5JeCO04+PsLapNwahLw141wvi 3ThEIokkFdnTt4g62h91d17dpmfJxwCMNKu9yDh4ebNyTUyNcGciaqJDyIhNjFBtoWXf sEN7XR1vAGNpU7p8rCrR0QWfR76GHHUpgsM/eO2igeXkOQBlzvPxug3iKA0EmLZ0LQGu dq6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708363542; x=1708968342; 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=L6Oq8wW83mYv2l6m5dZRs9rPR7CIzDAECgxUbwAoQGs=; b=ed2CAFiGuNhy60sAGCYxshqRtN6FkvoHohB7dYl6nc/z64ziH2+X67zH/5NVEVrDKi pvmhXdyvQOMpOX3uibvezyiZDxVpjKlyo/ifI5nCdJx3uBH98s6Ungba9ZBSHT4exCj4 BK79Hj6JWR9i7LieIIg4NOrm+GpxoWjz/gL2uyhsY/1ABOYtBiyBo6zmCBZHOprlN2kh kDXODvhZR8dO9KkB65UuytXlBQ+eXXVSmN0OZkHMB/b6bNJD3jl4FzZrJp4yPNFQSaQm I55/b32M7pFsItJS4lCgQSujj14SL3Izt2CpM9Q9QPQInDy9Iyft4unMRP6qJW5pOlNq Jd+w== X-Gm-Message-State: AOJu0YwxrKbqWN1s3VF4feC8cerag1nxnUZ9pSddz7tBcukYnYH3Ipne In5LGvpSMzj7cf380RPFB8U4cFZx7iEneQPuG9usrTVNkIU0c9QK44RgLGaFDJEsVtNHPBZZMOU L X-Google-Smtp-Source: AGHT+IFM4NCSECoV+80IhSeH27lpFPrvZpbufRPDWjJ3iWabCnv/EgQtqiRZvIhSPUjtP9NrXaihaQ== X-Received: by 2002:a05:6000:110d:b0:33d:1ee9:3640 with SMTP id z13-20020a056000110d00b0033d1ee93640mr7029083wrw.17.1708363542287; Mon, 19 Feb 2024 09:25:42 -0800 (PST) Received: from localhost ([193.47.165.251]) by smtp.gmail.com with ESMTPSA id s8-20020adf9788000000b0033ae7d768b2sm10961517wrb.117.2024.02.19.09.25.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 09:25:41 -0800 (PST) From: Jiri Pirko To: netdev@vger.kernel.org Cc: kuba@kernel.org, pabeni@redhat.com, davem@davemloft.net, edumazet@google.com, jacob.e.keller@intel.com, swarupkotikalapudi@gmail.com, donald.hunter@gmail.com, sdf@google.com, lorenzo@kernel.org, alessandromarcolini99@gmail.com Subject: [patch net-next 04/13] netlink: specs: allow sub-messages in genetlink-legacy Date: Mon, 19 Feb 2024 18:25:20 +0100 Message-ID: <20240219172525.71406-5-jiri@resnulli.us> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240219172525.71406-1-jiri@resnulli.us> References: <20240219172525.71406-1-jiri@resnulli.us> 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 From: Jiri Pirko Currently sub-messages are only supported in netlink-raw template. To be able to utilize them in devlink spec, allow them in genetlink-legacy as well. Signed-off-by: Jiri Pirko --- Documentation/netlink/genetlink-legacy.yaml | 47 +++++++- Documentation/netlink/netlink-raw.yaml | 6 +- .../netlink/genetlink-legacy.rst | 101 ++++++++++++++++++ .../userspace-api/netlink/netlink-raw.rst | 101 ------------------ 4 files changed, 148 insertions(+), 107 deletions(-) diff --git a/Documentation/netlink/genetlink-legacy.yaml b/Documentation/netlink/genetlink-legacy.yaml index 938703088306..6cb50e2cc021 100644 --- a/Documentation/netlink/genetlink-legacy.yaml +++ b/Documentation/netlink/genetlink-legacy.yaml @@ -200,7 +200,8 @@ properties: description: The netlink attribute type enum: [ unused, pad, flag, binary, bitfield32, uint, sint, u8, u16, u32, u64, s32, s64, - string, nest, array-nest, nest-type-value ] + string, nest, array-nest, nest-type-value, + sub-message ] doc: description: Documentation of the attribute. type: string @@ -261,6 +262,15 @@ properties: struct: description: Name of the struct type used for the attribute. type: string + sub-message: + description: | + Name of the sub-message definition to use for the attribute. + type: string + selector: + description: | + Name of the attribute to use for dynamic selection of sub-message + format specifier. + type: string # End genetlink-legacy # Make sure name-prefix does not appear in subsets (subsets inherit naming) @@ -284,6 +294,41 @@ properties: items: required: [ type ] + sub-messages: + description: Definition of sub message attributes + type: array + items: + type: object + additionalProperties: False + required: [ name, formats ] + properties: + name: + description: Name of the sub-message definition + type: string + formats: + description: Dynamically selected format specifiers + type: array + items: + type: object + additionalProperties: False + required: [ value ] + properties: + value: + description: | + Value to match for dynamic selection of sub-message format + specifier. + type: string + fixed-header: + description: | + Name of the struct definition to use as the fixed header + for the sub message. + type: string + attribute-set: + description: | + Name of the attribute space from which to resolve attributes + in the sub message. + type: string + operations: description: Operations supported by the protocol. type: object diff --git a/Documentation/netlink/netlink-raw.yaml b/Documentation/netlink/netlink-raw.yaml index ac4e05415f2f..cc38b026c451 100644 --- a/Documentation/netlink/netlink-raw.yaml +++ b/Documentation/netlink/netlink-raw.yaml @@ -280,8 +280,6 @@ properties: struct: description: Name of the struct type used for the attribute. type: string - # End genetlink-legacy - # Start netlink-raw sub-message: description: | Name of the sub-message definition to use for the attribute. @@ -291,7 +289,7 @@ properties: Name of the attribute to use for dynamic selection of sub-message format specifier. type: string - # End netlink-raw + # End genetlink-legacy # Make sure name-prefix does not appear in subsets (subsets inherit naming) dependencies: @@ -314,7 +312,6 @@ properties: items: required: [ type ] - # Start netlink-raw sub-messages: description: Definition of sub message attributes type: array @@ -349,7 +346,6 @@ properties: Name of the attribute space from which to resolve attributes in the sub message. type: string - # End netlink-raw operations: description: Operations supported by the protocol. diff --git a/Documentation/userspace-api/netlink/genetlink-legacy.rst b/Documentation/userspace-api/netlink/genetlink-legacy.rst index 70a77387f6c4..7126b650090e 100644 --- a/Documentation/userspace-api/netlink/genetlink-legacy.rst +++ b/Documentation/userspace-api/netlink/genetlink-legacy.rst @@ -280,3 +280,104 @@ At the spec level we can define a ``dumps`` property for the ``do``, perhaps with values of ``combine`` and ``multi-object`` depending on how the parsing should be implemented (parse into a single reply vs list of objects i.e. pretty much a dump). + +Sub-messages +------------ + +Several raw netlink families such as +:doc:`rt_link<../../networking/netlink_spec/rt_link>` and +:doc:`tc<../../networking/netlink_spec/tc>` use attribute nesting as an +abstraction to carry module specific information. + +Conceptually it looks as follows:: + + [OUTER NEST OR MESSAGE LEVEL] + [GENERIC ATTR 1] + [GENERIC ATTR 2] + [GENERIC ATTR 3] + [GENERIC ATTR - wrapper] + [MODULE SPECIFIC ATTR 1] + [MODULE SPECIFIC ATTR 2] + +The ``GENERIC ATTRs`` at the outer level are defined in the core (or rt_link or +core TC), while specific drivers, TC classifiers, qdiscs etc. can carry their +own information wrapped in the ``GENERIC ATTR - wrapper``. Even though the +example above shows attributes nesting inside the wrapper, the modules generally +have full freedom to define the format of the nest. In practice the payload of +the wrapper attr has very similar characteristics to a netlink message. It may +contain a fixed header / structure, netlink attributes, or both. Because of +those shared characteristics we refer to the payload of the wrapper attribute as +a sub-message. + +A sub-message attribute uses the value of another attribute as a selector key to +choose the right sub-message format. For example if the following attribute has +already been decoded: + +.. code-block:: json + + { "kind": "gre" } + +and we encounter the following attribute spec: + +.. code-block:: yaml + + - + name: data + type: sub-message + sub-message: linkinfo-data-msg + selector: kind + +Then we look for a sub-message definition called ``linkinfo-data-msg`` and use +the value of the ``kind`` attribute i.e. ``gre`` as the key to choose the +correct format for the sub-message: + +.. code-block:: yaml + + sub-messages: + name: linkinfo-data-msg + formats: + - + value: bridge + attribute-set: linkinfo-bridge-attrs + - + value: gre + attribute-set: linkinfo-gre-attrs + - + value: geneve + attribute-set: linkinfo-geneve-attrs + +This would decode the attribute value as a sub-message with the attribute-set +called ``linkinfo-gre-attrs`` as the attribute space. + +A sub-message can have an optional ``fixed-header`` followed by zero or more +attributes from an ``attribute-set``. For example the following +``tc-options-msg`` sub-message defines message formats that use a mixture of +``fixed-header``, ``attribute-set`` or both together: + +.. code-block:: yaml + + sub-messages: + - + name: tc-options-msg + formats: + - + value: bfifo + fixed-header: tc-fifo-qopt + - + value: cake + attribute-set: tc-cake-attrs + - + value: netem + fixed-header: tc-netem-qopt + attribute-set: tc-netem-attrs + +Note that a selector attribute must appear in a netlink message before any +sub-message attributes that depend on it. + +If an attribute such as ``kind`` is defined at more than one nest level, then a +sub-message selector will be resolved using the value 'closest' to the selector. +For example, if the same attribute name is defined in a nested ``attribute-set`` +alongside a sub-message selector and also in a top level ``attribute-set``, then +the selector will be resolved using the value 'closest' to the selector. If the +value is not present in the message at the same level as defined in the spec +then this is an error. diff --git a/Documentation/userspace-api/netlink/netlink-raw.rst b/Documentation/userspace-api/netlink/netlink-raw.rst index 1990eea772d0..5fb8b7cd6558 100644 --- a/Documentation/userspace-api/netlink/netlink-raw.rst +++ b/Documentation/userspace-api/netlink/netlink-raw.rst @@ -58,107 +58,6 @@ group registration. name: rtnlgrp-mctp-ifaddr value: 34 -Sub-messages ------------- - -Several raw netlink families such as -:doc:`rt_link<../../networking/netlink_spec/rt_link>` and -:doc:`tc<../../networking/netlink_spec/tc>` use attribute nesting as an -abstraction to carry module specific information. - -Conceptually it looks as follows:: - - [OUTER NEST OR MESSAGE LEVEL] - [GENERIC ATTR 1] - [GENERIC ATTR 2] - [GENERIC ATTR 3] - [GENERIC ATTR - wrapper] - [MODULE SPECIFIC ATTR 1] - [MODULE SPECIFIC ATTR 2] - -The ``GENERIC ATTRs`` at the outer level are defined in the core (or rt_link or -core TC), while specific drivers, TC classifiers, qdiscs etc. can carry their -own information wrapped in the ``GENERIC ATTR - wrapper``. Even though the -example above shows attributes nesting inside the wrapper, the modules generally -have full freedom to define the format of the nest. In practice the payload of -the wrapper attr has very similar characteristics to a netlink message. It may -contain a fixed header / structure, netlink attributes, or both. Because of -those shared characteristics we refer to the payload of the wrapper attribute as -a sub-message. - -A sub-message attribute uses the value of another attribute as a selector key to -choose the right sub-message format. For example if the following attribute has -already been decoded: - -.. code-block:: json - - { "kind": "gre" } - -and we encounter the following attribute spec: - -.. code-block:: yaml - - - - name: data - type: sub-message - sub-message: linkinfo-data-msg - selector: kind - -Then we look for a sub-message definition called ``linkinfo-data-msg`` and use -the value of the ``kind`` attribute i.e. ``gre`` as the key to choose the -correct format for the sub-message: - -.. code-block:: yaml - - sub-messages: - name: linkinfo-data-msg - formats: - - - value: bridge - attribute-set: linkinfo-bridge-attrs - - - value: gre - attribute-set: linkinfo-gre-attrs - - - value: geneve - attribute-set: linkinfo-geneve-attrs - -This would decode the attribute value as a sub-message with the attribute-set -called ``linkinfo-gre-attrs`` as the attribute space. - -A sub-message can have an optional ``fixed-header`` followed by zero or more -attributes from an ``attribute-set``. For example the following -``tc-options-msg`` sub-message defines message formats that use a mixture of -``fixed-header``, ``attribute-set`` or both together: - -.. code-block:: yaml - - sub-messages: - - - name: tc-options-msg - formats: - - - value: bfifo - fixed-header: tc-fifo-qopt - - - value: cake - attribute-set: tc-cake-attrs - - - value: netem - fixed-header: tc-netem-qopt - attribute-set: tc-netem-attrs - -Note that a selector attribute must appear in a netlink message before any -sub-message attributes that depend on it. - -If an attribute such as ``kind`` is defined at more than one nest level, then a -sub-message selector will be resolved using the value 'closest' to the selector. -For example, if the same attribute name is defined in a nested ``attribute-set`` -alongside a sub-message selector and also in a top level ``attribute-set``, then -the selector will be resolved using the value 'closest' to the selector. If the -value is not present in the message at the same level as defined in the spec -then this is an error. - Nested struct definitions ------------------------- From patchwork Mon Feb 19 17:25:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 13562927 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (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 2CAFC45940 for ; Mon, 19 Feb 2024 17:25:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708363548; cv=none; b=bGRAWJmRw4RJVhGJSinFIQyj4fYJuLQZnhuuXUVodiDfhK6HVCPMxbJ9iczW7BMbCtuuDgbUSBx//vM2YMQQvJ2qKCSkYAqAOrGDjCatnJ9eoNZhZ8Bszo+qJfp77vwBhelgVMVAv1ReEe4h5S0NRFhuF6lff6iNsQWqR21IbEY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708363548; c=relaxed/simple; bh=c+rfOiCkC1Yl33y4svN06aTyS1tSf8n6sobMDVXIleo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=G+yKJJmXjBi+SXSKGldI+exhhP/XvIWnsf5qE2jSxHBEZHKMJFnCCcslat/yCxGI2VdhmkVHhEs0vlXkqcn2vLoOqzApqu9XQ5YwmCC2Xz6ppsS6PLCO3di1CBDfpaoxsqu7mXELlGAVfKKtA41M1QtlSdKsl6Cboa/21XaUBt0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=resnulli.us; spf=none smtp.mailfrom=resnulli.us; dkim=pass (2048-bit key) header.d=resnulli-us.20230601.gappssmtp.com header.i=@resnulli-us.20230601.gappssmtp.com header.b=Z0oYaA0T; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=resnulli.us Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=resnulli.us Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=resnulli-us.20230601.gappssmtp.com header.i=@resnulli-us.20230601.gappssmtp.com header.b="Z0oYaA0T" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-4126b687bceso3106485e9.3 for ; Mon, 19 Feb 2024 09:25:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20230601.gappssmtp.com; s=20230601; t=1708363545; x=1708968345; 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=Ra7B4rF1DGNxCzvmLw1JReP7tMzfxZwtt5oi6Cd76zs=; b=Z0oYaA0TfSuTEdNuNUx0M+oI/SFlrNxKO12RatqU9s68BdHWbCqIk4nwPiT0+aACFv ufQvEGURJxuKd53Du9nuagCV+oxBfrXsPvuyiLtqnYauxrhcNdeVaGej2xJhi6V3/7hR TxeoaQf9dnn59yPvoM78FPSty8S9S++yrosjAZn+mvEmhK0UhndPdT9LpDcB2ruPMZTW jGNvuOat1c1KqoXjquxBm8jN8La4qHIbAmmJAf0qyPrvzcQ26B/2E7ZMwR5yZcYE+FYx jT3x1dc8bmHM7TZVZOFj6sQtjx6Imw63J4vQgKt3+e74wT6Ot3+70gEVFZLlF1Wr6z8x fbDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708363545; x=1708968345; 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=Ra7B4rF1DGNxCzvmLw1JReP7tMzfxZwtt5oi6Cd76zs=; b=g8FYA+a16WWWmRkPQvuQeXJ2UmspvKDmgmvrzWSwJOkNc10gY9DQl9CMAO0vCusAez Mr++MjkIoRAVgW1eo6EanDUlMWk5LEx8x0CQXwySTHGy0qk++hg0Se/6vuXlDDeKcvDR MOPTnEk3qnuwOEza8242n564ooeZrv1EPYksPzcEbK41VhRKcW3JQdtLCD5DfZ9rGF/y YWSqIHnfbyEttsTX5uGhMr3peg6zGT3zRrk1Eku4MxBM2bm5BoCiPh/rBysL9tvEB+bZ VwQL+NkIslZW5JHJ/RKQUawafQ5vRgyTjss7rZbIAa2+2KedLhDBNG1BJeNeiklA781c sq2g== X-Gm-Message-State: AOJu0YzLpEfuBSIFW3+DTtpIoQFglR5VbYT1OpFdWmfddExgghIIwTd/ pr1aoWVQnUjy7Q8W9k3TV2nTUb28TKe86nFYLAo9tJYYp6BEfxj8TznACnzNWtY/p/VWQw0VVsa + X-Google-Smtp-Source: AGHT+IGponmOjubaLWvN8uFEWR/aYzA/16LJm71Y58afF5BAJw4q13IEMNZDfc9G2xFHHQkZyjtyYQ== X-Received: by 2002:a05:600c:6014:b0:412:640a:fa0c with SMTP id az20-20020a05600c601400b00412640afa0cmr3628134wmb.16.1708363545782; Mon, 19 Feb 2024 09:25:45 -0800 (PST) Received: from localhost ([193.47.165.251]) by smtp.gmail.com with ESMTPSA id l37-20020a05600c1d2500b004126afe04f6sm1111848wms.32.2024.02.19.09.25.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 09:25:45 -0800 (PST) From: Jiri Pirko To: netdev@vger.kernel.org Cc: kuba@kernel.org, pabeni@redhat.com, davem@davemloft.net, edumazet@google.com, jacob.e.keller@intel.com, swarupkotikalapudi@gmail.com, donald.hunter@gmail.com, sdf@google.com, lorenzo@kernel.org, alessandromarcolini99@gmail.com Subject: [patch net-next 05/13] tools: ynl: allow attr in a subset to be of a different type Date: Mon, 19 Feb 2024 18:25:21 +0100 Message-ID: <20240219172525.71406-6-jiri@resnulli.us> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240219172525.71406-1-jiri@resnulli.us> References: <20240219172525.71406-1-jiri@resnulli.us> 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 From: Jiri Pirko Currently, when subset attribute is defined, it inherits the whole definition of the attribute in original set. To be able to achieve sub message decoding of the same attribute of different type, allow spec to define different type for the same attribute. Signed-off-by: Jiri Pirko --- tools/net/ynl/lib/nlspec.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/net/ynl/lib/nlspec.py b/tools/net/ynl/lib/nlspec.py index fbce52395b3b..5e48ee0fb8b4 100644 --- a/tools/net/ynl/lib/nlspec.py +++ b/tools/net/ynl/lib/nlspec.py @@ -217,6 +217,8 @@ class SpecAttrSet(SpecElement): real_set = family.attr_sets[self.subset_of] for elem in self.yaml['attributes']: attr = real_set[elem['name']] + if 'type' in elem and attr.type != elem['type']: + attr = self.new_attr(elem, attr.value) self.attrs[attr.name] = attr self.attrs_by_val[attr.value] = attr From patchwork Mon Feb 19 17:25:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 13562928 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (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 C127B4594D for ; Mon, 19 Feb 2024 17:25:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708363552; cv=none; b=E9jBsObzh3IEWsucPxV8BXVvM/uoUPzC765p6gSJaqjn7ockgnRRQEzj324zYoUbWfbbWbJzCRe8Oyyht5MJGkpTlpk27yMlIzcBcH9/IpLS0jzGyN1+Nm/z6GOvk0WTSNGQpMohzk+DVXKyCLKSqJQEWIMvwNsXp/5p7GiEFGQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708363552; c=relaxed/simple; bh=5fJUJEOkfTgvUJvW1qGZuBMvBdHBIzIKDwLY349Xc3o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uxDdXkVY5s+QbRhOdcYqs1pkmFiDHBZJyfIlNNUoy3KJK+RvG1Kap2N2iENO2RcFdNrTvrOL8hFJowEEh8nxr/hfX57RiYmv5l0ZNtE2wRz5ttDF/kLfStXmDd6Dyevkc7AOdGkB4faaujMg8ytxOrFDXAUdlZrkscAkrZnEy88= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=resnulli.us; spf=none smtp.mailfrom=resnulli.us; dkim=pass (2048-bit key) header.d=resnulli-us.20230601.gappssmtp.com header.i=@resnulli-us.20230601.gappssmtp.com header.b=enOehAiJ; arc=none smtp.client-ip=209.85.128.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=resnulli.us Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=resnulli.us Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=resnulli-us.20230601.gappssmtp.com header.i=@resnulli-us.20230601.gappssmtp.com header.b="enOehAiJ" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-41265d2f7acso9316075e9.1 for ; Mon, 19 Feb 2024 09:25:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20230601.gappssmtp.com; s=20230601; t=1708363549; x=1708968349; 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=mXQz0tUbRrPe2b96ddZ22n+oZureWQtegw85hUbDA6Q=; b=enOehAiJrTjiRbqLhKu93UBOS1UrrmL6r3EzucZuTA141JL2gqV2kuNYrBXeziGqu9 BCSN+OO1WZeRIZKdCgQE+NAuXaut6JGVUJ43Kz68/xclG3FwcHeP9IUo2hkCH5ghAtnz 3H9mT73H7deIfy2TJDj7mLsdodEXOAP62MhNikh3DZprBu5K52nb0yyGJ5RPFSUZQJsy /XVFpwOX91JwMsAISyMofALQRrwSIE6m3Puqs+l30OiZapAJLYnyBiGcjZ9wnQVSHVkB 732yzJU8kOIdI07aFrBAZgezgSBh1Al13LcKEObGp9fw4eYTT1MkIeN/4v3xEUZEVU6F Kd6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708363549; x=1708968349; 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=mXQz0tUbRrPe2b96ddZ22n+oZureWQtegw85hUbDA6Q=; b=TBF+8VHij6jqrXVjbTqpirFR87yf7iuxoiSvsQHRecTztWnA+REqeQf8qSgstiYfqO h8Ww/tjFj649oDHwPkyBArPrcue7G9F+AcaU2DgPeQuguhJqqiellxJghq+sO4ffouDL rxsT2p31Nf/ZwQijgEcjciHpYLXU/+MO2CVSJL92nnW8uEORZbXeJrZgRGI0+j5xikTI jtQJ4DC4C374TUtub4pImJZIvyviibIzCo1M5ATzJ26CXjw7aafVCJQ4/55zg+hsWDS0 UDMB4RnkyTvRaQpSx02zo2Bw73j+4PPMBl11HmkEI66qO7Yv6HgDCmRjLt+07PhR0Z22 DBVw== X-Gm-Message-State: AOJu0YxW0nQkYi+dKBwz3vNyMWVoZxtpV8d1po8BGYBkif5N7qxTGD+T uTenfEG4S7XybED0SLbH07MG1+5KjAss2mKJIvW1vkCUjmTouXPR8k/Olr1jYYH+XPWNap8Y9Ax C X-Google-Smtp-Source: AGHT+IFnQj0Cdzt/isZGwSfEDgXmFzDfTTU4dmGMMelPPyTOjQGGVDIgM4ix8T9DMyf1Cy7YLfN3oA== X-Received: by 2002:a05:600c:3c8a:b0:411:9508:e237 with SMTP id bg10-20020a05600c3c8a00b004119508e237mr10765574wmb.19.1708363549196; Mon, 19 Feb 2024 09:25:49 -0800 (PST) Received: from localhost ([193.47.165.251]) by smtp.gmail.com with ESMTPSA id jp5-20020a05600c558500b004126732390asm3024910wmb.37.2024.02.19.09.25.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 09:25:48 -0800 (PST) From: Jiri Pirko To: netdev@vger.kernel.org Cc: kuba@kernel.org, pabeni@redhat.com, davem@davemloft.net, edumazet@google.com, jacob.e.keller@intel.com, swarupkotikalapudi@gmail.com, donald.hunter@gmail.com, sdf@google.com, lorenzo@kernel.org, alessandromarcolini99@gmail.com Subject: [patch net-next 06/13] tools: ynl: introduce attribute-replace for sub-message Date: Mon, 19 Feb 2024 18:25:22 +0100 Message-ID: <20240219172525.71406-7-jiri@resnulli.us> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240219172525.71406-1-jiri@resnulli.us> References: <20240219172525.71406-1-jiri@resnulli.us> 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 From: Jiri Pirko For devlink param, param-value-data attr is used by kernel to fill different attribute type according to param-type attribute value. Currently the sub-message feature allows spec to embed custom message selected by another attribute. The sub-message is then nested inside the attr of sub-message type. Benefit from the sub-message feature and extend it. Introduce attribute-replace spec flag by which the spec indicates that ynl should consider sub-message as not nested in the original attribute, but rather to consider the original attribute as the sub-message right away. Signed-off-by: Jiri Pirko --- Documentation/netlink/genetlink-legacy.yaml | 4 +++ Documentation/netlink/netlink-raw.yaml | 4 +++ .../netlink/genetlink-legacy.rst | 25 ++++++++++++++++++ tools/net/ynl/lib/nlspec.py | 6 +++++ tools/net/ynl/lib/ynl.py | 26 ++++++++++++++----- 5 files changed, 59 insertions(+), 6 deletions(-) diff --git a/Documentation/netlink/genetlink-legacy.yaml b/Documentation/netlink/genetlink-legacy.yaml index 6cb50e2cc021..77d89f81c71f 100644 --- a/Documentation/netlink/genetlink-legacy.yaml +++ b/Documentation/netlink/genetlink-legacy.yaml @@ -328,6 +328,10 @@ properties: Name of the attribute space from which to resolve attributes in the sub message. type: string + attribute-replace: + description: | + Replace the parent nested attribute with attribute set + type: boolean operations: description: Operations supported by the protocol. diff --git a/Documentation/netlink/netlink-raw.yaml b/Documentation/netlink/netlink-raw.yaml index cc38b026c451..e32660fbe6c3 100644 --- a/Documentation/netlink/netlink-raw.yaml +++ b/Documentation/netlink/netlink-raw.yaml @@ -346,6 +346,10 @@ properties: Name of the attribute space from which to resolve attributes in the sub message. type: string + attribute-replace: + description: | + Replace the parent nested attribute with attribute set + type: boolean operations: description: Operations supported by the protocol. diff --git a/Documentation/userspace-api/netlink/genetlink-legacy.rst b/Documentation/userspace-api/netlink/genetlink-legacy.rst index 7126b650090e..a9ccbfbb4a8d 100644 --- a/Documentation/userspace-api/netlink/genetlink-legacy.rst +++ b/Documentation/userspace-api/netlink/genetlink-legacy.rst @@ -381,3 +381,28 @@ alongside a sub-message selector and also in a top level ``attribute-set``, then the selector will be resolved using the value 'closest' to the selector. If the value is not present in the message at the same level as defined in the spec then this is an error. + +Some users, like devlink param, fill different attribute type according to +selector attribute value. ``replace-attribute`` set to ``true`` indicates, +that sub-message is not nested inside the attribute, but rather replacing +the attribute. This allows to treat the attribute type differently according +to the selector: + +.. code-block:: yaml + + sub-messages: + - + name: dl-param-value-data-msg + formats: + - + value: u32 + attribute-set: dl-param-value-data-u32-attrs + attribute-replace: true + - + value: string + attribute-set: dl-param-value-data-string-attrs + attribute-replace: true + - + value: bool + attribute-set: dl-param-value-data-bool-attrs + attribute-replace: true diff --git a/tools/net/ynl/lib/nlspec.py b/tools/net/ynl/lib/nlspec.py index 5e48ee0fb8b4..280d50e9079c 100644 --- a/tools/net/ynl/lib/nlspec.py +++ b/tools/net/ynl/lib/nlspec.py @@ -237,6 +237,9 @@ class SpecAttrSet(SpecElement): def items(self): return self.attrs.items() + def keys(self): + return self.attrs.keys() + class SpecStructMember(SpecElement): """Struct member attribute @@ -318,6 +321,8 @@ class SpecSubMessageFormat(SpecElement): value attribute value to match against type selector fixed_header string, name of fixed header, or None attr_set string, name of attribute set, or None + attr_replace bool, indicates replacement of parent attribute with + attr_set decode, or None """ def __init__(self, family, yaml): super().__init__(family, yaml) @@ -325,6 +330,7 @@ class SpecSubMessageFormat(SpecElement): self.value = yaml.get('value') self.fixed_header = yaml.get('fixed-header') self.attr_set = yaml.get('attribute-set') + self.attr_replace = yaml.get('attribute-replace') class SpecOperation(SpecElement): diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py index d2ea1571d00c..8591e6bfe40b 100644 --- a/tools/net/ynl/lib/ynl.py +++ b/tools/net/ynl/lib/ynl.py @@ -507,11 +507,16 @@ class YnlFamily(SpecFamily): attr_payload += self._encode_struct(msg_format.fixed_header, value) if msg_format.attr_set: if msg_format.attr_set in self.attr_sets: - nl_type |= Netlink.NLA_F_NESTED - sub_attrs = SpaceAttrs(msg_format.attr_set, value, search_attrs) - for subname, subvalue in value.items(): - attr_payload += self._add_attr(msg_format.attr_set, - subname, subvalue, sub_attrs) + if msg_format.attr_replace: + first_attr_name = list(self.attr_sets[msg_format.attr_set].keys())[0] + return self._add_attr(msg_format.attr_set, first_attr_name, + value, search_attrs) + else: + nl_type |= Netlink.NLA_F_NESTED + sub_attrs = SpaceAttrs(msg_format.attr_set, value, search_attrs) + for subname, subvalue in value.items(): + attr_payload += self._add_attr(msg_format.attr_set, + subname, subvalue, sub_attrs) else: raise Exception(f"Unknown attribute-set '{msg_format.attr_set}'") else: @@ -600,8 +605,17 @@ class YnlFamily(SpecFamily): offset = self._struct_size(msg_format.fixed_header) if msg_format.attr_set: if msg_format.attr_set in self.attr_sets: - subdict = self._decode(NlAttrs(attr.raw, offset), msg_format.attr_set) + if msg_format.attr_replace: + attrs = [attr] + else: + attrs = NlAttrs(attr.raw, offset); + subdict = self._decode(attrs, msg_format.attr_set) decoded.update(subdict) + if msg_format.attr_replace: + try: + decoded = decoded[attr_spec.name] + except KeyError: + raise Exception(f"Attribute-set '{attr_space}' does not contain '{attr_spec.name}'") else: raise Exception(f"Unknown attribute-set '{attr_space}' when decoding '{attr_spec.name}'") return decoded From patchwork Mon Feb 19 17:25:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 13562929 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (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 085574594D for ; Mon, 19 Feb 2024 17:25:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708363555; cv=none; b=jOlMgvgSe9XK1gzp3CyqA/iqsIJDNyXLIfUscjXblyABFvEtntkztLNyctANDsLGa0ru2PjcdlYylH2ruPUuidqMb81JRS4frpjHzXIo4nfkPmGTOjmMFm+DxbTWaqsAQjlW+Mtr4fQ6hGJtHSnXxtsmt6taYMNA9cdaURtjVhA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708363555; c=relaxed/simple; bh=FAZBfa++7j/K7/n7e5FxBykhn9klPNwABfnn5l8c7zo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XZWy4P/IFAu450NXFFJRd8/RDTgf/GFFZuDvWaAowoEnPWOirAMDTn5ok0wF5d+ogD+o3cwAUjDwLdV5sYuRlYtdukI9Cp+IkkyfjHQ18dak7a4Swa8g/rKWZ+s5+QiHv9oZWFd6nbrbS8DjS934fHcq0f6/LQR9k1nE9gudHnE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=resnulli.us; spf=none smtp.mailfrom=resnulli.us; dkim=pass (2048-bit key) header.d=resnulli-us.20230601.gappssmtp.com header.i=@resnulli-us.20230601.gappssmtp.com header.b=gjRRgzp5; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=resnulli.us Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=resnulli.us Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=resnulli-us.20230601.gappssmtp.com header.i=@resnulli-us.20230601.gappssmtp.com header.b="gjRRgzp5" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-41265d2f7acso9316485e9.1 for ; Mon, 19 Feb 2024 09:25:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20230601.gappssmtp.com; s=20230601; t=1708363552; x=1708968352; 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=3Fq3p/IfJFXI2r+7jsJUt/OXDP9zZUxHE6KScodL9cI=; b=gjRRgzp5Y+/Jobcgq5pT39EcjuhjWxhObP8/mqtwLvfAmbIFSFxtFg6l0r4Y4o77mC mAqaillt5A/JgoX/A1CdbLmuPFD57QkB8mINsDXKEYGCLtWa10UZC11bZM2DfcDXjOTF Gl3wVqTegmoIYikwQUVt1nEe/zOKiJKJTu/Oe4IZLUt4oIw5VAB8vRA01jPOpBP0ua+/ ygiglmmpF0fDGvk2DdvYcWam7k6jLASdA0HlxyM+AlrJuP9hbplIvoV254ftBprID9TI A/dLGaVXPcc5DAg0EMc0hjAChCYUn4aQj9GWVJ5bGMm82LBSCKbmc6Je1KYEr/1y2DV5 zP0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708363552; x=1708968352; 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=3Fq3p/IfJFXI2r+7jsJUt/OXDP9zZUxHE6KScodL9cI=; b=toVTH3A92+CAFbaM8Bf8wq1RuWKF9ZYY/p41qOk5Vm3/MnBLZ3nqjmnEgZpQPQQKEs FpsPkAyiA4z40QHXIewLfFl6HM0NWoZUM29qC0U1yjVeZ6u6Pr/uH7HfbZRGjtJr7zTM 2rZG0/VzeNQ5P7W/ElDjZxXLUH2+7XIdw6L2dVSpx5NK+fAKDSYxej3XqZU5Oz7jZA3h PPwQSZjX92nM5ceN6STAHgH0Q/LDLjmdhW5RoCzMV5t/P2FTDRqC39djtIHcybkgajo3 HDDRuOZeX2+1+Mo8bV+bj0zE8eohL2NmwR21id6rZY+YiiDTYiLt5uEhkPrOyp23QGwq f1Ng== X-Gm-Message-State: AOJu0YzlZkjaBwPmv8Or4EeJr/4rjbYi3in9WEvqBccoxmp4hTzd+96t 2t9ktyznaLpnYZL09p6cjiOfPP9u46eJrXq/EZAVN508BbdH2HEKCoBUGaZ116sDf0iMxQ9uTa0 2 X-Google-Smtp-Source: AGHT+IG/mdfnikVko0WdQww8yuDh2qz70gzF76ETUhOUxch5dUBfRSn4+HJ8gpx7kLkx6UVyJHq3Cg== X-Received: by 2002:a05:600c:4711:b0:412:6b21:dad9 with SMTP id v17-20020a05600c471100b004126b21dad9mr773121wmo.25.1708363552493; Mon, 19 Feb 2024 09:25:52 -0800 (PST) Received: from localhost ([193.47.165.251]) by smtp.gmail.com with ESMTPSA id f8-20020a05600c4e8800b0040f0219c371sm12073169wmq.19.2024.02.19.09.25.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 09:25:52 -0800 (PST) From: Jiri Pirko To: netdev@vger.kernel.org Cc: kuba@kernel.org, pabeni@redhat.com, davem@davemloft.net, edumazet@google.com, jacob.e.keller@intel.com, swarupkotikalapudi@gmail.com, donald.hunter@gmail.com, sdf@google.com, lorenzo@kernel.org, alessandromarcolini99@gmail.com Subject: [patch net-next 07/13] tools: ynl: add support for list in nested attribute Date: Mon, 19 Feb 2024 18:25:23 +0100 Message-ID: <20240219172525.71406-8-jiri@resnulli.us> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240219172525.71406-1-jiri@resnulli.us> References: <20240219172525.71406-1-jiri@resnulli.us> 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 From: Jiri Pirko Some nested attributes, like devlink-fmg, contain plain list of attributes that may repeat. Current decode rsp implementation is dictionary which causes duplicate attributes to be re-written. To solve this, introduce "nested-list" flag for "nest" type which indicates the _decode() function to use list instead of dictionary and store each decoded attribute into this list as a separate dictionary. Signed-off-by: Jiri Pirko --- Documentation/netlink/genetlink-legacy.yaml | 3 +++ tools/net/ynl/lib/ynl.py | 18 ++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Documentation/netlink/genetlink-legacy.yaml b/Documentation/netlink/genetlink-legacy.yaml index 77d89f81c71f..0e0ee3b4ff5f 100644 --- a/Documentation/netlink/genetlink-legacy.yaml +++ b/Documentation/netlink/genetlink-legacy.yaml @@ -220,6 +220,9 @@ properties: nested-attributes: description: Name of the space (sub-space) used inside the attribute. type: string + nested-list: + description: The nested attribute contains a list of attributes. + type: boolean enum: description: Name of the enum type used for the attribute. type: string diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py index 8591e6bfe40b..08fe27c8dec7 100644 --- a/tools/net/ynl/lib/ynl.py +++ b/tools/net/ynl/lib/ynl.py @@ -386,8 +386,12 @@ class SpaceAttrs: def lookup(self, name): for scope in self.scopes: if name in scope.spec: - if name in scope.values: + if isinstance(scope.values, dict) and name in scope.values: return scope.values[name] + if isinstance(scope.values, list): + for item in reversed(scope.values): + if name in item: + return item[name] spec_name = scope.spec.yaml['name'] raise Exception( f"No value for '{name}' in attribute space '{spec_name}'") @@ -568,6 +572,10 @@ class YnlFamily(SpecFamily): return attr.as_bin() def _rsp_add(self, rsp, name, is_multi, decoded): + if isinstance(rsp, list): + rsp.append({name: decoded}) + return + if is_multi == None: if name in rsp and type(rsp[name]) is not list: rsp[name] = [rsp[name]] @@ -620,8 +628,8 @@ class YnlFamily(SpecFamily): raise Exception(f"Unknown attribute-set '{attr_space}' when decoding '{attr_spec.name}'") return decoded - def _decode(self, attrs, space, outer_attrs = None): - rsp = dict() + def _decode(self, attrs, space, outer_attrs = None, to_list = False): + rsp = list() if to_list else dict() if space: attr_space = self.attr_sets[space] search_attrs = SpaceAttrs(attr_space, rsp, outer_attrs) @@ -637,7 +645,9 @@ class YnlFamily(SpecFamily): continue if attr_spec["type"] == 'nest': - subdict = self._decode(NlAttrs(attr.raw), attr_spec['nested-attributes'], search_attrs) + nested_list = attr_spec['nested-list'] if 'nested-list' in attr_spec else False + subdict = self._decode(NlAttrs(attr.raw), attr_spec['nested-attributes'], + search_attrs, to_list = nested_list) decoded = subdict elif attr_spec["type"] == 'string': decoded = attr.as_strz() From patchwork Mon Feb 19 17:25:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 13562930 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) (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 E9CA445949 for ; Mon, 19 Feb 2024 17:25:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708363559; cv=none; b=gD2EvYqqFcOqBizegiUqsS7Q+Tn8QFXDh/lsiMhUYAzqJNTdEPQ66jn8d9ER+C+9ktbp2mpAbDqM37BnDYNez8/wPDsShECthoM0olpLhwTGKxZyq3rdQuRKRmgOXYIQSf3OWB4+hSa4OGDZgVO+udlY4YY4v68n906TLctzyCE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708363559; c=relaxed/simple; bh=BLq8wOiYXgw7Y4k8JludUzRIxFjVuD2WHVqu+wyJiPU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Egdh3YCaVJKZwNeoUJ/TAb65gQ8GGtnnnifpxBhDge1ogzZkWTyfsj6zHdtkcrBOcv9zIAAR+gnYTp/jWLKOgOjnH4iyX1wUENz11mOzKQ10jddT6ihsKDzYzT+tytpWSyBX9/ZMLsQxqQ75rRt+dRj97StCpwXoUDNxVSoOHj4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=resnulli.us; spf=none smtp.mailfrom=resnulli.us; dkim=pass (2048-bit key) header.d=resnulli-us.20230601.gappssmtp.com header.i=@resnulli-us.20230601.gappssmtp.com header.b=X+kWIDsS; arc=none smtp.client-ip=209.85.208.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=resnulli.us Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=resnulli.us Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=resnulli-us.20230601.gappssmtp.com header.i=@resnulli-us.20230601.gappssmtp.com header.b="X+kWIDsS" Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-2d23d301452so13743471fa.1 for ; Mon, 19 Feb 2024 09:25:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20230601.gappssmtp.com; s=20230601; t=1708363556; x=1708968356; 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=Rtar3L9lnS2gnPoYg+aSyBoSu9laTfbnubInsfKdzJ0=; b=X+kWIDsS7dvQMgmklMgWqmL00omiTVwHVnJ7rMaGRQDkmIf2tW8OE4o6pv3VWaKQ/9 QyE5YYO0BmNOiG9F2cUeZrxtFkEHDHOseqLQk3WxMUbN+T7enyw7lJKPsNTRvooEVOv/ jk0hxUV5PadDQZwVdGH0K3fKLPXZriHN0/gTMJ5aBiSTR/hN/6onhh7V3rwotvea4/bt oZelPJF8V31TNj4zdReH18geYwlVKLzkrEklthecVGfWDky0DcnHleJHJJerHWIIQw92 +hFhB8wIrBzrOBMoJf7bItz4EQ7YY2P6CYhVTTXmq0ZR9WAYdGrxUDX4xXcC7Gnxe/YW lg5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708363556; x=1708968356; 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=Rtar3L9lnS2gnPoYg+aSyBoSu9laTfbnubInsfKdzJ0=; b=pd/ZkGllc7EeljR/ruL7s1/XrlAqf4u2NI8RIl/Bq4IXZBI5SHoFO6XGmp/QXzzx3w xu/mEOC/Ab3sADm26Ue1uyWeWOhZwrTyo7oDHOpkCjvNUJ7ue29pLnQ9M5gpXUregPEc xzsdcRDwRD06fZmpxcBKM6O0LtEV4clybDmnbihF/cjqztrnZgX7qRLTICH1/pTcGWwN QCIHHMkoHTXwTwo6Qxmv9F703ChCZaAITx+VBXQTYof99LusBXNEsH62IrWnRxQzG2MX voeX13XN0aSRZGGD/Nk5E34S1gU1xqlkEjXKF/PuUH9+303hQ9jM5yVDrWw9QdhI9nQi mU5g== X-Gm-Message-State: AOJu0Yw+moWYV/sBG4Gly8HSi4jQA3IJpbd2Dt5Hf51PPWCGZO4gCAeu XuaexNxqIYc6K8nY+/ZrvGlKzmQ4KpG+wVhso+drnYbZadtddzu3Kv2d0x57Sb5umQi1BKNV+zB m X-Google-Smtp-Source: AGHT+IGr2hvzJR2lsk7bPNlr13fSnpv+bkLH/es6i94rLYQ6lPyQkUyTBs9tK6mC/nUviLdiUZWy8g== X-Received: by 2002:a2e:b1c9:0:b0:2d2:3f13:52e7 with SMTP id e9-20020a2eb1c9000000b002d23f1352e7mr1456333lja.12.1708363556019; Mon, 19 Feb 2024 09:25:56 -0800 (PST) Received: from localhost ([193.47.165.251]) by smtp.gmail.com with ESMTPSA id q17-20020a7bce91000000b00412656ba919sm4185147wmj.20.2024.02.19.09.25.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 09:25:55 -0800 (PST) From: Jiri Pirko To: netdev@vger.kernel.org Cc: kuba@kernel.org, pabeni@redhat.com, davem@davemloft.net, edumazet@google.com, jacob.e.keller@intel.com, swarupkotikalapudi@gmail.com, donald.hunter@gmail.com, sdf@google.com, lorenzo@kernel.org, alessandromarcolini99@gmail.com Subject: [patch net-next 08/13] netlink: specs: devlink: add enum for param-type attribute values Date: Mon, 19 Feb 2024 18:25:24 +0100 Message-ID: <20240219172525.71406-9-jiri@resnulli.us> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240219172525.71406-1-jiri@resnulli.us> References: <20240219172525.71406-1-jiri@resnulli.us> 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 From: Jiri Pirko For devlink param values, devlink relies on NLA_* values what are used internally in kernel to indicate which type the attribute is. This is not exposed over UAPI. Add devlink-param-type enum that defines these values as part of devlink yaml spec. Signed-off-by: Jiri Pirko --- Documentation/netlink/specs/devlink.yaml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Documentation/netlink/specs/devlink.yaml b/Documentation/netlink/specs/devlink.yaml index cf6eaa0da821..88abe137c8ef 100644 --- a/Documentation/netlink/specs/devlink.yaml +++ b/Documentation/netlink/specs/devlink.yaml @@ -164,6 +164,22 @@ definitions: value: 1 - name: fw-activate + - + type: enum + name: param-type + entries: + - + name: u8 + value: 1 + - + name: u16 + - + name: u32 + - + name: string + value: 5 + - + name: flag - type: enum name: param-cmode @@ -498,6 +514,7 @@ attribute-sets: - name: param-type type: u8 + enum: param-type # TODO: fill in the attributes in between From patchwork Mon Feb 19 17:25:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 13562931 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (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 E589547F66 for ; Mon, 19 Feb 2024 17:26:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708363562; cv=none; b=LfiCziqm2DazVeyebkcPc39gKuwZGUJUTLKFVelaWQ8cynItTEv+Lc9063b0IkkEqrnLsgjfuJ84QmI0np+A6y2LKR+LqEXmC9S+K3WcmKYhrBIvm7dSp4lZqkyK8VSoC/kIeYZTxnQZkCR076CHvLyq7E+eDiFoRVrIhQ+iXe0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708363562; c=relaxed/simple; bh=qoJaqWXXg5rI4XdWMgT95nwV5PqftHgMeTqk5uYVKrA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tDfgafeom5r9SbZ9/P/FdXm60Ka8n9MzKvyrEmkA2xV5PkUZNCpFQiT1VeRGazqNmLWS9x6LtJh3QQOD25iiapv/WZjqYwv8ITMJazNYUCJYfJN5DtyAXCsKz1qMbRcuA1q4N5Cw5K2/HSyjrEfHtMaoGJx1/CQAvOh7LScfMT8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=resnulli.us; spf=none smtp.mailfrom=resnulli.us; dkim=pass (2048-bit key) header.d=resnulli-us.20230601.gappssmtp.com header.i=@resnulli-us.20230601.gappssmtp.com header.b=Zh0msQR2; arc=none smtp.client-ip=209.85.128.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=resnulli.us Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=resnulli.us Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=resnulli-us.20230601.gappssmtp.com header.i=@resnulli-us.20230601.gappssmtp.com header.b="Zh0msQR2" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-41265d2f7acso9317815e9.1 for ; Mon, 19 Feb 2024 09:26:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20230601.gappssmtp.com; s=20230601; t=1708363559; x=1708968359; 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=RfmVQ5R2UOAKUN7/YSww2fNeo+L1KnH68E7KMxQ9YUU=; b=Zh0msQR2hLlBogcfRTJzT7AceNC01i9OrtRLUchcDk8+w1LvZmx+jwXkwWNB7bdGbc YN7qhWrIkEDgiJmBoBSmsFc5so/hjfP6rTgBvzlFcvKLUKnZB7flrPeZlQMoDhiS0IMQ u8MGXmCCbBfiEqFfPWWNLMOi0/m2A9lUyC1968EcV6tp8hg7mHifVr66mGGec6rdgF8W 6SlLKWPunADJ4bhRxRsCEW9FC9wGy7nA2Dh7HlDfB5W0YOlO+aucko0Gj8Im7Av6XLD4 BgsEDHeiX4PRAvLe2J7DJkR1wWckQOkJvuFSFDSru3PUjnA7FsJPBIUNJdztvQh6qm8a 4hhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708363559; x=1708968359; 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=RfmVQ5R2UOAKUN7/YSww2fNeo+L1KnH68E7KMxQ9YUU=; b=rs/5MxW/eWMUyCgTHlPs/MLKwdk9G8V9uP4S7bSEYeXiKsVSRhKSLYDZjxDAin35ZU blICMWq2sN5YvkBP0vw7UEMOAmyDZaZjO0Xl3h0fEK6WRczzZ9RRXfqTAV0jlt8C2GnY AwKanCnvXKxLcA9pmcUBWVSrQRo6gtsnurgoCEfjV8sN54PeUEb+xFryU06nPQ10jNl4 KnfVWmEsZAawRpVCRbX6Qc6AZW1gjVrA2bg8vmWVJzupADUjyadN1NcltjNOszvCpFzN 5GIETHke3X03Q37RDgtxb47Wou6KP33+ppVDxJKP32fmhW6x9Ukr1qdhPmynY7RtHw1+ G8Xw== X-Gm-Message-State: AOJu0YyXFut6X/lktm+Vd2gZW0oS8ohHdAgzYbUHVY24brgxj2YR8XbH +1VsN8qF1NvLeLam4jUYF+YgyhX0S1di4GO9WAh5g0uuvjBUDJJ5Xb/5CJCSwx+hBf/eH0VPCKS H X-Google-Smtp-Source: AGHT+IF8Oeci0xI4yrjharBye7dnDNOMT6j0r4aV0iWNntezCO2Zm86EQ3pZtufJ/oQ+SG/2uJ58eQ== X-Received: by 2002:a05:600c:91a:b0:40e:f46d:ad35 with SMTP id m26-20020a05600c091a00b0040ef46dad35mr11316981wmp.36.1708363559538; Mon, 19 Feb 2024 09:25:59 -0800 (PST) Received: from localhost ([193.47.165.251]) by smtp.gmail.com with ESMTPSA id c24-20020a7bc018000000b00411c724fa10sm11835191wmb.2.2024.02.19.09.25.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 09:25:58 -0800 (PST) From: Jiri Pirko To: netdev@vger.kernel.org Cc: kuba@kernel.org, pabeni@redhat.com, davem@davemloft.net, edumazet@google.com, jacob.e.keller@intel.com, swarupkotikalapudi@gmail.com, donald.hunter@gmail.com, sdf@google.com, lorenzo@kernel.org, alessandromarcolini99@gmail.com Subject: [patch net-next 09/13] netlink: specs: devlink: add missing param attribute definitions Date: Mon, 19 Feb 2024 18:25:25 +0100 Message-ID: <20240219172525.71406-10-jiri@resnulli.us> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240219172525.71406-1-jiri@resnulli.us> References: <20240219172525.71406-1-jiri@resnulli.us> 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 From: Jiri Pirko Add missing values list attribute and all nested attributes definition, including param-value-data. For this one, use newly introduced sub-message replace-attribute infrastructure to allow to process attribute type selected by param-value-type. Signed-off-by: Jiri Pirko --- Documentation/netlink/specs/devlink.yaml | 108 +++++++++++++++++++++-- 1 file changed, 102 insertions(+), 6 deletions(-) diff --git a/Documentation/netlink/specs/devlink.yaml b/Documentation/netlink/specs/devlink.yaml index 88abe137c8ef..71a95163c419 100644 --- a/Documentation/netlink/specs/devlink.yaml +++ b/Documentation/netlink/specs/devlink.yaml @@ -515,14 +515,24 @@ attribute-sets: name: param-type type: u8 enum: param-type - - # TODO: fill in the attributes in between - + - + name: param-values-list + type: nest + nested-attributes: dl-param-values-list + - + name: param-value + type: nest + multi-attr: true + nested-attributes: dl-param-value + - + name: param-value-data + type: sub-message + sub-message: dl-param-value-data-msg + selector: param-type - name: param-value-cmode type: u8 enum: param-cmode - value: 87 - name: region-name type: string @@ -1131,8 +1141,24 @@ attribute-sets: name: param-generic - name: param-type + - + name: param-values-list + + - + name: dl-param-values-list + subset-of: devlink + attributes: + - + name: param-value - # TODO: fill in the attribute param-value-list + - + name: dl-param-value + subset-of: devlink + attributes: + - + name: param-value-data + - + name: param-value-cmode - name: dl-region-snapshots @@ -1243,6 +1269,71 @@ attribute-sets: name: flash type: flag + - + name: dl-param-value-data-u8-attrs + subset-of: devlink + attributes: + - + name: param-value-data + type: u8 + + - + name: dl-param-value-data-u16-attrs + subset-of: devlink + attributes: + - + name: param-value-data + type: u16 + + - + name: dl-param-value-data-u32-attrs + subset-of: devlink + attributes: + - + name: param-value-data + type: u32 + + - + name: dl-param-value-data-string-attrs + subset-of: devlink + attributes: + - + name: param-value-data + type: string + + - + name: dl-param-value-data-flag-attrs + subset-of: devlink + attributes: + - + name: param-value-data + type: flag + +sub-messages: + - + name: dl-param-value-data-msg + formats: + - + value: u8 + attribute-set: dl-param-value-data-u8-attrs + attribute-replace: true + - + value: u16 + attribute-set: dl-param-value-data-u16-attrs + attribute-replace: true + - + value: u32 + attribute-set: dl-param-value-data-u32-attrs + attribute-replace: true + - + value: string + attribute-set: dl-param-value-data-string-attrs + attribute-replace: true + - + value: flag + attribute-set: dl-param-value-data-flag-attrs + attribute-replace: true + operations: enum-model: directional list: @@ -1731,7 +1822,12 @@ operations: - dev-name - param-name reply: ¶m-get-reply - attributes: *param-id-attrs + attributes: + - bus-name + - dev-name + - param-name + - param-type + - param-values-list dump: request: attributes: *dev-id-attrs From patchwork Mon Feb 19 17:26:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 13562932 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) (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 DF327481A3 for ; Mon, 19 Feb 2024 17:26:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708363594; cv=none; b=KgSPTVUGl6Xb5nr69tNyFjeexM3YqSsyDYKRKBzS6es5lSiupLUz1KOH3aKjqsbda0WhpLnvhCoP/R42sa0yy8quX5kSmClimis8T+BBwFUjDF1c2SIaDxPWOVBX9QgtQpls628FKPWq9jQ/ybxP9VYTFrdiUVa6xZTNsmfhwnc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708363594; c=relaxed/simple; bh=ZmRRi72QlLwVie4HVc++aEG+Gla3MKtvmWEBsk6eYvk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GgwBkXyKzNdU47Y114/EajiorEYeUSe/F2/MEaiBt5d3k6BPJ9v9oRgBNKI+eVkrXV7eLOYjmn4pl7IsTRbu48Z7E9e/vmU7lTD61evI7L4DjQ3gxFdtuiH4wcycszRFmnPro4xwh9mKkFqj83E97QnXxlUvFdGUShfW/yLP4y0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=resnulli.us; spf=none smtp.mailfrom=resnulli.us; dkim=pass (2048-bit key) header.d=resnulli-us.20230601.gappssmtp.com header.i=@resnulli-us.20230601.gappssmtp.com header.b=1jbkT23s; arc=none smtp.client-ip=209.85.208.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=resnulli.us Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=resnulli.us Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=resnulli-us.20230601.gappssmtp.com header.i=@resnulli-us.20230601.gappssmtp.com header.b="1jbkT23s" Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-2d22fa5c822so23959121fa.2 for ; Mon, 19 Feb 2024 09:26:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20230601.gappssmtp.com; s=20230601; t=1708363591; x=1708968391; 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=JQeo1UPxZL8Cd5PAqEqjdEFmeYRWQHzRP+SNpoBhjyo=; b=1jbkT23s1rh08hy3TIkIsQtO/vwPucvzTRXKQgBU90etaCmyt5t4KdLSYZXdiyCXaH B+JLRxo8nHTPemWim7KmNsiaEa3LFMlWXY3ebgdBhF84jhisW18odVcWjVgTNkshKT9b LzfmGRQIQvFBj+GxJpW7cpOSjPETGUteVSCT4WP6CPg+KyhqUJ2IwPjJFMhlckihuGz/ t3Ea9GaI09xw/kOOXf44UCJCDZJvcCJWckK4F6ala5ziSTSx2mNdTOPqupm0N/5VRsE7 v5/UR6o7YD04xadHulMzv2CwlXSsXaynS89PP0bxefdFoiVM1gZdImUqZKMCHCGoXamV 8M8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708363591; x=1708968391; 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=JQeo1UPxZL8Cd5PAqEqjdEFmeYRWQHzRP+SNpoBhjyo=; b=CeMH/B0VlValf5yKDdiyqeVKuIyxV2ue6Cc7V1lRHqGkfrtTr103b9T48RxIqyJcVD N6g7cIJ49tlmwLbZf67Ccd1ZsXMH5ffpNQsq+8u0FNVZheskp0MRR6B0qtayDGP5Cmr4 dQNoPe96a3LtB4/TBG1i5lJm0R9igS0mgBvSNQAnJWRKYpyqmbqWYQZPj/+nGHFh4PiU pO1esdKee6bzDQapV8xNW7Rr39CFSPmHU7qnTJRDuK7XZRodpDJi9E5wpFQ/R8BSxc+z UCOTUA47PDCmoeKSQXjO5l31NI2QWSvm55gc3wrW5BrgB8MUGomLgGte4jrnGEh79IL6 Uz+A== X-Gm-Message-State: AOJu0YweAnsehBWa3zieLaFAXteklV4zQP33rKaB8jVly56jJfBip4v3 +bKTCW8kwNMhLQ6dyB1eNNIVMcYKm6xS1aSGuNH1iZB1a8YKR7+ijbmwAAYJbppm2yyc+QgRiM0 B X-Google-Smtp-Source: AGHT+IFfkliyw68l3IDMRTzCBSccIOUmoBpz47Ean3U5BYaOA/CxirLrLM5jCLl4YBJO08gFEJFWhQ== X-Received: by 2002:a2e:b5ce:0:b0:2d2:31e5:103b with SMTP id g14-20020a2eb5ce000000b002d231e5103bmr4145404ljn.17.1708363591234; Mon, 19 Feb 2024 09:26:31 -0800 (PST) Received: from localhost ([193.47.165.251]) by smtp.gmail.com with ESMTPSA id u19-20020a05600c19d300b004126ca6c241sm378689wmq.23.2024.02.19.09.26.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 09:26:30 -0800 (PST) From: Jiri Pirko To: netdev@vger.kernel.org Cc: kuba@kernel.org, pabeni@redhat.com, davem@davemloft.net, edumazet@google.com, jacob.e.keller@intel.com, swarupkotikalapudi@gmail.com, donald.hunter@gmail.com, sdf@google.com, lorenzo@kernel.org, alessandromarcolini99@gmail.com Subject: [patch net-next 10/13] netlink: specs: devlink: treat dl-fmsg attribute as list Date: Mon, 19 Feb 2024 18:26:25 +0100 Message-ID: <20240219172628.71455-1-jiri@resnulli.us> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240219172525.71406-1-jiri@resnulli.us> References: <20240219172525.71406-1-jiri@resnulli.us> 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 From: Jiri Pirko Benefit from the previously introduces "nested-list" flag for "nest" type and use it to indicate dl-fmsg attribute contains a list. Signed-off-by: Jiri Pirko --- Documentation/netlink/specs/devlink.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/netlink/specs/devlink.yaml b/Documentation/netlink/specs/devlink.yaml index 71a95163c419..df1afdf06068 100644 --- a/Documentation/netlink/specs/devlink.yaml +++ b/Documentation/netlink/specs/devlink.yaml @@ -601,6 +601,7 @@ attribute-sets: name: fmsg type: nest nested-attributes: dl-fmsg + nested-list: true - name: fmsg-obj-nest-start type: flag From patchwork Mon Feb 19 17:26:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 13562933 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) (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 9650247A4D for ; Mon, 19 Feb 2024 17:26:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708363598; cv=none; b=UYoCsTt5TK+wERI0DgpATvoJkbh1FJdRyFKb6gisD0g7FR5Joik1QSpoMcKfPBLtUSOPpJjjUFYAxr35CGe3Jm4MFLUgWmH0wLzhOCilPXcEKK2ez25fuT3WKkuG9/SAAT0GbWLXWjHAbeVA90ylWJ4MnR4WzTswB9SxVJTc6Kk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708363598; c=relaxed/simple; bh=jKndwCTCAzjrCNl7/zG6rOf498cgyEExsuTgouFBll4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ajRL56pGEBZM68JtrBa/2vhVK+/ZVxP0siUFxdwn2aYMyxz/ukMz0pNs8UlfDKfxu+jMyUjQqGi+jBJbWB9EnHAUNWSHN3L6KntqiqfP4YNZDaTJX6LiFqf6ITBIsOwr661RBlc7e+vl4XlAn4I5/CtwHF09IXUqFhBOwynTl60= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=resnulli.us; spf=none smtp.mailfrom=resnulli.us; dkim=pass (2048-bit key) header.d=resnulli-us.20230601.gappssmtp.com header.i=@resnulli-us.20230601.gappssmtp.com header.b=wK54awbR; arc=none smtp.client-ip=209.85.208.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=resnulli.us Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=resnulli.us Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=resnulli-us.20230601.gappssmtp.com header.i=@resnulli-us.20230601.gappssmtp.com header.b="wK54awbR" Received: by mail-lj1-f180.google.com with SMTP id 38308e7fff4ca-2d2305589a2so24701271fa.1 for ; Mon, 19 Feb 2024 09:26:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20230601.gappssmtp.com; s=20230601; t=1708363595; x=1708968395; 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=u5PryIoP66cTJV5dj10Xgw4cU+fKj9Ha6rspTNzKBT8=; b=wK54awbR7MsgzIXYw67zMmV0WGIXSyV8AR2qVqkdCW2VNQRkOu072a9cdW4FPszqME JR7Lp3K7HBHriMfH0EK+MOKGfpv+fMXtNgeKAI2kygUYy32c9QfkQvBcUwNEULD1dK3L CUPR6+fFnMfoB1Utvo9+lt90U/aCdDyLqrQGRJC0X+kK0Q+qX/WXzEk4wm+CEHLySLwe Eqdlq483QgZpOVO5ZwTZw7kgo31crrF1xMmNf/zAZzH2eqLhB7g/yJ5kb6JFyu1lk233 uiI95Q97cqlfcr83/sfMdBxaF458YO/paresfBI85uskcXWCUWbz6VMYXVZ4v9UMFjy+ aNgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708363595; x=1708968395; 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=u5PryIoP66cTJV5dj10Xgw4cU+fKj9Ha6rspTNzKBT8=; b=dICEcLtY6IjGC4+3/OVJqNsRyFHAJ03Lwna4V+bPilLiXpAX8lTpVDai0D3YUfoFqi XkjGVcxcl9KxQ3KYN9nkI9sXYcEsSk9iCeHKb24Y/9ueZ2XoGLgmJPefZlHnqiZVOJzk QCjFiFRwXeBPBPWwEetoFoCBSSrQkxRnCPq1d3jST2VHgeksppi3Svj0C/BWRnM4y6ah owcD11OOIRrAnTSEO+9W8JlkIUAZpc1IvAWyLRS7WQjlxAcFznGtlFcoHBgpgBEITqGn ZeFtc9AWaz/aInTMeeeCzNuE4jQ7yDf9fauE8WUn042t3/+m34wRRjwV4w4tdUpPJWNr QmZA== X-Gm-Message-State: AOJu0Yw/3naq661uNb/UvwlCNow2gZ2oWne9Xt+HKVXXhoq07qc7jS8e u9mTLj8//A0our3wgMnmqy4b23KTIY1dSf+/lO96K8FdqPF0s0tTOmOrRLaiaPGjjzppsbtMn2W j X-Google-Smtp-Source: AGHT+IEzQihch9yCP9FJc3ygxQr+BsyNAKO2U/UCZ0ajlt1SLxipbyLPuClYZxy8uwlUeOWiujhDSQ== X-Received: by 2002:a05:651c:217:b0:2d2:4054:2fab with SMTP id y23-20020a05651c021700b002d240542fabmr1536251ljn.37.1708363594704; Mon, 19 Feb 2024 09:26:34 -0800 (PST) Received: from localhost ([193.47.165.251]) by smtp.gmail.com with ESMTPSA id 14-20020a056000154e00b0033d10bd6612sm11132559wry.81.2024.02.19.09.26.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 09:26:34 -0800 (PST) From: Jiri Pirko To: netdev@vger.kernel.org Cc: kuba@kernel.org, pabeni@redhat.com, davem@davemloft.net, edumazet@google.com, jacob.e.keller@intel.com, swarupkotikalapudi@gmail.com, donald.hunter@gmail.com, sdf@google.com, lorenzo@kernel.org, alessandromarcolini99@gmail.com Subject: [patch net-next 11/13] netlink: specs: devlink: add enum for fmsg-obj-value-type attribute values Date: Mon, 19 Feb 2024 18:26:26 +0100 Message-ID: <20240219172628.71455-2-jiri@resnulli.us> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240219172628.71455-1-jiri@resnulli.us> References: <20240219172525.71406-1-jiri@resnulli.us> <20240219172628.71455-1-jiri@resnulli.us> 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 From: Jiri Pirko For devlink fmsg object values, devlink relies on NLA_* values what are used internally in kernel to indicate which type the attribute is. This is not exposed over UAPI. Add devlink-param-type enum that defines these values as part of devlink yaml spec. Signed-off-by: Jiri Pirko --- Documentation/netlink/specs/devlink.yaml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Documentation/netlink/specs/devlink.yaml b/Documentation/netlink/specs/devlink.yaml index df1afdf06068..fa4440141b05 100644 --- a/Documentation/netlink/specs/devlink.yaml +++ b/Documentation/netlink/specs/devlink.yaml @@ -218,6 +218,26 @@ definitions: name: exception - name: control + - + type: enum + name: fmsg-obj-value-type + entries: + - + name: u8 + value: 1 + - + name: u32 + value: 3 + - + name: u64 + - + name: flag + value: 6 + - + name: string + value: 10 + - + name: binary attribute-sets: - @@ -620,6 +640,7 @@ attribute-sets: - name: fmsg-obj-value-type type: u8 + enum: fmsg-obj-value-type # TODO: fill in the attributes in between From patchwork Mon Feb 19 17:26:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 13562934 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-oi1-f180.google.com (mail-oi1-f180.google.com [209.85.167.180]) (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 6094F47F50 for ; Mon, 19 Feb 2024 17:26:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708363601; cv=none; b=TB62lcF6PGsiX2d4T8cF/E8AgU5QgfVWiAQk5oA6nlKQ6tdUf9p6+IvjjjdXOPOsQ67A1v3unqVgIGRsT8LkXgvH4UI0+JyO+QV6iFvd49FcFvOTMCltSdMYUPtPkhq+8zecc8ggo22mp/RfwjFu6w1+VG7ontHazHSbnX7jvmk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708363601; c=relaxed/simple; bh=VRKk7yOlO8DXmg9hQG2w/9bbrZuBSTd+E6Guh7zsh2E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ub02EoDEOkjL7A1udo3ZWoQvTq+JzuspiACPo95kmW+Xq6Q7iEPcxoxAsIRXUp0maBCKY++/PD4GUXNrF65ojF1pOt0qzecB8pbff2B9eLqVmvj6EBffIzYITYF0Hjv82eT9SdX2ieWvt86S/gGWh1VSP6vRPAzhkQe+5+J3jS4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=resnulli.us; spf=none smtp.mailfrom=resnulli.us; dkim=pass (2048-bit key) header.d=resnulli-us.20230601.gappssmtp.com header.i=@resnulli-us.20230601.gappssmtp.com header.b=BUIqyLia; arc=none smtp.client-ip=209.85.167.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=resnulli.us Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=resnulli.us Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=resnulli-us.20230601.gappssmtp.com header.i=@resnulli-us.20230601.gappssmtp.com header.b="BUIqyLia" Received: by mail-oi1-f180.google.com with SMTP id 5614622812f47-3c0485fc8b8so3791203b6e.3 for ; Mon, 19 Feb 2024 09:26:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20230601.gappssmtp.com; s=20230601; t=1708363599; x=1708968399; 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=7FqBgwBflH6YWZwugnlqxLB4TkK+bo8pYTgy0Tzpf9g=; b=BUIqyLiaK87yYxdUq2tlKrVZWLGIr2nvu6z9B0KAsGsNW8mhsyKLnr9CE5y4JPi+NU zjLvrZ6UHJWzT09xi1u03MbTmsz/D1jhfXD/06mDalRYD5wh2KnSOpKWqnt1T1XNc/QI yX1Hx8FVDzrLYDmihsm25t9+xehYqddqyCGZwy51GBhZNj7zJztCiBlXrCZPM8fW9D9H 1omq9LYUKS6FtUSz6IBXr4crYeExcZHO7Ud7iwqxPXGCXy8R90Uim9BZqdsAPNVPEhUY FJeszmMpW/sjPn7GzTBm1s7vaR+GSeh14Lib2UFAw5nWWcLdCaYcIUa2FnhmP+aJnFuR qEJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708363599; x=1708968399; 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=7FqBgwBflH6YWZwugnlqxLB4TkK+bo8pYTgy0Tzpf9g=; b=UvhHFnOSIbZcu56Eu0v1dsxsVl9N05vCMS2np4959XzxbRxVt3gjdyhpwFd4Zfvx0b nO9P108NAmtXFhUsLj0sZGMJRknEtE7oPHTSsMs0rb9DfWeu9bjiebaxw0P+O8JWfod9 Sa3LAlHWwZggBm9x6uvi9wyocXdWObLfzU1fSn979R8V1cyYffkDEV5hz18FQAvDfEPY Wpx6MdT7RgHXX3esVjS6n7kDZO4hIFm2KlDRYwQroY9uDU3bT+zl6oDCbMHH8AyrZzu9 HehoRsuRTjOQVWjCHPDzGTjhx7mUSoGxWl3HyUiL5cl0JosDT77pjFuH0ERcIR5UjgAy trEw== X-Gm-Message-State: AOJu0YxNzZRiKmoM1oFGxpaXVcDUYZtt9PP7w+mUHiVEFPjUuLMSGyVB Ht4k6M9RGtzxgrcKqHnh+1UC8ILtyWZ0tt7LgaoDzdaoDUGieXBUIshHFCUXwgifU7+Ml+dyTj5 s X-Google-Smtp-Source: AGHT+IF1spc64vDV0ybVKbrZ7Db0Y+UymsQr4fBAfYFFqnXN8UMmSOvnQKNGcWCPaU0SNHlkriyLjQ== X-Received: by 2002:a05:6871:289c:b0:21e:6066:a35c with SMTP id bq28-20020a056871289c00b0021e6066a35cmr12756415oac.6.1708363599474; Mon, 19 Feb 2024 09:26:39 -0800 (PST) Received: from localhost ([193.47.165.251]) by smtp.gmail.com with ESMTPSA id p7-20020a05622a13c700b0042c750bf876sm2737239qtk.43.2024.02.19.09.26.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 09:26:39 -0800 (PST) From: Jiri Pirko To: netdev@vger.kernel.org Cc: kuba@kernel.org, pabeni@redhat.com, davem@davemloft.net, edumazet@google.com, jacob.e.keller@intel.com, swarupkotikalapudi@gmail.com, donald.hunter@gmail.com, sdf@google.com, lorenzo@kernel.org, alessandromarcolini99@gmail.com Subject: [patch net-next 12/13] netlink: specs: devlink: add missing fmsg-obj-value-data attribute definitions Date: Mon, 19 Feb 2024 18:26:27 +0100 Message-ID: <20240219172628.71455-3-jiri@resnulli.us> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240219172628.71455-1-jiri@resnulli.us> References: <20240219172525.71406-1-jiri@resnulli.us> <20240219172628.71455-1-jiri@resnulli.us> 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 From: Jiri Pirko Add missing fmsg-obj-value-data definition. Use newly introduced sub-message replace-attribute infrastructure to allow to process attribute type selected by fmsg-obj-value-type. Signed-off-by: Jiri Pirko --- Documentation/netlink/specs/devlink.yaml | 89 ++++++++++++++++++++++-- 1 file changed, 85 insertions(+), 4 deletions(-) diff --git a/Documentation/netlink/specs/devlink.yaml b/Documentation/netlink/specs/devlink.yaml index fa4440141b05..d2bc0e366d09 100644 --- a/Documentation/netlink/specs/devlink.yaml +++ b/Documentation/netlink/specs/devlink.yaml @@ -641,13 +641,14 @@ attribute-sets: name: fmsg-obj-value-type type: u8 enum: fmsg-obj-value-type - - # TODO: fill in the attributes in between - + - + name: fmsg-obj-value-data + type: sub-message + sub-message: dl-fmsg-obj-value-data-msg + selector: fmsg-obj-value-type - name: health-reporter type: nest - value: 114 nested-attributes: dl-health-reporter - name: health-reporter-name @@ -1226,6 +1227,10 @@ attribute-sets: name: fmsg-nest-end - name: fmsg-obj-name + - + name: fmsg-obj-value-type + - + name: fmsg-obj-value-data - name: dl-health-reporter @@ -1331,6 +1336,54 @@ attribute-sets: name: param-value-data type: flag + - + name: dl-fmsg-obj-value-data-u8-attrs + subset-of: devlink + attributes: + - + name: fmsg-obj-value-data + type: u8 + + - + name: dl-fmsg-obj-value-data-u32-attrs + subset-of: devlink + attributes: + - + name: fmsg-obj-value-data + type: u32 + + - + name: dl-fmsg-obj-value-data-u64-attrs + subset-of: devlink + attributes: + - + name: fmsg-obj-value-data + type: u64 + + - + name: dl-fmsg-obj-value-data-flag-attrs + subset-of: devlink + attributes: + - + name: fmsg-obj-value-data + type: flag + + - + name: dl-fmsg-obj-value-data-string-attrs + subset-of: devlink + attributes: + - + name: fmsg-obj-value-data + type: string + + - + name: dl-fmsg-obj-value-data-binary-attrs + subset-of: devlink + attributes: + - + name: fmsg-obj-value-data + type: binary + sub-messages: - name: dl-param-value-data-msg @@ -1356,6 +1409,34 @@ sub-messages: attribute-set: dl-param-value-data-flag-attrs attribute-replace: true + - + name: dl-fmsg-obj-value-data-msg + formats: + - + value: u8 + attribute-set: dl-fmsg-obj-value-data-u8-attrs + attribute-replace: true + - + value: u32 + attribute-set: dl-fmsg-obj-value-data-u32-attrs + attribute-replace: true + - + value: u64 + attribute-set: dl-fmsg-obj-value-data-u64-attrs + attribute-replace: true + - + value: flag + attribute-set: dl-fmsg-obj-value-data-flag-attrs + attribute-replace: true + - + value: string + attribute-set: dl-fmsg-obj-value-data-string-attrs + attribute-replace: true + - + value: binary + attribute-set: dl-fmsg-obj-value-data-binary-attrs + attribute-replace: true + operations: enum-model: directional list: From patchwork Mon Feb 19 17:26:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 13562935 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) (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 9FD7047F5B for ; Mon, 19 Feb 2024 17:26:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708363607; cv=none; b=pKMEimtzEX5zkdjDO9z7DNnJgiqciiYa51qM+ZRhc8HuxQsio9b+WY6G+JIt/xw/xu9vR7OVPYO+GEuA00AxJXK7ul1juo7VM9aFsXziRa8Zd8Pyfy0mtlisZ58MMOdRaegBjsFN3+zOPV/1zgMfCJeJ9c9P+Jal5dZ0GAMdVPU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708363607; c=relaxed/simple; bh=w3sCc4InYbI3VoeSCcCMDfSA4cYH8lCampDSWQdidBc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gEuRYI1FlAff3o+2abex8oBSt6gwuOZ19RV3x+2VLZ50CcmGsjNHONaP87pxjTcXb0n7c64XstqBNfmOI6VpqkUvc8330lE1xOOBrTvxMrOKKapg5BZtALeeVcQLGQk8Pz6qeLIzPvUT0R8VNsp9GoQ+eM0b/rxoXiqsC3aotHg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=resnulli.us; spf=none smtp.mailfrom=resnulli.us; dkim=pass (2048-bit key) header.d=resnulli-us.20230601.gappssmtp.com header.i=@resnulli-us.20230601.gappssmtp.com header.b=BWKiC3gE; arc=none smtp.client-ip=209.85.208.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=resnulli.us Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=resnulli.us Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=resnulli-us.20230601.gappssmtp.com header.i=@resnulli-us.20230601.gappssmtp.com header.b="BWKiC3gE" Received: by mail-lj1-f172.google.com with SMTP id 38308e7fff4ca-2d0a4e1789cso54744241fa.3 for ; Mon, 19 Feb 2024 09:26:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20230601.gappssmtp.com; s=20230601; t=1708363604; x=1708968404; 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=jx7QF70/4SI2wHM+dTYIOQdmLxXMKSaQkl57wD2M9yY=; b=BWKiC3gEMn5foo1eMhWSSnuMxmfDC/cNSiTArMU1a6yOj+KmaheCpjcXPjqoZ/mb5A /WpEzUKY/g/dgTXZl66Iol/MRUv5z3ChTAFCz3DuekgQl4Klvyaa45KyCVK8ymByAsj8 HPPyz0Tqaem9n32QBng+93pF75fU2dbwzKOP2o9x+hpFUh7LZaz3g4kgcK1ps/HkRAKs cyvXTwv/SSN9/UpRYhMwE16pBpV8hpu+AjD9SgRa3SL/ku7/uzwJkVIFwmYigSDMT9Bi rv/ExcwiwFdbIU+hdRC1oPfzDkt7Bg7wlh/JlzH+UiT70Emxcg4NhXVanYfzWYA69pWV T5cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708363604; x=1708968404; 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=jx7QF70/4SI2wHM+dTYIOQdmLxXMKSaQkl57wD2M9yY=; b=P7GXteOtvsbX4sh2gDiJ4jo7yCN22kxznAey9MfVLy/+UrLlhCOic8qCSMVCAgDu31 xAw+8kQHcQ5DPD5HBlLCBDGflpXXLFF9P/wX5WlmewSXPDOT9HDefKSUBVKStHfK7rG5 EzHCAvwiO3p+5fnzyYhFCiTUvdi4h4ymHOXE3RrI8iH8yqYBksHirhNnt3DIW9kTxpc1 /OWTIIPdmGKRjR+pGxNAn+liUz9A+UEG9iIZvVcj2fTZ4ondBA6o9hzgwGBwZz5DaRdX aYC8a12Argabptj31+6AUl+nqKEqHhrSmOxzAYfMvKq3ODSvc5eRzilTLo8IP1QLk/pt X4JA== X-Gm-Message-State: AOJu0YxA3nyrl+nREPaVHWFYNxJ8Y9ZvLdlVlnqdSPQOCKfMFc3ai0gJ MoMP/RTR6pzYAR0BHZl5gpt9FraFkC/Z8vYgjityGZWrZIy2eJIwOHbiV+ZrCdmWSbpvqikNPhn 1 X-Google-Smtp-Source: AGHT+IG5DVz7rFriocLYnW3WuE9+UvAyNxuTnGUvreTf2QgfT1273Sx0ZPe1v0KSm9fhApohXMOD6Q== X-Received: by 2002:a05:6512:1306:b0:512:997a:a8c3 with SMTP id x6-20020a056512130600b00512997aa8c3mr6528141lfu.42.1708363603878; Mon, 19 Feb 2024 09:26:43 -0800 (PST) Received: from localhost ([193.47.165.251]) by smtp.gmail.com with ESMTPSA id o18-20020a056512051200b005128989aa1fsm977995lfb.47.2024.02.19.09.26.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 09:26:43 -0800 (PST) From: Jiri Pirko To: netdev@vger.kernel.org Cc: kuba@kernel.org, pabeni@redhat.com, davem@davemloft.net, edumazet@google.com, jacob.e.keller@intel.com, swarupkotikalapudi@gmail.com, donald.hunter@gmail.com, sdf@google.com, lorenzo@kernel.org, alessandromarcolini99@gmail.com Subject: [patch net-next 13/13] netlink: specs: devlink: add missing nested devlink definitions Date: Mon, 19 Feb 2024 18:26:28 +0100 Message-ID: <20240219172628.71455-4-jiri@resnulli.us> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240219172628.71455-1-jiri@resnulli.us> References: <20240219172525.71406-1-jiri@resnulli.us> <20240219172628.71455-1-jiri@resnulli.us> 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 From: Jiri Pirko Add missing nested devlink subspace definition with definition of two attributes using it. Signed-off-by: Jiri Pirko --- Documentation/netlink/specs/devlink.yaml | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/Documentation/netlink/specs/devlink.yaml b/Documentation/netlink/specs/devlink.yaml index d2bc0e366d09..c416339b69a6 100644 --- a/Documentation/netlink/specs/devlink.yaml +++ b/Documentation/netlink/specs/devlink.yaml @@ -853,13 +853,14 @@ attribute-sets: name: linecard-supported-types type: nest nested-attributes: dl-linecard-supported-types - - # TODO: fill in the attributes in between - + - + name: nested-devlink + type: nest + multi-attr: true + nested-attributes: dl-nested-devlink - name: selftests type: nest - value: 176 nested-attributes: dl-selftest-id - name: rate-tx-priority @@ -944,6 +945,10 @@ attribute-sets: type: bitfield32 enum: port-fn-attr-cap enum-as-flags: True + - + name: devlink + type: nest + nested-attributes: dl-nested-devlink - name: dl-dpipe-tables @@ -1288,6 +1293,17 @@ attribute-sets: - name: linecard-type + - + name: dl-nested-devlink + subset-of: devlink + attributes: + - + name: bus-name + - + name: dev-name + - + name: netns-id + - name: dl-selftest-id name-prefix: devlink-attr-selftest-id-