From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on0047.outbound.protection.outlook.com [104.47.1.47]) by dpdk.org (Postfix) with ESMTP id 01D2E56A1 for ; Fri, 9 Mar 2018 22:10:50 +0100 (CET) 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=kc3eB/JLCsc8XnrkiptpRyKvoI7t/QlfV8nflRokZDs=; b=FG1m8cmfpkjsLfPjo/NGcKoNJErl2CkfsyJxw3XMveS2wkyfeeDw4kmWSu1U/pxXu2tKmslx+fLUlJQCKl0PkphOoKKP2qGlfOOX15kwzoPSkKR4yuluPceDtB3VlrPUBP8vm/twLiHsKfvOEfb7u/CUZ9pYLcSwoGblFx7u5sk= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=ophirmu@mellanox.com; Received: from mellanox.com (37.142.13.130) by HE1PR0502MB3883.eurprd05.prod.outlook.com (2603:10a6:7:87::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.548.13; Fri, 9 Mar 2018 21:10:48 +0000 From: Ophir Munk To: dev@dpdk.org, Pascal Mazon Cc: Thomas Monjalon , Olga Shern , Ophir Munk Date: Fri, 9 Mar 2018 21:10:25 +0000 Message-Id: <1520629826-23055-2-git-send-email-ophirmu@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1520629826-23055-1-git-send-email-ophirmu@mellanox.com> References: <1520629826-23055-1-git-send-email-ophirmu@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: VI1PR07CA0199.eurprd07.prod.outlook.com (2603:10a6:802:3f::23) To HE1PR0502MB3883.eurprd05.prod.outlook.com (2603:10a6:7:87::26) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 544c3a2b-49f0-413b-222d-08d586023bd9 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020); SRVR:HE1PR0502MB3883; X-Microsoft-Exchange-Diagnostics: 1; HE1PR0502MB3883; 3:nCWIWBVVcynK7JzUmOkvlGTanV0oGrQA3xRUC8JjH9ERRH76ZSf2pEkJw/QT6B/2kqjYu6TjGYk1WRhmpUtULQkAt5dr/N73075O6IAL4NVJzHbgnVSivZmbF/T9NQEr784Qha4X/HKwxX5Gdpe0lOLIuq8if+NPdHLgB1PR7NTiqHc/bhjVNuHVm5YgkyYmXA1IjjjNegn3b8EgvmDr1xzNXF3FNPJzTrDc1SEf0GvfBd9NfauER+yLqvUEyQEX; 25:brFkqKWrErqFjeR+sTsCx4pA9XNyGzsfXgulQ+Og8XGPWoVpgizHX0whioHCoCrI8EXlHA54LV1I12kp/YzIqHYlknNUsF881V6XAOCCvf8KTZiuTpD8TRfgNdmmmvALodCttswAOyeHfynTFpuO7ksvCHQFk0hbfRhnfnPzU1TXCDH+BcR0Urr11eAEROFpkrwUyZ1THRtElnBTMORDfntQakyzkibU2Z3/XY8zp05+bwS82mgx5ZlITa7aKcLfUurZD6ppKTUgKBKojdjpmYLCPPhmw01GgTAL1WblLjqk0zfS8z0F+o0kJ6jgBRZmD/khchYiqpfJqx/3GwYh6w==; 31:E+w+ezuSbcjxL0No2TdBtvIsJgAlHiPENpOX10xPzpKWKXkBrNpCXUcZB7eI5JjoO4rlAhAKUJ4KM+4rTMyaaDzKmZbM44AmhkBEetgnmg0A1FLVpGq4hxZaT0CcoFDR9IHSwUCXbypr0VWOoOHGaINRVvTOGJ1PqEOJ7JPJ5LItTFtO/oIt8gh5wGNN66uypdzk+pZtgmsF/brobOq/D1MnN2bEKf4xs4R2qrb9TgM= X-MS-TrafficTypeDiagnostic: HE1PR0502MB3883: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; HE1PR0502MB3883; 20:YduXFTiq8ZNHQElpjNWYKo7WpTOm4iHn+cALnt78WWNQ6ur0hXGZeex4LKYbksXhlZnD8teWAnGhg7TWxuyWVqTmtsEERBUFRcG0vpepuVMRrc7DpRyjuFPHKWaLx59jr9WirwuQjGXRI6fcdIsE5aP94CZl+nd6R16ylA2zeQVH4A+K4lGaO79deeUiZ3lUDiLAI1jVaHWQW/DUOi6jFGzRN0CLdrO7W8FppsIgYr00ylVLPlZQQlXq/af/5xp3Yk2w/Q58BtwtFuLnyJitufSdsUZdOrbW3lPGSWS6fNWh6Cu8iTV1Oycj/sFtg1JrZMdGLaXye3tmPMQ+Br9OWXPI7m1Fn8pu+UQSR5kxzVoWnsVN/TNOvfDrBNPY6LRQPniOAfvZ16UKnYfrKmIJb38TMwv8DUPtiSSM9q4kuSBefWBVzzvptp8Lg993PCDfpQfD4pwnS5rir+K52Ppxu7JUftrQyzvZqbXbQUlNWAhD0f+YjwV3Q3hWfOyakz53; 4:l6RA08ZI4mKDM3Zv/0DGzhF1QZyPVpMZkO7XxcHzu6R7VELLCOK9dnjF5f1veGmTuRzE0Pu2mbfFsuXh7ZRCb+dkMJlNH0ZGH+8U3YJMlh/2Tg5nxFJHTxo6rvyUzVKhKH4S1kPL0Y+SvzDM6n8CZFEy6oO0DRhh2gfGGNpwFCa5aNo4Dx49DOr5JgtdGR3IMUhLbLWlEXKel2D/S2qKVVlxy/RhDY1NgrCUlrjf6w9VuM0d6ugVXaPf4LPEzPbTN3ncx/YLdBXC3Ue4xwVd4g== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(10201501046)(3002001)(93006095)(93001095)(3231220)(944501244)(52105095)(6055026)(6041310)(20161123560045)(20161123558120)(20161123564045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:HE1PR0502MB3883; BCL:0; PCL:0; RULEID:; SRVR:HE1PR0502MB3883; X-Forefront-PRVS: 0606BBEB39 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39860400002)(366004)(376002)(396003)(346002)(39380400002)(189003)(199004)(7736002)(4326008)(16586007)(3846002)(25786009)(50226002)(106356001)(21086003)(2906002)(36756003)(86362001)(575784001)(48376002)(16526019)(186003)(54906003)(50466002)(5660300001)(6116002)(53936002)(6666003)(478600001)(26005)(2950100002)(6916009)(68736007)(97736004)(305945005)(105586002)(107886003)(66066001)(81156014)(4720700003)(8676002)(52116002)(7696005)(51416003)(81166006)(76176011)(47776003)(386003)(316002)(69596002)(8936002)(55016002)(33026002); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR0502MB3883; H:mellanox.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HE1PR0502MB3883; 23:BSoi0oULFaAB1+LFOktZPCUvXMvZJXsvK2YtMsQ?= =?us-ascii?Q?JvnmTEe81JrYs3XG4CwI3aPKE95oQd9ejCUVDmVzPzCgtsBHYAFrQi1llwzn?= =?us-ascii?Q?UVNajmWB1GOgsfKhehjy6CeohFI+/mnNUQz6exdx3+3KWvUd2WMuQRQI133Q?= =?us-ascii?Q?VIv1cL9Rj5kYH81w+NSTQNgsHq8AG7Pc2SZq+HpsaPL5ZJjLtv5CFTk5N/mh?= =?us-ascii?Q?/St2TTiLZ177noJYf5XzaphWh0Ru0fhcsi/P6jla5KnSv0LxuVKcA+Ftvavu?= =?us-ascii?Q?RaWSpAYyxF8v+b3HIkf3FRy+9icyLfm8Oiy3r7tndFiVIqXrkAsXvP6e9Svo?= =?us-ascii?Q?lnPF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Ljq+aubvlLb2NlNP6Qk9swpsDi0pa9AK59np55YvUh0x5iyIdM98Hj6okbPuDqLcfRLCXZ0tC2kFYZYPRHUwQVhtTxxUnR86VsgdTXC7mlB5KAP80W3R+Q4HdER3lgUHCBX0WIY+U SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Mar 2018 21:10:48.4154 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 544c3a2b-49f0-413b-222d-08d586023bd9 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0502MB3883 Subject: [dpdk-dev] [RFC 1/2] net/tap: calculate checksum for 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: Fri, 09 Mar 2018 21:10:51 -0000 In past TAP implementation checksum offload calculations (for IP/UDP/TCP) were skipped in case of a multi segments packet. This commit improves TAP functionality by enabling checksum calculations in multi segments cases. The only restriction now is that the first segment must contain all headers of layers 2, 3 and 4 (where layer 4 header size is taken as that of TCP). Signed-off-by: Ophir Munk --- drivers/net/tap/rte_eth_tap.c | 42 ++++++++++++++++++++++++++++++++---------- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c index f09db0e..f312084 100644 --- a/drivers/net/tap/rte_eth_tap.c +++ b/drivers/net/tap/rte_eth_tap.c @@ -496,6 +496,9 @@ 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 */ /* stats.errs will be incremented */ if (rte_pktmbuf_pkt_len(mbuf) > max_size) @@ -503,25 +506,44 @@ pmd_tx_burst(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) 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 = 1; 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) + /* Only support 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[1].iov_len = l234_len; + k++; + /* Adjust data pointer beyond l2, l3, l4 headers. + * If this segment becomes empty - skip it + */ + if (seg_len > l234_len) { + rte_pktmbuf_adj(mbuf, l234_len); + } else { + seg = seg->next; + mbuf->nb_segs--; + } + } + for (j = k; 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; } /* copy the tx frame data */ n = writev(txq->fd, iovecs, mbuf->nb_segs + 1); -- 2.7.4