From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0085.outbound.protection.outlook.com [104.47.42.85]) by dpdk.org (Postfix) with ESMTP id AC3761B1F3 for ; Thu, 28 Sep 2017 13:24:18 +0200 (CEST) Received: from BN6PR03CA0078.namprd03.prod.outlook.com (10.164.122.144) by MWHPR03MB2701.namprd03.prod.outlook.com (10.168.207.135) 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 11:24:16 +0000 Received: from BN1AFFO11FD025.protection.gbl (2a01:111:f400:7c10::191) by BN6PR03CA0078.outlook.office365.com (2603:10b6:405:6f::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.56.11 via Frontend Transport; Thu, 28 Sep 2017 11:24:15 +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 BN1AFFO11FD025.mail.protection.outlook.com (10.58.52.85) 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 11:24:15 +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 v8SBMpGC016035; Thu, 28 Sep 2017 04:24:13 -0700 From: Shreyansh Jain To: CC: , Date: Thu, 28 Sep 2017 17:03:40 +0530 Message-ID: <20170928113344.12248-37-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170928113344.12248-1-shreyansh.jain@nxp.com> References: <20170909112132.13936-1-shreyansh.jain@nxp.com> <20170928113344.12248-1-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131510714555098629; (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)(336005)(7966004)(39380400002)(346002)(39860400002)(376002)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(77096006)(575784001)(50466002)(16586007)(48376002)(2351001)(106466001)(498600001)(105606002)(85426001)(86362001)(316002)(6666003)(8656003)(2906002)(104016004)(97736004)(1076002)(36756003)(189998001)(5660300001)(54906003)(305945005)(68736007)(8936002)(4326008)(53936002)(2950100002)(50226002)(50986999)(6916009)(81156014)(76176999)(8676002)(356003)(81166006)(33646002)(5003940100001)(47776003); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR03MB2701; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD025; 1:FRQjCqEsviYZVsplfRc+08JnP5qceOsqkeQrkJptytbr+dz+9F/kk+xAIR1D8CX1tgD0Hg6+TBcQbduxgO0u+wHfzfnLjwXXyviyjLAPkwyrXodBmWwfpFfLzdqnPDEG MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 198c0a61-ce9e-48cc-84a4-08d5066373ab X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017052603199)(201703131430075)(201703131517081); SRVR:MWHPR03MB2701; X-Microsoft-Exchange-Diagnostics: 1; MWHPR03MB2701; 3:sVMlSVJ9jXiD1rv/BQk8K34D599hvqUTl9UFOjAqUwpKnizJ9ldS+spa9QgpojfLVd2h3JHoc92OCF4YNmPW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FNhe+1vu6oQG6w32nVqigDSECi7yTrr5+7EoWC8wGmVU/zJJCVJKTADKs+wOymmcgDpM3saIgibKX7HEUlWUBfgGoomfeQ/+6xVnxLpnBUKr4Ji85i2gRdv3STdQUh8OI6lUOh/V7L1/Ci/JcuLMwv5bx0GSI0iOJrWy2MEmgiQ= 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)(5005006)(8121501046)(100000703101)(100105400095)(93006095)(93001095)(10201501046)(3002001)(6055026)(6096035)(201703131430075)(201703131441075)(201703131448075)(201703131433075)(201703161259150)(20161123559100)(20161123561025)(20161123563025)(20161123556025)(20161123565025)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:MWHPR03MB2701; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(400006)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:MWHPR03MB2701; X-Forefront-PRVS: 0444EB1997 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; MWHPR03MB2701; 23:7ESFj6F0YEJh8u5oD4fdCsH6qzF16nToxHnWW4kqQ?= =?us-ascii?Q?tuP1puhQcK8UTJjRaSqA84dkZ4x1CHZL4XnDjr7QwRhD43b0jdcW1yhZalNk?= =?us-ascii?Q?O5uTqpjNqGMO+wGvW9SUEgQQHlwp4tgYiHG1hx63ECG4FC5o/86g8khhKX6a?= =?us-ascii?Q?5BL9qt1Oqtp+5oiTdE0wD5iLbxqO+6l+wi8QhSg0ptlGx9a076EwqqDdnhBK?= =?us-ascii?Q?ptDyEAGaxRL1oRWXW6arPfV88kT5tmsXxXFF0kliBN7oyFe/85x2qEJpTNcc?= =?us-ascii?Q?wH1Z467CIkAzjLkKInWJISaUsqzRbAbYTqs97krX8jsKESlG9v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t1wlOslMkgxAvVEiDfRTy6SP0JOf6JRVMRVewCNJX2w=3D?= =?us-ascii?Q?=3D?= X-Microsoft-Exchange-Diagnostics: 1; MWHPR03MB2701; 6:KVB51qNS1LCTonzkI8mDDkc1x78GPwt7Ri36FCNSjx8eIElZBHWaK99bpKlYlJej57yEbXy4AKkvH0/mKbEcWiNNEQzrlTi0tAlfOgXnc3cAoL1FWlXyWPLbChYhfvpKMVB2QoASEq4X3K/6vo+ZN6hWUnQ6LRuKL4Mx7ZZHPUqwycH8w++L3w8YY8+2BRJ5zmth2X+v0ylVlXpYSo9bbSteGHo3+Ic8s9eTJk9HKD1x5GBEo2ty8zLsvPa9ZQVbQV8T4zrWr7KVC000XBKihwniIvtE1h/uQcmN3GhAGv9m9yEVsnwnYg9acnMOOvxeBLtsXxL0ZyDOE8lnV3BjDg==; 5:9Yb4vJ/PX/dsJoS1LMl8ZZW/AaObauXDrswkXb4bK4na6q5nZrm3Q9/WYGMPDg/gRMolbjDI7g7axykhxc3xR3Jh+Ex5ITwp6eHaV3qWwDu88znydsuyE0UZhTAyYe7PXSn52V71WIaeBX5zg5wYVA==; 24:tXm1I+I/9Twt7ICF216Q2lmRwiKfKg5IQz2nbNagXe7wR9/clJlp2FfPKitLzEJ3USOhURE3ssrW5mx2XfqblfgOO0Md0nZ8YnDad8Ca1Og=; 7:dWCn6oNatzQ491BwsTc74n5P1UuNEA9g9lEKdYVl0A7mIcsPCyFjAdTZS+g1mShtTOrw1sF0Zqi/t1E3t+JFHZze8blOke0Vb5s/sUyqqXNz1yUrZbrRT+baAxarKROhLifkTIVDU2eB7ff2xUAjViYQ2lbrfuofi8Q8LrtU0HhRPqbsKklc4WPEF2byKp51GxhvG1L75QNrmZf8mMMt93y+wdU7RCbx9iboHqBbyBQ= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2017 11:24:15.2758 (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: MWHPR03MB2701 Subject: [dpdk-dev] [PATCH v5 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 11:24: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 cf2c0c7..4eb9b62 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 /**