From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f52.google.com (mail-wm0-f52.google.com [74.125.82.52]) by dpdk.org (Postfix) with ESMTP id 3FA93C588 for ; Thu, 23 Jun 2016 19:05:48 +0200 (CEST) Received: by mail-wm0-f52.google.com with SMTP id r201so58917930wme.1 for ; Thu, 23 Jun 2016 10:05:48 -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; bh=jbinjXxwALby8qZuGzr+EnDxWyWRGC/qklIlZ4khrvA=; b=hruZPj0AyJhd4ZdyPzpuGXR8U2O3fw6VM7EJ3EnX17YA7r8CcVfuTTRJue7FyPyv9i dJ/fwDotQAk3Vv33n423PyE2BlBQBNo6tXdqryvFXt5BRCHSp3RYpUF4LCbmElrHvwQl gA4wFVwOwNvNWtmCpJgG3bhXj/DoVJZoy1CN0msaY3broRYwHP+GteO/fdEJfvM/Uufi NcoExO9ur9qYoA/ibKm8ES6yok5HQobAxHYy3sc3yUKHSNF254TnET815Fn3AdISR9ci 7KqRnef8TSnEWXNux1kxYjvpWb2peVO1/XbDu+fwR6eg6wXU1gc2PG8n3Rcy88fwKhvF TWlA== 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; bh=jbinjXxwALby8qZuGzr+EnDxWyWRGC/qklIlZ4khrvA=; b=DVrpN500sEEvVY+1kGtULGCpAiPr3ST/ZbuxZ1MlhcckiXymFAkmnSqoebdbG5xoaY F8aL2TsNQFHteNkxGGrupVAfGHOjA0bC8ORpHEqo7qmhhR5hi9ZpMMEQQoK5iohrI/ej TlYwF9MSZ0Ophi3NraFHqqhGLZiNDsWMDNurVkjUuyVrYCUjkt+4QuT4l7wOrmfXysAV ziUm6RZrNTIIJJJlxiKq12+MImEqlVvV6ovEEwO5sTnSwsQI7WBbhXf9o8AepBOPzPzY TcgLi5BdC9O+wFFTi3KJbJjUvuKpnwtFUefEPFagDU2Hdu74oyduV4hTwO0b6UhrgWwA 9baQ== X-Gm-Message-State: ALyK8tLt+hKwRZkzoEZm7EtyBG/LzQQbytfitIcrcAb5CFsRRBixGEQMBTR7qm0nVpg/MAeC X-Received: by 10.28.29.146 with SMTP id d140mr1843956wmd.27.1466701547770; Thu, 23 Jun 2016 10:05:47 -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 q63sm4770644wma.0.2016.06.23.10.05.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 23 Jun 2016 10:05:47 -0700 (PDT) From: Nelio Laranjeiro To: dev@dpdk.org Cc: Ferruh Yigit , Adrien Mazarguil Date: Thu, 23 Jun 2016 19:05:09 +0200 Message-Id: <1466700801-10383-11-git-send-email-nelio.laranjeiro@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1466700801-10383-1-git-send-email-nelio.laranjeiro@6wind.com> References: <1466586355-30777-1-git-send-email-nelio.laranjeiro@6wind.com> <1466700801-10383-1-git-send-email-nelio.laranjeiro@6wind.com> Subject: [dpdk-dev] [PATCH v5 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: Thu, 23 Jun 2016 17:05:48 -0000 Content-Type: text/plain; charset="UTF-8" Message-ID: <20160623170509.ek0pnTqHYRk588COpCwuuqShR76xy2QTdkb2zcmz9YQ@z> 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 | 73 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 3f45d84..6027393 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,71 @@ 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, negative 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) +{ + const char **params = (const char *[]){ + NULL, + }; + struct rte_kvargs *kvlist; + int ret = 0; + int i; + + if (devargs == NULL) + return 0; + /* Following UGLY cast is done to pass checkpatch. */ + 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 +475,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