From patchwork Fri Nov 7 13:38:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Venkatesh Vivekanandan X-Patchwork-Id: 40407 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0E0EC24237 for ; Fri, 7 Nov 2014 13:39:18 +0000 (UTC) Received: by mail-lb0-f200.google.com with SMTP id f15sf1924792lbj.11 for ; Fri, 07 Nov 2014 05:39:17 -0800 (PST) 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 :mime-version: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=exgeRc9bYcmxqCYlVhbe4WhMtkY0oIFvQEcs39JVz+o=; b=BjTN7icPT/e6hiU/XrmLgCDIlMcL81kxy2rCHvpWWerd75rzvCKPWTGOtuoJCMmVyz 8ZRrA+yv1TSQRXKFiU7KXFZi4MbI0zAH8Z694DFmDgJNTk2nP1NZq4pGpLNgmz+ZdnnJ WV0VwH4IFmlPh+DhQfhxV4WeNB4nNVLbw4Dk6CZ4rdwVb9373vli3e6hrt+U2Yo9nmIh Si8mp+Fu+jlej9VvbhP+lPGfsco4PiWAWt3Qc48m9FLaVnbpSujX6FlM23x4IHB9gKpF ofA2gDdAQkR3U3EacnLyzHr4b37EEoH8DeZmT5MuC7A5eyS8LneecX+3uXaz9a8dtPvP K5rA== X-Gm-Message-State: ALoCoQlbB925fmx2mxj9esbC8OZBc9zu7iBC2YGOjhkqEdquJ9GzotCDYbbM0J/zVL/VX5XX68NK X-Received: by 10.112.48.98 with SMTP id k2mr331180lbn.15.1415367556972; Fri, 07 Nov 2014 05:39:16 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.26.200 with SMTP id n8ls68216lag.10.gmail; Fri, 07 Nov 2014 05:39:16 -0800 (PST) X-Received: by 10.152.21.135 with SMTP id v7mr11480128lae.65.1415367556820; Fri, 07 Nov 2014 05:39:16 -0800 (PST) Received: from mail-lb0-f170.google.com (mail-lb0-f170.google.com. [209.85.217.170]) by mx.google.com with ESMTPS id ui10si15163549lbb.62.2014.11.07.05.39.16 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 07 Nov 2014 05:39:16 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.170 as permitted sender) client-ip=209.85.217.170; Received: by mail-lb0-f170.google.com with SMTP id z12so2664648lbi.29 for ; Fri, 07 Nov 2014 05:39:16 -0800 (PST) X-Received: by 10.152.42.226 with SMTP id r2mr11306992lal.29.1415367556683; Fri, 07 Nov 2014 05:39:16 -0800 (PST) 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.112.184.201 with SMTP id ew9csp197938lbc; Fri, 7 Nov 2014 05:39:16 -0800 (PST) X-Received: by 10.180.21.163 with SMTP id w3mr5253602wie.48.1415367556020; Fri, 07 Nov 2014 05:39:16 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id vl7si15401997wjc.27.2014.11.07.05.39.07 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 07 Nov 2014 05:39:16 -0800 (PST) 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-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Xmjkn-0000nE-Bf; Fri, 07 Nov 2014 13:39:05 +0000 Received: from mail-gw3-out.broadcom.com ([216.31.210.64]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Xmjkh-0000n9-MQ for lng-odp@lists.linaro.org; Fri, 07 Nov 2014 13:38:59 +0000 X-IronPort-AV: E=Sophos;i="5.07,332,1413270000"; d="scan'208";a="49985166" Received: from irvexchcas08.broadcom.com (HELO IRVEXCHCAS08.corp.ad.broadcom.com) ([10.9.208.57]) by mail-gw3-out.broadcom.com with ESMTP; 07 Nov 2014 05:44:31 -0800 Received: from IRVEXCHSMTP2.corp.ad.broadcom.com (10.9.207.52) by IRVEXCHCAS08.corp.ad.broadcom.com (10.9.208.57) with Microsoft SMTP Server (TLS) id 14.3.174.1; Fri, 7 Nov 2014 05:38:53 -0800 Received: from mail-irva-13.broadcom.com (10.10.10.20) by IRVEXCHSMTP2.corp.ad.broadcom.com (10.9.207.52) with Microsoft SMTP Server id 14.3.174.1; Fri, 7 Nov 2014 05:38:59 -0800 Received: from localhost.localdomain (unknown [10.131.60.56]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id D0FC940FE5; Fri, 7 Nov 2014 05:38:32 -0800 (PST) From: To: Date: Fri, 7 Nov 2014 19:08:30 +0530 Message-ID: <1415367510-6482-1-git-send-email-venkatesh.vivekanandan@linaro.org> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Topics: patch Subject: [lng-odp] [PATCH DPDK] Running IPsec App on ODP-DPDK 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: venkatesh.vivekanandan@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.170 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: Venkatesh Vivekanandan - Enabled crypto support in ODP-DPDK by calling odp_crypto_init_global during initialization. - Added platform specific odp_packet_io.h - Added odp_pktio_get_mac_addr API for ODP-DPDK. - Fixed data_len of mbuf. - set USE_MAC_ADDR_HACK to 0 in odp_ipsec.c to use odp API to get mac addr in ODP-DPDK platform. This is a temporary fix until ipsec app is modified to use odp_pktio_get_mac_addr permanently. Signed-off-by: Venkatesh Vivekanandan --- platform/linux-dpdk/Makefile.am | 2 +- platform/linux-dpdk/include/api/odp_packet_io.h | 152 ++++++++++++++++++++++++ platform/linux-dpdk/odp_init.c | 5 + platform/linux-dpdk/odp_packet.c | 1 + platform/linux-dpdk/odp_packet_io.c | 12 ++ 5 files changed, 171 insertions(+), 1 deletion(-) create mode 100644 platform/linux-dpdk/include/api/odp_packet_io.h diff --git a/platform/linux-dpdk/Makefile.am b/platform/linux-dpdk/Makefile.am index 3d68729..686df6a 100644 --- a/platform/linux-dpdk/Makefile.am +++ b/platform/linux-dpdk/Makefile.am @@ -38,7 +38,7 @@ include_HEADERS = \ $(top_srcdir)/platform/linux-generic/include/api/odp_init.h \ $(top_srcdir)/platform/linux-generic/include/api/odp_packet_flags.h \ $(srcdir)/include/api/odp_packet.h \ - $(top_srcdir)/platform/linux-generic/include/api/odp_packet_io.h \ + $(srcdir)/include/api/odp_packet_io.h \ $(top_srcdir)/platform/linux-generic/include/api/odp_queue.h \ $(top_srcdir)/platform/linux-generic/include/api/odp_rwlock.h \ $(top_srcdir)/platform/linux-generic/include/api/odp_schedule.h \ diff --git a/platform/linux-dpdk/include/api/odp_packet_io.h b/platform/linux-dpdk/include/api/odp_packet_io.h new file mode 100644 index 0000000..0c3be54 --- /dev/null +++ b/platform/linux-dpdk/include/api/odp_packet_io.h @@ -0,0 +1,152 @@ +/* Copyright (c) 2013, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + + +/** + * @file + * + * ODP Packet IO + */ + +#ifndef ODP_PACKET_IO_H_ +#define ODP_PACKET_IO_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include + +#include + +/** ODP packet IO handle */ +typedef uint32_t odp_pktio_t; + +/** Invalid packet IO handle */ +#define ODP_PKTIO_INVALID 0 + +/** + * Open an ODP packet IO instance + * + * @param dev Packet IO device + * @param pool Pool to use for packet IO + * @param params Set of parameters to pass to the arch dependent implementation + * + * @return ODP packet IO handle or ODP_PKTIO_INVALID on error + */ +odp_pktio_t odp_pktio_open(const char *dev, odp_buffer_pool_t pool, + odp_pktio_params_t *params); + +/** + * Close an ODP packet IO instance + * + * @param id ODP packet IO handle + * + * @return 0 on success or -1 on error + */ +int odp_pktio_close(odp_pktio_t id); + +/** + * Receive packets + * + * @param id ODP packet IO handle + * @param pkt_table[] Storage for received packets (filled by function) + * @param len Length of pkt_table[], i.e. max number of pkts to receive + * + * @return Number of packets received or -1 on error + */ +int odp_pktio_recv(odp_pktio_t id, odp_packet_t pkt_table[], unsigned len); + +/** + * Send packets + * + * @param id ODP packet IO handle + * @param pkt_table[] Array of packets to send + * @param len length of pkt_table[] + * + * @return Number of packets sent or -1 on error + */ +int odp_pktio_send(odp_pktio_t id, odp_packet_t pkt_table[], unsigned len); + +/** + * Set the default input queue to be associated with a pktio handle + * + * @param id ODP packet IO handle + * @param queue default input queue set + * @return 0 on success or -1 on error + */ +int odp_pktio_inq_setdef(odp_pktio_t id, odp_queue_t queue); + +/** + * Get default input queue associated with a pktio handle + * + * @param id ODP packet IO handle + * + * @return Default input queue set or ODP_QUEUE_INVALID on error + */ +odp_queue_t odp_pktio_inq_getdef(odp_pktio_t id); + +/** + * Remove default input queue (if set) + * + * @param id ODP packet IO handle + * + * @return 0 on success or -1 on error + */ +int odp_pktio_inq_remdef(odp_pktio_t id); + +/** + * Query default output queue + * + * @param id ODP packet IO handle + * + * @return Default out queue or ODP_QUEUE_INVALID on error + */ +odp_queue_t odp_pktio_outq_getdef(odp_pktio_t id); + +/** + * Store packet input handle into packet + * + * @param pkt ODP packet buffer handle + * @param id ODP packet IO handle + * + * @return + */ +void odp_pktio_set_input(odp_packet_t pkt, odp_pktio_t id); + +/** + * Get stored packet input handle from packet + * + * @param pkt ODP packet buffer handle + * + * @return Packet IO handle + */ +odp_pktio_t odp_pktio_get_input(odp_packet_t pkt); + +/** + * Defines the maximum length of mac address supported by this platform + */ +#define ODP_MAC_ADDR_MAX_LENGTH ETH_ALEN + +/** + * Get mac address of the interface + * + * @param id ODP packet IO handle + * @param mac_addr Storage for Mac address of the packet IO interface + * Storage provided by the caller should be equal + * to ODP_MAC_ADDR_MAX_LENGTH (filled by function) + * @return 0 on success or -1 on error +**/ +int odp_pktio_get_mac_addr(odp_pktio_t id, unsigned char *mac_addr); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/platform/linux-dpdk/odp_init.c b/platform/linux-dpdk/odp_init.c index ecc2066..404e616 100644 --- a/platform/linux-dpdk/odp_init.c +++ b/platform/linux-dpdk/odp_init.c @@ -91,6 +91,11 @@ int odp_init_global(void) return -1; } + if (odp_crypto_init_global()) { + ODP_ERR("ODP crypto init failed.\n"); + return -1; + } + return 0; } diff --git a/platform/linux-dpdk/odp_packet.c b/platform/linux-dpdk/odp_packet.c index 1cd190d..7b6b082 100644 --- a/platform/linux-dpdk/odp_packet.c +++ b/platform/linux-dpdk/odp_packet.c @@ -74,6 +74,7 @@ static int odp_packet_set_offset_len(odp_packet_t pkt, size_t frame_offset, return -1; } mb->pkt.pkt_len = len; + mb->pkt.data_len = len; return 0; } diff --git a/platform/linux-dpdk/odp_packet_io.c b/platform/linux-dpdk/odp_packet_io.c index 18635de..79394bb 100644 --- a/platform/linux-dpdk/odp_packet_io.c +++ b/platform/linux-dpdk/odp_packet_io.c @@ -422,3 +422,15 @@ int pktin_deq_multi(queue_entry_t *qentry, odp_buffer_hdr_t *buf_hdr[], int num) return nbr; } + +int odp_pktio_get_mac_addr(odp_pktio_t id, unsigned char *mac_addr) +{ + pktio_entry_t *pktio_entry = get_entry(id); + if (!pktio_entry) { + ODP_ERR("Invalid odp_pktio_t value\n"); + return -1; + } + rte_eth_macaddr_get(pktio_entry->s.pkt_dpdk.portid, + (struct ether_addr *)mac_addr); + return 0; +}