net/hns3: replace max private macro
[dpdk.git] / drivers / net / hns3 / hns3_cmd.c
index c85168b..0299072 100644 (file)
@@ -426,8 +426,29 @@ hns3_cmd_send(struct hns3_hw *hw, struct hns3_cmd_desc *desc, int num)
        return retval;
 }
 
+static void hns3_parse_capability(struct hns3_hw *hw,
+                                 struct hns3_query_version_cmd *cmd)
+{
+       uint32_t caps = rte_le_to_cpu_32(cmd->caps[0]);
+
+       if (hns3_get_bit(caps, HNS3_CAPS_UDP_GSO_B))
+               hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_UDP_GSO_B, 1);
+       if (hns3_get_bit(caps, HNS3_CAPS_ADQ_B))
+               hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_ADQ_B, 1);
+       if (hns3_get_bit(caps, HNS3_CAPS_PTP_B))
+               hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_PTP_B, 1);
+       if (hns3_get_bit(caps, HNS3_CAPS_TX_PUSH_B))
+               hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_TX_PUSH_B, 1);
+       if (hns3_get_bit(caps, HNS3_CAPS_PHY_IMP_B))
+               hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_COPPER_B, 1);
+       if (hns3_get_bit(caps, HNS3_CAPS_TQP_TXRX_INDEP_B))
+               hns3_set_bit(hw->capability, HNS3_CAPS_TQP_TXRX_INDEP_B, 1);
+       if (hns3_get_bit(caps, HNS3_CAPS_STASH_B))
+               hns3_set_bit(hw->capability, HNS3_DEV_SUPPORT_STASH_B, 1);
+}
+
 static enum hns3_cmd_status
-hns3_cmd_query_firmware_version(struct hns3_hw *hw, uint32_t *version)
+hns3_cmd_query_firmware_version_and_capability(struct hns3_hw *hw)
 {
        struct hns3_query_version_cmd *resp;
        struct hns3_cmd_desc desc;
@@ -438,10 +459,13 @@ hns3_cmd_query_firmware_version(struct hns3_hw *hw, uint32_t *version)
 
        /* Initialize the cmd function */
        ret = hns3_cmd_send(hw, &desc, 1);
-       if (ret == 0)
-               *version = rte_le_to_cpu_32(resp->firmware);
+       if (ret)
+               return ret;
 
-       return ret;
+       hw->fw_version = rte_le_to_cpu_32(resp->firmware);
+       hns3_parse_capability(hw, resp);
+
+       return 0;
 }
 
 int
@@ -490,6 +514,7 @@ err_crq:
 int
 hns3_cmd_init(struct hns3_hw *hw)
 {
+       uint32_t version;
        int ret;
 
        rte_spinlock_lock(&hw->cmq.csq.lock);
@@ -518,18 +543,27 @@ hns3_cmd_init(struct hns3_hw *hw)
        }
        rte_atomic16_clear(&hw->reset.disable_cmd);
 
-       ret = hns3_cmd_query_firmware_version(hw, &hw->fw_version);
+       ret = hns3_cmd_query_firmware_version_and_capability(hw);
        if (ret) {
                PMD_INIT_LOG(ERR, "firmware version query failed %d", ret);
                goto err_cmd_init;
        }
 
-       PMD_INIT_LOG(INFO, "The firmware version is %08x", hw->fw_version);
+       version = hw->fw_version;
+       PMD_INIT_LOG(INFO, "The firmware version is %lu.%lu.%lu.%lu",
+                    hns3_get_field(version, HNS3_FW_VERSION_BYTE3_M,
+                                   HNS3_FW_VERSION_BYTE3_S),
+                    hns3_get_field(version, HNS3_FW_VERSION_BYTE2_M,
+                                   HNS3_FW_VERSION_BYTE2_S),
+                    hns3_get_field(version, HNS3_FW_VERSION_BYTE1_M,
+                                   HNS3_FW_VERSION_BYTE1_S),
+                    hns3_get_field(version, HNS3_FW_VERSION_BYTE0_M,
+                                   HNS3_FW_VERSION_BYTE0_S));
 
        return 0;
 
 err_cmd_init:
-       hns3_cmd_uninit(hw);
+       rte_atomic16_set(&hw->reset.disable_cmd, 1);
        return ret;
 }