From patchwork Tue Aug 22 08:00:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 110614 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp5003843obb; Tue, 22 Aug 2017 01:02:05 -0700 (PDT) X-Received: by 10.200.3.73 with SMTP id w9mr5152172qtg.108.1503388925809; Tue, 22 Aug 2017 01:02:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503388925; cv=none; d=google.com; s=arc-20160816; b=ybcJbX7dkyApQwo67G+dt7H3Hqj/7yaRKkSrjGb57dCF5MpZ3ynXDj3lSDK2+0tbAL Hd4k7QdrOpgUvZl0HdyG1JONhcYJN5ZT4kY5V68h9it0Cwxtsp8n2JCBFziPE/JcwQC2 52reMHfHPY5EcCmWvk7fOyXJfYMesLE2ry6B18GquFvPVrVz6Vb02y7mVWO85AylM90L jYbzFj351X7u4ux67gOYhHTdLNNqv/HunyuM7vQVHaZTjbX4n+8CE82m8X4ZiFG5o2Lp 8mv66pkJu7sq0PVBVhqF+2fFEfNLhi8S/9Jva+k5anaZ1ojWyFGPSZxcgyqaRnFIL1aw EmgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=EYIIFMHsuIUlTzMoUjtF18MIbQL+vL+RKFaeSdRU1jY=; b=XDM24Oa4HJ0H1ppZVBpfP8+cjNiOzBUyiUGgqMG+0y2e3+LI0Vbuj5MAPNSkA0imAg I+taqbLfVKY72LzatbVBzGvnn6pys+x3BE7uhX4mkk8/sDcdyzzk/XpeOU8x9OlHA85+ hVwmAIh4YqlARjBPaO95XeOOa1GWWXstHbqZyvRx4T/jByGHxEr1BKS5tha/nx043P51 8vO82fvoBILh9LVcHqiGoA+aRVXcdWSszpiWIH4Fz1q2CUETkmHwaetvBqVnYwMATa6n nEIaay3vLOtP8uz8WuwXc046JzI+xBHSBRPFGu0pC5ErEdtPIxbeKWQkSLAyvryOPZYu zqCQ== ARC-Authentication-Results: i=1; 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 sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id m97si14367241qkh.236.2017.08.22.01.02.05; Tue, 22 Aug 2017 01:02:05 -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 sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 49EF3644B7; Tue, 22 Aug 2017 08:02:05 +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=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 5C6C360896; Tue, 22 Aug 2017 08:01:04 +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 88EF6644CD; Tue, 22 Aug 2017 08:00:48 +0000 (UTC) Received: from forward102j.mail.yandex.net (forward102j.mail.yandex.net [5.45.198.243]) by lists.linaro.org (Postfix) with ESMTPS id A9435644DD for ; Tue, 22 Aug 2017 08:00:16 +0000 (UTC) Received: from mxback8j.mail.yandex.net (mxback8j.mail.yandex.net [IPv6:2a02:6b8:0:1619::111]) by forward102j.mail.yandex.net (Yandex) with ESMTP id BA43B5601AF2 for ; Tue, 22 Aug 2017 11:00:14 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback8j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 3k9UAo4gJB-0EWKPDuC; Tue, 22 Aug 2017 11:00:14 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id IVkIzK7jNZ-0E0S1cIt; Tue, 22 Aug 2017 11:00:14 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Tue, 22 Aug 2017 11:00:06 +0300 Message-Id: <1503388810-6999-2-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1503388810-6999-1-git-send-email-odpbot@yandex.ru> References: <1503388810-6999-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 124 Subject: [lng-odp] [PATCH v3 1/5] linux-gen: dpdk: retrieve offload capabilities 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" From: Bogdan Pricope Signed-off-by: Bogdan Pricope --- /** Email created from pull request 124 (bogdanPricope:dpdk_hw_csum_pr) ** https://github.com/Linaro/odp/pull/124 ** Patch: https://github.com/Linaro/odp/pull/124.patch ** Base sha: aecb3c7a442b426761f1e6f43308a1e9ea709ef3 ** Merge commit sha: 23658e7f5acf9d3621ec7a8f617db98a26ee1bda **/ platform/linux-generic/pktio/dpdk.c | 54 +++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/platform/linux-generic/pktio/dpdk.c b/platform/linux-generic/pktio/dpdk.c index 19310651..a4884b91 100644 --- a/platform/linux-generic/pktio/dpdk.c +++ b/platform/linux-generic/pktio/dpdk.c @@ -897,6 +897,11 @@ static void dpdk_init_capability(pktio_entry_t *pktio_entry, { pkt_dpdk_t *pkt_dpdk = &pktio_entry->s.pkt_dpdk; odp_pktio_capability_t *capa = &pkt_dpdk->capa; + int ptype_cnt; + int ptype_l3_ipv4 = 0; + int ptype_l4_tcp = 0; + int ptype_l4_udp = 0; + uint32_t ptype_mask = RTE_PTYPE_L3_MASK | RTE_PTYPE_L4_MASK; memset(dev_info, 0, sizeof(struct rte_eth_dev_info)); memset(capa, 0, sizeof(odp_pktio_capability_t)); @@ -908,9 +913,58 @@ static void dpdk_init_capability(pktio_entry_t *pktio_entry, PKTIO_MAX_QUEUES); capa->set_op.op.promisc_mode = 1; + ptype_cnt = rte_eth_dev_get_supported_ptypes(pkt_dpdk->port_id, + ptype_mask, NULL, 0); + if (ptype_cnt > 0) { + uint32_t ptypes[ptype_cnt]; + int i; + + ptype_cnt = rte_eth_dev_get_supported_ptypes(pkt_dpdk->port_id, + ptype_mask, ptypes, + ptype_cnt); + for (i = 0; i < ptype_cnt; i++) + switch (ptypes[i]) { + case RTE_PTYPE_L3_IPV4: + /* Fall through */ + case RTE_PTYPE_L3_IPV4_EXT_UNKNOWN: + /* Fall through */ + case RTE_PTYPE_L3_IPV4_EXT: + ptype_l3_ipv4 = 1; + break; + case RTE_PTYPE_L4_TCP: + ptype_l4_tcp = 1; + break; + case RTE_PTYPE_L4_UDP: + ptype_l4_udp = 1; + break; + } + } + odp_pktio_config_init(&capa->config); capa->config.pktin.bit.ts_all = 1; capa->config.pktin.bit.ts_ptp = 1; + + capa->config.pktin.bit.ipv4_chksum = ptype_l3_ipv4 && + (dev_info->rx_offload_capa & DEV_RX_OFFLOAD_IPV4_CKSUM) ? 1 : 0; + if (capa->config.pktin.bit.ipv4_chksum) + capa->config.pktin.bit.drop_ipv4_err = 1; + + capa->config.pktin.bit.udp_chksum = ptype_l4_udp && + (dev_info->rx_offload_capa & DEV_RX_OFFLOAD_UDP_CKSUM) ? 1 : 0; + if (capa->config.pktin.bit.udp_chksum) + capa->config.pktin.bit.drop_udp_err = 1; + + capa->config.pktin.bit.tcp_chksum = ptype_l4_tcp && + (dev_info->rx_offload_capa & DEV_RX_OFFLOAD_TCP_CKSUM) ? 1 : 0; + if (capa->config.pktin.bit.tcp_chksum) + capa->config.pktin.bit.drop_tcp_err = 1; + + capa->config.pktout.bit.ipv4_chksum = + (dev_info->tx_offload_capa & DEV_TX_OFFLOAD_IPV4_CKSUM) ? 1 : 0; + capa->config.pktout.bit.udp_chksum = + (dev_info->tx_offload_capa & DEV_TX_OFFLOAD_UDP_CKSUM) ? 1 : 0; + capa->config.pktout.bit.tcp_chksum = + (dev_info->tx_offload_capa & DEV_TX_OFFLOAD_TCP_CKSUM) ? 1 : 0; } static int dpdk_open(odp_pktio_t id ODP_UNUSED, From patchwork Tue Aug 22 08:00:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 110618 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp5007387obb; Tue, 22 Aug 2017 01:05:29 -0700 (PDT) X-Received: by 10.237.57.106 with SMTP id l97mr2734779qte.128.1503389129614; Tue, 22 Aug 2017 01:05:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503389129; cv=none; d=google.com; s=arc-20160816; b=eU8UNzS//DNmrwHcfWxr2xnFbNv9bvPDqAaAHLnd6LWu9f6rGQA+zAF2hoQFQVO7bO XKal0e09mTNELR9FcelbWOUAze5FkBRNtsNB78M0VhXCN1uISxjd7gHLLDwxZRmK85rW HYIm1/JG/tM/vz2DWm/H8kwXI/JxfnMrg7H+QJ7mhSiA0Uk8gNGvfhjx5tq5hflITNfR 4gq3m0RFPE2w7+58arxTDRSg8+bb1WKs2HTWIYteTrEHwjtmJncAJnNVxFM9aLxKkvPQ sTmpTef/kkwGcGqP2ikhh0wxrQJHGQzmzOBPFKxVOQxHNHC38UJ2Kx8VKNcd5s2XF57w dySA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=f5p4EIpIxKsxQLfNxJ5LprGzFBIxGwBq/5peJ8t552Y=; b=OHuCbJcJzEjhroeoDAOOg0lb7ExYUOmFsswqssR7SJ60SRo3lmuasmSOoGqke8+zp0 WO/utiGmEYs9BYZL8ETHpM8XVra6k1StBkRxBAbpguPN44SVG7PYJ9hBqKD4HnXG/ijw 9gWmj8XuYVmf77VnULp+3O8BrtwqDbpPZsooAo3vlSBSmkwyVOg7cg11SfUv+v/Yi+rS AF+5egPmLvOcAswThX+ex6p5KEPF22P+I+d94+bMEe9WJkiqxs566nc6k/4ykT7o5yUS coR0sL+vovd5bWIJOsnjxvopkaqKnM1HfE6QsVE4v9mnDaEh2aq6tfqWBoIvSTZhdGYn FVmw== ARC-Authentication-Results: i=1; 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 sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 9si11229778qtd.312.2017.08.22.01.05.29; Tue, 22 Aug 2017 01:05:29 -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 sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 4A25C644C8; Tue, 22 Aug 2017 08:05:29 +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=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 73EEB644DD; Tue, 22 Aug 2017 08:01:30 +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 BFD8D644A3; Tue, 22 Aug 2017 08:01:06 +0000 (UTC) Received: from forward100p.mail.yandex.net (forward100p.mail.yandex.net [77.88.28.100]) by lists.linaro.org (Postfix) with ESMTPS id 25946644E6 for ; Tue, 22 Aug 2017 08:00:20 +0000 (UTC) Received: from mxback5g.mail.yandex.net (mxback5g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:166]) by forward100p.mail.yandex.net (Yandex) with ESMTP id 80996510149A for ; Tue, 22 Aug 2017 11:00:15 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback5g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id ckPh9ZHQ6U-0Fo8w86Q; Tue, 22 Aug 2017 11:00:15 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id IVkIzK7jNZ-0E0urYxx; Tue, 22 Aug 2017 11:00:14 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Tue, 22 Aug 2017 11:00:07 +0300 Message-Id: <1503388810-6999-3-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1503388810-6999-1-git-send-email-odpbot@yandex.ru> References: <1503388810-6999-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 124 Subject: [lng-odp] [PATCH v3 2/5] linux-gen: dpdk: enable per pktio RX IP/UDP/TCP checksum offload 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" From: Bogdan Pricope Signed-off-by: Bogdan Pricope --- /** Email created from pull request 124 (bogdanPricope:dpdk_hw_csum_pr) ** https://github.com/Linaro/odp/pull/124 ** Patch: https://github.com/Linaro/odp/pull/124.patch ** Base sha: aecb3c7a442b426761f1e6f43308a1e9ea709ef3 ** Merge commit sha: 23658e7f5acf9d3621ec7a8f617db98a26ee1bda **/ platform/linux-generic/pktio/dpdk.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/platform/linux-generic/pktio/dpdk.c b/platform/linux-generic/pktio/dpdk.c index a4884b91..693c0c97 100644 --- a/platform/linux-generic/pktio/dpdk.c +++ b/platform/linux-generic/pktio/dpdk.c @@ -666,6 +666,7 @@ static int dpdk_setup_port(pktio_entry_t *pktio_entry) int ret; pkt_dpdk_t *pkt_dpdk = &pktio_entry->s.pkt_dpdk; struct rte_eth_rss_conf rss_conf; + uint16_t hw_ip_checksum = 0; /* Always set some hash functions to enable DPDK RSS hash calculation */ if (pkt_dpdk->hash.all_bits == 0) { @@ -675,12 +676,17 @@ static int dpdk_setup_port(pktio_entry_t *pktio_entry) rss_conf_to_hash_proto(&rss_conf, &pkt_dpdk->hash); } + if (pktio_entry->s.config.pktin.bit.ipv4_chksum || + pktio_entry->s.config.pktin.bit.udp_chksum || + pktio_entry->s.config.pktin.bit.tcp_chksum) + hw_ip_checksum = 1; + struct rte_eth_conf port_conf = { .rxmode = { .mq_mode = ETH_MQ_RX_RSS, .split_hdr_size = 0, .header_split = 0, - .hw_ip_checksum = 0, + .hw_ip_checksum = hw_ip_checksum, .hw_vlan_filter = 0, .hw_strip_crc = 0, .enable_scatter = 0, From patchwork Tue Aug 22 08:00:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 110616 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp5005482obb; Tue, 22 Aug 2017 01:03:42 -0700 (PDT) X-Received: by 10.200.48.151 with SMTP id v23mr7540582qta.339.1503389022813; Tue, 22 Aug 2017 01:03:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503389022; cv=none; d=google.com; s=arc-20160816; b=ADSSKfx/fWDP8XOf9tz2PjMHWf1dk9FyNnuHt96XJFrCSQySWPMKS1RAjAc8QhXsRm iZWZC2v5kAqpuwP0++wvO6u5Dc4dlqXJTi4FwceA1xvF8mdWLIM7mTaJ5AsoZ2VMY3+4 68CVgpufTkwQGiiY16dAnm/mB5Va8cy3ttyoxAbi8jat9f0EHpP8g5HzHUlMnv05DbjT WgrwNtQXU9RdGL8MkVv1Fjz6sMfFOSZU0vpaYe7pqm12ulEVJheBHqK6sZ8hgd7d0WZa fkW8GrpflqRlnshn1YRJ2GJsHi8+2CvxDFJOUV3ldSsIcSAUheLexL+VDB3yBsAPL+7g hBGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=s8LEgKrv7TTBI2VkPnB0SBJtNyKGi7iZeRwyJmwrdRw=; b=amYeCAtnYzqWMtp6rCBl3Qd2zi41RTj4K/pE6thBOAQprhlu+n8QE8dCGixlgWJQ/j LK7NXsPlaQaJXS7RoEm4lYAYKU/mmQr4XJLYoxlWKQOTo2fIik/JBxhaMdwI5U+0wvGY sMXVjgepWe+35ClycfzQPM/KNCgAgBkEJyERsacrjtiTJ75VVasWxJ6PHUjAP7ODqlUc 9lolURLbqSZoWVAyeNHCZRO6HuXe9M1dwOHrA8Lg7fZhjcKllQjyMFpHe9Kqo4wttOHx BSdDl2B4xgf4hrNFlPAyPiWnNftm/V+dJ9wVD23AQfX96Z5g3HSlRBVLMogX3U1wJBaq QAXg== ARC-Authentication-Results: i=1; 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 sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id g123si13275621qkd.142.2017.08.22.01.03.42; Tue, 22 Aug 2017 01:03:42 -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 sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 57140644B7; Tue, 22 Aug 2017 08:03:42 +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=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 03A4564492; Tue, 22 Aug 2017 08:01:12 +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 6CFB2644CD; Tue, 22 Aug 2017 08:00:49 +0000 (UTC) Received: from forward101o.mail.yandex.net (forward101o.mail.yandex.net [37.140.190.181]) by lists.linaro.org (Postfix) with ESMTPS id BD91664492 for ; Tue, 22 Aug 2017 08:00:17 +0000 (UTC) Received: from mxback9g.mail.yandex.net (mxback9g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:170]) by forward101o.mail.yandex.net (Yandex) with ESMTP id 6241E134384E for ; Tue, 22 Aug 2017 11:00:16 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback9g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id WvxBFICcsW-0FEaK9pn; Tue, 22 Aug 2017 11:00:16 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id IVkIzK7jNZ-0F0Gqopl; Tue, 22 Aug 2017 11:00:15 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Tue, 22 Aug 2017 11:00:08 +0300 Message-Id: <1503388810-6999-4-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1503388810-6999-1-git-send-email-odpbot@yandex.ru> References: <1503388810-6999-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 124 Subject: [lng-odp] [PATCH v3 3/5] linux-gen: dpdk: RX - process checksum validation offload flags 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" From: Bogdan Pricope Signed-off-by: Bogdan Pricope --- /** Email created from pull request 124 (bogdanPricope:dpdk_hw_csum_pr) ** https://github.com/Linaro/odp/pull/124 ** Patch: https://github.com/Linaro/odp/pull/124.patch ** Base sha: aecb3c7a442b426761f1e6f43308a1e9ea709ef3 ** Merge commit sha: 23658e7f5acf9d3621ec7a8f617db98a26ee1bda **/ platform/linux-generic/pktio/dpdk.c | 59 +++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/platform/linux-generic/pktio/dpdk.c b/platform/linux-generic/pktio/dpdk.c index 693c0c97..6dfb8c7a 100644 --- a/platform/linux-generic/pktio/dpdk.c +++ b/platform/linux-generic/pktio/dpdk.c @@ -301,6 +301,48 @@ static struct rte_mempool_ops ops_stack = { MEMPOOL_REGISTER_OPS(ops_stack); +#define HAS_IP4_PROTO(m, proto) ((m->packet_type & RTE_PTYPE_L3_MASK) == proto) +#define HAS_IP4_PROTOS(m) (HAS_IP4_PROTO(m, RTE_PTYPE_L3_IPV4) ||\ + HAS_IP4_PROTO(m, RTE_PTYPE_L3_IPV4_EXT) ||\ + HAS_IP4_PROTO(m, RTE_PTYPE_L3_IPV4_EXT_UNKNOWN)) +#define HAS_IP4_CSUM_FLAG(m, f) ((m->ol_flags & PKT_RX_IP_CKSUM_MASK) == f) +#define HAS_L4_PROTO(m, proto) ((m->packet_type & RTE_PTYPE_L4_MASK) == proto) +#define HAS_L4_CSUM_FLAG(m, f) ((m->ol_flags & PKT_RX_L4_CKSUM_MASK) == f) + +#define PKTIN_CSUM_BITS 0x1C + +static inline int pkt_set_ol_rx(odp_pktin_config_opt_t *pktin_cfg, + odp_packet_hdr_t *pkt_hdr, + struct rte_mbuf *mbuf) +{ + if (pktin_cfg->bit.ipv4_chksum && + HAS_IP4_PROTOS(mbuf) && + HAS_IP4_CSUM_FLAG(mbuf, PKT_RX_IP_CKSUM_BAD)) { + if (pktin_cfg->bit.drop_ipv4_err) + return -1; + + pkt_hdr->p.error_flags.ip_err = 1; + } + + if (pktin_cfg->bit.udp_chksum && + HAS_L4_PROTO(mbuf, RTE_PTYPE_L4_UDP) && + HAS_L4_CSUM_FLAG(mbuf, PKT_RX_L4_CKSUM_BAD)) { + if (pktin_cfg->bit.drop_udp_err) + return -1; + + pkt_hdr->p.error_flags.udp_err = 1; + } else if (pktin_cfg->bit.tcp_chksum && + HAS_L4_PROTO(mbuf, RTE_PTYPE_L4_TCP) && + HAS_L4_CSUM_FLAG(mbuf, PKT_RX_L4_CKSUM_BAD)) { + if (pktin_cfg->bit.drop_tcp_err) + return -1; + + pkt_hdr->p.error_flags.tcp_err = 1; + } + + return 0; +} + static inline int mbuf_to_pkt(pktio_entry_t *pktio_entry, odp_packet_t pkt_table[], struct rte_mbuf *mbuf_table[], @@ -315,6 +357,7 @@ static inline int mbuf_to_pkt(pktio_entry_t *pktio_entry, int nb_pkts = 0; int alloc_len, num; odp_pool_t pool = pktio_entry->s.pkt_dpdk.pool; + odp_pktin_config_opt_t *pktin_cfg = &pktio_entry->s.config.pktin; /* Allocate maximum sized packets */ alloc_len = pktio_entry->s.pkt_dpdk.data_room; @@ -369,6 +412,14 @@ static inline int mbuf_to_pkt(pktio_entry_t *pktio_entry, packet_set_ts(pkt_hdr, ts); + if (pktin_cfg->all_bits & PKTIN_CSUM_BITS) { + if (pkt_set_ol_rx(pktin_cfg, pkt_hdr, mbuf)) { + odp_packet_free(pkt); + rte_pktmbuf_free(mbuf); + continue; + } + } + pkt_table[nb_pkts++] = pkt; rte_pktmbuf_free(mbuf); @@ -435,6 +486,7 @@ static inline int mbuf_to_pkt_zero(pktio_entry_t *pktio_entry, int i; int nb_pkts = 0; odp_pool_t pool = pktio_entry->s.pkt_dpdk.pool; + odp_pktin_config_opt_t *pktin_cfg = &pktio_entry->s.config.pktin; for (i = 0; i < mbuf_num; i++) { odp_packet_hdr_t parsed_hdr; @@ -480,6 +532,13 @@ static inline int mbuf_to_pkt_zero(pktio_entry_t *pktio_entry, packet_set_ts(pkt_hdr, ts); + if (pktin_cfg->all_bits & PKTIN_CSUM_BITS) { + if (pkt_set_ol_rx(pktin_cfg, pkt_hdr, mbuf)) { + rte_pktmbuf_free(mbuf); + continue; + } + } + pkt_table[nb_pkts++] = pkt; } From patchwork Tue Aug 22 08:00:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 110615 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp5004564obb; Tue, 22 Aug 2017 01:02:49 -0700 (PDT) X-Received: by 10.55.207.86 with SMTP id e83mr25250300qkj.108.1503388969661; Tue, 22 Aug 2017 01:02:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503388969; cv=none; d=google.com; s=arc-20160816; b=km19jNvLXf1QLhrs+8heAwSE0H+AwJYqamcBWtQ/RTBWykwdxDzdUDSm3QnnwXjHn6 LjcWMg9Ruy4aA10aqshM71OBCgwF4KiTzhBNcNZSpZgaSk0K7fSdbhr4/eh1YbB0IK48 MvWyhbIFbJ6lVR/3L4Yi8H3ZUbsLykavM9IIR6h2Pt0VZRb1lRkbSQuHRWdQQyCEKzAH oCBYnv4riR/EcJR8atiHkFpsKDxfppsJeQFNoNPU6g1BitH/XPpAbb+hVscoGi2L9WOf kBWgZBwwdot83dP8WakX+uoUSA6OPD8P+xiLLliXmAJrXP+HWnVtuq69j6380ZqCsywo 3TYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=GwCShh9J4hnUuOtDmB5dMjEJtG7Oqr5LilMgFAFp+0s=; b=aSNnQXt7EKbWVRHzKV8wEjAYOp0Qn2nFAVpaD5RWYPhjDlJgRqCShNphFl9xiCgx9c QxjdIACaKbqKdytcdxR0hGs40z/o0bYpa0C1CpZoxxxySauLuGmy9uR0xkD4Y5G8+tuL SzoQSMw5/KDWUsCwzVD+4yuo/3YhR6BgaLrhLAgVoK/ztaAJWcQtaQMqqRK8xoM6CvNO lm489g0oYTf8QAF68DmqyAlOoMaPfoYRlqDafvHNhkWHcSci34OpHp8pMFb++m2o0Ce8 zdfivSFL0mXj9sHlQcza4gFSMd5CRsfila8be7KxGvUW7V2vdXHxLdnFdc5EwQDska28 3b6w== ARC-Authentication-Results: i=1; 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 sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id j8si13575989qti.94.2017.08.22.01.02.49; Tue, 22 Aug 2017 01:02:49 -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 sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 4BFC0644A8; Tue, 22 Aug 2017 08:02:49 +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=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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 AA1066448F; Tue, 22 Aug 2017 08:01:05 +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 160E9644CD; Tue, 22 Aug 2017 08:00:49 +0000 (UTC) Received: from forward100o.mail.yandex.net (forward100o.mail.yandex.net [37.140.190.180]) by lists.linaro.org (Postfix) with ESMTPS id 9360F644D4 for ; Tue, 22 Aug 2017 08:00:19 +0000 (UTC) Received: from mxback14g.mail.yandex.net (mxback14g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:93]) by forward100o.mail.yandex.net (Yandex) with ESMTP id ED7C22A20D94 for ; Tue, 22 Aug 2017 11:00:16 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback14g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id PNCW4fcVpP-0G08GMUo; Tue, 22 Aug 2017 11:00:16 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id IVkIzK7jNZ-0G0iTt8F; Tue, 22 Aug 2017 11:00:16 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Tue, 22 Aug 2017 11:00:09 +0300 Message-Id: <1503388810-6999-5-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1503388810-6999-1-git-send-email-odpbot@yandex.ru> References: <1503388810-6999-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 124 Subject: [lng-odp] [PATCH v3 4/5] linux-gen: dpdk: TX - set checksum calculation offload flags 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" From: Bogdan Pricope Signed-off-by: Bogdan Pricope --- /** Email created from pull request 124 (bogdanPricope:dpdk_hw_csum_pr) ** https://github.com/Linaro/odp/pull/124 ** Patch: https://github.com/Linaro/odp/pull/124.patch ** Base sha: aecb3c7a442b426761f1e6f43308a1e9ea709ef3 ** Merge commit sha: 23658e7f5acf9d3621ec7a8f617db98a26ee1bda **/ platform/linux-generic/pktio/dpdk.c | 110 ++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) diff --git a/platform/linux-generic/pktio/dpdk.c b/platform/linux-generic/pktio/dpdk.c index 6dfb8c7a..bf383e09 100644 --- a/platform/linux-generic/pktio/dpdk.c +++ b/platform/linux-generic/pktio/dpdk.c @@ -30,6 +30,10 @@ #include #include #include +#include +#include +#include +#include #include #if ODP_DPDK_ZERO_COPY @@ -436,6 +440,97 @@ static inline int mbuf_to_pkt(pktio_entry_t *pktio_entry, return (i > 0 ? i : -1); } +static inline int packet_parse(void *l3_hdr, odp_bool_t *l3_proto_v4, + uint8_t *l4_proto) +{ + uint8_t l3_proto_ver = _ODP_IPV4HDR_VER(*(uint8_t *)l3_hdr); + + if (l3_proto_ver == _ODP_IPV4) { + struct ipv4_hdr *ip = (struct ipv4_hdr *)l3_hdr; + + *l3_proto_v4 = 1; + if (!rte_ipv4_frag_pkt_is_fragmented(ip)) + *l4_proto = ip->next_proto_id; + else + *l4_proto = 0; + + return 0; + } else if (l3_proto_ver == _ODP_IPV6) { + struct ipv6_hdr *ipv6 = (struct ipv6_hdr *)l3_hdr; + + *l3_proto_v4 = 0; + *l4_proto = ipv6->proto; + return 0; + } + + return -1; +} + +static inline uint16_t phdr_csum(odp_bool_t ipv4, void *l3_hdr, + uint64_t ol_flags) +{ + if (ipv4) + return rte_ipv4_phdr_cksum(l3_hdr, ol_flags); + else /*ipv6*/ + return rte_ipv6_phdr_cksum(l3_hdr, ol_flags); +} + +static inline int pkt_set_ol_tx(odp_pktout_config_opt_t *pktout_cfg, + odp_packet_hdr_t *pkt_hdr, + struct rte_mbuf *mbuf, + char *mbuf_data) +{ + void *l3_hdr, *l4_hdr; + uint8_t l4_proto; + odp_bool_t l3_proto_v4; + odp_bool_t ipv4_chksum_pkt, udp_chksum_pkt, tcp_chksum_pkt; + packet_parser_t *pkt_p = &pkt_hdr->p; + + l3_hdr = (void *)(mbuf_data + pkt_p->l3_offset); + + if (packet_parse(l3_hdr, &l3_proto_v4, &l4_proto)) + return 0; + + ipv4_chksum_pkt = pktout_cfg->bit.ipv4_chksum && l3_proto_v4; + udp_chksum_pkt = pktout_cfg->bit.udp_chksum && + (l4_proto == _ODP_IPPROTO_UDP); + tcp_chksum_pkt = pktout_cfg->bit.tcp_chksum && + (l4_proto == _ODP_IPPROTO_TCP); + + if (!ipv4_chksum_pkt && !udp_chksum_pkt && !tcp_chksum_pkt) + return 0; + + mbuf->l2_len = pkt_p->l3_offset - pkt_p->l2_offset; + mbuf->l3_len = pkt_p->l4_offset - pkt_p->l3_offset; + + if (l3_proto_v4) + mbuf->ol_flags = PKT_TX_IPV4; + else + mbuf->ol_flags = PKT_TX_IPV6; + + if (ipv4_chksum_pkt) { + mbuf->ol_flags |= PKT_TX_IP_CKSUM; + + ((struct ipv4_hdr *)l3_hdr)->hdr_checksum = 0; + } + + l4_hdr = (void *)(mbuf_data + pkt_p->l4_offset); + + if (udp_chksum_pkt) { + mbuf->ol_flags |= PKT_TX_UDP_CKSUM; + + ((struct udp_hdr *)l4_hdr)->dgram_cksum = + phdr_csum(l3_proto_v4, l3_hdr, mbuf->ol_flags); + } else if (tcp_chksum_pkt) { + mbuf->ol_flags |= PKT_TX_TCP_CKSUM; + + ((struct tcp_hdr *)l4_hdr)->cksum = + phdr_csum(l3_proto_v4, l3_hdr, mbuf->ol_flags); + } + + return 0; +} + static inline int pkt_to_mbuf(pktio_entry_t *pktio_entry, struct rte_mbuf *mbuf_table[], const odp_packet_t pkt_table[], uint16_t num) @@ -444,6 +539,7 @@ static inline int pkt_to_mbuf(pktio_entry_t *pktio_entry, int i, j; char *data; uint16_t pkt_len; + odp_pktout_config_opt_t *pktout_cfg = &pktio_entry->s.config.pktout; if (odp_unlikely((rte_pktmbuf_alloc_bulk(pkt_dpdk->pkt_pool, mbuf_table, num)))) { @@ -463,6 +559,11 @@ static inline int pkt_to_mbuf(pktio_entry_t *pktio_entry, data = rte_pktmbuf_append(mbuf_table[i], pkt_len); odp_packet_copy_to_mem(pkt_table[i], 0, pkt_len, data); + + if (pktout_cfg->all_bits) + pkt_set_ol_tx(pktout_cfg, + odp_packet_hdr(pkt_table[i]), + mbuf_table[i], data); } return i; @@ -551,6 +652,7 @@ static inline int pkt_to_mbuf_zero(pktio_entry_t *pktio_entry, uint16_t *copy_count) { pkt_dpdk_t *pkt_dpdk = &pktio_entry->s.pkt_dpdk; + odp_pktout_config_opt_t *pktout_cfg = &pktio_entry->s.config.pktout; int i; *copy_count = 0; @@ -567,6 +669,10 @@ static inline int pkt_to_mbuf_zero(pktio_entry_t *pktio_entry, if (odp_likely(pkt_hdr->buf_hdr.segcount == 1 && pkt_hdr->extra_type == PKT_EXTRA_TYPE_DPDK)) { mbuf_update(mbuf, pkt_hdr, pkt_len); + + if (pktout_cfg->all_bits) + pkt_set_ol_tx(pktout_cfg, pkt_hdr, + mbuf, odp_packet_data(pkt)); } else { pool_t *pool_entry = pkt_hdr->buf_hdr.pool_ptr; @@ -582,6 +688,10 @@ static inline int pkt_to_mbuf_zero(pktio_entry_t *pktio_entry, mbuf_init(pkt_dpdk->pkt_pool, mbuf, pkt_hdr); mbuf_update(mbuf, pkt_hdr, pkt_len); + if (pktout_cfg->all_bits) + pkt_set_ol_tx(pktout_cfg, pkt_hdr, + mbuf, + odp_packet_data(pkt)); } } mbuf_table[i] = mbuf; From patchwork Tue Aug 22 08:00:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 110617 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp5006280obb; Tue, 22 Aug 2017 01:04:25 -0700 (PDT) X-Received: by 10.200.48.100 with SMTP id g33mr6750302qte.248.1503389065412; Tue, 22 Aug 2017 01:04:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503389065; cv=none; d=google.com; s=arc-20160816; b=mubtpCh5CacxteWLDbFVAIvgwLbK+Mkhqwg04LGG1JIvFu0DrItTRVZNgqj8cTpF6O +/BvTXis3viqBEs1YSS4lipAc0iFm6JQ9orQjZziSUA7xQGWPeJq22ZbGwiaGGWe3eL1 e+DTzfSLoismxDHg89UwbdFdpmavIQZngeRsEPkLt+/Ko3vDmnhvSFEP0gRe9+35CdVP zK4bzKvkyEgxJ7IPKdmFCaqJuqNTOnfFVCLVIzYNAVlP9hJ8UAr/ZwIpeD3NxMq5AcsQ WP5Gfi9kcVDcXrGyvtKUE+5XkpqqdAJL7HTn7YJ/chTXvpGcHveLGWEd0+M+QW33vySH zPbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=rSrcYcb8Jzy8V5wKZD896CmSI7aX+Rzdce9fXKPzz90=; b=u7fkHNajZY6r+emjzP/n7Nb+xOUCFNMYic6fLqk9wxfnV65soLPpgzuqVrC3t+jrYR NRVH6oCu1jr2x3DJ1ZdFYbXXquwPwdv8AB1OrJIgLxeGXX6irHKzNr7HN/AlA9CQIzPr 1yrF0bgf0ZKDs6/MLCfdeR+j8hahEiLVULKNIiLZYPVZPVidZR1bbW0XTK6qp54wJBZg lH+e6fpkvHzu8x22KMoM+VzDd4nSNjoygbnRKeseqVO7G1qmMEvoATFp6jwhcqNf8zQb 21pNlJfUtolH3se1Re47u9Ixi07yX9cOgsW1LFJ3kQ2Xqy20wI5NtmdiJSKR6WEft0nq 2NRQ== ARC-Authentication-Results: i=1; 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 sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id v51si13259323qtv.52.2017.08.22.01.04.25; Tue, 22 Aug 2017 01:04:25 -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 sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 19542644A3; Tue, 22 Aug 2017 08:04:25 +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=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 35D86644D8; Tue, 22 Aug 2017 08:01:25 +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 EFB2862D32; Tue, 22 Aug 2017 08:01:00 +0000 (UTC) Received: from forward101p.mail.yandex.net (forward101p.mail.yandex.net [77.88.28.101]) by lists.linaro.org (Postfix) with ESMTPS id 973BC644DE for ; Tue, 22 Aug 2017 08:00:19 +0000 (UTC) Received: from mxback3j.mail.yandex.net (mxback3j.mail.yandex.net [IPv6:2a02:6b8:0:1619::10c]) by forward101p.mail.yandex.net (Yandex) with ESMTP id E8A806A82ADE for ; Tue, 22 Aug 2017 11:00:17 +0300 (MSK) Received: from smtp4o.mail.yandex.net (smtp4o.mail.yandex.net [2a02:6b8:0:1a2d::28]) by mxback3j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id tCPYKfs0La-0HD8D4l1; Tue, 22 Aug 2017 11:00:17 +0300 Received: by smtp4o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id IVkIzK7jNZ-0H0GbxE5; Tue, 22 Aug 2017 11:00:17 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Tue, 22 Aug 2017 11:00:10 +0300 Message-Id: <1503388810-6999-6-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1503388810-6999-1-git-send-email-odpbot@yandex.ru> References: <1503388810-6999-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 124 Subject: [lng-odp] [PATCH v3 5/5] examples: generator: update odp_generator to use HW checksum capabilities 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" From: Bogdan Pricope Signed-off-by: Bogdan Pricope --- /** Email created from pull request 124 (bogdanPricope:dpdk_hw_csum_pr) ** https://github.com/Linaro/odp/pull/124 ** Patch: https://github.com/Linaro/odp/pull/124.patch ** Base sha: aecb3c7a442b426761f1e6f43308a1e9ea709ef3 ** Merge commit sha: 23658e7f5acf9d3621ec7a8f617db98a26ee1bda **/ example/generator/odp_generator.c | 156 ++++++++++++++++++++++++++++++-------- 1 file changed, 124 insertions(+), 32 deletions(-) diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c index f3ec43be..65471f54 100644 --- a/example/generator/odp_generator.c +++ b/example/generator/odp_generator.c @@ -46,6 +46,7 @@ typedef struct { odp_pktio_t pktio; + odp_pktio_config_t config; odp_pktout_queue_t pktout[MAX_WORKERS]; unsigned pktout_count; } interface_t; @@ -91,7 +92,16 @@ static struct { /** * Thread specific arguments */ typedef struct { - odp_pktout_queue_t pktout; /**< Packet output queue to use*/ + union { + struct { + odp_pktout_queue_t pktout; /**< Packet output queue */ + odp_pktout_config_opt_t *pktout_cfg; /**< Packet output config*/ + } tx; + struct { + interface_t *ifs; /**< Interfaces array */ + int ifs_count; /**< Interfaces array size */ + } rx; + }; odp_pool_t pool; /**< Pool for packet IO */ odp_timer_pool_t tp; /**< Timer pool handle */ odp_queue_t tq; /**< Queue for timeouts */ @@ -116,6 +126,10 @@ static args_t *args; /** Barrier to sync threads execution */ static odp_barrier_t barrier; +/** Packet processing function types */ +typedef odp_packet_t (*setup_pkt_ref_t)(odp_pool_t, odp_pktout_config_opt_t *); +typedef int (*setup_pkt_t)(odp_packet_t, odp_pktout_config_opt_t *); + /* helper funcs */ static void parse_args(int argc, char *argv[], appl_args_t *appl_args); static void print_info(char *progname, appl_args_t *appl_args); @@ -190,20 +204,22 @@ static int scan_ip(char *buf, unsigned int *paddr) * Setup array of reference packets * * @param pool Packet pool + * @param pktout_cfg Interface output configuration * @param pkt_ref_array Packet array * @param pkt_ref_array_size Packet array size * @param setup_ref Packet setup function * @return 0 success, -1 failed */ static int setup_pkt_ref_array(odp_pool_t pool, + odp_pktout_config_opt_t *pktout_cfg, odp_packet_t *pkt_ref_array, int pkt_ref_array_size, - odp_packet_t (*setup_ref)(odp_pool_t)) + setup_pkt_ref_t setup_ref) { int i; for (i = 0; i < pkt_ref_array_size; i++) { - pkt_ref_array[i] = (*setup_ref)(pool); + pkt_ref_array[i] = (*setup_ref)(pool, pktout_cfg); if (pkt_ref_array[i] == ODP_PACKET_INVALID) break; } @@ -218,21 +234,23 @@ static int setup_pkt_ref_array(odp_pool_t pool, /** * Setup array of packets * + * @param pktout_cfg Interface output configuration * @param pkt_ref_array Reference packet array * @param pkt_array Packet array * @param pkt_array_size Packet array size * @param setup_pkt Packet setup function * @return 0 success, -1 failed */ -static int setup_pkt_array(odp_packet_t *pkt_ref_array, +static int setup_pkt_array(odp_pktout_config_opt_t *pktout_cfg, + odp_packet_t *pkt_ref_array, odp_packet_t *pkt_array, int pkt_array_size, - int (*setup_pkt)(odp_packet_t)) + setup_pkt_t setup_pkt) { int i; for (i = 0; i < pkt_array_size; i++) { - if ((*setup_pkt)(pkt_ref_array[i])) + if ((*setup_pkt)(pkt_ref_array[i], pktout_cfg)) break; pkt_array[i] = odp_packet_ref_static(pkt_ref_array[i]); @@ -252,13 +270,15 @@ static int setup_pkt_array(odp_packet_t *pkt_ref_array, * set up an udp packet reference * * @param pool Buffer pool to create packet in + * @param pktout_cfg Interface output configuration * * * @retval Handle of created packet * @retval ODP_PACKET_INVALID Packet could not be created * */ -static odp_packet_t setup_udp_pkt_ref(odp_pool_t pool) +static odp_packet_t setup_udp_pkt_ref(odp_pool_t pool, + odp_pktout_config_opt_t *pktout_cfg) { odp_packet_t pkt; char *buf; @@ -302,8 +322,10 @@ static odp_packet_t setup_udp_pkt_ref(odp_pool_t pool) udp->src_port = odp_cpu_to_be_16(args->appl.srcport); udp->dst_port = odp_cpu_to_be_16(args->appl.dstport); udp->length = odp_cpu_to_be_16(args->appl.payload + ODPH_UDPHDR_LEN); - udp->chksum = 0; - udp->chksum = odph_ipv4_udp_chksum(pkt); + if (!pktout_cfg->bit.udp_chksum) { + udp->chksum = 0; + udp->chksum = odph_ipv4_udp_chksum(pkt); + } return pkt; } @@ -312,11 +334,12 @@ static odp_packet_t setup_udp_pkt_ref(odp_pool_t pool) * set up an udp packet * * @param pkt Reference UDP packet + * @param pktout_cfg Interface output configuration * * @return Success/Failed * @retval 0 on success, -1 on fail */ -static int setup_udp_pkt(odp_packet_t pkt) +static int setup_udp_pkt(odp_packet_t pkt, odp_pktout_config_opt_t *pktout_cfg) { char *buf; odph_ipv4hdr_t *ip; @@ -328,9 +351,17 @@ static int setup_udp_pkt(odp_packet_t pkt) ip = (odph_ipv4hdr_t *)(buf + ODPH_ETHHDR_LEN); seq = odp_atomic_fetch_add_u64(&counters.seq, 1) % 0xFFFF; ip->id = odp_cpu_to_be_16(seq); - ip->chksum = 0; - ip->chksum = odph_chksum(ip, ODPH_IPV4HDR_LEN); + if (!pktout_cfg->bit.ipv4_chksum) { + ip->chksum = 0; + ip->chksum = odph_chksum(ip, ODPH_IPV4HDR_LEN); + } + if (pktout_cfg->bit.ipv4_chksum || pktout_cfg->bit.udp_chksum) { + odp_packet_l2_offset_set(pkt, 0); + odp_packet_l3_offset_set(pkt, ODPH_ETHHDR_LEN); + odp_packet_l4_offset_set(pkt, ODPH_ETHHDR_LEN + + ODPH_IPV4HDR_LEN); + } return 0; } @@ -338,11 +369,13 @@ static int setup_udp_pkt(odp_packet_t pkt) * Set up an icmp packet reference * * @param pool Buffer pool to create packet in + * @param pktout_cfg Interface output configuration * * @return Handle of created packet * @retval ODP_PACKET_INVALID Packet could not be created */ -static odp_packet_t setup_icmp_pkt_ref(odp_pool_t pool) +static odp_packet_t setup_icmp_pkt_ref(odp_pool_t pool, + odp_pktout_config_opt_t *pktout_cfg) { odp_packet_t pkt; char *buf; @@ -350,6 +383,8 @@ static odp_packet_t setup_icmp_pkt_ref(odp_pool_t pool) odph_ipv4hdr_t *ip; odph_icmphdr_t *icmp; + (void)pktout_cfg; + args->appl.payload = 56; pkt = odp_packet_alloc(pool, args->appl.payload + ODPH_ICMPHDR_LEN + ODPH_IPV4HDR_LEN + ODPH_ETHHDR_LEN); @@ -393,11 +428,13 @@ static odp_packet_t setup_icmp_pkt_ref(odp_pool_t pool) * Set up an icmp packet * * @param pkt Reference ICMP packet + * @param pktout_cfg Interface output configuration * * @return Success/Failed * @retval 0 on success, -1 on fail */ -static int setup_icmp_pkt(odp_packet_t pkt) +static int setup_icmp_pkt(odp_packet_t pkt, + odp_pktout_config_opt_t *pktout_cfg) { char *buf; odph_ipv4hdr_t *ip; @@ -412,8 +449,10 @@ static int setup_icmp_pkt(odp_packet_t pkt) ip = (odph_ipv4hdr_t *)(buf + ODPH_ETHHDR_LEN); seq = odp_atomic_fetch_add_u64(&counters.seq, 1) % 0xffff; ip->id = odp_cpu_to_be_16(seq); - ip->chksum = 0; - ip->chksum = odph_chksum(ip, ODPH_IPV4HDR_LEN); + if (!pktout_cfg->bit.ipv4_chksum) { + ip->chksum = 0; + ip->chksum = odph_chksum(ip, ODPH_IPV4HDR_LEN); + } /* icmp */ icmp = (odph_icmphdr_t *)(buf + ODPH_ETHHDR_LEN + ODPH_IPV4HDR_LEN); @@ -427,6 +466,13 @@ static int setup_icmp_pkt(odp_packet_t pkt) icmp->chksum = 0; icmp->chksum = odph_chksum(icmp, args->appl.payload + ODPH_ICMPHDR_LEN); + if (pktout_cfg->bit.ipv4_chksum) { + odp_packet_l2_offset_set(pkt, 0); + odp_packet_l3_offset_set(pkt, ODPH_ETHHDR_LEN); + odp_packet_l4_offset_set(pkt, ODPH_ETHHDR_LEN + + ODPH_IPV4HDR_LEN); + } + return 0; } @@ -467,6 +513,22 @@ static int create_pktio(const char *dev, odp_pool_t pool, dev); return -1; } + odp_pktio_config_init(&itf->config); + itf->config.pktin.bit.ipv4_chksum = capa.config.pktin.bit.ipv4_chksum; + itf->config.pktin.bit.udp_chksum = capa.config.pktin.bit.udp_chksum; + itf->config.pktin.bit.drop_ipv4_err = + capa.config.pktin.bit.drop_ipv4_err; + itf->config.pktin.bit.drop_udp_err = capa.config.pktin.bit.drop_udp_err; + + itf->config.pktout.bit.ipv4_chksum = capa.config.pktout.bit.ipv4_chksum; + itf->config.pktout.bit.udp_chksum = capa.config.pktout.bit.udp_chksum; + + if (odp_pktio_config(itf->pktio, &itf->config)) { + EXAMPLE_ERR("Error: Failed to set interface configuration %s\n", + dev); + return -1; + } + if (num_rx_queues > capa.max_input_queues) num_rx_queues = capa.max_input_queues; @@ -527,17 +589,18 @@ static int gen_send_thread(void *arg) int ret = 0; thread_args_t *thr_args; odp_pktout_queue_t pktout; + odp_pktout_config_opt_t *pktout_cfg; odp_packet_t pkt_ref_array[MAX_UDP_TX_BURST]; odp_packet_t pkt_array[MAX_UDP_TX_BURST]; int pkt_array_size; int burst_start, burst_size; - odp_packet_t (*setup_pkt_ref)(odp_pool_t) = NULL; - int (*setup_pkt)(odp_packet_t) = NULL; + setup_pkt_ref_t setup_pkt_ref = NULL; + setup_pkt_t setup_pkt = NULL; thr = odp_thread_id(); thr_args = arg; - - pktout = thr_args->pktout; + pktout = thr_args->tx.pktout; + pktout_cfg = thr_args->tx.pktout_cfg; /* Create reference packets*/ if (args->appl.mode == APPL_MODE_UDP) { @@ -554,8 +617,9 @@ static int gen_send_thread(void *arg) return -1; } - if (setup_pkt_ref_array(thr_args->pool, pkt_ref_array, - pkt_array_size, setup_pkt_ref)) { + if (setup_pkt_ref_array(thr_args->pool, pktout_cfg, + pkt_ref_array, pkt_array_size, + setup_pkt_ref)) { EXAMPLE_ERR("[%02i] Error: failed to create" " reference packets\n", thr); return -1; @@ -572,7 +636,7 @@ static int gen_send_thread(void *arg) break; /* Setup TX burst*/ - if (setup_pkt_array(pkt_ref_array, pkt_array, + if (setup_pkt_array(pktout_cfg, pkt_ref_array, pkt_array, pkt_array_size, setup_pkt)) { EXAMPLE_ERR("[%02i] Error: failed to setup packets\n", thr); @@ -718,12 +782,15 @@ static void print_pkts(int thr, odp_packet_t pkt_tbl[], unsigned len) static int gen_recv_thread(void *arg) { int thr; + thread_args_t *thr_args; odp_packet_t pkts[MAX_RX_BURST], pkt; odp_event_t events[MAX_RX_BURST]; int pkt_cnt, ev_cnt, i; + interface_t *itfs, *itf; thr = odp_thread_id(); - (void)arg; + thr_args = (thread_args_t *)arg; + itfs = thr_args->rx.ifs; printf(" [%02i] created mode: RECEIVE\n", thr); odp_barrier_wait(&barrier); @@ -742,6 +809,23 @@ static int gen_recv_thread(void *arg) continue; for (i = 0, pkt_cnt = 0; i < ev_cnt; i++) { pkt = odp_packet_from_event(events[i]); + itf = &itfs[odp_pktio_index(odp_packet_input(pkt))]; + + if (odp_packet_has_ipv4(pkt)) { + if (itf->config.pktin.bit.ipv4_chksum) { + /* HW validation */ + if (odp_packet_has_l3_error(pkt)) + printf("HW detected L3 error\n"); + } /* else SW validation */ + } + + if (odp_packet_has_udp(pkt)) { + if (itf->config.pktin.bit.udp_chksum) { + /* HW validation*/ + if (odp_packet_has_l4_error(pkt)) + printf("HW detected L4 error\n"); + } /* else SW validation */ + } /* Drop packets with errors */ if (odp_unlikely(odp_packet_has_error(pkt))) { @@ -751,9 +835,11 @@ static int gen_recv_thread(void *arg) pkts[pkt_cnt++] = pkt; } - print_pkts(thr, pkts, pkt_cnt); + if (pkt_cnt) { + print_pkts(thr, pkts, pkt_cnt); - odp_packet_free_multi(pkts, pkt_cnt); + odp_packet_free_multi(pkts, pkt_cnt); + } } return 0; @@ -1008,7 +1094,8 @@ int main(int argc, char *argv[]) EXAMPLE_ERR("queue_create failed\n"); abort(); } - (void)args->thread[1].pktout; /* Not used*/ + args->thread[1].rx.ifs = ifs; + args->thread[1].rx.ifs_count = args->appl.if_count; args->thread[1].pool = pool; args->thread[1].tp = tp; args->thread[1].tq = tq; @@ -1037,7 +1124,8 @@ int main(int argc, char *argv[]) EXAMPLE_ERR("queue_create failed\n"); abort(); } - args->thread[0].pktout = ifs[0].pktout[0]; + args->thread[0].tx.pktout = ifs[0].pktout[0]; + args->thread[0].tx.pktout_cfg = &ifs[0].config.pktout; args->thread[0].pool = pool; args->thread[0].tp = tp; args->thread[0].tq = tq; @@ -1069,15 +1157,19 @@ int main(int argc, char *argv[]) int (*thr_run_func)(void *); int if_idx, pktout_idx; - if (args->appl.mode == APPL_MODE_RCV) - (void)args->thread[i].pktout; /*not used*/ - else { + if (args->appl.mode == APPL_MODE_RCV) { + args->thread[i].rx.ifs = ifs; + args->thread[i].rx.ifs_count = + args->appl.if_count; + } else { if_idx = i % args->appl.if_count; pktout_idx = (i / args->appl.if_count) % ifs[if_idx].pktout_count; - args->thread[i].pktout = + args->thread[i].tx.pktout = ifs[if_idx].pktout[pktout_idx]; + args->thread[i].tx.pktout_cfg = + &ifs[if_idx].config.pktout; } tq = odp_queue_create("", NULL); if (tq == ODP_QUEUE_INVALID) {