From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-eopbgr60056.outbound.protection.outlook.com [40.107.6.56]) by dpdk.org (Postfix) with ESMTP id BBB752BF3 for ; Wed, 17 Jan 2018 15:04:55 +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=YFipszhx5GGjR4Tr9ldM4p1hDDXsTP1UvN9RVF1bK2Q=; b=vatuyzWlLO08U9ztXAUckHZR2GV7GZxdAAOLd9LsYu5EDSpSyl3OqL5RcLuKWnU08JZ6BVYau53hGrZQ7qoQxSK6Su8REZFr4yhVYjf6G/TO4G29DuEiL7+qkmTra9WtKRA4t8SQ0AR4IrnrjBDqjAMoFDIebCOmc+5wDzvrU6I= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=motih@mellanox.com; Received: from mellanox.com (37.142.13.130) by VI1PR05MB3215.eurprd05.prod.outlook.com (2603:10a6:802:1b::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.407.7; Wed, 17 Jan 2018 14:04:52 +0000 From: Moti Haimovsky To: pascal.mazon@6wind.com Cc: ferruh.yigit@intel.com, dev@dpdk.org, Moti Haimovsky Date: Wed, 17 Jan 2018 16:04:33 +0200 Message-Id: <1516197874-133169-1-git-send-email-motih@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1515601248-39458-2-git-send-email-motih@mellanox.com> References: <1515601248-39458-2-git-send-email-motih@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: HE1PR06CA0147.eurprd06.prod.outlook.com (2603:10a6:7:16::34) To VI1PR05MB3215.eurprd05.prod.outlook.com (2603:10a6:802:1b::32) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: f76b1231-a485-4491-268e-08d55db3485b X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:VI1PR05MB3215; X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB3215; 3:JLpEx6q5Ee3a5iQ+VLwKIAVvWjxNPGQU47ewUD327BdL5PeytYQdtNhu2bHvQFgpXw5MlrRPJbKlqKOPucpKRkZjyhDnIxf2Q0oSeWiQSZYjWpUzXq9TOsnw/VJ3XUmmJTrv4W7IuPJBupzdKkSOPWuSSoK5m9Y6uS50jZay6+eNAe0i/5RB7Q1ytsOC27uLY2sHAAVQyw4MqFc/Ch/bBsUvEatjB/CN7aGsDu0Yj+OJGD/z3/COXYSph7TchuAN; 25:QZyJHJExdnIkM6KWAZB7joX+f2By1HvyevkslxJXQo2mcFcgAKv5ciXG5QRAbjsGYo8KgacokVPnBZgCJX1L7yfLqSimDhU6965EMN2C/3YrDaSIf0b6jauv6W2+sw0GTU7nxFYIox/qGyTfJAKbZ2JQrao1/6wlGtfVC645E+TGa7ypH9vpuo9jZoMtymFLe7ypRujeHfZae8EFCxh+v2Gsu0Xjq7ZjN+UVy8brNfdBPbPml/XYdqx38Nlc14pFbDs29/6VqNpBRvSDShGidkw008ByDpom9N3oLWpd+5HvrxSnMHt8DUGzR74dbMgoQZN506WwsZPx+iwPn5ycNA==; 31:o8B5dCfIJhIxA+uA06lkhdNj2BCO+Plqx7Ca7Xwk7u7PTKFwyUtr0S/sqyMa6Py9c63i46GooflVGsBP9RN+zzPKRs9/ZwpI/zN2MEQXtPxCi476U/N1ZDydSytNvElkGeUMwOKvQHqqOhRyg78CR7NyjE2uOdwedCPgdjIPTHj6lucfTkxgpfz8YKTYOmnyVkCgrI57tQwXpD37qmVDxt+5ToHvuff6kA9rJa8a6zI= X-MS-TrafficTypeDiagnostic: VI1PR05MB3215: X-Microsoft-Exchange-Diagnostics: 1; VI1PR05MB3215; 20:qlLjhkYMdRSpCy2AfL7Yv7HkFzy1hKE5MrizZDuGywfRk5/Tdx4DLE2rYQGRlKIICtrqzgbLgjLYdT90PxahO+88DF43jaorYguWU2Rz+yweV1qmbXkcAbDYITrVJ/0bn63uTm8Hy0uEzhJ5YFjlqbh3Wmy9RL4VNngjKPR8LtnHFlxWT2Np9vmaMSWxJc9l1mR3ApCWTWCdkaC4l4Y/rLmZziMJcERcCcLmrvTMIpEbUpjo3eHhNW02q53FClfjHsL/nxLcjR0VgEEd9Hea4262dvLO9wczF2qMV99hMc588BnUZmEr2VPVcunWmL7ygUMMgJAZlldA1FgA9iY674Ck6VyugmwLcpQDRDrKeU7pCofB5QgQBw5zn6cO5Vr8b+Zl5mNmacfMmiN5JTQXXgUtV5bo0ectWtE3fG/h2ckPzVxoy7L5qPjOwXaQ2nX9WvpkoKnnfRniLO/hpRzlZ/hl+DW70dj3G1iQA0qaplJfGA6OyIiOVNi2REaCnU4X; 4:e7Np3bHMCgLt6F+i5d26DyR5RfwSPa2m5f5CdnvNziZXsNNtEXv5/VcKNgea7Wapklm6cNP4FUhFrT773yuWwSZ/Qj5IockIq2tWlZJlOP8s2A/sHAO21xQ4gGtuhKvvpSHoDNmOfOnnLkceZgMmkIti7PI65MnUwvWjn/0onn2LnND6duFbw5mdJLNwh1YwNiRm7Jf3fj81m08k8f7QrjLumIpqi4OViyUdNXE4Zs3kkni4143Gn6WqHOq9llQpg2pOtleNqp7WnGscLlvXiQ== 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)(93006095)(93001095)(3231023)(944501161)(10201501046)(6055026)(6041268)(20161123562045)(20161123564045)(20161123558120)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:VI1PR05MB3215; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:VI1PR05MB3215; X-Forefront-PRVS: 0555EC8317 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(376002)(396003)(346002)(366004)(39380400002)(39860400002)(189003)(199004)(51416003)(97736004)(106356001)(69596002)(6666003)(4720700003)(305945005)(105586002)(33026002)(5660300001)(26005)(2950100002)(6916009)(76176011)(478600001)(59450400001)(50226002)(81156014)(8936002)(8676002)(81166006)(2351001)(386003)(21086003)(68736007)(316002)(2361001)(16586007)(86362001)(50466002)(2906002)(48376002)(107886003)(3846002)(16526018)(55016002)(25786009)(53936002)(4326008)(52116002)(7696005)(7736002)(6116002)(66066001)(36756003)(47776003); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR05MB3215; 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; VI1PR05MB3215; 23:IEmucshPDcXwtuqE5MjEp8Zn4gU6bawUtH05am1cA?= =?us-ascii?Q?omfDFZR/Me7hcbx/GLjlhTWbxqbcUCwPJ/RwS47nmKQ7it2ZQFgXXGNV6g+u?= =?us-ascii?Q?UGVKEGgR2e2I3ysyecGKT/3/XByLIWqJiZtgAT9iOsYT7yfrj3QELohlucMa?= =?us-ascii?Q?q86bopYdXrKBL1IkJ5MuVzJ8xXlQbiSvpPjxB8YrroYHyTazLZsGKjpz7NDS?= =?us-ascii?Q?3rcrJUFalODsa69842Z6bjS2nGFAo9vZ6AI8PPHAatUuKzhQLXky/hPX8+fe?= =?us-ascii?Q?WRZYjs0QY2+wtXvvkPxXc6/0SqjJ69JrFQj6KCUQda75CbYT4bwh/VvkwYnY?= =?us-ascii?Q?PYj8vGBUuemTy8s3IT5ReW3yTOpdHBxcCZm+mYH83GOn0nq6+9raIVpCETG4?= =?us-ascii?Q?sJleezmaKcb9zkWKmvlWgtseVcfTJEfT3aFwMMXGFWE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oNTI6iVHRbi413s7mO5UXG4Gwd4bQKDD6NXGTvKdHyBFgStkkDDzx45AgewZf3ZZF8BhiUeopKCoavxFnxg+0AP9eaPbiztql/ERvATykOkZ7eeuGCEFFicDxOuilqBUgL6rbU5rZpuNU4ENHV++8unNEmYusX6dI6uqxmRj9DvwrIHUFKjYmY8/FOw/esv9aQOE6dEW21ZY+5y5WI6yqmITcc08CswCQLPr52IN0VOb1MY8Fs8dwgeKV2QXqjvmsQ1VeMiMMyqmtI9Lf1BeEb5+bu2mJZFQF8KFh1kUmAQx97DzaEVuWUWjbFlul44NbkT7AVDI/pKLnnxe+QvZ4fKfI=; 5:X67EAqQ2NCDBJL1ZSuJQH49aOGW2TLmtbDtDFg+8dzKrTBOUE/4OywvQXA6HnGg3JzNUiTOOSrNXsugMTrYJ0iC7uVKcnYY/2POtp/B68P4Gs23jHzurepVzJ95jEo+chBBNBztDKXaaY8PWlY7mkoAsqlrQVAN78u3pQye5Kt4=; 24:JTdRoYP6L++tpScM5lPbw9Psx25TqWCTELJJuz6I95HkqnXN2/kySEvyjEEGjvKIyT3THMYQV1T487OFkvDqK5kfQ6TpvlVUs0z4akvbGpc=; 7:5s/8Y0Yp2e/4RX9TZvYQX7idRd2WSkZ0FhWpNvpoP9FOXn4XjE1ozDpuOG5tGbH5t9l7DRWrIintVyHjZS3PifuEZ9coXY3UTgWO1q/3J3FF1Co0VN8GZJ5av0c23+Nxb5qt5fc3OrNaCdZqXxZwo3WVdo7JDvtzdFAoM7y4U8zl+l06ZE5yoUrIE6Ol/ySeo8pKNERe1XsXz4o+oxHQRmtE1m5NvVW1uNld4lgMw4ieXuIppYSvyNBL2e0KqAK7 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jan 2018 14:04:52.8661 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f76b1231-a485-4491-268e-08d55db3485b X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB3215 Subject: [dpdk-dev] [PATCH V5 1/2] net/tap: use 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, 17 Jan 2018 14:04:56 -0000 Ethdev Tx offloads API has changed since: commit cba7f53b717d ("ethdev: introduce Tx queue offloads API") This commit adds support for the new Tx offloads API. Signed-off-by: Moti Haimovsky --- V5: * Fixed compilation errors caused by not using PRIx64 in log messages when displaying uint64_t values. * Modified patch name V3: * Fixed coding style warnings V2: * Fixed coding style warnings --- drivers/net/tap/rte_eth_tap.c | 97 +++++++++++++++++++++++++++++++++++++------ drivers/net/tap/rte_eth_tap.h | 1 + 2 files changed, 86 insertions(+), 12 deletions(-) diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c index be73f93..7357dce 100644 --- a/drivers/net/tap/rte_eth_tap.c +++ b/drivers/net/tap/rte_eth_tap.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -346,6 +347,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) @@ -432,9 +469,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; @@ -572,6 +610,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%" PRIx64 " supported 0x%" PRIx64 "\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", @@ -648,10 +697,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 @@ -1025,21 +1073,46 @@ 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%" PRIx64 + " don't match port offloads 0x%" PRIx64 + " or supported offloads 0x%" PRIx64, + (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