From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-cys01nam02on0076.outbound.protection.outlook.com [104.47.37.76]) by dpdk.org (Postfix) with ESMTP id CFC69107A for ; Thu, 28 Sep 2017 14:20:18 +0200 (CEST) Received: from BN6PR03CA0050.namprd03.prod.outlook.com (2603:10b6:404:4c::12) by SN2PR03MB2367.namprd03.prod.outlook.com (2603:10b6:804:e::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.77.7; Thu, 28 Sep 2017 12:20:17 +0000 Received: from BL2FFO11FD036.protection.gbl (2a01:111:f400:7c09::136) by BN6PR03CA0050.outlook.office365.com (2603:10b6:404:4c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.56.8 via Frontend Transport; Thu, 28 Sep 2017 12:20:17 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BL2FFO11FD036.mail.protection.outlook.com (10.173.161.132) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.56.11 via Frontend Transport; Thu, 28 Sep 2017 12:20:17 +0000 Received: from Tophie.ap.freescale.net ([10.232.14.39]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id v8SCJ72T008785; Thu, 28 Sep 2017 05:20:15 -0700 From: Shreyansh Jain To: CC: , Date: Thu, 28 Sep 2017 17:59:56 +0530 Message-ID: <20170928123000.1711-37-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170928123000.1711-1-shreyansh.jain@nxp.com> References: <20170928113344.12248-1-shreyansh.jain@nxp.com> <20170928123000.1711-1-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131510748172228249; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7966004)(336005)(346002)(39380400002)(376002)(39860400002)(2980300002)(1109001)(1110001)(339900001)(189002)(199003)(54906003)(2950100002)(97736004)(1076002)(2906002)(305945005)(77096006)(48376002)(50466002)(356003)(8656003)(105606002)(2351001)(4326008)(36756003)(5660300001)(106466001)(498600001)(47776003)(85426001)(6916009)(76176999)(33646002)(6666003)(81166006)(8936002)(8676002)(81156014)(5003940100001)(104016004)(50986999)(68736007)(316002)(53936002)(50226002)(189998001)(86362001)(16586007); DIR:OUT; SFP:1101; SCL:1; SRVR:SN2PR03MB2367; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD036; 1:Q8vq72O+kGqsmHzh+cnl5t9vodVsnH8qPMxANtUtbYU03uxSsa3iMa/9dBwPo+Tj63Mt2DLzG6Zwb0u2wnsXLEMSUNinbY8Olb4ell+kVkxeXMPUVD+rjA4uCHEKIFw1 MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 60280c9b-40a0-4dc2-9699-08d5066b476a X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017052603199)(201703131430075)(201703131517081); SRVR:SN2PR03MB2367; X-Microsoft-Exchange-Diagnostics: 1; SN2PR03MB2367; 3:q7+H7r5clUoVj4IPI4gMrZYDSd/OjfNpSkxtXiS7zOFhmty+SYsd8mkTqPMxkCLeScwxaa2K5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FiTXrHQ6sFLBCRrogh6lYYsU81sQRcMa4FmCkfzgJlWKO+rxwK6mPP1cPaQTGceoP3N3x+m7gWenc7gjA20ItdFzXYHUfiFhwwxb+EB3alotAzfkE6AApLAWnGH90feX4YyJ+FgbtuMEO85vPK1/2NgH2oHqt/KWMbe/g= X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6095135)(2401047)(8121501046)(5005006)(10201501046)(3002001)(93006095)(93001095)(100000703101)(100105400095)(6055026)(6096035)(20161123556025)(20161123561025)(20161123563025)(20161123559100)(201703131430075)(201703131433075)(201703131441075)(201703131448075)(201703161259150)(20161123565025)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:SN2PR03MB2367; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(400006)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:SN2PR03MB2367; X-Forefront-PRVS: 0444EB1997 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; SN2PR03MB2367; 23:cYoHNI3GojR0ey3ET3lihPQ+qzHDc0dHJxEIPRQie?= =?us-ascii?Q?Frd/x0xEAMBZmBSbWS0u3tsVKWS5fi6Fr6BlZV0+HSgV1GAUBZ1sXmuPqTHQ?= =?us-ascii?Q?Fd6Mm33UvmSJet1eSM/01QevrjQLMR9ZbNcPSN68HxavfL7s5pFh2NLS/2U6?= =?us-ascii?Q?rMIE7FJeQdljXqC+RzY/FkOTUmTSzwdE8nOFPk23DpbV8b1hpBHZWpaa+UfE?= =?us-ascii?Q?Qf3Btp8NZovCKXQGlKohvC7p/UPNiVvwCLEeCPu+z9OVBzNZehSOWpyvQreL?= =?us-ascii?Q?KyDFW/3lq10KVl5vCbbkmzQ8fEC9r1yrxkux0p+4Q4wjLLYe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DhHeETqWH?= X-Microsoft-Exchange-Diagnostics: 1; SN2PR03MB2367; 6:x/zoQILOu+FFNWGlS/iXYkV32vy8E1hnKfJi54tencEg8B9a+nNFOWi8Y359V30IeLrusgmqWeVMCsKV2q8O15DumLPqW+ngZyHY5f29M5ZqYYxbqe+KCSY9VRDnjz1ATQGXX3eo6ZMIATCEQL096MBFLQuEjlQdHi4at5sb/0N7y7kjf0wzGuAjrb9BQmpp8oosZq5wTidjauK5p1TnSznrOxu8157IDTgMdbOy0bR180auCGyUpO60UHOi//rsqEHyTv0H/MRDHwVNHEX1M/yXsnRsUp2nzIoqvKJS+8/7bAFRK4pSi5Q4cwfDysVCknHlp9DE8RcVH+cBzSAWNQ==; 5:bs4VYyMXM6HzkCg1ES8IVkEQ+y4mUaMhxU/P9+jYPzqc+1LR7znY8GCUIZ6XbGAsmo0KdXT3znslT0iJpGjQVyxk0yG/+6FhzsEMPS+pmVwfcc+XofPn74Mk5YqecLnWez2sq3g52deU7ZNz0yHF3Q==; 24:LAktkS+ZfuFCN6KDGbGHTMb69OGS9pwvv66K9+GCDYPxlJJgoUSybXcfQpHr6C56IPj8OfeYnBD6FdjNRkL4LkAOEkEl7C5pHcfmHBxrrFY=; 7:KDQL5X2w2BLPczw9hzsevEMkWUJiwWB3Sn3xWPeYh8/lxe9rx9v/B8JgJtTiKcQtDGKxfWBDj/TMRe3JI/fZsZBWCFdYkBdl836H4J7mRaIP5PD4zq0TqdaH7GF7RKxju7g5p8FJcl7Rvl8Fs3aRHM74b0sMS1V2aByp+4uF78yVCAkxKz9VhwQ3AZ+ewNHTSSbPY+5BpBuGidGRD/MSFGwv42Drr060Nw0+cJey+IU= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2017 12:20:17.0668 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR03MB2367 Subject: [dpdk-dev] [PATCH v6 36/40] net/dpaa: support checksum offload 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: Thu, 28 Sep 2017 12:20:19 -0000 Signed-off-by: Hemant Agrawal Signed-off-by: Shreyansh Jain --- doc/guides/nics/features/dpaa.ini | 2 + drivers/net/dpaa/dpaa_ethdev.c | 4 ++ drivers/net/dpaa/dpaa_rxtx.c | 89 +++++++++++++++++++++++++++++++++++++++ drivers/net/dpaa/dpaa_rxtx.h | 23 +++++++++- 4 files changed, 117 insertions(+), 1 deletion(-) diff --git a/doc/guides/nics/features/dpaa.ini b/doc/guides/nics/features/dpaa.ini index 2ef1b56..23626c0 100644 --- a/doc/guides/nics/features/dpaa.ini +++ b/doc/guides/nics/features/dpaa.ini @@ -13,6 +13,8 @@ Allmulticast mode = Y Unicast MAC filter = Y RSS hash = Y Flow control = Y +L3 checksum offload = Y +L4 checksum offload = Y Packet type parsing = Y Basic stats = Y ARMv8 = Y diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c index 8ee00ed..12dcc68 100644 --- a/drivers/net/dpaa/dpaa_ethdev.c +++ b/drivers/net/dpaa/dpaa_ethdev.c @@ -186,6 +186,10 @@ static void dpaa_eth_dev_info(struct rte_eth_dev *dev, (DEV_RX_OFFLOAD_IPV4_CKSUM | DEV_RX_OFFLOAD_UDP_CKSUM | DEV_RX_OFFLOAD_TCP_CKSUM); + dev_info->tx_offload_capa = + (DEV_TX_OFFLOAD_IPV4_CKSUM | + DEV_TX_OFFLOAD_UDP_CKSUM | + DEV_TX_OFFLOAD_TCP_CKSUM); } static int dpaa_eth_link_update(struct rte_eth_dev *dev, diff --git a/drivers/net/dpaa/dpaa_rxtx.c b/drivers/net/dpaa/dpaa_rxtx.c index f8ac711..976268b 100644 --- a/drivers/net/dpaa/dpaa_rxtx.c +++ b/drivers/net/dpaa/dpaa_rxtx.c @@ -200,6 +200,82 @@ static inline void dpaa_eth_packet_info(struct rte_mbuf *m, /* Packet received without stripping the vlan */ } +static inline void dpaa_checksum(struct rte_mbuf *mbuf) +{ + struct ether_hdr *eth_hdr = rte_pktmbuf_mtod(mbuf, struct ether_hdr *); + char *l3_hdr = (char *)eth_hdr + mbuf->l2_len; + struct ipv4_hdr *ipv4_hdr = (struct ipv4_hdr *)l3_hdr; + struct ipv6_hdr *ipv6_hdr = (struct ipv6_hdr *)l3_hdr; + + DPAA_DP_LOG(DEBUG, "Calculating checksum for mbuf: %p", mbuf); + + if (((mbuf->packet_type & RTE_PTYPE_L3_MASK) == RTE_PTYPE_L3_IPV4) || + ((mbuf->packet_type & RTE_PTYPE_L3_MASK) == + RTE_PTYPE_L3_IPV4_EXT)) { + ipv4_hdr = (struct ipv4_hdr *)l3_hdr; + ipv4_hdr->hdr_checksum = 0; + ipv4_hdr->hdr_checksum = rte_ipv4_cksum(ipv4_hdr); + } else if (((mbuf->packet_type & RTE_PTYPE_L3_MASK) == + RTE_PTYPE_L3_IPV6) || + ((mbuf->packet_type & RTE_PTYPE_L3_MASK) == + RTE_PTYPE_L3_IPV6_EXT)) + ipv6_hdr = (struct ipv6_hdr *)l3_hdr; + + if ((mbuf->packet_type & RTE_PTYPE_L4_MASK) == RTE_PTYPE_L4_TCP) { + struct tcp_hdr *tcp_hdr = (struct tcp_hdr *)(l3_hdr + + mbuf->l3_len); + tcp_hdr->cksum = 0; + if (eth_hdr->ether_type == htons(ETHER_TYPE_IPv4)) + tcp_hdr->cksum = rte_ipv4_udptcp_cksum(ipv4_hdr, + tcp_hdr); + else /* assume ethertype == ETHER_TYPE_IPv6 */ + tcp_hdr->cksum = rte_ipv6_udptcp_cksum(ipv6_hdr, + tcp_hdr); + } else if ((mbuf->packet_type & RTE_PTYPE_L4_MASK) == + RTE_PTYPE_L4_UDP) { + struct udp_hdr *udp_hdr = (struct udp_hdr *)(l3_hdr + + mbuf->l3_len); + udp_hdr->dgram_cksum = 0; + if (eth_hdr->ether_type == htons(ETHER_TYPE_IPv4)) + udp_hdr->dgram_cksum = rte_ipv4_udptcp_cksum(ipv4_hdr, + udp_hdr); + else /* assume ethertype == ETHER_TYPE_IPv6 */ + udp_hdr->dgram_cksum = rte_ipv6_udptcp_cksum(ipv6_hdr, + udp_hdr); + } +} + +static inline void dpaa_checksum_offload(struct rte_mbuf *mbuf, + struct qm_fd *fd, char *prs_buf) +{ + struct dpaa_eth_parse_results_t *prs; + + DPAA_DP_LOG(DEBUG, " Offloading checksum for mbuf: %p", mbuf); + + prs = GET_TX_PRS(prs_buf); + prs->l3r = 0; + prs->l4r = 0; + if (((mbuf->packet_type & RTE_PTYPE_L3_MASK) == RTE_PTYPE_L3_IPV4) || + ((mbuf->packet_type & RTE_PTYPE_L3_MASK) == + RTE_PTYPE_L3_IPV4_EXT)) + prs->l3r = DPAA_L3_PARSE_RESULT_IPV4; + else if (((mbuf->packet_type & RTE_PTYPE_L3_MASK) == + RTE_PTYPE_L3_IPV6) || + ((mbuf->packet_type & RTE_PTYPE_L3_MASK) == + RTE_PTYPE_L3_IPV6_EXT)) + prs->l3r = DPAA_L3_PARSE_RESULT_IPV6; + + if ((mbuf->packet_type & RTE_PTYPE_L4_MASK) == RTE_PTYPE_L4_TCP) + prs->l4r = DPAA_L4_PARSE_RESULT_TCP; + else if ((mbuf->packet_type & RTE_PTYPE_L4_MASK) == RTE_PTYPE_L4_UDP) + prs->l4r = DPAA_L4_PARSE_RESULT_UDP; + + prs->ip_off[0] = mbuf->l2_len; + prs->l4_off = mbuf->l3_len + mbuf->l2_len; + /* Enable L3 (and L4, if TCP or UDP) HW checksum*/ + fd->cmd = DPAA_FD_CMD_RPD | DPAA_FD_CMD_DTC; +} + static inline struct rte_mbuf *dpaa_eth_fd_to_mbuf(struct qm_fd *fd, uint32_t ifid) { @@ -358,6 +434,19 @@ tx_on_dpaa_pool_unsegmented(struct rte_mbuf *mbuf, } rte_pktmbuf_free(mbuf); } + + if (mbuf->ol_flags & DPAA_TX_CKSUM_OFFLOAD_MASK) { + if (mbuf->data_off < (DEFAULT_TX_ICEOF + + sizeof(struct dpaa_eth_parse_results_t))) { + DPAA_DP_LOG(DEBUG, "Checksum offload Err: " + "Not enough Headroom " + "space for correct Checksum offload." + "So Calculating checksum in Software."); + dpaa_checksum(mbuf); + } else { + dpaa_checksum_offload(mbuf, fd_arr, mbuf->buf_addr); + } + } } /* Handle all mbufs on dpaa BMAN managed pool */ diff --git a/drivers/net/dpaa/dpaa_rxtx.h b/drivers/net/dpaa/dpaa_rxtx.h index 68d2c41..d10298e 100644 --- a/drivers/net/dpaa/dpaa_rxtx.h +++ b/drivers/net/dpaa/dpaa_rxtx.h @@ -41,6 +41,22 @@ /* IC offsets from buffer header address */ #define DEFAULT_RX_ICEOF 16 +#define DEFAULT_TX_ICEOF 16 + +/* + * Values for the L3R field of the FM Parse Results + */ +/* L3 Type field: First IP Present IPv4 */ +#define DPAA_L3_PARSE_RESULT_IPV4 0x80 +/* L3 Type field: First IP Present IPv6 */ +#define DPAA_L3_PARSE_RESULT_IPV6 0x40 +/* Values for the L4R field of the FM Parse Results + * See $8.8.4.7.20 - L4 HXS - L4 Results from DPAA-Rev2 Reference Manual. + */ +/* L4 Type field: UDP */ +#define DPAA_L4_PARSE_RESULT_UDP 0x40 +/* L4 Type field: TCP */ +#define DPAA_L4_PARSE_RESULT_TCP 0x20 #define DPAA_MAX_DEQUEUE_NUM_FRAMES 63 /**