From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id EA0E4460E0; Wed, 22 Jan 2025 09:53:36 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 679D040616; Wed, 22 Jan 2025 09:53:24 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) by mails.dpdk.org (Postfix) with ESMTP id 0AED440611 for ; Wed, 22 Jan 2025 09:53:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1737536003; x=1769072003; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=D/c+BoiQ36WGPuyzW/NtiTWzFOGp7hkylYfYDwmlMag=; b=Zz9ZmqsZQoi1aTnPBhICdF4Nywm90ULxhwYDmd0FQFDsbJMR858/nfZI EO6HobbfZF0b3Kra+kK9ARTKJo86T3MdNVjQ+QlED7YhPDI4OW4keBYxY JwkqLudl8fgtzPjrX3bu5pN4JTOdkgzg7VaoNtOUdadR22qq2E0j0M3nd ZGbDaJ5HLpmqB2Ngxx0FfV4parenMzWibg4f66WGBD3xCjE5hcb6uDFq9 /4v3fhGrSctmyt5gtjagDOpzSmIo/gFRwXLdqdWDhc7h5lrl+4ohoh24z StUEs2RFv7ksS4FTnb91MKqFlpd7QOpN+0gmbUk5rkn51YxPQZ8w7jh95 A==; X-CSE-ConnectionGUID: BrSCz1XCSrKpSij6IJaiAQ== X-CSE-MsgGUID: aPp/F1XwSH6TGG+AQYBL+g== X-IronPort-AV: E=McAfee;i="6700,10204,11322"; a="37865383" X-IronPort-AV: E=Sophos;i="6.13,224,1732608000"; d="scan'208";a="37865383" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jan 2025 00:53:22 -0800 X-CSE-ConnectionGUID: yKuJUKJeT+2kLXZQiHIVzw== X-CSE-MsgGUID: Tbiy52CmSQOolqlTjEyw5Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,224,1732608000"; d="scan'208";a="112076354" Received: from unknown (HELO localhost.localdomain) ([10.239.252.253]) by fmviesa004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jan 2025 00:53:20 -0800 From: Mingjin Ye To: dev@dpdk.org Cc: Mingjin Ye , Bruce Richardson , Anatoly Burakov Subject: [PATCH 3/3] net/ice: ACL filter support for IPv4 fragment Date: Wed, 22 Jan 2025 08:23:10 +0000 Message-Id: <20250122082310.380054-4-mingjinx.ye@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250122082310.380054-1-mingjinx.ye@intel.com> References: <20250122082310.380054-1-mingjinx.ye@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Enable ACL filter on PF. Add support for FRAG_IPV4 pattern and queue action. Flow rule can be created by the following command: flow create 0 ingress group 1 pattern eth / ipv4 fragment_offset spec 0x2000 fragment_offset mask 0x3FFF / end actions queue index / end Signed-off-by: Mingjin Ye --- drivers/net/ice/ice_acl_filter.c | 61 +++++++++++++++++++++++++++++--- drivers/net/ice/ice_ethdev.c | 1 - 2 files changed, 56 insertions(+), 6 deletions(-) diff --git a/drivers/net/ice/ice_acl_filter.c b/drivers/net/ice/ice_acl_filter.c index 63a525b363..df2cc01b2d 100644 --- a/drivers/net/ice/ice_acl_filter.c +++ b/drivers/net/ice/ice_acl_filter.c @@ -30,7 +30,8 @@ #define ICE_ACL_INSET_ETH_IPV4 ( \ ICE_INSET_SMAC | ICE_INSET_DMAC | \ - ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST) + ICE_INSET_IPV4_SRC | ICE_INSET_IPV4_DST | \ + ICE_INSET_IPV4_OFFSET) #define ICE_ACL_INSET_ETH_IPV4_UDP ( \ ICE_ACL_INSET_ETH_IPV4 | \ ICE_INSET_UDP_SRC_PORT | ICE_INSET_UDP_DST_PORT) @@ -214,6 +215,7 @@ ice_acl_prof_init(struct ice_pf *pf) { struct ice_hw *hw = ICE_PF_TO_HW(pf); struct ice_flow_prof *prof_ipv4 = NULL; + struct ice_flow_prof *prof_ipv4_frag = NULL; struct ice_flow_prof *prof_ipv4_udp = NULL; struct ice_flow_prof *prof_ipv4_tcp = NULL; struct ice_flow_prof *prof_ipv4_sctp = NULL; @@ -234,6 +236,15 @@ ice_acl_prof_init(struct ice_pf *pf) if (ret) goto err_add_prof; + ice_memset(seg, 0, sizeof(*seg), ICE_NONDMA_MEM); + ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_IPV_FRAG); + acl_add_prof_prepare(hw, seg, false, 0, 0); + ret = ice_flow_add_prof(hw, ICE_BLK_ACL, ICE_FLOW_RX, + ICE_FLTR_PTYPE_FRAG_IPV4, + seg, 1, NULL, 0, &prof_ipv4_frag); + if (ret) + goto err_add_prof_ipv4_udp_frag; + ice_memset(seg, 0, sizeof(*seg), ICE_NONDMA_MEM); ICE_FLOW_SET_HDRS(seg, ICE_FLOW_SEG_HDR_UDP | ICE_FLOW_SEG_HDR_IPV4); acl_add_prof_prepare(hw, seg, true, @@ -272,6 +283,10 @@ ice_acl_prof_init(struct ice_pf *pf) if (ret) goto err_assoc_prof; + ret = ice_flow_assoc_prof(hw, ICE_BLK_ACL, prof_ipv4_frag, i); + if (ret) + goto err_assoc_prof; + ret = ice_flow_assoc_prof(hw, ICE_BLK_ACL, prof_ipv4_udp, i); if (ret) goto err_assoc_prof; @@ -293,6 +308,8 @@ ice_acl_prof_init(struct ice_pf *pf) err_add_prof_ipv4_tcp: ice_flow_rem_prof(hw, ICE_BLK_ACL, ICE_FLTR_PTYPE_NONF_IPV4_UDP); err_add_prof_ipv4_udp: + ice_flow_rem_prof(hw, ICE_BLK_ACL, ICE_FLTR_PTYPE_FRAG_IPV4); +err_add_prof_ipv4_udp_frag: ice_flow_rem_prof(hw, ICE_BLK_ACL, ICE_FLTR_PTYPE_NONF_IPV4_OTHER); err_add_prof: ice_free(hw, seg); @@ -353,6 +370,7 @@ ice_acl_set_input_set(struct ice_acl_conf *filter, struct ice_fdir_fltr *input) ICE_NONDMA_TO_NONDMA); break; + case ICE_FLTR_PTYPE_FRAG_IPV4: case ICE_FLTR_PTYPE_NONF_IPV4_OTHER: ice_memcpy(&input->ip.v4, &filter->input.ip.v4, sizeof(struct ice_fdir_v4), @@ -519,6 +537,12 @@ ice_acl_create_filter(struct ice_adapter *ad, acts[0].data.acl_act.mdid = ICE_MDID_RX_PKT_DROP; acts[0].data.acl_act.prio = 0x3; acts[0].data.acl_act.value = CPU_TO_LE16(0x1); + } else if (filter->input.dest_ctl == + ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_QINDEX) { + acts[0].type = ICE_FLOW_ACT_FWD_QUEUE; + acts[0].data.acl_act.mdid = ICE_MDID_RX_DST_Q; + acts[0].data.acl_act.prio = 0x3; + acts[0].data.acl_act.value = CPU_TO_LE16(input->q_index); } input->acl_fltr = true; @@ -531,7 +555,8 @@ ice_acl_create_filter(struct ice_adapter *ad, return ret; } - if (flow_type == ICE_FLTR_PTYPE_NONF_IPV4_OTHER) { + if (flow_type == ICE_FLTR_PTYPE_NONF_IPV4_OTHER || + flow_type == ICE_FLTR_PTYPE_FRAG_IPV4) { ret = ice_acl_hw_set_conf(pf, input, acts, rule, ICE_FLTR_PTYPE_NONF_IPV4_UDP, 1); if (ret) @@ -576,6 +601,7 @@ ice_acl_destroy_filter(struct ice_adapter *ad, int ret = 0; switch (rule->flow_type) { + case ICE_FLTR_PTYPE_FRAG_IPV4: case ICE_FLTR_PTYPE_NONF_IPV4_OTHER: for (i = 0; i < 4; i++) { entry_id = rule->entry_id[i]; @@ -617,6 +643,8 @@ ice_acl_parse_action(__rte_unused struct ice_adapter *ad, struct rte_flow_error *error, struct ice_acl_conf *filter) { + struct ice_pf *pf = &ad->pf; + const struct rte_flow_action_queue *act_q; uint32_t dest_num = 0; for (; actions->type != RTE_FLOW_ACTION_TYPE_END; actions++) { @@ -629,6 +657,22 @@ ice_acl_parse_action(__rte_unused struct ice_adapter *ad, filter->input.dest_ctl = ICE_FLTR_PRGM_DESC_DEST_DROP_PKT; break; + case RTE_FLOW_ACTION_TYPE_QUEUE: + dest_num++; + + act_q = actions->conf; + filter->input.q_index = act_q->index; + if (filter->input.q_index >= + pf->dev_data->nb_rx_queues) { + rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, + actions, + "Invalid queue for FDIR."); + return -rte_errno; + } + filter->input.dest_ctl = + ICE_FLTR_PRGM_DESC_DEST_DIRECT_PKT_QINDEX; + break; default: rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ACTION, actions, @@ -713,12 +757,12 @@ ice_acl_parse_pattern(__rte_unused struct ice_adapter *ad, ipv4_spec = item->spec; ipv4_mask = item->mask; + flow_type = ICE_FLTR_PTYPE_NONF_IPV4_OTHER; if (ipv4_spec && ipv4_mask) { /* Check IPv4 mask and update input set */ if (ipv4_mask->hdr.version_ihl || ipv4_mask->hdr.total_length || ipv4_mask->hdr.packet_id || - ipv4_mask->hdr.fragment_offset || ipv4_mask->hdr.hdr_checksum) { rte_flow_error_set(error, EINVAL, RTE_FLOW_ERROR_TYPE_ITEM, @@ -753,9 +797,16 @@ ice_acl_parse_pattern(__rte_unused struct ice_adapter *ad, input_set |= ICE_INSET_IPV4_DST; } - } - flow_type = ICE_FLTR_PTYPE_NONF_IPV4_OTHER; + if (ipv4_mask->hdr.fragment_offset) { + filter->input.ip.v4.fragment_offset = + ipv4_spec->hdr.fragment_offset; + filter->input.mask.v4.fragment_offset = + ipv4_mask->hdr.fragment_offset; + flow_type = ICE_FLTR_PTYPE_FRAG_IPV4; + input_set |= ICE_INSET_IPV4_OFFSET; + } + } break; case RTE_FLOW_ITEM_TYPE_TCP: tcp_spec = item->spec; diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c index 93a6308a86..a57bcaf36e 100644 --- a/drivers/net/ice/ice_ethdev.c +++ b/drivers/net/ice/ice_ethdev.c @@ -2684,7 +2684,6 @@ ice_dev_init(struct rte_eth_dev *dev) } if (!ad->is_safe_mode) { - ad->disabled_engine_mask |= BIT(ICE_FLOW_ENGINE_ACL); ret = ice_flow_init(ad); if (ret) { PMD_INIT_LOG(ERR, "Failed to initialize flow"); -- 2.25.1