From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0087.outbound.protection.outlook.com [104.47.34.87]) by dpdk.org (Postfix) with ESMTP id 44FF258CD for ; Sat, 9 Sep 2017 13:11:43 +0200 (CEST) Received: from BN6PR03CA0058.namprd03.prod.outlook.com (10.173.137.20) by CY1PR03MB2266.namprd03.prod.outlook.com (10.166.207.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.13.10; Sat, 9 Sep 2017 11:11:41 +0000 Received: from BY2FFO11FD005.protection.gbl (2a01:111:f400:7c0c::177) by BN6PR03CA0058.outlook.office365.com (2603:10b6:404:4c::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.35.12 via Frontend Transport; Sat, 9 Sep 2017 11:11:41 +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 BY2FFO11FD005.mail.protection.outlook.com (10.1.14.126) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.13.11 via Frontend Transport; Sat, 9 Sep 2017 11:11:41 +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 v89BAUhb026326; Sat, 9 Sep 2017 04:11:39 -0700 From: Shreyansh Jain To: CC: , Date: Sat, 9 Sep 2017 16:51:28 +0530 Message-ID: <20170909112132.13936-38-shreyansh.jain@nxp.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170909112132.13936-1-shreyansh.jain@nxp.com> References: <20170823141213.25476-1-shreyansh.jain@nxp.com> <20170909112132.13936-1-shreyansh.jain@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131494291014541335; (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)(39860400002)(39380400002)(2980300002)(1110001)(1109001)(339900001)(189002)(199003)(48376002)(50466002)(33646002)(5003940100001)(5660300001)(68736007)(189998001)(106466001)(2351001)(105606002)(36756003)(47776003)(498600001)(77096006)(1076002)(6916009)(97736004)(2950100002)(6666003)(81156014)(81166006)(53936002)(85426001)(110136004)(356003)(305945005)(8936002)(2906002)(104016004)(8676002)(54906002)(4326008)(50226002)(8656003)(86362001)(76176999)(50986999); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR03MB2266; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD005; 1:/m82oNzsLcyHgmcn+Z2/xzq2SOnkrrjFlqGXe/8FQH0fZVCy6lsHg1mP3hpORP39Hi2hmXyp4lgHnhnDK8JSL6jAvsK//e7r6/FlZ80X2LMiFvHS7VsOuz1J0H0gXjtj MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1dbec9bd-de34-4222-7eba-08d4f7738c5e X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(300000502095)(300135100095)(22001)(300000503095)(300135400095)(2017052603199)(201703131430075)(201703131517081)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:CY1PR03MB2266; X-Microsoft-Exchange-Diagnostics: 1; CY1PR03MB2266; 3:jBgDPmYbJE0P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m4rAmnhaM72ZtHQzWWFsrCZ8zKA/nzj7THKHTH9as+HynCUgom2yxlA5U3XGeFPcGa6WH1jN87WvoXo2ztfN8+GOWjEomRPwQUcCDdeFGBxiMFKPCqQNxkCRJrrU/qMKeO/tlw5YDZTvq99ixaS0cxygfUd+ziGRkzgwVXNVOiFkH0xN6WdNsWMH93Q36JtBmQhkxaHh6XXjDSDWcaTXdKlPxxYwSL8i700= 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)(93006095)(93001095)(3002001)(100000703101)(100105400095)(10201501046)(6055026)(6096035)(201703131430075)(201703131448075)(201703131433075)(201703161259150)(201703151042153)(20161123565025)(20161123556025)(20161123559100)(20161123561025)(20161123563025)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:CY1PR03MB2266; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(400006)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:CY1PR03MB2266; X-Forefront-PRVS: 0425A67DEF X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR03MB2266; 23:G94iNPOlY89clOHL97aHQPnmWZ1EOJd+qz+sG2D24?= =?us-ascii?Q?3YlryHq/uWPw0YOPu6qvpFEduGTJp1LBEK36TW+sjWM25Ysw2h/GLRH/3Ptm?= =?us-ascii?Q?vyMe12u3Yigm1mtZF6NYAs3nWz8aLnJh5zmf0K2NAm6GgUcmbaWIJvGdf8VA?= =?us-ascii?Q?P0zmsJStOosQk8ae/rh1X7ilvYypDAqnUnAeggdtmTdIOgV106dpORt6D/BJ?= =?us-ascii?Q?9fxN3XPqRyBpAEQBFZTRPrxeeC3kLzRweaXN2i4FZLNXCk1YH+gGX8kWK8Bs?= =?us-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Exchange-Diagnostics: 1; CY1PR03MB2266; 6:DiYTq3yJbj2SNWICwd+Rpr11Nnj8sNOuDidkt4sWQeYoh/DBFZWMm/hOzwUwDjcsYJUiUAb6euyn/EqmEm5U3KngPTy3WL2Ft1cRhNos7KzfuTmWpEuFsV/vqqdM0qkKECGtELq7F2rOX7+VGHFgvONBS+C8Y17hNhPMTvFdKTQCOvbJXBbNCuqezVS2gH/SC/bDbRS0ZquU/n82hNPfvpuWU9EkNVzgHqV14Ui9qZD/6b+RaQyvMDJp0Dxw6QjkF6ZbH+s1xYNNGUVIM3F+NuZIMqE4Kuy5g7jePdPiLh4m0yJRAdjyI2v7q6bFhCDPjJurp/uWlR8JxWKpEv9jSw==; 5:FIJ9yFjkniA8CIp54jR9bn+JVd/7VgGF7gJynfy7KZqhU2SHH+Z0U3zRnOntepXnfYOMdhcFG+0Bhm0Ehtx9ewOwETUq7XJTaIl1aqkk9IwnrhzqEr/dNpkn2ITxXA2GewRFMkB+fOUElo6H0FPdTg==; 24:jmIiGYFEqyVPHIQ/TfvnxlOy7QUT3UbPlAQz0yNh8XmigsOZ7UsT4yHkIKo5tQd6wnmwoxQgv4Y0zsJJgLu0eZJpJy063xWIeRYu0HL5Vz4=; 7:xr8miP3PbKKbwbFVKz73ruVJURxPsRtxX3rWCJzzYVRBfmkdM1+UryBfLXZm1lGE+FThgha83iSOOK765xmGzRUs7qQlbR9lBAzbWDMKpQiMxyDW8CBD+2eofZ3a0Hk425ghqBGjkOPQXOdIVCUeBitwKTtipNmYV/EC59eO1WFm0+GwVMf5yUco0Tou4xUZdvDl+mgrR2bcgMiMMTEz9l0pwZsn78LXg30/KKjrW1g= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Sep 2017 11:11:41.2513 (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: CY1PR03MB2266 Subject: [dpdk-dev] [PATCH v4 37/41] net/dpaa: add support for 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: Sat, 09 Sep 2017 11:11:44 -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 64c70b8..1deefd3 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 90be40d..0f43bb4 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_TX_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_TX_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_TX_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 /**