From patchwork Sat Mar 2 10:42:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hyong Youb Kim (hyonkim)" X-Patchwork-Id: 50748 X-Patchwork-Delegate: ferruh.yigit@amd.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 8BF4C44BE; Sat, 2 Mar 2019 11:43:30 +0100 (CET) Received: from rcdn-iport-2.cisco.com (rcdn-iport-2.cisco.com [173.37.86.73]) by dpdk.org (Postfix) with ESMTP id 7A28A378E; Sat, 2 Mar 2019 11:43:28 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cisco.com; i=@cisco.com; l=6263; q=dns/txt; s=iport; t=1551523408; x=1552733008; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=ZPsKdvLdQAH0HwTkrCbDfh/BDdqYIfPt3+eD8Mf5Jzk=; b=BEEMCfmwMg/aZ56ViEQ1tnItfwbpUPibt19r4/ywQo63a/x7VpiCGjPd alHOV/K6P2lCkq1ohhcT8dSsYR7hZvPPiUI/60WtZwZ2HXYEvJdSIiswr B1NrGjeCzHb8LMYCObadOIKknudBFzCtPZfZ9+WJmr3tW7CPvR8U7BuJ2 A=; X-IronPort-AV: E=Sophos;i="5.58,431,1544486400"; d="scan'208";a="530643007" Received: from alln-core-11.cisco.com ([173.36.13.133]) by rcdn-iport-2.cisco.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Mar 2019 10:43:27 +0000 Received: from cisco.com (savbu-usnic-a.cisco.com [10.193.184.48]) by alln-core-11.cisco.com (8.15.2/8.15.2) with ESMTP id x22AhRDk002222; Sat, 2 Mar 2019 10:43:27 GMT Received: by cisco.com (Postfix, from userid 508933) id 215A720F2001; Sat, 2 Mar 2019 02:43:27 -0800 (PST) From: Hyong Youb Kim To: Ferruh Yigit Cc: dev@dpdk.org, John Daley , Hyong Youb Kim , stable@dpdk.org Date: Sat, 2 Mar 2019 02:42:40 -0800 Message-Id: <20190302104251.32565-3-hyonkim@cisco.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20190302104251.32565-1-hyonkim@cisco.com> References: <20190302104251.32565-1-hyonkim@cisco.com> X-Outbound-SMTP-Client: 10.193.184.48, savbu-usnic-a.cisco.com X-Outbound-Node: alln-core-11.cisco.com Subject: [dpdk-dev] [PATCH v2 02/13] net/enic: fix flow director SCTP matching 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" The firmware filter API does not have flags indicating "match SCTP packet". Instead, the driver needs to explicitly add an IP match and set the protocol number (132 for SCTP) in the IP header. The existing code (copy_fltr_v2) has two bugs. 1. It sets the protocol number (132) in the match value, but not the mask. The mask remains 0, so the match becomes a wildcard match. The NIC ends up matching all protocol numbers (i.e. thinks non-SCTP packets are SCTP). 2. It modifies the input argument (rte_eth_fdir_input). The driver tracks filters using rte_hash_{add,del}_key(input). So, addding (RTE_ETH_FILTER_ADD) and deleting (RTE_ETH_FILTER_DELETE) must use the same input argument for the same filter. But, overwriting the protocol number while adding the filter breaks this assumption, and causes delete operation to fail. So, set the mask as well as protocol value. Do not modify the input argument, and use const in function signatures to make the intention clear. Also move a couple function declarations to enic_clsf.c from enic.h as they are strictly local. Fixes: dfbd6a9cb504 ("net/enic: extend flow director support for 1300 series") Cc: stable@dpdk.org Signed-off-by: Hyong Youb Kim Reviewed-by: John Daley --- drivers/net/enic/enic.h | 8 ++------ drivers/net/enic/enic_clsf.c | 38 ++++++++++++++++++++++++++------------ 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/drivers/net/enic/enic.h b/drivers/net/enic/enic.h index 6c497e9a2..fa4d5590e 100644 --- a/drivers/net/enic/enic.h +++ b/drivers/net/enic/enic.h @@ -76,8 +76,8 @@ struct enic_fdir { u32 modes; u32 types_mask; void (*copy_fltr_fn)(struct filter_v2 *filt, - struct rte_eth_fdir_input *input, - struct rte_eth_fdir_masks *masks); + const struct rte_eth_fdir_input *input, + const struct rte_eth_fdir_masks *masks); }; struct enic_soft_stats { @@ -342,9 +342,5 @@ int enic_link_update(struct enic *enic); bool enic_use_vector_rx_handler(struct enic *enic); void enic_fdir_info(struct enic *enic); void enic_fdir_info_get(struct enic *enic, struct rte_eth_fdir_info *stats); -void copy_fltr_v1(struct filter_v2 *fltr, struct rte_eth_fdir_input *input, - struct rte_eth_fdir_masks *masks); -void copy_fltr_v2(struct filter_v2 *fltr, struct rte_eth_fdir_input *input, - struct rte_eth_fdir_masks *masks); extern const struct rte_flow_ops enic_flow_ops; #endif /* _ENIC_H_ */ diff --git a/drivers/net/enic/enic_clsf.c b/drivers/net/enic/enic_clsf.c index 9e9e548c2..48c8e6264 100644 --- a/drivers/net/enic/enic_clsf.c +++ b/drivers/net/enic/enic_clsf.c @@ -36,6 +36,13 @@ #define ENICPMD_CLSF_HASH_ENTRIES ENICPMD_FDIR_MAX +static void copy_fltr_v1(struct filter_v2 *fltr, + const struct rte_eth_fdir_input *input, + const struct rte_eth_fdir_masks *masks); +static void copy_fltr_v2(struct filter_v2 *fltr, + const struct rte_eth_fdir_input *input, + const struct rte_eth_fdir_masks *masks); + void enic_fdir_stats_get(struct enic *enic, struct rte_eth_fdir_stats *stats) { *stats = enic->fdir.stats; @@ -79,9 +86,9 @@ enic_set_layer(struct filter_generic_1 *gp, unsigned int flag, /* Copy Flow Director filter to a VIC ipv4 filter (for Cisco VICs * without advanced filter support. */ -void -copy_fltr_v1(struct filter_v2 *fltr, struct rte_eth_fdir_input *input, - __rte_unused struct rte_eth_fdir_masks *masks) +static void +copy_fltr_v1(struct filter_v2 *fltr, const struct rte_eth_fdir_input *input, + __rte_unused const struct rte_eth_fdir_masks *masks) { fltr->type = FILTER_IPV4_5TUPLE; fltr->u.ipv4.src_addr = rte_be_to_cpu_32( @@ -104,9 +111,9 @@ copy_fltr_v1(struct filter_v2 *fltr, struct rte_eth_fdir_input *input, /* Copy Flow Director filter to a VIC generic filter (requires advanced * filter support. */ -void -copy_fltr_v2(struct filter_v2 *fltr, struct rte_eth_fdir_input *input, - struct rte_eth_fdir_masks *masks) +static void +copy_fltr_v2(struct filter_v2 *fltr, const struct rte_eth_fdir_input *input, + const struct rte_eth_fdir_masks *masks) { struct filter_generic_1 *gp = &fltr->u.generic_1; @@ -163,9 +170,11 @@ copy_fltr_v2(struct filter_v2 *fltr, struct rte_eth_fdir_input *input, sctp_val.tag = input->flow.sctp4_flow.verify_tag; } - /* v4 proto should be 132, override ip4_flow.proto */ - input->flow.ip4_flow.proto = 132; - + /* + * Unlike UDP/TCP (FILTER_GENERIC_1_{UDP,TCP}), the firmware + * has no "packet is SCTP" flag. Use flag=0 (generic L4) and + * manually set proto_id=sctp below. + */ enic_set_layer(gp, 0, FILTER_GENERIC_1_L4, &sctp_mask, &sctp_val, sizeof(struct sctp_hdr)); } @@ -189,6 +198,10 @@ copy_fltr_v2(struct filter_v2 *fltr, struct rte_eth_fdir_input *input, if (input->flow.ip4_flow.proto) { ip4_mask.next_proto_id = masks->ipv4_mask.proto; ip4_val.next_proto_id = input->flow.ip4_flow.proto; + } else if (input->flow_type == RTE_ETH_FLOW_NONFRAG_IPV4_SCTP) { + /* Explicitly match the SCTP protocol number */ + ip4_mask.next_proto_id = 0xff; + ip4_val.next_proto_id = IPPROTO_SCTP; } if (input->flow.ip4_flow.src_ip) { ip4_mask.src_addr = masks->ipv4_mask.src_ip; @@ -251,9 +264,6 @@ copy_fltr_v2(struct filter_v2 *fltr, struct rte_eth_fdir_input *input, sctp_val.tag = input->flow.sctp6_flow.verify_tag; } - /* v4 proto should be 132, override ipv6_flow.proto */ - input->flow.ipv6_flow.proto = 132; - enic_set_layer(gp, 0, FILTER_GENERIC_1_L4, &sctp_mask, &sctp_val, sizeof(struct sctp_hdr)); } @@ -269,6 +279,10 @@ copy_fltr_v2(struct filter_v2 *fltr, struct rte_eth_fdir_input *input, if (input->flow.ipv6_flow.proto) { ipv6_mask.proto = masks->ipv6_mask.proto; ipv6_val.proto = input->flow.ipv6_flow.proto; + } else if (input->flow_type == RTE_ETH_FLOW_NONFRAG_IPV6_SCTP) { + /* See comments for IPv4 SCTP above. */ + ipv6_mask.proto = 0xff; + ipv6_val.proto = IPPROTO_SCTP; } memcpy(ipv6_mask.src_addr, masks->ipv6_mask.src_ip, sizeof(ipv6_mask.src_addr));