From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f195.google.com (mail-wr0-f195.google.com [209.85.128.195]) by dpdk.org (Postfix) with ESMTP id 66CB51B28D for ; Fri, 16 Feb 2018 11:49:02 +0100 (CET) Received: by mail-wr0-f195.google.com with SMTP id f8so2435710wrh.8 for ; Fri, 16 Feb 2018 02:49:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=lAE4NcEJ/G5q002t3Hu+liARYWGLDJ4nDKWFxkRboCc=; b=ZUQzPNVcAT/SFflaG5bkyIJxd0Vlf0mllICfFT59sOBwHF1tbjLq0slzPhW8QqnMNL 1YvERBf2WRbaxvBgOGxIYyNfJ6fUKVhLzlb4fW6e1jTF7IlFUs1WYZEk8sYm1m9H9Xkv GEeNBBoK4pXmb5FhcsJ5AhZ6FvgTJpWGMO6mQbtf2icu78lecoFrmBQOF976wA5Y2zcY zY44QR3XsuBCPcxsBflrtvE5hbB7rVdWbtV0o/Nn5G9jMMFmy0DmKeuoqywYYXq0qSQY nTilgcewcdUzkvlPmsRsoUPl1rYvobXbPRg+aw/libUDIsMA8cz8bGgjawgg19U37sOd 0kOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=lAE4NcEJ/G5q002t3Hu+liARYWGLDJ4nDKWFxkRboCc=; b=rXjo0FfI4EG6z+ySZaL8CKg0cxZ7ZhnEvFfUrBSb12M+UfZfdQv/wr/6MTZ0xNcRYy VTfz5ACukOZsxMC/c33iLImWFbmD/JgjLUr49nsO15hLYPLAS2sMPMjQR+7up0k2Csjk D2xfW4eiJLGo+2sLmFSVcyUXKG8GcEkQzL4XJ7y4yb83s9YwXyMNpDPyHge55AKjdRV9 wfCheLZZpxXC5A3seINK9PoYhZj1b+R6Nn56R6+l+BfgcSJPN9UtYAvWEWgoANHcL1kW 0X1pBrKYlMYJsQl6nP6OQhLQbeFLupMdq36jtTV6ZHCEWSim2Ipaysbf+py0mlcqC3Br e9Rw== X-Gm-Message-State: APf1xPC3yOpygZy331BG5mctYfytoUDiw5q3ZJocQoGJlt9mqba8/X96 9QMHQ7b6jzGEHI4BZ8lx3hik6czC X-Google-Smtp-Source: AH8x227mzozgHYbR201CgQLZplzvYcoo9P7Gi/fjI8lPnuj+TPt38qT3HeG5khXYWRMQJwGxVb5nMw== X-Received: by 10.223.179.5 with SMTP id j5mr4424961wrd.112.1518778142042; Fri, 16 Feb 2018 02:49:02 -0800 (PST) Received: from 6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id b54sm25553070wrg.27.2018.02.16.02.49.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Feb 2018 02:49:01 -0800 (PST) Date: Fri, 16 Feb 2018 11:48:48 +0100 From: Adrien Mazarguil To: Nelio Laranjeiro Cc: dev@dpdk.org, Yongseok Koh Message-ID: <20180216104848.GB4256@6wind.com> References: <21fb91002768a627d9c7f3d81e0c8a12fbf6811f.1518684427.git.nelio.laranjeiro@6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <21fb91002768a627d9c7f3d81e0c8a12fbf6811f.1518684427.git.nelio.laranjeiro@6wind.com> Subject: Re: [dpdk-dev] [PATCH 1/2] net/mlx5: add kernel version function X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Feb 2018 10:49:02 -0000 On Thu, Feb 15, 2018 at 09:47:27AM +0100, Nelio Laranjeiro wrote: > Use a function to retrieve the version of the kernel. > > Signed-off-by: Nelio Laranjeiro A couple of nits, please see below. > --- > drivers/net/mlx5/mlx5_ethdev.c | 13 +++++-------- > drivers/net/mlx5/mlx5_utils.h | 26 ++++++++++++++++++++++++++ > 2 files changed, 31 insertions(+), 8 deletions(-) > > diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c > index b73cb53df..0ce9f438a 100644 > --- a/drivers/net/mlx5/mlx5_ethdev.c > +++ b/drivers/net/mlx5/mlx5_ethdev.c > @@ -18,11 +18,9 @@ > #include > #include > #include > -#include > #include > #include > #include > -#include Looks like this one should remain; this file still uses KERNEL_VERSION(). > #include > #include > #include > @@ -715,15 +713,14 @@ int > priv_link_update(struct priv *priv, int wait_to_complete) > { > struct rte_eth_dev *dev = priv->dev; > - struct utsname utsname; > - int ver[3]; > int ret; > struct rte_eth_link dev_link = dev->data->dev_link; > + unsigned int current_version = mlx5_kernel_version(); > + int use_new_api = current_version > 0 ? > + current_version >= KERNEL_VERSION(4, 9, 0) : > + 0; > > - if (uname(&utsname) == -1 || > - sscanf(utsname.release, "%d.%d.%d", > - &ver[0], &ver[1], &ver[2]) != 3 || > - KERNEL_VERSION(ver[0], ver[1], ver[2]) < KERNEL_VERSION(4, 9, 0)) > + if (use_new_api) > ret = mlx5_link_update_unlocked_gset(dev, wait_to_complete); > else > ret = mlx5_link_update_unlocked_gs(dev, wait_to_complete); > diff --git a/drivers/net/mlx5/mlx5_utils.h b/drivers/net/mlx5/mlx5_utils.h > index e1bfb9cd9..bd179ed21 100644 > --- a/drivers/net/mlx5/mlx5_utils.h > +++ b/drivers/net/mlx5/mlx5_utils.h > @@ -12,6 +12,8 @@ > #include > #include > #include > +#include > +#include > > #include "mlx5_defs.h" > > @@ -159,4 +161,28 @@ log2above(unsigned int v) > return l + r; > } > > +/** > + * retrieve the current kernel version. > + * > + * @return > + * the current kernel version or negative errno on error. > + */ Missing caps! > +static inline unsigned int > +mlx5_kernel_version(void) > +{ > + struct utsname utsname; > + int ver[3]; > + int ret; > + > + ret = uname(&utsname); > + if (ret == -1) > + goto error; > + ret = sscanf(utsname.release, "%d.%d.%d", &ver[0], &ver[1], &ver[2]); > + if (ret != 3) > + goto error; > + return KERNEL_VERSION(ver[0], ver[1], ver[2]); > +error: > + return -errno; > +} > + > #endif /* RTE_PMD_MLX5_UTILS_H_ */ > -- > 2.11.0 > -- Adrien Mazarguil 6WIND