From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-eopbgr60055.outbound.protection.outlook.com [40.107.6.55]) by dpdk.org (Postfix) with ESMTP id 7155D7D30 for ; Wed, 10 Jan 2018 17:21:09 +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=QvqXSnh3XGtOOZ7Rqq6DWLM2oVGgkO+xXWgPEMFk7WkMHr45G+0CMaUAfn33bDbuD6mLS3xI77/8Y4/Njw0iiSXbESwUtRruI7yZnFF30xTlRF4fI4LnjSsdnNhPwBaTYOybIaEcY+xoCEFasNqzE2fj1DJ57Cy7VUoYSAhmOV8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=motih@mellanox.com; Received: from mellanox.com (37.142.13.130) by DB6PR05MB3206.eurprd05.prod.outlook.com (2603:10a6:6:1a::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.386.5; Wed, 10 Jan 2018 16:21:06 +0000 From: Moti Haimovsky To: pascal.mazon@6wind.com Cc: ferruh.yigit@intel.com, dev@dpdk.org, Moti Haimovsky Date: Wed, 10 Jan 2018 18:20:47 +0200 Message-Id: <1515601248-39458-1-git-send-email-motih@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515093521-185221-3-git-send-email-motih@mellanox.com> References: <1515093521-185221-3-git-send-email-motih@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: VI1PR09CA0054.eurprd09.prod.outlook.com (2603:10a6:802:28::22) To DB6PR05MB3206.eurprd05.prod.outlook.com (2603:10a6:6:1a::32) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 86c3dc87-f241-48f8-8b9c-08d55846275a X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020053)(4652020)(5600026)(4604075)(48565401081)(2017052603307)(7153060)(7193020); SRVR:DB6PR05MB3206; X-Microsoft-Exchange-Diagnostics: 1; DB6PR05MB3206; 3:3cCY7jdy1u3LpF1/tVo8t98xx8qI5AK3fi4IslDWDOOPlE6BVgMcGbZZ1HTJ0IfyiURRCjyV8tLBECMOOiekg+Xrp3Ewsj8DLxwS2enYiPQ2Arprdi9GJfdko9t3JHeqb3PiY6ebwCgX1sTmD0arDD0+Mq4aJGzHUGJb4X9oIn80L14MSHBNd+3Q0c9ZeqH06f0EmWtj1nxXW8OJPtP3Cfw04My2Ko5N3fyRvq5ofo+wrFuNCv192K+/YyM2VD91; 25:rnQAWHnQZ5fK9U5J3fmwcqDOzuYprKbzQdjAPg5DPy4KJgOibCu+bIuai2BfBQEyI1CSvP130zMCKv/XHYpQL/0e20hO4I7HlNN1d5uUh4f/niPUP4H8MGsnMVV+uoKz/szHUctW+Gay1XNWrr12GBaeNet5NorGGN8nLol+Up9K9J6HKLh2XPySru2kiHi/BJQLsGhVQPDT1753vhhagMikszWYhX4plx9HbXUWcszb6Cl53bbPqw8T5clbS3oyXzUmjfVP+hkJhoZqf1rBk9F6I+IaejvYVOLO6lWY2dI+EW6XgVIJNe5BQ+2PwVktr71DmXPjuy5BWgJNrcQYog==; 31:sRnXrzPD8djXw4yBT6nD+V93UAzSV4iFh8MfYRtzDT60TjCbdFRGEWN6LvkQLxT7bJG7KNcK2F06MYxxGOhIluyqKq6iwBuFmeU3/2zICQiPyD/1kyK6KevM+0KY/67YaH261mr2P3TD5Yvc30A8nhew3a56ZfSrlpMgSwSgl5SJwvLZbC0/LHQNiNj03+TU9VTEmkN5DuK+9GNjrzgdwvditByPBlqPvchZ/K3J7ho= X-MS-TrafficTypeDiagnostic: DB6PR05MB3206: X-Microsoft-Exchange-Diagnostics: 1; DB6PR05MB3206; 20:JC9YUGLx7IulusYwqfzaZahP6v/lc1Lr6vIeHC+CGmyDsdKSBw3hWOqr9qVFFjVAwAS61T9ZEkP//edl1CXWG7EfP9w8qihEzQC0g5IVvTlC+23sBpyyWfpgmkneREz4CdEp7duBdH/c2bp119PaRtzhBWN75nCGZg54BLmoOWsnBRG3tlcCq6iWrG8My9JAHz18gHjoAiMgUeknqH7YeRi2JkTTwo/vfd4JwxxRqa2V85QkDRM+xYtm/DvKXwAQ3FM74ey7avrySCnFfCBTySRm2Ygyp0ZcxcLzsQHWIvw89aXUMlphV+iKo85vcq1OOWdm4QWKx+ETQWHNQYE0a3ImaLxjOeLsRJTNoUyQbRYxXg+WC/ZTU0SXiep5UTuqq8+QYV8X6fsesYX/qXezGIHDptstC3jy9eHPqTxR60Lds9vDthBurjyLZTAR4X+B12Btj5/sdB8EswZieB6XhtQ3W4fZSknllI+tZQ15AN7l0vRnNqXmL5Nc+RQej7ut; 4:QcPgTA2fyv/HHvYIR1lvdVwyTYen+fuW0NzWoxdvd+ti2LYbpSI5ntkxtz7q6FekELfwid8IDKZzd/xOxT6FP37tNGialvLdY31x5G+ADfX1WdE2VX8v4IFein6hpPQ8ST9eIHcLnoyOvMWTx8gKv/sD/7xA7s1z6mSkgZD12hMiFDE7zgBEnYG22oFAzzJ9LhKWexrd5xarw6lZfTetH2rhXfihRBBWqNBBUS5JqXIuLNpueuBLCz/KKsTOlJh9IySVdMURFx8fg0wdlmYLTQ== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(5005006)(8121501046)(3231023)(944501119)(10201501046)(3002001)(93006095)(93001095)(6055026)(6041268)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123560045)(6072148)(201708071742011); SRVR:DB6PR05MB3206; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:DB6PR05MB3206; X-Forefront-PRVS: 0548586081 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(396003)(39380400002)(366004)(39860400002)(376002)(346002)(199004)(189003)(3846002)(2950100002)(33026002)(6916009)(97736004)(16586007)(5660300001)(6666003)(316002)(16526018)(4720700003)(48376002)(50466002)(47776003)(66066001)(21086003)(6116002)(86362001)(52116002)(76176011)(51416003)(7696005)(36756003)(478600001)(68736007)(55016002)(106356001)(105586002)(25786009)(386003)(7736002)(8936002)(4326008)(2351001)(2906002)(59450400001)(69596002)(50226002)(53936002)(2361001)(8676002)(81166006)(305945005)(107886003)(81156014); DIR:OUT; SFP:1101; SCL:1; SRVR:DB6PR05MB3206; 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; DB6PR05MB3206; 23:r/Jk1Bz7R0VKQ3R/eN9BeOqbF789QKem/zfvuNueP?= =?us-ascii?Q?Ee3s5EESJM8XESJBgoHeueAWZr/iQUzlX2NDqO1JnMiXbRRfk/OrPnlQ7EKI?= =?us-ascii?Q?LnKabLJUW/OitSEKlNWhWDG9dKaOnaS6AdNm3XzpfH2e7YYWdzsWQDeuYubR?= =?us-ascii?Q?/c2ZmtGiBALAhj7I+5/xP7tknKCxkJ7mi1Ky6PliEyGE0Rq88gK4nMlBvVoP?= =?us-ascii?Q?lkizdH7x13oTSwS+4tdKuR1LX9vDPLufTbF7A6T5EU2o9LVWnmJkGFClttjR?= =?us-ascii?Q?yr+kpC5Ru9fl8I6AIwTq4I/iIcCp7dFWqTsJzm5tdXJQ1AWWsAMA0MaJQUCX?= =?us-ascii?Q?fFAg+ELFOQm8hwax6AQWgEKmLwjOjU1rCCu8XR5nKTMS/sFkrXrG66B1Z6k0?= =?us-ascii?Q?IA4OhtfsccYzdDmp8S7xKBt2I7b3+0DQVsY1l7kt0ijR1eCejeS73Nx3+txD?= =?us-ascii?Q?uvZEYBD2F38m8r9455r2cGLyFxHl8882QaEliZQJyuI1i1MfydP69THo/w3c?= =?us-ascii?Q?bfhZlje6Mmf2CeYDJA5ZQTfMt4vKEFGlGCYbKJrngZ8CMe1mZJ/F1AdcR1J0?= =?us-ascii?Q?h021ay3oEkaJM/JiCRCx/FgWI0b6icFDpBmhDte8o1h2P/meB40aWynDG6Un?= =?us-ascii?Q?TzXSLX1i5FrPLCpHJa97mkaY2d+m/xMpKeXkCIQoSSlf5siRdqSztRRmkgYw?= =?us-ascii?Q?GOVP8q39P1b+qNB06QXr7dl+pNo09mzZDz+bp9N0mfsb+jZX3Y3oev8BWEyx?= =?us-ascii?Q?Dg/L4aH2G+zlWUsgNCC8pB+uyiA/139ZPF6n/5JYxQwwfO4pfHsAKopzoDiT?= =?us-ascii?Q?oONyLTKi5aOCdUzu8Bdl5zPnMkX+svXhEeqJG3H+3l6EmxwrYXLiASyZu/R/?= =?us-ascii?Q?qYXGve1uNiZx8QpznidLai+KmzGWIaMg5MBT9xgmsya2MOQF6/Imj7AhiEk+?= =?us-ascii?Q?jWVXlx3Jz7fkF2e0S69tiemzBZGX54Y05n/ObvA/hiNPdtsFLQNo1RtQ1VY+?= =?us-ascii?Q?ofkOuGWnOcL8/CpO45QXl3zDn5CHK73YEmNzkcb0StiRc5K8nCVr0c5z5gJL?= =?us-ascii?Q?hXWTtL0nNrhQ2blppqFJg50MUmDHzmiARH55zHMA05OmxeKgtkkNffqbHmsj?= =?us-ascii?Q?9KHC+S/8C8/cAD1hNxkqpLCojcN9Zz4V4YupEFjFJtOBXl4k/iKfTVLs81l8?= =?us-ascii?Q?sslUbhlbhSP5UV+YndLcUnn+fttLYNmTHrRphxxRaZK6ixiqwm2tpVz2g=3D?= =?us-ascii?Q?=3D?= X-Microsoft-Exchange-Diagnostics: 1; DB6PR05MB3206; 6:4p6Jrysw/o5QfjpGhA9RwG73ZJK/pTvYcTHQWPl1VUmP5YFRwrjoL1RixgWBh0UqU5lOieGfZN8WFxmbGObTpoEMknPY2WiLL9Ssy9N7FSGPZBYeSoQ5xvvZeHmSW7bHQBVHEGkDI4Cg/mv417Hxif36fDTRPevgwxVnUIJZunTe9v30LCd67wL9OUw2JFRlozMS2Mojzw08zbiCQ0pf/GqWtDwK9zTTeJQi2HCBMbi2ELSdiGyV4AVwp1LWnz0vhlUqfIknWER/xypk2E38bD8BQC2h5KYuuRalL8nzA10MgZLAOjICsWWKaK7Svafo8Iz1ZU+qWeIqQfkfHAC0J9SiRKHSLCTbsaQ2RNErYLA=; 5:A0FN34YFZjv44BK7BOTZzQSBwA6zds+eD70nFVupYUerunVySmYZ9JNFaviYtbgXnK8eiikJ9K2BRxDOXOoc8iov1v/DURtDNlemI6bb3V/aKPrQhgcWGe03UR9ypBTdjly+xd/Tuxv2ajrkrjPvu5rGEu72SiRiVhypEcNzijs=; 24:fKAjJrJjjRNstSUa91wcrr2i0KRiSL49l/JFpaDkIftZ8mE+H/nQlN8cgIdjeZTZejJgKMQMDEd8buw+GAHzG1+vUGdRfyCW435SDqM9ozI=; 7:7lJByXUl3BSQpCtMXg8FhZPMyHzlmolJCDaCSVIv32tFy4mT1Fm6eg3a//8zimiOoPc8JTqtLlw+B0pynfQfro8vWlMwcW7FKa0q/IX0G6i30YRFl0pEhT28SuPUiRP9CSYEef21dC46Ba6AY4/vAyP+7Q0ol0rSK5Bx1jwVCxdMprP9W76oTv9LGmStc6GG533N2hX2y6SsarBADTsXy/hxDdRO0x2hVfs6BnR3GCcQA2RWcGBpEnE4y+cLHTGS SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Jan 2018 16:21:06.6806 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 86c3dc87-f241-48f8-8b9c-08d55846275a X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR05MB3206 Subject: [dpdk-dev] [PATCH V4 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: Wed, 10 Jan 2018 16:21:09 -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