From patchwork Sun Dec 8 13:22:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Britstein X-Patchwork-Id: 1205668 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.138; helo=whitealder.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 whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47W6VQ0WdFz9sPK for ; Mon, 9 Dec 2019 00:24:13 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 457F486CD7; Sun, 8 Dec 2019 13:24:12 +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 VXqTlgmZOaA0; Sun, 8 Dec 2019 13:24:03 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by whitealder.osuosl.org (Postfix) with ESMTP id EA890875DC; Sun, 8 Dec 2019 13:23:37 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id DE3E2C1D89; Sun, 8 Dec 2019 13:23:37 +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 BFD8DC0881 for ; Sun, 8 Dec 2019 13:23:29 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id BD02E86B6B for ; Sun, 8 Dec 2019 13:23:29 +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 4cBhOxCSdLNT for ; Sun, 8 Dec 2019 13:23:27 +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 AF04B865E2 for ; Sun, 8 Dec 2019 13:23:26 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE1 (envelope-from elibr@mellanox.com) with ESMTPS (AES256-SHA encrypted); 8 Dec 2019 15:23:19 +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 xB8DNJgt002052; Sun, 8 Dec 2019 15:23:19 +0200 From: Eli Britstein To: dev@openvswitch.org, Ilya Maximets , Sriharsha Basavapatna Date: Sun, 8 Dec 2019 13:22:46 +0000 Message-Id: <20191208132304.15521-2-elibr@mellanox.com> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20191208132304.15521-1-elibr@mellanox.com> References: <20191208132304.15521-1-elibr@mellanox.com> Cc: Oz Shlomo , Majd Dibbiny , Eli Britstein , Ameer Mahagneh Subject: [ovs-dev] [PATCH V3 01/19] netdev-offload-dpdk: Refactor flow patterns 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" Refactor the flow patterns code to a helper function for better readability and towards supporting more matches. Signed-off-by: Eli Britstein Reviewed-by: Oz Shlomo --- lib/netdev-offload-dpdk.c | 208 +++++++++++++++++++++++++--------------------- 1 file changed, 112 insertions(+), 96 deletions(-) diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c index 96794dc4d..a008e642f 100644 --- a/lib/netdev-offload-dpdk.c +++ b/lib/netdev-offload-dpdk.c @@ -410,54 +410,42 @@ add_flow_rss_action(struct flow_actions *actions, return rss_data; } +struct flow_items { + struct rte_flow_item_eth eth; + struct rte_flow_item_vlan vlan; + struct rte_flow_item_ipv4 ipv4; + union { + struct rte_flow_item_tcp tcp; + struct rte_flow_item_udp udp; + struct rte_flow_item_sctp sctp; + struct rte_flow_item_icmp icmp; + }; +}; + 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) +parse_flow_match(struct flow_patterns *patterns, + struct flow_items *spec, + struct flow_items *mask, + const struct match *match) { - 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 *flow; - struct rte_flow_error error; uint8_t proto = 0; - int ret = 0; - struct flow_items { - struct rte_flow_item_eth eth; - struct rte_flow_item_vlan vlan; - struct rte_flow_item_ipv4 ipv4; - union { - struct rte_flow_item_tcp tcp; - struct rte_flow_item_udp udp; - struct rte_flow_item_sctp sctp; - struct rte_flow_item_icmp icmp; - }; - } spec, mask; - - memset(&spec, 0, sizeof spec); - memset(&mask, 0, sizeof mask); + + memset(spec, 0, sizeof *spec); + memset(mask, 0, sizeof *mask); /* Eth */ if (!eth_addr_is_zero(match->wc.masks.dl_src) || !eth_addr_is_zero(match->wc.masks.dl_dst)) { - memcpy(&spec.eth.dst, &match->flow.dl_dst, sizeof spec.eth.dst); - memcpy(&spec.eth.src, &match->flow.dl_src, sizeof spec.eth.src); - spec.eth.type = match->flow.dl_type; + memcpy(&spec->eth.dst, &match->flow.dl_dst, sizeof spec->eth.dst); + memcpy(&spec->eth.src, &match->flow.dl_src, sizeof spec->eth.src); + spec->eth.type = match->flow.dl_type; - memcpy(&mask.eth.dst, &match->wc.masks.dl_dst, sizeof mask.eth.dst); - memcpy(&mask.eth.src, &match->wc.masks.dl_src, sizeof mask.eth.src); - mask.eth.type = match->wc.masks.dl_type; + memcpy(&mask->eth.dst, &match->wc.masks.dl_dst, sizeof mask->eth.dst); + memcpy(&mask->eth.src, &match->wc.masks.dl_src, sizeof mask->eth.src); + mask->eth.type = match->wc.masks.dl_type; - add_flow_pattern(&patterns, RTE_FLOW_ITEM_TYPE_ETH, - &spec.eth, &mask.eth); + add_flow_pattern(patterns, RTE_FLOW_ITEM_TYPE_ETH, + &spec->eth, &mask->eth); } else { /* * If user specifies a flow (like UDP flow) without L2 patterns, @@ -466,41 +454,41 @@ netdev_offload_dpdk_add_flow(struct netdev *netdev, * NIC (such as XL710) doesn't support that. Below is a workaround, * which simply matches any L2 pkts. */ - add_flow_pattern(&patterns, RTE_FLOW_ITEM_TYPE_ETH, NULL, NULL); + add_flow_pattern(patterns, RTE_FLOW_ITEM_TYPE_ETH, NULL, NULL); } /* VLAN */ if (match->wc.masks.vlans[0].tci && match->flow.vlans[0].tci) { - spec.vlan.tci = match->flow.vlans[0].tci & ~htons(VLAN_CFI); - mask.vlan.tci = match->wc.masks.vlans[0].tci & ~htons(VLAN_CFI); + spec->vlan.tci = match->flow.vlans[0].tci & ~htons(VLAN_CFI); + mask->vlan.tci = match->wc.masks.vlans[0].tci & ~htons(VLAN_CFI); /* Match any protocols. */ - mask.vlan.inner_type = 0; + mask->vlan.inner_type = 0; - add_flow_pattern(&patterns, RTE_FLOW_ITEM_TYPE_VLAN, - &spec.vlan, &mask.vlan); + add_flow_pattern(patterns, RTE_FLOW_ITEM_TYPE_VLAN, + &spec->vlan, &mask->vlan); } /* IP v4 */ if (match->flow.dl_type == htons(ETH_TYPE_IP)) { - spec.ipv4.hdr.type_of_service = match->flow.nw_tos; - spec.ipv4.hdr.time_to_live = match->flow.nw_ttl; - spec.ipv4.hdr.next_proto_id = match->flow.nw_proto; - spec.ipv4.hdr.src_addr = match->flow.nw_src; - spec.ipv4.hdr.dst_addr = match->flow.nw_dst; + spec->ipv4.hdr.type_of_service = match->flow.nw_tos; + spec->ipv4.hdr.time_to_live = match->flow.nw_ttl; + spec->ipv4.hdr.next_proto_id = match->flow.nw_proto; + spec->ipv4.hdr.src_addr = match->flow.nw_src; + spec->ipv4.hdr.dst_addr = match->flow.nw_dst; - mask.ipv4.hdr.type_of_service = match->wc.masks.nw_tos; - mask.ipv4.hdr.time_to_live = match->wc.masks.nw_ttl; - mask.ipv4.hdr.next_proto_id = match->wc.masks.nw_proto; - mask.ipv4.hdr.src_addr = match->wc.masks.nw_src; - mask.ipv4.hdr.dst_addr = match->wc.masks.nw_dst; + mask->ipv4.hdr.type_of_service = match->wc.masks.nw_tos; + mask->ipv4.hdr.time_to_live = match->wc.masks.nw_ttl; + mask->ipv4.hdr.next_proto_id = match->wc.masks.nw_proto; + mask->ipv4.hdr.src_addr = match->wc.masks.nw_src; + mask->ipv4.hdr.dst_addr = match->wc.masks.nw_dst; - add_flow_pattern(&patterns, RTE_FLOW_ITEM_TYPE_IPV4, - &spec.ipv4, &mask.ipv4); + add_flow_pattern(patterns, RTE_FLOW_ITEM_TYPE_IPV4, + &spec->ipv4, &mask->ipv4); /* Save proto for L4 protocol setup. */ - proto = spec.ipv4.hdr.next_proto_id & - mask.ipv4.hdr.next_proto_id; + proto = spec->ipv4.hdr.next_proto_id & + mask->ipv4.hdr.next_proto_id; } if (proto != IPPROTO_ICMP && proto != IPPROTO_UDP && @@ -509,79 +497,107 @@ netdev_offload_dpdk_add_flow(struct netdev *netdev, match->wc.masks.tp_dst || match->wc.masks.tcp_flags)) { VLOG_DBG("L4 Protocol (%u) not supported", proto); - ret = -1; - goto out; + return -1; } if ((match->wc.masks.tp_src && match->wc.masks.tp_src != OVS_BE16_MAX) || (match->wc.masks.tp_dst && match->wc.masks.tp_dst != OVS_BE16_MAX)) { - ret = -1; - goto out; + return -1; } switch (proto) { case IPPROTO_TCP: - spec.tcp.hdr.src_port = match->flow.tp_src; - spec.tcp.hdr.dst_port = match->flow.tp_dst; - spec.tcp.hdr.data_off = ntohs(match->flow.tcp_flags) >> 8; - spec.tcp.hdr.tcp_flags = ntohs(match->flow.tcp_flags) & 0xff; + spec->tcp.hdr.src_port = match->flow.tp_src; + spec->tcp.hdr.dst_port = match->flow.tp_dst; + spec->tcp.hdr.data_off = ntohs(match->flow.tcp_flags) >> 8; + spec->tcp.hdr.tcp_flags = ntohs(match->flow.tcp_flags) & 0xff; - mask.tcp.hdr.src_port = match->wc.masks.tp_src; - mask.tcp.hdr.dst_port = match->wc.masks.tp_dst; - mask.tcp.hdr.data_off = ntohs(match->wc.masks.tcp_flags) >> 8; - mask.tcp.hdr.tcp_flags = ntohs(match->wc.masks.tcp_flags) & 0xff; + mask->tcp.hdr.src_port = match->wc.masks.tp_src; + mask->tcp.hdr.dst_port = match->wc.masks.tp_dst; + mask->tcp.hdr.data_off = ntohs(match->wc.masks.tcp_flags) >> 8; + mask->tcp.hdr.tcp_flags = ntohs(match->wc.masks.tcp_flags) & 0xff; - add_flow_pattern(&patterns, RTE_FLOW_ITEM_TYPE_TCP, - &spec.tcp, &mask.tcp); + add_flow_pattern(patterns, RTE_FLOW_ITEM_TYPE_TCP, + &spec->tcp, &mask->tcp); /* proto == TCP and ITEM_TYPE_TCP, thus no need for proto match. */ - mask.ipv4.hdr.next_proto_id = 0; + mask->ipv4.hdr.next_proto_id = 0; break; case IPPROTO_UDP: - spec.udp.hdr.src_port = match->flow.tp_src; - spec.udp.hdr.dst_port = match->flow.tp_dst; + spec->udp.hdr.src_port = match->flow.tp_src; + spec->udp.hdr.dst_port = match->flow.tp_dst; - mask.udp.hdr.src_port = match->wc.masks.tp_src; - mask.udp.hdr.dst_port = match->wc.masks.tp_dst; + mask->udp.hdr.src_port = match->wc.masks.tp_src; + mask->udp.hdr.dst_port = match->wc.masks.tp_dst; - add_flow_pattern(&patterns, RTE_FLOW_ITEM_TYPE_UDP, - &spec.udp, &mask.udp); + add_flow_pattern(patterns, RTE_FLOW_ITEM_TYPE_UDP, + &spec->udp, &mask->udp); /* proto == UDP and ITEM_TYPE_UDP, thus no need for proto match. */ - mask.ipv4.hdr.next_proto_id = 0; + mask->ipv4.hdr.next_proto_id = 0; break; case IPPROTO_SCTP: - spec.sctp.hdr.src_port = match->flow.tp_src; - spec.sctp.hdr.dst_port = match->flow.tp_dst; + spec->sctp.hdr.src_port = match->flow.tp_src; + spec->sctp.hdr.dst_port = match->flow.tp_dst; - mask.sctp.hdr.src_port = match->wc.masks.tp_src; - mask.sctp.hdr.dst_port = match->wc.masks.tp_dst; + mask->sctp.hdr.src_port = match->wc.masks.tp_src; + mask->sctp.hdr.dst_port = match->wc.masks.tp_dst; - add_flow_pattern(&patterns, RTE_FLOW_ITEM_TYPE_SCTP, - &spec.sctp, &mask.sctp); + add_flow_pattern(patterns, RTE_FLOW_ITEM_TYPE_SCTP, + &spec->sctp, &mask->sctp); /* proto == SCTP and ITEM_TYPE_SCTP, thus no need for proto match. */ - mask.ipv4.hdr.next_proto_id = 0; + mask->ipv4.hdr.next_proto_id = 0; break; case IPPROTO_ICMP: - spec.icmp.hdr.icmp_type = (uint8_t) ntohs(match->flow.tp_src); - spec.icmp.hdr.icmp_code = (uint8_t) ntohs(match->flow.tp_dst); + spec->icmp.hdr.icmp_type = (uint8_t) ntohs(match->flow.tp_src); + spec->icmp.hdr.icmp_code = (uint8_t) ntohs(match->flow.tp_dst); - mask.icmp.hdr.icmp_type = (uint8_t) ntohs(match->wc.masks.tp_src); - mask.icmp.hdr.icmp_code = (uint8_t) ntohs(match->wc.masks.tp_dst); + mask->icmp.hdr.icmp_type = (uint8_t) ntohs(match->wc.masks.tp_src); + mask->icmp.hdr.icmp_code = (uint8_t) ntohs(match->wc.masks.tp_dst); - add_flow_pattern(&patterns, RTE_FLOW_ITEM_TYPE_ICMP, - &spec.icmp, &mask.icmp); + add_flow_pattern(patterns, RTE_FLOW_ITEM_TYPE_ICMP, + &spec->icmp, &mask->icmp); /* proto == ICMP and ITEM_TYPE_ICMP, thus no need for proto match. */ - mask.ipv4.hdr.next_proto_id = 0; + mask->ipv4.hdr.next_proto_id = 0; break; } - add_flow_pattern(&patterns, RTE_FLOW_ITEM_TYPE_END, NULL, NULL); + add_flow_pattern(patterns, RTE_FLOW_ITEM_TYPE_END, NULL, NULL); + + return 0; +} + +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) +{ + 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 *flow; + struct rte_flow_error error; + int ret = 0; + struct flow_items spec, mask; + + ret = parse_flow_match(&patterns, &spec, &mask, match); + if (ret) { + ret = -1; + goto out; + } struct rte_flow_action_mark mark; struct action_rss_data *rss; From patchwork Sun Dec 8 13:22:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Britstein X-Patchwork-Id: 1205655 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.137; helo=fraxinus.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 fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47W6TZ3gw9z9sP6 for ; Mon, 9 Dec 2019 00:23:29 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 9358C863C5; Sun, 8 Dec 2019 13:23:27 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id reVkk56BeJJg; Sun, 8 Dec 2019 13:23:25 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by fraxinus.osuosl.org (Postfix) with ESMTP id 8D80D85F88; Sun, 8 Dec 2019 13:23:25 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 7A2FBC1D7F; Sun, 8 Dec 2019 13:23:25 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 59C29C0881 for ; Sun, 8 Dec 2019 13:23:24 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 42E5586169 for ; Sun, 8 Dec 2019 13:23:24 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pjAN2YHEd729 for ; Sun, 8 Dec 2019 13:23:23 +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 fraxinus.osuosl.org (Postfix) with ESMTP id 6551685F88 for ; Sun, 8 Dec 2019 13:23:22 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE1 (envelope-from elibr@mellanox.com) with ESMTPS (AES256-SHA encrypted); 8 Dec 2019 15:23:19 +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 xB8DNJgu002052; Sun, 8 Dec 2019 15:23:19 +0200 From: Eli Britstein To: dev@openvswitch.org, Ilya Maximets , Sriharsha Basavapatna Date: Sun, 8 Dec 2019 13:22:47 +0000 Message-Id: <20191208132304.15521-3-elibr@mellanox.com> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20191208132304.15521-1-elibr@mellanox.com> References: <20191208132304.15521-1-elibr@mellanox.com> Cc: Oz Shlomo , Majd Dibbiny , Eli Britstein , Ameer Mahagneh Subject: [ovs-dev] [PATCH V3 02/19] netdev-offload-dpdk: Refactor action items freeing scheme 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" Action item data structures are pointed by rte_flow_action items. Refactor the code to free the data structures when freeing the rte_flow_action items, allowing simpler future actions simpler to add to the code. Signed-off-by: Eli Britstein --- lib/netdev-offload-dpdk.c | 92 ++++++++++++++++++++++++++--------------------- 1 file changed, 52 insertions(+), 40 deletions(-) diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c index a008e642f..c3b595a0a 100644 --- a/lib/netdev-offload-dpdk.c +++ b/lib/netdev-offload-dpdk.c @@ -374,40 +374,19 @@ add_flow_action(struct flow_actions *actions, enum rte_flow_action_type type, actions->cnt++; } -struct action_rss_data { - struct rte_flow_action_rss conf; - uint16_t queue[0]; -}; - -static struct action_rss_data * -add_flow_rss_action(struct flow_actions *actions, - struct netdev *netdev) +static void +free_flow_actions(struct flow_actions *actions) { int i; - struct action_rss_data *rss_data; - - rss_data = xmalloc(sizeof *rss_data + - netdev_n_rxq(netdev) * sizeof rss_data->queue[0]); - *rss_data = (struct action_rss_data) { - .conf = (struct rte_flow_action_rss) { - .func = RTE_ETH_HASH_FUNCTION_DEFAULT, - .level = 0, - .types = 0, - .queue_num = netdev_n_rxq(netdev), - .queue = rss_data->queue, - .key_len = 0, - .key = NULL - }, - }; - /* Override queue array with default. */ - for (i = 0; i < netdev_n_rxq(netdev); i++) { - rss_data->queue[i] = i; + for (i = 0; i < actions->cnt; i++) { + if (actions->actions[i].conf) { + free((void *)actions->actions[i].conf); + } } - - add_flow_action(actions, RTE_FLOW_ACTION_TYPE_RSS, &rss_data->conf); - - return rss_data; + free(actions->actions); + actions->actions = NULL; + actions->cnt = 0; } struct flow_items { @@ -572,6 +551,47 @@ parse_flow_match(struct flow_patterns *patterns, return 0; } +static void +add_flow_mark_rss_actions(struct flow_actions *actions, + uint32_t flow_mark, + struct netdev *netdev) +{ + struct rte_flow_action_mark *mark; + struct action_rss_data { + struct rte_flow_action_rss conf; + uint16_t queue[0]; + } *rss_data; + int i; + + mark = xzalloc(sizeof *mark); + + mark->id = flow_mark; + add_flow_action(actions, RTE_FLOW_ACTION_TYPE_MARK, mark); + + rss_data = xmalloc(sizeof *rss_data + + netdev_n_rxq(netdev) * sizeof rss_data->queue[0]); + *rss_data = (struct action_rss_data) { + .conf = (struct rte_flow_action_rss) { + .func = RTE_ETH_HASH_FUNCTION_DEFAULT, + .level = 0, + .types = 0, + .queue_num = netdev_n_rxq(netdev), + .queue = rss_data->queue, + .key_len = 0, + .key = NULL + }, + }; + + /* Override queue array with default. */ + for (i = 0; i < netdev_n_rxq(netdev); i++) { + rss_data->queue[i] = i; + } + + add_flow_action(actions, RTE_FLOW_ACTION_TYPE_RSS, &rss_data->conf); + + add_flow_action(actions, RTE_FLOW_ACTION_TYPE_END, NULL); +} + static int netdev_offload_dpdk_add_flow(struct netdev *netdev, const struct match *match, @@ -599,20 +619,12 @@ netdev_offload_dpdk_add_flow(struct netdev *netdev, goto out; } - struct rte_flow_action_mark mark; - struct action_rss_data *rss; - - mark.id = info->flow_mark; - add_flow_action(&actions, RTE_FLOW_ACTION_TYPE_MARK, &mark); - - rss = add_flow_rss_action(&actions, netdev); - add_flow_action(&actions, RTE_FLOW_ACTION_TYPE_END, NULL); + add_flow_mark_rss_actions(&actions, info->flow_mark, netdev); flow = netdev_dpdk_rte_flow_create(netdev, &flow_attr, patterns.items, actions.actions, &error); - free(rss); if (!flow) { VLOG_ERR("%s: rte flow creat error: %u : message : %s\n", netdev_get_name(netdev), error.type, error.message); @@ -625,7 +637,7 @@ netdev_offload_dpdk_add_flow(struct netdev *netdev, out: free(patterns.items); - free(actions.actions); + free_flow_actions(&actions); return ret; } From patchwork Sun Dec 8 13:22:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Britstein X-Patchwork-Id: 1205657 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.137; helo=fraxinus.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 fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47W6Tn3nFfz9sP6 for ; Mon, 9 Dec 2019 00:23:41 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id E3ECD8631C; Sun, 8 Dec 2019 13:23:39 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id afA2xSr3hxOR; Sun, 8 Dec 2019 13:23:28 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by fraxinus.osuosl.org (Postfix) with ESMTP id B57B48618D; Sun, 8 Dec 2019 13:23:26 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 9CDD2C1D82; Sun, 8 Dec 2019 13:23:26 +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 0CE1FC0881 for ; Sun, 8 Dec 2019 13:23:25 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id E970287E62 for ; Sun, 8 Dec 2019 13:23:24 +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 29Ppuyu82bp4 for ; Sun, 8 Dec 2019 13:23:23 +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 6979A87D7B for ; Sun, 8 Dec 2019 13:23:22 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE1 (envelope-from elibr@mellanox.com) with ESMTPS (AES256-SHA encrypted); 8 Dec 2019 15:23:19 +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 xB8DNJgv002052; Sun, 8 Dec 2019 15:23:19 +0200 From: Eli Britstein To: dev@openvswitch.org, Ilya Maximets , Sriharsha Basavapatna Date: Sun, 8 Dec 2019 13:22:48 +0000 Message-Id: <20191208132304.15521-4-elibr@mellanox.com> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20191208132304.15521-1-elibr@mellanox.com> References: <20191208132304.15521-1-elibr@mellanox.com> Cc: Oz Shlomo , Majd Dibbiny , Eli Britstein , Ameer Mahagneh Subject: [ovs-dev] [PATCH V3 03/19] netdev-offload-dpdk: Dynamically allocate pattern items 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" Instead of statically allocated pattern items on the stack, dynamically allocate only the required items while parsing the matches, to simplify the parsing and make it self-contained, without need of external types, making it easier to support more matches in the future. Signed-off-by: Eli Britstein Reviewed-by: Oz Shlomo --- lib/netdev-offload-dpdk.c | 206 ++++++++++++++++++++++++++-------------------- 1 file changed, 118 insertions(+), 88 deletions(-) diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c index c3b595a0a..e48ac3b63 100644 --- a/lib/netdev-offload-dpdk.c +++ b/lib/netdev-offload-dpdk.c @@ -374,6 +374,24 @@ add_flow_action(struct flow_actions *actions, enum rte_flow_action_type type, actions->cnt++; } +static void +free_flow_patterns(struct flow_patterns *patterns) +{ + int i; + + for (i = 0; i < patterns->cnt; i++) { + if (patterns->items[i].spec) { + free((void *)patterns->items[i].spec); + } + if (patterns->items[i].mask) { + free((void *)patterns->items[i].mask); + } + } + free(patterns->items); + patterns->items = NULL; + patterns->cnt = 0; +} + static void free_flow_actions(struct flow_actions *actions) { @@ -389,42 +407,30 @@ free_flow_actions(struct flow_actions *actions) actions->cnt = 0; } -struct flow_items { - struct rte_flow_item_eth eth; - struct rte_flow_item_vlan vlan; - struct rte_flow_item_ipv4 ipv4; - union { - struct rte_flow_item_tcp tcp; - struct rte_flow_item_udp udp; - struct rte_flow_item_sctp sctp; - struct rte_flow_item_icmp icmp; - }; -}; - static int parse_flow_match(struct flow_patterns *patterns, - struct flow_items *spec, - struct flow_items *mask, const struct match *match) { + uint8_t *next_proto_mask = NULL; uint8_t proto = 0; - memset(spec, 0, sizeof *spec); - memset(mask, 0, sizeof *mask); - /* Eth */ if (!eth_addr_is_zero(match->wc.masks.dl_src) || !eth_addr_is_zero(match->wc.masks.dl_dst)) { - memcpy(&spec->eth.dst, &match->flow.dl_dst, sizeof spec->eth.dst); - memcpy(&spec->eth.src, &match->flow.dl_src, sizeof spec->eth.src); - spec->eth.type = match->flow.dl_type; + struct rte_flow_item_eth *spec, *mask; + + spec = xzalloc(sizeof *spec); + mask = xzalloc(sizeof *mask); - memcpy(&mask->eth.dst, &match->wc.masks.dl_dst, sizeof mask->eth.dst); - memcpy(&mask->eth.src, &match->wc.masks.dl_src, sizeof mask->eth.src); - mask->eth.type = match->wc.masks.dl_type; + memcpy(&spec->dst, &match->flow.dl_dst, sizeof spec->dst); + memcpy(&spec->src, &match->flow.dl_src, sizeof spec->src); + spec->type = match->flow.dl_type; - add_flow_pattern(patterns, RTE_FLOW_ITEM_TYPE_ETH, - &spec->eth, &mask->eth); + memcpy(&mask->dst, &match->wc.masks.dl_dst, sizeof mask->dst); + memcpy(&mask->src, &match->wc.masks.dl_src, sizeof mask->src); + mask->type = match->wc.masks.dl_type; + + add_flow_pattern(patterns, RTE_FLOW_ITEM_TYPE_ETH, spec, mask); } else { /* * If user specifies a flow (like UDP flow) without L2 patterns, @@ -438,36 +444,45 @@ parse_flow_match(struct flow_patterns *patterns, /* VLAN */ if (match->wc.masks.vlans[0].tci && match->flow.vlans[0].tci) { - spec->vlan.tci = match->flow.vlans[0].tci & ~htons(VLAN_CFI); - mask->vlan.tci = match->wc.masks.vlans[0].tci & ~htons(VLAN_CFI); + struct rte_flow_item_vlan *spec, *mask; + + spec = xzalloc(sizeof *spec); + mask = xzalloc(sizeof *mask); + + spec->tci = match->flow.vlans[0].tci & ~htons(VLAN_CFI); + mask->tci = match->wc.masks.vlans[0].tci & ~htons(VLAN_CFI); /* Match any protocols. */ - mask->vlan.inner_type = 0; + mask->inner_type = 0; - add_flow_pattern(patterns, RTE_FLOW_ITEM_TYPE_VLAN, - &spec->vlan, &mask->vlan); + add_flow_pattern(patterns, RTE_FLOW_ITEM_TYPE_VLAN, spec, mask); } /* IP v4 */ if (match->flow.dl_type == htons(ETH_TYPE_IP)) { - spec->ipv4.hdr.type_of_service = match->flow.nw_tos; - spec->ipv4.hdr.time_to_live = match->flow.nw_ttl; - spec->ipv4.hdr.next_proto_id = match->flow.nw_proto; - spec->ipv4.hdr.src_addr = match->flow.nw_src; - spec->ipv4.hdr.dst_addr = match->flow.nw_dst; + struct rte_flow_item_ipv4 *spec, *mask; + + spec = xzalloc(sizeof *spec); + mask = xzalloc(sizeof *mask); - mask->ipv4.hdr.type_of_service = match->wc.masks.nw_tos; - mask->ipv4.hdr.time_to_live = match->wc.masks.nw_ttl; - mask->ipv4.hdr.next_proto_id = match->wc.masks.nw_proto; - mask->ipv4.hdr.src_addr = match->wc.masks.nw_src; - mask->ipv4.hdr.dst_addr = match->wc.masks.nw_dst; + spec->hdr.type_of_service = match->flow.nw_tos; + spec->hdr.time_to_live = match->flow.nw_ttl; + spec->hdr.next_proto_id = match->flow.nw_proto; + spec->hdr.src_addr = match->flow.nw_src; + spec->hdr.dst_addr = match->flow.nw_dst; - add_flow_pattern(patterns, RTE_FLOW_ITEM_TYPE_IPV4, - &spec->ipv4, &mask->ipv4); + mask->hdr.type_of_service = match->wc.masks.nw_tos; + mask->hdr.time_to_live = match->wc.masks.nw_ttl; + mask->hdr.next_proto_id = match->wc.masks.nw_proto; + mask->hdr.src_addr = match->wc.masks.nw_src; + mask->hdr.dst_addr = match->wc.masks.nw_dst; + + add_flow_pattern(patterns, RTE_FLOW_ITEM_TYPE_IPV4, spec, mask); /* Save proto for L4 protocol setup. */ - proto = spec->ipv4.hdr.next_proto_id & - mask->ipv4.hdr.next_proto_id; + proto = spec->hdr.next_proto_id & + mask->hdr.next_proto_id; + next_proto_mask = &mask->hdr.next_proto_id; } if (proto != IPPROTO_ICMP && proto != IPPROTO_UDP && @@ -484,66 +499,82 @@ parse_flow_match(struct flow_patterns *patterns, return -1; } - switch (proto) { - case IPPROTO_TCP: - spec->tcp.hdr.src_port = match->flow.tp_src; - spec->tcp.hdr.dst_port = match->flow.tp_dst; - spec->tcp.hdr.data_off = ntohs(match->flow.tcp_flags) >> 8; - spec->tcp.hdr.tcp_flags = ntohs(match->flow.tcp_flags) & 0xff; + if (proto == IPPROTO_TCP) { + struct rte_flow_item_tcp *spec, *mask; + + spec = xzalloc(sizeof *spec); + mask = xzalloc(sizeof *mask); + + spec->hdr.src_port = match->flow.tp_src; + spec->hdr.dst_port = match->flow.tp_dst; + spec->hdr.data_off = ntohs(match->flow.tcp_flags) >> 8; + spec->hdr.tcp_flags = ntohs(match->flow.tcp_flags) & 0xff; - mask->tcp.hdr.src_port = match->wc.masks.tp_src; - mask->tcp.hdr.dst_port = match->wc.masks.tp_dst; - mask->tcp.hdr.data_off = ntohs(match->wc.masks.tcp_flags) >> 8; - mask->tcp.hdr.tcp_flags = ntohs(match->wc.masks.tcp_flags) & 0xff; + mask->hdr.src_port = match->wc.masks.tp_src; + mask->hdr.dst_port = match->wc.masks.tp_dst; + mask->hdr.data_off = ntohs(match->wc.masks.tcp_flags) >> 8; + mask->hdr.tcp_flags = ntohs(match->wc.masks.tcp_flags) & 0xff; - add_flow_pattern(patterns, RTE_FLOW_ITEM_TYPE_TCP, - &spec->tcp, &mask->tcp); + add_flow_pattern(patterns, RTE_FLOW_ITEM_TYPE_TCP, spec, mask); /* proto == TCP and ITEM_TYPE_TCP, thus no need for proto match. */ - mask->ipv4.hdr.next_proto_id = 0; - break; + if (next_proto_mask) { + *next_proto_mask = 0; + } + } else if (proto == IPPROTO_UDP) { + struct rte_flow_item_udp *spec, *mask; + + spec = xzalloc(sizeof *spec); + mask = xzalloc(sizeof *mask); - case IPPROTO_UDP: - spec->udp.hdr.src_port = match->flow.tp_src; - spec->udp.hdr.dst_port = match->flow.tp_dst; + spec->hdr.src_port = match->flow.tp_src; + spec->hdr.dst_port = match->flow.tp_dst; - mask->udp.hdr.src_port = match->wc.masks.tp_src; - mask->udp.hdr.dst_port = match->wc.masks.tp_dst; + mask->hdr.src_port = match->wc.masks.tp_src; + mask->hdr.dst_port = match->wc.masks.tp_dst; - add_flow_pattern(patterns, RTE_FLOW_ITEM_TYPE_UDP, - &spec->udp, &mask->udp); + add_flow_pattern(patterns, RTE_FLOW_ITEM_TYPE_UDP, spec, mask); /* proto == UDP and ITEM_TYPE_UDP, thus no need for proto match. */ - mask->ipv4.hdr.next_proto_id = 0; - break; + if (next_proto_mask) { + *next_proto_mask = 0; + } + } else if (proto == IPPROTO_SCTP) { + struct rte_flow_item_sctp *spec, *mask; + + spec = xzalloc(sizeof *spec); + mask = xzalloc(sizeof *mask); - case IPPROTO_SCTP: - spec->sctp.hdr.src_port = match->flow.tp_src; - spec->sctp.hdr.dst_port = match->flow.tp_dst; + spec->hdr.src_port = match->flow.tp_src; + spec->hdr.dst_port = match->flow.tp_dst; - mask->sctp.hdr.src_port = match->wc.masks.tp_src; - mask->sctp.hdr.dst_port = match->wc.masks.tp_dst; + mask->hdr.src_port = match->wc.masks.tp_src; + mask->hdr.dst_port = match->wc.masks.tp_dst; - add_flow_pattern(patterns, RTE_FLOW_ITEM_TYPE_SCTP, - &spec->sctp, &mask->sctp); + add_flow_pattern(patterns, RTE_FLOW_ITEM_TYPE_SCTP, spec, mask); /* proto == SCTP and ITEM_TYPE_SCTP, thus no need for proto match. */ - mask->ipv4.hdr.next_proto_id = 0; - break; + if (next_proto_mask) { + *next_proto_mask = 0; + } + } else if (proto == IPPROTO_ICMP) { + struct rte_flow_item_icmp *spec, *mask; + + spec = xzalloc(sizeof *spec); + mask = xzalloc(sizeof *mask); - case IPPROTO_ICMP: - spec->icmp.hdr.icmp_type = (uint8_t) ntohs(match->flow.tp_src); - spec->icmp.hdr.icmp_code = (uint8_t) ntohs(match->flow.tp_dst); + spec->hdr.icmp_type = (uint8_t) ntohs(match->flow.tp_src); + spec->hdr.icmp_code = (uint8_t) ntohs(match->flow.tp_dst); - mask->icmp.hdr.icmp_type = (uint8_t) ntohs(match->wc.masks.tp_src); - mask->icmp.hdr.icmp_code = (uint8_t) ntohs(match->wc.masks.tp_dst); + mask->hdr.icmp_type = (uint8_t) ntohs(match->wc.masks.tp_src); + mask->hdr.icmp_code = (uint8_t) ntohs(match->wc.masks.tp_dst); - add_flow_pattern(patterns, RTE_FLOW_ITEM_TYPE_ICMP, - &spec->icmp, &mask->icmp); + add_flow_pattern(patterns, RTE_FLOW_ITEM_TYPE_ICMP, spec, mask); /* proto == ICMP and ITEM_TYPE_ICMP, thus no need for proto match. */ - mask->ipv4.hdr.next_proto_id = 0; - break; + if (next_proto_mask) { + *next_proto_mask = 0; + } } add_flow_pattern(patterns, RTE_FLOW_ITEM_TYPE_END, NULL, NULL); @@ -611,9 +642,8 @@ netdev_offload_dpdk_add_flow(struct netdev *netdev, struct rte_flow *flow; struct rte_flow_error error; int ret = 0; - struct flow_items spec, mask; - ret = parse_flow_match(&patterns, &spec, &mask, match); + ret = parse_flow_match(&patterns, match); if (ret) { ret = -1; goto out; @@ -636,7 +666,7 @@ netdev_offload_dpdk_add_flow(struct netdev *netdev, netdev_get_name(netdev), flow, UUID_ARGS((struct uuid *)ufid)); out: - free(patterns.items); + free_flow_patterns(&patterns); free_flow_actions(&actions); return ret; } From patchwork Sun Dec 8 13:22:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Britstein X-Patchwork-Id: 1205674 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.138; helo=whitealder.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 whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47W6WG23q3z9sP6 for ; Mon, 9 Dec 2019 00:24:58 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 99B6C87689; Sun, 8 Dec 2019 13:24:56 +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 OkYs-VnmYIZH; Sun, 8 Dec 2019 13:24:52 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by whitealder.osuosl.org (Postfix) with ESMTP id 05214878E6; Sun, 8 Dec 2019 13:23:45 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id EB28DC1D8A; Sun, 8 Dec 2019 13:23:44 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 0A8FDC1D7F for ; Sun, 8 Dec 2019 13:23:42 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id EC7F186447 for ; Sun, 8 Dec 2019 13:23:41 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8r7zo7RgJboj for ; Sun, 8 Dec 2019 13:23:35 +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 fraxinus.osuosl.org (Postfix) with ESMTP id C214F862FC for ; Sun, 8 Dec 2019 13:23:26 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE1 (envelope-from elibr@mellanox.com) with ESMTPS (AES256-SHA encrypted); 8 Dec 2019 15:23:20 +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 xB8DNJgw002052; Sun, 8 Dec 2019 15:23:19 +0200 From: Eli Britstein To: dev@openvswitch.org, Ilya Maximets , Sriharsha Basavapatna Date: Sun, 8 Dec 2019 13:22:49 +0000 Message-Id: <20191208132304.15521-5-elibr@mellanox.com> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20191208132304.15521-1-elibr@mellanox.com> References: <20191208132304.15521-1-elibr@mellanox.com> Cc: Oz Shlomo , Majd Dibbiny , Eli Britstein , Ameer Mahagneh Subject: [ovs-dev] [PATCH V3 04/19] netdev-offload-dpdk: Fix typo 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" Fixes: e8a2b5bf92bb ("netdev-dpdk: implement flow offload with rte flow") Signed-off-by: Eli Britstein Reviewed-by: Oz Shlomo --- lib/netdev-offload-dpdk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c index e48ac3b63..041b72d53 100644 --- a/lib/netdev-offload-dpdk.c +++ b/lib/netdev-offload-dpdk.c @@ -656,7 +656,7 @@ netdev_offload_dpdk_add_flow(struct netdev *netdev, actions.actions, &error); if (!flow) { - VLOG_ERR("%s: rte flow creat error: %u : message : %s\n", + VLOG_ERR("%s: rte flow create error: %u : message : %s\n", netdev_get_name(netdev), error.type, error.message); ret = -1; goto out; From patchwork Sun Dec 8 13:22:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Britstein X-Patchwork-Id: 1205661 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.133; helo=hemlock.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 hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47W6Tw5p6vz9sP6 for ; Mon, 9 Dec 2019 00:23:48 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 4A5A988400; Sun, 8 Dec 2019 13:23:47 +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 LpZjYsfh2k1E; Sun, 8 Dec 2019 13:23:40 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id 493BE88076; Sun, 8 Dec 2019 13:23:36 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 3FA5AC1D82; Sun, 8 Dec 2019 13:23:36 +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 86F18C0881 for ; Sun, 8 Dec 2019 13:23:29 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 75B3787E79 for ; Sun, 8 Dec 2019 13:23:29 +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 y02e2fjNNk3D for ; Sun, 8 Dec 2019 13:23:27 +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 CE8DC87E6F for ; Sun, 8 Dec 2019 13:23:26 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE1 (envelope-from elibr@mellanox.com) with ESMTPS (AES256-SHA encrypted); 8 Dec 2019 15:23:20 +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 xB8DNJgx002052; Sun, 8 Dec 2019 15:23:20 +0200 From: Eli Britstein To: dev@openvswitch.org, Ilya Maximets , Sriharsha Basavapatna Date: Sun, 8 Dec 2019 13:22:50 +0000 Message-Id: <20191208132304.15521-6-elibr@mellanox.com> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20191208132304.15521-1-elibr@mellanox.com> References: <20191208132304.15521-1-elibr@mellanox.com> Cc: Oz Shlomo , Majd Dibbiny , Eli Britstein , Ameer Mahagneh Subject: [ovs-dev] [PATCH V3 05/19] netdev-dpdk: Improve HW offload flow debuggability 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" Add debug prints when creating and destroying rte flows, with all the flow details (attributes, patterns, actions). Signed-off-by: Eli Britstein Reviewed-by: Oz Shlomo --- lib/netdev-dpdk.c | 260 ++++++++++++++++++++++++++++++++++++++++++++++ lib/netdev-offload-dpdk.c | 207 +----------------------------------- 2 files changed, 264 insertions(+), 203 deletions(-) diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index 89c73a29b..da1349b69 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -4458,9 +4458,252 @@ netdev_dpdk_rte_flow_destroy(struct netdev *netdev, ovs_mutex_lock(&dev->mutex); ret = rte_flow_destroy(dev->port_id, rte_flow, error); ovs_mutex_unlock(&dev->mutex); + if (!ret) { + VLOG_DBG_RL(&rl, "Destroy rte_flow %p: netdev=%s, port=%d\n", + rte_flow, netdev_get_name(netdev), dev->port_id); + } else { + VLOG_ERR_RL(&rl, "Destroy rte_flow %p: netdev=%s, port=%d\n" + "FAILED. error %u : message : %s", + rte_flow, netdev_get_name(netdev), dev->port_id, + error->type, error->message); + } return ret; } +static void +ds_put_flow_attr(struct ds *s, const struct rte_flow_attr *attr) +{ + ds_put_format(s, + " Attributes: " + "ingress=%d, egress=%d, prio=%d, group=%d, transfer=%d\n", + attr->ingress, attr->egress, attr->priority, attr->group, + attr->transfer); +} + +static void +ds_put_flow_pattern(struct ds *s, const struct rte_flow_item *item) +{ + if (item->type == RTE_FLOW_ITEM_TYPE_ETH) { + const struct rte_flow_item_eth *eth_spec = item->spec; + const struct rte_flow_item_eth *eth_mask = item->mask; + + ds_put_cstr(s, "rte flow eth pattern:\n"); + if (eth_spec) { + ds_put_format(s, + " Spec: src="ETH_ADDR_FMT", dst="ETH_ADDR_FMT", " + "type=0x%04" PRIx16"\n", + ETH_ADDR_BYTES_ARGS(eth_spec->src.addr_bytes), + ETH_ADDR_BYTES_ARGS(eth_spec->dst.addr_bytes), + ntohs(eth_spec->type)); + } else { + ds_put_cstr(s, " Spec = null\n"); + } + if (eth_mask) { + ds_put_format(s, + " Mask: src="ETH_ADDR_FMT", dst="ETH_ADDR_FMT", " + "type=0x%04"PRIx16"\n", + ETH_ADDR_BYTES_ARGS(eth_mask->src.addr_bytes), + ETH_ADDR_BYTES_ARGS(eth_mask->dst.addr_bytes), + ntohs(eth_mask->type)); + } else { + ds_put_cstr(s, " Mask = null\n"); + } + } else if (item->type == RTE_FLOW_ITEM_TYPE_VLAN) { + const struct rte_flow_item_vlan *vlan_spec = item->spec; + const struct rte_flow_item_vlan *vlan_mask = item->mask; + + ds_put_cstr(s, "rte flow vlan pattern:\n"); + if (vlan_spec) { + ds_put_format(s, + " Spec: inner_type=0x%"PRIx16", tci=0x%"PRIx16"\n", + ntohs(vlan_spec->inner_type), ntohs(vlan_spec->tci)); + } else { + ds_put_cstr(s, " Spec = null\n"); + } + + if (vlan_mask) { + ds_put_format(s, + " Mask: inner_type=0x%"PRIx16", tci=0x%"PRIx16"\n", + ntohs(vlan_mask->inner_type), ntohs(vlan_mask->tci)); + } else { + ds_put_cstr(s, " Mask = null\n"); + } + } else if (item->type == RTE_FLOW_ITEM_TYPE_IPV4) { + const struct rte_flow_item_ipv4 *ipv4_spec = item->spec; + const struct rte_flow_item_ipv4 *ipv4_mask = item->mask; + + ds_put_cstr(s, "rte flow ipv4 pattern:\n"); + if (ipv4_spec) { + ds_put_format(s, + " Spec: tos=0x%"PRIx8", ttl=%"PRIx8 + ", proto=0x%"PRIx8 + ", src="IP_FMT", dst="IP_FMT"\n", + ipv4_spec->hdr.type_of_service, + ipv4_spec->hdr.time_to_live, + ipv4_spec->hdr.next_proto_id, + IP_ARGS(ipv4_spec->hdr.src_addr), + IP_ARGS(ipv4_spec->hdr.dst_addr)); + } else { + ds_put_cstr(s, " Spec = null\n"); + } + if (ipv4_mask) { + ds_put_format(s, + " Mask: tos=0x%"PRIx8", ttl=%"PRIx8 + ", proto=0x%"PRIx8 + ", src="IP_FMT", dst="IP_FMT"\n", + ipv4_mask->hdr.type_of_service, + ipv4_mask->hdr.time_to_live, + ipv4_mask->hdr.next_proto_id, + IP_ARGS(ipv4_mask->hdr.src_addr), + IP_ARGS(ipv4_mask->hdr.dst_addr)); + } else { + ds_put_cstr(s, " Mask = null\n"); + } + } else if (item->type == RTE_FLOW_ITEM_TYPE_UDP) { + const struct rte_flow_item_udp *udp_spec = item->spec; + const struct rte_flow_item_udp *udp_mask = item->mask; + + ds_put_cstr(s, "rte flow udp pattern:\n"); + if (udp_spec) { + ds_put_format(s, + " Spec: src_port=%"PRIu16", dst_port=%"PRIu16"\n", + ntohs(udp_spec->hdr.src_port), + ntohs(udp_spec->hdr.dst_port)); + } else { + ds_put_cstr(s, " Spec = null\n"); + } + if (udp_mask) { + ds_put_format(s, + " Mask: src_port=0x%"PRIx16 + ", dst_port=0x%"PRIx16"\n", + ntohs(udp_mask->hdr.src_port), + ntohs(udp_mask->hdr.dst_port)); + } else { + ds_put_cstr(s, " Mask = null\n"); + } + } else if (item->type == RTE_FLOW_ITEM_TYPE_SCTP) { + const struct rte_flow_item_sctp *sctp_spec = item->spec; + const struct rte_flow_item_sctp *sctp_mask = item->mask; + + ds_put_cstr(s, "rte flow sctp pattern:\n"); + if (sctp_spec) { + ds_put_format(s, + " Spec: src_port=%"PRIu16", dst_port=%"PRIu16"\n", + ntohs(sctp_spec->hdr.src_port), + ntohs(sctp_spec->hdr.dst_port)); + } else { + ds_put_cstr(s, " Spec = null\n"); + } + if (sctp_mask) { + ds_put_format(s, + " Mask: src_port=0x%"PRIx16 + ", dst_port=0x%"PRIx16"\n", + ntohs(sctp_mask->hdr.src_port), + ntohs(sctp_mask->hdr.dst_port)); + } else { + ds_put_cstr(s, " Mask = null\n"); + } + } else if (item->type == RTE_FLOW_ITEM_TYPE_ICMP) { + const struct rte_flow_item_icmp *icmp_spec = item->spec; + const struct rte_flow_item_icmp *icmp_mask = item->mask; + + ds_put_cstr(s, "rte flow icmp pattern:\n"); + if (icmp_spec) { + ds_put_format(s, + " Spec: icmp_type=%"PRIu8", icmp_code=%"PRIu8"\n", + icmp_spec->hdr.icmp_type, + icmp_spec->hdr.icmp_code); + } else { + ds_put_cstr(s, " Spec = null\n"); + } + if (icmp_mask) { + ds_put_format(s, + " Mask: icmp_type=0x%"PRIx8 + ", icmp_code=0x%"PRIx8"\n", + icmp_spec->hdr.icmp_type, + icmp_spec->hdr.icmp_code); + } else { + ds_put_cstr(s, " Mask = null\n"); + } + } else if (item->type == RTE_FLOW_ITEM_TYPE_TCP) { + const struct rte_flow_item_tcp *tcp_spec = item->spec; + const struct rte_flow_item_tcp *tcp_mask = item->mask; + + ds_put_cstr(s, "rte flow tcp pattern:\n"); + if (tcp_spec) { + ds_put_format(s, + " Spec: src_port=%"PRIu16", dst_port=%"PRIu16 + ", data_off=0x%"PRIx8", tcp_flags=0x%"PRIx8"\n", + ntohs(tcp_spec->hdr.src_port), + ntohs(tcp_spec->hdr.dst_port), + tcp_spec->hdr.data_off, + tcp_spec->hdr.tcp_flags); + } else { + ds_put_cstr(s, " Spec = null\n"); + } + if (tcp_mask) { + ds_put_format(s, + " Mask: src_port=%"PRIx16", dst_port=%"PRIx16 + ", data_off=0x%"PRIx8", tcp_flags=0x%"PRIx8"\n", + ntohs(tcp_mask->hdr.src_port), + ntohs(tcp_mask->hdr.dst_port), + tcp_mask->hdr.data_off, + tcp_mask->hdr.tcp_flags); + } else { + ds_put_cstr(s, " Mask = null\n"); + } + } else { + ds_put_format(s, "unknown rte flow pattern (%d)\n", item->type); + } +} + +static void +ds_put_flow_action(struct ds *s, const struct rte_flow_action *actions) +{ + if (actions->type == RTE_FLOW_ACTION_TYPE_MARK) { + const struct rte_flow_action_mark *mark = actions->conf; + + ds_put_cstr(s, "rte flow mark action:\n"); + if (mark) { + ds_put_format(s, + " Mark: id=%d\n", + mark->id); + } else { + ds_put_cstr(s, " Mark = null\n"); + } + } else if (actions->type == RTE_FLOW_ACTION_TYPE_RSS) { + const struct rte_flow_action_rss *rss = actions->conf; + + ds_put_cstr(s, "rte flow RSS action:\n"); + if (rss) { + ds_put_format(s, + " RSS: queue_num=%d\n", rss->queue_num); + } else { + ds_put_cstr(s, " RSS = null\n"); + } + } else { + ds_put_format(s, "unknown rte flow action (%d)\n", actions->type); + } +} + +static struct ds * +ds_put_flow(struct ds *s, + const struct rte_flow_attr *attr, + const struct rte_flow_item *items, + const struct rte_flow_action *actions) +{ + if (attr) { + ds_put_flow_attr(s, attr); + } + while (items && items->type != RTE_FLOW_ITEM_TYPE_END) { + ds_put_flow_pattern(s, items++); + } + while (actions && actions->type != RTE_FLOW_ACTION_TYPE_END) { + ds_put_flow_action(s, actions++); + } + return s; + } + struct rte_flow * netdev_dpdk_rte_flow_create(struct netdev *netdev, const struct rte_flow_attr *attr, @@ -4470,10 +4713,27 @@ netdev_dpdk_rte_flow_create(struct netdev *netdev, { struct rte_flow *flow; struct netdev_dpdk *dev = netdev_dpdk_cast(netdev); + struct ds s; ovs_mutex_lock(&dev->mutex); flow = rte_flow_create(dev->port_id, attr, items, actions, error); ovs_mutex_unlock(&dev->mutex); + ds_init(&s); + if (flow) { + VLOG_DBG_RL(&rl, "Create rte_flow: netdev=%s, port=%d\n" + "%s" + "Flow handle=%p\n", + netdev_get_name(netdev), dev->port_id, + ds_cstr(ds_put_flow(&s, attr, items, actions)), flow); + } else { + VLOG_ERR_RL(&rl, "Create rte_flow: netdev=%s, port=%d\n" + "%s" + "FAILED. error %u : message : %s\n", + netdev_get_name(netdev), dev->port_id, + ds_cstr(ds_put_flow(&s, attr, items, actions)), + error->type, error->message); + } + ds_destroy(&s); return flow; } diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c index 041b72d53..c272da340 100644 --- a/lib/netdev-offload-dpdk.c +++ b/lib/netdev-offload-dpdk.c @@ -131,204 +131,6 @@ struct flow_actions { int current_max; }; -static void -dump_flow_pattern(struct rte_flow_item *item) -{ - struct ds s; - - if (!VLOG_IS_DBG_ENABLED() || item->type == RTE_FLOW_ITEM_TYPE_END) { - return; - } - - ds_init(&s); - - if (item->type == RTE_FLOW_ITEM_TYPE_ETH) { - const struct rte_flow_item_eth *eth_spec = item->spec; - const struct rte_flow_item_eth *eth_mask = item->mask; - - ds_put_cstr(&s, "rte flow eth pattern:\n"); - if (eth_spec) { - ds_put_format(&s, - " Spec: src="ETH_ADDR_FMT", dst="ETH_ADDR_FMT", " - "type=0x%04" PRIx16"\n", - ETH_ADDR_BYTES_ARGS(eth_spec->src.addr_bytes), - ETH_ADDR_BYTES_ARGS(eth_spec->dst.addr_bytes), - ntohs(eth_spec->type)); - } else { - ds_put_cstr(&s, " Spec = null\n"); - } - if (eth_mask) { - ds_put_format(&s, - " Mask: src="ETH_ADDR_FMT", dst="ETH_ADDR_FMT", " - "type=0x%04"PRIx16"\n", - ETH_ADDR_BYTES_ARGS(eth_mask->src.addr_bytes), - ETH_ADDR_BYTES_ARGS(eth_mask->dst.addr_bytes), - ntohs(eth_mask->type)); - } else { - ds_put_cstr(&s, " Mask = null\n"); - } - } - - if (item->type == RTE_FLOW_ITEM_TYPE_VLAN) { - const struct rte_flow_item_vlan *vlan_spec = item->spec; - const struct rte_flow_item_vlan *vlan_mask = item->mask; - - ds_put_cstr(&s, "rte flow vlan pattern:\n"); - if (vlan_spec) { - ds_put_format(&s, - " Spec: inner_type=0x%"PRIx16", tci=0x%"PRIx16"\n", - ntohs(vlan_spec->inner_type), ntohs(vlan_spec->tci)); - } else { - ds_put_cstr(&s, " Spec = null\n"); - } - - if (vlan_mask) { - ds_put_format(&s, - " Mask: inner_type=0x%"PRIx16", tci=0x%"PRIx16"\n", - ntohs(vlan_mask->inner_type), ntohs(vlan_mask->tci)); - } else { - ds_put_cstr(&s, " Mask = null\n"); - } - } - - if (item->type == RTE_FLOW_ITEM_TYPE_IPV4) { - const struct rte_flow_item_ipv4 *ipv4_spec = item->spec; - const struct rte_flow_item_ipv4 *ipv4_mask = item->mask; - - ds_put_cstr(&s, "rte flow ipv4 pattern:\n"); - if (ipv4_spec) { - ds_put_format(&s, - " Spec: tos=0x%"PRIx8", ttl=%"PRIx8 - ", proto=0x%"PRIx8 - ", src="IP_FMT", dst="IP_FMT"\n", - ipv4_spec->hdr.type_of_service, - ipv4_spec->hdr.time_to_live, - ipv4_spec->hdr.next_proto_id, - IP_ARGS(ipv4_spec->hdr.src_addr), - IP_ARGS(ipv4_spec->hdr.dst_addr)); - } else { - ds_put_cstr(&s, " Spec = null\n"); - } - if (ipv4_mask) { - ds_put_format(&s, - " Mask: tos=0x%"PRIx8", ttl=%"PRIx8 - ", proto=0x%"PRIx8 - ", src="IP_FMT", dst="IP_FMT"\n", - ipv4_mask->hdr.type_of_service, - ipv4_mask->hdr.time_to_live, - ipv4_mask->hdr.next_proto_id, - IP_ARGS(ipv4_mask->hdr.src_addr), - IP_ARGS(ipv4_mask->hdr.dst_addr)); - } else { - ds_put_cstr(&s, " Mask = null\n"); - } - } - - if (item->type == RTE_FLOW_ITEM_TYPE_UDP) { - const struct rte_flow_item_udp *udp_spec = item->spec; - const struct rte_flow_item_udp *udp_mask = item->mask; - - ds_put_cstr(&s, "rte flow udp pattern:\n"); - if (udp_spec) { - ds_put_format(&s, - " Spec: src_port=%"PRIu16", dst_port=%"PRIu16"\n", - ntohs(udp_spec->hdr.src_port), - ntohs(udp_spec->hdr.dst_port)); - } else { - ds_put_cstr(&s, " Spec = null\n"); - } - if (udp_mask) { - ds_put_format(&s, - " Mask: src_port=0x%"PRIx16 - ", dst_port=0x%"PRIx16"\n", - ntohs(udp_mask->hdr.src_port), - ntohs(udp_mask->hdr.dst_port)); - } else { - ds_put_cstr(&s, " Mask = null\n"); - } - } - - if (item->type == RTE_FLOW_ITEM_TYPE_SCTP) { - const struct rte_flow_item_sctp *sctp_spec = item->spec; - const struct rte_flow_item_sctp *sctp_mask = item->mask; - - ds_put_cstr(&s, "rte flow sctp pattern:\n"); - if (sctp_spec) { - ds_put_format(&s, - " Spec: src_port=%"PRIu16", dst_port=%"PRIu16"\n", - ntohs(sctp_spec->hdr.src_port), - ntohs(sctp_spec->hdr.dst_port)); - } else { - ds_put_cstr(&s, " Spec = null\n"); - } - if (sctp_mask) { - ds_put_format(&s, - " Mask: src_port=0x%"PRIx16 - ", dst_port=0x%"PRIx16"\n", - ntohs(sctp_mask->hdr.src_port), - ntohs(sctp_mask->hdr.dst_port)); - } else { - ds_put_cstr(&s, " Mask = null\n"); - } - } - - if (item->type == RTE_FLOW_ITEM_TYPE_ICMP) { - const struct rte_flow_item_icmp *icmp_spec = item->spec; - const struct rte_flow_item_icmp *icmp_mask = item->mask; - - ds_put_cstr(&s, "rte flow icmp pattern:\n"); - if (icmp_spec) { - ds_put_format(&s, - " Spec: icmp_type=%"PRIu8", icmp_code=%"PRIu8"\n", - icmp_spec->hdr.icmp_type, - icmp_spec->hdr.icmp_code); - } else { - ds_put_cstr(&s, " Spec = null\n"); - } - if (icmp_mask) { - ds_put_format(&s, - " Mask: icmp_type=0x%"PRIx8 - ", icmp_code=0x%"PRIx8"\n", - icmp_spec->hdr.icmp_type, - icmp_spec->hdr.icmp_code); - } else { - ds_put_cstr(&s, " Mask = null\n"); - } - } - - if (item->type == RTE_FLOW_ITEM_TYPE_TCP) { - const struct rte_flow_item_tcp *tcp_spec = item->spec; - const struct rte_flow_item_tcp *tcp_mask = item->mask; - - ds_put_cstr(&s, "rte flow tcp pattern:\n"); - if (tcp_spec) { - ds_put_format(&s, - " Spec: src_port=%"PRIu16", dst_port=%"PRIu16 - ", data_off=0x%"PRIx8", tcp_flags=0x%"PRIx8"\n", - ntohs(tcp_spec->hdr.src_port), - ntohs(tcp_spec->hdr.dst_port), - tcp_spec->hdr.data_off, - tcp_spec->hdr.tcp_flags); - } else { - ds_put_cstr(&s, " Spec = null\n"); - } - if (tcp_mask) { - ds_put_format(&s, - " Mask: src_port=%"PRIx16", dst_port=%"PRIx16 - ", data_off=0x%"PRIx8", tcp_flags=0x%"PRIx8"\n", - ntohs(tcp_mask->hdr.src_port), - ntohs(tcp_mask->hdr.dst_port), - tcp_mask->hdr.data_off, - tcp_mask->hdr.tcp_flags); - } else { - ds_put_cstr(&s, " Mask = null\n"); - } - } - - VLOG_DBG("%s", ds_cstr(&s)); - ds_destroy(&s); -} - static void add_flow_pattern(struct flow_patterns *patterns, enum rte_flow_item_type type, const void *spec, const void *mask) @@ -349,7 +151,6 @@ add_flow_pattern(struct flow_patterns *patterns, enum rte_flow_item_type type, patterns->items[cnt].spec = spec; patterns->items[cnt].mask = mask; patterns->items[cnt].last = NULL; - dump_flow_pattern(&patterns->items[cnt]); patterns->cnt++; } @@ -656,8 +457,8 @@ netdev_offload_dpdk_add_flow(struct netdev *netdev, actions.actions, &error); if (!flow) { - VLOG_ERR("%s: rte flow create error: %u : message : %s\n", - netdev_get_name(netdev), error.type, error.message); + VLOG_ERR("%s: Failed to create flow: %s (%u)\n", + netdev_get_name(netdev), error.message, error.type); ret = -1; goto out; } @@ -757,8 +558,8 @@ netdev_offload_dpdk_destroy_flow(struct netdev *netdev, netdev_get_name(netdev), rte_flow, UUID_ARGS((struct uuid *)ufid)); } else { - VLOG_ERR("%s: rte flow destroy error: %u : message : %s\n", - netdev_get_name(netdev), error.type, error.message); + VLOG_ERR("%s: Failed to destroy flow: %s (%u)\n", + netdev_get_name(netdev), error.message, error.type); } return ret; From patchwork Sun Dec 8 13:22:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Britstein X-Patchwork-Id: 1205669 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.133; helo=hemlock.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 hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47W6VV5MYgz9sP6 for ; Mon, 9 Dec 2019 00:24:18 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 173F88832A; Sun, 8 Dec 2019 13:24:17 +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 HHSURNX+AS9h; Sun, 8 Dec 2019 13:24:11 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id A6A07882FC; Sun, 8 Dec 2019 13:23:43 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 8B6D8C1D89; Sun, 8 Dec 2019 13:23:43 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id EAEF5C1D88 for ; Sun, 8 Dec 2019 13:23:38 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id D57A08672E for ; Sun, 8 Dec 2019 13:23:38 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rCHMsWhie7Ju for ; Sun, 8 Dec 2019 13:23:34 +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 fraxinus.osuosl.org (Postfix) with ESMTP id C69BD86303 for ; Sun, 8 Dec 2019 13:23:26 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE1 (envelope-from elibr@mellanox.com) with ESMTPS (AES256-SHA encrypted); 8 Dec 2019 15:23:20 +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 xB8DNJh0002052; Sun, 8 Dec 2019 15:23:20 +0200 From: Eli Britstein To: dev@openvswitch.org, Ilya Maximets , Sriharsha Basavapatna Date: Sun, 8 Dec 2019 13:22:51 +0000 Message-Id: <20191208132304.15521-7-elibr@mellanox.com> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20191208132304.15521-1-elibr@mellanox.com> References: <20191208132304.15521-1-elibr@mellanox.com> Cc: Oz Shlomo , Majd Dibbiny , Eli Britstein , Ameer Mahagneh Subject: [ovs-dev] [PATCH V3 06/19] 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 | 112 +++++++++++++++++++++++++++++++++++++++------- lib/netdev-offload.h | 1 + 2 files changed, 97 insertions(+), 16 deletions(-) diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c index c272da340..b2ec05cec 100644 --- a/lib/netdev-offload-dpdk.c +++ b/lib/netdev-offload-dpdk.c @@ -28,6 +28,7 @@ #include "uuid.h" VLOG_DEFINE_THIS_MODULE(netdev_offload_dpdk); +static struct vlog_rate_limit error_rl = VLOG_RATE_LIMIT_INIT(100, 5); /* Thread-safety * ============= @@ -424,6 +425,93 @@ add_flow_mark_rss_actions(struct flow_actions *actions, add_flow_action(actions, RTE_FLOW_ACTION_TYPE_END, NULL); } +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 rte_flow_error error; + struct rte_flow *flow; + + add_flow_mark_rss_actions(&actions, flow_mark, netdev); + + flow = netdev_dpdk_rte_flow_create(netdev, &flow_attr, + patterns->items, + actions.actions, &error); + + if (!flow) { + VLOG_ERR("%s: Failed to create flow: %s (%u)\n", + netdev_get_name(netdev), error.message, error.type); + } + + 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(&error_rl, + "Unsupported action type %d", nl_attr_type(nla)); + return -1; + } + + if (nl_actions_len == 0) { + VLOG_DBG_RL(&error_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_dpdk_rte_flow_create(netdev, &flow_attr, patterns->items, + actions.actions, &error); + if (!flow) { + VLOG_ERR("%s: Failed to create flow: %s (%u)\n", + netdev_get_name(netdev), error.message, error.type); + } + if (flow && info->actions_offloaded) { + *info->actions_offloaded = true; + } +out: + free_flow_actions(&actions); + return flow; +} + static int netdev_offload_dpdk_add_flow(struct netdev *netdev, const struct match *match, @@ -432,16 +520,8 @@ netdev_offload_dpdk_add_flow(struct netdev *netdev, const ovs_u128 *ufid, struct offload_info *info) { - 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 *flow; - struct rte_flow_error error; int ret = 0; ret = parse_flow_match(&patterns, match); @@ -450,15 +530,16 @@ netdev_offload_dpdk_add_flow(struct netdev *netdev, goto out; } - add_flow_mark_rss_actions(&actions, info->flow_mark, netdev); - - flow = netdev_dpdk_rte_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); + } if (!flow) { - VLOG_ERR("%s: Failed to create flow: %s (%u)\n", - netdev_get_name(netdev), error.message, error.type); ret = -1; goto out; } @@ -468,7 +549,6 @@ netdev_offload_dpdk_add_flow(struct netdev *netdev, out: free_flow_patterns(&patterns); - free_flow_actions(&actions); return ret; } diff --git a/lib/netdev-offload.h b/lib/netdev-offload.h index 97a500647..892dca576 100644 --- a/lib/netdev-offload.h +++ b/lib/netdev-offload.h @@ -71,6 +71,7 @@ struct offload_info { * it will be in the pkt meta data. */ uint32_t flow_mark; + bool *actions_offloaded; /* true if flow is fully actions_offloaded */ }; int netdev_flow_flush(struct netdev *); From patchwork Sun Dec 8 13:22:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Britstein X-Patchwork-Id: 1205663 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.138; helo=whitealder.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 whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47W6Tz4Z6hz9sP6 for ; Mon, 9 Dec 2019 00:23:51 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id B1E0086E3A; Sun, 8 Dec 2019 13:23:48 +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 THlN1MqxElau; Sun, 8 Dec 2019 13:23:43 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by whitealder.osuosl.org (Postfix) with ESMTP id 00B498731C; Sun, 8 Dec 2019 13:23:34 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id D962BC1D88; Sun, 8 Dec 2019 13:23:33 +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 CAFD2C1D82 for ; Sun, 8 Dec 2019 13:23:28 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id C5D2286CB4 for ; Sun, 8 Dec 2019 13:23:28 +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 CSn43UIZvyPb for ; Sun, 8 Dec 2019 13:23:27 +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 BF9F186BE0 for ; Sun, 8 Dec 2019 13:23:26 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE1 (envelope-from elibr@mellanox.com) with ESMTPS (AES256-SHA encrypted); 8 Dec 2019 15:23:20 +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 xB8DNJh1002052; Sun, 8 Dec 2019 15:23:20 +0200 From: Eli Britstein To: dev@openvswitch.org, Ilya Maximets , Sriharsha Basavapatna Date: Sun, 8 Dec 2019 13:22:52 +0000 Message-Id: <20191208132304.15521-8-elibr@mellanox.com> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20191208132304.15521-1-elibr@mellanox.com> References: <20191208132304.15521-1-elibr@mellanox.com> Cc: Oz Shlomo , Majd Dibbiny , Eli Britstein , Ameer Mahagneh Subject: [ovs-dev] [PATCH V3 07/19] netdev-dpdk: Introduce rte flow query function 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" Introduce a rte flow query function as a pre-step towards reading HW statistics of fully offloaded flows. Signed-off-by: Eli Britstein Reviewed-by: Oz Shlomo --- lib/netdev-dpdk.c | 25 +++++++++++++++++++++++++ lib/netdev-dpdk.h | 6 ++++++ 2 files changed, 31 insertions(+) diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index da1349b69..e63a496c1 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -4737,6 +4737,31 @@ netdev_dpdk_rte_flow_create(struct netdev *netdev, return flow; } +int +netdev_dpdk_rte_flow_query(struct netdev *netdev, + struct rte_flow *rte_flow, + struct rte_flow_query_count *query, + struct rte_flow_error *error) +{ + struct netdev_dpdk *dev = netdev_dpdk_cast(netdev); + struct rte_flow_action_count count = {}; + const struct rte_flow_action actions[] = { + { + .type = RTE_FLOW_ACTION_TYPE_COUNT, + .conf = &count, + }, + { + .type = RTE_FLOW_ACTION_TYPE_END, + }, + }; + int ret; + + ovs_mutex_lock(&dev->mutex); + ret = rte_flow_query(dev->port_id, rte_flow, actions, query, error); + ovs_mutex_unlock(&dev->mutex); + return ret; +} + #define NETDEV_DPDK_CLASS_COMMON \ .is_pmd = true, \ .alloc = netdev_dpdk_alloc, \ diff --git a/lib/netdev-dpdk.h b/lib/netdev-dpdk.h index 60631c4f0..ed7cb235a 100644 --- a/lib/netdev-dpdk.h +++ b/lib/netdev-dpdk.h @@ -31,6 +31,7 @@ struct rte_flow_error; struct rte_flow_attr; struct rte_flow_item; struct rte_flow_action; +struct rte_flow_query_count; void netdev_dpdk_register(void); void free_dpdk_buf(struct dp_packet *); @@ -47,6 +48,11 @@ netdev_dpdk_rte_flow_create(struct netdev *netdev, const struct rte_flow_item *items, const struct rte_flow_action *actions, struct rte_flow_error *error); +int +netdev_dpdk_rte_flow_query(struct netdev *netdev, + struct rte_flow *rte_flow, + struct rte_flow_query_count *query, + struct rte_flow_error *error); #else From patchwork Sun Dec 8 13:22:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Britstein X-Patchwork-Id: 1205664 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.137; helo=fraxinus.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 fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47W6Tz70Vhz9sPK for ; Mon, 9 Dec 2019 00:23:51 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 7C2CF8698B; Sun, 8 Dec 2019 13:23:50 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id b2EPaWPTrdqu; Sun, 8 Dec 2019 13:23:48 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by fraxinus.osuosl.org (Postfix) with ESMTP id 9CCDA8652A; Sun, 8 Dec 2019 13:23:34 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 86882C1D83; Sun, 8 Dec 2019 13:23:34 +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 2100EC1D7F for ; Sun, 8 Dec 2019 13:23:29 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 0EA4486C4A for ; Sun, 8 Dec 2019 13:23:29 +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 6BSUPritgDBE for ; Sun, 8 Dec 2019 13:23:27 +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 C83E686BF9 for ; Sun, 8 Dec 2019 13:23:26 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE1 (envelope-from elibr@mellanox.com) with ESMTPS (AES256-SHA encrypted); 8 Dec 2019 15:23:20 +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 xB8DNJh2002052; Sun, 8 Dec 2019 15:23:20 +0200 From: Eli Britstein To: dev@openvswitch.org, Ilya Maximets , Sriharsha Basavapatna Date: Sun, 8 Dec 2019 13:22:53 +0000 Message-Id: <20191208132304.15521-9-elibr@mellanox.com> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20191208132304.15521-1-elibr@mellanox.com> References: <20191208132304.15521-1-elibr@mellanox.com> Cc: Oz Shlomo , Majd Dibbiny , Eli Britstein , Ameer Mahagneh Subject: [ovs-dev] [PATCH V3 08/19] netdev-offload-dpdk: Protect UFID map by mutex 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" Flow deletion and dumping for statistics collection are called from different threads. As a pre-step towards collecting HW statistics, protect the UFID map by mutex to make it thread safe. Signed-off-by: Eli Britstein --- lib/netdev-offload-dpdk.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c index b2ec05cec..5568400b6 100644 --- a/lib/netdev-offload-dpdk.c +++ b/lib/netdev-offload-dpdk.c @@ -51,6 +51,7 @@ static struct vlog_rate_limit error_rl = VLOG_RATE_LIMIT_INIT(100, 5); * A mapping from ufid to dpdk rte_flow. */ static struct cmap ufid_to_rte_flow = CMAP_INITIALIZER; +static struct ovs_mutex ufid_map_mutex = OVS_MUTEX_INITIALIZER; struct ufid_to_rte_flow_data { struct cmap_node node; @@ -630,8 +631,11 @@ netdev_offload_dpdk_destroy_flow(struct netdev *netdev, struct rte_flow *rte_flow) { struct rte_flow_error error; - int ret = netdev_dpdk_rte_flow_destroy(netdev, rte_flow, &error); + int ret; + + ovs_mutex_lock(&ufid_map_mutex); + ret = netdev_dpdk_rte_flow_destroy(netdev, rte_flow, &error); if (ret == 0) { ufid_to_rte_flow_disassociate(ufid); VLOG_DBG("%s: removed rte flow %p associated with ufid " UUID_FMT "\n", @@ -642,6 +646,7 @@ netdev_offload_dpdk_destroy_flow(struct netdev *netdev, netdev_get_name(netdev), error.message, error.type); } + ovs_mutex_unlock(&ufid_map_mutex); return ret; } From patchwork Sun Dec 8 13:22:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Britstein X-Patchwork-Id: 1205665 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.133; helo=hemlock.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 hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47W6VD3d4Vz9sP6 for ; Mon, 9 Dec 2019 00:24:04 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 6B25688543; Sun, 8 Dec 2019 13:24:01 +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 bEhVHVJpuiNA; Sun, 8 Dec 2019 13:23:58 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id D6913881BB; Sun, 8 Dec 2019 13:23:38 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 9B87EC1D8C; Sun, 8 Dec 2019 13:23:38 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 023AAC1D8A for ; Sun, 8 Dec 2019 13:23:33 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id E06D72049A for ; Sun, 8 Dec 2019 13:23:32 +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 VISn4bms3pLb for ; Sun, 8 Dec 2019 13:23:31 +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 silver.osuosl.org (Postfix) with ESMTP id EC770203FF for ; Sun, 8 Dec 2019 13:23:26 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE1 (envelope-from elibr@mellanox.com) with ESMTPS (AES256-SHA encrypted); 8 Dec 2019 15:23:20 +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 xB8DNJh3002052; Sun, 8 Dec 2019 15:23:20 +0200 From: Eli Britstein To: dev@openvswitch.org, Ilya Maximets , Sriharsha Basavapatna Date: Sun, 8 Dec 2019 13:22:54 +0000 Message-Id: <20191208132304.15521-10-elibr@mellanox.com> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20191208132304.15521-1-elibr@mellanox.com> References: <20191208132304.15521-1-elibr@mellanox.com> Cc: Oz Shlomo , Majd Dibbiny , Eli Britstein , Ameer Mahagneh Subject: [ovs-dev] [PATCH V3 09/19] netdev-offload-dpdk: Implement flow get method 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" Implement the flow get method for DPDK, to get the statistics of the provided ufid, towards reading statistics of fully offloaded flows. Signed-off-by: Eli Britstein Reviewed-by: Oz Shlomo --- lib/netdev-offload-dpdk.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c index 5568400b6..10ab9240a 100644 --- a/lib/netdev-offload-dpdk.c +++ b/lib/netdev-offload-dpdk.c @@ -705,9 +705,49 @@ netdev_offload_dpdk_init_flow_api(struct netdev *netdev) return netdev_dpdk_flow_api_supported(netdev) ? 0 : EOPNOTSUPP; } +static int +netdev_offload_dpdk_flow_get(struct netdev *netdev, + struct match *match OVS_UNUSED, + struct nlattr **actions OVS_UNUSED, + const ovs_u128 *ufid, + struct dpif_flow_stats *stats, + struct dpif_flow_attrs *attrs OVS_UNUSED, + struct ofpbuf *buf OVS_UNUSED) +{ + struct rte_flow_query_count query = { .reset = 1 }; + struct rte_flow_error error; + struct rte_flow *rte_flow; + int ret = 0; + + ovs_mutex_lock(&ufid_map_mutex); + rte_flow = ufid_to_rte_flow_find(ufid); + if (!rte_flow) { + ret = -1; + goto out; + } + + memset(stats, 0, sizeof *stats); + ret = netdev_dpdk_rte_flow_query(netdev, rte_flow, &query, &error); + if (ret) { + VLOG_DBG_RL(&error_rl, + "%s: Failed to query ufid "UUID_FMT" flow: %p\n", + netdev_get_name(netdev), UUID_ARGS((struct uuid *)ufid), + rte_flow); + ret = -1; + goto out; + } + stats->n_packets += (query.hits_set) ? query.hits : 0; + stats->n_bytes += (query.bytes_set) ? query.bytes : 0; + +out: + ovs_mutex_unlock(&ufid_map_mutex); + return ret; +} + const struct netdev_flow_api netdev_offload_dpdk = { .type = "dpdk_flow_api", .flow_put = netdev_offload_dpdk_flow_put, .flow_del = netdev_offload_dpdk_flow_del, .init_flow_api = netdev_offload_dpdk_init_flow_api, + .flow_get = netdev_offload_dpdk_flow_get, }; From patchwork Sun Dec 8 13:22:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Britstein X-Patchwork-Id: 1205670 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.133; helo=hemlock.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 hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47W6Vb5QF0z9sP6 for ; Mon, 9 Dec 2019 00:24:23 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 3DD5588603; Sun, 8 Dec 2019 13:24:22 +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 g1-KaVE2SkI2; Sun, 8 Dec 2019 13:24:18 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id DD28E88391; Sun, 8 Dec 2019 13:23:45 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id BBAA7C1D88; Sun, 8 Dec 2019 13:23:45 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id F36CFC1D8C for ; Sun, 8 Dec 2019 13:23:44 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 45AD0868BE for ; Sun, 8 Dec 2019 13:23:44 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id b9leTheLduIg for ; Sun, 8 Dec 2019 13:23:35 +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 fraxinus.osuosl.org (Postfix) with ESMTP id D35A286308 for ; Sun, 8 Dec 2019 13:23:26 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE1 (envelope-from elibr@mellanox.com) with ESMTPS (AES256-SHA encrypted); 8 Dec 2019 15:23:20 +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 xB8DNJh4002052; Sun, 8 Dec 2019 15:23:20 +0200 From: Eli Britstein To: dev@openvswitch.org, Ilya Maximets , Sriharsha Basavapatna Date: Sun, 8 Dec 2019 13:22:55 +0000 Message-Id: <20191208132304.15521-11-elibr@mellanox.com> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20191208132304.15521-1-elibr@mellanox.com> References: <20191208132304.15521-1-elibr@mellanox.com> Cc: Oz Shlomo , Majd Dibbiny , Eli Britstein , Ameer Mahagneh Subject: [ovs-dev] [PATCH V3 10/19] dpif-netdev: Read hw stats during flow_dump_next() call 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" From: Ophir Munk Use netdev flow get API in order to update the statistics of fully offloaded flows. Co-authored-by: Eli Britstein Signed-off-by: Ophir Munk Reviewed-by: Oz Shlomo Signed-off-by: Eli Britstein --- lib/dpif-netdev.c | 47 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 1e5493615..37e7e5c38 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -527,6 +527,7 @@ struct dp_netdev_flow { bool dead; uint32_t mark; /* Unique flow mark assigned to a flow */ + bool actions_offloaded; /* true if flow is fully offloaded. */ /* Statistics. */ struct dp_netdev_flow_stats stats; @@ -2409,6 +2410,7 @@ dp_netdev_flow_offload_put(struct dp_flow_offload_item *offload) } } info.flow_mark = mark; + info.actions_offloaded = &flow->actions_offloaded; port = netdev_ports_get(in_port, pmd->dp->dpif->dpif_class); if (!port || netdev_vport_is_vport_class(port->netdev_class)) { @@ -3071,8 +3073,8 @@ dp_netdev_flow_to_dpif_flow(const struct dp_netdev_flow *netdev_flow, flow->pmd_id = netdev_flow->pmd_id; get_dpif_flow_stats(netdev_flow, &flow->stats); - flow->attrs.offloaded = false; - flow->attrs.dp_layer = "ovs"; + flow->attrs.offloaded = netdev_flow->actions_offloaded; + flow->attrs.dp_layer = flow->attrs.offloaded ? "in_hw" : "ovs"; } static int @@ -3242,6 +3244,7 @@ dp_netdev_flow_add(struct dp_netdev_pmd_thread *pmd, flow->dead = false; flow->batch = NULL; flow->mark = INVALID_FLOW_MARK; + flow->actions_offloaded = false; *CONST_CAST(unsigned *, &flow->pmd_id) = pmd->core_id; *CONST_CAST(struct flow *, &flow->flow) = match->flow; *CONST_CAST(ovs_u128 *, &flow->ufid) = *ufid; @@ -3596,6 +3599,42 @@ dpif_netdev_flow_dump_thread_destroy(struct dpif_flow_dump_thread *thread_) free(thread); } +static int +dpif_netdev_offload_used(struct dp_netdev_flow *netdev_flow, + struct dp_netdev_pmd_thread *pmd) +{ + struct dpif_flow_stats stats; + struct netdev *netdev; + struct match match; + struct nlattr *actions; + struct dpif_flow_attrs attrs; + struct ofpbuf wbuffer; + + ovs_u128 ufid; + int ret = 0; + + netdev = netdev_ports_get(netdev_flow->flow.in_port.odp_port, + pmd->dp->class); + if (!netdev) { + return -1; + } + /* get offloaded stats */ + ufid = netdev_flow->mega_ufid; + ret = netdev_flow_get(netdev, &match, &actions, &ufid, &stats, &attrs, + &wbuffer); + netdev_close(netdev); + if (ret) { + return -1; + } + if (stats.n_packets) { + atomic_store_relaxed(&netdev_flow->stats.used, pmd->ctx.now / 1000); + non_atomic_ullong_add(&netdev_flow->stats.packet_count, stats.n_packets); + non_atomic_ullong_add(&netdev_flow->stats.byte_count, stats.n_bytes); + } + + return 0; +} + static int dpif_netdev_flow_dump_next(struct dpif_flow_dump_thread *thread_, struct dpif_flow *flows, int max_flows) @@ -3636,6 +3675,10 @@ dpif_netdev_flow_dump_next(struct dpif_flow_dump_thread *thread_, netdev_flows[n_flows] = CONTAINER_OF(node, struct dp_netdev_flow, node); + /* Read hardware stats in case of hardware offload */ + if (netdev_flows[n_flows]->actions_offloaded) { + dpif_netdev_offload_used(netdev_flows[n_flows], pmd); + } } /* When finishing dumping the current pmd thread, moves to * the next. */ From patchwork Sun Dec 8 13:22:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Britstein X-Patchwork-Id: 1205659 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 47W6Ts2b0nz9sPL for ; Mon, 9 Dec 2019 00:23:45 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 45DDC203ED; Sun, 8 Dec 2019 13:23:43 +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 HCow9G9gMLg7; Sun, 8 Dec 2019 13:23:37 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by silver.osuosl.org (Postfix) with ESMTP id 36C0020476; Sun, 8 Dec 2019 13:23:32 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 073A1C1D88; Sun, 8 Dec 2019 13:23:32 +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 AD30CC0881 for ; Sun, 8 Dec 2019 13:23:28 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 808C787E79 for ; Sun, 8 Dec 2019 13:23:28 +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 FHptB3HBHo8X for ; Sun, 8 Dec 2019 13:23:27 +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 21AEE87E6E for ; Sun, 8 Dec 2019 13:23:26 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE1 (envelope-from elibr@mellanox.com) with ESMTPS (AES256-SHA encrypted); 8 Dec 2019 15:23:20 +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 xB8DNJh5002052; Sun, 8 Dec 2019 15:23:20 +0200 From: Eli Britstein To: dev@openvswitch.org, Ilya Maximets , Sriharsha Basavapatna Date: Sun, 8 Dec 2019 13:22:56 +0000 Message-Id: <20191208132304.15521-12-elibr@mellanox.com> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20191208132304.15521-1-elibr@mellanox.com> References: <20191208132304.15521-1-elibr@mellanox.com> Cc: Oz Shlomo , Majd Dibbiny , Eli Britstein , Ameer Mahagneh Subject: [ovs-dev] [PATCH V3 11/19] dpif-netdev: Populate dpif class field in offload struct 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" Populate dpif class field in offload struct to be used in offloading flow put. Signed-off-by: Eli Britstein Reviewed-by: Oz Shlomo --- lib/dpif-netdev.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 37e7e5c38..1d1de94de 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -2373,6 +2373,7 @@ static int dp_netdev_flow_offload_put(struct dp_flow_offload_item *offload) { struct dp_netdev_pmd_thread *pmd = offload->pmd; + const struct dpif_class *dpif_class = pmd->dp->class; struct dp_netdev_flow *flow = offload->flow; odp_port_t in_port = flow->flow.in_port.odp_port; bool modification = offload->op == DP_NETDEV_FLOW_OFFLOAD_OP_MOD; @@ -2411,6 +2412,7 @@ dp_netdev_flow_offload_put(struct dp_flow_offload_item *offload) } info.flow_mark = mark; info.actions_offloaded = &flow->actions_offloaded; + info.dpif_class = dpif_class; port = netdev_ports_get(in_port, pmd->dp->dpif->dpif_class); if (!port || netdev_vport_is_vport_class(port->netdev_class)) { From patchwork Sun Dec 8 13:22:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Britstein X-Patchwork-Id: 1205656 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.138; helo=whitealder.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 whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47W6Tc6nt1z9sP6 for ; Mon, 9 Dec 2019 00:23:32 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 6E87A8675F; Sun, 8 Dec 2019 13:23:31 +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 5v4kP+EK+2h7; Sun, 8 Dec 2019 13:23:30 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by whitealder.osuosl.org (Postfix) with ESMTP id 4F94586B6B; Sun, 8 Dec 2019 13:23:30 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 356AAC1D7F; Sun, 8 Dec 2019 13:23:30 +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 74808C0881 for ; Sun, 8 Dec 2019 13:23:28 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 6334987EA1 for ; Sun, 8 Dec 2019 13:23:28 +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 VOUqK-F8fM2s for ; Sun, 8 Dec 2019 13:23:27 +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 2390287E79 for ; Sun, 8 Dec 2019 13:23:26 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE1 (envelope-from elibr@mellanox.com) with ESMTPS (AES256-SHA encrypted); 8 Dec 2019 15:23:20 +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 xB8DNJh6002052; Sun, 8 Dec 2019 15:23:20 +0200 From: Eli Britstein To: dev@openvswitch.org, Ilya Maximets , Sriharsha Basavapatna Date: Sun, 8 Dec 2019 13:22:57 +0000 Message-Id: <20191208132304.15521-13-elibr@mellanox.com> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20191208132304.15521-1-elibr@mellanox.com> References: <20191208132304.15521-1-elibr@mellanox.com> Cc: Oz Shlomo , Majd Dibbiny , Eli Britstein , Ameer Mahagneh Subject: [ovs-dev] [PATCH V3 12/19] netdev-dpdk: Getter function for dpdk port id API 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" Add a getter function for using the dpdk port id outside the scope of netdev-dpdk.c to be used for HW offload. Signed-off-by: Eli Britstein Reviewed-by: Oz Shlomo --- lib/netdev-dpdk.c | 18 ++++++++++++++++++ lib/netdev-dpdk.h | 2 ++ 2 files changed, 20 insertions(+) diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index e63a496c1..16baae0c4 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -4426,6 +4426,24 @@ unlock: return err; } +int +netdev_dpdk_get_port_id(struct netdev *netdev) +{ + struct netdev_dpdk *dev; + int ret = -1; + + if (!is_dpdk_class(netdev->netdev_class)) { + goto out; + } + + dev = netdev_dpdk_cast(netdev); + ovs_mutex_lock(&dev->mutex); + ret = dev->port_id; + ovs_mutex_unlock(&dev->mutex); +out: + return ret; +} + bool netdev_dpdk_flow_api_supported(struct netdev *netdev) { diff --git a/lib/netdev-dpdk.h b/lib/netdev-dpdk.h index ed7cb235a..65f6eedf3 100644 --- a/lib/netdev-dpdk.h +++ b/lib/netdev-dpdk.h @@ -53,6 +53,8 @@ netdev_dpdk_rte_flow_query(struct netdev *netdev, struct rte_flow *rte_flow, struct rte_flow_query_count *query, struct rte_flow_error *error); +int +netdev_dpdk_get_port_id(struct netdev *netdev); #else From patchwork Sun Dec 8 13:22:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Britstein X-Patchwork-Id: 1205658 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.137; helo=fraxinus.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 fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47W6Tr55DGz9sP6 for ; Mon, 9 Dec 2019 00:23:44 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 10BB38680B; Sun, 8 Dec 2019 13:23:43 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gDyacQemIG1O; Sun, 8 Dec 2019 13:23:40 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by fraxinus.osuosl.org (Postfix) with ESMTP id 44FB88648E; Sun, 8 Dec 2019 13:23:31 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 27600C1D8A; Sun, 8 Dec 2019 13:23:31 +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 85037C1D7F for ; Sun, 8 Dec 2019 13:23:28 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 57AE487E62 for ; Sun, 8 Dec 2019 13:23:28 +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 q-iK7SRzMu7q for ; Sun, 8 Dec 2019 13:23:27 +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 2E48487E8A for ; Sun, 8 Dec 2019 13:23:26 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE1 (envelope-from elibr@mellanox.com) with ESMTPS (AES256-SHA encrypted); 8 Dec 2019 15:23:20 +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 xB8DNJh7002052; Sun, 8 Dec 2019 15:23:20 +0200 From: Eli Britstein To: dev@openvswitch.org, Ilya Maximets , Sriharsha Basavapatna Date: Sun, 8 Dec 2019 13:22:58 +0000 Message-Id: <20191208132304.15521-14-elibr@mellanox.com> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20191208132304.15521-1-elibr@mellanox.com> References: <20191208132304.15521-1-elibr@mellanox.com> Cc: Oz Shlomo , Majd Dibbiny , Eli Britstein , Ameer Mahagneh Subject: [ovs-dev] [PATCH V3 13/19] netdev-offload: Introduce a function to validate same flow api handle 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" Signed-off-by: Eli Britstein --- lib/netdev-offload-provider.h | 1 + lib/netdev-offload.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/lib/netdev-offload-provider.h b/lib/netdev-offload-provider.h index 4e1c4251d..5a809c0cd 100644 --- a/lib/netdev-offload-provider.h +++ b/lib/netdev-offload-provider.h @@ -89,6 +89,7 @@ struct netdev_flow_api { int netdev_register_flow_api_provider(const struct netdev_flow_api *); int netdev_unregister_flow_api_provider(const char *type); +bool netdev_flow_api_equals(const struct netdev *, const struct netdev *); #ifdef __linux__ extern const struct netdev_flow_api netdev_offload_tc; diff --git a/lib/netdev-offload.c b/lib/netdev-offload.c index ae01acda6..32eab5910 100644 --- a/lib/netdev-offload.c +++ b/lib/netdev-offload.c @@ -156,6 +156,18 @@ netdev_unregister_flow_api_provider(const char *type) return error; } +bool +netdev_flow_api_equals(const struct netdev *netdev1, + const struct netdev *netdev2) +{ + const struct netdev_flow_api *netdev_flow_api1 = + ovsrcu_get(const struct netdev_flow_api *, &netdev1->flow_api); + const struct netdev_flow_api *netdev_flow_api2 = + ovsrcu_get(const struct netdev_flow_api *, &netdev2->flow_api); + + return netdev_flow_api1 == netdev_flow_api2; +} + static int netdev_assign_flow_api(struct netdev *netdev) { From patchwork Sun Dec 8 13:22:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Britstein X-Patchwork-Id: 1205660 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.133; helo=hemlock.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 hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47W6Ts2FfJz9sPK for ; Mon, 9 Dec 2019 00:23:44 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id A26B08805D; Sun, 8 Dec 2019 13:23:42 +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 9GesJzLf7TMI; Sun, 8 Dec 2019 13:23:37 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id B57398803E; Sun, 8 Dec 2019 13:23:35 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 8AA11C1D83; Sun, 8 Dec 2019 13:23:35 +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 5F262C0881 for ; Sun, 8 Dec 2019 13:23:29 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 5A3C786BF9 for ; Sun, 8 Dec 2019 13:23:29 +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 F6Ljzwf5fDP6 for ; Sun, 8 Dec 2019 13:23:27 +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 0738386C4D for ; Sun, 8 Dec 2019 13:23:26 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE1 (envelope-from elibr@mellanox.com) with ESMTPS (AES256-SHA encrypted); 8 Dec 2019 15:23:21 +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 xB8DNJh8002052; Sun, 8 Dec 2019 15:23:20 +0200 From: Eli Britstein To: dev@openvswitch.org, Ilya Maximets , Sriharsha Basavapatna Date: Sun, 8 Dec 2019 13:22:59 +0000 Message-Id: <20191208132304.15521-15-elibr@mellanox.com> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20191208132304.15521-1-elibr@mellanox.com> References: <20191208132304.15521-1-elibr@mellanox.com> Cc: Oz Shlomo , Majd Dibbiny , Eli Britstein , Ameer Mahagneh Subject: [ovs-dev] [PATCH V3 14/19] 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-dpdk.c | 22 +++++++++++++ lib/netdev-offload-dpdk.c | 73 +++++++++++++++++++++++++++++++++++++++++--- 4 files changed, 104 insertions(+), 9 deletions(-) diff --git a/Documentation/howto/dpdk.rst b/Documentation/howto/dpdk.rst index 766a7950c..f62ce82af 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 (a single output, as the last action). + Further Reading --------------- diff --git a/NEWS b/NEWS index 2acde3fe8..c430999a0 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). v2.12.0 - 03 Sep 2019 --------------------- diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index 16baae0c4..d9a2c2004 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -4699,6 +4699,28 @@ ds_put_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); } diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c index 10ab9240a..0b9087192 100644 --- a/lib/netdev-offload-dpdk.c +++ b/lib/netdev-offload-dpdk.c @@ -456,20 +456,83 @@ 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); + + count->shared = 0; + /* Each flow has a single count action, so no need of id */ + count->id = 0; + 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 = xzalloc(sizeof *port_id); + int outdev_id; + + outdev_id = netdev_dpdk_get_port_id(outdev); + if (outdev_id < 0) { + return -1; + } + 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(&error_rl, + "Cannot find netdev for odp port %d", port); + return -1; + } + if (!netdev_flow_api_equals(netdev, outdev) || + add_port_id_action(actions, outdev)) { + VLOG_DBG_RL(&error_rl, + "Output to %s cannot be offloaded", + 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(&error_rl, - "Unsupported action type %d", nl_attr_type(nla)); - return -1; + if (nl_attr_type(nla) == OVS_ACTION_ATTR_OUTPUT) { + if (!(left <= NLA_ALIGN(nla->nla_len)) || + add_output_action(netdev, actions, nla, info )) { + return -1; + } + } else { + VLOG_DBG_RL(&error_rl, + "Unsupported action type %d", nl_attr_type(nla)); + return -1; + } } if (nl_actions_len == 0) { From patchwork Sun Dec 8 13:23:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Britstein X-Patchwork-Id: 1205667 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.133; helo=hemlock.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 hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47W6VG6Sgbz9sPK for ; Mon, 9 Dec 2019 00:24:06 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 6A24388596; Sun, 8 Dec 2019 13:24:04 +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 Ih1ZFdQ29XNI; Sun, 8 Dec 2019 13:24:02 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id DCF4F88258; Sun, 8 Dec 2019 13:23:40 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id A5376C1D82; Sun, 8 Dec 2019 13:23:40 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 190D1C1D7F for ; Sun, 8 Dec 2019 13:23:35 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id F1AA9204B8 for ; Sun, 8 Dec 2019 13:23:34 +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 sM1mUcdpP4Bu for ; Sun, 8 Dec 2019 13:23:33 +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 silver.osuosl.org (Postfix) with ESMTP id 0666020412 for ; Sun, 8 Dec 2019 13:23:26 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE1 (envelope-from elibr@mellanox.com) with ESMTPS (AES256-SHA encrypted); 8 Dec 2019 15:23:21 +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 xB8DNJh9002052; Sun, 8 Dec 2019 15:23:21 +0200 From: Eli Britstein To: dev@openvswitch.org, Ilya Maximets , Sriharsha Basavapatna Date: Sun, 8 Dec 2019 13:23:00 +0000 Message-Id: <20191208132304.15521-16-elibr@mellanox.com> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20191208132304.15521-1-elibr@mellanox.com> References: <20191208132304.15521-1-elibr@mellanox.com> Cc: Oz Shlomo , Majd Dibbiny , Eli Britstein , Ameer Mahagneh Subject: [ovs-dev] [PATCH V3 15/19] netdev-offload-dpdk: Support offload of drop 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" Signed-off-by: Eli Britstein Reviewed-by: Oz Shlomo --- Documentation/howto/dpdk.rst | 1 + NEWS | 2 +- lib/netdev-dpdk.c | 2 ++ lib/netdev-offload-dpdk.c | 4 +--- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Documentation/howto/dpdk.rst b/Documentation/howto/dpdk.rst index f62ce82af..6cedd7f63 100644 --- a/Documentation/howto/dpdk.rst +++ b/Documentation/howto/dpdk.rst @@ -391,6 +391,7 @@ Supported protocols for hardware offload matches are: Supported actions for hardware offload are: - Output (a single output, as the last action). +- Drop. Further Reading --------------- diff --git a/NEWS b/NEWS index c430999a0..d019e066f 100644 --- a/NEWS +++ b/NEWS @@ -26,7 +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). + * Add hardware offload support for output and drop actions (experimental). v2.12.0 - 03 Sep 2019 --------------------- diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index d9a2c2004..872a45e75 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -4721,6 +4721,8 @@ ds_put_flow_action(struct ds *s, const struct rte_flow_action *actions) } else { ds_put_cstr(s, " Port-id = null\n"); } + } else if (actions->type == RTE_FLOW_ACTION_TYPE_DROP) { + ds_put_cstr(s, "rte flow drop action\n"); } else { ds_put_format(s, "unknown rte flow action (%d)\n", actions->type); } diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c index 0b9087192..bffb69cad 100644 --- a/lib/netdev-offload-dpdk.c +++ b/lib/netdev-offload-dpdk.c @@ -536,9 +536,7 @@ parse_flow_actions(struct netdev *netdev, } if (nl_actions_len == 0) { - VLOG_DBG_RL(&error_rl, - "Unsupported action type drop"); - return -1; + add_flow_action(actions, RTE_FLOW_ACTION_TYPE_DROP, NULL); } add_flow_action(actions, RTE_FLOW_ACTION_TYPE_END, NULL); From patchwork Sun Dec 8 13:23:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Britstein X-Patchwork-Id: 1205673 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.138; helo=whitealder.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 whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47W6W871k8z9sP6 for ; Mon, 9 Dec 2019 00:24:52 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 5EC75877FC; Sun, 8 Dec 2019 13:24:51 +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 EnqP+3t5n6no; Sun, 8 Dec 2019 13:24:44 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by whitealder.osuosl.org (Postfix) with ESMTP id 3E594877F5; Sun, 8 Dec 2019 13:23:44 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 21E82C1D88; Sun, 8 Dec 2019 13:23:44 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 5FC5BC1D82 for ; Sun, 8 Dec 2019 13:23:40 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 5B2438618D for ; Sun, 8 Dec 2019 13:23:40 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Nh1wIO31oU_W for ; Sun, 8 Dec 2019 13:23:35 +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 fraxinus.osuosl.org (Postfix) with ESMTP id 0F1D1861F0 for ; Sun, 8 Dec 2019 13:23:26 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE1 (envelope-from elibr@mellanox.com) with ESMTPS (AES256-SHA encrypted); 8 Dec 2019 15:23:21 +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 xB8DNJhA002052; Sun, 8 Dec 2019 15:23:21 +0200 From: Eli Britstein To: dev@openvswitch.org, Ilya Maximets , Sriharsha Basavapatna Date: Sun, 8 Dec 2019 13:23:01 +0000 Message-Id: <20191208132304.15521-17-elibr@mellanox.com> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20191208132304.15521-1-elibr@mellanox.com> References: <20191208132304.15521-1-elibr@mellanox.com> Cc: Oz Shlomo , Majd Dibbiny , Eli Britstein , Ameer Mahagneh Subject: [ovs-dev] [PATCH V3 16/19] netdev-offload-dpdk: Support offload of set MAC actions 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" Signed-off-by: Eli Britstein Reviewed-by: Oz Shlomo --- Documentation/howto/dpdk.rst | 1 + NEWS | 3 +- lib/netdev-dpdk.c | 15 ++++++ lib/netdev-offload-dpdk.c | 107 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 125 insertions(+), 1 deletion(-) diff --git a/Documentation/howto/dpdk.rst b/Documentation/howto/dpdk.rst index 6cedd7f63..d228493e9 100644 --- a/Documentation/howto/dpdk.rst +++ b/Documentation/howto/dpdk.rst @@ -392,6 +392,7 @@ Supported actions for hardware offload are: - Output (a single output, as the last action). - Drop. +- Modification of Ethernet (mod_dl_src/mod_dl_dst). Further Reading --------------- diff --git a/NEWS b/NEWS index d019e066f..3ade86d49 100644 --- a/NEWS +++ b/NEWS @@ -26,7 +26,8 @@ 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 and drop actions (experimental). + * Add hardware offload support for output, drop and set MAC actions + (experimental). v2.12.0 - 03 Sep 2019 --------------------- diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index 872a45e75..e67a3dd76 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -4723,6 +4723,21 @@ ds_put_flow_action(struct ds *s, const struct rte_flow_action *actions) } } else if (actions->type == RTE_FLOW_ACTION_TYPE_DROP) { ds_put_cstr(s, "rte flow drop action\n"); + } else if (actions->type == RTE_FLOW_ACTION_TYPE_SET_MAC_SRC || + actions->type == RTE_FLOW_ACTION_TYPE_SET_MAC_DST) { + const struct rte_flow_action_set_mac *set_mac = actions->conf; + + char *dirstr = actions->type == RTE_FLOW_ACTION_TYPE_SET_MAC_DST + ? "dst" : "src"; + + ds_put_format(s, "rte flow set-mac-%s action:\n", dirstr); + if (set_mac) { + ds_put_format(s, + " Set-mac-%s: "ETH_ADDR_FMT"\n", + dirstr, ETH_ADDR_BYTES_ARGS(set_mac->mac_addr)); + } else { + ds_put_format(s, " Set-mac-%s = null\n", dirstr); + } } else { ds_put_format(s, "unknown rte flow action (%d)\n", actions->type); } diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c index bffb69cad..07f5d4687 100644 --- a/lib/netdev-offload-dpdk.c +++ b/lib/netdev-offload-dpdk.c @@ -511,6 +511,103 @@ add_output_action(struct netdev *netdev, return ret; } +struct set_action_info { + const uint8_t *value, *mask; + const uint8_t size; + uint8_t *spec; + const int attr; +}; + +static int +add_set_flow_action(struct flow_actions *actions, + struct set_action_info *sa_info_arr, + size_t sa_info_arr_size) +{ + int field, i; + + for (field = 0; field < sa_info_arr_size; field++) { + if (sa_info_arr[field].mask) { + /* DPDK does not support partially masked set actions. In such + * case, fail the offload. + */ + if (sa_info_arr[field].mask[0] != 0x00 && + sa_info_arr[field].mask[0] != 0xFF) { + VLOG_DBG_RL(&error_rl, + "Partial mask is not supported"); + return -1; + } + + for (i = 1; i < sa_info_arr[field].size; i++) { + if (sa_info_arr[field].mask[i] != + sa_info_arr[field].mask[i - 1]) { + VLOG_DBG_RL(&error_rl, + "Partial mask is not supported"); + return -1; + } + } + + if (sa_info_arr[field].mask[0] == 0x00) { + /* mask bytes are all 0 - no rewrite action required */ + continue; + } + } + + memcpy(sa_info_arr[field].spec, sa_info_arr[field].value, + sa_info_arr[field].size); + add_flow_action(actions, sa_info_arr[field].attr, + sa_info_arr[field].spec); + } + + return 0; +} + +/* Mask is at the midpoint of the data. */ +#define get_mask(a, type) ((const type *)(const void *)(a + 1) + 1) + +#define SA_INFO(_field, _spec, _attr) { \ + .value = (uint8_t *)&key->_field, \ + .mask = (masked) ? (uint8_t *)&mask->_field : NULL, \ + .size = sizeof key->_field, \ + .spec = (uint8_t *)&_spec, \ + .attr = _attr } + +static int +parse_set_actions(struct flow_actions *actions, + const struct nlattr *set_actions, + const size_t set_actions_len, + bool masked) +{ + const struct nlattr *sa; + unsigned int sleft; + + NL_ATTR_FOR_EACH_UNSAFE (sa, sleft, set_actions, set_actions_len) { + if (nl_attr_type(sa) == OVS_KEY_ATTR_ETHERNET) { + const struct ovs_key_ethernet *key = nl_attr_get(sa); + const struct ovs_key_ethernet *mask = masked ? + get_mask(sa, struct ovs_key_ethernet) : NULL; + struct rte_flow_action_set_mac *src = xzalloc(sizeof *src); + struct rte_flow_action_set_mac *dst = xzalloc(sizeof *dst); + struct set_action_info sa_info_arr[] = { + SA_INFO(eth_src, src->mac_addr[0], + RTE_FLOW_ACTION_TYPE_SET_MAC_SRC), + SA_INFO(eth_dst, dst->mac_addr[0], + RTE_FLOW_ACTION_TYPE_SET_MAC_DST), + }; + + if (add_set_flow_action(actions, sa_info_arr, + ARRAY_SIZE(sa_info_arr))) { + return -1; + } + } else { + VLOG_DBG_RL(&error_rl, + "Unsupported set action type=%d", nl_attr_type(sa)); + return -1; + } + } + + return 0; +} + static int parse_flow_actions(struct netdev *netdev, struct flow_actions *actions, @@ -528,6 +625,16 @@ parse_flow_actions(struct netdev *netdev, add_output_action(netdev, actions, nla, info )) { return -1; } + } else if (nl_attr_type(nla) == OVS_ACTION_ATTR_SET || + nl_attr_type(nla) == OVS_ACTION_ATTR_SET_MASKED) { + const struct nlattr *set_actions = nl_attr_get(nla); + const size_t set_actions_len = nl_attr_get_size(nla); + bool masked = nl_attr_type(nla) == OVS_ACTION_ATTR_SET_MASKED; + + if (parse_set_actions(actions, set_actions, set_actions_len, + masked)) { + return -1; + } } else { VLOG_DBG_RL(&error_rl, "Unsupported action type %d", nl_attr_type(nla)); From patchwork Sun Dec 8 13:23:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Britstein X-Patchwork-Id: 1205672 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.138; helo=whitealder.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 whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47W6Vs0k8Qz9sP6 for ; Mon, 9 Dec 2019 00:24:37 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 86AAC880A0; Sun, 8 Dec 2019 13:24:35 +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 EpzpFiTp587z; Sun, 8 Dec 2019 13:24:31 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by whitealder.osuosl.org (Postfix) with ESMTP id C8DE6876C2; Sun, 8 Dec 2019 13:23:42 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id B19C6C1D83; Sun, 8 Dec 2019 13:23:42 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id C2461C1D90 for ; Sun, 8 Dec 2019 13:23:38 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id A29172045C for ; Sun, 8 Dec 2019 13:23:38 +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 XmyDym42x54k for ; Sun, 8 Dec 2019 13:23:33 +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 silver.osuosl.org (Postfix) with ESMTP id 0E64620424 for ; Sun, 8 Dec 2019 13:23:26 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE1 (envelope-from elibr@mellanox.com) with ESMTPS (AES256-SHA encrypted); 8 Dec 2019 15:23:21 +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 xB8DNJhB002052; Sun, 8 Dec 2019 15:23:21 +0200 From: Eli Britstein To: dev@openvswitch.org, Ilya Maximets , Sriharsha Basavapatna Date: Sun, 8 Dec 2019 13:23:02 +0000 Message-Id: <20191208132304.15521-18-elibr@mellanox.com> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20191208132304.15521-1-elibr@mellanox.com> References: <20191208132304.15521-1-elibr@mellanox.com> Cc: Oz Shlomo , Majd Dibbiny , Eli Britstein , Ameer Mahagneh Subject: [ovs-dev] [PATCH V3 17/19] netdev-offload-dpdk: Support offload of set IPv4 actions 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" Signed-off-by: Eli Britstein Reviewed-by: Oz Shlomo --- Documentation/howto/dpdk.rst | 1 + NEWS | 4 ++-- lib/netdev-dpdk.c | 24 ++++++++++++++++++++++++ lib/netdev-offload-dpdk.c | 26 ++++++++++++++++++++++++++ 4 files changed, 53 insertions(+), 2 deletions(-) diff --git a/Documentation/howto/dpdk.rst b/Documentation/howto/dpdk.rst index d228493e9..b9be83002 100644 --- a/Documentation/howto/dpdk.rst +++ b/Documentation/howto/dpdk.rst @@ -393,6 +393,7 @@ Supported actions for hardware offload are: - Output (a single output, as the last action). - Drop. - Modification of Ethernet (mod_dl_src/mod_dl_dst). +- Modification of IPv4 (mod_nw_src/mod_nw_dst/mod_nw_ttl). Further Reading --------------- diff --git a/NEWS b/NEWS index 3ade86d49..297ca6fff 100644 --- a/NEWS +++ b/NEWS @@ -26,8 +26,8 @@ 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, drop and set MAC actions - (experimental). + * Add hardware offload support for output, drop and set actions of + MAC and IPv4 (experimental). v2.12.0 - 03 Sep 2019 --------------------- diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index e67a3dd76..c4606363d 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -4738,6 +4738,30 @@ ds_put_flow_action(struct ds *s, const struct rte_flow_action *actions) } else { ds_put_format(s, " Set-mac-%s = null\n", dirstr); } + } else if (actions->type == RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC || + actions->type == RTE_FLOW_ACTION_TYPE_SET_IPV4_DST) { + const struct rte_flow_action_set_ipv4 *set_ipv4 = actions->conf; + char *dirstr = actions->type == RTE_FLOW_ACTION_TYPE_SET_IPV4_DST + ? "dst" : "src"; + + ds_put_format(s, "rte flow set-ipv4-%s action:\n", dirstr); + if (set_ipv4) { + ds_put_format(s, + " Set-ipv4-%s: "IP_FMT"\n", + dirstr, IP_ARGS(set_ipv4->ipv4_addr)); + } else { + ds_put_format(s, " Set-ipv4-%s = null\n", dirstr); + } + } else if (actions->type == RTE_FLOW_ACTION_TYPE_SET_TTL) { + const struct rte_flow_action_set_ttl *set_ttl = actions->conf; + + ds_put_cstr(s, "rte flow set-ttl action:\n"); + if (set_ttl) { + ds_put_format(s, + " Set-ttl: %d\n", set_ttl->ttl_value); + } else { + ds_put_cstr(s, " Set-ttl = null\n"); + } } else { ds_put_format(s, "unknown rte flow action (%d)\n", actions->type); } diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c index 07f5d4687..3fccac956 100644 --- a/lib/netdev-offload-dpdk.c +++ b/lib/netdev-offload-dpdk.c @@ -594,6 +594,32 @@ parse_set_actions(struct flow_actions *actions, RTE_FLOW_ACTION_TYPE_SET_MAC_DST), }; + if (add_set_flow_action(actions, sa_info_arr, + ARRAY_SIZE(sa_info_arr))) { + return -1; + } + } else if (nl_attr_type(sa) == OVS_KEY_ATTR_IPV4) { + const struct ovs_key_ipv4 *key = nl_attr_get(sa); + const struct ovs_key_ipv4 *mask = masked ? + get_mask(sa, struct ovs_key_ipv4) : NULL; + struct rte_flow_action_set_ipv4 *src = xzalloc(sizeof *src); + struct rte_flow_action_set_ipv4 *dst = xzalloc(sizeof *dst); + struct rte_flow_action_set_ttl *ttl = xzalloc(sizeof *ttl); + struct set_action_info sa_info_arr[] = { + SA_INFO(ipv4_src, src->ipv4_addr, + RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC), + SA_INFO(ipv4_dst, dst->ipv4_addr, + RTE_FLOW_ACTION_TYPE_SET_IPV4_DST), + SA_INFO(ipv4_ttl, ttl->ttl_value, + RTE_FLOW_ACTION_TYPE_SET_TTL), + }; + + if (mask && (mask->ipv4_proto || mask->ipv4_tos || + mask->ipv4_frag)) { + VLOG_DBG_RL(&error_rl, "Unsupported IPv4 set action"); + return -1; + } + if (add_set_flow_action(actions, sa_info_arr, ARRAY_SIZE(sa_info_arr))) { return -1; From patchwork Sun Dec 8 13:23:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Britstein X-Patchwork-Id: 1205662 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 47W6Ty1kMvz9sPK for ; Mon, 9 Dec 2019 00:23:50 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 2D082204A0; Sun, 8 Dec 2019 13:23:48 +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 lXXUzH37Lttk; Sun, 8 Dec 2019 13:23:41 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by silver.osuosl.org (Postfix) with ESMTP id 030612049C; Sun, 8 Dec 2019 13:23:33 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id DE4C2C1D88; Sun, 8 Dec 2019 13:23:32 +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 C5D0DC1D7F for ; Sun, 8 Dec 2019 13:23:28 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id A33B987E62 for ; Sun, 8 Dec 2019 13:23:28 +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 8blBPrv-BOkh for ; Sun, 8 Dec 2019 13:23:28 +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 4064E87E6D for ; Sun, 8 Dec 2019 13:23:26 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE1 (envelope-from elibr@mellanox.com) with ESMTPS (AES256-SHA encrypted); 8 Dec 2019 15:23:21 +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 xB8DNJhC002052; Sun, 8 Dec 2019 15:23:21 +0200 From: Eli Britstein To: dev@openvswitch.org, Ilya Maximets , Sriharsha Basavapatna Date: Sun, 8 Dec 2019 13:23:03 +0000 Message-Id: <20191208132304.15521-19-elibr@mellanox.com> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20191208132304.15521-1-elibr@mellanox.com> References: <20191208132304.15521-1-elibr@mellanox.com> Cc: Oz Shlomo , Majd Dibbiny , Eli Britstein , Ameer Mahagneh Subject: [ovs-dev] [PATCH V3 18/19] netdev-offload-dpdk: Support offload of clone tnl_push/output actions 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" Signed-off-by: Eli Britstein Reviewed-by: Oz Shlomo --- Documentation/howto/dpdk.rst | 2 ++ NEWS | 4 ++-- lib/netdev-dpdk.c | 14 +++++++++++++ lib/netdev-offload-dpdk.c | 48 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 66 insertions(+), 2 deletions(-) diff --git a/Documentation/howto/dpdk.rst b/Documentation/howto/dpdk.rst index b9be83002..b9aaf26bf 100644 --- a/Documentation/howto/dpdk.rst +++ b/Documentation/howto/dpdk.rst @@ -394,6 +394,8 @@ Supported actions for hardware offload are: - Drop. - Modification of Ethernet (mod_dl_src/mod_dl_dst). - Modification of IPv4 (mod_nw_src/mod_nw_dst/mod_nw_ttl). +- Clone with tnl_push and output (a single clone, as the last action, + with a single output, as the last nested clone action). Further Reading --------------- diff --git a/NEWS b/NEWS index 297ca6fff..25125801b 100644 --- a/NEWS +++ b/NEWS @@ -26,8 +26,8 @@ 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, drop and set actions of - MAC and IPv4 (experimental). + * Add hardware offload support for output, drop, set of MAC, IPv4 + and tunnel push-output actions (experimental). v2.12.0 - 03 Sep 2019 --------------------- diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index c4606363d..14f5d6f3b 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -4762,6 +4762,20 @@ ds_put_flow_action(struct ds *s, const struct rte_flow_action *actions) } else { ds_put_cstr(s, " Set-ttl = null\n"); } + } else if (actions->type == RTE_FLOW_ACTION_TYPE_RAW_ENCAP) { + const struct rte_flow_action_raw_encap *raw_encap = actions->conf; + + ds_put_cstr(s, "rte flow raw-encap action:\n"); + if (raw_encap) { + ds_put_format(s, + " Raw-encap: size=%ld\n", + raw_encap->size); + ds_put_format(s, + " Raw-encap: encap=\n"); + ds_put_hex_dump(s, raw_encap->data, raw_encap->size, 0, false); + } else { + ds_put_cstr(s, " Raw-encap = null\n"); + } } else { ds_put_format(s, "unknown rte flow action (%d)\n", actions->type); } diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c index 3fccac956..b0403a085 100644 --- a/lib/netdev-offload-dpdk.c +++ b/lib/netdev-offload-dpdk.c @@ -634,6 +634,45 @@ parse_set_actions(struct flow_actions *actions, return 0; } +static int +parse_clone_actions(struct netdev *netdev, + struct flow_actions *actions, + const struct nlattr *clone_actions, + const size_t clone_actions_len, + struct offload_info *info) +{ + const struct nlattr *ca; + unsigned int cleft; + + NL_ATTR_FOR_EACH_UNSAFE (ca, cleft, clone_actions, clone_actions_len) { + int clone_type = nl_attr_type(ca); + + if (clone_type == OVS_ACTION_ATTR_TUNNEL_PUSH) { + const struct ovs_action_push_tnl *tnl_push = nl_attr_get(ca); + struct rte_flow_action_raw_encap *raw_encap = + xzalloc(sizeof *raw_encap); + + raw_encap->data = (uint8_t *)tnl_push->header; + raw_encap->preserve = NULL; + raw_encap->size = tnl_push->header_len; + + add_flow_action(actions, RTE_FLOW_ACTION_TYPE_RAW_ENCAP, + raw_encap); + } else if (clone_type == OVS_ACTION_ATTR_OUTPUT) { + if (!(cleft <= NLA_ALIGN(ca->nla_len)) || + add_output_action(netdev, actions, ca, info)) { + return -1; + } + } else { + VLOG_DBG_RL(&error_rl, + "Unsupported clone action. clone_type=%d", clone_type); + return -1; + } + } + + return 0; +} + static int parse_flow_actions(struct netdev *netdev, struct flow_actions *actions, @@ -661,6 +700,15 @@ parse_flow_actions(struct netdev *netdev, masked)) { return -1; } + } else if (nl_attr_type(nla) == OVS_ACTION_ATTR_CLONE) { + const struct nlattr *clone_actions = nl_attr_get(nla); + size_t clone_actions_len = nl_attr_get_size(nla); + + if (!(left <= NLA_ALIGN(nla->nla_len)) || + parse_clone_actions(netdev, actions, clone_actions, + clone_actions_len, info)) { + return -1; + } } else { VLOG_DBG_RL(&error_rl, "Unsupported action type %d", nl_attr_type(nla)); From patchwork Sun Dec 8 13:23:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Britstein X-Patchwork-Id: 1205671 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.138; helo=whitealder.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 whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47W6Vl1QfKz9sP6 for ; Mon, 9 Dec 2019 00:24:31 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 966FD88134; Sun, 8 Dec 2019 13:24:29 +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 KWP2RVzjMMlw; Sun, 8 Dec 2019 13:24:23 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by whitealder.osuosl.org (Postfix) with ESMTP id C77528764B; Sun, 8 Dec 2019 13:23:41 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id A2AE0C1D83; Sun, 8 Dec 2019 13:23:41 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 97F8BC1D83 for ; Sun, 8 Dec 2019 13:23:36 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 86FF0203FE for ; Sun, 8 Dec 2019 13:23:36 +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 Fr3xPvtKbxLt for ; Sun, 8 Dec 2019 13:23:35 +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 silver.osuosl.org (Postfix) with ESMTP id 230DC20444 for ; Sun, 8 Dec 2019 13:23:26 +0000 (UTC) Received: from Internal Mail-Server by MTLPINE1 (envelope-from elibr@mellanox.com) with ESMTPS (AES256-SHA encrypted); 8 Dec 2019 15:23:21 +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 xB8DNJhD002052; Sun, 8 Dec 2019 15:23:21 +0200 From: Eli Britstein To: dev@openvswitch.org, Ilya Maximets , Sriharsha Basavapatna Date: Sun, 8 Dec 2019 13:23:04 +0000 Message-Id: <20191208132304.15521-20-elibr@mellanox.com> X-Mailer: git-send-email 2.14.5 In-Reply-To: <20191208132304.15521-1-elibr@mellanox.com> References: <20191208132304.15521-1-elibr@mellanox.com> Cc: Oz Shlomo , Majd Dibbiny , Eli Britstein , Ameer Mahagneh Subject: [ovs-dev] [PATCH V3 19/19] netdev-offload-dpdk: Support offload of set TCP/UDP ports actions 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" Signed-off-by: Eli Britstein Reviewed-by: Oz Shlomo --- Documentation/howto/dpdk.rst | 1 + NEWS | 4 ++-- lib/netdev-dpdk.c | 14 ++++++++++++++ lib/netdev-offload-dpdk.c | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 2 deletions(-) diff --git a/Documentation/howto/dpdk.rst b/Documentation/howto/dpdk.rst index b9aaf26bf..df863e4f1 100644 --- a/Documentation/howto/dpdk.rst +++ b/Documentation/howto/dpdk.rst @@ -396,6 +396,7 @@ Supported actions for hardware offload are: - Modification of IPv4 (mod_nw_src/mod_nw_dst/mod_nw_ttl). - Clone with tnl_push and output (a single clone, as the last action, with a single output, as the last nested clone action). +- Modification of TCP/UDP (mod_tp_src/mod_tp_dst). Further Reading --------------- diff --git a/NEWS b/NEWS index 25125801b..d01b8983b 100644 --- a/NEWS +++ b/NEWS @@ -26,8 +26,8 @@ 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, drop, set of MAC, IPv4 - and tunnel push-output actions (experimental). + * Add hardware offload support for output, drop, set of MAC, IPv4, + TCP/UDP ports and tunnel push-output actions (experimental). v2.12.0 - 03 Sep 2019 --------------------- diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index 14f5d6f3b..377e8ae07 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -4776,6 +4776,20 @@ ds_put_flow_action(struct ds *s, const struct rte_flow_action *actions) } else { ds_put_cstr(s, " Raw-encap = null\n"); } + } else if (actions->type == RTE_FLOW_ACTION_TYPE_SET_TP_SRC || + actions->type == RTE_FLOW_ACTION_TYPE_SET_TP_DST) { + const struct rte_flow_action_set_tp *set_tp = actions->conf; + char *dirstr = actions->type == RTE_FLOW_ACTION_TYPE_SET_TP_DST + ? "dst" : "src"; + + ds_put_format(s, "rte flow set-tcp/udp-port-%s action:\n", dirstr); + if (set_tp) { + ds_put_format(s, + " Set-%s-tcp/udp-port: %"PRIu16"\n", + dirstr, ntohs(set_tp->port)); + } else { + ds_put_format(s, " Set-%s-tcp/udp-port = null\n", dirstr); + } } else { ds_put_format(s, "unknown rte flow action (%d)\n", actions->type); } diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c index b0403a085..6a5d00276 100644 --- a/lib/netdev-offload-dpdk.c +++ b/lib/netdev-offload-dpdk.c @@ -620,6 +620,40 @@ parse_set_actions(struct flow_actions *actions, return -1; } + if (add_set_flow_action(actions, sa_info_arr, + ARRAY_SIZE(sa_info_arr))) { + return -1; + } + } else if (nl_attr_type(sa) == OVS_KEY_ATTR_TCP) { + const struct ovs_key_tcp *key = nl_attr_get(sa); + const struct ovs_key_tcp *mask = masked ? + get_mask(sa, struct ovs_key_tcp) : NULL; + struct rte_flow_action_set_tp *src = xzalloc(sizeof *src); + struct rte_flow_action_set_tp *dst = xzalloc(sizeof *dst); + struct set_action_info sa_info_arr[] = { + SA_INFO(tcp_src, src->port, + RTE_FLOW_ACTION_TYPE_SET_TP_SRC), + SA_INFO(tcp_dst, dst->port, + RTE_FLOW_ACTION_TYPE_SET_TP_DST), + }; + + if (add_set_flow_action(actions, sa_info_arr, + ARRAY_SIZE(sa_info_arr))) { + return -1; + } + } else if (nl_attr_type(sa) == OVS_KEY_ATTR_UDP) { + const struct ovs_key_udp *key = nl_attr_get(sa); + const struct ovs_key_udp *mask = masked ? + get_mask(sa, struct ovs_key_udp) : NULL; + struct rte_flow_action_set_tp *src = xzalloc(sizeof *src); + struct rte_flow_action_set_tp *dst = xzalloc(sizeof *dst); + struct set_action_info sa_info_arr[] = { + SA_INFO(udp_src, src->port, + RTE_FLOW_ACTION_TYPE_SET_TP_SRC), + SA_INFO(udp_dst, dst->port, + RTE_FLOW_ACTION_TYPE_SET_TP_DST), + }; + if (add_set_flow_action(actions, sa_info_arr, ARRAY_SIZE(sa_info_arr))) { return -1;