From patchwork Thu Dec 11 05:27:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jincheng Miao X-Patchwork-Id: 1950 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 55DB16A95; Thu, 11 Dec 2014 06:29:40 +0100 (CET) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id E182368BE for ; Thu, 11 Dec 2014 06:29:38 +0100 (CET) Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sBB5TZJa016019 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 11 Dec 2014 00:29:35 -0500 Received: from dhcp-66-71-51.eng.nay.redhat.com.com (dhcp-66-71-51.eng.nay.redhat.com [10.66.71.51] (may be forged)) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sBB5TVec024921; Thu, 11 Dec 2014 00:29:32 -0500 From: Jincheng Miao To: dev@dpdk.org Date: Thu, 11 Dec 2014 13:27:07 +0800 Message-Id: <1418275627-17145-1-git-send-email-jmiao@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 Subject: [dpdk-dev] [PATCH] kni: fix build on RHEL6.5 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" RHEL6.5 kernel is based on 2.6.32. But there are two changing from 2.6.35: 1. socket struct is changed It wrappered previous wait_queue_head_t of socket to struct socket_wq. So for the kernel older than 2.6.35, we should directly use socket->wait instead. 2. new function sk_sleep() This function is implemented from 2.6.35 to obtain wait queue from struct sock. This patch adds a macro in kni/compat.h to be compatible with older kernels. Patch is tested in RHEL6.5 and RHEL7.0 with: CONFIG_RTE_LIBRTE_KNI=y CONFIG_RTE_KNI_KO_DEBUG=y CONFIG_RTE_KNI_VHOST=y CONFIG_RTE_KNI_VHOST_MAX_CACHE_SIZE=1024 CONFIG_RTE_KNI_VHOST_VNET_HDR_EN=y CONFIG_RTE_KNI_VHOST_DEBUG_RX=y CONFIG_RTE_KNI_VHOST_DEBUG_TX=y Signed-off-by: Jincheng Miao --- lib/librte_eal/linuxapp/kni/compat.h | 6 ++++++ lib/librte_eal/linuxapp/kni/kni_vhost.c | 17 +++++++++++++++++ 2 files changed, 23 insertions(+), 0 deletions(-) diff --git a/lib/librte_eal/linuxapp/kni/compat.h b/lib/librte_eal/linuxapp/kni/compat.h index 0d87421..1313523 100644 --- a/lib/librte_eal/linuxapp/kni/compat.h +++ b/lib/librte_eal/linuxapp/kni/compat.h @@ -13,3 +13,9 @@ #define kstrtoul strict_strtoul #endif /* < 2.6.39 */ + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35) + +#define sk_sleep(s) (s)->sk_sleep + +#endif /* < 2.6.35 */ diff --git a/lib/librte_eal/linuxapp/kni/kni_vhost.c b/lib/librte_eal/linuxapp/kni/kni_vhost.c index c05c868..7141f83 100644 --- a/lib/librte_eal/linuxapp/kni/kni_vhost.c +++ b/lib/librte_eal/linuxapp/kni/kni_vhost.c @@ -33,6 +33,7 @@ #include #include +#include "compat.h" #include "kni_dev.h" #include "kni_fifo.h" @@ -215,10 +216,19 @@ kni_sock_poll(struct file *file, struct socket *sock, poll_table * wait) return POLLERR; kni = q->kni; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35) KNI_DBG("start kni_poll on group %d, wq 0x%16llx\n", kni->group_id, (uint64_t)sock->wq); +#else + KNI_DBG("start kni_poll on group %d, wait at 0x%16llx\n", + kni->group_id, (uint64_t)&sock->wait); +#endif +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35) poll_wait(file, &sock->wq->wait, wait); +#else + poll_wait(file, &sock->wait, wait); +#endif if (kni_fifo_count(kni->rx_q) > 0) mask |= POLLIN | POLLRDNORM; @@ -681,10 +691,17 @@ kni_vhost_backend_init(struct kni_dev *kni) kni->vq_status = BE_START; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35) KNI_DBG("backend init sockfd=%d, sock->wq=0x%16llx," "sk->sk_wq=0x%16llx", q->sockfd, (uint64_t)q->sock->wq, (uint64_t)q->sk.sk_wq); +#else + KNI_DBG("backend init sockfd=%d, sock->wait at 0x%16llx," + "sk->sk_sleep=0x%16llx", + q->sockfd, (uint64_t)&q->sock->wait, + (uint64_t)q->sk.sk_sleep); +#endif return 0;