Merge tag 'mt76-for-kvalo-2021-01-29' of https://github.com/nbd168/wireless
[linux-2.6-microblaze.git] / drivers / net / ethernet / intel / ice / ice_type.h
index 2226a29..a98800a 100644 (file)
@@ -313,14 +313,62 @@ struct ice_orom_info {
        u16 build;                      /* Build version of OROM */
 };
 
-/* NVM Information */
+/* NVM version information */
 struct ice_nvm_info {
+       u32 eetrack;
+       u8 major;
+       u8 minor;
+};
+
+/* netlist version information */
+struct ice_netlist_info {
+       u32 major;                      /* major high/low */
+       u32 minor;                      /* minor high/low */
+       u32 type;                       /* type high/low */
+       u32 rev;                        /* revision high/low */
+       u32 hash;                       /* SHA-1 hash word */
+       u16 cust_ver;                   /* customer version */
+};
+
+/* Enumeration of possible flash banks for the NVM, OROM, and Netlist modules
+ * of the flash image.
+ */
+enum ice_flash_bank {
+       ICE_INVALID_FLASH_BANK,
+       ICE_1ST_FLASH_BANK,
+       ICE_2ND_FLASH_BANK,
+};
+
+/* Enumeration of which flash bank is desired to read from, either the active
+ * bank or the inactive bank. Used to abstract 1st and 2nd bank notion from
+ * code which just wants to read the active or inactive flash bank.
+ */
+enum ice_bank_select {
+       ICE_ACTIVE_FLASH_BANK,
+       ICE_INACTIVE_FLASH_BANK,
+};
+
+/* information for accessing NVM, OROM, and Netlist flash banks */
+struct ice_bank_info {
+       u32 nvm_ptr;                            /* Pointer to 1st NVM bank */
+       u32 nvm_size;                           /* Size of NVM bank */
+       u32 orom_ptr;                           /* Pointer to 1st OROM bank */
+       u32 orom_size;                          /* Size of OROM bank */
+       u32 netlist_ptr;                        /* Pointer to 1st Netlist bank */
+       u32 netlist_size;                       /* Size of Netlist bank */
+       enum ice_flash_bank nvm_bank;           /* Active NVM bank */
+       enum ice_flash_bank orom_bank;          /* Active OROM bank */
+       enum ice_flash_bank netlist_bank;       /* Active Netlist bank */
+};
+
+/* Flash Chip Information */
+struct ice_flash_info {
        struct ice_orom_info orom;      /* Option ROM version info */
-       u32 eetrack;                    /* NVM data version */
+       struct ice_nvm_info nvm;        /* NVM version information */
+       struct ice_netlist_info netlist;/* Netlist version info */
+       struct ice_bank_info banks;     /* Flash Bank information */
        u16 sr_words;                   /* Shadow RAM size in words */
        u32 flash_size;                 /* Size of available flash in bytes */
-       u8 major_ver;                   /* major version of NVM package */
-       u8 minor_ver;                   /* minor version of dev starter */
        u8 blank_nvm_mode;              /* is NVM empty (no FW present) */
 };
 
