From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf0-f41.google.com (mail-lf0-f41.google.com [209.85.215.41]) by dpdk.org (Postfix) with ESMTP id 10F0DADE2 for ; Tue, 21 Jun 2016 09:24:07 +0200 (CEST) Received: by mail-lf0-f41.google.com with SMTP id q132so9619123lfe.3 for ; Tue, 21 Jun 2016 00:24:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=otQ1DzWtSLzlYHu9g7N+Fp/lZuSP/jWAMUVKLbmpBm4=; b=LKWR6/Y1NFml55mFAJsH1p+VBWI0zvZZat17+RrSx7+OGY8AjqHs2OARrQMgizCJ0n rv55VCy+YbuRZmMj/LF8JOnfMklG/X1T1eP4ZDld+knb5SkgSsZEI4HXlT0zx0YiIzjU 5CeN5A+lbwTxKXW1hXpi1ZXzXEzIDkK0AZvalnhALruglejvn2yxi8nrNVR4bps6nZHV 5jXx+vIWAeOqR2EPulxXx1DsTlEzbvjuTVG3XigKRmXPCWy4SSMr7BO+dEGxDB7d16Zi 6LLZVoP0LQdQog/h1izHigQsGhhu/3r89PKEjifvgSTIFX/Jm7fgGrpq1tq8MN7PSpCI v0IA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=otQ1DzWtSLzlYHu9g7N+Fp/lZuSP/jWAMUVKLbmpBm4=; b=E6cLjPN30o6txbWljtU0HgwaNH0a6i2i2Ms6MIyTBjy0FWz7jSr/CZRbJSAaE0d+7j HtjWCYl0Q0n1yuoBH5TxU3Zho2UB+oz/59oQzhZ+0onU9B2n5+f8FzrnmAO8J/wmIeHF LJUBkZQ2bFqJNH7pkhFjhgBgMJpwTUoa3x3Vn7MWNVjg1gWnOKA6LSWqP7RaVswtYopR KGW/piqWvmavGO4309c7smZHHzAdvsYdjYDkVoZqVJBg5ZUPYsu+6iw5pBbS16KxsJE8 E1aqae6XZt+IhnOUKV4DgU0ueb/djMuXNLt/w8elhok3z0Nf4BVY+yRPluoIln4x0gdu hsLg== X-Gm-Message-State: ALyK8tJBpPf+4Yo/FQ5eTZRwcN9n6df6xPuLCE524BEudU9X9Dey3i80BpmSdIfUyem6zBMq X-Received: by 10.46.0.139 with SMTP id e11mr5543523lji.37.1466493846751; Tue, 21 Jun 2016 00:24:06 -0700 (PDT) Received: from ping.vm.6wind.com (guy78-3-82-239-227-177.fbx.proxad.net. [82.239.227.177]) by smtp.gmail.com with ESMTPSA id mh10sm6527314lbb.14.2016.06.21.00.24.05 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 21 Jun 2016 00:24:06 -0700 (PDT) From: Nelio Laranjeiro To: dev@dpdk.org Cc: Ferruh Yigit , Adrien Mazarguil Date: Tue, 21 Jun 2016 09:23:24 +0200 Message-Id: <1466493818-1877-12-git-send-email-nelio.laranjeiro@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1466493818-1877-1-git-send-email-nelio.laranjeiro@6wind.com> References: <1465379291-25310-1-git-send-email-nelio.laranjeiro@6wind.com> <1466493818-1877-1-git-send-email-nelio.laranjeiro@6wind.com> In-Reply-To: <1465379291-25310-1-git-send-email-nelio.laranjeiro@6wind.com> References: <1465379291-25310-1-git-send-email-nelio.laranjeiro@6wind.com> Subject: [dpdk-dev] [PATCH v3 11/25] mlx5: add support for configuration through kvargs X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Jun 2016 07:24:07 -0000 The intent is to replace the remaining compile-time options and environment variables with a common mean of runtime configuration. This commit only adds the kvargs handling code, subsequent commits will update the rest. Signed-off-by: Nelio Laranjeiro Signed-off-by: Adrien Mazarguil --- drivers/net/mlx5/mlx5.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 3f45d84..56b1dfc 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -37,6 +37,7 @@ #include #include #include +#include #include /* Verbs header. */ @@ -57,6 +58,7 @@ #include #include #include +#include #ifdef PEDANTIC #pragma GCC diagnostic error "-pedantic" #endif @@ -237,6 +239,70 @@ mlx5_dev_idx(struct rte_pci_addr *pci_addr) return ret; } +/** + * Verify and store value for device argument. + * + * @param[in] key + * Key argument to verify. + * @param[in] val + * Value associated with key. + * @param opaque + * User data. + * + * @return + * 0 on success, errno value on failure. + */ +static int +mlx5_args_check(const char *key, const char *val, void *opaque) +{ + struct priv *priv = opaque; + + /* No parameters are expected at the moment. */ + (void)priv; + (void)val; + WARN("%s: unknown parameter", key); + return EINVAL; +} + +/** + * Parse device parameters. + * + * @param priv + * Pointer to private structure. + * @param devargs + * Device arguments structure. + * + * @return + * 0 on success, errno value on failure. + */ +static int +mlx5_args(struct priv *priv, struct rte_devargs *devargs) +{ + static const char *params[] = { + NULL, + }; + struct rte_kvargs *kvlist; + int ret = 0; + int i; + + if (devargs == NULL) + return 0; + kvlist = rte_kvargs_parse(devargs->args, params); + if (kvlist == NULL) + return 0; + /* Process parameters. */ + for (i = 0; (i != RTE_DIM(params)); ++i) { + if (rte_kvargs_count(kvlist, params[i])) { + ret = rte_kvargs_process(kvlist, params[i], + mlx5_args_check, priv); + if (ret != 0) + return ret; + } + } + rte_kvargs_free(kvlist); + return 0; +} + static struct eth_driver mlx5_driver; /** @@ -408,6 +474,12 @@ mlx5_pci_devinit(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) priv->port = port; priv->pd = pd; priv->mtu = ETHER_MTU; + err = mlx5_args(priv, pci_dev->devargs); + if (err) { + ERROR("failed to process device arguments: %s", + strerror(err)); + goto port_error; + } if (ibv_exp_query_device(ctx, &exp_device_attr)) { ERROR("ibv_exp_query_device() failed"); goto port_error; -- 2.1.4