From patchwork Fri Jul 22 10:04:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Elo, Matias \(Nokia - FI/Espoo\)" X-Patchwork-Id: 72607 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp911917qga; Fri, 22 Jul 2016 03:06:37 -0700 (PDT) X-Received: by 10.200.45.235 with SMTP id q40mr4745462qta.34.1469181997797; Fri, 22 Jul 2016 03:06:37 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 123si8206600qkg.261.2016.07.22.03.06.37; Fri, 22 Jul 2016 03:06:37 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE dis=NONE) header.from=nokia.com Received: by lists.linaro.org (Postfix, from userid 109) id 78C2F6825A; Fri, 22 Jul 2016 10:06:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 740D468257; Fri, 22 Jul 2016 10:06:06 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id A3A8C68410; Fri, 22 Jul 2016 10:05:59 +0000 (UTC) Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-eopbgr40120.outbound.protection.outlook.com [40.107.4.120]) by lists.linaro.org (Postfix) with ESMTPS id 2A55968251 for ; Fri, 22 Jul 2016 10:05:57 +0000 (UTC) Received: from VI1PR07CA0009.eurprd07.prod.outlook.com (10.163.160.147) by VI1PR07MB1007.eurprd07.prod.outlook.com (10.161.111.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.544.10; Fri, 22 Jul 2016 10:05:53 +0000 Received: from DB3FFO11FD053.protection.gbl (2a01:111:f400:7e04::144) by VI1PR07CA0009.outlook.office365.com (2a01:111:e400:533d::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.544.10 via Frontend Transport; Fri, 22 Jul 2016 10:05:52 +0000 Received-SPF: Pass (protection.outlook.com: domain of nokia.com designates 131.228.2.241 as permitted sender) receiver=protection.outlook.com; client-ip=131.228.2.241; helo=fihe3nok0735.emea.nsn-net.net; Received: from fihe3nok0735.emea.nsn-net.net (131.228.2.241) by DB3FFO11FD053.mail.protection.outlook.com (10.47.217.125) with Microsoft SMTP Server (TLS) id 15.1.539.16 via Frontend Transport; Fri, 22 Jul 2016 10:05:53 +0000 Received: from fihe3nok0735.emea.nsn-net.net (localhost [127.0.0.1]) by fihe3nok0735.emea.nsn-net.net (8.14.9/8.14.5) with ESMTP id u6MA5WVH013421 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 22 Jul 2016 13:05:32 +0300 Received: from 10.144.19.15 ([10.144.104.111]) by fihe3nok0735.emea.nsn-net.net (8.14.9/8.14.5) with ESMTP id u6MA5MWU013147 (version=TLSv1/SSLv3 cipher=AES128-SHA256 bits=128 verify=NOT) for ; Fri, 22 Jul 2016 13:05:32 +0300 X-HPESVCS-Source-Ip: 10.144.104.111 From: Matias Elo To: Date: Fri, 22 Jul 2016 13:04:56 +0300 Message-ID: <1469181897-19168-3-git-send-email-matias.elo@nokia.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1469181897-19168-1-git-send-email-matias.elo@nokia.com> References: <1469181897-19168-1-git-send-email-matias.elo@nokia.com> X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:131.228.2.241; IPV:NLI; CTRY:FI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(7916002)(2980300002)(438002)(199003)(189002)(107886002)(50466002)(47776003)(575784001)(2906002)(48376002)(189998001)(50226002)(77096005)(110136002)(16796002)(305945005)(19580395003)(33646002)(19580405001)(7846002)(229853001)(2351001)(450100001)(68736007)(36756003)(106466001)(76176999)(6806005)(92566002)(50986999)(8676002)(8936002)(5003940100001)(11100500001)(81166006)(81156014)(586003)(356003)(2950100001)(97736004)(87936001)(42882005); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR07MB1007; H:fihe3nok0735.emea.nsn-net.net; FPR:; SPF:Pass; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; DB3FFO11FD053; 1:8V3tLPuwimKvzVzR/6JfWhqnh9vG7yXSCN3gn3dGJeiKpmWgmuY8L0z/9nN4nk/rneaNzYBo4jEW6u0fdmLi+4rLEnxh9fFmHGyQamyYUMe+1kNh6xq5ByH70oKGjBXVM6q8l9vRAe4f85tUm/ZREgHouxaCh0Fy59OjPykbEGFl8XcJQZNEZ72eNYqZvbatZRAHeRjavVtu0cVVfQx01Y36YxLIz3N3HqaDOWkgJgxc0ZrT76SswCtPfYDkBHsJJamj4NC2mT3bACZNx32AY+IAmmcuYBwXxR01tKWjvLma8OeBrS1ncbyqpz8uUQqIJj42eDOrxfda0w4pi2RlEXQe1qT79buMm4wK/0V1Ar2FXtH7LZduBBZGNtnFulXGspXOMwt/aiOyuMpDubaG5bo3HFwBHV6KFaIsO5H5RI1ovY46KbmLHteiAlFv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U= X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501002); SRVR:VI1PR07MB1007; X-Microsoft-Exchange-Diagnostics: 1; VI1PR07MB1007; 31:boqaqRgdv5Yv5OauU/k4NbRsyzGqSOCekAE/O6sXx5T8SaA17bvNslqRLft353VHaQkBpVwltEQMPI582zYmkbH8mfBkPxF5eLP+p9FTuFTJXrIOpuHE77EEcVyeDaBr5NMWIj9rH+JplT3AGr6JRaIiSRAaf/G0TqGeUiExU8x/pObOyudl4mWeFOCZhCG5Etjn3QiR2jeIdbFUKwcxqQ==; 20:2hBAuZCD/5jwNAPibNVifdGP3tP9l87mIlkKxkDGkDACZt90A0zrEzF9nK4o+Q3pnr2f3eOM4ca/Ek8RZn57kHmdaguzaJu6UByqieG0atfE7lRVx0/xTJNIVDijYBnVlqEHC5CNP7cc2PZ/yCodF+aiP7ep/fq4VJBA4zXp/09jyNDTe5+nGsZf9yL5sMuPHPx7AigAQ5wrJvrR5SLw9rUcYgNRiC5fGj5upIClA7GX6ve2U8vwJZoh5L9PfE1YdOWqu2JMzDYGXbfFvgSZLuSPUdKuFUQq/j/pKYHlFYWUsgrMOhOZHBiQ94u3ZSo2F8JXc5uxCwU9vNW5XsD7Q6vKmjiX8mWnzcqxBi08e5+roKD18G5VefYPfr1IGVVr1OGxGkS0kfBaLeCTPdP9r1yaI5Z1DrdE2WDT4MKifVjTJaeGsiijuJPBwhxOSGZZGN/3gp8SnG8nUj33kJCZ+h5BqRAnnZCmYPVNtvwbFKU4XnsaEGoFc8a6yB4BSCcyryrBD8lIsE7fox/qyTcgZ5fLH+YtuK56CX0ccaHZw08FpmD4RZm/jGG/50tHFWTHJycG5lB4KGTSPQ60yvtwYni0/xEAHVT4viSzI1zXMWo= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(82608151540597); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13016025)(8121501046)(13018025)(5005006)(10201501046)(3002001)(6055026); SRVR:VI1PR07MB1007; BCL:0; PCL:0; RULEID:; SRVR:VI1PR07MB1007; X-Microsoft-Exchange-Diagnostics: 1; VI1PR07MB1007; 4:jcaA5XXJI4QjLdMrCs9gbuU8fJ0fidSnrBG6ibooVVqFCGQlutFZQXXu/FjPZRTnOqzT211XNNuMH5rbRi+nwutZjEm+reqJJl+BhLZVgneHT0NlQbSCduy8vbKX/lIFFP/TiEg3tmt720EsuE6hS3TTPDzLG9vNXekAeSY5vSr6l4RLA7wY5eFFmeji6zdLxx/oX1hOP1YZCDgTIJ67DZj5umaFM2eUbLZMCAgYjdIX6lbaARS0p5eqy71LbdlgUm11NpBYvOOJDTagFkTngujlXffLsFBfHioseqsd2w4fMHA2ZPdNZbF7OhJ0FyBM3emk198DuWB5QLvwsds0TJsCyVmgWYxufHi5fIU40PgaAFGPosPFR0m/BB31GjymGgFQk8d6gphaddn0bYXsdAZiB3Qit2raA38JHBl7gExDfiqx6ILbfJB6syp55zk687zRpEX/b/TzWrLCUNwx+A== X-Forefront-PRVS: 0011612A55 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR07MB1007; 23:g7CXNzpCtpMEcI6fUln5F3SC4GN0E7IePCnqxo2Eg?= =?us-ascii?Q?HD5yoo+w4e/BGJzMCKz6g8fQofJ0ThthiW2OpBRX9kO9C2hscJMHMpgufjLW?= =?us-ascii?Q?Seq1LvdeHEH8gixBpRB1A7+grdZGUWPPPtWnckZ80u+31yWVlbQYkxLw7DAS?= =?us-ascii?Q?tKvc7w15bTYSBYQbenbRwJLc23RUA8A0vlWqqNFaISpiCav3AyPp2sn7ex9j?= =?us-ascii?Q?OyafMOUqqubHlHGSMQwk3axAbnCBlnrKmcS7gtJt2BjVqBg7pNmWaJkah4yA?= =?us-ascii?Q?5QENV9ANVMNor7GedqSjhnbOc+Cn/WQYDekUKBHbOGCS4zD1yVcxN6Eu7Ano?= =?us-ascii?Q?vcSqW07eiL5GKkCjODo37XZiQ6BHoNnc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gN8IfEkw6dJ0kyPYYQCOi55xIq7UEKEBdIz3TQObGOK3KK80Mpv5EhNmBxhBGW8CSXHddj3GhDPYhF+IrdaPGkktk+QKtKd8o7eF+rSrs6dmYTZdtnGOF9pV6fMMq8cNY2aeJHEKckA0GxNFBS7KG5W+jY184FAP9TyPhv2f6aqnWZkpxcDhZl+CceItS7njK9A4rzK9ClINETwBpN7tfioxhOgcCm0nIeEAZBoM3JpX9wLoo++RI/6U9LVjkVrW/O4UlMUkw==; 5:RMOKnd8IfhPJ6owFKa7pq02daLDK7mjoiFmUDCgEQxkBqDsLTYoe/ToDK3i9GjY0O9Z2EJ9cOcuBNS6WsTeZiFPgy6QW3N1bJbGEpLXtgGJs39BvDh5saJs+XKLUZzET5HboxUScsWlt2dz5/6RQBA==; 24:SV49u3J/bBgS+QQn9cbI16P8HLGCaNr9oHf39n17bxLPAsd0E+VPRRbsWPh4KOy4AmPp8kwlE8q5XboMMdWN/L5lm5V7H8kxXyLF6A5vsFQ=; 7:aFISaTUx9YFo9ZTeZcT0un4fzT5yfN+JCG2XoAAguzTu7PMZv3msnfy69WPy1Z25o2pZZIS1ubL5b2c8R8IUoIhN9FdqoZHWF5e8MqNixWczDRB1PDBLwPWGjD0gLbPkBeQgu77Y2GV642kf3RM8SHtvqImFYcHOdQRrzcKZQJk01Uq8CB8BTu0suVpFdRBd4hSEDWFeNlFWrNPe3J4oD52yqJmLhL+GtvVKeSC7FaNXDBUGbmFEny02cXW5JTYe SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: nokia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2016 10:05:53.5659 (UTC) X-MS-Exchange-CrossTenant-Id: 5d471751-9675-428d-917b-70f44f9630b0 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5d471751-9675-428d-917b-70f44f9630b0; Ip=[131.228.2.241]; Helo=[fihe3nok0735.emea.nsn-net.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR07MB1007 X-Topics: patch Subject: [lng-odp] [PATCH v3 3/4] linux-gen: netmap: use multi alloc/free X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" Modify netmap pktio to take advantage of multi-alloc/free. Signed-off-by: Matias Elo --- platform/linux-generic/include/odp_packet_netmap.h | 6 + platform/linux-generic/pktio/netmap.c | 126 ++++++++++++--------- 2 files changed, 78 insertions(+), 54 deletions(-) -- 2.7.4 diff --git a/platform/linux-generic/include/odp_packet_netmap.h b/platform/linux-generic/include/odp_packet_netmap.h index 0e6c0dc..2aadbed 100644 --- a/platform/linux-generic/include/odp_packet_netmap.h +++ b/platform/linux-generic/include/odp_packet_netmap.h @@ -35,6 +35,12 @@ typedef union { uint8_t pad[ODP_CACHE_LINE_SIZE_ROUNDUP(sizeof(struct netmap_ring_t))]; } netmap_ring_t ODP_ALIGNED_CACHE; +/** Netmap ring slot */ +typedef struct { + char *buf; /**< Slot buffer pointer */ + uint16_t len; /**< Slot length */ +} netmap_slot_t; + /** Packet socket using netmap mmaped rings for both Rx and Tx */ typedef struct { odp_pool_t pool; /**< pool to alloc packets from */ diff --git a/platform/linux-generic/pktio/netmap.c b/platform/linux-generic/pktio/netmap.c index 6498429..412beec 100644 --- a/platform/linux-generic/pktio/netmap.c +++ b/platform/linux-generic/pktio/netmap.c @@ -580,67 +580,85 @@ static int netmap_stop(pktio_entry_t *pktio_entry ODP_UNUSED) } /** - * Create ODP packet from netmap packet + * Create ODP packets from netmap packets * * @param pktio_entry Packet IO entry - * @param pkt_out Storage for new ODP packet handle - * @param buf Netmap buffer address - * @param len Netmap buffer length + * @param pkt_tbl Array for new ODP packet handles + * @param slot_tbl Array of netmap ring slots + * @param slot_num Number of netmap ring slots * @param ts Pointer to pktin timestamp * * @retval Number of created packets - * @retval <0 on failure */ static inline int netmap_pkt_to_odp(pktio_entry_t *pktio_entry, - odp_packet_t *pkt_out, const char *buf, - uint16_t len, odp_time_t *ts) + odp_packet_t pkt_tbl[], + netmap_slot_t slot_tbl[], int16_t slot_num, + odp_time_t *ts) { odp_packet_t pkt; odp_pool_t pool = pktio_entry->s.pkt_nm.pool; odp_packet_hdr_t *pkt_hdr; odp_packet_hdr_t parsed_hdr; + int i; int num; + int alloc_len; - if (odp_unlikely(len > pktio_entry->s.pkt_nm.max_frame_len)) { - ODP_ERR("RX: frame too big %" PRIu16 " %zu!\n", len, - pktio_entry->s.pkt_nm.max_frame_len); - return -1; - } + /* Allocate maximum sized packets */ + alloc_len = pktio_entry->s.pkt_nm.mtu; - if (odp_unlikely(len < _ODP_ETH_LEN_MIN)) { - ODP_ERR("RX: Frame truncated: %" PRIu16 "\n", len); - return -1; - } + num = packet_alloc_multi(pool, alloc_len, pkt_tbl, slot_num); - if (pktio_cls_enabled(pktio_entry)) { - if (cls_classify_packet(pktio_entry, (const uint8_t *)buf, len, - len, &pool, &parsed_hdr)) - return -1; - } - num = packet_alloc_multi(pool, len, &pkt, 1); - if (num != 1) - return -1; + for (i = 0; i < num; i++) { + netmap_slot_t slot; + uint16_t len; - pkt_hdr = odp_packet_hdr(pkt); + slot = slot_tbl[i]; + len = slot.len; - /* For now copy the data in the mbuf, - worry about zero-copy later */ - if (odp_packet_copy_from_mem(pkt, 0, len, buf) != 0) { - odp_packet_free(pkt); - return -1; - } - pkt_hdr->input = pktio_entry->s.handle; + odp_prefetch(slot.buf); + + if (odp_unlikely(len > pktio_entry->s.pkt_nm.max_frame_len)) { + ODP_ERR("RX: frame too big %" PRIu16 " %zu!\n", len, + pktio_entry->s.pkt_nm.max_frame_len); + goto fail; + } + + if (odp_unlikely(len < _ODP_ETH_LEN_MIN)) { + ODP_ERR("RX: Frame truncated: %" PRIu16 "\n", len); + goto fail; + } - if (pktio_cls_enabled(pktio_entry)) - copy_packet_cls_metadata(&parsed_hdr, pkt_hdr); - else - packet_parse_l2(&pkt_hdr->p, len); + if (pktio_cls_enabled(pktio_entry)) { + if (cls_classify_packet(pktio_entry, + (const uint8_t *)slot.buf, len, + len, &pool, &parsed_hdr)) + goto fail; + } - packet_set_ts(pkt_hdr, ts); + pkt = pkt_tbl[i]; + pkt_hdr = odp_packet_hdr(pkt); + pull_tail(pkt_hdr, alloc_len - len); + + /* For now copy the data in the mbuf, + worry about zero-copy later */ + if (odp_packet_copy_from_mem(pkt, 0, len, slot.buf) != 0) + goto fail; + + pkt_hdr->input = pktio_entry->s.handle; + + if (pktio_cls_enabled(pktio_entry)) + copy_packet_cls_metadata(&parsed_hdr, pkt_hdr); + else + packet_parse_l2(&pkt_hdr->p, len); + + packet_set_ts(pkt_hdr, ts); + } - *pkt_out = pkt; + return i; - return 1; +fail: + odp_packet_free_multi(&pkt_tbl[i], num - i); + return i; } static inline int netmap_recv_desc(pktio_entry_t *pktio_entry, @@ -650,10 +668,10 @@ static inline int netmap_recv_desc(pktio_entry_t *pktio_entry, struct netmap_ring *ring; odp_time_t ts_val; odp_time_t *ts = NULL; + netmap_slot_t slot_tbl[num]; char *buf; uint32_t slot_id; int i; - int ret; int ring_id = desc->cur_rx_ring; int num_rx = 0; int num_rings = desc->last_rx_ring - desc->first_rx_ring + 1; @@ -668,29 +686,28 @@ static inline int netmap_recv_desc(pktio_entry_t *pktio_entry, ring = NETMAP_RXRING(desc->nifp, ring_id); - /* Take timestamp beforehand per ring to improve performance */ - if (ts != NULL) - ts_val = odp_time_global(); - while (!nm_ring_empty(ring) && num_rx != num) { slot_id = ring->cur; buf = NETMAP_BUF(ring, ring->slot[slot_id].buf_idx); - odp_prefetch(buf); - - ret = netmap_pkt_to_odp(pktio_entry, &pkt_table[num_rx], - buf, ring->slot[slot_id].len, - ts); - if (ret > 0) - num_rx += ret; + slot_tbl[num_rx].buf = buf; + slot_tbl[num_rx].len = ring->slot[slot_id].len; + num_rx++; ring->cur = nm_ring_next(ring, slot_id); - ring->head = ring->cur; } + ring->head = ring->cur; ring_id++; } desc->cur_rx_ring = ring_id; - return num_rx; + + if (num_rx) { + if (ts != NULL) + ts_val = odp_time_global(); + return netmap_pkt_to_odp(pktio_entry, pkt_table, slot_tbl, + num_rx, ts); + } + return 0; } static int netmap_recv(pktio_entry_t *pktio_entry, int index, @@ -806,7 +823,6 @@ static int netmap_send(pktio_entry_t *pktio_entry, int index, } if (i == NM_INJECT_RETRIES) break; - odp_packet_free(pkt); } /* Send pending packets */ poll(&polld, 1, 0); @@ -814,6 +830,8 @@ static int netmap_send(pktio_entry_t *pktio_entry, int index, if (!pkt_nm->lockless_tx) odp_ticketlock_unlock(&pkt_nm->tx_desc_ring[index].s.lock); + odp_packet_free_multi(pkt_table, nb_tx); + if (odp_unlikely(nb_tx == 0 && __odp_errno != 0)) return -1;