From patchwork Thu Dec 19 11:54:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Britstein X-Patchwork-Id: 1213261 X-Patchwork-Delegate: i.maximets@samsung.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.136; helo=silver.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=mellanox.com Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47dr1r11lNz9sPn for ; Thu, 19 Dec 2019 22:56:16 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 8A82324D71; Thu, 19 Dec 2019 11:56:14 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nM9ntkCti+iN; Thu, 19 Dec 2019 11:56:08 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by silver.osuosl.org (Postfix) with ESMTP id 49FCE20406; Thu, 19 Dec 2019 11:55:06 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 09BC0C1D89; Thu, 19 Dec 2019 11:55:06 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 2B0F3C1D88 for ; Thu, 19 Dec 2019 11:54:51 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 11CB28865C for ; Thu, 19 Dec 2019 11:54:51 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FMPxICKEW3RT for ; Thu, 19 Dec 2019 11:54:49 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by hemlock.osuosl.org (Postfix) with ESMTP id 5FC54885DE for ; Thu, 19 Dec 2019 11:54:47 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE1 (envelope-from elibr@mellanox.com) with ESMTPS (AES256-SHA encrypted); 19 Dec 2019 13:54:41 +0200 Received: from dev-r-vrt-215.mtr.labs.mlnx. (dev-r-vrt-215.mtr.labs.mlnx [10.212.215.1]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id xBJBserP014710; Thu, 19 Dec 2019 13:54:41 +0200 From: Eli Britstein To: dev@openvswitch.org, Ilya Maximets Date: Thu, 19 Dec 2019 11:54:25 +0000 Message-Id: <20191219115436.10354-8-elibr@mellanox.com> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20191219115436.10354-1-elibr@mellanox.com> References: <20191219115436.10354-1-elibr@mellanox.com> Cc: Oz Shlomo , Simon Horman , Majd Dibbiny , Eli Britstein , Ameer Mahagneh Subject: [ovs-dev] [PATCH V6 07/18] netdev-offload-dpdk: Framework for actions offload X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Currently HW offload is accelerating only the rule matching sequence. Introduce a framework for offloading rule actions as a pre-step for processing the rule actions in HW. In case of a failure, fallback to the legacy partial offload scheme. Note: a flow will be fully offloaded only if it can process all its actions in HW. Signed-off-by: Eli Britstein Reviewed-by: Oz Shlomo --- lib/netdev-offload-dpdk.c | 104 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 88 insertions(+), 16 deletions(-) diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c index 5345c434c..12da62a10 100644 --- a/lib/netdev-offload-dpdk.c +++ b/lib/netdev-offload-dpdk.c @@ -56,6 +56,7 @@ struct ufid_to_rte_flow_data { struct cmap_node node; ovs_u128 ufid; struct rte_flow *rte_flow; + bool actions_offloaded; }; /* Find rte_flow with @ufid. */ @@ -76,7 +77,7 @@ ufid_to_rte_flow_data_find(const ovs_u128 *ufid) static inline void ufid_to_rte_flow_associate(const ovs_u128 *ufid, - struct rte_flow *rte_flow) + struct rte_flow *rte_flow, bool actions_offloaded) { size_t hash = hash_bytes(ufid, sizeof *ufid, 0); struct ufid_to_rte_flow_data *data = xzalloc(sizeof *data); @@ -95,6 +96,7 @@ ufid_to_rte_flow_associate(const ovs_u128 *ufid, data->ufid = *ufid; data->rte_flow = rte_flow; + data->actions_offloaded = actions_offloaded; cmap_insert(&ufid_to_rte_flow, CONST_CAST(struct cmap_node *, &data->node), hash); @@ -697,24 +699,89 @@ add_flow_mark_rss_actions(struct flow_actions *actions, add_flow_action(actions, RTE_FLOW_ACTION_TYPE_END, NULL); } -static int -netdev_offload_dpdk_add_flow(struct netdev *netdev, - const struct match *match, - struct nlattr *nl_actions OVS_UNUSED, - size_t actions_len OVS_UNUSED, - const ovs_u128 *ufid, - struct offload_info *info) +static struct rte_flow * +netdev_offload_dpdk_mark_rss(struct flow_patterns *patterns, + struct netdev *netdev, + uint32_t flow_mark) { + struct flow_actions actions = { .actions = NULL, .cnt = 0 }; const struct rte_flow_attr flow_attr = { .group = 0, .priority = 0, .ingress = 1, .egress = 0 }; - struct flow_patterns patterns = { .items = NULL, .cnt = 0 }; - struct flow_actions actions = { .actions = NULL, .cnt = 0 }; + struct rte_flow_error error; struct rte_flow *flow; + + add_flow_mark_rss_actions(&actions, flow_mark, netdev); + + flow = netdev_offload_dpdk_flow_create(netdev, &flow_attr, patterns->items, + actions.actions, &error); + + free_flow_actions(&actions); + return flow; +} + +static int +parse_flow_actions(struct netdev *netdev OVS_UNUSED, + struct flow_actions *actions, + struct nlattr *nl_actions, + size_t nl_actions_len, + struct offload_info *info OVS_UNUSED) +{ + struct nlattr *nla; + size_t left; + + NL_ATTR_FOR_EACH_UNSAFE (nla, left, nl_actions, nl_actions_len) { + VLOG_DBG_RL(&rl, "Unsupported action type %d", nl_attr_type(nla)); + return -1; + } + + if (nl_actions_len == 0) { + VLOG_DBG_RL(&rl, "Unsupported action type drop"); + return -1; + } + + add_flow_action(actions, RTE_FLOW_ACTION_TYPE_END, NULL); + return 0; +} + +static struct rte_flow * +netdev_offload_dpdk_actions(struct netdev *netdev, + struct flow_patterns *patterns, + struct nlattr *nl_actions, + size_t actions_len, + struct offload_info *info) +{ + const struct rte_flow_attr flow_attr = { .ingress = 1, .transfer = 1 }; + struct flow_actions actions = { .actions = NULL, .cnt = 0 }; + struct rte_flow *flow = NULL; struct rte_flow_error error; + int ret; + + ret = parse_flow_actions(netdev, &actions, nl_actions, actions_len, info); + if (ret) { + goto out; + } + flow = netdev_offload_dpdk_flow_create(netdev, &flow_attr, patterns->items, + actions.actions, &error); +out: + free_flow_actions(&actions); + return flow; +} + +static int +netdev_offload_dpdk_add_flow(struct netdev *netdev, + const struct match *match, + struct nlattr *nl_actions, + size_t actions_len, + const ovs_u128 *ufid, + struct offload_info *info) +{ + struct flow_patterns patterns = { .items = NULL, .cnt = 0 }; + bool actions_offloaded = true; + struct rte_flow *flow; int ret = 0; ret = parse_flow_match(&patterns, match); @@ -722,22 +789,27 @@ netdev_offload_dpdk_add_flow(struct netdev *netdev, goto out; } - add_flow_mark_rss_actions(&actions, info->flow_mark, netdev); - - flow = netdev_offload_dpdk_flow_create(netdev, &flow_attr, patterns.items, - actions.actions, &error); + flow = netdev_offload_dpdk_actions(netdev, &patterns, nl_actions, + actions_len, info); + if (!flow) { + /* if we failed to offload the rule actions fallback to mark rss + * actions. + */ + flow = netdev_offload_dpdk_mark_rss(&patterns, netdev, + info->flow_mark); + actions_offloaded = false; + } if (!flow) { ret = -1; goto out; } - ufid_to_rte_flow_associate(ufid, flow); + ufid_to_rte_flow_associate(ufid, flow, actions_offloaded); VLOG_DBG("%s: installed flow %p by ufid "UUID_FMT"\n", netdev_get_name(netdev), flow, UUID_ARGS((struct uuid *)ufid)); out: free_flow_patterns(&patterns); - free_flow_actions(&actions); return ret; }