X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fhns3%2Fhns3_dcb.c;h=73693786d15bc00098c78ae0daee40205d0f6943;hb=f5ed7d99cf45d550a69c1430b7c4a5623a9c774a;hp=90c0d041c9023ec2836f08b64765ef6ed98c1d96;hpb=b67bdfc8f6630934f3005ad531225c7203304661;p=dpdk.git diff --git a/drivers/net/hns3/hns3_dcb.c b/drivers/net/hns3/hns3_dcb.c index 90c0d041c9..73693786d1 100644 --- a/drivers/net/hns3/hns3_dcb.c +++ b/drivers/net/hns3/hns3_dcb.c @@ -25,7 +25,7 @@ * IR(Mbps) = ------------------------- * CLOCK(1000Mbps) * Tick * (2 ^ IR_s) * - * @return: 0: calculate sucessful, negative: fail + * @return: 0: calculate successful, negative: fail */ static int hns3_shaper_para_calc(struct hns3_hw *hw, uint32_t ir, uint8_t shaper_level, @@ -36,8 +36,8 @@ hns3_shaper_para_calc(struct hns3_hw *hw, uint32_t ir, uint8_t shaper_level, #define DIVISOR_IR_B_126 (126 * DIVISOR_CLK) const uint16_t tick_array[HNS3_SHAPER_LVL_CNT] = { - 6 * 256, /* Prioriy level */ - 6 * 32, /* Prioriy group level */ + 6 * 256, /* Priority level */ + 6 * 32, /* Priority group level */ 6 * 8, /* Port level */ 6 * 256 /* Qset level */ }; @@ -415,7 +415,7 @@ hns3_dcb_pg_shapping_cfg(struct hns3_hw *hw, enum hns3_shap_bucket bucket, return hns3_cmd_send(hw, &desc, 1); } -int +static int hns3_pg_shaper_rate_cfg(struct hns3_hw *hw, uint8_t pg_id, uint32_t rate) { struct hns3_shaper_parameter shaper_parameter; @@ -551,7 +551,7 @@ hns3_dcb_pri_shapping_cfg(struct hns3_hw *hw, enum hns3_shap_bucket bucket, return hns3_cmd_send(hw, &desc, 1); } -int +static int hns3_pri_shaper_rate_cfg(struct hns3_hw *hw, uint8_t tc_no, uint32_t rate) { struct hns3_shaper_parameter shaper_parameter; @@ -750,19 +750,9 @@ static int hns3_dcb_update_tc_queue_mapping(struct hns3_hw *hw, uint16_t nb_rx_q, uint16_t nb_tx_q) { - struct hns3_adapter *hns = HNS3_DEV_HW_TO_ADAPTER(hw); - struct hns3_pf *pf = &hns->pf; - int ret; - hw->num_tc = hw->dcb_info.num_tc; - ret = hns3_queue_to_tc_mapping(hw, nb_rx_q, nb_tx_q); - if (ret) - return ret; - - if (!hns->is_vf) - memcpy(pf->prio_tc, hw->dcb_info.prio_tc, HNS3_MAX_USER_PRIO); - return 0; + return hns3_queue_to_tc_mapping(hw, nb_rx_q, nb_tx_q); } int @@ -918,7 +908,7 @@ hns3_dcb_pri_dwrr_cfg(struct hns3_hw *hw) if (ret) return ret; - if (!hns3_dev_dcb_supported(hw)) + if (!hns3_dev_get_support(hw, DCB)) return 0; ret = hns3_dcb_ets_tc_dwrr_cfg(hw); @@ -1368,7 +1358,7 @@ hns3_dcb_pause_setup_hw(struct hns3_hw *hw) } /* Only DCB-supported dev supports qset back pressure and pfc cmd */ - if (!hns3_dev_dcb_supported(hw)) + if (!hns3_dev_get_support(hw, DCB)) return 0; ret = hns3_pfc_setup_hw(hw); @@ -1400,42 +1390,22 @@ hns3_dcb_undrop_tc_map(struct hns3_hw *hw, uint8_t pfc_en) return pfc_map; } -static void -hns3_dcb_cfg_validate(struct hns3_adapter *hns, uint8_t *tc, bool *changed) +static uint8_t +hns3_dcb_parse_num_tc(struct hns3_adapter *hns) { struct rte_eth_dcb_rx_conf *dcb_rx_conf; struct hns3_hw *hw = &hns->hw; - uint16_t nb_rx_q = hw->data->nb_rx_queues; - uint16_t nb_tx_q = hw->data->nb_tx_queues; - uint8_t max_tc = 0; - uint8_t pfc_en; + uint8_t max_tc_id = 0; int i; dcb_rx_conf = &hw->data->dev_conf.rx_adv_conf.dcb_rx_conf; for (i = 0; i < HNS3_MAX_USER_PRIO; i++) { - if (dcb_rx_conf->dcb_tc[i] != hw->dcb_info.prio_tc[i]) - *changed = true; - - if (dcb_rx_conf->dcb_tc[i] > max_tc) - max_tc = dcb_rx_conf->dcb_tc[i]; + if (dcb_rx_conf->dcb_tc[i] > max_tc_id) + max_tc_id = dcb_rx_conf->dcb_tc[i]; } - *tc = max_tc + 1; - if (*tc != hw->dcb_info.num_tc) - *changed = true; - /* - * We ensure that dcb information can be reconfigured - * after the hns3_priority_flow_ctrl_set function called. - */ - if (hw->requested_fc_mode != HNS3_FC_FULL) - *changed = true; - pfc_en = RTE_LEN2MASK((uint8_t)dcb_rx_conf->nb_tcs, uint8_t); - if (hw->dcb_info.pfc_en != pfc_en) - *changed = true; - - /* tx/rx queue number is reconfigured. */ - if (nb_rx_q != hw->used_rx_queues || nb_tx_q != hw->used_tx_queues) - *changed = true; + /* Number of TC is equal to max_tc_id plus 1. */ + return max_tc_id + 1; } static int @@ -1552,11 +1522,11 @@ hns3_dcb_hw_configure(struct hns3_adapter *hns) ret = hns3_dcb_schd_setup_hw(hw); if (ret) { - hns3_err(hw, "dcb schdule configure failed! ret = %d", ret); + hns3_err(hw, "dcb schedule configure failed! ret = %d", ret); return ret; } - if (hw->data->dev_conf.dcb_capability_en & ETH_DCB_PFC_SUPPORT) { + if (hw->data->dev_conf.dcb_capability_en & RTE_ETH_DCB_PFC_SUPPORT) { dcb_rx_conf = &hw->data->dev_conf.rx_adv_conf.dcb_rx_conf; if (dcb_rx_conf->nb_tcs == 0) hw->dcb_info.pfc_en = 1; /* tc0 only */ @@ -1567,36 +1537,30 @@ hns3_dcb_hw_configure(struct hns3_adapter *hns) hw->dcb_info.hw_pfc_map = hns3_dcb_undrop_tc_map(hw, hw->dcb_info.pfc_en); - ret = hns3_buffer_alloc(hw); - if (ret) - goto buffer_alloc_fail; - hw->current_fc_status = HNS3_FC_STATUS_PFC; hw->requested_fc_mode = HNS3_FC_FULL; - ret = hns3_dcb_pause_setup_hw(hw); - if (ret) { - hns3_err(hw, "setup pfc failed! ret = %d", ret); - goto pfc_setup_fail; - } } else { - /* - * Although dcb_capability_en is lack of ETH_DCB_PFC_SUPPORT - * flag, the DCB information is configured, such as tc numbers. - * Therefore, refreshing the allocation of packet buffer is - * necessary. - */ - ret = hns3_buffer_alloc(hw); - if (ret) - return ret; + hw->current_fc_status = HNS3_FC_STATUS_NONE; + hw->requested_fc_mode = HNS3_FC_NONE; + hw->dcb_info.pfc_en = 0; + hw->dcb_info.hw_pfc_map = 0; + } + + ret = hns3_buffer_alloc(hw); + if (ret) + goto cfg_fail; + + ret = hns3_dcb_pause_setup_hw(hw); + if (ret) { + hns3_err(hw, "setup pfc failed! ret = %d", ret); + goto cfg_fail; } return 0; -pfc_setup_fail: +cfg_fail: hw->requested_fc_mode = requested_fc_mode; hw->current_fc_status = fc_status; - -buffer_alloc_fail: hw->dcb_info.pfc_en = pfc_en; hw->dcb_info.hw_pfc_map = hw_pfc_map; @@ -1612,23 +1576,20 @@ int hns3_dcb_configure(struct hns3_adapter *hns) { struct hns3_hw *hw = &hns->hw; - bool map_changed = false; - uint8_t num_tc = 0; + uint8_t num_tc; int ret; - hns3_dcb_cfg_validate(hns, &num_tc, &map_changed); - if (map_changed) { - ret = hns3_dcb_info_update(hns, num_tc); - if (ret) { - hns3_err(hw, "dcb info update failed: %d", ret); - return ret; - } + num_tc = hns3_dcb_parse_num_tc(hns); + ret = hns3_dcb_info_update(hns, num_tc); + if (ret) { + hns3_err(hw, "dcb info update failed: %d", ret); + return ret; + } - ret = hns3_dcb_hw_configure(hns); - if (ret) { - hns3_err(hw, "dcb sw configure failed: %d", ret); - return ret; - } + ret = hns3_dcb_hw_configure(hns); + if (ret) { + hns3_err(hw, "dcb sw configure failed: %d", ret); + return ret; } return 0; @@ -1722,7 +1683,7 @@ hns3_update_queue_map_configure(struct hns3_adapter *hns) uint16_t nb_tx_q = hw->data->nb_tx_queues; int ret; - if ((uint32_t)mq_mode & ETH_MQ_RX_DCB_FLAG) + if ((uint32_t)mq_mode & RTE_ETH_MQ_RX_DCB_FLAG) return 0; ret = hns3_dcb_update_tc_queue_mapping(hw, nb_rx_q, nb_tx_q); @@ -1742,22 +1703,22 @@ static void hns3_get_fc_mode(struct hns3_hw *hw, enum rte_eth_fc_mode mode) { switch (mode) { - case RTE_FC_NONE: + case RTE_ETH_FC_NONE: hw->requested_fc_mode = HNS3_FC_NONE; break; - case RTE_FC_RX_PAUSE: + case RTE_ETH_FC_RX_PAUSE: hw->requested_fc_mode = HNS3_FC_RX_PAUSE; break; - case RTE_FC_TX_PAUSE: + case RTE_ETH_FC_TX_PAUSE: hw->requested_fc_mode = HNS3_FC_TX_PAUSE; break; - case RTE_FC_FULL: + case RTE_ETH_FC_FULL: hw->requested_fc_mode = HNS3_FC_FULL; break; default: hw->requested_fc_mode = HNS3_FC_NONE; hns3_warn(hw, "fc_mode(%u) exceeds member scope and is " - "configured to RTE_FC_NONE", mode); + "configured to RTE_ETH_FC_NONE", mode); break; } } @@ -1766,7 +1727,7 @@ hns3_get_fc_mode(struct hns3_hw *hw, enum rte_eth_fc_mode mode) * hns3_dcb_pfc_enable - Enable priority flow control * @dev: pointer to ethernet device * - * Configures the pfc settings for one porority. + * Configures the pfc settings for one priority. */ int hns3_dcb_pfc_enable(struct rte_eth_dev *dev, struct rte_eth_pfc_conf *pfc_conf) @@ -1781,15 +1742,21 @@ hns3_dcb_pfc_enable(struct rte_eth_dev *dev, struct rte_eth_pfc_conf *pfc_conf) uint16_t pause_time = pf->pause_time; int ret; - pf->pause_time = pfc_conf->fc.pause_time; - hns3_get_fc_mode(hw, pfc_conf->fc.mode); - hw->current_fc_status = HNS3_FC_STATUS_PFC; hw->dcb_info.pfc_en |= BIT(priority); hw->dcb_info.hw_pfc_map = hns3_dcb_undrop_tc_map(hw, hw->dcb_info.pfc_en); ret = hns3_buffer_alloc(hw); - if (ret) - goto pfc_setup_fail; + if (ret) { + hns3_err(hw, "update packet buffer failed, ret = %d", ret); + goto buffer_alloc_fail; + } + + pf->pause_time = pfc_conf->fc.pause_time; + hns3_get_fc_mode(hw, pfc_conf->fc.mode); + if (hw->requested_fc_mode == HNS3_FC_NONE) + hw->current_fc_status = HNS3_FC_STATUS_NONE; + else + hw->current_fc_status = HNS3_FC_STATUS_PFC; /* * The flow control mode of all UPs will be changed based on @@ -1807,6 +1774,7 @@ pfc_setup_fail: hw->requested_fc_mode = old_fc_mode; hw->current_fc_status = fc_status; pf->pause_time = pause_time; +buffer_alloc_fail: hw->dcb_info.pfc_en = pfc_en; hw->dcb_info.hw_pfc_map = hw_pfc_map;