From patchwork Fri Aug 12 17:04:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Wang X-Patchwork-Id: 114862 X-Patchwork-Delegate: qi.z.zhang@intel.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A43F0A0543; Fri, 12 Aug 2022 11:06:58 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D0A2742C01; Fri, 12 Aug 2022 11:06:52 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id 0B47642BC0 for ; Fri, 12 Aug 2022 11:06:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1660295211; x=1691831211; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gVoyauOnQLCXr0vfeC8DaAoxRZdXUuz8GSxEikAtako=; b=Jswz1vJ0ryazPdxwNNUAKwJxysrF8SRsnY5mshvVjvx5SrQYJup+kgD1 xuKeIHPkVJdZS30CVSWQHSQjdV4nNxtzQgKifLWN0w2nuWYhSA36Jbj6P nWXSYSW1oIA/X7BAgpqPGbw+dSk2FEPB8HhZ6m6McyfCKRXDdTGywf0pv 5an4IwguDE0gB9PnpnIYsw3a19RyinUquFuchRBd1t8zDoacY5oBgAC6s XBEWw3XPEvnNhKGkObpL5WF+zLxpyObRUYhxuYVKnxE1QSkkEjFERCfeT dn+zA8rSJnDOeN5uZ9BpAq8xo5dvwblA7XdDKBQmtlESP4ptjs+x8S23c w==; X-IronPort-AV: E=McAfee;i="6400,9594,10436"; a="317526435" X-IronPort-AV: E=Sophos;i="5.93,231,1654585200"; d="scan'208";a="317526435" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Aug 2022 02:06:50 -0700 X-IronPort-AV: E=Sophos;i="5.93,231,1654585200"; d="scan'208";a="665752672" Received: from intel-cd-odc-gavin.cd.intel.com ([10.240.178.187]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Aug 2022 02:06:48 -0700 From: Jie Wang To: dev@dpdk.org Cc: qiming.yang@intel.com, qi.z.zhang@intel.com, jingjing.wu@intel.com, beilei.xing@intel.com, stevex.yang@intel.com, Jie Wang Subject: [PATCH v2 2/5] net/iavf: add flow subscription to AVF Date: Sat, 13 Aug 2022 01:04:44 +0800 Message-Id: <20220812170447.186992-3-jie1x.wang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220812170447.186992-1-jie1x.wang@intel.com> References: <20220809062122.1203281-1-jie1x.wang@intel.com> <20220812170447.186992-1-jie1x.wang@intel.com> MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Add the skeletal code of flow subscription to AVF driver. Signed-off-by: Jie Wang --- doc/guides/rel_notes/release_22_11.rst | 4 + drivers/net/iavf/iavf_fsub.c | 112 +++++++++++++++++++++++++ drivers/net/iavf/iavf_generic_flow.c | 17 +++- drivers/net/iavf/iavf_generic_flow.h | 1 + drivers/net/iavf/iavf_vchnl.c | 1 + drivers/net/iavf/meson.build | 1 + 6 files changed, 135 insertions(+), 1 deletion(-) create mode 100644 drivers/net/iavf/iavf_fsub.c diff --git a/doc/guides/rel_notes/release_22_11.rst b/doc/guides/rel_notes/release_22_11.rst index 8c021cf050..bb77a03e24 100644 --- a/doc/guides/rel_notes/release_22_11.rst +++ b/doc/guides/rel_notes/release_22_11.rst @@ -55,6 +55,10 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Updated Intel iavf driver.** + + * Added flow subscription support. + Removed Items ------------- diff --git a/drivers/net/iavf/iavf_fsub.c b/drivers/net/iavf/iavf_fsub.c new file mode 100644 index 0000000000..17f9bb2976 --- /dev/null +++ b/drivers/net/iavf/iavf_fsub.c @@ -0,0 +1,112 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2022 Intel Corporation + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "iavf_generic_flow.h" + + +static struct iavf_flow_parser iavf_fsub_parser; + +static struct iavf_pattern_match_item iavf_fsub_pattern_list[] = {}; + +static int +iavf_fsub_create(__rte_unused struct iavf_adapter *ad, + __rte_unused struct rte_flow *flow, + __rte_unused void *meta, + __rte_unused struct rte_flow_error *error) +{ + return -rte_errno; +} + +static int +iavf_fsub_destroy(__rte_unused struct iavf_adapter *ad, + __rte_unused struct rte_flow *flow, + __rte_unused struct rte_flow_error *error) +{ + return -rte_errno; +} + +static int +iavf_fsub_validation(__rte_unused struct iavf_adapter *ad, + __rte_unused struct rte_flow *flow, + __rte_unused void *meta, + __rte_unused struct rte_flow_error *error) +{ + return -rte_errno; +}; + +static int +iavf_fsub_parse(__rte_unused struct iavf_adapter *ad, + __rte_unused struct iavf_pattern_match_item *array, + __rte_unused uint32_t array_len, + __rte_unused const struct rte_flow_item pattern[], + __rte_unused const struct rte_flow_action actions[], + __rte_unused void **meta, + __rte_unused struct rte_flow_error *error) +{ + return -rte_errno; +} + +static int +iavf_fsub_init(struct iavf_adapter *ad) +{ + struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(ad); + struct iavf_flow_parser *parser; + + if (!vf->vf_res) + return -EINVAL; + + if (vf->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_FSUB_PF) + parser = &iavf_fsub_parser; + else + return -ENOTSUP; + + return iavf_register_parser(parser, ad); +} + +static void +iavf_fsub_uninit(struct iavf_adapter *ad) +{ + iavf_unregister_parser(&iavf_fsub_parser, ad); +} + +static struct +iavf_flow_engine iavf_fsub_engine = { + .init = iavf_fsub_init, + .uninit = iavf_fsub_uninit, + .create = iavf_fsub_create, + .destroy = iavf_fsub_destroy, + .validation = iavf_fsub_validation, + .type = IAVF_FLOW_ENGINE_FSUB, +}; + +static struct +iavf_flow_parser iavf_fsub_parser = { + .engine = &iavf_fsub_engine, + .array = iavf_fsub_pattern_list, + .array_len = RTE_DIM(iavf_fsub_pattern_list), + .parse_pattern_action = iavf_fsub_parse, + .stage = IAVF_FLOW_STAGE_DISTRIBUTOR, +}; + +RTE_INIT(iavf_fsub_engine_init) +{ + iavf_register_flow_engine(&iavf_fsub_engine); +} diff --git a/drivers/net/iavf/iavf_generic_flow.c b/drivers/net/iavf/iavf_generic_flow.c index e1a611e319..b04614ba6e 100644 --- a/drivers/net/iavf/iavf_generic_flow.c +++ b/drivers/net/iavf/iavf_generic_flow.c @@ -1866,6 +1866,8 @@ iavf_register_parser(struct iavf_flow_parser *parser, { struct iavf_parser_list *list = NULL; struct iavf_flow_parser_node *parser_node; + struct iavf_flow_parser_node *existing_node; + void *temp; struct iavf_info *vf = IAVF_DEV_PRIVATE_TO_VF(ad); parser_node = rte_zmalloc("iavf_parser", sizeof(*parser_node), 0); @@ -1880,14 +1882,26 @@ iavf_register_parser(struct iavf_flow_parser *parser, TAILQ_INSERT_TAIL(list, parser_node, node); } else if (parser->engine->type == IAVF_FLOW_ENGINE_FDIR) { list = &vf->dist_parser_list; + RTE_TAILQ_FOREACH_SAFE(existing_node, list, node, temp) { + if (existing_node->parser->engine->type == + IAVF_FLOW_ENGINE_FSUB) { + TAILQ_INSERT_AFTER(list, existing_node, + parser_node, node); + goto DONE; + } + } TAILQ_INSERT_HEAD(list, parser_node, node); } else if (parser->engine->type == IAVF_FLOW_ENGINE_IPSEC_CRYPTO) { list = &vf->ipsec_crypto_parser_list; TAILQ_INSERT_HEAD(list, parser_node, node); + } else if (parser->engine->type == IAVF_FLOW_ENGINE_FSUB) { + list = &vf->dist_parser_list; + TAILQ_INSERT_HEAD(list, parser_node, node); } else { return -EINVAL; } +DONE: return 0; } @@ -1902,7 +1916,8 @@ iavf_unregister_parser(struct iavf_flow_parser *parser, if (parser->engine->type == IAVF_FLOW_ENGINE_HASH) list = &vf->rss_parser_list; - else if (parser->engine->type == IAVF_FLOW_ENGINE_FDIR) + else if ((parser->engine->type == IAVF_FLOW_ENGINE_FDIR) || + (parser->engine->type == IAVF_FLOW_ENGINE_FSUB)) list = &vf->dist_parser_list; if (list == NULL) diff --git a/drivers/net/iavf/iavf_generic_flow.h b/drivers/net/iavf/iavf_generic_flow.h index 52eb1caf29..448facffa5 100644 --- a/drivers/net/iavf/iavf_generic_flow.h +++ b/drivers/net/iavf/iavf_generic_flow.h @@ -480,6 +480,7 @@ enum iavf_flow_engine_type { IAVF_FLOW_ENGINE_IPSEC_CRYPTO, IAVF_FLOW_ENGINE_FDIR, IAVF_FLOW_ENGINE_HASH, + IAVF_FLOW_ENGINE_FSUB, IAVF_FLOW_ENGINE_MAX, }; diff --git a/drivers/net/iavf/iavf_vchnl.c b/drivers/net/iavf/iavf_vchnl.c index 21bd1e2193..6d84add423 100644 --- a/drivers/net/iavf/iavf_vchnl.c +++ b/drivers/net/iavf/iavf_vchnl.c @@ -502,6 +502,7 @@ iavf_get_vf_resource(struct iavf_adapter *adapter) VIRTCHNL_VF_OFFLOAD_RX_FLEX_DESC | VIRTCHNL_VF_OFFLOAD_FDIR_PF | VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF | + VIRTCHNL_VF_OFFLOAD_FSUB_PF | VIRTCHNL_VF_OFFLOAD_REQ_QUEUES | VIRTCHNL_VF_OFFLOAD_CRC | VIRTCHNL_VF_OFFLOAD_VLAN_V2 | diff --git a/drivers/net/iavf/meson.build b/drivers/net/iavf/meson.build index 2da37de662..6df771f917 100644 --- a/drivers/net/iavf/meson.build +++ b/drivers/net/iavf/meson.build @@ -16,6 +16,7 @@ sources = files( 'iavf_hash.c', 'iavf_tm.c', 'iavf_ipsec_crypto.c', + 'iavf_fsub.c', ) if arch_subdir == 'x86'