+
+static int ice_dcf_commit_check(struct ice_dcf_hw *hw)
+{
+ struct ice_dcf_tm_node_list *tc_list = &hw->tm_conf.tc_list;
+ struct ice_dcf_tm_node_list *vsi_list = &hw->tm_conf.vsi_list;
+ struct ice_dcf_tm_node *tm_node;
+
+ if (!(hw->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_QOS)) {
+ PMD_DRV_LOG(ERR, "Configure VF bandwidth is not supported");
+ return ICE_ERR_NOT_SUPPORTED;
+ }
+
+ /* check if all TC nodes are set */
+ if (BIT(hw->tm_conf.nb_tc_node) & hw->ets_config->tc_valid_bits) {
+ PMD_DRV_LOG(ERR, "Not all enabled TC nodes are set");
+ return ICE_ERR_PARAM;
+ }
+
+ /* check if all VF vsi nodes are binded to all TCs */
+ TAILQ_FOREACH(tm_node, tc_list, node) {
+ if (tm_node->reference_count != hw->num_vfs) {
+ PMD_DRV_LOG(ERR, "Not all VFs are binded to TC%u",
+ tm_node->tc);
+ return ICE_ERR_PARAM;
+ }
+ }
+
+ /* check if VF vsi node id start with 0 */
+ tm_node = TAILQ_FIRST(vsi_list);
+ if (tm_node->id != 0) {
+ PMD_DRV_LOG(ERR, "VF vsi node id must start with 0");
+ return ICE_ERR_PARAM;
+ }
+
+ return ICE_SUCCESS;
+}
+
+int
+ice_dcf_replay_vf_bw(struct ice_dcf_hw *hw, uint16_t vf_id)
+{
+ struct ice_aqc_port_ets_elem old_ets_config;
+ struct ice_dcf_adapter *adapter;
+ struct ice_hw *parent_hw;
+ int ret, size;
+
+ adapter = hw->eth_dev->data->dev_private;
+ parent_hw = &adapter->parent.hw;
+
+ /* store the old ets config */
+ old_ets_config = *hw->ets_config;
+
+ ice_memset(hw->ets_config, 0, sizeof(*hw->ets_config), ICE_NONDMA_MEM);
+ ret = ice_aq_query_port_ets(parent_hw->port_info,
+ hw->ets_config, sizeof(*hw->ets_config),
+ NULL);
+ if (ret) {
+ PMD_DRV_LOG(ERR, "DCF Query Port ETS failed");
+ return ret;
+ }
+
+ if (memcmp(&old_ets_config, hw->ets_config, sizeof(old_ets_config))) {
+ PMD_DRV_LOG(DEBUG, "ETS config changes, do not replay BW");
+ return ICE_SUCCESS;
+ }
+
+ size = sizeof(struct virtchnl_dcf_bw_cfg_list) +
+ sizeof(struct virtchnl_dcf_bw_cfg) *
+ (hw->tm_conf.nb_tc_node - 1);
+
+ ret = ice_dcf_set_vf_bw(hw, hw->qos_bw_cfg[vf_id], size);
+ if (ret) {
+ PMD_DRV_LOG(DEBUG, "VF %u BW replay failed", vf_id);
+ return ICE_ERR_CFG;
+ }
+
+ return ICE_SUCCESS;
+}
+
+int
+ice_dcf_clear_bw(struct ice_dcf_hw *hw)
+{
+ uint16_t vf_id;
+ uint32_t tc;
+ int ret, size;
+
+ size = sizeof(struct virtchnl_dcf_bw_cfg_list) +
+ sizeof(struct virtchnl_dcf_bw_cfg) *
+ (hw->tm_conf.nb_tc_node - 1);
+
+ for (vf_id = 0; vf_id < hw->num_vfs; vf_id++) {
+ for (tc = 0; tc < hw->tm_conf.nb_tc_node; tc++) {
+ hw->qos_bw_cfg[vf_id]->cfg[tc].shaper.peak = 0;
+ hw->qos_bw_cfg[vf_id]->cfg[tc].shaper.committed = 0;
+ }
+ ret = ice_dcf_set_vf_bw(hw, hw->qos_bw_cfg[vf_id], size);
+ if (ret) {
+ PMD_DRV_LOG(DEBUG, "VF %u BW clear failed", vf_id);
+ return ICE_ERR_CFG;
+ }
+ }
+
+ return ICE_SUCCESS;
+}
+