From patchwork Tue Sep 19 19:28:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bodireddy, Bhanuprakash" X-Patchwork-Id: 815793 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xxY970zSVz9s7p for ; Wed, 20 Sep 2017 05:39:23 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 0AB73BA9; Tue, 19 Sep 2017 19:38:44 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id DAD27B2A for ; Tue, 19 Sep 2017 19:38:41 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 6D34C46F for ; Tue, 19 Sep 2017 19:38:41 +0000 (UTC) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP; 19 Sep 2017 12:38:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.42,418,1500966000"; d="scan'208"; a="1173892313" Received: from silpixa00393942.ir.intel.com (HELO silpixa00393942.ger.corp.intel.com) ([10.237.223.42]) by orsmga001.jf.intel.com with ESMTP; 19 Sep 2017 12:38:40 -0700 From: Bhanuprakash Bodireddy To: dev@openvswitch.org Date: Tue, 19 Sep 2017 20:28:55 +0100 Message-Id: <1505849344-52387-2-git-send-email-bhanuprakash.bodireddy@intel.com> X-Mailer: git-send-email 2.4.11 In-Reply-To: <1505849344-52387-1-git-send-email-bhanuprakash.bodireddy@intel.com> References: <1505849344-52387-1-git-send-email-bhanuprakash.bodireddy@intel.com> X-Spam-Status: No, score=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD autolearn=disabled version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH 01/10] netdev-linux: Clean up netdev_linux_sock_batch_send(). X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Use DP_PACKET_BATCH_FOR_EACH macro and dp_packet_batch_size() API in netdev_linux_sock_batch_send(). No change in functionality. Signed-off-by: Bhanuprakash Bodireddy --- lib/netdev-linux.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c index 2ff3e2b..a1d9e2f 100644 --- a/lib/netdev-linux.c +++ b/lib/netdev-linux.c @@ -1186,16 +1186,17 @@ static int netdev_linux_sock_batch_send(int sock, int ifindex, struct dp_packet_batch *batch) { + const size_t size = dp_packet_batch_size(batch); /* We don't bother setting most fields in sockaddr_ll because the * kernel ignores them for SOCK_RAW. */ struct sockaddr_ll sll = { .sll_family = AF_PACKET, .sll_ifindex = ifindex }; - struct mmsghdr *mmsg = xmalloc(sizeof(*mmsg) * batch->count); - struct iovec *iov = xmalloc(sizeof(*iov) * batch->count); + struct mmsghdr *mmsg = xmalloc(sizeof(*mmsg) * size); + struct iovec *iov = xmalloc(sizeof(*iov) * size); - for (int i = 0; i < batch->count; i++) { - struct dp_packet *packet = batch->packets[i]; + struct dp_packet *packet; + DP_PACKET_BATCH_FOR_EACH (packet, batch) { iov[i].iov_base = dp_packet_data(packet); iov[i].iov_len = dp_packet_get_send_len(packet); mmsg[i].msg_hdr = (struct msghdr) { .msg_name = &sll, @@ -1205,10 +1206,10 @@ netdev_linux_sock_batch_send(int sock, int ifindex, } int error = 0; - for (uint32_t ofs = 0; ofs < batch->count; ) { + for (uint32_t ofs = 0; ofs < size; ) { ssize_t retval; do { - retval = sendmmsg(sock, mmsg + ofs, batch->count - ofs, 0); + retval = sendmmsg(sock, mmsg + ofs, size - ofs, 0); error = retval < 0 ? errno : 0; } while (error == EINTR); if (error) {