From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 3EC74FE5 for ; Tue, 5 May 2015 16:08:03 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 05 May 2015 07:08:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,372,1427785200"; d="scan'208";a="724000344" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga002.jf.intel.com with ESMTP; 05 May 2015 07:08:01 -0700 Received: from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com [10.237.217.46]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id t45E80ch013995 for ; Tue, 5 May 2015 15:08:00 +0100 Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id t45E80RI014518 for ; Tue, 5 May 2015 15:08:00 +0100 Received: (from pdelarax@localhost) by sivswdev02.ir.intel.com with id t45E80HG014514 for dev@dpdk.org; Tue, 5 May 2015 15:08:00 +0100 From: Pablo de Lara To: dev@dpdk.org Date: Tue, 5 May 2015 15:08:00 +0100 Message-Id: <1430834880-14482-1-git-send-email-pablo.de.lara.guarch@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1430829319-22242-1-git-send-email-pablo.de.lara.guarch@intel.com> References: <1430829319-22242-1-git-send-email-pablo.de.lara.guarch@intel.com> Subject: [dpdk-dev] [PATCH v3] kni: fix compilation issue in KNI vhost on kernel 3.19/4.0 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: Tue, 05 May 2015 14:08:04 -0000 Due to commit c0371da6 in kernel 3.19, which removed msg_iov and msg_iovlen from struct msghdr, DPDK would not build. Also, functions memcpy_toiovecend and memcpy_fromiovecend were removed in commits ba7438ae and 57dd8a07, being substituted by copy_from_iter and copy_to_iter. This patch makes use of struct iov_iter, which has references to msg_iov and msg_iovln, and makes use of copy_from_iter and copy_to_iter. Changes in v2: - Replaced functions memcpy_toiovecend and memcpy_fromiovecend with copy_from_iter and copy_to_iter Changes in v3: - Fixed variable names - Add missing checks Reported-by: Thomas Monjalon Signed-off-by: Pablo de Lara --- lib/librte_eal/linuxapp/kni/compat.h | 4 +++ lib/librte_eal/linuxapp/kni/kni_vhost.c | 37 ++++++++++++++++++++++++------ 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/lib/librte_eal/linuxapp/kni/compat.h b/lib/librte_eal/linuxapp/kni/compat.h index 1313523..1ad22ba 100644 --- a/lib/librte_eal/linuxapp/kni/compat.h +++ b/lib/librte_eal/linuxapp/kni/compat.h @@ -19,3 +19,7 @@ #define sk_sleep(s) (s)->sk_sleep #endif /* < 2.6.35 */ + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0) +#define HAVE_IOV_ITER_MSGHDR +#endif diff --git a/lib/librte_eal/linuxapp/kni/kni_vhost.c b/lib/librte_eal/linuxapp/kni/kni_vhost.c index 7141f83..83d3351 100644 --- a/lib/librte_eal/linuxapp/kni/kni_vhost.c +++ b/lib/librte_eal/linuxapp/kni/kni_vhost.c @@ -76,7 +76,7 @@ static struct proto kni_raw_proto = { }; static inline int -kni_vhost_net_tx(struct kni_dev *kni, struct iovec *iov, +kni_vhost_net_tx(struct kni_dev *kni, struct msghdr *m, unsigned offset, unsigned len) { struct rte_kni_mbuf *pkt_kva = NULL; @@ -84,7 +84,11 @@ kni_vhost_net_tx(struct kni_dev *kni, struct iovec *iov, int ret; KNI_DBG_TX("tx offset=%d, len=%d, iovlen=%d\n", - offset, len, (int)iov->iov_len); +#ifdef HAVE_IOV_ITER_MSGHDR + offset, len, (int)m->msg_iter.iov->iov_len); +#else + offset, len, (int)m->msg_iov->iov_len); +#endif /** * Check if it has at least one free entry in tx_q and @@ -108,7 +112,12 @@ kni_vhost_net_tx(struct kni_dev *kni, struct iovec *iov, data_kva = pkt_kva->buf_addr + pkt_kva->data_off - kni->mbuf_va + kni->mbuf_kva; - memcpy_fromiovecend(data_kva, iov, offset, len); +#ifdef HAVE_IOV_ITER_MSGHDR + copy_from_iter(data_kva, len, &m->msg_iter); +#else + memcpy_fromiovecend(data_kva, m->msg_iov, offset, len); +#endif + if (unlikely(len < ETH_ZLEN)) { memset(data_kva + len, 0, ETH_ZLEN - len); len = ETH_ZLEN; @@ -143,7 +152,7 @@ drop: } static inline int -kni_vhost_net_rx(struct kni_dev *kni, struct iovec *iov, +kni_vhost_net_rx(struct kni_dev *kni, struct msghdr *m, unsigned offset, unsigned len) { uint32_t pkt_len; @@ -177,10 +186,18 @@ kni_vhost_net_rx(struct kni_dev *kni, struct iovec *iov, goto drop; KNI_DBG_RX("rx offset=%d, len=%d, pkt_len=%d, iovlen=%d\n", - offset, len, pkt_len, (int)iov->iov_len); +#ifdef HAVE_IOV_ITER_MSGHDR + offset, len, pkt_len, (int)m->msg_iter.iov->iov_len); +#else + offset, len, pkt_len, (int)m->msg_iov->iov_len); +#endif data_kva = kva->buf_addr + kva->data_off - kni->mbuf_va + kni->mbuf_kva; - if (unlikely(memcpy_toiovecend(iov, data_kva, offset, pkt_len))) +#ifdef HAVE_IOV_ITER_MSGHDR + if (unlikely(copy_to_iter(data_kva, pkt_len, &m->msg_iter))) +#else + if (unlikely(memcpy_toiovecend(m->msg_iov, data_kva, offset, pkt_len))) +#endif goto drop; /* Update statistics */ @@ -348,7 +365,11 @@ kni_sock_sndmsg(struct kiocb *iocb, struct socket *sock, return 0; KNI_DBG_TX("kni_sndmsg len %ld, flags 0x%08x, nb_iov %d\n", +#ifdef HAVE_IOV_ITER_MSGHDR + len, q->flags, (int)m->msg_iter.iov->iov_len); +#else len, q->flags, (int)m->msg_iovlen); +#endif #ifdef RTE_KNI_VHOST_VNET_HDR_EN if (likely(q->flags & IFF_VNET_HDR)) { @@ -362,7 +383,7 @@ kni_sock_sndmsg(struct kiocb *iocb, struct socket *sock, if (unlikely(len < ETH_HLEN + q->vnet_hdr_sz)) return -EINVAL; - return kni_vhost_net_tx(q->kni, m->msg_iov, vnet_hdr_len, len); + return kni_vhost_net_tx(q->kni, m, vnet_hdr_len, len); } static int @@ -391,7 +412,7 @@ kni_sock_rcvmsg(struct kiocb *iocb, struct socket *sock, #endif if (unlikely(0 == (pkt_len = kni_vhost_net_rx(q->kni, - m->msg_iov, vnet_hdr_len, len)))) + m, vnet_hdr_len, len)))) return 0; #ifdef RTE_KNI_VHOST_VNET_HDR_EN -- 1.7.4.1