From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <stable-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 814B6A0C4D
	for <public@inbox.dpdk.org>; Tue, 19 Oct 2021 12:48:49 +0200 (CEST)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 72D1F4114A;
	Tue, 19 Oct 2021 12:48:49 +0200 (CEST)
Received: from mga11.intel.com (mga11.intel.com [192.55.52.93])
 by mails.dpdk.org (Postfix) with ESMTP id 4D7804003E;
 Tue, 19 Oct 2021 12:48:46 +0200 (CEST)
X-IronPort-AV: E=McAfee;i="6200,9189,10141"; a="225939498"
X-IronPort-AV: E=Sophos;i="5.85,384,1624345200"; d="scan'208";a="225939498"
Received: from orsmga008.jf.intel.com ([10.7.209.65])
 by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 19 Oct 2021 03:48:45 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.85,384,1624345200"; d="scan'208";a="494041573"
Received: from silpixa00399752.ir.intel.com (HELO
 silpixa00399752.ger.corp.intel.com) ([10.237.222.27])
 by orsmga008.jf.intel.com with ESMTP; 19 Oct 2021 03:48:43 -0700
From: Ferruh Yigit <ferruh.yigit@intel.com>
To: dev@dpdk.org
Cc: Ferruh Yigit <ferruh.yigit@intel.com>,
 Aman Singh <aman.deep.singh@intel.com>, stable@dpdk.org,
 Christian Ehrhardt <christian.ehrhardt@canonical.com>,
 Marco Varlese <mvarlese@suse.de>
Date: Tue, 19 Oct 2021 11:48:41 +0100
Message-Id: <20211019104842.3118875-1-ferruh.yigit@intel.com>
X-Mailer: git-send-email 2.31.1
In-Reply-To: <20211013143302.7019-1-aman.deep.singh@intel.com>
References: <20211013143302.7019-1-aman.deep.singh@intel.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Subject: [dpdk-stable] [PATCH v2] kni: fix build for SLES15-SP3
X-BeenThere: stable@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: patches for DPDK stable branches <stable.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/stable>,
 <mailto:stable-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/stable/>
List-Post: <mailto:stable@dpdk.org>
List-Help: <mailto:stable-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/stable>,
 <mailto:stable-request@dpdk.org?subject=subscribe>
Errors-To: stable-bounces@dpdk.org
Sender: "stable" <stable-bounces@dpdk.org>

From: Aman Singh <aman.deep.singh@intel.com>

As suse version numbering is inconsistent to determine Linux kernel
API to be used. In this patch we check parameter of 'ndo_tx_timeout'
API directly from the kernel source. This is done only for suse build.

Bugzilla ID: 812
Cc: stable@dpdk.org

Signed-off-by: Aman Singh <aman.deep.singh@intel.com>
Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
Cc: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Cc: Marco Varlese <mvarlese@suse.de>

v2:
* Use explicit 'source' folder for header path. In SUSE 'source' is not
  link to 'build' folder.
---
 kernel/linux/kni/compat.h    |  3 ++-
 kernel/linux/kni/meson.build | 14 +++++++++++++-
 kernel/linux/meson.build     |  5 +++++
 3 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/kernel/linux/kni/compat.h b/kernel/linux/kni/compat.h
index 5f65640d5ed2..664785674ff1 100644
--- a/kernel/linux/kni/compat.h
+++ b/kernel/linux/kni/compat.h
@@ -133,7 +133,8 @@
 
 #if KERNEL_VERSION(5, 6, 0) <= LINUX_VERSION_CODE || \
 	(defined(RHEL_RELEASE_CODE) && \
-	 RHEL_RELEASE_VERSION(8, 3) <= RHEL_RELEASE_CODE)
+	 RHEL_RELEASE_VERSION(8, 3) <= RHEL_RELEASE_CODE) || \
+	 (defined(CONFIG_SUSE_KERNEL) && defined(HAVE_ARG_TX_QUEUE))
 #define HAVE_TX_TIMEOUT_TXQUEUE
 #endif
 
diff --git a/kernel/linux/kni/meson.build b/kernel/linux/kni/meson.build
index c15c78b0b474..c683fc7b36b2 100644
--- a/kernel/linux/kni/meson.build
+++ b/kernel/linux/kni/meson.build
@@ -1,6 +1,17 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2018 Luca Boccassi <bluca@debian.org>
 
+# For SUSE build check function arguments of ndo_tx_timeout API
+# Ref: https://jira.devtools.intel.com/browse/DPDK-29263
+kmod_cflags = ''
+file_path = kernel_source_dir + '/include/linux/netdevice.h'
+run_cmd = run_command('grep', 'ndo_tx_timeout', file_path)
+
+if run_cmd.stdout().contains('txqueue') == true
+   kmod_cflags = '-DHAVE_ARG_TX_QUEUE'
+endif
+
+
 kni_mkfile = custom_target('rte_kni_makefile',
         output: 'Makefile',
         command: ['touch', '@OUTPUT@'])
@@ -17,7 +28,8 @@ custom_target('rte_kni',
         command: ['make', '-j4', '-C', kernel_build_dir,
             'M=' + meson.current_build_dir(),
             'src=' + meson.current_source_dir(),
-            'MODULE_CFLAGS=-include ' + meson.source_root() + '/config/rte_config.h' +
+            ' '.join(['MODULE_CFLAGS=', kmod_cflags,'-include '])
+            + meson.source_root() + '/config/rte_config.h' +
             ' -I' + meson.source_root() + '/lib/eal/include' +
             ' -I' + meson.source_root() + '/lib/kni' +
             ' -I' + meson.build_root() +
diff --git a/kernel/linux/meson.build b/kernel/linux/meson.build
index 3a00ea954cc5..0637452e955c 100644
--- a/kernel/linux/meson.build
+++ b/kernel/linux/meson.build
@@ -4,6 +4,7 @@
 subdirs = ['kni']
 
 kernel_build_dir = get_option('kernel_dir')
+kernel_source_dir = get_option('kernel_dir')
 kernel_install_dir = ''
 install = not meson.is_cross_build()
 cross_args = []
@@ -16,6 +17,10 @@ if not meson.is_cross_build()
         # use default path for native builds
         kernel_build_dir = '/lib/modules/' + kernel_version + '/build'
     endif
+    if kernel_source_dir == ''
+        # use default path for native builds
+        kernel_source_dir = '/lib/modules/' + kernel_version + '/source'
+    endif
 
     # test running make in kernel directory, using "make kernelversion"
     make_returncode = run_command('make', '-sC', kernel_build_dir,
-- 
2.31.1