From patchwork Thu Sep 6 16:27:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Pattan, Reshma" X-Patchwork-Id: 44345 X-Patchwork-Delegate: cristian.dumitrescu@intel.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0BDDC5F2E; Thu, 6 Sep 2018 18:27:31 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id 9F47B5B30 for ; Thu, 6 Sep 2018 18:27:23 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Sep 2018 09:27:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,338,1531810800"; d="scan'208";a="68064526" Received: from sivswdev02.ir.intel.com (HELO localhost.localdomain) ([10.237.217.46]) by fmsmga007.fm.intel.com with ESMTP; 06 Sep 2018 09:27:22 -0700 From: Reshma Pattan To: dev@dpdk.org Cc: Cristian Dumitrescu , Reshma Pattan Date: Thu, 6 Sep 2018 17:27:01 +0100 Message-Id: <1536251222-17275-15-git-send-email-reshma.pattan@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1536251222-17275-1-git-send-email-reshma.pattan@intel.com> References: <1536251222-17275-1-git-send-email-reshma.pattan@intel.com> Subject: [dpdk-dev] [PATCH 14/15] net/softnic: add flow query API X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Added pmd_flow_query() API, for flow query support. Signed-off-by: Cristian Dumitrescu Signed-off-by: Reshma Pattan --- drivers/net/softnic/rte_eth_softnic_flow.c | 55 ++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/drivers/net/softnic/rte_eth_softnic_flow.c b/drivers/net/softnic/rte_eth_softnic_flow.c index 3f8531139..da235ff7f 100644 --- a/drivers/net/softnic/rte_eth_softnic_flow.c +++ b/drivers/net/softnic/rte_eth_softnic_flow.c @@ -1639,8 +1639,63 @@ pmd_flow_destroy(struct rte_eth_dev *dev, return 0; } +static int +pmd_flow_query(struct rte_eth_dev *dev __rte_unused, + struct rte_flow *flow, + const struct rte_flow_action *action __rte_unused, + void *data, + struct rte_flow_error *error) +{ + struct rte_table_action_stats_counters stats; + struct softnic_table *table; + struct rte_flow_query_count *flow_stats = data; + int status; + + /* Check input parameters. */ + if (flow == NULL) + return rte_flow_error_set(error, + EINVAL, + RTE_FLOW_ERROR_TYPE_HANDLE, + NULL, + "Null flow"); + + if (data == NULL) + return rte_flow_error_set(error, + EINVAL, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, + "Null data"); + + table = &flow->pipeline->table[flow->table_id]; + + /* Rule stats read. */ + status = rte_table_action_stats_read(table->a, + flow->data, + &stats, + flow_stats->reset); + if (status) + return rte_flow_error_set(error, + EINVAL, + RTE_FLOW_ERROR_TYPE_UNSPECIFIED, + NULL, + "Pipeline table rule stats read failed"); + + /* Fill in flow stats. */ + flow_stats->hits_set = + (table->ap->params.stats.n_packets_enabled) ? 1 : 0; + flow_stats->bytes_set = + (table->ap->params.stats.n_bytes_enabled) ? 1 : 0; + flow_stats->hits = stats.n_packets; + flow_stats->bytes = stats.n_bytes; + + return 0; +} + const struct rte_flow_ops pmd_flow_ops = { .validate = pmd_flow_validate, .create = pmd_flow_create, .destroy = pmd_flow_destroy, + .flush = NULL, + .query = pmd_flow_query, + .isolate = NULL, };