From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0080.outbound.protection.outlook.com [104.47.0.80]) by dpdk.org (Postfix) with ESMTP id 96A411B1B9 for ; Tue, 12 Dec 2017 13:27:38 +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=xtn/of9l3InJc/5AixDksJsimjlUA/1VZ0207X2Mbfs=; b=Fp7nlLOC7vEtIg+aejsMQ1J31gj2HaEI8RP55nLYSEVxrDFd3OwqrF7z/X+BPKMjVaESmEBqzQrU3ROMi2oXbZheDQnbDlaa4grrNYk9KLVaSSNOFi2MptwEaenspqWGx7drNVslQ48gsmbIKu/QNMd9tLI5ycOuDn2ddwUQap8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=shahafs@mellanox.com; Received: from mellanox.com (82.166.227.17) by VI1PR05MB3149.eurprd05.prod.outlook.com (2603:10a6:802:1b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.302.9; Tue, 12 Dec 2017 12:27:36 +0000 From: Shahaf Shuler To: dev@dpdk.org, konstantin.ananyev@intel.com, radu.nicolau@intel.com, arybchenko@solarflare.com Date: Tue, 12 Dec 2017 14:26:28 +0200 Message-Id: <80ffa44142adf75fc4d5ca524cc04085b62ad841.1513081087.git.shahafs@mellanox.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: References: <20171123121419.144132-1-shahafs@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [82.166.227.17] X-ClientProxiedBy: HE1P191CA0010.EURP191.PROD.OUTLOOK.COM (2603:10a6:3:cf::20) To VI1PR05MB3149.eurprd05.prod.outlook.com (2603:10a6:802:1b::14) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 19e4b803-a39c-4cc4-d9cf-08d5415bba78 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(5600026)(4604075)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(48565401081)(2017052603307); SRVR:VI1PR05MB3149; X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB3149; 3:qOI/vfuH6BRA0XZbVlitKY20zOORVGiSe6BC8vx9nC+F+Z1/ABKFIty2exwcWgFyKW4wH7Cz+Er/7xpTP3xZGfDxXdxtIoWGDiA1xKEJMKBIr12RztVEad/8yx562cZmgv4oLYK+97XCfKF+gswP9V1sus+UN931tgADiTP8bL63jw1iHV7I2nItBh1wR6VKfgHAtrjKqgt3exxeSRGjhR+4d2c4hkDELjxUbNxJKT4bfMuqMY0UJRyJec2dBf6b; 25:2SsKNvfOUrzcIutdBfWYFw+z3ZOBae5Zh1c0GbeWYBlvYHwcdW/9UT0IqbS+OuHToaX+lnZCfzEOtebewzjWFuzB+lgf1SxhVJ5A6OCHSuchuiYENJCTgj7xrdAP/TpEydFOe+miTry2Lh6IKOiyg4MjoYPm76YQtca+8ba9+E9tbAz/5uFm1d5D1J/JjyFO6TDiBVhA9WsXhDaEMrdyBfSJjn/ZMqgilLbBXSirO/w5YRJyQefA9Sac2HD7qTxr88LB7muj31+BdYBsVU7haruN0gjkcicWaDQSfU5/VEv5Ui6rXZczZP4RtnLidAPn+tTPkcE4Ze6PZxiSyfFsIg==; 31:4TcoN3ymlok5qmg9FfTaUTPTCUhOwbVKgqOWe2A3RgfIqRADyla+NwL0NZ6HBgD38eWqHE9xpz30yQkU1Jf949SMu1dwBQCqj8DMXur0e+30amH9vxinvqqsnIefaAKclscUxOZX7jA3Cq1Moy6459V9Ky1CPc3IgyT46tfYLkAF+vqN8MjiJXhQsLmuMieTl2NzJGkXWaLivBNvw37xENr2pjadTDZVmJaMX0QuKhk= X-MS-TrafficTypeDiagnostic: VI1PR05MB3149: X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB3149; 20:ohnfNhgs+VXRX4gaooc4Cca8p451IEeJ43P+BO+rtg3H4AVkUeUM0QN3kpJyyDmxu1H6V4usgVj0qFBY+l7uS1QMEOJ6h1twp3SJQcymun/vvwgip9aDPqprEjIRY4b3wnvQNwxFhC3oe7M8a9N/tlk/OcpllaM2RFi74h2jfurrLNPOTvo5ZtFP5DQet/dMx8kiSewMkXRMUB9ftD1ZeUWhv/6IGTS4j/x/8MNaRSCZz5WyOr+hptP9eza1cWLCZVXZMuQFvac9jlMFyVWpHE64vXmnez3xiPHt8piAIA8dtfr6fwmX/Tc/j7gDwuJSR3TSGOkwQCpuNSlaOjpvmJJASF1M+Yl3rfrqJ83omyLdrdCmart6shvY2AW1OnemH5+fRdvFOim7d0zJIyZp9BGFpxyZTrspzdJyR0LCrnNLzxYtJVDjf3G78K/LngG9QiIZDqvohKo4UoWcGbGlxNnGPBccHknr7e2ePL0Uvxdqwek2EVPH5/Qyaeir0Aym; 4:0C3qQMHeu9eYStJeLBucVyJb5Dzy3i74AuoTWgz7JXjZM8JEq+lOjoE38dfcTaXn335xdaY6h7HpI6hFV3kCrzc52i5mtszQgorD1tZ37bWraH2jCdwEL0EyCjrY4wccU5Y3/B3ArjZl5+e4l+g1QGu1LEu06X0gEiJJLqa/hSc3HV/v0JNvt4x2AdsVrJZ1qHvzGbQ0aSqWwnxGTSRpwFRlM6iaNVtYaLBGQZo/IteBvzyZ1SFb9uRt7X0OHA1nPNp4UfJxxSd92s2YjkcGBQ== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040450)(2401047)(8121501046)(5005006)(10201501046)(93006095)(93001095)(3002001)(3231023)(6055026)(6041248)(20161123564025)(20161123558100)(20161123562025)(20161123555025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(6072148)(201708071742011); SRVR:VI1PR05MB3149; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:VI1PR05MB3149; X-Forefront-PRVS: 051900244E X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(346002)(376002)(39860400002)(366004)(189003)(199004)(7736002)(8936002)(305945005)(66066001)(3846002)(5660300001)(47776003)(6116002)(2906002)(69596002)(68736007)(48376002)(33026002)(2950100002)(50466002)(81166006)(21086003)(81156014)(6666003)(8676002)(106356001)(105586002)(118296001)(97736004)(478600001)(51416003)(25786009)(316002)(52116002)(7696005)(50226002)(86362001)(55016002)(36756003)(59450400001)(76176011)(16586007)(53936002)(16526018); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR05MB3149; H:mellanox.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A: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; VI1PR05MB3149; 23:tVQ+qk9te5V3GqA4X2sfgS8+ka+ZgDN9ijpwugFLv?= =?us-ascii?Q?SmfpofVAejCU+VesQsQOxHab0V3V7w/pYDHa2f+XDF8VtPME5fS/1DLTfv9x?= =?us-ascii?Q?jzpJtoY8KzyZKKa7gKIf1nVddLxdgNihZwHHeahSLPpUYEyn60im4AOMFtiO?= =?us-ascii?Q?iwqf7xLBiD/CGf47h092fn4yHuEn6FjsWXe2uvLGAlzEHIwcbPXsE4JoAT+d?= =?us-ascii?Q?oo5d5+2Y1b0xG9v49c31O5+yn7WrpqmnIgXxMbt44VGlnu0/yGGy2xPttDQr?= =?us-ascii?Q?V8UuI/2uoJ7GPZFXyG3Uw5KG3rc41swYpk+Ye8yTPQERCUkZtnXFpxOpDctK?= =?us-ascii?Q?9Dm+G3f4qKLNRCerDe21wo9D+P/hzRvu974lrhRSpxffo1Vi0jfqqg+IgrpJ?= =?us-ascii?Q?oTplRgm2MNsVBUtSV8yvEsDQ5wwaqfUI6V9BC77aJouJzXoVhrOc73Gn9PQv?= =?us-ascii?Q?3LxbKfTVGgz/x4Ne9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goABGu8n7I/uYF9qswWUkL2sC5tcEtCOQPQJDfMblGUb+eqjMrwcowUtskDi0A6Nar9WI55LYs759Q=; 5:1YWBHE9TK2o4SnHb0ubfIwlYjXYCwW5yFdnyaauwxb4Br3r9rSnKFc9Mt/Htlj3nbnYpZaoZU1pZkBOEyx3r7QzzxYARgsQ/uthi9/9Apvc+nmwcVDYUdPUtdNDlTypiaWXgb60BE0WHX9CeQ8JFv19dViTTmu+NETqfCWePm8Y=; 24:H1K8bUuP8PlTsvzHzAHYmqPXV5K20vzdfnTNsM7JfQ/d3D+/YH0K2RewkO5i4z8pzG6M45UGfQbSbR7XjSnSWY3OmYjjBImTFFe+zSotSK4=; 7:gV5v8t8eA40KyUUQHzJH28rpR4UA255p7s/sXCIPG/RTYDkuNArcYqzpSsxnQjjp84RZSoULjT01G7Ea7HGVR2uSft3UCSylYOFGP+8+EW+PDcYgcGBTPnFZdRTLJ+MbmuwDUtmkVOYUvcv0y/lAzkrvjAHgFUSop3ZGWSSx7Mr1GOGTV1RAq/YZ0VhTYkvghqHztlGFX73uDs8pFc6B28c85r2xs/l3ytnlIabR1mboGyMf7jT3tgR2pAbfETW/ SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Dec 2017 12:27:36.0354 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 19e4b803-a39c-4cc4-d9cf-08d5415bba78 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB3149 Subject: [dpdk-dev] [PATCH v2 11/39] examples/kni: convert to new ethdev 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: Tue, 12 Dec 2017 12:27:38 -0000 Ethdev offloads API has changed since: commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API") commit cba7f53b717d ("ethdev: introduce Tx queue offloads API") This commit support the new API. Signed-off-by: Shahaf Shuler --- examples/kni/main.c | 66 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 57 insertions(+), 9 deletions(-) diff --git a/examples/kni/main.c b/examples/kni/main.c index 3f17385..6a35579 100644 --- a/examples/kni/main.c +++ b/examples/kni/main.c @@ -124,14 +124,12 @@ struct kni_port_params { /* Options for configuring ethernet port */ static struct rte_eth_conf port_conf = { .rxmode = { - .header_split = 0, /* Header Split disabled */ - .hw_ip_checksum = 0, /* IP checksum offload disabled */ - .hw_vlan_filter = 0, /* VLAN filtering disabled */ - .jumbo_frame = 0, /* Jumbo Frame Support disabled */ - .hw_strip_crc = 1, /* CRC stripped by hardware */ + .ignore_offload_bitfield = 1, + .offloads = DEV_RX_OFFLOAD_CRC_STRIP, }, .txmode = { .mq_mode = ETH_MQ_TX_NONE, + .offloads = DEV_TX_OFFLOAD_MBUF_FAST_FREE, }, }; @@ -607,10 +605,28 @@ struct kni_interface_stats { int ret; uint16_t nb_rxd = NB_RXD; uint16_t nb_txd = NB_TXD; + struct rte_eth_dev_info dev_info; + struct rte_eth_rxconf rxq_conf; + struct rte_eth_txconf txq_conf; /* Initialise device and RX/TX queues */ RTE_LOG(INFO, APP, "Initialising port %u ...\n", (unsigned)port); fflush(stdout); + rte_eth_dev_info_get(port, &dev_info); + if ((dev_info.rx_offload_capa & port_conf.rxmode.offloads) != + port_conf.rxmode.offloads) { + printf("Some Rx offloads are not supported " + "by port %d: requested 0x%lx supported 0x%lx\n", + port, port_conf.rxmode.offloads, + dev_info.rx_offload_capa); + } + if ((dev_info.tx_offload_capa & port_conf.txmode.offloads) != + port_conf.txmode.offloads) { + printf("Some Tx offloads are not supported " + "by port %d: requested 0x%lx supported 0x%lx\n", + port, port_conf.txmode.offloads, + dev_info.tx_offload_capa); + } ret = rte_eth_dev_configure(port, 1, 1, &port_conf); if (ret < 0) rte_exit(EXIT_FAILURE, "Could not configure port%u (%d)\n", @@ -621,14 +637,19 @@ struct kni_interface_stats { rte_exit(EXIT_FAILURE, "Could not adjust number of descriptors " "for port%u (%d)\n", (unsigned)port, ret); + rxq_conf = dev_info.default_rxconf; + rxq_conf.offloads = port_conf.rxmode.offloads; ret = rte_eth_rx_queue_setup(port, 0, nb_rxd, - rte_eth_dev_socket_id(port), NULL, pktmbuf_pool); + rte_eth_dev_socket_id(port), &rxq_conf, pktmbuf_pool); if (ret < 0) rte_exit(EXIT_FAILURE, "Could not setup up RX queue for " "port%u (%d)\n", (unsigned)port, ret); + txq_conf = dev_info.default_txconf; + txq_conf.txq_flags = ETH_TXQ_FLAGS_IGNORE; + txq_conf.offloads = port_conf.txmode.offloads; ret = rte_eth_tx_queue_setup(port, 0, nb_txd, - rte_eth_dev_socket_id(port), NULL); + rte_eth_dev_socket_id(port), &txq_conf); if (ret < 0) rte_exit(EXIT_FAILURE, "Could not setup up TX queue for " "port%u (%d)\n", (unsigned)port, ret); @@ -702,7 +723,10 @@ struct kni_interface_stats { kni_change_mtu(uint16_t port_id, unsigned int new_mtu) { int ret; + uint16_t nb_rxd = NB_RXD; struct rte_eth_conf conf; + struct rte_eth_dev_info dev_info; + struct rte_eth_rxconf rxq_conf; if (port_id >= rte_eth_dev_count()) { RTE_LOG(ERR, APP, "Invalid port id %d\n", port_id); @@ -717,19 +741,43 @@ struct kni_interface_stats { memcpy(&conf, &port_conf, sizeof(conf)); /* Set new MTU */ if (new_mtu > ETHER_MAX_LEN) - conf.rxmode.jumbo_frame = 1; + conf.rxmode.offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME; else - conf.rxmode.jumbo_frame = 0; + conf.rxmode.offloads &= ~DEV_RX_OFFLOAD_JUMBO_FRAME; /* mtu + length of header + length of FCS = max pkt length */ conf.rxmode.max_rx_pkt_len = new_mtu + KNI_ENET_HEADER_SIZE + KNI_ENET_FCS_SIZE; + rte_eth_dev_info_get(port_id, &dev_info); + if ((dev_info.rx_offload_capa & conf.rxmode.offloads) != + conf.rxmode.offloads) { + printf("Some Rx offloads are not supported " + "by port %d: requested 0x%lx supported 0x%lx\n", + port_id, conf.rxmode.offloads, + dev_info.rx_offload_capa); + } ret = rte_eth_dev_configure(port_id, 1, 1, &conf); if (ret < 0) { RTE_LOG(ERR, APP, "Fail to reconfigure port %d\n", port_id); return ret; } + ret = rte_eth_dev_adjust_nb_rx_tx_desc(port_id, &nb_rxd, NULL); + if (ret < 0) + rte_exit(EXIT_FAILURE, "Could not adjust number of descriptors " + "for port%u (%d)\n", (unsigned int)port_id, + ret); + + rxq_conf = dev_info.default_rxconf; + rxq_conf.offloads = conf.rxmode.offloads; + ret = rte_eth_rx_queue_setup(port_id, 0, nb_rxd, + rte_eth_dev_socket_id(port_id), &rxq_conf, pktmbuf_pool); + if (ret < 0) { + RTE_LOG(ERR, APP, "Fail to setup Rx queue of port %d\n", + port_id); + return ret; + } + /* Restart specific port */ ret = rte_eth_dev_start(port_id); if (ret < 0) { -- 1.8.3.1