From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00087.outbound.protection.outlook.com [40.107.0.87]) by dpdk.org (Postfix) with ESMTP id 6D7B71B040 for ; Thu, 4 Jan 2018 20:19:05 +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=VTxGPDu1l/IW1BOw61m855b3b4PGfE1FLRNtnokebt4=; b=S1ASr0KwHTi+HtcmJwOQnUWRwkAe+zNYuimanFw3OLTW4S9Esm0aMFgzMM2Y0O8vcstQZe/cccbnBQ06grd4MR+kNkzdHwZQ3YcPQlxRjWJ2UXh4eQgh6TuEXcLLJ4pqZUSfhSM2WE0wM0IyfI2pdOMZQQ97Guc2OhIktaGAqHw= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=motih@mellanox.com; Received: from mellanox.com (37.142.13.130) by HE1PR05MB3212.eurprd05.prod.outlook.com (2603:10a6:7:35::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.366.8; Thu, 4 Jan 2018 19:19:04 +0000 From: Moti Haimovsky To: pascal.mazon@6wind.com Cc: dev@dpdk.org, Moti Haimovsky Date: Thu, 4 Jan 2018 21:18:40 +0200 Message-Id: <1515093521-185221-2-git-send-email-motih@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515093521-185221-1-git-send-email-motih@mellanox.com> References: <1515093521-185221-1-git-send-email-motih@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: DB6PR1001CA0037.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:4:55::23) To HE1PR05MB3212.eurprd05.prod.outlook.com (2603:10a6:7:35::10) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: fa8db702-bdad-4f5b-581b-08d553a80524 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(2017052603307)(7153060); SRVR:HE1PR05MB3212; X-Microsoft-Exchange-Diagnostics: 1; HE1PR05MB3212; 3:fNSu5RhWuotbIeo16Urovv/V33IXLmxNnUDgw6g4ZkeS7YtRwynDQVGWqAzzIkwHJXE1d1NFJBiZAag1GsugN3MP7EGSQlCr81aTUeh7/0AcbeVcj71QqaWqiyLLQWsnLdUk7N27FUe2LnWrC2T8v1kuGgzvWCwtWX070a5poaDw3TLIyM8YBCRyQS4OeaqmN4a+ooMOPEeKb/GZD4CZ5dfLbt7pHJmvwXNQ8U5iAZu0cIsVpGi7XyqQpJ3mExWw; 25:t+aD5TQ1rjuCieS0YpavoYTOdAiN6FY4u4JA74yC9l680mS0UulqaBwpc+RAaDqBl2qCaMcC6UsagddpBZsrE071pe9ixJu+UKPacvOoDVTvrYWyfqesye+TXfr44anwZl2fifRFdbvDLw2Pw0VY0u/l/xXIoGcBH//emzGYjuFZXOS9/saM4sd4DOMT5eCodIKS9MvRE2lFlqR8d/Y0U3TQ9QeyxhcxL0dyvSIfpoIzNZPC/P+50vgf9lQGDo7WYjG3FUoM7Lr9ZhgtEMMlzAL5KVYW7Pr6KSReTg362etqZ/om4XsL+xZQnsj1fSFiKSChQRkl5FyJCOqIGVsC7A==; 31:MxNlpN+988ctnkviQky+EyVijyt1QP5JrVaKsW0eiS01HDOeCNaVnooU20smU08L2WCZ8OgvcArU3eMvuDB712KFKaEg4SQZFHe1MtW3IMe4n8sk2MGFV4YK/Tqw/0QZSjMus/gGBK4EWx6ZK+exTsCFa23eq8EZR0TtEfjCNHiYSEE80vQdR2VClm5fjg5Ubv4sJBA4JBTJEBmbo17YKJSyDc1cLpEI43Eq1410qDo= X-MS-TrafficTypeDiagnostic: HE1PR05MB3212: X-Microsoft-Exchange-Diagnostics: 1; HE1PR05MB3212; 20:Fb+0XuVvaHoIjZX0uTWS4Bbj2OPjiZuEkbDAZAo3eZiGNl4aSh960L76BJwjbIvApRM7QGxXr9viiINz8QFJoY/pyeRZS5n1thwUUAryOeDFg0EZVhPwMdxrZQ3cWoJc0/nAmamNp0QyLnWTVMNzw2pNSssi5VD6Pi2x3rrqoJPD0222vusZ/HgmXjevrFZUI36f2gSLkyk6CUNI0nupPUI3DHa+t2mtGTTRMa0f4Y5efZKKHDsA7Yn1hbaXRfmMcdXbS1KGuoIMNy7iBD9ii8AmBROG6GavWMDJdzqaUq5aiJk6DwCJPBY2hh4U+bPSaNdQCkmgXVvOCkftpwadfg3uwLhNs5cC/FVDZkXwh1fjiD+GbfEvsjK9uRYCi3fAQIQzWLGcuTfP2+3UOn3O0aWZ4+oJ8SU+01HcgI+6TWfXhgSXQu14/c0IST1ARlzpPk0+y4vXVOo8xnyddvIw6Do4Ihbijdmu0sORmZNpJbKxe/7Pi2YyDnMqLT0N+Zs1; 4:4QRZ954N1mDWRF/0PdUWQ9lj4Y4NUISWd4t0dEZzsWZdGcKbELDJ65jY6/pSGIhMY0yi8VJOcg9c46RW+BoDX8m5CreBjxrQZU+QzXrS06V+7PkvAPvhwyLafq2WYLivyMhGBUWmgSzd2COlPsQQekgAsGb9lr97cviSEH8dM7B4SPzAW08I8VTdDrkN4OZ6M9/nDeoVENcJWGw7OkJVMvh4VaH/Vr2+lVm93KuDR+dWoYZZoAOOH5zaLpJGeXw76gEac7mFwhfT1ra5i7fLLQ== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(8121501046)(5005006)(3002001)(3231023)(944501075)(93006095)(93001095)(10201501046)(6055026)(6041268)(20161123560045)(20161123562045)(20161123558120)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:HE1PR05MB3212; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:HE1PR05MB3212; X-Forefront-PRVS: 054231DC40 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(39860400002)(346002)(39380400002)(396003)(366004)(376002)(199004)(189003)(16526018)(478600001)(50466002)(5660300001)(7736002)(305945005)(4326008)(6116002)(3846002)(25786009)(97736004)(316002)(4720700003)(6666003)(48376002)(68736007)(81156014)(6916009)(2950100002)(8936002)(16586007)(8676002)(81166006)(50226002)(107886003)(51416003)(7696005)(86362001)(52116002)(76176011)(69596002)(33026002)(53936002)(386003)(21086003)(2906002)(47776003)(106356001)(2361001)(59450400001)(66066001)(36756003)(55016002)(105586002)(2351001); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR05MB3212; 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; HE1PR05MB3212; 23:4o+pp8oXbATOpjCdeTws5Y5bC9PbWrRTGgkHOhVuL?= =?us-ascii?Q?Hhu/XqvXYJHwZZYdsJcOZbzub65soFDUiMxGgF29MEo2aPSHrA0I+tmI4iMh?= =?us-ascii?Q?7yOvB2n24Mv6kPrtU1KIkT1KXyy9VoYVNfaik1TXOb3SeAjv7mQYC43mnQxP?= =?us-ascii?Q?2uORvbUCcUqUT4mPH8ZvBAWs7C+lBS480fIOwnBHamqFcnYX+scU08UEROkc?= =?us-ascii?Q?P6Ty8Rpfmk5TqL0xM0FqgUZxj3JNIV3LaeqS6ZDZLsrgyNq/91wdQDIN7OQy?= =?us-ascii?Q?1Ri0g012S8SB9yuT+aOmthDTKS8kCl3X+IgOuetQJGvWyliLEc+x8+cziZAK?= =?us-ascii?Q?kGYa+qhv4dvdTcsEeH+n+b8Cr3VxgU/48jP0IRBhY4yTzHxiJpAptj2VckEc?= =?us-ascii?Q?bgikHGfqJfDBxoUo0KhkBl2TwKlJEXH78/ZEuQ6Ris/3HU5IgZYICqdBiewB?= =?us-ascii?Q?kyKmVbHqzGWv01nF6XOFti/Bn1aalv13h4tkFkzFKobKthIa1mzd44KYXdJL?= =?us-ascii?Q?5dDqtdoDcWfqBrSfjjpP7SpwgifAJMs2SCe4NR14FRMrIG1aEsP++UK1eqh8?= =?us-ascii?Q?QMXZXwHk6bzO2tb7hR2e3TF9T478khD1H31diVM4M/D5Jl+cbYE9RQI/iWXD?= =?us-ascii?Q?zr49JFRdPMfCLCG7Vj5+nomhUX5q6nRPLXiriEfyUSW4GdcHRoDa7mIhgAYh?= =?us-ascii?Q?of5SVSLjr/RZRx+anECE6KlxLUa6GtEipN/WjaOwKj9krgCmRx4ALQLYo8K6?= =?us-ascii?Q?RjdWPGe6vuppZf6rbUU6a7t1DR4+GLmLCa9TQlpS8a3qElutLNchn1LC9LLe?= =?us-ascii?Q?1H+KRkuDdcAi1te6ZDx9lgJOp83ttflkJY3hbibVUEkqlrXfnAO7MOc49HPS?= =?us-ascii?Q?GBYaH5wna9v7z5RVNkMohAgF4kxg8jEle12Uhg6Xeoy3ZZi8GolQN4pQnS+W?= =?us-ascii?Q?zLbxYdUgDn3GmbLWAVfyWav2a9UMe1tb/19VpZKDSfwtLIWdxgu3lIL7mXXA?= =?us-ascii?Q?0ScIBG3LWCg5rPL7nF7/lrvSwNVd9umAjN+lNzRO5tBE8laoi6gRmRdfvhL+?= =?us-ascii?Q?9LrHAm0bRpP59yavTnFLPfs4elsak8UBYT7Hg9BKR9HroUWJfPvZdbdGhWZU?= =?us-ascii?Q?tBv5Iv75E2oqKS4h6OwAyvotF3yfWgt6n4jRjpHHpeBbGvVhvTfcE/CF3RzQ?= =?us-ascii?Q?L3u14tnslM9qjjV1shqe/cy8zqbipJ6MQMb+DL1nrsaGgvPvCyyRGGKdA=3D?= =?us-ascii?Q?=3D?= X-Microsoft-Exchange-Diagnostics: 1; HE1PR05MB3212; 6:S7yH1S4fyiOaMQmIK21AIsZw2mOlaM+vskjnV3af5uLNrny6DxD55owB+DpWoWurKZZ1dRq1hT9bhRpiz2iVq8/aI1EEfmjK56/bD2yrqwEHB5soOTYAZBIMzUVKRp2c5R9d0mvQxrgBNNHvz9rRRLShNX9KvXxbivUXa8MMrzNb6CFi126BAUFZlwzampSe9hbsj4H8hYQyeFjhuB3wHO9tB8lJrPlZ6ixIpXGiP+AzbSJX48hw9tGdSTTkw6eTBUZCD4OEjOGI/kdSSyjHaQfVERW6J9PdjyO1j/fXh2LBJv7l44V/x8Xin7d3D11VxMSZAm4Faro2oaNdA+pWhfQrEUZyfyumwSY/a43L30c=; 5:+K7GzNos0dBI5Y30Oqjo3zPqMhvVfZQNKtFCK4Y0IcfZS3a5+GQkmwqugHlcdggsmOlDpQYrQSYOqRZML5oj0x9Cj2qTydVroVKryh3v20OHYoCF3SrDaBG7MhuKvAeyD9nuDWqNhfZ+AN8+dHfobm4pcsHz22npbpFURxXXWnQ=; 24:oUC5xfdo8FRLCY2Aiehkyiq8THllg7/YSCp7AXXIChDMGR/whWqIRq2VzLEy7ib0PiFDGtyDfLHGBoYtix3vEHPWVsCt6PI+2x+LVx/ly8o=; 7:ZxRC6LqxqtQeOOcsfrloqeXnbxycuYVg0kdBk9HiCpbT4otkd/Y5zgT7eQ4zx+J61btQvX+mlBgbC/BV12wPypBivr/lE2AQaN8/7bX/qUNYlOi7mpG5FLUODNx54ooXkMh0nLwp2LULBHecli5IZUscDuko2NGxt06t+mYSrvCUqNJdmQQV3GJn5AZSwRyPdOhynHg2CWnTgme0FN6yOrLlisPivv34/O7PhRinqIb2CFlip7/s3WAp/etGYZCh SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jan 2018 19:19:04.2109 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fa8db702-bdad-4f5b-581b-08d553a80524 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR05MB3212 Subject: [dpdk-dev] [PATCH V3 1/2] net/tap: convert to new Tx offloads API 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, 04 Jan 2018 19:19:05 -0000 Ethdev Tx offloads API has changed since: commit cba7f53b717d ("ethdev: introduce Tx queue offloads API") This commit support the new Tx offloads API. Signed-off-by: Moti Haimovsky --- V3: * Fixed coding style warnings V2: * Fixed coding style warnings --- drivers/net/tap/rte_eth_tap.c | 96 +++++++++++++++++++++++++++++++++++++------ drivers/net/tap/rte_eth_tap.h | 1 + 2 files changed, 85 insertions(+), 12 deletions(-) diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c index 6b27679..1a84adb 100644 --- a/drivers/net/tap/rte_eth_tap.c +++ b/drivers/net/tap/rte_eth_tap.c @@ -53,6 +53,7 @@ #include #include #include +#include #include #include #include @@ -379,6 +380,42 @@ enum ioctl_mode { return num_rx; } +static uint64_t +tap_tx_offload_get_port_capa(void) +{ + /* + * In order to support legacy apps, + * report capabilities also as port capabilities. + */ + return DEV_TX_OFFLOAD_IPV4_CKSUM | + DEV_TX_OFFLOAD_UDP_CKSUM | + DEV_TX_OFFLOAD_TCP_CKSUM; +} + +static uint64_t +tap_tx_offload_get_queue_capa(void) +{ + return DEV_TX_OFFLOAD_IPV4_CKSUM | + DEV_TX_OFFLOAD_UDP_CKSUM | + DEV_TX_OFFLOAD_TCP_CKSUM; +} + +static bool +tap_txq_are_offloads_valid(struct rte_eth_dev *dev, uint64_t offloads) +{ + uint64_t port_offloads = dev->data->dev_conf.txmode.offloads; + uint64_t queue_supp_offloads = tap_tx_offload_get_queue_capa(); + uint64_t port_supp_offloads = tap_tx_offload_get_port_capa(); + + if ((offloads & (queue_supp_offloads | port_supp_offloads)) != + offloads) + return false; + /* Verify we have no conflict with port offloads */ + if ((port_offloads ^ offloads) & port_supp_offloads) + return false; + return true; +} + static void tap_tx_offload(char *packet, uint64_t ol_flags, unsigned int l2_len, unsigned int l3_len) @@ -465,9 +502,10 @@ enum ioctl_mode { rte_pktmbuf_mtod(seg, void *); seg = seg->next; } - if (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) { + 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) break; @@ -605,6 +643,17 @@ enum ioctl_mode { static int tap_dev_configure(struct rte_eth_dev *dev) { + uint64_t supp_tx_offloads = tap_tx_offload_get_port_capa(); + uint64_t tx_offloads = dev->data->dev_conf.txmode.offloads; + + if ((tx_offloads & supp_tx_offloads) != tx_offloads) { + rte_errno = ENOTSUP; + RTE_LOG(ERR, PMD, + "Some Tx offloads are not supported " + "requested 0x%lx supported 0x%lx\n", + tx_offloads, supp_tx_offloads); + return -rte_errno; + } if (dev->data->nb_rx_queues > RTE_PMD_TAP_MAX_QUEUES) { RTE_LOG(ERR, PMD, "%s: number of rx queues %d exceeds max num of queues %d\n", @@ -681,10 +730,9 @@ enum ioctl_mode { dev_info->rx_offload_capa = (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); + dev_info->tx_queue_offload_capa = tap_tx_offload_get_queue_capa(); + dev_info->tx_offload_capa = dev_info->tx_queue_offload_capa | + tap_tx_offload_get_port_capa(); } static int @@ -1058,21 +1106,45 @@ enum ioctl_mode { uint16_t tx_queue_id, uint16_t nb_tx_desc __rte_unused, unsigned int socket_id __rte_unused, - const struct rte_eth_txconf *tx_conf __rte_unused) + const struct rte_eth_txconf *tx_conf) { struct pmd_internals *internals = dev->data->dev_private; + struct tx_queue *txq; int ret; if (tx_queue_id >= dev->data->nb_tx_queues) return -1; - dev->data->tx_queues[tx_queue_id] = &internals->txq[tx_queue_id]; + txq = dev->data->tx_queues[tx_queue_id]; + /* + * Don't verify port offloads for application which + * use the old API. + */ + if (tx_conf != NULL && + !!(tx_conf->txq_flags & ETH_TXQ_FLAGS_IGNORE)) { + if (tap_txq_are_offloads_valid(dev, tx_conf->offloads)) { + txq->csum = !!(tx_conf->offloads & + (DEV_TX_OFFLOAD_IPV4_CKSUM | + DEV_TX_OFFLOAD_UDP_CKSUM | + DEV_TX_OFFLOAD_TCP_CKSUM)); + } else { + rte_errno = ENOTSUP; + RTE_LOG(ERR, PMD, + "%p: Tx queue offloads 0x%lx don't match port " + "offloads 0x%lx or supported offloads 0x%lx", + (void *)dev, tx_conf->offloads, + dev->data->dev_conf.txmode.offloads, + tap_tx_offload_get_port_capa()); + return -rte_errno; + } + } ret = tap_setup_queue(dev, internals, tx_queue_id, 0); if (ret == -1) return -1; - - RTE_LOG(DEBUG, PMD, " TX TAP device name %s, qid %d on fd %d\n", - internals->name, tx_queue_id, internals->txq[tx_queue_id].fd); + RTE_LOG(DEBUG, PMD, + " TX TAP device name %s, qid %d on fd %d csum %s\n", + internals->name, tx_queue_id, internals->txq[tx_queue_id].fd, + txq->csum ? "on" : "off"); return 0; } diff --git a/drivers/net/tap/rte_eth_tap.h b/drivers/net/tap/rte_eth_tap.h index 829f32f..69a1a08 100644 --- a/drivers/net/tap/rte_eth_tap.h +++ b/drivers/net/tap/rte_eth_tap.h @@ -76,6 +76,7 @@ struct rx_queue { struct tx_queue { int fd; uint16_t *mtu; /* Pointer to MTU from dev_data */ + uint16_t csum:1; /* Enable checksum offloading */ struct pkt_stats stats; /* Stats for this TX queue */ }; -- 1.8.3.1