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 C0DF0A0508; Thu, 7 Apr 2022 04:59:41 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D8D11410DC; Thu, 7 Apr 2022 04:59:02 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id 7D22B40689 for ; Thu, 7 Apr 2022 04:59:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1649300340; x=1680836340; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=pWlrl1pDLJsmPPTKlt6Us8AQKvxvo9DooapIJpyowDM=; b=kzjiXzFF86bUBEEF/r/nzWC1T+7wCXQAbYUq11ffx9sItUAnIbad2fsC 4GzOPTkttjFrYLow9WJrPIe11LTMGl0voIyzi3bskqPZtZ8qcBpYYfz4e QpnQQ8rStwh48nWNwXgbKCczT+jlGw+TR4ExpmRm4Y/rceIsqYZa1Dd5g Yifv5I1Xzu8s5BJjbpAE0T5hE4LdHodSup+Oq775xK+voVZOlXa8yRzoj 8yhOCh21D3nsIvk06vr4AB74NO+DRHeTWRxd/+wg7AfyrZ73SGJ6s8Qhw O+7odfYTY5fViJKfrW3RrMxtTdDOz0c1/oHRGKXG48mZ8Hnm9GWwvkORE A==; X-IronPort-AV: E=McAfee;i="6200,9189,10309"; a="248738381" X-IronPort-AV: E=Sophos;i="5.90,241,1643702400"; d="scan'208";a="248738381" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Apr 2022 19:59:00 -0700 X-IronPort-AV: E=Sophos;i="5.90,241,1643702400"; d="scan'208";a="570850611" Received: from intel-cd-odc-kevin.cd.intel.com ([10.240.178.195]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Apr 2022 19:58:57 -0700 From: Kevin Liu To: dev@dpdk.org Cc: qiming.yang@intel.com, qi.z.zhang@intel.com, stevex.yang@intel.com, Kevin Liu , Steven Zou , Alvin Zhang Subject: [PATCH 16/39] net/ice: support MDCF(multi-DCF) instance Date: Thu, 7 Apr 2022 10:56:43 +0000 Message-Id: <20220407105706.18889-17-kevinx.liu@intel.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220407105706.18889-1-kevinx.liu@intel.com> References: <20220407105706.18889-1-kevinx.liu@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 Add MDCF flushing flow rule ops. Support parsing commandline device capability 'mdcf'. Support PF reporting current DCF id and disabling the DCF capability of an MDCF instance. Signed-off-by: Steven Zou Signed-off-by: Alvin Zhang Signed-off-by: Kevin Liu --- drivers/net/ice/ice_dcf.c | 23 ++++++- drivers/net/ice/ice_dcf.h | 3 + drivers/net/ice/ice_dcf_ethdev.c | 99 ++++++++++++++++------------- drivers/net/ice/ice_dcf_parent.c | 8 +++ drivers/net/ice/ice_generic_flow.c | 10 +++ drivers/net/ice/ice_switch_filter.c | 5 +- 6 files changed, 100 insertions(+), 48 deletions(-) diff --git a/drivers/net/ice/ice_dcf.c b/drivers/net/ice/ice_dcf.c index 9c2f13cf72..7987b6261d 100644 --- a/drivers/net/ice/ice_dcf.c +++ b/drivers/net/ice/ice_dcf.c @@ -681,7 +681,8 @@ ice_dcf_init_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw) if (ice_dcf_get_vf_vsi_map(hw) < 0) { PMD_INIT_LOG(ERR, "Failed to get VF VSI map"); - ice_dcf_mode_disable(hw); + if (!hw->multi_inst) + ice_dcf_mode_disable(hw); goto err_alloc; } @@ -759,8 +760,8 @@ ice_dcf_uninit_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw) rte_intr_disable(intr_handle); rte_intr_callback_unregister(intr_handle, ice_dcf_dev_interrupt_handler, hw); - - ice_dcf_mode_disable(hw); + if (!hw->multi_inst) + ice_dcf_mode_disable(hw); iavf_shutdown_adminq(&hw->avf); rte_free(hw->arq_buf); @@ -1187,3 +1188,19 @@ ice_dcf_cap_reset(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw) ice_dcf_enable_irq0(hw); return ret; } + +int +ice_dcf_flush_rules(struct ice_dcf_hw *hw) +{ + struct dcf_virtchnl_cmd args; + int err = 0; + + memset(&args, 0, sizeof(args)); + args.v_op = VIRTCHNL_OP_DCF_RULE_FLUSH; + + err = ice_dcf_execute_virtchnl_cmd(hw, &args); + if (err) + PMD_DRV_LOG(WARNING, "fail to execute command OF_DCF_RULE_FLUSH, DCF role must be preempted."); + + return 0; +} diff --git a/drivers/net/ice/ice_dcf.h b/drivers/net/ice/ice_dcf.h index 8cf17e7700..42f4404a37 100644 --- a/drivers/net/ice/ice_dcf.h +++ b/drivers/net/ice/ice_dcf.h @@ -98,6 +98,8 @@ struct ice_dcf_hw { uint16_t vsi_id; struct rte_eth_dev *eth_dev; + bool multi_inst; + bool dcf_replaced; uint8_t *rss_lut; uint8_t *rss_key; uint64_t supported_rxdid; @@ -142,5 +144,6 @@ void ice_dcf_tm_conf_init(struct rte_eth_dev *dev); void ice_dcf_tm_conf_uninit(struct rte_eth_dev *dev); int ice_dcf_replay_vf_bw(struct ice_dcf_hw *hw, uint16_t vf_id); int ice_dcf_clear_bw(struct ice_dcf_hw *hw); +int ice_dcf_flush_rules(struct ice_dcf_hw *hw); #endif /* _ICE_DCF_H_ */ diff --git a/drivers/net/ice/ice_dcf_ethdev.c b/drivers/net/ice/ice_dcf_ethdev.c index d4bfa182a4..90787d8c49 100644 --- a/drivers/net/ice/ice_dcf_ethdev.c +++ b/drivers/net/ice/ice_dcf_ethdev.c @@ -19,6 +19,7 @@ #include #include #include +#include #include @@ -1788,12 +1789,66 @@ static const struct eth_dev_ops ice_dcf_eth_dev_ops = { .mtu_set = ice_dcf_dev_mtu_set, }; +static int +ice_dcf_cap_check_handler(__rte_unused const char *key, + const char *value, void *opaque) +{ + bool *mi = opaque; + + if (!strcmp(value, "dcf")) { + *mi = 0; + return 0; + } + if (!strcmp(value, "mdcf")) { + *mi = 1; + return 0; + } + + return -1; +} + +static int +ice_dcf_cap_selected(struct ice_dcf_adapter *adapter, + struct rte_devargs *devargs) +{ + struct ice_adapter *ad = &adapter->parent; + struct rte_kvargs *kvlist; + const char *key_cap = "cap"; + int ret = 0; + + if (devargs == NULL) + return 0; + + kvlist = rte_kvargs_parse(devargs->args, NULL); + if (kvlist == NULL) + return 0; + + if (!rte_kvargs_count(kvlist, key_cap)) + goto exit; + + /* dcf capability selected when there's a key-value pair: cap=dcf */ + if (rte_kvargs_process(kvlist, key_cap, + ice_dcf_cap_check_handler, + &adapter->real_hw.multi_inst) < 0) + goto exit; + + ret = 1; + +exit: + rte_kvargs_free(kvlist); + return ret; +} + static int ice_dcf_dev_init(struct rte_eth_dev *eth_dev) { + struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(eth_dev->device); struct ice_dcf_adapter *adapter = eth_dev->data->dev_private; struct ice_adapter *parent_adapter = &adapter->parent; + if (!ice_dcf_cap_selected(adapter, pci_dev->device.devargs)) + return 1; + eth_dev->dev_ops = &ice_dcf_eth_dev_ops; eth_dev->rx_pkt_burst = ice_dcf_recv_pkts; eth_dev->tx_pkt_burst = ice_dcf_xmit_pkts; @@ -1829,45 +1884,6 @@ ice_dcf_dev_uninit(struct rte_eth_dev *eth_dev) return 0; } -static int -ice_dcf_cap_check_handler(__rte_unused const char *key, - const char *value, __rte_unused void *opaque) -{ - if (strcmp(value, "dcf")) - return -1; - - return 0; -} - -static int -ice_dcf_cap_selected(struct rte_devargs *devargs) -{ - struct rte_kvargs *kvlist; - const char *key = "cap"; - int ret = 0; - - if (devargs == NULL) - return 0; - - kvlist = rte_kvargs_parse(devargs->args, NULL); - if (kvlist == NULL) - return 0; - - if (!rte_kvargs_count(kvlist, key)) - goto exit; - - /* dcf capability selected when there's a key-value pair: cap=dcf */ - if (rte_kvargs_process(kvlist, key, - ice_dcf_cap_check_handler, NULL) < 0) - goto exit; - - ret = 1; - -exit: - rte_kvargs_free(kvlist); - return ret; -} - static int eth_ice_dcf_pci_probe(__rte_unused struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev) @@ -1880,9 +1896,6 @@ eth_ice_dcf_pci_probe(__rte_unused struct rte_pci_driver *pci_drv, uint16_t dcf_vsi_id; int i, ret; - if (!ice_dcf_cap_selected(pci_dev->device.devargs)) - return 1; - ret = rte_eth_devargs_parse(pci_dev->device.devargs->args, ð_da); if (ret) return ret; @@ -1995,4 +2008,4 @@ static struct rte_pci_driver rte_ice_dcf_pmd = { RTE_PMD_REGISTER_PCI(net_ice_dcf, rte_ice_dcf_pmd); RTE_PMD_REGISTER_PCI_TABLE(net_ice_dcf, pci_id_ice_dcf_map); RTE_PMD_REGISTER_KMOD_DEP(net_ice_dcf, "* igb_uio | vfio-pci"); -RTE_PMD_REGISTER_PARAM_STRING(net_ice_dcf, "cap=dcf"); +RTE_PMD_REGISTER_PARAM_STRING(net_ice_dcf, "cap=dcf|mdcf"); diff --git a/drivers/net/ice/ice_dcf_parent.c b/drivers/net/ice/ice_dcf_parent.c index 2f96dedcce..2aa69c7368 100644 --- a/drivers/net/ice/ice_dcf_parent.c +++ b/drivers/net/ice/ice_dcf_parent.c @@ -125,6 +125,9 @@ ice_dcf_vsi_update_service_handler(void *param) pthread_detach(pthread_self()); + if (hw->multi_inst) + return NULL; + rte_delay_us(ICE_DCF_VSI_UPDATE_SERVICE_INTERVAL); rte_spinlock_lock(&vsi_update_lock); @@ -269,6 +272,10 @@ ice_dcf_handle_pf_event_msg(struct ice_dcf_hw *dcf_hw, start_vsi_reset_thread(dcf_hw, true, pf_msg->event_data.vf_vsi_map.vf_id); break; + case VIRTCHNL_EVENT_DCF_VSI_INFO: + if (dcf_hw->vsi_id != pf_msg->event_data.vf_vsi_map.vsi_id) + dcf_hw->dcf_replaced = true; + break; default: PMD_DRV_LOG(ERR, "Unknown event received %u", pf_msg->event); break; @@ -436,6 +443,7 @@ ice_dcf_init_parent_adapter(struct rte_eth_dev *eth_dev) parent_hw->aq_send_cmd_fn = ice_dcf_send_aq_cmd; parent_hw->aq_send_cmd_param = &adapter->real_hw; parent_hw->dcf_enabled = true; + hw->dcf_replaced = false; err = ice_dcf_init_parent_hw(parent_hw); if (err) { diff --git a/drivers/net/ice/ice_generic_flow.c b/drivers/net/ice/ice_generic_flow.c index 1433094ed4..2ebe9a1cce 100644 --- a/drivers/net/ice/ice_generic_flow.c +++ b/drivers/net/ice/ice_generic_flow.c @@ -17,6 +17,7 @@ #include "ice_ethdev.h" #include "ice_generic_flow.h" +#include "ice_dcf.h" /** * Non-pipeline mode, fdir and switch both used as distributor, @@ -2533,10 +2534,16 @@ ice_flow_flush(struct rte_eth_dev *dev, struct rte_flow_error *error) { struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private); + struct ice_adapter *ad = + ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private); + struct ice_dcf_hw *hw = ad->hw.aq_send_cmd_param; struct rte_flow *p_flow; void *temp; int ret = 0; + if (ad->hw.dcf_enabled && hw->dcf_replaced) + return ret; + RTE_TAILQ_FOREACH_SAFE(p_flow, &pf->flow_list, node, temp) { ret = ice_flow_destroy(dev, p_flow, error); if (ret) { @@ -2547,6 +2554,9 @@ ice_flow_flush(struct rte_eth_dev *dev, } } + if (ad->hw.dcf_enabled && hw->multi_inst) + return ice_dcf_flush_rules(ad->hw.aq_send_cmd_param); + return ret; } diff --git a/drivers/net/ice/ice_switch_filter.c b/drivers/net/ice/ice_switch_filter.c index e90e109eca..1e8625e71e 100644 --- a/drivers/net/ice/ice_switch_filter.c +++ b/drivers/net/ice/ice_switch_filter.c @@ -497,6 +497,7 @@ ice_switch_destroy(struct ice_adapter *ad, struct rte_flow *flow, struct rte_flow_error *error) { + struct ice_dcf_hw *dcf_hw = ad->hw.aq_send_cmd_param; struct ice_hw *hw = &ad->hw; int ret; struct ice_switch_filter_conf *filter_conf_ptr; @@ -524,7 +525,7 @@ ice_switch_destroy(struct ice_adapter *ad, } ret = ice_rem_adv_rule_by_id(hw, &filter_conf_ptr->sw_query_data); - if (ret) { + if (ret && !(hw->dcf_enabled && dcf_hw->multi_inst)) { if (ice_dcf_adminq_need_retry(ad)) ret = -EAGAIN; else @@ -537,7 +538,7 @@ ice_switch_destroy(struct ice_adapter *ad, } ice_switch_filter_rule_free(flow); - return ret; + return 0; } static bool -- 2.33.1