From patchwork Mon Jan 5 19:19:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zoltan Kiss X-Patchwork-Id: 42760 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f69.google.com (mail-ee0-f69.google.com [74.125.83.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E52F225B5B for ; Mon, 5 Jan 2015 19:20:19 +0000 (UTC) Received: by mail-ee0-f69.google.com with SMTP id d49sf12472536eek.4 for ; Mon, 05 Jan 2015 11:20:19 -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:subject :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=bE5FpyXazlWSb43Ou6dCVGO2mHeyPGDlRmxO5Lhm64I=; b=PeG7rt3fgiNPovWH5zthQ7eckocN+x7+abuZ5pPgygqwQR+PLMjo5AbiqUHmTOsPEH I8PxK5F2+eHOpKv6sdLLDQ3mUAFA05s0VwvCyY8Gh0FLS9mBtbAi+3HXFSQo/0oj7zu/ rl/dpoB/HkDYfIAg7DortelAxJwnuDYNmG1oZFWSZ+csC1O24M7Q8NhQBcp5q5NQsfTl DQlNvWxt6lGXfdAQ8sBsD76spEfWKEQbWG1Uq7DSejzhCdbWpp13Zv4Q+Zh1coYehUqf /jWS/6mXdQ4eqnc6Lh3QRSWpksbrk8utUnTSzfvdNcxVuzKbTX9sRCC1C41DgZTi8BnL jEyw== X-Gm-Message-State: ALoCoQnePuVj2mmIBMI9C+oZJ4K8Ly4BsnlaJPRJmPNqBt4ZW7QNJ5wycOm5HftUu4qIxj9iMIZP X-Received: by 10.180.24.35 with SMTP id r3mr1699668wif.0.1420485619131; Mon, 05 Jan 2015 11:20:19 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.21.39 with SMTP id s7ls1419085lae.20.gmail; Mon, 05 Jan 2015 11:20:18 -0800 (PST) X-Received: by 10.112.129.195 with SMTP id ny3mr96027614lbb.10.1420485618898; Mon, 05 Jan 2015 11:20:18 -0800 (PST) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com. [209.85.217.182]) by mx.google.com with ESMTPS id jc11si63222255lac.31.2015.01.05.11.20.18 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 05 Jan 2015 11:20:18 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.182 as permitted sender) client-ip=209.85.217.182; Received: by mail-lb0-f182.google.com with SMTP id f15so20321817lbj.27 for ; Mon, 05 Jan 2015 11:20:18 -0800 (PST) X-Received: by 10.112.180.135 with SMTP id do7mr52700936lbc.23.1420485618754; Mon, 05 Jan 2015 11:20:18 -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.9.200 with SMTP id c8csp970428lbb; Mon, 5 Jan 2015 11:20:17 -0800 (PST) X-Received: by 10.140.19.78 with SMTP id 72mr64534398qgg.41.1420485617017; Mon, 05 Jan 2015 11:20:17 -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 q1si61425851qcc.24.2015.01.05.11.20.15 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 05 Jan 2015 11:20:17 -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 1Y8DCG-0006Hn-Mp; Mon, 05 Jan 2015 19:20:12 +0000 Received: from mail-wi0-f171.google.com ([209.85.212.171]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Y8DBo-0006Gb-BE for lng-odp@lists.linaro.org; Mon, 05 Jan 2015 19:19:44 +0000 Received: by mail-wi0-f171.google.com with SMTP id bs8so3965278wib.10 for ; Mon, 05 Jan 2015 11:19:39 -0800 (PST) X-Received: by 10.180.87.72 with SMTP id v8mr4257067wiz.29.1420485578880; Mon, 05 Jan 2015 11:19:38 -0800 (PST) Received: from localhost.localdomain ([90.152.119.35]) by mx.google.com with ESMTPSA id dp8sm11008509wib.20.2015.01.05.11.19.37 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 05 Jan 2015 11:19:37 -0800 (PST) From: Zoltan Kiss To: lng-odp@lists.linaro.org Date: Mon, 5 Jan 2015 19:19:16 +0000 Message-Id: <1420485556-12841-1-git-send-email-zoltan.kiss@linaro.org> X-Mailer: git-send-email 1.9.1 X-Topics: patch Subject: [lng-odp] [PATCH] OVS-ODP: ODP v0.6.0 support 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.182 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 This is only compile tested, and there are a few questions in the patch. Signed-off-by: Zoltan Kiss diff --git a/lib/netdev-odp.c b/lib/netdev-odp.c index 96126a1..571b66e 100644 --- a/lib/netdev-odp.c +++ b/lib/netdev-odp.c @@ -45,7 +45,7 @@ #include "unaligned.h" #include "timeval.h" #include "unixctl.h" -#include "vlog.h" +#include "openvswitch/vlog.h" VLOG_DEFINE_THIS_MODULE(odp); @@ -94,7 +94,7 @@ struct netdev_rxq_odp { void free_odp_buf(struct ofpbuf *b) { - odph_packet_free(b->odp_pkt); + odp_packet_free(b->odp_pkt); odp_buffer_free(b->odp_ofpbuf); } @@ -129,26 +129,26 @@ odp_init(int argc, char *argv[]) static int odp_class_init(void) { - void *pool_base; odp_shm_t shm; + odp_buffer_pool_param_t params; int result = 0; /* create packet pool */ 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)) { + if (odp_unlikely(shm == ODP_SHM_INVALID)) { VLOG_ERR("Error: ODP packet pool mem alloc failed\n"); out_of_memory(); return -1; } - pool = odp_buffer_pool_create("packet_pool", pool_base, - SHM_PKT_POOL_SIZE, - SHM_PKT_POOL_BUF_SIZE, - ODP_CACHE_LINE_SIZE, - ODP_BUFFER_TYPE_PACKET); + params.buf_size = SHM_PKT_POOL_BUF_SIZE; + params.buf_align = ODP_CACHE_LINE_SIZE; + params.num_bufs = SHM_PKT_POOL_SIZE / SHM_PKT_POOL_BUF_SIZE; + params.buf_type = ODP_BUFFER_TYPE_PACKET; + + pool = odp_buffer_pool_create("packet_pool", shm, ¶ms); if (pool == ODP_BUFFER_POOL_INVALID) { VLOG_ERR("Error: packet pool create failed.\n"); @@ -159,19 +159,18 @@ odp_class_init(void) /* create ofpbuf pool */ 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)) { + if (odp_unlikely(shm == ODP_SHM_INVALID)) { VLOG_ERR("Error: ODP packet pool mem alloc failed\n"); out_of_memory(); return -1; } - ofpbuf_pool = odp_buffer_pool_create("ofpbuf_pool", pool_base, - SHM_OFPBUF_POOL_SIZE, - SHM_OFPBUF_POOL_BUF_SIZE, - ODP_CACHE_LINE_SIZE, - ODP_BUFFER_TYPE_RAW); + params.buf_size = SHM_OFPBUF_POOL_BUF_SIZE; + params.num_bufs = SHM_OFPBUF_POOL_SIZE / SHM_OFPBUF_POOL_BUF_SIZE; + params.buf_type = ODP_BUFFER_TYPE_RAW; + + ofpbuf_pool = odp_buffer_pool_create("ofpbuf_pool", shm, ¶ms); if (ofpbuf_pool == ODP_BUFFER_POOL_INVALID) { VLOG_ERR("Error: ofpbuf pool create failed.\n"); @@ -182,19 +181,17 @@ odp_class_init(void) /* create pool for structures */ 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)) { + if (odp_unlikely(shm == ODP_SHM_INVALID)) { VLOG_ERR("Error: ODP packet pool mem alloc failed\n"); out_of_memory(); return -1; } - struct_pool = odp_buffer_pool_create("struct_pool", pool_base, - SHM_STRUCT_POOL_SIZE, - SHM_STRUCT_POOL_BUF_SIZE, - ODP_CACHE_LINE_SIZE, - ODP_BUFFER_TYPE_RAW); + params.buf_size = SHM_STRUCT_POOL_BUF_SIZE; + params.num_bufs = SHM_STRUCT_POOL_SIZE / SHM_STRUCT_POOL_BUF_SIZE; + + struct_pool = odp_buffer_pool_create("struct_pool", shm, ¶ms); if (struct_pool == ODP_BUFFER_POOL_INVALID) { VLOG_ERR("Error: packet pool create failed.\n"); @@ -247,15 +244,15 @@ netdev_odp_construct(struct netdev *netdev_) } netdev->pkt_pool = pool; - pkt = odph_packet_alloc(netdev->pkt_pool); - if (!odph_packet_is_valid(pkt)) { + pkt = odp_packet_alloc(netdev->pkt_pool, 0); + if (!odp_packet_is_valid(pkt)) { out_of_memory(); goto out_err; } - netdev->max_frame_len = odph_packet_buf_size(pkt); + netdev->max_frame_len = odp_buffer_size(odp_packet_to_buffer(pkt)); - odph_packet_free(pkt); + odp_packet_free(pkt); ovs_mutex_init(&netdev->mutex); @@ -304,7 +301,7 @@ static int drop_err_pkts(odp_packet_t pkt_tbl[], unsigned len) pkt = pkt_tbl[i]; if (odp_unlikely(odp_packet_error(pkt))) { - odph_packet_free(pkt); /* Drop */ + odp_packet_free(pkt); /* Drop */ pkt_cnt--; } else if (odp_unlikely(i != j++)) { pkt_tbl[j-1] = pkt; @@ -334,19 +331,21 @@ clone_pkts(struct netdev_odp *dev, struct dpif_packet **pkts, dropped++; continue; } - pkt = odph_packet_alloc(dev->pkt_pool); + pkt = odp_packet_alloc(dev->pkt_pool, size); - if (OVS_UNLIKELY(!odph_packet_is_valid(pkt))) { + if (OVS_UNLIKELY(pkt == ODP_PACKET_INVALID)) { VLOG_WARN_RL(&rl, "Could not allocate packet"); dropped += cnt -i; break; } - odp_packet_init(pkt); - odp_packet_set_l2_offset(pkt, 0); + odp_packet_reset(pkt, 0); + odp_packet_l2_offset_set(pkt, 0); - memcpy(odp_packet_l2(pkt), ofpbuf_data(&pkts[i]->ofpbuf), size); - odp_packet_parse(pkt, size, 0); + memcpy(odp_packet_l2_ptr(pkt, NULL), ofpbuf_data(&pkts[i]->ofpbuf), + size); + /* TODO: is this OK? */ + _odp_packet_parse(pkt); odp_pkts[newcnt] = pkt; newcnt++; @@ -386,7 +385,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; - odph_packet_free(pkts[i]->ofpbuf.odp_ofpbuf); + odp_packet_free(pkts[i]->ofpbuf.odp_ofpbuf); } pkts_ok = cnt; } @@ -396,7 +395,7 @@ netdev_odp_send(struct netdev *netdev, struct dpif_packet **pkts, int cnt, ovs_mutex_lock(&dev->mutex); dev->stats.tx_packets += pkts_ok; for (i = 0; i < pkts_ok; i++) { - dev->stats.tx_bytes += odp_packet_get_len(odp_pkts[i]); + dev->stats.tx_bytes += odp_packet_len(odp_pkts[i]); } ovs_mutex_unlock(&dev->mutex); @@ -649,10 +648,12 @@ 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, odph_packet_buf_size(pkt_tbl[i])); + ofpbuf_init_odp(&packets[i]->ofpbuf, + odp_buffer_size(odp_packet_to_buffer(pkt_tbl[i]))); + /* ^^^ Is this OK?*/ packets[i]->ofpbuf.odp_pkt = pkt_tbl[i]; packets[i]->ofpbuf.odp_ofpbuf = buf; - rx_bytes += odp_packet_get_len(pkt_tbl[i]); + rx_bytes += odp_packet_len(pkt_tbl[i]); } *c = pkts_ok; diff --git a/lib/netdev-odp.h b/lib/netdev-odp.h index 9f521da..6162dd4 100644 --- a/lib/netdev-odp.h +++ b/lib/netdev-odp.h @@ -9,7 +9,7 @@ #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 d216917..764a799 100644 --- a/lib/ofpbuf.c +++ b/lib/ofpbuf.c @@ -154,7 +154,7 @@ ofpbuf_uninit(struct ofpbuf *b) #endif } else if (b->source == OFPBUF_ODP) { #ifdef ODP_NETDEV - odph_packet_free(b->odp_pkt); + odp_packet_free(b->odp_pkt); odp_buffer_free(b->odp_ofpbuf); #else ovs_assert(b->source != OFPBUF_ODP); diff --git a/lib/ofpbuf.h b/lib/ofpbuf.h index 1c5166f..47cee29 100644 --- a/lib/ofpbuf.h +++ b/lib/ofpbuf.h @@ -429,7 +429,7 @@ static inline void * ofpbuf_data(const struct ofpbuf *b) { #ifdef ODP_NETDEV if (b->source == OFPBUF_ODP) - return odp_packet_l2(b->odp_pkt); + return odp_packet_l2_ptr(b->odp_pkt, NULL); #endif return b->data_; @@ -439,8 +439,7 @@ static inline void ofpbuf_set_data(struct ofpbuf *b, void *d) { #ifdef ODP_NETDEV if (b->source == OFPBUF_ODP) { - ODP_ERR("ODP: Invalid use of ofpbuf_set_data\n"); - ovs_abort(0, "Invalid function call\n"); + ovs_abort(0, "ODP: Invalid use of ofpbuf_set_data\n"); } #endif @@ -451,8 +450,7 @@ static inline void * ofpbuf_base(const struct ofpbuf *b) { #ifdef ODP_NETDEV if (b->source == OFPBUF_ODP) { - ODP_ERR("ODP: Invalid use of ofpbuf_base\n"); - ovs_abort(0, "Invalid function call\n"); + ovs_abort(0, "ODP: Invalid use of ofpbuf_base\n"); } #endif @@ -463,8 +461,7 @@ static inline void ofpbuf_set_base(struct ofpbuf *b, void *d) { #ifdef ODP_NETDEV if (b->source == OFPBUF_ODP) { - ODP_ERR("ODP: Invalid use of ofpbuf_set_base\n"); - ovs_abort(0, "Invalid function call\n"); + ovs_abort(0, "ODP: Invalid use of ofpbuf_set_base\n\n"); } #endif @@ -475,7 +472,7 @@ static inline uint32_t ofpbuf_size(const struct ofpbuf *b) { #ifdef ODP_NETDEV if (b->source == OFPBUF_ODP) - return odp_packet_get_len(b->odp_pkt); + return odp_packet_len(b->odp_pkt); #endif return b->size_; @@ -485,8 +482,7 @@ static inline void ofpbuf_set_size(struct ofpbuf *b, uint32_t v) { #ifdef ODP_NETDEV if (b->source == OFPBUF_ODP) { - ODP_ERR("ODP: Invalid use of ofpbuf_set_size\n"); - ovs_abort(0, "Invalid function call\n"); + ovs_abort(0, "ODP: Invalid use of ofpbuf_set_size\n"); } #endif