From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34B4EC282C2 for ; Mon, 11 Feb 2019 02:47:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DEA9920863 for ; Mon, 11 Feb 2019 02:47:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nt67TBcP" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726310AbfBKCrA (ORCPT ); Sun, 10 Feb 2019 21:47:00 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:37650 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726102AbfBKCrA (ORCPT ); Sun, 10 Feb 2019 21:47:00 -0500 Received: by mail-pf1-f196.google.com with SMTP id y126so4569186pfb.4 for ; Sun, 10 Feb 2019 18:46:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=epl6GjbG/P3gsmuZ4rl7rYf9qqJCkYPFD4YOZRzZ1ik=; b=nt67TBcPfUKSS7zw5+9NIOFQsP4rzClpj31T6dmrJctejQACF8VpJ1czLhecxmPZeV kay/WyA5iVsUwGnypztERLrhtgpBizThIrD0JUuHvix3gC+pYRY+PBHvXD5ITMEVuUvS cBcrUdYk/+SVdazP3i4OF9H4bloxdVV3N8AxgYIPsUlM9nV+/x/HiCvG/OHZD/cm/83l 62CKMc7VevcyqV9gSypbsg7kSwTYp89eQO36pHHOuLihzWopb1RsOt9bXv1N6e1iZGCo 3/iq48wOSYppmJm/GzwSBcNttw+XPB/JZU8xPUH60MC66x1FJbEBqle8YyN+fhBHZx8Y SI0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=epl6GjbG/P3gsmuZ4rl7rYf9qqJCkYPFD4YOZRzZ1ik=; b=h4BehExir3zEbJXwucGfSAhycQH7k2vVxe9nEtuzp1js63YRiiUZhF/mmX2lvcUmQ4 XU/LGZsuSu7z7+qMj19f5KO8EDENFvxK5YL5UODJx/pZIVgAl2IIrZxKfUpHAFhItEtz 0WFgDONxxK2FHfpP7RGUfH5xPbiZqrKnwYAMqs0w+KuVULNsnyPhF2QGnQdx4eGYSgCC QCNR8iJXm5sygm4i/pHr0OvYYYlgziCRyZ8CxfrkA5yTc8wYj8shzr+x6k2Om3uXdqd8 yHVf+o3rxVULbLD1kKFZdNOsN0R/2qLsuz0WETkQRiuSrKGzyGK7pwb0rNTLUwpFeXbo 2mig== X-Gm-Message-State: AHQUAuakfWJxWGkwNmOLI0CGWqq+TseU9uvzY0X5scsIgAPjA4co+2Cg W/7rkfw07cpWxI0hRsUn8bvWUN4N X-Google-Smtp-Source: AHgI3IaZZaDMsuNjU/p+vT7EQtoD9KO20aXCVDwW4D3s4bj9E05npxth0icjcpSYLzavR9g6CHistg== X-Received: by 2002:a62:7086:: with SMTP id l128mr34515605pfc.68.1549853219125; Sun, 10 Feb 2019 18:46:59 -0800 (PST) Received: from ?IPv6:2601:282:800:fd80:ac47:4940:69b1:8e75? ([2601:282:800:fd80:ac47:4940:69b1:8e75]) by smtp.googlemail.com with ESMTPSA id o23sm23383011pfa.140.2019.02.10.18.46.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Feb 2019 18:46:58 -0800 (PST) Subject: Re: [PATCH for-next 1/4] devlink: refactor validation of finding required arguments To: Aya Levin , netdev@vger.kernel.org, "David S. Miller" , Jiri Pirko Cc: Moshe Shemesh , Eran Ben Elisha , Tal Alon , Ariel Almog References: <1549532202-943-1-git-send-email-eranbe@mellanox.com> <1549823329-10377-1-git-send-email-ayal@mellanox.com> <1549823329-10377-2-git-send-email-ayal@mellanox.com> From: David Ahern Message-ID: <1be3e541-3032-9a74-2d0d-16baea9071ac@gmail.com> Date: Sun, 10 Feb 2019 19:46:57 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <1549823329-10377-2-git-send-email-ayal@mellanox.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 2/10/19 11:28 AM, Aya Levin wrote: > @@ -950,6 +951,51 @@ static int param_cmode_get(const char *cmodestr, > return 0; > } > > +struct dl_args_metadata { > + uint32_t o_flag; > + char err_msg[DL_ARGS_REQUIRED_MAX_ERR_LEN]; > +}; > + > +static const struct dl_args_metadata dl_args_required[] = { > + {DL_OPT_PORT_TYPE, "Port type not set.\n"}, > + {DL_OPT_PORT_COUNT, "Port split count option expected.\n"}, > + {DL_OPT_SB_POOL, "Pool index option expected.\n"}, > + {DL_OPT_SB_SIZE, "Pool size option expected.\n"}, > + {DL_OPT_SB_TYPE, "Pool type option expected.\n"}, > + {DL_OPT_SB_THTYPE, "Pool threshold type option expected.\n"}, > + {DL_OPT_SB_TH, "Threshold option expected.\n"}, > + {DL_OPT_SB_TC, "TC index option expected.\n"}, > + {DL_OPT_ESWITCH_MODE, "E-Switch mode option expected.\n"}, > + {DL_OPT_ESWITCH_INLINE_MODE, "E-Switch inline-mode option expected.\n"}, > + {DL_OPT_DPIPE_TABLE_NAME, "Dpipe table name expected\n"}, > + {DL_OPT_DPIPE_TABLE_COUNTERS, "Dpipe table counter state expected\n"}, > + {DL_OPT_ESWITCH_ENCAP_MODE, "E-Switch encapsulation option expected.\n"}, > + {DL_OPT_PARAM_NAME, "Parameter name expected.\n"}, > + {DL_OPT_PARAM_VALUE, "Value to set expected.\n"}, > + {DL_OPT_PARAM_CMODE, "Configuration mode expected.\n"}, > + {DL_OPT_REGION_SNAPSHOT_ID, "Region snapshot id expected.\n"}, > + {DL_OPT_REGION_ADDRESS, "Region address value expected.\n"}, > + {DL_OPT_REGION_LENGTH, "Region length value expected.\n"}, > +}; > + > +static int validate_finding_required_dl_args(uint32_t o_required, > + uint32_t o_found) > +{ > + uint32_t dl_args_required_size; > + uint32_t o_flag; > + int i; > + > + dl_args_required_size = ARRAY_SIZE(dl_args_required); > + for (i = 0; i < dl_args_required_size; i++) { > + o_flag = dl_args_required[i].o_flag; > + if ((o_required & o_flag) && !(o_found & o_flag)) { > + pr_err("%s", dl_args_required[i].err_msg); > + return -EINVAL; > + } > + } > + return 0; > +} > + much better. Thank you for refactoring this.