net/qede/base: support doorbell overflow recovery
[dpdk.git] / drivers / net / qede / base / ecore.h
index c9f3b00..d921d9e 100644 (file)
 #include "ecore_proto_if.h"
 #include "mcp_public.h"
 
-#define MAX_HWFNS_PER_DEVICE   (4)
+#define ECORE_MAJOR_VERSION            8
+#define ECORE_MINOR_VERSION            18
+#define ECORE_REVISION_VERSION         7
+#define ECORE_ENGINEERING_VERSION      1
+
+#define ECORE_VERSION                                                  \
+       ((ECORE_MAJOR_VERSION << 24) | (ECORE_MINOR_VERSION << 16) |    \
+        (ECORE_REVISION_VERSION << 8) | ECORE_ENGINEERING_VERSION)
+
+#define STORM_FW_VERSION                                               \
+       ((FW_MAJOR_VERSION << 24) | (FW_MINOR_VERSION << 16) |  \
+        (FW_REVISION_VERSION << 8) | FW_ENGINEERING_VERSION)
+
+#define MAX_HWFNS_PER_DEVICE   2
 #define NAME_SIZE 128 /* @DPDK */
-#define VER_SIZE 16
 #define ECORE_WFQ_UNIT 100
 #include "../qede_logs.h" /* @DPDK */
 
