From patchwork Wed Jan 7 18:48:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zoltan Kiss X-Patchwork-Id: 42852 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0299B2055F for ; Wed, 7 Jan 2015 18:49:03 +0000 (UTC) Received: by mail-la0-f71.google.com with SMTP id q1sf2889972lam.2 for ; Wed, 07 Jan 2015 10:49:01 -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=1NXJ6Do5dtMX7PVQKXHFdo2qwYpDfsYIRWxIxIcDjbk=; b=kFOGE4reOp75Bl3+o+0XVxNgTS6DtgV3euZYvvOsT5k3ui90VMpIJyZlmWohpvpgUO FdCuULWMjxKc+UuS742oQOu7z34Lwg423TgCMGiR++ONyIDPh/q4j6C5VagFbKfWlye6 v22OztToElPwd0jXybHQxGWilfLE5o06wkhNprnT12VsQCLiV0Xh5y7s+zq4og4w0fcm 3h0YP5Z/chshqRNACCZsLI2HIVbq8spzJSUIY8FgREId/7tey6Hx/hh8uJfcGhwDRyBD ba8MVjArtI3aYEbKbHKszgY0AbCEdDRyxi/7W/pj3goBqBz4mP+OQNanZP0/qmR0N3KY NRHg== X-Gm-Message-State: ALoCoQlyPZ/Z26IQzKGVRTICQpIFKHh45yd8FWLbMEYrXfSo/pgBPJcYYIPkw7wQ/fmYZfagV6bF X-Received: by 10.180.105.97 with SMTP id gl1mr3167207wib.7.1420656541600; Wed, 07 Jan 2015 10:49:01 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.42.133 with SMTP id o5ls189555lal.78.gmail; Wed, 07 Jan 2015 10:49:01 -0800 (PST) X-Received: by 10.152.5.132 with SMTP id s4mr7233684las.39.1420656541428; Wed, 07 Jan 2015 10:49:01 -0800 (PST) Received: from mail-la0-f50.google.com (mail-la0-f50.google.com. [209.85.215.50]) by mx.google.com with ESMTPS id g1si4343330lbd.126.2015.01.07.10.49.01 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 07 Jan 2015 10:49:01 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) client-ip=209.85.215.50; Received: by mail-la0-f50.google.com with SMTP id pn19so5257269lab.9 for ; Wed, 07 Jan 2015 10:49:00 -0800 (PST) X-Received: by 10.112.98.99 with SMTP id eh3mr7201983lbb.32.1420656540909; Wed, 07 Jan 2015 10:49:00 -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 c8csp29487lbb; Wed, 7 Jan 2015 10:49:00 -0800 (PST) X-Received: by 10.224.14.66 with SMTP id f2mr7237404qaa.81.1420656539369; Wed, 07 Jan 2015 10:48:59 -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 eb3si2973098qcb.23.2015.01.07.10.48.58 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 07 Jan 2015 10:48:59 -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 1Y8vf6-0002Cd-AU; Wed, 07 Jan 2015 18:48:56 +0000 Received: from mail-wi0-f172.google.com ([209.85.212.172]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1Y8vf0-0002CY-EA for lng-odp@lists.linaro.org; Wed, 07 Jan 2015 18:48:50 +0000 Received: by mail-wi0-f172.google.com with SMTP id n3so8127715wiv.11 for ; Wed, 07 Jan 2015 10:48:45 -0800 (PST) X-Received: by 10.180.206.47 with SMTP id ll15mr10479430wic.34.1420656524904; Wed, 07 Jan 2015 10:48:44 -0800 (PST) Received: from localhost.localdomain ([90.152.119.35]) by mx.google.com with ESMTPSA id i3sm3171497wjw.2.2015.01.07.10.48.43 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Jan 2015 10:48:44 -0800 (PST) From: Zoltan Kiss To: lng-odp@lists.linaro.org Date: Wed, 7 Jan 2015 18:48:25 +0000 Message-Id: <1420656505-5947-1-git-send-email-zoltan.kiss@linaro.org> X-Mailer: git-send-email 1.9.1 X-Topics: patch Subject: [lng-odp] [PATCH v2] 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.215.50 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. To avoid warning pollution this fixes up netdev_odp_class as well, which changes when I upgraded the OVS master branch. Signed-off-by: Zoltan Kiss Reviewed-by: Bill Fischofer diff --git a/lib/netdev-odp.c b/lib/netdev-odp.c index 96126a1..a38acac 100644 --- a/lib/netdev-odp.c +++ b/lib/netdev-odp.c @@ -45,14 +45,14 @@ #include "unaligned.h" #include "timeval.h" #include "unixctl.h" -#include "vlog.h" +#include "openvswitch/vlog.h" VLOG_DEFINE_THIS_MODULE(odp); -#define SHM_PKT_POOL_SIZE (512*2048) +#define SHM_PKT_POOL_NUM_BUFS 512 #define SHM_PKT_POOL_BUF_SIZE 1856 -#define SHM_OFPBUF_POOL_SIZE (512*256) +#define SHM_OFPBUF_NUM_BUFS 512 #define SHM_OFPBUF_POOL_BUF_SIZE sizeof(struct dpif_packet) static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 20); @@ -88,13 +88,13 @@ struct netdev_rxq_odp { /* We need a pool of buffers that hold netdev and rxq structures */ #define STRUCTS_SIZE MAX(sizeof(struct netdev_odp), \ sizeof(struct netdev_rxq_odp)) -#define SHM_STRUCT_POOL_SIZE (512 * (STRUCTS_SIZE)) +#define SHM_STRUCT_POOL_NUM_BUFS 512 #define SHM_STRUCT_POOL_BUF_SIZE STRUCTS_SIZE 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,17 @@ 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)) { - 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_NUM_BUFS; + params.buf_type = ODP_BUFFER_TYPE_PACKET; + + pool = odp_buffer_pool_create("packet_pool", ODP_SHM_NULL, ¶ms); if (pool == ODP_BUFFER_POOL_INVALID) { VLOG_ERR("Error: packet pool create failed.\n"); @@ -157,21 +148,12 @@ odp_class_init(void) odp_buffer_pool_print(pool); /* 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)) { - 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_BUF_SIZE; + params.buf_type = ODP_BUFFER_TYPE_RAW; + + ofpbuf_pool = odp_buffer_pool_create("ofpbuf_pool", ODP_SHM_NULL, ¶ms); if (ofpbuf_pool == ODP_BUFFER_POOL_INVALID) { VLOG_ERR("Error: ofpbuf pool create failed.\n"); @@ -180,21 +162,11 @@ odp_class_init(void) odp_buffer_pool_print(ofpbuf_pool); /* 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)) { - 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_NUM_BUFS; + + struct_pool = odp_buffer_pool_create("struct_pool", ODP_SHM_NULL, ¶ms); if (struct_pool == ODP_BUFFER_POOL_INVALID) { VLOG_ERR("Error: packet pool create failed.\n"); @@ -229,7 +201,7 @@ netdev_odp_construct(struct netdev *netdev_) int err = 0; char *odp_if; struct netdev_odp *netdev = netdev_odp_cast(netdev_); - odp_packet_t pkt; + odp_buffer_pool_info_t info; odp_if = netdev_->name + 4; /* Names always start with "odp:" */ @@ -247,15 +219,14 @@ netdev_odp_construct(struct netdev *netdev_) } netdev->pkt_pool = pool; - pkt = odph_packet_alloc(netdev->pkt_pool); - if (!odph_packet_is_valid(pkt)) { - out_of_memory(); + + err = odp_buffer_pool_info(netdev->pkt_pool, &info); + if ( err != 0) { + VLOG_ERR("Error: Couldn't get default packet buffer size\n"); goto out_err; } - netdev->max_frame_len = odph_packet_buf_size(pkt); - - odph_packet_free(pkt); + netdev->max_frame_len = info.params.buf_size; ovs_mutex_init(&netdev->mutex); @@ -304,7 +275,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,20 +305,18 @@ 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); - - memcpy(odp_packet_l2(pkt), ofpbuf_data(&pkts[i]->ofpbuf), size); - odp_packet_parse(pkt, size, 0); + odp_packet_l2_offset_set(pkt, 0); + odp_packet_push_tail(pkt, size); + odp_packet_copydata_in(pkt, 0, size, ofpbuf_data(&pkts[i]->ofpbuf)); odp_pkts[newcnt] = pkt; newcnt++; } @@ -365,8 +334,8 @@ clone_pkts(struct netdev_odp *dev, struct dpif_packet **pkts, } static int -netdev_odp_send(struct netdev *netdev, struct dpif_packet **pkts, int cnt, - bool may_steal) +netdev_odp_send(struct netdev *netdev, int qid OVS_UNUSED, + struct dpif_packet **pkts, int cnt, bool may_steal) { struct netdev_odp *dev = netdev_odp_cast(netdev); odp_packet_t odp_pkts[NETDEV_MAX_RX_BATCH]; @@ -386,7 +355,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 +365,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); @@ -505,18 +474,6 @@ netdev_odp_get_stats(const struct netdev *netdev, struct netdev_stats *stats) } static int -netdev_odp_set_stats(struct netdev *netdev, const struct netdev_stats *stats) -{ - struct netdev_odp *dev = netdev_odp_cast(netdev); - - ovs_mutex_lock(&dev->mutex); - dev->stats = *stats; - ovs_mutex_unlock(&dev->mutex); - - return 0; -} - -static int netdev_odp_get_features(const struct netdev *netdev, enum netdev_features *current, enum netdev_features *advertised OVS_UNUSED, @@ -620,7 +577,7 @@ netdev_odp_rxq_recv(struct netdev_rxq *rxq_, struct dpif_packet **packets, size_t rx_bytes = 0; unsigned long err_cnt = 0; int i; - odp_pktio_t pkt_tbl[NETDEV_MAX_RX_BATCH]; + odp_packet_t pkt_tbl[NETDEV_MAX_RX_BATCH]; pkts = odp_pktio_recv(netdev->pktio, pkt_tbl, NETDEV_MAX_RX_BATCH); if (pkts < 0) { @@ -649,10 +606,10 @@ 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_packet_buf_len(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]); + rx_bytes += odp_packet_len(pkt_tbl[i]); } *c = pkts_ok; @@ -682,6 +639,11 @@ static struct netdev_class netdev_odp_class = { netdev_odp_get_config, NULL, /* netdev_odp_set_config */ NULL, /* get_tunnel_config */ + NULL, /* build_header */ + NULL, /* push_header */ + NULL, /* pop_header */ + NULL, /* get_numa_id */ + NULL, /* set_multiq */ netdev_odp_send, /* send */ NULL, /* send_wait */ @@ -695,7 +657,6 @@ static struct netdev_class netdev_odp_class = { netdev_odp_get_carrier_resets, netdev_odp_set_miimon, netdev_odp_get_stats, - netdev_odp_set_stats, netdev_odp_get_features, NULL, /* set_advertisements */ 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