From patchwork Sat Nov 21 16:17:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jingjing Wu X-Patchwork-Id: 9032 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 76A56532D; Sat, 21 Nov 2015 17:17:47 +0100 (CET) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id BABA711A2 for ; Sat, 21 Nov 2015 17:17:45 +0100 (CET) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP; 21 Nov 2015 08:17:44 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,328,1444719600"; d="scan'208";a="222485" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by fmsmga004.fm.intel.com with ESMTP; 21 Nov 2015 08:17:44 -0800 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id tALGHgGM020124; Sun, 22 Nov 2015 00:17:42 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id tALGHc1J009583; Sun, 22 Nov 2015 00:17:40 +0800 Received: (from wujingji@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id tALGHcaR009579; Sun, 22 Nov 2015 00:17:38 +0800 From: Jingjing Wu To: dev@dpdk.org Date: Sun, 22 Nov 2015 00:17:36 +0800 Message-Id: <1448122656-9549-1-git-send-email-jingjing.wu@intel.com> X-Mailer: git-send-email 1.7.4.1 Subject: [dpdk-dev] [PATCH] i40e: merge two duplicate functions together X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The functions i40e_vsi_dump_bw_config and i40e_vsi_get_bw_info do the similar actions on BW configuration of vsi. It is necessary to merge them together to avoid functions duplication. Signed-off-by: Jingjing Wu --- drivers/net/i40e/i40e_ethdev.c | 99 +++++++++++++----------------------------- 1 file changed, 30 insertions(+), 69 deletions(-) diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index 2c51a0b..57ee130 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -3789,14 +3789,21 @@ i40e_update_default_filter_setting(struct i40e_vsi *vsi) return i40e_vsi_add_mac(vsi, &filter); } +/* + * i40e_vsi_get_bw_config - Query VSI BW Information + * @vsi: the VSI to be queried + * + * Returns 0 on success, negative value on failure + */ static int -i40e_vsi_dump_bw_config(struct i40e_vsi *vsi) +i40e_vsi_get_bw_config(struct i40e_vsi *vsi) { struct i40e_aqc_query_vsi_bw_config_resp bw_config; struct i40e_aqc_query_vsi_ets_sla_config_resp ets_sla_config; struct i40e_hw *hw = &vsi->adapter->hw; i40e_status ret; int i; + uint32_t tc_bw_max; memset(&bw_config, 0, sizeof(bw_config)); ret = i40e_aq_query_vsi_bw_config(hw, vsi->seid, &bw_config, NULL); @@ -3815,7 +3822,7 @@ i40e_vsi_dump_bw_config(struct i40e_vsi *vsi) return ret; } - /* Not store the info yet, just print out */ + /* print BW info */ PMD_DRV_LOG(INFO, "VSI bw limit:%u", bw_config.port_bw_limit); PMD_DRV_LOG(INFO, "VSI max_bw:%u", bw_config.max_bw); for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) { @@ -3828,6 +3835,24 @@ i40e_vsi_dump_bw_config(struct i40e_vsi *vsi) (i * 4)); } + /* store BW info */ + vsi->bw_info.bw_limit = rte_le_to_cpu_16(bw_config.port_bw_limit); + vsi->bw_info.bw_max_quanta = bw_config.max_bw; + tc_bw_max = rte_le_to_cpu_16(ets_sla_config.tc_bw_max[0]) | + (rte_le_to_cpu_16(ets_sla_config.tc_bw_max[1]) << 16); + for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) { + vsi->bw_info.bw_ets_share_credits[i] = + ets_sla_config.share_credits[i]; + vsi->bw_info.bw_ets_limit_credits[i] = + rte_le_to_cpu_16(ets_sla_config.credits[i]); + /* 3 bits out of 4 for each TC */ + vsi->bw_info.bw_ets_max_quanta[i] = + (uint8_t)((tc_bw_max >> (i * 4)) & 0x7); + PMD_INIT_LOG(DEBUG, + "%s: vsi seid = %d, TC = %d, qset = 0x%x\n", + __func__, vsi->seid, i, bw_config.qs_handles[i]); + } + return 0; } @@ -4154,7 +4179,7 @@ i40e_vsi_setup(struct i40e_pf *pf, } /* Get VSI BW information */ - i40e_vsi_dump_bw_config(vsi); + i40e_vsi_get_bw_config(vsi); return vsi; fail_msix_alloc: i40e_res_pool_free(&pf->msix_pool,vsi->msix_intr); @@ -8081,70 +8106,6 @@ i40e_parse_dcb_configure(struct rte_eth_dev *dev, return 0; } -/* - * i40e_vsi_get_bw_info - Query VSI BW Information - * @vsi: the VSI being queried - * - * Returns 0 on success, negative value on failure - */ -static enum i40e_status_code -i40e_vsi_get_bw_info(struct i40e_vsi *vsi) -{ - struct i40e_aqc_query_vsi_ets_sla_config_resp bw_ets_config = {0}; - struct i40e_aqc_query_vsi_bw_config_resp bw_config = {0}; - struct i40e_hw *hw = I40E_VSI_TO_HW(vsi); - enum i40e_status_code ret; - int i; - uint32_t tc_bw_max; - - /* Get the VSI level BW configuration */ - ret = i40e_aq_query_vsi_bw_config(hw, vsi->seid, &bw_config, NULL); - if (ret) { - PMD_INIT_LOG(ERR, - "couldn't get PF vsi bw config, err %s aq_err %s\n", - i40e_stat_str(hw, ret), - i40e_aq_str(hw, hw->aq.asq_last_status)); - return ret; - } - - /* Get the VSI level BW configuration per TC */ - ret = i40e_aq_query_vsi_ets_sla_config(hw, vsi->seid, &bw_ets_config, - NULL); - if (ret) { - PMD_INIT_LOG(ERR, - "couldn't get PF vsi ets bw config, err %s aq_err %s\n", - i40e_stat_str(hw, ret), - i40e_aq_str(hw, hw->aq.asq_last_status)); - return ret; - } - - if (bw_config.tc_valid_bits != bw_ets_config.tc_valid_bits) { - PMD_INIT_LOG(WARNING, - "Enabled TCs mismatch from querying VSI BW info" - " 0x%08x 0x%08x\n", bw_config.tc_valid_bits, - bw_ets_config.tc_valid_bits); - /* Still continuing */ - } - - vsi->bw_info.bw_limit = rte_le_to_cpu_16(bw_config.port_bw_limit); - vsi->bw_info.bw_max_quanta = bw_config.max_bw; - tc_bw_max = rte_le_to_cpu_16(bw_ets_config.tc_bw_max[0]) | - (rte_le_to_cpu_16(bw_ets_config.tc_bw_max[1]) << 16); - for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) { - vsi->bw_info.bw_ets_share_credits[i] = - bw_ets_config.share_credits[i]; - vsi->bw_info.bw_ets_limit_credits[i] = - rte_le_to_cpu_16(bw_ets_config.credits[i]); - /* 3 bits out of 4 for each TC */ - vsi->bw_info.bw_ets_max_quanta[i] = - (uint8_t)((tc_bw_max >> (i * 4)) & 0x7); - PMD_INIT_LOG(DEBUG, - "%s: vsi seid = %d, TC = %d, qset = 0x%x\n", - __func__, vsi->seid, i, bw_config.qs_handles[i]); - } - - return ret; -} static enum i40e_status_code i40e_vsi_update_queue_mapping(struct i40e_vsi *vsi, @@ -8278,8 +8239,8 @@ i40e_vsi_config_tc(struct i40e_vsi *vsi, u8 tc_map) vsi->info.mapping_flags = ctxt.info.mapping_flags; vsi->info.valid_sections = 0; - /* Update current VSI BW information */ - ret = i40e_vsi_get_bw_info(vsi); + /* query and update current VSI BW information */ + ret = i40e_vsi_get_bw_config(vsi); if (ret) { PMD_INIT_LOG(ERR, "Failed updating vsi bw info, err %s aq_err %s",