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 D751AA0C47 for ; Mon, 26 Jul 2021 15:55:38 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CF3D440DDA; Mon, 26 Jul 2021 15:55:38 +0200 (CEST) Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) by mails.dpdk.org (Postfix) with ESMTP id 9351040DDA for ; Mon, 26 Jul 2021 15:55:37 +0200 (CEST) Received: by mail-wm1-f47.google.com with SMTP id u15so2006881wmj.1 for ; Mon, 26 Jul 2021 06:55:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gmOPAQdmB9V7DLIcKqk6sIFt8MRtk/MJWMUBqLK+AvI=; b=na2iNvb1ZAPpVE07Mxv5m7AX0BkVjNnmRbmt59jEW/Y2WawpCF0WGd+YtZZHmiMEDd aDPEdp2xDlDQ4Fpaamv6dOQvwlDk9TWwwrMGI2G/Sf92B70cTKF4/Vj89Rb+HlJ7O+kG A+Dag38T3tPHCqU+GNFJ5xE04aBl/sefh/QGjKJKmfyoKUyx7K7cCLHkC/yJbLW0Prkd YUp3mfbsyy+uoix6hgh2Ei185EkuY1ampfPQ/MLIvLY8NKjkx9u6L8I1lRQ7RnQUULug ikqrnVH/YHXbI7T8hAI5vnDGlnE5vnQpu7pjgi6Egg8Q6YPEf5kTIWm0bYHOGBWVu4Yg G/lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gmOPAQdmB9V7DLIcKqk6sIFt8MRtk/MJWMUBqLK+AvI=; b=Og+WhZqNleb+6ZC4ntL4Dav5YC2hHTyCkQ4anlfHlokQr97pTgKCxMT36LIv0wky/p 9RkuLLMxalZFvyfl7H/e5HUE4OgZhEwQBP8nItyOBDwDPexRLxmDwUUipf4AHYw7tQRS +SQxCXMAHzeov0xqMjPKsqZLrPmZyKjb1YxVaEx0PgQhX3mRLX6WUXa6tSeKWM90U80+ fai7lwokaJ0Cj3ZhiDptx+KonqjUWzK4h5pbPakkZFBRJdq/YT+Bo35+X4UwO3wsYw31 Osc2Oh0vzk+rrrZpJiJrfoxG+Sqqqzt6NUBQlaetkz1OiDFpdgA33CT8F/3CVgOy0B6P qx6g== X-Gm-Message-State: AOAM532kHvfbkLVNdULHwf95F60sAjQOojZkc5PS3b6RGkbofBc4+jj7 9DlmYVCoG7++QgG8kZxzPIE= X-Google-Smtp-Source: ABdhPJy84GdZmSwzoXE9lX6HhhJgKJ4hXZqXlOWOvy27lkzL/kERf3HrergfxJdeJP4EMZU46Zum6A== X-Received: by 2002:a1c:4603:: with SMTP id t3mr26777874wma.178.1627307737305; Mon, 26 Jul 2021 06:55:37 -0700 (PDT) Received: from localhost ([137.220.125.106]) by smtp.gmail.com with ESMTPSA id j1sm1460849wmo.4.2021.07.26.06.55.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jul 2021 06:55:36 -0700 (PDT) From: luca.boccassi@gmail.com To: Chengwen Feng Cc: Min Hu , dpdk stable Date: Mon, 26 Jul 2021 14:53:06 +0100 Message-Id: <20210726135322.149850-43-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210726135322.149850-1-luca.boccassi@gmail.com> References: <20210712130551.2462159-1-luca.boccassi@gmail.com> <20210726135322.149850-1-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'net/hns3: fix flow rule list in multi-process' has been queued to stable release 20.11.3 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to stable release 20.11.3 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 07/28/21. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/28a94eea0c5e71972d9e354a10f15ab44ad58ce1 Thanks. Luca Boccassi --- >From 28a94eea0c5e71972d9e354a10f15ab44ad58ce1 Mon Sep 17 00:00:00 2001 From: Chengwen Feng Date: Sat, 17 Jul 2021 10:02:55 +0800 Subject: [PATCH] net/hns3: fix flow rule list in multi-process [ upstream commit 9b290a3a63ca31ba7bd0a071315dc2e72ba75d8a ] Currently, hns3 driver saves rte_flow list into the rte_eth_dev.process_private field, it may cause following problem: The FDIR/RSS rules cannot be managed in a unified manner because the management structure is not visible between processes. This patch fixes it by moving rte_flow list to struct hns3_hw which is visible between processes. Fixes: fcba820d9b9e ("net/hns3: support flow director") Fixes: c37ca66f2b27 ("net/hns3: support RSS") Signed-off-by: Chengwen Feng Signed-off-by: Min Hu (Connor) --- drivers/net/hns3/hns3_ethdev.c | 24 +------ drivers/net/hns3/hns3_ethdev.h | 3 + drivers/net/hns3/hns3_ethdev_vf.c | 24 +------ drivers/net/hns3/hns3_fdir.h | 7 +-- drivers/net/hns3/hns3_flow.c | 101 +++++++++++++++--------------- 5 files changed, 60 insertions(+), 99 deletions(-) diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c index 25a9af4382..abe31c841e 100644 --- a/drivers/net/hns3/hns3_ethdev.c +++ b/drivers/net/hns3/hns3_ethdev.c @@ -4852,6 +4852,7 @@ hns3_uninit_pf(struct rte_eth_dev *eth_dev) hns3_rss_uninit(hns); (void)hns3_config_gro(hw, false); hns3_promisc_uninit(hw); + hns3_flow_uninit(eth_dev); hns3_fdir_filter_uninit(hns); (void)hns3_firmware_compat_config(hw, false); hns3_uninit_umv_space(hw); @@ -5188,11 +5189,8 @@ hns3_dev_close(struct rte_eth_dev *eth_dev) struct hns3_hw *hw = &hns->hw; int ret = 0; - if (rte_eal_process_type() != RTE_PROC_PRIMARY) { - rte_free(eth_dev->process_private); - eth_dev->process_private = NULL; + if (rte_eal_process_type() != RTE_PROC_PRIMARY) return 0; - } if (hw->adapter_state == HNS3_NIC_STARTED) ret = hns3_dev_stop(eth_dev); @@ -5207,8 +5205,6 @@ hns3_dev_close(struct rte_eth_dev *eth_dev) hns3_uninit_pf(eth_dev); hns3_free_all_queues(eth_dev); rte_free(hw->reset.wait_data); - rte_free(eth_dev->process_private); - eth_dev->process_private = NULL; hns3_mp_uninit_primary(); hns3_warn(hw, "Close port %u finished", hw->data->port_id); @@ -6269,15 +6265,6 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) PMD_INIT_FUNC_TRACE(); - eth_dev->process_private = (struct hns3_process_private *) - rte_zmalloc_socket("hns3_filter_list", - sizeof(struct hns3_process_private), - RTE_CACHE_LINE_SIZE, eth_dev->device->numa_node); - if (eth_dev->process_private == NULL) { - PMD_INIT_LOG(ERR, "Failed to alloc memory for process private"); - return -ENOMEM; - } - hns3_flow_init(eth_dev); hns3_set_rxtx_function(eth_dev); @@ -6379,8 +6366,6 @@ err_mp_init_secondary: eth_dev->rx_pkt_burst = NULL; eth_dev->tx_pkt_burst = NULL; eth_dev->tx_pkt_prepare = NULL; - rte_free(eth_dev->process_private); - eth_dev->process_private = NULL; return ret; } @@ -6392,11 +6377,8 @@ hns3_dev_uninit(struct rte_eth_dev *eth_dev) PMD_INIT_FUNC_TRACE(); - if (rte_eal_process_type() != RTE_PROC_PRIMARY) { - rte_free(eth_dev->process_private); - eth_dev->process_private = NULL; + if (rte_eal_process_type() != RTE_PROC_PRIMARY) return 0; - } if (hw->adapter_state < HNS3_NIC_CLOSING) hns3_dev_close(eth_dev); diff --git a/drivers/net/hns3/hns3_ethdev.h b/drivers/net/hns3/hns3_ethdev.h index 79a96bdd08..9d9291285e 100644 --- a/drivers/net/hns3/hns3_ethdev.h +++ b/drivers/net/hns3/hns3_ethdev.h @@ -556,6 +556,9 @@ struct hns3_hw { struct hns3_port_base_vlan_config port_base_vlan_cfg; pthread_mutex_t flows_lock; /* rte_flow ops lock */ + struct hns3_fdir_rule_list flow_fdir_list; /* flow fdir rule list */ + struct hns3_rss_filter_list flow_rss_list; /* flow RSS rule list */ + struct hns3_flow_mem_list flow_list; /* * PMD setup and configuration is not thread safe. Since it is not diff --git a/drivers/net/hns3/hns3_ethdev_vf.c b/drivers/net/hns3/hns3_ethdev_vf.c index 24bc540456..086828180b 100644 --- a/drivers/net/hns3/hns3_ethdev_vf.c +++ b/drivers/net/hns3/hns3_ethdev_vf.c @@ -1876,6 +1876,7 @@ hns3vf_uninit_vf(struct rte_eth_dev *eth_dev) (void)hns3_config_gro(hw, false); (void)hns3vf_set_alive(hw, false); (void)hns3vf_set_promisc_mode(hw, false, false, false); + hns3_flow_uninit(eth_dev); hns3_tqp_stats_uninit(hw); hns3vf_disable_irq0(hw); rte_intr_disable(&pci_dev->intr_handle); @@ -1990,11 +1991,8 @@ hns3vf_dev_close(struct rte_eth_dev *eth_dev) struct hns3_hw *hw = &hns->hw; int ret = 0; - if (rte_eal_process_type() != RTE_PROC_PRIMARY) { - rte_free(eth_dev->process_private); - eth_dev->process_private = NULL; + if (rte_eal_process_type() != RTE_PROC_PRIMARY) return 0; - } if (hw->adapter_state == HNS3_NIC_STARTED) ret = hns3vf_dev_stop(eth_dev); @@ -2008,8 +2006,6 @@ hns3vf_dev_close(struct rte_eth_dev *eth_dev) hns3vf_uninit_vf(eth_dev); hns3_free_all_queues(eth_dev); rte_free(hw->reset.wait_data); - rte_free(eth_dev->process_private); - eth_dev->process_private = NULL; hns3_mp_uninit_primary(); hns3_warn(hw, "Close port %u finished", hw->data->port_id); @@ -2756,15 +2752,6 @@ hns3vf_dev_init(struct rte_eth_dev *eth_dev) PMD_INIT_FUNC_TRACE(); - eth_dev->process_private = (struct hns3_process_private *) - rte_zmalloc_socket("hns3_filter_list", - sizeof(struct hns3_process_private), - RTE_CACHE_LINE_SIZE, eth_dev->device->numa_node); - if (eth_dev->process_private == NULL) { - PMD_INIT_LOG(ERR, "Failed to alloc memory for process private"); - return -ENOMEM; - } - hns3_flow_init(eth_dev); hns3_set_rxtx_function(eth_dev); @@ -2864,8 +2851,6 @@ err_mp_init_secondary: eth_dev->rx_pkt_burst = NULL; eth_dev->tx_pkt_burst = NULL; eth_dev->tx_pkt_prepare = NULL; - rte_free(eth_dev->process_private); - eth_dev->process_private = NULL; return ret; } @@ -2878,11 +2863,8 @@ hns3vf_dev_uninit(struct rte_eth_dev *eth_dev) PMD_INIT_FUNC_TRACE(); - if (rte_eal_process_type() != RTE_PROC_PRIMARY) { - rte_free(eth_dev->process_private); - eth_dev->process_private = NULL; + if (rte_eal_process_type() != RTE_PROC_PRIMARY) return 0; - } if (hw->adapter_state < HNS3_NIC_CLOSING) hns3vf_dev_close(eth_dev); diff --git a/drivers/net/hns3/hns3_fdir.h b/drivers/net/hns3/hns3_fdir.h index fc62daa994..3f610f7b11 100644 --- a/drivers/net/hns3/hns3_fdir.h +++ b/drivers/net/hns3/hns3_fdir.h @@ -189,12 +189,6 @@ TAILQ_HEAD(hns3_fdir_rule_list, hns3_fdir_rule_ele); TAILQ_HEAD(hns3_rss_filter_list, hns3_rss_conf_ele); TAILQ_HEAD(hns3_flow_mem_list, hns3_flow_mem); -struct hns3_process_private { - struct hns3_fdir_rule_list fdir_list; - struct hns3_rss_filter_list filter_rss_list; - struct hns3_flow_mem_list flow_list; -}; - /* * A structure used to define fields of a FDIR related info. */ @@ -220,6 +214,7 @@ int hns3_fdir_filter_program(struct hns3_adapter *hns, int hns3_clear_all_fdir_filter(struct hns3_adapter *hns); int hns3_get_count(struct hns3_hw *hw, uint32_t id, uint64_t *value); void hns3_flow_init(struct rte_eth_dev *dev); +void hns3_flow_uninit(struct rte_eth_dev *dev); int hns3_restore_all_fdir_filter(struct hns3_adapter *hns); #endif /* _HNS3_FDIR_H_ */ diff --git a/drivers/net/hns3/hns3_flow.c b/drivers/net/hns3/hns3_flow.c index 4e81769a8b..70c45f6bc5 100644 --- a/drivers/net/hns3/hns3_flow.c +++ b/drivers/net/hns3/hns3_flow.c @@ -1229,54 +1229,34 @@ hns3_parse_fdir_filter(struct rte_eth_dev *dev, return hns3_handle_actions(dev, actions, rule, error); } -void -hns3_flow_init(struct rte_eth_dev *dev) -{ - struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); - struct hns3_process_private *process_list = dev->process_private; - pthread_mutexattr_t attr; - - if (rte_eal_process_type() == RTE_PROC_PRIMARY) { - pthread_mutexattr_init(&attr); - pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED); - pthread_mutex_init(&hw->flows_lock, &attr); - dev->data->dev_flags |= RTE_ETH_DEV_FLOW_OPS_THREAD_SAFE; - } - - TAILQ_INIT(&process_list->fdir_list); - TAILQ_INIT(&process_list->filter_rss_list); - TAILQ_INIT(&process_list->flow_list); -} - static void hns3_filterlist_flush(struct rte_eth_dev *dev) { - struct hns3_process_private *process_list = dev->process_private; + struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); struct hns3_fdir_rule_ele *fdir_rule_ptr; struct hns3_rss_conf_ele *rss_filter_ptr; struct hns3_flow_mem *flow_node; - fdir_rule_ptr = TAILQ_FIRST(&process_list->fdir_list); + fdir_rule_ptr = TAILQ_FIRST(&hw->flow_fdir_list); while (fdir_rule_ptr) { - TAILQ_REMOVE(&process_list->fdir_list, fdir_rule_ptr, entries); + TAILQ_REMOVE(&hw->flow_fdir_list, fdir_rule_ptr, entries); rte_free(fdir_rule_ptr); - fdir_rule_ptr = TAILQ_FIRST(&process_list->fdir_list); + fdir_rule_ptr = TAILQ_FIRST(&hw->flow_fdir_list); } - rss_filter_ptr = TAILQ_FIRST(&process_list->filter_rss_list); + rss_filter_ptr = TAILQ_FIRST(&hw->flow_rss_list); while (rss_filter_ptr) { - TAILQ_REMOVE(&process_list->filter_rss_list, rss_filter_ptr, - entries); + TAILQ_REMOVE(&hw->flow_rss_list, rss_filter_ptr, entries); rte_free(rss_filter_ptr); - rss_filter_ptr = TAILQ_FIRST(&process_list->filter_rss_list); + rss_filter_ptr = TAILQ_FIRST(&hw->flow_rss_list); } - flow_node = TAILQ_FIRST(&process_list->flow_list); + flow_node = TAILQ_FIRST(&hw->flow_list); while (flow_node) { - TAILQ_REMOVE(&process_list->flow_list, flow_node, entries); + TAILQ_REMOVE(&hw->flow_list, flow_node, entries); rte_free(flow_node->flow); rte_free(flow_node); - flow_node = TAILQ_FIRST(&process_list->flow_list); + flow_node = TAILQ_FIRST(&hw->flow_list); } } @@ -1535,7 +1515,6 @@ static int hns3_config_rss_filter(struct rte_eth_dev *dev, const struct hns3_rss_conf *conf, bool add) { - struct hns3_process_private *process_list = dev->process_private; struct hns3_adapter *hns = dev->data->dev_private; struct hns3_rss_conf_ele *rss_filter_ptr; struct hns3_hw *hw = &hns->hw; @@ -1620,7 +1599,7 @@ hns3_config_rss_filter(struct rte_eth_dev *dev, * When create a new RSS rule, the old rule will be overlaid and set * invalid. */ - TAILQ_FOREACH(rss_filter_ptr, &process_list->filter_rss_list, entries) + TAILQ_FOREACH(rss_filter_ptr, &hw->flow_rss_list, entries) rss_filter_ptr->filter_info.valid = false; rss_config_err: @@ -1632,7 +1611,6 @@ rss_config_err: static int hns3_clear_rss_filter(struct rte_eth_dev *dev) { - struct hns3_process_private *process_list = dev->process_private; struct hns3_adapter *hns = dev->data->dev_private; struct hns3_rss_conf_ele *rss_filter_ptr; struct hns3_hw *hw = &hns->hw; @@ -1640,10 +1618,9 @@ hns3_clear_rss_filter(struct rte_eth_dev *dev) int rss_rule_fail_cnt = 0; /* count for failure of clearing RSS rules */ int ret = 0; - rss_filter_ptr = TAILQ_FIRST(&process_list->filter_rss_list); + rss_filter_ptr = TAILQ_FIRST(&hw->flow_rss_list); while (rss_filter_ptr) { - TAILQ_REMOVE(&process_list->filter_rss_list, rss_filter_ptr, - entries); + TAILQ_REMOVE(&hw->flow_rss_list, rss_filter_ptr, entries); ret = hns3_config_rss_filter(dev, &rss_filter_ptr->filter_info, false); if (ret) @@ -1651,7 +1628,7 @@ hns3_clear_rss_filter(struct rte_eth_dev *dev) else rss_rule_succ_cnt++; rte_free(rss_filter_ptr); - rss_filter_ptr = TAILQ_FIRST(&process_list->filter_rss_list); + rss_filter_ptr = TAILQ_FIRST(&hw->flow_rss_list); } if (rss_rule_fail_cnt) { @@ -1755,7 +1732,6 @@ hns3_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, const struct rte_flow_action actions[], struct rte_flow_error *error) { - struct hns3_process_private *process_list = dev->process_private; struct hns3_adapter *hns = dev->data->dev_private; struct hns3_hw *hw = &hns->hw; const struct hns3_rss_conf *rss_conf; @@ -1787,7 +1763,7 @@ hns3_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, } flow_node->flow = flow; - TAILQ_INSERT_TAIL(&process_list->flow_list, flow_node, entries); + TAILQ_INSERT_TAIL(&hw->flow_list, flow_node, entries); act = hns3_find_rss_general_action(pattern, actions); if (act) { @@ -1809,8 +1785,7 @@ hns3_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, hns3_rss_conf_copy(&rss_filter_ptr->filter_info, &rss_conf->conf); rss_filter_ptr->filter_info.valid = true; - TAILQ_INSERT_TAIL(&process_list->filter_rss_list, - rss_filter_ptr, entries); + TAILQ_INSERT_TAIL(&hw->flow_rss_list, rss_filter_ptr, entries); flow->rule = rss_filter_ptr; flow->filter_type = RTE_ETH_FILTER_HASH; @@ -1844,8 +1819,7 @@ hns3_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, if (!ret) { memcpy(&fdir_rule_ptr->fdir_conf, &fdir_rule, sizeof(struct hns3_fdir_rule)); - TAILQ_INSERT_TAIL(&process_list->fdir_list, - fdir_rule_ptr, entries); + TAILQ_INSERT_TAIL(&hw->flow_fdir_list, fdir_rule_ptr, entries); flow->rule = fdir_rule_ptr; flow->filter_type = RTE_ETH_FILTER_FDIR; @@ -1860,7 +1834,7 @@ err: rte_flow_error_set(error, -ret, RTE_FLOW_ERROR_TYPE_HANDLE, NULL, "Failed to create flow"); out: - TAILQ_REMOVE(&process_list->flow_list, flow_node, entries); + TAILQ_REMOVE(&hw->flow_list, flow_node, entries); rte_free(flow_node); rte_free(flow); return NULL; @@ -1871,13 +1845,13 @@ static int hns3_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow, struct rte_flow_error *error) { - struct hns3_process_private *process_list = dev->process_private; struct hns3_adapter *hns = dev->data->dev_private; struct hns3_fdir_rule_ele *fdir_rule_ptr; struct hns3_rss_conf_ele *rss_filter_ptr; struct hns3_flow_mem *flow_node; enum rte_filter_type filter_type; struct hns3_fdir_rule fdir_rule; + struct hns3_hw *hw = &hns->hw; int ret; if (flow == NULL) @@ -1899,7 +1873,7 @@ hns3_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow, "Destroy FDIR fail.Try again"); if (fdir_rule.flags & HNS3_RULE_FLAG_COUNTER) hns3_counter_release(dev, fdir_rule.act_cnt.id); - TAILQ_REMOVE(&process_list->fdir_list, fdir_rule_ptr, entries); + TAILQ_REMOVE(&hw->flow_fdir_list, fdir_rule_ptr, entries); rte_free(fdir_rule_ptr); fdir_rule_ptr = NULL; break; @@ -1912,8 +1886,7 @@ hns3_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow, RTE_FLOW_ERROR_TYPE_HANDLE, flow, "Destroy RSS fail.Try again"); - TAILQ_REMOVE(&process_list->filter_rss_list, rss_filter_ptr, - entries); + TAILQ_REMOVE(&hw->flow_rss_list, rss_filter_ptr, entries); rte_free(rss_filter_ptr); rss_filter_ptr = NULL; break; @@ -1923,10 +1896,9 @@ hns3_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow, "Unsupported filter type"); } - TAILQ_FOREACH(flow_node, &process_list->flow_list, entries) { + TAILQ_FOREACH(flow_node, &hw->flow_list, entries) { if (flow_node->flow == flow) { - TAILQ_REMOVE(&process_list->flow_list, flow_node, - entries); + TAILQ_REMOVE(&hw->flow_list, flow_node, entries); rte_free(flow_node); flow_node = NULL; break; @@ -2130,3 +2102,30 @@ hns3_dev_filter_ctrl(struct rte_eth_dev *dev, enum rte_filter_type filter_type, return ret; } + +void +hns3_flow_init(struct rte_eth_dev *dev) +{ + struct hns3_hw *hw = HNS3_DEV_PRIVATE_TO_HW(dev->data->dev_private); + pthread_mutexattr_t attr; + + if (rte_eal_process_type() != RTE_PROC_PRIMARY) + return; + + pthread_mutexattr_init(&attr); + pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_SHARED); + pthread_mutex_init(&hw->flows_lock, &attr); + dev->data->dev_flags |= RTE_ETH_DEV_FLOW_OPS_THREAD_SAFE; + + TAILQ_INIT(&hw->flow_fdir_list); + TAILQ_INIT(&hw->flow_rss_list); + TAILQ_INIT(&hw->flow_list); +} + +void +hns3_flow_uninit(struct rte_eth_dev *dev) +{ + struct rte_flow_error error; + if (rte_eal_process_type() == RTE_PROC_PRIMARY) + hns3_flow_flush_wrap(dev, &error); +} -- 2.30.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2021-07-26 13:53:18.206678295 +0100 +++ 0043-net-hns3-fix-flow-rule-list-in-multi-process.patch 2021-07-26 13:53:15.929294304 +0100 @@ -1 +1 @@ -From 9b290a3a63ca31ba7bd0a071315dc2e72ba75d8a Mon Sep 17 00:00:00 2001 +From 28a94eea0c5e71972d9e354a10f15ab44ad58ce1 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit 9b290a3a63ca31ba7bd0a071315dc2e72ba75d8a ] + @@ -16 +17,0 @@ -Cc: stable@dpdk.org @@ -29 +30 @@ -index 4a302d2072..a374fa7915 100644 +index 25a9af4382..abe31c841e 100644 @@ -32 +33 @@ -@@ -5292,6 +5292,7 @@ hns3_uninit_pf(struct rte_eth_dev *eth_dev) +@@ -4852,6 +4852,7 @@ hns3_uninit_pf(struct rte_eth_dev *eth_dev) @@ -37,0 +39 @@ + (void)hns3_firmware_compat_config(hw, false); @@ -39,2 +41 @@ - hns3_tqp_stats_uninit(hw); -@@ -5918,11 +5919,8 @@ hns3_dev_close(struct rte_eth_dev *eth_dev) +@@ -5188,11 +5189,8 @@ hns3_dev_close(struct rte_eth_dev *eth_dev) @@ -53 +54 @@ -@@ -5937,8 +5935,6 @@ hns3_dev_close(struct rte_eth_dev *eth_dev) +@@ -5207,8 +5205,6 @@ hns3_dev_close(struct rte_eth_dev *eth_dev) @@ -62 +63 @@ -@@ -7398,15 +7394,6 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) +@@ -6269,15 +6265,6 @@ hns3_dev_init(struct rte_eth_dev *eth_dev) @@ -78 +79,2 @@ -@@ -7510,8 +7497,6 @@ err_mp_init_secondary: +@@ -6379,8 +6366,6 @@ err_mp_init_secondary: + eth_dev->rx_pkt_burst = NULL; @@ -81 +82,0 @@ - eth_dev->tx_descriptor_status = NULL; @@ -87 +88 @@ -@@ -7523,11 +7508,8 @@ hns3_dev_uninit(struct rte_eth_dev *eth_dev) +@@ -6392,11 +6377,8 @@ hns3_dev_uninit(struct rte_eth_dev *eth_dev) @@ -101 +102 @@ -index 3485614b6f..8e66d9f0f3 100644 +index 79a96bdd08..9d9291285e 100644 @@ -104 +105 @@ -@@ -630,6 +630,9 @@ struct hns3_hw { +@@ -556,6 +556,9 @@ struct hns3_hw { @@ -115 +116 @@ -index de659c05f0..8d9b7979c8 100644 +index 24bc540456..086828180b 100644 @@ -118 +119 @@ -@@ -2071,6 +2071,7 @@ hns3vf_uninit_vf(struct rte_eth_dev *eth_dev) +@@ -1876,6 +1876,7 @@ hns3vf_uninit_vf(struct rte_eth_dev *eth_dev) @@ -126 +127 @@ -@@ -2186,11 +2187,8 @@ hns3vf_dev_close(struct rte_eth_dev *eth_dev) +@@ -1990,11 +1991,8 @@ hns3vf_dev_close(struct rte_eth_dev *eth_dev) @@ -139 +140 @@ -@@ -2204,8 +2202,6 @@ hns3vf_dev_close(struct rte_eth_dev *eth_dev) +@@ -2008,8 +2006,6 @@ hns3vf_dev_close(struct rte_eth_dev *eth_dev) @@ -148 +149 @@ -@@ -2962,15 +2958,6 @@ hns3vf_dev_init(struct rte_eth_dev *eth_dev) +@@ -2756,15 +2752,6 @@ hns3vf_dev_init(struct rte_eth_dev *eth_dev) @@ -164 +165,2 @@ -@@ -3072,8 +3059,6 @@ err_mp_init_secondary: +@@ -2864,8 +2851,6 @@ err_mp_init_secondary: + eth_dev->rx_pkt_burst = NULL; @@ -167 +168,0 @@ - eth_dev->tx_descriptor_status = NULL; @@ -173 +174 @@ -@@ -3086,11 +3071,8 @@ hns3vf_dev_uninit(struct rte_eth_dev *eth_dev) +@@ -2878,11 +2863,8 @@ hns3vf_dev_uninit(struct rte_eth_dev *eth_dev) @@ -212 +213 @@ -index 755a6f2c7c..fc77979c5f 100644 +index 4e81769a8b..70c45f6bc5 100644 @@ -215 +216 @@ -@@ -1202,54 +1202,34 @@ hns3_parse_fdir_filter(struct rte_eth_dev *dev, +@@ -1229,54 +1229,34 @@ hns3_parse_fdir_filter(struct rte_eth_dev *dev, @@ -280 +281 @@ -@@ -1519,7 +1499,6 @@ static int +@@ -1535,7 +1515,6 @@ static int @@ -288 +289 @@ -@@ -1604,7 +1583,7 @@ hns3_config_rss_filter(struct rte_eth_dev *dev, +@@ -1620,7 +1599,7 @@ hns3_config_rss_filter(struct rte_eth_dev *dev, @@ -297 +298 @@ -@@ -1616,7 +1595,6 @@ rss_config_err: +@@ -1632,7 +1611,6 @@ rss_config_err: @@ -305 +306 @@ -@@ -1624,10 +1602,9 @@ hns3_clear_rss_filter(struct rte_eth_dev *dev) +@@ -1640,10 +1618,9 @@ hns3_clear_rss_filter(struct rte_eth_dev *dev) @@ -318 +319 @@ -@@ -1635,7 +1612,7 @@ hns3_clear_rss_filter(struct rte_eth_dev *dev) +@@ -1651,7 +1628,7 @@ hns3_clear_rss_filter(struct rte_eth_dev *dev) @@ -327 +328 @@ -@@ -1739,7 +1716,6 @@ hns3_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, +@@ -1755,7 +1732,6 @@ hns3_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, @@ -335 +336 @@ -@@ -1771,7 +1747,7 @@ hns3_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, +@@ -1787,7 +1763,7 @@ hns3_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, @@ -344 +345 @@ -@@ -1793,8 +1769,7 @@ hns3_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, +@@ -1809,8 +1785,7 @@ hns3_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, @@ -354 +355 @@ -@@ -1828,8 +1803,7 @@ hns3_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, +@@ -1844,8 +1819,7 @@ hns3_flow_create(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, @@ -364 +365 @@ -@@ -1844,7 +1818,7 @@ err: +@@ -1860,7 +1834,7 @@ err: @@ -373 +374 @@ -@@ -1855,13 +1829,13 @@ static int +@@ -1871,13 +1845,13 @@ static int @@ -388 +389 @@ -@@ -1884,7 +1858,7 @@ hns3_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow, +@@ -1899,7 +1873,7 @@ hns3_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow, @@ -397 +398 @@ -@@ -1897,8 +1871,7 @@ hns3_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow, +@@ -1912,8 +1886,7 @@ hns3_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow, @@ -407 +408 @@ -@@ -1908,10 +1881,9 @@ hns3_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow, +@@ -1923,10 +1896,9 @@ hns3_flow_destroy(struct rte_eth_dev *dev, struct rte_flow *flow, @@ -420,3 +421,3 @@ -@@ -2097,3 +2069,30 @@ hns3_dev_flow_ops_get(struct rte_eth_dev *dev, - *ops = &hns3_flow_ops; - return 0; +@@ -2130,3 +2102,30 @@ hns3_dev_filter_ctrl(struct rte_eth_dev *dev, enum rte_filter_type filter_type, + + return ret;