kni: fix build with kernel < 2.6.35 and vhost debug enabled
authorJincheng Miao <jmiao@redhat.com>
Thu, 11 Dec 2014 05:27:07 +0000 (13:27 +0800)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Wed, 17 Dec 2014 23:26:08 +0000 (00:26 +0100)
commit190a61b14c76b194b2cae7b3af0eea6822caf510
treefc3cc6396da947c266e3bf2f6a6669801d46b62c
parentdb949b51d848832f2f5877b66f6e330fad7e5eaf
kni: fix build with kernel < 2.6.35 and vhost debug enabled

Seen on RHEL-6.5:
lib/librte_eal/linuxapp/kni/kni_vhost.c:222:
error: ‘struct socket’ has no member named ‘wq’
lib/librte_eal/linuxapp/kni/kni_vhost.c:313:
error: implicit declaration of function ‘sk_sleep’
lib/librte_eal/linuxapp/kni/kni_vhost.c:313:
error: passing argument 1 of ‘__wake_up’ makes pointer from integer without a cast
include/linux/wait.h:146: note: expected ‘struct wait_queue_head_t *’
but argument is of type ‘int’
lib/librte_eal/linuxapp/kni/kni_vhost.c:580:
error: assignment makes pointer from integer without a cast

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 <jmiao@redhat.com>
lib/librte_eal/linuxapp/kni/compat.h
lib/librte_eal/linuxapp/kni/kni_vhost.c