+static void
+hns3_get_autoneg_rxtx_pause_copper(struct hns3_hw *hw, bool *rx_pause,
+ bool *tx_pause)
+{
+ struct hns3_mac *mac = &hw->mac;
+ uint32_t advertising = mac->advertising;
+ uint32_t lp_advertising = mac->lp_advertising;
+ *rx_pause = false;
+ *tx_pause = false;
+
+ if (advertising & lp_advertising & HNS3_PHY_LINK_MODE_PAUSE_BIT) {
+ *rx_pause = true;
+ *tx_pause = true;
+ } else if (advertising & lp_advertising &
+ HNS3_PHY_LINK_MODE_ASYM_PAUSE_BIT) {
+ if (advertising & HNS3_PHY_LINK_MODE_PAUSE_BIT)
+ *rx_pause = true;
+ else if (lp_advertising & HNS3_PHY_LINK_MODE_PAUSE_BIT)
+ *tx_pause = true;
+ }
+}
+
+static enum hns3_fc_mode
+hns3_get_autoneg_fc_mode(struct hns3_hw *hw)
+{
+ enum hns3_fc_mode current_mode;
+ bool rx_pause = false;
+ bool tx_pause = false;
+
+ switch (hw->mac.media_type) {
+ case HNS3_MEDIA_TYPE_COPPER:
+ hns3_get_autoneg_rxtx_pause_copper(hw, &rx_pause, &tx_pause);
+ break;
+
+ /*
+ * Flow control auto-negotiation is not supported for fiber and
+ * backpalne media type.
+ */
+ case HNS3_MEDIA_TYPE_FIBER:
+ case HNS3_MEDIA_TYPE_BACKPLANE:
+ hns3_err(hw, "autoneg FC mode can't be obtained, but flow control auto-negotiation is enabled.");
+ current_mode = hw->requested_fc_mode;
+ goto out;
+ default:
+ hns3_err(hw, "autoneg FC mode can't be obtained for unknown media type(%u).",
+ hw->mac.media_type);
+ current_mode = HNS3_FC_NONE;
+ goto out;
+ }
+
+ if (rx_pause && tx_pause)
+ current_mode = HNS3_FC_FULL;
+ else if (rx_pause)
+ current_mode = HNS3_FC_RX_PAUSE;
+ else if (tx_pause)
+ current_mode = HNS3_FC_TX_PAUSE;
+ else
+ current_mode = HNS3_FC_NONE;
+
+out:
+ return current_mode;
+}
+
+static enum hns3_fc_mode
+hns3_get_current_fc_mode(struct rte_eth_dev *dev)