From patchwork Tue Sep 5 09:22:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuanhan Liu X-Patchwork-Id: 810033 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=fridaylinux-org.20150623.gappssmtp.com header.i=@fridaylinux-org.20150623.gappssmtp.com header.b="E5X0YseA"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xmh9t532Hz9sNr for ; Tue, 5 Sep 2017 19:24:18 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 3A4E0AB6; Tue, 5 Sep 2017 09:23:43 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id D1A97AA5 for ; Tue, 5 Sep 2017 09:23:41 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pf0-f176.google.com (mail-pf0-f176.google.com [209.85.192.176]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 329F2E0 for ; Tue, 5 Sep 2017 09:23:41 +0000 (UTC) Received: by mail-pf0-f176.google.com with SMTP id e199so6619509pfh.3 for ; Tue, 05 Sep 2017 02:23:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fridaylinux-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=aUB2EbF2hZsRT67zmjtuXErHqmQ9VuxCjQCjJdy+nic=; b=E5X0YseAo1Ags7fQ65OOxcAPwYdnDMpg7Iq6KMbk+xiaOHTPfFQd3dPBhEGMqvJXR/ ODy0tkkjuoe4CLLAcgzMDf9lIKNCO8ZmJlDUNi1hx6MSL7EXldYk36kMpSnXhMs5MR2Q +BmzuY7bdOo/TIYwFeW4Wq6cGA52S6G487UISQ0XVUXa/oRIu8y3xXo9mO6urPD4K9yZ 3PtzuM8EYMTNVmjWZEU9iNw7aTGz13oCa8F7ovZzgbttTchheSQl1qJNJswWYPRhkh7H /Wk91aqlIdg9y0PkHCWe1i91SQOgfT78tgXmtpza76PJltpqaTpsMxCqS6GuT9m1iQlu WcXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=aUB2EbF2hZsRT67zmjtuXErHqmQ9VuxCjQCjJdy+nic=; b=tiSCE5aiqdSwpc8HM7Wn3QHm9EVsEhjSNisEH69oxsAjGCFj78Kk80jbMzM3ELTk4R 9RHVwgHjMveG07WvMsoPleD97/J+PsgAclYpKpXUFIxxntCqw8CzcyRMc6AJDaIBqTDs X++Rg5F0lI9hKJopRxGyuAszatxOy9E+WPj9StratmzE7JfNiA7C10C2Ftay6u1POfhL 0E/K4l01B5nsimMje77eykPRt4VqE4RBJAQsYOloXfYBIE3UYv/kjXTv5Ybs/QmGKEey cF/vhUBF8kJjvkRvLfUBDD1UOa7wPGOfQYqhrBWGVE5j/l53SLBtr6r3GzOHCK7GXDL8 zI0w== X-Gm-Message-State: AHPjjUjUsmAj4K2nC0BlslI+3gw+chcVWjsMBJTN8ozvGaJjZatcuRTX IqTx2y0zjbqcDvMNXohCjg== X-Google-Smtp-Source: ADKCNb6z1o0axcTKttq6u32DubIP1TTcweNlCtPUdh59Z+XDlo7rPDJHssO3o1ZEqHtXfWkydFM3kQ== X-Received: by 10.98.155.139 with SMTP id e11mr3165927pfk.290.1504603420327; Tue, 05 Sep 2017 02:23:40 -0700 (PDT) Received: from localhost.localdomain ([101.228.204.163]) by smtp.gmail.com with ESMTPSA id i187sm295921pfe.71.2017.09.05.02.23.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 05 Sep 2017 02:23:38 -0700 (PDT) From: Yuanhan Liu To: dev@openvswitch.org Date: Tue, 5 Sep 2017 17:22:54 +0800 Message-Id: <1504603381-30071-2-git-send-email-yliu@fridaylinux.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504603381-30071-1-git-send-email-yliu@fridaylinux.org> References: <1504603381-30071-1-git-send-email-yliu@fridaylinux.org> X-Spam-Status: No, score=0.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, RCVD_IN_DNSWL_NONE autolearn=disabled version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v2 1/8] dpif-netdev: associate flow with a mark id X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org This patch associate a flow with a mark id (a uint32_t number) by CMAP. It re-uses the flow API (more precisely, the ->flow_put method) to setup the hw flow. The flow_put implementation then is supposed to create a flow with MARK action. Co-authored-by: Finn Christensen Signed-off-by: Yuanhan Liu Signed-off-by: Finn Christensen --- lib/dpif-netdev.c | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/netdev.h | 6 ++++ 2 files changed, 91 insertions(+) diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 071ec14..f3b7f25 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -446,6 +446,12 @@ struct dp_netdev_flow { const unsigned pmd_id; /* The 'core_id' of pmd thread owning this */ /* flow. */ + const struct cmap_node mark_node; /* In owning dp_netdev_pmd_thread's */ + /* 'mark_to_flow' */ + bool has_mark; /* A flag to tell whether this flow has a + valid mark asscoiated with it. */ + uint32_t mark; /* Unique flow mark assiged to a flow */ + /* Number of references. * The classifier owns one reference. * Any thread trying to keep a rule from being freed should hold its own @@ -569,6 +575,8 @@ struct dp_netdev_pmd_thread { struct ovs_mutex flow_mutex; struct cmap flow_table OVS_GUARDED; /* Flow table. */ + struct cmap mark_to_flow; + /* One classifier per in_port polled by the pmd */ struct cmap classifiers; /* Periodically sort subtable vectors according to hit frequencies */ @@ -1839,6 +1847,8 @@ dp_netdev_pmd_remove_flow(struct dp_netdev_pmd_thread *pmd, OVS_REQUIRES(pmd->flow_mutex) { struct cmap_node *node = CONST_CAST(struct cmap_node *, &flow->node); + struct cmap_node *mark_node = CONST_CAST(struct cmap_node *, + &flow->mark_node); struct dpcls *cls; odp_port_t in_port = flow->flow.in_port.odp_port; @@ -1846,6 +1856,10 @@ dp_netdev_pmd_remove_flow(struct dp_netdev_pmd_thread *pmd, ovs_assert(cls != NULL); dpcls_remove(cls, &flow->cr); cmap_remove(&pmd->flow_table, node, dp_netdev_flow_hash(&flow->ufid)); + if (flow->has_mark) { + cmap_remove(&pmd->mark_to_flow, mark_node, flow->mark); + flow->has_mark = false; + } flow->dead = true; dp_netdev_flow_unref(flow); @@ -2235,6 +2249,38 @@ dp_netdev_pmd_find_flow(const struct dp_netdev_pmd_thread *pmd, return NULL; } +static struct dp_netdev_flow * +dp_netdev_pmd_find_flow_by_mark(const struct dp_netdev_pmd_thread *pmd, + const uint32_t mark) +{ + struct dp_netdev_flow *netdev_flow; + + CMAP_FOR_EACH_WITH_HASH (netdev_flow, mark_node, mark, + &pmd->mark_to_flow) { + if (netdev_flow->has_mark && netdev_flow->mark == mark) { + return netdev_flow; + } + } + + return NULL; +} + +static bool +dp_netdev_alloc_flow_mark(const struct dp_netdev_pmd_thread *pmd, + uint32_t *mark) +{ + uint32_t i; + + for (i = 0; i < UINT32_MAX; i++) { + if (!dp_netdev_pmd_find_flow_by_mark(pmd, i)) { + *mark = i; + return true; + } + } + + return false; +} + static void get_dpif_flow_stats(const struct dp_netdev_flow *netdev_flow_, struct dpif_flow_stats *stats) @@ -2434,6 +2480,7 @@ dp_netdev_flow_add(struct dp_netdev_pmd_thread *pmd, struct dp_netdev_flow *flow; struct netdev_flow_key mask; struct dpcls *cls; + struct offload_info info; /* Make sure in_port is exact matched before we read it. */ ovs_assert(match->wc.masks.in_port.odp_port == ODPP_NONE); @@ -2460,6 +2507,7 @@ dp_netdev_flow_add(struct dp_netdev_pmd_thread *pmd, memset(&flow->stats, 0, sizeof flow->stats); flow->dead = false; flow->batch = NULL; + flow->has_mark = 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; @@ -2475,6 +2523,22 @@ dp_netdev_flow_add(struct dp_netdev_pmd_thread *pmd, cmap_insert(&pmd->flow_table, CONST_CAST(struct cmap_node *, &flow->node), dp_netdev_flow_hash(&flow->ufid)); + if (netdev_is_flow_api_enabled() && + dp_netdev_alloc_flow_mark(pmd, &info.flow_mark)) { + struct dp_netdev_port *port; + port = dp_netdev_lookup_port(pmd->dp, in_port); + if (netdev_flow_put(port->netdev, match, + CONST_CAST(struct nlattr *, actions), + actions_len, ufid, &info, NULL) == 0) { + flow->has_mark = true; + flow->mark = info.flow_mark; + cmap_insert(&pmd->mark_to_flow, + CONST_CAST(struct cmap_node *, &flow->mark_node), + info.flow_mark); + VLOG_INFO("installed flow %p with mark %u\n", flow, flow->mark); + } + } + if (OVS_UNLIKELY(!VLOG_DROP_DBG((&upcall_rl)))) { struct ds ds = DS_EMPTY_INITIALIZER; struct ofpbuf key_buf, mask_buf; @@ -2562,6 +2626,25 @@ flow_put_on_pmd(struct dp_netdev_pmd_thread *pmd, old_actions = dp_netdev_flow_get_actions(netdev_flow); ovsrcu_set(&netdev_flow->actions, new_actions); + if (netdev_flow->has_mark) { + struct offload_info info; + struct dp_netdev_port *port; + odp_port_t in_port; + int ret; + + in_port = netdev_flow->flow.in_port.odp_port; + port = dp_netdev_lookup_port(pmd->dp, in_port); + info.flow_mark = netdev_flow->mark; + ret = netdev_flow_put(port->netdev, match, + CONST_CAST(struct nlattr *, + put->actions), + put->actions_len, ufid, &info, stats); + + VLOG_INFO("%s to modify flow %p associated with mark %u\n", + ret == 0 ? "succeed" : "failed", + netdev_flow, netdev_flow->mark); + } + if (stats) { get_dpif_flow_stats(netdev_flow, stats); } @@ -4504,6 +4587,7 @@ dp_netdev_configure_pmd(struct dp_netdev_pmd_thread *pmd, struct dp_netdev *dp, ovs_mutex_init(&pmd->flow_mutex); ovs_mutex_init(&pmd->port_mutex); cmap_init(&pmd->flow_table); + cmap_init(&pmd->mark_to_flow); cmap_init(&pmd->classifiers); pmd->next_optimization = time_msec() + DPCLS_OPTIMIZATION_INTERVAL; pmd->rxq_interval = time_msec() + PMD_RXQ_INTERVAL_LEN; @@ -4538,6 +4622,7 @@ dp_netdev_destroy_pmd(struct dp_netdev_pmd_thread *pmd) } cmap_destroy(&pmd->classifiers); cmap_destroy(&pmd->flow_table); + cmap_destroy(&pmd->mark_to_flow); ovs_mutex_destroy(&pmd->flow_mutex); latch_destroy(&pmd->exit_latch); seq_destroy(pmd->reload_seq); diff --git a/lib/netdev.h b/lib/netdev.h index f8482f7..2003165 100644 --- a/lib/netdev.h +++ b/lib/netdev.h @@ -188,6 +188,12 @@ void netdev_send_wait(struct netdev *, int qid); struct offload_info { const struct dpif_class *dpif_class; ovs_be16 tp_dst_port; /* Destination port for tunnel in SET action */ + + /* + * The flow mark id assigened to the flow. If any pkts hit the flow, + * it will be in the pkt meta data. + */ + uint32_t flow_mark; }; struct dpif_class; struct netdev_flow_dump; From patchwork Tue Sep 5 09:22:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuanhan Liu X-Patchwork-Id: 810034 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=fridaylinux-org.20150623.gappssmtp.com header.i=@fridaylinux-org.20150623.gappssmtp.com header.b="t9SegZcW"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xmhBf15BBz9sNr for ; Tue, 5 Sep 2017 19:24:58 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 09043AC8; Tue, 5 Sep 2017 09:23:46 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 4E621AB5 for ; Tue, 5 Sep 2017 09:23:44 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg0-f48.google.com (mail-pg0-f48.google.com [74.125.83.48]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id CEA70E0 for ; Tue, 5 Sep 2017 09:23:43 +0000 (UTC) Received: by mail-pg0-f48.google.com with SMTP id j6so8140037pgc.1 for ; Tue, 05 Sep 2017 02:23:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fridaylinux-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1WU4S/nyLHgSpGcL0B15Gv75DPeVW0vNfKvnRxGmUNg=; b=t9SegZcW/O7+66IfZC7eky+dXTeIJz+gqEd1eDO4vC8dxT7Iw2sj2tQhPkxYFZEDyK xVrm4ohyBYcoHR+ozBqOgu6xBdbgjxFczOQnYfnTejGhK7e1JBLDmX7rVRAfyu7Dhy6y 1XOygLgEH01BnUQzv/HRgbfq11BdzXIQUJegRghPSXGkCwt4hw+3r+PfAXwBK9sInxP4 nJEPoIp0SVmtaqAvSqYkOwYQTY8dGWRS5ntgBShGQZ3pA1ZeB4bcmKgXjV/iGRUEvSXU KFnZlm1nn8ZS8MTUVO53uklsAMXDP+ZAipBWkE0oeh9s+qOMyljfB3TaqwViRgqrzs7Y bD/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=1WU4S/nyLHgSpGcL0B15Gv75DPeVW0vNfKvnRxGmUNg=; b=AMo5g26dWbWzfklleDiVaS36bYfLwK9H8nBFh5KhXPm7vN/3LfA5b/PzzpmmC9BiXN L9HKDyy/EpNPxuBpgozbxmqLtYTTkeSDu36924NTcJbUVXcBZ3gsH7K8RXNF/MaLhGEw FzaGtkxfvW0Jr303ihZr7I1xevZ9gIxXuwX4Gx/W8Tlt9q2Za7kR3Nx2MZQmXu9/Q9kT Ge+NyZyyzn2wqNe3LY+sIAgP41KTYssvgMD2k1EqwoWTmV+2G/NgygZpq7ksc3hbHh1V cMbfkj7mfS2Xx5p2zG/b8gu+Pk8AKuO2dwRNpKKt6XzBC5+FPg3nG5dDBs0hNkFuzDyw +kOQ== X-Gm-Message-State: AHPjjUjYEcDkwxfdVnDDE0PvEZZ2TdM52U74oht4C2G3N+PHdwPqnP8G vCqBc5GONOHYTgTorJhpgA== X-Google-Smtp-Source: ADKCNb5daE5EiuPtA1nrXg3kd8r9Wvvr4tkC7szAGHSgUErHhB9XUrWBiYKpTiZiFSunQQq4oxxjCw== X-Received: by 10.98.245.8 with SMTP id n8mr3118036pfh.108.1504603422933; Tue, 05 Sep 2017 02:23:42 -0700 (PDT) Received: from localhost.localdomain ([101.228.204.163]) by smtp.gmail.com with ESMTPSA id i187sm295921pfe.71.2017.09.05.02.23.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 05 Sep 2017 02:23:41 -0700 (PDT) From: Yuanhan Liu To: dev@openvswitch.org Date: Tue, 5 Sep 2017 17:22:55 +0800 Message-Id: <1504603381-30071-3-git-send-email-yliu@fridaylinux.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504603381-30071-1-git-send-email-yliu@fridaylinux.org> References: <1504603381-30071-1-git-send-email-yliu@fridaylinux.org> X-Spam-Status: No, score=0.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, RCVD_IN_DNSWL_NONE autolearn=disabled version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v2 2/8] dpif-netdev: retrieve flow directly from the flow mark X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org So that we could skip the heavy emc processing, notably, the miniflow_extract function. A simple PHY-PHY forwarding testing shows 53% performance improvement. Note that though the heavy miniflow_extract is skipped, we still have to do per packet checking, due to we have to check the tcp_flags. Co-authored-by: Finn Christensen Signed-off-by: Yuanhan Liu Signed-off-by: Finn Christensen --- v2: update tcp_flags, which also fixes the build warnings --- lib/dp-packet.h | 13 ++++++++++ lib/dpif-netdev.c | 27 ++++++++++++++----- lib/flow.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/flow.h | 1 + 4 files changed, 113 insertions(+), 6 deletions(-) diff --git a/lib/dp-packet.h b/lib/dp-packet.h index 046f3ab..a7a062f 100644 --- a/lib/dp-packet.h +++ b/lib/dp-packet.h @@ -691,6 +691,19 @@ reset_dp_packet_checksum_ol_flags(struct dp_packet *p) #define reset_dp_packet_checksum_ol_flags(arg) #endif +static inline bool +dp_packet_has_flow_mark(struct dp_packet *p OVS_UNUSED, + uint32_t *mark OVS_UNUSED) +{ +#ifdef DPDK_NETDEV + if (p->mbuf.ol_flags & PKT_RX_FDIR_ID) { + *mark = p->mbuf.hash.fdir.hi; + return true; + } +#endif + return false; +} + enum { NETDEV_MAX_BURST = 32 }; /* Maximum number packets in a batch. */ struct dp_packet_batch { diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index f3b7f25..a95b8d4 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -4883,10 +4883,10 @@ struct packet_batch_per_flow { static inline void packet_batch_per_flow_update(struct packet_batch_per_flow *batch, struct dp_packet *packet, - const struct miniflow *mf) + uint16_t tcp_flags) { batch->byte_count += dp_packet_size(packet); - batch->tcp_flags |= miniflow_get_tcp_flags(mf); + batch->tcp_flags |= tcp_flags; batch->array.packets[batch->array.count++] = packet; } @@ -4921,7 +4921,7 @@ packet_batch_per_flow_execute(struct packet_batch_per_flow *batch, static inline void dp_netdev_queue_batches(struct dp_packet *pkt, - struct dp_netdev_flow *flow, const struct miniflow *mf, + struct dp_netdev_flow *flow, uint16_t tcp_flags, struct packet_batch_per_flow *batches, size_t *n_batches) { @@ -4932,7 +4932,7 @@ dp_netdev_queue_batches(struct dp_packet *pkt, packet_batch_per_flow_init(batch, flow); } - packet_batch_per_flow_update(batch, pkt, mf); + packet_batch_per_flow_update(batch, pkt, tcp_flags); } /* Try to process all ('cnt') the 'packets' using only the exact match cache @@ -4960,11 +4960,13 @@ emc_processing(struct dp_netdev_pmd_thread *pmd, const size_t size = dp_packet_batch_size(packets_); uint32_t cur_min; int i; + uint16_t tcp_flags; atomic_read_relaxed(&pmd->dp->emc_insert_min, &cur_min); DP_PACKET_BATCH_REFILL_FOR_EACH (i, size, packet, packets_) { struct dp_netdev_flow *flow; + uint32_t flow_mark; if (OVS_UNLIKELY(dp_packet_size(packet) < ETH_HEADER_LEN)) { dp_packet_delete(packet); @@ -4972,6 +4974,16 @@ emc_processing(struct dp_netdev_pmd_thread *pmd, continue; } + if (dp_packet_has_flow_mark(packet, &flow_mark)) { + flow = dp_netdev_pmd_find_flow_by_mark(pmd, flow_mark); + if (flow) { + tcp_flags = parse_tcp_flags(packet); + dp_netdev_queue_batches(packet, flow, tcp_flags, batches, + n_batches); + continue; + } + } + if (i != size - 1) { struct dp_packet **packets = packets_->packets; /* Prefetch next packet data and metadata. */ @@ -4989,7 +5001,8 @@ emc_processing(struct dp_netdev_pmd_thread *pmd, /* If EMC is disabled skip emc_lookup */ flow = (cur_min == 0) ? NULL: emc_lookup(flow_cache, key); if (OVS_LIKELY(flow)) { - dp_netdev_queue_batches(packet, flow, &key->mf, batches, + tcp_flags = miniflow_get_tcp_flags(&key->mf); + dp_netdev_queue_batches(packet, flow, tcp_flags, batches, n_batches); } else { /* Exact match cache missed. Group missed packets together at @@ -5166,7 +5179,9 @@ fast_path_processing(struct dp_netdev_pmd_thread *pmd, flow = dp_netdev_flow_cast(rules[i]); emc_probabilistic_insert(pmd, &keys[i], flow); - dp_netdev_queue_batches(packet, flow, &keys[i].mf, batches, n_batches); + dp_netdev_queue_batches(packet, flow, + miniflow_get_tcp_flags(&keys[i].mf), + batches, n_batches); } dp_netdev_count_packet(pmd, DP_STAT_MASKED_HIT, cnt - miss_cnt); diff --git a/lib/flow.c b/lib/flow.c index b2b10aa..912c538 100644 --- a/lib/flow.c +++ b/lib/flow.c @@ -991,6 +991,84 @@ parse_dl_type(const struct eth_header *data_, size_t size) return parse_ethertype(&data, &size); } +uint16_t +parse_tcp_flags(struct dp_packet *packet) +{ + const void *data = dp_packet_data(packet); + size_t size = dp_packet_size(packet); + ovs_be16 dl_type; + uint8_t nw_frag = 0, nw_proto = 0; + + if (packet->packet_type != htonl(PT_ETH)) { + return 0; + } + + data_pull(&data, &size, ETH_ADDR_LEN * 2); + dl_type = parse_ethertype(&data, &size); + if (OVS_LIKELY(dl_type == htons(ETH_TYPE_IP))) { + const struct ip_header *nh = data; + int ip_len; + + if (OVS_UNLIKELY(size < IP_HEADER_LEN)) { + return 0; + } + ip_len = IP_IHL(nh->ip_ihl_ver) * 4; + + if (OVS_UNLIKELY(ip_len < IP_HEADER_LEN)) { + return 0; + } + if (OVS_UNLIKELY(size < ip_len)) { + return 0; + } + + if (OVS_UNLIKELY(IP_IS_FRAGMENT(nh->ip_frag_off))) { + nw_frag = FLOW_NW_FRAG_ANY; + if (nh->ip_frag_off & htons(IP_FRAG_OFF_MASK)) { + nw_frag |= FLOW_NW_FRAG_LATER; + } + } + nw_proto = nh->ip_proto; + data_pull(&data, &size, ip_len); + } else if (dl_type == htons(ETH_TYPE_IPV6)) { + const struct ovs_16aligned_ip6_hdr *nh; + uint16_t plen; + + if (OVS_UNLIKELY(size < sizeof *nh)) { + return 0; + } + nh = data_pull(&data, &size, sizeof *nh); + + plen = ntohs(nh->ip6_plen); + if (OVS_UNLIKELY(plen > size)) { + return 0; + } + /* Jumbo Payload option not supported yet. */ + if (OVS_UNLIKELY(size - plen > UINT8_MAX)) { + return 0; + } + size = plen; + + nw_proto = nh->ip6_nxt; + if (!parse_ipv6_ext_hdrs__(&data, &size, &nw_proto, &nw_frag)) { + return 0; + } + } else { + return 0; + } + + if (OVS_LIKELY(!(nw_frag & FLOW_NW_FRAG_LATER))) { + if (OVS_LIKELY(nw_proto == IPPROTO_TCP)) { + if (OVS_LIKELY(size >= TCP_HEADER_LEN)) { + const struct tcp_header *tcp = data; + + return TCP_FLAGS_BE32(tcp->tcp_ctl); + } + } + } + + return 0; +} + /* For every bit of a field that is wildcarded in 'wildcards', sets the * corresponding bit in 'flow' to zero. */ void diff --git a/lib/flow.h b/lib/flow.h index 6ae5a67..f113ec4 100644 --- a/lib/flow.h +++ b/lib/flow.h @@ -130,6 +130,7 @@ bool parse_ipv6_ext_hdrs(const void **datap, size_t *sizep, uint8_t *nw_proto, uint8_t *nw_frag); ovs_be16 parse_dl_type(const struct eth_header *data_, size_t size); bool parse_nsh(const void **datap, size_t *sizep, struct flow_nsh *key); +uint16_t parse_tcp_flags(struct dp_packet *packet); static inline uint64_t flow_get_xreg(const struct flow *flow, int idx) From patchwork Tue Sep 5 09:22:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuanhan Liu X-Patchwork-Id: 810037 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=fridaylinux-org.20150623.gappssmtp.com header.i=@fridaylinux-org.20150623.gappssmtp.com header.b="jw1V5Bx8"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xmhCg21ZGz9sNr for ; Tue, 5 Sep 2017 19:25:51 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 2D46AAD6; Tue, 5 Sep 2017 09:23:48 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id D2796AC9 for ; Tue, 5 Sep 2017 09:23:46 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pf0-f170.google.com (mail-pf0-f170.google.com [209.85.192.170]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 6A3CCE5 for ; Tue, 5 Sep 2017 09:23:46 +0000 (UTC) Received: by mail-pf0-f170.google.com with SMTP id e199so6619909pfh.3 for ; Tue, 05 Sep 2017 02:23:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fridaylinux-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=O15ElIDGRdMP3J8fgSurvRNqIKAoMegPs4RnC05hYnc=; b=jw1V5Bx8vzrAED7nFNomDv2IhH2Tsa+3IaWFkz3W/zM5qcHa+jhMcWtysvuvAeY1Fi pmWzk5AFbMxpL+/kw7p2Jm+Pi+5fUMmiBgmoXMDpiZUsGweP1gjM47rF1QMThAUKtkIm MOf/BOsUVJLHIP9Nr3EUhcHvt66faFsnjX/oKRuXvNMraocSwp429EJuUlcL1INWHsEU om+nMr6G+Aia6IB5W/qPvSGXrXrV6UEW4i5i9RyIn9TH1WeoZSj6jkzFaIdlnChlipBx sMiyCNGtT4LfXz4FTdwZT/uBIGgpM9YKmpxhzuqommjzs3ZpFDLWS36uxi+maj3qbP5B 8Qhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=O15ElIDGRdMP3J8fgSurvRNqIKAoMegPs4RnC05hYnc=; b=EBi0IbilMwenI3txcDks5UwE6OHehljMd2TJz8TtB1t/c/bF82eDNzGZhDlhbip7dV GaIl6uJkIq9E7Z6XMLLZ+CpF7GEdbmJpKtGYWzN4ITrvUQ+WetYkU4dWqkvsg8RD/5jM HFReLiKon4Nvd02JXFBOsucIhPb7QYSjAXtCf1syxbnYVODVlKh2TEmqgvuUeyJ0UdYW TlFtzkfi46ZhqwERZhgFUke2E/nCfvYrBv9RXdePsl4uJUzKCN/z1xMFzpRghGquRRNc HNTJGriJuraoOF6s6X+AN/E2Ofda4JMZUcEUDfsuxEr+5sD2v+1mhsktJI4sBW/lkwMp H8xg== X-Gm-Message-State: AHPjjUiDuGMg8DWQ9aT9IerSjJFsELVLD4NZJ1Vl3MCyhs9KCcARG1WN pE6Otb9unwE5BK7vVQZ0XQ== X-Google-Smtp-Source: ADKCNb7Tiey8sLjv1vAAfKV/105dTBPqLSyJLr5pA22xjBXZk3wJICsZJQkcK+sxtHp30+Tbp+tZSw== X-Received: by 10.98.141.77 with SMTP id z74mr3068746pfd.179.1504603425647; Tue, 05 Sep 2017 02:23:45 -0700 (PDT) Received: from localhost.localdomain ([101.228.204.163]) by smtp.gmail.com with ESMTPSA id i187sm295921pfe.71.2017.09.05.02.23.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 05 Sep 2017 02:23:44 -0700 (PDT) From: Yuanhan Liu To: dev@openvswitch.org Date: Tue, 5 Sep 2017 17:22:56 +0800 Message-Id: <1504603381-30071-4-git-send-email-yliu@fridaylinux.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504603381-30071-1-git-send-email-yliu@fridaylinux.org> References: <1504603381-30071-1-git-send-email-yliu@fridaylinux.org> X-Spam-Status: No, score=0.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, RCVD_IN_DNSWL_NONE autolearn=disabled version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v2 3/8] netdev-dpdk: convert ufid to dpdk flow X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Flows offloaded to DPDK are identified by rte_flow pointer while OVS flows are identified by ufid. This patches adds a hmap to convert ufid to dpdk flow (rte_flow). Most of the code are stolen from netdev-tc-offloads.c, with some modificatons. Some functions are marked as "inline", which is a trick to workaround the temp "functiond defined but not used" warnings. Co-authored-by: Finn Christensen Signed-off-by: Yuanhan Liu Signed-off-by: Finn Christensen --- lib/netdev-dpdk.c | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index f58e9be..46f9885 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -36,6 +36,7 @@ #include #include #include +#include #include "dirs.h" #include "dp-packet.h" @@ -3312,6 +3313,93 @@ unlock: return err; } +/* + * A mapping from ufid to dpdk rte_flow pointer + */ + +static struct hmap ufid_dpdk_flow = HMAP_INITIALIZER(&ufid_dpdk_flow); +static struct ovs_mutex ufid_lock = OVS_MUTEX_INITIALIZER; + +struct ufid_dpdk_flow_data { + struct hmap_node node; + ovs_u128 ufid; + struct rte_flow *rte_flow; +}; + +/* + * Find ufid_dpdk_flow_data node associated with @ufid + */ +static struct ufid_dpdk_flow_data * +find_ufid_dpdk_flow_mapping(const ovs_u128 *ufid) +{ + size_t hash = hash_bytes(ufid, sizeof(*ufid), 0); + struct ufid_dpdk_flow_data *data = NULL; + + ovs_mutex_lock(&ufid_lock); + HMAP_FOR_EACH_WITH_HASH (data, node, hash, &ufid_dpdk_flow) { + if (ovs_u128_equals(*ufid, data->ufid)) { + break; + } + } + ovs_mutex_unlock(&ufid_lock); + + return data; +} + +/* + * Remove ufid_dpdk_flow_data node associated with @ufid + */ +static inline void +del_ufid_dpdk_flow_mapping(const ovs_u128 *ufid) +{ + struct ufid_dpdk_flow_data *data; + + data = find_ufid_dpdk_flow_mapping(ufid); + if (data) { + ovs_mutex_lock(&ufid_lock); + hmap_remove(&ufid_dpdk_flow, &data->node); + free(data); + ovs_mutex_unlock(&ufid_lock); + } +} + +/* Add ufid to dpdk_flow mapping */ +static inline void +add_ufid_dpdk_flow_mapping(const ovs_u128 *ufid, struct rte_flow *rte_flow) +{ + size_t hash = hash_bytes(ufid, sizeof(*ufid), 0); + struct ufid_dpdk_flow_data *data = xzalloc(sizeof(*data)); + + /* + * We should not simply overwrite an existing rte flow. + * We should have deleted it first before re-adding it. + * Thus, if following assert triggers, something is wrong: + * the rte_flow is not destroyed. + */ + ovs_assert(find_ufid_dpdk_flow_mapping(ufid) == NULL); + + data->ufid = *ufid; + data->rte_flow = rte_flow; + + ovs_mutex_lock(&ufid_lock); + hmap_insert(&ufid_dpdk_flow, &data->node, hash); + ovs_mutex_unlock(&ufid_lock); +} + +/* Get rte_flow by ufid. + * + * Returns rte rte_flow if successful. Otherwise returns 0. + */ +static inline struct rte_flow * +get_rte_flow_by_ufid(const ovs_u128 *ufid) +{ + struct ufid_dpdk_flow_data *data; + + data = find_ufid_dpdk_flow_mapping(ufid); + return data ? data->rte_flow : NULL; +} + + #define NETDEV_DPDK_CLASS(NAME, INIT, CONSTRUCT, DESTRUCT, \ SET_CONFIG, SET_TX_MULTIQ, SEND, \ GET_CARRIER, GET_STATS, \ From patchwork Tue Sep 5 09:22:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuanhan Liu X-Patchwork-Id: 810041 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=fridaylinux-org.20150623.gappssmtp.com header.i=@fridaylinux-org.20150623.gappssmtp.com header.b="lvgeUpxb"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xmhDK0K7fz9s0g for ; Tue, 5 Sep 2017 19:26:25 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 0067FAE1; Tue, 5 Sep 2017 09:23:51 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 33F03AF4 for ; Tue, 5 Sep 2017 09:23:51 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg0-f53.google.com (mail-pg0-f53.google.com [74.125.83.53]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 5AAA11E8 for ; Tue, 5 Sep 2017 09:23:49 +0000 (UTC) Received: by mail-pg0-f53.google.com with SMTP id j6so8140510pgc.1 for ; Tue, 05 Sep 2017 02:23:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fridaylinux-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=hnEdNO8g6nyGg0p+dNw8L9ukK77X4pLPIOb6W6N+kyQ=; b=lvgeUpxbxUOmsK7bxk61NUSJ+CdZN7afA3aIN+D1/ai1drf/s2neLNDdW6rJBTNVNr 2BblO9/XNHE139Yjak1TegVHva16AKsRavJPMXPTJesIOX5/kQRgBv0KwUx5Uwl/4wxG t422Jkw6/Httha112KAA2yd67GLCcZcsCgISCSVD4zq1ZwgIg5KC96idjLx7op4jfYea vV6wv8h0dwAEk6HZpfFH00F7o0J2yIWm3To8qQVIP4l0/H9a4JflhPGGwrfGVEau/p2p 6wWKhn6ijYQQA6PaAkq1K8f93Nl5mLKp22Zm2MMqAvBXn9hoi3Op2REG4KWEeVGTFN/l bVog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=hnEdNO8g6nyGg0p+dNw8L9ukK77X4pLPIOb6W6N+kyQ=; b=f5t/6jNtSAMxlHmX46jJl0o9eCETKYxpIp5KJEQ18r6gdg+lSTrPxA0qvPD73m4C9i L78hLGz6i/PI8nPTgt++mQWK2tW1S3JTvHUWoL0gTR6zsr63ETwmoCADGq0GDI1zI/1Y RAewdd+CDfQ6eerMpZgeMEBCDDj3gxPmHLbiAfRx9QYr+tNKxMHvDt+HTdPPhtyXhXwz f1msktafJfHNZz+kTqUbxi/iIlRdGP5GyByy/Vn7dWAkDcDeIWQR23hlkUmQ9Z/u4VJL ROdh3hpAJSyNWzHRZwqQfbzqYVyXFyMnITxwV0K6ODHWf87c+F5H8c+6Qi/dqyMJHuTA Z6oA== X-Gm-Message-State: AHPjjUgkVZxvt1L/91e24w03i55sIC6IsHE/YeEhF4eVs3exal7AuaBT W5LlQq6ZZQFgzNzwvAJEng== X-Google-Smtp-Source: ADKCNb4VfEj54Q9TTX4nb1XHH0KE6t1KkLgHlTQHYlf3Bn8aD/jT/EXGQf0PW8fsqHDSUNLrMnE81g== X-Received: by 10.84.210.108 with SMTP id z99mr3589336plh.341.1504603428432; Tue, 05 Sep 2017 02:23:48 -0700 (PDT) Received: from localhost.localdomain ([101.228.204.163]) by smtp.gmail.com with ESMTPSA id i187sm295921pfe.71.2017.09.05.02.23.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 05 Sep 2017 02:23:47 -0700 (PDT) From: Yuanhan Liu To: dev@openvswitch.org Date: Tue, 5 Sep 2017 17:22:57 +0800 Message-Id: <1504603381-30071-5-git-send-email-yliu@fridaylinux.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504603381-30071-1-git-send-email-yliu@fridaylinux.org> References: <1504603381-30071-1-git-send-email-yliu@fridaylinux.org> X-Spam-Status: No, score=0.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, RCVD_IN_DNSWL_NONE autolearn=disabled version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v2 4/8] netdev-dpdk: implement flow put with rte flow X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org From: Finn Christensen The basic yet the major part of this patch is to translate the "match" to rte flow patterns. And then, we create a rte flow with a MARK action. Afterwards, all pkts matches the flow will have the mark id in the mbuf. For any unsupported flows, such as MPLS, -1 is returned, meaning the flow offload is failed and then skipped. Co-authored-by: Yuanhan Liu Signed-off-by: Finn Christensen Signed-off-by: Yuanhan Liu --- v2: - convert some macros to functions - do not hardcode the max number of flow/action - fix L2 patterns for Intel nic - add comments for not implemented offload methods --- lib/netdev-dpdk.c | 421 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 420 insertions(+), 1 deletion(-) diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index 46f9885..37b0f99 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -58,6 +58,7 @@ #include "smap.h" #include "sset.h" #include "unaligned.h" +#include "uuid.h" #include "timeval.h" #include "unixctl.h" @@ -3400,6 +3401,424 @@ get_rte_flow_by_ufid(const ovs_u128 *ufid) } +struct flow_patterns { + struct rte_flow_item *items; + int cnt; + int max; +}; + +struct flow_actions { + struct rte_flow_action *actions; + int cnt; + int max; +}; + +static void +add_flow_pattern(struct flow_patterns *patterns, enum rte_flow_item_type type, + const void *spec, const void *mask) +{ + int cnt = patterns->cnt; + + if (cnt == 0) { + patterns->max = 8; + patterns->items = xcalloc(patterns->max, sizeof(struct rte_flow_item)); + } else if (cnt == patterns->max) { + patterns->max *= 2; + patterns->items = xrealloc(patterns->items, patterns->max * + sizeof(struct rte_flow_item)); + } + + patterns->items[cnt].type = type; + patterns->items[cnt].spec = spec; + patterns->items[cnt].mask = mask; + patterns->items[cnt].last = NULL; + patterns->cnt++; +} + +static void +add_flow_action(struct flow_actions *actions, enum rte_flow_action_type type, + const void *conf) +{ + int cnt = actions->cnt; + + if (cnt == 0) { + actions->max = 8; + actions->actions = xcalloc(actions->max, + sizeof(struct rte_flow_action)); + } else if (cnt == actions->max) { + actions->max *= 2; + actions->actions = xrealloc(actions->actions, actions->max * + sizeof(struct rte_flow_action)); + } + + actions->actions[cnt].type = type; + actions->actions[cnt].conf = conf; + actions->cnt++; +} + +static int +netdev_dpdk_add_rte_flow_offload(struct netdev *netdev, + const struct match *match, + struct nlattr *nl_actions OVS_UNUSED, + size_t actions_len, + const ovs_u128 *ufid, + struct offload_info *info) +{ + struct netdev_dpdk *dev = netdev_dpdk_cast(netdev); + 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 *ipv4_next_proto_mask = NULL; + int ret = 0; + + /* Eth */ + struct rte_flow_item_eth eth_spec; + struct rte_flow_item_eth eth_mask; + memset(ð_mask, 0, sizeof(eth_mask)); + if (match->wc.masks.dl_src.be16[0] || + match->wc.masks.dl_src.be16[1] || + match->wc.masks.dl_src.be16[2] || + match->wc.masks.dl_dst.be16[0] || + match->wc.masks.dl_dst.be16[1] || + match->wc.masks.dl_dst.be16[2]) { + rte_memcpy(ð_spec.dst, &match->flow.dl_dst, sizeof(eth_spec.dst)); + rte_memcpy(ð_spec.src, &match->flow.dl_src, sizeof(eth_spec.src)); + eth_spec.type = match->flow.dl_type; + + rte_memcpy(ð_mask.dst, &match->wc.masks.dl_dst, + sizeof(eth_mask.dst)); + rte_memcpy(ð_mask.src, &match->wc.masks.dl_src, + sizeof(eth_mask.src)); + eth_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, + * OVS will at least set the dl_type. Normally, it's enough to + * create an eth pattern just with it. Unluckily, some Intel's + * 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); + } + + /* VLAN */ + struct rte_flow_item_vlan vlan_spec; + struct rte_flow_item_vlan vlan_mask; + memset(&vlan_mask, 0, sizeof(vlan_mask)); + if (match->wc.masks.vlans[0].tci && match->flow.vlans[0].tci) { + vlan_spec.tci = match->flow.vlans[0].tci; + vlan_mask.tci = match->wc.masks.vlans[0].tci; + + /* match any protocols */ + vlan_mask.tpid = 0; + + add_flow_pattern(&patterns, RTE_FLOW_ITEM_TYPE_VLAN, + &vlan_spec, &vlan_mask); + } + + /* IP v4 */ + uint8_t proto = 0; + struct rte_flow_item_ipv4 ipv4_spec; + struct rte_flow_item_ipv4 ipv4_mask; + memset(&ipv4_mask, 0, sizeof(ipv4_mask)); + if ((match->flow.dl_type == ntohs(ETH_TYPE_IP)) && + (match->wc.masks.nw_src || match->wc.masks.nw_dst || + match->wc.masks.nw_tos || match->wc.masks.nw_ttl || + match->wc.masks.nw_proto)) { + ipv4_spec.hdr.type_of_service = match->flow.nw_tos; + ipv4_spec.hdr.time_to_live = match->flow.nw_tos; + ipv4_spec.hdr.next_proto_id = match->flow.nw_proto; + ipv4_spec.hdr.src_addr = match->flow.nw_src; + ipv4_spec.hdr.dst_addr = match->flow.nw_dst; + + ipv4_mask.hdr.type_of_service = match->wc.masks.nw_tos; + ipv4_mask.hdr.time_to_live = match->wc.masks.nw_tos; + ipv4_mask.hdr.next_proto_id = match->wc.masks.nw_proto; + ipv4_mask.hdr.src_addr = match->wc.masks.nw_src; + ipv4_mask.hdr.dst_addr = match->wc.masks.nw_dst; + + add_flow_pattern(&patterns, RTE_FLOW_ITEM_TYPE_IPV4, + &ipv4_spec, &ipv4_mask); + + /* Save proto for L4 protocol setup */ + proto = ipv4_spec.hdr.next_proto_id & ipv4_mask.hdr.next_proto_id; + + /* Remember proto mask address for later modification */ + ipv4_next_proto_mask = &ipv4_mask.hdr.next_proto_id; + } + + if (proto != IPPROTO_ICMP && proto != IPPROTO_UDP && + proto != IPPROTO_SCTP && proto != IPPROTO_TCP && + (match->wc.masks.tp_src || + match->wc.masks.tp_dst || + match->wc.masks.tcp_flags)) { + VLOG_INFO("L4 Protocol (%u) not supported", proto); + ret = -1; + goto out; + } + + struct rte_flow_item_udp udp_spec; + struct rte_flow_item_udp udp_mask; + memset(&udp_mask, 0, sizeof(udp_mask)); + if ((proto == IPPROTO_UDP) && + (match->wc.masks.tp_src || match->wc.masks.tp_dst)) { + udp_spec.hdr.src_port = match->flow.tp_src; + udp_spec.hdr.dst_port = match->flow.tp_dst; + + udp_mask.hdr.src_port = match->wc.masks.tp_src; + udp_mask.hdr.dst_port = match->wc.masks.tp_dst; + + add_flow_pattern(&patterns, RTE_FLOW_ITEM_TYPE_UDP, + &udp_spec, &udp_mask); + + /* proto == UDP and ITEM_TYPE_UDP, thus no need for proto match */ + if (ipv4_next_proto_mask) { + *ipv4_next_proto_mask = 0; + } + } + + struct rte_flow_item_sctp sctp_spec; + struct rte_flow_item_sctp sctp_mask; + memset(&sctp_mask, 0, sizeof(sctp_mask)); + if ((proto == IPPROTO_SCTP) && + (match->wc.masks.tp_src || match->wc.masks.tp_dst)) { + sctp_spec.hdr.src_port = match->flow.tp_src; + sctp_spec.hdr.dst_port = match->flow.tp_dst; + + sctp_mask.hdr.src_port = match->wc.masks.tp_src; + sctp_mask.hdr.dst_port = match->wc.masks.tp_dst; + + add_flow_pattern(&patterns, RTE_FLOW_ITEM_TYPE_SCTP, + &sctp_spec, &sctp_mask); + + /* proto == SCTP and ITEM_TYPE_SCTP, thus no need for proto match */ + if (ipv4_next_proto_mask) { + *ipv4_next_proto_mask = 0; + } + } + + struct rte_flow_item_icmp icmp_spec; + struct rte_flow_item_icmp icmp_mask; + memset(&icmp_mask, 0, sizeof(icmp_mask)); + if ((proto == IPPROTO_ICMP) && + (match->wc.masks.tp_src || match->wc.masks.tp_dst)) { + icmp_spec.hdr.icmp_type = (uint8_t)ntohs(match->flow.tp_src); + icmp_spec.hdr.icmp_code = (uint8_t)ntohs(match->flow.tp_dst); + + icmp_mask.hdr.icmp_type = (uint8_t)ntohs(match->wc.masks.tp_src); + icmp_mask.hdr.icmp_code = (uint8_t)ntohs(match->wc.masks.tp_dst); + + add_flow_pattern(&patterns, RTE_FLOW_ITEM_TYPE_ICMP, + &icmp_spec, &icmp_mask); + + /* proto == ICMP and ITEM_TYPE_ICMP, thus no need for proto match */ + if (ipv4_next_proto_mask) { + *ipv4_next_proto_mask = 0; + } + } + + struct rte_flow_item_tcp tcp_spec; + struct rte_flow_item_tcp tcp_mask; + memset(&tcp_mask, 0, sizeof(tcp_mask)); + if ((proto == IPPROTO_TCP) && + (match->wc.masks.tp_src || + match->wc.masks.tp_dst || + match->wc.masks.tcp_flags)) { + tcp_spec.hdr.src_port = match->flow.tp_src; + tcp_spec.hdr.dst_port = match->flow.tp_dst; + tcp_spec.hdr.data_off = ntohs(match->flow.tcp_flags) >> 8; + tcp_spec.hdr.tcp_flags = ntohs(match->flow.tcp_flags) & 0xff; + + tcp_mask.hdr.src_port = match->wc.masks.tp_src; + tcp_mask.hdr.dst_port = match->wc.masks.tp_dst; + tcp_mask.hdr.data_off = ntohs(match->wc.masks.tcp_flags) >> 8; + tcp_mask.hdr.tcp_flags = ntohs(match->wc.masks.tcp_flags) & 0xff; + + add_flow_pattern(&patterns, RTE_FLOW_ITEM_TYPE_TCP, + &tcp_spec, &tcp_mask); + + /* proto == TCP and ITEM_TYPE_TCP, thus no need for proto match */ + if (ipv4_next_proto_mask) { + *ipv4_next_proto_mask = 0; + } + } + add_flow_pattern(&patterns, RTE_FLOW_ITEM_TYPE_END, NULL, NULL); + + struct rte_flow_action_mark mark; + if (actions_len) { + mark.id = info->flow_mark; + add_flow_action(&actions, RTE_FLOW_ACTION_TYPE_MARK, &mark); + } else { + add_flow_action(&actions, RTE_FLOW_ACTION_TYPE_DROP, NULL); + VLOG_INFO("no action given; drop pkts in hardware\n"); + } + add_flow_action(&actions, RTE_FLOW_ACTION_TYPE_END, NULL); + + flow = rte_flow_create(dev->port_id, &flow_attr, patterns.items, + actions.actions, &error); + if (!flow) { + VLOG_ERR("rte flow creat error: %u : message : %s\n", + error.type, error.message); + ret = -1; + goto out; + } + add_ufid_dpdk_flow_mapping(ufid, flow); + VLOG_INFO("installed flow %p by ufid "UUID_FMT"\n", + flow, UUID_ARGS((struct uuid *)ufid)); + +out: + free(patterns.items); + free(actions.actions); + return ret; +} + +/* + * Validate for later rte flow offload creation. If any unsupported + * flow are specified, return -1. + */ +static int +netdev_dpdk_validate_flow(const struct match *match) +{ + struct match match_zero_wc; + + /* Create a wc-zeroed version of flow */ + match_init(&match_zero_wc, &match->flow, &match->wc); + +#define CHECK_NONZERO_BYTES(addr, size) do { \ + uint8_t *padr = (uint8_t *)(addr); \ + int i; \ + for (i = 0; i < (size); i++) { \ + if (padr[i] != 0) { \ + goto err; \ + } \ + } \ +} while (0) + +#define CHECK_NONZERO(var) do { \ + if ((var) != 0) { \ + goto err; \ + } \ +} while (0) + + CHECK_NONZERO_BYTES(&match_zero_wc.flow.tunnel, + sizeof(match_zero_wc.flow.tunnel)); + CHECK_NONZERO(match->wc.masks.metadata); + CHECK_NONZERO(match->wc.masks.skb_priority); + CHECK_NONZERO(match->wc.masks.pkt_mark); + CHECK_NONZERO(match->wc.masks.dp_hash); + + /* recirc id must be zero */ + CHECK_NONZERO(match_zero_wc.flow.recirc_id); + + CHECK_NONZERO(match->wc.masks.ct_state); + CHECK_NONZERO(match->wc.masks.ct_zone); + CHECK_NONZERO(match->wc.masks.ct_mark); + CHECK_NONZERO(match->wc.masks.ct_label.u64.hi); + CHECK_NONZERO(match->wc.masks.ct_label.u64.lo); + CHECK_NONZERO(match->wc.masks.ct_nw_proto); + CHECK_NONZERO(match->wc.masks.ct_tp_src); + CHECK_NONZERO(match->wc.masks.ct_tp_dst); + CHECK_NONZERO(match->wc.masks.conj_id); + CHECK_NONZERO(match->wc.masks.actset_output); + + /* unsupported L2 */ + CHECK_NONZERO_BYTES(&match->wc.masks.mpls_lse, + sizeof(match_zero_wc.flow.mpls_lse) / + sizeof(ovs_be32)); + + /* unsupported L3 */ + CHECK_NONZERO_BYTES(&match->wc.masks.ipv6_src, sizeof(struct in6_addr)); + CHECK_NONZERO_BYTES(&match->wc.masks.ipv6_dst, sizeof(struct in6_addr)); + CHECK_NONZERO(match->wc.masks.ipv6_label); + CHECK_NONZERO_BYTES(&match->wc.masks.nd_target, sizeof(struct in6_addr)); + CHECK_NONZERO_BYTES(&match->wc.masks.arp_sha, sizeof(struct eth_addr)); + CHECK_NONZERO_BYTES(&match->wc.masks.arp_tha, sizeof(struct eth_addr)); + + /* If fragmented, then don't HW accelerate - for now */ + CHECK_NONZERO(match_zero_wc.flow.nw_frag); + + /* unsupported L4 */ + CHECK_NONZERO(match->wc.masks.igmp_group_ip4); + + return 0; + +err: + VLOG_INFO("Cannot HW accelerate this flow"); + return -1; +} + +static int +netdev_dpdk_destroy_rte_flow(struct netdev_dpdk *dev, + const ovs_u128 *ufid, + struct rte_flow *rte_flow) +{ + struct rte_flow_error error; + int ret; + + ret = rte_flow_destroy(dev->port_id, rte_flow, &error); + if (ret == 0) { + del_ufid_dpdk_flow_mapping(ufid); + VLOG_INFO("removed rte flow %p associated with ufid " UUID_FMT "\n", + rte_flow, UUID_ARGS((struct uuid *)ufid)); + } else { + VLOG_ERR("rte flow destroy error: %u : message : %s\n", + error.type, error.message); + } + + return ret; +} + +static int +netdev_dpdk_flow_put(struct netdev *netdev, struct match *match, + struct nlattr *actions, size_t actions_len, + const ovs_u128 *ufid, struct offload_info *info, + struct dpif_flow_stats *stats OVS_UNUSED) +{ + struct rte_flow *rte_flow; + int ret; + + /* + * If an old rte_flow exists, it means it's a flow modification. + * Here destroy the old rte flow first before adding a new one. + */ + rte_flow = get_rte_flow_by_ufid(ufid); + if (rte_flow) { + ret = netdev_dpdk_destroy_rte_flow(netdev_dpdk_cast(netdev), + ufid, rte_flow); + if (ret < 0) + return ret; + } + + ret = netdev_dpdk_validate_flow(match); + if (ret < 0) { + return ret; + } + + return netdev_dpdk_add_rte_flow_offload(netdev, match, actions, + actions_len, ufid, info); +} + +#define DPDK_FLOW_OFFLOAD_API \ + NULL, /* flow_flush */ \ + NULL, /* flow_dump_create */ \ + NULL, /* flow_dump_destroy */ \ + NULL, /* flow_dump_next */ \ + netdev_dpdk_flow_put, \ + NULL, /* flow_get */ \ + NULL, /* flow_del */ \ + NULL /* init_flow_api */ + + #define NETDEV_DPDK_CLASS(NAME, INIT, CONSTRUCT, DESTRUCT, \ SET_CONFIG, SET_TX_MULTIQ, SEND, \ GET_CARRIER, GET_STATS, \ @@ -3472,7 +3891,7 @@ get_rte_flow_by_ufid(const ovs_u128 *ufid) RXQ_RECV, \ NULL, /* rx_wait */ \ NULL, /* rxq_drain */ \ - NO_OFFLOAD_API \ + DPDK_FLOW_OFFLOAD_API \ } static const struct netdev_class dpdk_class = From patchwork Tue Sep 5 09:22:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuanhan Liu X-Patchwork-Id: 810044 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=fridaylinux-org.20150623.gappssmtp.com header.i=@fridaylinux-org.20150623.gappssmtp.com header.b="Hl5lUSHS"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xmhF66PYcz9s0g for ; Tue, 5 Sep 2017 19:27:06 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id AD6B4B0C; Tue, 5 Sep 2017 09:23:55 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 5B208B09 for ; Tue, 5 Sep 2017 09:23:54 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg0-f43.google.com (mail-pg0-f43.google.com [74.125.83.43]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id D0A4FE5 for ; Tue, 5 Sep 2017 09:23:53 +0000 (UTC) Received: by mail-pg0-f43.google.com with SMTP id t3so8163575pgt.0 for ; Tue, 05 Sep 2017 02:23:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fridaylinux-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=HLU0tSQ9DxomrVsarSG+ny84LxBvcGdJ6aHShwgNGt4=; b=Hl5lUSHSZnZYjmuCk5ComUiK/o/pIDGx0X8LU/kO6aGSvl7gK+OvyxOfyMCVUHSf8t AAQL00+PJsWvDTTuKcmADYJGKAx9vr9Erb1PEGco6vuPtsn0enI/3AMTt6NX8OWlWdpW aB12+KoUjsUbX9uJ6RxECOHl3hV57npG6mYTZqaUAG+cKAH/x3OBVRRVhRckhQ7QiCh6 nVVwWFE4yeQ3E1i0sFy9Y9/Jttxfyk9jnYBdeSgrbXu1HISm+gF3XrJgl1CaA9C2H8Ub jRatUPRQGEFA9d5X0BKudsowX+ptacoPkOqOBZqLuFdM/V2sA7pJP1DIrx+vyXjLhMDt k4pA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=HLU0tSQ9DxomrVsarSG+ny84LxBvcGdJ6aHShwgNGt4=; b=IzYFmm06lK2EFkZd6Vs1jJyGQE+sF5AnK2mLdoXhm6udSn90MvcDEyPz+OBeWcsPy3 rnfZ+KU0zEK3N2ayfS4nR4y57IAK3GrGQPZ1MzNaT8gD7CnYs/q7beYGMSK4TcWp3OD1 F4jNCXLbuSvor6c1iiEOHp8xUtBTUN5fthA4Bdx5HlMBMzObIi23hIzY9KMfAlYXRabI eG4GoQnTvY5mo9L3ZYhlIPXgO/trQOK99rZYZoZA9yFz//jBxhES0sDwHa0Z1PiqyRAD Dvlg1r62bG/4vOlDwWL5BCoFjy/5TWn+qDBQfL/KK/mkLOA5hkFb14DUsr+CsP5Ej2oz larQ== X-Gm-Message-State: AHPjjUhk99kqaErDKjHT6OH21QOtVxER2te3DEqxTCZlSCH1gmaH00pS 1ZeYvm3QggKJXmapmTSwNHkx X-Google-Smtp-Source: ADKCNb6EoYsgLnX9FXPUSbDVCFJ92Nj6qvXoxkPfe21T5ivAmiDFWwcflRAkTpNJDIibn6DKRGPJWw== X-Received: by 10.84.240.140 with SMTP id z12mr3676233plk.18.1504603431325; Tue, 05 Sep 2017 02:23:51 -0700 (PDT) Received: from localhost.localdomain ([101.228.204.163]) by smtp.gmail.com with ESMTPSA id i187sm295921pfe.71.2017.09.05.02.23.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 05 Sep 2017 02:23:50 -0700 (PDT) From: Yuanhan Liu To: dev@openvswitch.org Date: Tue, 5 Sep 2017 17:22:58 +0800 Message-Id: <1504603381-30071-6-git-send-email-yliu@fridaylinux.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504603381-30071-1-git-send-email-yliu@fridaylinux.org> References: <1504603381-30071-1-git-send-email-yliu@fridaylinux.org> X-Spam-Status: No, score=0.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, RCVD_IN_DNSWL_NONE autolearn=disabled version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v2 5/8] dpif-netdev: record rx queue id for the upcall X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org From: Shachar Beiser For the DPDK flow offload, which basically just binds a MARK action to a flow, the MARK is required to be used together with a QUEUE action for the most NICs I'm aware of. The QUEUE action then needs a queue index, which is not given in the flow content. Here we record the rx queue while recieving the pkts to solve above issue. Co-authored-by: Yuanhan Liu Signed-off-by: Shachar Beiser Signed-off-by: Yuanhan Liu --- lib/dp-packet.h | 1 + lib/dpif-netdev.c | 14 +++++++++----- lib/netdev.c | 1 + lib/netdev.h | 1 + 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/dp-packet.h b/lib/dp-packet.h index a7a062f..479a734 100644 --- a/lib/dp-packet.h +++ b/lib/dp-packet.h @@ -709,6 +709,7 @@ enum { NETDEV_MAX_BURST = 32 }; /* Maximum number packets in a batch. */ struct dp_packet_batch { size_t count; bool trunc; /* true if the batch needs truncate. */ + int rxq; struct dp_packet *packets[NETDEV_MAX_BURST]; }; diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index a95b8d4..3099c73 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -2474,7 +2474,8 @@ out: static struct dp_netdev_flow * dp_netdev_flow_add(struct dp_netdev_pmd_thread *pmd, struct match *match, const ovs_u128 *ufid, - const struct nlattr *actions, size_t actions_len) + const struct nlattr *actions, size_t actions_len, + int rxq) OVS_REQUIRES(pmd->flow_mutex) { struct dp_netdev_flow *flow; @@ -2527,6 +2528,7 @@ dp_netdev_flow_add(struct dp_netdev_pmd_thread *pmd, dp_netdev_alloc_flow_mark(pmd, &info.flow_mark)) { struct dp_netdev_port *port; port = dp_netdev_lookup_port(pmd->dp, in_port); + info.rxq = rxq; if (netdev_flow_put(port->netdev, match, CONST_CAST(struct nlattr *, actions), actions_len, ufid, &info, NULL) == 0) { @@ -2607,7 +2609,7 @@ flow_put_on_pmd(struct dp_netdev_pmd_thread *pmd, if (put->flags & DPIF_FP_CREATE) { if (cmap_count(&pmd->flow_table) < MAX_FLOWS) { dp_netdev_flow_add(pmd, match, ufid, put->actions, - put->actions_len); + put->actions_len, -1); error = 0; } else { error = EFBIG; @@ -2635,6 +2637,7 @@ flow_put_on_pmd(struct dp_netdev_pmd_thread *pmd, in_port = netdev_flow->flow.in_port.odp_port; port = dp_netdev_lookup_port(pmd->dp, in_port); info.flow_mark = netdev_flow->mark; + info.rxq = -1; ret = netdev_flow_put(port->netdev, match, CONST_CAST(struct nlattr *, put->actions), @@ -5026,7 +5029,7 @@ handle_packet_upcall(struct dp_netdev_pmd_thread *pmd, struct dp_packet *packet, const struct netdev_flow_key *key, struct ofpbuf *actions, struct ofpbuf *put_actions, - int *lost_cnt, long long now) + int *lost_cnt, long long now, int rxq) { struct ofpbuf *add_actions; struct dp_packet_batch b; @@ -5082,7 +5085,8 @@ handle_packet_upcall(struct dp_netdev_pmd_thread *pmd, if (OVS_LIKELY(!netdev_flow)) { netdev_flow = dp_netdev_flow_add(pmd, &match, &ufid, add_actions->data, - add_actions->size); + add_actions->size, + rxq); } ovs_mutex_unlock(&pmd->flow_mutex); emc_probabilistic_insert(pmd, key, netdev_flow); @@ -5152,7 +5156,7 @@ fast_path_processing(struct dp_netdev_pmd_thread *pmd, miss_cnt++; handle_packet_upcall(pmd, packets[i], &keys[i], &actions, - &put_actions, &lost_cnt, now); + &put_actions, &lost_cnt, now, packets_->rxq); } ofpbuf_uninit(&actions); diff --git a/lib/netdev.c b/lib/netdev.c index b4e570b..c9b7019 100644 --- a/lib/netdev.c +++ b/lib/netdev.c @@ -700,6 +700,7 @@ netdev_rxq_recv(struct netdev_rxq *rx, struct dp_packet_batch *batch) retval = rx->netdev->netdev_class->rxq_recv(rx, batch); if (!retval) { + batch->rxq = rx->queue_id; COVERAGE_INC(netdev_received); } else { batch->count = 0; diff --git a/lib/netdev.h b/lib/netdev.h index 2003165..28ad39d 100644 --- a/lib/netdev.h +++ b/lib/netdev.h @@ -194,6 +194,7 @@ struct offload_info { * it will be in the pkt meta data. */ uint32_t flow_mark; + int rxq; }; struct dpif_class; struct netdev_flow_dump; From patchwork Tue Sep 5 09:22:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuanhan Liu X-Patchwork-Id: 810046 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=fridaylinux-org.20150623.gappssmtp.com header.i=@fridaylinux-org.20150623.gappssmtp.com header.b="Sb7xdzaa"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xmhFs5Q4vz9s0g for ; Tue, 5 Sep 2017 19:27:45 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 89FD1B1B; Tue, 5 Sep 2017 09:23:56 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 62D9EB09 for ; Tue, 5 Sep 2017 09:23:55 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg0-f50.google.com (mail-pg0-f50.google.com [74.125.83.50]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id DBD1112A for ; Tue, 5 Sep 2017 09:23:54 +0000 (UTC) Received: by mail-pg0-f50.google.com with SMTP id m9so8114162pgd.3 for ; Tue, 05 Sep 2017 02:23:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fridaylinux-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=uoE/6dgezKyBZY2V144FAWMbddf7rH9g8dbvu6mY4QQ=; b=Sb7xdzaawIqDdZG+aHLbnEuNLvmbhQVSwuT5WGA/dhzUu6F69ioX1yqORZaWh1+pUR teizYyOpI6Ulq8JSvxNiVcyAY7zHFbe3aMJw7cZJMuARE1C9Pr0Vu+4Y+vHSh95Lyj5J fDQqmgj1fN8nlbcvZsTYDkgS0f8zS2q3FSR/LfF8mOqSk+kFchBp74vj+N8dRAPubP17 /aFAr8wH+FKcn7L3lqYcX5zWtMhJr/aoM0VLSYsm37GBVegT6SUveHFX4vqXmkBZ89tE a9ns/I4wAYERK7pQHwvKOzng1CZTeYniCVDd2bBy9NphSdQksobHmTqv87LRTEDQjBXu GzJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=uoE/6dgezKyBZY2V144FAWMbddf7rH9g8dbvu6mY4QQ=; b=ssnHkj1TTNBNhj47Scp/JC5hUaCP6R1eyqB4+ToDRlSQnIwc1SwX60ew1D4fXXSUzR PCC4l4bnyZaVZ3uJYy3w8ZuOUwRJFJZlAKIdqE9NlNMRuEU2W2P5kWoYMLLDd0dOwHb7 vIT+xYH9ANZXu3aaRVlS8hYwsrrLBoaz6ozqC6o7myUSd0kMHRLxuSKcoi1dt6Airkup A7DGM4QSPPQo2Yzu2mdAil7ShfY2uefU2g69vJdmEXJy94Z7mk4I2h5khrGfMFApzs50 xSI5rrUBMjkPKEJjHhv16neexVMUGQl8g6XGyLiGOViTc4p0MTablROwUO/7ECRNk4/u kAsQ== X-Gm-Message-State: AHPjjUhDN0aqsW9CwhNJn6QlQsKUOz+gTAThUMElOzU/m4zAEKHNRfdU 8y0ng6epMxNI5Osc+QrybFvN X-Google-Smtp-Source: ADKCNb7VFrRrkXW1uSx8FL8zp32YoDeCQHf6JrDuaux57SfkEO4K45Hh7Oiv3nGfleL/4uEhw244Bw== X-Received: by 10.84.133.6 with SMTP id 6mr3581214plf.237.1504603433927; Tue, 05 Sep 2017 02:23:53 -0700 (PDT) Received: from localhost.localdomain ([101.228.204.163]) by smtp.gmail.com with ESMTPSA id i187sm295921pfe.71.2017.09.05.02.23.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 05 Sep 2017 02:23:52 -0700 (PDT) From: Yuanhan Liu To: dev@openvswitch.org Date: Tue, 5 Sep 2017 17:22:59 +0800 Message-Id: <1504603381-30071-7-git-send-email-yliu@fridaylinux.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504603381-30071-1-git-send-email-yliu@fridaylinux.org> References: <1504603381-30071-1-git-send-email-yliu@fridaylinux.org> X-Spam-Status: No, score=0.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, RCVD_IN_DNSWL_NONE autolearn=disabled version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v2 6/8] netdev-dpdk: retry with queue action X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org From: Finn Christensen AFAIK, most (if not all) NICs (including Mellanox and Intel) do not support a pure MARK action. It's required to be used together with some other actions, like QUEUE. To workaround it, retry with a queue action when first try failed. Moreover, some Intel's NIC (say XL710) needs the QUEUE action set before the MARK action. Co-authored-by: Yuanhan Liu Signed-off-by: Finn Christensen Signed-off-by: Yuanhan Liu --- v2: - workarounded the queue action issue, which sets the queue index to 0 blindly. - added some comments regarding to the retry with queue action --- lib/netdev-dpdk.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 52 insertions(+), 7 deletions(-) diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index 37b0f99..320fe80 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -3324,6 +3324,7 @@ static struct ovs_mutex ufid_lock = OVS_MUTEX_INITIALIZER; struct ufid_dpdk_flow_data { struct hmap_node node; ovs_u128 ufid; + int rxq; struct rte_flow *rte_flow; }; @@ -3366,7 +3367,8 @@ del_ufid_dpdk_flow_mapping(const ovs_u128 *ufid) /* Add ufid to dpdk_flow mapping */ static inline void -add_ufid_dpdk_flow_mapping(const ovs_u128 *ufid, struct rte_flow *rte_flow) +add_ufid_dpdk_flow_mapping(const ovs_u128 *ufid, struct rte_flow *rte_flow, + int rxq) { size_t hash = hash_bytes(ufid, sizeof(*ufid), 0); struct ufid_dpdk_flow_data *data = xzalloc(sizeof(*data)); @@ -3381,6 +3383,7 @@ add_ufid_dpdk_flow_mapping(const ovs_u128 *ufid, struct rte_flow *rte_flow) data->ufid = *ufid; data->rte_flow = rte_flow; + data->rxq = rxq; ovs_mutex_lock(&ufid_lock); hmap_insert(&ufid_dpdk_flow, &data->node, hash); @@ -3664,15 +3667,51 @@ netdev_dpdk_add_rte_flow_offload(struct netdev *netdev, } add_flow_action(&actions, RTE_FLOW_ACTION_TYPE_END, NULL); + bool tried = 0; + struct rte_flow_action_queue queue; +again: flow = rte_flow_create(dev->port_id, &flow_attr, patterns.items, actions.actions, &error); - if (!flow) { + if (!flow && !tried && actions_len) { + /* + * Seems most (if not all) NICs do not support a pure MARK + * action. It's required to be used together with some other + * actions, such as QUEUE. + * + * Thus, if flow creation fails, here we try again with + * QUEUE action. + * + */ + if (info->rxq < 0 || info->rxq >= netdev->n_rxq) { + VLOG_ERR("invalid queue index: %d\n", info->rxq); + ret = -1; + goto out; + } + queue.index = info->rxq; + + /* re-build the action */ + actions.cnt = 0; + /* + * NOTE: Intel PMD driver needs the QUEUE action set before + * the MARK action. + */ + add_flow_action(&actions, RTE_FLOW_ACTION_TYPE_QUEUE, &queue); + add_flow_action(&actions, RTE_FLOW_ACTION_TYPE_MARK, &mark); + add_flow_action(&actions, RTE_FLOW_ACTION_TYPE_END, NULL); + + VLOG_INFO("failed to create rte flow, " + "try again with QUEUE action (queue index = %d)\n", + info->rxq); + tried = true; + + goto again; + } else if (!flow) { VLOG_ERR("rte flow creat error: %u : message : %s\n", error.type, error.message); ret = -1; goto out; } - add_ufid_dpdk_flow_mapping(ufid, flow); + add_ufid_dpdk_flow_mapping(ufid, flow, info->rxq); VLOG_INFO("installed flow %p by ufid "UUID_FMT"\n", flow, UUID_ARGS((struct uuid *)ufid)); @@ -3784,17 +3823,23 @@ netdev_dpdk_flow_put(struct netdev *netdev, struct match *match, const ovs_u128 *ufid, struct offload_info *info, struct dpif_flow_stats *stats OVS_UNUSED) { - struct rte_flow *rte_flow; + struct ufid_dpdk_flow_data *flow_data; int ret; /* * If an old rte_flow exists, it means it's a flow modification. * Here destroy the old rte flow first before adding a new one. */ - rte_flow = get_rte_flow_by_ufid(ufid); - if (rte_flow) { + flow_data = find_ufid_dpdk_flow_mapping(ufid); + if (flow_data && flow_data->rte_flow) { + /* + * there is no rxq given for flow modification. Instead, we + * retrieve it from the rxq firstly registered here (by flow + * add operation). + */ + info->rxq = flow_data->rxq; ret = netdev_dpdk_destroy_rte_flow(netdev_dpdk_cast(netdev), - ufid, rte_flow); + ufid, flow_data->rte_flow); if (ret < 0) return ret; } From patchwork Tue Sep 5 09:23:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuanhan Liu X-Patchwork-Id: 810048 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=fridaylinux-org.20150623.gappssmtp.com header.i=@fridaylinux-org.20150623.gappssmtp.com header.b="NYw/fsnO"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xmhGm4hynz9s0g for ; Tue, 5 Sep 2017 19:28:32 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 90196B09; Tue, 5 Sep 2017 09:23:59 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id AAE9EB09 for ; Tue, 5 Sep 2017 09:23:57 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg0-f51.google.com (mail-pg0-f51.google.com [74.125.83.51]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 5FFBBE0 for ; Tue, 5 Sep 2017 09:23:57 +0000 (UTC) Received: by mail-pg0-f51.google.com with SMTP id j6so8141197pgc.1 for ; Tue, 05 Sep 2017 02:23:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fridaylinux-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/+HkXwFcszP2aChN/oi9OGIAKgfBrKvXdnGfajev1AI=; b=NYw/fsnO9xXTPY03yBFi0pyEsLZ3TrP2FHj7N4dclbffgdWMwDxM39YZZAxxqa61yH 1ziiTBOW7o/TGFxknXG8r8fcU/CyM8pt/GopmgDSj/sPa+gvxwJUerJJoGlSJwiYY0Dw JcLF6/9OEN3JZTDxoesgvHBs0kX7I3oxvKYJEX6ea0YKdSm/GRbeJ2Y9DM8nFr7JUy02 eCWS+Y3jq70TP/4MeUiKtt5MQUZQNd/jnbO+PiS7AEKajUwN7OopqB3q7hbPjPiZktBo xZbuew45C1ADNev9K9FPl10QGc8WLHe+oSDb0qluVisUiGFwD5loljnCM9OpTvvrlVGo yk4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/+HkXwFcszP2aChN/oi9OGIAKgfBrKvXdnGfajev1AI=; b=WwGOMtvIHVbfvP4i4dU6V+LnC0A9466F0SJYeeLnU/bVWmmy0GH10N3z3hWL+fmu18 j8+irdhpLqIvjsNedthtfMDxLStiWUXDk0/95JkM7nAg5TIZh1Svh1CGnMRttuuGwKwH L+qYnQxnXRgTtbPf5vxbaIKd7rEflFWODXaUu9mhmhiSxezq+B7qwaAffop+qITOMHzN PDTDochpJTnlYYVw1iEiKZ03OsZhpnMdB0CM3Bnt6kMoXPMEgiZQeX/DUpdpMYFgPI/G W59+mkRKU43OCQcslfftuMJhR1oerdm8Mrk87XMxPSMX/iEvavBdbVE5NxURiDfSmpyC LcLw== X-Gm-Message-State: AHPjjUipnxt4ZJgWabSJrfDWbon2HS6hBwKJ23hfsTKuYNh97SA0PHBr UAV5x2u7zXaOHzUGGIWqIx1Q X-Google-Smtp-Source: ADKCNb7CXjpBGZtkbm3/8mWuTacOKGKepDZV8geCcGF+uqK8b+E7lXSTpL7WQquTNCPvj8ZrZK5eNQ== X-Received: by 10.84.236.69 with SMTP id h5mr3608198pln.338.1504603436651; Tue, 05 Sep 2017 02:23:56 -0700 (PDT) Received: from localhost.localdomain ([101.228.204.163]) by smtp.gmail.com with ESMTPSA id i187sm295921pfe.71.2017.09.05.02.23.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 05 Sep 2017 02:23:55 -0700 (PDT) From: Yuanhan Liu To: dev@openvswitch.org Date: Tue, 5 Sep 2017 17:23:00 +0800 Message-Id: <1504603381-30071-8-git-send-email-yliu@fridaylinux.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504603381-30071-1-git-send-email-yliu@fridaylinux.org> References: <1504603381-30071-1-git-send-email-yliu@fridaylinux.org> X-Spam-Status: No, score=0.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM autolearn=disabled version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v2 7/8] netdev-dpdk: remove offloaded flow on deletion X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Inovke netdev class '->flow_del' method on flow deletion. The dpdk netdev implementation will then remove the rte flow associated with the ufid. Co-authored-by: Finn Christensen Signed-off-by: Yuanhan Liu Signed-off-by: Finn Christensen --- v2: - check the returned "port" from dp_netdev_lookup_port - error log when flow is not found --- lib/dpif-netdev.c | 10 ++++++++-- lib/netdev-dpdk.c | 19 ++++++++++++++++++- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c index 3099c73..2fbaa96 100644 --- a/lib/dpif-netdev.c +++ b/lib/dpif-netdev.c @@ -1857,8 +1857,14 @@ dp_netdev_pmd_remove_flow(struct dp_netdev_pmd_thread *pmd, dpcls_remove(cls, &flow->cr); cmap_remove(&pmd->flow_table, node, dp_netdev_flow_hash(&flow->ufid)); if (flow->has_mark) { - cmap_remove(&pmd->mark_to_flow, mark_node, flow->mark); - flow->has_mark = false; + struct dp_netdev_port *port; + + port = dp_netdev_lookup_port(pmd->dp, in_port); + if (port) { + netdev_flow_del(port->netdev, &flow->ufid, NULL); + cmap_remove(&pmd->mark_to_flow, mark_node, flow->mark); + flow->has_mark = false; + } } flow->dead = true; diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index 320fe80..e363c92 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -3853,6 +3853,23 @@ netdev_dpdk_flow_put(struct netdev *netdev, struct match *match, actions_len, ufid, info); } +static int +netdev_dpdk_flow_del(struct netdev *netdev, const ovs_u128 *ufid, + struct dpif_flow_stats *stats OVS_UNUSED) +{ + + struct rte_flow *rte_flow = get_rte_flow_by_ufid(ufid); + + if (!rte_flow) { + VLOG_ERR("failed to find flow associated with ufid " UUID_FMT "\n", + UUID_ARGS((struct uuid *)ufid)); + return -1; + } + + return netdev_dpdk_destroy_rte_flow(netdev_dpdk_cast(netdev), + ufid, rte_flow); +} + #define DPDK_FLOW_OFFLOAD_API \ NULL, /* flow_flush */ \ NULL, /* flow_dump_create */ \ @@ -3860,7 +3877,7 @@ netdev_dpdk_flow_put(struct netdev *netdev, struct match *match, NULL, /* flow_dump_next */ \ netdev_dpdk_flow_put, \ NULL, /* flow_get */ \ - NULL, /* flow_del */ \ + netdev_dpdk_flow_del, \ NULL /* init_flow_api */ From patchwork Tue Sep 5 09:23:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuanhan Liu X-Patchwork-Id: 810051 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=fridaylinux-org.20150623.gappssmtp.com header.i=@fridaylinux-org.20150623.gappssmtp.com header.b="BWEfDRWR"; dkim-atps=neutral Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xmhHS50BGz9sPt for ; Tue, 5 Sep 2017 19:29:08 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 4F775B35; Tue, 5 Sep 2017 09:24:01 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 4BC93B12 for ; Tue, 5 Sep 2017 09:24:00 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg0-f49.google.com (mail-pg0-f49.google.com [74.125.83.49]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 143D7E0 for ; Tue, 5 Sep 2017 09:24:00 +0000 (UTC) Received: by mail-pg0-f49.google.com with SMTP id 188so4856812pgb.2 for ; Tue, 05 Sep 2017 02:24:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fridaylinux-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=lwokVe8/Y616VBjRFyfnw8oP9aDjO9oCrQ1UJh5N7tI=; b=BWEfDRWRyA+BITs5naNosvJvB4a85bDmRAnkFBkDd0xMIoTRJ++y8vi7u1LPbgdU/U MezcT+3cRrrkBefnJu8w38rW/U8YCkxEDM6iIZ/vOpQF/vZaCUqnr5vEvFkoWvxCzPCf uwMwMM3vf+pjPRYcT/ruGaG7+G0svgOQTlkrzqdEN4YDdt19bVJZZChabA0mhLiJIZk4 BntiuegFzbG7sA0qhERvB+VqrVwE0L91ywnMiWBWBC9XfOIVcpZPamxY94hAvyycjX3n eCTY3+zEeFSR7qVjinof4KjE+yabFAAQqgewWBnzSwwY/hmW52AQ6eYJejlHHuCxVjnh SehA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=lwokVe8/Y616VBjRFyfnw8oP9aDjO9oCrQ1UJh5N7tI=; b=APiWrEpZfkVSQerK8JdLGjO2QSfXZLIzGQ4tY7hvg5Z8nUWGKsHNC6vyvRFS6tpou0 FiZdCl2u8lXV74BgbTqHkTh9aGWCuQ1ZKu2JmrMJZTNnsLYqSMzGWYHpAqaE0kSzunbe MfeMVIio1RERIP8RrEWwunZMd/ZqskItkeJJUUS8IRkT9naT8FJh0Xwg4P9fnXA6c8w3 DQfVYKKPxOFygs4mFvHUJ7malpu1kCda7NDOjigt0VOq8jVZ0amvQitzYX9g8wuf9PIQ aWbGNYhBkFM0VHYspC730ARgTqJnzuuH9bAahw3uoUdshM/RgZvL3Z4LAFNVX2Ja9N7n EtQg== X-Gm-Message-State: AHPjjUi8c0qQp3+g6L2IC0wqVP8kSceDhx4PHjJ7nMqeTmZT1fHv2CAi kiydHYh1iEQYAwl0PokTEqHZ X-Google-Smtp-Source: ADKCNb7dRA7XHQEKCIOqo8fRCZOl3hQRGKuXrQo/ZGCc3qQdFgpTKvEolgPCkLrjS6MpKS3MPdcFjA== X-Received: by 10.84.211.72 with SMTP id b66mr3610332pli.286.1504603439364; Tue, 05 Sep 2017 02:23:59 -0700 (PDT) Received: from localhost.localdomain ([101.228.204.163]) by smtp.gmail.com with ESMTPSA id i187sm295921pfe.71.2017.09.05.02.23.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 05 Sep 2017 02:23:58 -0700 (PDT) From: Yuanhan Liu To: dev@openvswitch.org Date: Tue, 5 Sep 2017 17:23:01 +0800 Message-Id: <1504603381-30071-9-git-send-email-yliu@fridaylinux.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1504603381-30071-1-git-send-email-yliu@fridaylinux.org> References: <1504603381-30071-1-git-send-email-yliu@fridaylinux.org> X-Spam-Status: No, score=0.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, RCVD_IN_DNSWL_NONE autolearn=disabled version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH v2 8/8] netdev-dpdk: set FDIR config X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org From: Finn Christensen The Intel i40e PMD driver requires the fdir mode set to RTE_FDIR_MODE_PERFECT, otherwise, the flow creation would be failed. Co-authored-by: Yuanhan Liu Signed-off-by: Finn Christensen Signed-off-by: Yuanhan Liu --- --- lib/netdev-dpdk.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c index e363c92..beb7b68 100644 --- a/lib/netdev-dpdk.c +++ b/lib/netdev-dpdk.c @@ -177,6 +177,9 @@ static const struct rte_eth_conf port_conf = { .txmode = { .mq_mode = ETH_MQ_TX_NONE, }, + .fdir_conf = { + .mode = RTE_FDIR_MODE_PERFECT, + }, }; /*