From patchwork Thu Dec 19 11:54:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Britstein X-Patchwork-Id: 1213251 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 47dr0g4JYXz9sPh for ; Thu, 19 Dec 2019 22:55:15 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id DEB0123453; Thu, 19 Dec 2019 11:55:13 +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 Ro+XlR1zKihr; Thu, 19 Dec 2019 11:55:07 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by silver.osuosl.org (Postfix) with ESMTP id 470DE23455; Thu, 19 Dec 2019 11:54:55 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 1B868C1D89; Thu, 19 Dec 2019 11:54:55 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id ACB12C077D for ; Thu, 19 Dec 2019 11:54:49 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 99E7A87E9B for ; Thu, 19 Dec 2019 11:54:49 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jn-4GTWdwqVr for ; Thu, 19 Dec 2019 11:54:48 +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 whitealder.osuosl.org (Postfix) with ESMTP id 5ECFA87EA8 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:42 +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 xBJBserW014710; Thu, 19 Dec 2019 13:54:41 +0200 From: Eli Britstein To: dev@openvswitch.org, Ilya Maximets Date: Thu, 19 Dec 2019 11:54:32 +0000 Message-Id: <20191219115436.10354-15-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 14/18] netdev-offload-dpdk: Support offload of output action 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" Support offload of output action, also configuring count action for allowing query statistics of HW offloaded flows. Signed-off-by: Eli Britstein Reviewed-by: Oz Shlomo --- Documentation/howto/dpdk.rst | 17 ++++++--- NEWS | 1 + lib/netdev-offload-dpdk.c | 86 +++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 96 insertions(+), 8 deletions(-) diff --git a/Documentation/howto/dpdk.rst b/Documentation/howto/dpdk.rst index 766a7950c..f0fe2bef7 100644 --- a/Documentation/howto/dpdk.rst +++ b/Documentation/howto/dpdk.rst @@ -370,19 +370,28 @@ The flow hardware offload is disabled by default and can be enabled by:: $ ovs-vsctl set Open_vSwitch . other_config:hw-offload=true -So far only partial flow offload is implemented. Moreover, it only works -with PMD drivers have the rte_flow action "MARK + RSS" support. +Matches and actions are programmed into HW to achieve full offload of +the flow. If not all actions are supported, fallback to partial flow +offload (offloading matches only). Moreover, it only works with PMD +drivers that support the configured rte_flow actions. +Partial flow offload requires support of "MARK + RSS" actions. Full +hardware offload requires support of the actions listed below. The validated NICs are: - Mellanox (ConnectX-4, ConnectX-4 Lx, ConnectX-5) - Napatech (NT200B01) -Supported protocols for hardware offload are: +Supported protocols for hardware offload matches are: + - L2: Ethernet, VLAN -- L3: IPv4, IPv6 +- L3: IPv4 - L4: TCP, UDP, SCTP, ICMP +Supported actions for hardware offload are: + +- Output. + Further Reading --------------- diff --git a/NEWS b/NEWS index 85c4a4812..8b8bcab9a 100644 --- a/NEWS +++ b/NEWS @@ -26,6 +26,7 @@ Post-v2.12.0 * DPDK ring ports (dpdkr) are deprecated and will be removed in next releases. * Add support for DPDK 19.11. + * Add hardware offload support for output actions (experimental). - 'ovs-appctl dpctl/dump-flows' can now show offloaded=partial for partially offloaded flows, dp:dpdk for fully offloaded by dpdk, and type filter supports new filters: "dpdk" and "partially-offloaded". diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c index e2fce2ee4..e31761f1c 100644 --- a/lib/netdev-offload-dpdk.c +++ b/lib/netdev-offload-dpdk.c @@ -347,6 +347,26 @@ dump_flow_action(struct ds *s, const struct rte_flow_action *actions) } else { ds_put_cstr(s, " RSS = null\n"); } + } else if (actions->type == RTE_FLOW_ACTION_TYPE_COUNT) { + const struct rte_flow_action_count *count = actions->conf; + + ds_put_cstr(s, "rte flow count action:\n"); + if (count) { + ds_put_format(s, " Count: shared=%d, id=%d\n", count->shared, + count->id); + } else { + ds_put_cstr(s, " Count = null\n"); + } + } else if (actions->type == RTE_FLOW_ACTION_TYPE_PORT_ID) { + const struct rte_flow_action_port_id *port_id = actions->conf; + + ds_put_cstr(s, "rte flow port-id action:\n"); + if (port_id) { + ds_put_format(s, " Port-id: original=%d, id=%d\n", + port_id->original, port_id->id); + } else { + ds_put_cstr(s, " Port-id = null\n"); + } } else { ds_put_format(s, "unknown rte flow action (%d)\n", actions->type); } @@ -724,19 +744,77 @@ netdev_offload_dpdk_mark_rss(struct flow_patterns *patterns, return flow; } +static void +add_count_action(struct flow_actions *actions) +{ + struct rte_flow_action_count *count = xzalloc(sizeof *count); + + add_flow_action(actions, RTE_FLOW_ACTION_TYPE_COUNT, count); +} + static int -parse_flow_actions(struct netdev *netdev OVS_UNUSED, +add_port_id_action(struct flow_actions *actions, + struct netdev *outdev) +{ + struct rte_flow_action_port_id *port_id; + int outdev_id; + + outdev_id = netdev_dpdk_get_port_id(outdev); + if (outdev_id < 0) { + return -1; + } + port_id = xzalloc(sizeof *port_id); + port_id->id = outdev_id; + add_flow_action(actions, RTE_FLOW_ACTION_TYPE_PORT_ID, port_id); + return 0; +} + +static int +add_output_action(struct netdev *netdev, + struct flow_actions *actions, + const struct nlattr *nla, + struct offload_info *info) +{ + struct netdev *outdev; + odp_port_t port; + int ret = 0; + + port = nl_attr_get_odp_port(nla); + outdev = netdev_ports_get(port, info->dpif_class); + if (outdev == NULL) { + VLOG_DBG_RL(&rl, "Cannot find netdev for odp port %"PRIu32, port); + return -1; + } + if (!netdev_flow_api_equals(netdev, outdev) || + add_port_id_action(actions, outdev)) { + VLOG_DBG_RL(&rl, "%s: Output to port \'%s\' cannot be offloaded.", + netdev_get_name(netdev), netdev_get_name(outdev)); + ret = -1; + } + netdev_close(outdev); + return ret; +} + +static int +parse_flow_actions(struct netdev *netdev, struct flow_actions *actions, struct nlattr *nl_actions, size_t nl_actions_len, - struct offload_info *info OVS_UNUSED) + struct offload_info *info) { struct nlattr *nla; size_t left; + add_count_action(actions); 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_attr_type(nla) == OVS_ACTION_ATTR_OUTPUT) { + if (add_output_action(netdev, actions, nla, info)) { + return -1; + } + } else { + VLOG_DBG_RL(&rl, "Unsupported action type %d", nl_attr_type(nla)); + return -1; + } } if (nl_actions_len == 0) {