net/qede/base: convert device type to enum
authorRasesh Mody <rasesh.mody@cavium.com>
Tue, 19 Sep 2017 01:29:45 +0000 (18:29 -0700)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 6 Oct 2017 00:49:48 +0000 (02:49 +0200)
Add a new enum for device type and device type details to device info.

Signed-off-by: Rasesh Mody <rasesh.mody@cavium.com>
drivers/net/qede/base/ecore.h
drivers/net/qede/base/ecore_dev.c
drivers/net/qede/qede_if.h
drivers/net/qede/qede_main.c

index 0d68a9b..10fb16a 100644 (file)
@@ -632,15 +632,18 @@ enum qed_dbg_features {
        DBG_FEATURE_NUM
 };
 
+enum ecore_dev_type {
+       ECORE_DEV_TYPE_BB,
+       ECORE_DEV_TYPE_AH,
+};
+
 struct ecore_dev {
        u32                             dp_module;
        u8                              dp_level;
        char                            name[NAME_SIZE];
        void                            *dp_ctx;
 
-       u8                              type;
-#define ECORE_DEV_TYPE_BB      (0 << 0)
-#define ECORE_DEV_TYPE_AH      (1 << 0)
+       enum ecore_dev_type             type;
 /* Translate type/revision combo into the proper conditions */
 #define ECORE_IS_BB(dev)       ((dev)->type == ECORE_DEV_TYPE_BB)
 #define ECORE_IS_BB_A0(dev)    (ECORE_IS_BB(dev) && CHIP_REV_IS_A0(dev))
@@ -653,13 +656,12 @@ struct ecore_dev {
 #define ECORE_IS_AH(dev)       ((dev)->type == ECORE_DEV_TYPE_AH)
 #define ECORE_IS_K2(dev)       ECORE_IS_AH(dev)
 
+       u16 vendor_id;
+       u16 device_id;
 #define ECORE_DEV_ID_MASK      0xff00
 #define ECORE_DEV_ID_MASK_BB   0x1600
 #define ECORE_DEV_ID_MASK_AH   0x8000
 
-       u16 vendor_id;
-       u16 device_id;
-
        u16                             chip_num;
        #define CHIP_NUM_MASK                   0xffff
        #define CHIP_NUM_SHIFT                  16
index 6e40088..4a31d67 100644 (file)
@@ -3352,6 +3352,7 @@ ecore_get_hw_info(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
 static enum _ecore_status_t ecore_get_dev_info(struct ecore_dev *p_dev)
 {
        struct ecore_hwfn *p_hwfn = ECORE_LEADING_HWFN(p_dev);
+       u16 device_id_mask;
        u32 tmp;
 
        /* Read Vendor Id / Device Id */
@@ -3361,10 +3362,19 @@ static enum _ecore_status_t ecore_get_dev_info(struct ecore_dev *p_dev)
                                  &p_dev->device_id);
 
        /* Determine type */
-       if ((p_dev->device_id & ECORE_DEV_ID_MASK) == ECORE_DEV_ID_MASK_AH)
-               p_dev->type = ECORE_DEV_TYPE_AH;
-       else
+       device_id_mask = p_dev->device_id & ECORE_DEV_ID_MASK;
+       switch (device_id_mask) {
+       case ECORE_DEV_ID_MASK_BB:
                p_dev->type = ECORE_DEV_TYPE_BB;
+               break;
+       case ECORE_DEV_ID_MASK_AH:
+               p_dev->type = ECORE_DEV_TYPE_AH;
+               break;
+       default:
+               DP_NOTICE(p_hwfn, true, "Unknown device id 0x%x\n",
+                         p_dev->device_id);
+               return ECORE_ABORTED;
+       }
 
        p_dev->chip_num = (u16)ecore_rd(p_hwfn, p_hwfn->p_main_ptt,
                                         MISCS_REG_CHIP_NUM);
index 9864bb4..8e0c999 100644 (file)
@@ -48,6 +48,8 @@ struct qed_dev_info {
        bool vxlan_enable;
        bool gre_enable;
        bool geneve_enable;
+
+       enum ecore_dev_type dev_type;
 };
 
 struct qed_dev_eth_info {
index a6ff7af..2447ffb 100644 (file)
@@ -357,6 +357,7 @@ qed_fill_dev_info(struct ecore_dev *edev, struct qed_dev_info *dev_info)
        dev_info->num_hwfns = edev->num_hwfns;
        dev_info->is_mf_default = IS_MF_DEFAULT(&edev->hwfns[0]);
        dev_info->mtu = ECORE_LEADING_HWFN(edev)->hw_info.mtu;
+       dev_info->dev_type = edev->type;
 
        rte_memcpy(&dev_info->hw_mac, &edev->hwfns[0].hw_info.hw_mac_addr,
               ETHER_ADDR_LEN);