From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from rcdn-iport-2.cisco.com (rcdn-iport-2.cisco.com [173.37.86.73]) by dpdk.org (Postfix) with ESMTP id 64D1E2B91 for ; Fri, 31 Mar 2017 04:06:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=7088; q=dns/txt; s=iport; t=1490925987; x=1492135587; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=LJF9so/gHkyQi0suCFKWzXaqEKwJ7baDyrAkNcDk/Wk=; b=VdndLOkbx8ROQwUofhP/njtCS8oRxy8Nqt9SchPLS+DAgM+bZcgpXqQN D25Gvg97WI6oGJ/94/qJEOxl2Egvabz3nCsnNo52tY87+HUrvHXW70bop G8i+SP/b5xvSxNqRDqorjqHETgdXSAzQbLKxOT+QqFtsiAd8SxCK7Q7z1 w=; X-IronPort-AV: E=Sophos;i="5.36,250,1486425600"; d="scan'208";a="229974366" Received: from alln-core-5.cisco.com ([173.36.13.138]) by rcdn-iport-2.cisco.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 31 Mar 2017 02:06:26 +0000 Received: from cisco.com (savbu-usnic-a.cisco.com [10.193.184.48]) by alln-core-5.cisco.com (8.14.5/8.14.5) with ESMTP id v2V26Q78023995; Fri, 31 Mar 2017 02:06:26 GMT Received: by cisco.com (Postfix, from userid 392789) id 1C2EA20F2002; Thu, 30 Mar 2017 19:06:26 -0700 (PDT) From: John Daley To: ferruh.yigit@intel.com, john.mcnamara@intel.com Cc: dev@dpdk.org, John Daley Date: Thu, 30 Mar 2017 19:06:19 -0700 Message-Id: <20170331020622.25498-5-johndale@cisco.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170331020622.25498-1-johndale@cisco.com> References: <20170330212838.31291-1-johndale@cisco.com> <20170331020622.25498-1-johndale@cisco.com> Subject: [dpdk-dev] [PATCH v2 4/7] net/enic: flow API for NICs with advanced filters disabled 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: , X-List-Received-Date: Fri, 31 Mar 2017 02:06:28 -0000 Flow support for 1300 series adapters with the 'Advanced Filter' mode disabled via the UCS management interface. This allows: Attributes: ingress Items: eth, ipv4, ipv6, udp, tcp, vxlan, inner eth (full hdr masking) Actions: queue and void Selectors: 'is', 'spec' and 'mask'. 'last' is not supported With advanced filters disabled, an IPv4 or IPv6 item must be specified in the pattern. Signed-off-by: John Daley Reviewed-by: Nelson Escobar --- drivers/net/enic/enic_flow.c | 135 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 133 insertions(+), 2 deletions(-) diff --git a/drivers/net/enic/enic_flow.c b/drivers/net/enic/enic_flow.c index e4c043665..6ef5daccf 100644 --- a/drivers/net/enic/enic_flow.c +++ b/drivers/net/enic/enic_flow.c @@ -101,8 +101,85 @@ static enic_copy_item_fn enic_copy_item_tcp_v2; static enic_copy_item_fn enic_copy_item_sctp_v2; static enic_copy_item_fn enic_copy_item_sctp_v2; static enic_copy_item_fn enic_copy_item_vxlan_v2; +static copy_action_fn enic_copy_action_v1; static copy_action_fn enic_copy_action_v2; +/** + * NICs have Advanced Filters capability but they are disabled. This means + * that layer 3 must be specified. + */ +static const struct enic_items enic_items_v2[] = { + [RTE_FLOW_ITEM_TYPE_ETH] = { + .copy_item = enic_copy_item_eth_v2, + .valid_start_item = 1, + .prev_items = (const enum rte_flow_item_type[]) { + RTE_FLOW_ITEM_TYPE_VXLAN, + RTE_FLOW_ITEM_TYPE_END, + }, + }, + [RTE_FLOW_ITEM_TYPE_VLAN] = { + .copy_item = enic_copy_item_vlan_v2, + .valid_start_item = 1, + .prev_items = (const enum rte_flow_item_type[]) { + RTE_FLOW_ITEM_TYPE_ETH, + RTE_FLOW_ITEM_TYPE_END, + }, + }, + [RTE_FLOW_ITEM_TYPE_IPV4] = { + .copy_item = enic_copy_item_ipv4_v2, + .valid_start_item = 1, + .prev_items = (const enum rte_flow_item_type[]) { + RTE_FLOW_ITEM_TYPE_ETH, + RTE_FLOW_ITEM_TYPE_VLAN, + RTE_FLOW_ITEM_TYPE_END, + }, + }, + [RTE_FLOW_ITEM_TYPE_IPV6] = { + .copy_item = enic_copy_item_ipv6_v2, + .valid_start_item = 1, + .prev_items = (const enum rte_flow_item_type[]) { + RTE_FLOW_ITEM_TYPE_ETH, + RTE_FLOW_ITEM_TYPE_VLAN, + RTE_FLOW_ITEM_TYPE_END, + }, + }, + [RTE_FLOW_ITEM_TYPE_UDP] = { + .copy_item = enic_copy_item_udp_v2, + .valid_start_item = 0, + .prev_items = (const enum rte_flow_item_type[]) { + RTE_FLOW_ITEM_TYPE_IPV4, + RTE_FLOW_ITEM_TYPE_IPV6, + RTE_FLOW_ITEM_TYPE_END, + }, + }, + [RTE_FLOW_ITEM_TYPE_TCP] = { + .copy_item = enic_copy_item_tcp_v2, + .valid_start_item = 0, + .prev_items = (const enum rte_flow_item_type[]) { + RTE_FLOW_ITEM_TYPE_IPV4, + RTE_FLOW_ITEM_TYPE_IPV6, + RTE_FLOW_ITEM_TYPE_END, + }, + }, + [RTE_FLOW_ITEM_TYPE_SCTP] = { + .copy_item = enic_copy_item_sctp_v2, + .valid_start_item = 0, + .prev_items = (const enum rte_flow_item_type[]) { + RTE_FLOW_ITEM_TYPE_IPV4, + RTE_FLOW_ITEM_TYPE_IPV6, + RTE_FLOW_ITEM_TYPE_END, + }, + }, + [RTE_FLOW_ITEM_TYPE_VXLAN] = { + .copy_item = enic_copy_item_vxlan_v2, + .valid_start_item = 0, + .prev_items = (const enum rte_flow_item_type[]) { + RTE_FLOW_ITEM_TYPE_UDP, + RTE_FLOW_ITEM_TYPE_END, + }, + }, +}; + /** NICs with Advanced filters enabled */ static const struct enic_items enic_items_v3[] = { [RTE_FLOW_ITEM_TYPE_ETH] = { @@ -178,11 +255,20 @@ static const struct enic_items enic_items_v3[] = { /** Filtering capabilites indexed this NICs supported filter type. */ static const struct enic_filter_cap enic_filter_cap[] = { + [FILTER_USNIC_IP] = { + .item_info = enic_items_v2, + }, [FILTER_DPDK_1] = { .item_info = enic_items_v3, }, }; +/** Supported actions for older NICs */ +static const enum rte_flow_action_type enic_supported_actions_v1[] = { + RTE_FLOW_ACTION_TYPE_QUEUE, + RTE_FLOW_ACTION_TYPE_END, +}; + /** Supported actions for newer NICs */ static const enum rte_flow_action_type enic_supported_actions_v2[] = { RTE_FLOW_ACTION_TYPE_QUEUE, @@ -193,6 +279,10 @@ static const enum rte_flow_action_type enic_supported_actions_v2[] = { /** Action capabilites indexed by NIC version information */ static const struct enic_action_cap enic_action_cap[] = { + [FILTER_ACTION_RQ_STEERING_FLAG] = { + .actions = enic_supported_actions_v1, + .copy_fn = enic_copy_action_v1, + }, [FILTER_ACTION_V2_ALL] = { .actions = enic_supported_actions_v2, .copy_fn = enic_copy_action_v2, @@ -607,7 +697,6 @@ enic_copy_filter(const struct rte_flow_item pattern[], enum rte_flow_item_type prev_item; const struct enic_items *item_info; - enic_filter->type = FILTER_DPDK_1; u8 is_first_item = 1; FLOW_TRACE(); @@ -645,6 +734,44 @@ enic_copy_filter(const struct rte_flow_item pattern[], item, "stacking error"); return -rte_errno; } + +/** + * Build the intenal version 1 NIC action structure from the provided pattern. + * The pattern is validated as the items are copied. + * + * @param actions[in] + * @param enic_action[out] + * NIC specfilc actions derived from the actions. + * @param error[out] + */ +static int +enic_copy_action_v1(const struct rte_flow_action actions[], + struct filter_action_v2 *enic_action) +{ + FLOW_TRACE(); + + for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) { + if (actions->type == RTE_FLOW_ACTION_TYPE_VOID) + continue; + + switch (actions->type) { + case RTE_FLOW_ACTION_TYPE_QUEUE: { + const struct rte_flow_action_queue *queue = + (const struct rte_flow_action_queue *) + actions->conf; + enic_action->rq_idx = + enic_rte_rq_idx_to_sop_idx(queue->index); + break; + } + default: + RTE_ASSERT(0); + break; + } + } + enic_action->type = FILTER_ACTION_RQ_STEERING; + return 0; +} + /** * Build the intenal version 2 NIC action structure from the provided pattern. * The pattern is validated as the items are copied. @@ -719,7 +846,8 @@ static const struct enic_filter_cap * enic_get_filter_cap(struct enic *enic) { /* FIXME: only support advanced filters for now */ - if (enic->flow_filter_mode != FILTER_DPDK_1) + if ((enic->flow_filter_mode != FILTER_DPDK_1) && + (enic->flow_filter_mode != FILTER_USNIC_IP)) return (const struct enic_filter_cap *)NULL; if (enic->flow_filter_mode) @@ -736,6 +864,8 @@ enic_get_action_cap(struct enic *enic) if (enic->filter_tags) ea = &enic_action_cap[FILTER_ACTION_V2_ALL]; + else + ea = &enic_action_cap[FILTER_ACTION_RQ_STEERING_FLAG]; return ea; } /** @@ -848,6 +978,7 @@ enic_flow_parse(struct rte_eth_dev *dev, NULL, "Flow API not available"); return -rte_errno; } + enic_filter->type = enic->flow_filter_mode; ret = enic_copy_filter(pattern, enic_filter_cap->item_info, enic_filter, error); return ret; -- 2.12.0