@@ -348,16 +396,6 @@ struct ice_link_default_override_tlv {
 
 #define ICE_NVM_VER_LEN        32
 
-/* netlist version information */
-struct ice_netlist_ver_info {
-       u32 major;                      /* major high/low */
-       u32 minor;                      /* minor high/low */
-       u32 type;                       /* type high/low */
-       u32 rev;                        /* revision high/low */
-       u32 hash;                       /* SHA-1 hash word */
-       u16 cust_ver;                   /* customer version */
-};
-
 /* Max number of port to queue branches w.r.t topology */
 #define ICE_MAX_TRAFFIC_CLASS 8
 #define ICE_TXSCHED_MAX_BRANCHES ICE_MAX_TRAFFIC_CLASS
@@ -605,10 +643,9 @@ struct ice_hw {
        u8 evb_veb;             /* true for VEB, false for VEPA */
        u8 reset_ongoing;       /* true if HW is in reset, false otherwise */
        struct ice_bus_info bus;
-       struct ice_nvm_info nvm;
+       struct ice_flash_info flash;
        struct ice_hw_dev_caps dev_caps;        /* device capabilities */
        struct ice_hw_func_caps func_caps;      /* function capabilities */
-       struct ice_netlist_ver_info netlist_ver; /* netlist version info */
 
        struct ice_switch_info *switch_info;    /* switch filter lists */
 
@@ -765,6 +802,7 @@ struct ice_hw_port_stats {
 };
 
 /* Checksum and Shadow RAM pointers */
+#define ICE_SR_NVM_CTRL_WORD           0x00
 #define ICE_SR_BOOT_CFG_PTR            0x132
 #define ICE_SR_NVM_WOL_CFG             0x19
 #define ICE_NVM_OROM_VER_OFF           0x02
@@ -784,10 +822,71 @@ struct ice_hw_port_stats {
 #define ICE_OROM_VER_MASK              (0xff << ICE_OROM_VER_SHIFT)
 #define ICE_SR_PFA_PTR                 0x40
 #define ICE_SR_1ST_NVM_BANK_PTR                0x42
+#define ICE_SR_NVM_BANK_SIZE           0x43
 #define ICE_SR_1ST_OROM_BANK_PTR       0x44
+#define ICE_SR_OROM_BANK_SIZE          0x45
 #define ICE_SR_NETLIST_BANK_PTR                0x46
+#define ICE_SR_NETLIST_BANK_SIZE       0x47
 #define ICE_SR_SECTOR_SIZE_IN_WORDS    0x800
 
+/* CSS Header words */
+#define ICE_NVM_CSS_SREV_L                     0x14
+#define ICE_NVM_CSS_SREV_H                     0x15
+
+/* Length of CSS header section in words */
+#define ICE_CSS_HEADER_LENGTH                  330
+
+/* Offset of Shadow RAM copy in the NVM bank area. */
+#define ICE_NVM_SR_COPY_WORD_OFFSET            roundup(ICE_CSS_HEADER_LENGTH, 32)
+
+/* Size in bytes of Option ROM trailer */
+#define ICE_NVM_OROM_TRAILER_LENGTH            (2 * ICE_CSS_HEADER_LENGTH)
+
+/* The Link Topology Netlist section is stored as a series of words. It is
+ * stored in the NVM as a TLV, with the first two words containing the type
+ * and length.
+ */
+#define ICE_NETLIST_LINK_TOPO_MOD_ID           0x011B
+#define ICE_NETLIST_TYPE_OFFSET                        0x0000
+#define ICE_NETLIST_LEN_OFFSET                 0x0001
+
+/* The Link Topology section follows the TLV header. When reading the netlist
+ * using ice_read_netlist_module, we need to account for the 2-word TLV
+ * header.
+ */
+#define ICE_NETLIST_LINK_TOPO_OFFSET(n)                ((n) + 2)
+
+#define ICE_LINK_TOPO_MODULE_LEN               ICE_NETLIST_LINK_TOPO_OFFSET(0x0000)
+#define ICE_LINK_TOPO_NODE_COUNT               ICE_NETLIST_LINK_TOPO_OFFSET(0x0001)
+
+#define ICE_LINK_TOPO_NODE_COUNT_M             ICE_M(0x3FF, 0)
+
+/* The Netlist ID Block is located after all of the Link Topology nodes. */
+#define ICE_NETLIST_ID_BLK_SIZE                        0x30
+#define ICE_NETLIST_ID_BLK_OFFSET(n)           ICE_NETLIST_LINK_TOPO_OFFSET(0x0004 + 2 * (n))
+
+/* netlist ID block field offsets (word offsets) */
+#define ICE_NETLIST_ID_BLK_MAJOR_VER_LOW       0x02
+#define ICE_NETLIST_ID_BLK_MAJOR_VER_HIGH      0x03
+#define ICE_NETLIST_ID_BLK_MINOR_VER_LOW       0x04
+#define ICE_NETLIST_ID_BLK_MINOR_VER_HIGH      0x05
+#define ICE_NETLIST_ID_BLK_TYPE_LOW            0x06
+#define ICE_NETLIST_ID_BLK_TYPE_HIGH           0x07
+#define ICE_NETLIST_ID_BLK_REV_LOW             0x08
+#define ICE_NETLIST_ID_BLK_REV_HIGH            0x09
+#define ICE_NETLIST_ID_BLK_SHA_HASH_WORD(n)    (0x0A + (n))
+#define ICE_NETLIST_ID_BLK_CUST_VER            0x2F
+
+/* Auxiliary field, mask, and shift definition for Shadow RAM and NVM Flash */
+#define ICE_SR_CTRL_WORD_1_S           0x06
+#define ICE_SR_CTRL_WORD_1_M           (0x03 << ICE_SR_CTRL_WORD_1_S)
+#define ICE_SR_CTRL_WORD_VALID         0x1
+#define ICE_SR_CTRL_WORD_OROM_BANK     BIT(3)
+#define ICE_SR_CTRL_WORD_NETLIST_BANK  BIT(4)
+#define ICE_SR_CTRL_WORD_NVM_BANK      BIT(5)
+
+#define ICE_SR_NVM_PTR_4KB_UNITS       BIT(15)
+
 /* Link override related */
 #define ICE_SR_PFA_LINK_OVERRIDE_WORDS         10
 #define ICE_SR_PFA_LINK_OVERRIDE_PHY_WORDS     4