From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0049.outbound.protection.outlook.com [104.47.0.49]) by dpdk.org (Postfix) with ESMTP id B3EF77D57 for ; Thu, 24 Aug 2017 17:54:32 +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=4R+8uxN5KU1HC8tgWuJHB0pNN/8lGKCB0eIGZkJKThc=; b=lPSLxzFeY6Hzmsx85Q5bEQiD2utHCwJn10+4TYeC5PDtJMocfw8E93qs+iBYKH6SZqDbHKNzT6LJJ0LxQz2eNAYOer5NM4XlMwbJohb5ENeAjlxb5Uixpo5FndhiDXU0Q670aSQWta55wUn3gJn8U68rgOWEX5hjwCSzUOi7AKo= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=motih@mellanox.com; Received: from mellanox.com (37.142.13.130) by AM4PR05MB1907.eurprd05.prod.outlook.com (2603:10a6:200:15::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1362.18; Thu, 24 Aug 2017 15:54:30 +0000 From: Moti Haimovsky To: adrien.mazarguil@6wind.com Cc: dev@dpdk.org, Moti Haimovsky Date: Thu, 24 Aug 2017 18:54:09 +0300 Message-Id: <1503590050-196143-5-git-send-email-motih@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1503590050-196143-1-git-send-email-motih@mellanox.com> References: <1503590050-196143-1-git-send-email-motih@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: VI1PR0302CA0006.eurprd03.prod.outlook.com (2603:10a6:800:e9::16) To AM4PR05MB1907.eurprd05.prod.outlook.com (2603:10a6:200:15::15) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 035b5e6f-654e-4c2f-c68e-08d4eb0868ca X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:AM4PR05MB1907; X-Microsoft-Exchange-Diagnostics: 1; AM4PR05MB1907; 3:+1H7IjBwXWssPCoczQmSjLlToPoF3CAaMsvI7czF8TqchCFBJ4Q4FFqhUYt853kPKV9f+LS6ZmzSANk+yRcNEQRnn+2B0dLM8kkBQVP4R67KYz7bvyoeArUyEKlpJaADniGE6oFiARaoUWQzMpWzNPfWaUcVqj3KXhnNcEp8EuQk9HvCnCS7Mw563aAD081Em5PqZHBAcvJF03D3keMX7s96pIP/M8bhhrI4/ucd9ZOXgMJ3FGyVQPFOlgHGQ6Vr; 25:U8XSYHGPjA7CAgszHKe3iFlHIVdw9EpcqD9LkeRGVRyRp7cutM/1riOurjHp1YMZ5oIcYbmRvse18tyvaTQ2bJ+cTizgjLG/cyeEH6YHorfvwWqWejxC0tPBLwRN4Y5Yuu/PQ1PDuN/5ODXOO7zZjyrjRLgsIzQy3dKN5HeRHSh9/qW4ZnsDhgnC+krleOrWXQ+3fL6mQ/3cr+iJU8jVSu9p8vDYT8b3aE7BqnE7Pxggcj2tIIrbq+9empg1CnlctMDj15HBJEIzJkFStxOpmhXwMfVX8omlhQwTgkx14wEBRFjUNfTo1s6JZ/xys83VqYrqPeIvBWELy4QPJbz7GA==; 31:eCKJPUQoUINMxxDs8SWse9JHlglolOcYG6LDhFsoJbmRdKEJ75USDO8eR+eJxRQiyGYVfIeNLn2M5YNbK7Sc6Q6v5y8BHE17+5hERPi6XTwIeZykx/ad1KuhWUyBtS6T61bG2TeYuUoQqsWaVAJ9iWCbF6DQmi7RTiKQ/kSo40SxVZfR5Xp3uJ3EkgMp9nOcZlGbLAOwNk0FNVsD4MmYAf/CbfAJa1BgW8cXumgREuM= X-MS-TrafficTypeDiagnostic: AM4PR05MB1907: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; AM4PR05MB1907; 20:1XLMxOPRI8O24YyuPwerlrYxL8TMeAQsjl6Wq812o7lQrAjggSlLxQQ9WQuFrFxIaVk2CMPG1aA1CHHI1xSoz/KE88CjDkwgwVo8gwSoF56rxPo5Qgizbik1XtiXPZJ9Ki86KpqfWBkv/aBj0JbtgOW+xz6FDTWY1tWGbjt3h1XkVe9QOMdxPqWesxnj9175Gg2jbP7gPLB7CtcawvhwV7kK6w4m2Q8eTmsQ9KvkJqfzmaJZdq/d0s1L8Ef3uGaBtbeoFJIzM/SqDBXBuX5de/2LRNo9yCDXARKhU/OdrR24u9Qfr5Ix23pT3NRJ5D97KwlAK66p5KmJUwK3X5WWR9lT7/iJ2oCtIsF/waWdJ+FmtGV0v0ZndLES4tXo/q4dnZjhCmPSq8xqQm75gvCoWjRXdB0/QAPPBKPGH/U7dsNxbzvqsRE7wkppSh0NzCDqGu4ht3n4tVO2t6UAJ8FG3gKqgFz9heoqQK5V+F6Cr1zCXoq+t9XPDMLpsGvj/lzd; 4:LoBX8pSXjdKN9IWBkvcJ96C8wNvNUPYz9/OjE+IEAzqhHQhAKJQAM0Lg3nPPayfq0Uc/k+YNdTLbZxkRP+FWiAVzIN9NdVXm12x9vqOvfNCbQyYc6NzbfZkZZ4K6G6FMLdiBcmJpxbSerzJhqSevvtk5iD7KLrg29fxtDTSteBh2uFAlBDb4jGAKcqbKJUjcJrosK+6NKwAzAGUdSwb/9nNB5ovAYbqGrcaXHKAvPRqaOdxDL7hF0dRwSd2qb7xWBU7Aq9fEdcO0+dCcQXbsnhKI8+QHPY+DWOuE7lPUF3s= X-Exchange-Antispam-Report-Test: UriScan:(60795455431006); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(100000703101)(100105400095)(3002001)(6055026)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123560025)(20161123562025)(20161123555025)(20161123564025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:AM4PR05MB1907; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:AM4PR05MB1907; X-Forefront-PRVS: 04097B7F7F X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(7370300001)(6009001)(39860400002)(199003)(189002)(66066001)(47776003)(5660300001)(50226002)(2361001)(50986999)(81166006)(8676002)(69596002)(33026002)(478600001)(105586002)(7736002)(42186005)(76176999)(106356001)(305945005)(33646002)(4326008)(81156014)(2906002)(2351001)(101416001)(21086003)(48376002)(25786009)(189998001)(2950100002)(4720700003)(86362001)(6916009)(575784001)(55016002)(6666003)(53936002)(50466002)(107886003)(110136004)(7350300001)(6116002)(36756003)(5003940100001)(97736004)(3846002)(68736007); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR05MB1907; H:mellanox.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX: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; AM4PR05MB1907; 23:7uzT2oWwKbV5y6iw+eevBYka/mSCr5ATLx1dIAZGi?= =?us-ascii?Q?yPU+bmAtYBEyjyGZkbUHujODzKr24A9lFshz+8lHSnckeA0bKxYDNOaYWVW+?= =?us-ascii?Q?iIs9zr+fYSWpswIW8eRATYgGjE0TwCJU8MUx2tAokFIsXXXd7NHdKX5Zf5g2?= =?us-ascii?Q?teisS02XKHcmZjL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KR7DTw2vD8xFCuP+Anqc5lHe3aWoQxXvAkrvUps0aFBUX4sqUYpltWCGyiqdhDMGY= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2017 15:54:30.9436 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR05MB1907 Subject: [dpdk-dev] [PATCH 4/5] net/mlx4: add Tx checksum offloads 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, 24 Aug 2017 15:54:33 -0000 PMD now supports offloading the ip and tcp/udp checksum header calculation (including tunneled packets) to the hardware. Signed-off-by: Moti Haimovsky --- drivers/net/mlx4/mlx4.c | 7 +++++++ drivers/net/mlx4/mlx4.h | 2 ++ drivers/net/mlx4/mlx4_ethdev.c | 6 ++++++ drivers/net/mlx4/mlx4_prm.h | 2 ++ drivers/net/mlx4/mlx4_rxtx.c | 25 +++++++++++++++++++++---- drivers/net/mlx4/mlx4_rxtx.h | 2 ++ drivers/net/mlx4/mlx4_txq.c | 4 +++- 7 files changed, 43 insertions(+), 5 deletions(-) diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c index b084903..3149be6 100644 --- a/drivers/net/mlx4/mlx4.c +++ b/drivers/net/mlx4/mlx4.c @@ -397,6 +397,7 @@ struct mlx4_conf { .ports.present = 0, }; unsigned int vf; + unsigned int tunnel_en; int i; (void)pci_drv; @@ -456,6 +457,9 @@ struct mlx4_conf { rte_errno = ENODEV; goto error; } + /* Only cx3-pro supports L3 tunneling */ + tunnel_en = (device_attr.vendor_part_id == + PCI_DEVICE_ID_MELLANOX_CONNECTX3PRO); INFO("%u port(s) detected", device_attr.phys_port_cnt); conf.ports.present |= (UINT64_C(1) << device_attr.phys_port_cnt) - 1; if (mlx4_args(pci_dev->device.devargs, &conf)) { @@ -529,6 +533,9 @@ struct mlx4_conf { priv->pd = pd; priv->mtu = ETHER_MTU; priv->vf = vf; + priv->tunnel_en = tunnel_en; + priv->hw_csum = + !!(device_attr.device_cap_flags & IBV_DEVICE_RAW_IP_CSUM); /* Configure the first MAC address by default. */ if (mlx4_get_mac(priv, &mac.addr_bytes)) { ERROR("cannot get MAC address, is mlx4_en loaded?" diff --git a/drivers/net/mlx4/mlx4.h b/drivers/net/mlx4/mlx4.h index 93e5502..439a828 100644 --- a/drivers/net/mlx4/mlx4.h +++ b/drivers/net/mlx4/mlx4.h @@ -104,6 +104,8 @@ struct priv { unsigned int vf:1; /* This is a VF device. */ unsigned int intr_alarm:1; /* An interrupt alarm is scheduled. */ unsigned int isolated:1; /* Toggle isolated mode. */ + unsigned int hw_csum:1; /* Checksum offload is supported. */ + unsigned int tunnel_en:1; /* Device tunneling is enabled */ struct rte_intr_handle intr_handle; /* Port interrupt handle. */ struct rte_flow_drop *flow_drop_queue; /* Flow drop queue. */ LIST_HEAD(mlx4_flows, rte_flow) flows; diff --git a/drivers/net/mlx4/mlx4_ethdev.c b/drivers/net/mlx4/mlx4_ethdev.c index a9e8059..e4ecbfa 100644 --- a/drivers/net/mlx4/mlx4_ethdev.c +++ b/drivers/net/mlx4/mlx4_ethdev.c @@ -553,6 +553,12 @@ info->max_mac_addrs = 1; info->rx_offload_capa = 0; info->tx_offload_capa = 0; + if (priv->hw_csum) + info->tx_offload_capa |= (DEV_TX_OFFLOAD_IPV4_CKSUM | + DEV_TX_OFFLOAD_UDP_CKSUM | + DEV_TX_OFFLOAD_TCP_CKSUM); + if (priv->tunnel_en) + info->tx_offload_capa |= DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM; if (mlx4_get_ifname(priv, &ifname) == 0) info->if_index = if_nametoindex(ifname); info->speed_capa = diff --git a/drivers/net/mlx4/mlx4_prm.h b/drivers/net/mlx4/mlx4_prm.h index 8b0248a..38e9a45 100644 --- a/drivers/net/mlx4/mlx4_prm.h +++ b/drivers/net/mlx4/mlx4_prm.h @@ -60,6 +60,8 @@ /* WQE flags */ #define MLX4_OPCODE_SEND 0x0a #define MLX4_EN_BIT_WQE_OWN 0x80000000 +#define MLX4_WQE_CTRL_IIP_HDR_CSUM (1 << 28) +#define MLX4_WQE_CTRL_IL4_HDR_CSUM (1 << 27) #define SIZE_TO_TXBBS(size) (RTE_ALIGN((size), (TXBB_SIZE)) / (TXBB_SIZE)) diff --git a/drivers/net/mlx4/mlx4_rxtx.c b/drivers/net/mlx4/mlx4_rxtx.c index dae0e47..3415f63 100644 --- a/drivers/net/mlx4/mlx4_rxtx.c +++ b/drivers/net/mlx4/mlx4_rxtx.c @@ -475,9 +475,27 @@ MLX4_WQE_CTRL_FENCE : 0) | ((wqe_real_size / 16) & 0x3f); owner_opcode = MLX4_OPCODE_SEND | ((sq->head & sq->txbb_cnt) ? MLX4_EN_BIT_WQE_OWN : 0); + /* Should we enable HW CKSUM offload ? */ + if (txq->priv->hw_csum && + (pkt->ol_flags & + (PKT_TX_IP_CKSUM | PKT_TX_TCP_CKSUM | PKT_TX_UDP_CKSUM))) { + const uint64_t is_tunneled = pkt->ol_flags & + (PKT_TX_TUNNEL_GRE | + PKT_TX_TUNNEL_VXLAN); + + if (is_tunneled && txq->tunnel_en) { + owner_opcode |= MLX4_WQE_CTRL_IIP_HDR_CSUM | + MLX4_WQE_CTRL_IL4_HDR_CSUM; + if (pkt->ol_flags & PKT_TX_OUTER_IP_CKSUM) + srcrb_flags |= MLX4_WQE_CTRL_IP_HDR_CSUM; + } else { + srcrb_flags |= MLX4_WQE_CTRL_IP_HDR_CSUM | + MLX4_WQE_CTRL_TCP_UDP_CSUM; + } + } /* fill in ctrl info but ownership */ mlx4_set_ctrl_seg(ctrl, fence_size, srcrb_flags, 0); - /* If we used a bounce buffer then copy wqe back into sq */ + /* If we used a bounce buffer then copy wqe back into sq */ if (unlikely(bounce)) ctrl = mlx4_bounce_to_desc(txq, head_idx, wqe_size); /* @@ -485,9 +503,8 @@ * setting ownership bit (because HW can start * executing as soon as we do). */ - rte_wmb(); - ctrl->owner_opcode = rte_cpu_to_be_32(owner_opcode); - + rte_wmb(); + ctrl->owner_opcode = rte_cpu_to_be_32(owner_opcode); sq->head += nr_txbbs; rte_wmb(); return 0; diff --git a/drivers/net/mlx4/mlx4_rxtx.h b/drivers/net/mlx4/mlx4_rxtx.h index 35e0de7..b4675b7 100644 --- a/drivers/net/mlx4/mlx4_rxtx.h +++ b/drivers/net/mlx4/mlx4_rxtx.h @@ -146,6 +146,8 @@ struct txq { unsigned int socket; /**< CPU socket ID for allocations. */ struct mlx4_sq msq; /**< Info for directly manipulating the SQ. */ struct mlx4_cq mcq; /**< Info for directly manipulating the CQ. */ + uint16_t tunnel_en:1; + /* When set TX offload for tunneled packets are supported. */ char *bounce_buf; /**< Side memory to be used when wqe wraps around */ }; diff --git a/drivers/net/mlx4/mlx4_txq.c b/drivers/net/mlx4/mlx4_txq.c index 6f6ea9c..cecd5e8 100644 --- a/drivers/net/mlx4/mlx4_txq.c +++ b/drivers/net/mlx4/mlx4_txq.c @@ -306,7 +306,7 @@ struct txq_mp2mr_mbuf_check_data { struct mlx4dv_obj mlxdv; struct mlx4dv_qp dv_qp; struct mlx4dv_cq dv_cq; - struct txq tmpl = { + struct txq tmpl = { .priv = priv, .socket = socket }; @@ -334,6 +334,8 @@ struct txq_mp2mr_mbuf_check_data { (void *)dev, strerror(rte_errno)); goto error; } + if (priv->tunnel_en) + tmpl.tunnel_en = 1; DEBUG("priv->device_attr.max_qp_wr is %d", priv->device_attr.max_qp_wr); DEBUG("priv->device_attr.max_sge is %d", -- 1.8.3.1