From patchwork Tue Oct 28 18:19:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zoltan Kiss X-Patchwork-Id: 39691 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f70.google.com (mail-wg0-f70.google.com [74.125.82.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id DED9F24026 for ; Tue, 28 Oct 2014 18:19:54 +0000 (UTC) Received: by mail-wg0-f70.google.com with SMTP id x13sf798166wgg.1 for ; Tue, 28 Oct 2014 11:19:54 -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:subject:precedence:list-id:list-unsubscribe:list-archive :list-post:list-help:list-subscribe:mime-version:errors-to:sender :x-original-sender:x-original-authentication-results:mailing-list :content-type:content-transfer-encoding; bh=kvU+uSbOMUwXktZup1bW0/r4Iu5cVnsOS+1xz0ygmsI=; b=ICmja7RQH/e5YKbK1zUMwQ6Lw12rmwtzpc8a9GV+dapEEvmR8gGmNNyRZhtDmx7Mku 3R0mib4jWth4Qmkg0WaeFfet7CeJB7Y0+4j2KQPMgmE+gq9jiqUotCDL7r5l8/5zn7Um FUvTjeXOGKTO2b0kRwjH+4tycb7IfSSQWLPrLkxozG4dD2hDudNXu0TC9r2QnTpdLliu rFuMtSyhB3c3ZOc65/tFNWgmXmFN8mZP2ZcrRi/428t3gLhu+USnYQ2UaJTQJ392oL2K 6Nd5wcKWuRyi6+KVbGfZAwNPNBSqm0qUbDSH8447HkrpKTp+Le9n4xVRFmyMk+W/rdvN ZV/A== X-Gm-Message-State: ALoCoQk1+DButrNVoO8rDwkcQ2HrfpLnh1eRSK1+nKQMasF4t6vMR+Q/i8XttlZSc42Pieky7MQ5 X-Received: by 10.112.137.202 with SMTP id qk10mr758024lbb.11.1414520394066; Tue, 28 Oct 2014 11:19:54 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.7.99 with SMTP id i3ls106756laa.79.gmail; Tue, 28 Oct 2014 11:19:53 -0700 (PDT) X-Received: by 10.112.48.3 with SMTP id h3mr5950740lbn.71.1414520393922; Tue, 28 Oct 2014 11:19:53 -0700 (PDT) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com. [209.85.217.177]) by mx.google.com with ESMTPS id js17si3807912lab.24.2014.10.28.11.19.53 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 28 Oct 2014 11:19:53 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by mail-lb0-f177.google.com with SMTP id 10so1097289lbg.8 for ; Tue, 28 Oct 2014 11:19:53 -0700 (PDT) X-Received: by 10.112.77.74 with SMTP id q10mr5875263lbw.66.1414520393802; Tue, 28 Oct 2014 11:19:53 -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.112.84.229 with SMTP id c5csp531144lbz; Tue, 28 Oct 2014 11:19:53 -0700 (PDT) X-Received: by 10.140.81.210 with SMTP id f76mr7265429qgd.60.1414520392085; Tue, 28 Oct 2014 11:19:52 -0700 (PDT) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id d35si3608236qgf.62.2014.10.28.11.19.49 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 28 Oct 2014 11:19:52 -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-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XjBMy-0005xI-N2; Tue, 28 Oct 2014 18:19:48 +0000 Received: from mail-wi0-f182.google.com ([209.85.212.182]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XjBMf-0005wD-E7 for lng-odp@lists.linaro.org; Tue, 28 Oct 2014 18:19:29 +0000 Received: by mail-wi0-f182.google.com with SMTP id d1so2463758wiv.15 for ; Tue, 28 Oct 2014 11:19:23 -0700 (PDT) X-Received: by 10.194.57.81 with SMTP id g17mr6753392wjq.12.1414520363877; Tue, 28 Oct 2014 11:19:23 -0700 (PDT) Received: from localhost.localdomain ([90.152.119.35]) by mx.google.com with ESMTPSA id u8sm16229311wiz.14.2014.10.28.11.19.22 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Oct 2014 11:19:23 -0700 (PDT) From: Zoltan Kiss To: lng-odp@lists.linaro.org, ciprian.barbu@linaro.org Date: Tue, 28 Oct 2014 18:19:08 +0000 Message-Id: <1414520348-27537-4-git-send-email-zoltan.kiss@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1414520348-27537-1-git-send-email-zoltan.kiss@linaro.org> References: <1414520348-27537-1-git-send-email-zoltan.kiss@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH OVS 4/4] netdev, ofpbuf: Adjust OVS implementation to the latest ODP 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: , MIME-Version: 1.0 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: zoltan.kiss@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.177 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 --- lib/netdev-odp.c | 52 +++++++++++++++++++++++++++------------------------- lib/netdev-odp.h | 6 +++--- lib/ofpbuf.c | 2 +- 3 files changed, 31 insertions(+), 29 deletions(-) diff --git a/lib/netdev-odp.c b/lib/netdev-odp.c index 785dc06..f979743 100644 --- a/lib/netdev-odp.c +++ b/lib/netdev-odp.c @@ -94,7 +94,7 @@ struct netdev_rxq_odp { void free_odp_buf(struct ofpbuf *b) { - odp_packet_free(b->odp_pkt); + odph_packet_free(b->odp_pkt); odp_buffer_free(b->odp_ofpbuf); } @@ -102,7 +102,6 @@ int odp_init(int argc, char *argv[]) { int result; - int thr_id; if (strcmp(argv[1], "--odp")) return 0; @@ -110,14 +109,17 @@ odp_init(int argc, char *argv[]) argc--; argv++; - result = odp_init_global(); + result = odp_init_global(NULL, NULL); if (result) { ODP_ERR("Error: ODP global init failed\n"); return result; } - thr_id = odp_thread_create(0); - odp_init_local(thr_id); + /* Init this thread */ + if (odp_init_local()) { + ODP_ERR("Error: ODP local init failed.\n"); + exit(EXIT_FAILURE); + } odp_initialized = 1; @@ -128,11 +130,13 @@ static int odp_class_init(void) { void *pool_base; + odp_shm_t shm; int result = 0; /* create packet pool */ - pool_base = odp_shm_reserve("shm_packet_pool", SHM_PKT_POOL_SIZE, - ODP_CACHE_LINE_SIZE); + shm = odp_shm_reserve("shm_packet_pool", SHM_PKT_POOL_SIZE, + ODP_CACHE_LINE_SIZE, 0); + pool_base = odp_shm_addr(shm); if (odp_unlikely(pool_base == NULL)) { ODP_ERR("Error: ODP packet pool mem alloc failed\n"); @@ -153,8 +157,9 @@ odp_class_init(void) odp_buffer_pool_print(pool); /* create ofpbuf pool */ - pool_base = odp_shm_reserve("shm_ofpbuf_pool", SHM_OFPBUF_POOL_SIZE, - ODP_CACHE_LINE_SIZE); + shm = odp_shm_reserve("shm_ofpbuf_pool", SHM_OFPBUF_POOL_SIZE, + ODP_CACHE_LINE_SIZE, 0); + pool_base = odp_shm_addr(shm); if (odp_unlikely(pool_base == NULL)) { ODP_ERR("Error: ODP packet pool mem alloc failed\n"); @@ -175,8 +180,9 @@ odp_class_init(void) odp_buffer_pool_print(ofpbuf_pool); /* create pool for structures */ - pool_base = odp_shm_reserve("shm_struct_pool", SHM_STRUCT_POOL_SIZE, - ODP_CACHE_LINE_SIZE); + shm = odp_shm_reserve("shm_struct_pool", SHM_STRUCT_POOL_SIZE, + ODP_CACHE_LINE_SIZE, 0); + pool_base = odp_shm_addr(shm); if (odp_unlikely(pool_base == NULL)) { ODP_ERR("Error: ODP packet pool mem alloc failed\n"); @@ -222,8 +228,6 @@ netdev_odp_construct(struct netdev *netdev_) { int err = 0; char *odp_if; - odp_pktio_params_t params; - socket_params_t *sock_params = ¶ms.sock_params; struct netdev_odp *netdev = netdev_odp_cast(netdev_); odp_packet_t pkt; @@ -234,9 +238,7 @@ netdev_odp_construct(struct netdev *netdev_) goto out_err; } - sock_params->type = ODP_PKTIO_TYPE_SOCKET_BASIC; - - netdev->pktio = odp_pktio_open(odp_if, pool, ¶ms); + netdev->pktio = odp_pktio_open(odp_if, pool); if (netdev->pktio == ODP_PKTIO_INVALID) { ODP_ERR("Error: odp pktio failed\n"); @@ -245,15 +247,15 @@ netdev_odp_construct(struct netdev *netdev_) } netdev->pkt_pool = pool; - pkt = odp_packet_alloc(netdev->pkt_pool); - if (!odp_packet_is_valid(pkt)) { + pkt = odph_packet_alloc(netdev->pkt_pool); + if (!odph_packet_is_valid(pkt)) { out_of_memory(); goto out_err; } - netdev->max_frame_len = odp_packet_buf_size(pkt); + netdev->max_frame_len = odph_packet_buf_size(pkt); - odp_packet_free(pkt); + odph_packet_free(pkt); ovs_mutex_init(&netdev->mutex); @@ -302,7 +304,7 @@ static int drop_err_pkts(odp_packet_t pkt_tbl[], unsigned len) pkt = pkt_tbl[i]; if (odp_unlikely(odp_packet_error(pkt))) { - odp_packet_free(pkt); /* Drop */ + odph_packet_free(pkt); /* Drop */ pkt_cnt--; } else if (odp_unlikely(i != j++)) { pkt_tbl[j-1] = pkt; @@ -332,9 +334,9 @@ clone_pkts(struct netdev_odp *dev, struct dpif_packet **pkts, dropped++; continue; } - pkt = odp_packet_alloc(dev->pkt_pool); + pkt = odph_packet_alloc(dev->pkt_pool); - if (OVS_UNLIKELY(!odp_packet_is_valid(pkt))) { + if (OVS_UNLIKELY(!odph_packet_is_valid(pkt))) { VLOG_WARN_RL(&rl, "Could not allocate packet"); dropped += cnt -i; break; @@ -384,7 +386,7 @@ netdev_odp_send(struct netdev *netdev, struct dpif_packet **pkts, int cnt, } else { for (i = 0; i < cnt; i++) { odp_pkts[i] = pkts[i]->ofpbuf.odp_pkt; - odp_packet_free(pkts[i]->ofpbuf.odp_ofpbuf); + odph_packet_free(pkts[i]->ofpbuf.odp_ofpbuf); } pkts_ok = cnt; } @@ -647,7 +649,7 @@ netdev_odp_rxq_recv(struct netdev_rxq *rxq_, struct dpif_packet **packets, out_of_memory(); } packets[i] = (struct dpif_packet*) odp_buffer_addr(buf); - ofpbuf_init_odp(&packets[i]->ofpbuf, odp_packet_buf_size(pkt_tbl[i])); + ofpbuf_init_odp(&packets[i]->ofpbuf, odph_packet_buf_size(pkt_tbl[i])); packets[i]->ofpbuf.odp_pkt = pkt_tbl[i]; packets[i]->ofpbuf.odp_ofpbuf = buf; rx_bytes += odp_packet_get_len(pkt_tbl[i]); diff --git a/lib/netdev-odp.h b/lib/netdev-odp.h index a0a2594..f7eaa27 100644 --- a/lib/netdev-odp.h +++ b/lib/netdev-odp.h @@ -7,9 +7,9 @@ #ifdef ODP_NETDEV #include -#include -#include -#include +#include +#include +#include /* This function is not exported, we need another way to deal with creating a packet from an ofpbuf */ diff --git a/lib/ofpbuf.c b/lib/ofpbuf.c index 55c59e0..eec7b30 100644 --- a/lib/ofpbuf.c +++ b/lib/ofpbuf.c @@ -153,7 +153,7 @@ ofpbuf_uninit(struct ofpbuf *b) #endif } else if (b->source == OFPBUF_ODP) { #ifdef ODP_NETDEV - odp_packet_free(b->odp_pkt); + odph_packet_free(b->odp_pkt); odp_buffer_free(b->odp_ofpbuf); #else ovs_assert(b->source != OFPBUF_ODP);