From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on0058.outbound.protection.outlook.com [104.47.1.58]) by dpdk.org (Postfix) with ESMTP id 2935E1BA06 for ; Tue, 10 Apr 2018 00:33:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=ckI7TTA9sUyu6OXQ6wjM4WJ3lzVGdxbtxCrXoEWMFgM=; b=p4s0u8DVnEhuQmaA2Np5ZzJm7SOa7DBJAoxwY3iF2dOTyka/P6NpWOCUX7XxKkkoJE1T2Z/Ba7I1V6GtULdfdLbdcflorgdZwWfKmSHdVvdGtzHdh919pQ/nnTJI5I+DV0kWQzg89M3yz8x275xQJ1m8mQBPq+cvrLJSVcrFZ+8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=ophirmu@mellanox.com; Received: from mellanox.com (37.142.13.130) by DB6PR0501MB2309.eurprd05.prod.outlook.com (2603:10a6:4:4c::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.653.12; Mon, 9 Apr 2018 22:33:31 +0000 From: Ophir Munk To: dev@dpdk.org, Pascal Mazon Cc: Thomas Monjalon , Olga Shern , Ophir Munk Date: Mon, 9 Apr 2018 22:33:11 +0000 Message-Id: <1523313192-18048-2-git-send-email-ophirmu@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1523313192-18048-1-git-send-email-ophirmu@mellanox.com> References: <1520629826-23055-2-git-send-email-ophirmu@mellanox.com> <1523313192-18048-1-git-send-email-ophirmu@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: DB6P190CA0010.EURP190.PROD.OUTLOOK.COM (2603:10a6:6:2f::23) To DB6PR0501MB2309.eurprd05.prod.outlook.com (2603:10a6:4:4c::20) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 0051f68d-8502-4b02-70f1-08d59e69ecd4 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:DB6PR0501MB2309; X-Microsoft-Exchange-Diagnostics: 1; DB6PR0501MB2309; 3:o+qL4axvPd4xpDpp2V0EsJXB1vDBaTiKzdGAhc2wIydJzezyDbCcrtMYASXsmrXYfHYITUzMNFbggzY6vXcbfjbs3kDtQDupFx/5IbSMChnvUGuc6ZWPitjY/MXil9GBOvk5RrNE7y5woknKngF+wUFbERB+8922YKrVv2sg/BQgjRrhpYfTjTV9KvRTLFLj8TeOyyqOC8IOgOCXsbBKO1I0ptux531EOEKl7Xl5/bNFeEDHmhlzAilDUQUx4+/F; 25:tzuKcAiVk1kht7lkIhk1awLoWys09cl+F9ae0Ey4Xl0udU0A8BozHCkeUwvjjO5q89iPLJSrQkhY1jYTbBkZhjajVe5W6l2bCAgwcnZQfJ3iFF0uYItGRizgyDWMpRRWHPhmP5ZnffoYHw3mHq7Q5hi6wAD80NDe3MbnOaxROxbVadPmJOrTWP7192AdUO4BtxN3jn0UmrKZ/ezyHokeLqkBxKMXKbhlPS/kwo2mjvdndbRLDeCT+MxEMVJSLvPpnRUv5SUfKi4Y0f0rxSf6h1/UGGz2Pu687GLN7mErOlkyLo40VqG979Q1O9WyyifN6/jogeI4JF9Uj7cHLXwNLg==; 31:CUaHSoMgs9Ru93tThZfzFqst2pjv2hPbbl/cW5rqSnZWa+HHybzgF6PEFh6c2cHnU2kBasP60ERq0Xn9bR9TqTBZFPQ7MDgdZzpBFyhvqCQF2hs42e1kFRHkh4PbDw6U/pPyth0KWHoMpTKsjcP9zhJYwXYtoxslH8CA8yx7QdAbSre9mL0InY5z1MQwjtCm3lbNn39Ga9tuEbsEkUqF/DKrq/0Y2BdJP1NXWPHqItw= X-MS-TrafficTypeDiagnostic: DB6PR0501MB2309: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; DB6PR0501MB2309; 20:WZwhXSgb1rhSnDpgBWnoYCIyvehrW52JfblWjC9wmA5i5ALoJPX/to4FeT24ThlMwm8E9RCYR34+eu4jYeS1m2OLRd9SZ5wRSagWojgWWeftzsFt4xtLSVjSkMwTjDZze5wakFh9UYc4BDEvbhRb61ZDh+BgcSW8HoJm7P6Jfmqk6XkgaxCMSC6tQpUsjx8U52R6lzkNMeo2F3aKOBEYMZELxQw9ytX90bGVrsUa75KwjbldSLymShMIvgOXsZA7em7Oxwf7uKo0CP3CwkMoAzWszhbAbRlPWVnduT3xIDiv+qxeqf2cToksN0aZ/AkZ9l7jvz2LFIeOGa+sxreNb++U1L+ZTvbxLMBmZHSpUgLtnqZe+CRBcpq32ds5thywXd3kf4i+ef+y1G+KrkqJ7A9b3Nll2qomXODJOWvKEHqMqLfMw8FcCVsQExlfWh2k3glUlBNbeKW1E7/BSUu+r1uvRWj0R9TSR7RcNDHjn1f9G06UIrfQn4zaDX/H2DLj; 4:EgwtybWiNDUfs895SxPJYeGkSzk2jcTR2bSGEGbOK/ul/jjK63440Hf+MV3jzUMdvM/zBvE3uy8ZPwoE1t24j4lcHj0lIRoxCk6sDu5TUcRPkYEgGV/fASLMOt+6fxNuamIsmFC0Mm+nczj9ADe0h7C50vxxMvXW4qiOyI+1AtjvNKU0VqBevobGglNsKVioko277zYJf3tESkytEyexTuRjKveQSMFgubYzARMky0Hk01PSSOusi8OEiJfowhwBua/SujXEdiftSTJp3rpvHg== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3002001)(10201501046)(3231221)(944501327)(52105095)(93006095)(93001095)(6055026)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(6072148)(201708071742011); SRVR:DB6PR0501MB2309; BCL:0; PCL:0; RULEID:; SRVR:DB6PR0501MB2309; X-Forefront-PRVS: 0637FCE711 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(376002)(346002)(396003)(39380400002)(39860400002)(189003)(199004)(478600001)(81156014)(33026002)(21086003)(68736007)(51416003)(81166006)(7696005)(52116002)(476003)(486006)(386003)(50466002)(11346002)(66066001)(8676002)(47776003)(55016002)(105586002)(76176011)(48376002)(59450400001)(106356001)(2906002)(53936002)(2616005)(16526019)(7736002)(956004)(86362001)(446003)(186003)(97736004)(4326008)(107886003)(305945005)(8936002)(69596002)(50226002)(5660300001)(16586007)(25786009)(6916009)(6666003)(4720700003)(316002)(54906003)(3846002)(26005)(6116002)(36756003); DIR:OUT; SFP:1101; SCL:1; SRVR:DB6PR0501MB2309; H:mellanox.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DB6PR0501MB2309; 23:MESyARHj4ZDn18FUzx34n/jIika19d9fzl9yGDn?= =?us-ascii?Q?8THUkpE5JtlECFNkqsO15HFc79clbtSfyisHpP6C7bVYhSwBNr5JsrOLqty8?= =?us-ascii?Q?KFQNWsqvJ2Xxa80/pj6ZG6iGjZFeFaVeQR4FnE87bhs5jMUSCdL7jvege2Y4?= =?us-ascii?Q?ByphtsU5Lkhwla/4zUpag2F68Hnq+4g8QaVlpnbJVXbCKPiRqPr4gdZzBWgU?= =?us-ascii?Q?oH+FBZ1feEGbTUwcASwyZDYuSLh2axjxEmIdNPnUbTUtTPYg8GqzevE3ka4x?= =?us-ascii?Q?b6n0yMnDqx5ySC061gJYWmAgE84pEPmz4rRBohCzAz2xw3R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EsEngoIcpvhgvK1M+PtOwNVC7FaT+02+M4xRoiH3zCgQaWSl4F4lGXWweV+zMwk6SrK1iVyaT91gxNSRoOvVRGhOQ4o= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DB6PR0501MB2309; 7:fAPSatg9w1JYfSi7+U7C1HE9Uz5SMZi8olJ0EtsPgc3tVxsKyZDaAyqlWZXO63HA/QIaj2shGYdSLNsosUI9qnrl2QNrNek3Z0gQiw3XomTM2JrhqBWNpYtk9uTe2MauMQeNimIvBG4c/HdWY6qnYIOpt/nySHyUb4uJIf5E5CXtuDii8dH8In+v0DepMCTZGgcFGLV4DiVFuFrmsizWhHRyw1E5je03gWIWlf0nQDkhyVa8BIDRRKBWWF75EF5Y X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Apr 2018 22:33:31.6612 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0051f68d-8502-4b02-70f1-08d59e69ecd4 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0501MB2309 Subject: [dpdk-dev] [PATCH v1 1/2] net/tap: calculate checksums of multi segs packets X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Apr 2018 22:33:34 -0000 Prior to this commit IP/UDP/TCP checksum offload calculations were skipped in case of a multi segments packet. This commit enables TAP checksum calculations for multi segments packets. The only restriction is that the first segment must contain all headers of layers 2, 3 and 4 (where layer 4 header size equals TCP header size). Signed-off-by: Ophir Munk --- drivers/net/tap/rte_eth_tap.c | 54 ++++++++++++++++++++++++++++++++----------- 1 file changed, 40 insertions(+), 14 deletions(-) diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c index 61d6465..df23c4d 100644 --- a/drivers/net/tap/rte_eth_tap.c +++ b/drivers/net/tap/rte_eth_tap.c @@ -509,6 +509,10 @@ pmd_tx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) char m_copy[mbuf->data_len]; int n; int j; + int k; /* first index in iovecs for copying segments */ + uint16_t l234_len; /* length of layers 2,3,4 headers */ + uint16_t seg_len; /* length of first segment */ + uint16_t nb_segs; /* stats.errs will be incremented */ if (rte_pktmbuf_pkt_len(mbuf) > max_size) @@ -529,30 +533,52 @@ pmd_tx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) if (j & (0x40 | 0x60)) pi.proto = (j == 0x40) ? 0x0008 : 0xdd86; - iovecs[0].iov_base = π - iovecs[0].iov_len = sizeof(pi); - for (j = 1; j <= mbuf->nb_segs; j++) { - iovecs[j].iov_len = rte_pktmbuf_data_len(seg); - iovecs[j].iov_base = - rte_pktmbuf_mtod(seg, void *); - seg = seg->next; - } + k = 0; + iovecs[k].iov_base = π + iovecs[k].iov_len = sizeof(pi); + k++; + nb_segs = mbuf->nb_segs; if (txq->csum && ((mbuf->ol_flags & (PKT_TX_IP_CKSUM | PKT_TX_IPV4) || (mbuf->ol_flags & PKT_TX_L4_MASK) == PKT_TX_UDP_CKSUM || (mbuf->ol_flags & PKT_TX_L4_MASK) == PKT_TX_TCP_CKSUM))) { - /* Support only packets with all data in the same seg */ - if (mbuf->nb_segs > 1) + /* Support only packets with at least layer 4 + * header included in the first segment + */ + seg_len = rte_pktmbuf_data_len(mbuf); + l234_len = mbuf->l2_len + mbuf->l3_len + + sizeof(struct tcp_hdr); + if (seg_len < l234_len) break; - /* To change checksums, work on a copy of data. */ + + /* To change checksums, work on a + * copy of l2, l3 l4 headers. + */ rte_memcpy(m_copy, rte_pktmbuf_mtod(mbuf, void *), - rte_pktmbuf_data_len(mbuf)); + l234_len); tap_tx_offload(m_copy, mbuf->ol_flags, mbuf->l2_len, mbuf->l3_len); - iovecs[1].iov_base = m_copy; + iovecs[k].iov_base = m_copy; + iovecs[k].iov_len = l234_len; + k++; + /* Update next iovecs[] beyond l2, l3, l4 headers */ + if (seg_len > l234_len) { + iovecs[k].iov_len = seg_len - l234_len; + iovecs[k].iov_base = + rte_pktmbuf_mtod(seg, char *) + + l234_len; + k++; + } + nb_segs--; + seg = seg->next; + } + for (j = k; j <= nb_segs; j++) { + iovecs[j].iov_len = rte_pktmbuf_data_len(seg); + iovecs[j].iov_base = rte_pktmbuf_mtod(seg, void *); + seg = seg->next; } /* copy the tx frame data */ - n = writev(txq->fd, iovecs, mbuf->nb_segs + 1); + n = writev(txq->fd, iovecs, j); if (n <= 0) break; -- 2.7.4