From patchwork Sun Aug 24 10:53:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 35881 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f72.google.com (mail-pa0-f72.google.com [209.85.220.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 111D020565 for ; Sun, 24 Aug 2014 10:54:23 +0000 (UTC) Received: by mail-pa0-f72.google.com with SMTP id eu11sf107349932pac.7 for ; Sun, 24 Aug 2014 03:54:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:mime-version:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list:content-type :content-transfer-encoding; bh=DObDcEJmgDgFcTBog6hOddM+BY+dNOQcrlRoTqRKQkk=; b=Ykw3Fq9/CFG3W6tak85yHQJM4KSq20eZ6n8MnR0D4UCxJ2aF4PlhrGS9LNn9MjlHyt PKQPLozGXWX+bF6adoc+nGMOdfIc7ib/ZsYMwvAdS65eHweJ4ZWn6HK65ISRNpv7AN9F RbQ2C/PM5mhEYH/YJ5+fnKartVvAwYST1uJ9A04Xor8zj8z8vWJD7kzAdakllVv8csj+ +Cn6GmEIWnBOfufz7Gh2o14L+V8fGJ0I4nNwCAeDV/KkPqyp26veaYB/UumwHn1vJRX4 ZBainaIhSKroWr9GYZsQWUAhJWxGMxgnppwsPtFznlmf/Jo3KtBC74oi2dge2GGVF2Bx KXaQ== X-Gm-Message-State: ALoCoQniJ3gFvj5AQX7q3t6C7DX3b3yBU1CN4EW+xmrslcZxSGN+HA3/X+UebiqSFnrfuLLaIZa5 X-Received: by 10.70.103.67 with SMTP id fu3mr5421230pdb.6.1408877663356; Sun, 24 Aug 2014 03:54:23 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.38.80 with SMTP id s74ls1776769qgs.64.gmail; Sun, 24 Aug 2014 03:54:23 -0700 (PDT) X-Received: by 10.52.121.74 with SMTP id li10mr10366370vdb.19.1408877663226; Sun, 24 Aug 2014 03:54:23 -0700 (PDT) Received: from mail-vc0-f181.google.com (mail-vc0-f181.google.com [209.85.220.181]) by mx.google.com with ESMTPS id sq19si15862696vdb.44.2014.08.24.03.54.23 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 24 Aug 2014 03:54:23 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.181 as permitted sender) client-ip=209.85.220.181; Received: by mail-vc0-f181.google.com with SMTP id lf12so14192172vcb.12 for ; Sun, 24 Aug 2014 03:54:23 -0700 (PDT) X-Received: by 10.220.110.77 with SMTP id m13mr257933vcp.35.1408877663144; Sun, 24 Aug 2014 03:54:23 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.45.67 with SMTP id uj3csp42907vcb; Sun, 24 Aug 2014 03:54:22 -0700 (PDT) X-Received: by 10.224.123.8 with SMTP id n8mr25088029qar.40.1408877662613; Sun, 24 Aug 2014 03:54:22 -0700 (PDT) Received: from ip-10-141-164-156.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id gw7si48374518qcb.7.2014.08.24.03.54.21 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 24 Aug 2014 03:54:22 -0700 (PDT) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-141-164-156.ec2.internal) by ip-10-141-164-156.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XLVRF-0003O7-J1; Sun, 24 Aug 2014 10:54:21 +0000 Received: from ezexch.ezchip.com ([212.179.42.101] helo=ezchip.com) by ip-10-141-164-156.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XLVR4-0003NW-0C for lng-odp@lists.linaro.org; Sun, 24 Aug 2014 10:54:10 +0000 Received: from Internal Mail-Server by ezexch (envelope-from giladb@ezchip.com) with AES128-SHA encrypted SMTP; 24 Aug 2014 13:53:22 +0300 Received: from nps06.ezchip.com (10.1.3.132) by ezex10.ezchip.com (10.1.1.4) with Microsoft SMTP Server id 14.3.174.1; Sun, 24 Aug 2014 13:53:58 +0300 From: Gilad Ben-Yossef To: Date: Sun, 24 Aug 2014 13:53:58 +0300 Message-ID: <1408877638-18082-3-git-send-email-giladb@ezchip.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1408877638-18082-1-git-send-email-giladb@ezchip.com> References: <1408877638-18082-1-git-send-email-giladb@ezchip.com> MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-11.0.0.1191-7.500.1018-20902.006 X-TM-AS-Result: No--8.154300-8.000000-31 X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-Topics: patch Cc: Gilad Ben-Yossef Subject: [lng-odp] [PATCH 2/2] odp_packet_socket: add backwards compatible sendmmsg wrapper X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: lng-odp-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: giladb@ezchip.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.181 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Gilad Ben-Yossef RHEL / CentOS 6.2 and above have sendmmsg kernel support but no libc support. Also, it is quite easy to emulate sendmmsg on top of sendmsg. The following patch provides a sendmmsg wrapper as a weak symbol that provides both support to call the syscall even if libc support is missing, as well as an emulation in case no kernel support is there. This lets us drop the dependency on kernel version 3.0. Signed-off-by: Gilad Ben-Yossef --- DEPENDENCIES | 4 +- platform/linux-generic/odp_packet_socket.c | 32 ++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/DEPENDENCIES b/DEPENDENCIES index b4c04c9..9085b68 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -1,8 +1,8 @@ Prerequisites for building the OpenDataPlane (ODP) API -1. Linux kernel >= 3.0 +1. Linux kernel >= 2.6.32 - Version 3.0+ needed for the sendmmsg() interface + Earlier versions may or may not work. 2. autotools diff --git a/platform/linux-generic/odp_packet_socket.c b/platform/linux-generic/odp_packet_socket.c index d44c333..9f05618 100644 --- a/platform/linux-generic/odp_packet_socket.c +++ b/platform/linux-generic/odp_packet_socket.c @@ -42,6 +42,38 @@ #include #include +/** Provide a sendmmsg wrapper for systems with no libc or kernel support. + * As it is implemented as a weak symbol, it has zero effect on systems + * with both. + */ +int sendmmsg(int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags) __attribute__((weak)); +int sendmmsg(int fd, struct mmsghdr *vmessages, unsigned int vlen, int flags) +{ +#ifdef SYS_sendmmsg + return syscall(SYS_sendmmsg, fd, vmessages, vlen, flags); +#else + /* Emulate sendmmsg using sendmsg. + * Note: this emulated version does break sendmmsg promise + * that for blocking calls all the messages will be handled + * so it's not a good general purpose sendmmsg emulator, + * but for our purposes it suffices. + */ + ssize_t ret; + + if (vlen) { + ret = sendmsg(fd, &vmessages->msg_hdr, flags); + + if (ret != -1) { + vmessages->msg_len = ret; + return 1; + } + } + + return -1; + +#endif +} + /** Raw sockets does not support packets fanout across different cpus, * that's lead to same packet recieved in different thread. To avoid that