From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id E59D3A2E1B for ; Wed, 4 Sep 2019 13:35:59 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 753441EDB1; Wed, 4 Sep 2019 13:35:47 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id 3EA351EDA1 for ; Wed, 4 Sep 2019 13:35:45 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x84BZQmu031225; Wed, 4 Sep 2019 04:35:44 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0818; bh=uOloCT96PqfjcB27VVTUuOYP1lfJ0z96FA0H1oCx6uM=; b=nCJlxN4qdsIcSk94cXw8mrA739AUwGUWykrn107HbFYoMZyeA7rUhFVlYkfjInniBu2m WB3IvUGp+EAuvTbnrvuCC36KhAohOsZ3OoJDERPhVlzNrFWtdRzXSfSM99PQ/Fn1ghQu eREy6JIBDV5KCQeEoFFrkc+oyAOAV5UkvLmyCM9ubRYOitqaTfDu6X3YD3DevAKcN+/h X9Hxf+3H2lwEK6sIZLm5HkqDH+By4PQ+QMRsRieIzYdUFXdb7JH2YlaA9uHzLONHNfm+ YizatrhXcHmy6tFxpYZ8BPFtD8DQ97s7CkgF2BUTWPfaTrOrdVQHCVUi6YOXbPqO8XFC 3w== Received: from sc-exch02.marvell.com ([199.233.58.182]) by mx0a-0016f401.pphosted.com with ESMTP id 2uqp8pefkp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 04 Sep 2019 04:35:44 -0700 Received: from SC-EXCH03.marvell.com (10.93.176.83) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Wed, 4 Sep 2019 04:35:42 -0700 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Wed, 4 Sep 2019 04:35:42 -0700 Received: from dut1171.mv.qlogic.com (unknown [10.112.88.18]) by maili.marvell.com (Postfix) with ESMTP id 817C83F7040; Wed, 4 Sep 2019 04:35:41 -0700 (PDT) Received: from dut1171.mv.qlogic.com (localhost [127.0.0.1]) by dut1171.mv.qlogic.com (8.14.7/8.14.7) with ESMTP id x84BZfqU002296; Wed, 4 Sep 2019 04:35:41 -0700 Received: (from root@localhost) by dut1171.mv.qlogic.com (8.14.7/8.14.7/Submit) id x84BZfih002295; Wed, 4 Sep 2019 04:35:41 -0700 From: Shahed Shaikh To: CC: , , Date: Wed, 4 Sep 2019 04:30:46 -0700 Message-ID: <20190904113046.2213-2-shshaikh@marvell.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20190904113046.2213-1-shshaikh@marvell.com> References: <20190904113046.2213-1-shshaikh@marvell.com> MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.70,1.0.8 definitions=2019-09-04_03:2019-09-03,2019-09-04 signatures=0 Subject: [dpdk-dev] [PATCH 2/2] net/qede: implement rte_flow drop action 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" Add support to configure drop action in RTE_FLOW infrastructure. Also, add statistics counter for dropped packets due to this filter action "rx_gft_filter_drop" Signed-off-by: Shahed Shaikh --- drivers/net/qede/base/ecore_dev_api.h | 1 + drivers/net/qede/base/ecore_l2.c | 50 +++++++++++++++------------ drivers/net/qede/base/ecore_l2_api.h | 39 ++++++++++++++------- drivers/net/qede/qede_ethdev.c | 2 ++ drivers/net/qede/qede_ethdev.h | 1 + drivers/net/qede/qede_filter.c | 22 ++++++++---- 6 files changed, 75 insertions(+), 40 deletions(-) diff --git a/drivers/net/qede/base/ecore_dev_api.h b/drivers/net/qede/base/ecore_dev_api.h index 730806321..a99888097 100644 --- a/drivers/net/qede/base/ecore_dev_api.h +++ b/drivers/net/qede/base/ecore_dev_api.h @@ -334,6 +334,7 @@ struct ecore_eth_stats_common { u64 rx_bcast_pkts; u64 mftag_filter_discards; u64 mac_filter_discards; + u64 gft_filter_drop; u64 tx_ucast_bytes; u64 tx_mcast_bytes; u64 tx_bcast_bytes; diff --git a/drivers/net/qede/base/ecore_l2.c b/drivers/net/qede/base/ecore_l2.c index 8b9817eb2..5dcdc84fc 100644 --- a/drivers/net/qede/base/ecore_l2.c +++ b/drivers/net/qede/base/ecore_l2.c @@ -1782,6 +1782,8 @@ static void __ecore_get_vport_tstats(struct ecore_hwfn *p_hwfn, HILO_64_REGPAIR(tstats.mftag_filter_discard); p_stats->common.mac_filter_discards += HILO_64_REGPAIR(tstats.eth_mac_filter_discard); + p_stats->common.gft_filter_drop += + HILO_64_REGPAIR(tstats.eth_gft_drop_pkt); } static void __ecore_get_vport_ustats_addrlen(struct ecore_hwfn *p_hwfn, @@ -2140,9 +2142,7 @@ void ecore_arfs_mode_configure(struct ecore_hwfn *p_hwfn, enum _ecore_status_t ecore_configure_rfs_ntuple_filter(struct ecore_hwfn *p_hwfn, struct ecore_spq_comp_cb *p_cb, - dma_addr_t p_addr, u16 length, - u16 qid, u8 vport_id, - bool b_is_add) + struct ecore_ntuple_filter_params *p_params) { struct rx_update_gft_filter_data *p_ramrod = OSAL_NULL; struct ecore_spq_entry *p_ent = OSAL_NULL; @@ -2151,14 +2151,6 @@ ecore_configure_rfs_ntuple_filter(struct ecore_hwfn *p_hwfn, u8 abs_vport_id = 0; enum _ecore_status_t rc = ECORE_NOTIMPL; - rc = ecore_fw_vport(p_hwfn, vport_id, &abs_vport_id); - if (rc != ECORE_SUCCESS) - return rc; - - rc = ecore_fw_l2_queue(p_hwfn, qid, &abs_rx_q_id); - if (rc != ECORE_SUCCESS) - return rc; - /* Get SPQ entry */ OSAL_MEMSET(&init_data, 0, sizeof(init_data)); init_data.cid = ecore_spq_get_cid(p_hwfn); @@ -2180,27 +2172,41 @@ ecore_configure_rfs_ntuple_filter(struct ecore_hwfn *p_hwfn, p_ramrod = &p_ent->ramrod.rx_update_gft; - DMA_REGPAIR_LE(p_ramrod->pkt_hdr_addr, p_addr); - p_ramrod->pkt_hdr_length = OSAL_CPU_TO_LE16(length); + DMA_REGPAIR_LE(p_ramrod->pkt_hdr_addr, p_params->addr); + p_ramrod->pkt_hdr_length = OSAL_CPU_TO_LE16(p_params->length); - p_ramrod->action_icid_valid = 0; - p_ramrod->action_icid = 0; + if (p_params->b_is_drop) { + p_ramrod->vport_id = OSAL_CPU_TO_LE16(ETH_GFT_TRASHCAN_VPORT); + } else { + rc = ecore_fw_vport(p_hwfn, p_params->vport_id, + &abs_vport_id); + if (rc) + return rc; + + if (p_params->qid != ECORE_RFS_NTUPLE_QID_RSS) { + rc = ecore_fw_l2_queue(p_hwfn, p_params->qid, + &abs_rx_q_id); + if (rc) + return rc; - p_ramrod->rx_qid_valid = 1; - p_ramrod->rx_qid = OSAL_CPU_TO_LE16(abs_rx_q_id); + p_ramrod->rx_qid_valid = 1; + p_ramrod->rx_qid = OSAL_CPU_TO_LE16(abs_rx_q_id); + } + + p_ramrod->vport_id = OSAL_CPU_TO_LE16((u16)abs_vport_id); + } p_ramrod->flow_id_valid = 0; p_ramrod->flow_id = 0; - p_ramrod->vport_id = OSAL_CPU_TO_LE16((u16)abs_vport_id); - p_ramrod->filter_action = b_is_add ? GFT_ADD_FILTER - : GFT_DELETE_FILTER; + p_ramrod->filter_action = p_params->b_is_add ? GFT_ADD_FILTER + : GFT_DELETE_FILTER; DP_VERBOSE(p_hwfn, ECORE_MSG_SP, "V[%0x], Q[%04x] - %s filter from 0x%lx [length %04xb]\n", abs_vport_id, abs_rx_q_id, - b_is_add ? "Adding" : "Removing", - (unsigned long)p_addr, length); + p_params->b_is_add ? "Adding" : "Removing", + (unsigned long)p_params->addr, p_params->length); return ecore_spq_post(p_hwfn, p_ent, OSAL_NULL); } diff --git a/drivers/net/qede/base/ecore_l2_api.h b/drivers/net/qede/base/ecore_l2_api.h index 004fb61ba..acde81fad 100644 --- a/drivers/net/qede/base/ecore_l2_api.h +++ b/drivers/net/qede/base/ecore_l2_api.h @@ -448,6 +448,31 @@ void ecore_arfs_mode_configure(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt, struct ecore_arfs_config_params *p_cfg_params); +struct ecore_ntuple_filter_params { + /* Physically mapped address containing header of buffer to be used + * as filter. + */ + dma_addr_t addr; + + /* Length of header in bytes */ + u16 length; + + /* Relative queue-id to receive classified packet */ + #define ECORE_RFS_NTUPLE_QID_RSS ((u16)-1) + u16 qid; + + /* Identifier can either be according to vport-id or vfid */ + bool b_is_vf; + u8 vport_id; + u8 vf_id; + + /* true if this filter is to be added. Else to be removed */ + bool b_is_add; + + /* If packet needs to be dropped */ + bool b_is_drop; +}; + /** * @brief - ecore_configure_rfs_ntuple_filter * @@ -457,22 +482,12 @@ void ecore_arfs_mode_configure(struct ecore_hwfn *p_hwfn, * @params p_cb Used for ECORE_SPQ_MODE_CB,where client would initialize * it with cookie and callback function address, if not * using this mode then client must pass NULL. - * @params p_addr p_addr is an actual packet header that needs to be - * filter. It has to mapped with IO to read prior to - * calling this, [contains 4 tuples- src ip, dest ip, - * src port, dest port]. - * @params length length of p_addr header up to past the transport header. - * @params qid receive packet will be directed to this queue. - * @params vport_id - * @params b_is_add flag to add or remove filter. - * + * @params p_params */ enum _ecore_status_t ecore_configure_rfs_ntuple_filter(struct ecore_hwfn *p_hwfn, struct ecore_spq_comp_cb *p_cb, - dma_addr_t p_addr, u16 length, - u16 qid, u8 vport_id, - bool b_is_add); + struct ecore_ntuple_filter_params *p_params); /** * @brief - ecore_update_eth_rss_ind_table_entry diff --git a/drivers/net/qede/qede_ethdev.c b/drivers/net/qede/qede_ethdev.c index a033807e7..0e5d39c9a 100644 --- a/drivers/net/qede/qede_ethdev.c +++ b/drivers/net/qede/qede_ethdev.c @@ -125,6 +125,8 @@ static const struct rte_qede_xstats_name_off qede_xstats_strings[] = { offsetof(struct ecore_eth_stats_common, mftag_filter_discards)}, {"rx_mac_filter_discards", offsetof(struct ecore_eth_stats_common, mac_filter_discards)}, + {"rx_gft_filter_drop", + offsetof(struct ecore_eth_stats_common, gft_filter_drop)}, {"rx_hw_buffer_truncates", offsetof(struct ecore_eth_stats_common, brb_truncates)}, {"rx_hw_buffer_discards", diff --git a/drivers/net/qede/qede_ethdev.h b/drivers/net/qede/qede_ethdev.h index 5549d0bf3..b5f93e9fa 100644 --- a/drivers/net/qede/qede_ethdev.h +++ b/drivers/net/qede/qede_ethdev.h @@ -179,6 +179,7 @@ struct qede_arfs_entry { uint32_t soft_id; /* unused for now */ uint16_t pkt_len; /* actual packet length to match */ uint16_t rx_queue; /* queue to be steered to */ + bool is_drop; /* drop action */ const struct rte_memzone *mz; /* mz used to hold L2 frame */ struct qede_arfs_tuple tuple; SLIST_ENTRY(qede_arfs_entry) list; diff --git a/drivers/net/qede/qede_filter.c b/drivers/net/qede/qede_filter.c index 81509f04b..b7ad59ad6 100644 --- a/drivers/net/qede/qede_filter.c +++ b/drivers/net/qede/qede_filter.c @@ -272,6 +272,7 @@ qede_config_arfs_filter(struct rte_eth_dev *eth_dev, { struct qede_dev *qdev = QEDE_INIT_QDEV(eth_dev); struct ecore_dev *edev = QEDE_INIT_EDEV(qdev); + struct ecore_ntuple_filter_params params; char mz_name[RTE_MEMZONE_NAMESIZE] = {0}; struct qede_arfs_entry *tmp = NULL; const struct rte_memzone *mz; @@ -344,12 +345,18 @@ qede_config_arfs_filter(struct rte_eth_dev *eth_dev, ecore_arfs_mode_configure(p_hwfn, p_hwfn->p_arfs_ptt, &qdev->arfs_info.arfs); } + + memset(¶ms, 0, sizeof(params)); + params.addr = (dma_addr_t)mz->iova; + params.length = pkt_len; + params.qid = arfs->rx_queue; + params.vport_id = 0; + params.b_is_add = add; + params.b_is_drop = arfs->is_drop; + /* configure filter with ECORE_SPQ_MODE_EBLOCK */ rc = ecore_configure_rfs_ntuple_filter(p_hwfn, NULL, - (dma_addr_t)mz->iova, - pkt_len, - arfs->rx_queue, - 0, add); + ¶ms); if (rc == ECORE_SUCCESS) { if (add) { arfs->pkt_len = pkt_len; @@ -1371,12 +1378,15 @@ qede_flow_parse_actions(struct rte_eth_dev *dev, flow->entry.rx_queue = queue->index; break; - + case RTE_FLOW_ACTION_TYPE_DROP: + if (flow) + flow->entry.is_drop = true; + break; default: rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, actions, - "Action is not supported - only ACTION_TYPE_QUEUE supported"); + "Action is not supported - only ACTION_TYPE_QUEUE and ACTION_TYPE_DROP supported"); return -rte_errno; } } -- 2.17.1