@@ -54,6 +66,7 @@ enum ecore_nvm_cmd {
        ECORE_NVM_READ_NVRAM = DRV_MSG_CODE_NVM_READ_NVRAM,
        ECORE_NVM_WRITE_NVRAM = DRV_MSG_CODE_NVM_WRITE_NVRAM,
        ECORE_NVM_DEL_FILE = DRV_MSG_CODE_NVM_DEL_FILE,
+       ECORE_EXT_PHY_FW_UPGRADE = DRV_MSG_CODE_EXT_PHY_FW_UPGRADE,
        ECORE_NVM_SET_SECURE_MODE = DRV_MSG_CODE_SET_SECURE_MODE,
        ECORE_PHY_RAW_READ = DRV_MSG_CODE_PHY_RAW_READ,
        ECORE_PHY_RAW_WRITE = DRV_MSG_CODE_PHY_RAW_WRITE,
@@ -85,6 +98,15 @@ do {                                                                 \
 
 #define GET_FIELD(value, name)                                         \
        (((value) >> (name##_SHIFT)) & name##_MASK)
+
+#define GET_MFW_FIELD(name, field)                             \
+       (((name) & (field ## _MASK)) >> (field ## _OFFSET))
+
+#define SET_MFW_FIELD(name, field, value)                              \
+do {                                                                   \
+       (name) &= ~((field ## _MASK));          \
+       (name) |= (((value) << (field ## _OFFSET)) & (field ## _MASK)); \
+} while (0)
 #endif
 
 static OSAL_INLINE u32 DB_ADDR(u32 cid, u32 DEMS)
@@ -158,8 +180,8 @@ enum DP_MODULE {
        ECORE_MSG_CXT           = 0x800000,
        ECORE_MSG_LL2           = 0x1000000,
        ECORE_MSG_ILT           = 0x2000000,
-       ECORE_MSG_RDMA          = 0x4000000,
-       ECORE_MSG_DEBUG         = 0x8000000,
+       ECORE_MSG_RDMA          = 0x4000000,
+       ECORE_MSG_DEBUG         = 0x8000000,
        /* to be added...up to 0x8000000 */
 };
 #endif
@@ -179,6 +201,7 @@ struct ecore_cxt_mngr;
 struct ecore_dma_mem;
 struct ecore_sb_sp_info;
 struct ecore_ll2_info;
+struct ecore_l2_info;
 struct ecore_igu_info;
 struct ecore_mcp_info;
 struct ecore_dcbx_info;
@@ -205,33 +228,29 @@ enum ecore_tunn_clss {
        MAX_ECORE_TUNN_CLSS,
 };
 
-struct ecore_tunn_start_params {
-       unsigned long tunn_mode;
-       u16     vxlan_udp_port;
-       u16     geneve_udp_port;
-       u8      update_vxlan_udp_port;
-       u8      update_geneve_udp_port;
-       u8      tunn_clss_vxlan;
-       u8      tunn_clss_l2geneve;
-       u8      tunn_clss_ipgeneve;
-       u8      tunn_clss_l2gre;
-       u8      tunn_clss_ipgre;
+struct ecore_tunn_update_type {
+       bool b_update_mode;
+       bool b_mode_enabled;
+       enum ecore_tunn_clss tun_cls;
+};
+
+struct ecore_tunn_update_udp_port {
+       bool b_update_port;
+       u16 port;
 };
 
-struct ecore_tunn_update_params {
-       unsigned long tunn_mode_update_mask;
-       unsigned long tunn_mode;
-       u16     vxlan_udp_port;
-       u16     geneve_udp_port;
-       u8      update_rx_pf_clss;
-       u8      update_tx_pf_clss;
-       u8      update_vxlan_udp_port;
-       u8      update_geneve_udp_port;
-       u8      tunn_clss_vxlan;
-       u8      tunn_clss_l2geneve;
-       u8      tunn_clss_ipgeneve;
-       u8      tunn_clss_l2gre;
-       u8      tunn_clss_ipgre;
+struct ecore_tunnel_info {
+       struct ecore_tunn_update_type vxlan;
+       struct ecore_tunn_update_type l2_geneve;
+       struct ecore_tunn_update_type ip_geneve;
+       struct ecore_tunn_update_type l2_gre;
+       struct ecore_tunn_update_type ip_gre;
+
+       struct ecore_tunn_update_udp_port vxlan_port;
+       struct ecore_tunn_update_udp_port geneve_port;
+
+       bool b_update_rx_cls;
+       bool b_update_tx_cls;
 };
 
 /* The PCI personality is not quite synonymous to protocol ID:
@@ -243,7 +262,8 @@ enum ecore_pci_personality {
        ECORE_PCI_FCOE,
        ECORE_PCI_ISCSI,
        ECORE_PCI_ETH_ROCE,
-       ECORE_PCI_IWARP,
+       ECORE_PCI_ETH_IWARP,
+       ECORE_PCI_ETH_RDMA,
        ECORE_PCI_DEFAULT /* default in shmem */
 };
 
@@ -260,7 +280,6 @@ struct ecore_qm_iids {
  * is received from MFW.
  */
 enum ecore_resources {
-       ECORE_SB,
        ECORE_L2_QUEUE,
        ECORE_VPORT,
        ECORE_RSS_ENG,
@@ -273,7 +292,14 @@ enum ecore_resources {
        ECORE_LL2_QUEUE,
        ECORE_CMDQS_CQS,
        ECORE_RDMA_STATS_QUEUE,
-       ECORE_MAX_RESC,                 /* must be last */
+       ECORE_BDQ,
+
+       /* This is needed only internally for matching against the IGU.
+        * In case of legacy MFW, would be set to `0'.
+        */
+       ECORE_SB,
+
+       ECORE_MAX_RESC,
 };
 
 /* Features that require resources, given as input to the resource management
@@ -288,6 +314,7 @@ enum ecore_feature {
        ECORE_RDMA_CNQ,
        ECORE_ISCSI_CQ,
        ECORE_FCOE_CQ,
+       ECORE_VF_L2_QUE,
        ECORE_MAX_FEATURES,
 };
 
@@ -302,6 +329,7 @@ enum ecore_port_mode {
        ECORE_PORT_MODE_DE_2X25G,
        ECORE_PORT_MODE_DE_1X25G,
        ECORE_PORT_MODE_DE_4X25G,
+       ECORE_PORT_MODE_DE_2X10G,
 };
 
 enum ecore_dev_cap {
@@ -323,9 +351,28 @@ enum ecore_hw_err_type {
 };
 #endif
 
+enum ecore_db_rec_exec {
+       DB_REC_DRY_RUN,
+       DB_REC_REAL_DEAL,
+       DB_REC_ONCE,
+};
+
 struct ecore_hw_info {
        /* PCI personality */
        enum ecore_pci_personality personality;
+#define ECORE_IS_RDMA_PERSONALITY(dev)                     \
+       ((dev)->hw_info.personality == ECORE_PCI_ETH_ROCE ||  \
+        (dev)->hw_info.personality == ECORE_PCI_ETH_IWARP || \
+        (dev)->hw_info.personality == ECORE_PCI_ETH_RDMA)
+#define ECORE_IS_ROCE_PERSONALITY(dev)                    \
+       ((dev)->hw_info.personality == ECORE_PCI_ETH_ROCE || \
+        (dev)->hw_info.personality == ECORE_PCI_ETH_RDMA)
+#define ECORE_IS_IWARP_PERSONALITY(dev)                            \
+       ((dev)->hw_info.personality == ECORE_PCI_ETH_IWARP || \
+        (dev)->hw_info.personality == ECORE_PCI_ETH_RDMA)
+#define ECORE_IS_L2_PERSONALITY(dev)                 \
+       ((dev)->hw_info.personality == ECORE_PCI_ETH || \
+        ECORE_IS_RDMA_PERSONALITY(dev))
 
        /* Resource Allocation scheme results */
        u32 resc_start[ECORE_MAX_RESC];
@@ -347,9 +394,6 @@ struct ecore_hw_info {
 
        u8 num_active_tc;
 
-       /* Traffic class used for tcp out of order traffic */
-       u8 ooo_tc;
-
        /* The traffic class used by PF for it's offloaded protocol */
        u8 offload_tc;
 
@@ -372,16 +416,11 @@ struct ecore_hw_info {
        u32 port_mode;
        u32     hw_mode;
        unsigned long device_capabilities;
-};
 
-struct ecore_hw_cid_data {
-       u32     cid;
-       bool    b_cid_allocated;
-       u8      vfid; /* 1-based; 0 signals this is for a PF */
+       /* Default DCBX mode */
+       u8 dcbx_mode;
 
-       /* Additional identifiers */
-       u16     opaque_fid;
-       u8      vport_id;
+       u16 mtu;
 };
 
 /* maximun size of read/write commands (HW limit) */
@@ -424,15 +463,18 @@ struct ecore_qm_info {
        struct init_qm_port_params  *qm_port_params;
        u16                     start_pq;
        u8                      start_vport;
-       u8                      pure_lb_pq;
-       u8                      offload_pq;
-       u8                      pure_ack_pq;
-       u8                      ooo_pq;
-       u8                      vf_queues_offset;
+       u16                     pure_lb_pq;
+       u16                     offload_pq;
+       u16                     pure_ack_pq;
+       u16                     ooo_pq;
+       u16                     first_vf_pq;
+       u16                     first_mcos_pq;
+       u16                     first_rl_pq;
        u16                     num_pqs;
        u16                     num_vf_pqs;
        u8                      num_vports;
        u8                      max_phys_tcs_per_port;
+       u8                      ooo_tc;
        bool                    pf_rl_en;
        bool                    pf_wfq_en;
        bool                    vport_rl_en;
@@ -443,6 +485,12 @@ struct ecore_qm_info {
        u8                      num_pf_rls;
 };
 
+struct ecore_db_recovery_info {
+       osal_list_t list;
+       osal_spinlock_t lock;
+       u32 db_recovery_counter;
+};
+
 struct storm_stats {
        u32 address;
        u32 len;
@@ -472,7 +520,7 @@ struct ecore_hwfn {
        u32                             dp_module;
        u8                              dp_level;
        char                            name[NAME_SIZE];
-       void                            *dp_ctx;
+       void                            *dp_ctx;
 
        bool                            first_on_engine;
        bool                            hw_init_done;
@@ -526,10 +574,6 @@ struct ecore_hwfn {
        bool                            b_rdma_enabled_in_prs;
        u32                             rdma_prs_search_reg;
 
-       /* Array of sb_info of all status blocks */
-       struct ecore_sb_info            *sbs_info[MAX_SB_PER_PF_MIMD];
-       u16                             num_sbs;
-
        struct ecore_cxt_mngr           *p_cxt_mngr;
 
        /* Flag indicating whether interrupts are enabled or not*/
@@ -544,9 +588,6 @@ struct ecore_hwfn {
        struct ecore_mcp_info           *mcp_info;
        struct ecore_dcbx_info          *p_dcbx_info;
 
-       struct ecore_hw_cid_data        *p_tx_cids;
-       struct ecore_hw_cid_data        *p_rx_cids;
-
        struct ecore_dmae_info          dmae_info;
 
        /* QM init */
@@ -572,6 +613,15 @@ struct ecore_hwfn {
        /* If one of the following is set then EDPM shouldn't be used */
        u8                              dcbx_no_edpm;
        u8                              db_bar_no_edpm;
+
+       /* L2-related */
+       struct ecore_l2_info            *p_l2_info;
+
+       /* Mechanism for recovering from doorbell drop */
+       struct ecore_db_recovery_info   db_recovery_info;
+
+       /* @DPDK */
+       struct ecore_ptt                *p_arfs_ptt;
 };
 
 #ifndef __EXTRACT__LINUX__
@@ -599,15 +649,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;
+       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))
@@ -622,6 +675,9 @@ struct ecore_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                             chip_num;
        #define CHIP_NUM_MASK                   0xffff
@@ -679,7 +735,7 @@ struct ecore_dev {
 
        int                             pcie_width;
        int                             pcie_speed;
-       u8                              ver_str[NAME_SIZE]; /* @DPDK */
+
        /* Add MF related configuration */
        u8                              mcp_rev;
        u8                              boot_mode;
@@ -711,11 +767,9 @@ struct ecore_dev {
        /* SRIOV */
        struct ecore_hw_sriov_info      *p_iov_info;
 #define IS_ECORE_SRIOV(p_dev)          (!!(p_dev)->p_iov_info)
-       bool                            b_hw_channel;
-
-       unsigned long                   tunn_mode;
-
+       struct ecore_tunnel_info        tunnel;
        bool                            b_is_vf;
+       bool                            b_dont_override_vf_msix;
 
        u32                             drv_type;
 
@@ -736,7 +790,7 @@ struct ecore_dev {
        bool                            attn_clr_en;
 
        /* Indicates whether allowing the MFW to collect a crash dump */
-       bool                            mdump_en;
+       bool                            allow_mdump;
 
        /* Indicates if the reg_fifo is checked after any register access */
        bool                            chk_reg_fifo;
@@ -766,15 +820,6 @@ struct ecore_dev {
 #define NUM_OF_ENG_PFS(dev)    (ECORE_IS_BB(dev) ? MAX_NUM_PFS_BB \
                                                  : MAX_NUM_PFS_K2)
 
-#ifndef REAL_ASIC_ONLY
-#define ENABLE_EAGLE_ENG1_WORKAROUND(p_hwfn) ( \
-       (ECORE_IS_BB_A0(p_hwfn->p_dev)) && \
-       (ECORE_PATH_ID(p_hwfn) == 1) && \
-       ((p_hwfn->hw_info.port_mode == ECORE_PORT_MODE_DE_2X40G) || \
-        (p_hwfn->hw_info.port_mode == ECORE_PORT_MODE_DE_2X50G) || \
-        (p_hwfn->hw_info.port_mode == ECORE_PORT_MODE_DE_2X25G)))
-#endif
-
 /**
  * @brief ecore_concrete_to_sw_fid - get the sw function id from
  *        the concrete value.
@@ -783,8 +828,8 @@ struct ecore_dev {
  *
  * @return OSAL_INLINE u8
  */
-static OSAL_INLINE u8 ecore_concrete_to_sw_fid(struct ecore_dev *p_dev,
-                                         u32 concrete_fid)
+static OSAL_INLINE u8
+ecore_concrete_to_sw_fid(__rte_unused struct ecore_dev *p_dev, u32 concrete_fid)
 {
        u8 vfid     = GET_FIELD(concrete_fid, PXP_CONCRETE_FID_VFID);
        u8 pfid     = GET_FIELD(concrete_fid, PXP_CONCRETE_FID_PFID);
@@ -800,10 +845,11 @@ static OSAL_INLINE u8 ecore_concrete_to_sw_fid(struct ecore_dev *p_dev,
 }
 
 #define PURE_LB_TC 8
-#define OOO_LB_TC 9
+#define PKT_LB_TC 9
 
 int ecore_configure_vport_wfq(struct ecore_dev *p_dev, u16 vp_id, u32 rate);
 void ecore_configure_vp_wfq_on_link_change(struct ecore_dev *p_dev,
+                                          struct ecore_ptt *p_ptt,
                                           u32 min_pf_rate);
 
 int ecore_configure_pf_max_bandwidth(struct ecore_dev *p_dev, u8 max_bw);
@@ -811,6 +857,37 @@ int ecore_configure_pf_min_bandwidth(struct ecore_dev *p_dev, u8 min_bw);
 void ecore_clean_wfq_db(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt);
 int ecore_device_num_engines(struct ecore_dev *p_dev);
 int ecore_device_num_ports(struct ecore_dev *p_dev);
+void ecore_set_fw_mac_addr(__le16 *fw_msb, __le16 *fw_mid, __le16 *fw_lsb,
+                          u8 *mac);
+
+/* Flags for indication of required queues */
+#define PQ_FLAGS_RLS   (1 << 0)
+#define PQ_FLAGS_MCOS  (1 << 1)
+#define PQ_FLAGS_LB    (1 << 2)
+#define PQ_FLAGS_OOO   (1 << 3)
+#define PQ_FLAGS_ACK   (1 << 4)
+#define PQ_FLAGS_OFLD  (1 << 5)
+#define PQ_FLAGS_VFS   (1 << 6)
+
+/* physical queue index for cm context intialization */
+u16 ecore_get_cm_pq_idx(struct ecore_hwfn *p_hwfn, u32 pq_flags);
+u16 ecore_get_cm_pq_idx_mcos(struct ecore_hwfn *p_hwfn, u8 tc);
+u16 ecore_get_cm_pq_idx_vf(struct ecore_hwfn *p_hwfn, u16 vf);
+u16 ecore_get_cm_pq_idx_rl(struct ecore_hwfn *p_hwfn, u8 qpid);
+
+const char *ecore_hw_get_resc_name(enum ecore_resources res_id);
+
+/* doorbell recovery mechanism */
+void ecore_db_recovery_dp(struct ecore_hwfn *p_hwfn);
+void ecore_db_recovery_execute(struct ecore_hwfn *p_hwfn,
+                              enum ecore_db_rec_exec);
+
+/* amount of resources used in qm init */
+u8 ecore_init_qm_get_num_tcs(struct ecore_hwfn *p_hwfn);
+u16 ecore_init_qm_get_num_vfs(struct ecore_hwfn *p_hwfn);
+u16 ecore_init_qm_get_num_pf_rls(struct ecore_hwfn *p_hwfn);
+u16 ecore_init_qm_get_num_vports(struct ecore_hwfn *p_hwfn);
+u16 ecore_init_qm_get_num_pqs(struct ecore_hwfn *p_hwfn);
 
 #define ECORE_LEADING_HWFN(dev)        (&dev->hwfns[0])