From: Rasesh Mody Date: Tue, 19 Sep 2017 01:29:45 +0000 (-0700) Subject: net/qede/base: convert device type to enum X-Git-Tag: spdx-start~1937 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=dc8eba81f0ef8e32cd5cd841cd789c1ed6aa2812;p=dpdk.git net/qede/base: convert device type to enum Add a new enum for device type and device type details to device info. Signed-off-by: Rasesh Mody --- diff --git a/drivers/net/qede/base/ecore.h b/drivers/net/qede/base/ecore.h index 0d68a9bc3a..10fb16a561 100644 --- a/drivers/net/qede/base/ecore.h +++ b/drivers/net/qede/base/ecore.h @@ -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 diff --git a/drivers/net/qede/base/ecore_dev.c b/drivers/net/qede/base/ecore_dev.c index 6e40088126..4a31d67ac0 100644 --- a/drivers/net/qede/base/ecore_dev.c +++ b/drivers/net/qede/base/ecore_dev.c @@ -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); diff --git a/drivers/net/qede/qede_if.h b/drivers/net/qede/qede_if.h index 9864bb4484..8e0c999fe3 100644 --- a/drivers/net/qede/qede_if.h +++ b/drivers/net/qede/qede_if.h @@ -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 { diff --git a/drivers/net/qede/qede_main.c b/drivers/net/qede/qede_main.c index a6ff7af28a..2447ffb136 100644 --- a/drivers/net/qede/qede_main.c +++ b/drivers/net/qede/qede_main.c @@ -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);